| author | bors <bors@rust-lang.org> 2024-07-29 02:43:41 UTC |
| committer | bors <bors@rust-lang.org> 2024-07-29 02:43:41 UTC |
| log | 2e630267b2bce50af3258ce4817e377fa09c145b |
| tree | 29006db815bf547dfd0129910b23b8c54675bd98 |
| parent | 2cbbe8b8bb2be672b14cf741a2f0ec24a49f3f0b |
| parent | 84ac80f1921afc243d71fd0caaa4f2838c294102 |
rustfmt `use` declarations
This PR implements https://github.com/rust-lang/compiler-team/issues/750, which changes how `use` declarations are formatted by adding these options to `rustfmt.toml`:
```
group_imports = "StdExternalCrate"
imports_granularity = "Module"
```
r? `@ghost`1867 files changed, 8167 insertions(+), 8995 deletions(-)
compiler/rustc_abi/src/layout.rs+4-5| ... | ... | @@ -1,9 +1,7 @@ |
| 1 | 1 | use std::borrow::{Borrow, Cow}; |
| 2 | use std::cmp; | |
| 3 | 2 | use std::fmt::{self, Write}; |
| 4 | use std::iter; | |
| 5 | use std::ops::Bound; | |
| 6 | use std::ops::Deref; | |
| 3 | use std::ops::{Bound, Deref}; | |
| 4 | use std::{cmp, iter}; | |
| 7 | 5 | |
| 8 | 6 | use rustc_index::Idx; |
| 9 | 7 | use tracing::debug; |
| ... | ... | @@ -982,7 +980,8 @@ fn univariant< |
| 982 | 980 | if repr.can_randomize_type_layout() && cfg!(feature = "randomize") { |
| 983 | 981 | #[cfg(feature = "randomize")] |
| 984 | 982 | { |
| 985 | use rand::{seq::SliceRandom, SeedableRng}; | |
| 983 | use rand::seq::SliceRandom; | |
| 984 | use rand::SeedableRng; | |
| 986 | 985 | // `ReprOptions.field_shuffle_seed` is a deterministic seed we can use to randomize field |
| 987 | 986 | // ordering. |
| 988 | 987 | let mut rng = |
compiler/rustc_abi/src/lib.rs+3-4| ... | ... | @@ -6,21 +6,20 @@ |
| 6 | 6 | // tidy-alphabetical-end |
| 7 | 7 | |
| 8 | 8 | use std::fmt; |
| 9 | #[cfg(feature = "nightly")] | |
| 10 | use std::iter::Step; | |
| 9 | 11 | use std::num::{NonZeroUsize, ParseIntError}; |
| 10 | 12 | use std::ops::{Add, AddAssign, Mul, RangeInclusive, Sub}; |
| 11 | 13 | use std::str::FromStr; |
| 12 | 14 | |
| 13 | 15 | use bitflags::bitflags; |
| 14 | use rustc_index::{Idx, IndexSlice, IndexVec}; | |
| 15 | ||
| 16 | 16 | #[cfg(feature = "nightly")] |
| 17 | 17 | use rustc_data_structures::stable_hasher::StableOrd; |
| 18 | use rustc_index::{Idx, IndexSlice, IndexVec}; | |
| 18 | 19 | #[cfg(feature = "nightly")] |
| 19 | 20 | use rustc_macros::HashStable_Generic; |
| 20 | 21 | #[cfg(feature = "nightly")] |
| 21 | 22 | use rustc_macros::{Decodable_Generic, Encodable_Generic}; |
| 22 | #[cfg(feature = "nightly")] | |
| 23 | use std::iter::Step; | |
| 24 | 23 | |
| 25 | 24 | mod layout; |
| 26 | 25 | #[cfg(test)] |
compiler/rustc_arena/src/lib.rs+3-4| ... | ... | @@ -27,15 +27,14 @@ |
| 27 | 27 | #![feature(strict_provenance)] |
| 28 | 28 | // tidy-alphabetical-end |
| 29 | 29 | |
| 30 | use smallvec::SmallVec; | |
| 31 | ||
| 32 | 30 | use std::alloc::Layout; |
| 33 | 31 | use std::cell::{Cell, RefCell}; |
| 34 | 32 | use std::marker::PhantomData; |
| 35 | 33 | use std::mem::{self, MaybeUninit}; |
| 36 | 34 | use std::ptr::{self, NonNull}; |
| 37 | use std::slice; | |
| 38 | use std::{cmp, intrinsics}; | |
| 35 | use std::{cmp, intrinsics, slice}; | |
| 36 | ||
| 37 | use smallvec::SmallVec; | |
| 39 | 38 | |
| 40 | 39 | /// This calls the passed function while ensuring it won't be inlined into the caller. |
| 41 | 40 | #[inline(never)] |
compiler/rustc_arena/src/tests.rs+3-1| ... | ... | @@ -1,8 +1,10 @@ |
| 1 | 1 | extern crate test; |
| 2 | use super::TypedArena; | |
| 3 | 2 | use std::cell::Cell; |
| 3 | ||
| 4 | 4 | use test::Bencher; |
| 5 | 5 | |
| 6 | use super::TypedArena; | |
| 7 | ||
| 6 | 8 | #[allow(dead_code)] |
| 7 | 9 | #[derive(Debug, Eq, PartialEq)] |
| 8 | 10 | struct Point { |
compiler/rustc_ast/src/ast.rs+13-13| ... | ... | @@ -18,15 +18,9 @@ |
| 18 | 18 | //! - [`Attribute`]: Metadata associated with item. |
| 19 | 19 | //! - [`UnOp`], [`BinOp`], and [`BinOpKind`]: Unary and binary operators. |
| 20 | 20 | |
| 21 | pub use crate::format::*; | |
| 22 | pub use crate::util::parser::ExprPrecedence; | |
| 23 | pub use rustc_span::AttrId; | |
| 24 | pub use GenericArgs::*; | |
| 25 | pub use UnsafeSource::*; | |
| 21 | use std::borrow::Cow; | |
| 22 | use std::{cmp, fmt, mem}; | |
| 26 | 23 | |
| 27 | use crate::ptr::P; | |
| 28 | use crate::token::{self, CommentKind, Delimiter}; | |
| 29 | use crate::tokenstream::{DelimSpan, LazyAttrTokenStream, TokenStream}; | |
| 30 | 24 | pub use rustc_ast_ir::{Movability, Mutability}; |
| 31 | 25 | use rustc_data_structures::packed::Pu128; |
| 32 | 26 | use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; |
| ... | ... | @@ -35,12 +29,17 @@ use rustc_data_structures::sync::Lrc; |
| 35 | 29 | use rustc_macros::{Decodable, Encodable, HashStable_Generic}; |
| 36 | 30 | use rustc_span::source_map::{respan, Spanned}; |
| 37 | 31 | use rustc_span::symbol::{kw, sym, Ident, Symbol}; |
| 32 | pub use rustc_span::AttrId; | |
| 38 | 33 | use rustc_span::{ErrorGuaranteed, Span, DUMMY_SP}; |
| 39 | use std::borrow::Cow; | |
| 40 | use std::cmp; | |
| 41 | use std::fmt; | |
| 42 | use std::mem; | |
| 43 | 34 | use thin_vec::{thin_vec, ThinVec}; |
| 35 | pub use GenericArgs::*; | |
| 36 | pub use UnsafeSource::*; | |
| 37 | ||
| 38 | pub use crate::format::*; | |
| 39 | use crate::ptr::P; | |
| 40 | use crate::token::{self, CommentKind, Delimiter}; | |
| 41 | use crate::tokenstream::{DelimSpan, LazyAttrTokenStream, TokenStream}; | |
| 42 | pub use crate::util::parser::ExprPrecedence; | |
| 44 | 43 | |
| 45 | 44 | /// A "Label" is an identifier of some point in sources, |
| 46 | 45 | /// e.g. in the following code: |
| ... | ... | @@ -3491,8 +3490,9 @@ pub type ForeignItem = Item<ForeignItemKind>; |
| 3491 | 3490 | // Some nodes are used a lot. Make sure they don't unintentionally get bigger. |
| 3492 | 3491 | #[cfg(target_pointer_width = "64")] |
| 3493 | 3492 | mod size_asserts { |
| 3494 | use super::*; | |
| 3495 | 3493 | use rustc_data_structures::static_assert_size; |
| 3494 | ||
| 3495 | use super::*; | |
| 3496 | 3496 | // tidy-alphabetical-start |
| 3497 | 3497 | static_assert_size!(AssocItem, 88); |
| 3498 | 3498 | static_assert_size!(AssocItemKind, 16); |
compiler/rustc_ast/src/ast_traits.rs+8-7| ... | ... | @@ -2,16 +2,17 @@ |
| 2 | 2 | //! typically those used in AST fragments during macro expansion. |
| 3 | 3 | //! The traits are not implemented exhaustively, only when actually necessary. |
| 4 | 4 | |
| 5 | use std::fmt; | |
| 6 | use std::marker::PhantomData; | |
| 7 | ||
| 5 | 8 | use crate::ptr::P; |
| 6 | 9 | use crate::token::Nonterminal; |
| 7 | 10 | use crate::tokenstream::LazyAttrTokenStream; |
| 8 | use crate::{Arm, Crate, ExprField, FieldDef, GenericParam, Param, PatField, Variant}; | |
| 9 | use crate::{AssocItem, Expr, ForeignItem, Item, NodeId}; | |
| 10 | use crate::{AttrItem, AttrKind, Block, Pat, Path, Ty, Visibility}; | |
| 11 | use crate::{AttrVec, Attribute, Stmt, StmtKind}; | |
| 12 | ||
| 13 | use std::fmt; | |
| 14 | use std::marker::PhantomData; | |
| 11 | use crate::{ | |
| 12 | Arm, AssocItem, AttrItem, AttrKind, AttrVec, Attribute, Block, Crate, Expr, ExprField, | |
| 13 | FieldDef, ForeignItem, GenericParam, Item, NodeId, Param, Pat, PatField, Path, Stmt, StmtKind, | |
| 14 | Ty, Variant, Visibility, | |
| 15 | }; | |
| 15 | 16 | |
| 16 | 17 | /// A utility trait to reduce boilerplate. |
| 17 | 18 | /// Standard `Deref(Mut)` cannot be reused due to coherence. |
compiler/rustc_ast/src/attr/mod.rs+13-13| ... | ... | @@ -1,24 +1,24 @@ |
| 1 | 1 | //! Functions dealing with attributes and meta items. |
| 2 | 2 | |
| 3 | use std::iter; | |
| 4 | use std::sync::atomic::{AtomicU32, Ordering}; | |
| 5 | ||
| 6 | use rustc_index::bit_set::GrowableBitSet; | |
| 7 | use rustc_span::symbol::{sym, Ident, Symbol}; | |
| 8 | use rustc_span::Span; | |
| 9 | use smallvec::{smallvec, SmallVec}; | |
| 10 | use thin_vec::{thin_vec, ThinVec}; | |
| 11 | ||
| 3 | 12 | use crate::ast::{ |
| 4 | AttrArgs, AttrArgsEq, AttrId, AttrItem, AttrKind, AttrStyle, AttrVec, Attribute, Safety, | |
| 13 | AttrArgs, AttrArgsEq, AttrId, AttrItem, AttrKind, AttrStyle, AttrVec, Attribute, DelimArgs, | |
| 14 | Expr, ExprKind, LitKind, MetaItem, MetaItemKind, MetaItemLit, NestedMetaItem, NormalAttr, Path, | |
| 15 | PathSegment, Safety, DUMMY_NODE_ID, | |
| 5 | 16 | }; |
| 6 | use crate::ast::{DelimArgs, Expr, ExprKind, LitKind, MetaItemLit}; | |
| 7 | use crate::ast::{MetaItem, MetaItemKind, NestedMetaItem, NormalAttr}; | |
| 8 | use crate::ast::{Path, PathSegment, DUMMY_NODE_ID}; | |
| 9 | 17 | use crate::ptr::P; |
| 10 | 18 | use crate::token::{self, CommentKind, Delimiter, Token}; |
| 11 | use crate::tokenstream::{DelimSpan, Spacing, TokenTree}; | |
| 12 | use crate::tokenstream::{LazyAttrTokenStream, TokenStream}; | |
| 19 | use crate::tokenstream::{DelimSpan, LazyAttrTokenStream, Spacing, TokenStream, TokenTree}; | |
| 13 | 20 | use crate::util::comments; |
| 14 | 21 | use crate::util::literal::escape_string_symbol; |
| 15 | use rustc_index::bit_set::GrowableBitSet; | |
| 16 | use rustc_span::symbol::{sym, Ident, Symbol}; | |
| 17 | use rustc_span::Span; | |
| 18 | use smallvec::{smallvec, SmallVec}; | |
| 19 | use std::iter; | |
| 20 | use std::sync::atomic::{AtomicU32, Ordering}; | |
| 21 | use thin_vec::{thin_vec, ThinVec}; | |
| 22 | 22 | |
| 23 | 23 | pub struct MarkedAttrs(GrowableBitSet<AttrId>); |
| 24 | 24 |
compiler/rustc_ast/src/entry.rs+2-1| ... | ... | @@ -1,7 +1,8 @@ |
| 1 | use crate::{attr, Attribute}; | |
| 2 | 1 | use rustc_span::symbol::sym; |
| 3 | 2 | use rustc_span::Symbol; |
| 4 | 3 | |
| 4 | use crate::{attr, Attribute}; | |
| 5 | ||
| 5 | 6 | #[derive(Debug)] |
| 6 | 7 | pub enum EntryPointType { |
| 7 | 8 | /// This function is not an entrypoint. |
compiler/rustc_ast/src/expand/mod.rs+2-1| ... | ... | @@ -1,7 +1,8 @@ |
| 1 | 1 | //! Definitions shared by macros / syntax extensions and e.g. `rustc_middle`. |
| 2 | 2 | |
| 3 | 3 | use rustc_macros::{Decodable, Encodable, HashStable_Generic}; |
| 4 | use rustc_span::{def_id::DefId, symbol::Ident}; | |
| 4 | use rustc_span::def_id::DefId; | |
| 5 | use rustc_span::symbol::Ident; | |
| 5 | 6 | |
| 6 | 7 | use crate::MetaItem; |
| 7 | 8 |
compiler/rustc_ast/src/format.rs+3-2| ... | ... | @@ -1,10 +1,11 @@ |
| 1 | use crate::ptr::P; | |
| 2 | use crate::Expr; | |
| 3 | 1 | use rustc_data_structures::fx::FxHashMap; |
| 4 | 2 | use rustc_macros::{Decodable, Encodable}; |
| 5 | 3 | use rustc_span::symbol::{Ident, Symbol}; |
| 6 | 4 | use rustc_span::Span; |
| 7 | 5 | |
| 6 | use crate::ptr::P; | |
| 7 | use crate::Expr; | |
| 8 | ||
| 8 | 9 | // Definitions: |
| 9 | 10 | // |
| 10 | 11 | // format_args!("hello {abc:.xyz$}!!", abc="world"); |
compiler/rustc_ast/src/lib.rs+2-2| ... | ... | @@ -43,11 +43,11 @@ pub mod token; |
| 43 | 43 | pub mod tokenstream; |
| 44 | 44 | pub mod visit; |
| 45 | 45 | |
| 46 | use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; | |
| 47 | ||
| 46 | 48 | pub use self::ast::*; |
| 47 | 49 | pub use self::ast_traits::{AstDeref, AstNodeWrapper, HasAttrs, HasNodeId, HasTokens}; |
| 48 | 50 | |
| 49 | use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; | |
| 50 | ||
| 51 | 51 | /// Requirements for a `StableHashingContext` to be used in this crate. |
| 52 | 52 | /// This is a hack to allow using the `HashStable_Generic` derive macro |
| 53 | 53 | /// instead of implementing everything in `rustc_middle`. |
compiler/rustc_ast/src/mut_visit.rs+8-7| ... | ... | @@ -7,11 +7,8 @@ |
| 7 | 7 | //! a `MutVisitor` renaming item names in a module will miss all of those |
| 8 | 8 | //! that are created by the expansion of a macro. |
| 9 | 9 | |
| 10 | use crate::ast::*; | |
| 11 | use crate::ptr::P; | |
| 12 | use crate::token::{self, Token}; | |
| 13 | use crate::tokenstream::*; | |
| 14 | use crate::visit::{AssocCtxt, BoundKind}; | |
| 10 | use std::ops::DerefMut; | |
| 11 | use std::panic; | |
| 15 | 12 | |
| 16 | 13 | use rustc_data_structures::flat_map_in_place::FlatMapInPlace; |
| 17 | 14 | use rustc_data_structures::stack::ensure_sufficient_stack; |
| ... | ... | @@ -20,10 +17,14 @@ use rustc_span::source_map::Spanned; |
| 20 | 17 | use rustc_span::symbol::Ident; |
| 21 | 18 | use rustc_span::Span; |
| 22 | 19 | use smallvec::{smallvec, Array, SmallVec}; |
| 23 | use std::ops::DerefMut; | |
| 24 | use std::panic; | |
| 25 | 20 | use thin_vec::ThinVec; |
| 26 | 21 | |
| 22 | use crate::ast::*; | |
| 23 | use crate::ptr::P; | |
| 24 | use crate::token::{self, Token}; | |
| 25 | use crate::tokenstream::*; | |
| 26 | use crate::visit::{AssocCtxt, BoundKind}; | |
| 27 | ||
| 27 | 28 | pub trait ExpectOne<A: Array> { |
| 28 | 29 | fn expect_one(self, err: &'static str) -> A::Item; |
| 29 | 30 | } |
compiler/rustc_ast/src/node_id.rs+2-1| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | use rustc_span::LocalExpnId; | |
| 2 | 1 | use std::fmt; |
| 3 | 2 | |
| 3 | use rustc_span::LocalExpnId; | |
| 4 | ||
| 4 | 5 | rustc_index::newtype_index! { |
| 5 | 6 | /// Identifies an AST node. |
| 6 | 7 | /// |
compiler/rustc_ast/src/ptr.rs+1-2| ... | ... | @@ -21,9 +21,8 @@ use std::fmt::{self, Debug, Display}; |
| 21 | 21 | use std::ops::{Deref, DerefMut}; |
| 22 | 22 | use std::{slice, vec}; |
| 23 | 23 | |
| 24 | use rustc_serialize::{Decodable, Decoder, Encodable, Encoder}; | |
| 25 | ||
| 26 | 24 | use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; |
| 25 | use rustc_serialize::{Decodable, Decoder, Encodable, Encoder}; | |
| 27 | 26 | /// An owned smart pointer. |
| 28 | 27 | /// |
| 29 | 28 | /// See the [module level documentation][crate::ptr] for details. |
compiler/rustc_ast/src/token.rs+14-12| ... | ... | @@ -1,3 +1,15 @@ |
| 1 | use std::borrow::Cow; | |
| 2 | use std::fmt; | |
| 3 | ||
| 4 | use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; | |
| 5 | use rustc_data_structures::sync::Lrc; | |
| 6 | use rustc_macros::{Decodable, Encodable, HashStable_Generic}; | |
| 7 | use rustc_span::edition::Edition; | |
| 8 | use rustc_span::symbol::{kw, sym}; | |
| 9 | #[allow(clippy::useless_attribute)] // FIXME: following use of `hidden_glob_reexports` incorrectly triggers `useless_attribute` lint. | |
| 10 | #[allow(hidden_glob_reexports)] | |
| 11 | use rustc_span::symbol::{Ident, Symbol}; | |
| 12 | use rustc_span::{ErrorGuaranteed, Span, DUMMY_SP}; | |
| 1 | 13 | pub use BinOpToken::*; |
| 2 | 14 | pub use LitKind::*; |
| 3 | 15 | pub use Nonterminal::*; |
| ... | ... | @@ -9,17 +21,6 @@ use crate::ast; |
| 9 | 21 | use crate::ptr::P; |
| 10 | 22 | use crate::util::case::Case; |
| 11 | 23 | |
| 12 | use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; | |
| 13 | use rustc_data_structures::sync::Lrc; | |
| 14 | use rustc_macros::{Decodable, Encodable, HashStable_Generic}; | |
| 15 | use rustc_span::symbol::{kw, sym}; | |
| 16 | #[allow(clippy::useless_attribute)] // FIXME: following use of `hidden_glob_reexports` incorrectly triggers `useless_attribute` lint. | |
| 17 | #[allow(hidden_glob_reexports)] | |
| 18 | use rustc_span::symbol::{Ident, Symbol}; | |
| 19 | use rustc_span::{edition::Edition, ErrorGuaranteed, Span, DUMMY_SP}; | |
| 20 | use std::borrow::Cow; | |
| 21 | use std::fmt; | |
| 22 | ||
| 23 | 24 | #[derive(Clone, Copy, PartialEq, Encodable, Decodable, Debug, HashStable_Generic)] |
| 24 | 25 | pub enum CommentKind { |
| 25 | 26 | Line, |
| ... | ... | @@ -1062,8 +1063,9 @@ where |
| 1062 | 1063 | // Some types are used a lot. Make sure they don't unintentionally get bigger. |
| 1063 | 1064 | #[cfg(target_pointer_width = "64")] |
| 1064 | 1065 | mod size_asserts { |
| 1065 | use super::*; | |
| 1066 | 1066 | use rustc_data_structures::static_assert_size; |
| 1067 | ||
| 1068 | use super::*; | |
| 1067 | 1069 | // tidy-alphabetical-start |
| 1068 | 1070 | static_assert_size!(Lit, 12); |
| 1069 | 1071 | static_assert_size!(LitKind, 2); |
compiler/rustc_ast/src/tokenstream.rs+8-7| ... | ... | @@ -13,10 +13,8 @@ |
| 13 | 13 | //! and a borrowed `TokenStream` is sufficient to build an owned `TokenStream` without taking |
| 14 | 14 | //! ownership of the original. |
| 15 | 15 | |
| 16 | use crate::ast::{AttrStyle, StmtKind}; | |
| 17 | use crate::ast_traits::{HasAttrs, HasTokens}; | |
| 18 | use crate::token::{self, Delimiter, Nonterminal, Token, TokenKind}; | |
| 19 | use crate::{AttrVec, Attribute}; | |
| 16 | use std::borrow::Cow; | |
| 17 | use std::{cmp, fmt, iter}; | |
| 20 | 18 | |
| 21 | 19 | use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; |
| 22 | 20 | use rustc_data_structures::sync::{self, Lrc}; |
| ... | ... | @@ -24,8 +22,10 @@ use rustc_macros::{Decodable, Encodable, HashStable_Generic}; |
| 24 | 22 | use rustc_serialize::{Decodable, Encodable}; |
| 25 | 23 | use rustc_span::{sym, Span, SpanDecoder, SpanEncoder, Symbol, DUMMY_SP}; |
| 26 | 24 | |
| 27 | use std::borrow::Cow; | |
| 28 | use std::{cmp, fmt, iter}; | |
| 25 | use crate::ast::{AttrStyle, StmtKind}; | |
| 26 | use crate::ast_traits::{HasAttrs, HasTokens}; | |
| 27 | use crate::token::{self, Delimiter, Nonterminal, Token, TokenKind}; | |
| 28 | use crate::{AttrVec, Attribute}; | |
| 29 | 29 | |
| 30 | 30 | /// Part of a `TokenStream`. |
| 31 | 31 | #[derive(Debug, Clone, PartialEq, Encodable, Decodable, HashStable_Generic)] |
| ... | ... | @@ -767,8 +767,9 @@ impl DelimSpacing { |
| 767 | 767 | // Some types are used a lot. Make sure they don't unintentionally get bigger. |
| 768 | 768 | #[cfg(target_pointer_width = "64")] |
| 769 | 769 | mod size_asserts { |
| 770 | use super::*; | |
| 771 | 770 | use rustc_data_structures::static_assert_size; |
| 771 | ||
| 772 | use super::*; | |
| 772 | 773 | // tidy-alphabetical-start |
| 773 | 774 | static_assert_size!(AttrTokenStream, 8); |
| 774 | 775 | static_assert_size!(AttrTokenTree, 32); |
compiler/rustc_ast/src/util/comments.rs+2-1| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | use crate::token::CommentKind; | |
| 2 | 1 | use rustc_span::{BytePos, Symbol}; |
| 3 | 2 | |
| 3 | use crate::token::CommentKind; | |
| 4 | ||
| 4 | 5 | #[cfg(test)] |
| 5 | 6 | mod tests; |
| 6 | 7 |
compiler/rustc_ast/src/util/comments/tests.rs+2-1| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | use super::*; | |
| 2 | 1 | use rustc_span::create_default_session_globals_then; |
| 3 | 2 | |
| 3 | use super::*; | |
| 4 | ||
| 4 | 5 | #[test] |
| 5 | 6 | fn test_block_doc_comment_1() { |
| 6 | 7 | create_default_session_globals_then(|| { |
compiler/rustc_ast/src/util/literal.rs+5-3| ... | ... | @@ -1,15 +1,17 @@ |
| 1 | 1 | //! Code related to parsing literals. |
| 2 | 2 | |
| 3 | use crate::ast::{self, LitKind, MetaItemLit, StrStyle}; | |
| 4 | use crate::token::{self, Token}; | |
| 3 | use std::{ascii, fmt, str}; | |
| 4 | ||
| 5 | 5 | use rustc_lexer::unescape::{ |
| 6 | 6 | byte_from_char, unescape_byte, unescape_char, unescape_mixed, unescape_unicode, MixedUnit, Mode, |
| 7 | 7 | }; |
| 8 | 8 | use rustc_span::symbol::{kw, sym, Symbol}; |
| 9 | 9 | use rustc_span::Span; |
| 10 | use std::{ascii, fmt, str}; | |
| 11 | 10 | use tracing::debug; |
| 12 | 11 | |
| 12 | use crate::ast::{self, LitKind, MetaItemLit, StrStyle}; | |
| 13 | use crate::token::{self, Token}; | |
| 14 | ||
| 13 | 15 | // Escapes a string, represented as a symbol. Reuses the original symbol, |
| 14 | 16 | // avoiding interning, if no changes are required. |
| 15 | 17 | pub fn escape_string_symbol(symbol: Symbol) -> Symbol { |
compiler/rustc_ast/src/util/parser.rs+2-1| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | use rustc_span::symbol::kw; | |
| 2 | ||
| 1 | 3 | use crate::ast::{self, BinOpKind}; |
| 2 | 4 | use crate::token::{self, BinOpToken, Token}; |
| 3 | use rustc_span::symbol::kw; | |
| 4 | 5 | |
| 5 | 6 | /// Associative operator with precedence. |
| 6 | 7 | /// |
compiler/rustc_ast/src/visit.rs+4-5| ... | ... | @@ -13,14 +13,13 @@ |
| 13 | 13 | //! instance, a walker looking for item names in a module will miss all of |
| 14 | 14 | //! those that are created by the expansion of a macro. |
| 15 | 15 | |
| 16 | use crate::ast::*; | |
| 17 | use crate::ptr::P; | |
| 18 | ||
| 16 | pub use rustc_ast_ir::visit::VisitorResult; | |
| 17 | pub use rustc_ast_ir::{try_visit, visit_opt, walk_list, walk_visitable_list}; | |
| 19 | 18 | use rustc_span::symbol::Ident; |
| 20 | 19 | use rustc_span::Span; |
| 21 | 20 | |
| 22 | pub use rustc_ast_ir::visit::VisitorResult; | |
| 23 | pub use rustc_ast_ir::{try_visit, visit_opt, walk_list, walk_visitable_list}; | |
| 21 | use crate::ast::*; | |
| 22 | use crate::ptr::P; | |
| 24 | 23 | |
| 25 | 24 | #[derive(Copy, Clone, Debug, PartialEq)] |
| 26 | 25 | pub enum AssocCtxt { |
compiler/rustc_ast_lowering/src/asm.rs+12-12| ... | ... | @@ -1,13 +1,5 @@ |
| 1 | use crate::{ImplTraitContext, ImplTraitPosition, ParamMode, ResolverAstLoweringExt}; | |
| 2 | ||
| 3 | use super::errors::{ | |
| 4 | AbiSpecifiedMultipleTimes, AttSyntaxOnlyX86, ClobberAbiNotSupported, | |
| 5 | InlineAsmUnsupportedTarget, InvalidAbiClobberAbi, InvalidAsmTemplateModifierConst, | |
| 6 | InvalidAsmTemplateModifierLabel, InvalidAsmTemplateModifierRegClass, | |
| 7 | InvalidAsmTemplateModifierRegClassSub, InvalidAsmTemplateModifierSym, InvalidRegister, | |
| 8 | InvalidRegisterClass, RegisterClassOnlyClobber, RegisterConflict, | |
| 9 | }; | |
| 10 | use super::LoweringContext; | |
| 1 | use std::collections::hash_map::Entry; | |
| 2 | use std::fmt::Write; | |
| 11 | 3 | |
| 12 | 4 | use rustc_ast::ptr::P; |
| 13 | 5 | use rustc_ast::*; |
| ... | ... | @@ -18,8 +10,16 @@ use rustc_session::parse::feature_err; |
| 18 | 10 | use rustc_span::symbol::kw; |
| 19 | 11 | use rustc_span::{sym, Span}; |
| 20 | 12 | use rustc_target::asm; |
| 21 | use std::collections::hash_map::Entry; | |
| 22 | use std::fmt::Write; | |
| 13 | ||
| 14 | use super::errors::{ | |
| 15 | AbiSpecifiedMultipleTimes, AttSyntaxOnlyX86, ClobberAbiNotSupported, | |
| 16 | InlineAsmUnsupportedTarget, InvalidAbiClobberAbi, InvalidAsmTemplateModifierConst, | |
| 17 | InvalidAsmTemplateModifierLabel, InvalidAsmTemplateModifierRegClass, | |
| 18 | InvalidAsmTemplateModifierRegClassSub, InvalidAsmTemplateModifierSym, InvalidRegister, | |
| 19 | InvalidRegisterClass, RegisterClassOnlyClobber, RegisterConflict, | |
| 20 | }; | |
| 21 | use super::LoweringContext; | |
| 22 | use crate::{ImplTraitContext, ImplTraitPosition, ParamMode, ResolverAstLoweringExt}; | |
| 23 | 23 | |
| 24 | 24 | impl<'a, 'hir> LoweringContext<'a, 'hir> { |
| 25 | 25 | #[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable |
compiler/rustc_ast_lowering/src/block.rs+2-2| ... | ... | @@ -1,9 +1,9 @@ |
| 1 | use crate::{ImplTraitContext, ImplTraitPosition, LoweringContext}; | |
| 2 | 1 | use rustc_ast::{Block, BlockCheckMode, Local, LocalKind, Stmt, StmtKind}; |
| 3 | 2 | use rustc_hir as hir; |
| 4 | ||
| 5 | 3 | use smallvec::SmallVec; |
| 6 | 4 | |
| 5 | use crate::{ImplTraitContext, ImplTraitPosition, LoweringContext}; | |
| 6 | ||
| 7 | 7 | impl<'a, 'hir> LoweringContext<'a, 'hir> { |
| 8 | 8 | pub(super) fn lower_block( |
| 9 | 9 | &mut self, |
compiler/rustc_ast_lowering/src/delegation.rs+7-7| ... | ... | @@ -36,23 +36,23 @@ |
| 36 | 36 | //! In case of discrepancy with callee function the `NotSupportedDelegation` error will |
| 37 | 37 | //! also be emitted during HIR ty lowering. |
| 38 | 38 | |
| 39 | use crate::{ImplTraitPosition, ResolverAstLoweringExt}; | |
| 40 | ||
| 41 | use super::{ImplTraitContext, LoweringContext, ParamMode, ParenthesizedGenericArgs}; | |
| 39 | use std::iter; | |
| 42 | 40 | |
| 43 | 41 | use ast::visit::Visitor; |
| 44 | 42 | use hir::def::{DefKind, PartialRes, Res}; |
| 45 | 43 | use hir::{BodyId, HirId}; |
| 46 | use rustc_ast as ast; | |
| 47 | 44 | use rustc_ast::*; |
| 48 | 45 | use rustc_errors::ErrorGuaranteed; |
| 49 | use rustc_hir as hir; | |
| 50 | 46 | use rustc_hir::def_id::DefId; |
| 51 | 47 | use rustc_middle::span_bug; |
| 52 | 48 | use rustc_middle::ty::{Asyncness, ResolverAstLowering}; |
| 53 | use rustc_span::{symbol::Ident, Span}; | |
| 49 | use rustc_span::symbol::Ident; | |
| 50 | use rustc_span::Span; | |
| 54 | 51 | use rustc_target::spec::abi; |
| 55 | use std::iter; | |
| 52 | use {rustc_ast as ast, rustc_hir as hir}; | |
| 53 | ||
| 54 | use super::{ImplTraitContext, LoweringContext, ParamMode, ParenthesizedGenericArgs}; | |
| 55 | use crate::{ImplTraitPosition, ResolverAstLoweringExt}; | |
| 56 | 56 | |
| 57 | 57 | pub(crate) struct DelegationResults<'hir> { |
| 58 | 58 | pub body_id: hir::BodyId, |
compiler/rustc_ast_lowering/src/errors.rs+4-4| ... | ... | @@ -1,8 +1,8 @@ |
| 1 | use rustc_errors::{ | |
| 2 | codes::*, Diag, DiagArgFromDisplay, EmissionGuarantee, SubdiagMessageOp, Subdiagnostic, | |
| 3 | }; | |
| 1 | use rustc_errors::codes::*; | |
| 2 | use rustc_errors::{Diag, DiagArgFromDisplay, EmissionGuarantee, SubdiagMessageOp, Subdiagnostic}; | |
| 4 | 3 | use rustc_macros::{Diagnostic, Subdiagnostic}; |
| 5 | use rustc_span::{symbol::Ident, Span, Symbol}; | |
| 4 | use rustc_span::symbol::Ident; | |
| 5 | use rustc_span::{Span, Symbol}; | |
| 6 | 6 | |
| 7 | 7 | #[derive(Diagnostic)] |
| 8 | 8 | #[diag(ast_lowering_generic_type_with_parentheses, code = E0214)] |
compiler/rustc_ast_lowering/src/expr.rs+13-12| ... | ... | @@ -1,15 +1,5 @@ |
| 1 | 1 | use std::assert_matches::assert_matches; |
| 2 | 2 | |
| 3 | use super::errors::{ | |
| 4 | AsyncCoroutinesNotSupported, AwaitOnlyInAsyncFnAndBlocks, BaseExpressionDoubleDot, | |
| 5 | ClosureCannotBeStatic, CoroutineTooManyParameters, | |
| 6 | FunctionalRecordUpdateDestructuringAssignment, InclusiveRangeWithNoEnd, MatchArmWithNoBody, | |
| 7 | NeverPatternWithBody, NeverPatternWithGuard, UnderscoreExprLhsAssign, | |
| 8 | }; | |
| 9 | use super::ResolverAstLoweringExt; | |
| 10 | use super::{ImplTraitContext, LoweringContext, ParamMode, ParenthesizedGenericArgs}; | |
| 11 | use crate::errors::YieldInClosure; | |
| 12 | use crate::{FnDeclKind, ImplTraitPosition}; | |
| 13 | 3 | use rustc_ast::ptr::P as AstP; |
| 14 | 4 | use rustc_ast::*; |
| 15 | 5 | use rustc_data_structures::stack::ensure_sufficient_stack; |
| ... | ... | @@ -20,10 +10,21 @@ use rustc_middle::span_bug; |
| 20 | 10 | use rustc_session::errors::report_lit_error; |
| 21 | 11 | use rustc_span::source_map::{respan, Spanned}; |
| 22 | 12 | use rustc_span::symbol::{kw, sym, Ident, Symbol}; |
| 23 | use rustc_span::DUMMY_SP; | |
| 24 | use rustc_span::{DesugaringKind, Span}; | |
| 13 | use rustc_span::{DesugaringKind, Span, DUMMY_SP}; | |
| 25 | 14 | use thin_vec::{thin_vec, ThinVec}; |
| 26 | 15 | |
| 16 | use super::errors::{ | |
| 17 | AsyncCoroutinesNotSupported, AwaitOnlyInAsyncFnAndBlocks, BaseExpressionDoubleDot, | |
| 18 | ClosureCannotBeStatic, CoroutineTooManyParameters, | |
| 19 | FunctionalRecordUpdateDestructuringAssignment, InclusiveRangeWithNoEnd, MatchArmWithNoBody, | |
| 20 | NeverPatternWithBody, NeverPatternWithGuard, UnderscoreExprLhsAssign, | |
| 21 | }; | |
| 22 | use super::{ | |
| 23 | ImplTraitContext, LoweringContext, ParamMode, ParenthesizedGenericArgs, ResolverAstLoweringExt, | |
| 24 | }; | |
| 25 | use crate::errors::YieldInClosure; | |
| 26 | use crate::{FnDeclKind, ImplTraitPosition}; | |
| 27 | ||
| 27 | 28 | impl<'hir> LoweringContext<'_, 'hir> { |
| 28 | 29 | fn lower_exprs(&mut self, exprs: &[AstP<Expr>]) -> &'hir [hir::Expr<'hir>] { |
| 29 | 30 | self.arena.alloc_from_iter(exprs.iter().map(|x| self.lower_expr_mut(x))) |
compiler/rustc_ast_lowering/src/format.rs+7-9| ... | ... | @@ -1,16 +1,14 @@ |
| 1 | use super::LoweringContext; | |
| 2 | 1 | use core::ops::ControlFlow; |
| 3 | use rustc_ast as ast; | |
| 2 | use std::borrow::Cow; | |
| 3 | ||
| 4 | 4 | use rustc_ast::visit::Visitor; |
| 5 | 5 | use rustc_ast::*; |
| 6 | 6 | use rustc_data_structures::fx::FxIndexMap; |
| 7 | use rustc_hir as hir; | |
| 8 | use rustc_span::{ | |
| 9 | sym, | |
| 10 | symbol::{kw, Ident}, | |
| 11 | Span, Symbol, | |
| 12 | }; | |
| 13 | use std::borrow::Cow; | |
| 7 | use rustc_span::symbol::{kw, Ident}; | |
| 8 | use rustc_span::{sym, Span, Symbol}; | |
| 9 | use {rustc_ast as ast, rustc_hir as hir}; | |
| 10 | ||
| 11 | use super::LoweringContext; | |
| 14 | 12 | |
| 15 | 13 | impl<'hir> LoweringContext<'_, 'hir> { |
| 16 | 14 | pub(crate) fn lower_format_args(&mut self, sp: Span, fmt: &FormatArgs) -> hir::ExprKind<'hir> { |
compiler/rustc_ast_lowering/src/item.rs+6-5| ... | ... | @@ -1,8 +1,3 @@ |
| 1 | use super::errors::{InvalidAbi, InvalidAbiReason, InvalidAbiSuggestion, MisplacedRelaxTraitBound}; | |
| 2 | use super::ResolverAstLoweringExt; | |
| 3 | use super::{AstOwner, ImplTraitContext, ImplTraitPosition}; | |
| 4 | use super::{FnDeclKind, LoweringContext, ParamMode}; | |
| 5 | ||
| 6 | 1 | use rustc_ast::ptr::P; |
| 7 | 2 | use rustc_ast::visit::AssocCtxt; |
| 8 | 3 | use rustc_ast::*; |
| ... | ... | @@ -22,6 +17,12 @@ use smallvec::{smallvec, SmallVec}; |
| 22 | 17 | use thin_vec::ThinVec; |
| 23 | 18 | use tracing::instrument; |
| 24 | 19 | |
| 20 | use super::errors::{InvalidAbi, InvalidAbiReason, InvalidAbiSuggestion, MisplacedRelaxTraitBound}; | |
| 21 | use super::{ | |
| 22 | AstOwner, FnDeclKind, ImplTraitContext, ImplTraitPosition, LoweringContext, ParamMode, | |
| 23 | ResolverAstLoweringExt, | |
| 24 | }; | |
| 25 | ||
| 25 | 26 | pub(super) struct ItemLowerer<'a, 'hir> { |
| 26 | 27 | pub(super) tcx: TyCtxt<'hir>, |
| 27 | 28 | pub(super) resolver: &'a mut ResolverAstLowering, |
compiler/rustc_ast_lowering/src/lib.rs+6-4| ... | ... | @@ -39,7 +39,8 @@ |
| 39 | 39 | #![feature(rustdoc_internals)] |
| 40 | 40 | // tidy-alphabetical-end |
| 41 | 41 | |
| 42 | use crate::errors::{AssocTyParentheses, AssocTyParenthesesSub, MisplacedImplTrait}; | |
| 42 | use std::collections::hash_map::Entry; | |
| 43 | ||
| 43 | 44 | use rustc_ast::node_id::NodeMap; |
| 44 | 45 | use rustc_ast::ptr::P; |
| 45 | 46 | use rustc_ast::{self as ast, *}; |
| ... | ... | @@ -53,9 +54,9 @@ use rustc_data_structures::sync::Lrc; |
| 53 | 54 | use rustc_errors::{DiagArgFromDisplay, DiagCtxtHandle, StashKey}; |
| 54 | 55 | use rustc_hir::def::{DefKind, LifetimeRes, Namespace, PartialRes, PerNS, Res}; |
| 55 | 56 | use rustc_hir::def_id::{LocalDefId, LocalDefIdMap, CRATE_DEF_ID, LOCAL_CRATE}; |
| 56 | use rustc_hir::{self as hir}; | |
| 57 | 57 | use rustc_hir::{ |
| 58 | ConstArg, GenericArg, HirId, ItemLocalMap, MissingLifetimeKind, ParamName, TraitCandidate, | |
| 58 | self as hir, ConstArg, GenericArg, HirId, ItemLocalMap, MissingLifetimeKind, ParamName, | |
| 59 | TraitCandidate, | |
| 59 | 60 | }; |
| 60 | 61 | use rustc_index::{Idx, IndexSlice, IndexVec}; |
| 61 | 62 | use rustc_macros::extension; |
| ... | ... | @@ -65,10 +66,11 @@ use rustc_session::parse::{add_feature_diagnostics, feature_err}; |
| 65 | 66 | use rustc_span::symbol::{kw, sym, Ident, Symbol}; |
| 66 | 67 | use rustc_span::{DesugaringKind, Span, DUMMY_SP}; |
| 67 | 68 | use smallvec::{smallvec, SmallVec}; |
| 68 | use std::collections::hash_map::Entry; | |
| 69 | 69 | use thin_vec::ThinVec; |
| 70 | 70 | use tracing::{debug, instrument, trace}; |
| 71 | 71 | |
| 72 | use crate::errors::{AssocTyParentheses, AssocTyParenthesesSub, MisplacedImplTrait}; | |
| 73 | ||
| 72 | 74 | macro_rules! arena_vec { |
| 73 | 75 | ($this:expr; $($x:expr),*) => ( |
| 74 | 76 | $this.arena.alloc_from_iter([$($x),*]) |
compiler/rustc_ast_lowering/src/lifetime_collector.rs+2-1| ... | ... | @@ -1,4 +1,3 @@ |
| 1 | use super::ResolverAstLoweringExt; | |
| 2 | 1 | use rustc_ast::visit::{self, BoundKind, LifetimeCtxt, Visitor}; |
| 3 | 2 | use rustc_ast::{GenericBounds, Lifetime, NodeId, PathSegment, PolyTraitRef, Ty, TyKind}; |
| 4 | 3 | use rustc_data_structures::fx::FxIndexSet; |
| ... | ... | @@ -8,6 +7,8 @@ use rustc_middle::ty::ResolverAstLowering; |
| 8 | 7 | use rustc_span::symbol::{kw, Ident}; |
| 9 | 8 | use rustc_span::Span; |
| 10 | 9 | |
| 10 | use super::ResolverAstLoweringExt; | |
| 11 | ||
| 11 | 12 | struct LifetimeCollectVisitor<'ast> { |
| 12 | 13 | resolver: &'ast ResolverAstLowering, |
| 13 | 14 | current_binders: Vec<NodeId>, |
compiler/rustc_ast_lowering/src/pat.rs+8-8| ... | ... | @@ -1,17 +1,17 @@ |
| 1 | use super::errors::{ | |
| 2 | ArbitraryExpressionInPattern, ExtraDoubleDot, MisplacedDoubleDot, SubTupleBinding, | |
| 3 | }; | |
| 4 | use super::ResolverAstLoweringExt; | |
| 5 | use super::{ImplTraitContext, LoweringContext, ParamMode}; | |
| 6 | use crate::ImplTraitPosition; | |
| 7 | ||
| 8 | 1 | use rustc_ast::ptr::P; |
| 9 | 2 | use rustc_ast::*; |
| 10 | 3 | use rustc_data_structures::stack::ensure_sufficient_stack; |
| 11 | 4 | use rustc_hir as hir; |
| 12 | 5 | use rustc_hir::def::Res; |
| 6 | use rustc_span::source_map::Spanned; | |
| 13 | 7 | use rustc_span::symbol::Ident; |
| 14 | use rustc_span::{source_map::Spanned, Span}; | |
| 8 | use rustc_span::Span; | |
| 9 | ||
| 10 | use super::errors::{ | |
| 11 | ArbitraryExpressionInPattern, ExtraDoubleDot, MisplacedDoubleDot, SubTupleBinding, | |
| 12 | }; | |
| 13 | use super::{ImplTraitContext, LoweringContext, ParamMode, ResolverAstLoweringExt}; | |
| 14 | use crate::ImplTraitPosition; | |
| 15 | 15 | |
| 16 | 16 | impl<'a, 'hir> LoweringContext<'a, 'hir> { |
| 17 | 17 | pub(crate) fn lower_pat(&mut self, pattern: &Pat) -> &'hir hir::Pat<'hir> { |
compiler/rustc_ast_lowering/src/path.rs+10-11| ... | ... | @@ -1,13 +1,3 @@ |
| 1 | use crate::ImplTraitPosition; | |
| 2 | ||
| 3 | use super::errors::{ | |
| 4 | AsyncBoundNotOnTrait, AsyncBoundOnlyForFnTraits, BadReturnTypeNotation, | |
| 5 | GenericTypeWithParentheses, UseAngleBrackets, | |
| 6 | }; | |
| 7 | use super::ResolverAstLoweringExt; | |
| 8 | use super::{GenericArgsCtor, LifetimeRes, ParenthesizedGenericArgs}; | |
| 9 | use super::{ImplTraitContext, LoweringContext, ParamMode}; | |
| 10 | ||
| 11 | 1 | use rustc_ast::{self as ast, *}; |
| 12 | 2 | use rustc_data_structures::sync::Lrc; |
| 13 | 3 | use rustc_hir as hir; |
| ... | ... | @@ -17,10 +7,19 @@ use rustc_hir::GenericArg; |
| 17 | 7 | use rustc_middle::span_bug; |
| 18 | 8 | use rustc_span::symbol::{kw, sym, Ident}; |
| 19 | 9 | use rustc_span::{BytePos, DesugaringKind, Span, Symbol, DUMMY_SP}; |
| 20 | ||
| 21 | 10 | use smallvec::{smallvec, SmallVec}; |
| 22 | 11 | use tracing::{debug, instrument}; |
| 23 | 12 | |
| 13 | use super::errors::{ | |
| 14 | AsyncBoundNotOnTrait, AsyncBoundOnlyForFnTraits, BadReturnTypeNotation, | |
| 15 | GenericTypeWithParentheses, UseAngleBrackets, | |
| 16 | }; | |
| 17 | use super::{ | |
| 18 | GenericArgsCtor, ImplTraitContext, LifetimeRes, LoweringContext, ParamMode, | |
| 19 | ParenthesizedGenericArgs, ResolverAstLoweringExt, | |
| 20 | }; | |
| 21 | use crate::ImplTraitPosition; | |
| 22 | ||
| 24 | 23 | impl<'a, 'hir> LoweringContext<'a, 'hir> { |
| 25 | 24 | #[instrument(level = "trace", skip(self))] |
| 26 | 25 | pub(crate) fn lower_qpath( |
compiler/rustc_ast_passes/src/ast_validation.rs+3-2| ... | ... | @@ -16,6 +16,9 @@ |
| 16 | 16 | //! constructions produced by proc macros. This pass is only intended for simple checks that do not |
| 17 | 17 | //! require name resolution or type checking, or other kinds of complex analysis. |
| 18 | 18 | |
| 19 | use std::mem; | |
| 20 | use std::ops::{Deref, DerefMut}; | |
| 21 | ||
| 19 | 22 | use itertools::{Either, Itertools}; |
| 20 | 23 | use rustc_ast::ptr::P; |
| 21 | 24 | use rustc_ast::visit::{walk_list, AssocCtxt, BoundKind, FnCtxt, FnKind, Visitor}; |
| ... | ... | @@ -34,8 +37,6 @@ use rustc_session::Session; |
| 34 | 37 | use rustc_span::symbol::{kw, sym, Ident}; |
| 35 | 38 | use rustc_span::Span; |
| 36 | 39 | use rustc_target::spec::abi; |
| 37 | use std::mem; | |
| 38 | use std::ops::{Deref, DerefMut}; | |
| 39 | 40 | use thin_vec::thin_vec; |
| 40 | 41 | |
| 41 | 42 | use crate::errors::{self, TildeConstReason}; |
compiler/rustc_ast_passes/src/errors.rs+4-4| ... | ... | @@ -1,11 +1,11 @@ |
| 1 | 1 | //! Errors emitted by ast_passes. |
| 2 | 2 | |
| 3 | 3 | use rustc_ast::ParamKindOrd; |
| 4 | use rustc_errors::{ | |
| 5 | codes::*, Applicability, Diag, EmissionGuarantee, SubdiagMessageOp, Subdiagnostic, | |
| 6 | }; | |
| 4 | use rustc_errors::codes::*; | |
| 5 | use rustc_errors::{Applicability, Diag, EmissionGuarantee, SubdiagMessageOp, Subdiagnostic}; | |
| 7 | 6 | use rustc_macros::{Diagnostic, Subdiagnostic}; |
| 8 | use rustc_span::{symbol::Ident, Span, Symbol}; | |
| 7 | use rustc_span::symbol::Ident; | |
| 8 | use rustc_span::{Span, Symbol}; | |
| 9 | 9 | |
| 10 | 10 | use crate::fluent_generated as fluent; |
| 11 | 11 |
compiler/rustc_ast_passes/src/feature_gate.rs+1-2| ... | ... | @@ -1,7 +1,6 @@ |
| 1 | 1 | use rustc_ast as ast; |
| 2 | 2 | use rustc_ast::visit::{self, AssocCtxt, FnCtxt, FnKind, Visitor}; |
| 3 | use rustc_ast::{attr, NodeId}; | |
| 4 | use rustc_ast::{token, PatKind}; | |
| 3 | use rustc_ast::{attr, token, NodeId, PatKind}; | |
| 5 | 4 | use rustc_feature::{AttributeGate, BuiltinAttribute, Features, GateIssue, BUILTIN_ATTRIBUTE_MAP}; |
| 6 | 5 | use rustc_session::parse::{feature_err, feature_err_issue, feature_warn}; |
| 7 | 6 | use rustc_session::Session; |
compiler/rustc_ast_pretty/src/helpers.rs+2-1| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | use crate::pp::Printer; | |
| 2 | 1 | use std::borrow::Cow; |
| 3 | 2 | |
| 3 | use crate::pp::Printer; | |
| 4 | ||
| 4 | 5 | impl Printer { |
| 5 | 6 | pub fn word_space<W: Into<Cow<'static, str>>>(&mut self, w: W) { |
| 6 | 7 | self.word(w); |
compiler/rustc_ast_pretty/src/pp.rs+3-3| ... | ... | @@ -135,11 +135,11 @@ |
| 135 | 135 | mod convenience; |
| 136 | 136 | mod ring; |
| 137 | 137 | |
| 138 | use ring::RingBuffer; | |
| 139 | 138 | use std::borrow::Cow; |
| 140 | use std::cmp; | |
| 141 | 139 | use std::collections::VecDeque; |
| 142 | use std::iter; | |
| 140 | use std::{cmp, iter}; | |
| 141 | ||
| 142 | use ring::RingBuffer; | |
| 143 | 143 | |
| 144 | 144 | /// How to break. Described in more detail in the module docs. |
| 145 | 145 | #[derive(Clone, Copy, PartialEq)] |
compiler/rustc_ast_pretty/src/pp/convenience.rs+2-1| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | use crate::pp::{BeginToken, BreakToken, Breaks, IndentStyle, Printer, Token, SIZE_INFINITY}; | |
| 2 | 1 | use std::borrow::Cow; |
| 3 | 2 | |
| 3 | use crate::pp::{BeginToken, BreakToken, Breaks, IndentStyle, Printer, Token, SIZE_INFINITY}; | |
| 4 | ||
| 4 | 5 | impl Printer { |
| 5 | 6 | /// "raw box" |
| 6 | 7 | pub fn rbox(&mut self, indent: isize, breaks: Breaks) { |
compiler/rustc_ast_pretty/src/pprust/mod.rs+2-3| ... | ... | @@ -2,13 +2,12 @@ |
| 2 | 2 | mod tests; |
| 3 | 3 | |
| 4 | 4 | pub mod state; |
| 5 | pub use state::{print_crate, AnnNode, Comments, PpAnn, PrintState, State}; | |
| 5 | use std::borrow::Cow; | |
| 6 | 6 | |
| 7 | 7 | use rustc_ast as ast; |
| 8 | 8 | use rustc_ast::token::{Nonterminal, Token, TokenKind}; |
| 9 | 9 | use rustc_ast::tokenstream::{TokenStream, TokenTree}; |
| 10 | ||
| 11 | use std::borrow::Cow; | |
| 10 | pub use state::{print_crate, AnnNode, Comments, PpAnn, PrintState, State}; | |
| 12 | 11 | |
| 13 | 12 | pub fn nonterminal_to_string(nt: &Nonterminal) -> String { |
| 14 | 13 | State::new().nonterminal_to_string(nt) |
compiler/rustc_ast_pretty/src/pprust/state.rs+12-11| ... | ... | @@ -6,9 +6,8 @@ mod expr; |
| 6 | 6 | mod fixup; |
| 7 | 7 | mod item; |
| 8 | 8 | |
| 9 | use crate::pp::Breaks::{Consistent, Inconsistent}; | |
| 10 | use crate::pp::{self, Breaks}; | |
| 11 | use crate::pprust::state::fixup::FixupContext; | |
| 9 | use std::borrow::Cow; | |
| 10 | ||
| 12 | 11 | use ast::TraitBoundModifiers; |
| 13 | 12 | use rustc_ast::attr::AttrIdGenerator; |
| 14 | 13 | use rustc_ast::ptr::P; |
| ... | ... | @@ -16,18 +15,21 @@ use rustc_ast::token::{self, BinOpToken, CommentKind, Delimiter, Nonterminal, To |
| 16 | 15 | use rustc_ast::tokenstream::{Spacing, TokenStream, TokenTree}; |
| 17 | 16 | use rustc_ast::util::classify; |
| 18 | 17 | use rustc_ast::util::comments::{Comment, CommentStyle}; |
| 19 | use rustc_ast::{self as ast, AttrArgs, AttrArgsEq, BlockCheckMode, PatKind, Safety}; | |
| 20 | use rustc_ast::{attr, BindingMode, ByRef, DelimArgs, RangeEnd, RangeSyntax, Term}; | |
| 21 | use rustc_ast::{GenericArg, GenericBound, SelfKind}; | |
| 22 | use rustc_ast::{InlineAsmOperand, InlineAsmRegOrRegClass}; | |
| 23 | use rustc_ast::{InlineAsmOptions, InlineAsmTemplatePiece}; | |
| 18 | use rustc_ast::{ | |
| 19 | self as ast, attr, AttrArgs, AttrArgsEq, BindingMode, BlockCheckMode, ByRef, DelimArgs, | |
| 20 | GenericArg, GenericBound, InlineAsmOperand, InlineAsmOptions, InlineAsmRegOrRegClass, | |
| 21 | InlineAsmTemplatePiece, PatKind, RangeEnd, RangeSyntax, Safety, SelfKind, Term, | |
| 22 | }; | |
| 24 | 23 | use rustc_span::edition::Edition; |
| 25 | 24 | use rustc_span::source_map::{SourceMap, Spanned}; |
| 26 | 25 | use rustc_span::symbol::{kw, sym, Ident, IdentPrinter, Symbol}; |
| 27 | 26 | use rustc_span::{BytePos, CharPos, FileName, Pos, Span, DUMMY_SP}; |
| 28 | use std::borrow::Cow; | |
| 29 | 27 | use thin_vec::ThinVec; |
| 30 | 28 | |
| 29 | use crate::pp::Breaks::{Consistent, Inconsistent}; | |
| 30 | use crate::pp::{self, Breaks}; | |
| 31 | use crate::pprust::state::fixup::FixupContext; | |
| 32 | ||
| 31 | 33 | pub enum MacHeader<'a> { |
| 32 | 34 | Path(&'a ast::Path), |
| 33 | 35 | Keyword(&'static str), |
| ... | ... | @@ -290,8 +292,7 @@ pub fn print_crate<'a>( |
| 290 | 292 | fn space_between(tt1: &TokenTree, tt2: &TokenTree) -> bool { |
| 291 | 293 | use token::*; |
| 292 | 294 | use Delimiter::*; |
| 293 | use TokenTree::Delimited as Del; | |
| 294 | use TokenTree::Token as Tok; | |
| 295 | use TokenTree::{Delimited as Del, Token as Tok}; | |
| 295 | 296 | |
| 296 | 297 | fn is_punct(tt: &TokenTree) -> bool { |
| 297 | 298 | matches!(tt, TokenTree::Token(tok, _) if tok.is_punct()) |
compiler/rustc_ast_pretty/src/pprust/state/expr.rs+8-8| ... | ... | @@ -1,19 +1,19 @@ |
| 1 | use crate::pp::Breaks::Inconsistent; | |
| 2 | use crate::pprust::state::fixup::FixupContext; | |
| 3 | use crate::pprust::state::{AnnNode, PrintState, State, INDENT_UNIT}; | |
| 1 | use std::fmt::Write; | |
| 2 | ||
| 4 | 3 | use ast::{ForLoopKind, MatchKind}; |
| 5 | 4 | use itertools::{Itertools, Position}; |
| 6 | 5 | use rustc_ast::ptr::P; |
| 7 | use rustc_ast::token; | |
| 8 | 6 | use rustc_ast::util::classify; |
| 9 | 7 | use rustc_ast::util::literal::escape_byte_str_symbol; |
| 10 | 8 | use rustc_ast::util::parser::{self, AssocOp, Fixity}; |
| 11 | use rustc_ast::{self as ast, BlockCheckMode}; | |
| 12 | 9 | use rustc_ast::{ |
| 13 | FormatAlignment, FormatArgPosition, FormatArgsPiece, FormatCount, FormatDebugHex, FormatSign, | |
| 14 | FormatTrait, | |
| 10 | self as ast, token, BlockCheckMode, FormatAlignment, FormatArgPosition, FormatArgsPiece, | |
| 11 | FormatCount, FormatDebugHex, FormatSign, FormatTrait, | |
| 15 | 12 | }; |
| 16 | use std::fmt::Write; | |
| 13 | ||
| 14 | use crate::pp::Breaks::Inconsistent; | |
| 15 | use crate::pprust::state::fixup::FixupContext; | |
| 16 | use crate::pprust::state::{AnnNode, PrintState, State, INDENT_UNIT}; | |
| 17 | 17 | |
| 18 | 18 | impl<'a> State<'a> { |
| 19 | 19 | fn print_else(&mut self, els: Option<&ast::Expr>) { |
compiler/rustc_ast_pretty/src/pprust/state/item.rs+4-4| ... | ... | @@ -1,7 +1,3 @@ |
| 1 | use crate::pp::Breaks::Inconsistent; | |
| 2 | use crate::pprust::state::fixup::FixupContext; | |
| 3 | use crate::pprust::state::{AnnNode, PrintState, State, INDENT_UNIT}; | |
| 4 | ||
| 5 | 1 | use ast::StaticItem; |
| 6 | 2 | use itertools::{Itertools, Position}; |
| 7 | 3 | use rustc_ast as ast; |
| ... | ... | @@ -9,6 +5,10 @@ use rustc_ast::ptr::P; |
| 9 | 5 | use rustc_ast::ModKind; |
| 10 | 6 | use rustc_span::symbol::Ident; |
| 11 | 7 | |
| 8 | use crate::pp::Breaks::Inconsistent; | |
| 9 | use crate::pprust::state::fixup::FixupContext; | |
| 10 | use crate::pprust::state::{AnnNode, PrintState, State, INDENT_UNIT}; | |
| 11 | ||
| 12 | 12 | enum DelegationKind<'a> { |
| 13 | 13 | Single, |
| 14 | 14 | List(&'a [(Ident, Option<Ident>)]), |
compiler/rustc_ast_pretty/src/pprust/tests.rs+3-4| ... | ... | @@ -1,11 +1,10 @@ |
| 1 | use super::*; | |
| 2 | ||
| 3 | 1 | use rustc_ast as ast; |
| 4 | use rustc_span::create_default_session_globals_then; | |
| 5 | 2 | use rustc_span::symbol::Ident; |
| 6 | use rustc_span::DUMMY_SP; | |
| 3 | use rustc_span::{create_default_session_globals_then, DUMMY_SP}; | |
| 7 | 4 | use thin_vec::ThinVec; |
| 8 | 5 | |
| 6 | use super::*; | |
| 7 | ||
| 9 | 8 | fn fun_to_string( |
| 10 | 9 | decl: &ast::FnDecl, |
| 11 | 10 | header: ast::FnHeader, |
compiler/rustc_attr/src/builtin.rs+8-4| ... | ... | @@ -1,8 +1,12 @@ |
| 1 | 1 | //! Parsing and validation of builtin attributes |
| 2 | 2 | |
| 3 | use std::num::NonZero; | |
| 4 | ||
| 3 | 5 | use rustc_abi::Align; |
| 4 | use rustc_ast::{self as ast, attr}; | |
| 5 | use rustc_ast::{Attribute, LitKind, MetaItem, MetaItemKind, MetaItemLit, NestedMetaItem, NodeId}; | |
| 6 | use rustc_ast::{ | |
| 7 | self as ast, attr, Attribute, LitKind, MetaItem, MetaItemKind, MetaItemLit, NestedMetaItem, | |
| 8 | NodeId, | |
| 9 | }; | |
| 6 | 10 | use rustc_ast_pretty::pprust; |
| 7 | 11 | use rustc_errors::ErrorGuaranteed; |
| 8 | 12 | use rustc_feature::{find_gated_cfg, is_builtin_attr_name, Features, GatedCfg}; |
| ... | ... | @@ -13,8 +17,8 @@ use rustc_session::lint::BuiltinLintDiag; |
| 13 | 17 | use rustc_session::parse::feature_err; |
| 14 | 18 | use rustc_session::{RustcVersion, Session}; |
| 15 | 19 | use rustc_span::hygiene::Transparency; |
| 16 | use rustc_span::{symbol::sym, symbol::Symbol, Span}; | |
| 17 | use std::num::NonZero; | |
| 20 | use rustc_span::symbol::{sym, Symbol}; | |
| 21 | use rustc_span::Span; | |
| 18 | 22 | |
| 19 | 23 | use crate::session_diagnostics::{self, IncorrectReprFormatGenericCause}; |
| 20 | 24 |
compiler/rustc_attr/src/lib.rs+2-4| ... | ... | @@ -15,12 +15,10 @@ mod builtin; |
| 15 | 15 | mod session_diagnostics; |
| 16 | 16 | |
| 17 | 17 | pub use builtin::*; |
| 18 | pub use rustc_ast::attr::*; | |
| 19 | pub(crate) use rustc_session::HashStableContext; | |
| 18 | 20 | pub use IntType::*; |
| 19 | 21 | pub use ReprAttr::*; |
| 20 | 22 | pub use StabilityLevel::*; |
| 21 | 23 | |
| 22 | pub use rustc_ast::attr::*; | |
| 23 | ||
| 24 | pub(crate) use rustc_session::HashStableContext; | |
| 25 | ||
| 26 | 24 | rustc_fluent_macro::fluent_messages! { "../messages.ftl" } |
compiler/rustc_attr/src/session_diagnostics.rs+3-4| ... | ... | @@ -1,13 +1,12 @@ |
| 1 | 1 | use std::num::IntErrorKind; |
| 2 | 2 | |
| 3 | 3 | use rustc_ast as ast; |
| 4 | use rustc_errors::DiagCtxtHandle; | |
| 5 | use rustc_errors::{codes::*, Applicability, Diag, Diagnostic, EmissionGuarantee, Level}; | |
| 4 | use rustc_errors::codes::*; | |
| 5 | use rustc_errors::{Applicability, Diag, DiagCtxtHandle, Diagnostic, EmissionGuarantee, Level}; | |
| 6 | 6 | use rustc_macros::{Diagnostic, Subdiagnostic}; |
| 7 | 7 | use rustc_span::{Span, Symbol}; |
| 8 | 8 | |
| 9 | use crate::fluent_generated as fluent; | |
| 10 | use crate::UnsupportedLiteralReason; | |
| 9 | use crate::{fluent_generated as fluent, UnsupportedLiteralReason}; | |
| 11 | 10 | |
| 12 | 11 | #[derive(Diagnostic)] |
| 13 | 12 | #[diag(attr_expected_one_cfg_pattern, code = E0536)] |
compiler/rustc_borrowck/src/borrow_set.rs+8-7| ... | ... | @@ -1,16 +1,17 @@ |
| 1 | use crate::path_utils::allow_two_phase_borrow; | |
| 2 | use crate::place_ext::PlaceExt; | |
| 3 | use crate::BorrowIndex; | |
| 1 | use std::fmt; | |
| 2 | use std::ops::Index; | |
| 3 | ||
| 4 | 4 | use rustc_data_structures::fx::{FxIndexMap, FxIndexSet}; |
| 5 | 5 | use rustc_index::bit_set::BitSet; |
| 6 | use rustc_middle::mir::traversal; | |
| 7 | 6 | use rustc_middle::mir::visit::{MutatingUseContext, NonUseContext, PlaceContext, Visitor}; |
| 8 | use rustc_middle::mir::{self, Body, Local, Location}; | |
| 7 | use rustc_middle::mir::{self, traversal, Body, Local, Location}; | |
| 9 | 8 | use rustc_middle::span_bug; |
| 10 | 9 | use rustc_middle::ty::{RegionVid, TyCtxt}; |
| 11 | 10 | use rustc_mir_dataflow::move_paths::MoveData; |
| 12 | use std::fmt; | |
| 13 | use std::ops::Index; | |
| 11 | ||
| 12 | use crate::path_utils::allow_two_phase_borrow; | |
| 13 | use crate::place_ext::PlaceExt; | |
| 14 | use crate::BorrowIndex; | |
| 14 | 15 | |
| 15 | 16 | pub struct BorrowSet<'tcx> { |
| 16 | 17 | /// The fundamental map relating bitvector indexes to the borrows |
compiler/rustc_borrowck/src/borrowck_errors.rs+2-2| ... | ... | @@ -1,8 +1,8 @@ |
| 1 | 1 | #![allow(rustc::diagnostic_outside_of_impl)] |
| 2 | 2 | #![allow(rustc::untranslatable_diagnostic)] |
| 3 | 3 | |
| 4 | use rustc_errors::Applicability; | |
| 5 | use rustc_errors::{codes::*, struct_span_code_err, Diag, DiagCtxtHandle}; | |
| 4 | use rustc_errors::codes::*; | |
| 5 | use rustc_errors::{struct_span_code_err, Applicability, Diag, DiagCtxtHandle}; | |
| 6 | 6 | use rustc_hir as hir; |
| 7 | 7 | use rustc_middle::span_bug; |
| 8 | 8 | use rustc_middle::ty::{self, Ty, TyCtxt}; |
compiler/rustc_borrowck/src/constraints/graph.rs+2-5| ... | ... | @@ -4,11 +4,8 @@ use rustc_middle::mir::ConstraintCategory; |
| 4 | 4 | use rustc_middle::ty::{RegionVid, VarianceDiagInfo}; |
| 5 | 5 | use rustc_span::DUMMY_SP; |
| 6 | 6 | |
| 7 | use crate::{ | |
| 8 | constraints::OutlivesConstraintIndex, | |
| 9 | constraints::{OutlivesConstraint, OutlivesConstraintSet}, | |
| 10 | type_check::Locations, | |
| 11 | }; | |
| 7 | use crate::constraints::{OutlivesConstraint, OutlivesConstraintIndex, OutlivesConstraintSet}; | |
| 8 | use crate::type_check::Locations; | |
| 12 | 9 | |
| 13 | 10 | /// The construct graph organizes the constraints by their end-points. |
| 14 | 11 | /// It can be used to view a `R1: R2` constraint as either an edge `R1 |
compiler/rustc_borrowck/src/constraints/mod.rs+7-5| ... | ... | @@ -1,12 +1,14 @@ |
| 1 | use crate::region_infer::{ConstraintSccs, RegionDefinition, RegionTracker}; | |
| 2 | use crate::type_check::Locations; | |
| 3 | use crate::universal_regions::UniversalRegions; | |
| 1 | use std::fmt; | |
| 2 | use std::ops::Index; | |
| 3 | ||
| 4 | 4 | use rustc_index::{IndexSlice, IndexVec}; |
| 5 | 5 | use rustc_middle::mir::ConstraintCategory; |
| 6 | 6 | use rustc_middle::ty::{RegionVid, TyCtxt, VarianceDiagInfo}; |
| 7 | 7 | use rustc_span::Span; |
| 8 | use std::fmt; | |
| 9 | use std::ops::Index; | |
| 8 | ||
| 9 | use crate::region_infer::{ConstraintSccs, RegionDefinition, RegionTracker}; | |
| 10 | use crate::type_check::Locations; | |
| 11 | use crate::universal_regions::UniversalRegions; | |
| 10 | 12 | |
| 11 | 13 | pub(crate) mod graph; |
| 12 | 14 |
compiler/rustc_borrowck/src/consumers.rs+10-12| ... | ... | @@ -1,24 +1,22 @@ |
| 1 | 1 | //! This file provides API for compiler consumers. |
| 2 | 2 | |
| 3 | use std::rc::Rc; | |
| 4 | ||
| 3 | 5 | use rustc_hir::def_id::LocalDefId; |
| 4 | 6 | use rustc_index::{IndexSlice, IndexVec}; |
| 5 | 7 | use rustc_middle::mir::{Body, Promoted}; |
| 6 | 8 | use rustc_middle::ty::TyCtxt; |
| 7 | use std::rc::Rc; | |
| 8 | 9 | |
| 10 | pub use super::constraints::OutlivesConstraint; | |
| 11 | pub use super::dataflow::{calculate_borrows_out_of_scope_at_location, BorrowIndex, Borrows}; | |
| 12 | pub use super::facts::{AllFacts as PoloniusInput, RustcFacts}; | |
| 13 | pub use super::location::{LocationTable, RichLocation}; | |
| 14 | pub use super::nll::PoloniusOutput; | |
| 15 | pub use super::place_ext::PlaceExt; | |
| 16 | pub use super::places_conflict::{places_conflict, PlaceConflictBias}; | |
| 17 | pub use super::region_infer::RegionInferenceContext; | |
| 9 | 18 | use crate::borrow_set::BorrowSet; |
| 10 | 19 | |
| 11 | pub use super::{ | |
| 12 | constraints::OutlivesConstraint, | |
| 13 | dataflow::{calculate_borrows_out_of_scope_at_location, BorrowIndex, Borrows}, | |
| 14 | facts::{AllFacts as PoloniusInput, RustcFacts}, | |
| 15 | location::{LocationTable, RichLocation}, | |
| 16 | nll::PoloniusOutput, | |
| 17 | place_ext::PlaceExt, | |
| 18 | places_conflict::{places_conflict, PlaceConflictBias}, | |
| 19 | region_infer::RegionInferenceContext, | |
| 20 | }; | |
| 21 | ||
| 22 | 20 | /// Options determining the output behavior of [`get_body_with_borrowck_facts`]. |
| 23 | 21 | /// |
| 24 | 22 | /// If executing under `-Z polonius` the choice here has no effect, and everything as if |
compiler/rustc_borrowck/src/dataflow.rs+5-6| ... | ... | @@ -1,16 +1,15 @@ |
| 1 | use std::fmt; | |
| 2 | ||
| 1 | 3 | use rustc_data_structures::fx::FxIndexMap; |
| 2 | 4 | use rustc_data_structures::graph; |
| 3 | 5 | use rustc_index::bit_set::BitSet; |
| 4 | 6 | use rustc_middle::mir::{ |
| 5 | 7 | self, BasicBlock, Body, CallReturnPlaces, Location, Place, TerminatorEdges, |
| 6 | 8 | }; |
| 7 | use rustc_middle::ty::RegionVid; | |
| 8 | use rustc_middle::ty::TyCtxt; | |
| 9 | use rustc_middle::ty::{RegionVid, TyCtxt}; | |
| 10 | use rustc_mir_dataflow::fmt::DebugWithContext; | |
| 9 | 11 | use rustc_mir_dataflow::impls::{EverInitializedPlaces, MaybeUninitializedPlaces}; |
| 10 | use rustc_mir_dataflow::ResultsVisitable; | |
| 11 | use rustc_mir_dataflow::{fmt::DebugWithContext, GenKill}; | |
| 12 | use rustc_mir_dataflow::{Analysis, AnalysisDomain, Results}; | |
| 13 | use std::fmt; | |
| 12 | use rustc_mir_dataflow::{Analysis, AnalysisDomain, GenKill, Results, ResultsVisitable}; | |
| 14 | 13 | |
| 15 | 14 | use crate::{places_conflict, BorrowSet, PlaceConflictBias, PlaceExt, RegionInferenceContext}; |
| 16 | 15 |
compiler/rustc_borrowck/src/diagnostics/bound_region_errors.rs+13-15| ... | ... | @@ -1,17 +1,18 @@ |
| 1 | use std::fmt; | |
| 2 | use std::rc::Rc; | |
| 3 | ||
| 1 | 4 | use rustc_errors::Diag; |
| 2 | 5 | use rustc_hir::def_id::LocalDefId; |
| 3 | 6 | use rustc_infer::infer::canonical::Canonical; |
| 4 | use rustc_infer::infer::region_constraints::Constraint; | |
| 5 | use rustc_infer::infer::region_constraints::RegionConstraintData; | |
| 6 | use rustc_infer::infer::RegionVariableOrigin; | |
| 7 | use rustc_infer::infer::{InferCtxt, RegionResolutionError, SubregionOrigin, TyCtxtInferExt as _}; | |
| 7 | use rustc_infer::infer::region_constraints::{Constraint, RegionConstraintData}; | |
| 8 | use rustc_infer::infer::{ | |
| 9 | InferCtxt, RegionResolutionError, RegionVariableOrigin, SubregionOrigin, TyCtxtInferExt as _, | |
| 10 | }; | |
| 8 | 11 | use rustc_infer::traits::ObligationCause; |
| 9 | 12 | use rustc_middle::ty::error::TypeError; |
| 10 | use rustc_middle::ty::RePlaceholder; | |
| 11 | use rustc_middle::ty::Region; | |
| 12 | use rustc_middle::ty::RegionVid; | |
| 13 | use rustc_middle::ty::UniverseIndex; | |
| 14 | use rustc_middle::ty::{self, Ty, TyCtxt, TypeFoldable}; | |
| 13 | use rustc_middle::ty::{ | |
| 14 | self, RePlaceholder, Region, RegionVid, Ty, TyCtxt, TypeFoldable, UniverseIndex, | |
| 15 | }; | |
| 15 | 16 | use rustc_span::Span; |
| 16 | 17 | use rustc_trait_selection::error_reporting::infer::nice_region_error::NiceRegionError; |
| 17 | 18 | use rustc_trait_selection::error_reporting::InferCtxtErrorExt; |
| ... | ... | @@ -19,13 +20,10 @@ use rustc_trait_selection::traits::query::type_op; |
| 19 | 20 | use rustc_trait_selection::traits::ObligationCtxt; |
| 20 | 21 | use rustc_traits::{type_op_ascribe_user_type_with_span, type_op_prove_predicate_with_cause}; |
| 21 | 22 | |
| 22 | use std::fmt; | |
| 23 | use std::rc::Rc; | |
| 24 | ||
| 25 | 23 | use crate::region_infer::values::RegionElement; |
| 26 | use crate::session_diagnostics::HigherRankedErrorCause; | |
| 27 | use crate::session_diagnostics::HigherRankedLifetimeError; | |
| 28 | use crate::session_diagnostics::HigherRankedSubtypeError; | |
| 24 | use crate::session_diagnostics::{ | |
| 25 | HigherRankedErrorCause, HigherRankedLifetimeError, HigherRankedSubtypeError, | |
| 26 | }; | |
| 29 | 27 | use crate::MirBorrowckCtxt; |
| 30 | 28 | |
| 31 | 29 | #[derive(Clone)] |
compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs+14-21| ... | ... | @@ -3,25 +3,27 @@ |
| 3 | 3 | #![allow(rustc::diagnostic_outside_of_impl)] |
| 4 | 4 | #![allow(rustc::untranslatable_diagnostic)] |
| 5 | 5 | |
| 6 | use std::iter; | |
| 7 | use std::ops::ControlFlow; | |
| 8 | ||
| 6 | 9 | use either::Either; |
| 7 | 10 | use hir::{ClosureKind, Path}; |
| 8 | 11 | use rustc_data_structures::captures::Captures; |
| 9 | 12 | use rustc_data_structures::fx::FxIndexSet; |
| 10 | use rustc_errors::{codes::*, struct_span_code_err, Applicability, Diag, MultiSpan}; | |
| 13 | use rustc_errors::codes::*; | |
| 14 | use rustc_errors::{struct_span_code_err, Applicability, Diag, MultiSpan}; | |
| 11 | 15 | use rustc_hir as hir; |
| 12 | 16 | use rustc_hir::def::{DefKind, Res}; |
| 13 | 17 | use rustc_hir::intravisit::{walk_block, walk_expr, Map, Visitor}; |
| 14 | use rustc_hir::{CoroutineDesugaring, PatField}; | |
| 15 | use rustc_hir::{CoroutineKind, CoroutineSource, LangItem}; | |
| 18 | use rustc_hir::{CoroutineDesugaring, CoroutineKind, CoroutineSource, LangItem, PatField}; | |
| 16 | 19 | use rustc_middle::bug; |
| 17 | 20 | use rustc_middle::hir::nested_filter::OnlyBodies; |
| 18 | 21 | use rustc_middle::mir::tcx::PlaceTy; |
| 19 | use rustc_middle::mir::VarDebugInfoContents; | |
| 20 | 22 | use rustc_middle::mir::{ |
| 21 | 23 | self, AggregateKind, BindingForm, BorrowKind, CallSource, ClearCrossCrate, ConstraintCategory, |
| 22 | 24 | FakeBorrowKind, FakeReadCause, LocalDecl, LocalInfo, LocalKind, Location, MutBorrowKind, |
| 23 | 25 | Operand, Place, PlaceRef, ProjectionElem, Rvalue, Statement, StatementKind, Terminator, |
| 24 | TerminatorKind, VarBindingForm, | |
| 26 | TerminatorKind, VarBindingForm, VarDebugInfoContents, | |
| 25 | 27 | }; |
| 26 | 28 | use rustc_middle::ty::print::PrintTraitRefExt as _; |
| 27 | 29 | use rustc_middle::ty::{ |
| ... | ... | @@ -30,8 +32,7 @@ use rustc_middle::ty::{ |
| 30 | 32 | }; |
| 31 | 33 | use rustc_middle::util::CallKind; |
| 32 | 34 | use rustc_mir_dataflow::move_paths::{InitKind, MoveOutIndex, MovePathIndex}; |
| 33 | use rustc_span::def_id::DefId; | |
| 34 | use rustc_span::def_id::LocalDefId; | |
| 35 | use rustc_span::def_id::{DefId, LocalDefId}; | |
| 35 | 36 | use rustc_span::hygiene::DesugaringKind; |
| 36 | 37 | use rustc_span::symbol::{kw, sym, Ident}; |
| 37 | 38 | use rustc_span::{BytePos, Span, Symbol}; |
| ... | ... | @@ -39,22 +40,14 @@ use rustc_trait_selection::error_reporting::traits::FindExprBySpan; |
| 39 | 40 | use rustc_trait_selection::error_reporting::InferCtxtErrorExt; |
| 40 | 41 | use rustc_trait_selection::infer::InferCtxtExt; |
| 41 | 42 | use rustc_trait_selection::traits::{Obligation, ObligationCause, ObligationCtxt}; |
| 42 | use std::iter; | |
| 43 | use std::ops::ControlFlow; | |
| 44 | 43 | |
| 45 | use crate::borrow_set::TwoPhaseActivation; | |
| 46 | use crate::borrowck_errors; | |
| 44 | use super::explain_borrow::{BorrowExplanation, LaterUseKind}; | |
| 45 | use super::{DescribePlaceOpt, RegionName, RegionNameSource, UseSpans}; | |
| 46 | use crate::borrow_set::{BorrowData, TwoPhaseActivation}; | |
| 47 | 47 | use crate::diagnostics::conflict_errors::StorageDeadOrDrop::LocalStorageDead; |
| 48 | use crate::diagnostics::{find_all_local_uses, CapturedMessageOpt}; | |
| 49 | use crate::{ | |
| 50 | borrow_set::BorrowData, diagnostics::Instance, prefixes::IsPrefixOf, | |
| 51 | InitializationRequiringAction, MirBorrowckCtxt, WriteKind, | |
| 52 | }; | |
| 53 | ||
| 54 | use super::{ | |
| 55 | explain_borrow::{BorrowExplanation, LaterUseKind}, | |
| 56 | DescribePlaceOpt, RegionName, RegionNameSource, UseSpans, | |
| 57 | }; | |
| 48 | use crate::diagnostics::{find_all_local_uses, CapturedMessageOpt, Instance}; | |
| 49 | use crate::prefixes::IsPrefixOf; | |
| 50 | use crate::{borrowck_errors, InitializationRequiringAction, MirBorrowckCtxt, WriteKind}; | |
| 58 | 51 | |
| 59 | 52 | #[derive(Debug)] |
| 60 | 53 | struct MoveSite { |
compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs+4-6| ... | ... | @@ -19,13 +19,11 @@ use rustc_span::symbol::{kw, Symbol}; |
| 19 | 19 | use rustc_span::{sym, DesugaringKind, Span}; |
| 20 | 20 | use rustc_trait_selection::error_reporting::traits::FindExprBySpan; |
| 21 | 21 | |
| 22 | use crate::region_infer::{BlameConstraint, ExtraConstraintInfo}; | |
| 23 | use crate::{ | |
| 24 | borrow_set::BorrowData, nll::ConstraintDescription, region_infer::Cause, MirBorrowckCtxt, | |
| 25 | WriteKind, | |
| 26 | }; | |
| 27 | ||
| 28 | 22 | use super::{find_use, RegionName, UseSpans}; |
| 23 | use crate::borrow_set::BorrowData; | |
| 24 | use crate::nll::ConstraintDescription; | |
| 25 | use crate::region_infer::{BlameConstraint, Cause, ExtraConstraintInfo}; | |
| 26 | use crate::{MirBorrowckCtxt, WriteKind}; | |
| 29 | 27 | |
| 30 | 28 | #[derive(Debug)] |
| 31 | 29 | pub(crate) enum BorrowExplanation<'tcx> { |
compiler/rustc_borrowck/src/diagnostics/find_use.rs+3-4| ... | ... | @@ -1,15 +1,14 @@ |
| 1 | 1 | use std::collections::VecDeque; |
| 2 | 2 | use std::rc::Rc; |
| 3 | 3 | |
| 4 | use crate::{ | |
| 5 | def_use::{self, DefUse}, | |
| 6 | region_infer::{Cause, RegionInferenceContext}, | |
| 7 | }; | |
| 8 | 4 | use rustc_data_structures::fx::FxIndexSet; |
| 9 | 5 | use rustc_middle::mir::visit::{MirVisitable, PlaceContext, Visitor}; |
| 10 | 6 | use rustc_middle::mir::{self, Body, Local, Location}; |
| 11 | 7 | use rustc_middle::ty::{RegionVid, TyCtxt}; |
| 12 | 8 | |
| 9 | use crate::def_use::{self, DefUse}; | |
| 10 | use crate::region_infer::{Cause, RegionInferenceContext}; | |
| 11 | ||
| 13 | 12 | pub(crate) fn find<'tcx>( |
| 14 | 13 | body: &Body<'tcx>, |
| 15 | 14 | regioncx: &Rc<RegionInferenceContext<'tcx>>, |
compiler/rustc_borrowck/src/diagnostics/mod.rs+11-12| ... | ... | @@ -1,14 +1,8 @@ |
| 1 | 1 | //! Borrow checker diagnostics. |
| 2 | 2 | |
| 3 | use crate::session_diagnostics::{ | |
| 4 | CaptureArgLabel, CaptureReasonLabel, CaptureReasonNote, CaptureReasonSuggest, CaptureVarCause, | |
| 5 | CaptureVarKind, CaptureVarPathUseCause, OnClosureNote, | |
| 6 | }; | |
| 7 | use rustc_errors::MultiSpan; | |
| 8 | use rustc_errors::{Applicability, Diag}; | |
| 3 | use rustc_errors::{Applicability, Diag, MultiSpan}; | |
| 9 | 4 | use rustc_hir::def::{CtorKind, Namespace}; |
| 10 | use rustc_hir::CoroutineKind; | |
| 11 | use rustc_hir::{self as hir, LangItem}; | |
| 5 | use rustc_hir::{self as hir, CoroutineKind, LangItem}; | |
| 12 | 6 | use rustc_index::IndexSlice; |
| 13 | 7 | use rustc_infer::infer::BoundRegionConversionTime; |
| 14 | 8 | use rustc_infer::traits::SelectionError; |
| ... | ... | @@ -25,7 +19,8 @@ use rustc_middle::util::{call_kind, CallDesugaringKind}; |
| 25 | 19 | use rustc_mir_dataflow::move_paths::{InitLocation, LookupResult}; |
| 26 | 20 | use rustc_span::def_id::LocalDefId; |
| 27 | 21 | use rustc_span::source_map::Spanned; |
| 28 | use rustc_span::{symbol::sym, Span, Symbol, DUMMY_SP}; | |
| 22 | use rustc_span::symbol::sym; | |
| 23 | use rustc_span::{Span, Symbol, DUMMY_SP}; | |
| 29 | 24 | use rustc_target::abi::{FieldIdx, VariantIdx}; |
| 30 | 25 | use rustc_trait_selection::error_reporting::InferCtxtErrorExt; |
| 31 | 26 | use rustc_trait_selection::infer::InferCtxtExt; |
| ... | ... | @@ -33,10 +28,13 @@ use rustc_trait_selection::traits::{ |
| 33 | 28 | type_known_to_meet_bound_modulo_regions, FulfillmentErrorCode, |
| 34 | 29 | }; |
| 35 | 30 | |
| 36 | use crate::fluent_generated as fluent; | |
| 37 | ||
| 38 | 31 | use super::borrow_set::BorrowData; |
| 39 | 32 | use super::MirBorrowckCtxt; |
| 33 | use crate::fluent_generated as fluent; | |
| 34 | use crate::session_diagnostics::{ | |
| 35 | CaptureArgLabel, CaptureReasonLabel, CaptureReasonNote, CaptureReasonSuggest, CaptureVarCause, | |
| 36 | CaptureVarKind, CaptureVarPathUseCause, OnClosureNote, | |
| 37 | }; | |
| 40 | 38 | |
| 41 | 39 | mod find_all_local_uses; |
| 42 | 40 | mod find_use; |
| ... | ... | @@ -599,8 +597,9 @@ impl UseSpans<'_> { |
| 599 | 597 | err: &mut Diag<'_>, |
| 600 | 598 | action: crate::InitializationRequiringAction, |
| 601 | 599 | ) { |
| 602 | use crate::InitializationRequiringAction::*; | |
| 603 | 600 | use CaptureVarPathUseCause::*; |
| 601 | ||
| 602 | use crate::InitializationRequiringAction::*; | |
| 604 | 603 | if let UseSpans::ClosureUse { closure_kind, path_span, .. } = self { |
| 605 | 604 | match closure_kind { |
| 606 | 605 | hir::ClosureKind::Coroutine(_) => { |
compiler/rustc_borrowck/src/diagnostics/move_errors.rs+1-2| ... | ... | @@ -11,8 +11,7 @@ use rustc_mir_dataflow::move_paths::{LookupResult, MovePathIndex}; |
| 11 | 11 | use rustc_span::{BytePos, ExpnKind, MacroKind, Span}; |
| 12 | 12 | use rustc_trait_selection::error_reporting::traits::FindExprBySpan; |
| 13 | 13 | |
| 14 | use crate::diagnostics::CapturedMessageOpt; | |
| 15 | use crate::diagnostics::{DescribePlaceOpt, UseSpans}; | |
| 14 | use crate::diagnostics::{CapturedMessageOpt, DescribePlaceOpt, UseSpans}; | |
| 16 | 15 | use crate::prefixes::PrefixSet; |
| 17 | 16 | use crate::MirBorrowckCtxt; |
| 18 | 17 |
compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs+8-9| ... | ... | @@ -2,17 +2,18 @@ |
| 2 | 2 | #![allow(rustc::untranslatable_diagnostic)] |
| 3 | 3 | |
| 4 | 4 | use core::ops::ControlFlow; |
| 5 | ||
| 5 | 6 | use hir::{ExprKind, Param}; |
| 6 | 7 | use rustc_errors::{Applicability, Diag}; |
| 7 | 8 | use rustc_hir::intravisit::Visitor; |
| 8 | 9 | use rustc_hir::{self as hir, BindingMode, ByRef, Node}; |
| 9 | 10 | use rustc_middle::bug; |
| 10 | use rustc_middle::mir::{Mutability, Place, PlaceRef, ProjectionElem}; | |
| 11 | use rustc_middle::ty::{self, InstanceKind, Ty, TyCtxt, Upcast}; | |
| 12 | use rustc_middle::{ | |
| 13 | hir::place::PlaceBase, | |
| 14 | mir::{self, BindingForm, Local, LocalDecl, LocalInfo, LocalKind, Location}, | |
| 11 | use rustc_middle::hir::place::PlaceBase; | |
| 12 | use rustc_middle::mir::{ | |
| 13 | self, BindingForm, Local, LocalDecl, LocalInfo, LocalKind, Location, Mutability, Place, | |
| 14 | PlaceRef, ProjectionElem, | |
| 15 | 15 | }; |
| 16 | use rustc_middle::ty::{self, InstanceKind, Ty, TyCtxt, Upcast}; | |
| 16 | 17 | use rustc_span::symbol::{kw, Symbol}; |
| 17 | 18 | use rustc_span::{sym, BytePos, DesugaringKind, Span}; |
| 18 | 19 | use rustc_target::abi::FieldIdx; |
| ... | ... | @@ -847,10 +848,8 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> { |
| 847 | 848 | // Attempt to search similar mutable associated items for suggestion. |
| 848 | 849 | // In the future, attempt in all path but initially for RHS of for_loop |
| 849 | 850 | fn suggest_similar_mut_method_for_for_loop(&self, err: &mut Diag<'_>, span: Span) { |
| 850 | use hir::{ | |
| 851 | BorrowKind, Expr, | |
| 852 | ExprKind::{AddrOf, Block, Call, MethodCall}, | |
| 853 | }; | |
| 851 | use hir::ExprKind::{AddrOf, Block, Call, MethodCall}; | |
| 852 | use hir::{BorrowKind, Expr}; | |
| 854 | 853 | |
| 855 | 854 | let hir_map = self.infcx.tcx.hir(); |
| 856 | 855 | struct Finder { |
compiler/rustc_borrowck/src/diagnostics/outlives_suggestion.rs+3-3| ... | ... | @@ -4,15 +4,15 @@ |
| 4 | 4 | #![allow(rustc::diagnostic_outside_of_impl)] |
| 5 | 5 | #![allow(rustc::untranslatable_diagnostic)] |
| 6 | 6 | |
| 7 | use std::collections::BTreeMap; | |
| 8 | ||
| 7 | 9 | use rustc_data_structures::fx::FxIndexSet; |
| 8 | 10 | use rustc_errors::Diag; |
| 9 | 11 | use rustc_middle::ty::RegionVid; |
| 10 | 12 | use smallvec::SmallVec; |
| 11 | use std::collections::BTreeMap; | |
| 12 | ||
| 13 | use crate::MirBorrowckCtxt; | |
| 14 | 13 | |
| 15 | 14 | use super::{ErrorConstraintInfo, RegionName, RegionNameSource}; |
| 15 | use crate::MirBorrowckCtxt; | |
| 16 | 16 | |
| 17 | 17 | /// The different things we could suggest. |
| 18 | 18 | enum SuggestedConstraint { |
compiler/rustc_borrowck/src/diagnostics/region_errors.rs+7-14| ... | ... | @@ -14,10 +14,7 @@ use rustc_infer::infer::{NllRegionVariableOrigin, RelateParamBound}; |
| 14 | 14 | use rustc_middle::bug; |
| 15 | 15 | use rustc_middle::hir::place::PlaceBase; |
| 16 | 16 | use rustc_middle::mir::{ConstraintCategory, ReturnConstraint}; |
| 17 | use rustc_middle::ty::GenericArgs; | |
| 18 | use rustc_middle::ty::TypeVisitor; | |
| 19 | use rustc_middle::ty::{self, RegionVid, Ty}; | |
| 20 | use rustc_middle::ty::{Region, TyCtxt}; | |
| 17 | use rustc_middle::ty::{self, GenericArgs, Region, RegionVid, Ty, TyCtxt, TypeVisitor}; | |
| 21 | 18 | use rustc_span::symbol::{kw, Ident}; |
| 22 | 19 | use rustc_span::Span; |
| 23 | 20 | use rustc_trait_selection::error_reporting::infer::nice_region_error::{ |
| ... | ... | @@ -29,20 +26,16 @@ use rustc_trait_selection::error_reporting::InferCtxtErrorExt; |
| 29 | 26 | use rustc_trait_selection::infer::InferCtxtExt; |
| 30 | 27 | use rustc_trait_selection::traits::{Obligation, ObligationCtxt}; |
| 31 | 28 | |
| 32 | use crate::borrowck_errors; | |
| 29 | use super::{OutlivesSuggestionBuilder, RegionName, RegionNameSource}; | |
| 30 | use crate::nll::ConstraintDescription; | |
| 31 | use crate::region_infer::values::RegionElement; | |
| 32 | use crate::region_infer::{BlameConstraint, ExtraConstraintInfo, TypeTest}; | |
| 33 | 33 | use crate::session_diagnostics::{ |
| 34 | 34 | FnMutError, FnMutReturnTypeErr, GenericDoesNotLiveLongEnough, LifetimeOutliveErr, |
| 35 | 35 | LifetimeReturnCategoryErr, RequireStaticErr, VarHereDenote, |
| 36 | 36 | }; |
| 37 | ||
| 38 | use super::{OutlivesSuggestionBuilder, RegionName, RegionNameSource}; | |
| 39 | use crate::region_infer::{BlameConstraint, ExtraConstraintInfo}; | |
| 40 | use crate::{ | |
| 41 | nll::ConstraintDescription, | |
| 42 | region_infer::{values::RegionElement, TypeTest}, | |
| 43 | universal_regions::DefiningTy, | |
| 44 | MirBorrowckCtxt, | |
| 45 | }; | |
| 37 | use crate::universal_regions::DefiningTy; | |
| 38 | use crate::{borrowck_errors, MirBorrowckCtxt}; | |
| 46 | 39 | |
| 47 | 40 | impl<'tcx> ConstraintDescription for ConstraintCategory<'tcx> { |
| 48 | 41 | fn description(&self) -> &'static str { |
compiler/rustc_borrowck/src/diagnostics/region_name.rs+3-3| ... | ... | @@ -9,14 +9,14 @@ use rustc_errors::Diag; |
| 9 | 9 | use rustc_hir as hir; |
| 10 | 10 | use rustc_hir::def::{DefKind, Res}; |
| 11 | 11 | use rustc_middle::ty::print::RegionHighlightMode; |
| 12 | use rustc_middle::ty::{self, RegionVid, Ty}; | |
| 13 | use rustc_middle::ty::{GenericArgKind, GenericArgsRef}; | |
| 12 | use rustc_middle::ty::{self, GenericArgKind, GenericArgsRef, RegionVid, Ty}; | |
| 14 | 13 | use rustc_middle::{bug, span_bug}; |
| 15 | 14 | use rustc_span::symbol::{kw, sym, Symbol}; |
| 16 | 15 | use rustc_span::{Span, DUMMY_SP}; |
| 17 | 16 | use rustc_trait_selection::error_reporting::InferCtxtErrorExt; |
| 18 | 17 | |
| 19 | use crate::{universal_regions::DefiningTy, MirBorrowckCtxt}; | |
| 18 | use crate::universal_regions::DefiningTy; | |
| 19 | use crate::MirBorrowckCtxt; | |
| 20 | 20 | |
| 21 | 21 | /// A name for a particular region used in emitting diagnostics. This name could be a generated |
| 22 | 22 | /// name like `'1`, a name used by the user like `'a`, or a name like `'static`. |
compiler/rustc_borrowck/src/diagnostics/var_name.rs+2-1| ... | ... | @@ -1,10 +1,11 @@ |
| 1 | use crate::region_infer::RegionInferenceContext; | |
| 2 | 1 | use rustc_index::IndexSlice; |
| 3 | 2 | use rustc_middle::mir::{Body, Local}; |
| 4 | 3 | use rustc_middle::ty::{self, RegionVid, TyCtxt}; |
| 5 | 4 | use rustc_span::symbol::Symbol; |
| 6 | 5 | use rustc_span::Span; |
| 7 | 6 | |
| 7 | use crate::region_infer::RegionInferenceContext; | |
| 8 | ||
| 8 | 9 | impl<'tcx> RegionInferenceContext<'tcx> { |
| 9 | 10 | pub(crate) fn get_var_name_and_span_for_region( |
| 10 | 11 | &self, |
compiler/rustc_borrowck/src/facts.rs+9-8| ... | ... | @@ -1,17 +1,18 @@ |
| 1 | use crate::location::{LocationIndex, LocationTable}; | |
| 2 | use crate::BorrowIndex; | |
| 3 | use polonius_engine::AllFacts as PoloniusFacts; | |
| 4 | use polonius_engine::Atom; | |
| 5 | use rustc_macros::extension; | |
| 6 | use rustc_middle::mir::Local; | |
| 7 | use rustc_middle::ty::{RegionVid, TyCtxt}; | |
| 8 | use rustc_mir_dataflow::move_paths::MovePathIndex; | |
| 9 | 1 | use std::error::Error; |
| 10 | 2 | use std::fmt::Debug; |
| 11 | 3 | use std::fs::{self, File}; |
| 12 | 4 | use std::io::{BufWriter, Write}; |
| 13 | 5 | use std::path::Path; |
| 14 | 6 | |
| 7 | use polonius_engine::{AllFacts as PoloniusFacts, Atom}; | |
| 8 | use rustc_macros::extension; | |
| 9 | use rustc_middle::mir::Local; | |
| 10 | use rustc_middle::ty::{RegionVid, TyCtxt}; | |
| 11 | use rustc_mir_dataflow::move_paths::MovePathIndex; | |
| 12 | ||
| 13 | use crate::location::{LocationIndex, LocationTable}; | |
| 14 | use crate::BorrowIndex; | |
| 15 | ||
| 15 | 16 | #[derive(Copy, Clone, Debug)] |
| 16 | 17 | pub struct RustcFacts; |
| 17 | 18 |
compiler/rustc_borrowck/src/lib.rs+19-21| ... | ... | @@ -17,6 +17,13 @@ |
| 17 | 17 | #[macro_use] |
| 18 | 18 | extern crate tracing; |
| 19 | 19 | |
| 20 | use std::cell::RefCell; | |
| 21 | use std::collections::BTreeMap; | |
| 22 | use std::marker::PhantomData; | |
| 23 | use std::ops::Deref; | |
| 24 | use std::rc::Rc; | |
| 25 | ||
| 26 | use consumers::{BodyWithBorrowckFacts, ConsumerOptions}; | |
| 20 | 27 | use rustc_data_structures::fx::{FxIndexMap, FxIndexSet}; |
| 21 | 28 | use rustc_data_structures::graph::dominators::Dominators; |
| 22 | 29 | use rustc_errors::Diag; |
| ... | ... | @@ -24,40 +31,31 @@ use rustc_hir as hir; |
| 24 | 31 | use rustc_hir::def_id::LocalDefId; |
| 25 | 32 | use rustc_index::bit_set::{BitSet, ChunkedBitSet}; |
| 26 | 33 | use rustc_index::{IndexSlice, IndexVec}; |
| 27 | use rustc_infer::infer::TyCtxtInferExt; | |
| 28 | use rustc_infer::infer::{InferCtxt, NllRegionVariableOrigin, RegionVariableOrigin}; | |
| 34 | use rustc_infer::infer::{ | |
| 35 | InferCtxt, NllRegionVariableOrigin, RegionVariableOrigin, TyCtxtInferExt, | |
| 36 | }; | |
| 29 | 37 | use rustc_middle::mir::tcx::PlaceTy; |
| 30 | 38 | use rustc_middle::mir::*; |
| 31 | 39 | use rustc_middle::query::Providers; |
| 32 | 40 | use rustc_middle::ty::{self, ParamEnv, RegionVid, TyCtxt}; |
| 33 | 41 | use rustc_middle::{bug, span_bug}; |
| 42 | use rustc_mir_dataflow::impls::{ | |
| 43 | EverInitializedPlaces, MaybeInitializedPlaces, MaybeUninitializedPlaces, | |
| 44 | }; | |
| 45 | use rustc_mir_dataflow::move_paths::{ | |
| 46 | InitIndex, InitLocation, LookupResult, MoveData, MoveOutIndex, MovePathIndex, | |
| 47 | }; | |
| 48 | use rustc_mir_dataflow::{Analysis, MoveDataParamEnv}; | |
| 34 | 49 | use rustc_session::lint::builtin::UNUSED_MUT; |
| 35 | 50 | use rustc_span::{Span, Symbol}; |
| 36 | 51 | use rustc_target::abi::FieldIdx; |
| 37 | ||
| 38 | 52 | use smallvec::SmallVec; |
| 39 | use std::cell::RefCell; | |
| 40 | use std::collections::BTreeMap; | |
| 41 | use std::marker::PhantomData; | |
| 42 | use std::ops::Deref; | |
| 43 | use std::rc::Rc; | |
| 44 | ||
| 45 | use rustc_mir_dataflow::impls::{ | |
| 46 | EverInitializedPlaces, MaybeInitializedPlaces, MaybeUninitializedPlaces, | |
| 47 | }; | |
| 48 | use rustc_mir_dataflow::move_paths::{InitIndex, MoveOutIndex, MovePathIndex}; | |
| 49 | use rustc_mir_dataflow::move_paths::{InitLocation, LookupResult, MoveData}; | |
| 50 | use rustc_mir_dataflow::Analysis; | |
| 51 | use rustc_mir_dataflow::MoveDataParamEnv; | |
| 52 | ||
| 53 | use crate::session_diagnostics::VarNeedNotMut; | |
| 54 | 53 | |
| 55 | 54 | use self::diagnostics::{AccessKind, IllegalMoveOriginKind, MoveError, RegionName}; |
| 56 | 55 | use self::location::LocationTable; |
| 57 | use self::prefixes::PrefixSet; | |
| 58 | use consumers::{BodyWithBorrowckFacts, ConsumerOptions}; | |
| 59 | ||
| 60 | 56 | use self::path_utils::*; |
| 57 | use self::prefixes::PrefixSet; | |
| 58 | use crate::session_diagnostics::VarNeedNotMut; | |
| 61 | 59 | |
| 62 | 60 | pub mod borrow_set; |
| 63 | 61 | mod borrowck_errors; |
compiler/rustc_borrowck/src/member_constraints.rs+3-2| ... | ... | @@ -1,11 +1,12 @@ |
| 1 | use std::hash::Hash; | |
| 2 | use std::ops::Index; | |
| 3 | ||
| 1 | 4 | use rustc_data_structures::captures::Captures; |
| 2 | 5 | use rustc_data_structures::fx::FxIndexMap; |
| 3 | 6 | use rustc_index::{IndexSlice, IndexVec}; |
| 4 | 7 | use rustc_middle::infer::MemberConstraint; |
| 5 | 8 | use rustc_middle::ty::{self, Ty}; |
| 6 | 9 | use rustc_span::Span; |
| 7 | use std::hash::Hash; | |
| 8 | use std::ops::Index; | |
| 9 | 10 | |
| 10 | 11 | /// Compactly stores a set of `R0 member of [R1...Rn]` constraints, |
| 11 | 12 | /// indexed by the region `R0`. |
compiler/rustc_borrowck/src/nll.rs+18-20| ... | ... | @@ -1,11 +1,18 @@ |
| 1 | 1 | //! The entry point of the NLL borrow checker. |
| 2 | 2 | |
| 3 | use std::path::PathBuf; | |
| 4 | use std::rc::Rc; | |
| 5 | use std::str::FromStr; | |
| 6 | use std::{env, io}; | |
| 7 | ||
| 3 | 8 | use polonius_engine::{Algorithm, Output}; |
| 4 | 9 | use rustc_data_structures::fx::FxIndexMap; |
| 5 | 10 | use rustc_hir::def_id::LocalDefId; |
| 6 | 11 | use rustc_index::IndexSlice; |
| 7 | use rustc_middle::mir::{create_dump_file, dump_enabled, dump_mir, PassWhere}; | |
| 8 | use rustc_middle::mir::{Body, ClosureOutlivesSubject, ClosureRegionRequirements, Promoted}; | |
| 12 | use rustc_middle::mir::{ | |
| 13 | create_dump_file, dump_enabled, dump_mir, Body, ClosureOutlivesSubject, | |
| 14 | ClosureRegionRequirements, PassWhere, Promoted, | |
| 15 | }; | |
| 9 | 16 | use rustc_middle::ty::print::with_no_trimmed_paths; |
| 10 | 17 | use rustc_middle::ty::{self, OpaqueHiddenType, TyCtxt}; |
| 11 | 18 | use rustc_mir_dataflow::impls::MaybeInitializedPlaces; |
| ... | ... | @@ -13,25 +20,16 @@ use rustc_mir_dataflow::move_paths::MoveData; |
| 13 | 20 | use rustc_mir_dataflow::points::DenseLocationMap; |
| 14 | 21 | use rustc_mir_dataflow::ResultsCursor; |
| 15 | 22 | use rustc_span::symbol::sym; |
| 16 | use std::env; | |
| 17 | use std::io; | |
| 18 | use std::path::PathBuf; | |
| 19 | use std::rc::Rc; | |
| 20 | use std::str::FromStr; | |
| 21 | 23 | |
| 22 | use crate::{ | |
| 23 | borrow_set::BorrowSet, | |
| 24 | consumers::ConsumerOptions, | |
| 25 | diagnostics::RegionErrors, | |
| 26 | facts::{AllFacts, AllFactsExt, RustcFacts}, | |
| 27 | location::LocationTable, | |
| 28 | polonius, | |
| 29 | region_infer::RegionInferenceContext, | |
| 30 | renumber, | |
| 31 | type_check::{self, MirTypeckRegionConstraints, MirTypeckResults}, | |
| 32 | universal_regions::UniversalRegions, | |
| 33 | BorrowckInferCtxt, | |
| 34 | }; | |
| 24 | use crate::borrow_set::BorrowSet; | |
| 25 | use crate::consumers::ConsumerOptions; | |
| 26 | use crate::diagnostics::RegionErrors; | |
| 27 | use crate::facts::{AllFacts, AllFactsExt, RustcFacts}; | |
| 28 | use crate::location::LocationTable; | |
| 29 | use crate::region_infer::RegionInferenceContext; | |
| 30 | use crate::type_check::{self, MirTypeckRegionConstraints, MirTypeckResults}; | |
| 31 | use crate::universal_regions::UniversalRegions; | |
| 32 | use crate::{polonius, renumber, BorrowckInferCtxt}; | |
| 35 | 33 | |
| 36 | 34 | pub type PoloniusOutput = Output<RustcFacts>; |
| 37 | 35 |
compiler/rustc_borrowck/src/path_utils.rs+4-6| ... | ... | @@ -1,13 +1,11 @@ |
| 1 | use crate::borrow_set::{BorrowData, BorrowSet, TwoPhaseActivation}; | |
| 2 | use crate::places_conflict; | |
| 3 | use crate::AccessDepth; | |
| 4 | use crate::BorrowIndex; | |
| 5 | 1 | use rustc_data_structures::graph::dominators::Dominators; |
| 6 | use rustc_middle::mir::BorrowKind; | |
| 7 | use rustc_middle::mir::{BasicBlock, Body, Location, Place, PlaceRef, ProjectionElem}; | |
| 2 | use rustc_middle::mir::{BasicBlock, Body, BorrowKind, Location, Place, PlaceRef, ProjectionElem}; | |
| 8 | 3 | use rustc_middle::ty::TyCtxt; |
| 9 | 4 | use rustc_target::abi::FieldIdx; |
| 10 | 5 | |
| 6 | use crate::borrow_set::{BorrowData, BorrowSet, TwoPhaseActivation}; | |
| 7 | use crate::{places_conflict, AccessDepth, BorrowIndex}; | |
| 8 | ||
| 11 | 9 | /// Returns `true` if the borrow represented by `kind` is |
| 12 | 10 | /// allowed to be split into separate Reservation and |
| 13 | 11 | /// Activation phases. |
compiler/rustc_borrowck/src/place_ext.rs+3-3| ... | ... | @@ -1,10 +1,10 @@ |
| 1 | use crate::borrow_set::LocalsStateAtExit; | |
| 2 | 1 | use rustc_hir as hir; |
| 3 | 2 | use rustc_macros::extension; |
| 4 | use rustc_middle::mir::ProjectionElem; | |
| 5 | use rustc_middle::mir::{Body, Mutability, Place}; | |
| 3 | use rustc_middle::mir::{Body, Mutability, Place, ProjectionElem}; | |
| 6 | 4 | use rustc_middle::ty::{self, TyCtxt}; |
| 7 | 5 | |
| 6 | use crate::borrow_set::LocalsStateAtExit; | |
| 7 | ||
| 8 | 8 | #[extension(pub trait PlaceExt<'tcx>)] |
| 9 | 9 | impl<'tcx> Place<'tcx> { |
| 10 | 10 | /// Returns `true` if we can safely ignore borrows of this place. |
compiler/rustc_borrowck/src/places_conflict.rs+5-5| ... | ... | @@ -50,17 +50,17 @@ |
| 50 | 50 | //! and either equal or disjoint. |
| 51 | 51 | //! - If we did run out of access, the borrow can access a part of it. |
| 52 | 52 | |
| 53 | use crate::ArtificialField; | |
| 54 | use crate::Overlap; | |
| 55 | use crate::{AccessDepth, Deep, Shallow}; | |
| 53 | use std::cmp::max; | |
| 54 | use std::iter; | |
| 55 | ||
| 56 | 56 | use rustc_hir as hir; |
| 57 | 57 | use rustc_middle::bug; |
| 58 | 58 | use rustc_middle::mir::{ |
| 59 | 59 | Body, BorrowKind, FakeBorrowKind, MutBorrowKind, Place, PlaceElem, PlaceRef, ProjectionElem, |
| 60 | 60 | }; |
| 61 | 61 | use rustc_middle::ty::{self, TyCtxt}; |
| 62 | use std::cmp::max; | |
| 63 | use std::iter; | |
| 62 | ||
| 63 | use crate::{AccessDepth, ArtificialField, Deep, Overlap, Shallow}; | |
| 64 | 64 | |
| 65 | 65 | /// When checking if a place conflicts with another place, this enum is used to influence decisions |
| 66 | 66 | /// where a place might be equal or disjoint with another place, such as if `a[i] == a[j]`. |
compiler/rustc_borrowck/src/polonius/loan_invalidations.rs+9-7| ... | ... | @@ -2,17 +2,19 @@ use rustc_data_structures::graph::dominators::Dominators; |
| 2 | 2 | use rustc_middle::bug; |
| 3 | 3 | use rustc_middle::mir::visit::Visitor; |
| 4 | 4 | use rustc_middle::mir::{ |
| 5 | self, BasicBlock, Body, FakeBorrowKind, Location, NonDivergingIntrinsic, Place, Rvalue, | |
| 5 | self, BasicBlock, Body, BorrowKind, FakeBorrowKind, InlineAsmOperand, Location, Mutability, | |
| 6 | NonDivergingIntrinsic, Operand, Place, Rvalue, Statement, StatementKind, Terminator, | |
| 7 | TerminatorKind, | |
| 6 | 8 | }; |
| 7 | use rustc_middle::mir::{BorrowKind, Mutability, Operand}; | |
| 8 | use rustc_middle::mir::{InlineAsmOperand, Terminator, TerminatorKind}; | |
| 9 | use rustc_middle::mir::{Statement, StatementKind}; | |
| 10 | 9 | use rustc_middle::ty::TyCtxt; |
| 11 | 10 | |
| 11 | use crate::borrow_set::BorrowSet; | |
| 12 | use crate::facts::AllFacts; | |
| 13 | use crate::location::LocationTable; | |
| 14 | use crate::path_utils::*; | |
| 12 | 15 | use crate::{ |
| 13 | borrow_set::BorrowSet, facts::AllFacts, location::LocationTable, path_utils::*, AccessDepth, | |
| 14 | Activation, ArtificialField, BorrowIndex, Deep, LocalMutationIsAllowed, Read, ReadKind, | |
| 15 | ReadOrWrite, Reservation, Shallow, Write, WriteKind, | |
| 16 | AccessDepth, Activation, ArtificialField, BorrowIndex, Deep, LocalMutationIsAllowed, Read, | |
| 17 | ReadKind, ReadOrWrite, Reservation, Shallow, Write, WriteKind, | |
| 16 | 18 | }; |
| 17 | 19 | |
| 18 | 20 | /// Emit `loan_invalidated_at` facts. |
compiler/rustc_borrowck/src/polonius/loan_kills.rs+4-1| ... | ... | @@ -5,7 +5,10 @@ use rustc_middle::mir::{ |
| 5 | 5 | }; |
| 6 | 6 | use rustc_middle::ty::TyCtxt; |
| 7 | 7 | |
| 8 | use crate::{borrow_set::BorrowSet, facts::AllFacts, location::LocationTable, places_conflict}; | |
| 8 | use crate::borrow_set::BorrowSet; | |
| 9 | use crate::facts::AllFacts; | |
| 10 | use crate::location::LocationTable; | |
| 11 | use crate::places_conflict; | |
| 9 | 12 | |
| 10 | 13 | /// Emit `loan_killed_at` and `cfg_edge` facts at the same time. |
| 11 | 14 | pub(super) fn emit_loan_kills<'tcx>( |
compiler/rustc_borrowck/src/prefixes.rs+2-2| ... | ... | @@ -4,10 +4,10 @@ |
| 4 | 4 | //! is borrowed. But: writing `a` is legal if `*a` is borrowed, |
| 5 | 5 | //! whether or not `a` is a shared or mutable reference. [...] " |
| 6 | 6 | |
| 7 | use super::MirBorrowckCtxt; | |
| 8 | ||
| 9 | 7 | use rustc_middle::mir::{PlaceRef, ProjectionElem}; |
| 10 | 8 | |
| 9 | use super::MirBorrowckCtxt; | |
| 10 | ||
| 11 | 11 | pub trait IsPrefixOf<'tcx> { |
| 12 | 12 | fn is_prefix_of(&self, other: PlaceRef<'tcx>) -> bool; |
| 13 | 13 | } |
compiler/rustc_borrowck/src/region_infer/dump_mir.rs+5-3| ... | ... | @@ -3,11 +3,13 @@ |
| 3 | 3 | //! state of region inference. This code handles emitting the region |
| 4 | 4 | //! context internal state. |
| 5 | 5 | |
| 6 | use super::{OutlivesConstraint, RegionInferenceContext}; | |
| 7 | use crate::type_check::Locations; | |
| 6 | use std::io::{self, Write}; | |
| 7 | ||
| 8 | 8 | use rustc_infer::infer::NllRegionVariableOrigin; |
| 9 | 9 | use rustc_middle::ty::TyCtxt; |
| 10 | use std::io::{self, Write}; | |
| 10 | ||
| 11 | use super::{OutlivesConstraint, RegionInferenceContext}; | |
| 12 | use crate::type_check::Locations; | |
| 11 | 13 | |
| 12 | 14 | // Room for "'_#NNNNr" before things get misaligned. |
| 13 | 15 | // Easy enough to fix if this ever doesn't seem like |
compiler/rustc_borrowck/src/region_infer/graphviz.rs+2-1| ... | ... | @@ -5,11 +5,12 @@ |
| 5 | 5 | use std::borrow::Cow; |
| 6 | 6 | use std::io::{self, Write}; |
| 7 | 7 | |
| 8 | use super::*; | |
| 9 | 8 | use itertools::Itertools; |
| 10 | 9 | use rustc_graphviz as dot; |
| 11 | 10 | use rustc_middle::ty::UniverseIndex; |
| 12 | 11 | |
| 12 | use super::*; | |
| 13 | ||
| 13 | 14 | fn render_outlives_constraint(constraint: &OutlivesConstraint<'_>) -> String { |
| 14 | 15 | match constraint.locations { |
| 15 | 16 | Locations::All(_) => "All(...)".to_string(), |
compiler/rustc_borrowck/src/region_infer/mod.rs+12-14| ... | ... | @@ -17,27 +17,25 @@ use rustc_middle::mir::{ |
| 17 | 17 | ClosureRegionRequirements, ConstraintCategory, Local, Location, ReturnConstraint, |
| 18 | 18 | TerminatorKind, |
| 19 | 19 | }; |
| 20 | use rustc_middle::traits::ObligationCause; | |
| 21 | use rustc_middle::traits::ObligationCauseCode; | |
| 20 | use rustc_middle::traits::{ObligationCause, ObligationCauseCode}; | |
| 22 | 21 | use rustc_middle::ty::{self, RegionVid, Ty, TyCtxt, TypeFoldable, UniverseIndex}; |
| 23 | 22 | use rustc_mir_dataflow::points::DenseLocationMap; |
| 24 | 23 | use rustc_span::Span; |
| 25 | 24 | |
| 26 | 25 | use crate::constraints::graph::{self, NormalConstraintGraph, RegionGraph}; |
| 26 | use crate::constraints::{ConstraintSccIndex, OutlivesConstraint, OutlivesConstraintSet}; | |
| 27 | 27 | use crate::dataflow::BorrowIndex; |
| 28 | use crate::{ | |
| 29 | constraints::{ConstraintSccIndex, OutlivesConstraint, OutlivesConstraintSet}, | |
| 30 | diagnostics::{RegionErrorKind, RegionErrors, UniverseInfo}, | |
| 31 | member_constraints::{MemberConstraintSet, NllMemberConstraintIndex}, | |
| 32 | nll::PoloniusOutput, | |
| 33 | region_infer::reverse_sccs::ReverseSccGraph, | |
| 34 | region_infer::values::{ | |
| 35 | LivenessValues, PlaceholderIndices, RegionElement, RegionValues, ToElementIndex, | |
| 36 | }, | |
| 37 | type_check::{free_region_relations::UniversalRegionRelations, Locations}, | |
| 38 | universal_regions::UniversalRegions, | |
| 39 | BorrowckInferCtxt, | |
| 28 | use crate::diagnostics::{RegionErrorKind, RegionErrors, UniverseInfo}; | |
| 29 | use crate::member_constraints::{MemberConstraintSet, NllMemberConstraintIndex}; | |
| 30 | use crate::nll::PoloniusOutput; | |
| 31 | use crate::region_infer::reverse_sccs::ReverseSccGraph; | |
| 32 | use crate::region_infer::values::{ | |
| 33 | LivenessValues, PlaceholderIndices, RegionElement, RegionValues, ToElementIndex, | |
| 40 | 34 | }; |
| 35 | use crate::type_check::free_region_relations::UniversalRegionRelations; | |
| 36 | use crate::type_check::Locations; | |
| 37 | use crate::universal_regions::UniversalRegions; | |
| 38 | use crate::BorrowckInferCtxt; | |
| 41 | 39 | |
| 42 | 40 | mod dump_mir; |
| 43 | 41 | mod graphviz; |
compiler/rustc_borrowck/src/region_infer/opaque_types.rs+6-8| ... | ... | @@ -3,22 +3,20 @@ use rustc_errors::ErrorGuaranteed; |
| 3 | 3 | use rustc_hir::def::DefKind; |
| 4 | 4 | use rustc_hir::def_id::LocalDefId; |
| 5 | 5 | use rustc_hir::OpaqueTyOrigin; |
| 6 | use rustc_infer::infer::TyCtxtInferExt as _; | |
| 7 | use rustc_infer::infer::{InferCtxt, NllRegionVariableOrigin}; | |
| 6 | use rustc_infer::infer::{InferCtxt, NllRegionVariableOrigin, TyCtxtInferExt as _}; | |
| 8 | 7 | use rustc_infer::traits::{Obligation, ObligationCause}; |
| 9 | 8 | use rustc_macros::extension; |
| 10 | 9 | use rustc_middle::ty::visit::TypeVisitableExt; |
| 11 | use rustc_middle::ty::{self, OpaqueHiddenType, OpaqueTypeKey, Ty, TyCtxt, TypeFoldable}; | |
| 12 | use rustc_middle::ty::{GenericArgKind, GenericArgs}; | |
| 10 | use rustc_middle::ty::{ | |
| 11 | self, GenericArgKind, GenericArgs, OpaqueHiddenType, OpaqueTypeKey, Ty, TyCtxt, TypeFoldable, | |
| 12 | }; | |
| 13 | 13 | use rustc_span::Span; |
| 14 | 14 | use rustc_trait_selection::error_reporting::InferCtxtErrorExt; |
| 15 | 15 | use rustc_trait_selection::traits::ObligationCtxt; |
| 16 | 16 | |
| 17 | use crate::session_diagnostics::LifetimeMismatchOpaqueParam; | |
| 18 | use crate::session_diagnostics::NonGenericOpaqueTypeParam; | |
| 19 | use crate::universal_regions::RegionClassification; | |
| 20 | ||
| 21 | 17 | use super::RegionInferenceContext; |
| 18 | use crate::session_diagnostics::{LifetimeMismatchOpaqueParam, NonGenericOpaqueTypeParam}; | |
| 19 | use crate::universal_regions::RegionClassification; | |
| 22 | 20 | |
| 23 | 21 | impl<'tcx> RegionInferenceContext<'tcx> { |
| 24 | 22 | /// Resolve any opaque types that were encountered while borrow checking |
compiler/rustc_borrowck/src/region_infer/reverse_sccs.rs+5-3| ... | ... | @@ -1,10 +1,12 @@ |
| 1 | use crate::constraints::ConstraintSccIndex; | |
| 2 | use crate::RegionInferenceContext; | |
| 1 | use std::ops::Range; | |
| 2 | ||
| 3 | 3 | use rustc_data_structures::fx::{FxIndexMap, FxIndexSet}; |
| 4 | 4 | use rustc_data_structures::graph; |
| 5 | 5 | use rustc_data_structures::graph::vec_graph::VecGraph; |
| 6 | 6 | use rustc_middle::ty::RegionVid; |
| 7 | use std::ops::Range; | |
| 7 | ||
| 8 | use crate::constraints::ConstraintSccIndex; | |
| 9 | use crate::RegionInferenceContext; | |
| 8 | 10 | |
| 9 | 11 | pub(crate) struct ReverseSccGraph { |
| 10 | 12 | graph: VecGraph<ConstraintSccIndex>, |
compiler/rustc_borrowck/src/region_infer/values.rs+5-6| ... | ... | @@ -1,14 +1,13 @@ |
| 1 | use rustc_data_structures::fx::FxHashSet; | |
| 2 | use rustc_data_structures::fx::FxIndexSet; | |
| 1 | use std::fmt::Debug; | |
| 2 | use std::rc::Rc; | |
| 3 | ||
| 4 | use rustc_data_structures::fx::{FxHashSet, FxIndexSet}; | |
| 3 | 5 | use rustc_index::bit_set::SparseBitMatrix; |
| 4 | use rustc_index::interval::IntervalSet; | |
| 5 | use rustc_index::interval::SparseIntervalMatrix; | |
| 6 | use rustc_index::interval::{IntervalSet, SparseIntervalMatrix}; | |
| 6 | 7 | use rustc_index::Idx; |
| 7 | 8 | use rustc_middle::mir::{BasicBlock, Location}; |
| 8 | 9 | use rustc_middle::ty::{self, RegionVid}; |
| 9 | 10 | use rustc_mir_dataflow::points::{DenseLocationMap, PointIndex}; |
| 10 | use std::fmt::Debug; | |
| 11 | use std::rc::Rc; | |
| 12 | 11 | |
| 13 | 12 | use crate::BorrowIndex; |
| 14 | 13 |
compiler/rustc_borrowck/src/renumber.rs+3-3| ... | ... | @@ -1,12 +1,12 @@ |
| 1 | use crate::BorrowckInferCtxt; | |
| 2 | 1 | use rustc_index::IndexSlice; |
| 3 | 2 | use rustc_infer::infer::NllRegionVariableOrigin; |
| 4 | 3 | use rustc_middle::mir::visit::{MutVisitor, TyContext}; |
| 5 | 4 | use rustc_middle::mir::{Body, ConstOperand, Location, Promoted}; |
| 6 | use rustc_middle::ty::GenericArgsRef; | |
| 7 | use rustc_middle::ty::{self, Ty, TyCtxt, TypeFoldable}; | |
| 5 | use rustc_middle::ty::{self, GenericArgsRef, Ty, TyCtxt, TypeFoldable}; | |
| 8 | 6 | use rustc_span::Symbol; |
| 9 | 7 | |
| 8 | use crate::BorrowckInferCtxt; | |
| 9 | ||
| 10 | 10 | /// Replaces all free regions appearing in the MIR with fresh |
| 11 | 11 | /// inference variables, returning the number of variables created. |
| 12 | 12 | #[instrument(skip(infcx, body, promoted), level = "debug")] |
compiler/rustc_borrowck/src/session_diagnostics.rs+2-1| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | use rustc_errors::{codes::*, MultiSpan}; | |
| 1 | use rustc_errors::codes::*; | |
| 2 | use rustc_errors::MultiSpan; | |
| 2 | 3 | use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic}; |
| 3 | 4 | use rustc_middle::ty::{GenericArg, Ty}; |
| 4 | 5 | use rustc_span::Span; |
compiler/rustc_borrowck/src/type_check/canonical.rs+1-2| ... | ... | @@ -10,9 +10,8 @@ use rustc_span::Span; |
| 10 | 10 | use rustc_trait_selection::traits::query::type_op::{self, TypeOpOutput}; |
| 11 | 11 | use rustc_trait_selection::traits::ObligationCause; |
| 12 | 12 | |
| 13 | use crate::diagnostics::ToUniverseInfo; | |
| 14 | ||
| 15 | 13 | use super::{Locations, NormalizeLocation, TypeChecker}; |
| 14 | use crate::diagnostics::ToUniverseInfo; | |
| 16 | 15 | |
| 17 | 16 | impl<'a, 'tcx> TypeChecker<'a, 'tcx> { |
| 18 | 17 | /// Given some operation `op` that manipulates types, proves |
compiler/rustc_borrowck/src/type_check/constraint_conversion.rs+4-6| ... | ... | @@ -14,12 +14,10 @@ use rustc_trait_selection::traits::query::type_op::custom::CustomTypeOp; |
| 14 | 14 | use rustc_trait_selection::traits::query::type_op::{TypeOp, TypeOpOutput}; |
| 15 | 15 | use rustc_trait_selection::traits::ScrubbedTraitError; |
| 16 | 16 | |
| 17 | use crate::{ | |
| 18 | constraints::OutlivesConstraint, | |
| 19 | region_infer::TypeTest, | |
| 20 | type_check::{Locations, MirTypeckRegionConstraints}, | |
| 21 | universal_regions::UniversalRegions, | |
| 22 | }; | |
| 17 | use crate::constraints::OutlivesConstraint; | |
| 18 | use crate::region_infer::TypeTest; | |
| 19 | use crate::type_check::{Locations, MirTypeckRegionConstraints}; | |
| 20 | use crate::universal_regions::UniversalRegions; | |
| 23 | 21 | |
| 24 | 22 | pub(crate) struct ConstraintConversion<'a, 'tcx> { |
| 25 | 23 | infcx: &'a InferCtxt<'tcx>, |
compiler/rustc_borrowck/src/type_check/free_region_relations.rs+5-8| ... | ... | @@ -1,11 +1,12 @@ |
| 1 | use std::rc::Rc; | |
| 2 | ||
| 1 | 3 | use rustc_data_structures::frozen::Frozen; |
| 2 | 4 | use rustc_data_structures::transitive_relation::{TransitiveRelation, TransitiveRelationBuilder}; |
| 3 | 5 | use rustc_hir::def::DefKind; |
| 4 | 6 | use rustc_infer::infer::canonical::QueryRegionConstraints; |
| 5 | use rustc_infer::infer::outlives; | |
| 6 | 7 | use rustc_infer::infer::outlives::env::RegionBoundPairs; |
| 7 | 8 | use rustc_infer::infer::region_constraints::GenericKind; |
| 8 | use rustc_infer::infer::InferCtxt; | |
| 9 | use rustc_infer::infer::{outlives, InferCtxt}; | |
| 9 | 10 | use rustc_middle::mir::ConstraintCategory; |
| 10 | 11 | use rustc_middle::traits::query::OutlivesBound; |
| 11 | 12 | use rustc_middle::traits::ObligationCause; |
| ... | ... | @@ -14,14 +15,10 @@ use rustc_span::{ErrorGuaranteed, Span}; |
| 14 | 15 | use rustc_trait_selection::error_reporting::InferCtxtErrorExt; |
| 15 | 16 | use rustc_trait_selection::solve::deeply_normalize; |
| 16 | 17 | use rustc_trait_selection::traits::query::type_op::{self, TypeOp}; |
| 17 | use std::rc::Rc; | |
| 18 | 18 | use type_op::TypeOpOutput; |
| 19 | 19 | |
| 20 | use crate::{ | |
| 21 | type_check::constraint_conversion, | |
| 22 | type_check::{Locations, MirTypeckRegionConstraints}, | |
| 23 | universal_regions::UniversalRegions, | |
| 24 | }; | |
| 20 | use crate::type_check::{constraint_conversion, Locations, MirTypeckRegionConstraints}; | |
| 21 | use crate::universal_regions::UniversalRegions; | |
| 25 | 22 | |
| 26 | 23 | #[derive(Debug)] |
| 27 | 24 | pub(crate) struct UniversalRegionRelations<'tcx> { |
compiler/rustc_borrowck/src/type_check/input_output.rs+1-2| ... | ... | @@ -16,11 +16,10 @@ use rustc_middle::mir::*; |
| 16 | 16 | use rustc_middle::ty::{self, Ty}; |
| 17 | 17 | use rustc_span::Span; |
| 18 | 18 | |
| 19 | use super::{Locations, TypeChecker}; | |
| 19 | 20 | use crate::renumber::RegionCtxt; |
| 20 | 21 | use crate::universal_regions::{DefiningTy, UniversalRegions}; |
| 21 | 22 | |
| 22 | use super::{Locations, TypeChecker}; | |
| 23 | ||
| 24 | 23 | impl<'a, 'tcx> TypeChecker<'a, 'tcx> { |
| 25 | 24 | /// Check explicit closure signature annotation, |
| 26 | 25 | /// e.g., `|x: FxIndexMap<_, &'static u32>| ...`. |
compiler/rustc_borrowck/src/type_check/liveness/mod.rs+5-6| ... | ... | @@ -1,3 +1,5 @@ |
| 1 | use std::rc::Rc; | |
| 2 | ||
| 1 | 3 | use itertools::{Either, Itertools}; |
| 2 | 4 | use rustc_data_structures::fx::FxHashSet; |
| 3 | 5 | use rustc_middle::mir::visit::{TyContext, Visitor}; |
| ... | ... | @@ -9,14 +11,11 @@ use rustc_mir_dataflow::impls::MaybeInitializedPlaces; |
| 9 | 11 | use rustc_mir_dataflow::move_paths::MoveData; |
| 10 | 12 | use rustc_mir_dataflow::points::DenseLocationMap; |
| 11 | 13 | use rustc_mir_dataflow::ResultsCursor; |
| 12 | use std::rc::Rc; | |
| 13 | ||
| 14 | use crate::{ | |
| 15 | constraints::OutlivesConstraintSet, region_infer::values::LivenessValues, | |
| 16 | universal_regions::UniversalRegions, | |
| 17 | }; | |
| 18 | 14 | |
| 19 | 15 | use super::TypeChecker; |
| 16 | use crate::constraints::OutlivesConstraintSet; | |
| 17 | use crate::region_infer::values::LivenessValues; | |
| 18 | use crate::universal_regions::UniversalRegions; | |
| 20 | 19 | |
| 21 | 20 | mod local_use_map; |
| 22 | 21 | mod polonius; |
compiler/rustc_borrowck/src/type_check/liveness/polonius.rs+2-2| ... | ... | @@ -1,11 +1,11 @@ |
| 1 | use crate::def_use::{self, DefUse}; | |
| 2 | use crate::location::{LocationIndex, LocationTable}; | |
| 3 | 1 | use rustc_middle::mir::visit::{MutatingUseContext, PlaceContext, Visitor}; |
| 4 | 2 | use rustc_middle::mir::{Body, Local, Location, Place}; |
| 5 | 3 | use rustc_middle::ty::GenericArg; |
| 6 | 4 | use rustc_mir_dataflow::move_paths::{LookupResult, MoveData, MovePathIndex}; |
| 7 | 5 | |
| 8 | 6 | use super::TypeChecker; |
| 7 | use crate::def_use::{self, DefUse}; | |
| 8 | use crate::location::{LocationIndex, LocationTable}; | |
| 9 | 9 | |
| 10 | 10 | type VarPointRelation = Vec<(Local, LocationIndex)>; |
| 11 | 11 | type PathPointRelation = Vec<(MovePathIndex, LocationIndex)>; |
compiler/rustc_borrowck/src/type_check/liveness/trace.rs+9-12| ... | ... | @@ -1,3 +1,5 @@ |
| 1 | use std::rc::Rc; | |
| 2 | ||
| 1 | 3 | use rustc_data_structures::fx::{FxIndexMap, FxIndexSet}; |
| 2 | 4 | use rustc_index::bit_set::BitSet; |
| 3 | 5 | use rustc_index::interval::IntervalSet; |
| ... | ... | @@ -6,24 +8,19 @@ use rustc_infer::infer::outlives::for_liveness; |
| 6 | 8 | use rustc_middle::mir::{BasicBlock, Body, ConstraintCategory, Local, Location}; |
| 7 | 9 | use rustc_middle::traits::query::DropckOutlivesResult; |
| 8 | 10 | use rustc_middle::ty::{Ty, TyCtxt, TypeVisitable, TypeVisitableExt}; |
| 11 | use rustc_mir_dataflow::impls::MaybeInitializedPlaces; | |
| 12 | use rustc_mir_dataflow::move_paths::{HasMoveData, MoveData, MovePathIndex}; | |
| 9 | 13 | use rustc_mir_dataflow::points::{DenseLocationMap, PointIndex}; |
| 14 | use rustc_mir_dataflow::ResultsCursor; | |
| 10 | 15 | use rustc_span::DUMMY_SP; |
| 11 | 16 | use rustc_trait_selection::traits::query::type_op::outlives::DropckOutlives; |
| 12 | 17 | use rustc_trait_selection::traits::query::type_op::{TypeOp, TypeOpOutput}; |
| 13 | use std::rc::Rc; | |
| 14 | ||
| 15 | use rustc_mir_dataflow::impls::MaybeInitializedPlaces; | |
| 16 | use rustc_mir_dataflow::move_paths::{HasMoveData, MoveData, MovePathIndex}; | |
| 17 | use rustc_mir_dataflow::ResultsCursor; | |
| 18 | 18 | |
| 19 | 19 | use crate::location::RichLocation; |
| 20 | use crate::{ | |
| 21 | region_infer::values::{self, LiveLoans}, | |
| 22 | type_check::liveness::local_use_map::LocalUseMap, | |
| 23 | type_check::liveness::polonius, | |
| 24 | type_check::NormalizeLocation, | |
| 25 | type_check::TypeChecker, | |
| 26 | }; | |
| 20 | use crate::region_infer::values::{self, LiveLoans}; | |
| 21 | use crate::type_check::liveness::local_use_map::LocalUseMap; | |
| 22 | use crate::type_check::liveness::polonius; | |
| 23 | use crate::type_check::{NormalizeLocation, TypeChecker}; | |
| 27 | 24 | |
| 28 | 25 | /// This is the heart of the liveness computation. For each variable X |
| 29 | 26 | /// that requires a liveness computation, it walks over all the uses |
compiler/rustc_borrowck/src/type_check/mod.rs+20-27| ... | ... | @@ -4,7 +4,6 @@ use std::rc::Rc; |
| 4 | 4 | use std::{fmt, iter, mem}; |
| 5 | 5 | |
| 6 | 6 | use either::Either; |
| 7 | ||
| 8 | 7 | use rustc_data_structures::frozen::Frozen; |
| 9 | 8 | use rustc_data_structures::fx::{FxIndexMap, FxIndexSet}; |
| 10 | 9 | use rustc_errors::ErrorGuaranteed; |
| ... | ... | @@ -28,44 +27,38 @@ use rustc_middle::ty::cast::CastTy; |
| 28 | 27 | use rustc_middle::ty::visit::TypeVisitableExt; |
| 29 | 28 | use rustc_middle::ty::{ |
| 30 | 29 | self, Binder, CanonicalUserTypeAnnotation, CanonicalUserTypeAnnotations, CoroutineArgsExt, |
| 31 | Dynamic, OpaqueHiddenType, OpaqueTypeKey, RegionVid, Ty, TyCtxt, UserType, | |
| 32 | UserTypeAnnotationIndex, | |
| 30 | Dynamic, GenericArgsRef, OpaqueHiddenType, OpaqueTypeKey, RegionVid, Ty, TyCtxt, UserArgs, | |
| 31 | UserType, UserTypeAnnotationIndex, | |
| 33 | 32 | }; |
| 34 | use rustc_middle::ty::{GenericArgsRef, UserArgs}; | |
| 35 | 33 | use rustc_middle::{bug, span_bug}; |
| 34 | use rustc_mir_dataflow::impls::MaybeInitializedPlaces; | |
| 35 | use rustc_mir_dataflow::move_paths::MoveData; | |
| 36 | 36 | use rustc_mir_dataflow::points::DenseLocationMap; |
| 37 | use rustc_mir_dataflow::ResultsCursor; | |
| 37 | 38 | use rustc_span::def_id::CRATE_DEF_ID; |
| 38 | 39 | use rustc_span::source_map::Spanned; |
| 39 | 40 | use rustc_span::symbol::sym; |
| 40 | use rustc_span::Span; | |
| 41 | use rustc_span::DUMMY_SP; | |
| 41 | use rustc_span::{Span, DUMMY_SP}; | |
| 42 | 42 | use rustc_target::abi::{FieldIdx, FIRST_VARIANT}; |
| 43 | use rustc_trait_selection::traits::query::type_op::custom::scrape_region_constraints; | |
| 44 | use rustc_trait_selection::traits::query::type_op::custom::CustomTypeOp; | |
| 43 | use rustc_trait_selection::traits::query::type_op::custom::{ | |
| 44 | scrape_region_constraints, CustomTypeOp, | |
| 45 | }; | |
| 45 | 46 | use rustc_trait_selection::traits::query::type_op::{TypeOp, TypeOpOutput}; |
| 46 | ||
| 47 | 47 | use rustc_trait_selection::traits::PredicateObligation; |
| 48 | 48 | |
| 49 | use rustc_mir_dataflow::impls::MaybeInitializedPlaces; | |
| 50 | use rustc_mir_dataflow::move_paths::MoveData; | |
| 51 | use rustc_mir_dataflow::ResultsCursor; | |
| 52 | ||
| 49 | use crate::borrow_set::BorrowSet; | |
| 50 | use crate::constraints::{OutlivesConstraint, OutlivesConstraintSet}; | |
| 51 | use crate::diagnostics::UniverseInfo; | |
| 52 | use crate::facts::AllFacts; | |
| 53 | use crate::location::LocationTable; | |
| 54 | use crate::member_constraints::MemberConstraintSet; | |
| 55 | use crate::region_infer::values::{LivenessValues, PlaceholderIndex, PlaceholderIndices}; | |
| 56 | use crate::region_infer::TypeTest; | |
| 53 | 57 | use crate::renumber::RegionCtxt; |
| 54 | 58 | use crate::session_diagnostics::{MoveUnsized, SimdIntrinsicArgConst}; |
| 55 | use crate::{ | |
| 56 | borrow_set::BorrowSet, | |
| 57 | constraints::{OutlivesConstraint, OutlivesConstraintSet}, | |
| 58 | diagnostics::UniverseInfo, | |
| 59 | facts::AllFacts, | |
| 60 | location::LocationTable, | |
| 61 | member_constraints::MemberConstraintSet, | |
| 62 | path_utils, | |
| 63 | region_infer::values::{LivenessValues, PlaceholderIndex, PlaceholderIndices}, | |
| 64 | region_infer::TypeTest, | |
| 65 | type_check::free_region_relations::{CreateResult, UniversalRegionRelations}, | |
| 66 | universal_regions::{DefiningTy, UniversalRegions}, | |
| 67 | BorrowckInferCtxt, | |
| 68 | }; | |
| 59 | use crate::type_check::free_region_relations::{CreateResult, UniversalRegionRelations}; | |
| 60 | use crate::universal_regions::{DefiningTy, UniversalRegions}; | |
| 61 | use crate::{path_utils, BorrowckInferCtxt}; | |
| 69 | 62 | |
| 70 | 63 | macro_rules! span_mirbug { |
| 71 | 64 | ($context:expr, $elem:expr, $($message:tt)*) => ({ |
compiler/rustc_borrowck/src/universal_regions.rs+6-4| ... | ... | @@ -15,6 +15,9 @@ |
| 15 | 15 | #![allow(rustc::diagnostic_outside_of_impl)] |
| 16 | 16 | #![allow(rustc::untranslatable_diagnostic)] |
| 17 | 17 | |
| 18 | use std::cell::Cell; | |
| 19 | use std::iter; | |
| 20 | ||
| 18 | 21 | use rustc_data_structures::fx::FxIndexMap; |
| 19 | 22 | use rustc_errors::Diag; |
| 20 | 23 | use rustc_hir::def_id::{DefId, LocalDefId}; |
| ... | ... | @@ -25,13 +28,12 @@ use rustc_infer::infer::NllRegionVariableOrigin; |
| 25 | 28 | use rustc_macros::extension; |
| 26 | 29 | use rustc_middle::ty::fold::TypeFoldable; |
| 27 | 30 | use rustc_middle::ty::print::with_no_trimmed_paths; |
| 28 | use rustc_middle::ty::{self, InlineConstArgs, InlineConstArgsParts, RegionVid, Ty, TyCtxt}; | |
| 29 | use rustc_middle::ty::{GenericArgs, GenericArgsRef}; | |
| 31 | use rustc_middle::ty::{ | |
| 32 | self, GenericArgs, GenericArgsRef, InlineConstArgs, InlineConstArgsParts, RegionVid, Ty, TyCtxt, | |
| 33 | }; | |
| 30 | 34 | use rustc_middle::{bug, span_bug}; |
| 31 | 35 | use rustc_span::symbol::{kw, sym}; |
| 32 | 36 | use rustc_span::{ErrorGuaranteed, Symbol}; |
| 33 | use std::cell::Cell; | |
| 34 | use std::iter; | |
| 35 | 37 | |
| 36 | 38 | use crate::renumber::RegionCtxt; |
| 37 | 39 | use crate::BorrowckInferCtxt; |
compiler/rustc_borrowck/src/util/collect_writes.rs+1-2| ... | ... | @@ -1,5 +1,4 @@ |
| 1 | use rustc_middle::mir::visit::PlaceContext; | |
| 2 | use rustc_middle::mir::visit::Visitor; | |
| 1 | use rustc_middle::mir::visit::{PlaceContext, Visitor}; | |
| 3 | 2 | use rustc_middle::mir::{Body, Local, Location}; |
| 4 | 3 | |
| 5 | 4 | pub trait FindAssignments { |
compiler/rustc_builtin_macros/src/alloc_error_handler.rs+6-5| ... | ... | @@ -1,14 +1,15 @@ |
| 1 | use crate::errors; | |
| 2 | use crate::util::check_builtin_macro_attribute; | |
| 3 | ||
| 4 | 1 | use rustc_ast::ptr::P; |
| 5 | use rustc_ast::{self as ast, FnHeader, FnSig, Generics, StmtKind}; | |
| 6 | use rustc_ast::{Fn, ItemKind, Safety, Stmt, TyKind}; | |
| 2 | use rustc_ast::{ | |
| 3 | self as ast, Fn, FnHeader, FnSig, Generics, ItemKind, Safety, Stmt, StmtKind, TyKind, | |
| 4 | }; | |
| 7 | 5 | use rustc_expand::base::{Annotatable, ExtCtxt}; |
| 8 | 6 | use rustc_span::symbol::{kw, sym, Ident}; |
| 9 | 7 | use rustc_span::Span; |
| 10 | 8 | use thin_vec::{thin_vec, ThinVec}; |
| 11 | 9 | |
| 10 | use crate::errors; | |
| 11 | use crate::util::check_builtin_macro_attribute; | |
| 12 | ||
| 12 | 13 | pub(crate) fn expand( |
| 13 | 14 | ecx: &mut ExtCtxt<'_>, |
| 14 | 15 | _span: Span, |
compiler/rustc_builtin_macros/src/asm.rs+5-6| ... | ... | @@ -1,8 +1,5 @@ |
| 1 | use crate::errors; | |
| 2 | use crate::util::expr_to_spanned_string; | |
| 3 | 1 | use ast::token::IdentIsRaw; |
| 4 | 2 | use lint::BuiltinLintDiag; |
| 5 | use rustc_ast as ast; | |
| 6 | 3 | use rustc_ast::ptr::P; |
| 7 | 4 | use rustc_ast::token::{self, Delimiter}; |
| 8 | 5 | use rustc_ast::tokenstream::TokenStream; |
| ... | ... | @@ -11,13 +8,15 @@ use rustc_errors::PResult; |
| 11 | 8 | use rustc_expand::base::*; |
| 12 | 9 | use rustc_index::bit_set::GrowableBitSet; |
| 13 | 10 | use rustc_parse::parser::Parser; |
| 14 | use rustc_parse_format as parse; | |
| 15 | 11 | use rustc_session::lint; |
| 16 | use rustc_span::symbol::Ident; | |
| 17 | use rustc_span::symbol::{kw, sym, Symbol}; | |
| 12 | use rustc_span::symbol::{kw, sym, Ident, Symbol}; | |
| 18 | 13 | use rustc_span::{ErrorGuaranteed, InnerSpan, Span}; |
| 19 | 14 | use rustc_target::asm::InlineAsmArch; |
| 20 | 15 | use smallvec::smallvec; |
| 16 | use {rustc_ast as ast, rustc_parse_format as parse}; | |
| 17 | ||
| 18 | use crate::errors; | |
| 19 | use crate::util::expr_to_spanned_string; | |
| 21 | 20 | |
| 22 | 21 | pub struct AsmArgs { |
| 23 | 22 | pub templates: Vec<P<ast::Expr>>, |
compiler/rustc_builtin_macros/src/assert.rs+4-4| ... | ... | @@ -1,12 +1,9 @@ |
| 1 | 1 | mod context; |
| 2 | 2 | |
| 3 | use crate::edition_panic::use_panic_2021; | |
| 4 | use crate::errors; | |
| 5 | 3 | use rustc_ast::ptr::P; |
| 6 | use rustc_ast::token; | |
| 7 | 4 | use rustc_ast::token::Delimiter; |
| 8 | 5 | use rustc_ast::tokenstream::{DelimSpan, TokenStream}; |
| 9 | use rustc_ast::{DelimArgs, Expr, ExprKind, MacCall, Path, PathSegment, UnOp}; | |
| 6 | use rustc_ast::{token, DelimArgs, Expr, ExprKind, MacCall, Path, PathSegment, UnOp}; | |
| 10 | 7 | use rustc_ast_pretty::pprust; |
| 11 | 8 | use rustc_errors::PResult; |
| 12 | 9 | use rustc_expand::base::{DummyResult, ExpandResult, ExtCtxt, MacEager, MacroExpanderResult}; |
| ... | ... | @@ -15,6 +12,9 @@ use rustc_span::symbol::{sym, Ident, Symbol}; |
| 15 | 12 | use rustc_span::{Span, DUMMY_SP}; |
| 16 | 13 | use thin_vec::thin_vec; |
| 17 | 14 | |
| 15 | use crate::edition_panic::use_panic_2021; | |
| 16 | use crate::errors; | |
| 17 | ||
| 18 | 18 | pub(crate) fn expand_assert<'cx>( |
| 19 | 19 | cx: &'cx mut ExtCtxt<'_>, |
| 20 | 20 | span: Span, |
compiler/rustc_builtin_macros/src/assert/context.rs+5-7| ... | ... | @@ -1,17 +1,15 @@ |
| 1 | use rustc_ast::ptr::P; | |
| 2 | use rustc_ast::token::{self, Delimiter, IdentIsRaw}; | |
| 3 | use rustc_ast::tokenstream::{DelimSpan, TokenStream, TokenTree}; | |
| 1 | 4 | use rustc_ast::{ |
| 2 | ptr::P, | |
| 3 | token::{self, Delimiter, IdentIsRaw}, | |
| 4 | tokenstream::{DelimSpan, TokenStream, TokenTree}, | |
| 5 | 5 | BinOpKind, BorrowKind, DelimArgs, Expr, ExprKind, ItemKind, MacCall, MethodCall, Mutability, |
| 6 | 6 | Path, PathSegment, Stmt, StructRest, UnOp, UseTree, UseTreeKind, DUMMY_NODE_ID, |
| 7 | 7 | }; |
| 8 | 8 | use rustc_ast_pretty::pprust; |
| 9 | 9 | use rustc_data_structures::fx::FxHashSet; |
| 10 | 10 | use rustc_expand::base::ExtCtxt; |
| 11 | use rustc_span::{ | |
| 12 | symbol::{sym, Ident, Symbol}, | |
| 13 | Span, | |
| 14 | }; | |
| 11 | use rustc_span::symbol::{sym, Ident, Symbol}; | |
| 12 | use rustc_span::Span; | |
| 15 | 13 | use thin_vec::{thin_vec, ThinVec}; |
| 16 | 14 | |
| 17 | 15 | pub(super) struct Context<'cx, 'a> { |
compiler/rustc_builtin_macros/src/cfg.rs+3-3| ... | ... | @@ -2,14 +2,14 @@ |
| 2 | 2 | //! a literal `true` or `false` based on whether the given cfg matches the |
| 3 | 3 | //! current compilation environment. |
| 4 | 4 | |
| 5 | use crate::errors; | |
| 6 | use rustc_ast as ast; | |
| 7 | 5 | use rustc_ast::token; |
| 8 | 6 | use rustc_ast::tokenstream::TokenStream; |
| 9 | use rustc_attr as attr; | |
| 10 | 7 | use rustc_errors::PResult; |
| 11 | 8 | use rustc_expand::base::{DummyResult, ExpandResult, ExtCtxt, MacEager, MacroExpanderResult}; |
| 12 | 9 | use rustc_span::Span; |
| 10 | use {rustc_ast as ast, rustc_attr as attr}; | |
| 11 | ||
| 12 | use crate::errors; | |
| 13 | 13 | |
| 14 | 14 | pub(crate) fn expand_cfg( |
| 15 | 15 | cx: &mut ExtCtxt<'_>, |
compiler/rustc_builtin_macros/src/cfg_accessible.rs+2-1| ... | ... | @@ -1,6 +1,5 @@ |
| 1 | 1 | //! Implementation of the `#[cfg_accessible(path)]` attribute macro. |
| 2 | 2 | |
| 3 | use crate::errors; | |
| 4 | 3 | use rustc_ast as ast; |
| 5 | 4 | use rustc_expand::base::{Annotatable, ExpandResult, ExtCtxt, Indeterminate, MultiItemModifier}; |
| 6 | 5 | use rustc_feature::AttributeTemplate; |
| ... | ... | @@ -8,6 +7,8 @@ use rustc_parse::validate_attr; |
| 8 | 7 | use rustc_span::symbol::sym; |
| 9 | 8 | use rustc_span::Span; |
| 10 | 9 | |
| 10 | use crate::errors; | |
| 11 | ||
| 11 | 12 | pub(crate) struct Expander; |
| 12 | 13 | |
| 13 | 14 | fn validate_input<'a>(ecx: &ExtCtxt<'_>, mi: &'a ast::MetaItem) -> Option<&'a ast::Path> { |
compiler/rustc_builtin_macros/src/cfg_eval.rs+4-5| ... | ... | @@ -1,13 +1,10 @@ |
| 1 | use crate::util::{check_builtin_macro_attribute, warn_on_duplicate_attribute}; | |
| 2 | ||
| 3 | 1 | use core::ops::ControlFlow; |
| 2 | ||
| 4 | 3 | use rustc_ast as ast; |
| 5 | 4 | use rustc_ast::mut_visit::MutVisitor; |
| 6 | 5 | use rustc_ast::ptr::P; |
| 7 | 6 | use rustc_ast::visit::{AssocCtxt, Visitor}; |
| 8 | use rustc_ast::NodeId; | |
| 9 | use rustc_ast::{mut_visit, visit}; | |
| 10 | use rustc_ast::{Attribute, HasAttrs, HasTokens}; | |
| 7 | use rustc_ast::{mut_visit, visit, Attribute, HasAttrs, HasTokens, NodeId}; | |
| 11 | 8 | use rustc_errors::PResult; |
| 12 | 9 | use rustc_expand::base::{Annotatable, ExtCtxt}; |
| 13 | 10 | use rustc_expand::config::StripUnconfigured; |
| ... | ... | @@ -20,6 +17,8 @@ use rustc_span::Span; |
| 20 | 17 | use smallvec::SmallVec; |
| 21 | 18 | use tracing::instrument; |
| 22 | 19 | |
| 20 | use crate::util::{check_builtin_macro_attribute, warn_on_duplicate_attribute}; | |
| 21 | ||
| 23 | 22 | pub(crate) fn expand( |
| 24 | 23 | ecx: &mut ExtCtxt<'_>, |
| 25 | 24 | _span: Span, |
compiler/rustc_builtin_macros/src/cmdline_attrs.rs+3-3| ... | ... | @@ -1,14 +1,14 @@ |
| 1 | 1 | //! Attributes injected into the crate root from command line using `-Z crate-attr`. |
| 2 | 2 | |
| 3 | use crate::errors; | |
| 4 | 3 | use rustc_ast::attr::mk_attr; |
| 5 | use rustc_ast::token; | |
| 6 | use rustc_ast::{self as ast, AttrItem, AttrStyle}; | |
| 4 | use rustc_ast::{self as ast, token, AttrItem, AttrStyle}; | |
| 7 | 5 | use rustc_parse::parser::ForceCollect; |
| 8 | 6 | use rustc_parse::{new_parser_from_source_str, unwrap_or_emit_fatal}; |
| 9 | 7 | use rustc_session::parse::ParseSess; |
| 10 | 8 | use rustc_span::FileName; |
| 11 | 9 | |
| 10 | use crate::errors; | |
| 11 | ||
| 12 | 12 | pub fn inject(krate: &mut ast::Crate, psess: &ParseSess, attrs: &[String]) { |
| 13 | 13 | for raw_attr in attrs { |
| 14 | 14 | let mut parser = unwrap_or_emit_fatal(new_parser_from_source_str( |
compiler/rustc_builtin_macros/src/compile_error.rs+2-1| ... | ... | @@ -1,10 +1,11 @@ |
| 1 | 1 | // The compiler code necessary to support the compile_error! extension. |
| 2 | 2 | |
| 3 | use crate::util::get_single_str_from_tts; | |
| 4 | 3 | use rustc_ast::tokenstream::TokenStream; |
| 5 | 4 | use rustc_expand::base::{DummyResult, ExpandResult, ExtCtxt, MacroExpanderResult}; |
| 6 | 5 | use rustc_span::Span; |
| 7 | 6 | |
| 7 | use crate::util::get_single_str_from_tts; | |
| 8 | ||
| 8 | 9 | pub(crate) fn expand_compile_error<'cx>( |
| 9 | 10 | cx: &'cx mut ExtCtxt<'_>, |
| 10 | 11 | sp: Span, |
compiler/rustc_builtin_macros/src/concat.rs+3-2| ... | ... | @@ -1,11 +1,12 @@ |
| 1 | use crate::errors; | |
| 2 | use crate::util::get_exprs_from_tts; | |
| 3 | 1 | use rustc_ast::tokenstream::TokenStream; |
| 4 | 2 | use rustc_ast::{ExprKind, LitKind, UnOp}; |
| 5 | 3 | use rustc_expand::base::{DummyResult, ExpandResult, ExtCtxt, MacEager, MacroExpanderResult}; |
| 6 | 4 | use rustc_session::errors::report_lit_error; |
| 7 | 5 | use rustc_span::symbol::Symbol; |
| 8 | 6 | |
| 7 | use crate::errors; | |
| 8 | use crate::util::get_exprs_from_tts; | |
| 9 | ||
| 9 | 10 | pub(crate) fn expand_concat( |
| 10 | 11 | cx: &mut ExtCtxt<'_>, |
| 11 | 12 | sp: rustc_span::Span, |
compiler/rustc_builtin_macros/src/concat_bytes.rs+6-3| ... | ... | @@ -1,10 +1,13 @@ |
| 1 | use crate::errors; | |
| 2 | use crate::util::get_exprs_from_tts; | |
| 3 | use rustc_ast::{ptr::P, token, tokenstream::TokenStream, ExprKind, LitIntType, LitKind, UintTy}; | |
| 1 | use rustc_ast::ptr::P; | |
| 2 | use rustc_ast::tokenstream::TokenStream; | |
| 3 | use rustc_ast::{token, ExprKind, LitIntType, LitKind, UintTy}; | |
| 4 | 4 | use rustc_expand::base::{DummyResult, ExpandResult, ExtCtxt, MacEager, MacroExpanderResult}; |
| 5 | 5 | use rustc_session::errors::report_lit_error; |
| 6 | 6 | use rustc_span::{ErrorGuaranteed, Span}; |
| 7 | 7 | |
| 8 | use crate::errors; | |
| 9 | use crate::util::get_exprs_from_tts; | |
| 10 | ||
| 8 | 11 | /// Emits errors for literal expressions that are invalid inside and outside of an array. |
| 9 | 12 | fn invalid_type_err( |
| 10 | 13 | cx: &ExtCtxt<'_>, |
compiler/rustc_builtin_macros/src/derive.rs+3-3| ... | ... | @@ -1,6 +1,3 @@ |
| 1 | use crate::cfg_eval::cfg_eval; | |
| 2 | use crate::errors; | |
| 3 | ||
| 4 | 1 | use rustc_ast as ast; |
| 5 | 2 | use rustc_ast::{GenericParamKind, ItemKind, MetaItemKind, NestedMetaItem, Safety, StmtKind}; |
| 6 | 3 | use rustc_expand::base::{ |
| ... | ... | @@ -12,6 +9,9 @@ use rustc_session::Session; |
| 12 | 9 | use rustc_span::symbol::{sym, Ident}; |
| 13 | 10 | use rustc_span::{ErrorGuaranteed, Span}; |
| 14 | 11 | |
| 12 | use crate::cfg_eval::cfg_eval; | |
| 13 | use crate::errors; | |
| 14 | ||
| 15 | 15 | pub(crate) struct Expander { |
| 16 | 16 | pub is_const: bool, |
| 17 | 17 | } |
compiler/rustc_builtin_macros/src/deriving/bounds.rs+3-3| ... | ... | @@ -1,10 +1,10 @@ |
| 1 | use crate::deriving::generic::*; | |
| 2 | use crate::deriving::path_std; | |
| 3 | ||
| 4 | 1 | use rustc_ast::MetaItem; |
| 5 | 2 | use rustc_expand::base::{Annotatable, ExtCtxt}; |
| 6 | 3 | use rustc_span::Span; |
| 7 | 4 | |
| 5 | use crate::deriving::generic::*; | |
| 6 | use crate::deriving::path_std; | |
| 7 | ||
| 8 | 8 | pub(crate) fn expand_deriving_copy( |
| 9 | 9 | cx: &ExtCtxt<'_>, |
| 10 | 10 | span: Span, |
compiler/rustc_builtin_macros/src/deriving/clone.rs+4-3| ... | ... | @@ -1,6 +1,3 @@ |
| 1 | use crate::deriving::generic::ty::*; | |
| 2 | use crate::deriving::generic::*; | |
| 3 | use crate::deriving::path_std; | |
| 4 | 1 | use rustc_ast::{self as ast, Generics, ItemKind, MetaItem, VariantData}; |
| 5 | 2 | use rustc_data_structures::fx::FxHashSet; |
| 6 | 3 | use rustc_expand::base::{Annotatable, ExtCtxt}; |
| ... | ... | @@ -8,6 +5,10 @@ use rustc_span::symbol::{kw, sym, Ident}; |
| 8 | 5 | use rustc_span::Span; |
| 9 | 6 | use thin_vec::{thin_vec, ThinVec}; |
| 10 | 7 | |
| 8 | use crate::deriving::generic::ty::*; | |
| 9 | use crate::deriving::generic::*; | |
| 10 | use crate::deriving::path_std; | |
| 11 | ||
| 11 | 12 | pub(crate) fn expand_deriving_clone( |
| 12 | 13 | cx: &ExtCtxt<'_>, |
| 13 | 14 | span: Span, |
compiler/rustc_builtin_macros/src/deriving/cmp/eq.rs+4-4| ... | ... | @@ -1,7 +1,3 @@ |
| 1 | use crate::deriving::generic::ty::*; | |
| 2 | use crate::deriving::generic::*; | |
| 3 | use crate::deriving::path_std; | |
| 4 | ||
| 5 | 1 | use rustc_ast::{self as ast, MetaItem}; |
| 6 | 2 | use rustc_data_structures::fx::FxHashSet; |
| 7 | 3 | use rustc_expand::base::{Annotatable, ExtCtxt}; |
| ... | ... | @@ -9,6 +5,10 @@ use rustc_span::symbol::sym; |
| 9 | 5 | use rustc_span::Span; |
| 10 | 6 | use thin_vec::{thin_vec, ThinVec}; |
| 11 | 7 | |
| 8 | use crate::deriving::generic::ty::*; | |
| 9 | use crate::deriving::generic::*; | |
| 10 | use crate::deriving::path_std; | |
| 11 | ||
| 12 | 12 | pub(crate) fn expand_deriving_eq( |
| 13 | 13 | cx: &ExtCtxt<'_>, |
| 14 | 14 | span: Span, |
compiler/rustc_builtin_macros/src/deriving/cmp/ord.rs+4-3| ... | ... | @@ -1,12 +1,13 @@ |
| 1 | use crate::deriving::generic::ty::*; | |
| 2 | use crate::deriving::generic::*; | |
| 3 | use crate::deriving::path_std; | |
| 4 | 1 | use rustc_ast::MetaItem; |
| 5 | 2 | use rustc_expand::base::{Annotatable, ExtCtxt}; |
| 6 | 3 | use rustc_span::symbol::{sym, Ident}; |
| 7 | 4 | use rustc_span::Span; |
| 8 | 5 | use thin_vec::thin_vec; |
| 9 | 6 | |
| 7 | use crate::deriving::generic::ty::*; | |
| 8 | use crate::deriving::generic::*; | |
| 9 | use crate::deriving::path_std; | |
| 10 | ||
| 10 | 11 | pub(crate) fn expand_deriving_ord( |
| 11 | 12 | cx: &ExtCtxt<'_>, |
| 12 | 13 | span: Span, |
compiler/rustc_builtin_macros/src/deriving/cmp/partial_eq.rs+4-3| ... | ... | @@ -1,6 +1,3 @@ |
| 1 | use crate::deriving::generic::ty::*; | |
| 2 | use crate::deriving::generic::*; | |
| 3 | use crate::deriving::{path_local, path_std}; | |
| 4 | 1 | use rustc_ast::ptr::P; |
| 5 | 2 | use rustc_ast::{BinOpKind, BorrowKind, Expr, ExprKind, MetaItem, Mutability}; |
| 6 | 3 | use rustc_expand::base::{Annotatable, ExtCtxt}; |
| ... | ... | @@ -8,6 +5,10 @@ use rustc_span::symbol::sym; |
| 8 | 5 | use rustc_span::Span; |
| 9 | 6 | use thin_vec::thin_vec; |
| 10 | 7 | |
| 8 | use crate::deriving::generic::ty::*; | |
| 9 | use crate::deriving::generic::*; | |
| 10 | use crate::deriving::{path_local, path_std}; | |
| 11 | ||
| 11 | 12 | pub(crate) fn expand_deriving_partial_eq( |
| 12 | 13 | cx: &ExtCtxt<'_>, |
| 13 | 14 | span: Span, |
compiler/rustc_builtin_macros/src/deriving/cmp/partial_ord.rs+4-3| ... | ... | @@ -1,12 +1,13 @@ |
| 1 | use crate::deriving::generic::ty::*; | |
| 2 | use crate::deriving::generic::*; | |
| 3 | use crate::deriving::{path_std, pathvec_std}; | |
| 4 | 1 | use rustc_ast::{ExprKind, ItemKind, MetaItem, PatKind}; |
| 5 | 2 | use rustc_expand::base::{Annotatable, ExtCtxt}; |
| 6 | 3 | use rustc_span::symbol::{sym, Ident}; |
| 7 | 4 | use rustc_span::Span; |
| 8 | 5 | use thin_vec::thin_vec; |
| 9 | 6 | |
| 7 | use crate::deriving::generic::ty::*; | |
| 8 | use crate::deriving::generic::*; | |
| 9 | use crate::deriving::{path_std, pathvec_std}; | |
| 10 | ||
| 10 | 11 | pub(crate) fn expand_deriving_partial_ord( |
| 11 | 12 | cx: &ExtCtxt<'_>, |
| 12 | 13 | span: Span, |
compiler/rustc_builtin_macros/src/deriving/debug.rs+4-4| ... | ... | @@ -1,13 +1,13 @@ |
| 1 | use crate::deriving::generic::ty::*; | |
| 2 | use crate::deriving::generic::*; | |
| 3 | use crate::deriving::path_std; | |
| 4 | ||
| 5 | 1 | use rustc_ast::{self as ast, EnumDef, MetaItem}; |
| 6 | 2 | use rustc_expand::base::{Annotatable, ExtCtxt}; |
| 7 | 3 | use rustc_span::symbol::{sym, Ident, Symbol}; |
| 8 | 4 | use rustc_span::Span; |
| 9 | 5 | use thin_vec::{thin_vec, ThinVec}; |
| 10 | 6 | |
| 7 | use crate::deriving::generic::ty::*; | |
| 8 | use crate::deriving::generic::*; | |
| 9 | use crate::deriving::path_std; | |
| 10 | ||
| 11 | 11 | pub(crate) fn expand_deriving_debug( |
| 12 | 12 | cx: &ExtCtxt<'_>, |
| 13 | 13 | span: Span, |
compiler/rustc_builtin_macros/src/deriving/decodable.rs+4-3| ... | ... | @@ -1,8 +1,5 @@ |
| 1 | 1 | //! The compiler code necessary for `#[derive(RustcDecodable)]`. See encodable.rs for more. |
| 2 | 2 | |
| 3 | use crate::deriving::generic::ty::*; | |
| 4 | use crate::deriving::generic::*; | |
| 5 | use crate::deriving::pathvec_std; | |
| 6 | 3 | use rustc_ast::ptr::P; |
| 7 | 4 | use rustc_ast::{self as ast, Expr, MetaItem, Mutability}; |
| 8 | 5 | use rustc_expand::base::{Annotatable, ExtCtxt}; |
| ... | ... | @@ -10,6 +7,10 @@ use rustc_span::symbol::{sym, Ident, Symbol}; |
| 10 | 7 | use rustc_span::Span; |
| 11 | 8 | use thin_vec::{thin_vec, ThinVec}; |
| 12 | 9 | |
| 10 | use crate::deriving::generic::ty::*; | |
| 11 | use crate::deriving::generic::*; | |
| 12 | use crate::deriving::pathvec_std; | |
| 13 | ||
| 13 | 14 | pub(crate) fn expand_deriving_rustc_decodable( |
| 14 | 15 | cx: &ExtCtxt<'_>, |
| 15 | 16 | span: Span, |
compiler/rustc_builtin_macros/src/deriving/default.rs+6-5| ... | ... | @@ -1,17 +1,18 @@ |
| 1 | use crate::deriving::generic::ty::*; | |
| 2 | use crate::deriving::generic::*; | |
| 3 | use crate::errors; | |
| 4 | 1 | use core::ops::ControlFlow; |
| 2 | ||
| 5 | 3 | use rustc_ast as ast; |
| 6 | 4 | use rustc_ast::visit::visit_opt; |
| 7 | 5 | use rustc_ast::{attr, EnumDef, VariantData}; |
| 8 | 6 | use rustc_expand::base::{Annotatable, DummyResult, ExtCtxt}; |
| 9 | use rustc_span::symbol::Ident; | |
| 10 | use rustc_span::symbol::{kw, sym}; | |
| 7 | use rustc_span::symbol::{kw, sym, Ident}; | |
| 11 | 8 | use rustc_span::{ErrorGuaranteed, Span}; |
| 12 | 9 | use smallvec::SmallVec; |
| 13 | 10 | use thin_vec::{thin_vec, ThinVec}; |
| 14 | 11 | |
| 12 | use crate::deriving::generic::ty::*; | |
| 13 | use crate::deriving::generic::*; | |
| 14 | use crate::errors; | |
| 15 | ||
| 15 | 16 | pub(crate) fn expand_deriving_default( |
| 16 | 17 | cx: &ExtCtxt<'_>, |
| 17 | 18 | span: Span, |
compiler/rustc_builtin_macros/src/deriving/encodable.rs+4-3| ... | ... | @@ -85,15 +85,16 @@ |
| 85 | 85 | //! } |
| 86 | 86 | //! ``` |
| 87 | 87 | |
| 88 | use crate::deriving::generic::ty::*; | |
| 89 | use crate::deriving::generic::*; | |
| 90 | use crate::deriving::pathvec_std; | |
| 91 | 88 | use rustc_ast::{AttrVec, ExprKind, MetaItem, Mutability}; |
| 92 | 89 | use rustc_expand::base::{Annotatable, ExtCtxt}; |
| 93 | 90 | use rustc_span::symbol::{sym, Ident, Symbol}; |
| 94 | 91 | use rustc_span::Span; |
| 95 | 92 | use thin_vec::{thin_vec, ThinVec}; |
| 96 | 93 | |
| 94 | use crate::deriving::generic::ty::*; | |
| 95 | use crate::deriving::generic::*; | |
| 96 | use crate::deriving::pathvec_std; | |
| 97 | ||
| 97 | 98 | pub(crate) fn expand_deriving_rustc_encodable( |
| 98 | 99 | cx: &ExtCtxt<'_>, |
| 99 | 100 | span: Span, |
compiler/rustc_builtin_macros/src/deriving/generic/mod.rs+7-7| ... | ... | @@ -174,10 +174,10 @@ |
| 174 | 174 | //! ) |
| 175 | 175 | //! ``` |
| 176 | 176 | |
| 177 | pub(crate) use StaticFields::*; | |
| 178 | pub(crate) use SubstructureFields::*; | |
| 177 | use std::cell::RefCell; | |
| 178 | use std::ops::Not; | |
| 179 | use std::{iter, vec}; | |
| 179 | 180 | |
| 180 | use crate::{deriving, errors}; | |
| 181 | 181 | use rustc_ast::ptr::P; |
| 182 | 182 | use rustc_ast::{ |
| 183 | 183 | self as ast, BindingMode, ByRef, EnumDef, Expr, GenericArg, GenericParamKind, Generics, |
| ... | ... | @@ -188,12 +188,12 @@ use rustc_expand::base::{Annotatable, ExtCtxt}; |
| 188 | 188 | use rustc_session::lint::builtin::BYTE_SLICE_IN_PACKED_STRUCT_WITH_DERIVE; |
| 189 | 189 | use rustc_span::symbol::{kw, sym, Ident, Symbol}; |
| 190 | 190 | use rustc_span::{Span, DUMMY_SP}; |
| 191 | use std::cell::RefCell; | |
| 192 | use std::iter; | |
| 193 | use std::ops::Not; | |
| 194 | use std::vec; | |
| 195 | 191 | use thin_vec::{thin_vec, ThinVec}; |
| 196 | 192 | use ty::{Bounds, Path, Ref, Self_, Ty}; |
| 193 | pub(crate) use StaticFields::*; | |
| 194 | pub(crate) use SubstructureFields::*; | |
| 195 | ||
| 196 | use crate::{deriving, errors}; | |
| 197 | 197 | |
| 198 | 198 | pub(crate) mod ty; |
| 199 | 199 |
compiler/rustc_builtin_macros/src/deriving/generic/ty.rs+1-2| ... | ... | @@ -1,8 +1,6 @@ |
| 1 | 1 | //! A mini version of ast::Ty, which is easier to use, and features an explicit `Self` type to use |
| 2 | 2 | //! when specifying impls to be derived. |
| 3 | 3 | |
| 4 | pub(crate) use Ty::*; | |
| 5 | ||
| 6 | 4 | use rustc_ast::ptr::P; |
| 7 | 5 | use rustc_ast::{self as ast, Expr, GenericArg, GenericParamKind, Generics, SelfKind}; |
| 8 | 6 | use rustc_expand::base::ExtCtxt; |
| ... | ... | @@ -10,6 +8,7 @@ use rustc_span::source_map::respan; |
| 10 | 8 | use rustc_span::symbol::{kw, Ident, Symbol}; |
| 11 | 9 | use rustc_span::{Span, DUMMY_SP}; |
| 12 | 10 | use thin_vec::ThinVec; |
| 11 | pub(crate) use Ty::*; | |
| 13 | 12 | |
| 14 | 13 | /// A path, e.g., `::std::option::Option::<i32>` (global). Has support |
| 15 | 14 | /// for type parameters. |
compiler/rustc_builtin_macros/src/deriving/hash.rs+4-3| ... | ... | @@ -1,12 +1,13 @@ |
| 1 | use crate::deriving::generic::ty::*; | |
| 2 | use crate::deriving::generic::*; | |
| 3 | use crate::deriving::{path_std, pathvec_std}; | |
| 4 | 1 | use rustc_ast::{MetaItem, Mutability}; |
| 5 | 2 | use rustc_expand::base::{Annotatable, ExtCtxt}; |
| 6 | 3 | use rustc_span::symbol::sym; |
| 7 | 4 | use rustc_span::Span; |
| 8 | 5 | use thin_vec::thin_vec; |
| 9 | 6 | |
| 7 | use crate::deriving::generic::ty::*; | |
| 8 | use crate::deriving::generic::*; | |
| 9 | use crate::deriving::{path_std, pathvec_std}; | |
| 10 | ||
| 10 | 11 | pub(crate) fn expand_deriving_hash( |
| 11 | 12 | cx: &ExtCtxt<'_>, |
| 12 | 13 | span: Span, |
compiler/rustc_builtin_macros/src/env.rs+6-4| ... | ... | @@ -3,18 +3,20 @@ |
| 3 | 3 | // interface. |
| 4 | 4 | // |
| 5 | 5 | |
| 6 | use crate::errors; | |
| 7 | use crate::util::{expr_to_string, get_exprs_from_tts, get_single_str_from_tts}; | |
| 6 | use std::env; | |
| 7 | use std::env::VarError; | |
| 8 | ||
| 8 | 9 | use rustc_ast::token::{self, LitKind}; |
| 9 | 10 | use rustc_ast::tokenstream::TokenStream; |
| 10 | 11 | use rustc_ast::{AstDeref, ExprKind, GenericArg, Mutability}; |
| 11 | 12 | use rustc_expand::base::{DummyResult, ExpandResult, ExtCtxt, MacEager, MacroExpanderResult}; |
| 12 | 13 | use rustc_span::symbol::{kw, sym, Ident, Symbol}; |
| 13 | 14 | use rustc_span::Span; |
| 14 | use std::env; | |
| 15 | use std::env::VarError; | |
| 16 | 15 | use thin_vec::thin_vec; |
| 17 | 16 | |
| 17 | use crate::errors; | |
| 18 | use crate::util::{expr_to_string, get_exprs_from_tts, get_single_str_from_tts}; | |
| 19 | ||
| 18 | 20 | fn lookup_env<'cx>(cx: &'cx ExtCtxt<'_>, var: Symbol) -> Result<Symbol, VarError> { |
| 19 | 21 | let var = var.as_str(); |
| 20 | 22 | if let Some(value) = cx.sess.opts.logical_env.get(var) { |
compiler/rustc_builtin_macros/src/errors.rs+5-3| ... | ... | @@ -1,9 +1,11 @@ |
| 1 | use rustc_errors::codes::*; | |
| 1 | 2 | use rustc_errors::{ |
| 2 | codes::*, Diag, DiagCtxtHandle, Diagnostic, EmissionGuarantee, Level, MultiSpan, | |
| 3 | SingleLabelManySpans, SubdiagMessageOp, Subdiagnostic, | |
| 3 | Diag, DiagCtxtHandle, Diagnostic, EmissionGuarantee, Level, MultiSpan, SingleLabelManySpans, | |
| 4 | SubdiagMessageOp, Subdiagnostic, | |
| 4 | 5 | }; |
| 5 | 6 | use rustc_macros::{Diagnostic, Subdiagnostic}; |
| 6 | use rustc_span::{symbol::Ident, Span, Symbol}; | |
| 7 | use rustc_span::symbol::Ident; | |
| 8 | use rustc_span::{Span, Symbol}; | |
| 7 | 9 | |
| 8 | 10 | #[derive(Diagnostic)] |
| 9 | 11 | #[diag(builtin_macros_requires_cfg_pattern)] |
compiler/rustc_builtin_macros/src/format.rs+5-5| ... | ... | @@ -1,13 +1,10 @@ |
| 1 | use crate::errors; | |
| 2 | use crate::util::expr_to_spanned_string; | |
| 3 | 1 | use parse::Position::ArgumentNamed; |
| 4 | 2 | use rustc_ast::ptr::P; |
| 5 | 3 | use rustc_ast::tokenstream::TokenStream; |
| 6 | use rustc_ast::{token, StmtKind}; | |
| 7 | 4 | use rustc_ast::{ |
| 8 | Expr, ExprKind, FormatAlignment, FormatArgPosition, FormatArgPositionKind, FormatArgs, | |
| 5 | token, Expr, ExprKind, FormatAlignment, FormatArgPosition, FormatArgPositionKind, FormatArgs, | |
| 9 | 6 | FormatArgsPiece, FormatArgument, FormatArgumentKind, FormatArguments, FormatCount, |
| 10 | FormatDebugHex, FormatOptions, FormatPlaceholder, FormatSign, FormatTrait, Recovered, | |
| 7 | FormatDebugHex, FormatOptions, FormatPlaceholder, FormatSign, FormatTrait, Recovered, StmtKind, | |
| 11 | 8 | }; |
| 12 | 9 | use rustc_data_structures::fx::FxHashSet; |
| 13 | 10 | use rustc_errors::{Applicability, Diag, MultiSpan, PResult, SingleLabelManySpans}; |
| ... | ... | @@ -18,6 +15,9 @@ use rustc_parse_format as parse; |
| 18 | 15 | use rustc_span::symbol::{Ident, Symbol}; |
| 19 | 16 | use rustc_span::{BytePos, ErrorGuaranteed, InnerSpan, Span}; |
| 20 | 17 | |
| 18 | use crate::errors; | |
| 19 | use crate::util::expr_to_spanned_string; | |
| 20 | ||
| 21 | 21 | // The format_args!() macro is expanded in three steps: |
| 22 | 22 | // 1. First, `parse_args` will parse the `(literal, arg, arg, name=arg, name=arg)` syntax, |
| 23 | 23 | // but doesn't parse the template (the literal) itself. |
compiler/rustc_builtin_macros/src/format_foreign.rs+4-2| ... | ... | @@ -1,7 +1,8 @@ |
| 1 | 1 | pub(crate) mod printf { |
| 2 | use super::strcursor::StrCursor as Cur; | |
| 3 | 2 | use rustc_span::InnerSpan; |
| 4 | 3 | |
| 4 | use super::strcursor::StrCursor as Cur; | |
| 5 | ||
| 5 | 6 | /// Represents a single `printf`-style substitution. |
| 6 | 7 | #[derive(Clone, PartialEq, Debug)] |
| 7 | 8 | pub enum Substitution<'a> { |
| ... | ... | @@ -615,9 +616,10 @@ pub(crate) mod printf { |
| 615 | 616 | } |
| 616 | 617 | |
| 617 | 618 | pub mod shell { |
| 618 | use super::strcursor::StrCursor as Cur; | |
| 619 | 619 | use rustc_span::InnerSpan; |
| 620 | 620 | |
| 621 | use super::strcursor::StrCursor as Cur; | |
| 622 | ||
| 621 | 623 | #[derive(Clone, PartialEq, Debug)] |
| 622 | 624 | pub enum Substitution<'a> { |
| 623 | 625 | Ordinal(u8, (usize, usize)), |
compiler/rustc_builtin_macros/src/global_allocator.rs+7-5| ... | ... | @@ -1,17 +1,19 @@ |
| 1 | use crate::util::check_builtin_macro_attribute; | |
| 2 | ||
| 3 | use crate::errors; | |
| 4 | 1 | use rustc_ast::expand::allocator::{ |
| 5 | 2 | global_fn_name, AllocatorMethod, AllocatorMethodInput, AllocatorTy, ALLOCATOR_METHODS, |
| 6 | 3 | }; |
| 7 | 4 | use rustc_ast::ptr::P; |
| 8 | use rustc_ast::{self as ast, AttrVec, Expr, FnHeader, FnSig, Generics, Param, StmtKind}; | |
| 9 | use rustc_ast::{Fn, ItemKind, Mutability, Safety, Stmt, Ty, TyKind}; | |
| 5 | use rustc_ast::{ | |
| 6 | self as ast, AttrVec, Expr, Fn, FnHeader, FnSig, Generics, ItemKind, Mutability, Param, Safety, | |
| 7 | Stmt, StmtKind, Ty, TyKind, | |
| 8 | }; | |
| 10 | 9 | use rustc_expand::base::{Annotatable, ExtCtxt}; |
| 11 | 10 | use rustc_span::symbol::{kw, sym, Ident, Symbol}; |
| 12 | 11 | use rustc_span::Span; |
| 13 | 12 | use thin_vec::{thin_vec, ThinVec}; |
| 14 | 13 | |
| 14 | use crate::errors; | |
| 15 | use crate::util::check_builtin_macro_attribute; | |
| 16 | ||
| 15 | 17 | pub(crate) fn expand( |
| 16 | 18 | ecx: &mut ExtCtxt<'_>, |
| 17 | 19 | _span: Span, |
compiler/rustc_builtin_macros/src/lib.rs+2-1| ... | ... | @@ -21,11 +21,12 @@ |
| 21 | 21 | |
| 22 | 22 | extern crate proc_macro; |
| 23 | 23 | |
| 24 | use crate::deriving::*; | |
| 25 | 24 | use rustc_expand::base::{MacroExpanderFn, ResolverExpand, SyntaxExtensionKind}; |
| 26 | 25 | use rustc_expand::proc_macro::BangProcMacro; |
| 27 | 26 | use rustc_span::symbol::sym; |
| 28 | 27 | |
| 28 | use crate::deriving::*; | |
| 29 | ||
| 29 | 30 | mod alloc_error_handler; |
| 30 | 31 | mod assert; |
| 31 | 32 | mod cfg; |
compiler/rustc_builtin_macros/src/pattern_type.rs+3-1| ... | ... | @@ -1,4 +1,6 @@ |
| 1 | use rustc_ast::{ast, ptr::P, tokenstream::TokenStream, Pat, Ty}; | |
| 1 | use rustc_ast::ptr::P; | |
| 2 | use rustc_ast::tokenstream::TokenStream; | |
| 3 | use rustc_ast::{ast, Pat, Ty}; | |
| 2 | 4 | use rustc_errors::PResult; |
| 3 | 5 | use rustc_expand::base::{self, DummyResult, ExpandResult, ExtCtxt, MacroExpanderResult}; |
| 4 | 6 | use rustc_span::{sym, Span}; |
compiler/rustc_builtin_macros/src/proc_macro_harness.rs+4-2| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | use crate::errors; | |
| 1 | use std::mem; | |
| 2 | ||
| 2 | 3 | use rustc_ast::ptr::P; |
| 3 | 4 | use rustc_ast::visit::{self, Visitor}; |
| 4 | 5 | use rustc_ast::{self as ast, attr, NodeId}; |
| ... | ... | @@ -13,9 +14,10 @@ use rustc_span::source_map::SourceMap; |
| 13 | 14 | use rustc_span::symbol::{kw, sym, Ident, Symbol}; |
| 14 | 15 | use rustc_span::{Span, DUMMY_SP}; |
| 15 | 16 | use smallvec::smallvec; |
| 16 | use std::mem; | |
| 17 | 17 | use thin_vec::{thin_vec, ThinVec}; |
| 18 | 18 | |
| 19 | use crate::errors; | |
| 20 | ||
| 19 | 21 | struct ProcMacroDerive { |
| 20 | 22 | id: NodeId, |
| 21 | 23 | trait_name: Symbol, |
compiler/rustc_builtin_macros/src/source_util.rs+10-7| ... | ... | @@ -1,7 +1,6 @@ |
| 1 | use crate::errors; | |
| 2 | use crate::util::{ | |
| 3 | check_zero_tts, get_single_str_from_tts, get_single_str_spanned_from_tts, parse_expr, | |
| 4 | }; | |
| 1 | use std::path::{Path, PathBuf}; | |
| 2 | use std::rc::Rc; | |
| 3 | ||
| 5 | 4 | use rustc_ast as ast; |
| 6 | 5 | use rustc_ast::ptr::P; |
| 7 | 6 | use rustc_ast::token; |
| ... | ... | @@ -20,8 +19,11 @@ use rustc_span::source_map::SourceMap; |
| 20 | 19 | use rustc_span::symbol::Symbol; |
| 21 | 20 | use rustc_span::{Pos, Span}; |
| 22 | 21 | use smallvec::SmallVec; |
| 23 | use std::path::{Path, PathBuf}; | |
| 24 | use std::rc::Rc; | |
| 22 | ||
| 23 | use crate::errors; | |
| 24 | use crate::util::{ | |
| 25 | check_zero_tts, get_single_str_from_tts, get_single_str_spanned_from_tts, parse_expr, | |
| 26 | }; | |
| 25 | 27 | |
| 26 | 28 | // These macros all relate to the file system; they either return |
| 27 | 29 | // the column/row/filename of the expression, or they include |
| ... | ... | @@ -71,7 +73,8 @@ pub(crate) fn expand_file( |
| 71 | 73 | let topmost = cx.expansion_cause().unwrap_or(sp); |
| 72 | 74 | let loc = cx.source_map().lookup_char_pos(topmost.lo()); |
| 73 | 75 | |
| 74 | use rustc_session::{config::RemapPathScopeComponents, RemapFileNameExt}; | |
| 76 | use rustc_session::config::RemapPathScopeComponents; | |
| 77 | use rustc_session::RemapFileNameExt; | |
| 75 | 78 | ExpandResult::Ready(MacEager::expr(cx.expr_str( |
| 76 | 79 | topmost, |
| 77 | 80 | Symbol::intern( |
compiler/rustc_builtin_macros/src/test.rs+6-4| ... | ... | @@ -1,8 +1,9 @@ |
| 1 | 1 | //! The expansion from a test function to the appropriate test struct for libtest |
| 2 | 2 | //! Ideally, this code would be in libtest but for efficiency and error messages it lives here. |
| 3 | 3 | |
| 4 | use crate::errors; | |
| 5 | use crate::util::{check_builtin_macro_attribute, warn_on_duplicate_attribute}; | |
| 4 | use std::assert_matches::assert_matches; | |
| 5 | use std::iter; | |
| 6 | ||
| 6 | 7 | use rustc_ast::ptr::P; |
| 7 | 8 | use rustc_ast::{self as ast, attr, GenericParamKind}; |
| 8 | 9 | use rustc_ast_pretty::pprust; |
| ... | ... | @@ -10,11 +11,12 @@ use rustc_errors::{Applicability, Diag, Level}; |
| 10 | 11 | use rustc_expand::base::*; |
| 11 | 12 | use rustc_span::symbol::{sym, Ident, Symbol}; |
| 12 | 13 | use rustc_span::{ErrorGuaranteed, FileNameDisplayPreference, Span}; |
| 13 | use std::assert_matches::assert_matches; | |
| 14 | use std::iter; | |
| 15 | 14 | use thin_vec::{thin_vec, ThinVec}; |
| 16 | 15 | use tracing::debug; |
| 17 | 16 | |
| 17 | use crate::errors; | |
| 18 | use crate::util::{check_builtin_macro_attribute, warn_on_duplicate_attribute}; | |
| 19 | ||
| 18 | 20 | /// #[test_case] is used by custom test authors to mark tests |
| 19 | 21 | /// When building for test, it needs to make the item public and gensym the name |
| 20 | 22 | /// Otherwise, we'll omit the item. This behavior means that any item annotated |
compiler/rustc_builtin_macros/src/test_harness.rs+2-2| ... | ... | @@ -1,5 +1,7 @@ |
| 1 | 1 | // Code that generates a test runner to run all the tests in a crate |
| 2 | 2 | |
| 3 | use std::{iter, mem}; | |
| 4 | ||
| 3 | 5 | use rustc_ast as ast; |
| 4 | 6 | use rustc_ast::entry::EntryPointType; |
| 5 | 7 | use rustc_ast::mut_visit::*; |
| ... | ... | @@ -21,8 +23,6 @@ use smallvec::{smallvec, SmallVec}; |
| 21 | 23 | use thin_vec::{thin_vec, ThinVec}; |
| 22 | 24 | use tracing::debug; |
| 23 | 25 | |
| 24 | use std::{iter, mem}; | |
| 25 | ||
| 26 | 26 | use crate::errors; |
| 27 | 27 | |
| 28 | 28 | #[derive(Clone)] |
compiler/rustc_builtin_macros/src/trace_macros.rs+2-1| ... | ... | @@ -1,9 +1,10 @@ |
| 1 | use crate::errors; | |
| 2 | 1 | use rustc_ast::tokenstream::{TokenStream, TokenTree}; |
| 3 | 2 | use rustc_expand::base::{DummyResult, ExpandResult, ExtCtxt, MacroExpanderResult}; |
| 4 | 3 | use rustc_span::symbol::kw; |
| 5 | 4 | use rustc_span::Span; |
| 6 | 5 | |
| 6 | use crate::errors; | |
| 7 | ||
| 7 | 8 | pub(crate) fn expand_trace_macros( |
| 8 | 9 | cx: &mut ExtCtxt<'_>, |
| 9 | 10 | sp: Span, |
compiler/rustc_builtin_macros/src/util.rs+6-3| ... | ... | @@ -1,15 +1,18 @@ |
| 1 | use crate::errors; | |
| 1 | use rustc_ast::ptr::P; | |
| 2 | 2 | use rustc_ast::tokenstream::TokenStream; |
| 3 | use rustc_ast::{self as ast, attr, ptr::P, token, AttrStyle, Attribute, MetaItem}; | |
| 3 | use rustc_ast::{self as ast, attr, token, AttrStyle, Attribute, MetaItem}; | |
| 4 | 4 | use rustc_errors::{Applicability, Diag, ErrorGuaranteed}; |
| 5 | 5 | use rustc_expand::base::{Annotatable, ExpandResult, ExtCtxt}; |
| 6 | 6 | use rustc_expand::expand::AstFragment; |
| 7 | 7 | use rustc_feature::AttributeTemplate; |
| 8 | use rustc_lint_defs::{builtin::DUPLICATE_MACRO_ATTRIBUTES, BuiltinLintDiag}; | |
| 8 | use rustc_lint_defs::builtin::DUPLICATE_MACRO_ATTRIBUTES; | |
| 9 | use rustc_lint_defs::BuiltinLintDiag; | |
| 9 | 10 | use rustc_parse::{parser, validate_attr}; |
| 10 | 11 | use rustc_session::errors::report_lit_error; |
| 11 | 12 | use rustc_span::{BytePos, Span, Symbol}; |
| 12 | 13 | |
| 14 | use crate::errors; | |
| 15 | ||
| 13 | 16 | pub(crate) fn check_builtin_macro_attribute(ecx: &ExtCtxt<'_>, meta_item: &MetaItem, name: Symbol) { |
| 14 | 17 | // All the built-in macro attributes are "words" at the moment. |
| 15 | 18 | let template = AttributeTemplate { word: true, ..Default::default() }; |
compiler/rustc_codegen_cranelift/build_system/abi_cafe.rs+1-2| ... | ... | @@ -1,8 +1,7 @@ |
| 1 | use crate::build_sysroot; | |
| 2 | 1 | use crate::path::Dirs; |
| 3 | 2 | use crate::prepare::GitRepo; |
| 4 | 3 | use crate::utils::{spawn_and_wait, CargoProject, Compiler}; |
| 5 | use crate::{CodegenBackend, SysrootKind}; | |
| 4 | use crate::{build_sysroot, CodegenBackend, SysrootKind}; | |
| 6 | 5 | |
| 7 | 6 | static ABI_CAFE_REPO: GitRepo = GitRepo::github( |
| 8 | 7 | "Gankra", |
compiler/rustc_codegen_cranelift/build_system/build_sysroot.rs+1-2| ... | ... | @@ -1,7 +1,6 @@ |
| 1 | use std::env; | |
| 2 | use std::fs; | |
| 3 | 1 | use std::path::{Path, PathBuf}; |
| 4 | 2 | use std::process::Command; |
| 3 | use std::{env, fs}; | |
| 5 | 4 | |
| 6 | 5 | use crate::path::{Dirs, RelPath}; |
| 7 | 6 | use crate::rustc_info::get_file_name; |
compiler/rustc_codegen_cranelift/build_system/config.rs+1-2| ... | ... | @@ -1,5 +1,4 @@ |
| 1 | use std::fs; | |
| 2 | use std::process; | |
| 1 | use std::{fs, process}; | |
| 3 | 2 | |
| 4 | 3 | fn load_config_file() -> Vec<(String, Option<String>)> { |
| 5 | 4 | fs::read_to_string("config.txt") |
compiler/rustc_codegen_cranelift/build_system/main.rs+1-2| ... | ... | @@ -2,9 +2,8 @@ |
| 2 | 2 | #![warn(unused_lifetimes)] |
| 3 | 3 | #![warn(unreachable_pub)] |
| 4 | 4 | |
| 5 | use std::env; | |
| 6 | 5 | use std::path::PathBuf; |
| 7 | use std::process; | |
| 6 | use std::{env, process}; | |
| 8 | 7 | |
| 9 | 8 | use self::utils::Compiler; |
| 10 | 9 |
compiler/rustc_codegen_cranelift/build_system/tests.rs+1-3| ... | ... | @@ -3,14 +3,12 @@ use std::fs; |
| 3 | 3 | use std::path::PathBuf; |
| 4 | 4 | use std::process::Command; |
| 5 | 5 | |
| 6 | use crate::build_sysroot; | |
| 7 | use crate::config; | |
| 8 | 6 | use crate::path::{Dirs, RelPath}; |
| 9 | 7 | use crate::prepare::{apply_patches, GitRepo}; |
| 10 | 8 | use crate::rustc_info::get_default_sysroot; |
| 11 | 9 | use crate::shared_utils::rustflags_from_env; |
| 12 | 10 | use crate::utils::{spawn_and_wait, CargoProject, Compiler, LogGroup}; |
| 13 | use crate::{CodegenBackend, SysrootKind}; | |
| 11 | use crate::{build_sysroot, config, CodegenBackend, SysrootKind}; | |
| 14 | 12 | |
| 15 | 13 | static BUILD_EXAMPLE_OUT_DIR: RelPath = RelPath::BUILD.join("example"); |
| 16 | 14 |
compiler/rustc_codegen_cranelift/build_system/utils.rs+1-3| ... | ... | @@ -1,9 +1,7 @@ |
| 1 | use std::env; | |
| 2 | use std::fs; | |
| 3 | use std::io; | |
| 4 | 1 | use std::path::{Path, PathBuf}; |
| 5 | 2 | use std::process::{self, Command}; |
| 6 | 3 | use std::sync::atomic::{AtomicBool, Ordering}; |
| 4 | use std::{env, fs, io}; | |
| 7 | 5 | |
| 8 | 6 | use crate::path::{Dirs, RelPath}; |
| 9 | 7 | use crate::shared_utils::rustflags_to_cmd_env; |
compiler/rustc_codegen_cranelift/example/alloc_system.rs+3-2| ... | ... | @@ -8,8 +8,7 @@ pub struct System; |
| 8 | 8 | #[cfg(any(windows, unix, target_os = "redox"))] |
| 9 | 9 | mod realloc_fallback { |
| 10 | 10 | use core::alloc::{GlobalAlloc, Layout}; |
| 11 | use core::cmp; | |
| 12 | use core::ptr; | |
| 11 | use core::{cmp, ptr}; | |
| 13 | 12 | impl super::System { |
| 14 | 13 | pub(crate) unsafe fn realloc_fallback( |
| 15 | 14 | &self, |
| ... | ... | @@ -34,6 +33,7 @@ mod platform { |
| 34 | 33 | use core::alloc::{GlobalAlloc, Layout}; |
| 35 | 34 | use core::ffi::c_void; |
| 36 | 35 | use core::ptr; |
| 36 | ||
| 37 | 37 | use System; |
| 38 | 38 | extern "C" { |
| 39 | 39 | fn posix_memalign(memptr: *mut *mut c_void, align: usize, size: usize) -> i32; |
| ... | ... | @@ -71,6 +71,7 @@ mod platform { |
| 71 | 71 | #[allow(nonstandard_style)] |
| 72 | 72 | mod platform { |
| 73 | 73 | use core::alloc::{GlobalAlloc, Layout}; |
| 74 | ||
| 74 | 75 | use System; |
| 75 | 76 | type LPVOID = *mut u8; |
| 76 | 77 | type HANDLE = LPVOID; |
compiler/rustc_codegen_cranelift/example/arbitrary_self_types_pointers_and_wrappers.rs+2-4| ... | ... | @@ -2,10 +2,8 @@ |
| 2 | 2 | |
| 3 | 3 | #![feature(arbitrary_self_types, unsize, coerce_unsized, dispatch_from_dyn)] |
| 4 | 4 | |
| 5 | use std::{ | |
| 6 | marker::Unsize, | |
| 7 | ops::{CoerceUnsized, Deref, DispatchFromDyn}, | |
| 8 | }; | |
| 5 | use std::marker::Unsize; | |
| 6 | use std::ops::{CoerceUnsized, Deref, DispatchFromDyn}; | |
| 9 | 7 | |
| 10 | 8 | struct Ptr<T: ?Sized>(Box<T>); |
| 11 | 9 |
compiler/rustc_codegen_cranelift/rustfmt.toml+2| ... | ... | @@ -6,3 +6,5 @@ ignore = [ |
| 6 | 6 | version = "Two" |
| 7 | 7 | use_small_heuristics = "Max" |
| 8 | 8 | merge_derives = false |
| 9 | group_imports = "StdExternalCrate" | |
| 10 | imports_granularity = "Module" |
compiler/rustc_codegen_cranelift/src/debuginfo/unwind.rs+2-1| ... | ... | @@ -1,7 +1,8 @@ |
| 1 | 1 | //! Unwind info generation (`.eh_frame`) |
| 2 | 2 | |
| 3 | 3 | use cranelift_codegen::ir::Endianness; |
| 4 | use cranelift_codegen::isa::{unwind::UnwindInfo, TargetIsa}; | |
| 4 | use cranelift_codegen::isa::unwind::UnwindInfo; | |
| 5 | use cranelift_codegen::isa::TargetIsa; | |
| 5 | 6 | use cranelift_object::ObjectProduct; |
| 6 | 7 | use gimli::write::{CieId, EhFrame, FrameTable, Section}; |
| 7 | 8 | use gimli::RunTimeEndian; |
compiler/rustc_codegen_cranelift/src/driver/aot.rs+5-3| ... | ... | @@ -11,8 +11,9 @@ use rustc_codegen_ssa::assert_module_sources::CguReuse; |
| 11 | 11 | use rustc_codegen_ssa::back::link::ensure_removed; |
| 12 | 12 | use rustc_codegen_ssa::back::metadata::create_compressed_metadata_file; |
| 13 | 13 | use rustc_codegen_ssa::base::determine_cgu_reuse; |
| 14 | use rustc_codegen_ssa::errors as ssa_errors; | |
| 15 | use rustc_codegen_ssa::{CodegenResults, CompiledModule, CrateInfo, ModuleKind}; | |
| 14 | use rustc_codegen_ssa::{ | |
| 15 | errors as ssa_errors, CodegenResults, CompiledModule, CrateInfo, ModuleKind, | |
| 16 | }; | |
| 16 | 17 | use rustc_data_structures::profiling::SelfProfilerRef; |
| 17 | 18 | use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; |
| 18 | 19 | use rustc_data_structures::sync::{par_map, IntoDynSyncSend}; |
| ... | ... | @@ -26,8 +27,9 @@ use rustc_session::Session; |
| 26 | 27 | use crate::concurrency_limiter::{ConcurrencyLimiter, ConcurrencyLimiterToken}; |
| 27 | 28 | use crate::debuginfo::TypeDebugContext; |
| 28 | 29 | use crate::global_asm::GlobalAsmConfig; |
| 30 | use crate::prelude::*; | |
| 29 | 31 | use crate::unwind_module::UnwindModule; |
| 30 | use crate::{prelude::*, BackendConfig}; | |
| 32 | use crate::BackendConfig; | |
| 31 | 33 | |
| 32 | 34 | struct ModuleCodegenResult { |
| 33 | 35 | module_regular: CompiledModule, |
compiler/rustc_codegen_cranelift/src/driver/jit.rs+2-2| ... | ... | @@ -14,9 +14,9 @@ use rustc_session::Session; |
| 14 | 14 | use rustc_span::Symbol; |
| 15 | 15 | |
| 16 | 16 | use crate::debuginfo::TypeDebugContext; |
| 17 | use crate::prelude::*; | |
| 17 | 18 | use crate::unwind_module::UnwindModule; |
| 18 | use crate::{prelude::*, BackendConfig}; | |
| 19 | use crate::{CodegenCx, CodegenMode}; | |
| 19 | use crate::{BackendConfig, CodegenCx, CodegenMode}; | |
| 20 | 20 | |
| 21 | 21 | struct JitState { |
| 22 | 22 | jit_module: UnwindModule<JITModule>, |
compiler/rustc_codegen_cranelift/src/lib.rs+2-3| ... | ... | @@ -85,10 +85,9 @@ mod vtable; |
| 85 | 85 | mod prelude { |
| 86 | 86 | pub(crate) use cranelift_codegen::ir::condcodes::{FloatCC, IntCC}; |
| 87 | 87 | pub(crate) use cranelift_codegen::ir::function::Function; |
| 88 | pub(crate) use cranelift_codegen::ir::types; | |
| 89 | 88 | pub(crate) use cranelift_codegen::ir::{ |
| 90 | AbiParam, Block, FuncRef, Inst, InstBuilder, MemFlags, Signature, SourceLoc, StackSlot, | |
| 91 | StackSlotData, StackSlotKind, TrapCode, Type, Value, | |
| 89 | types, AbiParam, Block, FuncRef, Inst, InstBuilder, MemFlags, Signature, SourceLoc, | |
| 90 | StackSlot, StackSlotData, StackSlotKind, TrapCode, Type, Value, | |
| 92 | 91 | }; |
| 93 | 92 | pub(crate) use cranelift_codegen::Context; |
| 94 | 93 | pub(crate) use cranelift_module::{self, DataDescription, FuncId, Linkage, Module}; |
compiler/rustc_codegen_cranelift/src/main_shim.rs+1-2| ... | ... | @@ -1,7 +1,6 @@ |
| 1 | 1 | use cranelift_frontend::{FunctionBuilder, FunctionBuilderContext}; |
| 2 | 2 | use rustc_hir::LangItem; |
| 3 | use rustc_middle::ty::AssocKind; | |
| 4 | use rustc_middle::ty::GenericArg; | |
| 3 | use rustc_middle::ty::{AssocKind, GenericArg}; | |
| 5 | 4 | use rustc_session::config::{sigpipe, EntryFnType}; |
| 6 | 5 | use rustc_span::symbol::Ident; |
| 7 | 6 | use rustc_span::DUMMY_SP; |
compiler/rustc_codegen_cranelift/src/optimize/peephole.rs+2-1| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | 1 | //! Peephole optimizations that can be performed while creating clif ir. |
| 2 | 2 | |
| 3 | use cranelift_codegen::ir::{condcodes::IntCC, InstructionData, Opcode, Value, ValueDef}; | |
| 3 | use cranelift_codegen::ir::condcodes::IntCC; | |
| 4 | use cranelift_codegen::ir::{InstructionData, Opcode, Value, ValueDef}; | |
| 4 | 5 | use cranelift_frontend::FunctionBuilder; |
| 5 | 6 | |
| 6 | 7 | /// If the given value was produced by the lowering of `Rvalue::Not` return the input and true, |
compiler/rustc_codegen_gcc/build_system/src/build.rs+5-4| ... | ... | @@ -1,12 +1,13 @@ |
| 1 | use crate::config::{Channel, ConfigInfo}; | |
| 2 | use crate::utils::{ | |
| 3 | copy_file, create_dir, get_sysroot_dir, run_command, run_command_with_output_and_env, walk_dir, | |
| 4 | }; | |
| 5 | 1 | use std::collections::HashMap; |
| 6 | 2 | use std::ffi::OsStr; |
| 7 | 3 | use std::fs; |
| 8 | 4 | use std::path::Path; |
| 9 | 5 | |
| 6 | use crate::config::{Channel, ConfigInfo}; | |
| 7 | use crate::utils::{ | |
| 8 | copy_file, create_dir, get_sysroot_dir, run_command, run_command_with_output_and_env, walk_dir, | |
| 9 | }; | |
| 10 | ||
| 10 | 11 | #[derive(Default)] |
| 11 | 12 | struct BuildArg { |
| 12 | 13 | flags: Vec<String>, |
compiler/rustc_codegen_gcc/build_system/src/clean.rs+2-2| ... | ... | @@ -1,8 +1,8 @@ |
| 1 | use crate::utils::{get_sysroot_dir, remove_file, run_command}; | |
| 2 | ||
| 3 | 1 | use std::fs::remove_dir_all; |
| 4 | 2 | use std::path::Path; |
| 5 | 3 | |
| 4 | use crate::utils::{get_sysroot_dir, remove_file, run_command}; | |
| 5 | ||
| 6 | 6 | #[derive(Default)] |
| 7 | 7 | enum CleanArg { |
| 8 | 8 | /// `clean all` |
compiler/rustc_codegen_gcc/build_system/src/clone_gcc.rs+2-2| ... | ... | @@ -1,8 +1,8 @@ |
| 1 | use std::path::{Path, PathBuf}; | |
| 2 | ||
| 1 | 3 | use crate::config::ConfigInfo; |
| 2 | 4 | use crate::utils::{git_clone, run_command_with_output}; |
| 3 | 5 | |
| 4 | use std::path::{Path, PathBuf}; | |
| 5 | ||
| 6 | 6 | fn show_usage() { |
| 7 | 7 | println!( |
| 8 | 8 | r#" |
compiler/rustc_codegen_gcc/build_system/src/config.rs+8-7| ... | ... | @@ -1,14 +1,15 @@ |
| 1 | use crate::utils::{ | |
| 2 | create_dir, create_symlink, get_os_name, get_sysroot_dir, run_command_with_output, | |
| 3 | rustc_version_info, split_args, | |
| 4 | }; | |
| 5 | 1 | use std::collections::HashMap; |
| 6 | use std::env as std_env; | |
| 7 | 2 | use std::ffi::OsStr; |
| 8 | use std::fs; | |
| 9 | 3 | use std::path::{Path, PathBuf}; |
| 4 | use std::{env as std_env, fs}; | |
| 5 | ||
| 6 | use boml::types::TomlValue; | |
| 7 | use boml::Toml; | |
| 10 | 8 | |
| 11 | use boml::{types::TomlValue, Toml}; | |
| 9 | use crate::utils::{ | |
| 10 | create_dir, create_symlink, get_os_name, get_sysroot_dir, run_command_with_output, | |
| 11 | rustc_version_info, split_args, | |
| 12 | }; | |
| 12 | 13 | |
| 13 | 14 | #[derive(Default, PartialEq, Eq, Clone, Copy, Debug)] |
| 14 | 15 | pub enum Channel { |
compiler/rustc_codegen_gcc/build_system/src/fmt.rs+2-1| ... | ... | @@ -1,7 +1,8 @@ |
| 1 | use crate::utils::run_command_with_output; | |
| 2 | 1 | use std::ffi::OsStr; |
| 3 | 2 | use std::path::Path; |
| 4 | 3 | |
| 4 | use crate::utils::run_command_with_output; | |
| 5 | ||
| 5 | 6 | fn show_usage() { |
| 6 | 7 | println!( |
| 7 | 8 | r#" |
compiler/rustc_codegen_gcc/build_system/src/main.rs+1-2| ... | ... | @@ -1,5 +1,4 @@ |
| 1 | use std::env; | |
| 2 | use std::process; | |
| 1 | use std::{env, process}; | |
| 3 | 2 | |
| 4 | 3 | mod build; |
| 5 | 4 | mod clean; |
compiler/rustc_codegen_gcc/build_system/src/prepare.rs+3-3| ... | ... | @@ -1,12 +1,12 @@ |
| 1 | use std::fs; | |
| 2 | use std::path::{Path, PathBuf}; | |
| 3 | ||
| 1 | 4 | use crate::rustc_info::get_rustc_path; |
| 2 | 5 | use crate::utils::{ |
| 3 | 6 | cargo_install, create_dir, get_sysroot_dir, git_clone_root_dir, remove_file, run_command, |
| 4 | 7 | run_command_with_output, walk_dir, |
| 5 | 8 | }; |
| 6 | 9 | |
| 7 | use std::fs; | |
| 8 | use std::path::{Path, PathBuf}; | |
| 9 | ||
| 10 | 10 | fn prepare_libcore( |
| 11 | 11 | sysroot_path: &Path, |
| 12 | 12 | libgccjit12_patches: bool, |
compiler/rustc_codegen_gcc/build_system/src/rust_tools.rs+4-4| ... | ... | @@ -1,13 +1,13 @@ |
| 1 | use std::collections::HashMap; | |
| 2 | use std::ffi::OsStr; | |
| 3 | use std::path::PathBuf; | |
| 4 | ||
| 1 | 5 | use crate::config::ConfigInfo; |
| 2 | 6 | use crate::utils::{ |
| 3 | 7 | get_toolchain, run_command_with_output_and_env_no_err, rustc_toolchain_version_info, |
| 4 | 8 | rustc_version_info, |
| 5 | 9 | }; |
| 6 | 10 | |
| 7 | use std::collections::HashMap; | |
| 8 | use std::ffi::OsStr; | |
| 9 | use std::path::PathBuf; | |
| 10 | ||
| 11 | 11 | fn args(command: &str) -> Result<Option<Vec<String>>, String> { |
| 12 | 12 | // We skip the binary and the "cargo"/"rustc" option. |
| 13 | 13 | if let Some("--help") = std::env::args().skip(2).next().as_deref() { |
compiler/rustc_codegen_gcc/build_system/src/test.rs+7-7| ... | ... | @@ -1,3 +1,10 @@ |
| 1 | use std::collections::HashMap; | |
| 2 | use std::ffi::OsStr; | |
| 3 | use std::fs::{remove_dir_all, File}; | |
| 4 | use std::io::{BufRead, BufReader}; | |
| 5 | use std::path::{Path, PathBuf}; | |
| 6 | use std::str::FromStr; | |
| 7 | ||
| 1 | 8 | use crate::build; |
| 2 | 9 | use crate::config::{Channel, ConfigInfo}; |
| 3 | 10 | use crate::utils::{ |
| ... | ... | @@ -6,13 +13,6 @@ use crate::utils::{ |
| 6 | 13 | split_args, walk_dir, |
| 7 | 14 | }; |
| 8 | 15 | |
| 9 | use std::collections::HashMap; | |
| 10 | use std::ffi::OsStr; | |
| 11 | use std::fs::{remove_dir_all, File}; | |
| 12 | use std::io::{BufRead, BufReader}; | |
| 13 | use std::path::{Path, PathBuf}; | |
| 14 | use std::str::FromStr; | |
| 15 | ||
| 16 | 16 | type Env = HashMap<String, String>; |
| 17 | 17 | type Runner = fn(&Env, &TestArg) -> Result<(), String>; |
| 18 | 18 | type Runners = HashMap<&'static str, (&'static str, Runner)>; |
compiler/rustc_codegen_gcc/src/archive.rs+1-2| ... | ... | @@ -3,9 +3,8 @@ use std::path::{Path, PathBuf}; |
| 3 | 3 | use rustc_codegen_ssa::back::archive::{ |
| 4 | 4 | ArArchiveBuilder, ArchiveBuilder, ArchiveBuilderBuilder, DEFAULT_OBJECT_READER, |
| 5 | 5 | }; |
| 6 | use rustc_session::Session; | |
| 7 | ||
| 8 | 6 | use rustc_session::cstore::DllImport; |
| 7 | use rustc_session::Session; | |
| 9 | 8 | |
| 10 | 9 | pub(crate) struct ArArchiveBuilderBuilder; |
| 11 | 10 |
compiler/rustc_codegen_gcc/src/asm.rs+4-4| ... | ... | @@ -1,3 +1,5 @@ |
| 1 | use std::borrow::Cow; | |
| 2 | ||
| 1 | 3 | use gccjit::{LValue, RValue, ToRValue, Type}; |
| 2 | 4 | use rustc_ast::ast::{InlineAsmOptions, InlineAsmTemplatePiece}; |
| 3 | 5 | use rustc_codegen_ssa::mir::operand::OperandValue; |
| ... | ... | @@ -6,13 +8,11 @@ use rustc_codegen_ssa::traits::{ |
| 6 | 8 | AsmBuilderMethods, AsmMethods, BaseTypeMethods, BuilderMethods, GlobalAsmOperandRef, |
| 7 | 9 | InlineAsmOperandRef, |
| 8 | 10 | }; |
| 9 | ||
| 10 | use rustc_middle::{bug, ty::Instance}; | |
| 11 | use rustc_middle::bug; | |
| 12 | use rustc_middle::ty::Instance; | |
| 11 | 13 | use rustc_span::Span; |
| 12 | 14 | use rustc_target::asm::*; |
| 13 | 15 | |
| 14 | use std::borrow::Cow; | |
| 15 | ||
| 16 | 16 | use crate::builder::Builder; |
| 17 | 17 | use crate::callee::get_fn; |
| 18 | 18 | use crate::context::CodegenCx; |
compiler/rustc_codegen_gcc/src/attributes.rs+2-1| ... | ... | @@ -9,8 +9,9 @@ use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags; |
| 9 | 9 | use rustc_middle::ty; |
| 10 | 10 | use rustc_span::symbol::sym; |
| 11 | 11 | |
| 12 | use crate::context::CodegenCx; | |
| 13 | use crate::errors::TiedTargetFeatures; | |
| 12 | 14 | use crate::gcc_util::{check_tied_features, to_gcc_features}; |
| 13 | use crate::{context::CodegenCx, errors::TiedTargetFeatures}; | |
| 14 | 15 | |
| 15 | 16 | /// Get GCC attribute for the provided inline heuristic. |
| 16 | 17 | #[cfg(feature = "master")] |
compiler/rustc_codegen_gcc/src/base.rs+1-2| ... | ... | @@ -19,8 +19,7 @@ use rustc_target::spec::PanicStrategy; |
| 19 | 19 | |
| 20 | 20 | use crate::builder::Builder; |
| 21 | 21 | use crate::context::CodegenCx; |
| 22 | use crate::{gcc_util, new_context, LockedTargetInfo}; | |
| 23 | use crate::{GccContext, SyncContext}; | |
| 22 | use crate::{gcc_util, new_context, GccContext, LockedTargetInfo, SyncContext}; | |
| 24 | 23 | |
| 25 | 24 | #[cfg(feature = "master")] |
| 26 | 25 | pub fn visibility_to_gcc(linkage: Visibility) -> gccjit::Visibility { |
compiler/rustc_codegen_gcc/src/builder.rs+2-3| ... | ... | @@ -28,9 +28,8 @@ use rustc_middle::ty::layout::{ |
| 28 | 28 | use rustc_middle::ty::{Instance, ParamEnv, Ty, TyCtxt}; |
| 29 | 29 | use rustc_span::def_id::DefId; |
| 30 | 30 | use rustc_span::Span; |
| 31 | use rustc_target::abi::{ | |
| 32 | self, call::FnAbi, Align, HasDataLayout, Size, TargetDataLayout, WrappingRange, | |
| 33 | }; | |
| 31 | use rustc_target::abi::call::FnAbi; | |
| 32 | use rustc_target::abi::{self, Align, HasDataLayout, Size, TargetDataLayout, WrappingRange}; | |
| 34 | 33 | use rustc_target::spec::{HasTargetSpec, HasWasmCAbiOpt, Target, WasmCAbi}; |
| 35 | 34 | |
| 36 | 35 | use crate::common::{type_is_pointer, SignType, TypeReflection}; |
compiler/rustc_codegen_gcc/src/common.rs+1-2| ... | ... | @@ -1,5 +1,4 @@ |
| 1 | use gccjit::LValue; | |
| 2 | use gccjit::{RValue, ToRValue, Type}; | |
| 1 | use gccjit::{LValue, RValue, ToRValue, Type}; | |
| 3 | 2 | use rustc_codegen_ssa::traits::{BaseTypeMethods, ConstMethods, MiscMethods, StaticMethods}; |
| 4 | 3 | use rustc_middle::mir::interpret::{ConstAllocation, GlobalAlloc, Scalar}; |
| 5 | 4 | use rustc_middle::mir::Mutability; |
compiler/rustc_codegen_gcc/src/consts.rs+1-2| ... | ... | @@ -3,14 +3,13 @@ use gccjit::{FnAttribute, VarAttribute, Visibility}; |
| 3 | 3 | use gccjit::{Function, GlobalKind, LValue, RValue, ToRValue, Type}; |
| 4 | 4 | use rustc_codegen_ssa::traits::{BaseTypeMethods, ConstMethods, StaticMethods}; |
| 5 | 5 | use rustc_hir::def::DefKind; |
| 6 | use rustc_middle::bug; | |
| 7 | 6 | use rustc_middle::middle::codegen_fn_attrs::{CodegenFnAttrFlags, CodegenFnAttrs}; |
| 8 | 7 | use rustc_middle::mir::interpret::{ |
| 9 | 8 | self, read_target_uint, ConstAllocation, ErrorHandled, Scalar as InterpScalar, |
| 10 | 9 | }; |
| 11 | use rustc_middle::span_bug; | |
| 12 | 10 | use rustc_middle::ty::layout::LayoutOf; |
| 13 | 11 | use rustc_middle::ty::{self, Instance}; |
| 12 | use rustc_middle::{bug, span_bug}; | |
| 14 | 13 | use rustc_span::def_id::DefId; |
| 15 | 14 | use rustc_target::abi::{self, Align, HasDataLayout, Primitive, Size, WrappingRange}; |
| 16 | 15 |
compiler/rustc_codegen_gcc/src/context.rs+5-6| ... | ... | @@ -6,8 +6,7 @@ use gccjit::{ |
| 6 | 6 | use rustc_codegen_ssa::base::wants_msvc_seh; |
| 7 | 7 | use rustc_codegen_ssa::errors as ssa_errors; |
| 8 | 8 | use rustc_codegen_ssa::traits::{BackendTypes, BaseTypeMethods, MiscMethods}; |
| 9 | use rustc_data_structures::base_n::ToBaseN; | |
| 10 | use rustc_data_structures::base_n::ALPHANUMERIC_ONLY; | |
| 9 | use rustc_data_structures::base_n::{ToBaseN, ALPHANUMERIC_ONLY}; | |
| 11 | 10 | use rustc_data_structures::fx::{FxHashMap, FxHashSet}; |
| 12 | 11 | use rustc_middle::mir::mono::CodegenUnit; |
| 13 | 12 | use rustc_middle::span_bug; |
| ... | ... | @@ -17,10 +16,10 @@ use rustc_middle::ty::layout::{ |
| 17 | 16 | }; |
| 18 | 17 | use rustc_middle::ty::{self, Instance, ParamEnv, PolyExistentialTraitRef, Ty, TyCtxt}; |
| 19 | 18 | use rustc_session::Session; |
| 20 | use rustc_span::{source_map::respan, Span, DUMMY_SP}; | |
| 21 | use rustc_target::abi::{ | |
| 22 | call::FnAbi, HasDataLayout, PointeeInfo, Size, TargetDataLayout, VariantIdx, | |
| 23 | }; | |
| 19 | use rustc_span::source_map::respan; | |
| 20 | use rustc_span::{Span, DUMMY_SP}; | |
| 21 | use rustc_target::abi::call::FnAbi; | |
| 22 | use rustc_target::abi::{HasDataLayout, PointeeInfo, Size, TargetDataLayout, VariantIdx}; | |
| 24 | 23 | use rustc_target::spec::{HasTargetSpec, HasWasmCAbiOpt, Target, TlsModel, WasmCAbi}; |
| 25 | 24 | |
| 26 | 25 | use crate::callee::get_fn; |
compiler/rustc_codegen_gcc/src/debuginfo.rs+2-1| ... | ... | @@ -1,3 +1,5 @@ |
| 1 | use std::ops::Range; | |
| 2 | ||
| 1 | 3 | use gccjit::{Location, RValue}; |
| 2 | 4 | use rustc_codegen_ssa::mir::debuginfo::{DebugScope, FunctionDebugContext, VariableKind}; |
| 3 | 5 | use rustc_codegen_ssa::traits::{DebugInfoBuilderMethods, DebugInfoMethods}; |
| ... | ... | @@ -10,7 +12,6 @@ use rustc_session::config::DebugInfo; |
| 10 | 12 | use rustc_span::{BytePos, Pos, SourceFile, SourceFileAndLine, Span, Symbol}; |
| 11 | 13 | use rustc_target::abi::call::FnAbi; |
| 12 | 14 | use rustc_target::abi::Size; |
| 13 | use std::ops::Range; | |
| 14 | 15 | |
| 15 | 16 | use crate::builder::Builder; |
| 16 | 17 | use crate::context::CodegenCx; |
compiler/rustc_codegen_gcc/src/gcc_util.rs+1-2| ... | ... | @@ -1,11 +1,10 @@ |
| 1 | 1 | #[cfg(feature = "master")] |
| 2 | 2 | use gccjit::Context; |
| 3 | use smallvec::{smallvec, SmallVec}; | |
| 4 | ||
| 5 | 3 | use rustc_data_structures::fx::FxHashMap; |
| 6 | 4 | use rustc_middle::bug; |
| 7 | 5 | use rustc_session::Session; |
| 8 | 6 | use rustc_target::target_features::RUSTC_SPECIFIC_FEATURES; |
| 7 | use smallvec::{smallvec, SmallVec}; | |
| 9 | 8 | |
| 10 | 9 | use crate::errors::{ |
| 11 | 10 | PossibleFeature, TargetFeatureDisableOrEnable, UnknownCTargetFeature, |
compiler/rustc_codegen_gcc/src/int.rs+8-11| ... | ... | @@ -6,18 +6,13 @@ use gccjit::{BinaryOp, ComparisonOp, FunctionType, Location, RValue, ToRValue, T |
| 6 | 6 | use rustc_codegen_ssa::common::{IntPredicate, TypeKind}; |
| 7 | 7 | use rustc_codegen_ssa::traits::{BackendTypes, BaseTypeMethods, BuilderMethods, OverflowOp}; |
| 8 | 8 | use rustc_middle::ty::{ParamEnv, Ty}; |
| 9 | use rustc_target::abi::{ | |
| 10 | call::{ArgAbi, ArgAttributes, Conv, FnAbi, PassMode}, | |
| 11 | Endian, | |
| 12 | }; | |
| 9 | use rustc_target::abi::call::{ArgAbi, ArgAttributes, Conv, FnAbi, PassMode}; | |
| 10 | use rustc_target::abi::Endian; | |
| 13 | 11 | use rustc_target::spec; |
| 14 | 12 | |
| 15 | use crate::builder::ToGccComp; | |
| 16 | use crate::{ | |
| 17 | builder::Builder, | |
| 18 | common::{SignType, TypeReflection}, | |
| 19 | context::CodegenCx, | |
| 20 | }; | |
| 13 | use crate::builder::{Builder, ToGccComp}; | |
| 14 | use crate::common::{SignType, TypeReflection}; | |
| 15 | use crate::context::CodegenCx; | |
| 21 | 16 | |
| 22 | 17 | impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> { |
| 23 | 18 | pub fn gcc_urem(&self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> { |
| ... | ... | @@ -266,7 +261,9 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> { |
| 266 | 261 | lhs: <Self as BackendTypes>::Value, |
| 267 | 262 | rhs: <Self as BackendTypes>::Value, |
| 268 | 263 | ) -> (<Self as BackendTypes>::Value, <Self as BackendTypes>::Value) { |
| 269 | use rustc_middle::ty::{Int, IntTy::*, Uint, UintTy::*}; | |
| 264 | use rustc_middle::ty::IntTy::*; | |
| 265 | use rustc_middle::ty::UintTy::*; | |
| 266 | use rustc_middle::ty::{Int, Uint}; | |
| 270 | 267 | |
| 271 | 268 | let new_kind = match *typ.kind() { |
| 272 | 269 | Int(t @ Isize) => Int(t.normalize(self.tcx.sess.target.pointer_width)), |
compiler/rustc_codegen_gcc/src/intrinsic/llvm.rs+2-1| ... | ... | @@ -3,7 +3,8 @@ use std::borrow::Cow; |
| 3 | 3 | use gccjit::{Function, FunctionPtrType, RValue, ToRValue, UnaryOp}; |
| 4 | 4 | use rustc_codegen_ssa::traits::BuilderMethods; |
| 5 | 5 | |
| 6 | use crate::{builder::Builder, context::CodegenCx}; | |
| 6 | use crate::builder::Builder; | |
| 7 | use crate::context::CodegenCx; | |
| 7 | 8 | |
| 8 | 9 | pub fn adjust_intrinsic_arguments<'a, 'b, 'gcc, 'tcx>( |
| 9 | 10 | builder: &Builder<'a, 'gcc, 'tcx>, |
compiler/rustc_codegen_gcc/src/intrinsic/simd.rs+1-3| ... | ... | @@ -1,10 +1,8 @@ |
| 1 | 1 | use std::iter::FromIterator; |
| 2 | 2 | |
| 3 | use gccjit::ToRValue; | |
| 4 | use gccjit::{BinaryOp, RValue, Type}; | |
| 3 | use gccjit::{BinaryOp, RValue, ToRValue, Type}; | |
| 5 | 4 | #[cfg(feature = "master")] |
| 6 | 5 | use gccjit::{ComparisonOp, UnaryOp}; |
| 7 | ||
| 8 | 6 | use rustc_codegen_ssa::base::compare_simd_types; |
| 9 | 7 | use rustc_codegen_ssa::common::{IntPredicate, TypeKind}; |
| 10 | 8 | #[cfg(feature = "master")] |
compiler/rustc_codegen_gcc/src/lib.rs+3-6| ... | ... | @@ -79,14 +79,11 @@ use std::ops::Deref; |
| 79 | 79 | use std::sync::atomic::AtomicBool; |
| 80 | 80 | #[cfg(not(feature = "master"))] |
| 81 | 81 | use std::sync::atomic::Ordering; |
| 82 | use std::sync::Arc; | |
| 83 | use std::sync::Mutex; | |
| 82 | use std::sync::{Arc, Mutex}; | |
| 84 | 83 | |
| 85 | use back::lto::ThinBuffer; | |
| 86 | use back::lto::ThinData; | |
| 84 | use back::lto::{ThinBuffer, ThinData}; | |
| 87 | 85 | use errors::LTONotSupported; |
| 88 | use gccjit::CType; | |
| 89 | use gccjit::{Context, OptimizationLevel}; | |
| 86 | use gccjit::{CType, Context, OptimizationLevel}; | |
| 90 | 87 | #[cfg(feature = "master")] |
| 91 | 88 | use gccjit::{TargetInfo, Version}; |
| 92 | 89 | use rustc_ast::expand::allocator::AllocatorKind; |
compiler/rustc_codegen_gcc/src/mono_item.rs+1-2| ... | ... | @@ -9,10 +9,9 @@ use rustc_middle::mir::mono::{Linkage, Visibility}; |
| 9 | 9 | use rustc_middle::ty::layout::{FnAbiOf, LayoutOf}; |
| 10 | 10 | use rustc_middle::ty::{self, Instance, TypeVisitableExt}; |
| 11 | 11 | |
| 12 | use crate::attributes; | |
| 13 | use crate::base; | |
| 14 | 12 | use crate::context::CodegenCx; |
| 15 | 13 | use crate::type_of::LayoutGccExt; |
| 14 | use crate::{attributes, base}; | |
| 16 | 15 | |
| 17 | 16 | impl<'gcc, 'tcx> PreDefineMethods<'tcx> for CodegenCx<'gcc, 'tcx> { |
| 18 | 17 | #[cfg_attr(not(feature = "master"), allow(unused_variables))] |
compiler/rustc_codegen_llvm/src/abi.rs+9-11| ... | ... | @@ -1,12 +1,6 @@ |
| 1 | use crate::attributes; | |
| 2 | use crate::builder::Builder; | |
| 3 | use crate::context::CodegenCx; | |
| 4 | use crate::llvm::{self, Attribute, AttributePlace}; | |
| 5 | use crate::llvm_util; | |
| 6 | use crate::type_::Type; | |
| 7 | use crate::type_of::LayoutLlvmExt; | |
| 8 | use crate::value::Value; | |
| 1 | use std::cmp; | |
| 9 | 2 | |
| 3 | use libc::c_uint; | |
| 10 | 4 | use rustc_codegen_ssa::mir::operand::{OperandRef, OperandValue}; |
| 11 | 5 | use rustc_codegen_ssa::mir::place::{PlaceRef, PlaceValue}; |
| 12 | 6 | use rustc_codegen_ssa::traits::*; |
| ... | ... | @@ -20,11 +14,15 @@ pub use rustc_target::abi::call::*; |
| 20 | 14 | use rustc_target::abi::{self, HasDataLayout, Int, Size}; |
| 21 | 15 | pub use rustc_target::spec::abi::Abi; |
| 22 | 16 | use rustc_target::spec::SanitizerSet; |
| 23 | ||
| 24 | use libc::c_uint; | |
| 25 | 17 | use smallvec::SmallVec; |
| 26 | 18 | |
| 27 | use std::cmp; | |
| 19 | use crate::builder::Builder; | |
| 20 | use crate::context::CodegenCx; | |
| 21 | use crate::llvm::{self, Attribute, AttributePlace}; | |
| 22 | use crate::type_::Type; | |
| 23 | use crate::type_of::LayoutLlvmExt; | |
| 24 | use crate::value::Value; | |
| 25 | use crate::{attributes, llvm_util}; | |
| 28 | 26 | |
| 29 | 27 | pub trait ArgAttributesExt { |
| 30 | 28 | fn apply_attrs_to_llfn(&self, idx: AttributePlace, cx: &CodegenCx<'_, '_>, llfn: &Value); |
compiler/rustc_codegen_llvm/src/allocator.rs+1-3| ... | ... | @@ -1,4 +1,3 @@ |
| 1 | use crate::attributes; | |
| 2 | 1 | use libc::c_uint; |
| 3 | 2 | use rustc_ast::expand::allocator::{ |
| 4 | 3 | alloc_error_handler_name, default_fn_name, global_fn_name, AllocatorKind, AllocatorTy, |
| ... | ... | @@ -8,9 +7,8 @@ use rustc_middle::bug; |
| 8 | 7 | use rustc_middle::ty::TyCtxt; |
| 9 | 8 | use rustc_session::config::{DebugInfo, OomStrategy}; |
| 10 | 9 | |
| 11 | use crate::debuginfo; | |
| 12 | 10 | use crate::llvm::{self, Context, False, Module, True, Type}; |
| 13 | use crate::ModuleLlvm; | |
| 11 | use crate::{attributes, debuginfo, ModuleLlvm}; | |
| 14 | 12 | |
| 15 | 13 | pub(crate) unsafe fn codegen( |
| 16 | 14 | tcx: TyCtxt<'_>, |
compiler/rustc_codegen_llvm/src/asm.rs+11-12| ... | ... | @@ -1,25 +1,24 @@ |
| 1 | use crate::attributes; | |
| 2 | use crate::builder::Builder; | |
| 3 | use crate::common::Funclet; | |
| 4 | use crate::context::CodegenCx; | |
| 5 | use crate::llvm; | |
| 6 | use crate::type_::Type; | |
| 7 | use crate::type_of::LayoutLlvmExt; | |
| 8 | use crate::value::Value; | |
| 9 | ||
| 1 | use libc::{c_char, c_uint}; | |
| 10 | 2 | use rustc_ast::{InlineAsmOptions, InlineAsmTemplatePiece}; |
| 11 | 3 | use rustc_codegen_ssa::mir::operand::OperandValue; |
| 12 | 4 | use rustc_codegen_ssa::traits::*; |
| 13 | 5 | use rustc_data_structures::fx::FxHashMap; |
| 14 | 6 | use rustc_middle::ty::layout::TyAndLayout; |
| 15 | use rustc_middle::{bug, span_bug, ty::Instance}; | |
| 7 | use rustc_middle::ty::Instance; | |
| 8 | use rustc_middle::{bug, span_bug}; | |
| 16 | 9 | use rustc_span::{sym, Pos, Span, Symbol}; |
| 17 | 10 | use rustc_target::abi::*; |
| 18 | 11 | use rustc_target::asm::*; |
| 12 | use smallvec::SmallVec; | |
| 19 | 13 | use tracing::debug; |
| 20 | 14 | |
| 21 | use libc::{c_char, c_uint}; | |
| 22 | use smallvec::SmallVec; | |
| 15 | use crate::builder::Builder; | |
| 16 | use crate::common::Funclet; | |
| 17 | use crate::context::CodegenCx; | |
| 18 | use crate::type_::Type; | |
| 19 | use crate::type_of::LayoutLlvmExt; | |
| 20 | use crate::value::Value; | |
| 21 | use crate::{attributes, llvm}; | |
| 23 | 22 | |
| 24 | 23 | impl<'ll, 'tcx> AsmBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> { |
| 25 | 24 | fn codegen_inline_asm( |
compiler/rustc_codegen_llvm/src/attributes.rs+3-5| ... | ... | @@ -1,5 +1,6 @@ |
| 1 | 1 | //! Set and unset common attributes on LLVM values. |
| 2 | 2 | |
| 3 | pub use rustc_attr::{InlineAttr, InstructionSetAttr, OptimizeAttr}; | |
| 3 | 4 | use rustc_codegen_ssa::traits::*; |
| 4 | 5 | use rustc_hir::def_id::DefId; |
| 5 | 6 | use rustc_middle::middle::codegen_fn_attrs::{CodegenFnAttrFlags, PatchableFunctionEntry}; |
| ... | ... | @@ -9,15 +10,12 @@ use rustc_span::symbol::sym; |
| 9 | 10 | use rustc_target::spec::{FramePointer, SanitizerSet, StackProbeType, StackProtector}; |
| 10 | 11 | use smallvec::SmallVec; |
| 11 | 12 | |
| 12 | use crate::attributes; | |
| 13 | use crate::context::CodegenCx; | |
| 13 | 14 | use crate::errors::{MissingFeatures, SanitizerMemtagRequiresMte, TargetFeatureDisableOrEnable}; |
| 14 | 15 | use crate::llvm::AttributePlace::Function; |
| 15 | 16 | use crate::llvm::{self, AllocKindFlags, Attribute, AttributeKind, AttributePlace, MemoryEffects}; |
| 16 | use crate::llvm_util; | |
| 17 | pub use rustc_attr::{InlineAttr, InstructionSetAttr, OptimizeAttr}; | |
| 18 | ||
| 19 | use crate::context::CodegenCx; | |
| 20 | 17 | use crate::value::Value; |
| 18 | use crate::{attributes, llvm_util}; | |
| 21 | 19 | |
| 22 | 20 | pub fn apply_to_llfn(llfn: &Value, idx: AttributePlace, attrs: &[&Attribute]) { |
| 23 | 21 | if !attrs.is_empty() { |
compiler/rustc_codegen_llvm/src/back/archive.rs+9-13| ... | ... | @@ -1,27 +1,23 @@ |
| 1 | 1 | //! A helper class for dealing with static archives |
| 2 | 2 | |
| 3 | use std::env; | |
| 4 | 3 | use std::ffi::{c_char, c_void, CStr, CString, OsString}; |
| 5 | use std::io; | |
| 6 | use std::mem; | |
| 7 | 4 | use std::path::{Path, PathBuf}; |
| 8 | use std::ptr; | |
| 9 | use std::str; | |
| 5 | use std::{env, io, mem, ptr, str}; | |
| 10 | 6 | |
| 11 | use crate::common; | |
| 12 | use crate::errors::{ | |
| 13 | DlltoolFailImportLibrary, ErrorCallingDllTool, ErrorCreatingImportLibrary, ErrorWritingDEFFile, | |
| 14 | }; | |
| 15 | use crate::llvm::archive_ro::{ArchiveRO, Child}; | |
| 16 | use crate::llvm::{self, ArchiveKind, LLVMMachineType, LLVMRustCOFFShortExport}; | |
| 17 | 7 | use rustc_codegen_ssa::back::archive::{ |
| 18 | 8 | try_extract_macho_fat_archive, ArArchiveBuilder, ArchiveBuildFailure, ArchiveBuilder, |
| 19 | 9 | ArchiveBuilderBuilder, ObjectReader, UnknownArchiveKind, DEFAULT_OBJECT_READER, |
| 20 | 10 | }; |
| 21 | use tracing::trace; | |
| 22 | ||
| 23 | 11 | use rustc_session::cstore::DllImport; |
| 24 | 12 | use rustc_session::Session; |
| 13 | use tracing::trace; | |
| 14 | ||
| 15 | use crate::common; | |
| 16 | use crate::errors::{ | |
| 17 | DlltoolFailImportLibrary, ErrorCallingDllTool, ErrorCreatingImportLibrary, ErrorWritingDEFFile, | |
| 18 | }; | |
| 19 | use crate::llvm::archive_ro::{ArchiveRO, Child}; | |
| 20 | use crate::llvm::{self, ArchiveKind, LLVMMachineType, LLVMRustCOFFShortExport}; | |
| 25 | 21 | |
| 26 | 22 | /// Helper for adding many files to an archive. |
| 27 | 23 | #[must_use = "must call build() to finish building the archive"] |
compiler/rustc_codegen_llvm/src/back/lto.rs+16-17| ... | ... | @@ -1,11 +1,11 @@ |
| 1 | use crate::back::write::{ | |
| 2 | self, bitcode_section_name, save_temp_bitcode, CodegenDiagnosticsStage, DiagnosticHandlers, | |
| 3 | }; | |
| 4 | use crate::errors::{ | |
| 5 | DynamicLinkingWithLTO, LlvmError, LtoBitcodeFromRlib, LtoDisallowed, LtoDylib, LtoProcMacro, | |
| 6 | }; | |
| 7 | use crate::llvm::{self, build_string}; | |
| 8 | use crate::{LlvmCodegenBackend, ModuleLlvm}; | |
| 1 | use std::collections::BTreeMap; | |
| 2 | use std::ffi::{CStr, CString}; | |
| 3 | use std::fs::File; | |
| 4 | use std::mem::ManuallyDrop; | |
| 5 | use std::path::Path; | |
| 6 | use std::sync::Arc; | |
| 7 | use std::{io, iter, slice}; | |
| 8 | ||
| 9 | 9 | use object::read::archive::ArchiveFile; |
| 10 | 10 | use rustc_codegen_ssa::back::lto::{LtoModuleCodegen, SerializedModule, ThinModule, ThinShared}; |
| 11 | 11 | use rustc_codegen_ssa::back::symbol_export; |
| ... | ... | @@ -22,15 +22,14 @@ use rustc_middle::middle::exported_symbols::{SymbolExportInfo, SymbolExportLevel |
| 22 | 22 | use rustc_session::config::{self, CrateType, Lto}; |
| 23 | 23 | use tracing::{debug, info}; |
| 24 | 24 | |
| 25 | use std::collections::BTreeMap; | |
| 26 | use std::ffi::{CStr, CString}; | |
| 27 | use std::fs::File; | |
| 28 | use std::io; | |
| 29 | use std::iter; | |
| 30 | use std::mem::ManuallyDrop; | |
| 31 | use std::path::Path; | |
| 32 | use std::slice; | |
| 33 | use std::sync::Arc; | |
| 25 | use crate::back::write::{ | |
| 26 | self, bitcode_section_name, save_temp_bitcode, CodegenDiagnosticsStage, DiagnosticHandlers, | |
| 27 | }; | |
| 28 | use crate::errors::{ | |
| 29 | DynamicLinkingWithLTO, LlvmError, LtoBitcodeFromRlib, LtoDisallowed, LtoDylib, LtoProcMacro, | |
| 30 | }; | |
| 31 | use crate::llvm::{self, build_string}; | |
| 32 | use crate::{LlvmCodegenBackend, ModuleLlvm}; | |
| 34 | 33 | |
| 35 | 34 | /// We keep track of the computed LTO cache keys from the previous |
| 36 | 35 | /// session to determine which CGUs we can reuse. |
compiler/rustc_codegen_llvm/src/back/owned_target_machine.rs+6-7| ... | ... | @@ -1,13 +1,12 @@ |
| 1 | use std::{ | |
| 2 | ffi::{c_char, CStr}, | |
| 3 | marker::PhantomData, | |
| 4 | ops::Deref, | |
| 5 | ptr::NonNull, | |
| 6 | }; | |
| 1 | use std::ffi::{c_char, CStr}; | |
| 2 | use std::marker::PhantomData; | |
| 3 | use std::ops::Deref; | |
| 4 | use std::ptr::NonNull; | |
| 7 | 5 | |
| 8 | 6 | use rustc_data_structures::small_c_str::SmallCStr; |
| 9 | 7 | |
| 10 | use crate::{errors::LlvmError, llvm}; | |
| 8 | use crate::errors::LlvmError; | |
| 9 | use crate::llvm; | |
| 11 | 10 | |
| 12 | 11 | /// Responsible for safely creating and disposing llvm::TargetMachine via ffi functions. |
| 13 | 12 | /// Not cloneable as there is no clone function for llvm::TargetMachine. |
compiler/rustc_codegen_llvm/src/back/profiling.rs+4-2| ... | ... | @@ -1,9 +1,11 @@ |
| 1 | use measureme::{event_id::SEPARATOR_BYTE, EventId, StringComponent, StringId}; | |
| 2 | use rustc_data_structures::profiling::{SelfProfiler, TimingGuard}; | |
| 3 | 1 | use std::ffi::{c_void, CStr}; |
| 4 | 2 | use std::os::raw::c_char; |
| 5 | 3 | use std::sync::Arc; |
| 6 | 4 | |
| 5 | use measureme::event_id::SEPARATOR_BYTE; | |
| 6 | use measureme::{EventId, StringComponent, StringId}; | |
| 7 | use rustc_data_structures::profiling::{SelfProfiler, TimingGuard}; | |
| 8 | ||
| 7 | 9 | fn llvm_args_to_string_id(profiler: &SelfProfiler, pass_name: &str, ir_name: &str) -> EventId { |
| 8 | 10 | let pass_name = profiler.get_or_alloc_cached_string(pass_name); |
| 9 | 11 | let mut components = vec![StringComponent::Ref(pass_name)]; |
compiler/rustc_codegen_llvm/src/back/write.rs+22-26| ... | ... | @@ -1,19 +1,10 @@ |
| 1 | use crate::back::lto::ThinBuffer; | |
| 2 | use crate::back::owned_target_machine::OwnedTargetMachine; | |
| 3 | use crate::back::profiling::{ | |
| 4 | selfprofile_after_pass_callback, selfprofile_before_pass_callback, LlvmSelfProfiler, | |
| 5 | }; | |
| 6 | use crate::base; | |
| 7 | use crate::common; | |
| 8 | use crate::errors::{ | |
| 9 | CopyBitcode, FromLlvmDiag, FromLlvmOptimizationDiag, LlvmError, UnknownCompression, | |
| 10 | WithLlvmError, WriteBytecode, | |
| 11 | }; | |
| 12 | use crate::llvm::{self, DiagnosticInfo, PassManager}; | |
| 13 | use crate::llvm_util; | |
| 14 | use crate::type_::Type; | |
| 15 | use crate::LlvmCodegenBackend; | |
| 16 | use crate::ModuleLlvm; | |
| 1 | use std::ffi::CString; | |
| 2 | use std::io::{self, Write}; | |
| 3 | use std::path::{Path, PathBuf}; | |
| 4 | use std::sync::Arc; | |
| 5 | use std::{fs, slice, str}; | |
| 6 | ||
| 7 | use libc::{c_char, c_int, c_void, size_t}; | |
| 17 | 8 | use llvm::{ |
| 18 | 9 | LLVMRustLLVMHasZlibCompressionForDebugSymbols, LLVMRustLLVMHasZstdCompressionForDebugSymbols, |
| 19 | 10 | }; |
| ... | ... | @@ -29,23 +20,28 @@ use rustc_data_structures::small_c_str::SmallCStr; |
| 29 | 20 | use rustc_errors::{DiagCtxtHandle, FatalError, Level}; |
| 30 | 21 | use rustc_fs_util::{link_or_copy, path_to_c_string}; |
| 31 | 22 | use rustc_middle::ty::TyCtxt; |
| 32 | use rustc_session::config::{self, Lto, OutputType, Passes}; | |
| 33 | use rustc_session::config::{RemapPathScopeComponents, SplitDwarfKind, SwitchWithOptPath}; | |
| 23 | use rustc_session::config::{ | |
| 24 | self, Lto, OutputType, Passes, RemapPathScopeComponents, SplitDwarfKind, SwitchWithOptPath, | |
| 25 | }; | |
| 34 | 26 | use rustc_session::Session; |
| 35 | 27 | use rustc_span::symbol::sym; |
| 36 | 28 | use rustc_span::InnerSpan; |
| 37 | 29 | use rustc_target::spec::{CodeModel, RelocModel, SanitizerSet, SplitDebuginfo, TlsModel}; |
| 38 | 30 | use tracing::debug; |
| 39 | 31 | |
| 32 | use crate::back::lto::ThinBuffer; | |
| 33 | use crate::back::owned_target_machine::OwnedTargetMachine; | |
| 34 | use crate::back::profiling::{ | |
| 35 | selfprofile_after_pass_callback, selfprofile_before_pass_callback, LlvmSelfProfiler, | |
| 36 | }; | |
| 37 | use crate::errors::{ | |
| 38 | CopyBitcode, FromLlvmDiag, FromLlvmOptimizationDiag, LlvmError, UnknownCompression, | |
| 39 | WithLlvmError, WriteBytecode, | |
| 40 | }; | |
| 40 | 41 | use crate::llvm::diagnostic::OptimizationDiagnosticKind; |
| 41 | use libc::{c_char, c_int, c_void, size_t}; | |
| 42 | use std::ffi::CString; | |
| 43 | use std::fs; | |
| 44 | use std::io::{self, Write}; | |
| 45 | use std::path::{Path, PathBuf}; | |
| 46 | use std::slice; | |
| 47 | use std::str; | |
| 48 | use std::sync::Arc; | |
| 42 | use crate::llvm::{self, DiagnosticInfo, PassManager}; | |
| 43 | use crate::type_::Type; | |
| 44 | use crate::{base, common, llvm_util, LlvmCodegenBackend, ModuleLlvm}; | |
| 49 | 45 | |
| 50 | 46 | pub fn llvm_err<'a>(dcx: DiagCtxtHandle<'_>, err: LlvmError<'a>) -> FatalError { |
| 51 | 47 | match llvm::last_error() { |
compiler/rustc_codegen_llvm/src/base.rs+6-8| ... | ... | @@ -11,13 +11,7 @@ |
| 11 | 11 | //! [`Ty`]: rustc_middle::ty::Ty |
| 12 | 12 | //! [`val_ty`]: crate::common::val_ty |
| 13 | 13 | |
| 14 | use super::ModuleLlvm; | |
| 15 | ||
| 16 | use crate::attributes; | |
| 17 | use crate::builder::Builder; | |
| 18 | use crate::context::CodegenCx; | |
| 19 | use crate::llvm; | |
| 20 | use crate::value::Value; | |
| 14 | use std::time::Instant; | |
| 21 | 15 | |
| 22 | 16 | use rustc_codegen_ssa::base::maybe_create_entry_wrapper; |
| 23 | 17 | use rustc_codegen_ssa::mono_item::MonoItemExt; |
| ... | ... | @@ -32,7 +26,11 @@ use rustc_session::config::DebugInfo; |
| 32 | 26 | use rustc_span::symbol::Symbol; |
| 33 | 27 | use rustc_target::spec::SanitizerSet; |
| 34 | 28 | |
| 35 | use std::time::Instant; | |
| 29 | use super::ModuleLlvm; | |
| 30 | use crate::builder::Builder; | |
| 31 | use crate::context::CodegenCx; | |
| 32 | use crate::value::Value; | |
| 33 | use crate::{attributes, llvm}; | |
| 36 | 34 | |
| 37 | 35 | pub struct ValueIter<'ll> { |
| 38 | 36 | cur: Option<&'ll Value>, |
compiler/rustc_codegen_llvm/src/builder.rs+17-15| ... | ... | @@ -1,12 +1,7 @@ |
| 1 | use crate::abi::FnAbiLlvmExt; | |
| 2 | use crate::attributes; | |
| 3 | use crate::common::Funclet; | |
| 4 | use crate::context::CodegenCx; | |
| 5 | use crate::llvm::{self, AtomicOrdering, AtomicRmwBinOp, BasicBlock, False, True}; | |
| 6 | use crate::llvm_util; | |
| 7 | use crate::type_::Type; | |
| 8 | use crate::type_of::LayoutLlvmExt; | |
| 9 | use crate::value::Value; | |
| 1 | use std::borrow::Cow; | |
| 2 | use std::ops::Deref; | |
| 3 | use std::{iter, ptr}; | |
| 4 | ||
| 10 | 5 | use libc::{c_char, c_uint}; |
| 11 | 6 | use rustc_codegen_ssa::common::{IntPredicate, RealPredicate, SynchronizationScope, TypeKind}; |
| 12 | 7 | use rustc_codegen_ssa::mir::operand::{OperandRef, OperandValue}; |
| ... | ... | @@ -23,15 +18,21 @@ use rustc_middle::ty::{self, Instance, Ty, TyCtxt}; |
| 23 | 18 | use rustc_sanitizers::{cfi, kcfi}; |
| 24 | 19 | use rustc_session::config::OptLevel; |
| 25 | 20 | use rustc_span::Span; |
| 26 | use rustc_target::abi::{self, call::FnAbi, Align, Size, WrappingRange}; | |
| 21 | use rustc_target::abi::call::FnAbi; | |
| 22 | use rustc_target::abi::{self, Align, Size, WrappingRange}; | |
| 27 | 23 | use rustc_target::spec::{HasTargetSpec, SanitizerSet, Target}; |
| 28 | 24 | use smallvec::SmallVec; |
| 29 | use std::borrow::Cow; | |
| 30 | use std::iter; | |
| 31 | use std::ops::Deref; | |
| 32 | use std::ptr; | |
| 33 | 25 | use tracing::{debug, instrument}; |
| 34 | 26 | |
| 27 | use crate::abi::FnAbiLlvmExt; | |
| 28 | use crate::common::Funclet; | |
| 29 | use crate::context::CodegenCx; | |
| 30 | use crate::llvm::{self, AtomicOrdering, AtomicRmwBinOp, BasicBlock, False, True}; | |
| 31 | use crate::type_::Type; | |
| 32 | use crate::type_of::LayoutLlvmExt; | |
| 33 | use crate::value::Value; | |
| 34 | use crate::{attributes, llvm_util}; | |
| 35 | ||
| 35 | 36 | // All Builders must have an llfn associated with them |
| 36 | 37 | #[must_use] |
| 37 | 38 | pub struct Builder<'a, 'll, 'tcx> { |
| ... | ... | @@ -390,8 +391,9 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> { |
| 390 | 391 | lhs: Self::Value, |
| 391 | 392 | rhs: Self::Value, |
| 392 | 393 | ) -> (Self::Value, Self::Value) { |
| 394 | use rustc_middle::ty::IntTy::*; | |
| 395 | use rustc_middle::ty::UintTy::*; | |
| 393 | 396 | use rustc_middle::ty::{Int, Uint}; |
| 394 | use rustc_middle::ty::{IntTy::*, UintTy::*}; | |
| 395 | 397 | |
| 396 | 398 | let new_kind = match ty.kind() { |
| 397 | 399 | Int(t @ Isize) => Int(t.normalize(self.tcx.sess.target.pointer_width)), |
compiler/rustc_codegen_llvm/src/callee.rs+4-6| ... | ... | @@ -4,16 +4,14 @@ |
| 4 | 4 | //! and methods are represented as just a fn ptr and not a full |
| 5 | 5 | //! closure. |
| 6 | 6 | |
| 7 | use crate::attributes; | |
| 8 | use crate::common; | |
| 9 | use crate::context::CodegenCx; | |
| 10 | use crate::llvm; | |
| 11 | use crate::value::Value; | |
| 12 | ||
| 13 | 7 | use rustc_middle::ty::layout::{FnAbiOf, HasTyCtxt}; |
| 14 | 8 | use rustc_middle::ty::{self, Instance, TypeVisitableExt}; |
| 15 | 9 | use tracing::debug; |
| 16 | 10 | |
| 11 | use crate::context::CodegenCx; | |
| 12 | use crate::value::Value; | |
| 13 | use crate::{attributes, common, llvm}; | |
| 14 | ||
| 17 | 15 | /// Codegens a reference to a fn/method item, monomorphizing and |
| 18 | 16 | /// inlining as it goes. |
| 19 | 17 | /// |
compiler/rustc_codegen_llvm/src/common.rs+8-8| ... | ... | @@ -1,11 +1,8 @@ |
| 1 | 1 | //! Code that is useful in various codegen modules. |
| 2 | 2 | |
| 3 | use crate::consts::const_alloc_to_llvm; | |
| 4 | pub use crate::context::CodegenCx; | |
| 5 | use crate::llvm::{self, BasicBlock, Bool, ConstantInt, False, OperandBundleDef, True}; | |
| 6 | use crate::type_::Type; | |
| 7 | use crate::value::Value; | |
| 3 | use std::fmt::Write; | |
| 8 | 4 | |
| 5 | use libc::{c_char, c_uint}; | |
| 9 | 6 | use rustc_ast::Mutability; |
| 10 | 7 | use rustc_codegen_ssa::traits::*; |
| 11 | 8 | use rustc_data_structures::stable_hasher::{Hash128, HashStable, StableHasher}; |
| ... | ... | @@ -16,11 +13,14 @@ use rustc_middle::ty::TyCtxt; |
| 16 | 13 | use rustc_session::cstore::{DllCallingConvention, DllImport, PeImportNameType}; |
| 17 | 14 | use rustc_target::abi::{self, AddressSpace, HasDataLayout, Pointer}; |
| 18 | 15 | use rustc_target::spec::Target; |
| 19 | ||
| 20 | use libc::{c_char, c_uint}; | |
| 21 | use std::fmt::Write; | |
| 22 | 16 | use tracing::debug; |
| 23 | 17 | |
| 18 | use crate::consts::const_alloc_to_llvm; | |
| 19 | pub use crate::context::CodegenCx; | |
| 20 | use crate::llvm::{self, BasicBlock, Bool, ConstantInt, False, OperandBundleDef, True}; | |
| 21 | use crate::type_::Type; | |
| 22 | use crate::value::Value; | |
| 23 | ||
| 24 | 24 | /* |
| 25 | 25 | * A note on nomenclature of linking: "extern", "foreign", and "upcall". |
| 26 | 26 | * |
compiler/rustc_codegen_llvm/src/consts.rs+12-11| ... | ... | @@ -1,13 +1,5 @@ |
| 1 | use crate::base; | |
| 2 | use crate::common::{self, CodegenCx}; | |
| 3 | use crate::debuginfo; | |
| 4 | use crate::errors::{ | |
| 5 | InvalidMinimumAlignmentNotPowerOfTwo, InvalidMinimumAlignmentTooLarge, SymbolAlreadyDefined, | |
| 6 | }; | |
| 7 | use crate::llvm::{self, True}; | |
| 8 | use crate::type_::Type; | |
| 9 | use crate::type_of::LayoutLlvmExt; | |
| 10 | use crate::value::Value; | |
| 1 | use std::ops::Range; | |
| 2 | ||
| 11 | 3 | use rustc_codegen_ssa::traits::*; |
| 12 | 4 | use rustc_hir::def::DefKind; |
| 13 | 5 | use rustc_hir::def_id::DefId; |
| ... | ... | @@ -24,9 +16,18 @@ use rustc_session::config::Lto; |
| 24 | 16 | use rustc_target::abi::{ |
| 25 | 17 | Align, AlignFromBytesError, HasDataLayout, Primitive, Scalar, Size, WrappingRange, |
| 26 | 18 | }; |
| 27 | use std::ops::Range; | |
| 28 | 19 | use tracing::{debug, instrument, trace}; |
| 29 | 20 | |
| 21 | use crate::common::{self, CodegenCx}; | |
| 22 | use crate::errors::{ | |
| 23 | InvalidMinimumAlignmentNotPowerOfTwo, InvalidMinimumAlignmentTooLarge, SymbolAlreadyDefined, | |
| 24 | }; | |
| 25 | use crate::llvm::{self, True}; | |
| 26 | use crate::type_::Type; | |
| 27 | use crate::type_of::LayoutLlvmExt; | |
| 28 | use crate::value::Value; | |
| 29 | use crate::{base, debuginfo}; | |
| 30 | ||
| 30 | 31 | pub fn const_alloc_to_llvm<'ll>( |
| 31 | 32 | cx: &CodegenCx<'ll, '_>, |
| 32 | 33 | alloc: ConstAllocation<'_>, |
compiler/rustc_codegen_llvm/src/context.rs+17-20| ... | ... | @@ -1,19 +1,13 @@ |
| 1 | use crate::attributes; | |
| 2 | use crate::back::write::to_llvm_code_model; | |
| 3 | use crate::callee::get_fn; | |
| 4 | use crate::coverageinfo; | |
| 5 | use crate::debuginfo; | |
| 6 | use crate::debuginfo::metadata::apply_vcall_visibility_metadata; | |
| 7 | use crate::llvm; | |
| 8 | use crate::llvm_util; | |
| 9 | use crate::type_::Type; | |
| 10 | use crate::value::Value; | |
| 1 | use std::borrow::Borrow; | |
| 2 | use std::cell::{Cell, RefCell}; | |
| 3 | use std::ffi::CStr; | |
| 4 | use std::str; | |
| 11 | 5 | |
| 6 | use libc::c_uint; | |
| 12 | 7 | use rustc_codegen_ssa::base::{wants_msvc_seh, wants_wasm_eh}; |
| 13 | 8 | use rustc_codegen_ssa::errors as ssa_errors; |
| 14 | 9 | use rustc_codegen_ssa::traits::*; |
| 15 | use rustc_data_structures::base_n::ToBaseN; | |
| 16 | use rustc_data_structures::base_n::ALPHANUMERIC_ONLY; | |
| 10 | use rustc_data_structures::base_n::{ToBaseN, ALPHANUMERIC_ONLY}; | |
| 17 | 11 | use rustc_data_structures::fx::FxHashMap; |
| 18 | 12 | use rustc_data_structures::small_c_str::SmallCStr; |
| 19 | 13 | use rustc_hir::def_id::DefId; |
| ... | ... | @@ -24,20 +18,23 @@ use rustc_middle::ty::layout::{ |
| 24 | 18 | }; |
| 25 | 19 | use rustc_middle::ty::{self, Instance, Ty, TyCtxt}; |
| 26 | 20 | use rustc_middle::{bug, span_bug}; |
| 27 | use rustc_session::config::{BranchProtection, CFGuard, CFProtection}; | |
| 28 | use rustc_session::config::{CrateType, DebugInfo, PAuthKey, PacRet}; | |
| 21 | use rustc_session::config::{ | |
| 22 | BranchProtection, CFGuard, CFProtection, CrateType, DebugInfo, PAuthKey, PacRet, | |
| 23 | }; | |
| 29 | 24 | use rustc_session::Session; |
| 30 | 25 | use rustc_span::source_map::Spanned; |
| 31 | 26 | use rustc_span::{Span, DUMMY_SP}; |
| 32 | use rustc_target::abi::{call::FnAbi, HasDataLayout, TargetDataLayout, VariantIdx}; | |
| 27 | use rustc_target::abi::call::FnAbi; | |
| 28 | use rustc_target::abi::{HasDataLayout, TargetDataLayout, VariantIdx}; | |
| 33 | 29 | use rustc_target::spec::{HasTargetSpec, RelocModel, Target, TlsModel}; |
| 34 | 30 | use smallvec::SmallVec; |
| 35 | 31 | |
| 36 | use libc::c_uint; | |
| 37 | use std::borrow::Borrow; | |
| 38 | use std::cell::{Cell, RefCell}; | |
| 39 | use std::ffi::CStr; | |
| 40 | use std::str; | |
| 32 | use crate::back::write::to_llvm_code_model; | |
| 33 | use crate::callee::get_fn; | |
| 34 | use crate::debuginfo::metadata::apply_vcall_visibility_metadata; | |
| 35 | use crate::type_::Type; | |
| 36 | use crate::value::Value; | |
| 37 | use crate::{attributes, coverageinfo, debuginfo, llvm, llvm_util}; | |
| 41 | 38 | |
| 42 | 39 | /// There is one `CodegenCx` per compilation unit. Each one has its own LLVM |
| 43 | 40 | /// `llvm::Context` so that several compilation units may be optimized in parallel. |
compiler/rustc_codegen_llvm/src/coverageinfo/map_data.rs+2-2| ... | ... | @@ -1,5 +1,3 @@ |
| 1 | use crate::coverageinfo::ffi::{Counter, CounterExpression, ExprKind}; | |
| 2 | ||
| 3 | 1 | use rustc_data_structures::captures::Captures; |
| 4 | 2 | use rustc_data_structures::fx::FxIndexSet; |
| 5 | 3 | use rustc_index::bit_set::BitSet; |
| ... | ... | @@ -11,6 +9,8 @@ use rustc_middle::ty::Instance; |
| 11 | 9 | use rustc_span::Symbol; |
| 12 | 10 | use tracing::{debug, instrument}; |
| 13 | 11 | |
| 12 | use crate::coverageinfo::ffi::{Counter, CounterExpression, ExprKind}; | |
| 13 | ||
| 14 | 14 | /// Holds all of the coverage mapping data associated with a function instance, |
| 15 | 15 | /// collected during traversal of `Coverage` statements in the function's MIR. |
| 16 | 16 | #[derive(Debug)] |
compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs+6-8| ... | ... | @@ -1,21 +1,19 @@ |
| 1 | use crate::common::CodegenCx; | |
| 2 | use crate::coverageinfo; | |
| 3 | use crate::coverageinfo::ffi::CounterMappingRegion; | |
| 4 | use crate::coverageinfo::map_data::{FunctionCoverage, FunctionCoverageCollector}; | |
| 5 | use crate::llvm; | |
| 6 | ||
| 7 | 1 | use itertools::Itertools as _; |
| 8 | 2 | use rustc_codegen_ssa::traits::{BaseTypeMethods, ConstMethods}; |
| 9 | 3 | use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet}; |
| 10 | 4 | use rustc_hir::def_id::{DefId, LocalDefId}; |
| 11 | 5 | use rustc_index::IndexVec; |
| 12 | use rustc_middle::bug; | |
| 13 | use rustc_middle::mir; | |
| 14 | 6 | use rustc_middle::ty::{self, TyCtxt}; |
| 7 | use rustc_middle::{bug, mir}; | |
| 15 | 8 | use rustc_span::def_id::DefIdSet; |
| 16 | 9 | use rustc_span::Symbol; |
| 17 | 10 | use tracing::debug; |
| 18 | 11 | |
| 12 | use crate::common::CodegenCx; | |
| 13 | use crate::coverageinfo::ffi::CounterMappingRegion; | |
| 14 | use crate::coverageinfo::map_data::{FunctionCoverage, FunctionCoverageCollector}; | |
| 15 | use crate::{coverageinfo, llvm}; | |
| 16 | ||
| 19 | 17 | /// Generates and exports the Coverage Map. |
| 20 | 18 | /// |
| 21 | 19 | /// Rust Coverage Map generation supports LLVM Coverage Mapping Format versions |
compiler/rustc_codegen_llvm/src/coverageinfo/mod.rs+6-7| ... | ... | @@ -1,9 +1,4 @@ |
| 1 | use crate::llvm; | |
| 2 | ||
| 3 | use crate::builder::Builder; | |
| 4 | use crate::common::CodegenCx; | |
| 5 | use crate::coverageinfo::ffi::{CounterExpression, CounterMappingRegion}; | |
| 6 | use crate::coverageinfo::map_data::FunctionCoverageCollector; | |
| 1 | use std::cell::RefCell; | |
| 7 | 2 | |
| 8 | 3 | use libc::c_uint; |
| 9 | 4 | use rustc_codegen_ssa::traits::{ |
| ... | ... | @@ -19,7 +14,11 @@ use rustc_middle::ty::Instance; |
| 19 | 14 | use rustc_target::abi::{Align, Size}; |
| 20 | 15 | use tracing::{debug, instrument}; |
| 21 | 16 | |
| 22 | use std::cell::RefCell; | |
| 17 | use crate::builder::Builder; | |
| 18 | use crate::common::CodegenCx; | |
| 19 | use crate::coverageinfo::ffi::{CounterExpression, CounterMappingRegion}; | |
| 20 | use crate::coverageinfo::map_data::FunctionCoverageCollector; | |
| 21 | use crate::llvm; | |
| 23 | 22 | |
| 24 | 23 | pub(crate) mod ffi; |
| 25 | 24 | pub(crate) mod map_data; |
compiler/rustc_codegen_llvm/src/debuginfo/create_scope_map.rs+7-8| ... | ... | @@ -1,18 +1,17 @@ |
| 1 | use super::metadata::file_metadata; | |
| 2 | use super::utils::DIB; | |
| 3 | 1 | use rustc_codegen_ssa::mir::debuginfo::{DebugScope, FunctionDebugContext}; |
| 4 | 2 | use rustc_codegen_ssa::traits::*; |
| 5 | ||
| 6 | use crate::common::CodegenCx; | |
| 7 | use crate::llvm; | |
| 8 | use crate::llvm::debuginfo::{DILocation, DIScope}; | |
| 3 | use rustc_index::bit_set::BitSet; | |
| 4 | use rustc_index::Idx; | |
| 9 | 5 | use rustc_middle::mir::{Body, SourceScope}; |
| 10 | 6 | use rustc_middle::ty::layout::FnAbiOf; |
| 11 | 7 | use rustc_middle::ty::{self, Instance}; |
| 12 | 8 | use rustc_session::config::DebugInfo; |
| 13 | 9 | |
| 14 | use rustc_index::bit_set::BitSet; | |
| 15 | use rustc_index::Idx; | |
| 10 | use super::metadata::file_metadata; | |
| 11 | use super::utils::DIB; | |
| 12 | use crate::common::CodegenCx; | |
| 13 | use crate::llvm; | |
| 14 | use crate::llvm::debuginfo::{DILocation, DIScope}; | |
| 16 | 15 | |
| 17 | 16 | /// Produces DIScope DIEs for each MIR Scope which has variables defined in it. |
| 18 | 17 | // FIXME(eddyb) almost all of this should be in `rustc_codegen_ssa::mir::debuginfo`. |
compiler/rustc_codegen_llvm/src/debuginfo/gdb.rs+7-6| ... | ... | @@ -1,18 +1,19 @@ |
| 1 | 1 | // .debug_gdb_scripts binary section. |
| 2 | 2 | |
| 3 | use crate::llvm; | |
| 4 | ||
| 5 | use crate::builder::Builder; | |
| 6 | use crate::common::CodegenCx; | |
| 7 | use crate::value::Value; | |
| 8 | 3 | use rustc_ast::attr; |
| 9 | 4 | use rustc_codegen_ssa::base::collect_debugger_visualizers_transitive; |
| 10 | 5 | use rustc_codegen_ssa::traits::*; |
| 11 | 6 | use rustc_hir::def_id::LOCAL_CRATE; |
| 12 | use rustc_middle::{bug, middle::debugger_visualizer::DebuggerVisualizerType}; | |
| 7 | use rustc_middle::bug; | |
| 8 | use rustc_middle::middle::debugger_visualizer::DebuggerVisualizerType; | |
| 13 | 9 | use rustc_session::config::{CrateType, DebugInfo}; |
| 14 | 10 | use rustc_span::symbol::sym; |
| 15 | 11 | |
| 12 | use crate::builder::Builder; | |
| 13 | use crate::common::CodegenCx; | |
| 14 | use crate::llvm; | |
| 15 | use crate::value::Value; | |
| 16 | ||
| 16 | 17 | /// Inserts a side-effect free instruction sequence that makes sure that the |
| 17 | 18 | /// .debug_gdb_scripts global is referenced, so it isn't removed by the linker. |
| 18 | 19 | pub fn insert_reference_to_gdb_debug_scripts_section_global(bx: &mut Builder<'_, '_, '_>) { |
compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs+27-36| ... | ... | @@ -1,32 +1,14 @@ |
| 1 | use self::type_map::DINodeCreationResult; | |
| 2 | use self::type_map::Stub; | |
| 3 | use self::type_map::UniqueTypeId; | |
| 4 | ||
| 5 | use super::namespace::mangled_name_of_instance; | |
| 6 | use super::type_names::{compute_debuginfo_type_name, compute_debuginfo_vtable_name}; | |
| 7 | use super::utils::{ | |
| 8 | create_DIArray, debug_context, get_namespace_for_item, is_node_local_to_unit, DIB, | |
| 9 | }; | |
| 10 | use super::CodegenUnitDebugContext; | |
| 11 | ||
| 12 | use crate::abi; | |
| 13 | use crate::common::CodegenCx; | |
| 14 | use crate::debuginfo::metadata::type_map::build_type_with_children; | |
| 15 | use crate::debuginfo::utils::fat_pointer_kind; | |
| 16 | use crate::debuginfo::utils::FatPtrKind; | |
| 17 | use crate::llvm; | |
| 18 | use crate::llvm::debuginfo::{ | |
| 19 | DIDescriptor, DIFile, DIFlags, DILexicalBlock, DIScope, DIType, DebugEmissionKind, | |
| 20 | DebugNameTableKind, | |
| 21 | }; | |
| 22 | use crate::value::Value; | |
| 1 | use std::borrow::Cow; | |
| 2 | use std::fmt::{self, Write}; | |
| 3 | use std::hash::{Hash, Hasher}; | |
| 4 | use std::path::{Path, PathBuf}; | |
| 5 | use std::{iter, ptr}; | |
| 23 | 6 | |
| 24 | use rustc_codegen_ssa::debuginfo::type_names::cpp_like_debuginfo; | |
| 25 | use rustc_codegen_ssa::debuginfo::type_names::VTableNameKind; | |
| 7 | use libc::{c_char, c_longlong, c_uint}; | |
| 8 | use rustc_codegen_ssa::debuginfo::type_names::{cpp_like_debuginfo, VTableNameKind}; | |
| 26 | 9 | use rustc_codegen_ssa::traits::*; |
| 27 | 10 | use rustc_fs_util::path_to_c_string; |
| 28 | use rustc_hir::def::CtorKind; | |
| 29 | use rustc_hir::def::DefKind; | |
| 11 | use rustc_hir::def::{CtorKind, DefKind}; | |
| 30 | 12 | use rustc_hir::def_id::{DefId, LOCAL_CRATE}; |
| 31 | 13 | use rustc_middle::bug; |
| 32 | 14 | use rustc_middle::ty::layout::{LayoutOf, TyAndLayout}; |
| ... | ... | @@ -36,21 +18,29 @@ use rustc_middle::ty::{ |
| 36 | 18 | }; |
| 37 | 19 | use rustc_session::config::{self, DebugInfo, Lto}; |
| 38 | 20 | use rustc_span::symbol::Symbol; |
| 39 | use rustc_span::{hygiene, FileName, DUMMY_SP}; | |
| 40 | use rustc_span::{FileNameDisplayPreference, SourceFile}; | |
| 21 | use rustc_span::{hygiene, FileName, FileNameDisplayPreference, SourceFile, DUMMY_SP}; | |
| 41 | 22 | use rustc_symbol_mangling::typeid_for_trait_ref; |
| 42 | 23 | use rustc_target::abi::{Align, Size}; |
| 43 | 24 | use rustc_target::spec::DebuginfoKind; |
| 44 | 25 | use smallvec::smallvec; |
| 45 | 26 | use tracing::{debug, instrument}; |
| 46 | 27 | |
| 47 | use libc::{c_char, c_longlong, c_uint}; | |
| 48 | use std::borrow::Cow; | |
| 49 | use std::fmt::{self, Write}; | |
| 50 | use std::hash::{Hash, Hasher}; | |
| 51 | use std::iter; | |
| 52 | use std::path::{Path, PathBuf}; | |
| 53 | use std::ptr; | |
| 28 | use self::type_map::{DINodeCreationResult, Stub, UniqueTypeId}; | |
| 29 | use super::namespace::mangled_name_of_instance; | |
| 30 | use super::type_names::{compute_debuginfo_type_name, compute_debuginfo_vtable_name}; | |
| 31 | use super::utils::{ | |
| 32 | create_DIArray, debug_context, get_namespace_for_item, is_node_local_to_unit, DIB, | |
| 33 | }; | |
| 34 | use super::CodegenUnitDebugContext; | |
| 35 | use crate::common::CodegenCx; | |
| 36 | use crate::debuginfo::metadata::type_map::build_type_with_children; | |
| 37 | use crate::debuginfo::utils::{fat_pointer_kind, FatPtrKind}; | |
| 38 | use crate::llvm::debuginfo::{ | |
| 39 | DIDescriptor, DIFile, DIFlags, DILexicalBlock, DIScope, DIType, DebugEmissionKind, | |
| 40 | DebugNameTableKind, | |
| 41 | }; | |
| 42 | use crate::value::Value; | |
| 43 | use crate::{abi, llvm}; | |
| 54 | 44 | |
| 55 | 45 | impl PartialEq for llvm::Metadata { |
| 56 | 46 | fn eq(&self, other: &Self) -> bool { |
| ... | ... | @@ -874,7 +864,8 @@ pub fn build_compile_unit_di_node<'ll, 'tcx>( |
| 874 | 864 | codegen_unit_name: &str, |
| 875 | 865 | debug_context: &CodegenUnitDebugContext<'ll, 'tcx>, |
| 876 | 866 | ) -> &'ll DIDescriptor { |
| 877 | use rustc_session::{config::RemapPathScopeComponents, RemapFileNameExt}; | |
| 867 | use rustc_session::config::RemapPathScopeComponents; | |
| 868 | use rustc_session::RemapFileNameExt; | |
| 878 | 869 | let mut name_in_debuginfo = tcx |
| 879 | 870 | .sess |
| 880 | 871 | .local_crate_source_file() |
compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/cpp_like.rs+16-30| ... | ... | @@ -1,41 +1,27 @@ |
| 1 | 1 | use std::borrow::Cow; |
| 2 | 2 | |
| 3 | 3 | use libc::c_uint; |
| 4 | use rustc_codegen_ssa::{ | |
| 5 | debuginfo::{type_names::compute_debuginfo_type_name, wants_c_like_enum_debuginfo}, | |
| 6 | traits::ConstMethods, | |
| 7 | }; | |
| 8 | ||
| 4 | use rustc_codegen_ssa::debuginfo::type_names::compute_debuginfo_type_name; | |
| 5 | use rustc_codegen_ssa::debuginfo::wants_c_like_enum_debuginfo; | |
| 6 | use rustc_codegen_ssa::traits::ConstMethods; | |
| 9 | 7 | use rustc_index::IndexVec; |
| 10 | use rustc_middle::{ | |
| 11 | bug, | |
| 12 | ty::{ | |
| 13 | self, | |
| 14 | layout::{LayoutOf, TyAndLayout}, | |
| 15 | AdtDef, CoroutineArgs, CoroutineArgsExt, Ty, | |
| 16 | }, | |
| 17 | }; | |
| 8 | use rustc_middle::bug; | |
| 9 | use rustc_middle::ty::layout::{LayoutOf, TyAndLayout}; | |
| 10 | use rustc_middle::ty::{self, AdtDef, CoroutineArgs, CoroutineArgsExt, Ty}; | |
| 18 | 11 | use rustc_target::abi::{Align, Endian, Size, TagEncoding, VariantIdx, Variants}; |
| 19 | 12 | use smallvec::smallvec; |
| 20 | 13 | |
| 21 | use crate::{ | |
| 22 | common::CodegenCx, | |
| 23 | debuginfo::{ | |
| 24 | metadata::{ | |
| 25 | build_field_di_node, | |
| 26 | enums::{tag_base_type, DiscrResult}, | |
| 27 | file_metadata, size_and_align_of, type_di_node, | |
| 28 | type_map::{self, Stub, UniqueTypeId}, | |
| 29 | unknown_file_metadata, visibility_di_flags, DINodeCreationResult, SmallVec, | |
| 30 | NO_GENERICS, NO_SCOPE_METADATA, UNKNOWN_LINE_NUMBER, | |
| 31 | }, | |
| 32 | utils::DIB, | |
| 33 | }, | |
| 34 | llvm::{ | |
| 35 | self, | |
| 36 | debuginfo::{DIFile, DIFlags, DIType}, | |
| 37 | }, | |
| 14 | use crate::common::CodegenCx; | |
| 15 | use crate::debuginfo::metadata::enums::{tag_base_type, DiscrResult}; | |
| 16 | use crate::debuginfo::metadata::type_map::{self, Stub, UniqueTypeId}; | |
| 17 | use crate::debuginfo::metadata::{ | |
| 18 | build_field_di_node, file_metadata, size_and_align_of, type_di_node, unknown_file_metadata, | |
| 19 | visibility_di_flags, DINodeCreationResult, SmallVec, NO_GENERICS, NO_SCOPE_METADATA, | |
| 20 | UNKNOWN_LINE_NUMBER, | |
| 38 | 21 | }; |
| 22 | use crate::debuginfo::utils::DIB; | |
| 23 | use crate::llvm::debuginfo::{DIFile, DIFlags, DIType}; | |
| 24 | use crate::llvm::{self}; | |
| 39 | 25 | |
| 40 | 26 | // The names of the associated constants in each variant wrapper struct. |
| 41 | 27 | // These have to match up with the names being used in `intrinsic.natvis`. |
compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/mod.rs+18-34| ... | ... | @@ -1,45 +1,29 @@ |
| 1 | use rustc_codegen_ssa::debuginfo::{ | |
| 2 | type_names::{compute_debuginfo_type_name, cpp_like_debuginfo}, | |
| 3 | wants_c_like_enum_debuginfo, | |
| 4 | }; | |
| 1 | use std::borrow::Cow; | |
| 2 | ||
| 3 | use rustc_codegen_ssa::debuginfo::type_names::{compute_debuginfo_type_name, cpp_like_debuginfo}; | |
| 4 | use rustc_codegen_ssa::debuginfo::wants_c_like_enum_debuginfo; | |
| 5 | 5 | use rustc_hir::def::CtorKind; |
| 6 | 6 | use rustc_index::IndexSlice; |
| 7 | use rustc_middle::{ | |
| 8 | bug, | |
| 9 | mir::CoroutineLayout, | |
| 10 | ty::{ | |
| 11 | self, | |
| 12 | layout::{IntegerExt, LayoutOf, PrimitiveExt, TyAndLayout}, | |
| 13 | AdtDef, CoroutineArgs, CoroutineArgsExt, Ty, VariantDef, | |
| 14 | }, | |
| 15 | }; | |
| 7 | use rustc_middle::bug; | |
| 8 | use rustc_middle::mir::CoroutineLayout; | |
| 9 | use rustc_middle::ty::layout::{IntegerExt, LayoutOf, PrimitiveExt, TyAndLayout}; | |
| 10 | use rustc_middle::ty::{self, AdtDef, CoroutineArgs, CoroutineArgsExt, Ty, VariantDef}; | |
| 16 | 11 | use rustc_span::Symbol; |
| 17 | 12 | use rustc_target::abi::{ |
| 18 | 13 | FieldIdx, HasDataLayout, Integer, Primitive, TagEncoding, VariantIdx, Variants, |
| 19 | 14 | }; |
| 20 | use std::borrow::Cow; | |
| 21 | ||
| 22 | use crate::{ | |
| 23 | common::CodegenCx, | |
| 24 | debuginfo::{ | |
| 25 | metadata::{ | |
| 26 | build_field_di_node, build_generic_type_param_di_nodes, type_di_node, | |
| 27 | type_map::{self, Stub}, | |
| 28 | unknown_file_metadata, UNKNOWN_LINE_NUMBER, | |
| 29 | }, | |
| 30 | utils::{create_DIArray, get_namespace_for_item, DIB}, | |
| 31 | }, | |
| 32 | llvm::{ | |
| 33 | self, | |
| 34 | debuginfo::{DIFlags, DIType}, | |
| 35 | }, | |
| 36 | }; | |
| 37 | 15 | |
| 38 | use super::{ | |
| 39 | size_and_align_of, | |
| 40 | type_map::{DINodeCreationResult, UniqueTypeId}, | |
| 41 | SmallVec, | |
| 16 | use super::type_map::{DINodeCreationResult, UniqueTypeId}; | |
| 17 | use super::{size_and_align_of, SmallVec}; | |
| 18 | use crate::common::CodegenCx; | |
| 19 | use crate::debuginfo::metadata::type_map::{self, Stub}; | |
| 20 | use crate::debuginfo::metadata::{ | |
| 21 | build_field_di_node, build_generic_type_param_di_nodes, type_di_node, unknown_file_metadata, | |
| 22 | UNKNOWN_LINE_NUMBER, | |
| 42 | 23 | }; |
| 24 | use crate::debuginfo::utils::{create_DIArray, get_namespace_for_item, DIB}; | |
| 25 | use crate::llvm::debuginfo::{DIFlags, DIType}; | |
| 26 | use crate::llvm::{self}; | |
| 43 | 27 | |
| 44 | 28 | mod cpp_like; |
| 45 | 29 | mod native; |
compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/native.rs+17-28| ... | ... | @@ -1,37 +1,26 @@ |
| 1 | 1 | use std::borrow::Cow; |
| 2 | 2 | |
| 3 | use crate::{ | |
| 4 | common::CodegenCx, | |
| 5 | debuginfo::{ | |
| 6 | metadata::{ | |
| 7 | enums::tag_base_type, | |
| 8 | file_metadata, size_and_align_of, type_di_node, | |
| 9 | type_map::{self, Stub, StubInfo, UniqueTypeId}, | |
| 10 | unknown_file_metadata, visibility_di_flags, DINodeCreationResult, SmallVec, | |
| 11 | NO_GENERICS, UNKNOWN_LINE_NUMBER, | |
| 12 | }, | |
| 13 | utils::{create_DIArray, get_namespace_for_item, DIB}, | |
| 14 | }, | |
| 15 | llvm::{ | |
| 16 | self, | |
| 17 | debuginfo::{DIFile, DIFlags, DIType}, | |
| 18 | }, | |
| 19 | }; | |
| 20 | 3 | use libc::c_uint; |
| 21 | use rustc_codegen_ssa::{ | |
| 22 | debuginfo::{type_names::compute_debuginfo_type_name, wants_c_like_enum_debuginfo}, | |
| 23 | traits::ConstMethods, | |
| 24 | }; | |
| 25 | use rustc_middle::{ | |
| 26 | bug, | |
| 27 | ty::{ | |
| 28 | self, | |
| 29 | layout::{LayoutOf, TyAndLayout}, | |
| 30 | }, | |
| 31 | }; | |
| 4 | use rustc_codegen_ssa::debuginfo::type_names::compute_debuginfo_type_name; | |
| 5 | use rustc_codegen_ssa::debuginfo::wants_c_like_enum_debuginfo; | |
| 6 | use rustc_codegen_ssa::traits::ConstMethods; | |
| 7 | use rustc_middle::bug; | |
| 8 | use rustc_middle::ty::layout::{LayoutOf, TyAndLayout}; | |
| 9 | use rustc_middle::ty::{self}; | |
| 32 | 10 | use rustc_target::abi::{Size, TagEncoding, VariantIdx, Variants}; |
| 33 | 11 | use smallvec::smallvec; |
| 34 | 12 | |
| 13 | use crate::common::CodegenCx; | |
| 14 | use crate::debuginfo::metadata::enums::tag_base_type; | |
| 15 | use crate::debuginfo::metadata::type_map::{self, Stub, StubInfo, UniqueTypeId}; | |
| 16 | use crate::debuginfo::metadata::{ | |
| 17 | file_metadata, size_and_align_of, type_di_node, unknown_file_metadata, visibility_di_flags, | |
| 18 | DINodeCreationResult, SmallVec, NO_GENERICS, UNKNOWN_LINE_NUMBER, | |
| 19 | }; | |
| 20 | use crate::debuginfo::utils::{create_DIArray, get_namespace_for_item, DIB}; | |
| 21 | use crate::llvm::debuginfo::{DIFile, DIFlags, DIType}; | |
| 22 | use crate::llvm::{self}; | |
| 23 | ||
| 35 | 24 | /// Build the debuginfo node for an enum type. The listing below shows how such a |
| 36 | 25 | /// type looks like at the LLVM IR/DWARF level. It is a `DW_TAG_structure_type` |
| 37 | 26 | /// with a single `DW_TAG_variant_part` that in turn contains a `DW_TAG_variant` |
compiler/rustc_codegen_llvm/src/debuginfo/metadata/type_map.rs+9-18| ... | ... | @@ -1,27 +1,18 @@ |
| 1 | 1 | use std::cell::RefCell; |
| 2 | 2 | |
| 3 | use rustc_data_structures::{ | |
| 4 | fingerprint::Fingerprint, | |
| 5 | fx::FxHashMap, | |
| 6 | stable_hasher::{HashStable, StableHasher}, | |
| 7 | }; | |
| 3 | use rustc_data_structures::fingerprint::Fingerprint; | |
| 4 | use rustc_data_structures::fx::FxHashMap; | |
| 5 | use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; | |
| 8 | 6 | use rustc_macros::HashStable; |
| 9 | use rustc_middle::{ | |
| 10 | bug, | |
| 11 | ty::{ParamEnv, PolyExistentialTraitRef, Ty, TyCtxt}, | |
| 12 | }; | |
| 7 | use rustc_middle::bug; | |
| 8 | use rustc_middle::ty::{ParamEnv, PolyExistentialTraitRef, Ty, TyCtxt}; | |
| 13 | 9 | use rustc_target::abi::{Align, Size, VariantIdx}; |
| 14 | 10 | |
| 15 | use crate::{ | |
| 16 | common::CodegenCx, | |
| 17 | debuginfo::utils::{create_DIArray, debug_context, DIB}, | |
| 18 | llvm::{ | |
| 19 | self, | |
| 20 | debuginfo::{DIFlags, DIScope, DIType}, | |
| 21 | }, | |
| 22 | }; | |
| 23 | ||
| 24 | 11 | use super::{unknown_file_metadata, SmallVec, UNKNOWN_LINE_NUMBER}; |
| 12 | use crate::common::CodegenCx; | |
| 13 | use crate::debuginfo::utils::{create_DIArray, debug_context, DIB}; | |
| 14 | use crate::llvm::debuginfo::{DIFlags, DIScope, DIType}; | |
| 15 | use crate::llvm::{self}; | |
| 25 | 16 | |
| 26 | 17 | mod private { |
| 27 | 18 | use rustc_macros::HashStable; |
compiler/rustc_codegen_llvm/src/debuginfo/mod.rs+20-25| ... | ... | @@ -1,33 +1,21 @@ |
| 1 | 1 | #![doc = include_str!("doc.md")] |
| 2 | 2 | |
| 3 | use rustc_codegen_ssa::mir::debuginfo::VariableKind::*; | |
| 4 | use rustc_data_structures::unord::UnordMap; | |
| 5 | ||
| 6 | use self::metadata::{file_metadata, type_di_node}; | |
| 7 | use self::metadata::{UNKNOWN_COLUMN_NUMBER, UNKNOWN_LINE_NUMBER}; | |
| 8 | use self::namespace::mangled_name_of_instance; | |
| 9 | use self::utils::{create_DIArray, is_node_local_to_unit, DIB}; | |
| 10 | ||
| 11 | use crate::abi::FnAbi; | |
| 12 | use crate::builder::Builder; | |
| 13 | use crate::common::CodegenCx; | |
| 14 | use crate::llvm; | |
| 15 | use crate::llvm::debuginfo::{ | |
| 16 | DIArray, DIBuilder, DIFile, DIFlags, DILexicalBlock, DILocation, DISPFlags, DIScope, DIType, | |
| 17 | DIVariable, | |
| 18 | }; | |
| 19 | use crate::value::Value; | |
| 3 | use std::cell::{OnceCell, RefCell}; | |
| 4 | use std::iter; | |
| 5 | use std::ops::Range; | |
| 20 | 6 | |
| 7 | use libc::c_uint; | |
| 21 | 8 | use rustc_codegen_ssa::debuginfo::type_names; |
| 9 | use rustc_codegen_ssa::mir::debuginfo::VariableKind::*; | |
| 22 | 10 | use rustc_codegen_ssa::mir::debuginfo::{DebugScope, FunctionDebugContext, VariableKind}; |
| 23 | 11 | use rustc_codegen_ssa::traits::*; |
| 24 | 12 | use rustc_data_structures::sync::Lrc; |
| 13 | use rustc_data_structures::unord::UnordMap; | |
| 25 | 14 | use rustc_hir::def_id::{DefId, DefIdMap}; |
| 26 | 15 | use rustc_index::IndexVec; |
| 27 | 16 | use rustc_middle::mir; |
| 28 | 17 | use rustc_middle::ty::layout::LayoutOf; |
| 29 | use rustc_middle::ty::GenericArgsRef; | |
| 30 | use rustc_middle::ty::{self, Instance, ParamEnv, Ty, TypeVisitableExt}; | |
| 18 | use rustc_middle::ty::{self, GenericArgsRef, Instance, ParamEnv, Ty, TypeVisitableExt}; | |
| 31 | 19 | use rustc_session::config::{self, DebugInfo}; |
| 32 | 20 | use rustc_session::Session; |
| 33 | 21 | use rustc_span::symbol::Symbol; |
| ... | ... | @@ -35,15 +23,22 @@ use rustc_span::{ |
| 35 | 23 | BytePos, Pos, SourceFile, SourceFileAndLine, SourceFileHash, Span, StableSourceFileId, |
| 36 | 24 | }; |
| 37 | 25 | use rustc_target::abi::Size; |
| 38 | ||
| 39 | use libc::c_uint; | |
| 40 | 26 | use smallvec::SmallVec; |
| 41 | use std::cell::OnceCell; | |
| 42 | use std::cell::RefCell; | |
| 43 | use std::iter; | |
| 44 | use std::ops::Range; | |
| 45 | 27 | use tracing::debug; |
| 46 | 28 | |
| 29 | use self::metadata::{file_metadata, type_di_node, UNKNOWN_COLUMN_NUMBER, UNKNOWN_LINE_NUMBER}; | |
| 30 | use self::namespace::mangled_name_of_instance; | |
| 31 | use self::utils::{create_DIArray, is_node_local_to_unit, DIB}; | |
| 32 | use crate::abi::FnAbi; | |
| 33 | use crate::builder::Builder; | |
| 34 | use crate::common::CodegenCx; | |
| 35 | use crate::llvm; | |
| 36 | use crate::llvm::debuginfo::{ | |
| 37 | DIArray, DIBuilder, DIFile, DIFlags, DILexicalBlock, DILocation, DISPFlags, DIScope, DIType, | |
| 38 | DIVariable, | |
| 39 | }; | |
| 40 | use crate::value::Value; | |
| 41 | ||
| 47 | 42 | mod create_scope_map; |
| 48 | 43 | pub mod gdb; |
| 49 | 44 | pub mod metadata; |
compiler/rustc_codegen_llvm/src/debuginfo/namespace.rs+2-2| ... | ... | @@ -1,13 +1,13 @@ |
| 1 | 1 | // Namespace Handling. |
| 2 | 2 | |
| 3 | use super::utils::{debug_context, DIB}; | |
| 4 | 3 | use rustc_codegen_ssa::debuginfo::type_names; |
| 4 | use rustc_hir::def_id::DefId; | |
| 5 | 5 | use rustc_middle::ty::{self, Instance}; |
| 6 | 6 | |
| 7 | use super::utils::{debug_context, DIB}; | |
| 7 | 8 | use crate::common::CodegenCx; |
| 8 | 9 | use crate::llvm; |
| 9 | 10 | use crate::llvm::debuginfo::DIScope; |
| 10 | use rustc_hir::def_id::DefId; | |
| 11 | 11 | |
| 12 | 12 | pub fn mangled_name_of_instance<'a, 'tcx>( |
| 13 | 13 | cx: &CodegenCx<'a, 'tcx>, |
compiler/rustc_codegen_llvm/src/debuginfo/utils.rs+2-3| ... | ... | @@ -1,13 +1,12 @@ |
| 1 | 1 | // Utility Functions. |
| 2 | 2 | |
| 3 | use super::namespace::item_namespace; | |
| 4 | use super::CodegenUnitDebugContext; | |
| 5 | ||
| 6 | 3 | use rustc_hir::def_id::DefId; |
| 7 | 4 | use rustc_middle::ty::layout::{HasParamEnv, LayoutOf}; |
| 8 | 5 | use rustc_middle::ty::{self, Ty}; |
| 9 | 6 | use tracing::trace; |
| 10 | 7 | |
| 8 | use super::namespace::item_namespace; | |
| 9 | use super::CodegenUnitDebugContext; | |
| 11 | 10 | use crate::common::CodegenCx; |
| 12 | 11 | use crate::llvm; |
| 13 | 12 | use crate::llvm::debuginfo::{DIArray, DIBuilder, DIDescriptor, DIScope}; |
compiler/rustc_codegen_llvm/src/declare.rs+7-7| ... | ... | @@ -11,13 +11,6 @@ |
| 11 | 11 | //! * Use define_* family of methods when you might be defining the Value. |
| 12 | 12 | //! * When in doubt, define. |
| 13 | 13 | |
| 14 | use crate::abi::{FnAbi, FnAbiLlvmExt}; | |
| 15 | use crate::attributes; | |
| 16 | use crate::context::CodegenCx; | |
| 17 | use crate::llvm; | |
| 18 | use crate::llvm::AttributePlace::Function; | |
| 19 | use crate::type_::Type; | |
| 20 | use crate::value::Value; | |
| 21 | 14 | use itertools::Itertools; |
| 22 | 15 | use rustc_codegen_ssa::traits::TypeMembershipMethods; |
| 23 | 16 | use rustc_data_structures::fx::FxIndexSet; |
| ... | ... | @@ -26,6 +19,13 @@ use rustc_sanitizers::{cfi, kcfi}; |
| 26 | 19 | use smallvec::SmallVec; |
| 27 | 20 | use tracing::debug; |
| 28 | 21 | |
| 22 | use crate::abi::{FnAbi, FnAbiLlvmExt}; | |
| 23 | use crate::context::CodegenCx; | |
| 24 | use crate::llvm::AttributePlace::Function; | |
| 25 | use crate::type_::Type; | |
| 26 | use crate::value::Value; | |
| 27 | use crate::{attributes, llvm}; | |
| 28 | ||
| 29 | 29 | /// Declare a function. |
| 30 | 30 | /// |
| 31 | 31 | /// If there’s a value with the same name already declared, the function will |
compiler/rustc_codegen_llvm/src/errors.rs+2-1| ... | ... | @@ -2,12 +2,13 @@ use std::borrow::Cow; |
| 2 | 2 | use std::ffi::CString; |
| 3 | 3 | use std::path::Path; |
| 4 | 4 | |
| 5 | use crate::fluent_generated as fluent; | |
| 6 | 5 | use rustc_data_structures::small_c_str::SmallCStr; |
| 7 | 6 | use rustc_errors::{Diag, DiagCtxtHandle, Diagnostic, EmissionGuarantee, Level}; |
| 8 | 7 | use rustc_macros::{Diagnostic, Subdiagnostic}; |
| 9 | 8 | use rustc_span::Span; |
| 10 | 9 | |
| 10 | use crate::fluent_generated as fluent; | |
| 11 | ||
| 11 | 12 | #[derive(Diagnostic)] |
| 12 | 13 | #[diag(codegen_llvm_unknown_ctarget_feature_prefix)] |
| 13 | 14 | #[note] |
compiler/rustc_codegen_llvm/src/intrinsic.rs+9-9| ... | ... | @@ -1,11 +1,4 @@ |
| 1 | use crate::abi::{Abi, FnAbi, FnAbiLlvmExt, LlvmType, PassMode}; | |
| 2 | use crate::builder::Builder; | |
| 3 | use crate::context::CodegenCx; | |
| 4 | use crate::llvm; | |
| 5 | use crate::type_::Type; | |
| 6 | use crate::type_of::LayoutLlvmExt; | |
| 7 | use crate::va_arg::emit_va_arg; | |
| 8 | use crate::value::Value; | |
| 1 | use std::cmp::Ordering; | |
| 9 | 2 | |
| 10 | 3 | use rustc_codegen_ssa::base::{compare_simd_types, wants_msvc_seh, wants_wasm_eh}; |
| 11 | 4 | use rustc_codegen_ssa::common::{IntPredicate, TypeKind}; |
| ... | ... | @@ -23,7 +16,14 @@ use rustc_target::abi::{self, Align, Float, HasDataLayout, Primitive, Size}; |
| 23 | 16 | use rustc_target::spec::{HasTargetSpec, PanicStrategy}; |
| 24 | 17 | use tracing::debug; |
| 25 | 18 | |
| 26 | use std::cmp::Ordering; | |
| 19 | use crate::abi::{Abi, FnAbi, FnAbiLlvmExt, LlvmType, PassMode}; | |
| 20 | use crate::builder::Builder; | |
| 21 | use crate::context::CodegenCx; | |
| 22 | use crate::llvm; | |
| 23 | use crate::type_::Type; | |
| 24 | use crate::type_of::LayoutLlvmExt; | |
| 25 | use crate::va_arg::emit_va_arg; | |
| 26 | use crate::value::Value; | |
| 27 | 27 | |
| 28 | 28 | fn get_simple_intrinsic<'ll>( |
| 29 | 29 | cx: &CodegenCx<'ll, '_>, |
compiler/rustc_codegen_llvm/src/lib.rs+8-9| ... | ... | @@ -17,9 +17,13 @@ |
| 17 | 17 | #![feature(rustdoc_internals)] |
| 18 | 18 | // tidy-alphabetical-end |
| 19 | 19 | |
| 20 | use std::any::Any; | |
| 21 | use std::ffi::CStr; | |
| 22 | use std::io::Write; | |
| 23 | use std::mem::ManuallyDrop; | |
| 24 | ||
| 20 | 25 | use back::owned_target_machine::OwnedTargetMachine; |
| 21 | 26 | use back::write::{create_informational_target_machine, create_target_machine}; |
| 22 | ||
| 23 | 27 | use errors::ParseTargetMachineConfig; |
| 24 | 28 | pub use llvm_util::target_features; |
| 25 | 29 | use rustc_ast::expand::allocator::AllocatorKind; |
| ... | ... | @@ -28,8 +32,7 @@ use rustc_codegen_ssa::back::write::{ |
| 28 | 32 | CodegenContext, FatLtoInput, ModuleConfig, TargetMachineFactoryConfig, TargetMachineFactoryFn, |
| 29 | 33 | }; |
| 30 | 34 | use rustc_codegen_ssa::traits::*; |
| 31 | use rustc_codegen_ssa::ModuleCodegen; | |
| 32 | use rustc_codegen_ssa::{CodegenResults, CompiledModule}; | |
| 35 | use rustc_codegen_ssa::{CodegenResults, CompiledModule, ModuleCodegen}; | |
| 33 | 36 | use rustc_data_structures::fx::FxIndexMap; |
| 34 | 37 | use rustc_errors::{DiagCtxtHandle, ErrorGuaranteed, FatalError}; |
| 35 | 38 | use rustc_metadata::EncodedMetadata; |
| ... | ... | @@ -40,11 +43,6 @@ use rustc_session::config::{OptLevel, OutputFilenames, PrintKind, PrintRequest}; |
| 40 | 43 | use rustc_session::Session; |
| 41 | 44 | use rustc_span::symbol::Symbol; |
| 42 | 45 | |
| 43 | use std::any::Any; | |
| 44 | use std::ffi::CStr; | |
| 45 | use std::io::Write; | |
| 46 | use std::mem::ManuallyDrop; | |
| 47 | ||
| 48 | 46 | mod back { |
| 49 | 47 | pub mod archive; |
| 50 | 48 | pub mod lto; |
| ... | ... | @@ -394,9 +392,10 @@ impl CodegenBackend for LlvmCodegenBackend { |
| 394 | 392 | codegen_results: CodegenResults, |
| 395 | 393 | outputs: &OutputFilenames, |
| 396 | 394 | ) -> Result<(), ErrorGuaranteed> { |
| 397 | use crate::back::archive::LlvmArchiveBuilderBuilder; | |
| 398 | 395 | use rustc_codegen_ssa::back::link::link_binary; |
| 399 | 396 | |
| 397 | use crate::back::archive::LlvmArchiveBuilderBuilder; | |
| 398 | ||
| 400 | 399 | // Run the linker on any artifacts that resulted from the LLVM run. |
| 401 | 400 | // This should produce either a finished executable or library. |
| 402 | 401 | link_binary(sess, &LlvmArchiveBuilderBuilder, &codegen_results, outputs) |
compiler/rustc_codegen_llvm/src/llvm/archive_ro.rs+3-3| ... | ... | @@ -1,9 +1,9 @@ |
| 1 | 1 | //! A wrapper around LLVM's archive (.a) code |
| 2 | 2 | |
| 3 | use rustc_fs_util::path_to_c_string; | |
| 4 | 3 | use std::path::Path; |
| 5 | use std::slice; | |
| 6 | use std::str; | |
| 4 | use std::{slice, str}; | |
| 5 | ||
| 6 | use rustc_fs_util::path_to_c_string; | |
| 7 | 7 | |
| 8 | 8 | pub struct ArchiveRO { |
| 9 | 9 | pub raw: &'static mut super::Archive, |
compiler/rustc_codegen_llvm/src/llvm/diagnostic.rs+4-5| ... | ... | @@ -1,13 +1,12 @@ |
| 1 | 1 | //! LLVM diagnostic reports. |
| 2 | 2 | |
| 3 | pub use self::Diagnostic::*; | |
| 4 | pub use self::OptimizationDiagnosticKind::*; | |
| 5 | ||
| 6 | use crate::value::Value; | |
| 7 | 3 | use libc::c_uint; |
| 4 | use rustc_span::InnerSpan; | |
| 8 | 5 | |
| 6 | pub use self::Diagnostic::*; | |
| 7 | pub use self::OptimizationDiagnosticKind::*; | |
| 9 | 8 | use super::{DiagnosticInfo, SMDiagnostic}; |
| 10 | use rustc_span::InnerSpan; | |
| 9 | use crate::value::Value; | |
| 11 | 10 | |
| 12 | 11 | #[derive(Copy, Clone, Debug)] |
| 13 | 12 | pub enum OptimizationDiagnosticKind { |
compiler/rustc_codegen_llvm/src/llvm/ffi.rs+6-7| ... | ... | @@ -1,18 +1,16 @@ |
| 1 | 1 | #![allow(non_camel_case_types)] |
| 2 | 2 | #![allow(non_upper_case_globals)] |
| 3 | 3 | |
| 4 | use std::marker::PhantomData; | |
| 5 | ||
| 6 | use libc::{c_char, c_int, c_uint, c_ulonglong, c_void, size_t}; | |
| 7 | ||
| 4 | 8 | use super::debuginfo::{ |
| 5 | 9 | DIArray, DIBasicType, DIBuilder, DICompositeType, DIDerivedType, DIDescriptor, DIEnumerator, |
| 6 | 10 | DIFile, DIFlags, DIGlobalVariableExpression, DILexicalBlock, DILocation, DINameSpace, |
| 7 | 11 | DISPFlags, DIScope, DISubprogram, DISubrange, DITemplateTypeParameter, DIType, DIVariable, |
| 8 | 12 | DebugEmissionKind, DebugNameTableKind, |
| 9 | 13 | }; |
| 10 | ||
| 11 | use libc::{c_char, c_int, c_uint, size_t}; | |
| 12 | use libc::{c_ulonglong, c_void}; | |
| 13 | ||
| 14 | use std::marker::PhantomData; | |
| 15 | ||
| 16 | 14 | use super::RustString; |
| 17 | 15 | |
| 18 | 16 | pub type Bool = c_uint; |
| ... | ... | @@ -697,9 +695,10 @@ pub type DiagnosticHandlerTy = unsafe extern "C" fn(&DiagnosticInfo, *mut c_void |
| 697 | 695 | pub type InlineAsmDiagHandlerTy = unsafe extern "C" fn(&SMDiagnostic, *const c_void, c_uint); |
| 698 | 696 | |
| 699 | 697 | pub mod debuginfo { |
| 700 | use super::{InvariantOpaque, Metadata}; | |
| 701 | 698 | use bitflags::bitflags; |
| 702 | 699 | |
| 700 | use super::{InvariantOpaque, Metadata}; | |
| 701 | ||
| 703 | 702 | #[repr(C)] |
| 704 | 703 | pub struct DIBuilder<'a>(InvariantOpaque<'a>); |
| 705 | 704 |
compiler/rustc_codegen_llvm/src/llvm/mod.rs+10-9| ... | ... | @@ -1,5 +1,15 @@ |
| 1 | 1 | #![allow(non_snake_case)] |
| 2 | 2 | |
| 3 | use std::cell::RefCell; | |
| 4 | use std::ffi::{CStr, CString}; | |
| 5 | use std::str::FromStr; | |
| 6 | use std::string::FromUtf8Error; | |
| 7 | ||
| 8 | use libc::c_uint; | |
| 9 | use rustc_data_structures::small_c_str::SmallCStr; | |
| 10 | use rustc_llvm::RustString; | |
| 11 | use rustc_target::abi::Align; | |
| 12 | ||
| 3 | 13 | pub use self::AtomicRmwBinOp::*; |
| 4 | 14 | pub use self::CallConv::*; |
| 5 | 15 | pub use self::CodeGenOptSize::*; |
| ... | ... | @@ -8,15 +18,6 @@ pub use self::Linkage::*; |
| 8 | 18 | pub use self::MetadataType::*; |
| 9 | 19 | pub use self::RealPredicate::*; |
| 10 | 20 | |
| 11 | use libc::c_uint; | |
| 12 | use rustc_data_structures::small_c_str::SmallCStr; | |
| 13 | use rustc_llvm::RustString; | |
| 14 | use rustc_target::abi::Align; | |
| 15 | use std::cell::RefCell; | |
| 16 | use std::ffi::{CStr, CString}; | |
| 17 | use std::str::FromStr; | |
| 18 | use std::string::FromUtf8Error; | |
| 19 | ||
| 20 | 21 | pub mod archive_ro; |
| 21 | 22 | pub mod diagnostic; |
| 22 | 23 | mod ffi; |
compiler/rustc_codegen_llvm/src/llvm_util.rs+12-13| ... | ... | @@ -1,9 +1,9 @@ |
| 1 | use crate::back::write::create_informational_target_machine; | |
| 2 | use crate::errors::{ | |
| 3 | FixedX18InvalidArch, InvalidTargetFeaturePrefix, PossibleFeature, TargetFeatureDisableOrEnable, | |
| 4 | UnknownCTargetFeature, UnknownCTargetFeaturePrefix, UnstableCTargetFeature, | |
| 5 | }; | |
| 6 | use crate::llvm; | |
| 1 | use std::ffi::{c_char, c_void, CStr, CString}; | |
| 2 | use std::fmt::Write; | |
| 3 | use std::path::Path; | |
| 4 | use std::sync::Once; | |
| 5 | use std::{ptr, slice, str}; | |
| 6 | ||
| 7 | 7 | use libc::c_int; |
| 8 | 8 | use rustc_codegen_ssa::base::wants_wasm_eh; |
| 9 | 9 | use rustc_data_structures::fx::{FxHashMap, FxHashSet}; |
| ... | ... | @@ -16,13 +16,12 @@ use rustc_span::symbol::Symbol; |
| 16 | 16 | use rustc_target::spec::{MergeFunctions, PanicStrategy}; |
| 17 | 17 | use rustc_target::target_features::{RUSTC_SPECIAL_FEATURES, RUSTC_SPECIFIC_FEATURES}; |
| 18 | 18 | |
| 19 | use std::ffi::{c_char, c_void, CStr, CString}; | |
| 20 | use std::fmt::Write; | |
| 21 | use std::path::Path; | |
| 22 | use std::ptr; | |
| 23 | use std::slice; | |
| 24 | use std::str; | |
| 25 | use std::sync::Once; | |
| 19 | use crate::back::write::create_informational_target_machine; | |
| 20 | use crate::errors::{ | |
| 21 | FixedX18InvalidArch, InvalidTargetFeaturePrefix, PossibleFeature, TargetFeatureDisableOrEnable, | |
| 22 | UnknownCTargetFeature, UnknownCTargetFeaturePrefix, UnstableCTargetFeature, | |
| 23 | }; | |
| 24 | use crate::llvm; | |
| 26 | 25 | |
| 27 | 26 | static INIT: Once = Once::new(); |
| 28 | 27 |
compiler/rustc_codegen_llvm/src/mono_item.rs+5-6| ... | ... | @@ -1,9 +1,3 @@ |
| 1 | use crate::attributes; | |
| 2 | use crate::base; | |
| 3 | use crate::context::CodegenCx; | |
| 4 | use crate::errors::SymbolAlreadyDefined; | |
| 5 | use crate::llvm; | |
| 6 | use crate::type_of::LayoutLlvmExt; | |
| 7 | 1 | use rustc_codegen_ssa::traits::*; |
| 8 | 2 | use rustc_hir::def::DefKind; |
| 9 | 3 | use rustc_hir::def_id::{DefId, LOCAL_CRATE}; |
| ... | ... | @@ -15,6 +9,11 @@ use rustc_session::config::CrateType; |
| 15 | 9 | use rustc_target::spec::RelocModel; |
| 16 | 10 | use tracing::debug; |
| 17 | 11 | |
| 12 | use crate::context::CodegenCx; | |
| 13 | use crate::errors::SymbolAlreadyDefined; | |
| 14 | use crate::type_of::LayoutLlvmExt; | |
| 15 | use crate::{attributes, base, llvm}; | |
| 16 | ||
| 18 | 17 | impl<'tcx> PreDefineMethods<'tcx> for CodegenCx<'_, 'tcx> { |
| 19 | 18 | fn predefine_static( |
| 20 | 19 | &self, |
compiler/rustc_codegen_llvm/src/type_.rs+9-12| ... | ... | @@ -1,12 +1,6 @@ |
| 1 | pub use crate::llvm::Type; | |
| 1 | use std::{fmt, ptr}; | |
| 2 | 2 | |
| 3 | use crate::abi::{FnAbiLlvmExt, LlvmType}; | |
| 4 | use crate::common; | |
| 5 | use crate::context::CodegenCx; | |
| 6 | use crate::llvm; | |
| 7 | use crate::llvm::{Bool, False, True}; | |
| 8 | use crate::type_of::LayoutLlvmExt; | |
| 9 | use crate::value::Value; | |
| 3 | use libc::{c_char, c_uint}; | |
| 10 | 4 | use rustc_codegen_ssa::common::TypeKind; |
| 11 | 5 | use rustc_codegen_ssa::traits::*; |
| 12 | 6 | use rustc_data_structures::small_c_str::SmallCStr; |
| ... | ... | @@ -16,10 +10,13 @@ use rustc_middle::ty::{self, Ty}; |
| 16 | 10 | use rustc_target::abi::call::{CastTarget, FnAbi, Reg}; |
| 17 | 11 | use rustc_target::abi::{AddressSpace, Align, Integer, Size}; |
| 18 | 12 | |
| 19 | use std::fmt; | |
| 20 | use std::ptr; | |
| 21 | ||
| 22 | use libc::{c_char, c_uint}; | |
| 13 | use crate::abi::{FnAbiLlvmExt, LlvmType}; | |
| 14 | use crate::context::CodegenCx; | |
| 15 | pub use crate::llvm::Type; | |
| 16 | use crate::llvm::{Bool, False, True}; | |
| 17 | use crate::type_of::LayoutLlvmExt; | |
| 18 | use crate::value::Value; | |
| 19 | use crate::{common, llvm}; | |
| 23 | 20 | |
| 24 | 21 | impl PartialEq for Type { |
| 25 | 22 | fn eq(&self, other: &Self) -> bool { |
compiler/rustc_codegen_llvm/src/type_of.rs+5-6| ... | ... | @@ -1,16 +1,15 @@ |
| 1 | use crate::common::*; | |
| 2 | use crate::type_::Type; | |
| 1 | use std::fmt::Write; | |
| 2 | ||
| 3 | 3 | use rustc_codegen_ssa::traits::*; |
| 4 | 4 | use rustc_middle::bug; |
| 5 | 5 | use rustc_middle::ty::layout::{LayoutOf, TyAndLayout}; |
| 6 | 6 | use rustc_middle::ty::print::{with_no_trimmed_paths, with_no_visible_paths}; |
| 7 | 7 | use rustc_middle::ty::{self, CoroutineArgsExt, Ty, TypeVisitableExt}; |
| 8 | use rustc_target::abi::{Abi, Align, FieldsShape}; | |
| 9 | use rustc_target::abi::{Float, Int, Pointer}; | |
| 10 | use rustc_target::abi::{Scalar, Size, Variants}; | |
| 8 | use rustc_target::abi::{Abi, Align, FieldsShape, Float, Int, Pointer, Scalar, Size, Variants}; | |
| 11 | 9 | use tracing::debug; |
| 12 | 10 | |
| 13 | use std::fmt::Write; | |
| 11 | use crate::common::*; | |
| 12 | use crate::type_::Type; | |
| 14 | 13 | |
| 15 | 14 | fn uncached_llvm_type<'a, 'tcx>( |
| 16 | 15 | cx: &CodegenCx<'a, 'tcx>, |
compiler/rustc_codegen_llvm/src/va_arg.rs+7-8| ... | ... | @@ -1,16 +1,15 @@ |
| 1 | use crate::builder::Builder; | |
| 2 | use crate::type_::Type; | |
| 3 | use crate::type_of::LayoutLlvmExt; | |
| 4 | use crate::value::Value; | |
| 1 | use rustc_codegen_ssa::common::IntPredicate; | |
| 5 | 2 | use rustc_codegen_ssa::mir::operand::OperandRef; |
| 6 | use rustc_codegen_ssa::{ | |
| 7 | common::IntPredicate, | |
| 8 | traits::{BaseTypeMethods, BuilderMethods, ConstMethods}, | |
| 9 | }; | |
| 3 | use rustc_codegen_ssa::traits::{BaseTypeMethods, BuilderMethods, ConstMethods}; | |
| 10 | 4 | use rustc_middle::ty::layout::{HasTyCtxt, LayoutOf}; |
| 11 | 5 | use rustc_middle::ty::Ty; |
| 12 | 6 | use rustc_target::abi::{Align, Endian, HasDataLayout, Size}; |
| 13 | 7 | |
| 8 | use crate::builder::Builder; | |
| 9 | use crate::type_::Type; | |
| 10 | use crate::type_of::LayoutLlvmExt; | |
| 11 | use crate::value::Value; | |
| 12 | ||
| 14 | 13 | fn round_pointer_up_to_alignment<'ll>( |
| 15 | 14 | bx: &mut Builder<'_, 'll, '_>, |
| 16 | 15 | addr: &'ll Value, |
compiler/rustc_codegen_llvm/src/value.rs+3-5| ... | ... | @@ -1,10 +1,8 @@ |
| 1 | pub use crate::llvm::Value; | |
| 1 | use std::hash::{Hash, Hasher}; | |
| 2 | use std::{fmt, ptr}; | |
| 2 | 3 | |
| 3 | 4 | use crate::llvm; |
| 4 | ||
| 5 | use std::fmt; | |
| 6 | use std::hash::{Hash, Hasher}; | |
| 7 | use std::ptr; | |
| 5 | pub use crate::llvm::Value; | |
| 8 | 6 | |
| 9 | 7 | impl PartialEq for Value { |
| 10 | 8 | fn eq(&self, other: &Self) -> bool { |
compiler/rustc_codegen_ssa/src/assert_module_sources.rs+6-5| ... | ... | @@ -23,10 +23,11 @@ |
| 23 | 23 | //! allows for doing a more fine-grained check to see if pre- or post-lto data |
| 24 | 24 | //! was re-used. |
| 25 | 25 | |
| 26 | use crate::errors; | |
| 26 | use std::borrow::Cow; | |
| 27 | use std::fmt; | |
| 28 | ||
| 27 | 29 | use rustc_ast as ast; |
| 28 | use rustc_data_structures::unord::UnordMap; | |
| 29 | use rustc_data_structures::unord::UnordSet; | |
| 30 | use rustc_data_structures::unord::{UnordMap, UnordSet}; | |
| 30 | 31 | use rustc_errors::{DiagArgValue, IntoDiagArg}; |
| 31 | 32 | use rustc_hir::def_id::LOCAL_CRATE; |
| 32 | 33 | use rustc_middle::mir::mono::CodegenUnitNameBuilder; |
| ... | ... | @@ -34,11 +35,11 @@ use rustc_middle::ty::TyCtxt; |
| 34 | 35 | use rustc_session::Session; |
| 35 | 36 | use rustc_span::symbol::sym; |
| 36 | 37 | use rustc_span::{Span, Symbol}; |
| 37 | use std::borrow::Cow; | |
| 38 | use std::fmt; | |
| 39 | 38 | use thin_vec::ThinVec; |
| 40 | 39 | use tracing::debug; |
| 41 | 40 | |
| 41 | use crate::errors; | |
| 42 | ||
| 42 | 43 | #[allow(missing_docs)] |
| 43 | 44 | pub fn assert_module_sources(tcx: TyCtxt<'_>, set_reuse: &dyn Fn(&mut CguReuseTracker)) { |
| 44 | 45 | tcx.dep_graph.with_ignore(|| { |
compiler/rustc_codegen_ssa/src/back/archive.rs+10-12| ... | ... | @@ -1,22 +1,20 @@ |
| 1 | use rustc_data_structures::fx::FxIndexSet; | |
| 2 | use rustc_data_structures::memmap::Mmap; | |
| 3 | use rustc_session::cstore::DllImport; | |
| 4 | use rustc_session::Session; | |
| 5 | use rustc_span::symbol::Symbol; | |
| 6 | ||
| 7 | use super::metadata::search_for_section; | |
| 1 | use std::error::Error; | |
| 2 | use std::fs::{self, File}; | |
| 3 | use std::io::{self, Write}; | |
| 4 | use std::path::{Path, PathBuf}; | |
| 8 | 5 | |
| 9 | 6 | use ar_archive_writer::{write_archive_to_stream, ArchiveKind, NewArchiveMember}; |
| 10 | 7 | pub use ar_archive_writer::{ObjectReader, DEFAULT_OBJECT_READER}; |
| 11 | 8 | use object::read::archive::ArchiveFile; |
| 12 | 9 | use object::read::macho::FatArch; |
| 10 | use rustc_data_structures::fx::FxIndexSet; | |
| 11 | use rustc_data_structures::memmap::Mmap; | |
| 12 | use rustc_session::cstore::DllImport; | |
| 13 | use rustc_session::Session; | |
| 14 | use rustc_span::symbol::Symbol; | |
| 13 | 15 | use tempfile::Builder as TempFileBuilder; |
| 14 | 16 | |
| 15 | use std::error::Error; | |
| 16 | use std::fs::{self, File}; | |
| 17 | use std::io::{self, Write}; | |
| 18 | use std::path::{Path, PathBuf}; | |
| 19 | ||
| 17 | use super::metadata::search_for_section; | |
| 20 | 18 | // Re-exporting for rustc_codegen_llvm::back::archive |
| 21 | 19 | pub use crate::errors::{ArchiveBuildFailure, ExtractBundledLibsError, UnknownArchiveKind}; |
| 22 | 20 |
compiler/rustc_codegen_ssa/src/back/command.rs+1-3| ... | ... | @@ -2,10 +2,8 @@ |
| 2 | 2 | //! read the arguments that are built up. |
| 3 | 3 | |
| 4 | 4 | use std::ffi::{OsStr, OsString}; |
| 5 | use std::fmt; | |
| 6 | use std::io; | |
| 7 | use std::mem; | |
| 8 | 5 | use std::process::{self, Output}; |
| 6 | use std::{fmt, io, mem}; | |
| 9 | 7 | |
| 10 | 8 | use rustc_target::spec::LldFlavor; |
| 11 | 9 |
compiler/rustc_codegen_ssa/src/back/link.rs+23-23| ... | ... | @@ -1,3 +1,15 @@ |
| 1 | use std::collections::BTreeSet; | |
| 2 | use std::ffi::OsString; | |
| 3 | use std::fs::{read, File, OpenOptions}; | |
| 4 | use std::io::{BufWriter, Write}; | |
| 5 | use std::ops::Deref; | |
| 6 | use std::path::{Path, PathBuf}; | |
| 7 | use std::process::{ExitStatus, Output, Stdio}; | |
| 8 | use std::{env, fmt, fs, io, mem, str}; | |
| 9 | ||
| 10 | use cc::windows_registry; | |
| 11 | use itertools::Itertools; | |
| 12 | use regex::Regex; | |
| 1 | 13 | use rustc_arena::TypedArena; |
| 2 | 14 | use rustc_ast::CRATE_NODE_ID; |
| 3 | 15 | use rustc_data_structures::fx::{FxIndexMap, FxIndexSet}; |
| ... | ... | @@ -12,9 +24,10 @@ use rustc_middle::bug; |
| 12 | 24 | use rustc_middle::middle::debugger_visualizer::DebuggerVisualizerFile; |
| 13 | 25 | use rustc_middle::middle::dependency_format::Linkage; |
| 14 | 26 | use rustc_middle::middle::exported_symbols::SymbolExportKind; |
| 15 | use rustc_session::config::LinkerFeaturesCli; | |
| 16 | use rustc_session::config::{self, CFGuard, CrateType, DebugInfo, OutFileName, Strip}; | |
| 17 | use rustc_session::config::{OutputFilenames, OutputType, PrintKind, SplitDwarfKind}; | |
| 27 | use rustc_session::config::{ | |
| 28 | self, CFGuard, CrateType, DebugInfo, LinkerFeaturesCli, OutFileName, OutputFilenames, | |
| 29 | OutputType, PrintKind, SplitDwarfKind, Strip, | |
| 30 | }; | |
| 18 | 31 | use rustc_session::cstore::DllImport; |
| 19 | 32 | use rustc_session::output::{check_file_is_writeable, invalid_output_for_target, out_filename}; |
| 20 | 33 | use rustc_session::search_paths::PathKind; |
| ... | ... | @@ -24,11 +37,13 @@ use rustc_session::utils::NativeLibKind; |
| 24 | 37 | use rustc_session::{filesearch, Session}; |
| 25 | 38 | use rustc_span::symbol::Symbol; |
| 26 | 39 | use rustc_target::spec::crt_objects::CrtObjects; |
| 27 | use rustc_target::spec::LinkSelfContainedDefault; | |
| 28 | use rustc_target::spec::LinkerFlavorCli; | |
| 29 | use rustc_target::spec::{Cc, LinkOutputKind, LinkerFlavor, Lld, PanicStrategy}; | |
| 30 | use rustc_target::spec::{LinkSelfContainedComponents, LinkerFeatures}; | |
| 31 | use rustc_target::spec::{RelocModel, RelroLevel, SanitizerSet, SplitDebuginfo}; | |
| 40 | use rustc_target::spec::{ | |
| 41 | Cc, LinkOutputKind, LinkSelfContainedComponents, LinkSelfContainedDefault, LinkerFeatures, | |
| 42 | LinkerFlavor, LinkerFlavorCli, Lld, PanicStrategy, RelocModel, RelroLevel, SanitizerSet, | |
| 43 | SplitDebuginfo, | |
| 44 | }; | |
| 45 | use tempfile::Builder as TempFileBuilder; | |
| 46 | use tracing::{debug, info, warn}; | |
| 32 | 47 | |
| 33 | 48 | use super::archive::{ArchiveBuilder, ArchiveBuilderBuilder}; |
| 34 | 49 | use super::command::Command; |
| ... | ... | @@ -39,21 +54,6 @@ use crate::{ |
| 39 | 54 | errors, looks_like_rust_object_file, CodegenResults, CompiledModule, CrateInfo, NativeLib, |
| 40 | 55 | }; |
| 41 | 56 | |
| 42 | use cc::windows_registry; | |
| 43 | use regex::Regex; | |
| 44 | use tempfile::Builder as TempFileBuilder; | |
| 45 | ||
| 46 | use itertools::Itertools; | |
| 47 | use std::collections::BTreeSet; | |
| 48 | use std::ffi::OsString; | |
| 49 | use std::fs::{read, File, OpenOptions}; | |
| 50 | use std::io::{BufWriter, Write}; | |
| 51 | use std::ops::Deref; | |
| 52 | use std::path::{Path, PathBuf}; | |
| 53 | use std::process::{ExitStatus, Output, Stdio}; | |
| 54 | use std::{env, fmt, fs, io, mem, str}; | |
| 55 | use tracing::{debug, info, warn}; | |
| 56 | ||
| 57 | 57 | pub fn ensure_removed(dcx: DiagCtxtHandle<'_>, path: &Path) { |
| 58 | 58 | if let Err(e) = fs::remove_file(path) { |
| 59 | 59 | if e.kind() != io::ErrorKind::NotFound { |
compiler/rustc_codegen_ssa/src/back/linker.rs+6-7| ... | ... | @@ -1,8 +1,3 @@ |
| 1 | use super::command::Command; | |
| 2 | use super::symbol_export; | |
| 3 | use crate::errors; | |
| 4 | use rustc_span::symbol::sym; | |
| 5 | ||
| 6 | 1 | use std::ffi::{OsStr, OsString}; |
| 7 | 2 | use std::fs::{self, File}; |
| 8 | 3 | use std::io::prelude::*; |
| ... | ... | @@ -10,6 +5,7 @@ use std::io::{self, BufWriter}; |
| 10 | 5 | use std::path::{Path, PathBuf}; |
| 11 | 6 | use std::{env, iter, mem, str}; |
| 12 | 7 | |
| 8 | use cc::windows_registry; | |
| 13 | 9 | use rustc_hir::def_id::{CrateNum, LOCAL_CRATE}; |
| 14 | 10 | use rustc_metadata::find_native_static_library; |
| 15 | 11 | use rustc_middle::bug; |
| ... | ... | @@ -19,11 +15,14 @@ use rustc_middle::middle::exported_symbols::{ExportedSymbol, SymbolExportInfo, S |
| 19 | 15 | use rustc_middle::ty::TyCtxt; |
| 20 | 16 | use rustc_session::config::{self, CrateType, DebugInfo, LinkerPluginLto, Lto, OptLevel, Strip}; |
| 21 | 17 | use rustc_session::Session; |
| 18 | use rustc_span::symbol::sym; | |
| 22 | 19 | use rustc_target::spec::{Cc, LinkOutputKind, LinkerFlavor, Lld}; |
| 23 | ||
| 24 | use cc::windows_registry; | |
| 25 | 20 | use tracing::{debug, warn}; |
| 26 | 21 | |
| 22 | use super::command::Command; | |
| 23 | use super::symbol_export; | |
| 24 | use crate::errors; | |
| 25 | ||
| 27 | 26 | /// Disables non-English messages from localized linkers. |
| 28 | 27 | /// Such messages may cause issues with text encoding on Windows (#35785) |
| 29 | 28 | /// and prevent inspection of linker output in case of errors, which we occasionally do. |
compiler/rustc_codegen_ssa/src/back/lto.rs+5-5| ... | ... | @@ -1,12 +1,12 @@ |
| 1 | use super::write::CodegenContext; | |
| 2 | use crate::traits::*; | |
| 3 | use crate::ModuleCodegen; | |
| 1 | use std::ffi::CString; | |
| 2 | use std::sync::Arc; | |
| 4 | 3 | |
| 5 | 4 | use rustc_data_structures::memmap::Mmap; |
| 6 | 5 | use rustc_errors::FatalError; |
| 7 | 6 | |
| 8 | use std::ffi::CString; | |
| 9 | use std::sync::Arc; | |
| 7 | use super::write::CodegenContext; | |
| 8 | use crate::traits::*; | |
| 9 | use crate::ModuleCodegen; | |
| 10 | 10 | |
| 11 | 11 | pub struct ThinModule<B: WriteBackendMethods> { |
| 12 | 12 | pub shared: Arc<ThinShared<B>>, |
compiler/rustc_codegen_ssa/src/back/metadata.rs-1| ... | ... | @@ -10,7 +10,6 @@ use object::{ |
| 10 | 10 | elf, pe, xcoff, Architecture, BinaryFormat, Endianness, FileFlags, Object, ObjectSection, |
| 11 | 11 | ObjectSymbol, SectionFlags, SectionKind, SubArchitecture, SymbolFlags, SymbolKind, SymbolScope, |
| 12 | 12 | }; |
| 13 | ||
| 14 | 13 | use rustc_data_structures::memmap::Mmap; |
| 15 | 14 | use rustc_data_structures::owned_slice::{try_slice_owned, OwnedSlice}; |
| 16 | 15 | use rustc_metadata::creader::MetadataLoader; |
compiler/rustc_codegen_ssa/src/back/rpath.rs+3-2| ... | ... | @@ -1,8 +1,9 @@ |
| 1 | use std::ffi::OsString; | |
| 2 | use std::path::{Path, PathBuf}; | |
| 3 | ||
| 1 | 4 | use pathdiff::diff_paths; |
| 2 | 5 | use rustc_data_structures::fx::FxHashSet; |
| 3 | 6 | use rustc_fs_util::try_canonicalize; |
| 4 | use std::ffi::OsString; | |
| 5 | use std::path::{Path, PathBuf}; | |
| 6 | 7 | use tracing::debug; |
| 7 | 8 | |
| 8 | 9 | pub struct RPathConfig<'a> { |
compiler/rustc_codegen_ssa/src/back/rpath/tests.rs+2-2| ... | ... | @@ -1,8 +1,8 @@ |
| 1 | use super::RPathConfig; | |
| 2 | use super::{get_rpath_relative_to_output, minimize_rpaths, rpaths_to_flags}; | |
| 3 | 1 | use std::ffi::OsString; |
| 4 | 2 | use std::path::{Path, PathBuf}; |
| 5 | 3 | |
| 4 | use super::{get_rpath_relative_to_output, minimize_rpaths, rpaths_to_flags, RPathConfig}; | |
| 5 | ||
| 6 | 6 | #[test] |
| 7 | 7 | fn test_rpaths_to_flags() { |
| 8 | 8 | let flags = rpaths_to_flags(vec!["path1".into(), "path2".into()]); |
compiler/rustc_codegen_ssa/src/back/symbol_export.rs+3-5| ... | ... | @@ -1,5 +1,3 @@ |
| 1 | use crate::base::allocator_kind_for_codegen; | |
| 2 | ||
| 3 | 1 | use std::collections::hash_map::Entry::*; |
| 4 | 2 | |
| 5 | 3 | use rustc_ast::expand::allocator::{ALLOCATOR_METHODS, NO_ALLOC_SHIM_IS_UNSTABLE}; |
| ... | ... | @@ -12,14 +10,14 @@ use rustc_middle::middle::exported_symbols::{ |
| 12 | 10 | metadata_symbol_name, ExportedSymbol, SymbolExportInfo, SymbolExportKind, SymbolExportLevel, |
| 13 | 11 | }; |
| 14 | 12 | use rustc_middle::query::LocalCrate; |
| 15 | use rustc_middle::ty::Instance; | |
| 16 | use rustc_middle::ty::{self, SymbolName, TyCtxt}; | |
| 17 | use rustc_middle::ty::{GenericArgKind, GenericArgsRef}; | |
| 13 | use rustc_middle::ty::{self, GenericArgKind, GenericArgsRef, Instance, SymbolName, TyCtxt}; | |
| 18 | 14 | use rustc_middle::util::Providers; |
| 19 | 15 | use rustc_session::config::{CrateType, OomStrategy}; |
| 20 | 16 | use rustc_target::spec::{SanitizerSet, TlsModel}; |
| 21 | 17 | use tracing::debug; |
| 22 | 18 | |
| 19 | use crate::base::allocator_kind_for_codegen; | |
| 20 | ||
| 23 | 21 | pub fn threshold(tcx: TyCtxt<'_>) -> SymbolExportLevel { |
| 24 | 22 | crates_export_threshold(tcx.crate_types()) |
| 25 | 23 | } |
compiler/rustc_codegen_ssa/src/back/write.rs+18-21| ... | ... | @@ -1,12 +1,10 @@ |
| 1 | use super::link::{self, ensure_removed}; | |
| 2 | use super::lto::{self, SerializedModule}; | |
| 3 | use super::symbol_export::symbol_name_for_instance_in_crate; | |
| 1 | use std::any::Any; | |
| 2 | use std::marker::PhantomData; | |
| 3 | use std::path::{Path, PathBuf}; | |
| 4 | use std::sync::mpsc::{channel, Receiver, Sender}; | |
| 5 | use std::sync::Arc; | |
| 6 | use std::{fs, io, mem, str, thread}; | |
| 4 | 7 | |
| 5 | use crate::errors; | |
| 6 | use crate::traits::*; | |
| 7 | use crate::{ | |
| 8 | CachedModuleCodegen, CodegenResults, CompiledModule, CrateInfo, ModuleCodegen, ModuleKind, | |
| 9 | }; | |
| 10 | 8 | use jobserver::{Acquired, Client}; |
| 11 | 9 | use rustc_ast::attr; |
| 12 | 10 | use rustc_data_structures::fx::{FxHashMap, FxIndexMap}; |
| ... | ... | @@ -30,26 +28,25 @@ use rustc_middle::bug; |
| 30 | 28 | use rustc_middle::dep_graph::{WorkProduct, WorkProductId}; |
| 31 | 29 | use rustc_middle::middle::exported_symbols::SymbolExportInfo; |
| 32 | 30 | use rustc_middle::ty::TyCtxt; |
| 33 | use rustc_session::config::{self, CrateType, Lto, OutFileName, OutputFilenames, OutputType}; | |
| 34 | use rustc_session::config::{Passes, SwitchWithOptPath}; | |
| 31 | use rustc_session::config::{ | |
| 32 | self, CrateType, Lto, OutFileName, OutputFilenames, OutputType, Passes, SwitchWithOptPath, | |
| 33 | }; | |
| 35 | 34 | use rustc_session::Session; |
| 36 | 35 | use rustc_span::source_map::SourceMap; |
| 37 | 36 | use rustc_span::symbol::sym; |
| 38 | 37 | use rustc_span::{BytePos, FileName, InnerSpan, Pos, Span}; |
| 39 | 38 | use rustc_target::spec::{MergeFunctions, SanitizerSet}; |
| 39 | use tracing::debug; | |
| 40 | 40 | |
| 41 | use super::link::{self, ensure_removed}; | |
| 42 | use super::lto::{self, SerializedModule}; | |
| 43 | use super::symbol_export::symbol_name_for_instance_in_crate; | |
| 41 | 44 | use crate::errors::ErrorCreatingRemarkDir; |
| 42 | use std::any::Any; | |
| 43 | use std::fs; | |
| 44 | use std::io; | |
| 45 | use std::marker::PhantomData; | |
| 46 | use std::mem; | |
| 47 | use std::path::{Path, PathBuf}; | |
| 48 | use std::str; | |
| 49 | use std::sync::mpsc::{channel, Receiver, Sender}; | |
| 50 | use std::sync::Arc; | |
| 51 | use std::thread; | |
| 52 | use tracing::debug; | |
| 45 | use crate::traits::*; | |
| 46 | use crate::{ | |
| 47 | errors, CachedModuleCodegen, CodegenResults, CompiledModule, CrateInfo, ModuleCodegen, | |
| 48 | ModuleKind, | |
| 49 | }; | |
| 53 | 50 | |
| 54 | 51 | const PRE_LTO_BC_EXT: &str = "pre-lto.bc"; |
| 55 | 52 |
compiler/rustc_codegen_ssa/src/base.rs+20-23| ... | ... | @@ -1,19 +1,8 @@ |
| 1 | use crate::assert_module_sources::CguReuse; | |
| 2 | use crate::back::link::are_upstream_rust_objects_already_included; | |
| 3 | use crate::back::metadata::create_compressed_metadata_file; | |
| 4 | use crate::back::write::{ | |
| 5 | compute_per_cgu_lto_type, start_async_codegen, submit_codegened_module_to_llvm, | |
| 6 | submit_post_lto_module_to_llvm, submit_pre_lto_module_to_llvm, ComputedLtoType, OngoingCodegen, | |
| 7 | }; | |
| 8 | use crate::common::{self, IntPredicate, RealPredicate, TypeKind}; | |
| 9 | use crate::errors; | |
| 10 | use crate::meth; | |
| 11 | use crate::mir; | |
| 12 | use crate::mir::operand::OperandValue; | |
| 13 | use crate::mir::place::PlaceRef; | |
| 14 | use crate::traits::*; | |
| 15 | use crate::{CachedModuleCodegen, CompiledModule, CrateInfo, ModuleCodegen, ModuleKind}; | |
| 1 | use std::cmp; | |
| 2 | use std::collections::BTreeSet; | |
| 3 | use std::time::{Duration, Instant}; | |
| 16 | 4 | |
| 5 | use itertools::Itertools; | |
| 17 | 6 | use rustc_ast::expand::allocator::{global_fn_name, AllocatorKind, ALLOCATOR_METHODS}; |
| 18 | 7 | use rustc_attr as attr; |
| 19 | 8 | use rustc_data_structures::fx::{FxHashMap, FxIndexSet}; |
| ... | ... | @@ -26,9 +15,8 @@ use rustc_metadata::EncodedMetadata; |
| 26 | 15 | use rustc_middle::bug; |
| 27 | 16 | use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrs; |
| 28 | 17 | use rustc_middle::middle::debugger_visualizer::{DebuggerVisualizerFile, DebuggerVisualizerType}; |
| 29 | use rustc_middle::middle::exported_symbols; | |
| 30 | 18 | use rustc_middle::middle::exported_symbols::SymbolExportKind; |
| 31 | use rustc_middle::middle::lang_items; | |
| 19 | use rustc_middle::middle::{exported_symbols, lang_items}; | |
| 32 | 20 | use rustc_middle::mir::mono::{CodegenUnit, CodegenUnitNameBuilder, MonoItem}; |
| 33 | 21 | use rustc_middle::mir::BinOp; |
| 34 | 22 | use rustc_middle::query::Providers; |
| ... | ... | @@ -39,14 +27,23 @@ use rustc_session::Session; |
| 39 | 27 | use rustc_span::symbol::sym; |
| 40 | 28 | use rustc_span::{Symbol, DUMMY_SP}; |
| 41 | 29 | use rustc_target::abi::FIRST_VARIANT; |
| 42 | ||
| 43 | use std::cmp; | |
| 44 | use std::collections::BTreeSet; | |
| 45 | use std::time::{Duration, Instant}; | |
| 46 | ||
| 47 | use itertools::Itertools; | |
| 48 | 30 | use tracing::{debug, info}; |
| 49 | 31 | |
| 32 | use crate::assert_module_sources::CguReuse; | |
| 33 | use crate::back::link::are_upstream_rust_objects_already_included; | |
| 34 | use crate::back::metadata::create_compressed_metadata_file; | |
| 35 | use crate::back::write::{ | |
| 36 | compute_per_cgu_lto_type, start_async_codegen, submit_codegened_module_to_llvm, | |
| 37 | submit_post_lto_module_to_llvm, submit_pre_lto_module_to_llvm, ComputedLtoType, OngoingCodegen, | |
| 38 | }; | |
| 39 | use crate::common::{self, IntPredicate, RealPredicate, TypeKind}; | |
| 40 | use crate::mir::operand::OperandValue; | |
| 41 | use crate::mir::place::PlaceRef; | |
| 42 | use crate::traits::*; | |
| 43 | use crate::{ | |
| 44 | errors, meth, mir, CachedModuleCodegen, CompiledModule, CrateInfo, ModuleCodegen, ModuleKind, | |
| 45 | }; | |
| 46 | ||
| 50 | 47 | pub fn bin_op_to_icmp_predicate(op: BinOp, signed: bool) -> IntPredicate { |
| 51 | 48 | match op { |
| 52 | 49 | BinOp::Eq => IntPredicate::IntEQ, |
compiler/rustc_codegen_ssa/src/codegen_attrs.rs+6-3| ... | ... | @@ -1,17 +1,20 @@ |
| 1 | 1 | use rustc_ast::{ast, attr, MetaItemKind, NestedMetaItem}; |
| 2 | 2 | use rustc_attr::{list_contains_name, InlineAttr, InstructionSetAttr, OptimizeAttr}; |
| 3 | use rustc_errors::{codes::*, struct_span_code_err, DiagMessage, SubdiagMessage}; | |
| 3 | use rustc_errors::codes::*; | |
| 4 | use rustc_errors::{struct_span_code_err, DiagMessage, SubdiagMessage}; | |
| 4 | 5 | use rustc_hir as hir; |
| 5 | 6 | use rustc_hir::def::DefKind; |
| 6 | 7 | use rustc_hir::def_id::{DefId, LocalDefId, LOCAL_CRATE}; |
| 7 | use rustc_hir::{lang_items, weak_lang_items::WEAK_LANG_ITEMS, LangItem}; | |
| 8 | use rustc_hir::weak_lang_items::WEAK_LANG_ITEMS; | |
| 9 | use rustc_hir::{lang_items, LangItem}; | |
| 8 | 10 | use rustc_middle::middle::codegen_fn_attrs::{ |
| 9 | 11 | CodegenFnAttrFlags, CodegenFnAttrs, PatchableFunctionEntry, |
| 10 | 12 | }; |
| 11 | 13 | use rustc_middle::mir::mono::Linkage; |
| 12 | 14 | use rustc_middle::query::Providers; |
| 13 | 15 | use rustc_middle::ty::{self as ty, TyCtxt}; |
| 14 | use rustc_session::{lint, parse::feature_err}; | |
| 16 | use rustc_session::lint; | |
| 17 | use rustc_session::parse::feature_err; | |
| 15 | 18 | use rustc_span::symbol::Ident; |
| 16 | 19 | use rustc_span::{sym, Span}; |
| 17 | 20 | use rustc_target::spec::{abi, SanitizerSet}; |
compiler/rustc_codegen_ssa/src/common.rs+5-5| ... | ... | @@ -1,10 +1,9 @@ |
| 1 | 1 | #![allow(non_camel_case_types)] |
| 2 | 2 | |
| 3 | 3 | use rustc_hir::LangItem; |
| 4 | use rustc_middle::mir; | |
| 5 | use rustc_middle::ty::Instance; | |
| 6 | use rustc_middle::ty::{self, layout::TyAndLayout, TyCtxt}; | |
| 7 | use rustc_middle::{bug, span_bug}; | |
| 4 | use rustc_middle::ty::layout::TyAndLayout; | |
| 5 | use rustc_middle::ty::{self, Instance, TyCtxt}; | |
| 6 | use rustc_middle::{bug, mir, span_bug}; | |
| 8 | 7 | use rustc_span::Span; |
| 9 | 8 | |
| 10 | 9 | use crate::traits::*; |
| ... | ... | @@ -106,9 +105,10 @@ pub enum TypeKind { |
| 106 | 105 | // for now we content ourselves with providing a no-op HashStable |
| 107 | 106 | // implementation for CGUs. |
| 108 | 107 | mod temp_stable_hash_impls { |
| 109 | use crate::ModuleCodegen; | |
| 110 | 108 | use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; |
| 111 | 109 | |
| 110 | use crate::ModuleCodegen; | |
| 111 | ||
| 112 | 112 | impl<HCX, M> HashStable<HCX> for ModuleCodegen<M> { |
| 113 | 113 | fn hash_stable(&self, _: &mut HCX, _: &mut StableHasher) { |
| 114 | 114 | // do nothing |
compiler/rustc_codegen_ssa/src/debuginfo/mod.rs+2-1| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | use rustc_middle::ty::{self, layout::TyAndLayout}; | |
| 1 | use rustc_middle::ty::layout::TyAndLayout; | |
| 2 | use rustc_middle::ty::{self}; | |
| 2 | 3 | use rustc_target::abi::Size; |
| 3 | 4 | |
| 4 | 5 | // FIXME(eddyb) find a place for this (or a way to replace it). |
compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs+5-4| ... | ... | @@ -11,6 +11,8 @@ |
| 11 | 11 | // within the brackets). |
| 12 | 12 | // * `"` is treated as the start of a string. |
| 13 | 13 | |
| 14 | use std::fmt::Write; | |
| 15 | ||
| 14 | 16 | use rustc_data_structures::fx::FxHashSet; |
| 15 | 17 | use rustc_data_structures::stable_hasher::{Hash64, HashStable, StableHasher}; |
| 16 | 18 | use rustc_hir::def_id::DefId; |
| ... | ... | @@ -18,14 +20,13 @@ use rustc_hir::definitions::{DefPathData, DefPathDataName, DisambiguatedDefPathD |
| 18 | 20 | use rustc_hir::{CoroutineDesugaring, CoroutineKind, CoroutineSource, Mutability}; |
| 19 | 21 | use rustc_middle::bug; |
| 20 | 22 | use rustc_middle::ty::layout::{IntegerExt, TyAndLayout}; |
| 21 | use rustc_middle::ty::{self, ExistentialProjection, ParamEnv, Ty, TyCtxt}; | |
| 22 | use rustc_middle::ty::{GenericArgKind, GenericArgsRef}; | |
| 23 | use rustc_middle::ty::{ | |
| 24 | self, ExistentialProjection, GenericArgKind, GenericArgsRef, ParamEnv, Ty, TyCtxt, | |
| 25 | }; | |
| 23 | 26 | use rustc_span::DUMMY_SP; |
| 24 | 27 | use rustc_target::abi::Integer; |
| 25 | 28 | use smallvec::SmallVec; |
| 26 | 29 | |
| 27 | use std::fmt::Write; | |
| 28 | ||
| 29 | 30 | use crate::debuginfo::wants_c_like_enum_debuginfo; |
| 30 | 31 | |
| 31 | 32 | /// Compute the name of the type as it should be stored in debuginfo. Does not do |
compiler/rustc_codegen_ssa/src/errors.rs+11-8| ... | ... | @@ -1,20 +1,23 @@ |
| 1 | 1 | //! Errors emitted by codegen_ssa |
| 2 | 2 | |
| 3 | use crate::assert_module_sources::CguReuse; | |
| 4 | use crate::back::command::Command; | |
| 5 | use crate::fluent_generated as fluent; | |
| 3 | use std::borrow::Cow; | |
| 4 | use std::io::Error; | |
| 5 | use std::path::{Path, PathBuf}; | |
| 6 | use std::process::ExitStatus; | |
| 7 | ||
| 8 | use rustc_errors::codes::*; | |
| 6 | 9 | use rustc_errors::{ |
| 7 | codes::*, Diag, DiagArgValue, DiagCtxtHandle, Diagnostic, EmissionGuarantee, IntoDiagArg, Level, | |
| 10 | Diag, DiagArgValue, DiagCtxtHandle, Diagnostic, EmissionGuarantee, IntoDiagArg, Level, | |
| 8 | 11 | }; |
| 9 | 12 | use rustc_macros::Diagnostic; |
| 10 | 13 | use rustc_middle::ty::layout::LayoutError; |
| 11 | 14 | use rustc_middle::ty::Ty; |
| 12 | 15 | use rustc_span::{Span, Symbol}; |
| 13 | 16 | use rustc_type_ir::FloatTy; |
| 14 | use std::borrow::Cow; | |
| 15 | use std::io::Error; | |
| 16 | use std::path::{Path, PathBuf}; | |
| 17 | use std::process::ExitStatus; | |
| 17 | ||
| 18 | use crate::assert_module_sources::CguReuse; | |
| 19 | use crate::back::command::Command; | |
| 20 | use crate::fluent_generated as fluent; | |
| 18 | 21 | |
| 19 | 22 | #[derive(Diagnostic)] |
| 20 | 23 | #[diag(codegen_ssa_incorrect_cgu_reuse_type)] |
compiler/rustc_codegen_ssa/src/lib.rs+5-5| ... | ... | @@ -17,9 +17,12 @@ |
| 17 | 17 | //! The backend-agnostic functions of this crate use functions defined in various traits that |
| 18 | 18 | //! have to be implemented by each backend. |
| 19 | 19 | |
| 20 | use std::collections::BTreeSet; | |
| 21 | use std::io; | |
| 22 | use std::path::{Path, PathBuf}; | |
| 23 | ||
| 20 | 24 | use rustc_ast as ast; |
| 21 | use rustc_data_structures::fx::FxHashSet; | |
| 22 | use rustc_data_structures::fx::FxIndexMap; | |
| 25 | use rustc_data_structures::fx::{FxHashSet, FxIndexMap}; | |
| 23 | 26 | use rustc_data_structures::sync::Lrc; |
| 24 | 27 | use rustc_data_structures::unord::UnordMap; |
| 25 | 28 | use rustc_hir::def_id::CrateNum; |
| ... | ... | @@ -36,9 +39,6 @@ use rustc_session::cstore::{self, CrateSource}; |
| 36 | 39 | use rustc_session::utils::NativeLibKind; |
| 37 | 40 | use rustc_session::Session; |
| 38 | 41 | use rustc_span::symbol::Symbol; |
| 39 | use std::collections::BTreeSet; | |
| 40 | use std::io; | |
| 41 | use std::path::{Path, PathBuf}; | |
| 42 | 42 | |
| 43 | 43 | pub mod assert_module_sources; |
| 44 | 44 | pub mod back; |
compiler/rustc_codegen_ssa/src/meth.rs+2-2| ... | ... | @@ -1,5 +1,3 @@ |
| 1 | use crate::traits::*; | |
| 2 | ||
| 3 | 1 | use rustc_middle::bug; |
| 4 | 2 | use rustc_middle::ty::{self, GenericArgKind, Ty}; |
| 5 | 3 | use rustc_session::config::Lto; |
| ... | ... | @@ -7,6 +5,8 @@ use rustc_symbol_mangling::typeid_for_trait_ref; |
| 7 | 5 | use rustc_target::abi::call::FnAbi; |
| 8 | 6 | use tracing::{debug, instrument}; |
| 9 | 7 | |
| 8 | use crate::traits::*; | |
| 9 | ||
| 10 | 10 | #[derive(Copy, Clone, Debug)] |
| 11 | 11 | pub struct VirtualIndex(u64); |
| 12 | 12 |
compiler/rustc_codegen_ssa/src/mir/analyze.rs+4-4| ... | ... | @@ -1,18 +1,18 @@ |
| 1 | 1 | //! An analysis to determine which locals require allocas and |
| 2 | 2 | //! which do not. |
| 3 | 3 | |
| 4 | use super::FunctionCx; | |
| 5 | use crate::traits::*; | |
| 6 | 4 | use rustc_data_structures::graph::dominators::Dominators; |
| 7 | 5 | use rustc_index::bit_set::BitSet; |
| 8 | 6 | use rustc_index::{IndexSlice, IndexVec}; |
| 9 | use rustc_middle::mir::traversal; | |
| 10 | 7 | use rustc_middle::mir::visit::{MutatingUseContext, NonMutatingUseContext, PlaceContext, Visitor}; |
| 11 | use rustc_middle::mir::{self, DefLocation, Location, TerminatorKind}; | |
| 8 | use rustc_middle::mir::{self, traversal, DefLocation, Location, TerminatorKind}; | |
| 12 | 9 | use rustc_middle::ty::layout::{HasTyCtxt, LayoutOf}; |
| 13 | 10 | use rustc_middle::{bug, span_bug}; |
| 14 | 11 | use tracing::debug; |
| 15 | 12 | |
| 13 | use super::FunctionCx; | |
| 14 | use crate::traits::*; | |
| 15 | ||
| 16 | 16 | pub fn non_ssa_locals<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( |
| 17 | 17 | fx: &FunctionCx<'a, 'tcx, Bx>, |
| 18 | 18 | ) -> BitSet<mir::Local> { |
compiler/rustc_codegen_ssa/src/mir/block.rs+12-13| ... | ... | @@ -1,14 +1,4 @@ |
| 1 | use super::operand::OperandRef; | |
| 2 | use super::operand::OperandValue::{Immediate, Pair, Ref, ZeroSized}; | |
| 3 | use super::place::{PlaceRef, PlaceValue}; | |
| 4 | use super::{CachedLlbb, FunctionCx, LocalRef}; | |
| 5 | ||
| 6 | use crate::base::{self, is_call_from_compiler_builtins_to_upstream_monomorphization}; | |
| 7 | use crate::common::{self, IntPredicate}; | |
| 8 | use crate::errors::CompilerBuiltinsCannotCall; | |
| 9 | use crate::meth; | |
| 10 | use crate::traits::*; | |
| 11 | use crate::MemFlags; | |
| 1 | use std::cmp; | |
| 12 | 2 | |
| 13 | 3 | use rustc_ast as ast; |
| 14 | 4 | use rustc_ast::{InlineAsmOptions, InlineAsmTemplatePiece}; |
| ... | ... | @@ -19,13 +9,22 @@ use rustc_middle::ty::print::{with_no_trimmed_paths, with_no_visible_paths}; |
| 19 | 9 | use rustc_middle::ty::{self, Instance, Ty}; |
| 20 | 10 | use rustc_middle::{bug, span_bug}; |
| 21 | 11 | use rustc_session::config::OptLevel; |
| 22 | use rustc_span::{source_map::Spanned, sym, Span}; | |
| 12 | use rustc_span::source_map::Spanned; | |
| 13 | use rustc_span::{sym, Span}; | |
| 23 | 14 | use rustc_target::abi::call::{ArgAbi, FnAbi, PassMode, Reg}; |
| 24 | 15 | use rustc_target::abi::{self, HasDataLayout, WrappingRange}; |
| 25 | 16 | use rustc_target::spec::abi::Abi; |
| 26 | 17 | use tracing::{debug, info}; |
| 27 | 18 | |
| 28 | use std::cmp; | |
| 19 | use super::operand::OperandRef; | |
| 20 | use super::operand::OperandValue::{Immediate, Pair, Ref, ZeroSized}; | |
| 21 | use super::place::{PlaceRef, PlaceValue}; | |
| 22 | use super::{CachedLlbb, FunctionCx, LocalRef}; | |
| 23 | use crate::base::{self, is_call_from_compiler_builtins_to_upstream_monomorphization}; | |
| 24 | use crate::common::{self, IntPredicate}; | |
| 25 | use crate::errors::CompilerBuiltinsCannotCall; | |
| 26 | use crate::traits::*; | |
| 27 | use crate::{meth, MemFlags}; | |
| 29 | 28 | |
| 30 | 29 | // Indicates if we are in the middle of merging a BB's successor into it. This |
| 31 | 30 | // can happen when BB jumps directly to its successor and the successor has no |
compiler/rustc_codegen_ssa/src/mir/constant.rs+4-5| ... | ... | @@ -1,14 +1,13 @@ |
| 1 | use crate::errors; | |
| 2 | use crate::mir::operand::OperandRef; | |
| 3 | use crate::traits::*; | |
| 4 | use rustc_middle::mir; | |
| 5 | 1 | use rustc_middle::mir::interpret::ErrorHandled; |
| 6 | 2 | use rustc_middle::ty::layout::HasTyCtxt; |
| 7 | 3 | use rustc_middle::ty::{self, Ty}; |
| 8 | use rustc_middle::{bug, span_bug}; | |
| 4 | use rustc_middle::{bug, mir, span_bug}; | |
| 9 | 5 | use rustc_target::abi::Abi; |
| 10 | 6 | |
| 11 | 7 | use super::FunctionCx; |
| 8 | use crate::errors; | |
| 9 | use crate::mir::operand::OperandRef; | |
| 10 | use crate::traits::*; | |
| 12 | 11 | |
| 13 | 12 | impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { |
| 14 | 13 | pub fn eval_mir_constant_to_operand( |
compiler/rustc_codegen_ssa/src/mir/coverageinfo.rs+1-2| ... | ... | @@ -1,9 +1,8 @@ |
| 1 | use crate::traits::*; | |
| 2 | ||
| 3 | 1 | use rustc_middle::mir::coverage::CoverageKind; |
| 4 | 2 | use rustc_middle::mir::SourceScope; |
| 5 | 3 | |
| 6 | 4 | use super::FunctionCx; |
| 5 | use crate::traits::*; | |
| 7 | 6 | |
| 8 | 7 | impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { |
| 9 | 8 | pub fn codegen_coverage(&self, bx: &mut Bx, kind: &CoverageKind, scope: SourceScope) { |
compiler/rustc_codegen_ssa/src/mir/debuginfo.rs+5-8| ... | ... | @@ -1,13 +1,11 @@ |
| 1 | use crate::traits::*; | |
| 1 | use std::ops::Range; | |
| 2 | ||
| 2 | 3 | use rustc_data_structures::fx::FxHashMap; |
| 3 | 4 | use rustc_index::IndexVec; |
| 4 | use rustc_middle::bug; | |
| 5 | 5 | use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags; |
| 6 | use rustc_middle::mir; | |
| 7 | use rustc_middle::ty; | |
| 8 | 6 | use rustc_middle::ty::layout::{LayoutOf, TyAndLayout}; |
| 9 | use rustc_middle::ty::Instance; | |
| 10 | use rustc_middle::ty::Ty; | |
| 7 | use rustc_middle::ty::{Instance, Ty}; | |
| 8 | use rustc_middle::{bug, mir, ty}; | |
| 11 | 9 | use rustc_session::config::DebugInfo; |
| 12 | 10 | use rustc_span::symbol::{kw, Symbol}; |
| 13 | 11 | use rustc_span::{hygiene, BytePos, Span}; |
| ... | ... | @@ -16,8 +14,7 @@ use rustc_target::abi::{Abi, FieldIdx, FieldsShape, Size, VariantIdx}; |
| 16 | 14 | use super::operand::{OperandRef, OperandValue}; |
| 17 | 15 | use super::place::{PlaceRef, PlaceValue}; |
| 18 | 16 | use super::{FunctionCx, LocalRef}; |
| 19 | ||
| 20 | use std::ops::Range; | |
| 17 | use crate::traits::*; | |
| 21 | 18 | |
| 22 | 19 | pub struct FunctionDebugContext<'tcx, S, L> { |
| 23 | 20 | /// Maps from source code to the corresponding debug info scope. |
compiler/rustc_codegen_ssa/src/mir/intrinsic.rs+8-13| ... | ... | @@ -1,21 +1,16 @@ |
| 1 | use rustc_middle::ty::{self, Ty, TyCtxt}; | |
| 2 | use rustc_middle::{bug, span_bug}; | |
| 3 | use rustc_session::config::OptLevel; | |
| 4 | use rustc_span::{sym, Span}; | |
| 5 | use rustc_target::abi::call::{FnAbi, PassMode}; | |
| 6 | use rustc_target::abi::WrappingRange; | |
| 7 | ||
| 1 | 8 | use super::operand::OperandRef; |
| 2 | 9 | use super::place::PlaceRef; |
| 3 | 10 | use super::FunctionCx; |
| 4 | use crate::errors; | |
| 5 | 11 | use crate::errors::InvalidMonomorphization; |
| 6 | use crate::meth; | |
| 7 | use crate::size_of_val; | |
| 8 | 12 | use crate::traits::*; |
| 9 | use crate::MemFlags; | |
| 10 | ||
| 11 | use rustc_middle::ty::{self, Ty, TyCtxt}; | |
| 12 | use rustc_middle::{bug, span_bug}; | |
| 13 | use rustc_session::config::OptLevel; | |
| 14 | use rustc_span::{sym, Span}; | |
| 15 | use rustc_target::abi::{ | |
| 16 | call::{FnAbi, PassMode}, | |
| 17 | WrappingRange, | |
| 18 | }; | |
| 13 | use crate::{errors, meth, size_of_val, MemFlags}; | |
| 19 | 14 | |
| 20 | 15 | fn copy_intrinsic<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( |
| 21 | 16 | bx: &mut Bx, |
compiler/rustc_codegen_ssa/src/mir/locals.rs+5-3| ... | ... | @@ -2,14 +2,16 @@ |
| 2 | 2 | //! be careful wrt to subtyping. To deal with this we only allow updates by using |
| 3 | 3 | //! `FunctionCx::overwrite_local` which handles it automatically. |
| 4 | 4 | |
| 5 | use crate::mir::{FunctionCx, LocalRef}; | |
| 6 | use crate::traits::BuilderMethods; | |
| 5 | use std::ops::{Index, IndexMut}; | |
| 6 | ||
| 7 | 7 | use rustc_index::IndexVec; |
| 8 | 8 | use rustc_middle::mir; |
| 9 | 9 | use rustc_middle::ty::print::with_no_trimmed_paths; |
| 10 | use std::ops::{Index, IndexMut}; | |
| 11 | 10 | use tracing::{debug, warn}; |
| 12 | 11 | |
| 12 | use crate::mir::{FunctionCx, LocalRef}; | |
| 13 | use crate::traits::BuilderMethods; | |
| 14 | ||
| 13 | 15 | pub(super) struct Locals<'tcx, V> { |
| 14 | 16 | values: IndexVec<mir::Local, LocalRef<'tcx, V>>, |
| 15 | 17 | } |
compiler/rustc_codegen_ssa/src/mir/mod.rs+6-7| ... | ... | @@ -1,18 +1,17 @@ |
| 1 | use crate::base; | |
| 2 | use crate::traits::*; | |
| 1 | use std::iter; | |
| 2 | ||
| 3 | 3 | use rustc_index::bit_set::BitSet; |
| 4 | 4 | use rustc_index::IndexVec; |
| 5 | 5 | use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags; |
| 6 | use rustc_middle::mir; | |
| 7 | use rustc_middle::mir::traversal; | |
| 8 | use rustc_middle::mir::UnwindTerminateReason; | |
| 6 | use rustc_middle::mir::{traversal, UnwindTerminateReason}; | |
| 9 | 7 | use rustc_middle::ty::layout::{FnAbiOf, HasTyCtxt, TyAndLayout}; |
| 10 | 8 | use rustc_middle::ty::{self, Instance, Ty, TyCtxt, TypeFoldable, TypeVisitableExt}; |
| 11 | use rustc_middle::{bug, span_bug}; | |
| 9 | use rustc_middle::{bug, mir, span_bug}; | |
| 12 | 10 | use rustc_target::abi::call::{FnAbi, PassMode}; |
| 13 | 11 | use tracing::{debug, instrument}; |
| 14 | 12 | |
| 15 | use std::iter; | |
| 13 | use crate::base; | |
| 14 | use crate::traits::*; | |
| 16 | 15 | |
| 17 | 16 | mod analyze; |
| 18 | 17 | mod block; |
compiler/rustc_codegen_ssa/src/mir/operand.rs+8-11| ... | ... | @@ -1,23 +1,20 @@ |
| 1 | use super::place::{PlaceRef, PlaceValue}; | |
| 2 | use super::{FunctionCx, LocalRef}; | |
| 3 | ||
| 4 | use crate::size_of_val; | |
| 5 | use crate::traits::*; | |
| 6 | use crate::MemFlags; | |
| 1 | use std::fmt; | |
| 7 | 2 | |
| 3 | use arrayvec::ArrayVec; | |
| 4 | use either::Either; | |
| 8 | 5 | use rustc_middle::bug; |
| 9 | 6 | use rustc_middle::mir::interpret::{alloc_range, Pointer, Scalar}; |
| 10 | 7 | use rustc_middle::mir::{self, ConstValue}; |
| 11 | 8 | use rustc_middle::ty::layout::{LayoutOf, TyAndLayout}; |
| 12 | 9 | use rustc_middle::ty::Ty; |
| 13 | 10 | use rustc_target::abi::{self, Abi, Align, Size}; |
| 14 | ||
| 15 | use std::fmt; | |
| 16 | ||
| 17 | use arrayvec::ArrayVec; | |
| 18 | use either::Either; | |
| 19 | 11 | use tracing::debug; |
| 20 | 12 | |
| 13 | use super::place::{PlaceRef, PlaceValue}; | |
| 14 | use super::{FunctionCx, LocalRef}; | |
| 15 | use crate::traits::*; | |
| 16 | use crate::{size_of_val, MemFlags}; | |
| 17 | ||
| 21 | 18 | /// The representation of a Rust value. The enum variant is in fact |
| 22 | 19 | /// uniquely determined by the value's type, but is kept as a |
| 23 | 20 | /// safety check. |
compiler/rustc_codegen_ssa/src/mir/place.rs+9-10| ... | ... | @@ -1,19 +1,18 @@ |
| 1 | use rustc_middle::mir::tcx::PlaceTy; | |
| 2 | use rustc_middle::ty::layout::{HasTyCtxt, LayoutOf, TyAndLayout}; | |
| 3 | use rustc_middle::ty::{self, Ty}; | |
| 4 | use rustc_middle::{bug, mir}; | |
| 5 | use rustc_target::abi::{ | |
| 6 | Align, FieldsShape, Int, Pointer, Size, TagEncoding, VariantIdx, Variants, | |
| 7 | }; | |
| 8 | use tracing::{debug, instrument}; | |
| 9 | ||
| 1 | 10 | use super::operand::OperandValue; |
| 2 | 11 | use super::{FunctionCx, LocalRef}; |
| 3 | ||
| 4 | 12 | use crate::common::IntPredicate; |
| 5 | 13 | use crate::size_of_val; |
| 6 | 14 | use crate::traits::*; |
| 7 | 15 | |
| 8 | use rustc_middle::bug; | |
| 9 | use rustc_middle::mir; | |
| 10 | use rustc_middle::mir::tcx::PlaceTy; | |
| 11 | use rustc_middle::ty::layout::{HasTyCtxt, LayoutOf, TyAndLayout}; | |
| 12 | use rustc_middle::ty::{self, Ty}; | |
| 13 | use rustc_target::abi::{Align, FieldsShape, Int, Pointer, Size, TagEncoding}; | |
| 14 | use rustc_target::abi::{VariantIdx, Variants}; | |
| 15 | use tracing::{debug, instrument}; | |
| 16 | ||
| 17 | 16 | /// The location and extra runtime properties of the place. |
| 18 | 17 | /// |
| 19 | 18 | /// Typically found in a [`PlaceRef`] or an [`OperandValue::Ref`]. |
compiler/rustc_codegen_ssa/src/mir/rvalue.rs+11-14| ... | ... | @@ -1,23 +1,20 @@ |
| 1 | use super::operand::{OperandRef, OperandValue}; | |
| 2 | use super::place::PlaceRef; | |
| 3 | use super::{FunctionCx, LocalRef}; | |
| 4 | ||
| 5 | use crate::base; | |
| 6 | use crate::common::IntPredicate; | |
| 7 | use crate::traits::*; | |
| 8 | use crate::MemFlags; | |
| 9 | ||
| 10 | use rustc_middle::mir; | |
| 1 | use arrayvec::ArrayVec; | |
| 2 | use rustc_middle::ty::adjustment::PointerCoercion; | |
| 11 | 3 | use rustc_middle::ty::layout::{HasTyCtxt, LayoutOf, TyAndLayout}; |
| 12 | use rustc_middle::ty::{self, adjustment::PointerCoercion, Instance, Ty, TyCtxt}; | |
| 13 | use rustc_middle::{bug, span_bug}; | |
| 4 | use rustc_middle::ty::{self, Instance, Ty, TyCtxt}; | |
| 5 | use rustc_middle::{bug, mir, span_bug}; | |
| 14 | 6 | use rustc_session::config::OptLevel; |
| 15 | 7 | use rustc_span::{Span, DUMMY_SP}; |
| 16 | 8 | use rustc_target::abi::{self, FieldIdx, FIRST_VARIANT}; |
| 17 | ||
| 18 | use arrayvec::ArrayVec; | |
| 19 | 9 | use tracing::{debug, instrument}; |
| 20 | 10 | |
| 11 | use super::operand::{OperandRef, OperandValue}; | |
| 12 | use super::place::PlaceRef; | |
| 13 | use super::{FunctionCx, LocalRef}; | |
| 14 | use crate::common::IntPredicate; | |
| 15 | use crate::traits::*; | |
| 16 | use crate::{base, MemFlags}; | |
| 17 | ||
| 21 | 18 | impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { |
| 22 | 19 | #[instrument(level = "trace", skip(self, bx))] |
| 23 | 20 | pub fn codegen_rvalue( |
compiler/rustc_codegen_ssa/src/mir/statement.rs+1-2| ... | ... | @@ -3,8 +3,7 @@ use rustc_middle::span_bug; |
| 3 | 3 | use rustc_session::config::OptLevel; |
| 4 | 4 | use tracing::instrument; |
| 5 | 5 | |
| 6 | use super::FunctionCx; | |
| 7 | use super::LocalRef; | |
| 6 | use super::{FunctionCx, LocalRef}; | |
| 8 | 7 | use crate::traits::*; |
| 9 | 8 | |
| 10 | 9 | impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { |
compiler/rustc_codegen_ssa/src/mono_item.rs+5-7| ... | ... | @@ -1,16 +1,14 @@ |
| 1 | use crate::base; | |
| 2 | use crate::common; | |
| 3 | use crate::traits::*; | |
| 4 | 1 | use rustc_hir as hir; |
| 5 | 2 | use rustc_middle::mir::interpret::ErrorHandled; |
| 6 | use rustc_middle::mir::mono::MonoItem; | |
| 7 | use rustc_middle::mir::mono::{Linkage, Visibility}; | |
| 8 | use rustc_middle::span_bug; | |
| 9 | use rustc_middle::ty; | |
| 3 | use rustc_middle::mir::mono::{Linkage, MonoItem, Visibility}; | |
| 10 | 4 | use rustc_middle::ty::layout::{HasTyCtxt, LayoutOf}; |
| 11 | 5 | use rustc_middle::ty::Instance; |
| 6 | use rustc_middle::{span_bug, ty}; | |
| 12 | 7 | use tracing::debug; |
| 13 | 8 | |
| 9 | use crate::traits::*; | |
| 10 | use crate::{base, common}; | |
| 11 | ||
| 14 | 12 | pub trait MonoItemExt<'a, 'tcx> { |
| 15 | 13 | fn define<Bx: BuilderMethods<'a, 'tcx>>(&self, cx: &'a Bx::CodegenCx); |
| 16 | 14 | fn predefine<Bx: BuilderMethods<'a, 'tcx>>( |
compiler/rustc_codegen_ssa/src/size_of_val.rs+4-4| ... | ... | @@ -1,9 +1,5 @@ |
| 1 | 1 | //! Computing the size and alignment of a value. |
| 2 | 2 | |
| 3 | use crate::common; | |
| 4 | use crate::common::IntPredicate; | |
| 5 | use crate::meth; | |
| 6 | use crate::traits::*; | |
| 7 | 3 | use rustc_hir::LangItem; |
| 8 | 4 | use rustc_middle::bug; |
| 9 | 5 | use rustc_middle::ty::print::{with_no_trimmed_paths, with_no_visible_paths}; |
| ... | ... | @@ -11,6 +7,10 @@ use rustc_middle::ty::{self, Ty}; |
| 11 | 7 | use rustc_target::abi::WrappingRange; |
| 12 | 8 | use tracing::{debug, trace}; |
| 13 | 9 | |
| 10 | use crate::common::IntPredicate; | |
| 11 | use crate::traits::*; | |
| 12 | use crate::{common, meth}; | |
| 13 | ||
| 14 | 14 | pub fn size_and_align_of_dst<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( |
| 15 | 15 | bx: &mut Bx, |
| 16 | 16 | t: Ty<'tcx>, |
compiler/rustc_codegen_ssa/src/target_features.rs+4-6| ... | ... | @@ -1,21 +1,19 @@ |
| 1 | use crate::errors; | |
| 2 | 1 | use rustc_ast::ast; |
| 3 | 2 | use rustc_attr::InstructionSetAttr; |
| 4 | 3 | use rustc_data_structures::fx::FxIndexSet; |
| 5 | 4 | use rustc_data_structures::unord::UnordMap; |
| 6 | 5 | use rustc_errors::Applicability; |
| 7 | 6 | use rustc_hir::def::DefKind; |
| 8 | use rustc_hir::def_id::DefId; | |
| 9 | use rustc_hir::def_id::LocalDefId; | |
| 10 | use rustc_hir::def_id::LOCAL_CRATE; | |
| 7 | use rustc_hir::def_id::{DefId, LocalDefId, LOCAL_CRATE}; | |
| 11 | 8 | use rustc_middle::bug; |
| 12 | 9 | use rustc_middle::query::Providers; |
| 13 | 10 | use rustc_middle::ty::TyCtxt; |
| 14 | 11 | use rustc_session::parse::feature_err; |
| 15 | use rustc_span::symbol::sym; | |
| 16 | use rustc_span::symbol::Symbol; | |
| 12 | use rustc_span::symbol::{sym, Symbol}; | |
| 17 | 13 | use rustc_span::Span; |
| 18 | 14 | |
| 15 | use crate::errors; | |
| 16 | ||
| 19 | 17 | pub fn from_target_feature( |
| 20 | 18 | tcx: TyCtxt<'_>, |
| 21 | 19 | attr: &ast::Attribute, |
compiler/rustc_codegen_ssa/src/traits/asm.rs+4-3| ... | ... | @@ -1,12 +1,13 @@ |
| 1 | use super::BackendTypes; | |
| 2 | use crate::mir::operand::OperandRef; | |
| 3 | use crate::mir::place::PlaceRef; | |
| 4 | 1 | use rustc_ast::{InlineAsmOptions, InlineAsmTemplatePiece}; |
| 5 | 2 | use rustc_hir::def_id::DefId; |
| 6 | 3 | use rustc_middle::ty::Instance; |
| 7 | 4 | use rustc_span::Span; |
| 8 | 5 | use rustc_target::asm::InlineAsmRegOrRegClass; |
| 9 | 6 | |
| 7 | use super::BackendTypes; | |
| 8 | use crate::mir::operand::OperandRef; | |
| 9 | use crate::mir::place::PlaceRef; | |
| 10 | ||
| 10 | 11 | #[derive(Debug)] |
| 11 | 12 | pub enum InlineAsmOperandRef<'tcx, B: BackendTypes + ?Sized> { |
| 12 | 13 | In { |
compiler/rustc_codegen_ssa/src/traits/backend.rs+7-9| ... | ... | @@ -1,10 +1,5 @@ |
| 1 | 1 | use std::any::Any; |
| 2 | 2 | |
| 3 | use super::write::WriteBackendMethods; | |
| 4 | use super::CodegenObject; | |
| 5 | use crate::back::write::TargetMachineFactoryFn; | |
| 6 | use crate::{CodegenResults, ModuleCodegen}; | |
| 7 | ||
| 8 | 3 | use rustc_ast::expand::allocator::AllocatorKind; |
| 9 | 4 | use rustc_data_structures::fx::FxIndexMap; |
| 10 | 5 | use rustc_data_structures::sync::{DynSend, DynSync}; |
| ... | ... | @@ -15,13 +10,16 @@ use rustc_middle::dep_graph::{WorkProduct, WorkProductId}; |
| 15 | 10 | use rustc_middle::ty::layout::{FnAbiOf, HasTyCtxt, LayoutOf, TyAndLayout}; |
| 16 | 11 | use rustc_middle::ty::{Ty, TyCtxt}; |
| 17 | 12 | use rustc_middle::util::Providers; |
| 18 | use rustc_session::{ | |
| 19 | config::{self, OutputFilenames, PrintRequest}, | |
| 20 | Session, | |
| 21 | }; | |
| 13 | use rustc_session::config::{self, OutputFilenames, PrintRequest}; | |
| 14 | use rustc_session::Session; | |
| 22 | 15 | use rustc_span::symbol::Symbol; |
| 23 | 16 | use rustc_target::abi::call::FnAbi; |
| 24 | 17 | |
| 18 | use super::write::WriteBackendMethods; | |
| 19 | use super::CodegenObject; | |
| 20 | use crate::back::write::TargetMachineFactoryFn; | |
| 21 | use crate::{CodegenResults, ModuleCodegen}; | |
| 22 | ||
| 25 | 23 | pub trait BackendTypes { |
| 26 | 24 | type Value: CodegenObject; |
| 27 | 25 | type Function: CodegenObject; |
compiler/rustc_codegen_ssa/src/traits/builder.rs+9-10| ... | ... | @@ -1,3 +1,12 @@ |
| 1 | use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrs; | |
| 2 | use rustc_middle::ty::layout::{HasParamEnv, TyAndLayout}; | |
| 3 | use rustc_middle::ty::{Instance, Ty}; | |
| 4 | use rustc_session::config::OptLevel; | |
| 5 | use rustc_span::Span; | |
| 6 | use rustc_target::abi::call::FnAbi; | |
| 7 | use rustc_target::abi::{Abi, Align, Scalar, Size, WrappingRange}; | |
| 8 | use rustc_target::spec::HasTargetSpec; | |
| 9 | ||
| 1 | 10 | use super::abi::AbiBuilderMethods; |
| 2 | 11 | use super::asm::AsmBuilderMethods; |
| 3 | 12 | use super::consts::ConstMethods; |
| ... | ... | @@ -7,7 +16,6 @@ use super::intrinsic::IntrinsicCallMethods; |
| 7 | 16 | use super::misc::MiscMethods; |
| 8 | 17 | use super::type_::{ArgAbiMethods, BaseTypeMethods, LayoutTypeMethods}; |
| 9 | 18 | use super::{HasCodegen, StaticBuilderMethods}; |
| 10 | ||
| 11 | 19 | use crate::common::{ |
| 12 | 20 | AtomicOrdering, AtomicRmwBinOp, IntPredicate, RealPredicate, SynchronizationScope, TypeKind, |
| 13 | 21 | }; |
| ... | ... | @@ -15,15 +23,6 @@ use crate::mir::operand::{OperandRef, OperandValue}; |
| 15 | 23 | use crate::mir::place::{PlaceRef, PlaceValue}; |
| 16 | 24 | use crate::MemFlags; |
| 17 | 25 | |
| 18 | use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrs; | |
| 19 | use rustc_middle::ty::layout::{HasParamEnv, TyAndLayout}; | |
| 20 | use rustc_middle::ty::{Instance, Ty}; | |
| 21 | use rustc_session::config::OptLevel; | |
| 22 | use rustc_span::Span; | |
| 23 | use rustc_target::abi::call::FnAbi; | |
| 24 | use rustc_target::abi::{Abi, Align, Scalar, Size, WrappingRange}; | |
| 25 | use rustc_target::spec::HasTargetSpec; | |
| 26 | ||
| 27 | 26 | #[derive(Copy, Clone)] |
| 28 | 27 | pub enum OverflowOp { |
| 29 | 28 | Add, |
compiler/rustc_codegen_ssa/src/traits/consts.rs+2-1| ... | ... | @@ -1,7 +1,8 @@ |
| 1 | use super::BackendTypes; | |
| 2 | 1 | use rustc_middle::mir::interpret::{ConstAllocation, Scalar}; |
| 3 | 2 | use rustc_target::abi; |
| 4 | 3 | |
| 4 | use super::BackendTypes; | |
| 5 | ||
| 5 | 6 | pub trait ConstMethods<'tcx>: BackendTypes { |
| 6 | 7 | // Constant constructors |
| 7 | 8 | fn const_null(&self, t: Self::Type) -> Self::Value; |
compiler/rustc_codegen_ssa/src/traits/coverageinfo.rs+2-1| ... | ... | @@ -1,7 +1,8 @@ |
| 1 | use super::BackendTypes; | |
| 2 | 1 | use rustc_middle::mir::coverage::CoverageKind; |
| 3 | 2 | use rustc_middle::ty::Instance; |
| 4 | 3 | |
| 4 | use super::BackendTypes; | |
| 5 | ||
| 5 | 6 | pub trait CoverageInfoBuilderMethods<'tcx>: BackendTypes { |
| 6 | 7 | /// Performs any start-of-function codegen needed for coverage instrumentation. |
| 7 | 8 | /// |
compiler/rustc_codegen_ssa/src/traits/debuginfo.rs+4-3| ... | ... | @@ -1,12 +1,13 @@ |
| 1 | use super::BackendTypes; | |
| 2 | use crate::mir::debuginfo::{FunctionDebugContext, VariableKind}; | |
| 1 | use std::ops::Range; | |
| 2 | ||
| 3 | 3 | use rustc_middle::mir; |
| 4 | 4 | use rustc_middle::ty::{Instance, PolyExistentialTraitRef, Ty}; |
| 5 | 5 | use rustc_span::{SourceFile, Span, Symbol}; |
| 6 | 6 | use rustc_target::abi::call::FnAbi; |
| 7 | 7 | use rustc_target::abi::Size; |
| 8 | 8 | |
| 9 | use std::ops::Range; | |
| 9 | use super::BackendTypes; | |
| 10 | use crate::mir::debuginfo::{FunctionDebugContext, VariableKind}; | |
| 10 | 11 | |
| 11 | 12 | pub trait DebugInfoMethods<'tcx>: BackendTypes { |
| 12 | 13 | fn create_vtable_debuginfo( |
compiler/rustc_codegen_ssa/src/traits/declare.rs+2-1| ... | ... | @@ -1,8 +1,9 @@ |
| 1 | use super::BackendTypes; | |
| 2 | 1 | use rustc_hir::def_id::DefId; |
| 3 | 2 | use rustc_middle::mir::mono::{Linkage, Visibility}; |
| 4 | 3 | use rustc_middle::ty::Instance; |
| 5 | 4 | |
| 5 | use super::BackendTypes; | |
| 6 | ||
| 6 | 7 | pub trait PreDefineMethods<'tcx>: BackendTypes { |
| 7 | 8 | fn predefine_static( |
| 8 | 9 | &self, |
compiler/rustc_codegen_ssa/src/traits/intrinsic.rs+3-2| ... | ... | @@ -1,9 +1,10 @@ |
| 1 | use super::BackendTypes; | |
| 2 | use crate::mir::operand::OperandRef; | |
| 3 | 1 | use rustc_middle::ty::{self, Ty}; |
| 4 | 2 | use rustc_span::Span; |
| 5 | 3 | use rustc_target::abi::call::FnAbi; |
| 6 | 4 | |
| 5 | use super::BackendTypes; | |
| 6 | use crate::mir::operand::OperandRef; | |
| 7 | ||
| 7 | 8 | pub trait IntrinsicCallMethods<'tcx>: BackendTypes { |
| 8 | 9 | /// Remember to add all intrinsics here, in `compiler/rustc_hir_analysis/src/check/mod.rs`, |
| 9 | 10 | /// and in `library/core/src/intrinsics.rs`; if you need access to any LLVM intrinsics, |
compiler/rustc_codegen_ssa/src/traits/misc.rs+4-2| ... | ... | @@ -1,9 +1,11 @@ |
| 1 | use super::BackendTypes; | |
| 1 | use std::cell::RefCell; | |
| 2 | ||
| 2 | 3 | use rustc_data_structures::fx::FxHashMap; |
| 3 | 4 | use rustc_middle::mir::mono::CodegenUnit; |
| 4 | 5 | use rustc_middle::ty::{self, Instance, Ty}; |
| 5 | 6 | use rustc_session::Session; |
| 6 | use std::cell::RefCell; | |
| 7 | ||
| 8 | use super::BackendTypes; | |
| 7 | 9 | |
| 8 | 10 | pub trait MiscMethods<'tcx>: BackendTypes { |
| 9 | 11 | fn vtables( |
compiler/rustc_codegen_ssa/src/traits/mod.rs+5-5| ... | ... | @@ -28,6 +28,11 @@ mod statics; |
| 28 | 28 | mod type_; |
| 29 | 29 | mod write; |
| 30 | 30 | |
| 31 | use std::fmt; | |
| 32 | ||
| 33 | use rustc_middle::ty::layout::{HasParamEnv, HasTyCtxt}; | |
| 34 | use rustc_target::spec::HasTargetSpec; | |
| 35 | ||
| 31 | 36 | pub use self::abi::AbiBuilderMethods; |
| 32 | 37 | pub use self::asm::{AsmBuilderMethods, AsmMethods, GlobalAsmOperandRef, InlineAsmOperandRef}; |
| 33 | 38 | pub use self::backend::{Backend, BackendTypes, CodegenBackend, ExtraBackendMethods}; |
| ... | ... | @@ -45,11 +50,6 @@ pub use self::type_::{ |
| 45 | 50 | }; |
| 46 | 51 | pub use self::write::{ModuleBufferMethods, ThinBufferMethods, WriteBackendMethods}; |
| 47 | 52 | |
| 48 | use rustc_middle::ty::layout::{HasParamEnv, HasTyCtxt}; | |
| 49 | use rustc_target::spec::HasTargetSpec; | |
| 50 | ||
| 51 | use std::fmt; | |
| 52 | ||
| 53 | 53 | pub trait CodegenObject: Copy + PartialEq + fmt::Debug {} |
| 54 | 54 | impl<T: Copy + PartialEq + fmt::Debug> CodegenObject for T {} |
| 55 | 55 |
compiler/rustc_codegen_ssa/src/traits/statics.rs+2-1| ... | ... | @@ -1,7 +1,8 @@ |
| 1 | use super::BackendTypes; | |
| 2 | 1 | use rustc_hir::def_id::DefId; |
| 3 | 2 | use rustc_target::abi::Align; |
| 4 | 3 | |
| 4 | use super::BackendTypes; | |
| 5 | ||
| 5 | 6 | pub trait StaticMethods: BackendTypes { |
| 6 | 7 | fn static_addr_of(&self, cv: Self::Value, align: Align, kind: Option<&str>) -> Self::Value; |
| 7 | 8 | fn codegen_static(&self, def_id: DefId); |
compiler/rustc_codegen_ssa/src/traits/type_.rs+5-5| ... | ... | @@ -1,14 +1,14 @@ |
| 1 | use super::misc::MiscMethods; | |
| 2 | use super::Backend; | |
| 3 | use super::HasCodegen; | |
| 4 | use crate::common::TypeKind; | |
| 5 | use crate::mir::place::PlaceRef; | |
| 6 | 1 | use rustc_middle::bug; |
| 7 | 2 | use rustc_middle::ty::layout::TyAndLayout; |
| 8 | 3 | use rustc_middle::ty::{self, Ty}; |
| 9 | 4 | use rustc_target::abi::call::{ArgAbi, CastTarget, FnAbi, Reg}; |
| 10 | 5 | use rustc_target::abi::{AddressSpace, Float, Integer}; |
| 11 | 6 | |
| 7 | use super::misc::MiscMethods; | |
| 8 | use super::{Backend, HasCodegen}; | |
| 9 | use crate::common::TypeKind; | |
| 10 | use crate::mir::place::PlaceRef; | |
| 11 | ||
| 12 | 12 | // This depends on `Backend` and not `BackendTypes`, because consumers will probably want to use |
| 13 | 13 | // `LayoutOf` or `HasTyCtxt`. This way, they don't have to add a constraint on it themselves. |
| 14 | 14 | pub trait BaseTypeMethods<'tcx>: Backend<'tcx> { |
compiler/rustc_codegen_ssa/src/traits/write.rs+3-3| ... | ... | @@ -1,10 +1,10 @@ |
| 1 | use rustc_errors::{DiagCtxtHandle, FatalError}; | |
| 2 | use rustc_middle::dep_graph::WorkProduct; | |
| 3 | ||
| 1 | 4 | use crate::back::lto::{LtoModuleCodegen, SerializedModule, ThinModule}; |
| 2 | 5 | use crate::back::write::{CodegenContext, FatLtoInput, ModuleConfig}; |
| 3 | 6 | use crate::{CompiledModule, ModuleCodegen}; |
| 4 | 7 | |
| 5 | use rustc_errors::{DiagCtxtHandle, FatalError}; | |
| 6 | use rustc_middle::dep_graph::WorkProduct; | |
| 7 | ||
| 8 | 8 | pub trait WriteBackendMethods: 'static + Sized + Clone { |
| 9 | 9 | type Module: Send + Sync; |
| 10 | 10 | type TargetMachine; |
compiler/rustc_const_eval/src/check_consts/check.rs+5-6| ... | ... | @@ -1,5 +1,8 @@ |
| 1 | 1 | //! The `Visitor` responsible for actually checking a `mir::Body` for invalid operations. |
| 2 | 2 | |
| 3 | use std::mem; | |
| 4 | use std::ops::Deref; | |
| 5 | ||
| 3 | 6 | use rustc_errors::{Diag, ErrorGuaranteed}; |
| 4 | 7 | use rustc_hir::def_id::DefId; |
| 5 | 8 | use rustc_hir::{self as hir, LangItem}; |
| ... | ... | @@ -9,17 +12,13 @@ use rustc_infer::traits::ObligationCause; |
| 9 | 12 | use rustc_middle::mir::visit::{MutatingUseContext, NonMutatingUseContext, PlaceContext, Visitor}; |
| 10 | 13 | use rustc_middle::mir::*; |
| 11 | 14 | use rustc_middle::span_bug; |
| 12 | use rustc_middle::ty::{self, adjustment::PointerCoercion, Ty, TyCtxt}; | |
| 13 | use rustc_middle::ty::{Instance, InstanceKind, TypeVisitableExt}; | |
| 15 | use rustc_middle::ty::adjustment::PointerCoercion; | |
| 16 | use rustc_middle::ty::{self, Instance, InstanceKind, Ty, TyCtxt, TypeVisitableExt}; | |
| 14 | 17 | use rustc_mir_dataflow::Analysis; |
| 15 | 18 | use rustc_span::{sym, Span, Symbol, DUMMY_SP}; |
| 16 | 19 | use rustc_trait_selection::error_reporting::InferCtxtErrorExt; |
| 17 | 20 | use rustc_trait_selection::traits::{self, ObligationCauseCode, ObligationCtxt}; |
| 18 | 21 | use rustc_type_ir::visit::{TypeSuperVisitable, TypeVisitor}; |
| 19 | ||
| 20 | use std::mem; | |
| 21 | use std::ops::Deref; | |
| 22 | ||
| 23 | 22 | use tracing::{debug, instrument, trace}; |
| 24 | 23 | |
| 25 | 24 | use super::ops::{self, NonConstOp, Status}; |
compiler/rustc_const_eval/src/check_consts/mod.rs+2-4| ... | ... | @@ -4,14 +4,12 @@ |
| 4 | 4 | //! has interior mutability or needs to be dropped, as well as the visitor that emits errors when |
| 5 | 5 | //! it finds operations that are invalid in a certain context. |
| 6 | 6 | |
| 7 | use rustc_attr as attr; | |
| 8 | 7 | use rustc_errors::DiagCtxtHandle; |
| 9 | use rustc_hir as hir; | |
| 10 | 8 | use rustc_hir::def_id::{DefId, LocalDefId}; |
| 11 | use rustc_middle::bug; | |
| 12 | use rustc_middle::mir; | |
| 13 | 9 | use rustc_middle::ty::{self, PolyFnSig, TyCtxt}; |
| 10 | use rustc_middle::{bug, mir}; | |
| 14 | 11 | use rustc_span::Symbol; |
| 12 | use {rustc_attr as attr, rustc_hir as hir}; | |
| 15 | 13 | |
| 16 | 14 | pub use self::qualifs::Qualif; |
| 17 | 15 |
compiler/rustc_const_eval/src/check_consts/ops.rs+2-1| ... | ... | @@ -2,7 +2,8 @@ |
| 2 | 2 | |
| 3 | 3 | use hir::def_id::LocalDefId; |
| 4 | 4 | use hir::{ConstContext, LangItem}; |
| 5 | use rustc_errors::{codes::*, Diag}; | |
| 5 | use rustc_errors::codes::*; | |
| 6 | use rustc_errors::Diag; | |
| 6 | 7 | use rustc_hir as hir; |
| 7 | 8 | use rustc_hir::def_id::DefId; |
| 8 | 9 | use rustc_infer::infer::TyCtxtInferExt; |
compiler/rustc_const_eval/src/check_consts/post_drop_elaboration.rs+2-1| ... | ... | @@ -1,7 +1,8 @@ |
| 1 | 1 | use rustc_middle::mir::visit::Visitor; |
| 2 | 2 | use rustc_middle::mir::{self, BasicBlock, Location}; |
| 3 | 3 | use rustc_middle::ty::{Ty, TyCtxt}; |
| 4 | use rustc_span::{symbol::sym, Span}; | |
| 4 | use rustc_span::symbol::sym; | |
| 5 | use rustc_span::Span; | |
| 5 | 6 | use tracing::trace; |
| 6 | 7 | |
| 7 | 8 | use super::check::Qualifs; |
compiler/rustc_const_eval/src/check_consts/qualifs.rs+1-2| ... | ... | @@ -5,11 +5,10 @@ |
| 5 | 5 | use rustc_errors::ErrorGuaranteed; |
| 6 | 6 | use rustc_hir::LangItem; |
| 7 | 7 | use rustc_infer::infer::TyCtxtInferExt; |
| 8 | use rustc_middle::bug; | |
| 9 | use rustc_middle::mir; | |
| 10 | 8 | use rustc_middle::mir::*; |
| 11 | 9 | use rustc_middle::traits::BuiltinImplSource; |
| 12 | 10 | use rustc_middle::ty::{self, AdtDef, GenericArgsRef, Ty}; |
| 11 | use rustc_middle::{bug, mir}; | |
| 13 | 12 | use rustc_trait_selection::traits::{ |
| 14 | 13 | ImplSource, Obligation, ObligationCause, ObligationCtxt, SelectionContext, |
| 15 | 14 | }; |
compiler/rustc_const_eval/src/check_consts/resolver.rs+4-5| ... | ... | @@ -2,17 +2,16 @@ |
| 2 | 2 | //! |
| 3 | 3 | //! This contains the dataflow analysis used to track `Qualif`s on complex control-flow graphs. |
| 4 | 4 | |
| 5 | use std::fmt; | |
| 6 | use std::marker::PhantomData; | |
| 7 | ||
| 5 | 8 | use rustc_index::bit_set::BitSet; |
| 6 | 9 | use rustc_middle::mir::visit::Visitor; |
| 7 | 10 | use rustc_middle::mir::{ |
| 8 | 11 | self, BasicBlock, CallReturnPlaces, Local, Location, Statement, StatementKind, TerminatorEdges, |
| 9 | 12 | }; |
| 10 | 13 | use rustc_mir_dataflow::fmt::DebugWithContext; |
| 11 | use rustc_mir_dataflow::JoinSemiLattice; | |
| 12 | use rustc_mir_dataflow::{Analysis, AnalysisDomain}; | |
| 13 | ||
| 14 | use std::fmt; | |
| 15 | use std::marker::PhantomData; | |
| 14 | use rustc_mir_dataflow::{Analysis, AnalysisDomain, JoinSemiLattice}; | |
| 16 | 15 | |
| 17 | 16 | use super::{qualifs, ConstCx, Qualif}; |
| 18 | 17 |
compiler/rustc_const_eval/src/const_eval/dummy_machine.rs+5-5| ... | ... | @@ -1,14 +1,14 @@ |
| 1 | use crate::interpret::{ | |
| 2 | self, throw_machine_stop, HasStaticRootDefId, ImmTy, Immediate, InterpCx, PointerArithmetic, | |
| 3 | }; | |
| 4 | 1 | use rustc_middle::mir::interpret::{AllocId, ConstAllocation, InterpResult}; |
| 5 | 2 | use rustc_middle::mir::*; |
| 6 | 3 | use rustc_middle::query::TyCtxtAt; |
| 7 | use rustc_middle::ty; | |
| 8 | 4 | use rustc_middle::ty::layout::TyAndLayout; |
| 9 | use rustc_middle::{bug, span_bug}; | |
| 5 | use rustc_middle::{bug, span_bug, ty}; | |
| 10 | 6 | use rustc_span::def_id::DefId; |
| 11 | 7 | |
| 8 | use crate::interpret::{ | |
| 9 | self, throw_machine_stop, HasStaticRootDefId, ImmTy, Immediate, InterpCx, PointerArithmetic, | |
| 10 | }; | |
| 11 | ||
| 12 | 12 | /// Macro for machine-specific `InterpError` without allocation. |
| 13 | 13 | /// (These will never be shown to the user, but they help diagnose ICEs.) |
| 14 | 14 | pub macro throw_machine_stop_str($($tt:tt)*) {{ |
compiler/rustc_const_eval/src/const_eval/error.rs+7-5| ... | ... | @@ -4,14 +4,15 @@ use rustc_errors::{DiagArgName, DiagArgValue, DiagMessage, Diagnostic, IntoDiagA |
| 4 | 4 | use rustc_middle::mir::interpret::{Provenance, ReportedErrorInfo}; |
| 5 | 5 | use rustc_middle::mir::AssertKind; |
| 6 | 6 | use rustc_middle::query::TyCtxtAt; |
| 7 | use rustc_middle::ty::TyCtxt; | |
| 8 | use rustc_middle::ty::{layout::LayoutError, ConstInt}; | |
| 7 | use rustc_middle::ty::layout::LayoutError; | |
| 8 | use rustc_middle::ty::{ConstInt, TyCtxt}; | |
| 9 | 9 | use rustc_span::{Span, Symbol}; |
| 10 | 10 | |
| 11 | 11 | use super::CompileTimeMachine; |
| 12 | 12 | use crate::errors::{self, FrameNote, ReportErrorExt}; |
| 13 | use crate::interpret::{err_inval, err_machine_stop}; | |
| 14 | use crate::interpret::{ErrorHandled, Frame, InterpError, InterpErrorInfo, MachineStopType}; | |
| 13 | use crate::interpret::{ | |
| 14 | err_inval, err_machine_stop, ErrorHandled, Frame, InterpError, InterpErrorInfo, MachineStopType, | |
| 15 | }; | |
| 15 | 16 | |
| 16 | 17 | /// The CTFE machine has some custom error kinds. |
| 17 | 18 | #[derive(Clone, Debug)] |
| ... | ... | @@ -25,8 +26,9 @@ pub enum ConstEvalErrKind { |
| 25 | 26 | |
| 26 | 27 | impl MachineStopType for ConstEvalErrKind { |
| 27 | 28 | fn diagnostic_message(&self) -> DiagMessage { |
| 28 | use crate::fluent_generated::*; | |
| 29 | 29 | use ConstEvalErrKind::*; |
| 30 | ||
| 31 | use crate::fluent_generated::*; | |
| 30 | 32 | match self { |
| 31 | 33 | ConstAccessesMutGlobal => const_eval_const_accesses_mut_global, |
| 32 | 34 | ModifiedGlobal => const_eval_modified_global, |
compiler/rustc_const_eval/src/const_eval/eval_queries.rs+5-8| ... | ... | @@ -1,8 +1,6 @@ |
| 1 | 1 | use std::sync::atomic::Ordering::Relaxed; |
| 2 | 2 | |
| 3 | 3 | use either::{Left, Right}; |
| 4 | use tracing::{debug, instrument, trace}; | |
| 5 | ||
| 6 | 4 | use rustc_hir::def::DefKind; |
| 7 | 5 | use rustc_middle::bug; |
| 8 | 6 | use rustc_middle::mir::interpret::{AllocId, ErrorHandled, InterpErrorInfo}; |
| ... | ... | @@ -16,17 +14,16 @@ use rustc_session::lint; |
| 16 | 14 | use rustc_span::def_id::LocalDefId; |
| 17 | 15 | use rustc_span::{Span, DUMMY_SP}; |
| 18 | 16 | use rustc_target::abi::{self, Abi}; |
| 17 | use tracing::{debug, instrument, trace}; | |
| 19 | 18 | |
| 20 | 19 | use super::{CanAccessMutGlobal, CompileTimeInterpCx, CompileTimeMachine}; |
| 21 | 20 | use crate::const_eval::CheckAlignment; |
| 22 | use crate::errors::ConstEvalError; | |
| 23 | use crate::errors::{self, DanglingPtrInFinal}; | |
| 21 | use crate::errors::{self, ConstEvalError, DanglingPtrInFinal}; | |
| 24 | 22 | use crate::interpret::{ |
| 25 | create_static_alloc, intern_const_alloc_recursive, CtfeValidationMode, GlobalId, Immediate, | |
| 26 | InternKind, InterpCx, InterpError, InterpResult, MPlaceTy, MemoryKind, OpTy, RefTracking, | |
| 27 | StackPopCleanup, | |
| 23 | create_static_alloc, eval_nullary_intrinsic, intern_const_alloc_recursive, throw_exhaust, | |
| 24 | CtfeValidationMode, GlobalId, Immediate, InternKind, InternResult, InterpCx, InterpError, | |
| 25 | InterpResult, MPlaceTy, MemoryKind, OpTy, RefTracking, StackPopCleanup, | |
| 28 | 26 | }; |
| 29 | use crate::interpret::{eval_nullary_intrinsic, throw_exhaust, InternResult}; | |
| 30 | 27 | use crate::CTRL_C_RECEIVED; |
| 31 | 28 | |
| 32 | 29 | // Returns a pointer to where the result lives |
compiler/rustc_const_eval/src/const_eval/fn_queries.rs+1-2| ... | ... | @@ -1,10 +1,9 @@ |
| 1 | use rustc_attr as attr; | |
| 2 | use rustc_hir as hir; | |
| 3 | 1 | use rustc_hir::def::DefKind; |
| 4 | 2 | use rustc_hir::def_id::{DefId, LocalDefId}; |
| 5 | 3 | use rustc_middle::query::Providers; |
| 6 | 4 | use rustc_middle::ty::TyCtxt; |
| 7 | 5 | use rustc_span::symbol::Symbol; |
| 6 | use {rustc_attr as attr, rustc_hir as hir}; | |
| 8 | 7 | |
| 9 | 8 | /// Whether the `def_id` is an unstable const fn and what feature gate(s) are necessary to enable |
| 10 | 9 | /// it. |
compiler/rustc_const_eval/src/const_eval/machine.rs+7-11| ... | ... | @@ -4,18 +4,14 @@ use std::hash::Hash; |
| 4 | 4 | use std::ops::ControlFlow; |
| 5 | 5 | |
| 6 | 6 | use rustc_ast::Mutability; |
| 7 | use rustc_data_structures::fx::FxIndexMap; | |
| 8 | use rustc_data_structures::fx::IndexEntry; | |
| 9 | use rustc_hir::def_id::DefId; | |
| 10 | use rustc_hir::def_id::LocalDefId; | |
| 11 | use rustc_hir::LangItem; | |
| 12 | use rustc_hir::{self as hir, CRATE_HIR_ID}; | |
| 13 | use rustc_middle::bug; | |
| 14 | use rustc_middle::mir; | |
| 7 | use rustc_data_structures::fx::{FxIndexMap, IndexEntry}; | |
| 8 | use rustc_hir::def_id::{DefId, LocalDefId}; | |
| 9 | use rustc_hir::{self as hir, LangItem, CRATE_HIR_ID}; | |
| 15 | 10 | use rustc_middle::mir::AssertMessage; |
| 16 | 11 | use rustc_middle::query::TyCtxtAt; |
| 17 | 12 | use rustc_middle::ty::layout::{FnAbiOf, TyAndLayout}; |
| 18 | 13 | use rustc_middle::ty::{self, TyCtxt}; |
| 14 | use rustc_middle::{bug, mir}; | |
| 19 | 15 | use rustc_session::lint::builtin::WRITES_THROUGH_IMMUTABLE_POINTER; |
| 20 | 16 | use rustc_span::symbol::{sym, Symbol}; |
| 21 | 17 | use rustc_span::Span; |
| ... | ... | @@ -23,6 +19,7 @@ use rustc_target::abi::{Align, Size}; |
| 23 | 19 | use rustc_target::spec::abi::Abi as CallAbi; |
| 24 | 20 | use tracing::debug; |
| 25 | 21 | |
| 22 | use super::error::*; | |
| 26 | 23 | use crate::errors::{LongRunning, LongRunningWarn}; |
| 27 | 24 | use crate::fluent_generated as fluent; |
| 28 | 25 | use crate::interpret::{ |
| ... | ... | @@ -31,8 +28,6 @@ use crate::interpret::{ |
| 31 | 28 | GlobalAlloc, ImmTy, InterpCx, InterpResult, MPlaceTy, OpTy, Pointer, PointerArithmetic, Scalar, |
| 32 | 29 | }; |
| 33 | 30 | |
| 34 | use super::error::*; | |
| 35 | ||
| 36 | 31 | /// When hitting this many interpreted terminators we emit a deny by default lint |
| 37 | 32 | /// that notfies the user that their constant takes a long time to evaluate. If that's |
| 38 | 33 | /// what they intended, they can just allow the lint. |
| ... | ... | @@ -201,7 +196,8 @@ impl<'tcx> CompileTimeInterpCx<'tcx> { |
| 201 | 196 | let topmost = span.ctxt().outer_expn().expansion_cause().unwrap_or(span); |
| 202 | 197 | let caller = self.tcx.sess.source_map().lookup_char_pos(topmost.lo()); |
| 203 | 198 | |
| 204 | use rustc_session::{config::RemapPathScopeComponents, RemapFileNameExt}; | |
| 199 | use rustc_session::config::RemapPathScopeComponents; | |
| 200 | use rustc_session::RemapFileNameExt; | |
| 205 | 201 | ( |
| 206 | 202 | Symbol::intern( |
| 207 | 203 | &caller |
compiler/rustc_const_eval/src/const_eval/mod.rs+1-2| ... | ... | @@ -1,10 +1,9 @@ |
| 1 | 1 | // Not in interpret to make sure we do not use private implementation details |
| 2 | 2 | |
| 3 | use rustc_middle::bug; | |
| 4 | use rustc_middle::mir; | |
| 5 | 3 | use rustc_middle::mir::interpret::InterpErrorInfo; |
| 6 | 4 | use rustc_middle::query::{Key, TyCtxtAt}; |
| 7 | 5 | use rustc_middle::ty::{self, Ty, TyCtxt}; |
| 6 | use rustc_middle::{bug, mir}; | |
| 8 | 7 | use rustc_target::abi::VariantIdx; |
| 9 | 8 | use tracing::instrument; |
| 10 | 9 |
compiler/rustc_const_eval/src/const_eval/valtrees.rs+3-5| ... | ... | @@ -1,9 +1,8 @@ |
| 1 | 1 | use rustc_data_structures::stack::ensure_sufficient_stack; |
| 2 | use rustc_middle::bug; | |
| 3 | use rustc_middle::mir; | |
| 4 | 2 | use rustc_middle::mir::interpret::{EvalToValTreeResult, GlobalId}; |
| 5 | 3 | use rustc_middle::ty::layout::{LayoutCx, LayoutOf, TyAndLayout}; |
| 6 | 4 | use rustc_middle::ty::{self, ScalarInt, Ty, TyCtxt}; |
| 5 | use rustc_middle::{bug, mir}; | |
| 7 | 6 | use rustc_span::DUMMY_SP; |
| 8 | 7 | use rustc_target::abi::{Abi, VariantIdx}; |
| 9 | 8 | use tracing::{debug, instrument, trace}; |
| ... | ... | @@ -13,10 +12,9 @@ use super::machine::CompileTimeInterpCx; |
| 13 | 12 | use super::{ValTreeCreationError, ValTreeCreationResult, VALTREE_MAX_NODES}; |
| 14 | 13 | use crate::const_eval::CanAccessMutGlobal; |
| 15 | 14 | use crate::errors::MaxNumNodesInConstErr; |
| 16 | use crate::interpret::MPlaceTy; | |
| 17 | 15 | use crate::interpret::{ |
| 18 | intern_const_alloc_recursive, ImmTy, Immediate, InternKind, MemPlaceMeta, MemoryKind, PlaceTy, | |
| 19 | Projectable, Scalar, | |
| 16 | intern_const_alloc_recursive, ImmTy, Immediate, InternKind, MPlaceTy, MemPlaceMeta, MemoryKind, | |
| 17 | PlaceTy, Projectable, Scalar, | |
| 20 | 18 | }; |
| 21 | 19 | |
| 22 | 20 | #[instrument(skip(ecx), level = "debug")] |
compiler/rustc_const_eval/src/errors.rs+10-6| ... | ... | @@ -1,8 +1,9 @@ |
| 1 | 1 | use std::borrow::Cow; |
| 2 | 2 | |
| 3 | 3 | use either::Either; |
| 4 | use rustc_errors::codes::*; | |
| 4 | 5 | use rustc_errors::{ |
| 5 | codes::*, Diag, DiagArgValue, DiagCtxtHandle, DiagMessage, Diagnostic, EmissionGuarantee, Level, | |
| 6 | Diag, DiagArgValue, DiagCtxtHandle, DiagMessage, Diagnostic, EmissionGuarantee, Level, | |
| 6 | 7 | }; |
| 7 | 8 | use rustc_hir::ConstContext; |
| 8 | 9 | use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic}; |
| ... | ... | @@ -468,8 +469,9 @@ fn bad_pointer_message(msg: CheckInAllocMsg, dcx: DiagCtxtHandle<'_>) -> String |
| 468 | 469 | |
| 469 | 470 | impl<'a> ReportErrorExt for UndefinedBehaviorInfo<'a> { |
| 470 | 471 | fn diagnostic_message(&self) -> DiagMessage { |
| 471 | use crate::fluent_generated::*; | |
| 472 | 472 | use UndefinedBehaviorInfo::*; |
| 473 | ||
| 474 | use crate::fluent_generated::*; | |
| 473 | 475 | match self { |
| 474 | 476 | Ub(msg) => msg.clone().into(), |
| 475 | 477 | Custom(x) => (x.msg)(), |
| ... | ... | @@ -630,8 +632,9 @@ impl<'a> ReportErrorExt for UndefinedBehaviorInfo<'a> { |
| 630 | 632 | |
| 631 | 633 | impl<'tcx> ReportErrorExt for ValidationErrorInfo<'tcx> { |
| 632 | 634 | fn diagnostic_message(&self) -> DiagMessage { |
| 633 | use crate::fluent_generated::*; | |
| 634 | 635 | use rustc_middle::mir::interpret::ValidationErrorKind::*; |
| 636 | ||
| 637 | use crate::fluent_generated::*; | |
| 635 | 638 | match self.kind { |
| 636 | 639 | PtrToUninhabited { ptr_kind: PointerKind::Box, .. } => { |
| 637 | 640 | const_eval_validation_box_to_uninhabited |
| ... | ... | @@ -702,9 +705,10 @@ impl<'tcx> ReportErrorExt for ValidationErrorInfo<'tcx> { |
| 702 | 705 | } |
| 703 | 706 | |
| 704 | 707 | fn add_args<G: EmissionGuarantee>(self, err: &mut Diag<'_, G>) { |
| 705 | use crate::fluent_generated as fluent; | |
| 706 | 708 | use rustc_middle::mir::interpret::ValidationErrorKind::*; |
| 707 | 709 | |
| 710 | use crate::fluent_generated as fluent; | |
| 711 | ||
| 708 | 712 | if let PointerAsInt { .. } | PartialPointer = self.kind { |
| 709 | 713 | err.help(fluent::const_eval_ptr_as_bytes_1); |
| 710 | 714 | err.help(fluent::const_eval_ptr_as_bytes_2); |
| ... | ... | @@ -835,9 +839,9 @@ impl ReportErrorExt for UnsupportedOpInfo { |
| 835 | 839 | } |
| 836 | 840 | } |
| 837 | 841 | fn add_args<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) { |
| 838 | use crate::fluent_generated::*; | |
| 839 | ||
| 840 | 842 | use UnsupportedOpInfo::*; |
| 843 | ||
| 844 | use crate::fluent_generated::*; | |
| 841 | 845 | if let ReadPointerAsInt(_) | OverwritePartialPointer(_) | ReadPartialPointer(_) = self { |
| 842 | 846 | diag.help(const_eval_ptr_as_bytes_1); |
| 843 | 847 | diag.help(const_eval_ptr_as_bytes_2); |
compiler/rustc_const_eval/src/interpret/cast.rs+2-3| ... | ... | @@ -12,11 +12,10 @@ use rustc_target::abi::Integer; |
| 12 | 12 | use rustc_type_ir::TyKind::*; |
| 13 | 13 | use tracing::trace; |
| 14 | 14 | |
| 15 | use super::util::ensure_monomorphic_enough; | |
| 15 | 16 | use super::{ |
| 16 | err_inval, throw_ub, throw_ub_custom, util::ensure_monomorphic_enough, FnVal, ImmTy, Immediate, | |
| 17 | InterpCx, Machine, OpTy, PlaceTy, | |
| 17 | err_inval, throw_ub, throw_ub_custom, FnVal, ImmTy, Immediate, InterpCx, Machine, OpTy, PlaceTy, | |
| 18 | 18 | }; |
| 19 | ||
| 20 | 19 | use crate::fluent_generated as fluent; |
| 21 | 20 | |
| 22 | 21 | impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { |
compiler/rustc_const_eval/src/interpret/discriminant.rs+2-4| ... | ... | @@ -1,11 +1,9 @@ |
| 1 | 1 | //! Functions for reading and writing discriminants of multi-variant layouts (enums and coroutines). |
| 2 | 2 | |
| 3 | use rustc_middle::mir; | |
| 4 | use rustc_middle::span_bug; | |
| 5 | 3 | use rustc_middle::ty::layout::{LayoutOf, PrimitiveExt}; |
| 6 | 4 | use rustc_middle::ty::{self, CoroutineArgsExt, ScalarInt, Ty}; |
| 7 | use rustc_target::abi::{self, TagEncoding}; | |
| 8 | use rustc_target::abi::{VariantIdx, Variants}; | |
| 5 | use rustc_middle::{mir, span_bug}; | |
| 6 | use rustc_target::abi::{self, TagEncoding, VariantIdx, Variants}; | |
| 9 | 7 | use tracing::{instrument, trace}; |
| 10 | 8 | |
| 11 | 9 | use super::{ |
compiler/rustc_const_eval/src/interpret/eval_context.rs+11-12| ... | ... | @@ -2,16 +2,14 @@ use std::cell::Cell; |
| 2 | 2 | use std::{fmt, mem}; |
| 3 | 3 | |
| 4 | 4 | use either::{Either, Left, Right}; |
| 5 | use rustc_infer::infer::at::ToTrace; | |
| 6 | use rustc_infer::traits::ObligationCause; | |
| 7 | use rustc_trait_selection::traits::ObligationCtxt; | |
| 8 | use tracing::{debug, info, info_span, instrument, trace}; | |
| 9 | ||
| 10 | 5 | use rustc_errors::DiagCtxtHandle; |
| 11 | use rustc_hir::{self as hir, def_id::DefId, definitions::DefPathData}; | |
| 6 | use rustc_hir::def_id::DefId; | |
| 7 | use rustc_hir::definitions::DefPathData; | |
| 8 | use rustc_hir::{self as hir}; | |
| 12 | 9 | use rustc_index::IndexVec; |
| 10 | use rustc_infer::infer::at::ToTrace; | |
| 13 | 11 | use rustc_infer::infer::TyCtxtInferExt; |
| 14 | use rustc_middle::mir; | |
| 12 | use rustc_infer::traits::ObligationCause; | |
| 15 | 13 | use rustc_middle::mir::interpret::{ |
| 16 | 14 | CtfeProvenance, ErrorHandled, InvalidMetaKind, ReportedErrorInfo, |
| 17 | 15 | }; |
| ... | ... | @@ -21,11 +19,14 @@ use rustc_middle::ty::layout::{ |
| 21 | 19 | TyAndLayout, |
| 22 | 20 | }; |
| 23 | 21 | use rustc_middle::ty::{self, GenericArgsRef, ParamEnv, Ty, TyCtxt, TypeFoldable, Variance}; |
| 24 | use rustc_middle::{bug, span_bug}; | |
| 22 | use rustc_middle::{bug, mir, span_bug}; | |
| 25 | 23 | use rustc_mir_dataflow::storage::always_storage_live_locals; |
| 26 | 24 | use rustc_session::Limit; |
| 27 | 25 | use rustc_span::Span; |
| 28 | use rustc_target::abi::{call::FnAbi, Align, HasDataLayout, Size, TargetDataLayout}; | |
| 26 | use rustc_target::abi::call::FnAbi; | |
| 27 | use rustc_target::abi::{Align, HasDataLayout, Size, TargetDataLayout}; | |
| 28 | use rustc_trait_selection::traits::ObligationCtxt; | |
| 29 | use tracing::{debug, info, info_span, instrument, trace}; | |
| 29 | 30 | |
| 30 | 31 | use super::{ |
| 31 | 32 | err_inval, throw_inval, throw_ub, throw_ub_custom, throw_unsup, GlobalId, Immediate, |
| ... | ... | @@ -33,9 +34,7 @@ use super::{ |
| 33 | 34 | OpTy, Operand, Place, PlaceTy, Pointer, PointerArithmetic, Projectable, Provenance, |
| 34 | 35 | ReturnAction, Scalar, |
| 35 | 36 | }; |
| 36 | use crate::errors; | |
| 37 | use crate::util; | |
| 38 | use crate::{fluent_generated as fluent, ReportErrorExt}; | |
| 37 | use crate::{errors, fluent_generated as fluent, util, ReportErrorExt}; | |
| 39 | 38 | |
| 40 | 39 | pub struct InterpCx<'tcx, M: Machine<'tcx>> { |
| 41 | 40 | /// Stores the `Machine` instance. |
compiler/rustc_const_eval/src/interpret/intrinsics.rs+9-14| ... | ... | @@ -3,26 +3,21 @@ |
| 3 | 3 | //! and miri. |
| 4 | 4 | |
| 5 | 5 | use rustc_hir::def_id::DefId; |
| 6 | use rustc_middle::ty; | |
| 7 | use rustc_middle::ty::layout::{LayoutOf as _, ValidityRequirement}; | |
| 8 | use rustc_middle::ty::GenericArgsRef; | |
| 9 | use rustc_middle::ty::{Ty, TyCtxt}; | |
| 10 | use rustc_middle::{ | |
| 11 | bug, | |
| 12 | mir::{self, BinOp, ConstValue, NonDivergingIntrinsic}, | |
| 13 | ty::layout::TyAndLayout, | |
| 14 | }; | |
| 6 | use rustc_middle::mir::{self, BinOp, ConstValue, NonDivergingIntrinsic}; | |
| 7 | use rustc_middle::ty::layout::{LayoutOf as _, TyAndLayout, ValidityRequirement}; | |
| 8 | use rustc_middle::ty::{GenericArgsRef, Ty, TyCtxt}; | |
| 9 | use rustc_middle::{bug, ty}; | |
| 15 | 10 | use rustc_span::symbol::{sym, Symbol}; |
| 16 | 11 | use rustc_target::abi::Size; |
| 17 | 12 | use tracing::trace; |
| 18 | 13 | |
| 14 | use super::memory::MemoryKind; | |
| 15 | use super::util::ensure_monomorphic_enough; | |
| 19 | 16 | use super::{ |
| 20 | err_inval, err_ub_custom, err_unsup_format, memory::MemoryKind, throw_inval, throw_ub_custom, | |
| 21 | throw_ub_format, util::ensure_monomorphic_enough, Allocation, CheckInAllocMsg, ConstAllocation, | |
| 22 | GlobalId, ImmTy, InterpCx, InterpResult, MPlaceTy, Machine, OpTy, Pointer, PointerArithmetic, | |
| 23 | Provenance, Scalar, | |
| 17 | err_inval, err_ub_custom, err_unsup_format, throw_inval, throw_ub_custom, throw_ub_format, | |
| 18 | Allocation, CheckInAllocMsg, ConstAllocation, GlobalId, ImmTy, InterpCx, InterpResult, | |
| 19 | MPlaceTy, Machine, OpTy, Pointer, PointerArithmetic, Provenance, Scalar, | |
| 24 | 20 | }; |
| 25 | ||
| 26 | 21 | use crate::fluent_generated as fluent; |
| 27 | 22 | |
| 28 | 23 | /// Directly returns an `Allocation` containing an absolute path representation of the given type. |
compiler/rustc_const_eval/src/interpret/machine.rs+1-2| ... | ... | @@ -8,10 +8,9 @@ use std::hash::Hash; |
| 8 | 8 | |
| 9 | 9 | use rustc_apfloat::{Float, FloatConvert}; |
| 10 | 10 | use rustc_ast::{InlineAsmOptions, InlineAsmTemplatePiece}; |
| 11 | use rustc_middle::mir; | |
| 12 | 11 | use rustc_middle::query::TyCtxtAt; |
| 13 | use rustc_middle::ty; | |
| 14 | 12 | use rustc_middle::ty::layout::TyAndLayout; |
| 13 | use rustc_middle::{mir, ty}; | |
| 15 | 14 | use rustc_span::def_id::DefId; |
| 16 | 15 | use rustc_span::Span; |
| 17 | 16 | use rustc_target::abi::{Align, Size}; |
compiler/rustc_const_eval/src/interpret/memory.rs+2-5| ... | ... | @@ -10,8 +10,7 @@ use std::assert_matches::assert_matches; |
| 10 | 10 | use std::borrow::Cow; |
| 11 | 11 | use std::cell::Cell; |
| 12 | 12 | use std::collections::VecDeque; |
| 13 | use std::fmt; | |
| 14 | use std::ptr; | |
| 13 | use std::{fmt, ptr}; | |
| 15 | 14 | |
| 16 | 15 | use rustc_ast::Mutability; |
| 17 | 16 | use rustc_data_structures::fx::{FxHashSet, FxIndexMap}; |
| ... | ... | @@ -20,17 +19,15 @@ use rustc_middle::bug; |
| 20 | 19 | use rustc_middle::mir::display_allocation; |
| 21 | 20 | use rustc_middle::ty::{self, Instance, ParamEnv, Ty, TyCtxt}; |
| 22 | 21 | use rustc_target::abi::{Align, HasDataLayout, Size}; |
| 23 | ||
| 24 | 22 | use tracing::{debug, instrument, trace}; |
| 25 | 23 | |
| 26 | use crate::fluent_generated as fluent; | |
| 27 | ||
| 28 | 24 | use super::{ |
| 29 | 25 | alloc_range, err_ub, err_ub_custom, throw_ub, throw_ub_custom, throw_unsup, throw_unsup_format, |
| 30 | 26 | AllocBytes, AllocId, AllocMap, AllocRange, Allocation, CheckAlignMsg, CheckInAllocMsg, |
| 31 | 27 | CtfeProvenance, GlobalAlloc, InterpCx, InterpResult, Machine, MayLeak, Misalignment, Pointer, |
| 32 | 28 | PointerArithmetic, Provenance, Scalar, |
| 33 | 29 | }; |
| 30 | use crate::fluent_generated as fluent; | |
| 34 | 31 | |
| 35 | 32 | #[derive(Debug, PartialEq, Copy, Clone)] |
| 36 | 33 | pub enum MemoryKind<T> { |
compiler/rustc_const_eval/src/interpret/mod.rs+5-9| ... | ... | @@ -18,6 +18,7 @@ mod util; |
| 18 | 18 | mod validity; |
| 19 | 19 | mod visitor; |
| 20 | 20 | |
| 21 | use eval_context::{from_known_layout, mir_assign_valid_types}; | |
| 21 | 22 | #[doc(no_inline)] |
| 22 | 23 | pub use rustc_middle::mir::interpret::*; // have all the `interpret` symbols in one place: here |
| 23 | 24 | |
| ... | ... | @@ -26,20 +27,15 @@ pub use self::intern::{ |
| 26 | 27 | intern_const_alloc_for_constprop, intern_const_alloc_recursive, HasStaticRootDefId, InternKind, |
| 27 | 28 | InternResult, |
| 28 | 29 | }; |
| 30 | pub(crate) use self::intrinsics::eval_nullary_intrinsic; | |
| 29 | 31 | pub use self::machine::{compile_time_machine, AllocMap, Machine, MayLeak, ReturnAction}; |
| 30 | 32 | pub use self::memory::{AllocKind, AllocRef, AllocRefMut, FnVal, Memory, MemoryKind}; |
| 33 | use self::operand::Operand; | |
| 31 | 34 | pub use self::operand::{ImmTy, Immediate, OpTy, Readable}; |
| 32 | 35 | pub use self::place::{MPlaceTy, MemPlaceMeta, PlaceTy, Writeable}; |
| 36 | use self::place::{MemPlace, Place}; | |
| 33 | 37 | pub use self::projection::{OffsetMode, Projectable}; |
| 34 | 38 | pub use self::terminator::FnArg; |
| 39 | pub(crate) use self::util::create_static_alloc; | |
| 35 | 40 | pub use self::validity::{CtfeValidationMode, RefTracking}; |
| 36 | 41 | pub use self::visitor::ValueVisitor; |
| 37 | ||
| 38 | use self::{ | |
| 39 | operand::Operand, | |
| 40 | place::{MemPlace, Place}, | |
| 41 | }; | |
| 42 | ||
| 43 | pub(crate) use self::intrinsics::eval_nullary_intrinsic; | |
| 44 | pub(crate) use self::util::create_static_alloc; | |
| 45 | use eval_context::{from_known_layout, mir_assign_valid_types}; |
compiler/rustc_const_eval/src/interpret/operand.rs+4-5| ... | ... | @@ -4,16 +4,14 @@ |
| 4 | 4 | use std::assert_matches::assert_matches; |
| 5 | 5 | |
| 6 | 6 | use either::{Either, Left, Right}; |
| 7 | use tracing::trace; | |
| 8 | ||
| 9 | 7 | use rustc_hir::def::Namespace; |
| 10 | 8 | use rustc_middle::mir::interpret::ScalarSizeMismatch; |
| 11 | 9 | use rustc_middle::ty::layout::{HasParamEnv, HasTyCtxt, LayoutOf, TyAndLayout}; |
| 12 | 10 | use rustc_middle::ty::print::{FmtPrinter, PrettyPrinter}; |
| 13 | 11 | use rustc_middle::ty::{ConstInt, ScalarInt, Ty, TyCtxt}; |
| 14 | use rustc_middle::{bug, span_bug}; | |
| 15 | use rustc_middle::{mir, ty}; | |
| 12 | use rustc_middle::{bug, mir, span_bug, ty}; | |
| 16 | 13 | use rustc_target::abi::{self, Abi, HasDataLayout, Size}; |
| 14 | use tracing::trace; | |
| 17 | 15 | |
| 18 | 16 | use super::{ |
| 19 | 17 | alloc_range, err_ub, from_known_layout, mir_assign_valid_types, throw_ub, CtfeProvenance, |
| ... | ... | @@ -835,8 +833,9 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { |
| 835 | 833 | // Some nodes are used a lot. Make sure they don't unintentionally get bigger. |
| 836 | 834 | #[cfg(target_pointer_width = "64")] |
| 837 | 835 | mod size_asserts { |
| 838 | use super::*; | |
| 839 | 836 | use rustc_data_structures::static_assert_size; |
| 837 | ||
| 838 | use super::*; | |
| 840 | 839 | // tidy-alphabetical-start |
| 841 | 840 | static_assert_size!(Immediate, 48); |
| 842 | 841 | static_assert_size!(ImmTy<'_>, 64); |
compiler/rustc_const_eval/src/interpret/operator.rs+1-3| ... | ... | @@ -1,11 +1,9 @@ |
| 1 | 1 | use either::Either; |
| 2 | ||
| 3 | 2 | use rustc_apfloat::{Float, FloatConvert}; |
| 4 | use rustc_middle::mir; | |
| 5 | 3 | use rustc_middle::mir::interpret::{InterpResult, Scalar}; |
| 6 | 4 | use rustc_middle::ty::layout::{LayoutOf, TyAndLayout}; |
| 7 | 5 | use rustc_middle::ty::{self, FloatTy, ScalarInt}; |
| 8 | use rustc_middle::{bug, span_bug}; | |
| 6 | use rustc_middle::{bug, mir, span_bug}; | |
| 9 | 7 | use rustc_span::symbol::sym; |
| 10 | 8 | use tracing::trace; |
| 11 | 9 |
compiler/rustc_const_eval/src/interpret/place.rs+4-5| ... | ... | @@ -5,14 +5,12 @@ |
| 5 | 5 | use std::assert_matches::assert_matches; |
| 6 | 6 | |
| 7 | 7 | use either::{Either, Left, Right}; |
| 8 | use tracing::{instrument, trace}; | |
| 9 | ||
| 10 | 8 | use rustc_ast::Mutability; |
| 11 | use rustc_middle::mir; | |
| 12 | 9 | use rustc_middle::ty::layout::{LayoutOf, TyAndLayout}; |
| 13 | 10 | use rustc_middle::ty::Ty; |
| 14 | use rustc_middle::{bug, span_bug}; | |
| 11 | use rustc_middle::{bug, mir, span_bug}; | |
| 15 | 12 | use rustc_target::abi::{Abi, Align, HasDataLayout, Size}; |
| 13 | use tracing::{instrument, trace}; | |
| 16 | 14 | |
| 17 | 15 | use super::{ |
| 18 | 16 | alloc_range, mir_assign_valid_types, throw_ub, AllocRef, AllocRefMut, CheckAlignMsg, |
| ... | ... | @@ -1034,8 +1032,9 @@ where |
| 1034 | 1032 | // Some nodes are used a lot. Make sure they don't unintentionally get bigger. |
| 1035 | 1033 | #[cfg(target_pointer_width = "64")] |
| 1036 | 1034 | mod size_asserts { |
| 1037 | use super::*; | |
| 1038 | 1035 | use rustc_data_structures::static_assert_size; |
| 1036 | ||
| 1037 | use super::*; | |
| 1039 | 1038 | // tidy-alphabetical-start |
| 1040 | 1039 | static_assert_size!(MemPlace, 48); |
| 1041 | 1040 | static_assert_size!(MemPlaceMeta, 24); |
compiler/rustc_const_eval/src/interpret/projection.rs+2-6| ... | ... | @@ -10,14 +10,10 @@ |
| 10 | 10 | use std::marker::PhantomData; |
| 11 | 11 | use std::ops::Range; |
| 12 | 12 | |
| 13 | use rustc_middle::mir; | |
| 14 | use rustc_middle::ty; | |
| 15 | 13 | use rustc_middle::ty::layout::{LayoutOf, TyAndLayout}; |
| 16 | 14 | use rustc_middle::ty::Ty; |
| 17 | use rustc_middle::{bug, span_bug}; | |
| 18 | use rustc_target::abi::Size; | |
| 19 | use rustc_target::abi::{self, VariantIdx}; | |
| 20 | ||
| 15 | use rustc_middle::{bug, mir, span_bug, ty}; | |
| 16 | use rustc_target::abi::{self, Size, VariantIdx}; | |
| 21 | 17 | use tracing::{debug, instrument}; |
| 22 | 18 | |
| 23 | 19 | use super::{ |
compiler/rustc_const_eval/src/interpret/step.rs+2-4| ... | ... | @@ -3,13 +3,11 @@ |
| 3 | 3 | //! The main entry point is the `step` method. |
| 4 | 4 | |
| 5 | 5 | use either::Either; |
| 6 | use tracing::{info, instrument, trace}; | |
| 7 | ||
| 8 | 6 | use rustc_index::IndexSlice; |
| 9 | use rustc_middle::mir; | |
| 10 | 7 | use rustc_middle::ty::layout::LayoutOf; |
| 11 | use rustc_middle::{bug, span_bug}; | |
| 8 | use rustc_middle::{bug, mir, span_bug}; | |
| 12 | 9 | use rustc_target::abi::{FieldIdx, FIRST_VARIANT}; |
| 10 | use tracing::{info, instrument, trace}; | |
| 13 | 11 | |
| 14 | 12 | use super::{ |
| 15 | 13 | ImmTy, Immediate, InterpCx, InterpResult, Machine, MemPlaceMeta, PlaceTy, Projectable, Scalar, |
compiler/rustc_const_eval/src/interpret/terminator.rs+11-20| ... | ... | @@ -1,33 +1,24 @@ |
| 1 | 1 | use std::borrow::Cow; |
| 2 | 2 | |
| 3 | 3 | use either::Either; |
| 4 | use tracing::trace; | |
| 5 | ||
| 6 | use rustc_middle::{ | |
| 7 | bug, mir, span_bug, | |
| 8 | ty::{ | |
| 9 | self, | |
| 10 | layout::{FnAbiOf, IntegerExt, LayoutOf, TyAndLayout}, | |
| 11 | AdtDef, Instance, Ty, | |
| 12 | }, | |
| 13 | }; | |
| 14 | use rustc_span::{source_map::Spanned, sym}; | |
| 15 | use rustc_target::abi::{self, FieldIdx}; | |
| 16 | use rustc_target::abi::{ | |
| 17 | call::{ArgAbi, FnAbi, PassMode}, | |
| 18 | Integer, | |
| 19 | }; | |
| 4 | use rustc_middle::ty::layout::{FnAbiOf, IntegerExt, LayoutOf, TyAndLayout}; | |
| 5 | use rustc_middle::ty::{self, AdtDef, Instance, Ty}; | |
| 6 | use rustc_middle::{bug, mir, span_bug}; | |
| 7 | use rustc_span::source_map::Spanned; | |
| 8 | use rustc_span::sym; | |
| 9 | use rustc_target::abi::call::{ArgAbi, FnAbi, PassMode}; | |
| 10 | use rustc_target::abi::{self, FieldIdx, Integer}; | |
| 20 | 11 | use rustc_target::spec::abi::Abi; |
| 12 | use tracing::trace; | |
| 21 | 13 | |
| 22 | 14 | use super::{ |
| 23 | 15 | throw_ub, throw_ub_custom, throw_unsup_format, CtfeProvenance, FnVal, ImmTy, InterpCx, |
| 24 | 16 | InterpResult, MPlaceTy, Machine, OpTy, PlaceTy, Projectable, Provenance, Scalar, |
| 25 | 17 | StackPopCleanup, |
| 26 | 18 | }; |
| 27 | use crate::{ | |
| 28 | fluent_generated as fluent, | |
| 29 | interpret::{eval_context::StackPopInfo, ReturnAction}, | |
| 30 | }; | |
| 19 | use crate::fluent_generated as fluent; | |
| 20 | use crate::interpret::eval_context::StackPopInfo; | |
| 21 | use crate::interpret::ReturnAction; | |
| 31 | 22 | |
| 32 | 23 | /// An argment passed to a function. |
| 33 | 24 | #[derive(Clone, Debug)] |
compiler/rustc_const_eval/src/interpret/util.rs+3-2| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | use crate::const_eval::{CompileTimeInterpCx, CompileTimeMachine, InterpretationResult}; | |
| 1 | use std::ops::ControlFlow; | |
| 2 | ||
| 2 | 3 | use rustc_hir::def_id::LocalDefId; |
| 3 | 4 | use rustc_middle::mir; |
| 4 | 5 | use rustc_middle::mir::interpret::{Allocation, InterpResult, Pointer}; |
| ... | ... | @@ -6,10 +7,10 @@ use rustc_middle::ty::layout::TyAndLayout; |
| 6 | 7 | use rustc_middle::ty::{ |
| 7 | 8 | self, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor, |
| 8 | 9 | }; |
| 9 | use std::ops::ControlFlow; | |
| 10 | 10 | use tracing::debug; |
| 11 | 11 | |
| 12 | 12 | use super::{throw_inval, InterpCx, MPlaceTy, MemPlaceMeta, MemoryKind}; |
| 13 | use crate::const_eval::{CompileTimeInterpCx, CompileTimeMachine, InterpretationResult}; | |
| 13 | 14 | |
| 14 | 15 | /// Checks whether a type contains generic parameters which must be instantiated. |
| 15 | 16 | /// |
compiler/rustc_const_eval/src/interpret/validity.rs+6-6| ... | ... | @@ -9,17 +9,15 @@ use std::hash::Hash; |
| 9 | 9 | use std::num::NonZero; |
| 10 | 10 | |
| 11 | 11 | use either::{Left, Right}; |
| 12 | use tracing::trace; | |
| 13 | ||
| 14 | 12 | use hir::def::DefKind; |
| 15 | 13 | use rustc_ast::Mutability; |
| 16 | 14 | use rustc_data_structures::fx::FxHashSet; |
| 17 | 15 | use rustc_hir as hir; |
| 18 | 16 | use rustc_middle::bug; |
| 17 | use rustc_middle::mir::interpret::ValidationErrorKind::{self, *}; | |
| 19 | 18 | use rustc_middle::mir::interpret::{ |
| 20 | 19 | ExpectedKind, InterpError, InvalidMetaKind, Misalignment, PointerKind, Provenance, |
| 21 | 20 | UnsupportedOpInfo, ValidationErrorInfo, |
| 22 | ValidationErrorKind::{self, *}, | |
| 23 | 21 | }; |
| 24 | 22 | use rustc_middle::ty::layout::{LayoutOf, TyAndLayout}; |
| 25 | 23 | use rustc_middle::ty::{self, Ty}; |
| ... | ... | @@ -27,11 +25,13 @@ use rustc_span::symbol::{sym, Symbol}; |
| 27 | 25 | use rustc_target::abi::{ |
| 28 | 26 | Abi, FieldIdx, Scalar as ScalarAbi, Size, VariantIdx, Variants, WrappingRange, |
| 29 | 27 | }; |
| 28 | use tracing::trace; | |
| 30 | 29 | |
| 30 | use super::machine::AllocMap; | |
| 31 | 31 | use super::{ |
| 32 | err_ub, format_interp_error, machine::AllocMap, throw_ub, AllocId, AllocKind, CheckInAllocMsg, | |
| 33 | GlobalAlloc, ImmTy, Immediate, InterpCx, InterpResult, MPlaceTy, Machine, MemPlaceMeta, OpTy, | |
| 34 | Pointer, Projectable, Scalar, ValueVisitor, | |
| 32 | err_ub, format_interp_error, throw_ub, AllocId, AllocKind, CheckInAllocMsg, GlobalAlloc, ImmTy, | |
| 33 | Immediate, InterpCx, InterpResult, MPlaceTy, Machine, MemPlaceMeta, OpTy, Pointer, Projectable, | |
| 34 | Scalar, ValueVisitor, | |
| 35 | 35 | }; |
| 36 | 36 | |
| 37 | 37 | // for the validation errors |
compiler/rustc_const_eval/src/interpret/visitor.rs+3-4| ... | ... | @@ -1,15 +1,14 @@ |
| 1 | 1 | //! Visitor for a run-time value with a given layout: Traverse enums, structs and other compound |
| 2 | 2 | //! types until we arrive at the leaves, with custom handling for primitive types. |
| 3 | 3 | |
| 4 | use std::num::NonZero; | |
| 5 | ||
| 4 | 6 | use rustc_index::IndexVec; |
| 5 | 7 | use rustc_middle::mir::interpret::InterpResult; |
| 6 | 8 | use rustc_middle::ty::{self, Ty}; |
| 7 | use rustc_target::abi::FieldIdx; | |
| 8 | use rustc_target::abi::{FieldsShape, VariantIdx, Variants}; | |
| 9 | use rustc_target::abi::{FieldIdx, FieldsShape, VariantIdx, Variants}; | |
| 9 | 10 | use tracing::trace; |
| 10 | 11 | |
| 11 | use std::num::NonZero; | |
| 12 | ||
| 13 | 12 | use super::{throw_inval, InterpCx, MPlaceTy, Machine, Projectable}; |
| 14 | 13 | |
| 15 | 14 | /// How to traverse a value and what to do when we are at the leaves. |
compiler/rustc_const_eval/src/lib.rs+2-2| ... | ... | @@ -26,8 +26,8 @@ pub mod util; |
| 26 | 26 | use std::sync::atomic::AtomicBool; |
| 27 | 27 | |
| 28 | 28 | pub use errors::ReportErrorExt; |
| 29 | ||
| 30 | use rustc_middle::{ty, util::Providers}; | |
| 29 | use rustc_middle::ty; | |
| 30 | use rustc_middle::util::Providers; | |
| 31 | 31 | |
| 32 | 32 | rustc_fluent_macro::fluent_messages! { "../messages.ftl" } |
| 33 | 33 |
compiler/rustc_const_eval/src/util/caller_location.rs+1-2| ... | ... | @@ -1,9 +1,8 @@ |
| 1 | 1 | use rustc_hir::LangItem; |
| 2 | use rustc_middle::bug; | |
| 3 | use rustc_middle::mir; | |
| 4 | 2 | use rustc_middle::query::TyCtxtAt; |
| 5 | 3 | use rustc_middle::ty::layout::LayoutOf; |
| 6 | 4 | use rustc_middle::ty::{self, Mutability}; |
| 5 | use rustc_middle::{bug, mir}; | |
| 7 | 6 | use rustc_span::symbol::Symbol; |
| 8 | 7 | use tracing::trace; |
| 9 | 8 |
compiler/rustc_const_eval/src/util/type_name.rs+4-6| ... | ... | @@ -1,13 +1,11 @@ |
| 1 | use std::fmt::Write; | |
| 2 | ||
| 1 | 3 | use rustc_data_structures::intern::Interned; |
| 2 | 4 | use rustc_hir::def_id::CrateNum; |
| 3 | 5 | use rustc_hir::definitions::DisambiguatedDefPathData; |
| 4 | 6 | use rustc_middle::bug; |
| 5 | use rustc_middle::ty::{ | |
| 6 | self, | |
| 7 | print::{PrettyPrinter, Print, PrintError, Printer}, | |
| 8 | GenericArg, GenericArgKind, Ty, TyCtxt, | |
| 9 | }; | |
| 10 | use std::fmt::Write; | |
| 7 | use rustc_middle::ty::print::{PrettyPrinter, Print, PrintError, Printer}; | |
| 8 | use rustc_middle::ty::{self, GenericArg, GenericArgKind, Ty, TyCtxt}; | |
| 11 | 9 | |
| 12 | 10 | struct AbsolutePathPrinter<'tcx> { |
| 13 | 11 | tcx: TyCtxt<'tcx>, |
compiler/rustc_data_structures/src/base_n.rs+1-2| ... | ... | @@ -1,8 +1,7 @@ |
| 1 | 1 | //! Converts unsigned integers into a string representation with some base. |
| 2 | 2 | //! Bases up to and including 36 can be used for case-insensitive things. |
| 3 | 3 | |
| 4 | use std::ascii; | |
| 5 | use std::fmt; | |
| 4 | use std::{ascii, fmt}; | |
| 6 | 5 | |
| 7 | 6 | #[cfg(test)] |
| 8 | 7 | mod tests; |
compiler/rustc_data_structures/src/fingerprint.rs+6-3| ... | ... | @@ -1,8 +1,11 @@ |
| 1 | use crate::stable_hasher::impl_stable_traits_for_trivial_type; | |
| 2 | use crate::stable_hasher::{FromStableHash, Hash64, StableHasherHash}; | |
| 3 | use rustc_serialize::{Decodable, Decoder, Encodable, Encoder}; | |
| 4 | 1 | use std::hash::{Hash, Hasher}; |
| 5 | 2 | |
| 3 | use rustc_serialize::{Decodable, Decoder, Encodable, Encoder}; | |
| 4 | ||
| 5 | use crate::stable_hasher::{ | |
| 6 | impl_stable_traits_for_trivial_type, FromStableHash, Hash64, StableHasherHash, | |
| 7 | }; | |
| 8 | ||
| 6 | 9 | #[cfg(test)] |
| 7 | 10 | mod tests; |
| 8 | 11 |
compiler/rustc_data_structures/src/flat_map_in_place.rs+2-1| ... | ... | @@ -1,5 +1,6 @@ |
| 1 | use smallvec::{Array, SmallVec}; | |
| 2 | 1 | use std::ptr; |
| 2 | ||
| 3 | use smallvec::{Array, SmallVec}; | |
| 3 | 4 | use thin_vec::ThinVec; |
| 4 | 5 | |
| 5 | 6 | pub trait FlatMapInPlace<T>: Sized { |
compiler/rustc_data_structures/src/flock/unix.rs+1-2| ... | ... | @@ -1,8 +1,7 @@ |
| 1 | 1 | use std::fs::{File, OpenOptions}; |
| 2 | use std::io; | |
| 3 | use std::mem; | |
| 4 | 2 | use std::os::unix::prelude::*; |
| 5 | 3 | use std::path::Path; |
| 4 | use std::{io, mem}; | |
| 6 | 5 | |
| 7 | 6 | #[derive(Debug)] |
| 8 | 7 | pub struct Lock { |
compiler/rustc_data_structures/src/flock/windows.rs+6-8| ... | ... | @@ -2,16 +2,14 @@ use std::fs::{File, OpenOptions}; |
| 2 | 2 | use std::io; |
| 3 | 3 | use std::os::windows::prelude::*; |
| 4 | 4 | use std::path::Path; |
| 5 | use tracing::debug; | |
| 6 | 5 | |
| 7 | use windows::{ | |
| 8 | Win32::Foundation::{ERROR_INVALID_FUNCTION, HANDLE}, | |
| 9 | Win32::Storage::FileSystem::{ | |
| 10 | LockFileEx, FILE_SHARE_DELETE, FILE_SHARE_READ, FILE_SHARE_WRITE, LOCKFILE_EXCLUSIVE_LOCK, | |
| 11 | LOCKFILE_FAIL_IMMEDIATELY, LOCK_FILE_FLAGS, | |
| 12 | }, | |
| 13 | Win32::System::IO::OVERLAPPED, | |
| 6 | use tracing::debug; | |
| 7 | use windows::Win32::Foundation::{ERROR_INVALID_FUNCTION, HANDLE}; | |
| 8 | use windows::Win32::Storage::FileSystem::{ | |
| 9 | LockFileEx, FILE_SHARE_DELETE, FILE_SHARE_READ, FILE_SHARE_WRITE, LOCKFILE_EXCLUSIVE_LOCK, | |
| 10 | LOCKFILE_FAIL_IMMEDIATELY, LOCK_FILE_FLAGS, | |
| 14 | 11 | }; |
| 12 | use windows::Win32::System::IO::OVERLAPPED; | |
| 15 | 13 | |
| 16 | 14 | #[derive(Debug)] |
| 17 | 15 | pub struct Lock { |
compiler/rustc_data_structures/src/graph/dominators/mod.rs+3-2| ... | ... | @@ -9,10 +9,11 @@ |
| 9 | 9 | //! Thomas Lengauer and Robert Endre Tarjan. |
| 10 | 10 | //! <https://www.cs.princeton.edu/courses/archive/spr03/cs423/download/dominators.pdf> |
| 11 | 11 | |
| 12 | use super::ControlFlowGraph; | |
| 12 | use std::cmp::Ordering; | |
| 13 | ||
| 13 | 14 | use rustc_index::{Idx, IndexSlice, IndexVec}; |
| 14 | 15 | |
| 15 | use std::cmp::Ordering; | |
| 16 | use super::ControlFlowGraph; | |
| 16 | 17 | |
| 17 | 18 | #[cfg(test)] |
| 18 | 19 | mod tests; |
compiler/rustc_data_structures/src/graph/dominators/tests.rs+1-2| ... | ... | @@ -1,6 +1,5 @@ |
| 1 | use super::*; | |
| 2 | ||
| 3 | 1 | use super::super::tests::TestGraph; |
| 2 | use super::*; | |
| 4 | 3 | |
| 5 | 4 | #[test] |
| 6 | 5 | fn diamond() { |
compiler/rustc_data_structures/src/graph/implementation/mod.rs+2-1| ... | ... | @@ -20,8 +20,9 @@ |
| 20 | 20 | //! the field `next_edge`). Each of those fields is an array that should |
| 21 | 21 | //! be indexed by the direction (see the type `Direction`). |
| 22 | 22 | |
| 23 | use rustc_index::bit_set::BitSet; | |
| 24 | 23 | use std::fmt::Debug; |
| 24 | ||
| 25 | use rustc_index::bit_set::BitSet; | |
| 25 | 26 | use tracing::debug; |
| 26 | 27 | |
| 27 | 28 | #[cfg(test)] |
compiler/rustc_data_structures/src/graph/implementation/tests.rs+2-1| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | use crate::graph::implementation::*; | |
| 2 | 1 | use tracing::debug; |
| 3 | 2 | |
| 3 | use crate::graph::implementation::*; | |
| 4 | ||
| 4 | 5 | type TestGraph = Graph<&'static str, &'static str>; |
| 5 | 6 | |
| 6 | 7 | fn create_graph() -> TestGraph { |
compiler/rustc_data_structures/src/graph/iterate/mod.rs+4-2| ... | ... | @@ -1,7 +1,9 @@ |
| 1 | use super::{DirectedGraph, StartNode, Successors}; | |
| 1 | use std::ops::ControlFlow; | |
| 2 | ||
| 2 | 3 | use rustc_index::bit_set::BitSet; |
| 3 | 4 | use rustc_index::{IndexSlice, IndexVec}; |
| 4 | use std::ops::ControlFlow; | |
| 5 | ||
| 6 | use super::{DirectedGraph, StartNode, Successors}; | |
| 5 | 7 | |
| 6 | 8 | #[cfg(test)] |
| 7 | 9 | mod tests; |
compiler/rustc_data_structures/src/graph/iterate/tests.rs-1| ... | ... | @@ -1,5 +1,4 @@ |
| 1 | 1 | use super::super::tests::TestGraph; |
| 2 | ||
| 3 | 2 | use super::*; |
| 4 | 3 | |
| 5 | 4 | #[test] |
compiler/rustc_data_structures/src/graph/scc/mod.rs+6-4| ... | ... | @@ -8,14 +8,16 @@ |
| 8 | 8 | //! Typical examples would include: minimum element in SCC, maximum element |
| 9 | 9 | //! reachable from it, etc. |
| 10 | 10 | |
| 11 | use crate::fx::FxHashSet; | |
| 12 | use crate::graph::vec_graph::VecGraph; | |
| 13 | use crate::graph::{DirectedGraph, NumEdges, Successors}; | |
| 14 | use rustc_index::{Idx, IndexSlice, IndexVec}; | |
| 15 | 11 | use std::fmt::Debug; |
| 16 | 12 | use std::ops::Range; |
| 13 | ||
| 14 | use rustc_index::{Idx, IndexSlice, IndexVec}; | |
| 17 | 15 | use tracing::{debug, instrument}; |
| 18 | 16 | |
| 17 | use crate::fx::FxHashSet; | |
| 18 | use crate::graph::vec_graph::VecGraph; | |
| 19 | use crate::graph::{DirectedGraph, NumEdges, Successors}; | |
| 20 | ||
| 19 | 21 | #[cfg(test)] |
| 20 | 22 | mod tests; |
| 21 | 23 |
compiler/rustc_data_structures/src/graph/tests.rs+1-1| ... | ... | @@ -1,7 +1,7 @@ |
| 1 | use crate::fx::FxHashMap; | |
| 2 | 1 | use std::cmp::max; |
| 3 | 2 | |
| 4 | 3 | use super::*; |
| 4 | use crate::fx::FxHashMap; | |
| 5 | 5 | |
| 6 | 6 | pub struct TestGraph { |
| 7 | 7 | num_nodes: usize, |
compiler/rustc_data_structures/src/graph/vec_graph/mod.rs+2-1| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | use crate::graph::{DirectedGraph, NumEdges, Predecessors, Successors}; | |
| 2 | 1 | use rustc_index::{Idx, IndexVec}; |
| 3 | 2 | |
| 3 | use crate::graph::{DirectedGraph, NumEdges, Predecessors, Successors}; | |
| 4 | ||
| 4 | 5 | #[cfg(test)] |
| 5 | 6 | mod tests; |
| 6 | 7 |
compiler/rustc_data_structures/src/graph/vec_graph/tests.rs+1-2| ... | ... | @@ -1,6 +1,5 @@ |
| 1 | use crate::graph; | |
| 2 | ||
| 3 | 1 | use super::*; |
| 2 | use crate::graph; | |
| 4 | 3 | |
| 5 | 4 | fn create_graph() -> VecGraph<usize> { |
| 6 | 5 | // Create a simple graph |
compiler/rustc_data_structures/src/hashes.rs+4-2| ... | ... | @@ -11,11 +11,13 @@ |
| 11 | 11 | //! connect the fact that they can only be produced by a `StableHasher` to their |
| 12 | 12 | //! `Encode`/`Decode` impls. |
| 13 | 13 | |
| 14 | use crate::stable_hasher::{FromStableHash, StableHasherHash}; | |
| 15 | use rustc_serialize::{Decodable, Decoder, Encodable, Encoder}; | |
| 16 | 14 | use std::fmt; |
| 17 | 15 | use std::ops::BitXorAssign; |
| 18 | 16 | |
| 17 | use rustc_serialize::{Decodable, Decoder, Encodable, Encoder}; | |
| 18 | ||
| 19 | use crate::stable_hasher::{FromStableHash, StableHasherHash}; | |
| 20 | ||
| 19 | 21 | #[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)] |
| 20 | 22 | pub struct Hash64 { |
| 21 | 23 | inner: u64, |
compiler/rustc_data_structures/src/intern.rs+2-1| ... | ... | @@ -1,10 +1,11 @@ |
| 1 | use crate::stable_hasher::{HashStable, StableHasher}; | |
| 2 | 1 | use std::cmp::Ordering; |
| 3 | 2 | use std::fmt::{self, Debug}; |
| 4 | 3 | use std::hash::{Hash, Hasher}; |
| 5 | 4 | use std::ops::Deref; |
| 6 | 5 | use std::ptr; |
| 7 | 6 | |
| 7 | use crate::stable_hasher::{HashStable, StableHasher}; | |
| 8 | ||
| 8 | 9 | mod private { |
| 9 | 10 | #[derive(Clone, Copy, Debug)] |
| 10 | 11 | pub struct PrivateZst; |
compiler/rustc_data_structures/src/jobserver.rs+2-3| ... | ... | @@ -1,9 +1,8 @@ |
| 1 | pub use jobserver_crate::Client; | |
| 1 | use std::sync::{LazyLock, OnceLock}; | |
| 2 | 2 | |
| 3 | pub use jobserver_crate::Client; | |
| 3 | 4 | use jobserver_crate::{FromEnv, FromEnvErrorKind}; |
| 4 | 5 | |
| 5 | use std::sync::{LazyLock, OnceLock}; | |
| 6 | ||
| 7 | 6 | // We can only call `from_env_ext` once per process |
| 8 | 7 | |
| 9 | 8 | // We stick this in a global because there could be multiple rustc instances |
compiler/rustc_data_structures/src/lib.rs+3-5| ... | ... | @@ -39,14 +39,12 @@ |
| 39 | 39 | #![feature(unwrap_infallible)] |
| 40 | 40 | // tidy-alphabetical-end |
| 41 | 41 | |
| 42 | use std::fmt; | |
| 43 | ||
| 42 | 44 | pub use atomic_ref::AtomicRef; |
| 43 | pub use ena::snapshot_vec; | |
| 44 | pub use ena::undo_log; | |
| 45 | pub use ena::unify; | |
| 45 | pub use ena::{snapshot_vec, undo_log, unify}; | |
| 46 | 46 | pub use rustc_index::static_assert_size; |
| 47 | 47 | |
| 48 | use std::fmt; | |
| 49 | ||
| 50 | 48 | pub mod aligned; |
| 51 | 49 | pub mod base_n; |
| 52 | 50 | pub mod binary_search_util; |
compiler/rustc_data_structures/src/obligation_forest/graphviz.rs+5-4| ... | ... | @@ -1,11 +1,12 @@ |
| 1 | use crate::obligation_forest::{ForestObligation, ObligationForest}; | |
| 2 | use rustc_graphviz as dot; | |
| 3 | 1 | use std::env::var_os; |
| 4 | 2 | use std::fs::File; |
| 5 | 3 | use std::io::BufWriter; |
| 6 | 4 | use std::path::Path; |
| 7 | use std::sync::atomic::AtomicUsize; | |
| 8 | use std::sync::atomic::Ordering; | |
| 5 | use std::sync::atomic::{AtomicUsize, Ordering}; | |
| 6 | ||
| 7 | use rustc_graphviz as dot; | |
| 8 | ||
| 9 | use crate::obligation_forest::{ForestObligation, ObligationForest}; | |
| 9 | 10 | |
| 10 | 11 | impl<O: ForestObligation> ObligationForest<O> { |
| 11 | 12 | /// Creates a graphviz representation of the obligation forest. Given a directory this will |
compiler/rustc_data_structures/src/obligation_forest/mod.rs+3-1| ... | ... | @@ -69,14 +69,16 @@ |
| 69 | 69 | //! step, we compress the vector to remove completed and error nodes, which |
| 70 | 70 | //! aren't needed anymore. |
| 71 | 71 | |
| 72 | use crate::fx::{FxHashMap, FxHashSet}; | |
| 73 | 72 | use std::cell::Cell; |
| 74 | 73 | use std::collections::hash_map::Entry; |
| 75 | 74 | use std::fmt::Debug; |
| 76 | 75 | use std::hash; |
| 77 | 76 | use std::marker::PhantomData; |
| 77 | ||
| 78 | 78 | use tracing::debug; |
| 79 | 79 | |
| 80 | use crate::fx::{FxHashMap, FxHashSet}; | |
| 81 | ||
| 80 | 82 | mod graphviz; |
| 81 | 83 | |
| 82 | 84 | #[cfg(test)] |
compiler/rustc_data_structures/src/obligation_forest/tests.rs+2-2| ... | ... | @@ -1,7 +1,7 @@ |
| 1 | use super::*; | |
| 2 | ||
| 3 | 1 | use std::fmt; |
| 4 | 2 | |
| 3 | use super::*; | |
| 4 | ||
| 5 | 5 | impl<'a> super::ForestObligation for &'a str { |
| 6 | 6 | type CacheKey = &'a str; |
| 7 | 7 |
compiler/rustc_data_structures/src/owned_slice.rs+3-2| ... | ... | @@ -1,10 +1,11 @@ |
| 1 | use std::{borrow::Borrow, ops::Deref}; | |
| 1 | use std::borrow::Borrow; | |
| 2 | use std::ops::Deref; | |
| 2 | 3 | |
| 3 | use crate::sync::Lrc; | |
| 4 | 4 | // Use our fake Send/Sync traits when on not parallel compiler, |
| 5 | 5 | // so that `OwnedSlice` only implements/requires Send/Sync |
| 6 | 6 | // for parallel compiler builds. |
| 7 | 7 | use crate::sync; |
| 8 | use crate::sync::Lrc; | |
| 8 | 9 | |
| 9 | 10 | /// An owned slice. |
| 10 | 11 | /// |
compiler/rustc_data_structures/src/owned_slice/tests.rs+6-12| ... | ... | @@ -1,15 +1,9 @@ |
| 1 | use std::{ | |
| 2 | ops::Deref, | |
| 3 | sync::{ | |
| 4 | atomic::{self, AtomicBool}, | |
| 5 | Arc, | |
| 6 | }, | |
| 7 | }; | |
| 8 | ||
| 9 | use crate::{ | |
| 10 | defer, | |
| 11 | owned_slice::{slice_owned, try_slice_owned, OwnedSlice}, | |
| 12 | }; | |
| 1 | use std::ops::Deref; | |
| 2 | use std::sync::atomic::{self, AtomicBool}; | |
| 3 | use std::sync::Arc; | |
| 4 | ||
| 5 | use crate::defer; | |
| 6 | use crate::owned_slice::{slice_owned, try_slice_owned, OwnedSlice}; | |
| 13 | 7 | |
| 14 | 8 | #[test] |
| 15 | 9 | fn smoke() { |
compiler/rustc_data_structures/src/packed.rs+4-2| ... | ... | @@ -1,8 +1,10 @@ |
| 1 | use crate::stable_hasher::{HashStable, StableHasher}; | |
| 2 | use rustc_serialize::{Decodable, Decoder, Encodable, Encoder}; | |
| 3 | 1 | use std::cmp::Ordering; |
| 4 | 2 | use std::fmt; |
| 5 | 3 | |
| 4 | use rustc_serialize::{Decodable, Decoder, Encodable, Encoder}; | |
| 5 | ||
| 6 | use crate::stable_hasher::{HashStable, StableHasher}; | |
| 7 | ||
| 6 | 8 | /// A packed 128-bit integer. Useful for reducing the size of structures in |
| 7 | 9 | /// some cases. |
| 8 | 10 | #[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] |
compiler/rustc_data_structures/src/profiling.rs+4-5| ... | ... | @@ -81,19 +81,15 @@ |
| 81 | 81 | //! |
| 82 | 82 | //! [mm]: https://github.com/rust-lang/measureme/ |
| 83 | 83 | |
| 84 | use crate::fx::FxHashMap; | |
| 85 | use crate::outline; | |
| 86 | ||
| 87 | 84 | use std::borrow::Borrow; |
| 88 | 85 | use std::collections::hash_map::Entry; |
| 89 | 86 | use std::error::Error; |
| 90 | 87 | use std::fmt::Display; |
| 91 | use std::fs; | |
| 92 | 88 | use std::intrinsics::unlikely; |
| 93 | 89 | use std::path::Path; |
| 94 | use std::process; | |
| 95 | 90 | use std::sync::Arc; |
| 96 | 91 | use std::time::{Duration, Instant}; |
| 92 | use std::{fs, process}; | |
| 97 | 93 | |
| 98 | 94 | pub use measureme::EventId; |
| 99 | 95 | use measureme::{EventIdBuilder, Profiler, SerializableString, StringId}; |
| ... | ... | @@ -101,6 +97,9 @@ use parking_lot::RwLock; |
| 101 | 97 | use smallvec::SmallVec; |
| 102 | 98 | use tracing::warn; |
| 103 | 99 | |
| 100 | use crate::fx::FxHashMap; | |
| 101 | use crate::outline; | |
| 102 | ||
| 104 | 103 | bitflags::bitflags! { |
| 105 | 104 | #[derive(Clone, Copy)] |
| 106 | 105 | struct EventFilter: u16 { |
compiler/rustc_data_structures/src/sharded.rs+8-7| ... | ... | @@ -1,14 +1,15 @@ |
| 1 | use std::borrow::Borrow; | |
| 2 | use std::collections::hash_map::RawEntryMut; | |
| 3 | use std::hash::{Hash, Hasher}; | |
| 4 | use std::{iter, mem}; | |
| 5 | ||
| 6 | #[cfg(parallel_compiler)] | |
| 7 | use either::Either; | |
| 8 | ||
| 1 | 9 | use crate::fx::{FxHashMap, FxHasher}; |
| 2 | 10 | #[cfg(parallel_compiler)] |
| 3 | 11 | use crate::sync::{is_dyn_thread_safe, CacheAligned}; |
| 4 | 12 | use crate::sync::{Lock, LockGuard, Mode}; |
| 5 | #[cfg(parallel_compiler)] | |
| 6 | use either::Either; | |
| 7 | use std::borrow::Borrow; | |
| 8 | use std::collections::hash_map::RawEntryMut; | |
| 9 | use std::hash::{Hash, Hasher}; | |
| 10 | use std::iter; | |
| 11 | use std::mem; | |
| 12 | 13 | |
| 13 | 14 | // 32 shards is sufficient to reduce contention on an 8-core Ryzen 7 1700, |
| 14 | 15 | // but this should be tested on higher core count CPUs. How the `Sharded` type gets used |
compiler/rustc_data_structures/src/snapshot_map/mod.rs+2-2| ... | ... | @@ -1,11 +1,11 @@ |
| 1 | use crate::fx::FxHashMap; | |
| 2 | use crate::undo_log::{Rollback, Snapshots, UndoLogs, VecLog}; | |
| 3 | 1 | use std::borrow::{Borrow, BorrowMut}; |
| 4 | 2 | use std::hash::Hash; |
| 5 | 3 | use std::marker::PhantomData; |
| 6 | 4 | use std::ops; |
| 7 | 5 | |
| 6 | use crate::fx::FxHashMap; | |
| 8 | 7 | pub use crate::undo_log::Snapshot; |
| 8 | use crate::undo_log::{Rollback, Snapshots, UndoLogs, VecLog}; | |
| 9 | 9 | |
| 10 | 10 | #[cfg(test)] |
| 11 | 11 | mod tests; |
compiler/rustc_data_structures/src/sorted_map.rs+4-2| ... | ... | @@ -1,10 +1,12 @@ |
| 1 | use crate::stable_hasher::{HashStable, StableHasher, StableOrd}; | |
| 2 | use rustc_macros::{Decodable_Generic, Encodable_Generic}; | |
| 3 | 1 | use std::borrow::Borrow; |
| 4 | 2 | use std::fmt::Debug; |
| 5 | 3 | use std::mem; |
| 6 | 4 | use std::ops::{Bound, Index, IndexMut, RangeBounds}; |
| 7 | 5 | |
| 6 | use rustc_macros::{Decodable_Generic, Encodable_Generic}; | |
| 7 | ||
| 8 | use crate::stable_hasher::{HashStable, StableHasher, StableOrd}; | |
| 9 | ||
| 8 | 10 | mod index_map; |
| 9 | 11 | |
| 10 | 12 | pub use index_map::SortedIndexMultiMap; |
compiler/rustc_data_structures/src/sorted_map/index_map.rs+2-1| ... | ... | @@ -2,9 +2,10 @@ |
| 2 | 2 | |
| 3 | 3 | use std::hash::{Hash, Hasher}; |
| 4 | 4 | |
| 5 | use crate::stable_hasher::{HashStable, StableHasher}; | |
| 6 | 5 | use rustc_index::{Idx, IndexVec}; |
| 7 | 6 | |
| 7 | use crate::stable_hasher::{HashStable, StableHasher}; | |
| 8 | ||
| 8 | 9 | /// An indexed multi-map that preserves insertion order while permitting both *O*(log *n*) lookup of |
| 9 | 10 | /// an item by key and *O*(1) lookup by index. |
| 10 | 11 | /// |
compiler/rustc_data_structures/src/sso/map.rs+5-3| ... | ... | @@ -1,10 +1,12 @@ |
| 1 | use crate::fx::FxHashMap; | |
| 2 | use arrayvec::ArrayVec; | |
| 3 | use either::Either; | |
| 4 | 1 | use std::fmt; |
| 5 | 2 | use std::hash::Hash; |
| 6 | 3 | use std::ops::Index; |
| 7 | 4 | |
| 5 | use arrayvec::ArrayVec; | |
| 6 | use either::Either; | |
| 7 | ||
| 8 | use crate::fx::FxHashMap; | |
| 9 | ||
| 8 | 10 | /// For pointer-sized arguments arrays |
| 9 | 11 | /// are faster than set/map for up to 64 |
| 10 | 12 | /// arguments. |
compiler/rustc_data_structures/src/stable_hasher.rs+8-7| ... | ... | @@ -1,19 +1,20 @@ |
| 1 | use rustc_index::bit_set::{self, BitSet}; | |
| 2 | use rustc_index::{Idx, IndexSlice, IndexVec}; | |
| 3 | use smallvec::SmallVec; | |
| 4 | 1 | use std::hash::{BuildHasher, Hash, Hasher}; |
| 5 | 2 | use std::marker::PhantomData; |
| 6 | 3 | use std::mem; |
| 7 | 4 | use std::num::NonZero; |
| 8 | 5 | |
| 6 | use rustc_index::bit_set::{self, BitSet}; | |
| 7 | use rustc_index::{Idx, IndexSlice, IndexVec}; | |
| 8 | use smallvec::SmallVec; | |
| 9 | ||
| 9 | 10 | #[cfg(test)] |
| 10 | 11 | mod tests; |
| 11 | 12 | |
| 12 | pub use crate::hashes::{Hash128, Hash64}; | |
| 13 | pub use rustc_stable_hash::{ | |
| 14 | FromStableHash, SipHasher128Hash as StableHasherHash, StableSipHasher128 as StableHasher, | |
| 15 | }; | |
| 13 | 16 | |
| 14 | pub use rustc_stable_hash::FromStableHash; | |
| 15 | pub use rustc_stable_hash::SipHasher128Hash as StableHasherHash; | |
| 16 | pub use rustc_stable_hash::StableSipHasher128 as StableHasher; | |
| 17 | pub use crate::hashes::{Hash128, Hash64}; | |
| 17 | 18 | |
| 18 | 19 | /// Something that implements `HashStable<CTX>` can be hashed in a way that is |
| 19 | 20 | /// stable across multiple compilation sessions. |
compiler/rustc_data_structures/src/svh.rs+4-2| ... | ... | @@ -5,10 +5,12 @@ |
| 5 | 5 | //! mismatches where we have two versions of the same crate that were |
| 6 | 6 | //! compiled from distinct sources. |
| 7 | 7 | |
| 8 | use std::fmt; | |
| 9 | ||
| 10 | use rustc_macros::{Decodable_Generic, Encodable_Generic}; | |
| 11 | ||
| 8 | 12 | use crate::fingerprint::Fingerprint; |
| 9 | 13 | use crate::stable_hasher; |
| 10 | use rustc_macros::{Decodable_Generic, Encodable_Generic}; | |
| 11 | use std::fmt; | |
| 12 | 14 | |
| 13 | 15 | #[derive(Copy, Clone, PartialEq, Eq, Debug, Encodable_Generic, Decodable_Generic, Hash)] |
| 14 | 16 | pub struct Svh { |
compiler/rustc_data_structures/src/sync.rs+2-2| ... | ... | @@ -41,10 +41,11 @@ |
| 41 | 41 | //! |
| 42 | 42 | //! [^2]: `MTRef`, `MTLockRef` are type aliases. |
| 43 | 43 | |
| 44 | pub use crate::marker::*; | |
| 45 | 44 | use std::collections::HashMap; |
| 46 | 45 | use std::hash::{BuildHasher, Hash}; |
| 47 | 46 | |
| 47 | pub use crate::marker::*; | |
| 48 | ||
| 48 | 49 | mod lock; |
| 49 | 50 | #[doc(no_inline)] |
| 50 | 51 | pub use lock::{Lock, LockGuard, Mode}; |
| ... | ... | @@ -56,7 +57,6 @@ mod parallel; |
| 56 | 57 | #[cfg(parallel_compiler)] |
| 57 | 58 | pub use parallel::scope; |
| 58 | 59 | pub use parallel::{join, par_for_each_in, par_map, parallel_guard, try_par_for_each_in}; |
| 59 | ||
| 60 | 60 | pub use vec::{AppendOnlyIndexVec, AppendOnlyVec}; |
| 61 | 61 | |
| 62 | 62 | mod vec; |
compiler/rustc_data_structures/src/sync/freeze.rs+7-8| ... | ... | @@ -1,14 +1,13 @@ |
| 1 | use std::cell::UnsafeCell; | |
| 2 | use std::intrinsics::likely; | |
| 3 | use std::marker::PhantomData; | |
| 4 | use std::ops::{Deref, DerefMut}; | |
| 5 | use std::ptr::NonNull; | |
| 6 | use std::sync::atomic::Ordering; | |
| 7 | ||
| 1 | 8 | use crate::sync::{AtomicBool, ReadGuard, RwLock, WriteGuard}; |
| 2 | 9 | #[cfg(parallel_compiler)] |
| 3 | 10 | use crate::sync::{DynSend, DynSync}; |
| 4 | use std::{ | |
| 5 | cell::UnsafeCell, | |
| 6 | intrinsics::likely, | |
| 7 | marker::PhantomData, | |
| 8 | ops::{Deref, DerefMut}, | |
| 9 | ptr::NonNull, | |
| 10 | sync::atomic::Ordering, | |
| 11 | }; | |
| 12 | 11 | |
| 13 | 12 | /// A type which allows mutation using a lock until |
| 14 | 13 | /// the value is frozen and can be accessed lock-free. |
compiler/rustc_data_structures/src/sync/lock.rs+11-10| ... | ... | @@ -19,19 +19,20 @@ pub enum Mode { |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | mod maybe_sync { |
| 22 | use super::Mode; | |
| 23 | use crate::sync::mode; | |
| 24 | #[cfg(parallel_compiler)] | |
| 25 | use crate::sync::{DynSend, DynSync}; | |
| 26 | use parking_lot::lock_api::RawMutex as _; | |
| 27 | use parking_lot::RawMutex; | |
| 28 | use std::cell::Cell; | |
| 29 | use std::cell::UnsafeCell; | |
| 22 | use std::cell::{Cell, UnsafeCell}; | |
| 30 | 23 | use std::intrinsics::unlikely; |
| 31 | 24 | use std::marker::PhantomData; |
| 32 | 25 | use std::mem::ManuallyDrop; |
| 33 | 26 | use std::ops::{Deref, DerefMut}; |
| 34 | 27 | |
| 28 | use parking_lot::lock_api::RawMutex as _; | |
| 29 | use parking_lot::RawMutex; | |
| 30 | ||
| 31 | use super::Mode; | |
| 32 | use crate::sync::mode; | |
| 33 | #[cfg(parallel_compiler)] | |
| 34 | use crate::sync::{DynSend, DynSync}; | |
| 35 | ||
| 35 | 36 | /// A guard holding mutable access to a `Lock` which is in a locked state. |
| 36 | 37 | #[must_use = "if unused the Lock will immediately unlock"] |
| 37 | 38 | pub struct LockGuard<'a, T> { |
| ... | ... | @@ -186,12 +187,12 @@ mod maybe_sync { |
| 186 | 187 | } |
| 187 | 188 | |
| 188 | 189 | mod no_sync { |
| 189 | use super::Mode; | |
| 190 | 190 | use std::cell::RefCell; |
| 191 | ||
| 192 | 191 | #[doc(no_inline)] |
| 193 | 192 | pub use std::cell::RefMut as LockGuard; |
| 194 | 193 | |
| 194 | use super::Mode; | |
| 195 | ||
| 195 | 196 | pub struct Lock<T>(RefCell<T>); |
| 196 | 197 | |
| 197 | 198 | impl<T> Lock<T> { |
compiler/rustc_data_structures/src/sync/parallel.rs+4-3| ... | ... | @@ -3,9 +3,6 @@ |
| 3 | 3 | |
| 4 | 4 | #![allow(dead_code)] |
| 5 | 5 | |
| 6 | use crate::sync::IntoDynSyncSend; | |
| 7 | use crate::FatalErrorMarker; | |
| 8 | use parking_lot::Mutex; | |
| 9 | 6 | use std::any::Any; |
| 10 | 7 | use std::panic::{catch_unwind, resume_unwind, AssertUnwindSafe}; |
| 11 | 8 | |
| ... | ... | @@ -13,6 +10,10 @@ use std::panic::{catch_unwind, resume_unwind, AssertUnwindSafe}; |
| 13 | 10 | pub use disabled::*; |
| 14 | 11 | #[cfg(parallel_compiler)] |
| 15 | 12 | pub use enabled::*; |
| 13 | use parking_lot::Mutex; | |
| 14 | ||
| 15 | use crate::sync::IntoDynSyncSend; | |
| 16 | use crate::FatalErrorMarker; | |
| 16 | 17 | |
| 17 | 18 | /// A guard used to hold panics that occur during a parallel section to later by unwound. |
| 18 | 19 | /// This is used for the parallel compiler to prevent fatal errors from non-deterministically |
compiler/rustc_data_structures/src/sync/worker_local.rs+2-3| ... | ... | @@ -1,11 +1,10 @@ |
| 1 | use parking_lot::Mutex; | |
| 2 | use std::cell::Cell; | |
| 3 | use std::cell::OnceCell; | |
| 1 | use std::cell::{Cell, OnceCell}; | |
| 4 | 2 | use std::num::NonZero; |
| 5 | 3 | use std::ops::Deref; |
| 6 | 4 | use std::ptr; |
| 7 | 5 | use std::sync::Arc; |
| 8 | 6 | |
| 7 | use parking_lot::Mutex; | |
| 9 | 8 | #[cfg(parallel_compiler)] |
| 10 | 9 | use {crate::outline, crate::sync::CacheAligned}; |
| 11 | 10 |
compiler/rustc_data_structures/src/tagged_ptr/copy.rs+3-2| ... | ... | @@ -1,5 +1,3 @@ |
| 1 | use super::{Pointer, Tag}; | |
| 2 | use crate::stable_hasher::{HashStable, StableHasher}; | |
| 3 | 1 | use std::fmt; |
| 4 | 2 | use std::hash::{Hash, Hasher}; |
| 5 | 3 | use std::marker::PhantomData; |
| ... | ... | @@ -8,6 +6,9 @@ use std::num::NonZero; |
| 8 | 6 | use std::ops::{Deref, DerefMut}; |
| 9 | 7 | use std::ptr::NonNull; |
| 10 | 8 | |
| 9 | use super::{Pointer, Tag}; | |
| 10 | use crate::stable_hasher::{HashStable, StableHasher}; | |
| 11 | ||
| 11 | 12 | /// A [`Copy`] tagged pointer. |
| 12 | 13 | /// |
| 13 | 14 | /// This is essentially `{ pointer: P, tag: T }` packed in a single pointer. |
compiler/rustc_data_structures/src/tagged_ptr/drop.rs+1-2| ... | ... | @@ -2,8 +2,7 @@ use std::fmt; |
| 2 | 2 | use std::hash::{Hash, Hasher}; |
| 3 | 3 | use std::ops::{Deref, DerefMut}; |
| 4 | 4 | |
| 5 | use super::CopyTaggedPtr; | |
| 6 | use super::{Pointer, Tag}; | |
| 5 | use super::{CopyTaggedPtr, Pointer, Tag}; | |
| 7 | 6 | use crate::stable_hasher::{HashStable, StableHasher}; |
| 8 | 7 | |
| 9 | 8 | /// A tagged pointer that supports pointers that implement [`Drop`]. |
compiler/rustc_data_structures/src/tagged_ptr/drop/tests.rs+2-1| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | use std::{ptr, sync::Arc}; | |
| 1 | use std::ptr; | |
| 2 | use std::sync::Arc; | |
| 2 | 3 | |
| 3 | 4 | use crate::tagged_ptr::{Pointer, Tag, Tag2, TaggedPtr}; |
| 4 | 5 |
compiler/rustc_data_structures/src/temp_dir.rs+1| ... | ... | @@ -1,5 +1,6 @@ |
| 1 | 1 | use std::mem::ManuallyDrop; |
| 2 | 2 | use std::path::Path; |
| 3 | ||
| 3 | 4 | use tempfile::TempDir; |
| 4 | 5 | |
| 5 | 6 | /// This is used to avoid TempDir being dropped on error paths unintentionally. |
compiler/rustc_data_structures/src/transitive_relation.rs+5-3| ... | ... | @@ -1,11 +1,13 @@ |
| 1 | use crate::frozen::Frozen; | |
| 2 | use crate::fx::{FxHashSet, FxIndexSet}; | |
| 3 | use rustc_index::bit_set::BitMatrix; | |
| 4 | 1 | use std::fmt::Debug; |
| 5 | 2 | use std::hash::Hash; |
| 6 | 3 | use std::mem; |
| 7 | 4 | use std::ops::Deref; |
| 8 | 5 | |
| 6 | use rustc_index::bit_set::BitMatrix; | |
| 7 | ||
| 8 | use crate::frozen::Frozen; | |
| 9 | use crate::fx::{FxHashSet, FxIndexSet}; | |
| 10 | ||
| 9 | 11 | #[cfg(test)] |
| 10 | 12 | mod tests; |
| 11 | 13 |
compiler/rustc_data_structures/src/unord.rs+9-13| ... | ... | @@ -2,21 +2,17 @@ |
| 2 | 2 | //! ordering. This is a useful property for deterministic computations, such |
| 3 | 3 | //! as required by the query system. |
| 4 | 4 | |
| 5 | use std::borrow::{Borrow, BorrowMut}; | |
| 6 | use std::collections::hash_map::{Entry, OccupiedError}; | |
| 7 | use std::hash::Hash; | |
| 8 | use std::iter::{Product, Sum}; | |
| 9 | use std::ops::Index; | |
| 10 | ||
| 5 | 11 | use rustc_hash::{FxHashMap, FxHashSet}; |
| 6 | 12 | use rustc_macros::{Decodable_Generic, Encodable_Generic}; |
| 7 | use std::collections::hash_map::OccupiedError; | |
| 8 | use std::{ | |
| 9 | borrow::{Borrow, BorrowMut}, | |
| 10 | collections::hash_map::Entry, | |
| 11 | hash::Hash, | |
| 12 | iter::{Product, Sum}, | |
| 13 | ops::Index, | |
| 14 | }; | |
| 15 | ||
| 16 | use crate::{ | |
| 17 | fingerprint::Fingerprint, | |
| 18 | stable_hasher::{HashStable, StableCompare, StableHasher, ToStableHashKey}, | |
| 19 | }; | |
| 13 | ||
| 14 | use crate::fingerprint::Fingerprint; | |
| 15 | use crate::stable_hasher::{HashStable, StableCompare, StableHasher, ToStableHashKey}; | |
| 20 | 16 | |
| 21 | 17 | /// `UnordItems` is the order-less version of `Iterator`. It only contains methods |
| 22 | 18 | /// that don't (easily) expose an ordering of the underlying items. |
compiler/rustc_data_structures/src/work_queue.rs+2-1| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | use std::collections::VecDeque; | |
| 2 | ||
| 1 | 3 | use rustc_index::bit_set::BitSet; |
| 2 | 4 | use rustc_index::Idx; |
| 3 | use std::collections::VecDeque; | |
| 4 | 5 | |
| 5 | 6 | /// A work queue is a handy data structure for tracking work left to |
| 6 | 7 | /// do. (For example, basic blocks left to process.) It is basically a |
compiler/rustc_driver_impl/src/lib.rs+19-18| ... | ... | @@ -17,8 +17,23 @@ |
| 17 | 17 | #![feature(rustdoc_internals)] |
| 18 | 18 | // tidy-alphabetical-end |
| 19 | 19 | |
| 20 | use std::cmp::max; | |
| 21 | use std::collections::BTreeMap; | |
| 22 | use std::ffi::OsString; | |
| 23 | use std::fmt::Write as _; | |
| 24 | use std::fs::{self, File}; | |
| 25 | use std::io::{self, IsTerminal, Read, Write}; | |
| 26 | use std::panic::{self, catch_unwind, PanicHookInfo}; | |
| 27 | use std::path::PathBuf; | |
| 28 | use std::process::{self, Command, Stdio}; | |
| 29 | use std::sync::atomic::{AtomicBool, Ordering}; | |
| 30 | use std::sync::{Arc, OnceLock}; | |
| 31 | use std::time::{Duration, Instant, SystemTime}; | |
| 32 | use std::{env, str}; | |
| 33 | ||
| 20 | 34 | use rustc_ast as ast; |
| 21 | use rustc_codegen_ssa::{traits::CodegenBackend, CodegenErrors, CodegenResults}; | |
| 35 | use rustc_codegen_ssa::traits::CodegenBackend; | |
| 36 | use rustc_codegen_ssa::{CodegenErrors, CodegenResults}; | |
| 22 | 37 | use rustc_const_eval::CTRL_C_RECEIVED; |
| 23 | 38 | use rustc_data_structures::profiling::{ |
| 24 | 39 | get_resident_set_size, print_time_passes_entry, TimePassesFormat, |
| ... | ... | @@ -35,8 +50,9 @@ use rustc_lint::unerased_lint_store; |
| 35 | 50 | use rustc_metadata::creader::MetadataLoader; |
| 36 | 51 | use rustc_metadata::locator; |
| 37 | 52 | use rustc_parse::{new_parser_from_file, new_parser_from_source_str, unwrap_or_emit_fatal}; |
| 38 | use rustc_session::config::{nightly_options, CG_OPTIONS, Z_OPTIONS}; | |
| 39 | use rustc_session::config::{ErrorOutputType, Input, OutFileName, OutputType}; | |
| 53 | use rustc_session::config::{ | |
| 54 | nightly_options, ErrorOutputType, Input, OutFileName, OutputType, CG_OPTIONS, Z_OPTIONS, | |
| 55 | }; | |
| 40 | 56 | use rustc_session::getopts::{self, Matches}; |
| 41 | 57 | use rustc_session::lint::{Lint, LintId}; |
| 42 | 58 | use rustc_session::output::collect_crate_types; |
| ... | ... | @@ -46,20 +62,6 @@ use rustc_span::symbol::sym; |
| 46 | 62 | use rustc_span::FileName; |
| 47 | 63 | use rustc_target::json::ToJson; |
| 48 | 64 | use rustc_target::spec::{Target, TargetTriple}; |
| 49 | use std::cmp::max; | |
| 50 | use std::collections::BTreeMap; | |
| 51 | use std::env; | |
| 52 | use std::ffi::OsString; | |
| 53 | use std::fmt::Write as _; | |
| 54 | use std::fs::{self, File}; | |
| 55 | use std::io::{self, IsTerminal, Read, Write}; | |
| 56 | use std::panic::{self, catch_unwind, PanicHookInfo}; | |
| 57 | use std::path::PathBuf; | |
| 58 | use std::process::{self, Command, Stdio}; | |
| 59 | use std::str; | |
| 60 | use std::sync::atomic::{AtomicBool, Ordering}; | |
| 61 | use std::sync::{Arc, OnceLock}; | |
| 62 | use std::time::{Duration, Instant, SystemTime}; | |
| 63 | 65 | use time::OffsetDateTime; |
| 64 | 66 | use tracing::trace; |
| 65 | 67 | |
| ... | ... | @@ -689,7 +691,6 @@ fn print_crate_info( |
| 689 | 691 | parse_attrs: bool, |
| 690 | 692 | ) -> Compilation { |
| 691 | 693 | use rustc_session::config::PrintKind::*; |
| 692 | ||
| 693 | 694 | // This import prevents the following code from using the printing macros |
| 694 | 695 | // used by the rest of the module. Within this function, we only write to |
| 695 | 696 | // the output specified by `sess.io.output_file`. |
compiler/rustc_driver_impl/src/pretty.rs+4-4| ... | ... | @@ -1,9 +1,10 @@ |
| 1 | 1 | //! The various pretty-printing routines. |
| 2 | 2 | |
| 3 | use rustc_ast as ast; | |
| 3 | use std::cell::Cell; | |
| 4 | use std::fmt::Write; | |
| 5 | ||
| 4 | 6 | use rustc_ast_pretty::pprust as pprust_ast; |
| 5 | 7 | use rustc_errors::FatalError; |
| 6 | use rustc_hir_pretty as pprust_hir; | |
| 7 | 8 | use rustc_middle::bug; |
| 8 | 9 | use rustc_middle::mir::{write_mir_graphviz, write_mir_pretty}; |
| 9 | 10 | use rustc_middle::ty::{self, TyCtxt}; |
| ... | ... | @@ -12,9 +13,8 @@ use rustc_session::Session; |
| 12 | 13 | use rustc_smir::rustc_internal::pretty::write_smir_pretty; |
| 13 | 14 | use rustc_span::symbol::Ident; |
| 14 | 15 | use rustc_span::FileName; |
| 15 | use std::cell::Cell; | |
| 16 | use std::fmt::Write; | |
| 17 | 16 | use tracing::debug; |
| 17 | use {rustc_ast as ast, rustc_hir_pretty as pprust_hir}; | |
| 18 | 18 | |
| 19 | 19 | pub use self::PpMode::*; |
| 20 | 20 | pub use self::PpSourceMode::*; |
compiler/rustc_driver_impl/src/signal_handler.rs+2-1| ... | ... | @@ -1,10 +1,11 @@ |
| 1 | 1 | //! Signal handler for rustc |
| 2 | 2 | //! Primarily used to extract a backtrace from stack overflow |
| 3 | 3 | |
| 4 | use rustc_interface::util::{DEFAULT_STACK_SIZE, STACK_SIZE}; | |
| 5 | 4 | use std::alloc::{alloc, Layout}; |
| 6 | 5 | use std::{fmt, mem, ptr}; |
| 7 | 6 | |
| 7 | use rustc_interface::util::{DEFAULT_STACK_SIZE, STACK_SIZE}; | |
| 8 | ||
| 8 | 9 | extern "C" { |
| 9 | 10 | fn backtrace_symbols_fd(buffer: *const *mut libc::c_void, size: libc::c_int, fd: libc::c_int); |
| 10 | 11 | } |
compiler/rustc_error_messages/src/lib.rs+12-15| ... | ... | @@ -6,31 +6,28 @@ |
| 6 | 6 | #![feature(type_alias_impl_trait)] |
| 7 | 7 | // tidy-alphabetical-end |
| 8 | 8 | |
| 9 | use fluent_bundle::FluentResource; | |
| 10 | use fluent_syntax::parser::ParserError; | |
| 11 | use icu_provider_adapters::fallback::{LocaleFallbackProvider, LocaleFallbacker}; | |
| 12 | use rustc_data_structures::sync::{IntoDynSyncSend, Lrc}; | |
| 13 | use rustc_macros::{Decodable, Encodable}; | |
| 14 | use rustc_span::Span; | |
| 15 | 9 | use std::borrow::Cow; |
| 16 | use std::error::Error; | |
| 17 | use std::fmt; | |
| 18 | use std::fs; | |
| 19 | use std::io; | |
| 20 | use std::path::{Path, PathBuf}; | |
| 21 | use tracing::{instrument, trace}; | |
| 22 | ||
| 23 | 10 | #[cfg(not(parallel_compiler))] |
| 24 | 11 | use std::cell::LazyCell as Lazy; |
| 12 | use std::error::Error; | |
| 13 | use std::path::{Path, PathBuf}; | |
| 25 | 14 | #[cfg(parallel_compiler)] |
| 26 | 15 | use std::sync::LazyLock as Lazy; |
| 16 | use std::{fmt, fs, io}; | |
| 27 | 17 | |
| 18 | pub use fluent_bundle::types::FluentType; | |
| 19 | use fluent_bundle::FluentResource; | |
| 20 | pub use fluent_bundle::{self, FluentArgs, FluentError, FluentValue}; | |
| 21 | use fluent_syntax::parser::ParserError; | |
| 22 | use icu_provider_adapters::fallback::{LocaleFallbackProvider, LocaleFallbacker}; | |
| 28 | 23 | #[cfg(parallel_compiler)] |
| 29 | 24 | use intl_memoizer::concurrent::IntlLangMemoizer; |
| 30 | 25 | #[cfg(not(parallel_compiler))] |
| 31 | 26 | use intl_memoizer::IntlLangMemoizer; |
| 32 | ||
| 33 | pub use fluent_bundle::{self, types::FluentType, FluentArgs, FluentError, FluentValue}; | |
| 27 | use rustc_data_structures::sync::{IntoDynSyncSend, Lrc}; | |
| 28 | use rustc_macros::{Decodable, Encodable}; | |
| 29 | use rustc_span::Span; | |
| 30 | use tracing::{instrument, trace}; | |
| 34 | 31 | pub use unic_langid::{langid, LanguageIdentifier}; |
| 35 | 32 | |
| 36 | 33 | pub type FluentBundle = |
compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs+6-5| ... | ... | @@ -5,6 +5,12 @@ |
| 5 | 5 | //! |
| 6 | 6 | //! [annotate_snippets]: https://docs.rs/crate/annotate-snippets/ |
| 7 | 7 | |
| 8 | use annotate_snippets::{Annotation, AnnotationType, Renderer, Slice, Snippet, SourceAnnotation}; | |
| 9 | use rustc_data_structures::sync::Lrc; | |
| 10 | use rustc_error_messages::FluentArgs; | |
| 11 | use rustc_span::source_map::SourceMap; | |
| 12 | use rustc_span::SourceFile; | |
| 13 | ||
| 8 | 14 | use crate::emitter::FileWithAnnotatedLines; |
| 9 | 15 | use crate::snippet::Line; |
| 10 | 16 | use crate::translation::{to_fluent_args, Translate}; |
| ... | ... | @@ -12,11 +18,6 @@ use crate::{ |
| 12 | 18 | CodeSuggestion, DiagInner, DiagMessage, Emitter, ErrCode, FluentBundle, LazyFallbackBundle, |
| 13 | 19 | Level, MultiSpan, Style, Subdiag, |
| 14 | 20 | }; |
| 15 | use annotate_snippets::{Annotation, AnnotationType, Renderer, Slice, Snippet, SourceAnnotation}; | |
| 16 | use rustc_data_structures::sync::Lrc; | |
| 17 | use rustc_error_messages::FluentArgs; | |
| 18 | use rustc_span::source_map::SourceMap; | |
| 19 | use rustc_span::SourceFile; | |
| 20 | 21 | |
| 21 | 22 | /// Generates diagnostics using annotate-snippet |
| 22 | 23 | pub struct AnnotateSnippetEmitter { |
compiler/rustc_errors/src/diagnostic.rs+14-13| ... | ... | @@ -1,16 +1,3 @@ |
| 1 | use crate::snippet::Style; | |
| 2 | use crate::{ | |
| 3 | CodeSuggestion, DiagCtxtHandle, DiagMessage, ErrCode, ErrorGuaranteed, ExplicitBug, Level, | |
| 4 | MultiSpan, StashKey, SubdiagMessage, Substitution, SubstitutionPart, SuggestionStyle, | |
| 5 | }; | |
| 6 | use rustc_data_structures::fx::FxIndexMap; | |
| 7 | use rustc_error_messages::fluent_value_from_str_list_sep_by_and; | |
| 8 | use rustc_error_messages::FluentValue; | |
| 9 | use rustc_lint_defs::{Applicability, LintExpectationId}; | |
| 10 | use rustc_macros::{Decodable, Encodable}; | |
| 11 | use rustc_span::source_map::Spanned; | |
| 12 | use rustc_span::symbol::Symbol; | |
| 13 | use rustc_span::{Span, DUMMY_SP}; | |
| 14 | 1 | use std::borrow::Cow; |
| 15 | 2 | use std::fmt::{self, Debug}; |
| 16 | 3 | use std::hash::{Hash, Hasher}; |
| ... | ... | @@ -18,8 +5,22 @@ use std::marker::PhantomData; |
| 18 | 5 | use std::ops::{Deref, DerefMut}; |
| 19 | 6 | use std::panic; |
| 20 | 7 | use std::thread::panicking; |
| 8 | ||
| 9 | use rustc_data_structures::fx::FxIndexMap; | |
| 10 | use rustc_error_messages::{fluent_value_from_str_list_sep_by_and, FluentValue}; | |
| 11 | use rustc_lint_defs::{Applicability, LintExpectationId}; | |
| 12 | use rustc_macros::{Decodable, Encodable}; | |
| 13 | use rustc_span::source_map::Spanned; | |
| 14 | use rustc_span::symbol::Symbol; | |
| 15 | use rustc_span::{Span, DUMMY_SP}; | |
| 21 | 16 | use tracing::debug; |
| 22 | 17 | |
| 18 | use crate::snippet::Style; | |
| 19 | use crate::{ | |
| 20 | CodeSuggestion, DiagCtxtHandle, DiagMessage, ErrCode, ErrorGuaranteed, ExplicitBug, Level, | |
| 21 | MultiSpan, StashKey, SubdiagMessage, Substitution, SubstitutionPart, SuggestionStyle, | |
| 22 | }; | |
| 23 | ||
| 23 | 24 | /// Error type for `DiagInner`'s `suggestions` field, indicating that |
| 24 | 25 | /// `.disable_suggestions()` was called on the `DiagInner`. |
| 25 | 26 | #[derive(Clone, Debug, PartialEq, Eq, Hash, Encodable, Decodable)] |
compiler/rustc_errors/src/diagnostic_impls.rs+14-14| ... | ... | @@ -1,12 +1,11 @@ |
| 1 | use crate::diagnostic::DiagLocation; | |
| 2 | use crate::{fluent_generated as fluent, DiagCtxtHandle, Subdiagnostic}; | |
| 3 | use crate::{ | |
| 4 | Diag, DiagArgValue, Diagnostic, EmissionGuarantee, ErrCode, IntoDiagArg, Level, | |
| 5 | SubdiagMessageOp, | |
| 6 | }; | |
| 7 | use rustc_ast as ast; | |
| 1 | use std::backtrace::Backtrace; | |
| 2 | use std::borrow::Cow; | |
| 3 | use std::fmt; | |
| 4 | use std::num::ParseIntError; | |
| 5 | use std::path::{Path, PathBuf}; | |
| 6 | use std::process::ExitStatus; | |
| 7 | ||
| 8 | 8 | use rustc_ast_pretty::pprust; |
| 9 | use rustc_hir as hir; | |
| 10 | 9 | use rustc_macros::Subdiagnostic; |
| 11 | 10 | use rustc_span::edition::Edition; |
| 12 | 11 | use rustc_span::symbol::{Ident, MacroRulesNormalizedIdent, Symbol}; |
| ... | ... | @@ -14,12 +13,13 @@ use rustc_span::Span; |
| 14 | 13 | use rustc_target::abi::TargetDataLayoutErrors; |
| 15 | 14 | use rustc_target::spec::{PanicStrategy, SplitDebuginfo, StackProtector, TargetTriple}; |
| 16 | 15 | use rustc_type_ir::{ClosureKind, FloatTy}; |
| 17 | use std::backtrace::Backtrace; | |
| 18 | use std::borrow::Cow; | |
| 19 | use std::fmt; | |
| 20 | use std::num::ParseIntError; | |
| 21 | use std::path::{Path, PathBuf}; | |
| 22 | use std::process::ExitStatus; | |
| 16 | use {rustc_ast as ast, rustc_hir as hir}; | |
| 17 | ||
| 18 | use crate::diagnostic::DiagLocation; | |
| 19 | use crate::{ | |
| 20 | fluent_generated as fluent, Diag, DiagArgValue, DiagCtxtHandle, Diagnostic, EmissionGuarantee, | |
| 21 | ErrCode, IntoDiagArg, Level, SubdiagMessageOp, Subdiagnostic, | |
| 22 | }; | |
| 23 | 23 | |
| 24 | 24 | pub struct DiagArgFromDisplay<'a>(pub &'a dyn fmt::Display); |
| 25 | 25 |
compiler/rustc_errors/src/emitter.rs+19-19| ... | ... | @@ -7,35 +7,35 @@ |
| 7 | 7 | //! |
| 8 | 8 | //! The output types are defined in `rustc_session::config::ErrorOutputType`. |
| 9 | 9 | |
| 10 | use std::borrow::Cow; | |
| 11 | use std::cmp::{max, min, Reverse}; | |
| 12 | use std::error::Report; | |
| 13 | use std::io::prelude::*; | |
| 14 | use std::io::{self, IsTerminal}; | |
| 15 | use std::iter; | |
| 16 | use std::path::Path; | |
| 17 | ||
| 18 | use derive_setters::Setters; | |
| 19 | use rustc_data_structures::fx::{FxHashMap, FxIndexMap, FxIndexSet}; | |
| 20 | use rustc_data_structures::sync::{DynSend, IntoDynSyncSend, Lrc}; | |
| 21 | use rustc_error_messages::{FluentArgs, SpanLabel}; | |
| 22 | use rustc_lint_defs::pluralize; | |
| 23 | use rustc_span::hygiene::{ExpnKind, MacroKind}; | |
| 10 | 24 | use rustc_span::source_map::SourceMap; |
| 11 | 25 | use rustc_span::{char_width, FileLines, FileName, SourceFile, Span}; |
| 26 | use termcolor::{Buffer, BufferWriter, Color, ColorChoice, ColorSpec, StandardStream, WriteColor}; | |
| 27 | use tracing::{debug, instrument, trace, warn}; | |
| 12 | 28 | |
| 29 | use crate::diagnostic::DiagLocation; | |
| 13 | 30 | use crate::snippet::{ |
| 14 | 31 | Annotation, AnnotationColumn, AnnotationType, Line, MultilineAnnotation, Style, StyledString, |
| 15 | 32 | }; |
| 16 | 33 | use crate::styled_buffer::StyledBuffer; |
| 17 | 34 | use crate::translation::{to_fluent_args, Translate}; |
| 18 | 35 | use crate::{ |
| 19 | diagnostic::DiagLocation, CodeSuggestion, DiagCtxt, DiagInner, DiagMessage, ErrCode, | |
| 20 | FluentBundle, LazyFallbackBundle, Level, MultiSpan, Subdiag, SubstitutionHighlight, | |
| 21 | SuggestionStyle, TerminalUrl, | |
| 36 | CodeSuggestion, DiagCtxt, DiagInner, DiagMessage, ErrCode, FluentBundle, LazyFallbackBundle, | |
| 37 | Level, MultiSpan, Subdiag, SubstitutionHighlight, SuggestionStyle, TerminalUrl, | |
| 22 | 38 | }; |
| 23 | use derive_setters::Setters; | |
| 24 | use rustc_data_structures::fx::{FxHashMap, FxIndexMap, FxIndexSet}; | |
| 25 | use rustc_data_structures::sync::{DynSend, IntoDynSyncSend, Lrc}; | |
| 26 | use rustc_error_messages::{FluentArgs, SpanLabel}; | |
| 27 | use rustc_lint_defs::pluralize; | |
| 28 | use rustc_span::hygiene::{ExpnKind, MacroKind}; | |
| 29 | use std::borrow::Cow; | |
| 30 | use std::cmp::{max, min, Reverse}; | |
| 31 | use std::error::Report; | |
| 32 | use std::io::prelude::*; | |
| 33 | use std::io::{self, IsTerminal}; | |
| 34 | use std::iter; | |
| 35 | use std::path::Path; | |
| 36 | use termcolor::{Buffer, BufferWriter, ColorChoice, ColorSpec, StandardStream}; | |
| 37 | use termcolor::{Color, WriteColor}; | |
| 38 | use tracing::{debug, instrument, trace, warn}; | |
| 39 | 39 | |
| 40 | 40 | /// Default column width, used in tests and when terminal dimensions cannot be determined. |
| 41 | 41 | const DEFAULT_COLUMN_WIDTH: usize = 140; |
compiler/rustc_errors/src/error.rs+3-4| ... | ... | @@ -1,11 +1,10 @@ |
| 1 | use rustc_error_messages::{ | |
| 2 | fluent_bundle::resolver::errors::{ReferenceKind, ResolverError}, | |
| 3 | FluentArgs, FluentError, | |
| 4 | }; | |
| 5 | 1 | use std::borrow::Cow; |
| 6 | 2 | use std::error::Error; |
| 7 | 3 | use std::fmt; |
| 8 | 4 | |
| 5 | use rustc_error_messages::fluent_bundle::resolver::errors::{ReferenceKind, ResolverError}; | |
| 6 | use rustc_error_messages::{FluentArgs, FluentError}; | |
| 7 | ||
| 9 | 8 | #[derive(Debug)] |
| 10 | 9 | pub enum TranslateError<'args> { |
| 11 | 10 | One { |
compiler/rustc_errors/src/json.rs+17-15| ... | ... | @@ -9,16 +9,12 @@ |
| 9 | 9 | |
| 10 | 10 | // FIXME: spec the JSON output properly. |
| 11 | 11 | |
| 12 | use crate::emitter::{ | |
| 13 | should_show_source_code, ColorConfig, Destination, Emitter, HumanEmitter, | |
| 14 | HumanReadableErrorType, | |
| 15 | }; | |
| 16 | use crate::registry::Registry; | |
| 17 | use crate::translation::{to_fluent_args, Translate}; | |
| 18 | use crate::{ | |
| 19 | diagnostic::IsLint, CodeSuggestion, FluentBundle, LazyFallbackBundle, MultiSpan, SpanLabel, | |
| 20 | Subdiag, TerminalUrl, | |
| 21 | }; | |
| 12 | use std::error::Report; | |
| 13 | use std::io::{self, Write}; | |
| 14 | use std::path::Path; | |
| 15 | use std::sync::{Arc, Mutex}; | |
| 16 | use std::vec; | |
| 17 | ||
| 22 | 18 | use derive_setters::Setters; |
| 23 | 19 | use rustc_data_structures::sync::{IntoDynSyncSend, Lrc}; |
| 24 | 20 | use rustc_error_messages::FluentArgs; |
| ... | ... | @@ -27,13 +23,19 @@ use rustc_span::hygiene::ExpnData; |
| 27 | 23 | use rustc_span::source_map::SourceMap; |
| 28 | 24 | use rustc_span::Span; |
| 29 | 25 | use serde::Serialize; |
| 30 | use std::error::Report; | |
| 31 | use std::io::{self, Write}; | |
| 32 | use std::path::Path; | |
| 33 | use std::sync::{Arc, Mutex}; | |
| 34 | use std::vec; | |
| 35 | 26 | use termcolor::{ColorSpec, WriteColor}; |
| 36 | 27 | |
| 28 | use crate::diagnostic::IsLint; | |
| 29 | use crate::emitter::{ | |
| 30 | should_show_source_code, ColorConfig, Destination, Emitter, HumanEmitter, | |
| 31 | HumanReadableErrorType, | |
| 32 | }; | |
| 33 | use crate::registry::Registry; | |
| 34 | use crate::translation::{to_fluent_args, Translate}; | |
| 35 | use crate::{ | |
| 36 | CodeSuggestion, FluentBundle, LazyFallbackBundle, MultiSpan, SpanLabel, Subdiag, TerminalUrl, | |
| 37 | }; | |
| 38 | ||
| 37 | 39 | #[cfg(test)] |
| 38 | 40 | mod tests; |
| 39 | 41 |
compiler/rustc_errors/src/json/tests.rs+4-5| ... | ... | @@ -1,13 +1,12 @@ |
| 1 | use super::*; | |
| 1 | use std::str; | |
| 2 | 2 | |
| 3 | use crate::DiagCtxt; | |
| 4 | 3 | use rustc_span::source_map::FilePathMapping; |
| 5 | 4 | use rustc_span::BytePos; |
| 6 | ||
| 7 | use std::str; | |
| 8 | ||
| 9 | 5 | use serde::Deserialize; |
| 10 | 6 | |
| 7 | use super::*; | |
| 8 | use crate::DiagCtxt; | |
| 9 | ||
| 11 | 10 | #[derive(Deserialize, Debug, PartialEq, Eq)] |
| 12 | 11 | struct TestData { |
| 13 | 12 | spans: Vec<SpanTestData>, |
compiler/rustc_errors/src/lib.rs+21-24| ... | ... | @@ -28,6 +28,17 @@ |
| 28 | 28 | |
| 29 | 29 | extern crate self as rustc_errors; |
| 30 | 30 | |
| 31 | use std::backtrace::{Backtrace, BacktraceStatus}; | |
| 32 | use std::borrow::Cow; | |
| 33 | use std::cell::Cell; | |
| 34 | use std::error::Report; | |
| 35 | use std::hash::Hash; | |
| 36 | use std::io::Write; | |
| 37 | use std::num::NonZero; | |
| 38 | use std::ops::DerefMut; | |
| 39 | use std::path::{Path, PathBuf}; | |
| 40 | use std::{fmt, panic}; | |
| 41 | ||
| 31 | 42 | pub use codes::*; |
| 32 | 43 | pub use diagnostic::{ |
| 33 | 44 | BugAbort, Diag, DiagArg, DiagArgMap, DiagArgName, DiagArgValue, DiagInner, DiagStyledString, |
| ... | ... | @@ -39,42 +50,28 @@ pub use diagnostic_impls::{ |
| 39 | 50 | IndicateAnonymousLifetime, SingleLabelManySpans, |
| 40 | 51 | }; |
| 41 | 52 | pub use emitter::ColorConfig; |
| 53 | use emitter::{is_case_difference, DynEmitter, Emitter}; | |
| 54 | use registry::Registry; | |
| 55 | use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet}; | |
| 56 | use rustc_data_structures::stable_hasher::{Hash128, StableHasher}; | |
| 57 | use rustc_data_structures::sync::{Lock, Lrc}; | |
| 58 | use rustc_data_structures::AtomicRef; | |
| 42 | 59 | pub use rustc_error_messages::{ |
| 43 | 60 | fallback_fluent_bundle, fluent_bundle, DiagMessage, FluentBundle, LanguageIdentifier, |
| 44 | 61 | LazyFallbackBundle, MultiSpan, SpanLabel, SubdiagMessage, |
| 45 | 62 | }; |
| 63 | use rustc_lint_defs::LintExpectationId; | |
| 46 | 64 | pub use rustc_lint_defs::{pluralize, Applicability}; |
| 65 | use rustc_macros::{Decodable, Encodable}; | |
| 47 | 66 | pub use rustc_span::fatal_error::{FatalError, FatalErrorMarker}; |
| 67 | use rustc_span::source_map::SourceMap; | |
| 48 | 68 | pub use rustc_span::ErrorGuaranteed; |
| 69 | use rustc_span::{Loc, Span, DUMMY_SP}; | |
| 49 | 70 | pub use snippet::Style; |
| 50 | ||
| 51 | 71 | // Used by external projects such as `rust-gpu`. |
| 52 | 72 | // See https://github.com/rust-lang/rust/pull/115393. |
| 53 | 73 | pub use termcolor::{Color, ColorSpec, WriteColor}; |
| 54 | ||
| 55 | use emitter::{is_case_difference, DynEmitter, Emitter}; | |
| 56 | use registry::Registry; | |
| 57 | use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet}; | |
| 58 | use rustc_data_structures::stable_hasher::{Hash128, StableHasher}; | |
| 59 | use rustc_data_structures::sync::{Lock, Lrc}; | |
| 60 | use rustc_data_structures::AtomicRef; | |
| 61 | use rustc_lint_defs::LintExpectationId; | |
| 62 | use rustc_macros::{Decodable, Encodable}; | |
| 63 | use rustc_span::source_map::SourceMap; | |
| 64 | use rustc_span::{Loc, Span, DUMMY_SP}; | |
| 65 | use std::backtrace::{Backtrace, BacktraceStatus}; | |
| 66 | use std::borrow::Cow; | |
| 67 | use std::cell::Cell; | |
| 68 | use std::error::Report; | |
| 69 | use std::fmt; | |
| 70 | use std::hash::Hash; | |
| 71 | use std::io::Write; | |
| 72 | use std::num::NonZero; | |
| 73 | use std::ops::DerefMut; | |
| 74 | use std::panic; | |
| 75 | use std::path::{Path, PathBuf}; | |
| 76 | 74 | use tracing::debug; |
| 77 | ||
| 78 | 75 | use Level::*; |
| 79 | 76 | |
| 80 | 77 | pub mod annotate_snippet_emitter_writer; |
compiler/rustc_errors/src/lock.rs+4-4| ... | ... | @@ -16,10 +16,10 @@ pub fn acquire_global_lock(name: &str) -> Box<dyn Any> { |
| 16 | 16 | use std::ffi::CString; |
| 17 | 17 | use std::io; |
| 18 | 18 | |
| 19 | use windows::{ | |
| 20 | core::PCSTR, | |
| 21 | Win32::Foundation::{CloseHandle, HANDLE, WAIT_ABANDONED, WAIT_OBJECT_0}, | |
| 22 | Win32::System::Threading::{CreateMutexA, ReleaseMutex, WaitForSingleObject, INFINITE}, | |
| 19 | use windows::core::PCSTR; | |
| 20 | use windows::Win32::Foundation::{CloseHandle, HANDLE, WAIT_ABANDONED, WAIT_OBJECT_0}; | |
| 21 | use windows::Win32::System::Threading::{ | |
| 22 | CreateMutexA, ReleaseMutex, WaitForSingleObject, INFINITE, | |
| 23 | 23 | }; |
| 24 | 24 | |
| 25 | 25 | struct Handle(HANDLE); |
compiler/rustc_errors/src/markdown/parse.rs+2-1| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | use crate::markdown::{MdStream, MdTree}; | |
| 2 | 1 | use std::{iter, mem, str}; |
| 3 | 2 | |
| 3 | use crate::markdown::{MdStream, MdTree}; | |
| 4 | ||
| 4 | 5 | /// Short aliases that we can use in match patterns. If an end pattern is not |
| 5 | 6 | /// included, this type may be variable |
| 6 | 7 | const ANC_E: &[u8] = b">"; |
compiler/rustc_errors/src/markdown/tests/parse.rs+2-1| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | use super::*; | |
| 2 | 1 | use ParseOpt as PO; |
| 3 | 2 | |
| 3 | use super::*; | |
| 4 | ||
| 4 | 5 | #[test] |
| 5 | 6 | fn test_parse_simple() { |
| 6 | 7 | let buf = "**abcd** rest"; |
compiler/rustc_errors/src/markdown/tests/term.rs+1| ... | ... | @@ -1,5 +1,6 @@ |
| 1 | 1 | use std::io::BufWriter; |
| 2 | 2 | use std::path::PathBuf; |
| 3 | ||
| 3 | 4 | use termcolor::{BufferWriter, ColorChoice}; |
| 4 | 5 | |
| 5 | 6 | use super::*; |
compiler/rustc_errors/src/registry.rs+2-1| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | use crate::ErrCode; | |
| 2 | 1 | use rustc_data_structures::fx::FxHashMap; |
| 3 | 2 | |
| 3 | use crate::ErrCode; | |
| 4 | ||
| 4 | 5 | #[derive(Debug)] |
| 5 | 6 | pub struct InvalidErrorCode; |
| 6 | 7 |
compiler/rustc_errors/src/snippet.rs+2-1| ... | ... | @@ -1,8 +1,9 @@ |
| 1 | 1 | // Code for annotating snippets. |
| 2 | 2 | |
| 3 | use crate::{Level, Loc}; | |
| 4 | 3 | use rustc_macros::{Decodable, Encodable}; |
| 5 | 4 | |
| 5 | use crate::{Level, Loc}; | |
| 6 | ||
| 6 | 7 | #[derive(Clone, Debug, PartialOrd, Ord, PartialEq, Eq)] |
| 7 | 8 | pub struct Line { |
| 8 | 9 | pub line_index: usize, |
compiler/rustc_errors/src/tests.rs+4-4| ... | ... | @@ -1,11 +1,11 @@ |
| 1 | use rustc_data_structures::sync::{IntoDynSyncSend, Lrc}; | |
| 2 | use rustc_error_messages::fluent_bundle::resolver::errors::{ReferenceKind, ResolverError}; | |
| 3 | use rustc_error_messages::{langid, DiagMessage}; | |
| 4 | ||
| 1 | 5 | use crate::error::{TranslateError, TranslateErrorKind}; |
| 2 | 6 | use crate::fluent_bundle::*; |
| 3 | 7 | use crate::translation::Translate; |
| 4 | 8 | use crate::FluentBundle; |
| 5 | use rustc_data_structures::sync::{IntoDynSyncSend, Lrc}; | |
| 6 | use rustc_error_messages::fluent_bundle::resolver::errors::{ReferenceKind, ResolverError}; | |
| 7 | use rustc_error_messages::langid; | |
| 8 | use rustc_error_messages::DiagMessage; | |
| 9 | 9 | |
| 10 | 10 | struct Dummy { |
| 11 | 11 | bundle: FluentBundle, |
compiler/rustc_errors/src/translation.rs+7-5| ... | ... | @@ -1,13 +1,15 @@ |
| 1 | use crate::error::{TranslateError, TranslateErrorKind}; | |
| 2 | use crate::snippet::Style; | |
| 3 | use crate::{DiagArg, DiagMessage, FluentBundle}; | |
| 4 | use rustc_data_structures::sync::Lrc; | |
| 5 | pub use rustc_error_messages::FluentArgs; | |
| 6 | 1 | use std::borrow::Cow; |
| 7 | 2 | use std::env; |
| 8 | 3 | use std::error::Report; |
| 4 | ||
| 5 | use rustc_data_structures::sync::Lrc; | |
| 6 | pub use rustc_error_messages::FluentArgs; | |
| 9 | 7 | use tracing::{debug, trace}; |
| 10 | 8 | |
| 9 | use crate::error::{TranslateError, TranslateErrorKind}; | |
| 10 | use crate::snippet::Style; | |
| 11 | use crate::{DiagArg, DiagMessage, FluentBundle}; | |
| 12 | ||
| 11 | 13 | /// Convert diagnostic arguments (a rustc internal type that exists to implement |
| 12 | 14 | /// `Encodable`/`Decodable`) into `FluentArgs` which is necessary to perform translation. |
| 13 | 15 | /// |
compiler/rustc_expand/src/base.rs+13-10| ... | ... | @@ -1,7 +1,7 @@ |
| 1 | use crate::base::ast::NestedMetaItem; | |
| 2 | use crate::errors; | |
| 3 | use crate::expand::{self, AstFragment, Invocation}; | |
| 4 | use crate::module::DirOwnership; | |
| 1 | use std::default::Default; | |
| 2 | use std::iter; | |
| 3 | use std::path::{Path, PathBuf}; | |
| 4 | use std::rc::Rc; | |
| 5 | 5 | |
| 6 | 6 | use rustc_ast::attr::MarkedAttrs; |
| 7 | 7 | use rustc_ast::ptr::P; |
| ... | ... | @@ -15,9 +15,11 @@ use rustc_data_structures::sync::{self, Lrc}; |
| 15 | 15 | use rustc_errors::{DiagCtxtHandle, ErrorGuaranteed, PResult}; |
| 16 | 16 | use rustc_feature::Features; |
| 17 | 17 | use rustc_lint_defs::{BufferedEarlyLint, RegisteredTools}; |
| 18 | use rustc_parse::{parser::Parser, MACRO_ARGUMENTS}; | |
| 18 | use rustc_parse::parser::Parser; | |
| 19 | use rustc_parse::MACRO_ARGUMENTS; | |
| 19 | 20 | use rustc_session::config::CollapseMacroDebuginfo; |
| 20 | use rustc_session::{parse::ParseSess, Limit, Session}; | |
| 21 | use rustc_session::parse::ParseSess; | |
| 22 | use rustc_session::{Limit, Session}; | |
| 21 | 23 | use rustc_span::def_id::{CrateNum, DefId, LocalDefId}; |
| 22 | 24 | use rustc_span::edition::Edition; |
| 23 | 25 | use rustc_span::hygiene::{AstPass, ExpnData, ExpnKind, LocalExpnId, MacroKind}; |
| ... | ... | @@ -25,12 +27,13 @@ use rustc_span::source_map::SourceMap; |
| 25 | 27 | use rustc_span::symbol::{kw, sym, Ident, Symbol}; |
| 26 | 28 | use rustc_span::{FileName, Span, DUMMY_SP}; |
| 27 | 29 | use smallvec::{smallvec, SmallVec}; |
| 28 | use std::default::Default; | |
| 29 | use std::iter; | |
| 30 | use std::path::{Path, PathBuf}; | |
| 31 | use std::rc::Rc; | |
| 32 | 30 | use thin_vec::ThinVec; |
| 33 | 31 | |
| 32 | use crate::base::ast::NestedMetaItem; | |
| 33 | use crate::errors; | |
| 34 | use crate::expand::{self, AstFragment, Invocation}; | |
| 35 | use crate::module::DirOwnership; | |
| 36 | ||
| 34 | 37 | // When adding new variants, make sure to |
| 35 | 38 | // adjust the `visit_*` / `flat_map_*` calls in `InvocationCollector` |
| 36 | 39 | // to use `assign_id!` |
compiler/rustc_expand/src/build.rs+6-3| ... | ... | @@ -1,12 +1,15 @@ |
| 1 | use crate::base::ExtCtxt; | |
| 2 | 1 | use rustc_ast::ptr::P; |
| 3 | use rustc_ast::{self as ast, AttrVec, BlockCheckMode, Expr, LocalKind, MatchKind, PatKind, UnOp}; | |
| 4 | use rustc_ast::{attr, token, util::literal}; | |
| 2 | use rustc_ast::util::literal; | |
| 3 | use rustc_ast::{ | |
| 4 | self as ast, attr, token, AttrVec, BlockCheckMode, Expr, LocalKind, MatchKind, PatKind, UnOp, | |
| 5 | }; | |
| 5 | 6 | use rustc_span::source_map::Spanned; |
| 6 | 7 | use rustc_span::symbol::{kw, sym, Ident, Symbol}; |
| 7 | 8 | use rustc_span::{Span, DUMMY_SP}; |
| 8 | 9 | use thin_vec::{thin_vec, ThinVec}; |
| 9 | 10 | |
| 11 | use crate::base::ExtCtxt; | |
| 12 | ||
| 10 | 13 | impl<'a> ExtCtxt<'a> { |
| 11 | 14 | pub fn path(&self, span: Span, strs: Vec<Ident>) -> ast::Path { |
| 12 | 15 | self.path_all(span, false, strs, vec![]) |
compiler/rustc_expand/src/config.rs+10-10| ... | ... | @@ -1,19 +1,14 @@ |
| 1 | 1 | //! Conditional compilation stripping. |
| 2 | 2 | |
| 3 | use crate::errors::{ | |
| 4 | FeatureNotAllowed, FeatureRemoved, FeatureRemovedReason, InvalidCfg, MalformedFeatureAttribute, | |
| 5 | MalformedFeatureAttributeHelp, RemoveExprNotSupported, | |
| 6 | }; | |
| 7 | 3 | use rustc_ast::ptr::P; |
| 8 | 4 | use rustc_ast::token::{Delimiter, Token, TokenKind}; |
| 9 | use rustc_ast::tokenstream::{AttrTokenStream, AttrTokenTree, Spacing}; | |
| 10 | use rustc_ast::tokenstream::{LazyAttrTokenStream, TokenTree}; | |
| 11 | use rustc_ast::NodeId; | |
| 12 | use rustc_ast::{self as ast, AttrStyle, Attribute, HasAttrs, HasTokens, MetaItem}; | |
| 5 | use rustc_ast::tokenstream::{ | |
| 6 | AttrTokenStream, AttrTokenTree, LazyAttrTokenStream, Spacing, TokenTree, | |
| 7 | }; | |
| 8 | use rustc_ast::{self as ast, AttrStyle, Attribute, HasAttrs, HasTokens, MetaItem, NodeId}; | |
| 13 | 9 | use rustc_attr as attr; |
| 14 | 10 | use rustc_data_structures::flat_map_in_place::FlatMapInPlace; |
| 15 | use rustc_feature::Features; | |
| 16 | use rustc_feature::{ACCEPTED_FEATURES, REMOVED_FEATURES, UNSTABLE_FEATURES}; | |
| 11 | use rustc_feature::{Features, ACCEPTED_FEATURES, REMOVED_FEATURES, UNSTABLE_FEATURES}; | |
| 17 | 12 | use rustc_lint_defs::BuiltinLintDiag; |
| 18 | 13 | use rustc_parse::validate_attr; |
| 19 | 14 | use rustc_session::parse::feature_err; |
| ... | ... | @@ -23,6 +18,11 @@ use rustc_span::Span; |
| 23 | 18 | use thin_vec::ThinVec; |
| 24 | 19 | use tracing::instrument; |
| 25 | 20 | |
| 21 | use crate::errors::{ | |
| 22 | FeatureNotAllowed, FeatureRemoved, FeatureRemovedReason, InvalidCfg, MalformedFeatureAttribute, | |
| 23 | MalformedFeatureAttributeHelp, RemoveExprNotSupported, | |
| 24 | }; | |
| 25 | ||
| 26 | 26 | /// A folder that strips out items that do not belong in the current configuration. |
| 27 | 27 | pub struct StripUnconfigured<'a> { |
| 28 | 28 | pub sess: &'a Session, |
compiler/rustc_expand/src/errors.rs+2-1| ... | ... | @@ -1,10 +1,11 @@ |
| 1 | use std::borrow::Cow; | |
| 2 | ||
| 1 | 3 | use rustc_ast::ast; |
| 2 | 4 | use rustc_errors::codes::*; |
| 3 | 5 | use rustc_macros::{Diagnostic, Subdiagnostic}; |
| 4 | 6 | use rustc_session::Limit; |
| 5 | 7 | use rustc_span::symbol::{Ident, MacroRulesNormalizedIdent}; |
| 6 | 8 | use rustc_span::{Span, Symbol}; |
| 7 | use std::borrow::Cow; | |
| 8 | 9 | |
| 9 | 10 | #[derive(Diagnostic)] |
| 10 | 11 | #[diag(expand_expr_repeat_no_syntax_vars)] |
compiler/rustc_expand/src/expand.rs+20-19| ... | ... | @@ -1,13 +1,7 @@ |
| 1 | use crate::base::*; | |
| 2 | use crate::config::StripUnconfigured; | |
| 3 | use crate::errors::{ | |
| 4 | EmptyDelegationMac, GlobDelegationOutsideImpls, GlobDelegationTraitlessQpath, IncompleteParse, | |
| 5 | RecursionLimitReached, RemoveExprNotSupported, RemoveNodeNotSupported, UnsupportedKeyValue, | |
| 6 | WrongFragmentKind, | |
| 7 | }; | |
| 8 | use crate::mbe::diagnostics::annotate_err_with_kind; | |
| 9 | use crate::module::{mod_dir_path, parse_external_mod, DirOwnership, ParsedExternalMod}; | |
| 10 | use crate::placeholders::{placeholder, PlaceholderExpander}; | |
| 1 | use std::ops::Deref; | |
| 2 | use std::path::PathBuf; | |
| 3 | use std::rc::Rc; | |
| 4 | use std::{iter, mem}; | |
| 11 | 5 | |
| 12 | 6 | use rustc_ast as ast; |
| 13 | 7 | use rustc_ast::mut_visit::*; |
| ... | ... | @@ -15,10 +9,11 @@ use rustc_ast::ptr::P; |
| 15 | 9 | use rustc_ast::token::{self, Delimiter}; |
| 16 | 10 | use rustc_ast::tokenstream::TokenStream; |
| 17 | 11 | use rustc_ast::visit::{self, try_visit, walk_list, AssocCtxt, Visitor, VisitorResult}; |
| 18 | use rustc_ast::{AssocItemKind, AstNodeWrapper, AttrArgs, AttrStyle, AttrVec, ExprKind}; | |
| 19 | use rustc_ast::{ForeignItemKind, HasAttrs, HasNodeId}; | |
| 20 | use rustc_ast::{Inline, ItemKind, MacStmtStyle, MetaItemKind, ModKind}; | |
| 21 | use rustc_ast::{NestedMetaItem, NodeId, PatKind, StmtKind, TyKind}; | |
| 12 | use rustc_ast::{ | |
| 13 | AssocItemKind, AstNodeWrapper, AttrArgs, AttrStyle, AttrVec, ExprKind, ForeignItemKind, | |
| 14 | HasAttrs, HasNodeId, Inline, ItemKind, MacStmtStyle, MetaItemKind, ModKind, NestedMetaItem, | |
| 15 | NodeId, PatKind, StmtKind, TyKind, | |
| 16 | }; | |
| 22 | 17 | use rustc_ast_pretty::pprust; |
| 23 | 18 | use rustc_data_structures::flat_map_in_place::FlatMapInPlace; |
| 24 | 19 | use rustc_data_structures::sync::Lrc; |
| ... | ... | @@ -35,12 +30,18 @@ use rustc_session::{Limit, Session}; |
| 35 | 30 | use rustc_span::hygiene::SyntaxContext; |
| 36 | 31 | use rustc_span::symbol::{sym, Ident}; |
| 37 | 32 | use rustc_span::{ErrorGuaranteed, FileName, LocalExpnId, Span}; |
| 38 | ||
| 39 | 33 | use smallvec::SmallVec; |
| 40 | use std::ops::Deref; | |
| 41 | use std::path::PathBuf; | |
| 42 | use std::rc::Rc; | |
| 43 | use std::{iter, mem}; | |
| 34 | ||
| 35 | use crate::base::*; | |
| 36 | use crate::config::StripUnconfigured; | |
| 37 | use crate::errors::{ | |
| 38 | EmptyDelegationMac, GlobDelegationOutsideImpls, GlobDelegationTraitlessQpath, IncompleteParse, | |
| 39 | RecursionLimitReached, RemoveExprNotSupported, RemoveNodeNotSupported, UnsupportedKeyValue, | |
| 40 | WrongFragmentKind, | |
| 41 | }; | |
| 42 | use crate::mbe::diagnostics::annotate_err_with_kind; | |
| 43 | use crate::module::{mod_dir_path, parse_external_mod, DirOwnership, ParsedExternalMod}; | |
| 44 | use crate::placeholders::{placeholder, PlaceholderExpander}; | |
| 44 | 45 | |
| 45 | 46 | macro_rules! ast_fragments { |
| 46 | 47 | ( |
compiler/rustc_expand/src/mbe/diagnostics.rs+7-7| ... | ... | @@ -1,9 +1,5 @@ |
| 1 | use crate::base::{DummyResult, ExtCtxt, MacResult}; | |
| 2 | use crate::expand::{parse_ast_fragment, AstFragmentKind}; | |
| 3 | use crate::mbe::{ | |
| 4 | macro_parser::{MatcherLoc, NamedParseResult, ParseResult::*, TtParser}, | |
| 5 | macro_rules::{try_match_macro, Tracker}, | |
| 6 | }; | |
| 1 | use std::borrow::Cow; | |
| 2 | ||
| 7 | 3 | use rustc_ast::token::{self, Token, TokenKind}; |
| 8 | 4 | use rustc_ast::tokenstream::TokenStream; |
| 9 | 5 | use rustc_ast_pretty::pprust; |
| ... | ... | @@ -13,10 +9,14 @@ use rustc_parse::parser::{Parser, Recovery}; |
| 13 | 9 | use rustc_span::source_map::SourceMap; |
| 14 | 10 | use rustc_span::symbol::Ident; |
| 15 | 11 | use rustc_span::{ErrorGuaranteed, Span}; |
| 16 | use std::borrow::Cow; | |
| 17 | 12 | use tracing::debug; |
| 18 | 13 | |
| 19 | 14 | use super::macro_rules::{parser_from_cx, NoopTracker}; |
| 15 | use crate::base::{DummyResult, ExtCtxt, MacResult}; | |
| 16 | use crate::expand::{parse_ast_fragment, AstFragmentKind}; | |
| 17 | use crate::mbe::macro_parser::ParseResult::*; | |
| 18 | use crate::mbe::macro_parser::{MatcherLoc, NamedParseResult, TtParser}; | |
| 19 | use crate::mbe::macro_rules::{try_match_macro, Tracker}; | |
| 20 | 20 | |
| 21 | 21 | pub(super) fn failed_to_match_macro<'cx>( |
| 22 | 22 | cx: &'cx mut ExtCtxt<'_>, |
compiler/rustc_expand/src/mbe/macro_check.rs+5-7| ... | ... | @@ -105,8 +105,7 @@ |
| 105 | 105 | //! stored when entering a macro definition starting from the state in which the meta-variable is |
| 106 | 106 | //! bound. |
| 107 | 107 | |
| 108 | use crate::errors; | |
| 109 | use crate::mbe::{KleeneToken, TokenTree}; | |
| 108 | use std::iter; | |
| 110 | 109 | |
| 111 | 110 | use rustc_ast::token::{Delimiter, IdentIsRaw, Token, TokenKind}; |
| 112 | 111 | use rustc_ast::{NodeId, DUMMY_NODE_ID}; |
| ... | ... | @@ -116,14 +115,13 @@ use rustc_lint_defs::BuiltinLintDiag; |
| 116 | 115 | use rustc_session::lint::builtin::{META_VARIABLE_MISUSE, MISSING_FRAGMENT_SPECIFIER}; |
| 117 | 116 | use rustc_session::parse::ParseSess; |
| 118 | 117 | use rustc_span::edition::Edition; |
| 119 | use rustc_span::symbol::kw; | |
| 120 | use rustc_span::{symbol::MacroRulesNormalizedIdent, ErrorGuaranteed, Span}; | |
| 121 | ||
| 118 | use rustc_span::symbol::{kw, MacroRulesNormalizedIdent}; | |
| 119 | use rustc_span::{ErrorGuaranteed, Span}; | |
| 122 | 120 | use smallvec::SmallVec; |
| 123 | 121 | |
| 124 | use std::iter; | |
| 125 | ||
| 126 | 122 | use super::quoted::VALID_FRAGMENT_NAMES_MSG_2021; |
| 123 | use crate::errors; | |
| 124 | use crate::mbe::{KleeneToken, TokenTree}; | |
| 127 | 125 | |
| 128 | 126 | /// Stack represented as linked list. |
| 129 | 127 | /// |
compiler/rustc_expand/src/mbe/macro_parser.rs+10-10| ... | ... | @@ -70,10 +70,10 @@ |
| 70 | 70 | //! eof: [a $( a )* a b ·] |
| 71 | 71 | //! ``` |
| 72 | 72 | |
| 73 | pub(crate) use NamedMatch::*; | |
| 74 | pub(crate) use ParseResult::*; | |
| 75 | ||
| 76 | use crate::mbe::{macro_rules::Tracker, KleeneOp, TokenTree}; | |
| 73 | use std::borrow::Cow; | |
| 74 | use std::collections::hash_map::Entry::{Occupied, Vacant}; | |
| 75 | use std::fmt::Display; | |
| 76 | use std::rc::Rc; | |
| 77 | 77 | |
| 78 | 78 | use rustc_ast::token::{self, DocComment, NonterminalKind, Token}; |
| 79 | 79 | use rustc_ast_pretty::pprust; |
| ... | ... | @@ -81,13 +81,13 @@ use rustc_data_structures::fx::FxHashMap; |
| 81 | 81 | use rustc_errors::ErrorGuaranteed; |
| 82 | 82 | use rustc_lint_defs::pluralize; |
| 83 | 83 | use rustc_parse::parser::{ParseNtResult, Parser}; |
| 84 | use rustc_span::symbol::Ident; | |
| 85 | use rustc_span::symbol::MacroRulesNormalizedIdent; | |
| 84 | use rustc_span::symbol::{Ident, MacroRulesNormalizedIdent}; | |
| 86 | 85 | use rustc_span::Span; |
| 87 | use std::borrow::Cow; | |
| 88 | use std::collections::hash_map::Entry::{Occupied, Vacant}; | |
| 89 | use std::fmt::Display; | |
| 90 | use std::rc::Rc; | |
| 86 | pub(crate) use NamedMatch::*; | |
| 87 | pub(crate) use ParseResult::*; | |
| 88 | ||
| 89 | use crate::mbe::macro_rules::Tracker; | |
| 90 | use crate::mbe::{KleeneOp, TokenTree}; | |
| 91 | 91 | |
| 92 | 92 | /// A unit within a matcher that a `MatcherPos` can refer to. Similar to (and derived from) |
| 93 | 93 | /// `mbe::TokenTree`, but designed specifically for fast and easy traversal during matching. |
compiler/rustc_expand/src/mbe/macro_rules.rs+17-16| ... | ... | @@ -1,18 +1,12 @@ |
| 1 | use crate::base::{DummyResult, SyntaxExtension, SyntaxExtensionKind}; | |
| 2 | use crate::base::{ExpandResult, ExtCtxt, MacResult, MacroExpanderResult, TTMacroExpander}; | |
| 3 | use crate::expand::{ensure_complete_parse, parse_ast_fragment, AstFragment, AstFragmentKind}; | |
| 4 | use crate::mbe; | |
| 5 | use crate::mbe::diagnostics::{annotate_doc_comment, parse_failure_msg}; | |
| 6 | use crate::mbe::macro_check; | |
| 7 | use crate::mbe::macro_parser::{Error, ErrorReported, Failure, Success, TtParser}; | |
| 8 | use crate::mbe::macro_parser::{MatcherLoc, NamedMatch::*}; | |
| 9 | use crate::mbe::transcribe::transcribe; | |
| 1 | use std::borrow::Cow; | |
| 2 | use std::collections::hash_map::Entry; | |
| 3 | use std::{mem, slice}; | |
| 10 | 4 | |
| 11 | 5 | use ast::token::IdentIsRaw; |
| 12 | 6 | use rustc_ast as ast; |
| 13 | use rustc_ast::token::{ | |
| 14 | self, Delimiter, NonterminalKind, NtPatKind::*, Token, TokenKind, TokenKind::*, | |
| 15 | }; | |
| 7 | use rustc_ast::token::NtPatKind::*; | |
| 8 | use rustc_ast::token::TokenKind::*; | |
| 9 | use rustc_ast::token::{self, Delimiter, NonterminalKind, Token, TokenKind}; | |
| 16 | 10 | use rustc_ast::tokenstream::{DelimSpan, TokenStream}; |
| 17 | 11 | use rustc_ast::{NodeId, DUMMY_NODE_ID}; |
| 18 | 12 | use rustc_ast_pretty::pprust; |
| ... | ... | @@ -33,12 +27,19 @@ use rustc_span::symbol::{kw, sym, Ident, MacroRulesNormalizedIdent}; |
| 33 | 27 | use rustc_span::Span; |
| 34 | 28 | use tracing::{debug, instrument, trace, trace_span}; |
| 35 | 29 | |
| 36 | use std::borrow::Cow; | |
| 37 | use std::collections::hash_map::Entry; | |
| 38 | use std::{mem, slice}; | |
| 39 | ||
| 40 | 30 | use super::diagnostics; |
| 41 | 31 | use super::macro_parser::{NamedMatches, NamedParseResult}; |
| 32 | use crate::base::{ | |
| 33 | DummyResult, ExpandResult, ExtCtxt, MacResult, MacroExpanderResult, SyntaxExtension, | |
| 34 | SyntaxExtensionKind, TTMacroExpander, | |
| 35 | }; | |
| 36 | use crate::expand::{ensure_complete_parse, parse_ast_fragment, AstFragment, AstFragmentKind}; | |
| 37 | use crate::mbe; | |
| 38 | use crate::mbe::diagnostics::{annotate_doc_comment, parse_failure_msg}; | |
| 39 | use crate::mbe::macro_check; | |
| 40 | use crate::mbe::macro_parser::NamedMatch::*; | |
| 41 | use crate::mbe::macro_parser::{Error, ErrorReported, Failure, MatcherLoc, Success, TtParser}; | |
| 42 | use crate::mbe::transcribe::transcribe; | |
| 42 | 43 | |
| 43 | 44 | pub(crate) struct ParserAnyMacro<'a> { |
| 44 | 45 | parser: Parser<'a>, |
compiler/rustc_expand/src/mbe/quoted.rs+7-7| ... | ... | @@ -1,18 +1,18 @@ |
| 1 | use crate::errors; | |
| 2 | use crate::mbe::macro_parser::count_metavar_decls; | |
| 3 | use crate::mbe::{Delimited, KleeneOp, KleeneToken, MetaVarExpr, SequenceRepetition, TokenTree}; | |
| 4 | ||
| 5 | use rustc_ast::token::{self, Delimiter, IdentIsRaw, NonterminalKind, NtExprKind::*, Token}; | |
| 1 | use rustc_ast::token::NtExprKind::*; | |
| 2 | use rustc_ast::token::{self, Delimiter, IdentIsRaw, NonterminalKind, Token}; | |
| 6 | 3 | use rustc_ast::{tokenstream, NodeId}; |
| 7 | 4 | use rustc_ast_pretty::pprust; |
| 8 | 5 | use rustc_feature::Features; |
| 9 | 6 | use rustc_session::parse::feature_err; |
| 10 | 7 | use rustc_session::Session; |
| 11 | use rustc_span::symbol::{kw, sym, Ident}; | |
| 12 | ||
| 13 | 8 | use rustc_span::edition::Edition; |
| 9 | use rustc_span::symbol::{kw, sym, Ident}; | |
| 14 | 10 | use rustc_span::Span; |
| 15 | 11 | |
| 12 | use crate::errors; | |
| 13 | use crate::mbe::macro_parser::count_metavar_decls; | |
| 14 | use crate::mbe::{Delimited, KleeneOp, KleeneToken, MetaVarExpr, SequenceRepetition, TokenTree}; | |
| 15 | ||
| 16 | 16 | const VALID_FRAGMENT_NAMES_MSG: &str = "valid fragment specifiers are \ |
| 17 | 17 | `ident`, `block`, `stmt`, `expr`, `pat`, `ty`, `lifetime`, \ |
| 18 | 18 | `literal`, `path`, `meta`, `tt`, `item` and `vis`"; |
compiler/rustc_expand/src/mbe/transcribe.rs+13-12| ... | ... | @@ -1,26 +1,27 @@ |
| 1 | use crate::errors::{ | |
| 2 | CountRepetitionMisplaced, MetaVarExprUnrecognizedVar, MetaVarsDifSeqMatchers, MustRepeatOnce, | |
| 3 | NoSyntaxVarsExprRepeat, VarStillRepeating, | |
| 4 | }; | |
| 5 | use crate::mbe::macro_parser::{NamedMatch, NamedMatch::*}; | |
| 6 | use crate::mbe::metavar_expr::{MetaVarExprConcatElem, RAW_IDENT_ERR}; | |
| 7 | use crate::mbe::{self, KleeneOp, MetaVarExpr}; | |
| 1 | use std::mem; | |
| 2 | ||
| 8 | 3 | use rustc_ast::mut_visit::{self, MutVisitor}; |
| 9 | use rustc_ast::token::{self, Delimiter, Nonterminal, Token, TokenKind}; | |
| 10 | use rustc_ast::token::{IdentIsRaw, Lit, LitKind}; | |
| 4 | use rustc_ast::token::{self, Delimiter, IdentIsRaw, Lit, LitKind, Nonterminal, Token, TokenKind}; | |
| 11 | 5 | use rustc_ast::tokenstream::{DelimSpacing, DelimSpan, Spacing, TokenStream, TokenTree}; |
| 12 | 6 | use rustc_ast::ExprKind; |
| 13 | 7 | use rustc_data_structures::fx::FxHashMap; |
| 14 | 8 | use rustc_errors::{pluralize, Diag, DiagCtxtHandle, PResult}; |
| 15 | 9 | use rustc_parse::lexer::nfc_normalize; |
| 16 | 10 | use rustc_parse::parser::ParseNtResult; |
| 17 | use rustc_session::parse::ParseSess; | |
| 18 | use rustc_session::parse::SymbolGallery; | |
| 11 | use rustc_session::parse::{ParseSess, SymbolGallery}; | |
| 19 | 12 | use rustc_span::hygiene::{LocalExpnId, Transparency}; |
| 20 | 13 | use rustc_span::symbol::{sym, Ident, MacroRulesNormalizedIdent}; |
| 21 | 14 | use rustc_span::{with_metavar_spans, Span, Symbol, SyntaxContext}; |
| 22 | 15 | use smallvec::{smallvec, SmallVec}; |
| 23 | use std::mem; | |
| 16 | ||
| 17 | use crate::errors::{ | |
| 18 | CountRepetitionMisplaced, MetaVarExprUnrecognizedVar, MetaVarsDifSeqMatchers, MustRepeatOnce, | |
| 19 | NoSyntaxVarsExprRepeat, VarStillRepeating, | |
| 20 | }; | |
| 21 | use crate::mbe::macro_parser::NamedMatch; | |
| 22 | use crate::mbe::macro_parser::NamedMatch::*; | |
| 23 | use crate::mbe::metavar_expr::{MetaVarExprConcatElem, RAW_IDENT_ERR}; | |
| 24 | use crate::mbe::{self, KleeneOp, MetaVarExpr}; | |
| 24 | 25 | |
| 25 | 26 | // A Marker adds the given mark to the syntax context. |
| 26 | 27 | struct Marker(LocalExpnId, Transparency, FxHashMap<SyntaxContext, SyntaxContext>); |
compiler/rustc_expand/src/module.rs+9-8| ... | ... | @@ -1,20 +1,21 @@ |
| 1 | use crate::base::ModuleData; | |
| 2 | use crate::errors::{ | |
| 3 | ModuleCircular, ModuleFileNotFound, ModuleInBlock, ModuleInBlockName, ModuleMultipleCandidates, | |
| 4 | }; | |
| 1 | use std::iter::once; | |
| 2 | use std::path::{self, Path, PathBuf}; | |
| 3 | ||
| 5 | 4 | use rustc_ast::ptr::P; |
| 6 | 5 | use rustc_ast::{token, AttrVec, Attribute, Inline, Item, ModSpans}; |
| 7 | 6 | use rustc_errors::{Diag, ErrorGuaranteed}; |
| 8 | use rustc_parse::validate_attr; | |
| 9 | use rustc_parse::{new_parser_from_file, unwrap_or_emit_fatal}; | |
| 7 | use rustc_parse::{new_parser_from_file, unwrap_or_emit_fatal, validate_attr}; | |
| 10 | 8 | use rustc_session::parse::ParseSess; |
| 11 | 9 | use rustc_session::Session; |
| 12 | 10 | use rustc_span::symbol::{sym, Ident}; |
| 13 | 11 | use rustc_span::Span; |
| 14 | use std::iter::once; | |
| 15 | use std::path::{self, Path, PathBuf}; | |
| 16 | 12 | use thin_vec::ThinVec; |
| 17 | 13 | |
| 14 | use crate::base::ModuleData; | |
| 15 | use crate::errors::{ | |
| 16 | ModuleCircular, ModuleFileNotFound, ModuleInBlock, ModuleInBlockName, ModuleMultipleCandidates, | |
| 17 | }; | |
| 18 | ||
| 18 | 19 | #[derive(Copy, Clone)] |
| 19 | 20 | pub enum DirOwnership { |
| 20 | 21 | Owned { |
compiler/rustc_expand/src/placeholders.rs+4-2| ... | ... | @@ -1,14 +1,16 @@ |
| 1 | use crate::expand::{AstFragment, AstFragmentKind}; | |
| 2 | 1 | use rustc_ast::mut_visit::*; |
| 3 | 2 | use rustc_ast::ptr::P; |
| 4 | 3 | use rustc_ast::token::Delimiter; |
| 5 | use rustc_ast::{self as ast, visit::AssocCtxt}; | |
| 4 | use rustc_ast::visit::AssocCtxt; | |
| 5 | use rustc_ast::{self as ast}; | |
| 6 | 6 | use rustc_data_structures::fx::FxHashMap; |
| 7 | 7 | use rustc_span::symbol::Ident; |
| 8 | 8 | use rustc_span::DUMMY_SP; |
| 9 | 9 | use smallvec::{smallvec, SmallVec}; |
| 10 | 10 | use thin_vec::ThinVec; |
| 11 | 11 | |
| 12 | use crate::expand::{AstFragment, AstFragmentKind}; | |
| 13 | ||
| 12 | 14 | pub(crate) fn placeholder( |
| 13 | 15 | kind: AstFragmentKind, |
| 14 | 16 | id: ast::NodeId, |
compiler/rustc_expand/src/proc_macro.rs+3-4| ... | ... | @@ -1,7 +1,3 @@ |
| 1 | use crate::base::{self, *}; | |
| 2 | use crate::errors; | |
| 3 | use crate::proc_macro_server; | |
| 4 | ||
| 5 | 1 | use rustc_ast as ast; |
| 6 | 2 | use rustc_ast::ptr::P; |
| 7 | 3 | use rustc_ast::tokenstream::TokenStream; |
| ... | ... | @@ -11,6 +7,9 @@ use rustc_session::config::ProcMacroExecutionStrategy; |
| 11 | 7 | use rustc_span::profiling::SpannedEventArgRecorder; |
| 12 | 8 | use rustc_span::Span; |
| 13 | 9 | |
| 10 | use crate::base::{self, *}; | |
| 11 | use crate::{errors, proc_macro_server}; | |
| 12 | ||
| 14 | 13 | struct MessagePipe<T> { |
| 15 | 14 | tx: std::sync::mpsc::SyncSender<T>, |
| 16 | 15 | rx: std::sync::mpsc::Receiver<T>, |
compiler/rustc_expand/src/proc_macro_server.rs+4-2| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | use crate::base::ExtCtxt; | |
| 1 | use std::ops::{Bound, Range}; | |
| 2 | ||
| 2 | 3 | use ast::token::IdentIsRaw; |
| 3 | 4 | use pm::bridge::{ |
| 4 | 5 | server, DelimSpan, Diagnostic, ExpnGlobals, Group, Ident, LitKind, Literal, Punct, TokenTree, |
| ... | ... | @@ -20,7 +21,8 @@ use rustc_span::def_id::CrateNum; |
| 20 | 21 | use rustc_span::symbol::{self, sym, Symbol}; |
| 21 | 22 | use rustc_span::{BytePos, FileName, Pos, SourceFile, Span}; |
| 22 | 23 | use smallvec::{smallvec, SmallVec}; |
| 23 | use std::ops::{Bound, Range}; | |
| 24 | ||
| 25 | use crate::base::ExtCtxt; | |
| 24 | 26 | |
| 25 | 27 | trait FromInternal<T> { |
| 26 | 28 | fn from_internal(x: T) -> Self; |
compiler/rustc_feature/src/accepted.rs+2-1| ... | ... | @@ -1,8 +1,9 @@ |
| 1 | 1 | //! List of the accepted feature gates. |
| 2 | 2 | |
| 3 | use super::{to_nonzero, Feature}; | |
| 4 | 3 | use rustc_span::symbol::sym; |
| 5 | 4 | |
| 5 | use super::{to_nonzero, Feature}; | |
| 6 | ||
| 6 | 7 | macro_rules! declare_features { |
| 7 | 8 | ($( |
| 8 | 9 | $(#[doc = $doc:tt])* (accepted, $feature:ident, $ver:expr, $issue:expr), |
compiler/rustc_feature/src/builtin_attrs.rs+4-5| ... | ... | @@ -1,16 +1,15 @@ |
| 1 | 1 | //! Built-in attributes and `cfg` flag gating. |
| 2 | 2 | |
| 3 | use std::sync::LazyLock; | |
| 4 | ||
| 5 | use rustc_data_structures::fx::FxHashMap; | |
| 6 | use rustc_span::symbol::{sym, Symbol}; | |
| 3 | 7 | use AttributeDuplicates::*; |
| 4 | 8 | use AttributeGate::*; |
| 5 | 9 | use AttributeType::*; |
| 6 | 10 | |
| 7 | 11 | use crate::{Features, Stability}; |
| 8 | 12 | |
| 9 | use rustc_data_structures::fx::FxHashMap; | |
| 10 | use rustc_span::symbol::{sym, Symbol}; | |
| 11 | ||
| 12 | use std::sync::LazyLock; | |
| 13 | ||
| 14 | 13 | type GateFn = fn(&Features) -> bool; |
| 15 | 14 | |
| 16 | 15 | macro_rules! cfg_fn { |
compiler/rustc_feature/src/lib.rs+4-4| ... | ... | @@ -25,9 +25,10 @@ mod unstable; |
| 25 | 25 | #[cfg(test)] |
| 26 | 26 | mod tests; |
| 27 | 27 | |
| 28 | use rustc_span::symbol::Symbol; | |
| 29 | 28 | use std::num::NonZero; |
| 30 | 29 | |
| 30 | use rustc_span::symbol::Symbol; | |
| 31 | ||
| 31 | 32 | #[derive(Debug, Clone)] |
| 32 | 33 | pub struct Feature { |
| 33 | 34 | pub name: Symbol, |
| ... | ... | @@ -126,11 +127,10 @@ pub fn find_feature_issue(feature: Symbol, issue: GateIssue) -> Option<NonZero<u |
| 126 | 127 | } |
| 127 | 128 | |
| 128 | 129 | pub use accepted::ACCEPTED_FEATURES; |
| 129 | pub use builtin_attrs::AttributeDuplicates; | |
| 130 | 130 | pub use builtin_attrs::{ |
| 131 | 131 | deprecated_attributes, encode_cross_crate, find_gated_cfg, is_builtin_attr_name, |
| 132 | is_valid_for_get_attr, AttributeGate, AttributeSafety, AttributeTemplate, AttributeType, | |
| 133 | BuiltinAttribute, GatedCfg, BUILTIN_ATTRIBUTES, BUILTIN_ATTRIBUTE_MAP, | |
| 132 | is_valid_for_get_attr, AttributeDuplicates, AttributeGate, AttributeSafety, AttributeTemplate, | |
| 133 | AttributeType, BuiltinAttribute, GatedCfg, BUILTIN_ATTRIBUTES, BUILTIN_ATTRIBUTE_MAP, | |
| 134 | 134 | }; |
| 135 | 135 | pub use removed::REMOVED_FEATURES; |
| 136 | 136 | pub use unstable::{Features, INCOMPATIBLE_FEATURES, UNSTABLE_FEATURES}; |
compiler/rustc_feature/src/removed.rs+2-1| ... | ... | @@ -1,8 +1,9 @@ |
| 1 | 1 | //! List of the removed feature gates. |
| 2 | 2 | |
| 3 | use super::{to_nonzero, Feature}; | |
| 4 | 3 | use rustc_span::symbol::sym; |
| 5 | 4 | |
| 5 | use super::{to_nonzero, Feature}; | |
| 6 | ||
| 6 | 7 | pub struct RemovedFeature { |
| 7 | 8 | pub feature: Feature, |
| 8 | 9 | pub reason: Option<&'static str>, |
compiler/rustc_feature/src/unstable.rs+2-2| ... | ... | @@ -1,11 +1,11 @@ |
| 1 | 1 | //! List of the unstable feature gates. |
| 2 | 2 | |
| 3 | use super::{to_nonzero, Feature}; | |
| 4 | ||
| 5 | 3 | use rustc_data_structures::fx::FxHashSet; |
| 6 | 4 | use rustc_span::symbol::{sym, Symbol}; |
| 7 | 5 | use rustc_span::Span; |
| 8 | 6 | |
| 7 | use super::{to_nonzero, Feature}; | |
| 8 | ||
| 9 | 9 | pub struct UnstableFeature { |
| 10 | 10 | pub feature: Feature, |
| 11 | 11 | pub set_enabled: fn(&mut Features), |
compiler/rustc_fluent_macro/src/fluent.rs+7-11| ... | ... | @@ -1,20 +1,16 @@ |
| 1 | use std::collections::{HashMap, HashSet}; | |
| 2 | use std::fs::read_to_string; | |
| 3 | use std::path::{Path, PathBuf}; | |
| 4 | ||
| 1 | 5 | use annotate_snippets::{Annotation, AnnotationType, Renderer, Slice, Snippet, SourceAnnotation}; |
| 2 | 6 | use fluent_bundle::{FluentBundle, FluentError, FluentResource}; |
| 3 | use fluent_syntax::{ | |
| 4 | ast::{ | |
| 5 | Attribute, Entry, Expression, Identifier, InlineExpression, Message, Pattern, | |
| 6 | PatternElement, | |
| 7 | }, | |
| 8 | parser::ParserError, | |
| 7 | use fluent_syntax::ast::{ | |
| 8 | Attribute, Entry, Expression, Identifier, InlineExpression, Message, Pattern, PatternElement, | |
| 9 | 9 | }; |
| 10 | use fluent_syntax::parser::ParserError; | |
| 10 | 11 | use proc_macro::{Diagnostic, Level, Span}; |
| 11 | 12 | use proc_macro2::TokenStream; |
| 12 | 13 | use quote::quote; |
| 13 | use std::{ | |
| 14 | collections::{HashMap, HashSet}, | |
| 15 | fs::read_to_string, | |
| 16 | path::{Path, PathBuf}, | |
| 17 | }; | |
| 18 | 14 | use syn::{parse_macro_input, Ident, LitStr}; |
| 19 | 15 | use unic_langid::langid; |
| 20 | 16 |
compiler/rustc_fs_util/src/lib.rs+1-2| ... | ... | @@ -1,7 +1,6 @@ |
| 1 | 1 | use std::ffi::CString; |
| 2 | use std::fs; | |
| 3 | use std::io; | |
| 4 | 2 | use std::path::{absolute, Path, PathBuf}; |
| 3 | use std::{fs, io}; | |
| 5 | 4 | |
| 6 | 5 | // Unfortunately, on windows, it looks like msvcrt.dll is silently translating |
| 7 | 6 | // verbatim paths under the hood to non-verbatim paths! This manifests itself as |
compiler/rustc_graphviz/src/lib.rs+2-2| ... | ... | @@ -279,12 +279,12 @@ |
| 279 | 279 | #![feature(rustdoc_internals)] |
| 280 | 280 | // tidy-alphabetical-end |
| 281 | 281 | |
| 282 | use LabelText::*; | |
| 283 | ||
| 284 | 282 | use std::borrow::Cow; |
| 285 | 283 | use std::io; |
| 286 | 284 | use std::io::prelude::*; |
| 287 | 285 | |
| 286 | use LabelText::*; | |
| 287 | ||
| 288 | 288 | /// The text for a graphviz label on a node or edge. |
| 289 | 289 | pub enum LabelText<'a> { |
| 290 | 290 | /// This kind of label preserves the text directly as is. |
compiler/rustc_graphviz/src/tests.rs+4-2| ... | ... | @@ -1,9 +1,11 @@ |
| 1 | use super::LabelText::{self, EscStr, HtmlStr, LabelStr}; | |
| 2 | use super::{render, Edges, GraphWalk, Id, Labeller, Nodes, Style}; | |
| 3 | 1 | use std::io; |
| 4 | 2 | use std::io::prelude::*; |
| 3 | ||
| 5 | 4 | use NodeLabels::*; |
| 6 | 5 | |
| 6 | use super::LabelText::{self, EscStr, HtmlStr, LabelStr}; | |
| 7 | use super::{render, Edges, GraphWalk, Id, Labeller, Nodes, Style}; | |
| 8 | ||
| 7 | 9 | /// each node is an index in a vector in the graph. |
| 8 | 10 | type Node = usize; |
| 9 | 11 | struct Edge { |
compiler/rustc_hir/src/def.rs+4-4| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | use crate::definitions::DefPathData; | |
| 2 | use crate::hir; | |
| 1 | use std::array::IntoIter; | |
| 2 | use std::fmt::Debug; | |
| 3 | 3 | |
| 4 | 4 | use rustc_ast as ast; |
| 5 | 5 | use rustc_ast::NodeId; |
| ... | ... | @@ -11,8 +11,8 @@ use rustc_span::hygiene::MacroKind; |
| 11 | 11 | use rustc_span::symbol::kw; |
| 12 | 12 | use rustc_span::Symbol; |
| 13 | 13 | |
| 14 | use std::array::IntoIter; | |
| 15 | use std::fmt::Debug; | |
| 14 | use crate::definitions::DefPathData; | |
| 15 | use crate::hir; | |
| 16 | 16 | |
| 17 | 17 | /// Encodes if a `DefKind::Ctor` is the constructor of an enum variant or a struct. |
| 18 | 18 | #[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug, HashStable_Generic)] |
compiler/rustc_hir/src/definitions.rs+7-5| ... | ... | @@ -4,18 +4,20 @@ |
| 4 | 4 | //! There are also some rather random cases (like const initializer |
| 5 | 5 | //! expressions) that are mostly just leftovers. |
| 6 | 6 | |
| 7 | pub use crate::def_id::DefPathHash; | |
| 8 | use crate::def_id::{CrateNum, DefIndex, LocalDefId, StableCrateId, CRATE_DEF_INDEX, LOCAL_CRATE}; | |
| 9 | use crate::def_path_hash_map::DefPathHashMap; | |
| 7 | use std::fmt::{self, Write}; | |
| 8 | use std::hash::Hash; | |
| 9 | ||
| 10 | 10 | use rustc_data_structures::stable_hasher::{Hash64, StableHasher}; |
| 11 | 11 | use rustc_data_structures::unord::UnordMap; |
| 12 | 12 | use rustc_index::IndexVec; |
| 13 | 13 | use rustc_macros::{Decodable, Encodable}; |
| 14 | 14 | use rustc_span::symbol::{kw, sym, Symbol}; |
| 15 | use std::fmt::{self, Write}; | |
| 16 | use std::hash::Hash; | |
| 17 | 15 | use tracing::{debug, instrument}; |
| 18 | 16 | |
| 17 | pub use crate::def_id::DefPathHash; | |
| 18 | use crate::def_id::{CrateNum, DefIndex, LocalDefId, StableCrateId, CRATE_DEF_INDEX, LOCAL_CRATE}; | |
| 19 | use crate::def_path_hash_map::DefPathHashMap; | |
| 20 | ||
| 19 | 21 | /// The `DefPathTable` maps `DefIndex`es to `DefKey`s and vice versa. |
| 20 | 22 | /// Internally the `DefPathTable` holds a tree of `DefKey`s, where each `DefKey` |
| 21 | 23 | /// stores the `DefIndex` of its parent. |
compiler/rustc_hir/src/diagnostic_items.rs+2-1| ... | ... | @@ -1,9 +1,10 @@ |
| 1 | use crate::def_id::DefId; | |
| 2 | 1 | use rustc_data_structures::fx::FxIndexMap; |
| 3 | 2 | use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; |
| 4 | 3 | use rustc_span::def_id::DefIdMap; |
| 5 | 4 | use rustc_span::Symbol; |
| 6 | 5 | |
| 6 | use crate::def_id::DefId; | |
| 7 | ||
| 7 | 8 | #[derive(Debug, Default)] |
| 8 | 9 | pub struct DiagnosticItems { |
| 9 | 10 | pub id_to_name: DefIdMap<Symbol>, |
compiler/rustc_hir/src/hir.rs+20-13| ... | ... | @@ -1,29 +1,35 @@ |
| 1 | use crate::def::{CtorKind, DefKind, Res}; | |
| 2 | use crate::def_id::{DefId, LocalDefIdMap}; | |
| 3 | pub(crate) use crate::hir_id::{HirId, ItemLocalId, ItemLocalMap, OwnerId}; | |
| 4 | use crate::intravisit::FnKind; | |
| 5 | use crate::LangItem; | |
| 1 | use std::fmt; | |
| 2 | ||
| 6 | 3 | use rustc_ast as ast; |
| 7 | 4 | use rustc_ast::util::parser::ExprPrecedence; |
| 8 | use rustc_ast::{Attribute, FloatTy, IntTy, Label, LitKind, TraitObjectSyntax, UintTy}; | |
| 9 | pub use rustc_ast::{BinOp, BinOpKind, BindingMode, BorrowKind, ByRef, CaptureBy}; | |
| 10 | pub use rustc_ast::{ImplPolarity, IsAuto, Movability, Mutability, UnOp}; | |
| 11 | use rustc_ast::{InlineAsmOptions, InlineAsmTemplatePiece}; | |
| 5 | use rustc_ast::{ | |
| 6 | Attribute, FloatTy, InlineAsmOptions, InlineAsmTemplatePiece, IntTy, Label, LitKind, | |
| 7 | TraitObjectSyntax, UintTy, | |
| 8 | }; | |
| 9 | pub use rustc_ast::{ | |
| 10 | BinOp, BinOpKind, BindingMode, BorrowKind, ByRef, CaptureBy, ImplPolarity, IsAuto, Movability, | |
| 11 | Mutability, UnOp, | |
| 12 | }; | |
| 12 | 13 | use rustc_data_structures::fingerprint::Fingerprint; |
| 13 | 14 | use rustc_data_structures::sorted_map::SortedMap; |
| 14 | 15 | use rustc_index::IndexVec; |
| 15 | 16 | use rustc_macros::{Decodable, Encodable, HashStable_Generic}; |
| 17 | use rustc_span::def_id::LocalDefId; | |
| 16 | 18 | use rustc_span::hygiene::MacroKind; |
| 17 | 19 | use rustc_span::source_map::Spanned; |
| 18 | 20 | use rustc_span::symbol::{kw, sym, Ident, Symbol}; |
| 19 | use rustc_span::ErrorGuaranteed; | |
| 20 | use rustc_span::{def_id::LocalDefId, BytePos, Span, DUMMY_SP}; | |
| 21 | use rustc_span::{BytePos, ErrorGuaranteed, Span, DUMMY_SP}; | |
| 21 | 22 | use rustc_target::asm::InlineAsmRegOrRegClass; |
| 22 | 23 | use rustc_target::spec::abi::Abi; |
| 23 | 24 | use smallvec::SmallVec; |
| 24 | use std::fmt; | |
| 25 | 25 | use tracing::debug; |
| 26 | 26 | |
| 27 | use crate::def::{CtorKind, DefKind, Res}; | |
| 28 | use crate::def_id::{DefId, LocalDefIdMap}; | |
| 29 | pub(crate) use crate::hir_id::{HirId, ItemLocalId, ItemLocalMap, OwnerId}; | |
| 30 | use crate::intravisit::FnKind; | |
| 31 | use crate::LangItem; | |
| 32 | ||
| 27 | 33 | #[derive(Debug, Copy, Clone, HashStable_Generic)] |
| 28 | 34 | pub struct Lifetime { |
| 29 | 35 | pub hir_id: HirId, |
| ... | ... | @@ -4008,8 +4014,9 @@ impl<'hir> Node<'hir> { |
| 4008 | 4014 | // Some nodes are used a lot. Make sure they don't unintentionally get bigger. |
| 4009 | 4015 | #[cfg(target_pointer_width = "64")] |
| 4010 | 4016 | mod size_asserts { |
| 4011 | use super::*; | |
| 4012 | 4017 | use rustc_data_structures::static_assert_size; |
| 4018 | ||
| 4019 | use super::*; | |
| 4013 | 4020 | // tidy-alphabetical-start |
| 4014 | 4021 | static_assert_size!(Block<'_>, 48); |
| 4015 | 4022 | static_assert_size!(Body<'_>, 24); |
compiler/rustc_hir/src/hir_id.rs+6-3| ... | ... | @@ -1,8 +1,11 @@ |
| 1 | use crate::def_id::{DefId, DefIndex, LocalDefId, CRATE_DEF_ID}; | |
| 1 | use std::fmt::{self, Debug}; | |
| 2 | ||
| 2 | 3 | use rustc_data_structures::stable_hasher::{HashStable, StableHasher, StableOrd, ToStableHashKey}; |
| 3 | 4 | use rustc_macros::{Decodable, Encodable, HashStable_Generic}; |
| 4 | use rustc_span::{def_id::DefPathHash, HashStableContext}; | |
| 5 | use std::fmt::{self, Debug}; | |
| 5 | use rustc_span::def_id::DefPathHash; | |
| 6 | use rustc_span::HashStableContext; | |
| 7 | ||
| 8 | use crate::def_id::{DefId, DefIndex, LocalDefId, CRATE_DEF_ID}; | |
| 6 | 9 | |
| 7 | 10 | #[derive(Copy, Clone, PartialEq, Eq, Hash, Encodable, Decodable)] |
| 8 | 11 | pub struct OwnerId { |
compiler/rustc_hir/src/intravisit.rs+2-1| ... | ... | @@ -64,13 +64,14 @@ |
| 64 | 64 | //! This order consistency is required in a few places in rustc, for |
| 65 | 65 | //! example coroutine inference, and possibly also HIR borrowck. |
| 66 | 66 | |
| 67 | use crate::hir::*; | |
| 68 | 67 | use rustc_ast::visit::{try_visit, visit_opt, walk_list, VisitorResult}; |
| 69 | 68 | use rustc_ast::{Attribute, Label}; |
| 70 | 69 | use rustc_span::def_id::LocalDefId; |
| 71 | 70 | use rustc_span::symbol::{Ident, Symbol}; |
| 72 | 71 | use rustc_span::Span; |
| 73 | 72 | |
| 73 | use crate::hir::*; | |
| 74 | ||
| 74 | 75 | pub trait IntoVisitor<'hir> { |
| 75 | 76 | type Visitor: Visitor<'hir>; |
| 76 | 77 | fn into_visitor(&self) -> Self::Visitor; |
compiler/rustc_hir/src/lang_items.rs+3-3| ... | ... | @@ -7,9 +7,6 @@ |
| 7 | 7 | //! * Traits that represent operators; e.g., `Add`, `Sub`, `Index`. |
| 8 | 8 | //! * Functions called by the compiler itself. |
| 9 | 9 | |
| 10 | use crate::def_id::DefId; | |
| 11 | use crate::{MethodKind, Target}; | |
| 12 | ||
| 13 | 10 | use rustc_ast as ast; |
| 14 | 11 | use rustc_data_structures::fx::FxIndexMap; |
| 15 | 12 | use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; |
| ... | ... | @@ -17,6 +14,9 @@ use rustc_macros::{Decodable, Encodable, HashStable_Generic}; |
| 17 | 14 | use rustc_span::symbol::{kw, sym, Symbol}; |
| 18 | 15 | use rustc_span::Span; |
| 19 | 16 | |
| 17 | use crate::def_id::DefId; | |
| 18 | use crate::{MethodKind, Target}; | |
| 19 | ||
| 20 | 20 | /// All of the lang items, defined or not. |
| 21 | 21 | /// Defined lang items can come from the current crate or its dependencies. |
| 22 | 22 | #[derive(HashStable_Generic, Debug)] |
compiler/rustc_hir/src/pat_util.rs+5-4| ... | ... | @@ -1,10 +1,11 @@ |
| 1 | use crate::def::{CtorOf, DefKind, Res}; | |
| 2 | use crate::def_id::{DefId, DefIdSet}; | |
| 3 | use crate::hir::{self, BindingMode, ByRef, HirId, PatKind}; | |
| 1 | use std::iter::Enumerate; | |
| 2 | ||
| 4 | 3 | use rustc_span::symbol::Ident; |
| 5 | 4 | use rustc_span::Span; |
| 6 | 5 | |
| 7 | use std::iter::Enumerate; | |
| 6 | use crate::def::{CtorOf, DefKind, Res}; | |
| 7 | use crate::def_id::{DefId, DefIdSet}; | |
| 8 | use crate::hir::{self, BindingMode, ByRef, HirId, PatKind}; | |
| 8 | 9 | |
| 9 | 10 | pub struct EnumerateAndAdjust<I> { |
| 10 | 11 | enumerate: Enumerate<I>, |
compiler/rustc_hir/src/stable_hash_impls.rs+1-1| ... | ... | @@ -1,10 +1,10 @@ |
| 1 | 1 | use rustc_data_structures::stable_hasher::{HashStable, StableHasher, ToStableHashKey}; |
| 2 | use rustc_span::def_id::DefPathHash; | |
| 2 | 3 | |
| 3 | 4 | use crate::hir::{ |
| 4 | 5 | AttributeMap, BodyId, Crate, ForeignItemId, ImplItemId, ItemId, OwnerNodes, TraitItemId, |
| 5 | 6 | }; |
| 6 | 7 | use crate::hir_id::{HirId, ItemLocalId}; |
| 7 | use rustc_span::def_id::DefPathHash; | |
| 8 | 8 | |
| 9 | 9 | /// Requirements for a `StableHashingContext` to be used in this crate. |
| 10 | 10 | /// This is a hack to allow using the `HashStable_Generic` derive macro |
compiler/rustc_hir/src/target.rs+2-3| ... | ... | @@ -4,11 +4,10 @@ |
| 4 | 4 | //! conflicts between multiple such attributes attached to the same |
| 5 | 5 | //! item. |
| 6 | 6 | |
| 7 | use crate::hir; | |
| 8 | use crate::{Item, ItemKind, TraitItem, TraitItemKind}; | |
| 7 | use std::fmt::{self, Display}; | |
| 9 | 8 | |
| 10 | 9 | use crate::def::DefKind; |
| 11 | use std::fmt::{self, Display}; | |
| 10 | use crate::{hir, Item, ItemKind, TraitItem, TraitItemKind}; | |
| 12 | 11 | |
| 13 | 12 | #[derive(Copy, Clone, PartialEq, Debug)] |
| 14 | 13 | pub enum GenericParamKind { |
compiler/rustc_hir/src/tests.rs+2-1| ... | ... | @@ -1,9 +1,10 @@ |
| 1 | use crate::definitions::{DefKey, DefPathData, DisambiguatedDefPathData}; | |
| 2 | 1 | use rustc_data_structures::stable_hasher::Hash64; |
| 3 | 2 | use rustc_span::def_id::{DefPathHash, StableCrateId}; |
| 4 | 3 | use rustc_span::edition::Edition; |
| 5 | 4 | use rustc_span::{create_session_globals_then, Symbol}; |
| 6 | 5 | |
| 6 | use crate::definitions::{DefKey, DefPathData, DisambiguatedDefPathData}; | |
| 7 | ||
| 7 | 8 | #[test] |
| 8 | 9 | fn def_path_hash_depends_on_crate_id() { |
| 9 | 10 | // This test makes sure that *both* halves of a DefPathHash depend on |
compiler/rustc_hir/src/weak_lang_items.rs+2-2| ... | ... | @@ -1,9 +1,9 @@ |
| 1 | 1 | //! Validity checking for weak lang items |
| 2 | 2 | |
| 3 | use crate::LangItem; | |
| 4 | ||
| 5 | 3 | use rustc_span::symbol::{sym, Symbol}; |
| 6 | 4 | |
| 5 | use crate::LangItem; | |
| 6 | ||
| 7 | 7 | macro_rules! weak_lang_items { |
| 8 | 8 | ($($item:ident, $sym:ident;)*) => { |
| 9 | 9 | pub static WEAK_LANG_ITEMS: &[LangItem] = &[$(LangItem::$item,)*]; |
compiler/rustc_hir_analysis/src/autoderef.rs+6-7| ... | ... | @@ -1,15 +1,14 @@ |
| 1 | use crate::errors::AutoDerefReachedRecursionLimit; | |
| 2 | use crate::traits; | |
| 3 | use crate::traits::query::evaluate_obligation::InferCtxtExt; | |
| 4 | 1 | use rustc_infer::infer::InferCtxt; |
| 5 | use rustc_middle::ty::TypeVisitableExt; | |
| 6 | use rustc_middle::ty::{self, Ty, TyCtxt}; | |
| 2 | use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitableExt}; | |
| 7 | 3 | use rustc_session::Limit; |
| 8 | use rustc_span::def_id::LocalDefId; | |
| 9 | use rustc_span::def_id::LOCAL_CRATE; | |
| 4 | use rustc_span::def_id::{LocalDefId, LOCAL_CRATE}; | |
| 10 | 5 | use rustc_span::Span; |
| 11 | 6 | use rustc_trait_selection::traits::ObligationCtxt; |
| 12 | 7 | |
| 8 | use crate::errors::AutoDerefReachedRecursionLimit; | |
| 9 | use crate::traits; | |
| 10 | use crate::traits::query::evaluate_obligation::InferCtxtExt; | |
| 11 | ||
| 13 | 12 | #[derive(Copy, Clone, Debug)] |
| 14 | 13 | pub enum AutoderefKind { |
| 15 | 14 | /// A true pointer type, such as `&T` and `*mut T`. |
compiler/rustc_hir_analysis/src/check/check.rs+10-11| ... | ... | @@ -1,12 +1,9 @@ |
| 1 | use crate::check::intrinsicck::InlineAsmCtxt; | |
| 1 | use std::cell::LazyCell; | |
| 2 | use std::ops::ControlFlow; | |
| 2 | 3 | |
| 3 | use super::compare_impl_item::check_type_bounds; | |
| 4 | use super::compare_impl_item::{compare_impl_method, compare_impl_ty}; | |
| 5 | use super::*; | |
| 6 | use rustc_attr as attr; | |
| 7 | 4 | use rustc_data_structures::unord::{UnordMap, UnordSet}; |
| 8 | use rustc_errors::{codes::*, MultiSpan}; | |
| 9 | use rustc_hir as hir; | |
| 5 | use rustc_errors::codes::*; | |
| 6 | use rustc_errors::MultiSpan; | |
| 10 | 7 | use rustc_hir::def::{CtorKind, DefKind}; |
| 11 | 8 | use rustc_hir::Node; |
| 12 | 9 | use rustc_infer::infer::{RegionVariableOrigin, TyCtxtInferExt}; |
| ... | ... | @@ -19,9 +16,9 @@ use rustc_middle::ty::error::TypeErrorToStringExt; |
| 19 | 16 | use rustc_middle::ty::fold::BottomUpFolder; |
| 20 | 17 | use rustc_middle::ty::layout::{LayoutError, MAX_SIMD_LANES}; |
| 21 | 18 | use rustc_middle::ty::util::{Discr, InspectCoroutineFields, IntTypeExt}; |
| 22 | use rustc_middle::ty::GenericArgKind; | |
| 23 | 19 | use rustc_middle::ty::{ |
| 24 | AdtDef, ParamEnv, RegionKind, TypeSuperVisitable, TypeVisitable, TypeVisitableExt, | |
| 20 | AdtDef, GenericArgKind, ParamEnv, RegionKind, TypeSuperVisitable, TypeVisitable, | |
| 21 | TypeVisitableExt, | |
| 25 | 22 | }; |
| 26 | 23 | use rustc_session::lint::builtin::{UNINHABITED_STATIC, UNSUPPORTED_CALLING_CONVENTIONS}; |
| 27 | 24 | use rustc_target::abi::FieldIdx; |
| ... | ... | @@ -30,9 +27,11 @@ use rustc_trait_selection::error_reporting::InferCtxtErrorExt; |
| 30 | 27 | use rustc_trait_selection::traits; |
| 31 | 28 | use rustc_trait_selection::traits::outlives_bounds::InferCtxtExt as _; |
| 32 | 29 | use rustc_type_ir::fold::TypeFoldable; |
| 30 | use {rustc_attr as attr, rustc_hir as hir}; | |
| 33 | 31 | |
| 34 | use std::cell::LazyCell; | |
| 35 | use std::ops::ControlFlow; | |
| 32 | use super::compare_impl_item::{check_type_bounds, compare_impl_method, compare_impl_ty}; | |
| 33 | use super::*; | |
| 34 | use crate::check::intrinsicck::InlineAsmCtxt; | |
| 36 | 35 | |
| 37 | 36 | pub fn check_abi(tcx: TyCtxt<'_>, hir_id: hir::HirId, span: Span, abi: Abi) { |
| 38 | 37 | match tcx.sess.target.is_abi_supported(abi) { |
compiler/rustc_hir_analysis/src/check/compare_impl_item.rs+11-10| ... | ... | @@ -1,24 +1,24 @@ |
| 1 | use super::potentially_plural_count; | |
| 2 | use crate::errors::{LifetimesOrBoundsMismatchOnTrait, MethodShouldReturnFuture}; | |
| 3 | 1 | use core::ops::ControlFlow; |
| 2 | use std::borrow::Cow; | |
| 3 | use std::iter; | |
| 4 | ||
| 4 | 5 | use hir::def_id::{DefId, DefIdMap, LocalDefId}; |
| 5 | 6 | use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet}; |
| 6 | use rustc_errors::{codes::*, pluralize, struct_span_code_err, Applicability, ErrorGuaranteed}; | |
| 7 | use rustc_errors::codes::*; | |
| 8 | use rustc_errors::{pluralize, struct_span_code_err, Applicability, ErrorGuaranteed}; | |
| 7 | 9 | use rustc_hir as hir; |
| 8 | 10 | use rustc_hir::def::{DefKind, Res}; |
| 9 | use rustc_hir::intravisit; | |
| 10 | use rustc_hir::{GenericParamKind, ImplItemKind}; | |
| 11 | use rustc_hir::{intravisit, GenericParamKind, ImplItemKind}; | |
| 11 | 12 | use rustc_infer::infer::outlives::env::OutlivesEnvironment; |
| 12 | 13 | use rustc_infer::infer::{self, InferCtxt, TyCtxtInferExt}; |
| 13 | 14 | use rustc_infer::traits::util; |
| 14 | 15 | use rustc_middle::ty::error::{ExpectedFound, TypeError}; |
| 15 | 16 | use rustc_middle::ty::fold::BottomUpFolder; |
| 16 | 17 | use rustc_middle::ty::util::ExplicitSelf; |
| 17 | use rustc_middle::ty::Upcast; | |
| 18 | 18 | use rustc_middle::ty::{ |
| 19 | self, GenericArgs, Ty, TypeFoldable, TypeFolder, TypeSuperFoldable, TypeVisitableExt, | |
| 19 | self, GenericArgs, GenericParamDefKind, Ty, TyCtxt, TypeFoldable, TypeFolder, | |
| 20 | TypeSuperFoldable, TypeVisitableExt, Upcast, | |
| 20 | 21 | }; |
| 21 | use rustc_middle::ty::{GenericParamDefKind, TyCtxt}; | |
| 22 | 22 | use rustc_middle::{bug, span_bug}; |
| 23 | 23 | use rustc_span::Span; |
| 24 | 24 | use rustc_trait_selection::error_reporting::InferCtxtErrorExt; |
| ... | ... | @@ -28,8 +28,9 @@ use rustc_trait_selection::traits::outlives_bounds::InferCtxtExt as _; |
| 28 | 28 | use rustc_trait_selection::traits::{ |
| 29 | 29 | self, FulfillmentError, ObligationCause, ObligationCauseCode, ObligationCtxt, Reveal, |
| 30 | 30 | }; |
| 31 | use std::borrow::Cow; | |
| 32 | use std::iter; | |
| 31 | ||
| 32 | use super::potentially_plural_count; | |
| 33 | use crate::errors::{LifetimesOrBoundsMismatchOnTrait, MethodShouldReturnFuture}; | |
| 33 | 34 | |
| 34 | 35 | mod refine; |
| 35 | 36 |
compiler/rustc_hir_analysis/src/check/compare_impl_item/refine.rs+4-4| ... | ... | @@ -1,7 +1,8 @@ |
| 1 | 1 | use rustc_data_structures::fx::FxIndexSet; |
| 2 | 2 | use rustc_hir as hir; |
| 3 | 3 | use rustc_hir::def_id::DefId; |
| 4 | use rustc_infer::infer::{outlives::env::OutlivesEnvironment, TyCtxtInferExt}; | |
| 4 | use rustc_infer::infer::outlives::env::OutlivesEnvironment; | |
| 5 | use rustc_infer::infer::TyCtxtInferExt; | |
| 5 | 6 | use rustc_lint_defs::builtin::{REFINING_IMPL_TRAIT_INTERNAL, REFINING_IMPL_TRAIT_REACHABLE}; |
| 6 | 7 | use rustc_middle::span_bug; |
| 7 | 8 | use rustc_middle::traits::{ObligationCause, Reveal}; |
| ... | ... | @@ -10,9 +11,8 @@ use rustc_middle::ty::{ |
| 10 | 11 | }; |
| 11 | 12 | use rustc_span::Span; |
| 12 | 13 | use rustc_trait_selection::regions::InferCtxtRegionExt; |
| 13 | use rustc_trait_selection::traits::{ | |
| 14 | elaborate, normalize_param_env_or_error, outlives_bounds::InferCtxtExt, ObligationCtxt, | |
| 15 | }; | |
| 14 | use rustc_trait_selection::traits::outlives_bounds::InferCtxtExt; | |
| 15 | use rustc_trait_selection::traits::{elaborate, normalize_param_env_or_error, ObligationCtxt}; | |
| 16 | 16 | |
| 17 | 17 | /// Check that an implementation does not refine an RPITIT from a trait method signature. |
| 18 | 18 | pub(super) fn check_refining_return_position_impl_trait_in_trait<'tcx>( |
compiler/rustc_hir_analysis/src/check/dropck.rs+3-3| ... | ... | @@ -3,13 +3,13 @@ |
| 3 | 3 | // We don't do any drop checking during hir typeck. |
| 4 | 4 | |
| 5 | 5 | use rustc_data_structures::fx::FxHashSet; |
| 6 | use rustc_errors::{codes::*, struct_span_code_err, ErrorGuaranteed}; | |
| 6 | use rustc_errors::codes::*; | |
| 7 | use rustc_errors::{struct_span_code_err, ErrorGuaranteed}; | |
| 7 | 8 | use rustc_infer::infer::outlives::env::OutlivesEnvironment; |
| 8 | 9 | use rustc_infer::infer::{RegionResolutionError, TyCtxtInferExt}; |
| 9 | 10 | use rustc_infer::traits::{ObligationCause, ObligationCauseCode}; |
| 10 | 11 | use rustc_middle::ty::util::CheckRegions; |
| 11 | use rustc_middle::ty::{self, TyCtxt}; | |
| 12 | use rustc_middle::ty::{GenericArgsRef, Ty}; | |
| 12 | use rustc_middle::ty::{self, GenericArgsRef, Ty, TyCtxt}; | |
| 13 | 13 | use rustc_trait_selection::regions::InferCtxtRegionExt; |
| 14 | 14 | use rustc_trait_selection::traits::{self, ObligationCtxt}; |
| 15 | 15 |
compiler/rustc_hir_analysis/src/check/entry.rs+4-3| ... | ... | @@ -1,3 +1,5 @@ |
| 1 | use std::ops::Not; | |
| 2 | ||
| 1 | 3 | use rustc_hir as hir; |
| 2 | 4 | use rustc_hir::Node; |
| 3 | 5 | use rustc_infer::infer::TyCtxtInferExt; |
| ... | ... | @@ -5,13 +7,12 @@ use rustc_middle::span_bug; |
| 5 | 7 | use rustc_middle::ty::{self, Ty, TyCtxt}; |
| 6 | 8 | use rustc_session::config::EntryFnType; |
| 7 | 9 | use rustc_span::def_id::{DefId, LocalDefId, CRATE_DEF_ID}; |
| 8 | use rustc_span::{symbol::sym, Span}; | |
| 10 | use rustc_span::symbol::sym; | |
| 11 | use rustc_span::Span; | |
| 9 | 12 | use rustc_target::spec::abi::Abi; |
| 10 | 13 | use rustc_trait_selection::error_reporting::InferCtxtErrorExt; |
| 11 | 14 | use rustc_trait_selection::traits::{self, ObligationCause, ObligationCauseCode}; |
| 12 | 15 | |
| 13 | use std::ops::Not; | |
| 14 | ||
| 15 | 16 | use super::check_function_signature; |
| 16 | 17 | use crate::errors; |
| 17 | 18 |
compiler/rustc_hir_analysis/src/check/intrinsic.rs+8-7| ... | ... | @@ -1,13 +1,8 @@ |
| 1 | 1 | //! Type-checking for the rust-intrinsic and platform-intrinsic |
| 2 | 2 | //! intrinsics that the compiler exposes. |
| 3 | 3 | |
| 4 | use crate::check::check_function_signature; | |
| 5 | use crate::errors::{ | |
| 6 | UnrecognizedAtomicOperation, UnrecognizedIntrinsicFunction, | |
| 7 | WrongNumberOfGenericArgumentsToIntrinsic, | |
| 8 | }; | |
| 9 | ||
| 10 | use rustc_errors::{codes::*, struct_span_code_err, DiagMessage}; | |
| 4 | use rustc_errors::codes::*; | |
| 5 | use rustc_errors::{struct_span_code_err, DiagMessage}; | |
| 11 | 6 | use rustc_hir as hir; |
| 12 | 7 | use rustc_middle::bug; |
| 13 | 8 | use rustc_middle::traits::{ObligationCause, ObligationCauseCode}; |
| ... | ... | @@ -17,6 +12,12 @@ use rustc_span::symbol::sym; |
| 17 | 12 | use rustc_span::{Span, Symbol}; |
| 18 | 13 | use rustc_target::spec::abi::Abi; |
| 19 | 14 | |
| 15 | use crate::check::check_function_signature; | |
| 16 | use crate::errors::{ | |
| 17 | UnrecognizedAtomicOperation, UnrecognizedIntrinsicFunction, | |
| 18 | WrongNumberOfGenericArgumentsToIntrinsic, | |
| 19 | }; | |
| 20 | ||
| 20 | 21 | fn equate_intrinsic_type<'tcx>( |
| 21 | 22 | tcx: TyCtxt<'tcx>, |
| 22 | 23 | span: Span, |
compiler/rustc_hir_analysis/src/check/mod.rs+6-10| ... | ... | @@ -72,13 +72,11 @@ pub mod intrinsicck; |
| 72 | 72 | mod region; |
| 73 | 73 | pub mod wfcheck; |
| 74 | 74 | |
| 75 | pub use check::check_abi; | |
| 76 | ||
| 77 | 75 | use std::num::NonZero; |
| 78 | 76 | |
| 77 | pub use check::check_abi; | |
| 79 | 78 | use rustc_data_structures::fx::{FxHashSet, FxIndexMap}; |
| 80 | use rustc_errors::ErrorGuaranteed; | |
| 81 | use rustc_errors::{pluralize, struct_span_code_err, Diag}; | |
| 79 | use rustc_errors::{pluralize, struct_span_code_err, Diag, ErrorGuaranteed}; | |
| 82 | 80 | use rustc_hir::def_id::{DefId, LocalDefId}; |
| 83 | 81 | use rustc_hir::intravisit::Visitor; |
| 84 | 82 | use rustc_index::bit_set::BitSet; |
| ... | ... | @@ -87,12 +85,12 @@ use rustc_infer::infer::{self, TyCtxtInferExt as _}; |
| 87 | 85 | use rustc_infer::traits::ObligationCause; |
| 88 | 86 | use rustc_middle::query::Providers; |
| 89 | 87 | use rustc_middle::ty::error::{ExpectedFound, TypeError}; |
| 90 | use rustc_middle::ty::{self, Ty, TyCtxt}; | |
| 91 | use rustc_middle::ty::{GenericArgs, GenericArgsRef}; | |
| 88 | use rustc_middle::ty::{self, GenericArgs, GenericArgsRef, Ty, TyCtxt}; | |
| 92 | 89 | use rustc_middle::{bug, span_bug}; |
| 93 | 90 | use rustc_session::parse::feature_err; |
| 91 | use rustc_span::def_id::CRATE_DEF_ID; | |
| 94 | 92 | use rustc_span::symbol::{kw, sym, Ident}; |
| 95 | use rustc_span::{def_id::CRATE_DEF_ID, BytePos, Span, Symbol, DUMMY_SP}; | |
| 93 | use rustc_span::{BytePos, Span, Symbol, DUMMY_SP}; | |
| 96 | 94 | use rustc_target::abi::VariantIdx; |
| 97 | 95 | use rustc_target::spec::abi::Abi; |
| 98 | 96 | use rustc_trait_selection::error_reporting::infer::ObligationCauseExt as _; |
| ... | ... | @@ -100,11 +98,9 @@ use rustc_trait_selection::error_reporting::traits::suggestions::ReturnsVisitor; |
| 100 | 98 | use rustc_trait_selection::error_reporting::InferCtxtErrorExt; |
| 101 | 99 | use rustc_trait_selection::traits::ObligationCtxt; |
| 102 | 100 | |
| 103 | use crate::errors; | |
| 104 | use crate::require_c_abi_if_c_variadic; | |
| 105 | ||
| 106 | 101 | use self::compare_impl_item::collect_return_position_impl_trait_in_trait_tys; |
| 107 | 102 | use self::region::region_scope_tree; |
| 103 | use crate::{errors, require_c_abi_if_c_variadic}; | |
| 108 | 104 | |
| 109 | 105 | pub fn provide(providers: &mut Providers) { |
| 110 | 106 | wfcheck::provide(providers); |
compiler/rustc_hir_analysis/src/check/region.rs+2-2| ... | ... | @@ -6,6 +6,8 @@ |
| 6 | 6 | //! |
| 7 | 7 | //! [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/borrow_check.html |
| 8 | 8 | |
| 9 | use std::mem; | |
| 10 | ||
| 9 | 11 | use rustc_data_structures::fx::FxHashSet; |
| 10 | 12 | use rustc_hir as hir; |
| 11 | 13 | use rustc_hir::def_id::DefId; |
| ... | ... | @@ -19,8 +21,6 @@ use rustc_span::source_map; |
| 19 | 21 | |
| 20 | 22 | use super::errs::{maybe_expr_static_mut, maybe_stmt_static_mut}; |
| 21 | 23 | |
| 22 | use std::mem; | |
| 23 | ||
| 24 | 24 | #[derive(Debug, Copy, Clone)] |
| 25 | 25 | pub struct Context { |
| 26 | 26 | /// The scope that contains any new variables declared, plus its depth in |
compiler/rustc_hir_analysis/src/check/wfcheck.rs+11-13| ... | ... | @@ -1,14 +1,10 @@ |
| 1 | use crate::autoderef::Autoderef; | |
| 2 | use crate::collect::CollectItemTypesVisitor; | |
| 3 | use crate::constrained_generic_params::{identify_constrained_generic_params, Parameter}; | |
| 4 | use crate::errors; | |
| 5 | use crate::fluent_generated as fluent; | |
| 1 | use std::cell::LazyCell; | |
| 2 | use std::ops::{ControlFlow, Deref}; | |
| 6 | 3 | |
| 7 | 4 | use hir::intravisit::{self, Visitor}; |
| 8 | use rustc_ast as ast; | |
| 9 | 5 | use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexSet}; |
| 10 | use rustc_errors::{codes::*, pluralize, struct_span_code_err, Applicability, ErrorGuaranteed}; | |
| 11 | use rustc_hir as hir; | |
| 6 | use rustc_errors::codes::*; | |
| 7 | use rustc_errors::{pluralize, struct_span_code_err, Applicability, ErrorGuaranteed}; | |
| 12 | 8 | use rustc_hir::def::{DefKind, Res}; |
| 13 | 9 | use rustc_hir::def_id::{DefId, LocalDefId, LocalModDefId}; |
| 14 | 10 | use rustc_hir::lang_items::LangItem; |
| ... | ... | @@ -20,10 +16,9 @@ use rustc_middle::query::Providers; |
| 20 | 16 | use rustc_middle::ty::print::with_no_trimmed_paths; |
| 21 | 17 | use rustc_middle::ty::trait_def::TraitSpecializationKind; |
| 22 | 18 | use rustc_middle::ty::{ |
| 23 | self, AdtKind, GenericParamDefKind, Ty, TyCtxt, TypeFoldable, TypeSuperVisitable, | |
| 24 | TypeVisitable, TypeVisitableExt, TypeVisitor, Upcast, | |
| 19 | self, AdtKind, GenericArgKind, GenericArgs, GenericParamDefKind, Ty, TyCtxt, TypeFoldable, | |
| 20 | TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor, Upcast, | |
| 25 | 21 | }; |
| 26 | use rustc_middle::ty::{GenericArgKind, GenericArgs}; | |
| 27 | 22 | use rustc_middle::{bug, span_bug}; |
| 28 | 23 | use rustc_session::parse::feature_err; |
| 29 | 24 | use rustc_span::symbol::{sym, Ident}; |
| ... | ... | @@ -41,9 +36,12 @@ use rustc_trait_selection::traits::{ |
| 41 | 36 | }; |
| 42 | 37 | use rustc_type_ir::solve::NoSolution; |
| 43 | 38 | use rustc_type_ir::TypeFlags; |
| 39 | use {rustc_ast as ast, rustc_hir as hir}; | |
| 44 | 40 | |
| 45 | use std::cell::LazyCell; | |
| 46 | use std::ops::{ControlFlow, Deref}; | |
| 41 | use crate::autoderef::Autoderef; | |
| 42 | use crate::collect::CollectItemTypesVisitor; | |
| 43 | use crate::constrained_generic_params::{identify_constrained_generic_params, Parameter}; | |
| 44 | use crate::{errors, fluent_generated as fluent}; | |
| 47 | 45 | |
| 48 | 46 | pub(super) struct WfCheckingCtxt<'a, 'tcx> { |
| 49 | 47 | pub(super) ocx: ObligationCtxt<'a, 'tcx, FulfillmentError<'tcx>>, |
compiler/rustc_hir_analysis/src/coherence/builtin.rs+5-6| ... | ... | @@ -1,7 +1,7 @@ |
| 1 | 1 | //! Check properties that are required by built-in traits and set |
| 2 | 2 | //! up data structures required by type-checking/codegen. |
| 3 | 3 | |
| 4 | use crate::errors; | |
| 4 | use std::collections::BTreeMap; | |
| 5 | 5 | |
| 6 | 6 | use rustc_data_structures::fx::FxHashSet; |
| 7 | 7 | use rustc_errors::{ErrorGuaranteed, MultiSpan}; |
| ... | ... | @@ -10,8 +10,7 @@ use rustc_hir::def_id::{DefId, LocalDefId}; |
| 10 | 10 | use rustc_hir::lang_items::LangItem; |
| 11 | 11 | use rustc_hir::ItemKind; |
| 12 | 12 | use rustc_infer::infer::outlives::env::OutlivesEnvironment; |
| 13 | use rustc_infer::infer::TyCtxtInferExt; | |
| 14 | use rustc_infer::infer::{self, RegionResolutionError}; | |
| 13 | use rustc_infer::infer::{self, RegionResolutionError, TyCtxtInferExt}; | |
| 15 | 14 | use rustc_infer::traits::Obligation; |
| 16 | 15 | use rustc_middle::ty::adjustment::CoerceUnsizedInfo; |
| 17 | 16 | use rustc_middle::ty::print::PrintTraitRefExt as _; |
| ... | ... | @@ -22,9 +21,9 @@ use rustc_trait_selection::traits::misc::{ |
| 22 | 21 | type_allowed_to_implement_const_param_ty, type_allowed_to_implement_copy, |
| 23 | 22 | ConstParamTyImplementationError, CopyImplementationError, InfringingFieldsReason, |
| 24 | 23 | }; |
| 25 | use rustc_trait_selection::traits::ObligationCtxt; | |
| 26 | use rustc_trait_selection::traits::{self, ObligationCause}; | |
| 27 | use std::collections::BTreeMap; | |
| 24 | use rustc_trait_selection::traits::{self, ObligationCause, ObligationCtxt}; | |
| 25 | ||
| 26 | use crate::errors; | |
| 28 | 27 | |
| 29 | 28 | pub(super) fn check_trait<'tcx>( |
| 30 | 29 | tcx: TyCtxt<'tcx>, |
compiler/rustc_hir_analysis/src/coherence/inherent_impls_overlap.rs+3-3| ... | ... | @@ -1,6 +1,6 @@ |
| 1 | use rustc_data_structures::fx::IndexEntry; | |
| 2 | use rustc_data_structures::fx::{FxHashSet, FxIndexMap}; | |
| 3 | use rustc_errors::{codes::*, struct_span_code_err}; | |
| 1 | use rustc_data_structures::fx::{FxHashSet, FxIndexMap, IndexEntry}; | |
| 2 | use rustc_errors::codes::*; | |
| 3 | use rustc_errors::struct_span_code_err; | |
| 4 | 4 | use rustc_hir as hir; |
| 5 | 5 | use rustc_hir::def::DefKind; |
| 6 | 6 | use rustc_hir::def_id::DefId; |
compiler/rustc_hir_analysis/src/coherence/mod.rs+4-2| ... | ... | @@ -5,8 +5,8 @@ |
| 5 | 5 | // done by the orphan and overlap modules. Then we build up various |
| 6 | 6 | // mappings. That mapping code resides here. |
| 7 | 7 | |
| 8 | use crate::errors; | |
| 9 | use rustc_errors::{codes::*, struct_span_code_err}; | |
| 8 | use rustc_errors::codes::*; | |
| 9 | use rustc_errors::struct_span_code_err; | |
| 10 | 10 | use rustc_hir::def_id::{DefId, LocalDefId}; |
| 11 | 11 | use rustc_hir::LangItem; |
| 12 | 12 | use rustc_middle::query::Providers; |
| ... | ... | @@ -14,6 +14,8 @@ use rustc_middle::ty::{self, TyCtxt, TypeVisitableExt}; |
| 14 | 14 | use rustc_session::parse::feature_err; |
| 15 | 15 | use rustc_span::{sym, ErrorGuaranteed}; |
| 16 | 16 | |
| 17 | use crate::errors; | |
| 18 | ||
| 17 | 19 | mod builtin; |
| 18 | 20 | mod inherent_impls; |
| 19 | 21 | mod inherent_impls_overlap; |
compiler/rustc_hir_analysis/src/coherence/orphan.rs+9-7| ... | ... | @@ -1,19 +1,21 @@ |
| 1 | 1 | //! Orphan checker: every impl either implements a trait defined in this |
| 2 | 2 | //! crate or pertains to a type defined in this crate. |
| 3 | 3 | |
| 4 | use crate::errors; | |
| 5 | ||
| 6 | 4 | use rustc_data_structures::fx::FxIndexSet; |
| 7 | 5 | use rustc_errors::ErrorGuaranteed; |
| 8 | 6 | use rustc_infer::infer::{InferCtxt, TyCtxtInferExt}; |
| 9 | 7 | use rustc_lint_defs::builtin::UNCOVERED_PARAM_IN_PROJECTION; |
| 10 | use rustc_middle::ty::{self, Ty, TyCtxt}; | |
| 11 | use rustc_middle::ty::{TypeFoldable, TypeFolder, TypeSuperFoldable}; | |
| 12 | use rustc_middle::ty::{TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor}; | |
| 8 | use rustc_middle::ty::{ | |
| 9 | self, Ty, TyCtxt, TypeFoldable, TypeFolder, TypeSuperFoldable, TypeSuperVisitable, | |
| 10 | TypeVisitable, TypeVisitableExt, TypeVisitor, | |
| 11 | }; | |
| 13 | 12 | use rustc_middle::{bug, span_bug}; |
| 14 | 13 | use rustc_span::def_id::{DefId, LocalDefId}; |
| 15 | use rustc_trait_selection::traits::{self, IsFirstInputType, UncoveredTyParams}; | |
| 16 | use rustc_trait_selection::traits::{OrphanCheckErr, OrphanCheckMode}; | |
| 14 | use rustc_trait_selection::traits::{ | |
| 15 | self, IsFirstInputType, OrphanCheckErr, OrphanCheckMode, UncoveredTyParams, | |
| 16 | }; | |
| 17 | ||
| 18 | use crate::errors; | |
| 17 | 19 | |
| 18 | 20 | #[instrument(level = "debug", skip(tcx))] |
| 19 | 21 | pub(crate) fn orphan_check_impl( |
compiler/rustc_hir_analysis/src/coherence/unsafety.rs+4-2| ... | ... | @@ -1,10 +1,12 @@ |
| 1 | 1 | //! Unsafety checker: every impl either implements a trait defined in this |
| 2 | 2 | //! crate or pertains to a type defined in this crate. |
| 3 | 3 | |
| 4 | use rustc_errors::{codes::*, struct_span_code_err}; | |
| 4 | use rustc_errors::codes::*; | |
| 5 | use rustc_errors::struct_span_code_err; | |
| 5 | 6 | use rustc_hir::Safety; |
| 6 | 7 | use rustc_middle::ty::print::PrintTraitRefExt as _; |
| 7 | use rustc_middle::ty::{ImplPolarity::*, ImplTraitHeader, TraitDef, TyCtxt}; | |
| 8 | use rustc_middle::ty::ImplPolarity::*; | |
| 9 | use rustc_middle::ty::{ImplTraitHeader, TraitDef, TyCtxt}; | |
| 8 | 10 | use rustc_span::def_id::LocalDefId; |
| 9 | 11 | use rustc_span::ErrorGuaranteed; |
| 10 | 12 |
compiler/rustc_hir_analysis/src/collect.rs+5-5| ... | ... | @@ -14,6 +14,10 @@ |
| 14 | 14 | //! At present, however, we do run collection across all items in the |
| 15 | 15 | //! crate as a kind of pass. This should eventually be factored away. |
| 16 | 16 | |
| 17 | use std::cell::Cell; | |
| 18 | use std::iter; | |
| 19 | use std::ops::Bound; | |
| 20 | ||
| 17 | 21 | use rustc_ast::Recovered; |
| 18 | 22 | use rustc_data_structures::captures::Captures; |
| 19 | 23 | use rustc_data_structures::fx::{FxHashSet, FxIndexMap}; |
| ... | ... | @@ -24,8 +28,7 @@ use rustc_errors::{ |
| 24 | 28 | use rustc_hir::def::DefKind; |
| 25 | 29 | use rustc_hir::def_id::{DefId, LocalDefId}; |
| 26 | 30 | use rustc_hir::intravisit::{self, walk_generics, Visitor}; |
| 27 | use rustc_hir::{self as hir}; | |
| 28 | use rustc_hir::{GenericParamKind, Node}; | |
| 31 | use rustc_hir::{self as hir, GenericParamKind, Node}; | |
| 29 | 32 | use rustc_infer::infer::{InferCtxt, TyCtxtInferExt}; |
| 30 | 33 | use rustc_infer::traits::ObligationCause; |
| 31 | 34 | use rustc_middle::hir::nested_filter; |
| ... | ... | @@ -39,9 +42,6 @@ use rustc_target::spec::abi; |
| 39 | 42 | use rustc_trait_selection::error_reporting::traits::suggestions::NextTypeParamName; |
| 40 | 43 | use rustc_trait_selection::infer::InferCtxtExt; |
| 41 | 44 | use rustc_trait_selection::traits::ObligationCtxt; |
| 42 | use std::cell::Cell; | |
| 43 | use std::iter; | |
| 44 | use std::ops::Bound; | |
| 45 | 45 | |
| 46 | 46 | use crate::check::intrinsic::intrinsic_operation_unsafety; |
| 47 | 47 | use crate::errors; |
compiler/rustc_hir_analysis/src/collect/generics_of.rs+4-5| ... | ... | @@ -1,10 +1,7 @@ |
| 1 | 1 | use std::ops::ControlFlow; |
| 2 | 2 | |
| 3 | use crate::middle::resolve_bound_vars as rbv; | |
| 4 | use hir::{ | |
| 5 | intravisit::{self, Visitor}, | |
| 6 | GenericParamKind, HirId, Node, | |
| 7 | }; | |
| 3 | use hir::intravisit::{self, Visitor}; | |
| 4 | use hir::{GenericParamKind, HirId, Node}; | |
| 8 | 5 | use rustc_hir as hir; |
| 9 | 6 | use rustc_hir::def::DefKind; |
| 10 | 7 | use rustc_hir::def_id::LocalDefId; |
| ... | ... | @@ -13,6 +10,8 @@ use rustc_session::lint; |
| 13 | 10 | use rustc_span::symbol::{kw, Symbol}; |
| 14 | 11 | use rustc_span::Span; |
| 15 | 12 | |
| 13 | use crate::middle::resolve_bound_vars as rbv; | |
| 14 | ||
| 16 | 15 | #[instrument(level = "debug", skip(tcx), ret)] |
| 17 | 16 | pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Generics { |
| 18 | 17 | use rustc_hir::*; |
compiler/rustc_hir_analysis/src/collect/item_bounds.rs+6-4| ... | ... | @@ -1,15 +1,17 @@ |
| 1 | use super::ItemCtxt; | |
| 2 | use crate::hir_ty_lowering::{HirTyLowerer, PredicateFilter}; | |
| 3 | 1 | use rustc_data_structures::fx::FxIndexSet; |
| 4 | 2 | use rustc_hir as hir; |
| 5 | 3 | use rustc_infer::traits::util; |
| 6 | use rustc_middle::ty::GenericArgs; | |
| 7 | use rustc_middle::ty::{self, Ty, TyCtxt, TypeFoldable, TypeFolder, TypeSuperFoldable}; | |
| 4 | use rustc_middle::ty::{ | |
| 5 | self, GenericArgs, Ty, TyCtxt, TypeFoldable, TypeFolder, TypeSuperFoldable, | |
| 6 | }; | |
| 8 | 7 | use rustc_middle::{bug, span_bug}; |
| 9 | 8 | use rustc_span::def_id::{DefId, LocalDefId}; |
| 10 | 9 | use rustc_span::Span; |
| 11 | 10 | use rustc_type_ir::Upcast; |
| 12 | 11 | |
| 12 | use super::ItemCtxt; | |
| 13 | use crate::hir_ty_lowering::{HirTyLowerer, PredicateFilter}; | |
| 14 | ||
| 13 | 15 | /// For associated types we include both bounds written on the type |
| 14 | 16 | /// (`type X: Trait`) and predicates from the trait: `where Self::X: Trait`. |
| 15 | 17 | /// |
compiler/rustc_hir_analysis/src/collect/predicates_of.rs+6-6| ... | ... | @@ -1,19 +1,19 @@ |
| 1 | use crate::bounds::Bounds; | |
| 2 | use crate::collect::ItemCtxt; | |
| 3 | use crate::constrained_generic_params as cgp; | |
| 4 | use crate::hir_ty_lowering::{HirTyLowerer, OnlySelfBounds, PredicateFilter, RegionInferReason}; | |
| 5 | 1 | use hir::{HirId, Node}; |
| 6 | 2 | use rustc_data_structures::fx::FxIndexSet; |
| 7 | 3 | use rustc_hir as hir; |
| 8 | 4 | use rustc_hir::def::DefKind; |
| 9 | 5 | use rustc_hir::def_id::{DefId, LocalDefId}; |
| 10 | 6 | use rustc_hir::intravisit::{self, Visitor}; |
| 11 | use rustc_middle::ty::{self, Ty, TyCtxt}; | |
| 12 | use rustc_middle::ty::{GenericPredicates, ImplTraitInTraitData, Upcast}; | |
| 7 | use rustc_middle::ty::{self, GenericPredicates, ImplTraitInTraitData, Ty, TyCtxt, Upcast}; | |
| 13 | 8 | use rustc_middle::{bug, span_bug}; |
| 14 | 9 | use rustc_span::symbol::Ident; |
| 15 | 10 | use rustc_span::{Span, DUMMY_SP}; |
| 16 | 11 | |
| 12 | use crate::bounds::Bounds; | |
| 13 | use crate::collect::ItemCtxt; | |
| 14 | use crate::constrained_generic_params as cgp; | |
| 15 | use crate::hir_ty_lowering::{HirTyLowerer, OnlySelfBounds, PredicateFilter, RegionInferReason}; | |
| 16 | ||
| 17 | 17 | /// Returns a list of all type predicates (explicit and implicit) for the definition with |
| 18 | 18 | /// ID `def_id`. This includes all predicates returned by `predicates_defined_on`, plus |
| 19 | 19 | /// `Self: Trait` predicates for traits. |
compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs+2-1| ... | ... | @@ -7,6 +7,8 @@ |
| 7 | 7 | //! is also responsible for assigning their semantics to implicit lifetimes in trait objects. |
| 8 | 8 | |
| 9 | 9 | use core::ops::ControlFlow; |
| 10 | use std::fmt; | |
| 11 | ||
| 10 | 12 | use rustc_ast::visit::walk_list; |
| 11 | 13 | use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet}; |
| 12 | 14 | use rustc_hir as hir; |
| ... | ... | @@ -23,7 +25,6 @@ use rustc_middle::{bug, span_bug}; |
| 23 | 25 | use rustc_span::def_id::DefId; |
| 24 | 26 | use rustc_span::symbol::{sym, Ident}; |
| 25 | 27 | use rustc_span::Span; |
| 26 | use std::fmt; | |
| 27 | 28 | |
| 28 | 29 | use crate::errors; |
| 29 | 30 |
compiler/rustc_hir_analysis/src/collect/type_of.rs+2-3| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | 1 | use core::ops::ControlFlow; |
| 2 | ||
| 2 | 3 | use rustc_errors::{Applicability, StashKey}; |
| 3 | 4 | use rustc_hir as hir; |
| 4 | 5 | use rustc_hir::def_id::{DefId, LocalDefId}; |
| ... | ... | @@ -11,12 +12,10 @@ use rustc_middle::{bug, span_bug}; |
| 11 | 12 | use rustc_span::symbol::Ident; |
| 12 | 13 | use rustc_span::{Span, DUMMY_SP}; |
| 13 | 14 | |
| 15 | use super::{bad_placeholder, ItemCtxt}; | |
| 14 | 16 | use crate::errors::TypeofReservedKeywordUsed; |
| 15 | 17 | use crate::hir_ty_lowering::HirTyLowerer; |
| 16 | 18 | |
| 17 | use super::bad_placeholder; | |
| 18 | use super::ItemCtxt; | |
| 19 | ||
| 20 | 19 | mod opaque; |
| 21 | 20 | |
| 22 | 21 | fn anon_const_type_of<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> Ty<'tcx> { |
compiler/rustc_hir_analysis/src/errors.rs+6-3| ... | ... | @@ -1,12 +1,15 @@ |
| 1 | 1 | //! Errors emitted by `rustc_hir_analysis`. |
| 2 | 2 | |
| 3 | use crate::fluent_generated as fluent; | |
| 3 | use rustc_errors::codes::*; | |
| 4 | 4 | use rustc_errors::{ |
| 5 | codes::*, Applicability, Diag, DiagCtxtHandle, Diagnostic, EmissionGuarantee, Level, MultiSpan, | |
| 5 | Applicability, Diag, DiagCtxtHandle, Diagnostic, EmissionGuarantee, Level, MultiSpan, | |
| 6 | 6 | }; |
| 7 | 7 | use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic}; |
| 8 | 8 | use rustc_middle::ty::Ty; |
| 9 | use rustc_span::{symbol::Ident, Span, Symbol}; | |
| 9 | use rustc_span::symbol::Ident; | |
| 10 | use rustc_span::{Span, Symbol}; | |
| 11 | ||
| 12 | use crate::fluent_generated as fluent; | |
| 10 | 13 | mod pattern_types; |
| 11 | 14 | pub use pattern_types::*; |
| 12 | 15 | pub mod wrong_number_of_generic_args; |
compiler/rustc_hir_analysis/src/errors/wrong_number_of_generic_args.rs+4-5| ... | ... | @@ -1,11 +1,10 @@ |
| 1 | use rustc_errors::{ | |
| 2 | codes::*, pluralize, Applicability, Diag, Diagnostic, EmissionGuarantee, MultiSpan, | |
| 3 | }; | |
| 1 | use std::iter; | |
| 2 | ||
| 3 | use rustc_errors::codes::*; | |
| 4 | use rustc_errors::{pluralize, Applicability, Diag, Diagnostic, EmissionGuarantee, MultiSpan}; | |
| 4 | 5 | use rustc_hir as hir; |
| 5 | 6 | use rustc_middle::ty::{self as ty, AssocItems, AssocKind, TyCtxt}; |
| 6 | 7 | use rustc_span::def_id::DefId; |
| 7 | use std::iter; | |
| 8 | ||
| 9 | 8 | use GenericArgsInfo::*; |
| 10 | 9 | |
| 11 | 10 | /// Handles the `wrong number of type / lifetime / ... arguments` family of error messages. |
compiler/rustc_hir_analysis/src/hir_ty_lowering/bounds.rs+5-3| ... | ... | @@ -1,7 +1,8 @@ |
| 1 | 1 | use std::ops::ControlFlow; |
| 2 | 2 | |
| 3 | 3 | use rustc_data_structures::fx::{FxIndexMap, FxIndexSet}; |
| 4 | use rustc_errors::{codes::*, struct_span_code_err}; | |
| 4 | use rustc_errors::codes::*; | |
| 5 | use rustc_errors::struct_span_code_err; | |
| 5 | 6 | use rustc_hir as hir; |
| 6 | 7 | use rustc_hir::def::{DefKind, Res}; |
| 7 | 8 | use rustc_hir::def_id::{DefId, LocalDefId}; |
| ... | ... | @@ -15,8 +16,9 @@ use smallvec::SmallVec; |
| 15 | 16 | |
| 16 | 17 | use crate::bounds::Bounds; |
| 17 | 18 | use crate::errors; |
| 18 | use crate::hir_ty_lowering::HirTyLowerer; | |
| 19 | use crate::hir_ty_lowering::{AssocItemQSelf, OnlySelfBounds, PredicateFilter, RegionInferReason}; | |
| 19 | use crate::hir_ty_lowering::{ | |
| 20 | AssocItemQSelf, HirTyLowerer, OnlySelfBounds, PredicateFilter, RegionInferReason, | |
| 21 | }; | |
| 20 | 22 | |
| 21 | 23 | impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { |
| 22 | 24 | /// Add a `Sized` bound to the `bounds` if appropriate. |
compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs+15-16| ... | ... | @@ -1,15 +1,9 @@ |
| 1 | use crate::errors::{ | |
| 2 | self, AssocItemConstraintsNotAllowedHere, ManualImplementation, MissingTypeParams, | |
| 3 | ParenthesizedFnTraitExpansion, TraitObjectDeclaredWithNoTraits, | |
| 4 | }; | |
| 5 | use crate::fluent_generated as fluent; | |
| 6 | use crate::hir_ty_lowering::{AssocItemQSelf, HirTyLowerer}; | |
| 7 | 1 | use rustc_data_structures::fx::{FxIndexMap, FxIndexSet}; |
| 8 | 2 | use rustc_data_structures::sorted_map::SortedMap; |
| 9 | 3 | use rustc_data_structures::unord::UnordMap; |
| 10 | use rustc_errors::MultiSpan; | |
| 4 | use rustc_errors::codes::*; | |
| 11 | 5 | use rustc_errors::{ |
| 12 | codes::*, pluralize, struct_span_code_err, Applicability, Diag, ErrorGuaranteed, | |
| 6 | pluralize, struct_span_code_err, Applicability, Diag, ErrorGuaranteed, MultiSpan, | |
| 13 | 7 | }; |
| 14 | 8 | use rustc_hir as hir; |
| 15 | 9 | use rustc_hir::def::{DefKind, Res}; |
| ... | ... | @@ -17,21 +11,26 @@ use rustc_hir::def_id::DefId; |
| 17 | 11 | use rustc_middle::bug; |
| 18 | 12 | use rustc_middle::query::Key; |
| 19 | 13 | use rustc_middle::ty::print::{PrintPolyTraitRefExt as _, PrintTraitRefExt as _}; |
| 20 | use rustc_middle::ty::GenericParamDefKind; | |
| 21 | use rustc_middle::ty::{self, suggest_constraining_type_param}; | |
| 22 | use rustc_middle::ty::{AdtDef, Ty, TyCtxt, TypeVisitableExt}; | |
| 23 | use rustc_middle::ty::{Binder, TraitRef}; | |
| 14 | use rustc_middle::ty::{ | |
| 15 | self, suggest_constraining_type_param, AdtDef, Binder, GenericParamDefKind, TraitRef, Ty, | |
| 16 | TyCtxt, TypeVisitableExt, | |
| 17 | }; | |
| 24 | 18 | use rustc_session::parse::feature_err; |
| 25 | 19 | use rustc_span::edit_distance::find_best_match_for_name; |
| 26 | 20 | use rustc_span::symbol::{kw, sym, Ident}; |
| 27 | use rustc_span::BytePos; | |
| 28 | use rustc_span::{Span, Symbol, DUMMY_SP}; | |
| 21 | use rustc_span::{BytePos, Span, Symbol, DUMMY_SP}; | |
| 29 | 22 | use rustc_trait_selection::error_reporting::traits::report_object_safety_error; |
| 30 | use rustc_trait_selection::traits::FulfillmentError; | |
| 31 | 23 | use rustc_trait_selection::traits::{ |
| 32 | object_safety_violations_for_assoc_item, TraitAliasExpansionInfo, | |
| 24 | object_safety_violations_for_assoc_item, FulfillmentError, TraitAliasExpansionInfo, | |
| 33 | 25 | }; |
| 34 | 26 | |
| 27 | use crate::errors::{ | |
| 28 | self, AssocItemConstraintsNotAllowedHere, ManualImplementation, MissingTypeParams, | |
| 29 | ParenthesizedFnTraitExpansion, TraitObjectDeclaredWithNoTraits, | |
| 30 | }; | |
| 31 | use crate::fluent_generated as fluent; | |
| 32 | use crate::hir_ty_lowering::{AssocItemQSelf, HirTyLowerer}; | |
| 33 | ||
| 35 | 34 | impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { |
| 36 | 35 | /// On missing type parameters, emit an E0393 error and provide a structured suggestion using |
| 37 | 36 | /// the type parameter's name as a placeholder. |
compiler/rustc_hir_analysis/src/hir_ty_lowering/generics.rs+10-9| ... | ... | @@ -1,13 +1,6 @@ |
| 1 | use super::{HirTyLowerer, IsMethodCall}; | |
| 2 | use crate::errors::wrong_number_of_generic_args::{GenericArgsInfo, WrongNumberOfGenericArgs}; | |
| 3 | use crate::hir_ty_lowering::{ | |
| 4 | errors::prohibit_assoc_item_constraint, ExplicitLateBound, GenericArgCountMismatch, | |
| 5 | GenericArgCountResult, GenericArgPosition, GenericArgsLowerer, | |
| 6 | }; | |
| 7 | 1 | use rustc_ast::ast::ParamKindOrd; |
| 8 | use rustc_errors::{ | |
| 9 | codes::*, struct_span_code_err, Applicability, Diag, ErrorGuaranteed, MultiSpan, | |
| 10 | }; | |
| 2 | use rustc_errors::codes::*; | |
| 3 | use rustc_errors::{struct_span_code_err, Applicability, Diag, ErrorGuaranteed, MultiSpan}; | |
| 11 | 4 | use rustc_hir as hir; |
| 12 | 5 | use rustc_hir::def::{DefKind, Res}; |
| 13 | 6 | use rustc_hir::def_id::DefId; |
| ... | ... | @@ -19,6 +12,14 @@ use rustc_session::lint::builtin::LATE_BOUND_LIFETIME_ARGUMENTS; |
| 19 | 12 | use rustc_span::symbol::{kw, sym}; |
| 20 | 13 | use smallvec::SmallVec; |
| 21 | 14 | |
| 15 | use super::{HirTyLowerer, IsMethodCall}; | |
| 16 | use crate::errors::wrong_number_of_generic_args::{GenericArgsInfo, WrongNumberOfGenericArgs}; | |
| 17 | use crate::hir_ty_lowering::errors::prohibit_assoc_item_constraint; | |
| 18 | use crate::hir_ty_lowering::{ | |
| 19 | ExplicitLateBound, GenericArgCountMismatch, GenericArgCountResult, GenericArgPosition, | |
| 20 | GenericArgsLowerer, | |
| 21 | }; | |
| 22 | ||
| 22 | 23 | /// Report an error that a generic argument did not match the generic parameter that was |
| 23 | 24 | /// expected. |
| 24 | 25 | fn generic_arg_mismatch_err( |
compiler/rustc_hir_analysis/src/hir_ty_lowering/lint.rs+4-2| ... | ... | @@ -1,8 +1,10 @@ |
| 1 | 1 | use rustc_ast::TraitObjectSyntax; |
| 2 | use rustc_errors::{codes::*, Diag, EmissionGuarantee, StashKey}; | |
| 2 | use rustc_errors::codes::*; | |
| 3 | use rustc_errors::{Diag, EmissionGuarantee, StashKey}; | |
| 3 | 4 | use rustc_hir as hir; |
| 4 | 5 | use rustc_hir::def::{DefKind, Res}; |
| 5 | use rustc_lint_defs::{builtin::BARE_TRAIT_OBJECTS, Applicability}; | |
| 6 | use rustc_lint_defs::builtin::BARE_TRAIT_OBJECTS; | |
| 7 | use rustc_lint_defs::Applicability; | |
| 6 | 8 | use rustc_span::Span; |
| 7 | 9 | use rustc_trait_selection::error_reporting::traits::suggestions::NextTypeParamName; |
| 8 | 10 |
compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs+10-9| ... | ... | @@ -20,17 +20,13 @@ pub mod generics; |
| 20 | 20 | mod lint; |
| 21 | 21 | mod object_safety; |
| 22 | 22 | |
| 23 | use crate::bounds::Bounds; | |
| 24 | use crate::errors::{AmbiguousLifetimeBound, WildPatTy}; | |
| 25 | use crate::hir_ty_lowering::errors::{prohibit_assoc_item_constraint, GenericsArgsErrExtend}; | |
| 26 | use crate::hir_ty_lowering::generics::{check_generic_arg_count, lower_generic_args}; | |
| 27 | use crate::middle::resolve_bound_vars as rbv; | |
| 28 | use crate::require_c_abi_if_c_variadic; | |
| 23 | use std::slice; | |
| 24 | ||
| 29 | 25 | use rustc_ast::TraitObjectSyntax; |
| 30 | 26 | use rustc_data_structures::fx::{FxHashSet, FxIndexMap}; |
| 27 | use rustc_errors::codes::*; | |
| 31 | 28 | use rustc_errors::{ |
| 32 | codes::*, struct_span_code_err, Applicability, Diag, DiagCtxtHandle, ErrorGuaranteed, | |
| 33 | FatalError, | |
| 29 | struct_span_code_err, Applicability, Diag, DiagCtxtHandle, ErrorGuaranteed, FatalError, | |
| 34 | 30 | }; |
| 35 | 31 | use rustc_hir as hir; |
| 36 | 32 | use rustc_hir::def::{CtorOf, DefKind, Namespace, Res}; |
| ... | ... | @@ -55,7 +51,12 @@ use rustc_trait_selection::infer::InferCtxtExt; |
| 55 | 51 | use rustc_trait_selection::traits::wf::object_region_bounds; |
| 56 | 52 | use rustc_trait_selection::traits::{self, ObligationCtxt}; |
| 57 | 53 | |
| 58 | use std::slice; | |
| 54 | use crate::bounds::Bounds; | |
| 55 | use crate::errors::{AmbiguousLifetimeBound, WildPatTy}; | |
| 56 | use crate::hir_ty_lowering::errors::{prohibit_assoc_item_constraint, GenericsArgsErrExtend}; | |
| 57 | use crate::hir_ty_lowering::generics::{check_generic_arg_count, lower_generic_args}; | |
| 58 | use crate::middle::resolve_bound_vars as rbv; | |
| 59 | use crate::require_c_abi_if_c_variadic; | |
| 59 | 60 | |
| 60 | 61 | /// A path segment that is semantically allowed to have generic arguments. |
| 61 | 62 | #[derive(Debug)] |
compiler/rustc_hir_analysis/src/hir_ty_lowering/object_safety.rs+9-8| ... | ... | @@ -1,24 +1,25 @@ |
| 1 | use crate::bounds::Bounds; | |
| 2 | use crate::hir_ty_lowering::{ | |
| 3 | GenericArgCountMismatch, GenericArgCountResult, OnlySelfBounds, RegionInferReason, | |
| 4 | }; | |
| 5 | 1 | use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet}; |
| 6 | use rustc_errors::{codes::*, struct_span_code_err}; | |
| 2 | use rustc_errors::codes::*; | |
| 3 | use rustc_errors::struct_span_code_err; | |
| 7 | 4 | use rustc_hir as hir; |
| 8 | 5 | use rustc_hir::def::{DefKind, Res}; |
| 9 | 6 | use rustc_hir::def_id::DefId; |
| 10 | 7 | use rustc_lint_defs::builtin::UNUSED_ASSOCIATED_TYPE_BOUNDS; |
| 11 | 8 | use rustc_middle::span_bug; |
| 12 | 9 | use rustc_middle::ty::fold::BottomUpFolder; |
| 13 | use rustc_middle::ty::{self, ExistentialPredicateStableCmpExt as _, Ty, TyCtxt, TypeFoldable}; | |
| 14 | use rustc_middle::ty::{DynKind, Upcast}; | |
| 10 | use rustc_middle::ty::{ | |
| 11 | self, DynKind, ExistentialPredicateStableCmpExt as _, Ty, TyCtxt, TypeFoldable, Upcast, | |
| 12 | }; | |
| 15 | 13 | use rustc_span::{ErrorGuaranteed, Span}; |
| 16 | 14 | use rustc_trait_selection::error_reporting::traits::report_object_safety_error; |
| 17 | 15 | use rustc_trait_selection::traits::{self, hir_ty_lowering_object_safety_violations}; |
| 18 | ||
| 19 | 16 | use smallvec::{smallvec, SmallVec}; |
| 20 | 17 | |
| 21 | 18 | use super::HirTyLowerer; |
| 19 | use crate::bounds::Bounds; | |
| 20 | use crate::hir_ty_lowering::{ | |
| 21 | GenericArgCountMismatch, GenericArgCountResult, OnlySelfBounds, RegionInferReason, | |
| 22 | }; | |
| 22 | 23 | |
| 23 | 24 | impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { |
| 24 | 25 | /// Lower a trait object type from the HIR to our internal notion of a type. |
compiler/rustc_hir_analysis/src/hir_wf_check.rs+2-1| ... | ... | @@ -1,4 +1,3 @@ |
| 1 | use crate::collect::ItemCtxt; | |
| 2 | 1 | use rustc_hir as hir; |
| 3 | 2 | use rustc_hir::intravisit::{self, Visitor}; |
| 4 | 3 | use rustc_hir::{ForeignItem, ForeignItemKind}; |
| ... | ... | @@ -10,6 +9,8 @@ use rustc_middle::ty::{self, TyCtxt}; |
| 10 | 9 | use rustc_span::def_id::LocalDefId; |
| 11 | 10 | use rustc_trait_selection::traits::{self, ObligationCtxt}; |
| 12 | 11 | |
| 12 | use crate::collect::ItemCtxt; | |
| 13 | ||
| 13 | 14 | pub fn provide(providers: &mut Providers) { |
| 14 | 15 | *providers = Providers { diagnostic_hir_wf_check, ..*providers }; |
| 15 | 16 | } |
compiler/rustc_hir_analysis/src/impl_wf_check.rs+3-2| ... | ... | @@ -8,9 +8,7 @@ |
| 8 | 8 | //! specialization errors. These things can (and probably should) be |
| 9 | 9 | //! fixed, but for the moment it's easier to do these checks early. |
| 10 | 10 | |
| 11 | use crate::{constrained_generic_params as cgp, errors::UnconstrainedGenericParameter}; | |
| 12 | 11 | use min_specialization::check_min_specialization; |
| 13 | ||
| 14 | 12 | use rustc_data_structures::fx::FxHashSet; |
| 15 | 13 | use rustc_errors::codes::*; |
| 16 | 14 | use rustc_hir::def::DefKind; |
| ... | ... | @@ -18,6 +16,9 @@ use rustc_hir::def_id::LocalDefId; |
| 18 | 16 | use rustc_middle::ty::{self, TyCtxt, TypeVisitableExt}; |
| 19 | 17 | use rustc_span::ErrorGuaranteed; |
| 20 | 18 | |
| 19 | use crate::constrained_generic_params as cgp; | |
| 20 | use crate::errors::UnconstrainedGenericParameter; | |
| 21 | ||
| 21 | 22 | mod min_specialization; |
| 22 | 23 | |
| 23 | 24 | /// Checks that all the type/lifetime parameters on an impl also |
compiler/rustc_hir_analysis/src/impl_wf_check/min_specialization.rs+4-5| ... | ... | @@ -65,9 +65,6 @@ |
| 65 | 65 | //! cause use after frees with purely safe code in the same way as specializing |
| 66 | 66 | //! on traits with methods can. |
| 67 | 67 | |
| 68 | use crate::errors::GenericArgsOnOverriddenImpl; | |
| 69 | use crate::{constrained_generic_params as cgp, errors}; | |
| 70 | ||
| 71 | 68 | use rustc_data_structures::fx::FxHashSet; |
| 72 | 69 | use rustc_hir as hir; |
| 73 | 70 | use rustc_hir::def_id::{DefId, LocalDefId}; |
| ... | ... | @@ -75,13 +72,15 @@ use rustc_infer::infer::outlives::env::OutlivesEnvironment; |
| 75 | 72 | use rustc_infer::infer::TyCtxtInferExt; |
| 76 | 73 | use rustc_infer::traits::specialization_graph::Node; |
| 77 | 74 | use rustc_middle::ty::trait_def::TraitSpecializationKind; |
| 78 | use rustc_middle::ty::{self, TyCtxt, TypeVisitableExt}; | |
| 79 | use rustc_middle::ty::{GenericArg, GenericArgs, GenericArgsRef}; | |
| 75 | use rustc_middle::ty::{self, GenericArg, GenericArgs, GenericArgsRef, TyCtxt, TypeVisitableExt}; | |
| 80 | 76 | use rustc_span::{ErrorGuaranteed, Span}; |
| 81 | 77 | use rustc_trait_selection::error_reporting::InferCtxtErrorExt; |
| 82 | 78 | use rustc_trait_selection::traits::outlives_bounds::InferCtxtExt as _; |
| 83 | 79 | use rustc_trait_selection::traits::{self, translate_args_with_cause, wf, ObligationCtxt}; |
| 84 | 80 | |
| 81 | use crate::errors::GenericArgsOnOverriddenImpl; | |
| 82 | use crate::{constrained_generic_params as cgp, errors}; | |
| 83 | ||
| 85 | 84 | pub(super) fn check_min_specialization( |
| 86 | 85 | tcx: TyCtxt<'_>, |
| 87 | 86 | impl_def_id: LocalDefId, |
compiler/rustc_hir_analysis/src/lib.rs+2-1| ... | ... | @@ -100,7 +100,8 @@ use rustc_middle::mir::interpret::GlobalId; |
| 100 | 100 | use rustc_middle::query::Providers; |
| 101 | 101 | use rustc_middle::ty::{self, Ty, TyCtxt}; |
| 102 | 102 | use rustc_session::parse::feature_err; |
| 103 | use rustc_span::{symbol::sym, Span}; | |
| 103 | use rustc_span::symbol::sym; | |
| 104 | use rustc_span::Span; | |
| 104 | 105 | use rustc_target::spec::abi::Abi; |
| 105 | 106 | use rustc_trait_selection::traits; |
| 106 | 107 |
compiler/rustc_hir_analysis/src/outlives/implicit_infer.rs+1-2| ... | ... | @@ -1,8 +1,7 @@ |
| 1 | 1 | use rustc_data_structures::fx::FxIndexMap; |
| 2 | 2 | use rustc_hir::def::DefKind; |
| 3 | 3 | use rustc_hir::def_id::DefId; |
| 4 | use rustc_middle::ty::{self, Ty, TyCtxt}; | |
| 5 | use rustc_middle::ty::{GenericArg, GenericArgKind}; | |
| 4 | use rustc_middle::ty::{self, GenericArg, GenericArgKind, Ty, TyCtxt}; | |
| 6 | 5 | use rustc_span::Span; |
| 7 | 6 | |
| 8 | 7 | use super::explicit::ExplicitPredicatesMap; |
compiler/rustc_hir_analysis/src/outlives/mod.rs+1-2| ... | ... | @@ -1,8 +1,7 @@ |
| 1 | 1 | use rustc_hir::def::DefKind; |
| 2 | 2 | use rustc_hir::def_id::LocalDefId; |
| 3 | 3 | use rustc_middle::query::Providers; |
| 4 | use rustc_middle::ty::GenericArgKind; | |
| 5 | use rustc_middle::ty::{self, CratePredicatesMap, TyCtxt, Upcast}; | |
| 4 | use rustc_middle::ty::{self, CratePredicatesMap, GenericArgKind, TyCtxt, Upcast}; | |
| 6 | 5 | use rustc_span::Span; |
| 7 | 6 | |
| 8 | 7 | pub(crate) mod dump; |
compiler/rustc_hir_analysis/src/outlives/utils.rs+1-2| ... | ... | @@ -1,6 +1,5 @@ |
| 1 | 1 | use rustc_data_structures::fx::FxIndexMap; |
| 2 | use rustc_middle::ty::{self, Region, Ty, TyCtxt}; | |
| 3 | use rustc_middle::ty::{GenericArg, GenericArgKind}; | |
| 2 | use rustc_middle::ty::{self, GenericArg, GenericArgKind, Region, Ty, TyCtxt}; | |
| 4 | 3 | use rustc_middle::{bug, span_bug}; |
| 5 | 4 | use rustc_span::Span; |
| 6 | 5 | use rustc_type_ir::outlives::{push_outlives_components, Component}; |
compiler/rustc_hir_analysis/src/variance/constraints.rs+1-2| ... | ... | @@ -6,8 +6,7 @@ |
| 6 | 6 | use hir::def_id::{DefId, LocalDefId}; |
| 7 | 7 | use rustc_hir as hir; |
| 8 | 8 | use rustc_hir::def::DefKind; |
| 9 | use rustc_middle::ty::{self, Ty, TyCtxt}; | |
| 10 | use rustc_middle::ty::{GenericArgKind, GenericArgsRef}; | |
| 9 | use rustc_middle::ty::{self, GenericArgKind, GenericArgsRef, Ty, TyCtxt}; | |
| 11 | 10 | use rustc_middle::{bug, span_bug}; |
| 12 | 11 | |
| 13 | 12 | use super::terms::VarianceTerm::*; |
compiler/rustc_hir_analysis/src/variance/mod.rs+3-2| ... | ... | @@ -9,8 +9,9 @@ use rustc_hir::def::DefKind; |
| 9 | 9 | use rustc_hir::def_id::{DefId, LocalDefId}; |
| 10 | 10 | use rustc_middle::query::Providers; |
| 11 | 11 | use rustc_middle::span_bug; |
| 12 | use rustc_middle::ty::{self, CrateVariancesMap, GenericArgsRef, Ty, TyCtxt}; | |
| 13 | use rustc_middle::ty::{TypeSuperVisitable, TypeVisitable}; | |
| 12 | use rustc_middle::ty::{ | |
| 13 | self, CrateVariancesMap, GenericArgsRef, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, | |
| 14 | }; | |
| 14 | 15 | |
| 15 | 16 | /// Defines the `TermsContext` basically houses an arena where we can |
| 16 | 17 | /// allocate terms. |
compiler/rustc_hir_analysis/src/variance/terms.rs+2-1| ... | ... | @@ -9,11 +9,12 @@ |
| 9 | 9 | // `InferredIndex` is a newtype'd int representing the index of such |
| 10 | 10 | // a variable. |
| 11 | 11 | |
| 12 | use std::fmt; | |
| 13 | ||
| 12 | 14 | use rustc_arena::DroplessArena; |
| 13 | 15 | use rustc_hir::def::DefKind; |
| 14 | 16 | use rustc_hir::def_id::{LocalDefId, LocalDefIdMap}; |
| 15 | 17 | use rustc_middle::ty::{self, TyCtxt}; |
| 16 | use std::fmt; | |
| 17 | 18 | |
| 18 | 19 | use self::VarianceTerm::*; |
| 19 | 20 |
compiler/rustc_hir_pretty/src/lib.rs+4-5| ... | ... | @@ -5,12 +5,13 @@ |
| 5 | 5 | #![recursion_limit = "256"] |
| 6 | 6 | // tidy-alphabetical-end |
| 7 | 7 | |
| 8 | use rustc_ast as ast; | |
| 8 | use std::cell::Cell; | |
| 9 | use std::vec; | |
| 10 | ||
| 9 | 11 | use rustc_ast::util::parser::{self, AssocOp, Fixity}; |
| 10 | 12 | use rustc_ast_pretty::pp::Breaks::{Consistent, Inconsistent}; |
| 11 | 13 | use rustc_ast_pretty::pp::{self, Breaks}; |
| 12 | 14 | use rustc_ast_pretty::pprust::{Comments, PrintState}; |
| 13 | use rustc_hir as hir; | |
| 14 | 15 | use rustc_hir::{ |
| 15 | 16 | BindingMode, ByRef, ConstArgKind, GenericArg, GenericBound, GenericParam, GenericParamKind, |
| 16 | 17 | HirId, LifetimeParamKind, Node, PatKind, PreciseCapturingArg, RangeEnd, Term, |
| ... | ... | @@ -20,9 +21,7 @@ use rustc_span::source_map::SourceMap; |
| 20 | 21 | use rustc_span::symbol::{kw, Ident, Symbol}; |
| 21 | 22 | use rustc_span::FileName; |
| 22 | 23 | use rustc_target::spec::abi::Abi; |
| 23 | ||
| 24 | use std::cell::Cell; | |
| 25 | use std::vec; | |
| 24 | use {rustc_ast as ast, rustc_hir as hir}; | |
| 26 | 25 | |
| 27 | 26 | pub fn id_to_string(map: &dyn rustc_hir::intravisit::Map<'_>, hir_id: HirId) -> String { |
| 28 | 27 | to_string(&map, |s| s.print_node(map.hir_node(hir_id))) |
compiler/rustc_hir_typeck/src/_match.rs+3-2| ... | ... | @@ -1,5 +1,3 @@ |
| 1 | use crate::coercion::{AsCoercionSite, CoerceMany}; | |
| 2 | use crate::{Diverges, Expectation, FnCtxt, Needs}; | |
| 3 | 1 | use rustc_errors::{Applicability, Diag}; |
| 4 | 2 | use rustc_hir::def::{CtorOf, DefKind, Res}; |
| 5 | 3 | use rustc_hir::def_id::LocalDefId; |
| ... | ... | @@ -11,6 +9,9 @@ use rustc_trait_selection::traits::{ |
| 11 | 9 | IfExpressionCause, MatchExpressionArmCause, ObligationCause, ObligationCauseCode, |
| 12 | 10 | }; |
| 13 | 11 | |
| 12 | use crate::coercion::{AsCoercionSite, CoerceMany}; | |
| 13 | use crate::{Diverges, Expectation, FnCtxt, Needs}; | |
| 14 | ||
| 14 | 15 | impl<'a, 'tcx> FnCtxt<'a, 'tcx> { |
| 15 | 16 | #[instrument(skip(self), level = "debug", ret)] |
| 16 | 17 | pub fn check_match( |
compiler/rustc_hir_typeck/src/autoderef.rs+3-3| ... | ... | @@ -1,7 +1,6 @@ |
| 1 | 1 | //! Some helper functions for `AutoDeref`. |
| 2 | 2 | |
| 3 | use super::method::MethodCallee; | |
| 4 | use super::{FnCtxt, PlaceOp}; | |
| 3 | use std::iter; | |
| 5 | 4 | |
| 6 | 5 | use itertools::Itertools; |
| 7 | 6 | use rustc_hir_analysis::autoderef::{Autoderef, AutoderefKind}; |
| ... | ... | @@ -10,7 +9,8 @@ use rustc_middle::ty::adjustment::{Adjust, Adjustment, OverloadedDeref}; |
| 10 | 9 | use rustc_middle::ty::{self, Ty}; |
| 11 | 10 | use rustc_span::Span; |
| 12 | 11 | |
| 13 | use std::iter; | |
| 12 | use super::method::MethodCallee; | |
| 13 | use super::{FnCtxt, PlaceOp}; | |
| 14 | 14 | |
| 15 | 15 | impl<'a, 'tcx> FnCtxt<'a, 'tcx> { |
| 16 | 16 | pub fn autoderef(&'a self, span: Span, base_ty: Ty<'tcx>) -> Autoderef<'a, 'tcx> { |
compiler/rustc_hir_typeck/src/callee.rs+8-12| ... | ... | @@ -1,24 +1,17 @@ |
| 1 | use super::method::probe::ProbeScope; | |
| 2 | use super::method::MethodCallee; | |
| 3 | use super::{Expectation, FnCtxt, TupleArgumentsFlag}; | |
| 1 | use std::{iter, slice}; | |
| 4 | 2 | |
| 5 | use crate::errors; | |
| 6 | 3 | use rustc_ast::util::parser::PREC_UNAMBIGUOUS; |
| 7 | 4 | use rustc_errors::{Applicability, Diag, ErrorGuaranteed, StashKey}; |
| 8 | 5 | use rustc_hir::def::{self, CtorKind, Namespace, Res}; |
| 9 | 6 | use rustc_hir::def_id::DefId; |
| 10 | 7 | use rustc_hir::{self as hir, LangItem}; |
| 11 | 8 | use rustc_hir_analysis::autoderef::Autoderef; |
| 12 | use rustc_infer::traits::ObligationCauseCode; | |
| 13 | use rustc_infer::{ | |
| 14 | infer, | |
| 15 | traits::{self, Obligation, ObligationCause}, | |
| 16 | }; | |
| 9 | use rustc_infer::infer; | |
| 10 | use rustc_infer::traits::{self, Obligation, ObligationCause, ObligationCauseCode}; | |
| 17 | 11 | use rustc_middle::ty::adjustment::{ |
| 18 | 12 | Adjust, Adjustment, AllowTwoPhase, AutoBorrow, AutoBorrowMutability, |
| 19 | 13 | }; |
| 20 | use rustc_middle::ty::GenericArgsRef; | |
| 21 | use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitableExt}; | |
| 14 | use rustc_middle::ty::{self, GenericArgsRef, Ty, TyCtxt, TypeVisitableExt}; | |
| 22 | 15 | use rustc_middle::{bug, span_bug}; |
| 23 | 16 | use rustc_span::def_id::LocalDefId; |
| 24 | 17 | use rustc_span::symbol::{sym, Ident}; |
| ... | ... | @@ -28,7 +21,10 @@ use rustc_trait_selection::error_reporting::traits::DefIdOrName; |
| 28 | 21 | use rustc_trait_selection::infer::InferCtxtExt as _; |
| 29 | 22 | use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt as _; |
| 30 | 23 | |
| 31 | use std::{iter, slice}; | |
| 24 | use super::method::probe::ProbeScope; | |
| 25 | use super::method::MethodCallee; | |
| 26 | use super::{Expectation, FnCtxt, TupleArgumentsFlag}; | |
| 27 | use crate::errors; | |
| 32 | 28 | |
| 33 | 29 | /// Checks that it is legal to call methods of the trait corresponding |
| 34 | 30 | /// to `trait_id` (this only cares about the trait, not the specific |
compiler/rustc_hir_typeck/src/cast.rs+7-9| ... | ... | @@ -28,12 +28,9 @@ |
| 28 | 28 | //! expression, `e as U2` is not necessarily so (in fact it will only be valid if |
| 29 | 29 | //! `U1` coerces to `U2`). |
| 30 | 30 | |
| 31 | use super::FnCtxt; | |
| 32 | ||
| 33 | use crate::errors; | |
| 34 | use crate::type_error_struct; | |
| 35 | 31 | use rustc_data_structures::fx::FxHashSet; |
| 36 | use rustc_errors::{codes::*, Applicability, Diag, ErrorGuaranteed}; | |
| 32 | use rustc_errors::codes::*; | |
| 33 | use rustc_errors::{Applicability, Diag, ErrorGuaranteed}; | |
| 37 | 34 | use rustc_hir::{self as hir, ExprKind}; |
| 38 | 35 | use rustc_macros::{TypeFoldable, TypeVisitable}; |
| 39 | 36 | use rustc_middle::bug; |
| ... | ... | @@ -41,15 +38,16 @@ use rustc_middle::mir::Mutability; |
| 41 | 38 | use rustc_middle::ty::adjustment::AllowTwoPhase; |
| 42 | 39 | use rustc_middle::ty::cast::{CastKind, CastTy}; |
| 43 | 40 | use rustc_middle::ty::error::TypeError; |
| 44 | use rustc_middle::ty::TyCtxt; | |
| 45 | use rustc_middle::ty::{self, Ty, TypeAndMut, TypeVisitableExt, VariantDef}; | |
| 41 | use rustc_middle::ty::{self, Ty, TyCtxt, TypeAndMut, TypeVisitableExt, VariantDef}; | |
| 46 | 42 | use rustc_session::lint; |
| 47 | 43 | use rustc_span::def_id::LOCAL_CRATE; |
| 48 | 44 | use rustc_span::symbol::sym; |
| 49 | use rustc_span::Span; | |
| 50 | use rustc_span::DUMMY_SP; | |
| 45 | use rustc_span::{Span, DUMMY_SP}; | |
| 51 | 46 | use rustc_trait_selection::infer::InferCtxtExt; |
| 52 | 47 | |
| 48 | use super::FnCtxt; | |
| 49 | use crate::{errors, type_error_struct}; | |
| 50 | ||
| 53 | 51 | /// Reifies a cast check to be checked once we have full type information for |
| 54 | 52 | /// a function context. |
| 55 | 53 | #[derive(Debug)] |
compiler/rustc_hir_typeck/src/check.rs+4-3| ... | ... | @@ -1,8 +1,5 @@ |
| 1 | 1 | use std::cell::RefCell; |
| 2 | 2 | |
| 3 | use crate::coercion::CoerceMany; | |
| 4 | use crate::gather_locals::GatherLocalsVisitor; | |
| 5 | use crate::{CoroutineTypes, Diverges, FnCtxt}; | |
| 6 | 3 | use rustc_hir as hir; |
| 7 | 4 | use rustc_hir::def::DefKind; |
| 8 | 5 | use rustc_hir::intravisit::Visitor; |
| ... | ... | @@ -16,6 +13,10 @@ use rustc_span::symbol::sym; |
| 16 | 13 | use rustc_target::spec::abi::Abi; |
| 17 | 14 | use rustc_trait_selection::traits::{ObligationCause, ObligationCauseCode}; |
| 18 | 15 | |
| 16 | use crate::coercion::CoerceMany; | |
| 17 | use crate::gather_locals::GatherLocalsVisitor; | |
| 18 | use crate::{CoroutineTypes, Diverges, FnCtxt}; | |
| 19 | ||
| 19 | 20 | /// Helper used for fns and closures. Does the grungy work of checking a function |
| 20 | 21 | /// body and returns the function context used for that purpose, since in the case of a fn item |
| 21 | 22 | /// there is still a bit more to do. |
compiler/rustc_hir_typeck/src/closure.rs+6-7| ... | ... | @@ -1,27 +1,26 @@ |
| 1 | 1 | //! Code for type-checking closure expressions. |
| 2 | 2 | |
| 3 | use super::{check_fn, CoroutineTypes, Expectation, FnCtxt}; | |
| 3 | use std::iter; | |
| 4 | use std::ops::ControlFlow; | |
| 4 | 5 | |
| 5 | 6 | use rustc_errors::ErrorGuaranteed; |
| 6 | 7 | use rustc_hir as hir; |
| 7 | 8 | use rustc_hir::lang_items::LangItem; |
| 8 | 9 | use rustc_hir_analysis::hir_ty_lowering::HirTyLowerer; |
| 9 | use rustc_infer::infer::{BoundRegionConversionTime, DefineOpaqueTypes}; | |
| 10 | use rustc_infer::infer::{InferOk, InferResult}; | |
| 10 | use rustc_infer::infer::{BoundRegionConversionTime, DefineOpaqueTypes, InferOk, InferResult}; | |
| 11 | 11 | use rustc_infer::traits::ObligationCauseCode; |
| 12 | 12 | use rustc_macros::{TypeFoldable, TypeVisitable}; |
| 13 | 13 | use rustc_middle::span_bug; |
| 14 | 14 | use rustc_middle::ty::visit::{TypeVisitable, TypeVisitableExt}; |
| 15 | use rustc_middle::ty::GenericArgs; | |
| 16 | use rustc_middle::ty::{self, Ty, TyCtxt, TypeSuperVisitable, TypeVisitor}; | |
| 15 | use rustc_middle::ty::{self, GenericArgs, Ty, TyCtxt, TypeSuperVisitable, TypeVisitor}; | |
| 17 | 16 | use rustc_span::def_id::LocalDefId; |
| 18 | 17 | use rustc_span::Span; |
| 19 | 18 | use rustc_target::spec::abi::Abi; |
| 20 | 19 | use rustc_trait_selection::error_reporting::traits::ArgKind; |
| 21 | 20 | use rustc_trait_selection::traits; |
| 22 | 21 | use rustc_type_ir::ClosureKind; |
| 23 | use std::iter; | |
| 24 | use std::ops::ControlFlow; | |
| 22 | ||
| 23 | use super::{check_fn, CoroutineTypes, Expectation, FnCtxt}; | |
| 25 | 24 | |
| 26 | 25 | /// What signature do we *expect* the closure to have from context? |
| 27 | 26 | #[derive(Debug, Clone, TypeFoldable, TypeVisitable)] |
compiler/rustc_hir_typeck/src/coercion.rs+10-7| ... | ... | @@ -35,16 +35,18 @@ |
| 35 | 35 | //! // and are then unable to coerce `&7i32` to `&mut i32`. |
| 36 | 36 | //! ``` |
| 37 | 37 | |
| 38 | use crate::errors::SuggestBoxingForReturnImplTrait; | |
| 39 | use crate::FnCtxt; | |
| 40 | use rustc_errors::{codes::*, struct_span_code_err, Applicability, Diag}; | |
| 38 | use std::ops::Deref; | |
| 39 | ||
| 40 | use rustc_errors::codes::*; | |
| 41 | use rustc_errors::{struct_span_code_err, Applicability, Diag}; | |
| 41 | 42 | use rustc_hir as hir; |
| 42 | 43 | use rustc_hir::def_id::{DefId, LocalDefId}; |
| 43 | 44 | use rustc_hir_analysis::hir_ty_lowering::HirTyLowerer; |
| 44 | 45 | use rustc_infer::infer::relate::RelateResult; |
| 45 | 46 | use rustc_infer::infer::{Coercion, DefineOpaqueTypes, InferOk, InferResult}; |
| 46 | use rustc_infer::traits::{IfExpressionCause, MatchExpressionArmCause}; | |
| 47 | use rustc_infer::traits::{Obligation, PredicateObligation}; | |
| 47 | use rustc_infer::traits::{ | |
| 48 | IfExpressionCause, MatchExpressionArmCause, Obligation, PredicateObligation, | |
| 49 | }; | |
| 48 | 50 | use rustc_middle::lint::in_external_macro; |
| 49 | 51 | use rustc_middle::span_bug; |
| 50 | 52 | use rustc_middle::traits::BuiltinImplSource; |
| ... | ... | @@ -63,9 +65,10 @@ use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt; |
| 63 | 65 | use rustc_trait_selection::traits::{ |
| 64 | 66 | self, NormalizeExt, ObligationCause, ObligationCauseCode, ObligationCtxt, |
| 65 | 67 | }; |
| 66 | ||
| 67 | 68 | use smallvec::{smallvec, SmallVec}; |
| 68 | use std::ops::Deref; | |
| 69 | ||
| 70 | use crate::errors::SuggestBoxingForReturnImplTrait; | |
| 71 | use crate::FnCtxt; | |
| 69 | 72 | |
| 70 | 73 | struct Coerce<'a, 'tcx> { |
| 71 | 74 | fcx: &'a FnCtxt<'a, 'tcx>, |
compiler/rustc_hir_typeck/src/demand.rs+2-3| ... | ... | @@ -1,6 +1,4 @@ |
| 1 | use crate::FnCtxt; | |
| 2 | use rustc_errors::MultiSpan; | |
| 3 | use rustc_errors::{Applicability, Diag}; | |
| 1 | use rustc_errors::{Applicability, Diag, MultiSpan}; | |
| 4 | 2 | use rustc_hir as hir; |
| 5 | 3 | use rustc_hir::def::Res; |
| 6 | 4 | use rustc_hir::intravisit::Visitor; |
| ... | ... | @@ -17,6 +15,7 @@ use rustc_trait_selection::infer::InferCtxtExt; |
| 17 | 15 | use rustc_trait_selection::traits::ObligationCause; |
| 18 | 16 | |
| 19 | 17 | use super::method::probe; |
| 18 | use crate::FnCtxt; | |
| 20 | 19 | |
| 21 | 20 | impl<'a, 'tcx> FnCtxt<'a, 'tcx> { |
| 22 | 21 | pub fn emit_type_mismatch_suggestions( |
compiler/rustc_hir_typeck/src/diverges.rs+2-1| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | use rustc_span::{Span, DUMMY_SP}; | |
| 2 | 1 | use std::{cmp, ops}; |
| 3 | 2 | |
| 3 | use rustc_span::{Span, DUMMY_SP}; | |
| 4 | ||
| 4 | 5 | /// Tracks whether executing a node may exit normally (versus |
| 5 | 6 | /// return/break/panic, which "diverge", leaving dead code in their |
| 6 | 7 | /// wake). Tracked semi-automatically (through type variables marked |
compiler/rustc_hir_typeck/src/errors.rs+8-8| ... | ... | @@ -2,18 +2,18 @@ |
| 2 | 2 | |
| 3 | 3 | use std::borrow::Cow; |
| 4 | 4 | |
| 5 | use crate::fluent_generated as fluent; | |
| 5 | use rustc_errors::codes::*; | |
| 6 | 6 | use rustc_errors::{ |
| 7 | codes::*, Applicability, Diag, DiagArgValue, DiagSymbolList, EmissionGuarantee, IntoDiagArg, | |
| 8 | MultiSpan, SubdiagMessageOp, Subdiagnostic, | |
| 7 | Applicability, Diag, DiagArgValue, DiagSymbolList, EmissionGuarantee, IntoDiagArg, MultiSpan, | |
| 8 | SubdiagMessageOp, Subdiagnostic, | |
| 9 | 9 | }; |
| 10 | 10 | use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic}; |
| 11 | 11 | use rustc_middle::ty::{self, Ty}; |
| 12 | use rustc_span::{ | |
| 13 | edition::{Edition, LATEST_STABLE_EDITION}, | |
| 14 | symbol::Ident, | |
| 15 | Span, Symbol, | |
| 16 | }; | |
| 12 | use rustc_span::edition::{Edition, LATEST_STABLE_EDITION}; | |
| 13 | use rustc_span::symbol::Ident; | |
| 14 | use rustc_span::{Span, Symbol}; | |
| 15 | ||
| 16 | use crate::fluent_generated as fluent; | |
| 17 | 17 | |
| 18 | 18 | #[derive(Diagnostic)] |
| 19 | 19 | #[diag(hir_typeck_field_multiply_specified_in_initializer, code = E0062)] |
compiler/rustc_hir_typeck/src/expr.rs+20-29| ... | ... | @@ -2,33 +2,13 @@ |
| 2 | 2 | //! |
| 3 | 3 | //! See [`rustc_hir_analysis::check`] for more context on type checking in general. |
| 4 | 4 | |
| 5 | use crate::cast; | |
| 6 | use crate::coercion::CoerceMany; | |
| 7 | use crate::coercion::DynamicCoerceMany; | |
| 8 | use crate::errors::ReturnLikeStatementKind; | |
| 9 | use crate::errors::TypeMismatchFruTypo; | |
| 10 | use crate::errors::{AddressOfTemporaryTaken, ReturnStmtOutsideOfFnBody, StructExprNonExhaustive}; | |
| 11 | use crate::errors::{ | |
| 12 | FieldMultiplySpecifiedInInitializer, FunctionalRecordUpdateOnNonStruct, HelpUseLatestEdition, | |
| 13 | YieldExprOutsideOfCoroutine, | |
| 14 | }; | |
| 15 | use crate::fatally_break_rust; | |
| 16 | use crate::type_error_struct; | |
| 17 | use crate::CoroutineTypes; | |
| 18 | use crate::Expectation::{self, ExpectCastableToType, ExpectHasType, NoExpectation}; | |
| 19 | use crate::{ | |
| 20 | report_unexpected_variant_res, BreakableCtxt, Diverges, FnCtxt, Needs, | |
| 21 | TupleArgumentsFlag::DontTupleArguments, | |
| 22 | }; | |
| 23 | use rustc_ast as ast; | |
| 24 | 5 | use rustc_data_structures::fx::{FxHashMap, FxHashSet}; |
| 25 | 6 | use rustc_data_structures::stack::ensure_sufficient_stack; |
| 26 | 7 | use rustc_data_structures::unord::UnordMap; |
| 8 | use rustc_errors::codes::*; | |
| 27 | 9 | use rustc_errors::{ |
| 28 | codes::*, pluralize, struct_span_code_err, Applicability, Diag, ErrorGuaranteed, StashKey, | |
| 29 | Subdiagnostic, | |
| 10 | pluralize, struct_span_code_err, Applicability, Diag, ErrorGuaranteed, StashKey, Subdiagnostic, | |
| 30 | 11 | }; |
| 31 | use rustc_hir as hir; | |
| 32 | 12 | use rustc_hir::def::{CtorKind, DefKind, Res}; |
| 33 | 13 | use rustc_hir::def_id::DefId; |
| 34 | 14 | use rustc_hir::intravisit::Visitor; |
| ... | ... | @@ -36,14 +16,12 @@ use rustc_hir::lang_items::LangItem; |
| 36 | 16 | use rustc_hir::{ExprKind, HirId, QPath}; |
| 37 | 17 | use rustc_hir_analysis::hir_ty_lowering::HirTyLowerer as _; |
| 38 | 18 | use rustc_infer::infer; |
| 39 | use rustc_infer::infer::DefineOpaqueTypes; | |
| 40 | use rustc_infer::infer::InferOk; | |
| 19 | use rustc_infer::infer::{DefineOpaqueTypes, InferOk}; | |
| 41 | 20 | use rustc_infer::traits::query::NoSolution; |
| 42 | 21 | use rustc_infer::traits::ObligationCause; |
| 43 | 22 | use rustc_middle::ty::adjustment::{Adjust, Adjustment, AllowTwoPhase}; |
| 44 | 23 | use rustc_middle::ty::error::{ExpectedFound, TypeError}; |
| 45 | use rustc_middle::ty::GenericArgsRef; | |
| 46 | use rustc_middle::ty::{self, AdtKind, Ty, TypeVisitableExt}; | |
| 24 | use rustc_middle::ty::{self, AdtKind, GenericArgsRef, Ty, TypeVisitableExt}; | |
| 47 | 25 | use rustc_middle::{bug, span_bug}; |
| 48 | 26 | use rustc_session::errors::ExprParenthesesNeeded; |
| 49 | 27 | use rustc_session::parse::feature_err; |
| ... | ... | @@ -54,10 +32,23 @@ use rustc_span::symbol::{kw, sym, Ident, Symbol}; |
| 54 | 32 | use rustc_span::Span; |
| 55 | 33 | use rustc_target::abi::{FieldIdx, FIRST_VARIANT}; |
| 56 | 34 | use rustc_trait_selection::infer::InferCtxtExt; |
| 57 | use rustc_trait_selection::traits::ObligationCtxt; | |
| 58 | use rustc_trait_selection::traits::{self, ObligationCauseCode}; | |
| 59 | ||
| 35 | use rustc_trait_selection::traits::{self, ObligationCauseCode, ObligationCtxt}; | |
| 60 | 36 | use smallvec::SmallVec; |
| 37 | use {rustc_ast as ast, rustc_hir as hir}; | |
| 38 | ||
| 39 | use crate::coercion::{CoerceMany, DynamicCoerceMany}; | |
| 40 | use crate::errors::{ | |
| 41 | AddressOfTemporaryTaken, FieldMultiplySpecifiedInInitializer, | |
| 42 | FunctionalRecordUpdateOnNonStruct, HelpUseLatestEdition, ReturnLikeStatementKind, | |
| 43 | ReturnStmtOutsideOfFnBody, StructExprNonExhaustive, TypeMismatchFruTypo, | |
| 44 | YieldExprOutsideOfCoroutine, | |
| 45 | }; | |
| 46 | use crate::Expectation::{self, ExpectCastableToType, ExpectHasType, NoExpectation}; | |
| 47 | use crate::TupleArgumentsFlag::DontTupleArguments; | |
| 48 | use crate::{ | |
| 49 | cast, fatally_break_rust, report_unexpected_variant_res, type_error_struct, BreakableCtxt, | |
| 50 | CoroutineTypes, Diverges, FnCtxt, Needs, | |
| 51 | }; | |
| 61 | 52 | |
| 62 | 53 | impl<'a, 'tcx> FnCtxt<'a, 'tcx> { |
| 63 | 54 | pub fn check_expr_has_type_or_error( |
compiler/rustc_hir_typeck/src/expr_use_visitor.rs+3-4| ... | ... | @@ -9,16 +9,15 @@ use std::slice::from_ref; |
| 9 | 9 | use hir::def::DefKind; |
| 10 | 10 | use hir::pat_util::EnumerateAndAdjustIterator as _; |
| 11 | 11 | use hir::Expr; |
| 12 | use rustc_lint::LateContext; | |
| 13 | // Export these here so that Clippy can use them. | |
| 14 | pub use rustc_middle::hir::place::{Place, PlaceBase, PlaceWithHirId, Projection}; | |
| 15 | ||
| 16 | 12 | use rustc_data_structures::fx::FxIndexMap; |
| 17 | 13 | use rustc_hir as hir; |
| 18 | 14 | use rustc_hir::def::{CtorOf, Res}; |
| 19 | 15 | use rustc_hir::def_id::LocalDefId; |
| 20 | 16 | use rustc_hir::{HirId, PatKind}; |
| 17 | use rustc_lint::LateContext; | |
| 21 | 18 | use rustc_middle::hir::place::ProjectionKind; |
| 19 | // Export these here so that Clippy can use them. | |
| 20 | pub use rustc_middle::hir::place::{Place, PlaceBase, PlaceWithHirId, Projection}; | |
| 22 | 21 | use rustc_middle::mir::FakeReadCause; |
| 23 | 22 | use rustc_middle::ty::{ |
| 24 | 23 | self, adjustment, AdtKind, Ty, TyCtxt, TypeFoldable, TypeVisitableExt as _, |
compiler/rustc_hir_typeck/src/fallback.rs+8-7| ... | ... | @@ -1,10 +1,9 @@ |
| 1 | 1 | use std::cell::OnceCell; |
| 2 | 2 | |
| 3 | use crate::{errors, FnCtxt, TypeckRootCtxt}; | |
| 4 | use rustc_data_structures::{ | |
| 5 | graph::{self, iterate::DepthFirstSearch, vec_graph::VecGraph}, | |
| 6 | unord::{UnordBag, UnordMap, UnordSet}, | |
| 7 | }; | |
| 3 | use rustc_data_structures::graph::iterate::DepthFirstSearch; | |
| 4 | use rustc_data_structures::graph::vec_graph::VecGraph; | |
| 5 | use rustc_data_structures::graph::{self}; | |
| 6 | use rustc_data_structures::unord::{UnordBag, UnordMap, UnordSet}; | |
| 8 | 7 | use rustc_hir as hir; |
| 9 | 8 | use rustc_hir::intravisit::Visitor; |
| 10 | 9 | use rustc_hir::HirId; |
| ... | ... | @@ -12,10 +11,12 @@ use rustc_infer::infer::{DefineOpaqueTypes, InferOk}; |
| 12 | 11 | use rustc_middle::bug; |
| 13 | 12 | use rustc_middle::ty::{self, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable}; |
| 14 | 13 | use rustc_session::lint; |
| 15 | use rustc_span::DUMMY_SP; | |
| 16 | use rustc_span::{def_id::LocalDefId, Span}; | |
| 14 | use rustc_span::def_id::LocalDefId; | |
| 15 | use rustc_span::{Span, DUMMY_SP}; | |
| 17 | 16 | use rustc_trait_selection::traits::{ObligationCause, ObligationCtxt}; |
| 18 | 17 | |
| 18 | use crate::{errors, FnCtxt, TypeckRootCtxt}; | |
| 19 | ||
| 19 | 20 | #[derive(Copy, Clone)] |
| 20 | 21 | pub enum DivergingFallbackBehavior { |
| 21 | 22 | /// Always fallback to `()` (aka "always spontaneous decay") |
compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs+9-9| ... | ... | @@ -1,8 +1,6 @@ |
| 1 | use crate::callee::{self, DeferredCallResolution}; | |
| 2 | use crate::errors::{self, CtorIsPrivate}; | |
| 3 | use crate::method::{self, MethodCallee}; | |
| 4 | use crate::rvalue_scopes; | |
| 5 | use crate::{BreakableCtxt, Diverges, Expectation, FnCtxt, LoweredTy}; | |
| 1 | use std::collections::hash_map::Entry; | |
| 2 | use std::slice; | |
| 3 | ||
| 6 | 4 | use rustc_data_structures::fx::FxHashSet; |
| 7 | 5 | use rustc_errors::{Applicability, Diag, ErrorGuaranteed, MultiSpan, StashKey}; |
| 8 | 6 | use rustc_hir as hir; |
| ... | ... | @@ -26,9 +24,9 @@ use rustc_middle::ty::error::TypeError; |
| 26 | 24 | use rustc_middle::ty::fold::TypeFoldable; |
| 27 | 25 | use rustc_middle::ty::visit::{TypeVisitable, TypeVisitableExt}; |
| 28 | 26 | use rustc_middle::ty::{ |
| 29 | self, AdtKind, CanonicalUserType, GenericParamDefKind, IsIdentity, Ty, TyCtxt, UserType, | |
| 27 | self, AdtKind, CanonicalUserType, GenericArgKind, GenericArgsRef, GenericParamDefKind, | |
| 28 | IsIdentity, Ty, TyCtxt, UserArgs, UserSelfTy, UserType, | |
| 30 | 29 | }; |
| 31 | use rustc_middle::ty::{GenericArgKind, GenericArgsRef, UserArgs, UserSelfTy}; | |
| 32 | 30 | use rustc_middle::{bug, span_bug}; |
| 33 | 31 | use rustc_session::lint; |
| 34 | 32 | use rustc_span::def_id::LocalDefId; |
| ... | ... | @@ -41,8 +39,10 @@ use rustc_trait_selection::traits::{ |
| 41 | 39 | self, NormalizeExt, ObligationCauseCode, ObligationCtxt, StructurallyNormalizeExt, |
| 42 | 40 | }; |
| 43 | 41 | |
| 44 | use std::collections::hash_map::Entry; | |
| 45 | use std::slice; | |
| 42 | use crate::callee::{self, DeferredCallResolution}; | |
| 43 | use crate::errors::{self, CtorIsPrivate}; | |
| 44 | use crate::method::{self, MethodCallee}; | |
| 45 | use crate::{rvalue_scopes, BreakableCtxt, Diverges, Expectation, FnCtxt, LoweredTy}; | |
| 46 | 46 | |
| 47 | 47 | impl<'a, 'tcx> FnCtxt<'a, 'tcx> { |
| 48 | 48 | /// Produces warning on the given node, if the current point in the |
compiler/rustc_hir_typeck/src/fn_ctxt/adjust_fulfillment_errors.rs+5-3| ... | ... | @@ -1,13 +1,15 @@ |
| 1 | use crate::FnCtxt; | |
| 1 | use std::ops::ControlFlow; | |
| 2 | ||
| 2 | 3 | use rustc_hir as hir; |
| 3 | 4 | use rustc_hir::def::{DefKind, Res}; |
| 4 | 5 | use rustc_hir::def_id::DefId; |
| 5 | 6 | use rustc_infer::traits::ObligationCauseCode; |
| 6 | 7 | use rustc_middle::ty::{self, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitor}; |
| 7 | use rustc_span::{symbol::kw, Span}; | |
| 8 | use rustc_span::symbol::kw; | |
| 9 | use rustc_span::Span; | |
| 8 | 10 | use rustc_trait_selection::traits; |
| 9 | 11 | |
| 10 | use std::ops::ControlFlow; | |
| 12 | use crate::FnCtxt; | |
| 11 | 13 | |
| 12 | 14 | impl<'a, 'tcx> FnCtxt<'a, 'tcx> { |
| 13 | 15 | pub fn adjust_fulfillment_error_for_expr_obligation( |
compiler/rustc_hir_typeck/src/fn_ctxt/arg_matrix.rs+2-1| ... | ... | @@ -1,7 +1,8 @@ |
| 1 | 1 | use core::cmp::Ordering; |
| 2 | use std::cmp; | |
| 3 | ||
| 2 | 4 | use rustc_index::IndexVec; |
| 3 | 5 | use rustc_middle::ty::error::TypeError; |
| 4 | use std::cmp; | |
| 5 | 6 | |
| 6 | 7 | rustc_index::newtype_index! { |
| 7 | 8 | #[orderable] |
compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs+22-23| ... | ... | @@ -1,26 +1,12 @@ |
| 1 | use crate::coercion::CoerceMany; | |
| 2 | use crate::errors::SuggestPtrNullMut; | |
| 3 | use crate::fn_ctxt::arg_matrix::{ArgMatrix, Compatibility, Error, ExpectedIdx, ProvidedIdx}; | |
| 4 | use crate::fn_ctxt::infer::FnCall; | |
| 5 | use crate::gather_locals::Declaration; | |
| 6 | use crate::method::probe::IsSuggestion; | |
| 7 | use crate::method::probe::Mode::MethodCall; | |
| 8 | use crate::method::probe::ProbeScope::TraitsInScope; | |
| 9 | use crate::method::MethodCallee; | |
| 10 | use crate::TupleArgumentsFlag::*; | |
| 11 | use crate::{errors, Expectation::*}; | |
| 12 | use crate::{ | |
| 13 | struct_span_code_err, BreakableCtxt, Diverges, Expectation, FnCtxt, LoweredTy, Needs, | |
| 14 | TupleArgumentsFlag, | |
| 15 | }; | |
| 1 | use std::{iter, mem}; | |
| 2 | ||
| 16 | 3 | use itertools::Itertools; |
| 17 | use rustc_ast as ast; | |
| 18 | 4 | use rustc_data_structures::fx::FxIndexSet; |
| 5 | use rustc_errors::codes::*; | |
| 19 | 6 | use rustc_errors::{ |
| 20 | a_or_an, codes::*, display_list_with_comma_and, pluralize, Applicability, Diag, | |
| 21 | ErrorGuaranteed, MultiSpan, StashKey, | |
| 7 | a_or_an, display_list_with_comma_and, pluralize, Applicability, Diag, ErrorGuaranteed, | |
| 8 | MultiSpan, StashKey, | |
| 22 | 9 | }; |
| 23 | use rustc_hir as hir; | |
| 24 | 10 | use rustc_hir::def::{CtorOf, DefKind, Res}; |
| 25 | 11 | use rustc_hir::def_id::DefId; |
| 26 | 12 | use rustc_hir::intravisit::Visitor; |
| ... | ... | @@ -29,8 +15,7 @@ use rustc_hir_analysis::check::intrinsicck::InlineAsmCtxt; |
| 29 | 15 | use rustc_hir_analysis::check::potentially_plural_count; |
| 30 | 16 | use rustc_hir_analysis::hir_ty_lowering::HirTyLowerer; |
| 31 | 17 | use rustc_index::IndexVec; |
| 32 | use rustc_infer::infer::TypeTrace; | |
| 33 | use rustc_infer::infer::{DefineOpaqueTypes, InferOk}; | |
| 18 | use rustc_infer::infer::{DefineOpaqueTypes, InferOk, TypeTrace}; | |
| 34 | 19 | use rustc_middle::ty::adjustment::AllowTwoPhase; |
| 35 | 20 | use rustc_middle::ty::visit::TypeVisitableExt; |
| 36 | 21 | use rustc_middle::ty::{self, IsSuggestable, Ty, TyCtxt}; |
| ... | ... | @@ -41,9 +26,23 @@ use rustc_span::{sym, BytePos, Span, DUMMY_SP}; |
| 41 | 26 | use rustc_trait_selection::error_reporting::infer::{FailureCode, ObligationCauseExt}; |
| 42 | 27 | use rustc_trait_selection::infer::InferCtxtExt; |
| 43 | 28 | use rustc_trait_selection::traits::{self, ObligationCauseCode, SelectionContext}; |
| 29 | use {rustc_ast as ast, rustc_hir as hir}; | |
| 44 | 30 | |
| 45 | use std::iter; | |
| 46 | use std::mem; | |
| 31 | use crate::coercion::CoerceMany; | |
| 32 | use crate::errors::SuggestPtrNullMut; | |
| 33 | use crate::fn_ctxt::arg_matrix::{ArgMatrix, Compatibility, Error, ExpectedIdx, ProvidedIdx}; | |
| 34 | use crate::fn_ctxt::infer::FnCall; | |
| 35 | use crate::gather_locals::Declaration; | |
| 36 | use crate::method::probe::IsSuggestion; | |
| 37 | use crate::method::probe::Mode::MethodCall; | |
| 38 | use crate::method::probe::ProbeScope::TraitsInScope; | |
| 39 | use crate::method::MethodCallee; | |
| 40 | use crate::Expectation::*; | |
| 41 | use crate::TupleArgumentsFlag::*; | |
| 42 | use crate::{ | |
| 43 | errors, struct_span_code_err, BreakableCtxt, Diverges, Expectation, FnCtxt, LoweredTy, Needs, | |
| 44 | TupleArgumentsFlag, | |
| 45 | }; | |
| 47 | 46 | |
| 48 | 47 | #[derive(Clone, Copy, Default)] |
| 49 | 48 | pub enum DivergingBlockBehavior { |
compiler/rustc_hir_typeck/src/fn_ctxt/inspect_obligations.rs+5-3| ... | ... | @@ -1,12 +1,14 @@ |
| 1 | 1 | //! A utility module to inspect currently ambiguous obligations in the current context. |
| 2 | 2 | |
| 3 | use crate::FnCtxt; | |
| 4 | 3 | use rustc_infer::traits::{self, ObligationCause}; |
| 5 | 4 | use rustc_middle::traits::solve::Goal; |
| 6 | 5 | use rustc_middle::ty::{self, Ty, TypeVisitableExt}; |
| 7 | 6 | use rustc_span::Span; |
| 8 | use rustc_trait_selection::solve::inspect::ProofTreeInferCtxtExt; | |
| 9 | use rustc_trait_selection::solve::inspect::{InspectConfig, InspectGoal, ProofTreeVisitor}; | |
| 7 | use rustc_trait_selection::solve::inspect::{ | |
| 8 | InspectConfig, InspectGoal, ProofTreeInferCtxtExt, ProofTreeVisitor, | |
| 9 | }; | |
| 10 | ||
| 11 | use crate::FnCtxt; | |
| 10 | 12 | |
| 11 | 13 | impl<'a, 'tcx> FnCtxt<'a, 'tcx> { |
| 12 | 14 | /// Returns a list of all obligations whose self type has been unified |
compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs+7-7| ... | ... | @@ -5,13 +5,11 @@ mod checks; |
| 5 | 5 | mod inspect_obligations; |
| 6 | 6 | mod suggestions; |
| 7 | 7 | |
| 8 | use rustc_errors::DiagCtxtHandle; | |
| 8 | use std::cell::{Cell, RefCell}; | |
| 9 | use std::ops::Deref; | |
| 9 | 10 | |
| 10 | use crate::coercion::DynamicCoerceMany; | |
| 11 | use crate::fallback::DivergingFallbackBehavior; | |
| 12 | use crate::fn_ctxt::checks::DivergingBlockBehavior; | |
| 13 | use crate::{CoroutineTypes, Diverges, EnclosingBreakables, TypeckRootCtxt}; | |
| 14 | 11 | use hir::def_id::CRATE_DEF_ID; |
| 12 | use rustc_errors::DiagCtxtHandle; | |
| 15 | 13 | use rustc_hir as hir; |
| 16 | 14 | use rustc_hir::def_id::{DefId, LocalDefId}; |
| 17 | 15 | use rustc_hir_analysis::hir_ty_lowering::{HirTyLowerer, RegionInferReason}; |
| ... | ... | @@ -24,8 +22,10 @@ use rustc_trait_selection::error_reporting::infer::sub_relations::SubRelations; |
| 24 | 22 | use rustc_trait_selection::error_reporting::TypeErrCtxt; |
| 25 | 23 | use rustc_trait_selection::traits::{ObligationCause, ObligationCauseCode, ObligationCtxt}; |
| 26 | 24 | |
| 27 | use std::cell::{Cell, RefCell}; | |
| 28 | use std::ops::Deref; | |
| 25 | use crate::coercion::DynamicCoerceMany; | |
| 26 | use crate::fallback::DivergingFallbackBehavior; | |
| 27 | use crate::fn_ctxt::checks::DivergingBlockBehavior; | |
| 28 | use crate::{CoroutineTypes, Diverges, EnclosingBreakables, TypeckRootCtxt}; | |
| 29 | 29 | |
| 30 | 30 | /// The `FnCtxt` stores type-checking context needed to type-check bodies of |
| 31 | 31 | /// functions, closures, and `const`s, including performing type inference |
compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs+13-12| ... | ... | @@ -1,20 +1,12 @@ |
| 1 | use super::FnCtxt; | |
| 2 | ||
| 3 | use crate::errors; | |
| 4 | use crate::fluent_generated as fluent; | |
| 5 | use crate::fn_ctxt::rustc_span::BytePos; | |
| 6 | use crate::hir::is_range_literal; | |
| 7 | use crate::method::probe; | |
| 8 | use crate::method::probe::{IsSuggestion, Mode, ProbeScope}; | |
| 9 | 1 | use core::cmp::min; |
| 10 | 2 | use core::iter; |
| 3 | ||
| 11 | 4 | use hir::def_id::LocalDefId; |
| 12 | 5 | use rustc_ast::util::parser::{ExprPrecedence, PREC_UNAMBIGUOUS}; |
| 13 | 6 | use rustc_data_structures::packed::Pu128; |
| 14 | 7 | use rustc_errors::{Applicability, Diag, MultiSpan}; |
| 15 | 8 | use rustc_hir as hir; |
| 16 | use rustc_hir::def::Res; | |
| 17 | use rustc_hir::def::{CtorKind, CtorOf, DefKind}; | |
| 9 | use rustc_hir::def::{CtorKind, CtorOf, DefKind, Res}; | |
| 18 | 10 | use rustc_hir::lang_items::LangItem; |
| 19 | 11 | use rustc_hir::{ |
| 20 | 12 | Arm, CoroutineDesugaring, CoroutineKind, CoroutineSource, Expr, ExprKind, GenericBound, HirId, |
| ... | ... | @@ -26,8 +18,10 @@ use rustc_middle::lint::in_external_macro; |
| 26 | 18 | use rustc_middle::middle::stability::EvalResult; |
| 27 | 19 | use rustc_middle::span_bug; |
| 28 | 20 | use rustc_middle::ty::print::with_no_trimmed_paths; |
| 29 | use rustc_middle::ty::{self, suggest_constraining_type_params, Article, Binder}; | |
| 30 | use rustc_middle::ty::{IsSuggestable, Ty, TyCtxt, TypeVisitableExt, Upcast}; | |
| 21 | use rustc_middle::ty::{ | |
| 22 | self, suggest_constraining_type_params, Article, Binder, IsSuggestable, Ty, TyCtxt, | |
| 23 | TypeVisitableExt, Upcast, | |
| 24 | }; | |
| 31 | 25 | use rustc_session::errors::ExprParenthesesNeeded; |
| 32 | 26 | use rustc_span::source_map::Spanned; |
| 33 | 27 | use rustc_span::symbol::{sym, Ident}; |
| ... | ... | @@ -38,6 +32,13 @@ use rustc_trait_selection::infer::InferCtxtExt; |
| 38 | 32 | use rustc_trait_selection::traits; |
| 39 | 33 | use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt as _; |
| 40 | 34 | |
| 35 | use super::FnCtxt; | |
| 36 | use crate::fn_ctxt::rustc_span::BytePos; | |
| 37 | use crate::hir::is_range_literal; | |
| 38 | use crate::method::probe; | |
| 39 | use crate::method::probe::{IsSuggestion, Mode, ProbeScope}; | |
| 40 | use crate::{errors, fluent_generated as fluent}; | |
| 41 | ||
| 41 | 42 | impl<'a, 'tcx> FnCtxt<'a, 'tcx> { |
| 42 | 43 | pub(crate) fn body_fn_sig(&self) -> Option<ty::FnSig<'tcx>> { |
| 43 | 44 | self.typeck_results |
compiler/rustc_hir_typeck/src/gather_locals.rs+3-3| ... | ... | @@ -1,13 +1,13 @@ |
| 1 | use crate::FnCtxt; | |
| 2 | 1 | use rustc_hir as hir; |
| 3 | 2 | use rustc_hir::intravisit::{self, Visitor}; |
| 4 | 3 | use rustc_hir::{HirId, PatKind}; |
| 5 | 4 | use rustc_infer::traits::ObligationCauseCode; |
| 6 | use rustc_middle::ty::Ty; | |
| 7 | use rustc_middle::ty::UserType; | |
| 5 | use rustc_middle::ty::{Ty, UserType}; | |
| 8 | 6 | use rustc_span::def_id::LocalDefId; |
| 9 | 7 | use rustc_span::Span; |
| 10 | 8 | |
| 9 | use crate::FnCtxt; | |
| 10 | ||
| 11 | 11 | /// Provides context for checking patterns in declarations. More specifically this |
| 12 | 12 | /// allows us to infer array types if the pattern is irrefutable and allows us to infer |
| 13 | 13 | /// the size of the array. See issue #76342. |
compiler/rustc_hir_typeck/src/intrinsicck.rs+2-1| ... | ... | @@ -1,5 +1,6 @@ |
| 1 | 1 | use hir::HirId; |
| 2 | use rustc_errors::{codes::*, struct_span_code_err}; | |
| 2 | use rustc_errors::codes::*; | |
| 3 | use rustc_errors::struct_span_code_err; | |
| 3 | 4 | use rustc_hir as hir; |
| 4 | 5 | use rustc_index::Idx; |
| 5 | 6 | use rustc_middle::bug; |
compiler/rustc_hir_typeck/src/lib.rs+10-9| ... | ... | @@ -44,16 +44,9 @@ mod writeback; |
| 44 | 44 | |
| 45 | 45 | pub use coercion::can_coerce; |
| 46 | 46 | use fn_ctxt::FnCtxt; |
| 47 | use typeck_root_ctxt::TypeckRootCtxt; | |
| 48 | ||
| 49 | use crate::check::check_fn; | |
| 50 | use crate::coercion::DynamicCoerceMany; | |
| 51 | use crate::diverges::Diverges; | |
| 52 | use crate::expectation::Expectation; | |
| 53 | use crate::fn_ctxt::LoweredTy; | |
| 54 | use crate::gather_locals::GatherLocalsVisitor; | |
| 55 | 47 | use rustc_data_structures::unord::UnordSet; |
| 56 | use rustc_errors::{codes::*, struct_span_code_err, Applicability, ErrorGuaranteed}; | |
| 48 | use rustc_errors::codes::*; | |
| 49 | use rustc_errors::{struct_span_code_err, Applicability, ErrorGuaranteed}; | |
| 57 | 50 | use rustc_hir as hir; |
| 58 | 51 | use rustc_hir::def::{DefKind, Res}; |
| 59 | 52 | use rustc_hir::intravisit::Visitor; |
| ... | ... | @@ -67,6 +60,14 @@ use rustc_middle::{bug, span_bug}; |
| 67 | 60 | use rustc_session::config; |
| 68 | 61 | use rustc_span::def_id::LocalDefId; |
| 69 | 62 | use rustc_span::Span; |
| 63 | use typeck_root_ctxt::TypeckRootCtxt; | |
| 64 | ||
| 65 | use crate::check::check_fn; | |
| 66 | use crate::coercion::DynamicCoerceMany; | |
| 67 | use crate::diverges::Diverges; | |
| 68 | use crate::expectation::Expectation; | |
| 69 | use crate::fn_ctxt::LoweredTy; | |
| 70 | use crate::gather_locals::GatherLocalsVisitor; | |
| 70 | 71 | |
| 71 | 72 | rustc_fluent_macro::fluent_messages! { "../messages.ftl" } |
| 72 | 73 |
compiler/rustc_hir_typeck/src/method/confirm.rs+6-5| ... | ... | @@ -1,6 +1,5 @@ |
| 1 | use super::{probe, MethodCallee}; | |
| 1 | use std::ops::Deref; | |
| 2 | 2 | |
| 3 | use crate::{callee, FnCtxt}; | |
| 4 | 3 | use rustc_hir as hir; |
| 5 | 4 | use rustc_hir::def_id::DefId; |
| 6 | 5 | use rustc_hir::GenericArg; |
| ... | ... | @@ -12,8 +11,9 @@ use rustc_hir_analysis::hir_ty_lowering::{ |
| 12 | 11 | }; |
| 13 | 12 | use rustc_infer::infer::{self, DefineOpaqueTypes, InferOk}; |
| 14 | 13 | use rustc_middle::traits::{ObligationCauseCode, UnifyReceiverContext}; |
| 15 | use rustc_middle::ty::adjustment::{Adjust, Adjustment, PointerCoercion}; | |
| 16 | use rustc_middle::ty::adjustment::{AllowTwoPhase, AutoBorrow, AutoBorrowMutability}; | |
| 14 | use rustc_middle::ty::adjustment::{ | |
| 15 | Adjust, Adjustment, AllowTwoPhase, AutoBorrow, AutoBorrowMutability, PointerCoercion, | |
| 16 | }; | |
| 17 | 17 | use rustc_middle::ty::fold::TypeFoldable; |
| 18 | 18 | use rustc_middle::ty::{ |
| 19 | 19 | self, GenericArgs, GenericArgsRef, GenericParamDefKind, Ty, TyCtxt, UserArgs, UserType, |
| ... | ... | @@ -22,7 +22,8 @@ use rustc_middle::{bug, span_bug}; |
| 22 | 22 | use rustc_span::{Span, DUMMY_SP}; |
| 23 | 23 | use rustc_trait_selection::traits; |
| 24 | 24 | |
| 25 | use std::ops::Deref; | |
| 25 | use super::{probe, MethodCallee}; | |
| 26 | use crate::{callee, FnCtxt}; | |
| 26 | 27 | |
| 27 | 28 | struct ConfirmContext<'a, 'tcx> { |
| 28 | 29 | fcx: &'a FnCtxt<'a, 'tcx>, |
compiler/rustc_hir_typeck/src/method/mod.rs+5-5| ... | ... | @@ -7,9 +7,6 @@ mod prelude_edition_lints; |
| 7 | 7 | pub mod probe; |
| 8 | 8 | mod suggest; |
| 9 | 9 | |
| 10 | pub use self::MethodError::*; | |
| 11 | ||
| 12 | use crate::FnCtxt; | |
| 13 | 10 | use rustc_errors::{Applicability, Diag, SubdiagMessage}; |
| 14 | 11 | use rustc_hir as hir; |
| 15 | 12 | use rustc_hir::def::{CtorOf, DefKind, Namespace}; |
| ... | ... | @@ -17,8 +14,9 @@ use rustc_hir::def_id::DefId; |
| 17 | 14 | use rustc_infer::infer::{self, InferOk}; |
| 18 | 15 | use rustc_middle::query::Providers; |
| 19 | 16 | use rustc_middle::traits::ObligationCause; |
| 20 | use rustc_middle::ty::{self, GenericParamDefKind, Ty, TypeVisitableExt}; | |
| 21 | use rustc_middle::ty::{GenericArgs, GenericArgsRef}; | |
| 17 | use rustc_middle::ty::{ | |
| 18 | self, GenericArgs, GenericArgsRef, GenericParamDefKind, Ty, TypeVisitableExt, | |
| 19 | }; | |
| 22 | 20 | use rustc_middle::{bug, span_bug}; |
| 23 | 21 | use rustc_span::symbol::Ident; |
| 24 | 22 | use rustc_span::Span; |
| ... | ... | @@ -26,6 +24,8 @@ use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt; |
| 26 | 24 | use rustc_trait_selection::traits::{self, NormalizeExt}; |
| 27 | 25 | |
| 28 | 26 | use self::probe::{IsSuggestion, ProbeScope}; |
| 27 | pub use self::MethodError::*; | |
| 28 | use crate::FnCtxt; | |
| 29 | 29 | |
| 30 | 30 | pub fn provide(providers: &mut Providers) { |
| 31 | 31 | probe::provide(providers); |
compiler/rustc_hir_typeck/src/method/prelude_edition_lints.rs+5-5| ... | ... | @@ -1,9 +1,7 @@ |
| 1 | use crate::method::probe::{self, Pick}; | |
| 2 | use crate::FnCtxt; | |
| 1 | use std::fmt::Write; | |
| 3 | 2 | |
| 4 | 3 | use hir::def_id::DefId; |
| 5 | use hir::HirId; | |
| 6 | use hir::ItemKind; | |
| 4 | use hir::{HirId, ItemKind}; | |
| 7 | 5 | use rustc_errors::Applicability; |
| 8 | 6 | use rustc_hir as hir; |
| 9 | 7 | use rustc_lint::{ARRAY_INTO_ITER, BOXED_SLICE_INTO_ITER}; |
| ... | ... | @@ -14,7 +12,9 @@ use rustc_span::symbol::kw::{Empty, Underscore}; |
| 14 | 12 | use rustc_span::symbol::{sym, Ident}; |
| 15 | 13 | use rustc_span::Span; |
| 16 | 14 | use rustc_trait_selection::infer::InferCtxtExt; |
| 17 | use std::fmt::Write; | |
| 15 | ||
| 16 | use crate::method::probe::{self, Pick}; | |
| 17 | use crate::FnCtxt; | |
| 18 | 18 | |
| 19 | 19 | impl<'a, 'tcx> FnCtxt<'a, 'tcx> { |
| 20 | 20 | pub(super) fn lint_edition_dependent_dot_call( |
compiler/rustc_hir_typeck/src/method/probe.rs+17-29| ... | ... | @@ -1,58 +1,46 @@ |
| 1 | use super::suggest; | |
| 2 | use super::CandidateSource; | |
| 3 | use super::MethodError; | |
| 4 | use super::NoMatchData; | |
| 1 | use std::cell::{Cell, RefCell}; | |
| 2 | use std::cmp::max; | |
| 3 | use std::iter; | |
| 4 | use std::ops::Deref; | |
| 5 | 5 | |
| 6 | use crate::FnCtxt; | |
| 7 | 6 | use rustc_data_structures::fx::FxHashSet; |
| 8 | 7 | use rustc_errors::Applicability; |
| 9 | 8 | use rustc_hir as hir; |
| 10 | 9 | use rustc_hir::def::DefKind; |
| 11 | 10 | use rustc_hir::HirId; |
| 12 | 11 | use rustc_hir_analysis::autoderef::{self, Autoderef}; |
| 13 | use rustc_infer::infer::canonical::OriginalQueryValues; | |
| 14 | use rustc_infer::infer::canonical::{Canonical, QueryResponse}; | |
| 15 | use rustc_infer::infer::DefineOpaqueTypes; | |
| 16 | use rustc_infer::infer::{self, InferOk, TyCtxtInferExt}; | |
| 12 | use rustc_infer::infer::canonical::{Canonical, OriginalQueryValues, QueryResponse}; | |
| 13 | use rustc_infer::infer::{self, DefineOpaqueTypes, InferOk, TyCtxtInferExt}; | |
| 17 | 14 | use rustc_infer::traits::ObligationCauseCode; |
| 18 | 15 | use rustc_middle::middle::stability; |
| 19 | 16 | use rustc_middle::query::Providers; |
| 20 | 17 | use rustc_middle::ty::fast_reject::{simplify_type, TreatParams}; |
| 21 | use rustc_middle::ty::AssocItem; | |
| 22 | use rustc_middle::ty::AssocItemContainer; | |
| 23 | use rustc_middle::ty::GenericParamDefKind; | |
| 24 | use rustc_middle::ty::Upcast; | |
| 25 | use rustc_middle::ty::{self, ParamEnvAnd, Ty, TyCtxt, TypeVisitableExt}; | |
| 26 | use rustc_middle::ty::{GenericArgs, GenericArgsRef}; | |
| 18 | use rustc_middle::ty::{ | |
| 19 | self, AssocItem, AssocItemContainer, GenericArgs, GenericArgsRef, GenericParamDefKind, | |
| 20 | ParamEnvAnd, Ty, TyCtxt, TypeVisitableExt, Upcast, | |
| 21 | }; | |
| 27 | 22 | use rustc_middle::{bug, span_bug}; |
| 28 | 23 | use rustc_session::lint; |
| 29 | use rustc_span::def_id::DefId; | |
| 30 | use rustc_span::def_id::LocalDefId; | |
| 24 | use rustc_span::def_id::{DefId, LocalDefId}; | |
| 31 | 25 | use rustc_span::edit_distance::{ |
| 32 | 26 | edit_distance_with_substrings, find_best_match_for_name_with_substrings, |
| 33 | 27 | }; |
| 34 | use rustc_span::symbol::sym; | |
| 35 | use rustc_span::{symbol::Ident, Span, Symbol, DUMMY_SP}; | |
| 28 | use rustc_span::symbol::{sym, Ident}; | |
| 29 | use rustc_span::{Span, Symbol, DUMMY_SP}; | |
| 36 | 30 | use rustc_trait_selection::error_reporting::infer::need_type_info::TypeAnnotationNeeded; |
| 37 | 31 | use rustc_trait_selection::infer::InferCtxtExt as _; |
| 38 | 32 | use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt; |
| 39 | use rustc_trait_selection::traits::query::method_autoderef::MethodAutoderefBadTy; | |
| 40 | 33 | use rustc_trait_selection::traits::query::method_autoderef::{ |
| 41 | CandidateStep, MethodAutoderefStepsResult, | |
| 34 | CandidateStep, MethodAutoderefBadTy, MethodAutoderefStepsResult, | |
| 42 | 35 | }; |
| 43 | 36 | use rustc_trait_selection::traits::query::CanonicalTyGoal; |
| 44 | use rustc_trait_selection::traits::ObligationCtxt; | |
| 45 | use rustc_trait_selection::traits::{self, ObligationCause}; | |
| 46 | use std::cell::Cell; | |
| 47 | use std::cell::RefCell; | |
| 48 | use std::cmp::max; | |
| 49 | use std::iter; | |
| 50 | use std::ops::Deref; | |
| 51 | ||
| 37 | use rustc_trait_selection::traits::{self, ObligationCause, ObligationCtxt}; | |
| 52 | 38 | use smallvec::{smallvec, SmallVec}; |
| 53 | 39 | |
| 54 | 40 | use self::CandidateKind::*; |
| 55 | 41 | pub use self::PickKind::*; |
| 42 | use super::{suggest, CandidateSource, MethodError, NoMatchData}; | |
| 43 | use crate::FnCtxt; | |
| 56 | 44 | |
| 57 | 45 | /// Boolean flag used to indicate if this search is for a suggestion |
| 58 | 46 | /// or not. If true, we can allow ambiguity and so forth. |
compiler/rustc_hir_typeck/src/method/suggest.rs+13-17| ... | ... | @@ -3,49 +3,45 @@ |
| 3 | 3 | |
| 4 | 4 | // ignore-tidy-filelength |
| 5 | 5 | |
| 6 | use crate::errors::{self, CandidateTraitNote, NoAssociatedItem}; | |
| 7 | use crate::Expectation; | |
| 8 | use crate::FnCtxt; | |
| 9 | 6 | use core::ops::ControlFlow; |
| 7 | use std::borrow::Cow; | |
| 8 | ||
| 10 | 9 | use hir::Expr; |
| 11 | 10 | use rustc_ast::ast::Mutability; |
| 12 | 11 | use rustc_attr::parse_confusables; |
| 13 | 12 | use rustc_data_structures::fx::{FxIndexMap, FxIndexSet}; |
| 14 | 13 | use rustc_data_structures::sorted_map::SortedMap; |
| 15 | 14 | use rustc_data_structures::unord::UnordSet; |
| 16 | use rustc_errors::{ | |
| 17 | codes::*, pluralize, struct_span_code_err, Applicability, Diag, MultiSpan, StashKey, | |
| 18 | }; | |
| 15 | use rustc_errors::codes::*; | |
| 16 | use rustc_errors::{pluralize, struct_span_code_err, Applicability, Diag, MultiSpan, StashKey}; | |
| 19 | 17 | use rustc_hir::def::DefKind; |
| 20 | 18 | use rustc_hir::def_id::DefId; |
| 19 | use rustc_hir::intravisit::{self, Visitor}; | |
| 21 | 20 | use rustc_hir::lang_items::LangItem; |
| 22 | use rustc_hir::PathSegment; | |
| 23 | use rustc_hir::{self as hir, HirId}; | |
| 24 | use rustc_hir::{ExprKind, Node, QPath}; | |
| 21 | use rustc_hir::{self as hir, ExprKind, HirId, Node, PathSegment, QPath}; | |
| 25 | 22 | use rustc_infer::infer::{self, RegionVariableOrigin}; |
| 26 | 23 | use rustc_middle::bug; |
| 27 | use rustc_middle::ty::fast_reject::DeepRejectCtxt; | |
| 28 | use rustc_middle::ty::fast_reject::{simplify_type, TreatParams}; | |
| 24 | use rustc_middle::ty::fast_reject::{simplify_type, DeepRejectCtxt, TreatParams}; | |
| 29 | 25 | use rustc_middle::ty::print::{ |
| 30 | 26 | with_crate_prefix, with_forced_trimmed_paths, PrintTraitRefExt as _, |
| 31 | 27 | }; |
| 32 | use rustc_middle::ty::IsSuggestable; | |
| 33 | use rustc_middle::ty::{self, GenericArgKind, Ty, TyCtxt, TypeVisitableExt}; | |
| 28 | use rustc_middle::ty::{self, GenericArgKind, IsSuggestable, Ty, TyCtxt, TypeVisitableExt}; | |
| 34 | 29 | use rustc_span::def_id::DefIdSet; |
| 35 | 30 | use rustc_span::symbol::{kw, sym, Ident}; |
| 36 | use rustc_span::{edit_distance, ErrorGuaranteed, ExpnKind, FileName, MacroKind, Span}; | |
| 37 | use rustc_span::{Symbol, DUMMY_SP}; | |
| 31 | use rustc_span::{ | |
| 32 | edit_distance, ErrorGuaranteed, ExpnKind, FileName, MacroKind, Span, Symbol, DUMMY_SP, | |
| 33 | }; | |
| 38 | 34 | use rustc_trait_selection::error_reporting::traits::on_unimplemented::OnUnimplementedNote; |
| 39 | 35 | use rustc_trait_selection::infer::InferCtxtExt; |
| 40 | 36 | use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt as _; |
| 41 | 37 | use rustc_trait_selection::traits::{ |
| 42 | 38 | supertraits, FulfillmentError, Obligation, ObligationCause, ObligationCauseCode, |
| 43 | 39 | }; |
| 44 | use std::borrow::Cow; | |
| 45 | 40 | |
| 46 | 41 | use super::probe::{AutorefOrPtrAdjustment, IsSuggestion, Mode, ProbeScope}; |
| 47 | 42 | use super::{CandidateSource, MethodError, NoMatchData}; |
| 48 | use rustc_hir::intravisit::{self, Visitor}; | |
| 43 | use crate::errors::{self, CandidateTraitNote, NoAssociatedItem}; | |
| 44 | use crate::{Expectation, FnCtxt}; | |
| 49 | 45 | |
| 50 | 46 | impl<'a, 'tcx> FnCtxt<'a, 'tcx> { |
| 51 | 47 | fn is_fn_ty(&self, ty: Ty<'tcx>, span: Span) -> bool { |
compiler/rustc_hir_typeck/src/op.rs+7-6| ... | ... | @@ -1,12 +1,8 @@ |
| 1 | 1 | //! Code related to processing overloaded binary and unary operators. |
| 2 | 2 | |
| 3 | use super::method::MethodCallee; | |
| 4 | use super::FnCtxt; | |
| 5 | use crate::Expectation; | |
| 6 | use rustc_ast as ast; | |
| 7 | 3 | use rustc_data_structures::packed::Pu128; |
| 8 | use rustc_errors::{codes::*, struct_span_code_err, Applicability, Diag}; | |
| 9 | use rustc_hir as hir; | |
| 4 | use rustc_errors::codes::*; | |
| 5 | use rustc_errors::{struct_span_code_err, Applicability, Diag}; | |
| 10 | 6 | use rustc_infer::traits::ObligationCauseCode; |
| 11 | 7 | use rustc_middle::ty::adjustment::{ |
| 12 | 8 | Adjust, Adjustment, AllowTwoPhase, AutoBorrow, AutoBorrowMutability, |
| ... | ... | @@ -21,6 +17,11 @@ use rustc_span::Span; |
| 21 | 17 | use rustc_trait_selection::infer::InferCtxtExt; |
| 22 | 18 | use rustc_trait_selection::traits::{FulfillmentError, ObligationCtxt}; |
| 23 | 19 | use rustc_type_ir::TyKind::*; |
| 20 | use {rustc_ast as ast, rustc_hir as hir}; | |
| 21 | ||
| 22 | use super::method::MethodCallee; | |
| 23 | use super::FnCtxt; | |
| 24 | use crate::Expectation; | |
| 24 | 25 | |
| 25 | 26 | impl<'a, 'tcx> FnCtxt<'a, 'tcx> { |
| 26 | 27 | /// Checks a `a <op>= b` |
compiler/rustc_hir_typeck/src/pat.rs+9-7| ... | ... | @@ -1,9 +1,11 @@ |
| 1 | use crate::gather_locals::DeclOrigin; | |
| 2 | use crate::{errors, FnCtxt, LoweredTy}; | |
| 1 | use std::cmp; | |
| 2 | use std::collections::hash_map::Entry::{Occupied, Vacant}; | |
| 3 | ||
| 3 | 4 | use rustc_ast as ast; |
| 4 | 5 | use rustc_data_structures::fx::FxHashMap; |
| 6 | use rustc_errors::codes::*; | |
| 5 | 7 | use rustc_errors::{ |
| 6 | codes::*, pluralize, struct_span_code_err, Applicability, Diag, ErrorGuaranteed, MultiSpan, | |
| 8 | pluralize, struct_span_code_err, Applicability, Diag, ErrorGuaranteed, MultiSpan, | |
| 7 | 9 | }; |
| 8 | 10 | use rustc_hir::def::{CtorKind, DefKind, Res}; |
| 9 | 11 | use rustc_hir::pat_util::EnumerateAndAdjustIterator; |
| ... | ... | @@ -12,7 +14,8 @@ use rustc_infer::infer; |
| 12 | 14 | use rustc_middle::mir::interpret::ErrorHandled; |
| 13 | 15 | use rustc_middle::ty::{self, Ty, TypeVisitableExt}; |
| 14 | 16 | use rustc_middle::{bug, span_bug}; |
| 15 | use rustc_session::{lint::builtin::NON_EXHAUSTIVE_OMITTED_PATTERNS, parse::feature_err}; | |
| 17 | use rustc_session::lint::builtin::NON_EXHAUSTIVE_OMITTED_PATTERNS; | |
| 18 | use rustc_session::parse::feature_err; | |
| 16 | 19 | use rustc_span::edit_distance::find_best_match_for_name; |
| 17 | 20 | use rustc_span::hygiene::DesugaringKind; |
| 18 | 21 | use rustc_span::source_map::Spanned; |
| ... | ... | @@ -23,10 +26,9 @@ use rustc_trait_selection::infer::InferCtxtExt; |
| 23 | 26 | use rustc_trait_selection::traits::{ObligationCause, ObligationCauseCode}; |
| 24 | 27 | use ty::VariantDef; |
| 25 | 28 | |
| 26 | use std::cmp; | |
| 27 | use std::collections::hash_map::Entry::{Occupied, Vacant}; | |
| 28 | ||
| 29 | 29 | use super::report_unexpected_variant_res; |
| 30 | use crate::gather_locals::DeclOrigin; | |
| 31 | use crate::{errors, FnCtxt, LoweredTy}; | |
| 30 | 32 | |
| 31 | 33 | const CANNOT_IMPLICITLY_DEREF_POINTER_TRAIT_OBJ: &str = "\ |
| 32 | 34 | This error indicates that a pointer to a trait type cannot be implicitly dereferenced by a \ |
compiler/rustc_hir_typeck/src/place_op.rs+8-6| ... | ... | @@ -1,16 +1,18 @@ |
| 1 | use crate::method::MethodCallee; | |
| 2 | use crate::{FnCtxt, PlaceOp}; | |
| 3 | use rustc_ast as ast; | |
| 4 | 1 | use rustc_errors::Applicability; |
| 5 | use rustc_hir as hir; | |
| 6 | 2 | use rustc_hir_analysis::autoderef::Autoderef; |
| 7 | 3 | use rustc_infer::infer::InferOk; |
| 8 | 4 | use rustc_middle::span_bug; |
| 9 | use rustc_middle::ty::adjustment::{Adjust, Adjustment, OverloadedDeref, PointerCoercion}; | |
| 10 | use rustc_middle::ty::adjustment::{AllowTwoPhase, AutoBorrow, AutoBorrowMutability}; | |
| 5 | use rustc_middle::ty::adjustment::{ | |
| 6 | Adjust, Adjustment, AllowTwoPhase, AutoBorrow, AutoBorrowMutability, OverloadedDeref, | |
| 7 | PointerCoercion, | |
| 8 | }; | |
| 11 | 9 | use rustc_middle::ty::{self, Ty}; |
| 12 | 10 | use rustc_span::symbol::{sym, Ident}; |
| 13 | 11 | use rustc_span::Span; |
| 12 | use {rustc_ast as ast, rustc_hir as hir}; | |
| 13 | ||
| 14 | use crate::method::MethodCallee; | |
| 15 | use crate::{FnCtxt, PlaceOp}; | |
| 14 | 16 | |
| 15 | 17 | impl<'a, 'tcx> FnCtxt<'a, 'tcx> { |
| 16 | 18 | /// Type-check `*oprnd_expr` with `oprnd_expr` type-checked already. |
compiler/rustc_hir_typeck/src/rvalue_scopes.rs+2-1| ... | ... | @@ -1,4 +1,3 @@ |
| 1 | use super::FnCtxt; | |
| 2 | 1 | use hir::def_id::DefId; |
| 3 | 2 | use hir::Node; |
| 4 | 3 | use rustc_hir as hir; |
| ... | ... | @@ -6,6 +5,8 @@ use rustc_middle::bug; |
| 6 | 5 | use rustc_middle::middle::region::{RvalueCandidateType, Scope, ScopeTree}; |
| 7 | 6 | use rustc_middle::ty::RvalueScopes; |
| 8 | 7 | |
| 8 | use super::FnCtxt; | |
| 9 | ||
| 9 | 10 | /// Applied to an expression `expr` if `expr` -- or something owned or partially owned by |
| 10 | 11 | /// `expr` -- is going to be indirectly referenced by a variable in a let statement. In that |
| 11 | 12 | /// case, the "temporary lifetime" or `expr` is extended to be the block enclosing the `let` |
compiler/rustc_hir_typeck/src/typeck_root_ctxt.rs+3-3| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | use super::callee::DeferredCallResolution; | |
| 1 | use std::cell::RefCell; | |
| 2 | use std::ops::Deref; | |
| 2 | 3 | |
| 3 | 4 | use rustc_data_structures::unord::{UnordMap, UnordSet}; |
| 4 | 5 | use rustc_hir as hir; |
| ... | ... | @@ -15,8 +16,7 @@ use rustc_trait_selection::traits::{ |
| 15 | 16 | self, FulfillmentError, PredicateObligation, TraitEngine, TraitEngineExt as _, |
| 16 | 17 | }; |
| 17 | 18 | |
| 18 | use std::cell::RefCell; | |
| 19 | use std::ops::Deref; | |
| 19 | use super::callee::DeferredCallResolution; | |
| 20 | 20 | |
| 21 | 21 | /// Data shared between a "typeck root" and its nested bodies, |
| 22 | 22 | /// e.g. closures defined within the function. For example: |
compiler/rustc_hir_typeck/src/upvar.rs+6-8| ... | ... | @@ -30,9 +30,9 @@ |
| 30 | 30 | //! then mean that all later passes would have to check for these figments |
| 31 | 31 | //! and report an error, and it just seems like more mess in the end.) |
| 32 | 32 | |
| 33 | use super::FnCtxt; | |
| 33 | use std::iter; | |
| 34 | 34 | |
| 35 | use crate::expr_use_visitor as euv; | |
| 35 | use rustc_data_structures::fx::{FxIndexMap, FxIndexSet}; | |
| 36 | 36 | use rustc_data_structures::unord::{ExtendUnord, UnordSet}; |
| 37 | 37 | use rustc_errors::{Applicability, MultiSpan}; |
| 38 | 38 | use rustc_hir as hir; |
| ... | ... | @@ -49,14 +49,12 @@ use rustc_middle::ty::{ |
| 49 | 49 | }; |
| 50 | 50 | use rustc_middle::{bug, span_bug}; |
| 51 | 51 | use rustc_session::lint; |
| 52 | use rustc_span::sym; | |
| 53 | use rustc_span::{BytePos, Pos, Span, Symbol}; | |
| 54 | use rustc_trait_selection::infer::InferCtxtExt; | |
| 55 | ||
| 56 | use rustc_data_structures::fx::{FxIndexMap, FxIndexSet}; | |
| 52 | use rustc_span::{sym, BytePos, Pos, Span, Symbol}; | |
| 57 | 53 | use rustc_target::abi::FIRST_VARIANT; |
| 54 | use rustc_trait_selection::infer::InferCtxtExt; | |
| 58 | 55 | |
| 59 | use std::iter; | |
| 56 | use super::FnCtxt; | |
| 57 | use crate::expr_use_visitor as euv; | |
| 60 | 58 | |
| 61 | 59 | /// Describe the relationship between the paths of two places |
| 62 | 60 | /// eg: |
compiler/rustc_hir_typeck/src/writeback.rs+4-4| ... | ... | @@ -2,7 +2,8 @@ |
| 2 | 2 | // unresolved type variables and replaces "ty_var" types with their |
| 3 | 3 | // generic parameters. |
| 4 | 4 | |
| 5 | use crate::FnCtxt; | |
| 5 | use std::mem; | |
| 6 | ||
| 6 | 7 | use rustc_data_structures::unord::ExtendUnord; |
| 7 | 8 | use rustc_errors::{ErrorGuaranteed, StashKey}; |
| 8 | 9 | use rustc_hir as hir; |
| ... | ... | @@ -13,14 +14,13 @@ use rustc_middle::traits::ObligationCause; |
| 13 | 14 | use rustc_middle::ty::adjustment::{Adjust, Adjustment, PointerCoercion}; |
| 14 | 15 | use rustc_middle::ty::fold::{TypeFoldable, TypeFolder}; |
| 15 | 16 | use rustc_middle::ty::visit::TypeVisitableExt; |
| 16 | use rustc_middle::ty::TypeSuperFoldable; | |
| 17 | use rustc_middle::ty::{self, Ty, TyCtxt}; | |
| 17 | use rustc_middle::ty::{self, Ty, TyCtxt, TypeSuperFoldable}; | |
| 18 | 18 | use rustc_span::symbol::sym; |
| 19 | 19 | use rustc_span::Span; |
| 20 | 20 | use rustc_trait_selection::error_reporting::infer::need_type_info::TypeAnnotationNeeded; |
| 21 | 21 | use rustc_trait_selection::solve; |
| 22 | 22 | |
| 23 | use std::mem; | |
| 23 | use crate::FnCtxt; | |
| 24 | 24 | |
| 25 | 25 | /////////////////////////////////////////////////////////////////////////// |
| 26 | 26 | // Entry point |
compiler/rustc_incremental/src/assert_dep_graph.rs+7-7| ... | ... | @@ -33,12 +33,12 @@ |
| 33 | 33 | //! fn baz() { foo(); } |
| 34 | 34 | //! ``` |
| 35 | 35 | |
| 36 | use crate::errors; | |
| 37 | use rustc_ast as ast; | |
| 36 | use std::env; | |
| 37 | use std::fs::{self, File}; | |
| 38 | use std::io::{BufWriter, Write}; | |
| 39 | ||
| 38 | 40 | use rustc_data_structures::fx::FxIndexSet; |
| 39 | 41 | use rustc_data_structures::graph::implementation::{Direction, NodeIndex, INCOMING, OUTGOING}; |
| 40 | use rustc_graphviz as dot; | |
| 41 | use rustc_hir as hir; | |
| 42 | 42 | use rustc_hir::def_id::{DefId, LocalDefId, CRATE_DEF_ID}; |
| 43 | 43 | use rustc_hir::intravisit::{self, Visitor}; |
| 44 | 44 | use rustc_middle::dep_graph::{ |
| ... | ... | @@ -49,10 +49,10 @@ use rustc_middle::ty::TyCtxt; |
| 49 | 49 | use rustc_middle::{bug, span_bug}; |
| 50 | 50 | use rustc_span::symbol::{sym, Symbol}; |
| 51 | 51 | use rustc_span::Span; |
| 52 | use std::env; | |
| 53 | use std::fs::{self, File}; | |
| 54 | use std::io::{BufWriter, Write}; | |
| 55 | 52 | use tracing::debug; |
| 53 | use {rustc_ast as ast, rustc_graphviz as dot, rustc_hir as hir}; | |
| 54 | ||
| 55 | use crate::errors; | |
| 56 | 56 | |
| 57 | 57 | #[allow(missing_docs)] |
| 58 | 58 | pub fn assert_dep_graph(tcx: TyCtxt<'_>) { |
compiler/rustc_incremental/src/errors.rs+4-2| ... | ... | @@ -1,7 +1,9 @@ |
| 1 | use rustc_macros::Diagnostic; | |
| 2 | use rustc_span::{symbol::Ident, Span, Symbol}; | |
| 3 | 1 | use std::path::{Path, PathBuf}; |
| 4 | 2 | |
| 3 | use rustc_macros::Diagnostic; | |
| 4 | use rustc_span::symbol::Ident; | |
| 5 | use rustc_span::{Span, Symbol}; | |
| 6 | ||
| 5 | 7 | #[derive(Diagnostic)] |
| 6 | 8 | #[diag(incremental_unrecognized_depnode)] |
| 7 | 9 | pub struct UnrecognizedDepNode { |
compiler/rustc_incremental/src/lib.rs+5-9| ... | ... | @@ -12,14 +12,10 @@ mod assert_dep_graph; |
| 12 | 12 | mod errors; |
| 13 | 13 | mod persist; |
| 14 | 14 | |
| 15 | pub use persist::copy_cgu_workproduct_to_incr_comp_cache_dir; | |
| 16 | pub use persist::finalize_session_directory; | |
| 17 | pub use persist::in_incr_comp_dir; | |
| 18 | pub use persist::in_incr_comp_dir_sess; | |
| 19 | pub use persist::load_query_result_cache; | |
| 20 | pub use persist::save_dep_graph; | |
| 21 | pub use persist::save_work_product_index; | |
| 22 | pub use persist::setup_dep_graph; | |
| 23 | pub use persist::LoadResult; | |
| 15 | pub use persist::{ | |
| 16 | copy_cgu_workproduct_to_incr_comp_cache_dir, finalize_session_directory, in_incr_comp_dir, | |
| 17 | in_incr_comp_dir_sess, load_query_result_cache, save_dep_graph, save_work_product_index, | |
| 18 | setup_dep_graph, LoadResult, | |
| 19 | }; | |
| 24 | 20 | |
| 25 | 21 | rustc_fluent_macro::fluent_messages! { "../messages.ftl" } |
compiler/rustc_incremental/src/persist/dirty_clean.rs+3-4| ... | ... | @@ -19,14 +19,11 @@ |
| 19 | 19 | //! Errors are reported if we are in the suitable configuration but |
| 20 | 20 | //! the required condition is not met. |
| 21 | 21 | |
| 22 | use crate::errors; | |
| 23 | 22 | use rustc_ast::{self as ast, Attribute, NestedMetaItem}; |
| 24 | 23 | use rustc_data_structures::fx::FxHashSet; |
| 25 | 24 | use rustc_data_structures::unord::UnordSet; |
| 26 | 25 | use rustc_hir::def_id::LocalDefId; |
| 27 | use rustc_hir::intravisit; | |
| 28 | use rustc_hir::Node as HirNode; | |
| 29 | use rustc_hir::{ImplItemKind, ItemKind as HirItem, TraitItemKind}; | |
| 26 | use rustc_hir::{intravisit, ImplItemKind, ItemKind as HirItem, Node as HirNode, TraitItemKind}; | |
| 30 | 27 | use rustc_middle::dep_graph::{label_strs, DepNode, DepNodeExt}; |
| 31 | 28 | use rustc_middle::hir::nested_filter; |
| 32 | 29 | use rustc_middle::ty::TyCtxt; |
| ... | ... | @@ -35,6 +32,8 @@ use rustc_span::Span; |
| 35 | 32 | use thin_vec::ThinVec; |
| 36 | 33 | use tracing::debug; |
| 37 | 34 | |
| 35 | use crate::errors; | |
| 36 | ||
| 38 | 37 | const LOADED_FROM_DISK: Symbol = sym::loaded_from_disk; |
| 39 | 38 | const EXCEPT: Symbol = sym::except; |
| 40 | 39 | const CFG: Symbol = sym::cfg; |
compiler/rustc_incremental/src/persist/file_format.rs+7-6| ... | ... | @@ -9,18 +9,19 @@ |
| 9 | 9 | //! compiler versions don't change frequently for the typical user, being |
| 10 | 10 | //! conservative here practically has no downside. |
| 11 | 11 | |
| 12 | use crate::errors; | |
| 12 | use std::borrow::Cow; | |
| 13 | use std::io::{self, Read}; | |
| 14 | use std::path::{Path, PathBuf}; | |
| 15 | use std::{env, fs}; | |
| 16 | ||
| 13 | 17 | use rustc_data_structures::memmap::Mmap; |
| 14 | 18 | use rustc_serialize::opaque::{FileEncodeResult, FileEncoder}; |
| 15 | 19 | use rustc_serialize::Encoder; |
| 16 | 20 | use rustc_session::Session; |
| 17 | use std::borrow::Cow; | |
| 18 | use std::env; | |
| 19 | use std::fs; | |
| 20 | use std::io::{self, Read}; | |
| 21 | use std::path::{Path, PathBuf}; | |
| 22 | 21 | use tracing::debug; |
| 23 | 22 | |
| 23 | use crate::errors; | |
| 24 | ||
| 24 | 25 | /// The first few bytes of files generated by incremental compilation. |
| 25 | 26 | const FILE_MAGIC: &[u8] = b"RSIC"; |
| 26 | 27 |
compiler/rustc_incremental/src/persist/fs.rs+10-13| ... | ... | @@ -103,30 +103,27 @@ |
| 103 | 103 | //! unsupported file system and emit a warning in that case. This is not yet |
| 104 | 104 | //! implemented. |
| 105 | 105 | |
| 106 | use crate::errors; | |
| 107 | use rustc_data_structures::base_n; | |
| 108 | use rustc_data_structures::base_n::BaseNString; | |
| 109 | use rustc_data_structures::base_n::ToBaseN; | |
| 110 | use rustc_data_structures::base_n::CASE_INSENSITIVE; | |
| 111 | use rustc_data_structures::flock; | |
| 106 | use std::fs as std_fs; | |
| 107 | use std::io::{self, ErrorKind}; | |
| 108 | use std::path::{Path, PathBuf}; | |
| 109 | use std::time::{Duration, SystemTime, UNIX_EPOCH}; | |
| 110 | ||
| 111 | use rand::{thread_rng, RngCore}; | |
| 112 | use rustc_data_structures::base_n::{BaseNString, ToBaseN, CASE_INSENSITIVE}; | |
| 112 | 113 | use rustc_data_structures::fx::{FxHashSet, FxIndexSet}; |
| 113 | 114 | use rustc_data_structures::svh::Svh; |
| 114 | 115 | use rustc_data_structures::unord::{UnordMap, UnordSet}; |
| 116 | use rustc_data_structures::{base_n, flock}; | |
| 115 | 117 | use rustc_errors::ErrorGuaranteed; |
| 116 | 118 | use rustc_fs_util::{link_or_copy, try_canonicalize, LinkOrCopy}; |
| 117 | 119 | use rustc_middle::bug; |
| 118 | 120 | use rustc_session::config::CrateType; |
| 119 | 121 | use rustc_session::output::{collect_crate_types, find_crate_name}; |
| 120 | 122 | use rustc_session::{Session, StableCrateId}; |
| 121 | ||
| 122 | use std::fs as std_fs; | |
| 123 | use std::io::{self, ErrorKind}; | |
| 124 | use std::path::{Path, PathBuf}; | |
| 125 | use std::time::{Duration, SystemTime, UNIX_EPOCH}; | |
| 126 | ||
| 127 | use rand::{thread_rng, RngCore}; | |
| 128 | 123 | use tracing::debug; |
| 129 | 124 | |
| 125 | use crate::errors; | |
| 126 | ||
| 130 | 127 | #[cfg(test)] |
| 131 | 128 | mod tests; |
| 132 | 129 |
compiler/rustc_incremental/src/persist/load.rs+5-5| ... | ... | @@ -1,6 +1,8 @@ |
| 1 | 1 | //! Code to load the dep-graph from files. |
| 2 | 2 | |
| 3 | use crate::errors; | |
| 3 | use std::path::{Path, PathBuf}; | |
| 4 | use std::sync::Arc; | |
| 5 | ||
| 4 | 6 | use rustc_data_structures::memmap::Mmap; |
| 5 | 7 | use rustc_data_structures::unord::UnordMap; |
| 6 | 8 | use rustc_middle::dep_graph::{DepGraph, DepsType, SerializedDepGraph, WorkProductMap}; |
| ... | ... | @@ -10,15 +12,13 @@ use rustc_serialize::Decodable; |
| 10 | 12 | use rustc_session::config::IncrementalStateAssertion; |
| 11 | 13 | use rustc_session::Session; |
| 12 | 14 | use rustc_span::ErrorGuaranteed; |
| 13 | use std::path::{Path, PathBuf}; | |
| 14 | use std::sync::Arc; | |
| 15 | 15 | use tracing::{debug, warn}; |
| 16 | 16 | |
| 17 | 17 | use super::data::*; |
| 18 | use super::file_format; | |
| 19 | 18 | use super::fs::*; |
| 20 | 19 | use super::save::build_dep_graph; |
| 21 | use super::work_product; | |
| 20 | use super::{file_format, work_product}; | |
| 21 | use crate::errors; | |
| 22 | 22 | |
| 23 | 23 | #[derive(Debug)] |
| 24 | 24 | /// Represents the result of an attempt to load incremental compilation data. |
compiler/rustc_incremental/src/persist/mod.rs+3-8| ... | ... | @@ -10,12 +10,7 @@ mod load; |
| 10 | 10 | mod save; |
| 11 | 11 | mod work_product; |
| 12 | 12 | |
| 13 | pub use fs::finalize_session_directory; | |
| 14 | pub use fs::in_incr_comp_dir; | |
| 15 | pub use fs::in_incr_comp_dir_sess; | |
| 16 | pub use load::load_query_result_cache; | |
| 17 | pub use load::setup_dep_graph; | |
| 18 | pub use load::LoadResult; | |
| 19 | pub use save::save_dep_graph; | |
| 20 | pub use save::save_work_product_index; | |
| 13 | pub use fs::{finalize_session_directory, in_incr_comp_dir, in_incr_comp_dir_sess}; | |
| 14 | pub use load::{load_query_result_cache, setup_dep_graph, LoadResult}; | |
| 15 | pub use save::{save_dep_graph, save_work_product_index}; | |
| 21 | 16 | pub use work_product::copy_cgu_workproduct_to_incr_comp_cache_dir; |
compiler/rustc_incremental/src/persist/save.rs+6-7| ... | ... | @@ -1,5 +1,6 @@ |
| 1 | use crate::assert_dep_graph::assert_dep_graph; | |
| 2 | use crate::errors; | |
| 1 | use std::fs; | |
| 2 | use std::sync::Arc; | |
| 3 | ||
| 3 | 4 | use rustc_data_structures::fx::FxIndexMap; |
| 4 | 5 | use rustc_data_structures::sync::join; |
| 5 | 6 | use rustc_middle::dep_graph::{ |
| ... | ... | @@ -9,15 +10,13 @@ use rustc_middle::ty::TyCtxt; |
| 9 | 10 | use rustc_serialize::opaque::{FileEncodeResult, FileEncoder}; |
| 10 | 11 | use rustc_serialize::Encodable as RustcEncodable; |
| 11 | 12 | use rustc_session::Session; |
| 12 | use std::fs; | |
| 13 | use std::sync::Arc; | |
| 14 | 13 | use tracing::debug; |
| 15 | 14 | |
| 16 | 15 | use super::data::*; |
| 17 | use super::dirty_clean; | |
| 18 | use super::file_format; | |
| 19 | 16 | use super::fs::*; |
| 20 | use super::work_product; | |
| 17 | use super::{dirty_clean, file_format, work_product}; | |
| 18 | use crate::assert_dep_graph::assert_dep_graph; | |
| 19 | use crate::errors; | |
| 21 | 20 | |
| 22 | 21 | /// Saves and writes the [`DepGraph`] to the file system. |
| 23 | 22 | /// |
compiler/rustc_incremental/src/persist/work_product.rs+6-4| ... | ... | @@ -2,16 +2,18 @@ |
| 2 | 2 | //! |
| 3 | 3 | //! [work products]: WorkProduct |
| 4 | 4 | |
| 5 | use crate::errors; | |
| 6 | use crate::persist::fs::*; | |
| 5 | use std::fs as std_fs; | |
| 6 | use std::path::Path; | |
| 7 | ||
| 7 | 8 | use rustc_data_structures::unord::UnordMap; |
| 8 | 9 | use rustc_fs_util::link_or_copy; |
| 9 | 10 | use rustc_middle::dep_graph::{WorkProduct, WorkProductId}; |
| 10 | 11 | use rustc_session::Session; |
| 11 | use std::fs as std_fs; | |
| 12 | use std::path::Path; | |
| 13 | 12 | use tracing::debug; |
| 14 | 13 | |
| 14 | use crate::errors; | |
| 15 | use crate::persist::fs::*; | |
| 16 | ||
| 15 | 17 | /// Copies a CGU work product to the incremental compilation directory, so next compilation can |
| 16 | 18 | /// find and reuse it. |
| 17 | 19 | pub fn copy_cgu_workproduct_to_incr_comp_cache_dir( |
compiler/rustc_index/src/bit_set.rs+3-8| ... | ... | @@ -1,21 +1,16 @@ |
| 1 | use std::fmt; | |
| 2 | use std::iter; | |
| 3 | 1 | use std::marker::PhantomData; |
| 4 | use std::mem; | |
| 5 | 2 | use std::ops::{BitAnd, BitAndAssign, BitOrAssign, Bound, Not, Range, RangeBounds, Shl}; |
| 6 | 3 | use std::rc::Rc; |
| 7 | use std::slice; | |
| 4 | use std::{fmt, iter, mem, slice}; | |
| 8 | 5 | |
| 9 | 6 | use arrayvec::ArrayVec; |
| 10 | use smallvec::{smallvec, SmallVec}; | |
| 11 | ||
| 12 | 7 | #[cfg(feature = "nightly")] |
| 13 | 8 | use rustc_macros::{Decodable_Generic, Encodable_Generic}; |
| 9 | use smallvec::{smallvec, SmallVec}; | |
| 10 | use Chunk::*; | |
| 14 | 11 | |
| 15 | 12 | use crate::{Idx, IndexVec}; |
| 16 | 13 | |
| 17 | use Chunk::*; | |
| 18 | ||
| 19 | 14 | #[cfg(test)] |
| 20 | 15 | mod tests; |
| 21 | 16 |
compiler/rustc_index/src/bit_set/tests.rs+1| ... | ... | @@ -2,6 +2,7 @@ use super::*; |
| 2 | 2 | |
| 3 | 3 | extern crate test; |
| 4 | 4 | use std::hint::black_box; |
| 5 | ||
| 5 | 6 | use test::Bencher; |
| 6 | 7 | |
| 7 | 8 | #[test] |
compiler/rustc_index/src/interval.rs+1-2| ... | ... | @@ -1,7 +1,6 @@ |
| 1 | 1 | use std::iter::Step; |
| 2 | 2 | use std::marker::PhantomData; |
| 3 | use std::ops::RangeBounds; | |
| 4 | use std::ops::{Bound, Range}; | |
| 3 | use std::ops::{Bound, Range, RangeBounds}; | |
| 5 | 4 | |
| 6 | 5 | use smallvec::SmallVec; |
| 7 | 6 |
compiler/rustc_index/src/lib.rs+3-2| ... | ... | @@ -12,9 +12,10 @@ mod idx; |
| 12 | 12 | mod slice; |
| 13 | 13 | mod vec; |
| 14 | 14 | |
| 15 | pub use {idx::Idx, slice::IndexSlice, vec::IndexVec}; | |
| 16 | ||
| 15 | pub use idx::Idx; | |
| 17 | 16 | pub use rustc_index_macros::newtype_index; |
| 17 | pub use slice::IndexSlice; | |
| 18 | pub use vec::IndexVec; | |
| 18 | 19 | |
| 19 | 20 | /// Type size assertion. The first argument is a type and the second argument is its expected size. |
| 20 | 21 | /// |
compiler/rustc_index/src/slice.rs+3-6| ... | ... | @@ -1,9 +1,6 @@ |
| 1 | use std::{ | |
| 2 | fmt, | |
| 3 | marker::PhantomData, | |
| 4 | ops::{Index, IndexMut}, | |
| 5 | slice, | |
| 6 | }; | |
| 1 | use std::marker::PhantomData; | |
| 2 | use std::ops::{Index, IndexMut}; | |
| 3 | use std::{fmt, slice}; | |
| 7 | 4 | |
| 8 | 5 | use crate::{Idx, IndexVec}; |
| 9 | 6 |
compiler/rustc_index/src/vec.rs+4-6| ... | ... | @@ -1,13 +1,11 @@ |
| 1 | #[cfg(feature = "nightly")] | |
| 2 | use rustc_serialize::{Decodable, Decoder, Encodable, Encoder}; | |
| 3 | ||
| 4 | 1 | use std::borrow::{Borrow, BorrowMut}; |
| 5 | use std::fmt; | |
| 6 | 2 | use std::hash::Hash; |
| 7 | 3 | use std::marker::PhantomData; |
| 8 | 4 | use std::ops::{Deref, DerefMut, RangeBounds}; |
| 9 | use std::slice; | |
| 10 | use std::vec; | |
| 5 | use std::{fmt, slice, vec}; | |
| 6 | ||
| 7 | #[cfg(feature = "nightly")] | |
| 8 | use rustc_serialize::{Decodable, Decoder, Encodable, Encoder}; | |
| 11 | 9 | |
| 12 | 10 | use crate::{Idx, IndexSlice}; |
| 13 | 11 |
compiler/rustc_infer/src/infer/at.rs+2-3| ... | ... | @@ -25,12 +25,11 @@ |
| 25 | 25 | //! sometimes useful when the types of `c` and `d` are not traceable |
| 26 | 26 | //! things. (That system should probably be refactored.) |
| 27 | 27 | |
| 28 | use super::*; | |
| 29 | ||
| 30 | use crate::infer::relate::{Relate, StructurallyRelateAliases, TypeRelation}; | |
| 31 | 28 | use rustc_middle::bug; |
| 32 | 29 | use rustc_middle::ty::{Const, ImplSubject}; |
| 33 | 30 | |
| 31 | use super::*; | |
| 32 | use crate::infer::relate::{Relate, StructurallyRelateAliases, TypeRelation}; | |
| 34 | 33 | use crate::traits::Obligation; |
| 35 | 34 | |
| 36 | 35 | /// Whether we should define opaque types or just treat them opaquely. |
compiler/rustc_infer/src/infer/canonical/canonicalizer.rs+9-8| ... | ... | @@ -5,18 +5,19 @@ |
| 5 | 5 | //! |
| 6 | 6 | //! [c]: https://rust-lang.github.io/chalk/book/canonical_queries/canonicalization.html |
| 7 | 7 | |
| 8 | use rustc_data_structures::fx::FxHashMap; | |
| 9 | use rustc_index::Idx; | |
| 10 | use rustc_middle::bug; | |
| 11 | use rustc_middle::ty::fold::{TypeFoldable, TypeFolder, TypeSuperFoldable}; | |
| 12 | use rustc_middle::ty::{ | |
| 13 | self, BoundVar, GenericArg, InferConst, List, Ty, TyCtxt, TypeFlags, TypeVisitableExt, | |
| 14 | }; | |
| 15 | use smallvec::SmallVec; | |
| 16 | ||
| 8 | 17 | use crate::infer::canonical::{ |
| 9 | 18 | Canonical, CanonicalTyVarKind, CanonicalVarInfo, CanonicalVarKind, OriginalQueryValues, |
| 10 | 19 | }; |
| 11 | 20 | use crate::infer::InferCtxt; |
| 12 | use rustc_middle::bug; | |
| 13 | use rustc_middle::ty::fold::{TypeFoldable, TypeFolder, TypeSuperFoldable}; | |
| 14 | use rustc_middle::ty::GenericArg; | |
| 15 | use rustc_middle::ty::{self, BoundVar, InferConst, List, Ty, TyCtxt, TypeFlags, TypeVisitableExt}; | |
| 16 | ||
| 17 | use rustc_data_structures::fx::FxHashMap; | |
| 18 | use rustc_index::Idx; | |
| 19 | use smallvec::SmallVec; | |
| 20 | 21 | |
| 21 | 22 | impl<'tcx> InferCtxt<'tcx> { |
| 22 | 23 | /// Canonicalizes a query value `V`. When we canonicalize a query, |
compiler/rustc_infer/src/infer/canonical/instantiate.rs+3-3| ... | ... | @@ -6,12 +6,12 @@ |
| 6 | 6 | //! |
| 7 | 7 | //! [c]: https://rust-lang.github.io/chalk/book/canonical_queries/canonicalization.html |
| 8 | 8 | |
| 9 | use crate::infer::canonical::{Canonical, CanonicalVarValues}; | |
| 10 | 9 | use rustc_macros::extension; |
| 11 | 10 | use rustc_middle::bug; |
| 12 | 11 | use rustc_middle::ty::fold::{FnMutDelegate, TypeFoldable}; |
| 13 | use rustc_middle::ty::GenericArgKind; | |
| 14 | use rustc_middle::ty::{self, TyCtxt}; | |
| 12 | use rustc_middle::ty::{self, GenericArgKind, TyCtxt}; | |
| 13 | ||
| 14 | use crate::infer::canonical::{Canonical, CanonicalVarValues}; | |
| 15 | 15 | |
| 16 | 16 | /// FIXME(-Znext-solver): This or public because it is shared with the |
| 17 | 17 | /// new trait solver implementation. We should deduplicate canonicalization. |
compiler/rustc_infer/src/infer/canonical/mod.rs+4-5| ... | ... | @@ -21,16 +21,15 @@ |
| 21 | 21 | //! |
| 22 | 22 | //! [c]: https://rust-lang.github.io/chalk/book/canonical_queries/canonicalization.html |
| 23 | 23 | |
| 24 | use crate::infer::{InferCtxt, RegionVariableOrigin}; | |
| 24 | pub use instantiate::CanonicalExt; | |
| 25 | 25 | use rustc_index::IndexVec; |
| 26 | pub use rustc_middle::infer::canonical::*; | |
| 26 | 27 | use rustc_middle::infer::unify_key::EffectVarValue; |
| 27 | 28 | use rustc_middle::ty::fold::TypeFoldable; |
| 28 | use rustc_middle::ty::GenericArg; | |
| 29 | use rustc_middle::ty::{self, List, Ty, TyCtxt}; | |
| 29 | use rustc_middle::ty::{self, GenericArg, List, Ty, TyCtxt}; | |
| 30 | 30 | use rustc_span::Span; |
| 31 | 31 | |
| 32 | pub use instantiate::CanonicalExt; | |
| 33 | pub use rustc_middle::infer::canonical::*; | |
| 32 | use crate::infer::{InferCtxt, RegionVariableOrigin}; | |
| 34 | 33 | |
| 35 | 34 | mod canonicalizer; |
| 36 | 35 | mod instantiate; |
compiler/rustc_infer/src/infer/canonical/query_response.rs+14-13| ... | ... | @@ -7,6 +7,17 @@ |
| 7 | 7 | //! |
| 8 | 8 | //! [c]: https://rust-lang.github.io/chalk/book/canonical_queries/canonicalization.html |
| 9 | 9 | |
| 10 | use std::fmt::Debug; | |
| 11 | use std::iter; | |
| 12 | ||
| 13 | use rustc_data_structures::captures::Captures; | |
| 14 | use rustc_index::{Idx, IndexVec}; | |
| 15 | use rustc_middle::arena::ArenaAllocatable; | |
| 16 | use rustc_middle::mir::ConstraintCategory; | |
| 17 | use rustc_middle::ty::fold::TypeFoldable; | |
| 18 | use rustc_middle::ty::{self, BoundVar, GenericArg, GenericArgKind, Ty, TyCtxt}; | |
| 19 | use rustc_middle::{bug, span_bug}; | |
| 20 | ||
| 10 | 21 | use crate::infer::canonical::instantiate::{instantiate_value, CanonicalExt}; |
| 11 | 22 | use crate::infer::canonical::{ |
| 12 | 23 | Canonical, CanonicalQueryResponse, CanonicalVarValues, Certainty, OriginalQueryValues, |
| ... | ... | @@ -15,19 +26,9 @@ use crate::infer::canonical::{ |
| 15 | 26 | use crate::infer::region_constraints::{Constraint, RegionConstraintData}; |
| 16 | 27 | use crate::infer::{DefineOpaqueTypes, InferCtxt, InferOk, InferResult}; |
| 17 | 28 | use crate::traits::query::NoSolution; |
| 18 | use crate::traits::{Obligation, ObligationCause, PredicateObligation}; | |
| 19 | use crate::traits::{ScrubbedTraitError, TraitEngine}; | |
| 20 | use rustc_data_structures::captures::Captures; | |
| 21 | use rustc_index::Idx; | |
| 22 | use rustc_index::IndexVec; | |
| 23 | use rustc_middle::arena::ArenaAllocatable; | |
| 24 | use rustc_middle::mir::ConstraintCategory; | |
| 25 | use rustc_middle::ty::fold::TypeFoldable; | |
| 26 | use rustc_middle::ty::{self, BoundVar, Ty, TyCtxt}; | |
| 27 | use rustc_middle::ty::{GenericArg, GenericArgKind}; | |
| 28 | use rustc_middle::{bug, span_bug}; | |
| 29 | use std::fmt::Debug; | |
| 30 | use std::iter; | |
| 29 | use crate::traits::{ | |
| 30 | Obligation, ObligationCause, PredicateObligation, ScrubbedTraitError, TraitEngine, | |
| 31 | }; | |
| 31 | 32 | |
| 32 | 33 | impl<'tcx> InferCtxt<'tcx> { |
| 33 | 34 | /// This method is meant to be invoked as the final step of a canonical query |
compiler/rustc_infer/src/infer/freshen.rs+4-2| ... | ... | @@ -31,12 +31,14 @@ |
| 31 | 31 | //! variable only once, and it does so as soon as it can, so it is reasonable to ask what the type |
| 32 | 32 | //! inferencer knows "so far". |
| 33 | 33 | |
| 34 | use super::InferCtxt; | |
| 34 | use std::collections::hash_map::Entry; | |
| 35 | ||
| 35 | 36 | use rustc_data_structures::fx::FxHashMap; |
| 36 | 37 | use rustc_middle::bug; |
| 37 | 38 | use rustc_middle::ty::fold::TypeFolder; |
| 38 | 39 | use rustc_middle::ty::{self, Ty, TyCtxt, TypeFoldable, TypeSuperFoldable, TypeVisitableExt}; |
| 39 | use std::collections::hash_map::Entry; | |
| 40 | ||
| 41 | use super::InferCtxt; | |
| 40 | 42 | |
| 41 | 43 | pub struct TypeFreshener<'a, 'tcx> { |
| 42 | 44 | infcx: &'a InferCtxt<'tcx>, |
compiler/rustc_infer/src/infer/lexical_region_resolve/mod.rs+10-13| ... | ... | @@ -1,13 +1,7 @@ |
| 1 | 1 | //! Lexical region resolution. |
| 2 | 2 | |
| 3 | use crate::infer::region_constraints::Constraint; | |
| 4 | use crate::infer::region_constraints::GenericKind; | |
| 5 | use crate::infer::region_constraints::RegionConstraintData; | |
| 6 | use crate::infer::region_constraints::VarInfos; | |
| 7 | use crate::infer::region_constraints::VerifyBound; | |
| 8 | use crate::infer::RegionRelations; | |
| 9 | use crate::infer::RegionVariableOrigin; | |
| 10 | use crate::infer::SubregionOrigin; | |
| 3 | use std::fmt; | |
| 4 | ||
| 11 | 5 | use rustc_data_structures::fx::FxHashSet; |
| 12 | 6 | use rustc_data_structures::graph::implementation::{ |
| 13 | 7 | Direction, Graph, NodeIndex, INCOMING, OUTGOING, |
| ... | ... | @@ -16,15 +10,18 @@ use rustc_data_structures::intern::Interned; |
| 16 | 10 | use rustc_data_structures::unord::UnordSet; |
| 17 | 11 | use rustc_index::{IndexSlice, IndexVec}; |
| 18 | 12 | use rustc_middle::ty::fold::TypeFoldable; |
| 19 | use rustc_middle::ty::{self, Ty, TyCtxt}; | |
| 20 | use rustc_middle::ty::{ReBound, RePlaceholder, ReVar}; | |
| 21 | use rustc_middle::ty::{ReEarlyParam, ReErased, ReError, ReLateParam, ReStatic}; | |
| 22 | use rustc_middle::ty::{Region, RegionVid}; | |
| 13 | use rustc_middle::ty::{ | |
| 14 | self, ReBound, ReEarlyParam, ReErased, ReError, ReLateParam, RePlaceholder, ReStatic, ReVar, | |
| 15 | Region, RegionVid, Ty, TyCtxt, | |
| 16 | }; | |
| 23 | 17 | use rustc_middle::{bug, span_bug}; |
| 24 | 18 | use rustc_span::Span; |
| 25 | use std::fmt; | |
| 26 | 19 | |
| 27 | 20 | use super::outlives::test_type_match; |
| 21 | use crate::infer::region_constraints::{ | |
| 22 | Constraint, GenericKind, RegionConstraintData, VarInfos, VerifyBound, | |
| 23 | }; | |
| 24 | use crate::infer::{RegionRelations, RegionVariableOrigin, SubregionOrigin}; | |
| 28 | 25 | |
| 29 | 26 | /// This function performs lexical region resolution given a complete |
| 30 | 27 | /// set of constraints and variable origins. It performs a fixed-point |
compiler/rustc_infer/src/infer/mod.rs+29-28| ... | ... | @@ -1,55 +1,56 @@ |
| 1 | pub use at::DefineOpaqueTypes; | |
| 2 | pub use freshen::TypeFreshener; | |
| 3 | pub use lexical_region_resolve::RegionResolutionError; | |
| 4 | pub use relate::combine::CombineFields; | |
| 5 | pub use relate::combine::PredicateEmittingRelation; | |
| 6 | pub use relate::StructurallyRelateAliases; | |
| 7 | use rustc_errors::DiagCtxtHandle; | |
| 8 | pub use rustc_macros::{TypeFoldable, TypeVisitable}; | |
| 9 | pub use rustc_middle::ty::IntVarValue; | |
| 10 | pub use BoundRegionConversionTime::*; | |
| 11 | pub use RegionVariableOrigin::*; | |
| 12 | pub use SubregionOrigin::*; | |
| 1 | use std::cell::{Cell, RefCell}; | |
| 2 | use std::fmt; | |
| 13 | 3 | |
| 14 | use crate::infer::relate::RelateResult; | |
| 15 | use crate::traits::{self, ObligationCause, ObligationInspector, PredicateObligation, TraitEngine}; | |
| 4 | pub use at::DefineOpaqueTypes; | |
| 16 | 5 | use free_regions::RegionRelations; |
| 6 | pub use freshen::TypeFreshener; | |
| 17 | 7 | use lexical_region_resolve::LexicalRegionResolutions; |
| 8 | pub use lexical_region_resolve::RegionResolutionError; | |
| 18 | 9 | use opaque_types::OpaqueTypeStorage; |
| 19 | use region_constraints::{GenericKind, VarInfos, VerifyBound}; | |
| 20 | use region_constraints::{RegionConstraintCollector, RegionConstraintStorage}; | |
| 10 | use region_constraints::{ | |
| 11 | GenericKind, RegionConstraintCollector, RegionConstraintStorage, VarInfos, VerifyBound, | |
| 12 | }; | |
| 13 | pub use relate::combine::{CombineFields, PredicateEmittingRelation}; | |
| 14 | pub use relate::StructurallyRelateAliases; | |
| 21 | 15 | use rustc_data_structures::captures::Captures; |
| 22 | 16 | use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap}; |
| 23 | 17 | use rustc_data_structures::sync::Lrc; |
| 24 | 18 | use rustc_data_structures::undo_log::Rollback; |
| 25 | 19 | use rustc_data_structures::unify as ut; |
| 26 | use rustc_errors::ErrorGuaranteed; | |
| 20 | use rustc_errors::{DiagCtxtHandle, ErrorGuaranteed}; | |
| 27 | 21 | use rustc_hir as hir; |
| 28 | 22 | use rustc_hir::def_id::{DefId, LocalDefId}; |
| 29 | 23 | use rustc_macros::extension; |
| 24 | pub use rustc_macros::{TypeFoldable, TypeVisitable}; | |
| 30 | 25 | use rustc_middle::infer::canonical::{Canonical, CanonicalVarValues}; |
| 31 | use rustc_middle::infer::unify_key::ConstVariableOrigin; | |
| 32 | use rustc_middle::infer::unify_key::ConstVariableValue; | |
| 33 | use rustc_middle::infer::unify_key::EffectVarValue; | |
| 34 | use rustc_middle::infer::unify_key::{ConstVidKey, EffectVidKey}; | |
| 26 | use rustc_middle::infer::unify_key::{ | |
| 27 | ConstVariableOrigin, ConstVariableValue, ConstVidKey, EffectVarValue, EffectVidKey, | |
| 28 | }; | |
| 35 | 29 | use rustc_middle::mir::interpret::{ErrorHandled, EvalToValTreeResult}; |
| 36 | 30 | use rustc_middle::mir::ConstraintCategory; |
| 37 | 31 | use rustc_middle::traits::select; |
| 38 | 32 | use rustc_middle::traits::solve::{Goal, NoSolution}; |
| 39 | 33 | use rustc_middle::ty::error::{ExpectedFound, TypeError}; |
| 40 | use rustc_middle::ty::fold::BoundVarReplacerDelegate; | |
| 41 | use rustc_middle::ty::fold::{TypeFoldable, TypeFolder, TypeSuperFoldable}; | |
| 34 | use rustc_middle::ty::fold::{ | |
| 35 | BoundVarReplacerDelegate, TypeFoldable, TypeFolder, TypeSuperFoldable, | |
| 36 | }; | |
| 42 | 37 | use rustc_middle::ty::visit::TypeVisitableExt; |
| 43 | use rustc_middle::ty::{self, GenericParamDefKind, InferConst, Ty, TyCtxt}; | |
| 44 | use rustc_middle::ty::{ConstVid, EffectVid, FloatVid, IntVid, TyVid}; | |
| 45 | use rustc_middle::ty::{GenericArg, GenericArgKind, GenericArgs, GenericArgsRef}; | |
| 38 | pub use rustc_middle::ty::IntVarValue; | |
| 39 | use rustc_middle::ty::{ | |
| 40 | self, ConstVid, EffectVid, FloatVid, GenericArg, GenericArgKind, GenericArgs, GenericArgsRef, | |
| 41 | GenericParamDefKind, InferConst, IntVid, Ty, TyCtxt, TyVid, | |
| 42 | }; | |
| 46 | 43 | use rustc_middle::{bug, span_bug}; |
| 47 | 44 | use rustc_span::symbol::Symbol; |
| 48 | 45 | use rustc_span::Span; |
| 49 | 46 | use snapshot::undo_log::InferCtxtUndoLogs; |
| 50 | use std::cell::{Cell, RefCell}; | |
| 51 | use std::fmt; | |
| 52 | 47 | use type_variable::TypeVariableOrigin; |
| 48 | pub use BoundRegionConversionTime::*; | |
| 49 | pub use RegionVariableOrigin::*; | |
| 50 | pub use SubregionOrigin::*; | |
| 51 | ||
| 52 | use crate::infer::relate::RelateResult; | |
| 53 | use crate::traits::{self, ObligationCause, ObligationInspector, PredicateObligation, TraitEngine}; | |
| 53 | 54 | |
| 54 | 55 | pub mod at; |
| 55 | 56 | pub mod canonical; |
compiler/rustc_infer/src/infer/opaque_types/mod.rs+6-6| ... | ... | @@ -1,6 +1,3 @@ |
| 1 | use crate::errors::OpaqueHiddenTypeDiag; | |
| 2 | use crate::infer::{InferCtxt, InferOk}; | |
| 3 | use crate::traits::{self, Obligation}; | |
| 4 | 1 | use hir::def_id::{DefId, LocalDefId}; |
| 5 | 2 | use rustc_data_structures::fx::FxIndexMap; |
| 6 | 3 | use rustc_data_structures::sync::Lrc; |
| ... | ... | @@ -9,13 +6,16 @@ use rustc_middle::traits::solve::Goal; |
| 9 | 6 | use rustc_middle::traits::ObligationCause; |
| 10 | 7 | use rustc_middle::ty::error::{ExpectedFound, TypeError}; |
| 11 | 8 | use rustc_middle::ty::fold::BottomUpFolder; |
| 12 | use rustc_middle::ty::GenericArgKind; | |
| 13 | 9 | use rustc_middle::ty::{ |
| 14 | self, OpaqueHiddenType, OpaqueTypeKey, Ty, TyCtxt, TypeFoldable, TypeSuperVisitable, | |
| 15 | TypeVisitable, TypeVisitableExt, TypeVisitor, | |
| 10 | self, GenericArgKind, OpaqueHiddenType, OpaqueTypeKey, Ty, TyCtxt, TypeFoldable, | |
| 11 | TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor, | |
| 16 | 12 | }; |
| 17 | 13 | use rustc_span::Span; |
| 18 | 14 | |
| 15 | use crate::errors::OpaqueHiddenTypeDiag; | |
| 16 | use crate::infer::{InferCtxt, InferOk}; | |
| 17 | use crate::traits::{self, Obligation}; | |
| 18 | ||
| 19 | 19 | mod table; |
| 20 | 20 | |
| 21 | 21 | pub type OpaqueTypeMap<'tcx> = FxIndexMap<OpaqueTypeKey<'tcx>, OpaqueTypeDecl<'tcx>>; |
compiler/rustc_infer/src/infer/opaque_types/table.rs+1-2| ... | ... | @@ -2,9 +2,8 @@ use rustc_data_structures::undo_log::UndoLogs; |
| 2 | 2 | use rustc_middle::bug; |
| 3 | 3 | use rustc_middle::ty::{self, OpaqueHiddenType, OpaqueTypeKey, Ty}; |
| 4 | 4 | |
| 5 | use crate::infer::snapshot::undo_log::{InferCtxtUndoLogs, UndoLog}; | |
| 6 | ||
| 7 | 5 | use super::{OpaqueTypeDecl, OpaqueTypeMap}; |
| 6 | use crate::infer::snapshot::undo_log::{InferCtxtUndoLogs, UndoLog}; | |
| 8 | 7 | |
| 9 | 8 | #[derive(Default, Debug, Clone)] |
| 10 | 9 | pub struct OpaqueTypeStorage<'tcx> { |
compiler/rustc_infer/src/infer/outlives/env.rs+3-3| ... | ... | @@ -1,12 +1,12 @@ |
| 1 | use crate::infer::free_regions::FreeRegionMap; | |
| 2 | use crate::infer::GenericKind; | |
| 3 | use crate::traits::query::OutlivesBound; | |
| 4 | 1 | use rustc_data_structures::fx::FxIndexSet; |
| 5 | 2 | use rustc_data_structures::transitive_relation::TransitiveRelationBuilder; |
| 6 | 3 | use rustc_middle::bug; |
| 7 | 4 | use rustc_middle::ty::{self, Region}; |
| 8 | 5 | |
| 9 | 6 | use super::explicit_outlives_bounds; |
| 7 | use crate::infer::free_regions::FreeRegionMap; | |
| 8 | use crate::infer::GenericKind; | |
| 9 | use crate::traits::query::OutlivesBound; | |
| 10 | 10 | |
| 11 | 11 | /// The `OutlivesEnvironment` collects information about what outlives |
| 12 | 12 | /// what in a given type-checking setting. For example, if we have a |
compiler/rustc_infer/src/infer/outlives/mod.rs+3-2| ... | ... | @@ -1,12 +1,13 @@ |
| 1 | 1 | //! Various code related to computing outlives relations. |
| 2 | 2 | |
| 3 | use rustc_middle::traits::query::{NoSolution, OutlivesBound}; | |
| 4 | use rustc_middle::ty; | |
| 5 | ||
| 3 | 6 | use self::env::OutlivesEnvironment; |
| 4 | 7 | use super::region_constraints::RegionConstraintData; |
| 5 | 8 | use super::{InferCtxt, RegionResolutionError, SubregionOrigin}; |
| 6 | 9 | use crate::infer::free_regions::RegionRelations; |
| 7 | 10 | use crate::infer::lexical_region_resolve; |
| 8 | use rustc_middle::traits::query::{NoSolution, OutlivesBound}; | |
| 9 | use rustc_middle::ty; | |
| 10 | 11 | |
| 11 | 12 | pub mod env; |
| 12 | 13 | pub mod for_liveness; |
compiler/rustc_infer/src/infer/outlives/obligations.rs+8-8| ... | ... | @@ -59,25 +59,25 @@ |
| 59 | 59 | //! might later infer `?U` to something like `&'b u32`, which would |
| 60 | 60 | //! imply that `'b: 'a`. |
| 61 | 61 | |
| 62 | use crate::infer::outlives::env::RegionBoundPairs; | |
| 63 | use crate::infer::outlives::verify::VerifyBoundCx; | |
| 64 | use crate::infer::resolve::OpportunisticRegionResolver; | |
| 65 | use crate::infer::snapshot::undo_log::UndoLog; | |
| 66 | use crate::infer::{self, GenericKind, InferCtxt, RegionObligation, SubregionOrigin, VerifyBound}; | |
| 67 | use crate::traits::{ObligationCause, ObligationCauseCode}; | |
| 68 | 62 | use rustc_data_structures::undo_log::UndoLogs; |
| 69 | 63 | use rustc_middle::bug; |
| 70 | 64 | use rustc_middle::mir::ConstraintCategory; |
| 71 | 65 | use rustc_middle::traits::query::NoSolution; |
| 72 | 66 | use rustc_middle::ty::{ |
| 73 | self, GenericArgsRef, Region, Ty, TyCtxt, TypeFoldable as _, TypeVisitableExt, | |
| 67 | self, GenericArgKind, GenericArgsRef, PolyTypeOutlivesPredicate, Region, Ty, TyCtxt, | |
| 68 | TypeFoldable as _, TypeVisitableExt, | |
| 74 | 69 | }; |
| 75 | use rustc_middle::ty::{GenericArgKind, PolyTypeOutlivesPredicate}; | |
| 76 | 70 | use rustc_span::DUMMY_SP; |
| 77 | 71 | use rustc_type_ir::outlives::{push_outlives_components, Component}; |
| 78 | 72 | use smallvec::smallvec; |
| 79 | 73 | |
| 80 | 74 | use super::env::OutlivesEnvironment; |
| 75 | use crate::infer::outlives::env::RegionBoundPairs; | |
| 76 | use crate::infer::outlives::verify::VerifyBoundCx; | |
| 77 | use crate::infer::resolve::OpportunisticRegionResolver; | |
| 78 | use crate::infer::snapshot::undo_log::UndoLog; | |
| 79 | use crate::infer::{self, GenericKind, InferCtxt, RegionObligation, SubregionOrigin, VerifyBound}; | |
| 80 | use crate::traits::{ObligationCause, ObligationCauseCode}; | |
| 81 | 81 | |
| 82 | 82 | impl<'tcx> InferCtxt<'tcx> { |
| 83 | 83 | /// Registers that the given region obligation must be resolved |
compiler/rustc_infer/src/infer/outlives/test_type_match.rs+1-2| ... | ... | @@ -2,8 +2,7 @@ use std::collections::hash_map::Entry; |
| 2 | 2 | |
| 3 | 3 | use rustc_data_structures::fx::FxHashMap; |
| 4 | 4 | use rustc_middle::ty::error::TypeError; |
| 5 | use rustc_middle::ty::TypeVisitableExt; | |
| 6 | use rustc_middle::ty::{self, Ty, TyCtxt}; | |
| 5 | use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitableExt}; | |
| 7 | 6 | |
| 8 | 7 | use crate::infer::region_constraints::VerifyIfEq; |
| 9 | 8 | use crate::infer::relate::{self as relate, Relate, RelateResult, TypeRelation}; |
compiler/rustc_infer/src/infer/outlives/verify.rs+4-4| ... | ... | @@ -1,11 +1,11 @@ |
| 1 | use crate::infer::outlives::env::RegionBoundPairs; | |
| 2 | use crate::infer::region_constraints::VerifyIfEq; | |
| 3 | use crate::infer::{GenericKind, VerifyBound}; | |
| 4 | 1 | use rustc_middle::ty::{self, OutlivesPredicate, Ty, TyCtxt}; |
| 5 | 2 | use rustc_type_ir::outlives::{compute_alias_components_recursive, Component}; |
| 6 | ||
| 7 | 3 | use smallvec::smallvec; |
| 8 | 4 | |
| 5 | use crate::infer::outlives::env::RegionBoundPairs; | |
| 6 | use crate::infer::region_constraints::VerifyIfEq; | |
| 7 | use crate::infer::{GenericKind, VerifyBound}; | |
| 8 | ||
| 9 | 9 | /// The `TypeOutlives` struct has the job of "lowering" a `T: 'a` |
| 10 | 10 | /// obligation into a series of `'a: 'b` constraints and "verifys", as |
| 11 | 11 | /// described on the module comment. The final constraints are emitted |
compiler/rustc_infer/src/infer/projection.rs+1-2| ... | ... | @@ -1,9 +1,8 @@ |
| 1 | 1 | use rustc_middle::traits::ObligationCause; |
| 2 | 2 | use rustc_middle::ty::{self, Ty}; |
| 3 | 3 | |
| 4 | use crate::traits::{Obligation, PredicateObligation}; | |
| 5 | ||
| 6 | 4 | use super::InferCtxt; |
| 5 | use crate::traits::{Obligation, PredicateObligation}; | |
| 7 | 6 | |
| 8 | 7 | impl<'tcx> InferCtxt<'tcx> { |
| 9 | 8 | /// Instead of normalizing an associated type projection, |
compiler/rustc_infer/src/infer/region_constraints/leak_check.rs+6-4| ... | ... | @@ -1,12 +1,14 @@ |
| 1 | use super::*; | |
| 2 | use crate::infer::relate::RelateResult; | |
| 3 | use crate::infer::snapshot::CombinedSnapshot; | |
| 4 | 1 | use rustc_data_structures::fx::FxIndexMap; |
| 5 | use rustc_data_structures::graph::{scc::Sccs, vec_graph::VecGraph}; | |
| 2 | use rustc_data_structures::graph::scc::Sccs; | |
| 3 | use rustc_data_structures::graph::vec_graph::VecGraph; | |
| 6 | 4 | use rustc_index::Idx; |
| 7 | 5 | use rustc_middle::span_bug; |
| 8 | 6 | use rustc_middle::ty::error::TypeError; |
| 9 | 7 | |
| 8 | use super::*; | |
| 9 | use crate::infer::relate::RelateResult; | |
| 10 | use crate::infer::snapshot::CombinedSnapshot; | |
| 11 | ||
| 10 | 12 | impl<'tcx> RegionConstraintCollector<'_, 'tcx> { |
| 11 | 13 | /// Searches new universes created during `snapshot`, looking for |
| 12 | 14 | /// placeholders that may "leak" out from the universes they are contained |
compiler/rustc_infer/src/infer/region_constraints/mod.rs+7-11| ... | ... | @@ -1,10 +1,7 @@ |
| 1 | 1 | //! See `README.md`. |
| 2 | 2 | |
| 3 | use self::CombineMapType::*; | |
| 4 | use self::UndoLog::*; | |
| 5 | ||
| 6 | use super::{MiscVariable, RegionVariableOrigin, Rollback, SubregionOrigin}; | |
| 7 | use crate::infer::snapshot::undo_log::{InferCtxtUndoLogs, Snapshot}; | |
| 3 | use std::ops::Range; | |
| 4 | use std::{cmp, fmt, mem}; | |
| 8 | 5 | |
| 9 | 6 | use rustc_data_structures::fx::FxHashMap; |
| 10 | 7 | use rustc_data_structures::sync::Lrc; |
| ... | ... | @@ -13,15 +10,14 @@ use rustc_data_structures::unify as ut; |
| 13 | 10 | use rustc_index::IndexVec; |
| 14 | 11 | use rustc_macros::{TypeFoldable, TypeVisitable}; |
| 15 | 12 | use rustc_middle::infer::unify_key::{RegionVariableValue, RegionVidKey}; |
| 16 | use rustc_middle::ty::ReStatic; | |
| 17 | use rustc_middle::ty::{self, Ty, TyCtxt}; | |
| 18 | use rustc_middle::ty::{ReBound, ReVar}; | |
| 19 | use rustc_middle::ty::{Region, RegionVid}; | |
| 13 | use rustc_middle::ty::{self, ReBound, ReStatic, ReVar, Region, RegionVid, Ty, TyCtxt}; | |
| 20 | 14 | use rustc_middle::{bug, span_bug}; |
| 21 | 15 | use rustc_span::Span; |
| 22 | 16 | |
| 23 | use std::ops::Range; | |
| 24 | use std::{cmp, fmt, mem}; | |
| 17 | use self::CombineMapType::*; | |
| 18 | use self::UndoLog::*; | |
| 19 | use super::{MiscVariable, RegionVariableOrigin, Rollback, SubregionOrigin}; | |
| 20 | use crate::infer::snapshot::undo_log::{InferCtxtUndoLogs, Snapshot}; | |
| 25 | 21 | |
| 26 | 22 | mod leak_check; |
| 27 | 23 |
compiler/rustc_infer/src/infer/relate/combine.rs+7-10| ... | ... | @@ -18,22 +18,19 @@ |
| 18 | 18 | //! On success, the LUB/GLB operations return the appropriate bound. The |
| 19 | 19 | //! return value of `Equate` or `Sub` shouldn't really be used. |
| 20 | 20 | |
| 21 | use rustc_middle::bug; | |
| 22 | use rustc_middle::infer::unify_key::EffectVarValue; | |
| 23 | use rustc_middle::traits::solve::Goal; | |
| 24 | use rustc_middle::ty::error::{ExpectedFound, TypeError}; | |
| 25 | use rustc_middle::ty::{self, InferConst, IntType, Ty, TyCtxt, TypeVisitableExt, UintType, Upcast}; | |
| 21 | 26 | pub use rustc_next_trait_solver::relate::combine::*; |
| 22 | 27 | |
| 23 | 28 | use super::glb::Glb; |
| 24 | 29 | use super::lub::Lub; |
| 25 | 30 | use super::type_relating::TypeRelating; |
| 26 | use super::RelateResult; | |
| 27 | use super::StructurallyRelateAliases; | |
| 28 | use crate::infer::relate; | |
| 29 | use crate::infer::{DefineOpaqueTypes, InferCtxt, TypeTrace}; | |
| 31 | use super::{RelateResult, StructurallyRelateAliases}; | |
| 32 | use crate::infer::{relate, DefineOpaqueTypes, InferCtxt, TypeTrace}; | |
| 30 | 33 | use crate::traits::{Obligation, PredicateObligation}; |
| 31 | use rustc_middle::bug; | |
| 32 | use rustc_middle::infer::unify_key::EffectVarValue; | |
| 33 | use rustc_middle::traits::solve::Goal; | |
| 34 | use rustc_middle::ty::error::{ExpectedFound, TypeError}; | |
| 35 | use rustc_middle::ty::{self, InferConst, Ty, TyCtxt, TypeVisitableExt, Upcast}; | |
| 36 | use rustc_middle::ty::{IntType, UintType}; | |
| 37 | 34 | |
| 38 | 35 | #[derive(Clone)] |
| 39 | 36 | pub struct CombineFields<'infcx, 'tcx> { |
compiler/rustc_infer/src/infer/relate/generalize.rs+9-7| ... | ... | @@ -1,10 +1,5 @@ |
| 1 | 1 | use std::mem; |
| 2 | 2 | |
| 3 | use super::StructurallyRelateAliases; | |
| 4 | use super::{PredicateEmittingRelation, Relate, RelateResult, TypeRelation}; | |
| 5 | use crate::infer::relate; | |
| 6 | use crate::infer::type_variable::TypeVariableValue; | |
| 7 | use crate::infer::{InferCtxt, RegionVariableOrigin}; | |
| 8 | 3 | use rustc_data_structures::sso::SsoHashMap; |
| 9 | 4 | use rustc_data_structures::stack::ensure_sufficient_stack; |
| 10 | 5 | use rustc_hir::def_id::DefId; |
| ... | ... | @@ -12,10 +7,17 @@ use rustc_middle::bug; |
| 12 | 7 | use rustc_middle::infer::unify_key::ConstVariableValue; |
| 13 | 8 | use rustc_middle::ty::error::TypeError; |
| 14 | 9 | use rustc_middle::ty::visit::MaxUniverse; |
| 15 | use rustc_middle::ty::{self, Ty, TyCtxt}; | |
| 16 | use rustc_middle::ty::{AliasRelationDirection, InferConst, Term, TypeVisitable, TypeVisitableExt}; | |
| 10 | use rustc_middle::ty::{ | |
| 11 | self, AliasRelationDirection, InferConst, Term, Ty, TyCtxt, TypeVisitable, TypeVisitableExt, | |
| 12 | }; | |
| 17 | 13 | use rustc_span::Span; |
| 18 | 14 | |
| 15 | use super::{ | |
| 16 | PredicateEmittingRelation, Relate, RelateResult, StructurallyRelateAliases, TypeRelation, | |
| 17 | }; | |
| 18 | use crate::infer::type_variable::TypeVariableValue; | |
| 19 | use crate::infer::{relate, InferCtxt, RegionVariableOrigin}; | |
| 20 | ||
| 19 | 21 | impl<'tcx> InferCtxt<'tcx> { |
| 20 | 22 | /// The idea is that we should ensure that the type variable `target_vid` |
| 21 | 23 | /// is equal to, a subtype of, or a supertype of `source_ty`. |
compiler/rustc_infer/src/infer/relate/higher_ranked.rs+3-2| ... | ... | @@ -1,11 +1,12 @@ |
| 1 | 1 | //! Helper routines for higher-ranked things. See the `doc` module at |
| 2 | 2 | //! the end of the file for details. |
| 3 | 3 | |
| 4 | use rustc_middle::ty::fold::FnMutDelegate; | |
| 5 | use rustc_middle::ty::{self, Ty, TyCtxt, TypeFoldable}; | |
| 6 | ||
| 4 | 7 | use super::RelateResult; |
| 5 | 8 | use crate::infer::snapshot::CombinedSnapshot; |
| 6 | 9 | use crate::infer::InferCtxt; |
| 7 | use rustc_middle::ty::fold::FnMutDelegate; | |
| 8 | use rustc_middle::ty::{self, Ty, TyCtxt, TypeFoldable}; | |
| 9 | 10 | |
| 10 | 11 | impl<'tcx> InferCtxt<'tcx> { |
| 11 | 12 | /// Replaces all bound variables (lifetimes, types, and constants) bound by |
compiler/rustc_infer/src/infer/relate/lattice.rs+3-4| ... | ... | @@ -17,14 +17,13 @@ |
| 17 | 17 | //! |
| 18 | 18 | //! [lattices]: https://en.wikipedia.org/wiki/Lattice_(order) |
| 19 | 19 | |
| 20 | use rustc_middle::ty::relate::RelateResult; | |
| 21 | use rustc_middle::ty::{self, Ty, TyVar}; | |
| 22 | ||
| 20 | 23 | use super::combine::PredicateEmittingRelation; |
| 21 | 24 | use crate::infer::{DefineOpaqueTypes, InferCtxt}; |
| 22 | 25 | use crate::traits::ObligationCause; |
| 23 | 26 | |
| 24 | use rustc_middle::ty::relate::RelateResult; | |
| 25 | use rustc_middle::ty::TyVar; | |
| 26 | use rustc_middle::ty::{self, Ty}; | |
| 27 | ||
| 28 | 27 | /// Trait for returning data about a lattice, and for abstracting |
| 29 | 28 | /// over the "direction" of the lattice operation (LUB/GLB). |
| 30 | 29 | /// |
compiler/rustc_infer/src/infer/relate/lub.rs+5-5| ... | ... | @@ -1,16 +1,16 @@ |
| 1 | 1 | //! Least upper bound. See [`lattice`]. |
| 2 | 2 | |
| 3 | use rustc_middle::traits::solve::Goal; | |
| 4 | use rustc_middle::ty::relate::{Relate, RelateResult, TypeRelation}; | |
| 5 | use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitableExt}; | |
| 6 | use rustc_span::Span; | |
| 7 | ||
| 3 | 8 | use super::combine::{CombineFields, PredicateEmittingRelation}; |
| 4 | 9 | use super::lattice::{self, LatticeDir}; |
| 5 | 10 | use super::StructurallyRelateAliases; |
| 6 | 11 | use crate::infer::{DefineOpaqueTypes, InferCtxt, SubregionOrigin}; |
| 7 | 12 | use crate::traits::ObligationCause; |
| 8 | 13 | |
| 9 | use rustc_middle::traits::solve::Goal; | |
| 10 | use rustc_middle::ty::relate::{Relate, RelateResult, TypeRelation}; | |
| 11 | use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitableExt}; | |
| 12 | use rustc_span::Span; | |
| 13 | ||
| 14 | 14 | /// "Least upper bound" (common supertype) |
| 15 | 15 | pub struct Lub<'combine, 'infcx, 'tcx> { |
| 16 | 16 | fields: &'combine mut CombineFields<'infcx, 'tcx>, |
compiler/rustc_infer/src/infer/relate/mod.rs+1-2| ... | ... | @@ -5,8 +5,7 @@ |
| 5 | 5 | pub use rustc_middle::ty::relate::RelateResult; |
| 6 | 6 | pub use rustc_next_trait_solver::relate::*; |
| 7 | 7 | |
| 8 | pub use self::combine::CombineFields; | |
| 9 | pub use self::combine::PredicateEmittingRelation; | |
| 8 | pub use self::combine::{CombineFields, PredicateEmittingRelation}; | |
| 10 | 9 | |
| 11 | 10 | #[allow(hidden_glob_reexports)] |
| 12 | 11 | pub(super) mod combine; |
compiler/rustc_infer/src/infer/relate/type_relating.rs+6-6| ... | ... | @@ -1,15 +1,15 @@ |
| 1 | use super::combine::CombineFields; | |
| 2 | use crate::infer::relate::{PredicateEmittingRelation, StructurallyRelateAliases}; | |
| 3 | use crate::infer::BoundRegionConversionTime::HigherRankedType; | |
| 4 | use crate::infer::{DefineOpaqueTypes, InferCtxt, SubregionOrigin}; | |
| 5 | 1 | use rustc_middle::traits::solve::Goal; |
| 6 | 2 | use rustc_middle::ty::relate::{ |
| 7 | 3 | relate_args_invariantly, relate_args_with_variances, Relate, RelateResult, TypeRelation, |
| 8 | 4 | }; |
| 9 | use rustc_middle::ty::TyVar; | |
| 10 | use rustc_middle::ty::{self, Ty, TyCtxt}; | |
| 5 | use rustc_middle::ty::{self, Ty, TyCtxt, TyVar}; | |
| 11 | 6 | use rustc_span::Span; |
| 12 | 7 | |
| 8 | use super::combine::CombineFields; | |
| 9 | use crate::infer::relate::{PredicateEmittingRelation, StructurallyRelateAliases}; | |
| 10 | use crate::infer::BoundRegionConversionTime::HigherRankedType; | |
| 11 | use crate::infer::{DefineOpaqueTypes, InferCtxt, SubregionOrigin}; | |
| 12 | ||
| 13 | 13 | /// Enforce that `a` is equal to or a subtype of `b`. |
| 14 | 14 | pub struct TypeRelating<'combine, 'a, 'tcx> { |
| 15 | 15 | fields: &'combine mut CombineFields<'a, 'tcx>, |
compiler/rustc_infer/src/infer/resolve.rs+2-1| ... | ... | @@ -1,9 +1,10 @@ |
| 1 | use super::{FixupError, FixupResult, InferCtxt}; | |
| 2 | 1 | use rustc_middle::bug; |
| 3 | 2 | use rustc_middle::ty::fold::{FallibleTypeFolder, TypeFolder, TypeSuperFoldable}; |
| 4 | 3 | use rustc_middle::ty::visit::TypeVisitableExt; |
| 5 | 4 | use rustc_middle::ty::{self, Const, InferConst, Ty, TyCtxt, TypeFoldable}; |
| 6 | 5 | |
| 6 | use super::{FixupError, FixupResult, InferCtxt}; | |
| 7 | ||
| 7 | 8 | /////////////////////////////////////////////////////////////////////////// |
| 8 | 9 | // OPPORTUNISTIC VAR RESOLVER |
| 9 | 10 |
compiler/rustc_infer/src/infer/snapshot/fudge.rs+5-8| ... | ... | @@ -1,16 +1,13 @@ |
| 1 | use std::ops::Range; | |
| 2 | ||
| 3 | use rustc_data_structures::{snapshot_vec as sv, unify as ut}; | |
| 1 | 4 | use rustc_middle::infer::unify_key::{ConstVariableValue, ConstVidKey}; |
| 2 | 5 | use rustc_middle::ty::fold::{TypeFoldable, TypeFolder, TypeSuperFoldable}; |
| 3 | 6 | use rustc_middle::ty::{self, ConstVid, FloatVid, IntVid, RegionVid, Ty, TyCtxt, TyVid}; |
| 4 | ||
| 5 | use crate::infer::type_variable::TypeVariableOrigin; | |
| 6 | use crate::infer::InferCtxt; | |
| 7 | use crate::infer::{ConstVariableOrigin, RegionVariableOrigin, UnificationTable}; | |
| 8 | ||
| 9 | use rustc_data_structures::snapshot_vec as sv; | |
| 10 | use rustc_data_structures::unify as ut; | |
| 11 | 7 | use ut::UnifyKey; |
| 12 | 8 | |
| 13 | use std::ops::Range; | |
| 9 | use crate::infer::type_variable::TypeVariableOrigin; | |
| 10 | use crate::infer::{ConstVariableOrigin, InferCtxt, RegionVariableOrigin, UnificationTable}; | |
| 14 | 11 | |
| 15 | 12 | fn vars_since_snapshot<'tcx, T>( |
| 16 | 13 | table: &UnificationTable<'_, 'tcx, T>, |
compiler/rustc_infer/src/infer/snapshot/mod.rs+3-2| ... | ... | @@ -1,8 +1,9 @@ |
| 1 | use super::region_constraints::RegionSnapshot; | |
| 2 | use super::InferCtxt; | |
| 3 | 1 | use rustc_data_structures::undo_log::UndoLogs; |
| 4 | 2 | use rustc_middle::ty; |
| 5 | 3 | |
| 4 | use super::region_constraints::RegionSnapshot; | |
| 5 | use super::InferCtxt; | |
| 6 | ||
| 6 | 7 | mod fudge; |
| 7 | 8 | pub(crate) mod undo_log; |
| 8 | 9 |
compiler/rustc_infer/src/infer/snapshot/undo_log.rs+3-6| ... | ... | @@ -1,15 +1,12 @@ |
| 1 | 1 | use std::marker::PhantomData; |
| 2 | 2 | |
| 3 | use rustc_data_structures::snapshot_vec as sv; | |
| 4 | 3 | use rustc_data_structures::undo_log::{Rollback, UndoLogs}; |
| 5 | use rustc_data_structures::unify as ut; | |
| 4 | use rustc_data_structures::{snapshot_vec as sv, unify as ut}; | |
| 6 | 5 | use rustc_middle::infer::unify_key::{ConstVidKey, EffectVidKey, RegionVidKey}; |
| 7 | 6 | use rustc_middle::ty::{self, OpaqueHiddenType, OpaqueTypeKey}; |
| 8 | 7 | |
| 9 | use crate::{ | |
| 10 | infer::{region_constraints, type_variable, InferCtxtInner}, | |
| 11 | traits, | |
| 12 | }; | |
| 8 | use crate::infer::{region_constraints, type_variable, InferCtxtInner}; | |
| 9 | use crate::traits; | |
| 13 | 10 | |
| 14 | 11 | pub struct Snapshot<'tcx> { |
| 15 | 12 | pub(crate) undo_len: usize, |
compiler/rustc_infer/src/infer/type_variable.rs+5-6| ... | ... | @@ -1,4 +1,9 @@ |
| 1 | use std::cmp; | |
| 2 | use std::marker::PhantomData; | |
| 3 | use std::ops::Range; | |
| 4 | ||
| 1 | 5 | use rustc_data_structures::undo_log::Rollback; |
| 6 | use rustc_data_structures::{snapshot_vec as sv, unify as ut}; | |
| 2 | 7 | use rustc_hir::def_id::DefId; |
| 3 | 8 | use rustc_index::IndexVec; |
| 4 | 9 | use rustc_middle::bug; |
| ... | ... | @@ -7,12 +12,6 @@ use rustc_span::Span; |
| 7 | 12 | |
| 8 | 13 | use crate::infer::InferCtxtUndoLogs; |
| 9 | 14 | |
| 10 | use rustc_data_structures::snapshot_vec as sv; | |
| 11 | use rustc_data_structures::unify as ut; | |
| 12 | use std::cmp; | |
| 13 | use std::marker::PhantomData; | |
| 14 | use std::ops::Range; | |
| 15 | ||
| 16 | 15 | impl<'tcx> Rollback<sv::UndoLog<ut::Delegate<TyVidEqKey<'tcx>>>> for TypeVariableStorage<'tcx> { |
| 17 | 16 | fn reverse(&mut self, undo: sv::UndoLog<ut::Delegate<TyVidEqKey<'tcx>>>) { |
| 18 | 17 | self.eq_relations.reverse(undo) |
compiler/rustc_infer/src/traits/engine.rs+2-2| ... | ... | @@ -1,11 +1,11 @@ |
| 1 | 1 | use std::fmt::Debug; |
| 2 | 2 | |
| 3 | use crate::infer::InferCtxt; | |
| 4 | use crate::traits::Obligation; | |
| 5 | 3 | use rustc_hir::def_id::DefId; |
| 6 | 4 | use rustc_middle::ty::{self, Ty, Upcast}; |
| 7 | 5 | |
| 8 | 6 | use super::{ObligationCause, PredicateObligation}; |
| 7 | use crate::infer::InferCtxt; | |
| 8 | use crate::traits::Obligation; | |
| 9 | 9 | |
| 10 | 10 | /// A trait error with most of its information removed. This is the error |
| 11 | 11 | /// returned by an `ObligationCtxt` by default, and suitable if you just |
compiler/rustc_infer/src/traits/mod.rs+6-8| ... | ... | @@ -14,21 +14,19 @@ use hir::def_id::LocalDefId; |
| 14 | 14 | use rustc_hir as hir; |
| 15 | 15 | use rustc_middle::traits::query::NoSolution; |
| 16 | 16 | use rustc_middle::traits::solve::Certainty; |
| 17 | pub use rustc_middle::traits::*; | |
| 17 | 18 | use rustc_middle::ty::{self, Ty, TyCtxt, Upcast}; |
| 18 | 19 | use rustc_span::Span; |
| 19 | 20 | |
| 20 | pub use self::ImplSource::*; | |
| 21 | pub use self::SelectionError::*; | |
| 22 | use crate::infer::InferCtxt; | |
| 23 | ||
| 24 | 21 | pub use self::engine::{FromSolverError, ScrubbedTraitError, TraitEngine}; |
| 25 | pub use self::project::MismatchedProjectionTypes; | |
| 26 | 22 | pub(crate) use self::project::UndoLog; |
| 27 | 23 | pub use self::project::{ |
| 28 | Normalized, NormalizedTerm, ProjectionCache, ProjectionCacheEntry, ProjectionCacheKey, | |
| 29 | ProjectionCacheStorage, Reveal, | |
| 24 | MismatchedProjectionTypes, Normalized, NormalizedTerm, ProjectionCache, ProjectionCacheEntry, | |
| 25 | ProjectionCacheKey, ProjectionCacheStorage, Reveal, | |
| 30 | 26 | }; |
| 31 | pub use rustc_middle::traits::*; | |
| 27 | pub use self::ImplSource::*; | |
| 28 | pub use self::SelectionError::*; | |
| 29 | use crate::infer::InferCtxt; | |
| 32 | 30 | |
| 33 | 31 | /// An `Obligation` represents some trait reference (e.g., `i32: Eq`) for |
| 34 | 32 | /// which the "impl_source" must be found. The process of finding an "impl_source" is |
compiler/rustc_infer/src/traits/project.rs+5-9| ... | ... | @@ -1,16 +1,12 @@ |
| 1 | 1 | //! Code for projecting associated types out of trait references. |
| 2 | 2 | |
| 3 | use super::PredicateObligation; | |
| 4 | ||
| 5 | use crate::infer::snapshot::undo_log::InferCtxtUndoLogs; | |
| 6 | ||
| 7 | use rustc_data_structures::{ | |
| 8 | snapshot_map::{self, SnapshotMapRef, SnapshotMapStorage}, | |
| 9 | undo_log::Rollback, | |
| 10 | }; | |
| 3 | use rustc_data_structures::snapshot_map::{self, SnapshotMapRef, SnapshotMapStorage}; | |
| 4 | use rustc_data_structures::undo_log::Rollback; | |
| 5 | pub use rustc_middle::traits::{EvaluationResult, Reveal}; | |
| 11 | 6 | use rustc_middle::ty; |
| 12 | 7 | |
| 13 | pub use rustc_middle::traits::{EvaluationResult, Reveal}; | |
| 8 | use super::PredicateObligation; | |
| 9 | use crate::infer::snapshot::undo_log::InferCtxtUndoLogs; | |
| 14 | 10 | |
| 15 | 11 | pub(crate) type UndoLog<'tcx> = |
| 16 | 12 | snapshot_map::UndoLog<ProjectionCacheKey<'tcx>, ProjectionCacheEntry<'tcx>>; |
compiler/rustc_infer/src/traits/structural_impls.rs+4-3| ... | ... | @@ -1,11 +1,12 @@ |
| 1 | use crate::traits; | |
| 2 | use crate::traits::project::Normalized; | |
| 1 | use std::fmt; | |
| 2 | ||
| 3 | 3 | use rustc_ast_ir::try_visit; |
| 4 | 4 | use rustc_middle::ty::fold::{FallibleTypeFolder, TypeFoldable}; |
| 5 | 5 | use rustc_middle::ty::visit::{TypeVisitable, TypeVisitor}; |
| 6 | 6 | use rustc_middle::ty::{self, TyCtxt}; |
| 7 | 7 | |
| 8 | use std::fmt; | |
| 8 | use crate::traits; | |
| 9 | use crate::traits::project::Normalized; | |
| 9 | 10 | |
| 10 | 11 | // Structural impls for the structs in `traits`. |
| 11 | 12 |
compiler/rustc_infer/src/traits/util.rs+3-3| ... | ... | @@ -1,11 +1,11 @@ |
| 1 | use crate::traits::{self, Obligation, ObligationCauseCode, PredicateObligation}; | |
| 2 | 1 | use rustc_data_structures::fx::FxHashSet; |
| 3 | use rustc_middle::ty::ToPolyTraitRef; | |
| 4 | use rustc_middle::ty::{self, TyCtxt}; | |
| 2 | use rustc_middle::ty::{self, ToPolyTraitRef, TyCtxt}; | |
| 5 | 3 | use rustc_span::symbol::Ident; |
| 6 | 4 | use rustc_span::Span; |
| 7 | 5 | pub use rustc_type_ir::elaborate::*; |
| 8 | 6 | |
| 7 | use crate::traits::{self, Obligation, ObligationCauseCode, PredicateObligation}; | |
| 8 | ||
| 9 | 9 | pub fn anonymize_predicate<'tcx>( |
| 10 | 10 | tcx: TyCtxt<'tcx>, |
| 11 | 11 | pred: ty::Predicate<'tcx>, |
compiler/rustc_interface/src/callbacks.rs+2-1| ... | ... | @@ -9,12 +9,13 @@ |
| 9 | 9 | //! The functions in this file should fall back to the default set in their |
| 10 | 10 | //! origin crate when the `TyCtxt` is not present in TLS. |
| 11 | 11 | |
| 12 | use std::fmt; | |
| 13 | ||
| 12 | 14 | use rustc_errors::{DiagInner, TRACK_DIAGNOSTIC}; |
| 13 | 15 | use rustc_middle::dep_graph::{DepNodeExt, TaskDepsRef}; |
| 14 | 16 | use rustc_middle::ty::tls; |
| 15 | 17 | use rustc_query_system::dep_graph::dep_node::default_dep_kind_debug; |
| 16 | 18 | use rustc_query_system::dep_graph::{DepContext, DepKind, DepNode}; |
| 17 | use std::fmt; | |
| 18 | 19 | |
| 19 | 20 | fn track_span_parent(def_id: rustc_span::def_id::LocalDefId) { |
| 20 | 21 | tls::with_opt(|tcx| { |
compiler/rustc_interface/src/errors.rs+3-3| ... | ... | @@ -1,9 +1,9 @@ |
| 1 | use rustc_macros::Diagnostic; | |
| 2 | use rustc_span::{Span, Symbol}; | |
| 3 | ||
| 4 | 1 | use std::io; |
| 5 | 2 | use std::path::Path; |
| 6 | 3 | |
| 4 | use rustc_macros::Diagnostic; | |
| 5 | use rustc_span::{Span, Symbol}; | |
| 6 | ||
| 7 | 7 | #[derive(Diagnostic)] |
| 8 | 8 | #[diag(interface_ferris_identifier)] |
| 9 | 9 | pub struct FerrisIdentifier { |
compiler/rustc_interface/src/interface.rs+7-8| ... | ... | @@ -1,13 +1,13 @@ |
| 1 | use crate::util; | |
| 1 | use std::path::PathBuf; | |
| 2 | use std::result; | |
| 3 | use std::sync::Arc; | |
| 2 | 4 | |
| 3 | use rustc_ast::token; | |
| 4 | use rustc_ast::{LitKind, MetaItemKind}; | |
| 5 | use rustc_ast::{token, LitKind, MetaItemKind}; | |
| 5 | 6 | use rustc_codegen_ssa::traits::CodegenBackend; |
| 6 | use rustc_data_structures::defer; | |
| 7 | 7 | use rustc_data_structures::fx::{FxHashMap, FxHashSet}; |
| 8 | use rustc_data_structures::jobserver; | |
| 9 | 8 | use rustc_data_structures::stable_hasher::StableHasher; |
| 10 | 9 | use rustc_data_structures::sync::Lrc; |
| 10 | use rustc_data_structures::{defer, jobserver}; | |
| 11 | 11 | use rustc_errors::registry::Registry; |
| 12 | 12 | use rustc_errors::{DiagCtxtHandle, ErrorGuaranteed}; |
| 13 | 13 | use rustc_lint::LintStore; |
| ... | ... | @@ -24,11 +24,10 @@ use rustc_session::{lint, CompilerIO, EarlyDiagCtxt, Session}; |
| 24 | 24 | use rustc_span::source_map::{FileLoader, RealFileLoader, SourceMapInputs}; |
| 25 | 25 | use rustc_span::symbol::sym; |
| 26 | 26 | use rustc_span::FileName; |
| 27 | use std::path::PathBuf; | |
| 28 | use std::result; | |
| 29 | use std::sync::Arc; | |
| 30 | 27 | use tracing::trace; |
| 31 | 28 | |
| 29 | use crate::util; | |
| 30 | ||
| 32 | 31 | pub type Result<T> = result::Result<T, ErrorGuaranteed>; |
| 33 | 32 | |
| 34 | 33 | /// Represents a compiler session. Note that every `Compiler` contains a |
compiler/rustc_interface/src/passes.rs+10-13| ... | ... | @@ -1,7 +1,9 @@ |
| 1 | use crate::errors; | |
| 2 | use crate::interface::{Compiler, Result}; | |
| 3 | use crate::proc_macro_decls; | |
| 4 | use crate::util; | |
| 1 | use std::any::Any; | |
| 2 | use std::ffi::OsString; | |
| 3 | use std::io::{self, BufWriter, Write}; | |
| 4 | use std::path::{Path, PathBuf}; | |
| 5 | use std::sync::{Arc, LazyLock}; | |
| 6 | use std::{env, fs, iter}; | |
| 5 | 7 | |
| 6 | 8 | use rustc_ast::{self as ast, visit}; |
| 7 | 9 | use rustc_codegen_ssa::traits::CodegenBackend; |
| ... | ... | @@ -27,23 +29,18 @@ use rustc_resolve::Resolver; |
| 27 | 29 | use rustc_session::code_stats::VTableSizeInfo; |
| 28 | 30 | use rustc_session::config::{CrateType, Input, OutFileName, OutputFilenames, OutputType}; |
| 29 | 31 | use rustc_session::cstore::Untracked; |
| 30 | use rustc_session::output::filename_for_input; | |
| 31 | use rustc_session::output::{collect_crate_types, find_crate_name}; | |
| 32 | use rustc_session::output::{collect_crate_types, filename_for_input, find_crate_name}; | |
| 32 | 33 | use rustc_session::search_paths::PathKind; |
| 33 | 34 | use rustc_session::{Limit, Session}; |
| 34 | 35 | use rustc_span::symbol::{sym, Symbol}; |
| 35 | 36 | use rustc_span::FileName; |
| 36 | 37 | use rustc_target::spec::PanicStrategy; |
| 37 | 38 | use rustc_trait_selection::traits; |
| 38 | ||
| 39 | use std::any::Any; | |
| 40 | use std::ffi::OsString; | |
| 41 | use std::io::{self, BufWriter, Write}; | |
| 42 | use std::path::{Path, PathBuf}; | |
| 43 | use std::sync::{Arc, LazyLock}; | |
| 44 | use std::{env, fs, iter}; | |
| 45 | 39 | use tracing::{info, instrument}; |
| 46 | 40 | |
| 41 | use crate::interface::{Compiler, Result}; | |
| 42 | use crate::{errors, proc_macro_decls, util}; | |
| 43 | ||
| 47 | 44 | pub(crate) fn parse<'a>(sess: &'a Session) -> Result<ast::Crate> { |
| 48 | 45 | let krate = sess |
| 49 | 46 | .time("parse_crate", || { |
compiler/rustc_interface/src/queries.rs+7-6| ... | ... | @@ -1,6 +1,6 @@ |
| 1 | use crate::errors::FailedWritingFile; | |
| 2 | use crate::interface::{Compiler, Result}; | |
| 3 | use crate::{errors, passes}; | |
| 1 | use std::any::Any; | |
| 2 | use std::cell::{RefCell, RefMut}; | |
| 3 | use std::sync::Arc; | |
| 4 | 4 | |
| 5 | 5 | use rustc_ast as ast; |
| 6 | 6 | use rustc_codegen_ssa::traits::CodegenBackend; |
| ... | ... | @@ -15,9 +15,10 @@ use rustc_middle::ty::{GlobalCtxt, TyCtxt}; |
| 15 | 15 | use rustc_serialize::opaque::FileEncodeResult; |
| 16 | 16 | use rustc_session::config::{self, OutputFilenames, OutputType}; |
| 17 | 17 | use rustc_session::Session; |
| 18 | use std::any::Any; | |
| 19 | use std::cell::{RefCell, RefMut}; | |
| 20 | use std::sync::Arc; | |
| 18 | ||
| 19 | use crate::errors::FailedWritingFile; | |
| 20 | use crate::interface::{Compiler, Result}; | |
| 21 | use crate::{errors, passes}; | |
| 21 | 22 | |
| 22 | 23 | /// Represent the result of a query. |
| 23 | 24 | /// |
compiler/rustc_interface/src/tests.rs+16-21| ... | ... | @@ -1,23 +1,20 @@ |
| 1 | 1 | #![allow(rustc::bad_opt_access)] |
| 2 | use crate::interface::{initialize_checked_jobserver, parse_cfg}; | |
| 2 | use std::collections::{BTreeMap, BTreeSet}; | |
| 3 | use std::num::NonZero; | |
| 4 | use std::path::{Path, PathBuf}; | |
| 5 | use std::sync::Arc; | |
| 6 | ||
| 3 | 7 | use rustc_data_structures::profiling::TimePassesFormat; |
| 4 | use rustc_errors::{emitter::HumanReadableErrorType, registry, ColorConfig}; | |
| 5 | use rustc_session::config::{build_configuration, build_session_options, rustc_optgroups}; | |
| 6 | use rustc_session::config::{ | |
| 7 | BranchProtection, CFGuard, Cfg, CollapseMacroDebuginfo, CoverageLevel, CoverageOptions, | |
| 8 | DebugInfo, DumpMonoStatsFormat, ErrorOutputType, | |
| 9 | }; | |
| 10 | use rustc_session::config::{ | |
| 11 | ExternEntry, ExternLocation, Externs, FunctionReturn, InliningThreshold, Input, | |
| 12 | InstrumentCoverage, InstrumentXRay, LinkSelfContained, LinkerPluginLto, | |
| 13 | }; | |
| 14 | use rustc_session::config::{ | |
| 15 | LocationDetail, LtoCli, NextSolverConfig, OomStrategy, Options, OutFileName, OutputType, | |
| 16 | OutputTypes, PAuthKey, PacRet, Passes, PatchableFunctionEntry, | |
| 17 | }; | |
| 8 | use rustc_errors::emitter::HumanReadableErrorType; | |
| 9 | use rustc_errors::{registry, ColorConfig}; | |
| 18 | 10 | use rustc_session::config::{ |
| 19 | Polonius, ProcMacroExecutionStrategy, Strip, SwitchWithOptPath, SymbolManglingVersion, | |
| 20 | WasiExecModel, | |
| 11 | build_configuration, build_session_options, rustc_optgroups, BranchProtection, CFGuard, Cfg, | |
| 12 | CollapseMacroDebuginfo, CoverageLevel, CoverageOptions, DebugInfo, DumpMonoStatsFormat, | |
| 13 | ErrorOutputType, ExternEntry, ExternLocation, Externs, FunctionReturn, InliningThreshold, | |
| 14 | Input, InstrumentCoverage, InstrumentXRay, LinkSelfContained, LinkerPluginLto, LocationDetail, | |
| 15 | LtoCli, NextSolverConfig, OomStrategy, Options, OutFileName, OutputType, OutputTypes, PAuthKey, | |
| 16 | PacRet, Passes, PatchableFunctionEntry, Polonius, ProcMacroExecutionStrategy, Strip, | |
| 17 | SwitchWithOptPath, SymbolManglingVersion, WasiExecModel, | |
| 21 | 18 | }; |
| 22 | 19 | use rustc_session::lint::Level; |
| 23 | 20 | use rustc_session::search_paths::SearchPath; |
| ... | ... | @@ -31,10 +28,8 @@ use rustc_target::spec::{ |
| 31 | 28 | CodeModel, FramePointer, LinkerFlavorCli, MergeFunctions, OnBrokenPipe, PanicStrategy, |
| 32 | 29 | RelocModel, RelroLevel, SanitizerSet, SplitDebuginfo, StackProtector, TlsModel, WasmCAbi, |
| 33 | 30 | }; |
| 34 | use std::collections::{BTreeMap, BTreeSet}; | |
| 35 | use std::num::NonZero; | |
| 36 | use std::path::{Path, PathBuf}; | |
| 37 | use std::sync::Arc; | |
| 31 | ||
| 32 | use crate::interface::{initialize_checked_jobserver, parse_cfg}; | |
| 38 | 33 | |
| 39 | 34 | fn sess_and_cfg<F>(args: &[&'static str], f: F) |
| 40 | 35 | where |
compiler/rustc_interface/src/util.rs+12-9| ... | ... | @@ -1,4 +1,9 @@ |
| 1 | use crate::errors; | |
| 1 | use std::env::consts::{DLL_PREFIX, DLL_SUFFIX}; | |
| 2 | use std::path::{Path, PathBuf}; | |
| 3 | use std::sync::atomic::{AtomicBool, Ordering}; | |
| 4 | use std::sync::OnceLock; | |
| 5 | use std::{env, iter, thread}; | |
| 6 | ||
| 2 | 7 | use rustc_ast as ast; |
| 3 | 8 | use rustc_codegen_ssa::traits::CodegenBackend; |
| 4 | 9 | #[cfg(parallel_compiler)] |
| ... | ... | @@ -16,14 +21,10 @@ use rustc_span::edition::Edition; |
| 16 | 21 | use rustc_span::source_map::SourceMapInputs; |
| 17 | 22 | use rustc_span::symbol::sym; |
| 18 | 23 | use rustc_target::spec::Target; |
| 19 | use std::env::consts::{DLL_PREFIX, DLL_SUFFIX}; | |
| 20 | use std::path::{Path, PathBuf}; | |
| 21 | use std::sync::atomic::{AtomicBool, Ordering}; | |
| 22 | use std::sync::OnceLock; | |
| 23 | use std::thread; | |
| 24 | use std::{env, iter}; | |
| 25 | 24 | use tracing::info; |
| 26 | 25 | |
| 26 | use crate::errors; | |
| 27 | ||
| 27 | 28 | /// Function pointer type that constructs a new CodegenBackend. |
| 28 | 29 | pub type MakeBackendFn = fn() -> Box<dyn CodegenBackend>; |
| 29 | 30 | |
| ... | ... | @@ -136,11 +137,13 @@ pub(crate) fn run_in_thread_pool_with_globals<F: FnOnce(CurrentGcx) -> R + Send, |
| 136 | 137 | sm_inputs: SourceMapInputs, |
| 137 | 138 | f: F, |
| 138 | 139 | ) -> R { |
| 139 | use rustc_data_structures::{defer, jobserver, sync::FromDyn}; | |
| 140 | use std::process; | |
| 141 | ||
| 142 | use rustc_data_structures::sync::FromDyn; | |
| 143 | use rustc_data_structures::{defer, jobserver}; | |
| 140 | 144 | use rustc_middle::ty::tls; |
| 141 | 145 | use rustc_query_impl::QueryCtxt; |
| 142 | 146 | use rustc_query_system::query::{break_query_cycles, QueryContext}; |
| 143 | use std::process; | |
| 144 | 147 | |
| 145 | 148 | let thread_stack_size = init_stack_size(thread_builder_diag); |
| 146 | 149 |
compiler/rustc_lexer/src/lib.rs+2-2| ... | ... | @@ -31,12 +31,12 @@ pub mod unescape; |
| 31 | 31 | #[cfg(test)] |
| 32 | 32 | mod tests; |
| 33 | 33 | |
| 34 | pub use crate::cursor::Cursor; | |
| 34 | use unicode_properties::UnicodeEmoji; | |
| 35 | 35 | |
| 36 | 36 | use self::LiteralKind::*; |
| 37 | 37 | use self::TokenKind::*; |
| 38 | pub use crate::cursor::Cursor; | |
| 38 | 39 | use crate::cursor::EOF_CHAR; |
| 39 | use unicode_properties::UnicodeEmoji; | |
| 40 | 40 | |
| 41 | 41 | /// Parsed token. |
| 42 | 42 | /// It doesn't contain information about data that has been parsed, |
compiler/rustc_lexer/src/tests.rs+2-2| ... | ... | @@ -1,7 +1,7 @@ |
| 1 | use super::*; | |
| 2 | ||
| 3 | 1 | use expect_test::{expect, Expect}; |
| 4 | 2 | |
| 3 | use super::*; | |
| 4 | ||
| 5 | 5 | fn check_raw_str(s: &str, expected: Result<u8, RawStrError>) { |
| 6 | 6 | let s = &format!("r{}", s); |
| 7 | 7 | let mut cursor = Cursor::new(s); |
compiler/rustc_lint/src/async_fn_in_trait.rs+3-3| ... | ... | @@ -1,10 +1,10 @@ |
| 1 | use crate::lints::AsyncFnInTraitDiag; | |
| 2 | use crate::LateContext; | |
| 3 | use crate::LateLintPass; | |
| 4 | 1 | use rustc_hir as hir; |
| 5 | 2 | use rustc_session::{declare_lint, declare_lint_pass}; |
| 6 | 3 | use rustc_trait_selection::error_reporting::traits::suggestions::suggest_desugaring_async_fn_to_impl_future_in_trait; |
| 7 | 4 | |
| 5 | use crate::lints::AsyncFnInTraitDiag; | |
| 6 | use crate::{LateContext, LateLintPass}; | |
| 7 | ||
| 8 | 8 | declare_lint! { |
| 9 | 9 | /// The `async_fn_in_trait` lint detects use of `async fn` in the |
| 10 | 10 | /// definition of a publicly-reachable trait. |
compiler/rustc_lint/src/builtin.rs+28-30| ... | ... | @@ -20,25 +20,8 @@ |
| 20 | 20 | //! If you define a new `LateLintPass`, you will also need to add it to the |
| 21 | 21 | //! `late_lint_methods!` invocation in `lib.rs`. |
| 22 | 22 | |
| 23 | use crate::fluent_generated as fluent; | |
| 24 | use crate::{ | |
| 25 | errors::BuiltinEllipsisInclusiveRangePatterns, | |
| 26 | lints::{ | |
| 27 | BuiltinAnonymousParams, BuiltinConstNoMangle, BuiltinDeprecatedAttrLink, | |
| 28 | BuiltinDeprecatedAttrLinkSuggestion, BuiltinDeprecatedAttrUsed, BuiltinDerefNullptr, | |
| 29 | BuiltinEllipsisInclusiveRangePatternsLint, BuiltinExplicitOutlives, | |
| 30 | BuiltinExplicitOutlivesSuggestion, BuiltinFeatureIssueNote, BuiltinIncompleteFeatures, | |
| 31 | BuiltinIncompleteFeaturesHelp, BuiltinInternalFeatures, BuiltinKeywordIdents, | |
| 32 | BuiltinMissingCopyImpl, BuiltinMissingDebugImpl, BuiltinMissingDoc, | |
| 33 | BuiltinMutablesTransmutes, BuiltinNoMangleGeneric, BuiltinNonShorthandFieldPatterns, | |
| 34 | BuiltinSpecialModuleNameUsed, BuiltinTrivialBounds, BuiltinTypeAliasBounds, | |
| 35 | BuiltinUngatedAsyncFnTrackCaller, BuiltinUnpermittedTypeInit, | |
| 36 | BuiltinUnpermittedTypeInitSub, BuiltinUnreachablePub, BuiltinUnsafe, | |
| 37 | BuiltinUnstableFeatures, BuiltinUnusedDocComment, BuiltinUnusedDocCommentSub, | |
| 38 | BuiltinWhileTrue, InvalidAsmLabel, | |
| 39 | }, | |
| 40 | EarlyContext, EarlyLintPass, LateContext, LateLintPass, Level, LintContext, | |
| 41 | }; | |
| 23 | use std::fmt::Write; | |
| 24 | ||
| 42 | 25 | use ast::token::TokenKind; |
| 43 | 26 | use rustc_ast::tokenstream::{TokenStream, TokenTree}; |
| 44 | 27 | use rustc_ast::visit::{FnCtxt, FnKind}; |
| ... | ... | @@ -55,9 +38,9 @@ use rustc_middle::bug; |
| 55 | 38 | use rustc_middle::lint::in_external_macro; |
| 56 | 39 | use rustc_middle::ty::layout::LayoutOf; |
| 57 | 40 | use rustc_middle::ty::print::with_no_trimmed_paths; |
| 58 | use rustc_middle::ty::TypeVisitableExt; | |
| 59 | use rustc_middle::ty::Upcast; | |
| 60 | use rustc_middle::ty::{self, Ty, TyCtxt, VariantDef}; | |
| 41 | use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitableExt, Upcast, VariantDef}; | |
| 42 | // hardwired lints from rustc_lint_defs | |
| 43 | pub use rustc_session::lint::builtin::*; | |
| 61 | 44 | use rustc_session::lint::FutureIncompatibilityReason; |
| 62 | 45 | use rustc_session::{declare_lint, declare_lint_pass, impl_lint_pass}; |
| 63 | 46 | use rustc_span::edition::Edition; |
| ... | ... | @@ -67,15 +50,29 @@ use rustc_span::{BytePos, InnerSpan, Span}; |
| 67 | 50 | use rustc_target::abi::Abi; |
| 68 | 51 | use rustc_target::asm::InlineAsmArch; |
| 69 | 52 | use rustc_trait_selection::infer::{InferCtxtExt, TyCtxtInferExt}; |
| 53 | use rustc_trait_selection::traits::misc::type_allowed_to_implement_copy; | |
| 70 | 54 | use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt as _; |
| 71 | use rustc_trait_selection::traits::{self, misc::type_allowed_to_implement_copy}; | |
| 72 | ||
| 55 | use rustc_trait_selection::traits::{self}; | |
| 56 | ||
| 57 | use crate::errors::BuiltinEllipsisInclusiveRangePatterns; | |
| 58 | use crate::lints::{ | |
| 59 | BuiltinAnonymousParams, BuiltinConstNoMangle, BuiltinDeprecatedAttrLink, | |
| 60 | BuiltinDeprecatedAttrLinkSuggestion, BuiltinDeprecatedAttrUsed, BuiltinDerefNullptr, | |
| 61 | BuiltinEllipsisInclusiveRangePatternsLint, BuiltinExplicitOutlives, | |
| 62 | BuiltinExplicitOutlivesSuggestion, BuiltinFeatureIssueNote, BuiltinIncompleteFeatures, | |
| 63 | BuiltinIncompleteFeaturesHelp, BuiltinInternalFeatures, BuiltinKeywordIdents, | |
| 64 | BuiltinMissingCopyImpl, BuiltinMissingDebugImpl, BuiltinMissingDoc, BuiltinMutablesTransmutes, | |
| 65 | BuiltinNoMangleGeneric, BuiltinNonShorthandFieldPatterns, BuiltinSpecialModuleNameUsed, | |
| 66 | BuiltinTrivialBounds, BuiltinTypeAliasBounds, BuiltinUngatedAsyncFnTrackCaller, | |
| 67 | BuiltinUnpermittedTypeInit, BuiltinUnpermittedTypeInitSub, BuiltinUnreachablePub, | |
| 68 | BuiltinUnsafe, BuiltinUnstableFeatures, BuiltinUnusedDocComment, BuiltinUnusedDocCommentSub, | |
| 69 | BuiltinWhileTrue, InvalidAsmLabel, | |
| 70 | }; | |
| 73 | 71 | use crate::nonstandard_style::{method_context, MethodLateContext}; |
| 74 | ||
| 75 | use std::fmt::Write; | |
| 76 | ||
| 77 | // hardwired lints from rustc_lint_defs | |
| 78 | pub use rustc_session::lint::builtin::*; | |
| 72 | use crate::{ | |
| 73 | fluent_generated as fluent, EarlyContext, EarlyLintPass, LateContext, LateLintPass, Level, | |
| 74 | LintContext, | |
| 75 | }; | |
| 79 | 76 | |
| 80 | 77 | declare_lint! { |
| 81 | 78 | /// The `while_true` lint detects `while true { }`. |
| ... | ... | @@ -1672,7 +1669,8 @@ impl EarlyLintPass for EllipsisInclusiveRangePatterns { |
| 1672 | 1669 | return; |
| 1673 | 1670 | } |
| 1674 | 1671 | |
| 1675 | use self::ast::{PatKind, RangeSyntax::DotDotDot}; | |
| 1672 | use self::ast::PatKind; | |
| 1673 | use self::ast::RangeSyntax::DotDotDot; | |
| 1676 | 1674 | |
| 1677 | 1675 | /// If `pat` is a `...` pattern, return the start and end of the range, as well as the span |
| 1678 | 1676 | /// corresponding to the ellipsis. |
compiler/rustc_lint/src/context.rs+11-10| ... | ... | @@ -14,10 +14,9 @@ |
| 14 | 14 | //! upon. As the ast is traversed, this keeps track of the current lint level |
| 15 | 15 | //! for all lint attributes. |
| 16 | 16 | |
| 17 | use self::TargetLint::*; | |
| 17 | use std::cell::Cell; | |
| 18 | use std::{iter, slice}; | |
| 18 | 19 | |
| 19 | use crate::levels::LintLevelsBuilder; | |
| 20 | use crate::passes::{EarlyLintPassObject, LateLintPassObject}; | |
| 21 | 20 | use rustc_data_structures::fx::FxIndexMap; |
| 22 | 21 | use rustc_data_structures::sync; |
| 23 | 22 | use rustc_data_structures::unord::UnordMap; |
| ... | ... | @@ -30,20 +29,22 @@ use rustc_hir::definitions::{DefPathData, DisambiguatedDefPathData}; |
| 30 | 29 | use rustc_middle::bug; |
| 31 | 30 | use rustc_middle::middle::privacy::EffectiveVisibilities; |
| 32 | 31 | use rustc_middle::ty::layout::{LayoutError, LayoutOfHelpers, TyAndLayout}; |
| 33 | use rustc_middle::ty::print::{with_no_trimmed_paths, PrintError, PrintTraitRefExt as _}; | |
| 34 | use rustc_middle::ty::{self, print::Printer, GenericArg, RegisteredTools, Ty, TyCtxt}; | |
| 35 | use rustc_session::lint::{BuiltinLintDiag, LintExpectationId}; | |
| 36 | use rustc_session::lint::{FutureIncompatibleInfo, Level, Lint, LintBuffer, LintId}; | |
| 32 | use rustc_middle::ty::print::{with_no_trimmed_paths, PrintError, PrintTraitRefExt as _, Printer}; | |
| 33 | use rustc_middle::ty::{self, GenericArg, RegisteredTools, Ty, TyCtxt}; | |
| 34 | use rustc_session::lint::{ | |
| 35 | BuiltinLintDiag, FutureIncompatibleInfo, Level, Lint, LintBuffer, LintExpectationId, LintId, | |
| 36 | }; | |
| 37 | 37 | use rustc_session::{LintStoreMarker, Session}; |
| 38 | 38 | use rustc_span::edit_distance::find_best_match_for_names; |
| 39 | 39 | use rustc_span::symbol::{sym, Ident, Symbol}; |
| 40 | 40 | use rustc_span::Span; |
| 41 | 41 | use rustc_target::abi; |
| 42 | use std::cell::Cell; | |
| 43 | use std::iter; | |
| 44 | use std::slice; | |
| 45 | 42 | use tracing::debug; |
| 46 | 43 | |
| 44 | use self::TargetLint::*; | |
| 45 | use crate::levels::LintLevelsBuilder; | |
| 46 | use crate::passes::{EarlyLintPassObject, LateLintPassObject}; | |
| 47 | ||
| 47 | 48 | mod diagnostics; |
| 48 | 49 | |
| 49 | 50 | type EarlyLintPassFactory = dyn Fn() -> EarlyLintPassObject + sync::DynSend + sync::DynSync; |
compiler/rustc_lint/src/context/diagnostics.rs+3-2| ... | ... | @@ -4,8 +4,9 @@ |
| 4 | 4 | use std::borrow::Cow; |
| 5 | 5 | |
| 6 | 6 | use rustc_ast::util::unicode::TEXT_FLOW_CONTROL_CHARS; |
| 7 | use rustc_errors::elided_lifetime_in_path_suggestion; | |
| 8 | use rustc_errors::{Applicability, Diag, DiagArgValue, LintDiagnostic}; | |
| 7 | use rustc_errors::{ | |
| 8 | elided_lifetime_in_path_suggestion, Applicability, Diag, DiagArgValue, LintDiagnostic, | |
| 9 | }; | |
| 9 | 10 | use rustc_middle::middle::stability; |
| 10 | 11 | use rustc_session::lint::BuiltinLintDiag; |
| 11 | 12 | use rustc_session::Session; |
compiler/rustc_lint/src/context/diagnostics/check_cfg.rs+2-1| ... | ... | @@ -1,5 +1,6 @@ |
| 1 | 1 | use rustc_middle::bug; |
| 2 | use rustc_session::{config::ExpectedValues, Session}; | |
| 2 | use rustc_session::config::ExpectedValues; | |
| 3 | use rustc_session::Session; | |
| 3 | 4 | use rustc_span::edit_distance::find_best_match_for_name; |
| 4 | 5 | use rustc_span::{sym, Span, Symbol}; |
| 5 | 6 |
compiler/rustc_lint/src/deref_into_dyn_supertrait.rs+3-5| ... | ... | @@ -1,8 +1,3 @@ |
| 1 | use crate::{ | |
| 2 | lints::{SupertraitAsDerefTarget, SupertraitAsDerefTargetLabel}, | |
| 3 | LateContext, LateLintPass, LintContext, | |
| 4 | }; | |
| 5 | ||
| 6 | 1 | use rustc_hir::{self as hir, LangItem}; |
| 7 | 2 | use rustc_middle::ty; |
| 8 | 3 | use rustc_session::lint::FutureIncompatibilityReason; |
| ... | ... | @@ -10,6 +5,9 @@ use rustc_session::{declare_lint, declare_lint_pass}; |
| 10 | 5 | use rustc_span::sym; |
| 11 | 6 | use rustc_trait_selection::traits::supertraits; |
| 12 | 7 | |
| 8 | use crate::lints::{SupertraitAsDerefTarget, SupertraitAsDerefTargetLabel}; | |
| 9 | use crate::{LateContext, LateLintPass, LintContext}; | |
| 10 | ||
| 13 | 11 | declare_lint! { |
| 14 | 12 | /// The `deref_into_dyn_supertrait` lint is output whenever there is a use of the |
| 15 | 13 | /// `Deref` implementation with a `dyn SuperTrait` type as `Output`. |
compiler/rustc_lint/src/drop_forget_useless.rs+4-6| ... | ... | @@ -3,13 +3,11 @@ use rustc_middle::ty; |
| 3 | 3 | use rustc_session::{declare_lint, declare_lint_pass}; |
| 4 | 4 | use rustc_span::sym; |
| 5 | 5 | |
| 6 | use crate::{ | |
| 7 | lints::{ | |
| 8 | DropCopyDiag, DropRefDiag, ForgetCopyDiag, ForgetRefDiag, UndroppedManuallyDropsDiag, | |
| 9 | UndroppedManuallyDropsSuggestion, UseLetUnderscoreIgnoreSuggestion, | |
| 10 | }, | |
| 11 | LateContext, LateLintPass, LintContext, | |
| 6 | use crate::lints::{ | |
| 7 | DropCopyDiag, DropRefDiag, ForgetCopyDiag, ForgetRefDiag, UndroppedManuallyDropsDiag, | |
| 8 | UndroppedManuallyDropsSuggestion, UseLetUnderscoreIgnoreSuggestion, | |
| 12 | 9 | }; |
| 10 | use crate::{LateContext, LateLintPass, LintContext}; | |
| 13 | 11 | |
| 14 | 12 | declare_lint! { |
| 15 | 13 | /// The `dropping_references` lint checks for calls to `std::mem::drop` with a reference |
compiler/rustc_lint/src/early.rs+3-2| ... | ... | @@ -14,8 +14,6 @@ |
| 14 | 14 | //! upon. As the ast is traversed, this keeps track of the current lint level |
| 15 | 15 | //! for all lint attributes. |
| 16 | 16 | |
| 17 | use crate::context::{EarlyContext, LintStore}; | |
| 18 | use crate::passes::{EarlyLintPass, EarlyLintPassObject}; | |
| 19 | 17 | use rustc_ast::ptr::P; |
| 20 | 18 | use rustc_ast::visit::{self as ast_visit, walk_list, Visitor}; |
| 21 | 19 | use rustc_ast::{self as ast, HasAttrs}; |
| ... | ... | @@ -28,6 +26,9 @@ use rustc_span::symbol::Ident; |
| 28 | 26 | use rustc_span::Span; |
| 29 | 27 | use tracing::debug; |
| 30 | 28 | |
| 29 | use crate::context::{EarlyContext, LintStore}; | |
| 30 | use crate::passes::{EarlyLintPass, EarlyLintPassObject}; | |
| 31 | ||
| 31 | 32 | macro_rules! lint_callback { ($cx:expr, $f:ident, $($args:expr),*) => ({ |
| 32 | 33 | $cx.pass.$f(&$cx.context, $($args),*); |
| 33 | 34 | }) } |
compiler/rustc_lint/src/enum_intrinsics_non_enums.rs+8-7| ... | ... | @@ -1,12 +1,13 @@ |
| 1 | use crate::{ | |
| 2 | context::LintContext, | |
| 3 | lints::{EnumIntrinsicsMemDiscriminate, EnumIntrinsicsMemVariant}, | |
| 4 | LateContext, LateLintPass, | |
| 5 | }; | |
| 6 | 1 | use rustc_hir as hir; |
| 7 | use rustc_middle::ty::{visit::TypeVisitableExt, Ty}; | |
| 2 | use rustc_middle::ty::visit::TypeVisitableExt; | |
| 3 | use rustc_middle::ty::Ty; | |
| 8 | 4 | use rustc_session::{declare_lint, declare_lint_pass}; |
| 9 | use rustc_span::{symbol::sym, Span}; | |
| 5 | use rustc_span::symbol::sym; | |
| 6 | use rustc_span::Span; | |
| 7 | ||
| 8 | use crate::context::LintContext; | |
| 9 | use crate::lints::{EnumIntrinsicsMemDiscriminate, EnumIntrinsicsMemVariant}; | |
| 10 | use crate::{LateContext, LateLintPass}; | |
| 10 | 11 | |
| 11 | 12 | declare_lint! { |
| 12 | 13 | /// The `enum_intrinsics_non_enums` lint detects calls to |
compiler/rustc_lint/src/errors.rs+4-2| ... | ... | @@ -1,9 +1,11 @@ |
| 1 | use crate::fluent_generated as fluent; | |
| 2 | use rustc_errors::{codes::*, Diag, EmissionGuarantee, SubdiagMessageOp, Subdiagnostic}; | |
| 1 | use rustc_errors::codes::*; | |
| 2 | use rustc_errors::{Diag, EmissionGuarantee, SubdiagMessageOp, Subdiagnostic}; | |
| 3 | 3 | use rustc_macros::{Diagnostic, Subdiagnostic}; |
| 4 | 4 | use rustc_session::lint::Level; |
| 5 | 5 | use rustc_span::{Span, Symbol}; |
| 6 | 6 | |
| 7 | use crate::fluent_generated as fluent; | |
| 8 | ||
| 7 | 9 | #[derive(Diagnostic)] |
| 8 | 10 | #[diag(lint_overruled_attribute, code = E0453)] |
| 9 | 11 | pub struct OverruledAttribute<'a> { |
compiler/rustc_lint/src/expect.rs+2-1| ... | ... | @@ -1,10 +1,11 @@ |
| 1 | use crate::lints::{Expectation, ExpectationNote}; | |
| 2 | 1 | use rustc_middle::query::Providers; |
| 3 | 2 | use rustc_middle::ty::TyCtxt; |
| 4 | 3 | use rustc_session::lint::builtin::UNFULFILLED_LINT_EXPECTATIONS; |
| 5 | 4 | use rustc_session::lint::LintExpectationId; |
| 6 | 5 | use rustc_span::Symbol; |
| 7 | 6 | |
| 7 | use crate::lints::{Expectation, ExpectationNote}; | |
| 8 | ||
| 8 | 9 | pub(crate) fn provide(providers: &mut Providers) { |
| 9 | 10 | *providers = Providers { check_expectations, ..*providers }; |
| 10 | 11 | } |
compiler/rustc_lint/src/for_loops_over_fallibles.rs+8-9| ... | ... | @@ -1,19 +1,18 @@ |
| 1 | use crate::{ | |
| 2 | lints::{ | |
| 3 | ForLoopsOverFalliblesDiag, ForLoopsOverFalliblesLoopSub, ForLoopsOverFalliblesQuestionMark, | |
| 4 | ForLoopsOverFalliblesSuggestion, | |
| 5 | }, | |
| 6 | LateContext, LateLintPass, LintContext, | |
| 7 | }; | |
| 8 | ||
| 9 | 1 | use hir::{Expr, Pat}; |
| 10 | 2 | use rustc_hir as hir; |
| 11 | use rustc_infer::{infer::TyCtxtInferExt, traits::ObligationCause}; | |
| 3 | use rustc_infer::infer::TyCtxtInferExt; | |
| 4 | use rustc_infer::traits::ObligationCause; | |
| 12 | 5 | use rustc_middle::ty; |
| 13 | 6 | use rustc_session::{declare_lint, declare_lint_pass}; |
| 14 | 7 | use rustc_span::{sym, Span}; |
| 15 | 8 | use rustc_trait_selection::traits::ObligationCtxt; |
| 16 | 9 | |
| 10 | use crate::lints::{ | |
| 11 | ForLoopsOverFalliblesDiag, ForLoopsOverFalliblesLoopSub, ForLoopsOverFalliblesQuestionMark, | |
| 12 | ForLoopsOverFalliblesSuggestion, | |
| 13 | }; | |
| 14 | use crate::{LateContext, LateLintPass, LintContext}; | |
| 15 | ||
| 17 | 16 | declare_lint! { |
| 18 | 17 | /// The `for_loops_over_fallibles` lint checks for `for` loops over `Option` or `Result` values. |
| 19 | 18 | /// |
compiler/rustc_lint/src/hidden_unicode_codepoints.rs+5-7| ... | ... | @@ -1,15 +1,13 @@ |
| 1 | use crate::{ | |
| 2 | lints::{ | |
| 3 | HiddenUnicodeCodepointsDiag, HiddenUnicodeCodepointsDiagLabels, | |
| 4 | HiddenUnicodeCodepointsDiagSub, | |
| 5 | }, | |
| 6 | EarlyContext, EarlyLintPass, LintContext, | |
| 7 | }; | |
| 8 | 1 | use ast::util::unicode::{contains_text_flow_control_chars, TEXT_FLOW_CONTROL_CHARS}; |
| 9 | 2 | use rustc_ast as ast; |
| 10 | 3 | use rustc_session::{declare_lint, declare_lint_pass}; |
| 11 | 4 | use rustc_span::{BytePos, Span, Symbol}; |
| 12 | 5 | |
| 6 | use crate::lints::{ | |
| 7 | HiddenUnicodeCodepointsDiag, HiddenUnicodeCodepointsDiagLabels, HiddenUnicodeCodepointsDiagSub, | |
| 8 | }; | |
| 9 | use crate::{EarlyContext, EarlyLintPass, LintContext}; | |
| 10 | ||
| 13 | 11 | declare_lint! { |
| 14 | 12 | /// The `text_direction_codepoint_in_literal` lint detects Unicode codepoints that change the |
| 15 | 13 | /// visual representation of text on screen in a way that does not correspond to their on |
compiler/rustc_lint/src/impl_trait_overcaptures.rs+1-2| ... | ... | @@ -13,8 +13,7 @@ use rustc_middle::ty::{ |
| 13 | 13 | use rustc_session::{declare_lint, declare_lint_pass}; |
| 14 | 14 | use rustc_span::Span; |
| 15 | 15 | |
| 16 | use crate::fluent_generated as fluent; | |
| 17 | use crate::{LateContext, LateLintPass}; | |
| 16 | use crate::{fluent_generated as fluent, LateContext, LateLintPass}; | |
| 18 | 17 | |
| 19 | 18 | declare_lint! { |
| 20 | 19 | /// The `impl_trait_overcaptures` lint warns against cases where lifetime |
compiler/rustc_lint/src/internal.rs+12-8| ... | ... | @@ -1,16 +1,13 @@ |
| 1 | 1 | //! Some lints that are only useful in the compiler or crates that use compiler internals, such as |
| 2 | 2 | //! Clippy. |
| 3 | 3 | |
| 4 | use crate::lints::{ | |
| 5 | BadOptAccessDiag, DefaultHashTypesDiag, DiagOutOfImpl, LintPassByHand, NonExistentDocKeyword, | |
| 6 | NonGlobImportTypeIrInherent, QueryInstability, SpanUseEqCtxtDiag, TyQualified, TykindDiag, | |
| 7 | TykindKind, UntranslatableDiag, | |
| 8 | }; | |
| 9 | use crate::{EarlyContext, EarlyLintPass, LateContext, LateLintPass, LintContext}; | |
| 10 | 4 | use rustc_ast as ast; |
| 11 | 5 | use rustc_hir::def::Res; |
| 12 | use rustc_hir::{def_id::DefId, Expr, ExprKind, GenericArg, PatKind, Path, PathSegment, QPath}; | |
| 13 | use rustc_hir::{BinOp, BinOpKind, HirId, Impl, Item, ItemKind, Node, Pat, Ty, TyKind}; | |
| 6 | use rustc_hir::def_id::DefId; | |
| 7 | use rustc_hir::{ | |
| 8 | BinOp, BinOpKind, Expr, ExprKind, GenericArg, HirId, Impl, Item, ItemKind, Node, Pat, PatKind, | |
| 9 | Path, PathSegment, QPath, Ty, TyKind, | |
| 10 | }; | |
| 14 | 11 | use rustc_middle::ty::{self, Ty as MiddleTy}; |
| 15 | 12 | use rustc_session::{declare_lint_pass, declare_tool_lint}; |
| 16 | 13 | use rustc_span::hygiene::{ExpnKind, MacroKind}; |
| ... | ... | @@ -18,6 +15,13 @@ use rustc_span::symbol::{kw, sym, Symbol}; |
| 18 | 15 | use rustc_span::Span; |
| 19 | 16 | use tracing::debug; |
| 20 | 17 | |
| 18 | use crate::lints::{ | |
| 19 | BadOptAccessDiag, DefaultHashTypesDiag, DiagOutOfImpl, LintPassByHand, NonExistentDocKeyword, | |
| 20 | NonGlobImportTypeIrInherent, QueryInstability, SpanUseEqCtxtDiag, TyQualified, TykindDiag, | |
| 21 | TykindKind, UntranslatableDiag, | |
| 22 | }; | |
| 23 | use crate::{EarlyContext, EarlyLintPass, LateContext, LateLintPass, LintContext}; | |
| 24 | ||
| 21 | 25 | declare_tool_lint! { |
| 22 | 26 | /// The `default_hash_type` lint detects use of [`std::collections::HashMap`] and |
| 23 | 27 | /// [`std::collections::HashSet`], suggesting the use of `FxHashMap`/`FxHashSet`. |
compiler/rustc_lint/src/late.rs+7-5| ... | ... | @@ -14,22 +14,24 @@ |
| 14 | 14 | //! upon. As the ast is traversed, this keeps track of the current lint level |
| 15 | 15 | //! for all lint attributes. |
| 16 | 16 | |
| 17 | use crate::{passes::LateLintPassObject, LateContext, LateLintPass, LintStore}; | |
| 17 | use std::any::Any; | |
| 18 | use std::cell::Cell; | |
| 19 | ||
| 18 | 20 | use rustc_data_structures::stack::ensure_sufficient_stack; |
| 19 | 21 | use rustc_data_structures::sync::{join, Lrc}; |
| 20 | 22 | use rustc_hir as hir; |
| 21 | 23 | use rustc_hir::def_id::{LocalDefId, LocalModDefId}; |
| 22 | use rustc_hir::intravisit as hir_visit; | |
| 23 | use rustc_hir::HirId; | |
| 24 | use rustc_hir::{intravisit as hir_visit, HirId}; | |
| 24 | 25 | use rustc_middle::hir::nested_filter; |
| 25 | 26 | use rustc_middle::ty::{self, TyCtxt}; |
| 26 | 27 | use rustc_session::lint::LintPass; |
| 27 | 28 | use rustc_session::Session; |
| 28 | 29 | use rustc_span::Span; |
| 29 | use std::any::Any; | |
| 30 | use std::cell::Cell; | |
| 31 | 30 | use tracing::debug; |
| 32 | 31 | |
| 32 | use crate::passes::LateLintPassObject; | |
| 33 | use crate::{LateContext, LateLintPass, LintStore}; | |
| 34 | ||
| 33 | 35 | /// Extract the [`LintStore`] from [`Session`]. |
| 34 | 36 | /// |
| 35 | 37 | /// This function exists because [`Session::lint_store`] is type-erased. |
compiler/rustc_lint/src/let_underscore.rs+3-4| ... | ... | @@ -1,13 +1,12 @@ |
| 1 | use crate::{ | |
| 2 | lints::{NonBindingLet, NonBindingLetSub}, | |
| 3 | LateContext, LateLintPass, LintContext, | |
| 4 | }; | |
| 5 | 1 | use rustc_errors::MultiSpan; |
| 6 | 2 | use rustc_hir as hir; |
| 7 | 3 | use rustc_middle::ty; |
| 8 | 4 | use rustc_session::{declare_lint, declare_lint_pass}; |
| 9 | 5 | use rustc_span::{sym, Symbol}; |
| 10 | 6 | |
| 7 | use crate::lints::{NonBindingLet, NonBindingLetSub}; | |
| 8 | use crate::{LateContext, LateLintPass, LintContext}; | |
| 9 | ||
| 11 | 10 | declare_lint! { |
| 12 | 11 | /// The `let_underscore_drop` lint checks for statements which don't bind |
| 13 | 12 | /// an expression which has a non-trivial Drop implementation to anything, |
compiler/rustc_lint/src/levels.rs+17-25| ... | ... | @@ -1,24 +1,7 @@ |
| 1 | use crate::errors::{CheckNameUnknownTool, RequestedLevel, UnsupportedGroup}; | |
| 2 | use crate::lints::{ | |
| 3 | DeprecatedLintNameFromCommandLine, RemovedLintFromCommandLine, RenamedLintFromCommandLine, | |
| 4 | UnknownLintFromCommandLine, | |
| 5 | }; | |
| 6 | use crate::{ | |
| 7 | builtin::MISSING_DOCS, | |
| 8 | context::{CheckLintNameResult, LintStore}, | |
| 9 | fluent_generated as fluent, | |
| 10 | late::unerased_lint_store, | |
| 11 | lints::{ | |
| 12 | DeprecatedLintName, IgnoredUnlessCrateSpecified, OverruledAttributeLint, RemovedLint, | |
| 13 | RenamedLint, RenamedLintSuggestion, UnknownLint, UnknownLintSuggestion, | |
| 14 | }, | |
| 15 | }; | |
| 16 | use rustc_ast as ast; | |
| 17 | 1 | use rustc_ast_pretty::pprust; |
| 18 | 2 | use rustc_data_structures::fx::FxIndexMap; |
| 19 | 3 | use rustc_errors::{Diag, LintDiagnostic, MultiSpan}; |
| 20 | 4 | use rustc_feature::{Features, GateIssue}; |
| 21 | use rustc_hir as hir; | |
| 22 | 5 | use rustc_hir::intravisit::{self, Visitor}; |
| 23 | 6 | use rustc_hir::HirId; |
| 24 | 7 | use rustc_index::IndexVec; |
| ... | ... | @@ -30,21 +13,30 @@ use rustc_middle::lint::{ |
| 30 | 13 | }; |
| 31 | 14 | use rustc_middle::query::Providers; |
| 32 | 15 | use rustc_middle::ty::{RegisteredTools, TyCtxt}; |
| 33 | use rustc_session::lint::{ | |
| 34 | builtin::{ | |
| 35 | self, FORBIDDEN_LINT_GROUPS, RENAMED_AND_REMOVED_LINTS, SINGLE_USE_LIFETIMES, | |
| 36 | UNFULFILLED_LINT_EXPECTATIONS, UNKNOWN_LINTS, UNUSED_ATTRIBUTES, | |
| 37 | }, | |
| 38 | Level, Lint, LintExpectationId, LintId, | |
| 16 | use rustc_session::lint::builtin::{ | |
| 17 | self, FORBIDDEN_LINT_GROUPS, RENAMED_AND_REMOVED_LINTS, SINGLE_USE_LIFETIMES, | |
| 18 | UNFULFILLED_LINT_EXPECTATIONS, UNKNOWN_LINTS, UNUSED_ATTRIBUTES, | |
| 39 | 19 | }; |
| 20 | use rustc_session::lint::{Level, Lint, LintExpectationId, LintId}; | |
| 40 | 21 | use rustc_session::Session; |
| 41 | 22 | use rustc_span::symbol::{sym, Symbol}; |
| 42 | 23 | use rustc_span::{Span, DUMMY_SP}; |
| 43 | 24 | use tracing::{debug, instrument}; |
| 25 | use {rustc_ast as ast, rustc_hir as hir}; | |
| 44 | 26 | |
| 27 | use crate::builtin::MISSING_DOCS; | |
| 28 | use crate::context::{CheckLintNameResult, LintStore}; | |
| 45 | 29 | use crate::errors::{ |
| 46 | MalformedAttribute, MalformedAttributeSub, OverruledAttribute, OverruledAttributeSub, | |
| 47 | UnknownToolInScopedLint, | |
| 30 | CheckNameUnknownTool, MalformedAttribute, MalformedAttributeSub, OverruledAttribute, | |
| 31 | OverruledAttributeSub, RequestedLevel, UnknownToolInScopedLint, UnsupportedGroup, | |
| 32 | }; | |
| 33 | use crate::fluent_generated as fluent; | |
| 34 | use crate::late::unerased_lint_store; | |
| 35 | use crate::lints::{ | |
| 36 | DeprecatedLintName, DeprecatedLintNameFromCommandLine, IgnoredUnlessCrateSpecified, | |
| 37 | OverruledAttributeLint, RemovedLint, RemovedLintFromCommandLine, RenamedLint, | |
| 38 | RenamedLintFromCommandLine, RenamedLintSuggestion, UnknownLint, UnknownLintFromCommandLine, | |
| 39 | UnknownLintSuggestion, | |
| 48 | 40 | }; |
| 49 | 41 | |
| 50 | 42 | /// Collection of lint levels for the whole crate. |
compiler/rustc_lint/src/lib.rs+10-10| ... | ... | @@ -83,12 +83,6 @@ mod types; |
| 83 | 83 | mod unit_bindings; |
| 84 | 84 | mod unused; |
| 85 | 85 | |
| 86 | pub use shadowed_into_iter::{ARRAY_INTO_ITER, BOXED_SLICE_INTO_ITER}; | |
| 87 | ||
| 88 | use rustc_hir::def_id::LocalModDefId; | |
| 89 | use rustc_middle::query::Providers; | |
| 90 | use rustc_middle::ty::TyCtxt; | |
| 91 | ||
| 92 | 86 | use async_closures::AsyncClosureUsage; |
| 93 | 87 | use async_fn_in_trait::AsyncFnInTrait; |
| 94 | 88 | use builtin::*; |
| ... | ... | @@ -116,7 +110,11 @@ use precedence::*; |
| 116 | 110 | use ptr_nulls::*; |
| 117 | 111 | use redundant_semicolon::*; |
| 118 | 112 | use reference_casting::*; |
| 113 | use rustc_hir::def_id::LocalModDefId; | |
| 114 | use rustc_middle::query::Providers; | |
| 115 | use rustc_middle::ty::TyCtxt; | |
| 119 | 116 | use shadowed_into_iter::ShadowedIntoIter; |
| 117 | pub use shadowed_into_iter::{ARRAY_INTO_ITER, BOXED_SLICE_INTO_ITER}; | |
| 120 | 118 | use traits::*; |
| 121 | 119 | use types::*; |
| 122 | 120 | use unit_bindings::*; |
| ... | ... | @@ -124,14 +122,16 @@ use unused::*; |
| 124 | 122 | |
| 125 | 123 | #[rustfmt::skip] |
| 126 | 124 | pub use builtin::{MissingDoc, SoftLints}; |
| 127 | pub use context::{CheckLintNameResult, FindLintError, LintStore}; | |
| 128 | pub use context::{EarlyContext, LateContext, LintContext}; | |
| 125 | pub use context::{ | |
| 126 | CheckLintNameResult, EarlyContext, FindLintError, LateContext, LintContext, LintStore, | |
| 127 | }; | |
| 129 | 128 | pub use early::{check_ast_node, EarlyCheckNode}; |
| 130 | 129 | pub use late::{check_crate, late_lint_mod, unerased_lint_store}; |
| 131 | 130 | pub use passes::{EarlyLintPass, LateLintPass}; |
| 132 | 131 | pub use rustc_session::lint::Level::{self, *}; |
| 133 | pub use rustc_session::lint::{BufferedEarlyLint, FutureIncompatibleInfo, Lint, LintId}; | |
| 134 | pub use rustc_session::lint::{LintPass, LintVec}; | |
| 132 | pub use rustc_session::lint::{ | |
| 133 | BufferedEarlyLint, FutureIncompatibleInfo, Lint, LintId, LintPass, LintVec, | |
| 134 | }; | |
| 135 | 135 | |
| 136 | 136 | rustc_fluent_macro::fluent_messages! { "../messages.ftl" } |
| 137 | 137 |
compiler/rustc_lint/src/lints.rs+17-18| ... | ... | @@ -2,27 +2,26 @@ |
| 2 | 2 | #![allow(rustc::untranslatable_diagnostic)] |
| 3 | 3 | use std::num::NonZero; |
| 4 | 4 | |
| 5 | use crate::builtin::{InitError, ShorthandAssocTyCollector, TypeAliasBounds}; | |
| 6 | use crate::errors::{OverruledAttributeSub, RequestedLevel}; | |
| 7 | use crate::fluent_generated as fluent; | |
| 8 | use crate::LateContext; | |
| 5 | use rustc_errors::codes::*; | |
| 9 | 6 | use rustc_errors::{ |
| 10 | codes::*, Applicability, Diag, DiagArgValue, DiagMessage, DiagStyledString, | |
| 11 | ElidedLifetimeInPathSubdiag, EmissionGuarantee, LintDiagnostic, MultiSpan, SubdiagMessageOp, | |
| 12 | Subdiagnostic, SuggestionStyle, | |
| 7 | Applicability, Diag, DiagArgValue, DiagMessage, DiagStyledString, ElidedLifetimeInPathSubdiag, | |
| 8 | EmissionGuarantee, LintDiagnostic, MultiSpan, SubdiagMessageOp, Subdiagnostic, SuggestionStyle, | |
| 13 | 9 | }; |
| 14 | use rustc_hir::{self as hir, def::Namespace, def_id::DefId}; | |
| 10 | use rustc_hir::def::Namespace; | |
| 11 | use rustc_hir::def_id::DefId; | |
| 12 | use rustc_hir::{self as hir}; | |
| 15 | 13 | use rustc_macros::{LintDiagnostic, Subdiagnostic}; |
| 16 | use rustc_middle::ty::{ | |
| 17 | inhabitedness::InhabitedPredicate, Clause, PolyExistentialTraitRef, Ty, TyCtxt, | |
| 18 | }; | |
| 19 | use rustc_session::{lint::AmbiguityErrorDiag, Session}; | |
| 20 | use rustc_span::{ | |
| 21 | edition::Edition, | |
| 22 | sym, | |
| 23 | symbol::{Ident, MacroRulesNormalizedIdent}, | |
| 24 | Span, Symbol, | |
| 25 | }; | |
| 14 | use rustc_middle::ty::inhabitedness::InhabitedPredicate; | |
| 15 | use rustc_middle::ty::{Clause, PolyExistentialTraitRef, Ty, TyCtxt}; | |
| 16 | use rustc_session::lint::AmbiguityErrorDiag; | |
| 17 | use rustc_session::Session; | |
| 18 | use rustc_span::edition::Edition; | |
| 19 | use rustc_span::symbol::{Ident, MacroRulesNormalizedIdent}; | |
| 20 | use rustc_span::{sym, Span, Symbol}; | |
| 21 | ||
| 22 | use crate::builtin::{InitError, ShorthandAssocTyCollector, TypeAliasBounds}; | |
| 23 | use crate::errors::{OverruledAttributeSub, RequestedLevel}; | |
| 24 | use crate::{fluent_generated as fluent, LateContext}; | |
| 26 | 25 | |
| 27 | 26 | // array_into_iter.rs |
| 28 | 27 | #[derive(LintDiagnostic)] |
compiler/rustc_lint/src/macro_expr_fragment_specifier_2024_migration.rs+4-8| ... | ... | @@ -1,16 +1,12 @@ |
| 1 | 1 | //! Migration code for the `expr_fragment_specifier_2024` |
| 2 | 2 | //! rule. |
| 3 | use tracing::debug; | |
| 4 | ||
| 5 | use rustc_ast::token::Token; | |
| 6 | use rustc_ast::token::TokenKind; | |
| 7 | use rustc_ast::tokenstream::TokenStream; | |
| 8 | use rustc_ast::tokenstream::TokenTree; | |
| 9 | use rustc_session::declare_lint; | |
| 10 | use rustc_session::declare_lint_pass; | |
| 3 | use rustc_ast::token::{Token, TokenKind}; | |
| 4 | use rustc_ast::tokenstream::{TokenStream, TokenTree}; | |
| 11 | 5 | use rustc_session::lint::FutureIncompatibilityReason; |
| 6 | use rustc_session::{declare_lint, declare_lint_pass}; | |
| 12 | 7 | use rustc_span::edition::Edition; |
| 13 | 8 | use rustc_span::sym; |
| 9 | use tracing::debug; | |
| 14 | 10 | |
| 15 | 11 | use crate::lints::MacroExprFragment2024; |
| 16 | 12 | use crate::EarlyLintPass; |
compiler/rustc_lint/src/map_unit_fn.rs+5-7| ... | ... | @@ -1,13 +1,11 @@ |
| 1 | use crate::lints::MappingToUnit; | |
| 2 | use crate::{LateContext, LateLintPass, LintContext}; | |
| 3 | ||
| 4 | 1 | use rustc_hir::{Expr, ExprKind, HirId, Stmt, StmtKind}; |
| 5 | use rustc_middle::{ | |
| 6 | query::Key, | |
| 7 | ty::{self, Ty}, | |
| 8 | }; | |
| 2 | use rustc_middle::query::Key; | |
| 3 | use rustc_middle::ty::{self, Ty}; | |
| 9 | 4 | use rustc_session::{declare_lint, declare_lint_pass}; |
| 10 | 5 | |
| 6 | use crate::lints::MappingToUnit; | |
| 7 | use crate::{LateContext, LateLintPass, LintContext}; | |
| 8 | ||
| 11 | 9 | declare_lint! { |
| 12 | 10 | /// The `map_unit_fn` lint checks for `Iterator::map` receive |
| 13 | 11 | /// a callable that returns `()`. |
compiler/rustc_lint/src/methods.rs+5-5| ... | ... | @@ -1,11 +1,11 @@ |
| 1 | use crate::lints::CStringPtr; | |
| 2 | use crate::LateContext; | |
| 3 | use crate::LateLintPass; | |
| 4 | use crate::LintContext; | |
| 5 | 1 | use rustc_hir::{Expr, ExprKind}; |
| 6 | 2 | use rustc_middle::ty; |
| 7 | 3 | use rustc_session::{declare_lint, declare_lint_pass}; |
| 8 | use rustc_span::{symbol::sym, Span}; | |
| 4 | use rustc_span::symbol::sym; | |
| 5 | use rustc_span::Span; | |
| 6 | ||
| 7 | use crate::lints::CStringPtr; | |
| 8 | use crate::{LateContext, LateLintPass, LintContext}; | |
| 9 | 9 | |
| 10 | 10 | declare_lint! { |
| 11 | 11 | /// The `temporary_cstring_as_ptr` lint detects getting the inner pointer of |
compiler/rustc_lint/src/multiple_supertrait_upcastable.rs+2-2| ... | ... | @@ -1,8 +1,8 @@ |
| 1 | use crate::{LateContext, LateLintPass, LintContext}; | |
| 2 | ||
| 3 | 1 | use rustc_hir as hir; |
| 4 | 2 | use rustc_session::{declare_lint, declare_lint_pass}; |
| 5 | 3 | |
| 4 | use crate::{LateContext, LateLintPass, LintContext}; | |
| 5 | ||
| 6 | 6 | declare_lint! { |
| 7 | 7 | /// The `multiple_supertrait_upcastable` lint detects when an object-safe trait has multiple |
| 8 | 8 | /// supertraits. |
compiler/rustc_lint/src/non_ascii_idents.rs+8-6| ... | ... | @@ -1,8 +1,3 @@ |
| 1 | use crate::lints::{ | |
| 2 | ConfusableIdentifierPair, IdentifierNonAsciiChar, IdentifierUncommonCodepoints, | |
| 3 | MixedScriptConfusables, | |
| 4 | }; | |
| 5 | use crate::{EarlyContext, EarlyLintPass, LintContext}; | |
| 6 | 1 | use rustc_ast as ast; |
| 7 | 2 | use rustc_data_structures::fx::FxIndexMap; |
| 8 | 3 | use rustc_data_structures::unord::UnordMap; |
| ... | ... | @@ -10,6 +5,12 @@ use rustc_session::{declare_lint, declare_lint_pass}; |
| 10 | 5 | use rustc_span::symbol::Symbol; |
| 11 | 6 | use unicode_security::general_security_profile::IdentifierType; |
| 12 | 7 | |
| 8 | use crate::lints::{ | |
| 9 | ConfusableIdentifierPair, IdentifierNonAsciiChar, IdentifierUncommonCodepoints, | |
| 10 | MixedScriptConfusables, | |
| 11 | }; | |
| 12 | use crate::{EarlyContext, EarlyLintPass, LintContext}; | |
| 13 | ||
| 13 | 14 | declare_lint! { |
| 14 | 15 | /// The `non_ascii_idents` lint detects non-ASCII identifiers. |
| 15 | 16 | /// |
| ... | ... | @@ -152,9 +153,10 @@ declare_lint_pass!(NonAsciiIdents => [NON_ASCII_IDENTS, UNCOMMON_CODEPOINTS, CON |
| 152 | 153 | |
| 153 | 154 | impl EarlyLintPass for NonAsciiIdents { |
| 154 | 155 | fn check_crate(&mut self, cx: &EarlyContext<'_>, _: &ast::Crate) { |
| 156 | use std::collections::BTreeMap; | |
| 157 | ||
| 155 | 158 | use rustc_session::lint::Level; |
| 156 | 159 | use rustc_span::Span; |
| 157 | use std::collections::BTreeMap; | |
| 158 | 160 | use unicode_security::GeneralSecurityProfile; |
| 159 | 161 | |
| 160 | 162 | let check_non_ascii_idents = cx.builder.lint_level(NON_ASCII_IDENTS).0 != Level::Allow; |
compiler/rustc_lint/src/non_fmt_panic.rs+6-5| ... | ... | @@ -1,19 +1,20 @@ |
| 1 | use crate::lints::{NonFmtPanicBraces, NonFmtPanicUnused}; | |
| 2 | use crate::{fluent_generated as fluent, LateContext, LateLintPass, LintContext}; | |
| 3 | 1 | use rustc_ast as ast; |
| 4 | 2 | use rustc_errors::Applicability; |
| 5 | 3 | use rustc_hir::{self as hir, LangItem}; |
| 6 | 4 | use rustc_infer::infer::TyCtxtInferExt; |
| 7 | use rustc_middle::bug; | |
| 8 | 5 | use rustc_middle::lint::in_external_macro; |
| 9 | use rustc_middle::ty; | |
| 6 | use rustc_middle::{bug, ty}; | |
| 10 | 7 | use rustc_parse_format::{ParseMode, Parser, Piece}; |
| 11 | 8 | use rustc_session::lint::FutureIncompatibilityReason; |
| 12 | 9 | use rustc_session::{declare_lint, declare_lint_pass}; |
| 13 | 10 | use rustc_span::edition::Edition; |
| 14 | use rustc_span::{hygiene, sym, symbol::kw, InnerSpan, Span, Symbol}; | |
| 11 | use rustc_span::symbol::kw; | |
| 12 | use rustc_span::{hygiene, sym, InnerSpan, Span, Symbol}; | |
| 15 | 13 | use rustc_trait_selection::infer::InferCtxtExt; |
| 16 | 14 | |
| 15 | use crate::lints::{NonFmtPanicBraces, NonFmtPanicUnused}; | |
| 16 | use crate::{fluent_generated as fluent, LateContext, LateLintPass, LintContext}; | |
| 17 | ||
| 17 | 18 | declare_lint! { |
| 18 | 19 | /// The `non_fmt_panics` lint detects `panic!(..)` invocations where the first |
| 19 | 20 | /// argument is not a formatting string. |
compiler/rustc_lint/src/non_local_def.rs+8-9| ... | ... | @@ -1,24 +1,23 @@ |
| 1 | 1 | use rustc_errors::MultiSpan; |
| 2 | use rustc_hir::def::DefKind; | |
| 2 | 3 | use rustc_hir::intravisit::{self, Visitor}; |
| 3 | use rustc_hir::HirId; | |
| 4 | use rustc_hir::{def::DefKind, Body, Item, ItemKind, Node, TyKind}; | |
| 5 | use rustc_hir::{Path, QPath}; | |
| 4 | use rustc_hir::{Body, HirId, Item, ItemKind, Node, Path, QPath, TyKind}; | |
| 6 | 5 | use rustc_infer::infer::InferCtxt; |
| 7 | 6 | use rustc_infer::traits::{Obligation, ObligationCause}; |
| 8 | use rustc_middle::ty::{self, Binder, Ty, TyCtxt, TypeFoldable, TypeFolder}; | |
| 9 | use rustc_middle::ty::{EarlyBinder, TraitRef, TypeSuperFoldable}; | |
| 7 | use rustc_middle::ty::{ | |
| 8 | self, Binder, EarlyBinder, TraitRef, Ty, TyCtxt, TypeFoldable, TypeFolder, TypeSuperFoldable, | |
| 9 | }; | |
| 10 | 10 | use rustc_session::{declare_lint, impl_lint_pass}; |
| 11 | 11 | use rustc_span::def_id::{DefId, LOCAL_CRATE}; |
| 12 | use rustc_span::Span; | |
| 13 | use rustc_span::{sym, symbol::kw, ExpnKind, MacroKind, Symbol}; | |
| 12 | use rustc_span::symbol::kw; | |
| 13 | use rustc_span::{sym, ExpnKind, MacroKind, Span, Symbol}; | |
| 14 | 14 | use rustc_trait_selection::error_reporting::traits::ambiguity::{ |
| 15 | 15 | compute_applicable_impls_for_diagnostics, CandidateSource, |
| 16 | 16 | }; |
| 17 | 17 | use rustc_trait_selection::infer::TyCtxtInferExt; |
| 18 | 18 | |
| 19 | use crate::fluent_generated as fluent; | |
| 20 | 19 | use crate::lints::{NonLocalDefinitionsCargoUpdateNote, NonLocalDefinitionsDiag}; |
| 21 | use crate::{LateContext, LateLintPass, LintContext}; | |
| 20 | use crate::{fluent_generated as fluent, LateContext, LateLintPass, LintContext}; | |
| 22 | 21 | |
| 23 | 22 | declare_lint! { |
| 24 | 23 | /// The `non_local_definitions` lint checks for `impl` blocks and `#[macro_export]` |
compiler/rustc_lint/src/nonstandard_style.rs+7-8| ... | ... | @@ -1,11 +1,3 @@ |
| 1 | use crate::lints::{ | |
| 2 | NonCamelCaseType, NonCamelCaseTypeSub, NonSnakeCaseDiag, NonSnakeCaseDiagSub, | |
| 3 | NonUpperCaseGlobal, NonUpperCaseGlobalSub, | |
| 4 | }; | |
| 5 | use crate::{EarlyContext, EarlyLintPass, LateContext, LateLintPass, LintContext}; | |
| 6 | use rustc_ast as ast; | |
| 7 | use rustc_attr as attr; | |
| 8 | use rustc_hir as hir; | |
| 9 | 1 | use rustc_hir::def::{DefKind, Res}; |
| 10 | 2 | use rustc_hir::intravisit::FnKind; |
| 11 | 3 | use rustc_hir::{GenericParamKind, PatKind}; |
| ... | ... | @@ -16,6 +8,13 @@ use rustc_span::def_id::LocalDefId; |
| 16 | 8 | use rustc_span::symbol::{sym, Ident}; |
| 17 | 9 | use rustc_span::{BytePos, Span}; |
| 18 | 10 | use rustc_target::spec::abi::Abi; |
| 11 | use {rustc_ast as ast, rustc_attr as attr, rustc_hir as hir}; | |
| 12 | ||
| 13 | use crate::lints::{ | |
| 14 | NonCamelCaseType, NonCamelCaseTypeSub, NonSnakeCaseDiag, NonSnakeCaseDiagSub, | |
| 15 | NonUpperCaseGlobal, NonUpperCaseGlobalSub, | |
| 16 | }; | |
| 17 | use crate::{EarlyContext, EarlyLintPass, LateContext, LateLintPass, LintContext}; | |
| 19 | 18 | |
| 20 | 19 | #[derive(PartialEq)] |
| 21 | 20 | pub enum MethodLateContext { |
compiler/rustc_lint/src/noop_method_call.rs+6-6| ... | ... | @@ -1,9 +1,3 @@ |
| 1 | use crate::context::LintContext; | |
| 2 | use crate::lints::{ | |
| 3 | NoopMethodCallDiag, SuspiciousDoubleRefCloneDiag, SuspiciousDoubleRefDerefDiag, | |
| 4 | }; | |
| 5 | use crate::LateContext; | |
| 6 | use crate::LateLintPass; | |
| 7 | 1 | use rustc_hir::def::DefKind; |
| 8 | 2 | use rustc_hir::{Expr, ExprKind}; |
| 9 | 3 | use rustc_middle::ty; |
| ... | ... | @@ -11,6 +5,12 @@ use rustc_middle::ty::adjustment::Adjust; |
| 11 | 5 | use rustc_session::{declare_lint, declare_lint_pass}; |
| 12 | 6 | use rustc_span::symbol::sym; |
| 13 | 7 | |
| 8 | use crate::context::LintContext; | |
| 9 | use crate::lints::{ | |
| 10 | NoopMethodCallDiag, SuspiciousDoubleRefCloneDiag, SuspiciousDoubleRefDerefDiag, | |
| 11 | }; | |
| 12 | use crate::{LateContext, LateLintPass}; | |
| 13 | ||
| 14 | 14 | declare_lint! { |
| 15 | 15 | /// The `noop_method_call` lint detects specific calls to noop methods |
| 16 | 16 | /// such as a calling `<&T as Clone>::clone` where `T: !Clone`. |
compiler/rustc_lint/src/opaque_hidden_inferred_bound.rs+4-2| ... | ... | @@ -1,10 +1,12 @@ |
| 1 | 1 | use rustc_hir as hir; |
| 2 | 2 | use rustc_infer::infer::TyCtxtInferExt; |
| 3 | 3 | use rustc_macros::{LintDiagnostic, Subdiagnostic}; |
| 4 | use rustc_middle::ty::fold::BottomUpFolder; | |
| 4 | 5 | use rustc_middle::ty::print::{PrintTraitPredicateExt as _, TraitPredPrintModifiersAndPath}; |
| 5 | use rustc_middle::ty::{self, fold::BottomUpFolder, Ty, TypeFoldable}; | |
| 6 | use rustc_middle::ty::{self, Ty, TypeFoldable}; | |
| 6 | 7 | use rustc_session::{declare_lint, declare_lint_pass}; |
| 7 | use rustc_span::{symbol::kw, Span}; | |
| 8 | use rustc_span::symbol::kw; | |
| 9 | use rustc_span::Span; | |
| 8 | 10 | use rustc_trait_selection::traits::{self, ObligationCtxt}; |
| 9 | 11 | |
| 10 | 12 | use crate::{LateContext, LateLintPass, LintContext}; |
compiler/rustc_lint/src/pass_by_value.rs+3-2| ... | ... | @@ -1,5 +1,3 @@ |
| 1 | use crate::lints::PassByValueDiag; | |
| 2 | use crate::{LateContext, LateLintPass, LintContext}; | |
| 3 | 1 | use rustc_hir as hir; |
| 4 | 2 | use rustc_hir::def::Res; |
| 5 | 3 | use rustc_hir::{GenericArg, PathSegment, QPath, TyKind}; |
| ... | ... | @@ -7,6 +5,9 @@ use rustc_middle::ty; |
| 7 | 5 | use rustc_session::{declare_lint_pass, declare_tool_lint}; |
| 8 | 6 | use rustc_span::symbol::sym; |
| 9 | 7 | |
| 8 | use crate::lints::PassByValueDiag; | |
| 9 | use crate::{LateContext, LateLintPass, LintContext}; | |
| 10 | ||
| 10 | 11 | declare_tool_lint! { |
| 11 | 12 | /// The `rustc_pass_by_value` lint marks a type with `#[rustc_pass_by_value]` requiring it to |
| 12 | 13 | /// always be passed by value. This is usually used for types that are thin wrappers around |
compiler/rustc_lint/src/passes.rs+2-2| ... | ... | @@ -1,8 +1,8 @@ |
| 1 | use crate::context::{EarlyContext, LateContext}; | |
| 2 | ||
| 3 | 1 | use rustc_session::lint::builtin::HardwiredLints; |
| 4 | 2 | use rustc_session::lint::LintPass; |
| 5 | 3 | |
| 4 | use crate::context::{EarlyContext, LateContext}; | |
| 5 | ||
| 6 | 6 | #[macro_export] |
| 7 | 7 | macro_rules! late_lint_methods { |
| 8 | 8 | ($macro:path, $args:tt) => ( |
compiler/rustc_lint/src/ptr_nulls.rs+3-1| ... | ... | @@ -1,9 +1,11 @@ |
| 1 | use crate::{lints::PtrNullChecksDiag, LateContext, LateLintPass, LintContext}; | |
| 2 | 1 | use rustc_ast::LitKind; |
| 3 | 2 | use rustc_hir::{BinOpKind, Expr, ExprKind, TyKind}; |
| 4 | 3 | use rustc_session::{declare_lint, declare_lint_pass}; |
| 5 | 4 | use rustc_span::sym; |
| 6 | 5 | |
| 6 | use crate::lints::PtrNullChecksDiag; | |
| 7 | use crate::{LateContext, LateLintPass, LintContext}; | |
| 8 | ||
| 7 | 9 | declare_lint! { |
| 8 | 10 | /// The `useless_ptr_null_checks` lint checks for useless null checks against pointers |
| 9 | 11 | /// obtained from non-null types. |
compiler/rustc_lint/src/redundant_semicolon.rs+3-1| ... | ... | @@ -1,8 +1,10 @@ |
| 1 | use crate::{lints::RedundantSemicolonsDiag, EarlyContext, EarlyLintPass, LintContext}; | |
| 2 | 1 | use rustc_ast::{Block, StmtKind}; |
| 3 | 2 | use rustc_session::{declare_lint, declare_lint_pass}; |
| 4 | 3 | use rustc_span::Span; |
| 5 | 4 | |
| 5 | use crate::lints::RedundantSemicolonsDiag; | |
| 6 | use crate::{EarlyContext, EarlyLintPass, LintContext}; | |
| 7 | ||
| 6 | 8 | declare_lint! { |
| 7 | 9 | /// The `redundant_semicolons` lint detects unnecessary trailing |
| 8 | 10 | /// semicolons. |
compiler/rustc_lint/src/reference_casting.rs+4-3| ... | ... | @@ -1,11 +1,12 @@ |
| 1 | 1 | use rustc_ast::Mutability; |
| 2 | 2 | use rustc_hir::{Expr, ExprKind, UnOp}; |
| 3 | use rustc_middle::ty::layout::LayoutOf as _; | |
| 4 | use rustc_middle::ty::{self, layout::TyAndLayout}; | |
| 3 | use rustc_middle::ty::layout::{LayoutOf as _, TyAndLayout}; | |
| 4 | use rustc_middle::ty::{self}; | |
| 5 | 5 | use rustc_session::{declare_lint, declare_lint_pass}; |
| 6 | 6 | use rustc_span::sym; |
| 7 | 7 | |
| 8 | use crate::{lints::InvalidReferenceCastingDiag, LateContext, LateLintPass, LintContext}; | |
| 8 | use crate::lints::InvalidReferenceCastingDiag; | |
| 9 | use crate::{LateContext, LateLintPass, LintContext}; | |
| 9 | 10 | |
| 10 | 11 | declare_lint! { |
| 11 | 12 | /// The `invalid_reference_casting` lint checks for casts of `&T` to `&mut T` |
compiler/rustc_lint/src/shadowed_into_iter.rs+3-2| ... | ... | @@ -1,11 +1,12 @@ |
| 1 | use crate::lints::{ShadowedIntoIterDiag, ShadowedIntoIterDiagSub}; | |
| 2 | use crate::{LateContext, LateLintPass, LintContext}; | |
| 3 | 1 | use rustc_hir as hir; |
| 4 | 2 | use rustc_middle::ty::{self, Ty}; |
| 5 | 3 | use rustc_session::lint::FutureIncompatibilityReason; |
| 6 | 4 | use rustc_session::{declare_lint, impl_lint_pass}; |
| 7 | 5 | use rustc_span::edition::Edition; |
| 8 | 6 | |
| 7 | use crate::lints::{ShadowedIntoIterDiag, ShadowedIntoIterDiagSub}; | |
| 8 | use crate::{LateContext, LateLintPass, LintContext}; | |
| 9 | ||
| 9 | 10 | declare_lint! { |
| 10 | 11 | /// The `array_into_iter` lint detects calling `into_iter` on arrays. |
| 11 | 12 | /// |
compiler/rustc_lint/src/tests.rs+2-1| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | use crate::levels::parse_lint_and_tool_name; | |
| 2 | 1 | use rustc_span::{create_default_session_globals_then, Symbol}; |
| 3 | 2 | |
| 3 | use crate::levels::parse_lint_and_tool_name; | |
| 4 | ||
| 4 | 5 | #[test] |
| 5 | 6 | fn parse_lint_no_tool() { |
| 6 | 7 | create_default_session_globals_then(|| { |
compiler/rustc_lint/src/traits.rs+3-4| ... | ... | @@ -1,11 +1,10 @@ |
| 1 | use crate::lints::{DropGlue, DropTraitConstraintsDiag}; | |
| 2 | use crate::LateContext; | |
| 3 | use crate::LateLintPass; | |
| 4 | use crate::LintContext; | |
| 5 | 1 | use rustc_hir::{self as hir, LangItem}; |
| 6 | 2 | use rustc_session::{declare_lint, declare_lint_pass}; |
| 7 | 3 | use rustc_span::symbol::sym; |
| 8 | 4 | |
| 5 | use crate::lints::{DropGlue, DropTraitConstraintsDiag}; | |
| 6 | use crate::{LateContext, LateLintPass, LintContext}; | |
| 7 | ||
| 9 | 8 | declare_lint! { |
| 10 | 9 | /// The `drop_bounds` lint checks for generics with `std::ops::Drop` as |
| 11 | 10 | /// bounds. |
compiler/rustc_lint/src/types.rs+18-24| ... | ... | @@ -1,39 +1,33 @@ |
| 1 | use crate::{ | |
| 2 | fluent_generated as fluent, | |
| 3 | lints::{ | |
| 4 | AmbiguousWidePointerComparisons, AmbiguousWidePointerComparisonsAddrMetadataSuggestion, | |
| 5 | AmbiguousWidePointerComparisonsAddrSuggestion, AtomicOrderingFence, AtomicOrderingLoad, | |
| 6 | AtomicOrderingStore, ImproperCTypes, InvalidAtomicOrderingDiag, InvalidNanComparisons, | |
| 7 | InvalidNanComparisonsSuggestion, OnlyCastu8ToChar, OverflowingBinHex, | |
| 8 | OverflowingBinHexSign, OverflowingBinHexSignBitSub, OverflowingBinHexSub, OverflowingInt, | |
| 9 | OverflowingIntHelp, OverflowingLiteral, OverflowingUInt, RangeEndpointOutOfRange, | |
| 10 | UnusedComparisons, UseInclusiveRange, VariantSizeDifferencesDiag, | |
| 11 | }, | |
| 12 | }; | |
| 13 | use crate::{LateContext, LateLintPass, LintContext}; | |
| 14 | use rustc_ast as ast; | |
| 15 | use rustc_attr as attr; | |
| 1 | use std::iter; | |
| 2 | use std::ops::ControlFlow; | |
| 3 | ||
| 16 | 4 | use rustc_data_structures::fx::FxHashSet; |
| 17 | 5 | use rustc_errors::DiagMessage; |
| 18 | use rustc_hir as hir; | |
| 19 | 6 | use rustc_hir::{is_range_literal, Expr, ExprKind, Node}; |
| 20 | 7 | use rustc_middle::bug; |
| 21 | 8 | use rustc_middle::ty::layout::{IntegerExt, LayoutOf, SizeSkeleton}; |
| 22 | use rustc_middle::ty::GenericArgsRef; | |
| 23 | 9 | use rustc_middle::ty::{ |
| 24 | self, AdtKind, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitableExt, | |
| 10 | self, AdtKind, GenericArgsRef, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitableExt, | |
| 25 | 11 | }; |
| 26 | 12 | use rustc_session::{declare_lint, declare_lint_pass, impl_lint_pass}; |
| 27 | 13 | use rustc_span::def_id::LocalDefId; |
| 28 | use rustc_span::source_map; | |
| 29 | 14 | use rustc_span::symbol::sym; |
| 30 | use rustc_span::{Span, Symbol}; | |
| 31 | use rustc_target::abi::{Abi, Size, WrappingRange}; | |
| 32 | use rustc_target::abi::{Integer, TagEncoding, Variants}; | |
| 15 | use rustc_span::{source_map, Span, Symbol}; | |
| 16 | use rustc_target::abi::{Abi, Integer, Size, TagEncoding, Variants, WrappingRange}; | |
| 33 | 17 | use rustc_target::spec::abi::Abi as SpecAbi; |
| 34 | use std::iter; | |
| 35 | use std::ops::ControlFlow; | |
| 36 | 18 | use tracing::debug; |
| 19 | use {rustc_ast as ast, rustc_attr as attr, rustc_hir as hir}; | |
| 20 | ||
| 21 | use crate::lints::{ | |
| 22 | AmbiguousWidePointerComparisons, AmbiguousWidePointerComparisonsAddrMetadataSuggestion, | |
| 23 | AmbiguousWidePointerComparisonsAddrSuggestion, AtomicOrderingFence, AtomicOrderingLoad, | |
| 24 | AtomicOrderingStore, ImproperCTypes, InvalidAtomicOrderingDiag, InvalidNanComparisons, | |
| 25 | InvalidNanComparisonsSuggestion, OnlyCastu8ToChar, OverflowingBinHex, OverflowingBinHexSign, | |
| 26 | OverflowingBinHexSignBitSub, OverflowingBinHexSub, OverflowingInt, OverflowingIntHelp, | |
| 27 | OverflowingLiteral, OverflowingUInt, RangeEndpointOutOfRange, UnusedComparisons, | |
| 28 | UseInclusiveRange, VariantSizeDifferencesDiag, | |
| 29 | }; | |
| 30 | use crate::{fluent_generated as fluent, LateContext, LateLintPass, LintContext}; | |
| 37 | 31 | |
| 38 | 32 | declare_lint! { |
| 39 | 33 | /// The `unused_comparisons` lint detects comparisons made useless by |
compiler/rustc_lint/src/unit_bindings.rs+3-2| ... | ... | @@ -1,8 +1,9 @@ |
| 1 | use crate::lints::UnitBindingsDiag; | |
| 2 | use crate::{LateLintPass, LintContext}; | |
| 3 | 1 | use rustc_hir as hir; |
| 4 | 2 | use rustc_session::{declare_lint, declare_lint_pass}; |
| 5 | 3 | |
| 4 | use crate::lints::UnitBindingsDiag; | |
| 5 | use crate::{LateLintPass, LintContext}; | |
| 6 | ||
| 6 | 7 | declare_lint! { |
| 7 | 8 | /// The `unit_bindings` lint detects cases where bindings are useless because they have |
| 8 | 9 | /// the unit type `()` as their inferred type. The lint is suppressed if the user explicitly |
compiler/rustc_lint/src/unused.rs+15-15| ... | ... | @@ -1,11 +1,6 @@ |
| 1 | use crate::lints::{ | |
| 2 | PathStatementDrop, PathStatementDropSub, PathStatementNoEffect, UnusedAllocationDiag, | |
| 3 | UnusedAllocationMutDiag, UnusedClosure, UnusedCoroutine, UnusedDef, UnusedDefSuggestion, | |
| 4 | UnusedDelim, UnusedDelimSuggestion, UnusedImportBracesDiag, UnusedOp, UnusedOpSuggestion, | |
| 5 | UnusedResult, | |
| 6 | }; | |
| 7 | use crate::Lint; | |
| 8 | use crate::{EarlyContext, EarlyLintPass, LateContext, LateLintPass, LintContext}; | |
| 1 | use std::iter; | |
| 2 | use std::ops::ControlFlow; | |
| 3 | ||
| 9 | 4 | use rustc_ast as ast; |
| 10 | 5 | use rustc_ast::util::{classify, parser}; |
| 11 | 6 | use rustc_ast::{ExprKind, StmtKind}; |
| ... | ... | @@ -14,16 +9,20 @@ use rustc_hir::def::{DefKind, Res}; |
| 14 | 9 | use rustc_hir::def_id::DefId; |
| 15 | 10 | use rustc_hir::{self as hir, LangItem}; |
| 16 | 11 | use rustc_infer::traits::util::elaborate; |
| 17 | use rustc_middle::ty::adjustment; | |
| 18 | use rustc_middle::ty::{self, Ty}; | |
| 12 | use rustc_middle::ty::{self, adjustment, Ty}; | |
| 19 | 13 | use rustc_session::{declare_lint, declare_lint_pass, impl_lint_pass}; |
| 20 | use rustc_span::symbol::Symbol; | |
| 21 | use rustc_span::symbol::{kw, sym}; | |
| 14 | use rustc_span::symbol::{kw, sym, Symbol}; | |
| 22 | 15 | use rustc_span::{BytePos, Span}; |
| 23 | use std::iter; | |
| 24 | use std::ops::ControlFlow; | |
| 25 | 16 | use tracing::instrument; |
| 26 | 17 | |
| 18 | use crate::lints::{ | |
| 19 | PathStatementDrop, PathStatementDropSub, PathStatementNoEffect, UnusedAllocationDiag, | |
| 20 | UnusedAllocationMutDiag, UnusedClosure, UnusedCoroutine, UnusedDef, UnusedDefSuggestion, | |
| 21 | UnusedDelim, UnusedDelimSuggestion, UnusedImportBracesDiag, UnusedOp, UnusedOpSuggestion, | |
| 22 | UnusedResult, | |
| 23 | }; | |
| 24 | use crate::{EarlyContext, EarlyLintPass, LateContext, LateLintPass, Lint, LintContext}; | |
| 25 | ||
| 27 | 26 | declare_lint! { |
| 28 | 27 | /// The `unused_must_use` lint detects unused result of a type flagged as |
| 29 | 28 | /// `#[must_use]`. |
| ... | ... | @@ -1205,7 +1204,8 @@ impl EarlyLintPass for UnusedParens { |
| 1205 | 1204 | } |
| 1206 | 1205 | |
| 1207 | 1206 | fn check_pat(&mut self, cx: &EarlyContext<'_>, p: &ast::Pat) { |
| 1208 | use ast::{Mutability, PatKind::*}; | |
| 1207 | use ast::Mutability; | |
| 1208 | use ast::PatKind::*; | |
| 1209 | 1209 | let keep_space = (false, false); |
| 1210 | 1210 | match &p.kind { |
| 1211 | 1211 | // Do not lint on `(..)` as that will result in the other arms being useless. |
compiler/rustc_lint_defs/src/builtin.rs+2-1| ... | ... | @@ -7,9 +7,10 @@ |
| 7 | 7 | //! When removing a lint, make sure to also add a call to `register_removed` in |
| 8 | 8 | //! compiler/rustc_lint/src/lib.rs. |
| 9 | 9 | |
| 10 | use crate::{declare_lint, declare_lint_pass, FutureIncompatibilityReason}; | |
| 11 | 10 | use rustc_span::edition::Edition; |
| 12 | 11 | |
| 12 | use crate::{declare_lint, declare_lint_pass, FutureIncompatibilityReason}; | |
| 13 | ||
| 13 | 14 | declare_lint_pass! { |
| 14 | 15 | /// Does nothing as a lint pass, but registers some `Lint`s |
| 15 | 16 | /// that are used by other parts of the compiler. |
compiler/rustc_lint_defs/src/lib.rs+5-6| ... | ... | @@ -1,4 +1,3 @@ |
| 1 | pub use self::Level::*; | |
| 2 | 1 | use rustc_ast::node_id::NodeId; |
| 3 | 2 | use rustc_ast::{AttrId, Attribute}; |
| 4 | 3 | use rustc_data_structures::fx::{FxIndexMap, FxIndexSet}; |
| ... | ... | @@ -7,16 +6,16 @@ use rustc_data_structures::stable_hasher::{ |
| 7 | 6 | }; |
| 8 | 7 | use rustc_error_messages::{DiagMessage, MultiSpan}; |
| 9 | 8 | use rustc_hir::def::Namespace; |
| 10 | use rustc_hir::HashStableContext; | |
| 11 | use rustc_hir::HirId; | |
| 9 | use rustc_hir::{HashStableContext, HirId}; | |
| 12 | 10 | use rustc_macros::{Decodable, Encodable, HashStable_Generic}; |
| 13 | 11 | use rustc_span::edition::Edition; |
| 14 | use rustc_span::symbol::MacroRulesNormalizedIdent; | |
| 15 | use rustc_span::{sym, symbol::Ident, Span, Symbol}; | |
| 12 | use rustc_span::symbol::{Ident, MacroRulesNormalizedIdent}; | |
| 13 | use rustc_span::{sym, Span, Symbol}; | |
| 16 | 14 | use rustc_target::spec::abi::Abi; |
| 17 | ||
| 18 | 15 | use serde::{Deserialize, Serialize}; |
| 19 | 16 | |
| 17 | pub use self::Level::*; | |
| 18 | ||
| 20 | 19 | pub mod builtin; |
| 21 | 20 | |
| 22 | 21 | #[macro_export] |
compiler/rustc_llvm/src/lib.rs+2-1| ... | ... | @@ -7,10 +7,11 @@ |
| 7 | 7 | |
| 8 | 8 | // NOTE: This crate only exists to allow linking on mingw targets. |
| 9 | 9 | |
| 10 | use libc::{c_char, size_t}; | |
| 11 | 10 | use std::cell::RefCell; |
| 12 | 11 | use std::slice; |
| 13 | 12 | |
| 13 | use libc::{c_char, size_t}; | |
| 14 | ||
| 14 | 15 | #[repr(C)] |
| 15 | 16 | pub struct RustString { |
| 16 | 17 | pub bytes: RefCell<Vec<u8>>, |
compiler/rustc_log/src/lib.rs+3-4| ... | ... | @@ -41,12 +41,11 @@ |
| 41 | 41 | use std::env::{self, VarError}; |
| 42 | 42 | use std::fmt::{self, Display}; |
| 43 | 43 | use std::io::{self, IsTerminal}; |
| 44 | ||
| 44 | 45 | use tracing_core::{Event, Subscriber}; |
| 45 | 46 | use tracing_subscriber::filter::{Directive, EnvFilter, LevelFilter}; |
| 46 | use tracing_subscriber::fmt::{ | |
| 47 | format::{self, FormatEvent, FormatFields}, | |
| 48 | FmtContext, | |
| 49 | }; | |
| 47 | use tracing_subscriber::fmt::format::{self, FormatEvent, FormatFields}; | |
| 48 | use tracing_subscriber::fmt::FmtContext; | |
| 50 | 49 | use tracing_subscriber::layer::SubscriberExt; |
| 51 | 50 | |
| 52 | 51 | /// The values of all the environment variables that matter for configuring a logger. |
compiler/rustc_macros/src/diagnostics/diagnostic.rs+4-3| ... | ... | @@ -2,14 +2,15 @@ |
| 2 | 2 | |
| 3 | 3 | use std::cell::RefCell; |
| 4 | 4 | |
| 5 | use crate::diagnostics::diagnostic_builder::DiagnosticDeriveKind; | |
| 6 | use crate::diagnostics::error::{span_err, DiagnosticDeriveError}; | |
| 7 | use crate::diagnostics::utils::SetOnce; | |
| 8 | 5 | use proc_macro2::TokenStream; |
| 9 | 6 | use quote::quote; |
| 10 | 7 | use syn::spanned::Spanned; |
| 11 | 8 | use synstructure::Structure; |
| 12 | 9 | |
| 10 | use crate::diagnostics::diagnostic_builder::DiagnosticDeriveKind; | |
| 11 | use crate::diagnostics::error::{span_err, DiagnosticDeriveError}; | |
| 12 | use crate::diagnostics::utils::SetOnce; | |
| 13 | ||
| 13 | 14 | /// The central struct for constructing the `into_diag` method from an annotated struct. |
| 14 | 15 | pub(crate) struct DiagnosticDerive<'a> { |
| 15 | 16 | structure: Structure<'a>, |
compiler/rustc_macros/src/diagnostics/diagnostic_builder.rs+7-7| ... | ... | @@ -1,5 +1,12 @@ |
| 1 | 1 | #![deny(unused_must_use)] |
| 2 | 2 | |
| 3 | use proc_macro2::{Ident, Span, TokenStream}; | |
| 4 | use quote::{format_ident, quote, quote_spanned}; | |
| 5 | use syn::spanned::Spanned; | |
| 6 | use syn::{parse_quote, Attribute, Meta, Path, Token, Type}; | |
| 7 | use synstructure::{BindingInfo, Structure, VariantInfo}; | |
| 8 | ||
| 9 | use super::utils::SubdiagnosticVariant; | |
| 3 | 10 | use crate::diagnostics::error::{ |
| 4 | 11 | span_err, throw_invalid_attr, throw_span_err, DiagnosticDeriveError, |
| 5 | 12 | }; |
| ... | ... | @@ -8,13 +15,6 @@ use crate::diagnostics::utils::{ |
| 8 | 15 | should_generate_arg, type_is_bool, type_is_unit, type_matches_path, FieldInfo, FieldInnerTy, |
| 9 | 16 | FieldMap, HasFieldMap, SetOnce, SpannedOption, SubdiagnosticKind, |
| 10 | 17 | }; |
| 11 | use proc_macro2::{Ident, Span, TokenStream}; | |
| 12 | use quote::{format_ident, quote, quote_spanned}; | |
| 13 | use syn::Token; | |
| 14 | use syn::{parse_quote, spanned::Spanned, Attribute, Meta, Path, Type}; | |
| 15 | use synstructure::{BindingInfo, Structure, VariantInfo}; | |
| 16 | ||
| 17 | use super::utils::SubdiagnosticVariant; | |
| 18 | 18 | |
| 19 | 19 | /// What kind of diagnostic is being derived - a fatal/error/warning or a lint? |
| 20 | 20 | #[derive(Clone, Copy, PartialEq, Eq)] |
compiler/rustc_macros/src/diagnostics/error.rs+2-1| ... | ... | @@ -1,7 +1,8 @@ |
| 1 | 1 | use proc_macro::{Diagnostic, Level, MultiSpan}; |
| 2 | 2 | use proc_macro2::TokenStream; |
| 3 | 3 | use quote::quote; |
| 4 | use syn::{spanned::Spanned, Attribute, Error as SynError, Meta}; | |
| 4 | use syn::spanned::Spanned; | |
| 5 | use syn::{Attribute, Error as SynError, Meta}; | |
| 5 | 6 | |
| 6 | 7 | #[derive(Debug)] |
| 7 | 8 | pub(crate) enum DiagnosticDeriveError { |
compiler/rustc_macros/src/diagnostics/subdiagnostic.rs+7-6| ... | ... | @@ -1,5 +1,12 @@ |
| 1 | 1 | #![deny(unused_must_use)] |
| 2 | 2 | |
| 3 | use proc_macro2::TokenStream; | |
| 4 | use quote::{format_ident, quote}; | |
| 5 | use syn::spanned::Spanned; | |
| 6 | use syn::{Attribute, Meta, MetaList, Path}; | |
| 7 | use synstructure::{BindingInfo, Structure, VariantInfo}; | |
| 8 | ||
| 9 | use super::utils::SubdiagnosticVariant; | |
| 3 | 10 | use crate::diagnostics::error::{ |
| 4 | 11 | invalid_attr, span_err, throw_invalid_attr, throw_span_err, DiagnosticDeriveError, |
| 5 | 12 | }; |
| ... | ... | @@ -9,12 +16,6 @@ use crate::diagnostics::utils::{ |
| 9 | 16 | should_generate_arg, AllowMultipleAlternatives, FieldInfo, FieldInnerTy, FieldMap, HasFieldMap, |
| 10 | 17 | SetOnce, SpannedOption, SubdiagnosticKind, |
| 11 | 18 | }; |
| 12 | use proc_macro2::TokenStream; | |
| 13 | use quote::{format_ident, quote}; | |
| 14 | use syn::{spanned::Spanned, Attribute, Meta, MetaList, Path}; | |
| 15 | use synstructure::{BindingInfo, Structure, VariantInfo}; | |
| 16 | ||
| 17 | use super::utils::SubdiagnosticVariant; | |
| 18 | 19 | |
| 19 | 20 | /// The central struct for constructing the `add_to_diag` method from an annotated struct. |
| 20 | 21 | pub(crate) struct SubdiagnosticDerive { |
compiler/rustc_macros/src/diagnostics/utils.rs+9-8| ... | ... | @@ -1,20 +1,21 @@ |
| 1 | use crate::diagnostics::error::{ | |
| 2 | span_err, throw_invalid_attr, throw_span_err, DiagnosticDeriveError, | |
| 3 | }; | |
| 4 | use proc_macro::Span; | |
| 5 | use proc_macro2::{Ident, TokenStream}; | |
| 6 | use quote::{format_ident, quote, ToTokens}; | |
| 7 | 1 | use std::cell::RefCell; |
| 8 | 2 | use std::collections::{BTreeSet, HashMap}; |
| 9 | 3 | use std::fmt; |
| 10 | 4 | use std::str::FromStr; |
| 5 | ||
| 6 | use proc_macro::Span; | |
| 7 | use proc_macro2::{Ident, TokenStream}; | |
| 8 | use quote::{format_ident, quote, ToTokens}; | |
| 11 | 9 | use syn::meta::ParseNestedMeta; |
| 12 | 10 | use syn::punctuated::Punctuated; |
| 13 | use syn::{parenthesized, LitStr, Path, Token}; | |
| 14 | use syn::{spanned::Spanned, Attribute, Field, Meta, Type, TypeTuple}; | |
| 11 | use syn::spanned::Spanned; | |
| 12 | use syn::{parenthesized, Attribute, Field, LitStr, Meta, Path, Token, Type, TypeTuple}; | |
| 15 | 13 | use synstructure::{BindingInfo, VariantInfo}; |
| 16 | 14 | |
| 17 | 15 | use super::error::invalid_attr; |
| 16 | use crate::diagnostics::error::{ | |
| 17 | span_err, throw_invalid_attr, throw_span_err, DiagnosticDeriveError, | |
| 18 | }; | |
| 18 | 19 | |
| 19 | 20 | thread_local! { |
| 20 | 21 | pub(crate) static CODE_IDENT_COUNT: RefCell<u32> = RefCell::new(0); |
compiler/rustc_macros/src/lib.rs+1-2| ... | ... | @@ -10,9 +10,8 @@ |
| 10 | 10 | #![feature(proc_macro_tracked_env)] |
| 11 | 11 | // tidy-alphabetical-end |
| 12 | 12 | |
| 13 | use synstructure::decl_derive; | |
| 14 | ||
| 15 | 13 | use proc_macro::TokenStream; |
| 14 | use synstructure::decl_derive; | |
| 16 | 15 | |
| 17 | 16 | mod current_version; |
| 18 | 17 | mod diagnostics; |
compiler/rustc_macros/src/symbols.rs+4-2| ... | ... | @@ -24,11 +24,13 @@ |
| 24 | 24 | //! CFG_RELEASE="0.0.0" cargo +nightly expand > /tmp/rustc_span.rs |
| 25 | 25 | //! ``` |
| 26 | 26 | |
| 27 | use std::collections::HashMap; | |
| 28 | ||
| 27 | 29 | use proc_macro2::{Span, TokenStream}; |
| 28 | 30 | use quote::quote; |
| 29 | use std::collections::HashMap; | |
| 30 | 31 | use syn::parse::{Parse, ParseStream, Result}; |
| 31 | use syn::{braced, punctuated::Punctuated, Expr, Ident, Lit, LitStr, Macro, Token}; | |
| 32 | use syn::punctuated::Punctuated; | |
| 33 | use syn::{braced, Expr, Ident, Lit, LitStr, Macro, Token}; | |
| 32 | 34 | |
| 33 | 35 | #[cfg(test)] |
| 34 | 36 | mod tests; |
compiler/rustc_metadata/src/creader.rs+10-10| ... | ... | @@ -1,9 +1,13 @@ |
| 1 | 1 | //! Validates all used crates and extern libraries and loads their metadata |
| 2 | 2 | |
| 3 | use crate::errors; | |
| 4 | use crate::locator::{CrateError, CrateLocator, CratePaths}; | |
| 5 | use crate::rmeta::{CrateDep, CrateMetadata, CrateNumMap, CrateRoot, MetadataBlob}; | |
| 3 | use std::error::Error; | |
| 4 | use std::ops::Fn; | |
| 5 | use std::path::Path; | |
| 6 | use std::str::FromStr; | |
| 7 | use std::time::Duration; | |
| 8 | use std::{cmp, env, iter}; | |
| 6 | 9 | |
| 10 | use proc_macro::bridge::client::ProcMacro; | |
| 7 | 11 | use rustc_ast::expand::allocator::{alloc_error_handler_name, global_fn_name, AllocatorKind}; |
| 8 | 12 | use rustc_ast::{self as ast, *}; |
| 9 | 13 | use rustc_data_structures::fx::FxHashSet; |
| ... | ... | @@ -29,13 +33,9 @@ use rustc_span::{Span, DUMMY_SP}; |
| 29 | 33 | use rustc_target::spec::{PanicStrategy, Target, TargetTriple}; |
| 30 | 34 | use tracing::{debug, info, trace}; |
| 31 | 35 | |
| 32 | use proc_macro::bridge::client::ProcMacro; | |
| 33 | use std::error::Error; | |
| 34 | use std::ops::Fn; | |
| 35 | use std::path::Path; | |
| 36 | use std::str::FromStr; | |
| 37 | use std::time::Duration; | |
| 38 | use std::{cmp, env, iter}; | |
| 36 | use crate::errors; | |
| 37 | use crate::locator::{CrateError, CrateLocator, CratePaths}; | |
| 38 | use crate::rmeta::{CrateDep, CrateMetadata, CrateNumMap, CrateRoot, MetadataBlob}; | |
| 39 | 39 | |
| 40 | 40 | /// The backend's way to give the crate store access to the metadata in a library. |
| 41 | 41 | /// Note that it returns the raw metadata bytes stored in the library file, whether |
compiler/rustc_metadata/src/dependency_format.rs+6-6| ... | ... | @@ -51,12 +51,6 @@ |
| 51 | 51 | //! Additionally, the algorithm is geared towards finding *any* solution rather |
| 52 | 52 | //! than finding a number of solutions (there are normally quite a few). |
| 53 | 53 | |
| 54 | use crate::creader::CStore; | |
| 55 | use crate::errors::{ | |
| 56 | BadPanicStrategy, CrateDepMultiple, IncompatiblePanicInDropStrategy, LibRequired, | |
| 57 | NonStaticCrateDep, RequiredPanicStrategy, RlibRequired, RustcLibRequired, TwoPanicRuntimes, | |
| 58 | }; | |
| 59 | ||
| 60 | 54 | use rustc_data_structures::fx::FxHashMap; |
| 61 | 55 | use rustc_hir::def_id::CrateNum; |
| 62 | 56 | use rustc_middle::bug; |
| ... | ... | @@ -67,6 +61,12 @@ use rustc_session::cstore::CrateDepKind; |
| 67 | 61 | use rustc_session::cstore::LinkagePreference::{self, RequireDynamic, RequireStatic}; |
| 68 | 62 | use tracing::info; |
| 69 | 63 | |
| 64 | use crate::creader::CStore; | |
| 65 | use crate::errors::{ | |
| 66 | BadPanicStrategy, CrateDepMultiple, IncompatiblePanicInDropStrategy, LibRequired, | |
| 67 | NonStaticCrateDep, RequiredPanicStrategy, RlibRequired, RustcLibRequired, TwoPanicRuntimes, | |
| 68 | }; | |
| 69 | ||
| 70 | 70 | pub(crate) fn calculate(tcx: TyCtxt<'_>) -> Dependencies { |
| 71 | 71 | tcx.crate_types() |
| 72 | 72 | .iter() |
compiler/rustc_metadata/src/errors.rs+4-5| ... | ... | @@ -1,9 +1,8 @@ |
| 1 | use std::{ | |
| 2 | io::Error, | |
| 3 | path::{Path, PathBuf}, | |
| 4 | }; | |
| 1 | use std::io::Error; | |
| 2 | use std::path::{Path, PathBuf}; | |
| 5 | 3 | |
| 6 | use rustc_errors::{codes::*, Diag, DiagCtxtHandle, Diagnostic, EmissionGuarantee, Level}; | |
| 4 | use rustc_errors::codes::*; | |
| 5 | use rustc_errors::{Diag, DiagCtxtHandle, Diagnostic, EmissionGuarantee, Level}; | |
| 7 | 6 | use rustc_macros::{Diagnostic, Subdiagnostic}; |
| 8 | 7 | use rustc_span::{sym, Span, Symbol}; |
| 9 | 8 | use rustc_target::spec::{PanicStrategy, TargetTriple}; |
compiler/rustc_metadata/src/fs.rs+7-7| ... | ... | @@ -1,8 +1,5 @@ |
| 1 | use crate::errors::{ | |
| 2 | BinaryOutputToTty, FailedCopyToStdout, FailedCreateEncodedMetadata, FailedCreateFile, | |
| 3 | FailedCreateTempdir, FailedWriteError, | |
| 4 | }; | |
| 5 | use crate::{encode_metadata, EncodedMetadata}; | |
| 1 | use std::path::{Path, PathBuf}; | |
| 2 | use std::{fs, io}; | |
| 6 | 3 | |
| 7 | 4 | use rustc_data_structures::temp_dir::MaybeTempDir; |
| 8 | 5 | use rustc_middle::ty::TyCtxt; |
| ... | ... | @@ -11,8 +8,11 @@ use rustc_session::output::filename_for_metadata; |
| 11 | 8 | use rustc_session::{MetadataKind, Session}; |
| 12 | 9 | use tempfile::Builder as TempFileBuilder; |
| 13 | 10 | |
| 14 | use std::path::{Path, PathBuf}; | |
| 15 | use std::{fs, io}; | |
| 11 | use crate::errors::{ | |
| 12 | BinaryOutputToTty, FailedCopyToStdout, FailedCreateEncodedMetadata, FailedCreateFile, | |
| 13 | FailedCreateTempdir, FailedWriteError, | |
| 14 | }; | |
| 15 | use crate::{encode_metadata, EncodedMetadata}; | |
| 16 | 16 | |
| 17 | 17 | // FIXME(eddyb) maybe include the crate name in this? |
| 18 | 18 | pub const METADATA_FILENAME: &str = "lib.rmeta"; |
compiler/rustc_metadata/src/locator.rs+9-9| ... | ... | @@ -212,9 +212,11 @@ |
| 212 | 212 | //! no means all of the necessary details. Take a look at the rest of |
| 213 | 213 | //! metadata::locator or metadata::creader for all the juicy details! |
| 214 | 214 | |
| 215 | use crate::creader::{Library, MetadataLoader}; | |
| 216 | use crate::errors; | |
| 217 | use crate::rmeta::{rustc_version, MetadataBlob, METADATA_HEADER}; | |
| 215 | use std::borrow::Cow; | |
| 216 | use std::io::{Read, Result as IoResult, Write}; | |
| 217 | use std::ops::Deref; | |
| 218 | use std::path::{Path, PathBuf}; | |
| 219 | use std::{cmp, fmt}; | |
| 218 | 220 | |
| 219 | 221 | use rustc_data_structures::fx::{FxHashMap, FxHashSet}; |
| 220 | 222 | use rustc_data_structures::memmap::Mmap; |
| ... | ... | @@ -230,14 +232,12 @@ use rustc_session::Session; |
| 230 | 232 | use rustc_span::symbol::Symbol; |
| 231 | 233 | use rustc_span::Span; |
| 232 | 234 | use rustc_target::spec::{Target, TargetTriple}; |
| 235 | use snap::read::FrameDecoder; | |
| 233 | 236 | use tracing::{debug, info}; |
| 234 | 237 | |
| 235 | use snap::read::FrameDecoder; | |
| 236 | use std::borrow::Cow; | |
| 237 | use std::io::{Read, Result as IoResult, Write}; | |
| 238 | use std::ops::Deref; | |
| 239 | use std::path::{Path, PathBuf}; | |
| 240 | use std::{cmp, fmt}; | |
| 238 | use crate::creader::{Library, MetadataLoader}; | |
| 239 | use crate::errors; | |
| 240 | use crate::rmeta::{rustc_version, MetadataBlob, METADATA_HEADER}; | |
| 241 | 241 | |
| 242 | 242 | #[derive(Clone)] |
| 243 | 243 | pub(crate) struct CrateLocator<'a> { |
compiler/rustc_metadata/src/native_libs.rs+2-2| ... | ... | @@ -1,3 +1,5 @@ |
| 1 | use std::path::PathBuf; | |
| 2 | ||
| 1 | 3 | use rustc_ast::{NestedMetaItem, CRATE_NODE_ID}; |
| 2 | 4 | use rustc_attr as attr; |
| 3 | 5 | use rustc_data_structures::fx::FxHashSet; |
| ... | ... | @@ -17,8 +19,6 @@ use rustc_target::spec::abi::Abi; |
| 17 | 19 | |
| 18 | 20 | use crate::errors; |
| 19 | 21 | |
| 20 | use std::path::PathBuf; | |
| 21 | ||
| 22 | 22 | pub fn find_native_static_library(name: &str, verbatim: bool, sess: &Session) -> PathBuf { |
| 23 | 23 | let formats = if verbatim { |
| 24 | 24 | vec![("".into(), "".into())] |
compiler/rustc_metadata/src/rmeta/decoder.rs+9-10| ... | ... | @@ -1,9 +1,11 @@ |
| 1 | 1 | // Decoding metadata from a single crate's metadata |
| 2 | 2 | |
| 3 | use crate::creader::CStore; | |
| 4 | use crate::rmeta::table::IsDefault; | |
| 5 | use crate::rmeta::*; | |
| 3 | use std::iter::TrustedLen; | |
| 4 | use std::path::Path; | |
| 5 | use std::{io, iter, mem}; | |
| 6 | 6 | |
| 7 | pub(super) use cstore_impl::provide; | |
| 8 | use proc_macro::bridge::client::ProcMacro; | |
| 7 | 9 | use rustc_ast as ast; |
| 8 | 10 | use rustc_data_structures::captures::Captures; |
| 9 | 11 | use rustc_data_structures::fingerprint::Fingerprint; |
| ... | ... | @@ -27,17 +29,14 @@ use rustc_serialize::opaque::MemDecoder; |
| 27 | 29 | use rustc_serialize::{Decodable, Decoder}; |
| 28 | 30 | use rustc_session::cstore::{CrateSource, ExternCrate}; |
| 29 | 31 | use rustc_session::Session; |
| 32 | use rustc_span::hygiene::HygieneDecodeContext; | |
| 30 | 33 | use rustc_span::symbol::kw; |
| 31 | 34 | use rustc_span::{BytePos, Pos, SpanData, SpanDecoder, SyntaxContext, DUMMY_SP}; |
| 32 | 35 | use tracing::debug; |
| 33 | 36 | |
| 34 | use proc_macro::bridge::client::ProcMacro; | |
| 35 | use std::iter::TrustedLen; | |
| 36 | use std::path::Path; | |
| 37 | use std::{io, iter, mem}; | |
| 38 | ||
| 39 | pub(super) use cstore_impl::provide; | |
| 40 | use rustc_span::hygiene::HygieneDecodeContext; | |
| 37 | use crate::creader::CStore; | |
| 38 | use crate::rmeta::table::IsDefault; | |
| 39 | use crate::rmeta::*; | |
| 41 | 40 | |
| 42 | 41 | mod cstore_impl; |
| 43 | 42 |
compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs+7-10| ... | ... | @@ -1,8 +1,5 @@ |
| 1 | use crate::creader::{CStore, LoadedMacro}; | |
| 2 | use crate::foreign_modules; | |
| 3 | use crate::native_libs; | |
| 4 | use crate::rmeta::table::IsDefault; | |
| 5 | use crate::rmeta::AttrFlags; | |
| 1 | use std::any::Any; | |
| 2 | use std::mem; | |
| 6 | 3 | |
| 7 | 4 | use rustc_ast as ast; |
| 8 | 5 | use rustc_attr::Deprecation; |
| ... | ... | @@ -15,8 +12,7 @@ use rustc_middle::bug; |
| 15 | 12 | use rustc_middle::metadata::ModChild; |
| 16 | 13 | use rustc_middle::middle::exported_symbols::ExportedSymbol; |
| 17 | 14 | use rustc_middle::middle::stability::DeprecationEntry; |
| 18 | use rustc_middle::query::ExternProviders; | |
| 19 | use rustc_middle::query::LocalCrate; | |
| 15 | use rustc_middle::query::{ExternProviders, LocalCrate}; | |
| 20 | 16 | use rustc_middle::ty::fast_reject::SimplifiedType; |
| 21 | 17 | use rustc_middle::ty::{self, TyCtxt}; |
| 22 | 18 | use rustc_middle::util::Providers; |
| ... | ... | @@ -26,10 +22,11 @@ use rustc_span::hygiene::ExpnId; |
| 26 | 22 | use rustc_span::symbol::{kw, Symbol}; |
| 27 | 23 | use rustc_span::Span; |
| 28 | 24 | |
| 29 | use std::any::Any; | |
| 30 | use std::mem; | |
| 31 | ||
| 32 | 25 | use super::{Decodable, DecodeContext, DecodeIterator}; |
| 26 | use crate::creader::{CStore, LoadedMacro}; | |
| 27 | use crate::rmeta::table::IsDefault; | |
| 28 | use crate::rmeta::AttrFlags; | |
| 29 | use crate::{foreign_modules, native_libs}; | |
| 33 | 30 | |
| 34 | 31 | trait ProcessQueryValue<'tcx, T> { |
| 35 | 32 | fn process_decoded(self, _tcx: TyCtxt<'tcx>, _err: impl Fn() -> !) -> T; |
compiler/rustc_metadata/src/rmeta/def_path_hash_map.rs+2-2| ... | ... | @@ -1,11 +1,11 @@ |
| 1 | use crate::rmeta::DecodeContext; | |
| 2 | use crate::rmeta::EncodeContext; | |
| 3 | 1 | use rustc_data_structures::owned_slice::OwnedSlice; |
| 4 | 2 | use rustc_hir::def_path_hash_map::{Config as HashMapConfig, DefPathHashMap}; |
| 5 | 3 | use rustc_middle::parameterized_over_tcx; |
| 6 | 4 | use rustc_serialize::{Decodable, Decoder, Encodable, Encoder}; |
| 7 | 5 | use rustc_span::def_id::{DefIndex, DefPathHash}; |
| 8 | 6 | |
| 7 | use crate::rmeta::{DecodeContext, EncodeContext}; | |
| 8 | ||
| 9 | 9 | pub(crate) enum DefPathHashMapRef<'tcx> { |
| 10 | 10 | OwnedFromMetadata(odht::HashTable<HashMapConfig, OwnedSlice>), |
| 11 | 11 | BorrowedFromTcx(&'tcx DefPathHashMap), |
compiler/rustc_metadata/src/rmeta/encoder.rs+8-7| ... | ... | @@ -1,5 +1,8 @@ |
| 1 | use crate::errors::{FailCreateFileEncoder, FailWriteFile}; | |
| 2 | use crate::rmeta::*; | |
| 1 | use std::borrow::Borrow; | |
| 2 | use std::collections::hash_map::Entry; | |
| 3 | use std::fs::File; | |
| 4 | use std::io::{Read, Seek, Write}; | |
| 5 | use std::path::{Path, PathBuf}; | |
| 3 | 6 | |
| 4 | 7 | use rustc_ast::Attribute; |
| 5 | 8 | use rustc_data_structures::fx::{FxIndexMap, FxIndexSet}; |
| ... | ... | @@ -27,13 +30,11 @@ use rustc_span::symbol::sym; |
| 27 | 30 | use rustc_span::{ |
| 28 | 31 | ExternalSource, FileName, SourceFile, SpanData, SpanEncoder, StableSourceFileId, SyntaxContext, |
| 29 | 32 | }; |
| 30 | use std::borrow::Borrow; | |
| 31 | use std::collections::hash_map::Entry; | |
| 32 | use std::fs::File; | |
| 33 | use std::io::{Read, Seek, Write}; | |
| 34 | use std::path::{Path, PathBuf}; | |
| 35 | 33 | use tracing::{debug, instrument, trace}; |
| 36 | 34 | |
| 35 | use crate::errors::{FailCreateFileEncoder, FailWriteFile}; | |
| 36 | use crate::rmeta::*; | |
| 37 | ||
| 37 | 38 | pub(super) struct EncodeContext<'a, 'tcx> { |
| 38 | 39 | opaque: opaque::FileEncoder, |
| 39 | 40 | tcx: TyCtxt<'tcx>, |
compiler/rustc_metadata/src/rmeta/mod.rs+13-12| ... | ... | @@ -1,35 +1,35 @@ |
| 1 | use crate::creader::CrateMetadataRef; | |
| 1 | use std::marker::PhantomData; | |
| 2 | use std::num::NonZero; | |
| 3 | ||
| 2 | 4 | pub(crate) use decoder::{CrateMetadata, CrateNumMap, MetadataBlob}; |
| 3 | 5 | use decoder::{DecodeContext, Metadata}; |
| 4 | 6 | use def_path_hash_map::DefPathHashMapRef; |
| 5 | 7 | use encoder::EncodeContext; |
| 6 | 8 | pub use encoder::{encode_metadata, rendered_const, EncodedMetadata}; |
| 7 | use rustc_ast as ast; | |
| 8 | 9 | use rustc_ast::expand::StrippedCfgItem; |
| 9 | use rustc_attr as attr; | |
| 10 | 10 | use rustc_data_structures::fx::FxHashMap; |
| 11 | 11 | use rustc_data_structures::svh::Svh; |
| 12 | use rustc_hir as hir; | |
| 13 | 12 | use rustc_hir::def::{CtorKind, DefKind, DocLinkResMap}; |
| 14 | 13 | use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, DefIndex, DefPathHash, StableCrateId}; |
| 15 | 14 | use rustc_hir::definitions::DefKey; |
| 16 | 15 | use rustc_hir::lang_items::LangItem; |
| 17 | 16 | use rustc_index::bit_set::BitSet; |
| 18 | 17 | use rustc_index::IndexVec; |
| 19 | use rustc_macros::{Decodable, Encodable, TyDecodable, TyEncodable}; | |
| 20 | use rustc_macros::{MetadataDecodable, MetadataEncodable}; | |
| 18 | use rustc_macros::{ | |
| 19 | Decodable, Encodable, MetadataDecodable, MetadataEncodable, TyDecodable, TyEncodable, | |
| 20 | }; | |
| 21 | 21 | use rustc_middle::metadata::ModChild; |
| 22 | 22 | use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrs; |
| 23 | 23 | use rustc_middle::middle::debugger_visualizer::DebuggerVisualizerFile; |
| 24 | 24 | use rustc_middle::middle::exported_symbols::{ExportedSymbol, SymbolExportInfo}; |
| 25 | 25 | use rustc_middle::middle::lib_features::FeatureStability; |
| 26 | 26 | use rustc_middle::middle::resolve_bound_vars::ObjectLifetimeDefault; |
| 27 | use rustc_middle::mir; | |
| 28 | use rustc_middle::trivially_parameterized_over_tcx; | |
| 29 | 27 | use rustc_middle::ty::fast_reject::SimplifiedType; |
| 30 | use rustc_middle::ty::{self, ReprOptions, Ty, UnusedGenericParams}; | |
| 31 | use rustc_middle::ty::{DeducedParamAttrs, ParameterizedOverTcx, TyCtxt}; | |
| 28 | use rustc_middle::ty::{ | |
| 29 | self, DeducedParamAttrs, ParameterizedOverTcx, ReprOptions, Ty, TyCtxt, UnusedGenericParams, | |
| 30 | }; | |
| 32 | 31 | use rustc_middle::util::Providers; |
| 32 | use rustc_middle::{mir, trivially_parameterized_over_tcx}; | |
| 33 | 33 | use rustc_serialize::opaque::FileEncoder; |
| 34 | 34 | use rustc_session::config::SymbolManglingVersion; |
| 35 | 35 | use rustc_session::cstore::{CrateDepKind, ForeignModule, LinkagePreference, NativeLib}; |
| ... | ... | @@ -39,9 +39,10 @@ use rustc_span::symbol::{Ident, Symbol}; |
| 39 | 39 | use rustc_span::{self, ExpnData, ExpnHash, ExpnId, Span}; |
| 40 | 40 | use rustc_target::abi::{FieldIdx, VariantIdx}; |
| 41 | 41 | use rustc_target::spec::{PanicStrategy, TargetTriple}; |
| 42 | use std::marker::PhantomData; | |
| 43 | use std::num::NonZero; | |
| 44 | 42 | use table::TableBuilder; |
| 43 | use {rustc_ast as ast, rustc_attr as attr, rustc_hir as hir}; | |
| 44 | ||
| 45 | use crate::creader::CrateMetadataRef; | |
| 45 | 46 | |
| 46 | 47 | mod decoder; |
| 47 | 48 | mod def_path_hash_map; |
compiler/rustc_metadata/src/rmeta/table.rs+2-2| ... | ... | @@ -1,9 +1,9 @@ |
| 1 | use crate::rmeta::*; | |
| 2 | ||
| 3 | 1 | use rustc_hir::def::CtorOf; |
| 4 | 2 | use rustc_index::Idx; |
| 5 | 3 | use tracing::trace; |
| 6 | 4 | |
| 5 | use crate::rmeta::*; | |
| 6 | ||
| 7 | 7 | pub(super) trait IsDefault: Default { |
| 8 | 8 | fn is_default(&self) -> bool; |
| 9 | 9 | } |
compiler/rustc_middle/src/dep_graph/dep_node.rs+4-5| ... | ... | @@ -56,18 +56,17 @@ |
| 56 | 56 | //! |
| 57 | 57 | //! [dependency graph]: https://rustc-dev-guide.rust-lang.org/query.html |
| 58 | 58 | |
| 59 | use crate::mir::mono::MonoItem; | |
| 60 | use crate::ty::TyCtxt; | |
| 61 | ||
| 62 | 59 | use rustc_data_structures::fingerprint::Fingerprint; |
| 63 | 60 | use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, LocalModDefId, ModDefId, LOCAL_CRATE}; |
| 64 | 61 | use rustc_hir::definitions::DefPathHash; |
| 65 | 62 | use rustc_hir::{HirId, ItemLocalId, OwnerId}; |
| 63 | pub use rustc_query_system::dep_graph::dep_node::DepKind; | |
| 66 | 64 | use rustc_query_system::dep_graph::FingerprintStyle; |
| 65 | pub use rustc_query_system::dep_graph::{DepContext, DepNode, DepNodeParams}; | |
| 67 | 66 | use rustc_span::symbol::Symbol; |
| 68 | 67 | |
| 69 | pub use rustc_query_system::dep_graph::dep_node::DepKind; | |
| 70 | pub use rustc_query_system::dep_graph::{DepContext, DepNode, DepNodeParams}; | |
| 68 | use crate::mir::mono::MonoItem; | |
| 69 | use crate::ty::TyCtxt; | |
| 71 | 70 | |
| 72 | 71 | macro_rules! define_dep_nodes { |
| 73 | 72 | ( |
compiler/rustc_middle/src/dep_graph/mod.rs+7-8| ... | ... | @@ -1,20 +1,19 @@ |
| 1 | use crate::ty::{self, TyCtxt}; | |
| 2 | 1 | use rustc_data_structures::profiling::SelfProfilerRef; |
| 3 | 2 | use rustc_query_system::ich::StableHashingContext; |
| 4 | 3 | use rustc_session::Session; |
| 5 | 4 | |
| 5 | use crate::ty::{self, TyCtxt}; | |
| 6 | ||
| 6 | 7 | #[macro_use] |
| 7 | 8 | mod dep_node; |
| 8 | 9 | |
| 9 | pub use rustc_query_system::dep_graph::debug::EdgeFilter; | |
| 10 | pub use rustc_query_system::dep_graph::{ | |
| 11 | debug::DepNodeFilter, hash_result, DepContext, DepGraphQuery, DepNodeIndex, Deps, | |
| 12 | SerializedDepGraph, SerializedDepNodeIndex, TaskDepsRef, WorkProduct, WorkProductId, | |
| 13 | WorkProductMap, | |
| 14 | }; | |
| 15 | ||
| 16 | 10 | pub use dep_node::{dep_kinds, label_strs, DepKind, DepNode, DepNodeExt}; |
| 17 | 11 | pub(crate) use dep_node::{make_compile_codegen_unit, make_compile_mono_item}; |
| 12 | pub use rustc_query_system::dep_graph::debug::{DepNodeFilter, EdgeFilter}; | |
| 13 | pub use rustc_query_system::dep_graph::{ | |
| 14 | hash_result, DepContext, DepGraphQuery, DepNodeIndex, Deps, SerializedDepGraph, | |
| 15 | SerializedDepNodeIndex, TaskDepsRef, WorkProduct, WorkProductId, WorkProductMap, | |
| 16 | }; | |
| 18 | 17 | |
| 19 | 18 | pub type DepGraph = rustc_query_system::dep_graph::DepGraph<DepsType>; |
| 20 | 19 |
compiler/rustc_middle/src/error.rs+2-1| ... | ... | @@ -1,7 +1,8 @@ |
| 1 | 1 | use std::fmt; |
| 2 | 2 | use std::path::PathBuf; |
| 3 | 3 | |
| 4 | use rustc_errors::{codes::*, DiagArgName, DiagArgValue, DiagMessage}; | |
| 4 | use rustc_errors::codes::*; | |
| 5 | use rustc_errors::{DiagArgName, DiagArgValue, DiagMessage}; | |
| 5 | 6 | use rustc_macros::{Diagnostic, Subdiagnostic}; |
| 6 | 7 | use rustc_span::{Span, Symbol}; |
| 7 | 8 |
compiler/rustc_middle/src/hir/map/mod.rs+6-6| ... | ... | @@ -1,8 +1,3 @@ |
| 1 | use crate::hir::ModuleItems; | |
| 2 | use crate::middle::debugger_visualizer::DebuggerVisualizerFile; | |
| 3 | use crate::query::LocalCrate; | |
| 4 | use crate::ty::TyCtxt; | |
| 5 | use rustc_ast as ast; | |
| 6 | 1 | use rustc_ast::visit::{walk_list, VisitorResult}; |
| 7 | 2 | use rustc_data_structures::fingerprint::Fingerprint; |
| 8 | 3 | use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; |
| ... | ... | @@ -13,12 +8,17 @@ use rustc_hir::def_id::{DefId, LocalDefId, LocalModDefId, LOCAL_CRATE}; |
| 13 | 8 | use rustc_hir::definitions::{DefKey, DefPath, DefPathHash}; |
| 14 | 9 | use rustc_hir::intravisit::Visitor; |
| 15 | 10 | use rustc_hir::*; |
| 16 | use rustc_hir_pretty as pprust_hir; | |
| 17 | 11 | use rustc_middle::hir::nested_filter; |
| 18 | 12 | use rustc_span::def_id::StableCrateId; |
| 19 | 13 | use rustc_span::symbol::{kw, sym, Ident, Symbol}; |
| 20 | 14 | use rustc_span::{ErrorGuaranteed, Span}; |
| 21 | 15 | use rustc_target::spec::abi::Abi; |
| 16 | use {rustc_ast as ast, rustc_hir_pretty as pprust_hir}; | |
| 17 | ||
| 18 | use crate::hir::ModuleItems; | |
| 19 | use crate::middle::debugger_visualizer::DebuggerVisualizerFile; | |
| 20 | use crate::query::LocalCrate; | |
| 21 | use crate::ty::TyCtxt; | |
| 22 | 22 | |
| 23 | 23 | // FIXME: the structure was necessary in the past but now it |
| 24 | 24 | // only serves as "namespace" for HIR-related methods, and can be |
compiler/rustc_middle/src/hir/mod.rs+3-2| ... | ... | @@ -6,8 +6,6 @@ pub mod map; |
| 6 | 6 | pub mod nested_filter; |
| 7 | 7 | pub mod place; |
| 8 | 8 | |
| 9 | use crate::query::Providers; | |
| 10 | use crate::ty::{EarlyBinder, ImplSubject, TyCtxt}; | |
| 11 | 9 | use rustc_data_structures::fingerprint::Fingerprint; |
| 12 | 10 | use rustc_data_structures::sorted_map::SortedMap; |
| 13 | 11 | use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; |
| ... | ... | @@ -18,6 +16,9 @@ use rustc_hir::*; |
| 18 | 16 | use rustc_macros::{Decodable, Encodable, HashStable}; |
| 19 | 17 | use rustc_span::{ErrorGuaranteed, ExpnId}; |
| 20 | 18 | |
| 19 | use crate::query::Providers; | |
| 20 | use crate::ty::{EarlyBinder, ImplSubject, TyCtxt}; | |
| 21 | ||
| 21 | 22 | /// Gather the LocalDefId for each item-like within a module, including items contained within |
| 22 | 23 | /// bodies. The Ids are in visitor order. This is used to partition a pass between modules. |
| 23 | 24 | #[derive(Debug, HashStable, Encodable, Decodable)] |
compiler/rustc_middle/src/hir/place.rs+3-3| ... | ... | @@ -1,10 +1,10 @@ |
| 1 | use crate::ty; | |
| 2 | use crate::ty::Ty; | |
| 3 | ||
| 4 | 1 | use rustc_hir::HirId; |
| 5 | 2 | use rustc_macros::{HashStable, TyDecodable, TyEncodable, TypeFoldable, TypeVisitable}; |
| 6 | 3 | use rustc_target::abi::{FieldIdx, VariantIdx}; |
| 7 | 4 | |
| 5 | use crate::ty; | |
| 6 | use crate::ty::Ty; | |
| 7 | ||
| 8 | 8 | #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, TyEncodable, TyDecodable, HashStable)] |
| 9 | 9 | #[derive(TypeFoldable, TypeVisitable)] |
| 10 | 10 | pub enum PlaceBase { |
compiler/rustc_middle/src/hooks/mod.rs+4-3| ... | ... | @@ -3,15 +3,16 @@ |
| 3 | 3 | //! queries come with a lot of machinery for caching and incremental compilation, whereas hooks are |
| 4 | 4 | //! just plain function pointers without any of the query magic. |
| 5 | 5 | |
| 6 | use crate::mir; | |
| 7 | use crate::query::TyCtxtAt; | |
| 8 | use crate::ty::{Ty, TyCtxt}; | |
| 9 | 6 | use rustc_hir::def_id::{DefId, DefPathHash}; |
| 10 | 7 | use rustc_session::StableCrateId; |
| 11 | 8 | use rustc_span::def_id::{CrateNum, LocalDefId}; |
| 12 | 9 | use rustc_span::{ExpnHash, ExpnId, DUMMY_SP}; |
| 13 | 10 | use tracing::instrument; |
| 14 | 11 | |
| 12 | use crate::mir; | |
| 13 | use crate::query::TyCtxtAt; | |
| 14 | use crate::ty::{Ty, TyCtxt}; | |
| 15 | ||
| 15 | 16 | macro_rules! declare_hooks { |
| 16 | 17 | ($($(#[$attr:meta])*hook $name:ident($($arg:ident: $K:ty),*) -> $V:ty;)*) => { |
| 17 | 18 |
compiler/rustc_middle/src/infer/canonical.rs+3-3| ... | ... | @@ -21,18 +21,18 @@ |
| 21 | 21 | //! |
| 22 | 22 | //! [c]: https://rust-lang.github.io/chalk/book/canonical_queries/canonicalization.html |
| 23 | 23 | |
| 24 | use std::collections::hash_map::Entry; | |
| 25 | ||
| 24 | 26 | use rustc_data_structures::fx::FxHashMap; |
| 25 | 27 | use rustc_data_structures::sync::Lock; |
| 26 | 28 | use rustc_macros::{HashStable, TypeFoldable, TypeVisitable}; |
| 27 | 29 | pub use rustc_type_ir as ir; |
| 28 | 30 | pub use rustc_type_ir::{CanonicalTyVarKind, CanonicalVarKind}; |
| 29 | 31 | use smallvec::SmallVec; |
| 30 | use std::collections::hash_map::Entry; | |
| 31 | 32 | |
| 32 | 33 | use crate::infer::MemberConstraint; |
| 33 | 34 | use crate::mir::ConstraintCategory; |
| 34 | use crate::ty::GenericArg; | |
| 35 | use crate::ty::{self, List, Ty, TyCtxt, TypeFlags, TypeVisitableExt}; | |
| 35 | use crate::ty::{self, GenericArg, List, Ty, TyCtxt, TypeFlags, TypeVisitableExt}; | |
| 36 | 36 | |
| 37 | 37 | pub type Canonical<'tcx, V> = ir::Canonical<TyCtxt<'tcx>, V>; |
| 38 | 38 | pub type CanonicalVarInfo<'tcx> = ir::CanonicalVarInfo<TyCtxt<'tcx>>; |
compiler/rustc_middle/src/infer/mod.rs+2-2| ... | ... | @@ -1,12 +1,12 @@ |
| 1 | 1 | pub mod canonical; |
| 2 | 2 | pub mod unify_key; |
| 3 | 3 | |
| 4 | use crate::ty::Region; | |
| 5 | use crate::ty::{OpaqueTypeKey, Ty}; | |
| 6 | 4 | use rustc_data_structures::sync::Lrc; |
| 7 | 5 | use rustc_macros::{HashStable, TypeFoldable, TypeVisitable}; |
| 8 | 6 | use rustc_span::Span; |
| 9 | 7 | |
| 8 | use crate::ty::{OpaqueTypeKey, Region, Ty}; | |
| 9 | ||
| 10 | 10 | /// Requires that `region` must be equal to one of the regions in `choice_regions`. |
| 11 | 11 | /// We often denote this using the syntax: |
| 12 | 12 | /// |
compiler/rustc_middle/src/infer/unify_key.rs+5-3| ... | ... | @@ -1,9 +1,11 @@ |
| 1 | use crate::ty::{self, Ty, TyCtxt}; | |
| 1 | use std::cmp; | |
| 2 | use std::marker::PhantomData; | |
| 3 | ||
| 2 | 4 | use rustc_data_structures::unify::{NoError, UnifyKey, UnifyValue}; |
| 3 | 5 | use rustc_span::def_id::DefId; |
| 4 | 6 | use rustc_span::Span; |
| 5 | use std::cmp; | |
| 6 | use std::marker::PhantomData; | |
| 7 | ||
| 8 | use crate::ty::{self, Ty, TyCtxt}; | |
| 7 | 9 | |
| 8 | 10 | pub trait ToType { |
| 9 | 11 | fn to_type<'tcx>(&self, tcx: TyCtxt<'tcx>) -> Ty<'tcx>; |
compiler/rustc_middle/src/lint.rs+2-4| ... | ... | @@ -5,10 +5,8 @@ use rustc_data_structures::sorted_map::SortedMap; |
| 5 | 5 | use rustc_errors::{Diag, MultiSpan}; |
| 6 | 6 | use rustc_hir::{HirId, ItemLocalId}; |
| 7 | 7 | use rustc_macros::HashStable; |
| 8 | use rustc_session::lint::{ | |
| 9 | builtin::{self, FORBIDDEN_LINT_GROUPS}, | |
| 10 | FutureIncompatibilityReason, Level, Lint, LintId, | |
| 11 | }; | |
| 8 | use rustc_session::lint::builtin::{self, FORBIDDEN_LINT_GROUPS}; | |
| 9 | use rustc_session::lint::{FutureIncompatibilityReason, Level, Lint, LintId}; | |
| 12 | 10 | use rustc_session::Session; |
| 13 | 11 | use rustc_span::hygiene::{ExpnKind, MacroKind}; |
| 14 | 12 | use rustc_span::{symbol, DesugaringKind, Span, Symbol, DUMMY_SP}; |
compiler/rustc_middle/src/metadata.rs+2-2| ... | ... | @@ -1,11 +1,11 @@ |
| 1 | use crate::ty; | |
| 2 | ||
| 3 | 1 | use rustc_hir::def::Res; |
| 4 | 2 | use rustc_macros::{HashStable, TyDecodable, TyEncodable}; |
| 5 | 3 | use rustc_span::def_id::DefId; |
| 6 | 4 | use rustc_span::symbol::Ident; |
| 7 | 5 | use smallvec::SmallVec; |
| 8 | 6 | |
| 7 | use crate::ty; | |
| 8 | ||
| 9 | 9 | /// A simplified version of `ImportKind` from resolve. |
| 10 | 10 | /// `DefId`s here correspond to `use` and `extern crate` items themselves, not their targets. |
| 11 | 11 | #[derive(Clone, Copy, Debug, TyEncodable, TyDecodable, HashStable)] |
compiler/rustc_middle/src/middle/codegen_fn_attrs.rs+2-1| ... | ... | @@ -1,10 +1,11 @@ |
| 1 | use crate::mir::mono::Linkage; | |
| 2 | 1 | use rustc_attr::{InlineAttr, InstructionSetAttr, OptimizeAttr}; |
| 3 | 2 | use rustc_macros::{HashStable, TyDecodable, TyEncodable}; |
| 4 | 3 | use rustc_span::symbol::Symbol; |
| 5 | 4 | use rustc_target::abi::Align; |
| 6 | 5 | use rustc_target::spec::SanitizerSet; |
| 7 | 6 | |
| 7 | use crate::mir::mono::Linkage; | |
| 8 | ||
| 8 | 9 | #[derive(Clone, TyEncodable, TyDecodable, HashStable, Debug)] |
| 9 | 10 | pub struct CodegenFnAttrs { |
| 10 | 11 | pub flags: CodegenFnAttrFlags, |
compiler/rustc_middle/src/middle/debugger_visualizer.rs+2-1| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | use std::path::PathBuf; | |
| 2 | ||
| 1 | 3 | use rustc_data_structures::sync::Lrc; |
| 2 | 4 | use rustc_macros::{Decodable, Encodable, HashStable}; |
| 3 | use std::path::PathBuf; | |
| 4 | 5 | |
| 5 | 6 | #[derive(HashStable)] |
| 6 | 7 | #[derive(Copy, PartialEq, PartialOrd, Clone, Ord, Eq, Hash, Debug, Encodable, Decodable)] |
compiler/rustc_middle/src/middle/exported_symbols.rs+2-2| ... | ... | @@ -1,8 +1,8 @@ |
| 1 | use crate::ty::GenericArgsRef; | |
| 2 | use crate::ty::{self, Ty, TyCtxt}; | |
| 3 | 1 | use rustc_hir::def_id::{DefId, LOCAL_CRATE}; |
| 4 | 2 | use rustc_macros::{Decodable, Encodable, HashStable, TyDecodable, TyEncodable}; |
| 5 | 3 | |
| 4 | use crate::ty::{self, GenericArgsRef, Ty, TyCtxt}; | |
| 5 | ||
| 6 | 6 | /// The SymbolExportLevel of a symbols specifies from which kinds of crates |
| 7 | 7 | /// the symbol will be exported. `C` symbols will be exported from any |
| 8 | 8 | /// kind of crate, including cdylibs which export very few things. |
compiler/rustc_middle/src/middle/lang_items.rs+2-2| ... | ... | @@ -7,13 +7,13 @@ |
| 7 | 7 | //! * Traits that represent operators; e.g., `Add`, `Sub`, `Index`. |
| 8 | 8 | //! * Functions called by the compiler itself. |
| 9 | 9 | |
| 10 | use crate::ty::{self, TyCtxt}; | |
| 11 | ||
| 12 | 10 | use rustc_hir::def_id::DefId; |
| 13 | 11 | use rustc_hir::LangItem; |
| 14 | 12 | use rustc_span::Span; |
| 15 | 13 | use rustc_target::spec::PanicStrategy; |
| 16 | 14 | |
| 15 | use crate::ty::{self, TyCtxt}; | |
| 16 | ||
| 17 | 17 | impl<'tcx> TyCtxt<'tcx> { |
| 18 | 18 | /// Returns the `DefId` for a given `LangItem`. |
| 19 | 19 | /// If not found, fatally aborts compilation. |
compiler/rustc_middle/src/middle/limits.rs+5-5| ... | ... | @@ -8,14 +8,14 @@ |
| 8 | 8 | //! this via an attribute on the crate like `#![recursion_limit="22"]`. This pass |
| 9 | 9 | //! just peeks and looks for that attribute. |
| 10 | 10 | |
| 11 | use crate::error::LimitInvalid; | |
| 12 | use crate::query::Providers; | |
| 11 | use std::num::IntErrorKind; | |
| 12 | ||
| 13 | 13 | use rustc_ast::Attribute; |
| 14 | use rustc_session::Session; | |
| 15 | use rustc_session::{Limit, Limits}; | |
| 14 | use rustc_session::{Limit, Limits, Session}; | |
| 16 | 15 | use rustc_span::symbol::{sym, Symbol}; |
| 17 | 16 | |
| 18 | use std::num::IntErrorKind; | |
| 17 | use crate::error::LimitInvalid; | |
| 18 | use crate::query::Providers; | |
| 19 | 19 | |
| 20 | 20 | pub fn provide(providers: &mut Providers) { |
| 21 | 21 | providers.limits = |tcx, ()| Limits { |
compiler/rustc_middle/src/middle/mod.rs+2-1| ... | ... | @@ -6,7 +6,8 @@ pub mod lang_items; |
| 6 | 6 | pub mod lib_features { |
| 7 | 7 | use rustc_data_structures::unord::UnordMap; |
| 8 | 8 | use rustc_macros::{HashStable, TyDecodable, TyEncodable}; |
| 9 | use rustc_span::{symbol::Symbol, Span}; | |
| 9 | use rustc_span::symbol::Symbol; | |
| 10 | use rustc_span::Span; | |
| 10 | 11 | |
| 11 | 12 | #[derive(Copy, Clone, Debug, PartialEq, Eq)] |
| 12 | 13 | #[derive(HashStable, TyEncodable, TyDecodable)] |
compiler/rustc_middle/src/middle/privacy.rs+4-2| ... | ... | @@ -2,14 +2,16 @@ |
| 2 | 2 | //! outside their scopes. This pass will also generate a set of exported items |
| 3 | 3 | //! which are available for use externally when compiled as a library. |
| 4 | 4 | |
| 5 | use crate::ty::{TyCtxt, Visibility}; | |
| 5 | use std::hash::Hash; | |
| 6 | ||
| 6 | 7 | use rustc_data_structures::fx::{FxIndexMap, IndexEntry}; |
| 7 | 8 | use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; |
| 8 | 9 | use rustc_hir::def::DefKind; |
| 9 | 10 | use rustc_macros::HashStable; |
| 10 | 11 | use rustc_query_system::ich::StableHashingContext; |
| 11 | 12 | use rustc_span::def_id::{LocalDefId, CRATE_DEF_ID}; |
| 12 | use std::hash::Hash; | |
| 13 | ||
| 14 | use crate::ty::{TyCtxt, Visibility}; | |
| 13 | 15 | |
| 14 | 16 | /// Represents the levels of effective visibility an item can have. |
| 15 | 17 | /// |
compiler/rustc_middle/src/middle/region.rs+4-3| ... | ... | @@ -6,7 +6,9 @@ |
| 6 | 6 | //! |
| 7 | 7 | //! [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/borrow_check.html |
| 8 | 8 | |
| 9 | use crate::ty::TyCtxt; | |
| 9 | use std::fmt; | |
| 10 | use std::ops::Deref; | |
| 11 | ||
| 10 | 12 | use rustc_data_structures::fx::FxIndexMap; |
| 11 | 13 | use rustc_data_structures::unord::UnordMap; |
| 12 | 14 | use rustc_hir as hir; |
| ... | ... | @@ -15,8 +17,7 @@ use rustc_macros::{HashStable, TyDecodable, TyEncodable}; |
| 15 | 17 | use rustc_span::{Span, DUMMY_SP}; |
| 16 | 18 | use tracing::debug; |
| 17 | 19 | |
| 18 | use std::fmt; | |
| 19 | use std::ops::Deref; | |
| 20 | use crate::ty::TyCtxt; | |
| 20 | 21 | |
| 21 | 22 | /// Represents a statically-describable scope that can be used to |
| 22 | 23 | /// bound the lifetime/region for values. |
compiler/rustc_middle/src/middle/resolve_bound_vars.rs+2-2| ... | ... | @@ -1,13 +1,13 @@ |
| 1 | 1 | //! Name resolution for lifetimes and late-bound type and const variables: type declarations. |
| 2 | 2 | |
| 3 | use crate::ty; | |
| 4 | ||
| 5 | 3 | use rustc_data_structures::fx::FxIndexMap; |
| 6 | 4 | use rustc_errors::ErrorGuaranteed; |
| 7 | 5 | use rustc_hir::def_id::DefId; |
| 8 | 6 | use rustc_hir::{ItemLocalId, OwnerId}; |
| 9 | 7 | use rustc_macros::{Decodable, Encodable, HashStable, TyDecodable, TyEncodable}; |
| 10 | 8 | |
| 9 | use crate::ty; | |
| 10 | ||
| 11 | 11 | #[derive(Clone, Copy, PartialEq, Eq, Hash, TyEncodable, TyDecodable, Debug, HashStable)] |
| 12 | 12 | pub enum ResolvedArg { |
| 13 | 13 | StaticLifetime, |
compiler/rustc_middle/src/middle/stability.rs+4-3| ... | ... | @@ -1,9 +1,8 @@ |
| 1 | 1 | //! A pass that annotates every item and method with its stability level, |
| 2 | 2 | //! propagating default levels lexically from parent to children ast nodes. |
| 3 | 3 | |
| 4 | pub use self::StabilityLevel::*; | |
| 4 | use std::num::NonZero; | |
| 5 | 5 | |
| 6 | use crate::ty::{self, TyCtxt}; | |
| 7 | 6 | use rustc_ast::NodeId; |
| 8 | 7 | use rustc_attr::{ |
| 9 | 8 | self as attr, ConstStability, DefaultBodyStability, DeprecatedSince, Deprecation, Stability, |
| ... | ... | @@ -22,9 +21,11 @@ use rustc_session::parse::feature_err_issue; |
| 22 | 21 | use rustc_session::Session; |
| 23 | 22 | use rustc_span::symbol::{sym, Symbol}; |
| 24 | 23 | use rustc_span::Span; |
| 25 | use std::num::NonZero; | |
| 26 | 24 | use tracing::debug; |
| 27 | 25 | |
| 26 | pub use self::StabilityLevel::*; | |
| 27 | use crate::ty::{self, TyCtxt}; | |
| 28 | ||
| 28 | 29 | #[derive(PartialEq, Clone, Copy, Debug)] |
| 29 | 30 | pub enum StabilityLevel { |
| 30 | 31 | Unstable, |
compiler/rustc_middle/src/mir/basic_blocks.rs+3-3| ... | ... | @@ -1,6 +1,3 @@ |
| 1 | use crate::mir::traversal::Postorder; | |
| 2 | use crate::mir::{BasicBlock, BasicBlockData, Terminator, TerminatorKind, START_BLOCK}; | |
| 3 | ||
| 4 | 1 | use rustc_data_structures::fx::FxHashMap; |
| 5 | 2 | use rustc_data_structures::graph; |
| 6 | 3 | use rustc_data_structures::graph::dominators::{dominators, Dominators}; |
| ... | ... | @@ -11,6 +8,9 @@ use rustc_macros::{HashStable, TyDecodable, TyEncodable, TypeFoldable, TypeVisit |
| 11 | 8 | use rustc_serialize::{Decodable, Decoder, Encodable, Encoder}; |
| 12 | 9 | use smallvec::SmallVec; |
| 13 | 10 | |
| 11 | use crate::mir::traversal::Postorder; | |
| 12 | use crate::mir::{BasicBlock, BasicBlockData, Terminator, TerminatorKind, START_BLOCK}; | |
| 13 | ||
| 14 | 14 | #[derive(Clone, TyEncodable, TyDecodable, Debug, HashStable, TypeFoldable, TypeVisitable)] |
| 15 | 15 | pub struct BasicBlocks<'tcx> { |
| 16 | 16 | basic_blocks: IndexVec<BasicBlock, BasicBlockData<'tcx>>, |
compiler/rustc_middle/src/mir/consts.rs+4-5| ... | ... | @@ -2,16 +2,15 @@ use std::fmt::{self, Debug, Display, Formatter}; |
| 2 | 2 | |
| 3 | 3 | use rustc_hir::def_id::DefId; |
| 4 | 4 | use rustc_macros::{HashStable, Lift, TyDecodable, TyEncodable, TypeFoldable, TypeVisitable}; |
| 5 | use rustc_session::{config::RemapPathScopeComponents, RemapFileNameExt}; | |
| 5 | use rustc_session::config::RemapPathScopeComponents; | |
| 6 | use rustc_session::RemapFileNameExt; | |
| 6 | 7 | use rustc_span::{Span, DUMMY_SP}; |
| 7 | 8 | use rustc_target::abi::{HasDataLayout, Size}; |
| 8 | 9 | |
| 9 | 10 | use crate::mir::interpret::{alloc_range, AllocId, ConstAllocation, ErrorHandled, Scalar}; |
| 10 | 11 | use crate::mir::{pretty_print_const_value, Promoted}; |
| 11 | use crate::ty::print::with_no_trimmed_paths; | |
| 12 | use crate::ty::GenericArgsRef; | |
| 13 | use crate::ty::ScalarInt; | |
| 14 | use crate::ty::{self, print::pretty_print_const, Ty, TyCtxt}; | |
| 12 | use crate::ty::print::{pretty_print_const, with_no_trimmed_paths}; | |
| 13 | use crate::ty::{self, GenericArgsRef, ScalarInt, Ty, TyCtxt}; | |
| 15 | 14 | |
| 16 | 15 | /////////////////////////////////////////////////////////////////////////// |
| 17 | 16 | /// Evaluated Constants |
compiler/rustc_middle/src/mir/coverage.rs+2-2| ... | ... | @@ -1,11 +1,11 @@ |
| 1 | 1 | //! Metadata from source code coverage analysis and instrumentation. |
| 2 | 2 | |
| 3 | use std::fmt::{self, Debug, Formatter}; | |
| 4 | ||
| 3 | 5 | use rustc_index::IndexVec; |
| 4 | 6 | use rustc_macros::{HashStable, TyDecodable, TyEncodable, TypeFoldable, TypeVisitable}; |
| 5 | 7 | use rustc_span::{Span, Symbol}; |
| 6 | 8 | |
| 7 | use std::fmt::{self, Debug, Formatter}; | |
| 8 | ||
| 9 | 9 | rustc_index::newtype_index! { |
| 10 | 10 | /// Used by [`CoverageKind::BlockMarker`] to mark blocks during THIR-to-MIR |
| 11 | 11 | /// lowering, so that those blocks can be identified later. |
compiler/rustc_middle/src/mir/generic_graphviz.rs+2-1| ... | ... | @@ -1,7 +1,8 @@ |
| 1 | use std::io::{self, Write}; | |
| 2 | ||
| 1 | 3 | use rustc_data_structures::graph::{self, iterate}; |
| 2 | 4 | use rustc_graphviz as dot; |
| 3 | 5 | use rustc_middle::ty::TyCtxt; |
| 4 | use std::io::{self, Write}; | |
| 5 | 6 | |
| 6 | 7 | pub struct GraphvizWriter< |
| 7 | 8 | 'a, |
compiler/rustc_middle/src/mir/graphviz.rs+2-1| ... | ... | @@ -1,7 +1,8 @@ |
| 1 | use std::io::{self, Write}; | |
| 2 | ||
| 1 | 3 | use gsgdt::GraphvizSettings; |
| 2 | 4 | use rustc_graphviz as dot; |
| 3 | 5 | use rustc_middle::mir::*; |
| 4 | use std::io::{self, Write}; | |
| 5 | 6 | |
| 6 | 7 | use super::generic_graph::mir_fn_to_generic_graph; |
| 7 | 8 | use super::pretty::dump_mir_def_ids; |
compiler/rustc_middle/src/mir/interpret/allocation.rs+4-8| ... | ... | @@ -4,14 +4,14 @@ mod init_mask; |
| 4 | 4 | mod provenance_map; |
| 5 | 5 | |
| 6 | 6 | use std::borrow::Cow; |
| 7 | use std::fmt; | |
| 8 | use std::hash; | |
| 9 | 7 | use std::hash::Hash; |
| 10 | 8 | use std::ops::{Deref, DerefMut, Range}; |
| 11 | use std::ptr; | |
| 9 | use std::{fmt, hash, ptr}; | |
| 12 | 10 | |
| 13 | 11 | use either::{Left, Right}; |
| 14 | ||
| 12 | use init_mask::*; | |
| 13 | pub use init_mask::{InitChunk, InitChunkIter}; | |
| 14 | use provenance_map::*; | |
| 15 | 15 | use rustc_ast::Mutability; |
| 16 | 16 | use rustc_data_structures::intern::Interned; |
| 17 | 17 | use rustc_macros::{HashStable, TyDecodable, TyEncodable}; |
| ... | ... | @@ -23,10 +23,6 @@ use super::{ |
| 23 | 23 | ScalarSizeMismatch, UndefinedBehaviorInfo, UnsupportedOpInfo, |
| 24 | 24 | }; |
| 25 | 25 | use crate::ty; |
| 26 | use init_mask::*; | |
| 27 | use provenance_map::*; | |
| 28 | ||
| 29 | pub use init_mask::{InitChunk, InitChunkIter}; | |
| 30 | 26 | |
| 31 | 27 | /// Functionality required for the bytes of an `Allocation`. |
| 32 | 28 | pub trait AllocBytes: Clone + fmt::Debug + Deref<Target = [u8]> + DerefMut<Target = [u8]> { |
compiler/rustc_middle/src/mir/interpret/allocation/init_mask.rs+1-2| ... | ... | @@ -1,9 +1,8 @@ |
| 1 | 1 | #[cfg(test)] |
| 2 | 2 | mod tests; |
| 3 | 3 | |
| 4 | use std::hash; | |
| 5 | use std::iter; | |
| 6 | 4 | use std::ops::Range; |
| 5 | use std::{hash, iter}; | |
| 7 | 6 | |
| 8 | 7 | use rustc_macros::{HashStable, TyDecodable, TyEncodable}; |
| 9 | 8 | use rustc_serialize::{Decodable, Encodable}; |
compiler/rustc_middle/src/mir/interpret/allocation/provenance_map.rs+2-1| ... | ... | @@ -3,13 +3,14 @@ |
| 3 | 3 | |
| 4 | 4 | use std::cmp; |
| 5 | 5 | |
| 6 | use super::{alloc_range, AllocError, AllocRange, AllocResult, CtfeProvenance, Provenance}; | |
| 7 | 6 | use rustc_data_structures::sorted_map::SortedMap; |
| 8 | 7 | use rustc_macros::HashStable; |
| 9 | 8 | use rustc_serialize::{Decodable, Decoder, Encodable, Encoder}; |
| 10 | 9 | use rustc_target::abi::{HasDataLayout, Size}; |
| 11 | 10 | use tracing::trace; |
| 12 | 11 | |
| 12 | use super::{alloc_range, AllocError, AllocRange, AllocResult, CtfeProvenance, Provenance}; | |
| 13 | ||
| 13 | 14 | /// Stores the provenance information of pointers stored in memory. |
| 14 | 15 | #[derive(Clone, PartialEq, Eq, Hash, Debug)] |
| 15 | 16 | #[derive(HashStable)] |
compiler/rustc_middle/src/mir/interpret/error.rs+5-5| ... | ... | @@ -1,19 +1,19 @@ |
| 1 | use std::any::Any; | |
| 2 | use std::backtrace::Backtrace; | |
| 1 | 3 | use std::borrow::Cow; |
| 2 | use std::{any::Any, backtrace::Backtrace, fmt}; | |
| 4 | use std::fmt; | |
| 3 | 5 | |
| 4 | 6 | use either::Either; |
| 5 | ||
| 6 | 7 | use rustc_ast_ir::Mutability; |
| 7 | 8 | use rustc_data_structures::sync::Lock; |
| 8 | 9 | use rustc_errors::{DiagArgName, DiagArgValue, DiagMessage, ErrorGuaranteed, IntoDiagArg}; |
| 9 | 10 | use rustc_macros::{HashStable, TyDecodable, TyEncodable}; |
| 10 | 11 | use rustc_session::CtfeBacktrace; |
| 11 | use rustc_span::Symbol; | |
| 12 | use rustc_span::{def_id::DefId, Span, DUMMY_SP}; | |
| 12 | use rustc_span::def_id::DefId; | |
| 13 | use rustc_span::{Span, Symbol, DUMMY_SP}; | |
| 13 | 14 | use rustc_target::abi::{call, Align, Size, VariantIdx, WrappingRange}; |
| 14 | 15 | |
| 15 | 16 | use super::{AllocId, AllocRange, ConstAllocation, Pointer, Scalar}; |
| 16 | ||
| 17 | 17 | use crate::error; |
| 18 | 18 | use crate::mir::{ConstAlloc, ConstValue}; |
| 19 | 19 | use crate::ty::{self, layout, tls, Ty, TyCtxt, ValTree}; |
compiler/rustc_middle/src/mir/interpret/mod.rs+14-21| ... | ... | @@ -8,12 +8,9 @@ mod pointer; |
| 8 | 8 | mod queries; |
| 9 | 9 | mod value; |
| 10 | 10 | |
| 11 | use std::fmt; | |
| 12 | use std::io; | |
| 13 | 11 | use std::io::{Read, Write}; |
| 14 | 12 | use std::num::NonZero; |
| 15 | ||
| 16 | use tracing::{debug, trace}; | |
| 13 | use std::{fmt, io}; | |
| 17 | 14 | |
| 18 | 15 | use rustc_ast::LitKind; |
| 19 | 16 | use rustc_attr::InlineAttr; |
| ... | ... | @@ -25,20 +22,7 @@ use rustc_macros::{HashStable, TyDecodable, TyEncodable, TypeFoldable, TypeVisit |
| 25 | 22 | use rustc_middle::ty::print::with_no_trimmed_paths; |
| 26 | 23 | use rustc_serialize::{Decodable, Encodable}; |
| 27 | 24 | use rustc_target::abi::{AddressSpace, Endian, HasDataLayout}; |
| 28 | ||
| 29 | use crate::mir; | |
| 30 | use crate::ty::codec::{TyDecoder, TyEncoder}; | |
| 31 | use crate::ty::GenericArgKind; | |
| 32 | use crate::ty::{self, Instance, Ty, TyCtxt}; | |
| 33 | ||
| 34 | pub use self::error::{ | |
| 35 | BadBytesAccess, CheckAlignMsg, CheckInAllocMsg, ErrorHandled, EvalStaticInitializerRawResult, | |
| 36 | EvalToAllocationRawResult, EvalToConstValueResult, EvalToValTreeResult, ExpectedKind, | |
| 37 | InterpError, InterpErrorInfo, InterpResult, InvalidMetaKind, InvalidProgramInfo, | |
| 38 | MachineStopType, Misalignment, PointerKind, ReportedErrorInfo, ResourceExhaustionInfo, | |
| 39 | ScalarSizeMismatch, UndefinedBehaviorInfo, UnsupportedOpInfo, ValidationErrorInfo, | |
| 40 | ValidationErrorKind, | |
| 41 | }; | |
| 25 | use tracing::{debug, trace}; | |
| 42 | 26 | // Also make the error macros available from this module. |
| 43 | 27 | pub use { |
| 44 | 28 | err_exhaust, err_inval, err_machine_stop, err_ub, err_ub_custom, err_ub_format, err_unsup, |
| ... | ... | @@ -46,14 +30,23 @@ pub use { |
| 46 | 30 | throw_ub_format, throw_unsup, throw_unsup_format, |
| 47 | 31 | }; |
| 48 | 32 | |
| 49 | pub use self::value::Scalar; | |
| 50 | ||
| 51 | 33 | pub use self::allocation::{ |
| 52 | 34 | alloc_range, AllocBytes, AllocError, AllocRange, AllocResult, Allocation, ConstAllocation, |
| 53 | 35 | InitChunk, InitChunkIter, |
| 54 | 36 | }; |
| 55 | ||
| 37 | pub use self::error::{ | |
| 38 | BadBytesAccess, CheckAlignMsg, CheckInAllocMsg, ErrorHandled, EvalStaticInitializerRawResult, | |
| 39 | EvalToAllocationRawResult, EvalToConstValueResult, EvalToValTreeResult, ExpectedKind, | |
| 40 | InterpError, InterpErrorInfo, InterpResult, InvalidMetaKind, InvalidProgramInfo, | |
| 41 | MachineStopType, Misalignment, PointerKind, ReportedErrorInfo, ResourceExhaustionInfo, | |
| 42 | ScalarSizeMismatch, UndefinedBehaviorInfo, UnsupportedOpInfo, ValidationErrorInfo, | |
| 43 | ValidationErrorKind, | |
| 44 | }; | |
| 56 | 45 | pub use self::pointer::{CtfeProvenance, Pointer, PointerArithmetic, Provenance}; |
| 46 | pub use self::value::Scalar; | |
| 47 | use crate::mir; | |
| 48 | use crate::ty::codec::{TyDecoder, TyEncoder}; | |
| 49 | use crate::ty::{self, GenericArgKind, Instance, Ty, TyCtxt}; | |
| 57 | 50 | |
| 58 | 51 | /// Uniquely identifies one of the following: |
| 59 | 52 | /// - A constant |
compiler/rustc_middle/src/mir/interpret/pointer.rs+3-2| ... | ... | @@ -1,10 +1,11 @@ |
| 1 | use super::{AllocId, InterpResult}; | |
| 1 | use std::fmt; | |
| 2 | use std::num::NonZero; | |
| 2 | 3 | |
| 3 | 4 | use rustc_data_structures::static_assert_size; |
| 4 | 5 | use rustc_macros::{HashStable, TyDecodable, TyEncodable}; |
| 5 | 6 | use rustc_target::abi::{HasDataLayout, Size}; |
| 6 | 7 | |
| 7 | use std::{fmt, num::NonZero}; | |
| 8 | use super::{AllocId, InterpResult}; | |
| 8 | 9 | |
| 9 | 10 | //////////////////////////////////////////////////////////////////////////////// |
| 10 | 11 | // Pointer arithmetic |
compiler/rustc_middle/src/mir/interpret/queries.rs+7-8| ... | ... | @@ -1,17 +1,16 @@ |
| 1 | use rustc_hir::def::DefKind; | |
| 2 | use rustc_hir::def_id::DefId; | |
| 3 | use rustc_session::lint; | |
| 4 | use rustc_span::{Span, DUMMY_SP}; | |
| 5 | use tracing::{debug, instrument}; | |
| 6 | ||
| 1 | 7 | use super::{ |
| 2 | 8 | ErrorHandled, EvalToAllocationRawResult, EvalToConstValueResult, EvalToValTreeResult, GlobalId, |
| 3 | 9 | }; |
| 4 | ||
| 5 | 10 | use crate::mir; |
| 6 | 11 | use crate::query::TyCtxtEnsure; |
| 7 | 12 | use crate::ty::visit::TypeVisitableExt; |
| 8 | use crate::ty::GenericArgs; | |
| 9 | use crate::ty::{self, TyCtxt}; | |
| 10 | use rustc_hir::def::DefKind; | |
| 11 | use rustc_hir::def_id::DefId; | |
| 12 | use rustc_session::lint; | |
| 13 | use rustc_span::{Span, DUMMY_SP}; | |
| 14 | use tracing::{debug, instrument}; | |
| 13 | use crate::ty::{self, GenericArgs, TyCtxt}; | |
| 15 | 14 | |
| 16 | 15 | impl<'tcx> TyCtxt<'tcx> { |
| 17 | 16 | /// Evaluates a constant without providing any generic parameters. This is useful to evaluate consts |
compiler/rustc_middle/src/mir/interpret/value.rs+3-7| ... | ... | @@ -1,20 +1,16 @@ |
| 1 | 1 | use std::fmt; |
| 2 | 2 | |
| 3 | 3 | use either::{Either, Left, Right}; |
| 4 | ||
| 5 | use rustc_apfloat::{ | |
| 6 | ieee::{Double, Half, Quad, Single}, | |
| 7 | Float, | |
| 8 | }; | |
| 4 | use rustc_apfloat::ieee::{Double, Half, Quad, Single}; | |
| 5 | use rustc_apfloat::Float; | |
| 9 | 6 | use rustc_macros::{HashStable, TyDecodable, TyEncodable}; |
| 10 | 7 | use rustc_target::abi::{HasDataLayout, Size}; |
| 11 | 8 | |
| 12 | use crate::ty::ScalarInt; | |
| 13 | ||
| 14 | 9 | use super::{ |
| 15 | 10 | AllocId, CtfeProvenance, InterpResult, Pointer, PointerArithmetic, Provenance, |
| 16 | 11 | ScalarSizeMismatch, |
| 17 | 12 | }; |
| 13 | use crate::ty::ScalarInt; | |
| 18 | 14 | |
| 19 | 15 | /// A `Scalar` represents an immediate, primitive value existing outside of a |
| 20 | 16 | /// `memory::Allocation`. It is in many ways like a small chunk of an `Allocation`, up to 16 bytes in |
compiler/rustc_middle/src/mir/mod.rs+34-36| ... | ... | @@ -2,53 +2,49 @@ |
| 2 | 2 | //! |
| 3 | 3 | //! [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/mir/index.html |
| 4 | 4 | |
| 5 | use crate::mir::interpret::{AllocRange, Scalar}; | |
| 6 | use crate::mir::visit::MirVisitable; | |
| 7 | use crate::ty::codec::{TyDecoder, TyEncoder}; | |
| 8 | use crate::ty::fold::{FallibleTypeFolder, TypeFoldable}; | |
| 9 | use crate::ty::print::{pretty_print_const, with_no_trimmed_paths}; | |
| 10 | use crate::ty::print::{FmtPrinter, Printer}; | |
| 11 | use crate::ty::visit::TypeVisitableExt; | |
| 12 | use crate::ty::{self, List, Ty, TyCtxt}; | |
| 13 | use crate::ty::{AdtDef, Instance, InstanceKind, UserTypeAnnotationIndex}; | |
| 14 | use crate::ty::{GenericArg, GenericArgsRef}; | |
| 5 | use std::borrow::Cow; | |
| 6 | use std::cell::RefCell; | |
| 7 | use std::collections::hash_map::Entry; | |
| 8 | use std::fmt::{self, Debug, Formatter}; | |
| 9 | use std::ops::{Index, IndexMut}; | |
| 10 | use std::{iter, mem}; | |
| 15 | 11 | |
| 12 | pub use basic_blocks::BasicBlocks; | |
| 13 | use either::Either; | |
| 14 | use polonius_engine::Atom; | |
| 15 | pub use rustc_ast::Mutability; | |
| 16 | 16 | use rustc_data_structures::captures::Captures; |
| 17 | use rustc_data_structures::fx::{FxHashMap, FxHashSet}; | |
| 18 | use rustc_data_structures::graph::dominators::Dominators; | |
| 17 | 19 | use rustc_errors::{DiagArgName, DiagArgValue, DiagMessage, ErrorGuaranteed, IntoDiagArg}; |
| 18 | 20 | use rustc_hir::def::{CtorKind, Namespace}; |
| 19 | 21 | use rustc_hir::def_id::{DefId, CRATE_DEF_ID}; |
| 20 | 22 | use rustc_hir::{ |
| 21 | 23 | self as hir, BindingMode, ByRef, CoroutineDesugaring, CoroutineKind, HirId, ImplicitSelfKind, |
| 22 | 24 | }; |
| 23 | use rustc_macros::{HashStable, TyDecodable, TyEncodable, TypeFoldable, TypeVisitable}; | |
| 24 | use rustc_session::Session; | |
| 25 | use rustc_span::source_map::Spanned; | |
| 26 | use rustc_target::abi::{FieldIdx, VariantIdx}; | |
| 27 | ||
| 28 | use polonius_engine::Atom; | |
| 29 | pub use rustc_ast::Mutability; | |
| 30 | use rustc_data_structures::fx::FxHashMap; | |
| 31 | use rustc_data_structures::fx::FxHashSet; | |
| 32 | use rustc_data_structures::graph::dominators::Dominators; | |
| 33 | 25 | use rustc_index::bit_set::BitSet; |
| 34 | 26 | use rustc_index::{Idx, IndexSlice, IndexVec}; |
| 27 | use rustc_macros::{HashStable, TyDecodable, TyEncodable, TypeFoldable, TypeVisitable}; | |
| 35 | 28 | use rustc_serialize::{Decodable, Encodable}; |
| 29 | use rustc_session::Session; | |
| 30 | use rustc_span::source_map::Spanned; | |
| 36 | 31 | use rustc_span::symbol::Symbol; |
| 37 | 32 | use rustc_span::{Span, DUMMY_SP}; |
| 38 | ||
| 39 | use either::Either; | |
| 33 | use rustc_target::abi::{FieldIdx, VariantIdx}; | |
| 40 | 34 | use tracing::trace; |
| 41 | 35 | |
| 42 | use std::borrow::Cow; | |
| 43 | use std::cell::RefCell; | |
| 44 | use std::collections::hash_map::Entry; | |
| 45 | use std::fmt::{self, Debug, Formatter}; | |
| 46 | use std::ops::{Index, IndexMut}; | |
| 47 | use std::{iter, mem}; | |
| 48 | ||
| 49 | 36 | pub use self::query::*; |
| 50 | 37 | use self::visit::TyContext; |
| 51 | pub use basic_blocks::BasicBlocks; | |
| 38 | use crate::mir::interpret::{AllocRange, Scalar}; | |
| 39 | use crate::mir::visit::MirVisitable; | |
| 40 | use crate::ty::codec::{TyDecoder, TyEncoder}; | |
| 41 | use crate::ty::fold::{FallibleTypeFolder, TypeFoldable}; | |
| 42 | use crate::ty::print::{pretty_print_const, with_no_trimmed_paths, FmtPrinter, Printer}; | |
| 43 | use crate::ty::visit::TypeVisitableExt; | |
| 44 | use crate::ty::{ | |
| 45 | self, AdtDef, GenericArg, GenericArgsRef, Instance, InstanceKind, List, Ty, TyCtxt, | |
| 46 | UserTypeAnnotationIndex, | |
| 47 | }; | |
| 52 | 48 | |
| 53 | 49 | mod basic_blocks; |
| 54 | 50 | mod consts; |
| ... | ... | @@ -70,17 +66,18 @@ pub mod traversal; |
| 70 | 66 | mod type_foldable; |
| 71 | 67 | pub mod visit; |
| 72 | 68 | |
| 73 | pub use self::generic_graph::graphviz_safe_def_name; | |
| 74 | pub use self::graphviz::write_mir_graphviz; | |
| 75 | pub use self::pretty::{ | |
| 76 | create_dump_file, display_allocation, dump_enabled, dump_mir, write_mir_pretty, PassWhere, | |
| 77 | }; | |
| 78 | 69 | pub use consts::*; |
| 79 | 70 | use pretty::pretty_print_const_value; |
| 80 | 71 | pub use statement::*; |
| 81 | 72 | pub use syntax::*; |
| 82 | 73 | pub use terminator::*; |
| 83 | 74 | |
| 75 | pub use self::generic_graph::graphviz_safe_def_name; | |
| 76 | pub use self::graphviz::write_mir_graphviz; | |
| 77 | pub use self::pretty::{ | |
| 78 | create_dump_file, display_allocation, dump_enabled, dump_mir, write_mir_pretty, PassWhere, | |
| 79 | }; | |
| 80 | ||
| 84 | 81 | /// Types for locals |
| 85 | 82 | pub type LocalDecls<'tcx> = IndexSlice<Local, LocalDecl<'tcx>>; |
| 86 | 83 | |
| ... | ... | @@ -1815,8 +1812,9 @@ impl DefLocation { |
| 1815 | 1812 | // Some nodes are used a lot. Make sure they don't unintentionally get bigger. |
| 1816 | 1813 | #[cfg(target_pointer_width = "64")] |
| 1817 | 1814 | mod size_asserts { |
| 1818 | use super::*; | |
| 1819 | 1815 | use rustc_data_structures::static_assert_size; |
| 1816 | ||
| 1817 | use super::*; | |
| 1820 | 1818 | // tidy-alphabetical-start |
| 1821 | 1819 | static_assert_size!(BasicBlockData<'_>, 128); |
| 1822 | 1820 | static_assert_size!(LocalDecl<'_>, 40); |
compiler/rustc_middle/src/mir/mono.rs+7-7| ... | ... | @@ -1,9 +1,8 @@ |
| 1 | use crate::dep_graph::{DepNode, WorkProduct, WorkProductId}; | |
| 2 | use crate::ty::{GenericArgs, Instance, InstanceKind, SymbolName, TyCtxt}; | |
| 1 | use std::fmt; | |
| 2 | use std::hash::Hash; | |
| 3 | ||
| 3 | 4 | use rustc_attr::InlineAttr; |
| 4 | use rustc_data_structures::base_n::BaseNString; | |
| 5 | use rustc_data_structures::base_n::ToBaseN; | |
| 6 | use rustc_data_structures::base_n::CASE_INSENSITIVE; | |
| 5 | use rustc_data_structures::base_n::{BaseNString, ToBaseN, CASE_INSENSITIVE}; | |
| 7 | 6 | use rustc_data_structures::fingerprint::Fingerprint; |
| 8 | 7 | use rustc_data_structures::fx::FxIndexMap; |
| 9 | 8 | use rustc_data_structures::stable_hasher::{Hash128, HashStable, StableHasher, ToStableHashKey}; |
| ... | ... | @@ -16,10 +15,11 @@ use rustc_query_system::ich::StableHashingContext; |
| 16 | 15 | use rustc_session::config::OptLevel; |
| 17 | 16 | use rustc_span::symbol::Symbol; |
| 18 | 17 | use rustc_span::Span; |
| 19 | use std::fmt; | |
| 20 | use std::hash::Hash; | |
| 21 | 18 | use tracing::debug; |
| 22 | 19 | |
| 20 | use crate::dep_graph::{DepNode, WorkProduct, WorkProductId}; | |
| 21 | use crate::ty::{GenericArgs, Instance, InstanceKind, SymbolName, TyCtxt}; | |
| 22 | ||
| 23 | 23 | /// Describes how a monomorphization will be instantiated in object files. |
| 24 | 24 | #[derive(PartialEq)] |
| 25 | 25 | pub enum InstantiationMode { |
compiler/rustc_middle/src/mir/pretty.rs+3-3| ... | ... | @@ -4,9 +4,6 @@ use std::fs; |
| 4 | 4 | use std::io::{self, Write as _}; |
| 5 | 5 | use std::path::{Path, PathBuf}; |
| 6 | 6 | |
| 7 | use crate::mir::interpret::ConstAllocation; | |
| 8 | ||
| 9 | use super::graphviz::write_mir_fn_graphviz; | |
| 10 | 7 | use rustc_ast::{InlineAsmOptions, InlineAsmTemplatePiece}; |
| 11 | 8 | use rustc_middle::mir::interpret::{ |
| 12 | 9 | alloc_range, read_target_uint, AllocBytes, AllocId, Allocation, GlobalAlloc, Pointer, |
| ... | ... | @@ -17,6 +14,9 @@ use rustc_middle::mir::*; |
| 17 | 14 | use rustc_target::abi::Size; |
| 18 | 15 | use tracing::trace; |
| 19 | 16 | |
| 17 | use super::graphviz::write_mir_fn_graphviz; | |
| 18 | use crate::mir::interpret::ConstAllocation; | |
| 19 | ||
| 20 | 20 | const INDENT: &str = " "; |
| 21 | 21 | /// Alignment for lining up comments following MIR statements |
| 22 | 22 | pub(crate) const ALIGN: usize = 40; |
compiler/rustc_middle/src/mir/query.rs+5-4| ... | ... | @@ -1,7 +1,8 @@ |
| 1 | 1 | //! Values computed by queries that use MIR. |
| 2 | 2 | |
| 3 | use crate::mir; | |
| 4 | use crate::ty::{self, CoroutineArgsExt, OpaqueHiddenType, Ty, TyCtxt}; | |
| 3 | use std::cell::Cell; | |
| 4 | use std::fmt::{self, Debug}; | |
| 5 | ||
| 5 | 6 | use derive_where::derive_where; |
| 6 | 7 | use rustc_data_structures::fx::FxIndexMap; |
| 7 | 8 | use rustc_errors::ErrorGuaranteed; |
| ... | ... | @@ -13,10 +14,10 @@ use rustc_span::symbol::Symbol; |
| 13 | 14 | use rustc_span::Span; |
| 14 | 15 | use rustc_target::abi::{FieldIdx, VariantIdx}; |
| 15 | 16 | use smallvec::SmallVec; |
| 16 | use std::cell::Cell; | |
| 17 | use std::fmt::{self, Debug}; | |
| 18 | 17 | |
| 19 | 18 | use super::{ConstValue, SourceInfo}; |
| 19 | use crate::mir; | |
| 20 | use crate::ty::{self, CoroutineArgsExt, OpaqueHiddenType, Ty, TyCtxt}; | |
| 20 | 21 | |
| 21 | 22 | rustc_index::newtype_index! { |
| 22 | 23 | #[derive(HashStable)] |
compiler/rustc_middle/src/mir/statement.rs+2-1| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | 1 | //! Functionality for statements, operands, places, and things that appear in them. |
| 2 | 2 | |
| 3 | use super::{interpret::GlobalAlloc, *}; | |
| 3 | use super::interpret::GlobalAlloc; | |
| 4 | use super::*; | |
| 4 | 5 | |
| 5 | 6 | /////////////////////////////////////////////////////////////////////////// |
| 6 | 7 | // Statements |
compiler/rustc_middle/src/mir/syntax.rs+11-15| ... | ... | @@ -3,31 +3,26 @@ |
| 3 | 3 | //! This is in a dedicated file so that changes to this file can be reviewed more carefully. |
| 4 | 4 | //! The intention is that this file only contains datatype declarations, no code. |
| 5 | 5 | |
| 6 | use super::{BasicBlock, Const, Local, UserTypeProjection}; | |
| 7 | ||
| 8 | use crate::mir::coverage::CoverageKind; | |
| 9 | use crate::traits::Reveal; | |
| 10 | use crate::ty::adjustment::PointerCoercion; | |
| 11 | use crate::ty::GenericArgsRef; | |
| 12 | use crate::ty::{self, List, Ty}; | |
| 13 | use crate::ty::{Region, UserTypeAnnotationIndex}; | |
| 14 | ||
| 15 | use rustc_ast::{InlineAsmOptions, InlineAsmTemplatePiece}; | |
| 6 | use rustc_ast::{InlineAsmOptions, InlineAsmTemplatePiece, Mutability}; | |
| 16 | 7 | use rustc_data_structures::packed::Pu128; |
| 17 | 8 | use rustc_hir::def_id::DefId; |
| 18 | 9 | use rustc_hir::CoroutineKind; |
| 19 | 10 | use rustc_index::IndexVec; |
| 20 | 11 | use rustc_macros::{HashStable, TyDecodable, TyEncodable, TypeFoldable, TypeVisitable}; |
| 21 | use rustc_span::source_map::Spanned; | |
| 22 | use rustc_target::abi::{FieldIdx, VariantIdx}; | |
| 23 | ||
| 24 | use rustc_ast::Mutability; | |
| 25 | 12 | use rustc_span::def_id::LocalDefId; |
| 13 | use rustc_span::source_map::Spanned; | |
| 26 | 14 | use rustc_span::symbol::Symbol; |
| 27 | 15 | use rustc_span::Span; |
| 16 | use rustc_target::abi::{FieldIdx, VariantIdx}; | |
| 28 | 17 | use rustc_target::asm::InlineAsmRegOrRegClass; |
| 29 | 18 | use smallvec::SmallVec; |
| 30 | 19 | |
| 20 | use super::{BasicBlock, Const, Local, UserTypeProjection}; | |
| 21 | use crate::mir::coverage::CoverageKind; | |
| 22 | use crate::traits::Reveal; | |
| 23 | use crate::ty::adjustment::PointerCoercion; | |
| 24 | use crate::ty::{self, GenericArgsRef, List, Region, Ty, UserTypeAnnotationIndex}; | |
| 25 | ||
| 31 | 26 | /// Represents the "flavors" of MIR. |
| 32 | 27 | /// |
| 33 | 28 | /// All flavors of MIR use the same data structure, but there are some important differences. These |
| ... | ... | @@ -1583,8 +1578,9 @@ pub enum BinOp { |
| 1583 | 1578 | // Some nodes are used a lot. Make sure they don't unintentionally get bigger. |
| 1584 | 1579 | #[cfg(target_pointer_width = "64")] |
| 1585 | 1580 | mod size_asserts { |
| 1586 | use super::*; | |
| 1587 | 1581 | use rustc_data_structures::static_assert_size; |
| 1582 | ||
| 1583 | use super::*; | |
| 1588 | 1584 | // tidy-alphabetical-start |
| 1589 | 1585 | static_assert_size!(AggregateKind<'_>, 32); |
| 1590 | 1586 | static_assert_size!(Operand<'_>, 24); |
compiler/rustc_middle/src/mir/tcx.rs+2-1| ... | ... | @@ -3,10 +3,11 @@ |
| 3 | 3 | * building is complete. |
| 4 | 4 | */ |
| 5 | 5 | |
| 6 | use crate::mir::*; | |
| 7 | 6 | use rustc_hir as hir; |
| 8 | 7 | use tracing::{debug, instrument}; |
| 9 | 8 | |
| 9 | use crate::mir::*; | |
| 10 | ||
| 10 | 11 | #[derive(Copy, Clone, Debug, TypeFoldable, TypeVisitable)] |
| 11 | 12 | pub struct PlaceTy<'tcx> { |
| 12 | 13 | pub ty: Ty<'tcx>, |
compiler/rustc_middle/src/mir/terminator.rs+6-6| ... | ... | @@ -1,14 +1,13 @@ |
| 1 | 1 | //! Functionality for terminators and helper types that appear in terminators. |
| 2 | 2 | |
| 3 | use rustc_hir::LangItem; | |
| 4 | use smallvec::{smallvec, SmallVec}; | |
| 3 | use std::slice; | |
| 5 | 4 | |
| 6 | use super::TerminatorKind; | |
| 7 | 5 | use rustc_data_structures::packed::Pu128; |
| 6 | use rustc_hir::LangItem; | |
| 8 | 7 | use rustc_macros::{HashStable, TyDecodable, TyEncodable, TypeFoldable, TypeVisitable}; |
| 9 | use std::slice; | |
| 8 | use smallvec::{smallvec, SmallVec}; | |
| 10 | 9 | |
| 11 | use super::*; | |
| 10 | use super::{TerminatorKind, *}; | |
| 12 | 11 | |
| 13 | 12 | impl SwitchTargets { |
| 14 | 13 | /// Creates switch targets from an iterator of values and target blocks. |
| ... | ... | @@ -295,9 +294,10 @@ impl<O> AssertKind<O> { |
| 295 | 294 | /// Note that we deliberately show more details here than we do at runtime, such as the actual |
| 296 | 295 | /// numbers that overflowed -- it is much easier to do so here than at runtime. |
| 297 | 296 | pub fn diagnostic_message(&self) -> DiagMessage { |
| 298 | use crate::fluent_generated::*; | |
| 299 | 297 | use AssertKind::*; |
| 300 | 298 | |
| 299 | use crate::fluent_generated::*; | |
| 300 | ||
| 301 | 301 | match self { |
| 302 | 302 | BoundsCheck { .. } => middle_bounds_check, |
| 303 | 303 | Overflow(BinOp::Shl, _, _) => middle_assert_shl_overflow, |
compiler/rustc_middle/src/query/erase.rs+4-4| ... | ... | @@ -1,10 +1,10 @@ |
| 1 | use crate::mir; | |
| 1 | use std::intrinsics::transmute_unchecked; | |
| 2 | use std::mem::MaybeUninit; | |
| 3 | ||
| 2 | 4 | use crate::query::CyclePlaceholder; |
| 3 | use crate::traits; | |
| 4 | 5 | use crate::ty::adjustment::CoerceUnsizedInfo; |
| 5 | 6 | use crate::ty::{self, Ty}; |
| 6 | use std::intrinsics::transmute_unchecked; | |
| 7 | use std::mem::MaybeUninit; | |
| 7 | use crate::{mir, traits}; | |
| 8 | 8 | |
| 9 | 9 | #[derive(Copy, Clone)] |
| 10 | 10 | pub struct Erased<T: Copy> { |
compiler/rustc_middle/src/query/keys.rs+6-7| ... | ... | @@ -1,12 +1,5 @@ |
| 1 | 1 | //! Defines the set of legal keys that can be used in queries. |
| 2 | 2 | |
| 3 | use crate::infer::canonical::Canonical; | |
| 4 | use crate::mir; | |
| 5 | use crate::traits; | |
| 6 | use crate::ty::fast_reject::SimplifiedType; | |
| 7 | use crate::ty::layout::{TyAndLayout, ValidityRequirement}; | |
| 8 | use crate::ty::{self, Ty, TyCtxt}; | |
| 9 | use crate::ty::{GenericArg, GenericArgsRef}; | |
| 10 | 3 | use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, LocalModDefId, ModDefId, LOCAL_CRATE}; |
| 11 | 4 | use rustc_hir::hir_id::{HirId, OwnerId}; |
| 12 | 5 | use rustc_query_system::query::{DefIdCache, DefaultCache, SingleCache, VecCache}; |
| ... | ... | @@ -14,6 +7,12 @@ use rustc_span::symbol::{Ident, Symbol}; |
| 14 | 7 | use rustc_span::{Span, DUMMY_SP}; |
| 15 | 8 | use rustc_target::abi; |
| 16 | 9 | |
| 10 | use crate::infer::canonical::Canonical; | |
| 11 | use crate::ty::fast_reject::SimplifiedType; | |
| 12 | use crate::ty::layout::{TyAndLayout, ValidityRequirement}; | |
| 13 | use crate::ty::{self, GenericArg, GenericArgsRef, Ty, TyCtxt}; | |
| 14 | use crate::{mir, traits}; | |
| 15 | ||
| 17 | 16 | /// Placeholder for `CrateNum`'s "local" counterpart |
| 18 | 17 | #[derive(Copy, Clone, Debug)] |
| 19 | 18 | pub struct LocalCrate; |
compiler/rustc_middle/src/query/mod.rs+46-53| ... | ... | @@ -6,7 +6,44 @@ |
| 6 | 6 | |
| 7 | 7 | #![allow(unused_parens)] |
| 8 | 8 | |
| 9 | use crate::dep_graph; | |
| 9 | use std::mem; | |
| 10 | use std::ops::Deref; | |
| 11 | use std::path::PathBuf; | |
| 12 | use std::sync::Arc; | |
| 13 | ||
| 14 | use rustc_arena::TypedArena; | |
| 15 | use rustc_ast::expand::allocator::AllocatorKind; | |
| 16 | use rustc_ast::expand::StrippedCfgItem; | |
| 17 | use rustc_data_structures::fingerprint::Fingerprint; | |
| 18 | use rustc_data_structures::fx::{FxIndexMap, FxIndexSet}; | |
| 19 | use rustc_data_structures::steal::Steal; | |
| 20 | use rustc_data_structures::svh::Svh; | |
| 21 | use rustc_data_structures::sync::Lrc; | |
| 22 | use rustc_data_structures::unord::{UnordMap, UnordSet}; | |
| 23 | use rustc_errors::ErrorGuaranteed; | |
| 24 | use rustc_hir::def::{DefKind, DocLinkResMap}; | |
| 25 | use rustc_hir::def_id::{ | |
| 26 | CrateNum, DefId, DefIdMap, DefIdSet, LocalDefId, LocalDefIdMap, LocalDefIdSet, LocalModDefId, | |
| 27 | }; | |
| 28 | use rustc_hir::lang_items::{LangItem, LanguageItems}; | |
| 29 | use rustc_hir::{Crate, ItemLocalId, ItemLocalMap, TraitCandidate}; | |
| 30 | use rustc_index::IndexVec; | |
| 31 | use rustc_macros::rustc_queries; | |
| 32 | use rustc_query_system::ich::StableHashingContext; | |
| 33 | use rustc_query_system::query::{try_get_cached, QueryCache, QueryMode, QueryState}; | |
| 34 | use rustc_session::config::{EntryFnType, OptLevel, OutputFilenames, SymbolManglingVersion}; | |
| 35 | use rustc_session::cstore::{ | |
| 36 | CrateDepKind, CrateSource, ExternCrate, ForeignModule, LinkagePreference, NativeLib, | |
| 37 | }; | |
| 38 | use rustc_session::lint::LintExpectationId; | |
| 39 | use rustc_session::Limits; | |
| 40 | use rustc_span::def_id::LOCAL_CRATE; | |
| 41 | use rustc_span::symbol::Symbol; | |
| 42 | use rustc_span::{Span, DUMMY_SP}; | |
| 43 | use rustc_target::abi; | |
| 44 | use rustc_target::spec::PanicStrategy; | |
| 45 | use {rustc_ast as ast, rustc_attr as attr, rustc_hir as hir}; | |
| 46 | ||
| 10 | 47 | use crate::infer::canonical::{self, Canonical}; |
| 11 | 48 | use crate::lint::LintExpectation; |
| 12 | 49 | use crate::metadata::ModChild; |
| ... | ... | @@ -17,79 +54,35 @@ use crate::middle::lib_features::LibFeatures; |
| 17 | 54 | use crate::middle::privacy::EffectiveVisibilities; |
| 18 | 55 | use crate::middle::resolve_bound_vars::{ObjectLifetimeDefault, ResolveBoundVars, ResolvedArg}; |
| 19 | 56 | use crate::middle::stability::{self, DeprecationEntry}; |
| 20 | use crate::mir; | |
| 21 | use crate::mir::interpret::GlobalId; | |
| 22 | 57 | use crate::mir::interpret::{ |
| 23 | 58 | EvalStaticInitializerRawResult, EvalToAllocationRawResult, EvalToConstValueResult, |
| 24 | EvalToValTreeResult, | |
| 59 | EvalToValTreeResult, GlobalId, LitToConstError, LitToConstInput, | |
| 25 | 60 | }; |
| 26 | use crate::mir::interpret::{LitToConstError, LitToConstInput}; | |
| 27 | 61 | use crate::mir::mono::CodegenUnit; |
| 28 | 62 | use crate::query::erase::{erase, restore, Erase}; |
| 29 | 63 | use crate::query::plumbing::{ |
| 30 | 64 | query_ensure, query_ensure_error_guaranteed, query_get_at, CyclePlaceholder, DynamicQuery, |
| 31 | 65 | }; |
| 32 | use crate::thir; | |
| 33 | 66 | use crate::traits::query::{ |
| 34 | 67 | CanonicalAliasGoal, CanonicalPredicateGoal, CanonicalTyGoal, |
| 35 | 68 | CanonicalTypeOpAscribeUserTypeGoal, CanonicalTypeOpEqGoal, CanonicalTypeOpNormalizeGoal, |
| 36 | CanonicalTypeOpProvePredicateGoal, CanonicalTypeOpSubtypeGoal, NoSolution, | |
| 37 | }; | |
| 38 | use crate::traits::query::{ | |
| 39 | DropckConstraint, DropckOutlivesResult, MethodAutoderefStepsResult, NormalizationResult, | |
| 69 | CanonicalTypeOpProvePredicateGoal, CanonicalTypeOpSubtypeGoal, DropckConstraint, | |
| 70 | DropckOutlivesResult, MethodAutoderefStepsResult, NoSolution, NormalizationResult, | |
| 40 | 71 | OutlivesBound, |
| 41 | 72 | }; |
| 42 | use crate::traits::specialization_graph; | |
| 43 | 73 | use crate::traits::{ |
| 44 | CodegenObligationError, EvaluationResult, ImplSource, ObjectSafetyViolation, ObligationCause, | |
| 45 | OverflowError, WellFormedLoc, | |
| 74 | specialization_graph, CodegenObligationError, EvaluationResult, ImplSource, | |
| 75 | ObjectSafetyViolation, ObligationCause, OverflowError, WellFormedLoc, | |
| 46 | 76 | }; |
| 47 | 77 | use crate::ty::fast_reject::SimplifiedType; |
| 48 | 78 | use crate::ty::layout::ValidityRequirement; |
| 49 | use crate::ty::print::PrintTraitRefExt; | |
| 79 | use crate::ty::print::{describe_as_module, PrintTraitRefExt}; | |
| 50 | 80 | use crate::ty::util::AlwaysRequiresDrop; |
| 51 | use crate::ty::TyCtxtFeed; | |
| 52 | 81 | use crate::ty::{ |
| 53 | self, print::describe_as_module, CrateInherentImpls, ParamEnvAnd, Ty, TyCtxt, | |
| 82 | self, CrateInherentImpls, GenericArg, GenericArgsRef, ParamEnvAnd, Ty, TyCtxt, TyCtxtFeed, | |
| 54 | 83 | UnusedGenericParams, |
| 55 | 84 | }; |
| 56 | use crate::ty::{GenericArg, GenericArgsRef}; | |
| 57 | use rustc_arena::TypedArena; | |
| 58 | use rustc_ast as ast; | |
| 59 | use rustc_ast::expand::{allocator::AllocatorKind, StrippedCfgItem}; | |
| 60 | use rustc_attr as attr; | |
| 61 | use rustc_data_structures::fingerprint::Fingerprint; | |
| 62 | use rustc_data_structures::fx::{FxIndexMap, FxIndexSet}; | |
| 63 | use rustc_data_structures::steal::Steal; | |
| 64 | use rustc_data_structures::svh::Svh; | |
| 65 | use rustc_data_structures::sync::Lrc; | |
| 66 | use rustc_data_structures::unord::{UnordMap, UnordSet}; | |
| 67 | use rustc_errors::ErrorGuaranteed; | |
| 68 | use rustc_hir as hir; | |
| 69 | use rustc_hir::def::{DefKind, DocLinkResMap}; | |
| 70 | use rustc_hir::def_id::{ | |
| 71 | CrateNum, DefId, DefIdMap, DefIdSet, LocalDefId, LocalDefIdMap, LocalDefIdSet, LocalModDefId, | |
| 72 | }; | |
| 73 | use rustc_hir::lang_items::{LangItem, LanguageItems}; | |
| 74 | use rustc_hir::{Crate, ItemLocalId, ItemLocalMap, TraitCandidate}; | |
| 75 | use rustc_index::IndexVec; | |
| 76 | use rustc_macros::rustc_queries; | |
| 77 | use rustc_query_system::ich::StableHashingContext; | |
| 78 | use rustc_query_system::query::{try_get_cached, QueryCache, QueryMode, QueryState}; | |
| 79 | use rustc_session::config::{EntryFnType, OptLevel, OutputFilenames, SymbolManglingVersion}; | |
| 80 | use rustc_session::cstore::{CrateDepKind, CrateSource}; | |
| 81 | use rustc_session::cstore::{ExternCrate, ForeignModule, LinkagePreference, NativeLib}; | |
| 82 | use rustc_session::lint::LintExpectationId; | |
| 83 | use rustc_session::Limits; | |
| 84 | use rustc_span::def_id::LOCAL_CRATE; | |
| 85 | use rustc_span::symbol::Symbol; | |
| 86 | use rustc_span::{Span, DUMMY_SP}; | |
| 87 | use rustc_target::abi; | |
| 88 | use rustc_target::spec::PanicStrategy; | |
| 89 | use std::mem; | |
| 90 | use std::ops::Deref; | |
| 91 | use std::path::PathBuf; | |
| 92 | use std::sync::Arc; | |
| 85 | use crate::{dep_graph, mir, thir}; | |
| 93 | 86 | |
| 94 | 87 | pub mod erase; |
| 95 | 88 | mod keys; |
compiler/rustc_middle/src/query/on_disk_cache.rs+7-9| ... | ... | @@ -1,3 +1,6 @@ |
| 1 | use std::collections::hash_map::Entry; | |
| 2 | use std::mem; | |
| 3 | ||
| 1 | 4 | use rustc_data_structures::fx::{FxHashMap, FxIndexSet}; |
| 2 | 5 | use rustc_data_structures::memmap::Mmap; |
| 3 | 6 | use rustc_data_structures::sync::{HashMapExt, Lock, Lrc, RwLock}; |
| ... | ... | @@ -13,22 +16,17 @@ use rustc_middle::mir::{self, interpret}; |
| 13 | 16 | use rustc_middle::ty::codec::{RefDecodable, TyDecoder, TyEncoder}; |
| 14 | 17 | use rustc_middle::ty::{self, Ty, TyCtxt}; |
| 15 | 18 | use rustc_query_system::query::QuerySideEffects; |
| 16 | use rustc_serialize::{ | |
| 17 | opaque::{FileEncodeResult, FileEncoder, IntEncodedWithFixedSize, MemDecoder}, | |
| 18 | Decodable, Decoder, Encodable, Encoder, | |
| 19 | }; | |
| 19 | use rustc_serialize::opaque::{FileEncodeResult, FileEncoder, IntEncodedWithFixedSize, MemDecoder}; | |
| 20 | use rustc_serialize::{Decodable, Decoder, Encodable, Encoder}; | |
| 20 | 21 | use rustc_session::Session; |
| 21 | 22 | use rustc_span::hygiene::{ |
| 22 | 23 | ExpnId, HygieneDecodeContext, HygieneEncodeContext, SyntaxContext, SyntaxContextData, |
| 23 | 24 | }; |
| 24 | 25 | use rustc_span::source_map::SourceMap; |
| 25 | 26 | use rustc_span::{ |
| 26 | BytePos, ExpnData, ExpnHash, Pos, RelativeBytePos, SourceFile, Span, SpanDecoder, SpanEncoder, | |
| 27 | StableSourceFileId, | |
| 27 | BytePos, CachingSourceMapView, ExpnData, ExpnHash, Pos, RelativeBytePos, SourceFile, Span, | |
| 28 | SpanDecoder, SpanEncoder, StableSourceFileId, Symbol, | |
| 28 | 29 | }; |
| 29 | use rustc_span::{CachingSourceMapView, Symbol}; | |
| 30 | use std::collections::hash_map::Entry; | |
| 31 | use std::mem; | |
| 32 | 30 | |
| 33 | 31 | const TAG_FILE_FOOTER: u128 = 0xC0FFEE_C0FFEE_C0FFEE_C0FFEE_C0FFEE; |
| 34 | 32 |
compiler/rustc_middle/src/query/plumbing.rs+14-15| ... | ... | @@ -1,25 +1,23 @@ |
| 1 | use crate::dep_graph; | |
| 2 | use crate::dep_graph::DepKind; | |
| 3 | use crate::query::on_disk_cache::CacheEncoder; | |
| 4 | use crate::query::on_disk_cache::EncodedDepNodeIndex; | |
| 5 | use crate::query::on_disk_cache::OnDiskCache; | |
| 6 | use crate::query::{ | |
| 7 | DynamicQueries, ExternProviders, Providers, QueryArenas, QueryCaches, QueryEngine, QueryStates, | |
| 8 | }; | |
| 9 | use crate::ty::TyCtxt; | |
| 1 | use std::ops::Deref; | |
| 2 | ||
| 10 | 3 | use field_offset::FieldOffset; |
| 11 | use rustc_data_structures::sync::AtomicU64; | |
| 12 | use rustc_data_structures::sync::WorkerLocal; | |
| 4 | use rustc_data_structures::sync::{AtomicU64, WorkerLocal}; | |
| 13 | 5 | use rustc_hir::def_id::{DefId, LocalDefId}; |
| 14 | 6 | use rustc_hir::hir_id::OwnerId; |
| 15 | 7 | use rustc_macros::HashStable; |
| 16 | use rustc_query_system::dep_graph::DepNodeIndex; | |
| 17 | use rustc_query_system::dep_graph::SerializedDepNodeIndex; | |
| 8 | use rustc_query_system::dep_graph::{DepNodeIndex, SerializedDepNodeIndex}; | |
| 18 | 9 | pub(crate) use rustc_query_system::query::QueryJobId; |
| 19 | 10 | use rustc_query_system::query::*; |
| 20 | 11 | use rustc_query_system::HandleCycleError; |
| 21 | 12 | use rustc_span::{ErrorGuaranteed, Span, DUMMY_SP}; |
| 22 | use std::ops::Deref; | |
| 13 | ||
| 14 | use crate::dep_graph; | |
| 15 | use crate::dep_graph::DepKind; | |
| 16 | use crate::query::on_disk_cache::{CacheEncoder, EncodedDepNodeIndex, OnDiskCache}; | |
| 17 | use crate::query::{ | |
| 18 | DynamicQueries, ExternProviders, Providers, QueryArenas, QueryCaches, QueryEngine, QueryStates, | |
| 19 | }; | |
| 20 | use crate::ty::TyCtxt; | |
| 23 | 21 | |
| 24 | 22 | pub struct DynamicQuery<'tcx, C: QueryCache> { |
| 25 | 23 | pub name: &'static str, |
| ... | ... | @@ -574,9 +572,10 @@ macro_rules! define_feedable { |
| 574 | 572 | // as they will raise an fatal error on query cycles instead. |
| 575 | 573 | |
| 576 | 574 | mod sealed { |
| 577 | use super::{DefId, LocalDefId, OwnerId}; | |
| 578 | 575 | use rustc_hir::def_id::{LocalModDefId, ModDefId}; |
| 579 | 576 | |
| 577 | use super::{DefId, LocalDefId, OwnerId}; | |
| 578 | ||
| 580 | 579 | /// An analogue of the `Into` trait that's intended only for query parameters. |
| 581 | 580 | /// |
| 582 | 581 | /// This exists to allow queries to accept either `DefId` or `LocalDefId` while requiring that the |
compiler/rustc_middle/src/thir.rs+7-6| ... | ... | @@ -8,13 +8,16 @@ |
| 8 | 8 | //! |
| 9 | 9 | //! [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/thir.html |
| 10 | 10 | |
| 11 | use std::cmp::Ordering; | |
| 12 | use std::fmt; | |
| 13 | use std::ops::Index; | |
| 14 | ||
| 11 | 15 | use rustc_ast::{InlineAsmOptions, InlineAsmTemplatePiece}; |
| 12 | 16 | use rustc_errors::{DiagArgValue, IntoDiagArg}; |
| 13 | 17 | use rustc_hir as hir; |
| 14 | 18 | use rustc_hir::def_id::DefId; |
| 15 | 19 | use rustc_hir::{BindingMode, ByRef, HirId, MatchSource, RangeEnd}; |
| 16 | use rustc_index::newtype_index; | |
| 17 | use rustc_index::IndexVec; | |
| 20 | use rustc_index::{newtype_index, IndexVec}; | |
| 18 | 21 | use rustc_macros::{HashStable, TyDecodable, TyEncodable, TypeVisitable}; |
| 19 | 22 | use rustc_middle::middle::region; |
| 20 | 23 | use rustc_middle::mir::interpret::AllocId; |
| ... | ... | @@ -29,9 +32,6 @@ use rustc_span::def_id::LocalDefId; |
| 29 | 32 | use rustc_span::{sym, ErrorGuaranteed, Span, Symbol, DUMMY_SP}; |
| 30 | 33 | use rustc_target::abi::{FieldIdx, Integer, Size, VariantIdx}; |
| 31 | 34 | use rustc_target::asm::InlineAsmRegOrRegClass; |
| 32 | use std::cmp::Ordering; | |
| 33 | use std::fmt; | |
| 34 | use std::ops::Index; | |
| 35 | 35 | use tracing::instrument; |
| 36 | 36 | |
| 37 | 37 | pub mod visit; |
| ... | ... | @@ -1236,8 +1236,9 @@ impl<'tcx> fmt::Display for Pat<'tcx> { |
| 1236 | 1236 | // Some nodes are used a lot. Make sure they don't unintentionally get bigger. |
| 1237 | 1237 | #[cfg(target_pointer_width = "64")] |
| 1238 | 1238 | mod size_asserts { |
| 1239 | use super::*; | |
| 1240 | 1239 | use rustc_data_structures::static_assert_size; |
| 1240 | ||
| 1241 | use super::*; | |
| 1241 | 1242 | // tidy-alphabetical-start |
| 1242 | 1243 | static_assert_size!(Block, 48); |
| 1243 | 1244 | static_assert_size!(Expr<'_>, 64); |
compiler/rustc_middle/src/traits/mod.rs+7-9| ... | ... | @@ -8,10 +8,8 @@ pub mod solve; |
| 8 | 8 | pub mod specialization_graph; |
| 9 | 9 | mod structural_impls; |
| 10 | 10 | |
| 11 | use crate::mir::ConstraintCategory; | |
| 12 | use crate::ty::abstract_const::NotConstEvaluatable; | |
| 13 | use crate::ty::GenericArgsRef; | |
| 14 | use crate::ty::{self, AdtKind, Ty}; | |
| 11 | use std::borrow::Cow; | |
| 12 | use std::hash::{Hash, Hasher}; | |
| 15 | 13 | |
| 16 | 14 | use rustc_data_structures::sync::Lrc; |
| 17 | 15 | use rustc_errors::{Applicability, Diag, EmissionGuarantee}; |
| ... | ... | @@ -24,14 +22,14 @@ use rustc_macros::{ |
| 24 | 22 | use rustc_span::def_id::{LocalDefId, CRATE_DEF_ID}; |
| 25 | 23 | use rustc_span::symbol::Symbol; |
| 26 | 24 | use rustc_span::{Span, DUMMY_SP}; |
| 25 | // FIXME: Remove this import and import via `solve::` | |
| 26 | pub use rustc_type_ir::solve::{BuiltinImplSource, Reveal}; | |
| 27 | 27 | use smallvec::{smallvec, SmallVec}; |
| 28 | 28 | |
| 29 | use std::borrow::Cow; | |
| 30 | use std::hash::{Hash, Hasher}; | |
| 31 | ||
| 32 | 29 | pub use self::select::{EvaluationCache, EvaluationResult, OverflowError, SelectionCache}; |
| 33 | // FIXME: Remove this import and import via `solve::` | |
| 34 | pub use rustc_type_ir::solve::{BuiltinImplSource, Reveal}; | |
| 30 | use crate::mir::ConstraintCategory; | |
| 31 | use crate::ty::abstract_const::NotConstEvaluatable; | |
| 32 | use crate::ty::{self, AdtKind, GenericArgsRef, Ty}; | |
| 35 | 33 | |
| 36 | 34 | /// The reason why we incurred this obligation; used for error reporting. |
| 37 | 35 | /// |
compiler/rustc_middle/src/traits/query.rs+8-6| ... | ... | @@ -5,20 +5,22 @@ |
| 5 | 5 | //! The providers for the queries defined here can be found in |
| 6 | 6 | //! `rustc_traits`. |
| 7 | 7 | |
| 8 | use crate::error::DropCheckOverflow; | |
| 9 | use crate::infer::canonical::{Canonical, QueryResponse}; | |
| 10 | use crate::ty::GenericArg; | |
| 11 | use crate::ty::{self, Ty, TyCtxt}; | |
| 12 | 8 | use rustc_macros::{HashStable, TypeFoldable, TypeVisitable}; |
| 13 | 9 | use rustc_span::Span; |
| 14 | 10 | // FIXME: Remove this import and import via `traits::solve`. |
| 15 | 11 | pub use rustc_type_ir::solve::NoSolution; |
| 16 | 12 | |
| 13 | use crate::error::DropCheckOverflow; | |
| 14 | use crate::infer::canonical::{Canonical, QueryResponse}; | |
| 15 | use crate::ty::{self, GenericArg, Ty, TyCtxt}; | |
| 16 | ||
| 17 | 17 | pub mod type_op { |
| 18 | use std::fmt; | |
| 19 | ||
| 20 | use rustc_macros::{HashStable, TypeFoldable, TypeVisitable}; | |
| 21 | ||
| 18 | 22 | use crate::ty::fold::TypeFoldable; |
| 19 | 23 | use crate::ty::{Predicate, Ty, TyCtxt, UserType}; |
| 20 | use rustc_macros::{HashStable, TypeFoldable, TypeVisitable}; | |
| 21 | use std::fmt; | |
| 22 | 24 | |
| 23 | 25 | #[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, HashStable, TypeFoldable, TypeVisitable)] |
| 24 | 26 | pub struct AscribeUserType<'tcx> { |
compiler/rustc_middle/src/traits/select.rs+4-6| ... | ... | @@ -2,17 +2,15 @@ |
| 2 | 2 | //! |
| 3 | 3 | //! [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/traits/resolution.html#selection |
| 4 | 4 | |
| 5 | use self::EvaluationResult::*; | |
| 6 | ||
| 7 | use super::{SelectionError, SelectionResult}; | |
| 8 | 5 | use rustc_errors::ErrorGuaranteed; |
| 9 | ||
| 10 | use crate::ty; | |
| 11 | ||
| 12 | 6 | use rustc_hir::def_id::DefId; |
| 13 | 7 | use rustc_macros::{HashStable, TypeVisitable}; |
| 14 | 8 | use rustc_query_system::cache::Cache; |
| 15 | 9 | |
| 10 | use self::EvaluationResult::*; | |
| 11 | use super::{SelectionError, SelectionResult}; | |
| 12 | use crate::ty; | |
| 13 | ||
| 16 | 14 | pub type SelectionCache<'tcx> = Cache< |
| 17 | 15 | // This cache does not use `ParamEnvAnd` in its keys because `ParamEnv::and` can replace |
| 18 | 16 | // caller bounds with an empty list if the `TraitPredicate` looks global, which may happen |
compiler/rustc_middle/src/traits/specialization_graph.rs+5-4| ... | ... | @@ -1,13 +1,14 @@ |
| 1 | use crate::error::StrictCoherenceNeedsNegativeCoherence; | |
| 2 | use crate::ty::fast_reject::SimplifiedType; | |
| 3 | use crate::ty::visit::TypeVisitableExt; | |
| 4 | use crate::ty::{self, TyCtxt}; | |
| 5 | 1 | use rustc_data_structures::fx::FxIndexMap; |
| 6 | 2 | use rustc_errors::ErrorGuaranteed; |
| 7 | 3 | use rustc_hir::def_id::{DefId, DefIdMap}; |
| 8 | 4 | use rustc_macros::{HashStable, TyDecodable, TyEncodable}; |
| 9 | 5 | use rustc_span::symbol::sym; |
| 10 | 6 | |
| 7 | use crate::error::StrictCoherenceNeedsNegativeCoherence; | |
| 8 | use crate::ty::fast_reject::SimplifiedType; | |
| 9 | use crate::ty::visit::TypeVisitableExt; | |
| 10 | use crate::ty::{self, TyCtxt}; | |
| 11 | ||
| 11 | 12 | /// A per-trait graph of impls in specialization order. At the moment, this |
| 12 | 13 | /// graph forms a tree rooted with the trait itself, with all other nodes |
| 13 | 14 | /// representing impls, and parent-child relationships representing |
compiler/rustc_middle/src/traits/structural_impls.rs+2-2| ... | ... | @@ -1,7 +1,7 @@ |
| 1 | use crate::traits; | |
| 2 | ||
| 3 | 1 | use std::fmt; |
| 4 | 2 | |
| 3 | use crate::traits; | |
| 4 | ||
| 5 | 5 | // Structural impls for the structs in `traits`. |
| 6 | 6 | |
| 7 | 7 | impl<'tcx, N: fmt::Debug> fmt::Debug for traits::ImplSource<'tcx, N> { |
compiler/rustc_middle/src/ty/abstract_const.rs+3-2| ... | ... | @@ -1,11 +1,12 @@ |
| 1 | 1 | //! A subset of a mir body used for const evaluability checking. |
| 2 | 2 | |
| 3 | use rustc_errors::ErrorGuaranteed; | |
| 4 | use rustc_macros::{HashStable, TyDecodable, TyEncodable, TypeVisitable}; | |
| 5 | ||
| 3 | 6 | use crate::ty::{ |
| 4 | 7 | self, Const, EarlyBinder, Ty, TyCtxt, TypeFoldable, TypeFolder, TypeSuperFoldable, |
| 5 | 8 | TypeVisitableExt, |
| 6 | 9 | }; |
| 7 | use rustc_errors::ErrorGuaranteed; | |
| 8 | use rustc_macros::{HashStable, TyDecodable, TyEncodable, TypeVisitable}; | |
| 9 | 10 | |
| 10 | 11 | #[derive(Hash, Debug, Clone, Copy, Ord, PartialOrd, PartialEq, Eq)] |
| 11 | 12 | #[derive(TyDecodable, TyEncodable, HashStable, TypeVisitable, TypeFoldable)] |
compiler/rustc_middle/src/ty/adjustment.rs+2-1| ... | ... | @@ -1,10 +1,11 @@ |
| 1 | use crate::ty::{self, Ty, TyCtxt}; | |
| 2 | 1 | use rustc_hir as hir; |
| 3 | 2 | use rustc_hir::lang_items::LangItem; |
| 4 | 3 | use rustc_macros::{HashStable, TyDecodable, TyEncodable, TypeFoldable, TypeVisitable}; |
| 5 | 4 | use rustc_span::Span; |
| 6 | 5 | use rustc_target::abi::FieldIdx; |
| 7 | 6 | |
| 7 | use crate::ty::{self, Ty, TyCtxt}; | |
| 8 | ||
| 8 | 9 | #[derive(Clone, Copy, Debug, PartialEq, Eq, TyEncodable, TyDecodable, Hash, HashStable)] |
| 9 | 10 | pub enum PointerCoercion { |
| 10 | 11 | /// Go from a fn-item type to a fn-pointer type. |
compiler/rustc_middle/src/ty/adt.rs+9-10| ... | ... | @@ -1,12 +1,13 @@ |
| 1 | use crate::mir::interpret::ErrorHandled; | |
| 2 | use crate::ty; | |
| 3 | use crate::ty::util::{Discr, IntTypeExt}; | |
| 1 | use std::cell::RefCell; | |
| 2 | use std::hash::{Hash, Hasher}; | |
| 3 | use std::ops::Range; | |
| 4 | use std::str; | |
| 5 | ||
| 4 | 6 | use rustc_data_structures::captures::Captures; |
| 5 | 7 | use rustc_data_structures::fingerprint::Fingerprint; |
| 6 | 8 | use rustc_data_structures::fx::FxHashMap; |
| 7 | 9 | use rustc_data_structures::intern::Interned; |
| 8 | use rustc_data_structures::stable_hasher::HashingControls; | |
| 9 | use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; | |
| 10 | use rustc_data_structures::stable_hasher::{HashStable, HashingControls, StableHasher}; | |
| 10 | 11 | use rustc_errors::ErrorGuaranteed; |
| 11 | 12 | use rustc_hir::def::{CtorKind, DefKind, Res}; |
| 12 | 13 | use rustc_hir::def_id::DefId; |
| ... | ... | @@ -19,14 +20,12 @@ use rustc_span::symbol::sym; |
| 19 | 20 | use rustc_target::abi::{ReprOptions, VariantIdx, FIRST_VARIANT}; |
| 20 | 21 | use tracing::{debug, info, trace}; |
| 21 | 22 | |
| 22 | use std::cell::RefCell; | |
| 23 | use std::hash::{Hash, Hasher}; | |
| 24 | use std::ops::Range; | |
| 25 | use std::str; | |
| 26 | ||
| 27 | 23 | use super::{ |
| 28 | 24 | AsyncDestructor, Destructor, FieldDef, GenericPredicates, Ty, TyCtxt, VariantDef, VariantDiscr, |
| 29 | 25 | }; |
| 26 | use crate::mir::interpret::ErrorHandled; | |
| 27 | use crate::ty; | |
| 28 | use crate::ty::util::{Discr, IntTypeExt}; | |
| 30 | 29 | |
| 31 | 30 | #[derive(Clone, Copy, PartialEq, Eq, Hash, HashStable, TyEncodable, TyDecodable)] |
| 32 | 31 | pub struct AdtFlags(u16); |
compiler/rustc_middle/src/ty/assoc.rs+1-1| ... | ... | @@ -1,4 +1,3 @@ |
| 1 | use crate::ty; | |
| 2 | 1 | use rustc_data_structures::sorted_map::SortedIndexMultiMap; |
| 3 | 2 | use rustc_hir as hir; |
| 4 | 3 | use rustc_hir::def::{DefKind, Namespace}; |
| ... | ... | @@ -7,6 +6,7 @@ use rustc_macros::{Decodable, Encodable, HashStable}; |
| 7 | 6 | use rustc_span::symbol::{Ident, Symbol}; |
| 8 | 7 | |
| 9 | 8 | use super::{TyCtxt, Visibility}; |
| 9 | use crate::ty; | |
| 10 | 10 | |
| 11 | 11 | #[derive(Clone, Copy, PartialEq, Eq, Debug, HashStable, Hash, Encodable, Decodable)] |
| 12 | 12 | pub enum AssocItemContainer { |
compiler/rustc_middle/src/ty/cast.rs+2-2| ... | ... | @@ -1,10 +1,10 @@ |
| 1 | 1 | // Helpers for handling cast expressions, used in both |
| 2 | 2 | // typeck and codegen. |
| 3 | 3 | |
| 4 | use crate::ty::{self, Ty}; | |
| 4 | use rustc_macros::{HashStable, TyDecodable, TyEncodable}; | |
| 5 | 5 | use rustc_middle::mir; |
| 6 | 6 | |
| 7 | use rustc_macros::{HashStable, TyDecodable, TyEncodable}; | |
| 7 | use crate::ty::{self, Ty}; | |
| 8 | 8 | |
| 9 | 9 | /// Types that are represented as ints. |
| 10 | 10 | #[derive(Copy, Clone, Debug, PartialEq, Eq)] |
compiler/rustc_middle/src/ty/closure.rs+6-8| ... | ... | @@ -1,11 +1,5 @@ |
| 1 | use crate::hir::place::{ | |
| 2 | Place as HirPlace, PlaceBase as HirPlaceBase, ProjectionKind as HirProjectionKind, | |
| 3 | }; | |
| 4 | use crate::{mir, ty}; | |
| 5 | ||
| 6 | 1 | use std::fmt::Write; |
| 7 | 2 | |
| 8 | use crate::query::Providers; | |
| 9 | 3 | use rustc_data_structures::captures::Captures; |
| 10 | 4 | use rustc_data_structures::fx::FxIndexMap; |
| 11 | 5 | use rustc_hir as hir; |
| ... | ... | @@ -16,9 +10,13 @@ use rustc_span::def_id::LocalDefIdMap; |
| 16 | 10 | use rustc_span::symbol::Ident; |
| 17 | 11 | use rustc_span::{Span, Symbol}; |
| 18 | 12 | |
| 19 | use super::TyCtxt; | |
| 20 | ||
| 21 | 13 | use self::BorrowKind::*; |
| 14 | use super::TyCtxt; | |
| 15 | use crate::hir::place::{ | |
| 16 | Place as HirPlace, PlaceBase as HirPlaceBase, ProjectionKind as HirProjectionKind, | |
| 17 | }; | |
| 18 | use crate::query::Providers; | |
| 19 | use crate::{mir, ty}; | |
| 22 | 20 | |
| 23 | 21 | /// Captures are represented using fields inside a structure. |
| 24 | 22 | /// This represents accessing self in the closure structure |
compiler/rustc_middle/src/ty/codec.rs+11-13| ... | ... | @@ -6,16 +6,10 @@ |
| 6 | 6 | //! The functionality in here is shared between persisting to crate metadata and |
| 7 | 7 | //! persisting to incr. comp. caches. |
| 8 | 8 | |
| 9 | use crate::arena::ArenaAllocatable; | |
| 10 | use crate::infer::canonical::{CanonicalVarInfo, CanonicalVarInfos}; | |
| 11 | use crate::mir::interpret::CtfeProvenance; | |
| 12 | use crate::mir::{ | |
| 13 | self, | |
| 14 | interpret::{AllocId, ConstAllocation}, | |
| 15 | }; | |
| 16 | use crate::traits; | |
| 17 | use crate::ty::GenericArgsRef; | |
| 18 | use crate::ty::{self, AdtDef, Ty}; | |
| 9 | use std::hash::Hash; | |
| 10 | use std::intrinsics; | |
| 11 | use std::marker::DiscriminantKind; | |
| 12 | ||
| 19 | 13 | use rustc_data_structures::fx::FxHashMap; |
| 20 | 14 | use rustc_hir::def_id::LocalDefId; |
| 21 | 15 | use rustc_middle::ty::TyCtxt; |
| ... | ... | @@ -23,9 +17,13 @@ use rustc_serialize::{Decodable, Encodable}; |
| 23 | 17 | use rustc_span::Span; |
| 24 | 18 | use rustc_target::abi::{FieldIdx, VariantIdx}; |
| 25 | 19 | pub use rustc_type_ir::{TyDecoder, TyEncoder}; |
| 26 | use std::hash::Hash; | |
| 27 | use std::intrinsics; | |
| 28 | use std::marker::DiscriminantKind; | |
| 20 | ||
| 21 | use crate::arena::ArenaAllocatable; | |
| 22 | use crate::infer::canonical::{CanonicalVarInfo, CanonicalVarInfos}; | |
| 23 | use crate::mir::interpret::{AllocId, ConstAllocation, CtfeProvenance}; | |
| 24 | use crate::mir::{self}; | |
| 25 | use crate::traits; | |
| 26 | use crate::ty::{self, AdtDef, GenericArgsRef, Ty}; | |
| 29 | 27 | |
| 30 | 28 | /// The shorthand encoding uses an enum's variant index `usize` |
| 31 | 29 | /// and is offset by this value so it never matches a real variant. |
compiler/rustc_middle/src/ty/consts.rs+5-5| ... | ... | @@ -1,6 +1,3 @@ |
| 1 | use crate::middle::resolve_bound_vars as rbv; | |
| 2 | use crate::mir::interpret::{ErrorHandled, LitToConstInput, Scalar}; | |
| 3 | use crate::ty::{self, GenericArgs, ParamEnv, ParamEnvAnd, Ty, TyCtxt, TypeVisitableExt}; | |
| 4 | 1 | use either::Either; |
| 5 | 2 | use rustc_data_structures::intern::Interned; |
| 6 | 3 | use rustc_error_messages::MultiSpan; |
| ... | ... | @@ -11,14 +8,17 @@ use rustc_macros::HashStable; |
| 11 | 8 | use rustc_type_ir::{self as ir, TypeFlags, WithCachedTypeInfo}; |
| 12 | 9 | use tracing::{debug, instrument}; |
| 13 | 10 | |
| 11 | use crate::middle::resolve_bound_vars as rbv; | |
| 12 | use crate::mir::interpret::{ErrorHandled, LitToConstInput, Scalar}; | |
| 13 | use crate::ty::{self, GenericArgs, ParamEnv, ParamEnvAnd, Ty, TyCtxt, TypeVisitableExt}; | |
| 14 | ||
| 14 | 15 | mod int; |
| 15 | 16 | mod kind; |
| 16 | 17 | mod valtree; |
| 17 | 18 | |
| 18 | 19 | pub use int::*; |
| 19 | 20 | pub use kind::*; |
| 20 | use rustc_span::DUMMY_SP; | |
| 21 | use rustc_span::{ErrorGuaranteed, Span}; | |
| 21 | use rustc_span::{ErrorGuaranteed, Span, DUMMY_SP}; | |
| 22 | 22 | pub use valtree::*; |
| 23 | 23 | |
| 24 | 24 | pub type ConstKind<'tcx> = ir::ConstKind<TyCtxt<'tcx>>; |
compiler/rustc_middle/src/ty/consts/int.rs+3-2| ... | ... | @@ -1,10 +1,11 @@ |
| 1 | use std::fmt; | |
| 2 | use std::num::NonZero; | |
| 3 | ||
| 1 | 4 | use rustc_apfloat::ieee::{Double, Half, Quad, Single}; |
| 2 | 5 | use rustc_apfloat::Float; |
| 3 | 6 | use rustc_errors::{DiagArgValue, IntoDiagArg}; |
| 4 | 7 | use rustc_serialize::{Decodable, Decoder, Encodable, Encoder}; |
| 5 | 8 | use rustc_target::abi::Size; |
| 6 | use std::fmt; | |
| 7 | use std::num::NonZero; | |
| 8 | 9 | |
| 9 | 10 | use crate::ty::TyCtxt; |
| 10 | 11 |
compiler/rustc_middle/src/ty/consts/kind.rs+4-2| ... | ... | @@ -1,8 +1,10 @@ |
| 1 | use rustc_macros::{extension, HashStable, TyDecodable, TyEncodable, TypeFoldable, TypeVisitable}; | |
| 2 | ||
| 1 | 3 | use super::Const; |
| 2 | 4 | use crate::mir; |
| 3 | 5 | use crate::ty::abstract_const::CastKind; |
| 4 | use crate::ty::{self, visit::TypeVisitableExt as _, Ty, TyCtxt}; | |
| 5 | use rustc_macros::{extension, HashStable, TyDecodable, TyEncodable, TypeFoldable, TypeVisitable}; | |
| 6 | use crate::ty::visit::TypeVisitableExt as _; | |
| 7 | use crate::ty::{self, Ty, TyCtxt}; | |
| 6 | 8 | |
| 7 | 9 | #[extension(pub(crate) trait UnevaluatedConstEvalExt<'tcx>)] |
| 8 | 10 | impl<'tcx> ty::UnevaluatedConst<'tcx> { |
compiler/rustc_middle/src/ty/consts/valtree.rs+2-1| ... | ... | @@ -1,7 +1,8 @@ |
| 1 | use rustc_macros::{HashStable, TyDecodable, TyEncodable}; | |
| 2 | ||
| 1 | 3 | use super::ScalarInt; |
| 2 | 4 | use crate::mir::interpret::Scalar; |
| 3 | 5 | use crate::ty::{self, Ty, TyCtxt}; |
| 4 | use rustc_macros::{HashStable, TyDecodable, TyEncodable}; | |
| 5 | 6 | |
| 6 | 7 | #[derive(Copy, Clone, Debug, Hash, TyEncodable, TyDecodable, Eq, PartialEq)] |
| 7 | 8 | #[derive(HashStable)] |
compiler/rustc_middle/src/ty/context.rs+33-38| ... | ... | @@ -4,36 +4,14 @@ |
| 4 | 4 | |
| 5 | 5 | pub mod tls; |
| 6 | 6 | |
| 7 | pub use rustc_type_ir::lift::Lift; | |
| 7 | use std::assert_matches::assert_matches; | |
| 8 | use std::borrow::Borrow; | |
| 9 | use std::cmp::Ordering; | |
| 10 | use std::hash::{Hash, Hasher}; | |
| 11 | use std::marker::PhantomData; | |
| 12 | use std::ops::{Bound, Deref}; | |
| 13 | use std::{fmt, iter, mem}; | |
| 8 | 14 | |
| 9 | use crate::arena::Arena; | |
| 10 | use crate::dep_graph::{DepGraph, DepKindStruct}; | |
| 11 | use crate::infer::canonical::{CanonicalParamEnvCache, CanonicalVarInfo, CanonicalVarInfos}; | |
| 12 | use crate::lint::lint_level; | |
| 13 | use crate::metadata::ModChild; | |
| 14 | use crate::middle::codegen_fn_attrs::CodegenFnAttrs; | |
| 15 | use crate::middle::resolve_bound_vars; | |
| 16 | use crate::middle::stability; | |
| 17 | use crate::mir::interpret::{self, Allocation, ConstAllocation}; | |
| 18 | use crate::mir::{Body, Local, Place, PlaceElem, ProjectionKind, Promoted}; | |
| 19 | use crate::query::plumbing::QuerySystem; | |
| 20 | use crate::query::LocalCrate; | |
| 21 | use crate::query::Providers; | |
| 22 | use crate::query::{IntoQueryParam, TyCtxtAt}; | |
| 23 | use crate::thir::Thir; | |
| 24 | use crate::traits; | |
| 25 | use crate::traits::solve; | |
| 26 | use crate::traits::solve::{ | |
| 27 | ExternalConstraints, ExternalConstraintsData, PredefinedOpaques, PredefinedOpaquesData, | |
| 28 | }; | |
| 29 | use crate::ty::predicate::ExistentialPredicateStableCmpExt as _; | |
| 30 | use crate::ty::{ | |
| 31 | self, AdtDef, AdtDefData, AdtKind, Binder, Clause, Clauses, Const, GenericParamDefKind, | |
| 32 | ImplPolarity, List, ListWithCachedTypeInfo, ParamConst, ParamTy, Pattern, PatternKind, | |
| 33 | PolyExistentialPredicate, PolyFnSig, Predicate, PredicateKind, PredicatePolarity, Region, | |
| 34 | RegionKind, ReprOptions, TraitObjectVisitor, Ty, TyKind, TyVid, Visibility, | |
| 35 | }; | |
| 36 | use crate::ty::{GenericArg, GenericArgs, GenericArgsRef}; | |
| 37 | 15 | use rustc_ast::{self as ast, attr}; |
| 38 | 16 | use rustc_data_structures::defer; |
| 39 | 17 | use rustc_data_structures::fingerprint::Fingerprint; |
| ... | ... | @@ -74,20 +52,37 @@ use rustc_target::abi::{FieldIdx, Layout, LayoutS, TargetDataLayout, VariantIdx} |
| 74 | 52 | use rustc_target::spec::abi; |
| 75 | 53 | use rustc_type_ir::fold::TypeFoldable; |
| 76 | 54 | use rustc_type_ir::lang_items::TraitSolverLangItem; |
| 55 | pub use rustc_type_ir::lift::Lift; | |
| 77 | 56 | use rustc_type_ir::solve::SolverMode; |
| 78 | 57 | use rustc_type_ir::TyKind::*; |
| 79 | 58 | use rustc_type_ir::{search_graph, CollectAndApply, Interner, TypeFlags, WithCachedTypeInfo}; |
| 80 | 59 | use tracing::{debug, instrument}; |
| 81 | 60 | |
| 82 | use std::assert_matches::assert_matches; | |
| 83 | use std::borrow::Borrow; | |
| 84 | use std::cmp::Ordering; | |
| 85 | use std::fmt; | |
| 86 | use std::hash::{Hash, Hasher}; | |
| 87 | use std::iter; | |
| 88 | use std::marker::PhantomData; | |
| 89 | use std::mem; | |
| 90 | use std::ops::{Bound, Deref}; | |
| 61 | use crate::arena::Arena; | |
| 62 | use crate::dep_graph::{DepGraph, DepKindStruct}; | |
| 63 | use crate::infer::canonical::{CanonicalParamEnvCache, CanonicalVarInfo, CanonicalVarInfos}; | |
| 64 | use crate::lint::lint_level; | |
| 65 | use crate::metadata::ModChild; | |
| 66 | use crate::middle::codegen_fn_attrs::CodegenFnAttrs; | |
| 67 | use crate::middle::{resolve_bound_vars, stability}; | |
| 68 | use crate::mir::interpret::{self, Allocation, ConstAllocation}; | |
| 69 | use crate::mir::{Body, Local, Place, PlaceElem, ProjectionKind, Promoted}; | |
| 70 | use crate::query::plumbing::QuerySystem; | |
| 71 | use crate::query::{IntoQueryParam, LocalCrate, Providers, TyCtxtAt}; | |
| 72 | use crate::thir::Thir; | |
| 73 | use crate::traits; | |
| 74 | use crate::traits::solve; | |
| 75 | use crate::traits::solve::{ | |
| 76 | ExternalConstraints, ExternalConstraintsData, PredefinedOpaques, PredefinedOpaquesData, | |
| 77 | }; | |
| 78 | use crate::ty::predicate::ExistentialPredicateStableCmpExt as _; | |
| 79 | use crate::ty::{ | |
| 80 | self, AdtDef, AdtDefData, AdtKind, Binder, Clause, Clauses, Const, GenericArg, GenericArgs, | |
| 81 | GenericArgsRef, GenericParamDefKind, ImplPolarity, List, ListWithCachedTypeInfo, ParamConst, | |
| 82 | ParamTy, Pattern, PatternKind, PolyExistentialPredicate, PolyFnSig, Predicate, PredicateKind, | |
| 83 | PredicatePolarity, Region, RegionKind, ReprOptions, TraitObjectVisitor, Ty, TyKind, TyVid, | |
| 84 | Visibility, | |
| 85 | }; | |
| 91 | 86 | |
| 92 | 87 | #[allow(rustc::usage_of_ty_tykind)] |
| 93 | 88 | impl<'tcx> Interner for TyCtxt<'tcx> { |
compiler/rustc_middle/src/ty/context/tls.rs+7-7| ... | ... | @@ -1,15 +1,15 @@ |
| 1 | use super::{GlobalCtxt, TyCtxt}; | |
| 1 | #[cfg(not(parallel_compiler))] | |
| 2 | use std::cell::Cell; | |
| 3 | use std::{mem, ptr}; | |
| 2 | 4 | |
| 3 | use crate::dep_graph::TaskDepsRef; | |
| 4 | use crate::query::plumbing::QueryJobId; | |
| 5 | 5 | use rustc_data_structures::sync::{self, Lock}; |
| 6 | 6 | use rustc_errors::DiagInner; |
| 7 | #[cfg(not(parallel_compiler))] | |
| 8 | use std::cell::Cell; | |
| 9 | use std::mem; | |
| 10 | use std::ptr; | |
| 11 | 7 | use thin_vec::ThinVec; |
| 12 | 8 | |
| 9 | use super::{GlobalCtxt, TyCtxt}; | |
| 10 | use crate::dep_graph::TaskDepsRef; | |
| 11 | use crate::query::plumbing::QueryJobId; | |
| 12 | ||
| 13 | 13 | /// This is the implicit state of rustc. It contains the current |
| 14 | 14 | /// `TyCtxt` and query. It is updated when creating a local interner or |
| 15 | 15 | /// executing a new query. Whenever there's a `TyCtxt` value available |
compiler/rustc_middle/src/ty/diagnostics.rs+6-6| ... | ... | @@ -4,12 +4,6 @@ use std::borrow::Cow; |
| 4 | 4 | use std::fmt::Write; |
| 5 | 5 | use std::ops::ControlFlow; |
| 6 | 6 | |
| 7 | use crate::ty::{ | |
| 8 | self, AliasTy, Const, ConstKind, FallibleTypeFolder, InferConst, InferTy, Opaque, | |
| 9 | PolyTraitPredicate, Projection, Ty, TyCtxt, TypeFoldable, TypeSuperFoldable, | |
| 10 | TypeSuperVisitable, TypeVisitable, TypeVisitor, | |
| 11 | }; | |
| 12 | ||
| 13 | 7 | use rustc_data_structures::fx::FxHashMap; |
| 14 | 8 | use rustc_errors::{into_diag_arg_using_display, Applicability, Diag, DiagArgValue, IntoDiagArg}; |
| 15 | 9 | use rustc_hir as hir; |
| ... | ... | @@ -19,6 +13,12 @@ use rustc_hir::{PredicateOrigin, WherePredicate}; |
| 19 | 13 | use rustc_span::{BytePos, Span}; |
| 20 | 14 | use rustc_type_ir::TyKind::*; |
| 21 | 15 | |
| 16 | use crate::ty::{ | |
| 17 | self, AliasTy, Const, ConstKind, FallibleTypeFolder, InferConst, InferTy, Opaque, | |
| 18 | PolyTraitPredicate, Projection, Ty, TyCtxt, TypeFoldable, TypeSuperFoldable, | |
| 19 | TypeSuperVisitable, TypeVisitable, TypeVisitor, | |
| 20 | }; | |
| 21 | ||
| 22 | 22 | into_diag_arg_using_display! { |
| 23 | 23 | Ty<'_>, |
| 24 | 24 | ty::Region<'_>, |
compiler/rustc_middle/src/ty/erase_regions.rs+2-1| ... | ... | @@ -1,7 +1,8 @@ |
| 1 | use tracing::debug; | |
| 2 | ||
| 1 | 3 | use crate::query::Providers; |
| 2 | 4 | use crate::ty::fold::{TypeFoldable, TypeFolder, TypeSuperFoldable}; |
| 3 | 5 | use crate::ty::{self, Ty, TyCtxt, TypeFlags, TypeVisitableExt}; |
| 4 | use tracing::debug; | |
| 5 | 6 | |
| 6 | 7 | pub(super) fn provide(providers: &mut Providers) { |
| 7 | 8 | *providers = Providers { erase_regions_ty, ..*providers }; |
compiler/rustc_middle/src/ty/error.rs+5-5| ... | ... | @@ -1,5 +1,6 @@ |
| 1 | use crate::ty::print::{with_forced_trimmed_paths, FmtPrinter, PrettyPrinter}; | |
| 2 | use crate::ty::{self, Ty, TyCtxt}; | |
| 1 | use std::borrow::Cow; | |
| 2 | use std::hash::{DefaultHasher, Hash, Hasher}; | |
| 3 | use std::path::PathBuf; | |
| 3 | 4 | |
| 4 | 5 | use rustc_errors::pluralize; |
| 5 | 6 | use rustc_hir as hir; |
| ... | ... | @@ -7,9 +8,8 @@ use rustc_hir::def::{CtorOf, DefKind}; |
| 7 | 8 | use rustc_macros::extension; |
| 8 | 9 | pub use rustc_type_ir::error::ExpectedFound; |
| 9 | 10 | |
| 10 | use std::borrow::Cow; | |
| 11 | use std::hash::{DefaultHasher, Hash, Hasher}; | |
| 12 | use std::path::PathBuf; | |
| 11 | use crate::ty::print::{with_forced_trimmed_paths, FmtPrinter, PrettyPrinter}; | |
| 12 | use crate::ty::{self, Ty, TyCtxt}; | |
| 13 | 13 | |
| 14 | 14 | pub type TypeError<'tcx> = rustc_type_ir::error::TypeError<TyCtxt<'tcx>>; |
| 15 | 15 |
compiler/rustc_middle/src/ty/fast_reject.rs+1-2| ... | ... | @@ -1,9 +1,8 @@ |
| 1 | 1 | use rustc_hir::def_id::DefId; |
| 2 | pub use rustc_type_ir::fast_reject::*; | |
| 2 | 3 | |
| 3 | 4 | use super::TyCtxt; |
| 4 | 5 | |
| 5 | pub use rustc_type_ir::fast_reject::*; | |
| 6 | ||
| 7 | 6 | pub type DeepRejectCtxt<'tcx> = rustc_type_ir::fast_reject::DeepRejectCtxt<TyCtxt<'tcx>>; |
| 8 | 7 | |
| 9 | 8 | pub type SimplifiedType = rustc_type_ir::fast_reject::SimplifiedType<DefId>; |
compiler/rustc_middle/src/ty/flags.rs+2-2| ... | ... | @@ -1,7 +1,7 @@ |
| 1 | use crate::ty::{self, InferConst, Ty, TypeFlags}; | |
| 2 | use crate::ty::{GenericArg, GenericArgKind}; | |
| 3 | 1 | use std::slice; |
| 4 | 2 | |
| 3 | use crate::ty::{self, GenericArg, GenericArgKind, InferConst, Ty, TypeFlags}; | |
| 4 | ||
| 5 | 5 | #[derive(Debug)] |
| 6 | 6 | pub struct FlagComputation { |
| 7 | 7 | pub flags: TypeFlags, |
compiler/rustc_middle/src/ty/fold.rs+3-3| ... | ... | @@ -1,11 +1,11 @@ |
| 1 | use crate::ty::{self, Binder, BoundTy, Ty, TyCtxt, TypeVisitableExt}; | |
| 2 | 1 | use rustc_data_structures::fx::FxIndexMap; |
| 3 | 2 | use rustc_hir::def_id::DefId; |
| 4 | use tracing::{debug, instrument}; | |
| 5 | ||
| 6 | 3 | pub use rustc_type_ir::fold::{ |
| 7 | 4 | shift_region, shift_vars, FallibleTypeFolder, TypeFoldable, TypeFolder, TypeSuperFoldable, |
| 8 | 5 | }; |
| 6 | use tracing::{debug, instrument}; | |
| 7 | ||
| 8 | use crate::ty::{self, Binder, BoundTy, Ty, TyCtxt, TypeVisitableExt}; | |
| 9 | 9 | |
| 10 | 10 | /////////////////////////////////////////////////////////////////////////// |
| 11 | 11 | // Some sample folders |
compiler/rustc_middle/src/ty/generic_args.rs+12-13| ... | ... | @@ -1,28 +1,27 @@ |
| 1 | 1 | // Generic arguments. |
| 2 | 2 | |
| 3 | use crate::ty::codec::{TyDecoder, TyEncoder}; | |
| 4 | use crate::ty::fold::{FallibleTypeFolder, TypeFoldable}; | |
| 5 | use crate::ty::visit::{TypeVisitable, TypeVisitor}; | |
| 6 | use crate::ty::{ | |
| 7 | self, ClosureArgs, CoroutineArgs, CoroutineClosureArgs, InlineConstArgs, Lift, List, Ty, TyCtxt, | |
| 8 | }; | |
| 3 | use core::intrinsics; | |
| 4 | use std::marker::PhantomData; | |
| 5 | use std::mem; | |
| 6 | use std::num::NonZero; | |
| 7 | use std::ptr::NonNull; | |
| 9 | 8 | |
| 10 | 9 | use rustc_ast_ir::visit::VisitorResult; |
| 11 | 10 | use rustc_ast_ir::walk_visitable_list; |
| 12 | 11 | use rustc_data_structures::intern::Interned; |
| 13 | 12 | use rustc_errors::{DiagArgValue, IntoDiagArg}; |
| 14 | 13 | use rustc_hir::def_id::DefId; |
| 15 | use rustc_macros::extension; | |
| 16 | use rustc_macros::{HashStable, TyDecodable, TyEncodable, TypeFoldable, TypeVisitable}; | |
| 14 | use rustc_macros::{extension, HashStable, TyDecodable, TyEncodable, TypeFoldable, TypeVisitable}; | |
| 17 | 15 | use rustc_serialize::{Decodable, Encodable}; |
| 18 | 16 | use rustc_type_ir::WithCachedTypeInfo; |
| 19 | 17 | use smallvec::SmallVec; |
| 20 | 18 | |
| 21 | use core::intrinsics; | |
| 22 | use std::marker::PhantomData; | |
| 23 | use std::mem; | |
| 24 | use std::num::NonZero; | |
| 25 | use std::ptr::NonNull; | |
| 19 | use crate::ty::codec::{TyDecoder, TyEncoder}; | |
| 20 | use crate::ty::fold::{FallibleTypeFolder, TypeFoldable}; | |
| 21 | use crate::ty::visit::{TypeVisitable, TypeVisitor}; | |
| 22 | use crate::ty::{ | |
| 23 | self, ClosureArgs, CoroutineArgs, CoroutineClosureArgs, InlineConstArgs, Lift, List, Ty, TyCtxt, | |
| 24 | }; | |
| 26 | 25 | |
| 27 | 26 | pub type GenericArgKind<'tcx> = rustc_type_ir::GenericArgKind<TyCtxt<'tcx>>; |
| 28 | 27 | pub type TermKind<'tcx> = rustc_type_ir::TermKind<TyCtxt<'tcx>>; |
compiler/rustc_middle/src/ty/generics.rs+2-2| ... | ... | @@ -1,5 +1,3 @@ |
| 1 | use crate::ty; | |
| 2 | use crate::ty::{EarlyBinder, GenericArgsRef}; | |
| 3 | 1 | use rustc_ast as ast; |
| 4 | 2 | use rustc_data_structures::fx::FxHashMap; |
| 5 | 3 | use rustc_hir::def_id::DefId; |
| ... | ... | @@ -9,6 +7,8 @@ use rustc_span::Span; |
| 9 | 7 | use tracing::instrument; |
| 10 | 8 | |
| 11 | 9 | use super::{Clause, InstantiatedPredicates, ParamConst, ParamTy, Ty, TyCtxt}; |
| 10 | use crate::ty; | |
| 11 | use crate::ty::{EarlyBinder, GenericArgsRef}; | |
| 12 | 12 | |
| 13 | 13 | #[derive(Clone, Debug, TyEncodable, TyDecodable, HashStable)] |
| 14 | 14 | pub enum GenericParamDefKind { |
compiler/rustc_middle/src/ty/impls_ty.rs+9-7| ... | ... | @@ -1,18 +1,20 @@ |
| 1 | 1 | //! This module contains `HashStable` implementations for various data types |
| 2 | 2 | //! from `rustc_middle::ty` in no particular order. |
| 3 | 3 | |
| 4 | use crate::middle::region; | |
| 5 | use crate::mir; | |
| 6 | use crate::ty; | |
| 4 | use std::cell::RefCell; | |
| 5 | use std::ptr; | |
| 6 | ||
| 7 | 7 | use rustc_data_structures::fingerprint::Fingerprint; |
| 8 | 8 | use rustc_data_structures::fx::FxHashMap; |
| 9 | use rustc_data_structures::stable_hasher::HashingControls; | |
| 10 | use rustc_data_structures::stable_hasher::{HashStable, StableHasher, ToStableHashKey}; | |
| 9 | use rustc_data_structures::stable_hasher::{ | |
| 10 | HashStable, HashingControls, StableHasher, ToStableHashKey, | |
| 11 | }; | |
| 11 | 12 | use rustc_query_system::ich::StableHashingContext; |
| 12 | use std::cell::RefCell; | |
| 13 | use std::ptr; | |
| 14 | 13 | use tracing::trace; |
| 15 | 14 | |
| 15 | use crate::middle::region; | |
| 16 | use crate::{mir, ty}; | |
| 17 | ||
| 16 | 18 | impl<'a, 'tcx, H, T> HashStable<StableHashingContext<'a>> for &'tcx ty::list::RawList<H, T> |
| 17 | 19 | where |
| 18 | 20 | T: HashStable<StableHashingContext<'a>>, |
compiler/rustc_middle/src/ty/inhabitedness/mod.rs+3-3| ... | ... | @@ -43,13 +43,13 @@ |
| 43 | 43 | //! This code should only compile in modules where the uninhabitedness of `Foo` |
| 44 | 44 | //! is visible. |
| 45 | 45 | |
| 46 | use rustc_type_ir::TyKind::*; | |
| 47 | use tracing::instrument; | |
| 48 | ||
| 46 | 49 | use crate::query::Providers; |
| 47 | 50 | use crate::ty::context::TyCtxt; |
| 48 | 51 | use crate::ty::{self, DefId, Ty, TypeVisitableExt, VariantDef, Visibility}; |
| 49 | 52 | |
| 50 | use rustc_type_ir::TyKind::*; | |
| 51 | use tracing::instrument; | |
| 52 | ||
| 53 | 53 | pub mod inhabited_predicate; |
| 54 | 54 | |
| 55 | 55 | pub use inhabited_predicate::InhabitedPredicate; |
compiler/rustc_middle/src/ty/instance.rs+11-10| ... | ... | @@ -1,10 +1,7 @@ |
| 1 | use crate::error; | |
| 2 | use crate::middle::codegen_fn_attrs::CodegenFnAttrFlags; | |
| 3 | use crate::ty::print::{shrunk_instance_name, FmtPrinter, Printer}; | |
| 4 | use crate::ty::{ | |
| 5 | self, EarlyBinder, GenericArgs, GenericArgsRef, Ty, TyCtxt, TypeFoldable, TypeSuperFoldable, | |
| 6 | TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor, | |
| 7 | }; | |
| 1 | use std::assert_matches::assert_matches; | |
| 2 | use std::fmt; | |
| 3 | use std::path::PathBuf; | |
| 4 | ||
| 8 | 5 | use rustc_data_structures::fx::FxHashMap; |
| 9 | 6 | use rustc_errors::ErrorGuaranteed; |
| 10 | 7 | use rustc_hir as hir; |
| ... | ... | @@ -18,9 +15,13 @@ use rustc_span::def_id::LOCAL_CRATE; |
| 18 | 15 | use rustc_span::{Span, Symbol, DUMMY_SP}; |
| 19 | 16 | use tracing::{debug, instrument}; |
| 20 | 17 | |
| 21 | use std::assert_matches::assert_matches; | |
| 22 | use std::fmt; | |
| 23 | use std::path::PathBuf; | |
| 18 | use crate::error; | |
| 19 | use crate::middle::codegen_fn_attrs::CodegenFnAttrFlags; | |
| 20 | use crate::ty::print::{shrunk_instance_name, FmtPrinter, Printer}; | |
| 21 | use crate::ty::{ | |
| 22 | self, EarlyBinder, GenericArgs, GenericArgsRef, Ty, TyCtxt, TypeFoldable, TypeSuperFoldable, | |
| 23 | TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor, | |
| 24 | }; | |
| 24 | 25 | |
| 25 | 26 | /// An `InstanceKind` along with the args that are needed to substitute the instance. |
| 26 | 27 | /// |
compiler/rustc_middle/src/ty/intrinsic.rs+2-1| ... | ... | @@ -1,5 +1,6 @@ |
| 1 | 1 | use rustc_macros::{Decodable, Encodable, HashStable}; |
| 2 | use rustc_span::{def_id::DefId, Symbol}; | |
| 2 | use rustc_span::def_id::DefId; | |
| 3 | use rustc_span::Symbol; | |
| 3 | 4 | |
| 4 | 5 | use super::TyCtxt; |
| 5 | 6 |
compiler/rustc_middle/src/ty/layout.rs+16-15| ... | ... | @@ -1,8 +1,8 @@ |
| 1 | use crate::error::UnsupportedFnAbi; | |
| 2 | use crate::middle::codegen_fn_attrs::CodegenFnAttrFlags; | |
| 3 | use crate::query::TyCtxtAt; | |
| 4 | use crate::ty::normalize_erasing_regions::NormalizationError; | |
| 5 | use crate::ty::{self, CoroutineArgsExt, Ty, TyCtxt, TypeVisitableExt}; | |
| 1 | use std::borrow::Cow; | |
| 2 | use std::num::NonZero; | |
| 3 | use std::ops::Bound; | |
| 4 | use std::{cmp, fmt}; | |
| 5 | ||
| 6 | 6 | use rustc_error_messages::DiagMessage; |
| 7 | 7 | use rustc_errors::{ |
| 8 | 8 | Diag, DiagArgValue, DiagCtxtHandle, Diagnostic, EmissionGuarantee, IntoDiagArg, Level, |
| ... | ... | @@ -17,16 +17,15 @@ use rustc_span::symbol::{sym, Symbol}; |
| 17 | 17 | use rustc_span::{ErrorGuaranteed, Span, DUMMY_SP}; |
| 18 | 18 | use rustc_target::abi::call::FnAbi; |
| 19 | 19 | use rustc_target::abi::*; |
| 20 | use rustc_target::spec::{ | |
| 21 | abi::Abi as SpecAbi, HasTargetSpec, HasWasmCAbiOpt, PanicStrategy, Target, WasmCAbi, | |
| 22 | }; | |
| 20 | use rustc_target::spec::abi::Abi as SpecAbi; | |
| 21 | use rustc_target::spec::{HasTargetSpec, HasWasmCAbiOpt, PanicStrategy, Target, WasmCAbi}; | |
| 23 | 22 | use tracing::debug; |
| 24 | 23 | |
| 25 | use std::borrow::Cow; | |
| 26 | use std::cmp; | |
| 27 | use std::fmt; | |
| 28 | use std::num::NonZero; | |
| 29 | use std::ops::Bound; | |
| 24 | use crate::error::UnsupportedFnAbi; | |
| 25 | use crate::middle::codegen_fn_attrs::CodegenFnAttrFlags; | |
| 26 | use crate::query::TyCtxtAt; | |
| 27 | use crate::ty::normalize_erasing_regions::NormalizationError; | |
| 28 | use crate::ty::{self, CoroutineArgsExt, Ty, TyCtxt, TypeVisitableExt}; | |
| 30 | 29 | |
| 31 | 30 | #[extension(pub trait IntegerExt)] |
| 32 | 31 | impl Integer { |
| ... | ... | @@ -231,8 +230,9 @@ pub enum LayoutError<'tcx> { |
| 231 | 230 | |
| 232 | 231 | impl<'tcx> LayoutError<'tcx> { |
| 233 | 232 | pub fn diagnostic_message(&self) -> DiagMessage { |
| 234 | use crate::fluent_generated::*; | |
| 235 | 233 | use LayoutError::*; |
| 234 | ||
| 235 | use crate::fluent_generated::*; | |
| 236 | 236 | match self { |
| 237 | 237 | Unknown(_) => middle_unknown_layout, |
| 238 | 238 | SizeOverflow(_) => middle_values_too_big, |
| ... | ... | @@ -243,8 +243,9 @@ impl<'tcx> LayoutError<'tcx> { |
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | pub fn into_diagnostic(self) -> crate::error::LayoutError<'tcx> { |
| 246 | use crate::error::LayoutError as E; | |
| 247 | 246 | use LayoutError::*; |
| 247 | ||
| 248 | use crate::error::LayoutError as E; | |
| 248 | 249 | match self { |
| 249 | 250 | Unknown(ty) => E::Unknown { ty }, |
| 250 | 251 | SizeOverflow(ty) => E::Overflow { ty }, |
compiler/rustc_middle/src/ty/list.rs+7-10| ... | ... | @@ -1,20 +1,17 @@ |
| 1 | use super::flags::FlagComputation; | |
| 2 | use super::{DebruijnIndex, TypeFlags}; | |
| 3 | use crate::arena::Arena; | |
| 4 | use rustc_data_structures::aligned::{align_of, Aligned}; | |
| 5 | use rustc_serialize::{Encodable, Encoder}; | |
| 6 | 1 | use std::alloc::Layout; |
| 7 | 2 | use std::cmp::Ordering; |
| 8 | use std::fmt; | |
| 9 | 3 | use std::hash::{Hash, Hasher}; |
| 10 | use std::iter; | |
| 11 | use std::mem; | |
| 12 | 4 | use std::ops::Deref; |
| 13 | use std::ptr; | |
| 14 | use std::slice; | |
| 5 | use std::{fmt, iter, mem, ptr, slice}; | |
| 15 | 6 | |
| 7 | use rustc_data_structures::aligned::{align_of, Aligned}; | |
| 16 | 8 | #[cfg(parallel_compiler)] |
| 17 | 9 | use rustc_data_structures::sync::DynSync; |
| 10 | use rustc_serialize::{Encodable, Encoder}; | |
| 11 | ||
| 12 | use super::flags::FlagComputation; | |
| 13 | use super::{DebruijnIndex, TypeFlags}; | |
| 14 | use crate::arena::Arena; | |
| 18 | 15 | |
| 19 | 16 | /// `List<T>` is a bit like `&[T]`, but with some critical differences. |
| 20 | 17 | /// - IMPORTANT: Every `List<T>` is *required* to have unique contents. The |
compiler/rustc_middle/src/ty/mod.rs+30-33| ... | ... | @@ -11,37 +11,28 @@ |
| 11 | 11 | |
| 12 | 12 | #![allow(rustc::usage_of_ty_tykind)] |
| 13 | 13 | |
| 14 | pub use self::fold::{FallibleTypeFolder, TypeFoldable, TypeFolder, TypeSuperFoldable}; | |
| 15 | pub use self::visit::{TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor}; | |
| 16 | pub use self::AssocItemContainer::*; | |
| 17 | pub use self::BorrowKind::*; | |
| 18 | pub use self::IntVarValue::*; | |
| 19 | use crate::error::{OpaqueHiddenTypeMismatch, TypeMismatchReason}; | |
| 20 | use crate::metadata::ModChild; | |
| 21 | use crate::middle::privacy::EffectiveVisibilities; | |
| 22 | use crate::mir::{Body, CoroutineLayout}; | |
| 23 | use crate::query::Providers; | |
| 24 | use crate::traits::{self, Reveal}; | |
| 25 | use crate::ty; | |
| 26 | use crate::ty::fast_reject::SimplifiedType; | |
| 27 | use crate::ty::util::Discr; | |
| 14 | use std::assert_matches::assert_matches; | |
| 15 | use std::fmt::Debug; | |
| 16 | use std::hash::{Hash, Hasher}; | |
| 17 | use std::marker::PhantomData; | |
| 18 | use std::num::NonZero; | |
| 19 | use std::ptr::NonNull; | |
| 20 | use std::{fmt, mem, str}; | |
| 21 | ||
| 28 | 22 | pub use adt::*; |
| 29 | 23 | pub use assoc::*; |
| 30 | 24 | pub use generic_args::{GenericArgKind, TermKind, *}; |
| 31 | 25 | pub use generics::*; |
| 32 | 26 | pub use intrinsic::IntrinsicDef; |
| 33 | use rustc_ast as ast; | |
| 34 | 27 | use rustc_ast::expand::StrippedCfgItem; |
| 35 | 28 | use rustc_ast::node_id::NodeMap; |
| 36 | 29 | pub use rustc_ast_ir::{try_visit, Movability, Mutability}; |
| 37 | use rustc_attr as attr; | |
| 38 | 30 | use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap, FxIndexSet}; |
| 39 | 31 | use rustc_data_structures::intern::Interned; |
| 40 | 32 | use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; |
| 41 | 33 | use rustc_data_structures::steal::Steal; |
| 42 | 34 | use rustc_data_structures::tagged_ptr::CopyTaggedPtr; |
| 43 | 35 | use rustc_errors::{Diag, ErrorGuaranteed, StashKey}; |
| 44 | use rustc_hir as hir; | |
| 45 | 36 | use rustc_hir::def::{CtorKind, CtorOf, DefKind, DocLinkResMap, LifetimeRes, Res}; |
| 46 | 37 | use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, LocalDefId, LocalDefIdMap}; |
| 47 | 38 | use rustc_index::IndexVec; |
| ... | ... | @@ -59,24 +50,14 @@ use rustc_span::{ExpnId, ExpnKind, Span}; |
| 59 | 50 | use rustc_target::abi::{Align, FieldIdx, Integer, IntegerType, VariantIdx}; |
| 60 | 51 | pub use rustc_target::abi::{ReprFlags, ReprOptions}; |
| 61 | 52 | pub use rustc_type_ir::relate::VarianceDiagInfo; |
| 62 | use tracing::{debug, instrument}; | |
| 63 | pub use vtable::*; | |
| 64 | ||
| 65 | use std::assert_matches::assert_matches; | |
| 66 | use std::fmt::Debug; | |
| 67 | use std::hash::{Hash, Hasher}; | |
| 68 | use std::marker::PhantomData; | |
| 69 | use std::mem; | |
| 70 | use std::num::NonZero; | |
| 71 | use std::ptr::NonNull; | |
| 72 | use std::{fmt, str}; | |
| 73 | ||
| 74 | pub use crate::ty::diagnostics::*; | |
| 75 | 53 | pub use rustc_type_ir::ConstKind::{ |
| 76 | 54 | Bound as BoundCt, Error as ErrorCt, Expr as ExprCt, Infer as InferCt, Param as ParamCt, |
| 77 | 55 | Placeholder as PlaceholderCt, Unevaluated, Value, |
| 78 | 56 | }; |
| 79 | 57 | pub use rustc_type_ir::*; |
| 58 | use tracing::{debug, instrument}; | |
| 59 | pub use vtable::*; | |
| 60 | use {rustc_ast as ast, rustc_attr as attr, rustc_hir as hir}; | |
| 80 | 61 | |
| 81 | 62 | pub use self::closure::{ |
| 82 | 63 | analyze_coroutine_closure_captures, is_ancestor_or_same_capture, place_to_string_for_capture, |
| ... | ... | @@ -91,6 +72,7 @@ pub use self::context::{ |
| 91 | 72 | tls, CtxtInterners, CurrentGcx, DeducedParamAttrs, Feed, FreeRegionInfo, GlobalCtxt, Lift, |
| 92 | 73 | TyCtxt, TyCtxtFeed, |
| 93 | 74 | }; |
| 75 | pub use self::fold::{FallibleTypeFolder, TypeFoldable, TypeFolder, TypeSuperFoldable}; | |
| 94 | 76 | pub use self::instance::{Instance, InstanceKind, ReifyReason, ShortInstance, UnusedGenericParams}; |
| 95 | 77 | pub use self::list::{List, ListWithCachedTypeInfo}; |
| 96 | 78 | pub use self::opaque_types::OpaqueTypeKey; |
| ... | ... | @@ -105,9 +87,9 @@ pub use self::predicate::{ |
| 105 | 87 | PredicateKind, ProjectionPredicate, RegionOutlivesPredicate, SubtypePredicate, ToPolyTraitRef, |
| 106 | 88 | TraitPredicate, TraitRef, TypeOutlivesPredicate, |
| 107 | 89 | }; |
| 90 | pub use self::region::BoundRegionKind::*; | |
| 108 | 91 | pub use self::region::{ |
| 109 | BoundRegion, BoundRegionKind, BoundRegionKind::*, EarlyParamRegion, LateParamRegion, Region, | |
| 110 | RegionKind, RegionVid, | |
| 92 | BoundRegion, BoundRegionKind, EarlyParamRegion, LateParamRegion, Region, RegionKind, RegionVid, | |
| 111 | 93 | }; |
| 112 | 94 | pub use self::rvalue_scopes::RvalueScopes; |
| 113 | 95 | pub use self::sty::{ |
| ... | ... | @@ -120,6 +102,20 @@ pub use self::typeck_results::{ |
| 120 | 102 | CanonicalUserType, CanonicalUserTypeAnnotation, CanonicalUserTypeAnnotations, IsIdentity, |
| 121 | 103 | TypeckResults, UserType, UserTypeAnnotationIndex, |
| 122 | 104 | }; |
| 105 | pub use self::visit::{TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor}; | |
| 106 | pub use self::AssocItemContainer::*; | |
| 107 | pub use self::BorrowKind::*; | |
| 108 | pub use self::IntVarValue::*; | |
| 109 | use crate::error::{OpaqueHiddenTypeMismatch, TypeMismatchReason}; | |
| 110 | use crate::metadata::ModChild; | |
| 111 | use crate::middle::privacy::EffectiveVisibilities; | |
| 112 | use crate::mir::{Body, CoroutineLayout}; | |
| 113 | use crate::query::Providers; | |
| 114 | use crate::traits::{self, Reveal}; | |
| 115 | use crate::ty; | |
| 116 | pub use crate::ty::diagnostics::*; | |
| 117 | use crate::ty::fast_reject::SimplifiedType; | |
| 118 | use crate::ty::util::Discr; | |
| 123 | 119 | |
| 124 | 120 | pub mod abstract_const; |
| 125 | 121 | pub mod adjustment; |
| ... | ... | @@ -2148,8 +2144,9 @@ pub struct DestructuredConst<'tcx> { |
| 2148 | 2144 | // Some types are used a lot. Make sure they don't unintentionally get bigger. |
| 2149 | 2145 | #[cfg(target_pointer_width = "64")] |
| 2150 | 2146 | mod size_asserts { |
| 2151 | use super::*; | |
| 2152 | 2147 | use rustc_data_structures::static_assert_size; |
| 2148 | ||
| 2149 | use super::*; | |
| 2153 | 2150 | // tidy-alphabetical-start |
| 2154 | 2151 | static_assert_size!(PredicateKind<'_>, 32); |
| 2155 | 2152 | static_assert_size!(WithCachedTypeInfo<TyKind<'_>>, 56); |
compiler/rustc_middle/src/ty/normalize_erasing_regions.rs+3-2| ... | ... | @@ -7,11 +7,12 @@ |
| 7 | 7 | //! `normalize_generic_arg_after_erasing_regions` query for each type |
| 8 | 8 | //! or constant found within. (This underlying query is what is cached.) |
| 9 | 9 | |
| 10 | use rustc_macros::{HashStable, TyDecodable, TyEncodable}; | |
| 11 | use tracing::{debug, instrument}; | |
| 12 | ||
| 10 | 13 | use crate::traits::query::NoSolution; |
| 11 | 14 | use crate::ty::fold::{FallibleTypeFolder, TypeFoldable, TypeFolder}; |
| 12 | 15 | use crate::ty::{self, EarlyBinder, GenericArgsRef, Ty, TyCtxt, TypeVisitableExt}; |
| 13 | use rustc_macros::{HashStable, TyDecodable, TyEncodable}; | |
| 14 | use tracing::{debug, instrument}; | |
| 15 | 16 | |
| 16 | 17 | #[derive(Debug, Copy, Clone, HashStable, TyEncodable, TyDecodable)] |
| 17 | 18 | pub enum NormalizationError<'tcx> { |
compiler/rustc_middle/src/ty/opaque_types.rs+4-4| ... | ... | @@ -1,12 +1,12 @@ |
| 1 | use crate::error::ConstNotUsedTraitAlias; | |
| 2 | use crate::ty::fold::{TypeFolder, TypeSuperFoldable}; | |
| 3 | use crate::ty::{self, Ty, TyCtxt, TypeFoldable}; | |
| 4 | use crate::ty::{GenericArg, GenericArgKind}; | |
| 5 | 1 | use rustc_data_structures::fx::FxHashMap; |
| 6 | 2 | use rustc_span::def_id::DefId; |
| 7 | 3 | use rustc_span::Span; |
| 8 | 4 | use tracing::{debug, instrument, trace}; |
| 9 | 5 | |
| 6 | use crate::error::ConstNotUsedTraitAlias; | |
| 7 | use crate::ty::fold::{TypeFolder, TypeSuperFoldable}; | |
| 8 | use crate::ty::{self, GenericArg, GenericArgKind, Ty, TyCtxt, TypeFoldable}; | |
| 9 | ||
| 10 | 10 | pub type OpaqueTypeKey<'tcx> = rustc_type_ir::OpaqueTypeKey<TyCtxt<'tcx>>; |
| 11 | 11 | |
| 12 | 12 | /// Converts generic params of a TypeFoldable from one |
compiler/rustc_middle/src/ty/parameterized.rs+2-1| ... | ... | @@ -1,7 +1,8 @@ |
| 1 | use std::hash::Hash; | |
| 2 | ||
| 1 | 3 | use rustc_data_structures::unord::UnordMap; |
| 2 | 4 | use rustc_hir::def_id::DefIndex; |
| 3 | 5 | use rustc_index::{Idx, IndexVec}; |
| 4 | use std::hash::Hash; | |
| 5 | 6 | |
| 6 | 7 | use crate::ty; |
| 7 | 8 |
compiler/rustc_middle/src/ty/pattern.rs+2-1| ... | ... | @@ -1,9 +1,10 @@ |
| 1 | 1 | use std::fmt; |
| 2 | 2 | |
| 3 | use crate::ty; | |
| 4 | 3 | use rustc_data_structures::intern::Interned; |
| 5 | 4 | use rustc_macros::{HashStable, TyDecodable, TyEncodable, TypeFoldable, TypeVisitable}; |
| 6 | 5 | |
| 6 | use crate::ty; | |
| 7 | ||
| 7 | 8 | #[derive(Copy, Clone, PartialEq, Eq, Hash, HashStable)] |
| 8 | 9 | #[rustc_pass_by_value] |
| 9 | 10 | pub struct Pattern<'tcx>(pub Interned<'tcx, PatternKind<'tcx>>); |
compiler/rustc_middle/src/ty/predicate.rs+2-1| ... | ... | @@ -1,9 +1,10 @@ |
| 1 | use std::cmp::Ordering; | |
| 2 | ||
| 1 | 3 | use rustc_data_structures::captures::Captures; |
| 2 | 4 | use rustc_data_structures::intern::Interned; |
| 3 | 5 | use rustc_hir::def_id::DefId; |
| 4 | 6 | use rustc_macros::{extension, HashStable}; |
| 5 | 7 | use rustc_type_ir as ir; |
| 6 | use std::cmp::Ordering; | |
| 7 | 8 | use tracing::instrument; |
| 8 | 9 | |
| 9 | 10 | use crate::ty::{ |
compiler/rustc_middle/src/ty/print/mod.rs+2-4| ... | ... | @@ -1,8 +1,5 @@ |
| 1 | 1 | use std::path::PathBuf; |
| 2 | 2 | |
| 3 | use crate::ty::GenericArg; | |
| 4 | use crate::ty::{self, ShortInstance, Ty, TyCtxt}; | |
| 5 | ||
| 6 | 3 | use hir::def::Namespace; |
| 7 | 4 | use rustc_data_structures::fx::FxHashSet; |
| 8 | 5 | use rustc_data_structures::sso::SsoHashSet; |
| ... | ... | @@ -11,10 +8,11 @@ use rustc_hir::def_id::{CrateNum, DefId, LocalDefId}; |
| 11 | 8 | use rustc_hir::definitions::{DefPathData, DisambiguatedDefPathData}; |
| 12 | 9 | use tracing::{debug, instrument, trace}; |
| 13 | 10 | |
| 11 | use crate::ty::{self, GenericArg, ShortInstance, Ty, TyCtxt}; | |
| 12 | ||
| 14 | 13 | // `pretty` is a separate module only for organization. |
| 15 | 14 | mod pretty; |
| 16 | 15 | pub use self::pretty::*; |
| 17 | ||
| 18 | 16 | use super::Lift; |
| 19 | 17 | |
| 20 | 18 | pub type PrintError = std::fmt::Error; |
compiler/rustc_middle/src/ty/print/pretty.rs+11-13| ... | ... | @@ -1,11 +1,8 @@ |
| 1 | use crate::mir::interpret::{AllocRange, GlobalAlloc, Pointer, Provenance, Scalar}; | |
| 2 | use crate::query::IntoQueryParam; | |
| 3 | use crate::query::Providers; | |
| 4 | use crate::ty::GenericArgKind; | |
| 5 | use crate::ty::{ | |
| 6 | ConstInt, Expr, ParamConst, ScalarInt, Term, TermKind, TypeFoldable, TypeSuperFoldable, | |
| 7 | TypeSuperVisitable, TypeVisitable, TypeVisitableExt, | |
| 8 | }; | |
| 1 | use std::cell::Cell; | |
| 2 | use std::fmt::{self, Write as _}; | |
| 3 | use std::iter; | |
| 4 | use std::ops::{Deref, DerefMut}; | |
| 5 | ||
| 9 | 6 | use rustc_apfloat::ieee::{Double, Half, Quad, Single}; |
| 10 | 7 | use rustc_apfloat::Float; |
| 11 | 8 | use rustc_data_structures::fx::{FxHashMap, FxIndexMap}; |
| ... | ... | @@ -25,13 +22,14 @@ use rustc_target::spec::abi::Abi; |
| 25 | 22 | use rustc_type_ir::{elaborate, Upcast as _}; |
| 26 | 23 | use smallvec::SmallVec; |
| 27 | 24 | |
| 28 | use std::cell::Cell; | |
| 29 | use std::fmt::{self, Write as _}; | |
| 30 | use std::iter; | |
| 31 | use std::ops::{Deref, DerefMut}; | |
| 32 | ||
| 33 | 25 | // `pretty` is a separate module only for organization. |
| 34 | 26 | use super::*; |
| 27 | use crate::mir::interpret::{AllocRange, GlobalAlloc, Pointer, Provenance, Scalar}; | |
| 28 | use crate::query::{IntoQueryParam, Providers}; | |
| 29 | use crate::ty::{ | |
| 30 | ConstInt, Expr, GenericArgKind, ParamConst, ScalarInt, Term, TermKind, TypeFoldable, | |
| 31 | TypeSuperFoldable, TypeSuperVisitable, TypeVisitable, TypeVisitableExt, | |
| 32 | }; | |
| 35 | 33 | |
| 36 | 34 | macro_rules! p { |
| 37 | 35 | (@$lit:literal) => { |
compiler/rustc_middle/src/ty/region.rs+3-3| ... | ... | @@ -1,13 +1,13 @@ |
| 1 | use std::ops::Deref; | |
| 2 | ||
| 1 | 3 | use rustc_data_structures::intern::Interned; |
| 2 | 4 | use rustc_errors::MultiSpan; |
| 3 | 5 | use rustc_hir::def_id::DefId; |
| 4 | 6 | use rustc_macros::{HashStable, TyDecodable, TyEncodable}; |
| 5 | use rustc_span::symbol::sym; | |
| 6 | use rustc_span::symbol::{kw, Symbol}; | |
| 7 | use rustc_span::symbol::{kw, sym, Symbol}; | |
| 7 | 8 | use rustc_span::{ErrorGuaranteed, DUMMY_SP}; |
| 8 | 9 | use rustc_type_ir::RegionKind as IrRegionKind; |
| 9 | 10 | pub use rustc_type_ir::RegionVid; |
| 10 | use std::ops::Deref; | |
| 11 | 11 | use tracing::debug; |
| 12 | 12 | |
| 13 | 13 | use crate::ty::{self, BoundVar, TyCtxt, TypeFlags}; |
compiler/rustc_middle/src/ty/rvalue_scopes.rs+2-1| ... | ... | @@ -1,9 +1,10 @@ |
| 1 | use crate::middle::region::{Scope, ScopeData, ScopeTree}; | |
| 2 | 1 | use rustc_hir as hir; |
| 3 | 2 | use rustc_hir::ItemLocalMap; |
| 4 | 3 | use rustc_macros::{HashStable, TyDecodable, TyEncodable}; |
| 5 | 4 | use tracing::debug; |
| 6 | 5 | |
| 6 | use crate::middle::region::{Scope, ScopeData, ScopeTree}; | |
| 7 | ||
| 7 | 8 | /// `RvalueScopes` is a mapping from sub-expressions to _extended_ lifetime as determined by |
| 8 | 9 | /// rules laid out in `rustc_hir_analysis::check::rvalue_scopes`. |
| 9 | 10 | #[derive(TyEncodable, TyDecodable, Clone, Debug, Default, Eq, PartialEq, HashStable)] |
compiler/rustc_middle/src/ty/structural_impls.rs+8-10| ... | ... | @@ -3,11 +3,8 @@ |
| 3 | 3 | //! written by hand, though we've recently added some macros and proc-macros |
| 4 | 4 | //! to help with the tedium. |
| 5 | 5 | |
| 6 | use crate::mir::interpret; | |
| 7 | use crate::ty::fold::{FallibleTypeFolder, TypeFoldable, TypeSuperFoldable}; | |
| 8 | use crate::ty::print::{with_no_trimmed_paths, FmtPrinter, Printer}; | |
| 9 | use crate::ty::visit::{TypeSuperVisitable, TypeVisitable, TypeVisitor}; | |
| 10 | use crate::ty::{self, InferConst, Lift, Term, TermKind, Ty, TyCtxt}; | |
| 6 | use std::fmt::{self, Debug}; | |
| 7 | ||
| 11 | 8 | use rustc_ast_ir::try_visit; |
| 12 | 9 | use rustc_ast_ir::visit::VisitorResult; |
| 13 | 10 | use rustc_hir::def::Namespace; |
| ... | ... | @@ -15,12 +12,13 @@ use rustc_span::source_map::Spanned; |
| 15 | 12 | use rustc_target::abi::TyAndLayout; |
| 16 | 13 | use rustc_type_ir::ConstKind; |
| 17 | 14 | |
| 18 | use std::fmt::{self, Debug}; | |
| 19 | ||
| 20 | 15 | use super::print::PrettyPrinter; |
| 21 | use super::{GenericArg, GenericArgKind, Region}; | |
| 22 | ||
| 23 | use super::Pattern; | |
| 16 | use super::{GenericArg, GenericArgKind, Pattern, Region}; | |
| 17 | use crate::mir::interpret; | |
| 18 | use crate::ty::fold::{FallibleTypeFolder, TypeFoldable, TypeSuperFoldable}; | |
| 19 | use crate::ty::print::{with_no_trimmed_paths, FmtPrinter, Printer}; | |
| 20 | use crate::ty::visit::{TypeSuperVisitable, TypeVisitable, TypeVisitor}; | |
| 21 | use crate::ty::{self, InferConst, Lift, Term, TermKind, Ty, TyCtxt}; | |
| 24 | 22 | |
| 25 | 23 | impl fmt::Debug for ty::TraitDef { |
| 26 | 24 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
compiler/rustc_middle/src/ty/sty.rs+14-15| ... | ... | @@ -2,14 +2,11 @@ |
| 2 | 2 | |
| 3 | 3 | #![allow(rustc::usage_of_ty_tykind)] |
| 4 | 4 | |
| 5 | use crate::infer::canonical::Canonical; | |
| 6 | use crate::ty::InferTy::*; | |
| 7 | use crate::ty::{ | |
| 8 | self, AdtDef, BoundRegionKind, Discr, Region, Ty, TyCtxt, TypeFlags, TypeSuperVisitable, | |
| 9 | TypeVisitable, TypeVisitor, | |
| 10 | }; | |
| 11 | use crate::ty::{GenericArg, GenericArgs, GenericArgsRef}; | |
| 12 | use crate::ty::{List, ParamEnv}; | |
| 5 | use std::assert_matches::debug_assert_matches; | |
| 6 | use std::borrow::Cow; | |
| 7 | use std::iter; | |
| 8 | use std::ops::{ControlFlow, Range}; | |
| 9 | ||
| 13 | 10 | use hir::def::{CtorKind, DefKind}; |
| 14 | 11 | use rustc_data_structures::captures::Captures; |
| 15 | 12 | use rustc_errors::{ErrorGuaranteed, MultiSpan}; |
| ... | ... | @@ -22,16 +19,17 @@ use rustc_span::{Span, DUMMY_SP}; |
| 22 | 19 | use rustc_target::abi::{FieldIdx, VariantIdx, FIRST_VARIANT}; |
| 23 | 20 | use rustc_target::spec::abi; |
| 24 | 21 | use rustc_type_ir::visit::TypeVisitableExt; |
| 25 | use std::assert_matches::debug_assert_matches; | |
| 26 | use std::borrow::Cow; | |
| 27 | use std::iter; | |
| 28 | use std::ops::{ControlFlow, Range}; | |
| 29 | use ty::util::{AsyncDropGlueMorphology, IntTypeExt}; | |
| 30 | ||
| 31 | 22 | use rustc_type_ir::TyKind::*; |
| 32 | 23 | use rustc_type_ir::{self as ir, BoundVar, CollectAndApply, DynKind}; |
| 24 | use ty::util::{AsyncDropGlueMorphology, IntTypeExt}; | |
| 33 | 25 | |
| 34 | 26 | use super::GenericParamDefKind; |
| 27 | use crate::infer::canonical::Canonical; | |
| 28 | use crate::ty::InferTy::*; | |
| 29 | use crate::ty::{ | |
| 30 | self, AdtDef, BoundRegionKind, Discr, GenericArg, GenericArgs, GenericArgsRef, List, ParamEnv, | |
| 31 | Region, Ty, TyCtxt, TypeFlags, TypeSuperVisitable, TypeVisitable, TypeVisitor, | |
| 32 | }; | |
| 35 | 33 | |
| 36 | 34 | // Re-export and re-parameterize some `I = TyCtxt<'tcx>` types here |
| 37 | 35 | #[rustc_diagnostic_item = "TyKind"] |
| ... | ... | @@ -1966,8 +1964,9 @@ impl<'tcx> rustc_type_ir::inherent::Tys<TyCtxt<'tcx>> for &'tcx ty::List<Ty<'tcx |
| 1966 | 1964 | // Some types are used a lot. Make sure they don't unintentionally get bigger. |
| 1967 | 1965 | #[cfg(target_pointer_width = "64")] |
| 1968 | 1966 | mod size_asserts { |
| 1969 | use super::*; | |
| 1970 | 1967 | use rustc_data_structures::static_assert_size; |
| 1968 | ||
| 1969 | use super::*; | |
| 1971 | 1970 | // tidy-alphabetical-start |
| 1972 | 1971 | static_assert_size!(ty::RegionKind<'_>, 24); |
| 1973 | 1972 | static_assert_size!(ty::TyKind<'_>, 32); |
compiler/rustc_middle/src/ty/trait_def.rs+2-3| ... | ... | @@ -1,13 +1,12 @@ |
| 1 | 1 | use std::iter; |
| 2 | use tracing::debug; | |
| 3 | 2 | |
| 4 | 3 | use rustc_data_structures::fx::FxIndexMap; |
| 5 | 4 | use rustc_errors::ErrorGuaranteed; |
| 6 | 5 | use rustc_hir as hir; |
| 7 | 6 | use rustc_hir::def::DefKind; |
| 8 | use rustc_hir::def_id::DefId; | |
| 9 | use rustc_hir::def_id::LOCAL_CRATE; | |
| 7 | use rustc_hir::def_id::{DefId, LOCAL_CRATE}; | |
| 10 | 8 | use rustc_macros::{Decodable, Encodable, HashStable}; |
| 9 | use tracing::debug; | |
| 11 | 10 | |
| 12 | 11 | use crate::query::LocalCrate; |
| 13 | 12 | use crate::traits::specialization_graph; |
compiler/rustc_middle/src/ty/typeck_results.rs+15-15| ... | ... | @@ -1,21 +1,15 @@ |
| 1 | use crate::{ | |
| 2 | hir::place::Place as HirPlace, | |
| 3 | infer::canonical::Canonical, | |
| 4 | traits::ObligationCause, | |
| 5 | ty::{ | |
| 6 | self, tls, BoundVar, CanonicalPolyFnSig, ClosureSizeProfileData, GenericArgKind, | |
| 7 | GenericArgs, GenericArgsRef, Ty, UserArgs, | |
| 8 | }, | |
| 9 | }; | |
| 1 | use std::collections::hash_map::Entry; | |
| 2 | use std::hash::Hash; | |
| 3 | use std::iter; | |
| 4 | ||
| 10 | 5 | use rustc_data_structures::fx::{FxIndexMap, FxIndexSet}; |
| 11 | 6 | use rustc_data_structures::unord::{ExtendUnord, UnordItems, UnordSet}; |
| 12 | 7 | use rustc_errors::ErrorGuaranteed; |
| 8 | use rustc_hir::def::{DefKind, Res}; | |
| 9 | use rustc_hir::def_id::{DefId, LocalDefId, LocalDefIdMap}; | |
| 10 | use rustc_hir::hir_id::OwnerId; | |
| 13 | 11 | use rustc_hir::{ |
| 14 | self as hir, | |
| 15 | def::{DefKind, Res}, | |
| 16 | def_id::{DefId, LocalDefId, LocalDefIdMap}, | |
| 17 | hir_id::OwnerId, | |
| 18 | BindingMode, ByRef, HirId, ItemLocalId, ItemLocalMap, ItemLocalSet, Mutability, | |
| 12 | self as hir, BindingMode, ByRef, HirId, ItemLocalId, ItemLocalMap, ItemLocalSet, Mutability, | |
| 19 | 13 | }; |
| 20 | 14 | use rustc_index::IndexVec; |
| 21 | 15 | use rustc_macros::{HashStable, TyDecodable, TyEncodable, TypeFoldable, TypeVisitable}; |
| ... | ... | @@ -23,9 +17,15 @@ use rustc_middle::mir::FakeReadCause; |
| 23 | 17 | use rustc_session::Session; |
| 24 | 18 | use rustc_span::Span; |
| 25 | 19 | use rustc_target::abi::{FieldIdx, VariantIdx}; |
| 26 | use std::{collections::hash_map::Entry, hash::Hash, iter}; | |
| 27 | 20 | |
| 28 | 21 | use super::RvalueScopes; |
| 22 | use crate::hir::place::Place as HirPlace; | |
| 23 | use crate::infer::canonical::Canonical; | |
| 24 | use crate::traits::ObligationCause; | |
| 25 | use crate::ty::{ | |
| 26 | self, tls, BoundVar, CanonicalPolyFnSig, ClosureSizeProfileData, GenericArgKind, GenericArgs, | |
| 27 | GenericArgsRef, Ty, UserArgs, | |
| 28 | }; | |
| 29 | 29 | |
| 30 | 30 | #[derive(TyEncodable, TyDecodable, Debug, HashStable)] |
| 31 | 31 | pub struct TypeckResults<'tcx> { |
compiler/rustc_middle/src/ty/util.rs+10-9| ... | ... | @@ -1,13 +1,7 @@ |
| 1 | 1 | //! Miscellaneous type-system utilities that are too small to deserve their own modules. |
| 2 | 2 | |
| 3 | use crate::middle::codegen_fn_attrs::CodegenFnAttrFlags; | |
| 4 | use crate::query::{IntoQueryParam, Providers}; | |
| 5 | use crate::ty::layout::{FloatExt, IntegerExt}; | |
| 6 | use crate::ty::{ | |
| 7 | self, Asyncness, FallibleTypeFolder, Ty, TyCtxt, TypeFoldable, TypeFolder, TypeSuperFoldable, | |
| 8 | TypeVisitableExt, Upcast, | |
| 9 | }; | |
| 10 | use crate::ty::{GenericArgKind, GenericArgsRef}; | |
| 3 | use std::{fmt, iter}; | |
| 4 | ||
| 11 | 5 | use rustc_apfloat::Float as _; |
| 12 | 6 | use rustc_data_structures::fx::{FxHashMap, FxHashSet}; |
| 13 | 7 | use rustc_data_structures::stable_hasher::{Hash128, HashStable, StableHasher}; |
| ... | ... | @@ -23,9 +17,16 @@ use rustc_span::sym; |
| 23 | 17 | use rustc_target::abi::{Float, Integer, IntegerType, Size}; |
| 24 | 18 | use rustc_target::spec::abi::Abi; |
| 25 | 19 | use smallvec::{smallvec, SmallVec}; |
| 26 | use std::{fmt, iter}; | |
| 27 | 20 | use tracing::{debug, instrument, trace}; |
| 28 | 21 | |
| 22 | use crate::middle::codegen_fn_attrs::CodegenFnAttrFlags; | |
| 23 | use crate::query::{IntoQueryParam, Providers}; | |
| 24 | use crate::ty::layout::{FloatExt, IntegerExt}; | |
| 25 | use crate::ty::{ | |
| 26 | self, Asyncness, FallibleTypeFolder, GenericArgKind, GenericArgsRef, Ty, TyCtxt, TypeFoldable, | |
| 27 | TypeFolder, TypeSuperFoldable, TypeVisitableExt, Upcast, | |
| 28 | }; | |
| 29 | ||
| 29 | 30 | #[derive(Copy, Clone, Debug)] |
| 30 | 31 | pub struct Discr<'tcx> { |
| 31 | 32 | /// Bit representation of the discriminant (e.g., `-128i8` is `0xFF_u128`). |
compiler/rustc_middle/src/ty/visit.rs+3-3| ... | ... | @@ -1,11 +1,11 @@ |
| 1 | use crate::ty::{self, Binder, Ty, TyCtxt, TypeFlags}; | |
| 1 | use std::ops::ControlFlow; | |
| 2 | 2 | |
| 3 | 3 | use rustc_data_structures::fx::FxHashSet; |
| 4 | 4 | use rustc_type_ir::fold::TypeFoldable; |
| 5 | use std::ops::ControlFlow; | |
| 6 | ||
| 7 | 5 | pub use rustc_type_ir::visit::{TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor}; |
| 8 | 6 | |
| 7 | use crate::ty::{self, Binder, Ty, TyCtxt, TypeFlags}; | |
| 8 | ||
| 9 | 9 | /////////////////////////////////////////////////////////////////////////// |
| 10 | 10 | // Region folder |
| 11 | 11 |
compiler/rustc_middle/src/ty/vtable.rs+3-2| ... | ... | @@ -1,10 +1,11 @@ |
| 1 | 1 | use std::fmt; |
| 2 | 2 | |
| 3 | use crate::mir::interpret::{alloc_range, AllocId, Allocation, Pointer, Scalar}; | |
| 4 | use crate::ty::{self, Instance, PolyTraitRef, Ty, TyCtxt}; | |
| 5 | 3 | use rustc_ast::Mutability; |
| 6 | 4 | use rustc_macros::HashStable; |
| 7 | 5 | |
| 6 | use crate::mir::interpret::{alloc_range, AllocId, Allocation, Pointer, Scalar}; | |
| 7 | use crate::ty::{self, Instance, PolyTraitRef, Ty, TyCtxt}; | |
| 8 | ||
| 8 | 9 | #[derive(Clone, Copy, PartialEq, HashStable)] |
| 9 | 10 | pub enum VtblEntry<'tcx> { |
| 10 | 11 | /// destructor of this type (used in vtable header) |
compiler/rustc_middle/src/ty/walk.rs+2-2| ... | ... | @@ -1,12 +1,12 @@ |
| 1 | 1 | //! An iterator over the type substructure. |
| 2 | 2 | //! WARNING: this does not keep track of the region depth. |
| 3 | 3 | |
| 4 | use crate::ty::{self, Ty}; | |
| 5 | use crate::ty::{GenericArg, GenericArgKind}; | |
| 6 | 4 | use rustc_data_structures::sso::SsoHashSet; |
| 7 | 5 | use smallvec::{smallvec, SmallVec}; |
| 8 | 6 | use tracing::debug; |
| 9 | 7 | |
| 8 | use crate::ty::{self, GenericArg, GenericArgKind, Ty}; | |
| 9 | ||
| 10 | 10 | // The TypeWalker's stack is hot enough that it's worth going to some effort to |
| 11 | 11 | // avoid heap allocations. |
| 12 | 12 | type TypeWalkerStack<'tcx> = SmallVec<[GenericArg<'tcx>; 8]>; |
compiler/rustc_middle/src/util/bug.rs+5-3| ... | ... | @@ -1,11 +1,13 @@ |
| 1 | 1 | // These functions are used by macro expansion for bug! and span_bug! |
| 2 | 2 | |
| 3 | use crate::ty::{tls, TyCtxt}; | |
| 4 | use rustc_errors::MultiSpan; | |
| 5 | use rustc_span::Span; | |
| 6 | 3 | use std::fmt; |
| 7 | 4 | use std::panic::{panic_any, Location}; |
| 8 | 5 | |
| 6 | use rustc_errors::MultiSpan; | |
| 7 | use rustc_span::Span; | |
| 8 | ||
| 9 | use crate::ty::{tls, TyCtxt}; | |
| 10 | ||
| 9 | 11 | #[cold] |
| 10 | 12 | #[inline(never)] |
| 11 | 13 | #[track_caller] |
compiler/rustc_middle/src/util/call_kind.rs+2-2| ... | ... | @@ -2,14 +2,14 @@ |
| 2 | 2 | //! as well as errors when attempting to call a non-const function in a const |
| 3 | 3 | //! context. |
| 4 | 4 | |
| 5 | use crate::ty::GenericArgsRef; | |
| 6 | use crate::ty::{AssocItemContainer, Instance, ParamEnv, Ty, TyCtxt}; | |
| 7 | 5 | use rustc_hir::def_id::DefId; |
| 8 | 6 | use rustc_hir::{lang_items, LangItem}; |
| 9 | 7 | use rustc_span::symbol::Ident; |
| 10 | 8 | use rustc_span::{sym, DesugaringKind, Span}; |
| 11 | 9 | use tracing::debug; |
| 12 | 10 | |
| 11 | use crate::ty::{AssocItemContainer, GenericArgsRef, Instance, ParamEnv, Ty, TyCtxt}; | |
| 12 | ||
| 13 | 13 | #[derive(Clone, Copy, PartialEq, Eq, Debug)] |
| 14 | 14 | pub enum CallDesugaringKind { |
| 15 | 15 | /// for _ in x {} calls x.into_iter() |
compiler/rustc_middle/src/util/find_self_call.rs+3-3| ... | ... | @@ -1,10 +1,10 @@ |
| 1 | use crate::mir::*; | |
| 2 | use crate::ty::GenericArgsRef; | |
| 3 | use crate::ty::{self, TyCtxt}; | |
| 4 | 1 | use rustc_span::def_id::DefId; |
| 5 | 2 | use rustc_span::source_map::Spanned; |
| 6 | 3 | use tracing::debug; |
| 7 | 4 | |
| 5 | use crate::mir::*; | |
| 6 | use crate::ty::{self, GenericArgsRef, TyCtxt}; | |
| 7 | ||
| 8 | 8 | /// Checks if the specified `local` is used as the `self` parameter of a method call |
| 9 | 9 | /// in the provided `BasicBlock`. If it is, then the `DefId` of the called method is |
| 10 | 10 | /// returned. |
compiler/rustc_middle/src/values.rs+9-8| ... | ... | @@ -1,19 +1,20 @@ |
| 1 | use crate::dep_graph::dep_kinds; | |
| 2 | use crate::query::plumbing::CyclePlaceholder; | |
| 1 | use std::collections::VecDeque; | |
| 2 | use std::fmt::Write; | |
| 3 | use std::ops::ControlFlow; | |
| 4 | ||
| 3 | 5 | use rustc_data_structures::fx::FxHashSet; |
| 4 | use rustc_errors::{codes::*, pluralize, struct_span_code_err, Applicability, MultiSpan}; | |
| 6 | use rustc_errors::codes::*; | |
| 7 | use rustc_errors::{pluralize, struct_span_code_err, Applicability, MultiSpan}; | |
| 5 | 8 | use rustc_hir as hir; |
| 6 | 9 | use rustc_hir::def::{DefKind, Res}; |
| 7 | use rustc_middle::ty::Representability; | |
| 8 | use rustc_middle::ty::{self, Ty, TyCtxt}; | |
| 10 | use rustc_middle::ty::{self, Representability, Ty, TyCtxt}; | |
| 9 | 11 | use rustc_query_system::query::{report_cycle, CycleError}; |
| 10 | 12 | use rustc_query_system::Value; |
| 11 | 13 | use rustc_span::def_id::LocalDefId; |
| 12 | 14 | use rustc_span::{ErrorGuaranteed, Span}; |
| 13 | 15 | |
| 14 | use std::collections::VecDeque; | |
| 15 | use std::fmt::Write; | |
| 16 | use std::ops::ControlFlow; | |
| 16 | use crate::dep_graph::dep_kinds; | |
| 17 | use crate::query::plumbing::CyclePlaceholder; | |
| 17 | 18 | |
| 18 | 19 | impl<'tcx> Value<TyCtxt<'tcx>> for Ty<'_> { |
| 19 | 20 | fn from_cycle_error(tcx: TyCtxt<'tcx>, _: &CycleError, guar: ErrorGuaranteed) -> Self { |
compiler/rustc_mir_build/src/build/block.rs+6-5| ... | ... | @@ -1,13 +1,14 @@ |
| 1 | use crate::build::matches::{DeclareLetBindings, EmitStorageLive, ScheduleDrops}; | |
| 2 | use crate::build::ForGuard::OutsideGuard; | |
| 3 | use crate::build::{BlockAnd, BlockAndExtension, BlockFrame, Builder}; | |
| 4 | 1 | use rustc_middle::middle::region::Scope; |
| 5 | use rustc_middle::span_bug; | |
| 2 | use rustc_middle::mir::*; | |
| 6 | 3 | use rustc_middle::thir::*; |
| 7 | use rustc_middle::{mir::*, ty}; | |
| 4 | use rustc_middle::{span_bug, ty}; | |
| 8 | 5 | use rustc_span::Span; |
| 9 | 6 | use tracing::debug; |
| 10 | 7 | |
| 8 | use crate::build::matches::{DeclareLetBindings, EmitStorageLive, ScheduleDrops}; | |
| 9 | use crate::build::ForGuard::OutsideGuard; | |
| 10 | use crate::build::{BlockAnd, BlockAndExtension, BlockFrame, Builder}; | |
| 11 | ||
| 11 | 12 | impl<'a, 'tcx> Builder<'a, 'tcx> { |
| 12 | 13 | pub(crate) fn ast_block( |
| 13 | 14 | &mut self, |
compiler/rustc_mir_build/src/build/cfg.rs+2-1| ... | ... | @@ -1,10 +1,11 @@ |
| 1 | 1 | //! Routines for manipulating the control-flow graph. |
| 2 | 2 | |
| 3 | use crate::build::CFG; | |
| 4 | 3 | use rustc_middle::mir::*; |
| 5 | 4 | use rustc_middle::ty::TyCtxt; |
| 6 | 5 | use tracing::debug; |
| 7 | 6 | |
| 7 | use crate::build::CFG; | |
| 8 | ||
| 8 | 9 | impl<'tcx> CFG<'tcx> { |
| 9 | 10 | pub(crate) fn block_data(&self, blk: BasicBlock) -> &BasicBlockData<'tcx> { |
| 10 | 11 | &self.basic_blocks[blk] |
compiler/rustc_mir_build/src/build/custom/mod.rs+4-6| ... | ... | @@ -22,12 +22,10 @@ use rustc_data_structures::fx::FxHashMap; |
| 22 | 22 | use rustc_hir::def_id::DefId; |
| 23 | 23 | use rustc_hir::HirId; |
| 24 | 24 | use rustc_index::{IndexSlice, IndexVec}; |
| 25 | use rustc_middle::{ | |
| 26 | mir::*, | |
| 27 | span_bug, | |
| 28 | thir::*, | |
| 29 | ty::{ParamEnv, Ty, TyCtxt}, | |
| 30 | }; | |
| 25 | use rustc_middle::mir::*; | |
| 26 | use rustc_middle::span_bug; | |
| 27 | use rustc_middle::thir::*; | |
| 28 | use rustc_middle::ty::{ParamEnv, Ty, TyCtxt}; | |
| 31 | 29 | use rustc_span::Span; |
| 32 | 30 | |
| 33 | 31 | mod parse; |
compiler/rustc_mir_build/src/build/custom/parse.rs+2-1| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | 1 | use rustc_index::IndexSlice; |
| 2 | use rustc_middle::mir::*; | |
| 3 | use rustc_middle::thir::*; | |
| 2 | 4 | use rustc_middle::ty::{self, Ty}; |
| 3 | use rustc_middle::{mir::*, thir::*}; | |
| 4 | 5 | use rustc_span::Span; |
| 5 | 6 | |
| 6 | 7 | use super::{PResult, ParseCtxt, ParseError}; |
compiler/rustc_mir_build/src/build/custom/parse/instruction.rs+4-3| ... | ... | @@ -1,16 +1,17 @@ |
| 1 | 1 | use rustc_middle::mir::interpret::Scalar; |
| 2 | 2 | use rustc_middle::mir::tcx::PlaceTy; |
| 3 | use rustc_middle::mir::*; | |
| 4 | use rustc_middle::thir::*; | |
| 5 | use rustc_middle::ty; | |
| 3 | 6 | use rustc_middle::ty::cast::mir_cast_kind; |
| 4 | use rustc_middle::{mir::*, thir::*, ty}; | |
| 5 | 7 | use rustc_span::source_map::Spanned; |
| 6 | 8 | use rustc_span::Span; |
| 7 | 9 | use rustc_target::abi::{FieldIdx, VariantIdx}; |
| 8 | 10 | |
| 11 | use super::{parse_by_kind, PResult, ParseCtxt}; | |
| 9 | 12 | use crate::build::custom::ParseError; |
| 10 | 13 | use crate::build::expr::as_constant::as_constant_inner; |
| 11 | 14 | |
| 12 | use super::{parse_by_kind, PResult, ParseCtxt}; | |
| 13 | ||
| 14 | 15 | impl<'tcx, 'body> ParseCtxt<'tcx, 'body> { |
| 15 | 16 | pub(crate) fn parse_statement(&self, expr_id: ExprId) -> PResult<StatementKind<'tcx>> { |
| 16 | 17 | parse_by_kind!(self, expr_id, _, "statement", |
compiler/rustc_mir_build/src/build/expr/as_constant.rs+3-3| ... | ... | @@ -1,19 +1,19 @@ |
| 1 | 1 | //! See docs in build/expr/mod.rs |
| 2 | 2 | |
| 3 | use crate::build::{parse_float_into_constval, Builder}; | |
| 4 | 3 | use rustc_ast as ast; |
| 5 | 4 | use rustc_hir::LangItem; |
| 6 | use rustc_middle::mir; | |
| 7 | 5 | use rustc_middle::mir::interpret::{Allocation, LitToConstError, LitToConstInput, Scalar}; |
| 8 | 6 | use rustc_middle::mir::*; |
| 9 | 7 | use rustc_middle::thir::*; |
| 10 | 8 | use rustc_middle::ty::{ |
| 11 | 9 | self, CanonicalUserType, CanonicalUserTypeAnnotation, Ty, TyCtxt, UserTypeAnnotationIndex, |
| 12 | 10 | }; |
| 13 | use rustc_middle::{bug, span_bug}; | |
| 11 | use rustc_middle::{bug, mir, span_bug}; | |
| 14 | 12 | use rustc_target::abi::Size; |
| 15 | 13 | use tracing::{instrument, trace}; |
| 16 | 14 | |
| 15 | use crate::build::{parse_float_into_constval, Builder}; | |
| 16 | ||
| 17 | 17 | impl<'a, 'tcx> Builder<'a, 'tcx> { |
| 18 | 18 | /// Compile `expr`, yielding a compile-time constant. Assumes that |
| 19 | 19 | /// `expr` is a valid compile-time constant! |
compiler/rustc_mir_build/src/build/expr/as_operand.rs+3-2| ... | ... | @@ -1,12 +1,13 @@ |
| 1 | 1 | //! See docs in build/expr/mod.rs |
| 2 | 2 | |
| 3 | use crate::build::expr::category::Category; | |
| 4 | use crate::build::{BlockAnd, BlockAndExtension, Builder, NeedsTemporary}; | |
| 5 | 3 | use rustc_middle::middle::region; |
| 6 | 4 | use rustc_middle::mir::*; |
| 7 | 5 | use rustc_middle::thir::*; |
| 8 | 6 | use tracing::{debug, instrument}; |
| 9 | 7 | |
| 8 | use crate::build::expr::category::Category; | |
| 9 | use crate::build::{BlockAnd, BlockAndExtension, Builder, NeedsTemporary}; | |
| 10 | ||
| 10 | 11 | impl<'a, 'tcx> Builder<'a, 'tcx> { |
| 11 | 12 | /// Returns an operand suitable for use until the end of the current |
| 12 | 13 | /// scope expression. |
compiler/rustc_mir_build/src/build/expr/as_place.rs+8-9| ... | ... | @@ -1,24 +1,23 @@ |
| 1 | 1 | //! See docs in build/expr/mod.rs |
| 2 | 2 | |
| 3 | use crate::build::expr::category::Category; | |
| 4 | use crate::build::ForGuard::{OutsideGuard, RefWithinGuard}; | |
| 5 | use crate::build::{BlockAnd, BlockAndExtension, Builder, Capture, CaptureMap}; | |
| 3 | use std::assert_matches::assert_matches; | |
| 4 | use std::iter; | |
| 5 | ||
| 6 | 6 | use rustc_hir::def_id::LocalDefId; |
| 7 | use rustc_middle::hir::place::Projection as HirProjection; | |
| 8 | use rustc_middle::hir::place::ProjectionKind as HirProjectionKind; | |
| 7 | use rustc_middle::hir::place::{Projection as HirProjection, ProjectionKind as HirProjectionKind}; | |
| 9 | 8 | use rustc_middle::middle::region; |
| 10 | 9 | use rustc_middle::mir::AssertKind::BoundsCheck; |
| 11 | 10 | use rustc_middle::mir::*; |
| 12 | 11 | use rustc_middle::thir::*; |
| 13 | use rustc_middle::ty::AdtDef; | |
| 14 | use rustc_middle::ty::{self, CanonicalUserTypeAnnotation, Ty, Variance}; | |
| 12 | use rustc_middle::ty::{self, AdtDef, CanonicalUserTypeAnnotation, Ty, Variance}; | |
| 15 | 13 | use rustc_middle::{bug, span_bug}; |
| 16 | 14 | use rustc_span::Span; |
| 17 | 15 | use rustc_target::abi::{FieldIdx, VariantIdx, FIRST_VARIANT}; |
| 18 | 16 | use tracing::{debug, instrument, trace}; |
| 19 | 17 | |
| 20 | use std::assert_matches::assert_matches; | |
| 21 | use std::iter; | |
| 18 | use crate::build::expr::category::Category; | |
| 19 | use crate::build::ForGuard::{OutsideGuard, RefWithinGuard}; | |
| 20 | use crate::build::{BlockAnd, BlockAndExtension, Builder, Capture, CaptureMap}; | |
| 22 | 21 | |
| 23 | 22 | /// The "outermost" place that holds this value. |
| 24 | 23 | #[derive(Copy, Clone, Debug, PartialEq)] |
compiler/rustc_mir_build/src/build/expr/as_rvalue.rs+8-8| ... | ... | @@ -1,14 +1,7 @@ |
| 1 | 1 | //! See docs in `build/expr/mod.rs`. |
| 2 | 2 | |
| 3 | use rustc_index::{Idx, IndexVec}; | |
| 4 | use rustc_middle::ty::util::IntTypeExt; | |
| 5 | use rustc_span::source_map::Spanned; | |
| 6 | use rustc_target::abi::{Abi, FieldIdx, Primitive}; | |
| 7 | ||
| 8 | use crate::build::expr::as_place::PlaceBase; | |
| 9 | use crate::build::expr::category::{Category, RvalueFunc}; | |
| 10 | use crate::build::{BlockAnd, BlockAndExtension, Builder, NeedsTemporary}; | |
| 11 | 3 | use rustc_hir::lang_items::LangItem; |
| 4 | use rustc_index::{Idx, IndexVec}; | |
| 12 | 5 | use rustc_middle::bug; |
| 13 | 6 | use rustc_middle::middle::region; |
| 14 | 7 | use rustc_middle::mir::interpret::Scalar; |
| ... | ... | @@ -16,10 +9,17 @@ use rustc_middle::mir::*; |
| 16 | 9 | use rustc_middle::thir::*; |
| 17 | 10 | use rustc_middle::ty::cast::{mir_cast_kind, CastTy}; |
| 18 | 11 | use rustc_middle::ty::layout::IntegerExt; |
| 12 | use rustc_middle::ty::util::IntTypeExt; | |
| 19 | 13 | use rustc_middle::ty::{self, Ty, UpvarArgs}; |
| 14 | use rustc_span::source_map::Spanned; | |
| 20 | 15 | use rustc_span::{Span, DUMMY_SP}; |
| 16 | use rustc_target::abi::{Abi, FieldIdx, Primitive}; | |
| 21 | 17 | use tracing::debug; |
| 22 | 18 | |
| 19 | use crate::build::expr::as_place::PlaceBase; | |
| 20 | use crate::build::expr::category::{Category, RvalueFunc}; | |
| 21 | use crate::build::{BlockAnd, BlockAndExtension, Builder, NeedsTemporary}; | |
| 22 | ||
| 23 | 23 | impl<'a, 'tcx> Builder<'a, 'tcx> { |
| 24 | 24 | /// Returns an rvalue suitable for use until the end of the current |
| 25 | 25 | /// scope expression. |
compiler/rustc_mir_build/src/build/expr/as_temp.rs+3-2| ... | ... | @@ -1,13 +1,14 @@ |
| 1 | 1 | //! See docs in build/expr/mod.rs |
| 2 | 2 | |
| 3 | use crate::build::scope::DropKind; | |
| 4 | use crate::build::{BlockAnd, BlockAndExtension, Builder}; | |
| 5 | 3 | use rustc_data_structures::stack::ensure_sufficient_stack; |
| 6 | 4 | use rustc_middle::middle::region; |
| 7 | 5 | use rustc_middle::mir::*; |
| 8 | 6 | use rustc_middle::thir::*; |
| 9 | 7 | use tracing::{debug, instrument}; |
| 10 | 8 | |
| 9 | use crate::build::scope::DropKind; | |
| 10 | use crate::build::{BlockAnd, BlockAndExtension, Builder}; | |
| 11 | ||
| 11 | 12 | impl<'a, 'tcx> Builder<'a, 'tcx> { |
| 12 | 13 | /// Compile `expr` into a fresh temporary. This is used when building |
| 13 | 14 | /// up rvalues so as to freeze the value that will be consumed. |
compiler/rustc_mir_build/src/build/expr/into.rs+6-4| ... | ... | @@ -1,8 +1,7 @@ |
| 1 | 1 | //! See docs in build/expr/mod.rs |
| 2 | 2 | |
| 3 | use crate::build::expr::category::{Category, RvalueFunc}; | |
| 4 | use crate::build::matches::DeclareLetBindings; | |
| 5 | use crate::build::{BlockAnd, BlockAndExtension, BlockFrame, Builder, NeedsTemporary}; | |
| 3 | use std::iter; | |
| 4 | ||
| 6 | 5 | use rustc_ast::InlineAsmOptions; |
| 7 | 6 | use rustc_data_structures::fx::FxHashMap; |
| 8 | 7 | use rustc_data_structures::stack::ensure_sufficient_stack; |
| ... | ... | @@ -12,9 +11,12 @@ use rustc_middle::span_bug; |
| 12 | 11 | use rustc_middle::thir::*; |
| 13 | 12 | use rustc_middle::ty::CanonicalUserTypeAnnotation; |
| 14 | 13 | use rustc_span::source_map::Spanned; |
| 15 | use std::iter; | |
| 16 | 14 | use tracing::{debug, instrument}; |
| 17 | 15 | |
| 16 | use crate::build::expr::category::{Category, RvalueFunc}; | |
| 17 | use crate::build::matches::DeclareLetBindings; | |
| 18 | use crate::build::{BlockAnd, BlockAndExtension, BlockFrame, Builder, NeedsTemporary}; | |
| 19 | ||
| 18 | 20 | impl<'a, 'tcx> Builder<'a, 'tcx> { |
| 19 | 21 | /// Compile `expr`, storing the result into `destination`, which |
| 20 | 22 | /// is assumed to be uninitialized. |
compiler/rustc_mir_build/src/build/expr/stmt.rs+3-2| ... | ... | @@ -1,5 +1,3 @@ |
| 1 | use crate::build::scope::BreakableTarget; | |
| 2 | use crate::build::{BlockAnd, BlockAndExtension, BlockFrame, Builder}; | |
| 3 | 1 | use rustc_middle::middle::region; |
| 4 | 2 | use rustc_middle::mir::*; |
| 5 | 3 | use rustc_middle::span_bug; |
| ... | ... | @@ -7,6 +5,9 @@ use rustc_middle::thir::*; |
| 7 | 5 | use rustc_span::source_map::Spanned; |
| 8 | 6 | use tracing::debug; |
| 9 | 7 | |
| 8 | use crate::build::scope::BreakableTarget; | |
| 9 | use crate::build::{BlockAnd, BlockAndExtension, BlockFrame, Builder}; | |
| 10 | ||
| 10 | 11 | impl<'a, 'tcx> Builder<'a, 'tcx> { |
| 11 | 12 | /// Builds a block of MIR statements to evaluate the THIR `expr`. |
| 12 | 13 | /// |
compiler/rustc_mir_build/src/build/matches/mod.rs+9-6| ... | ... | @@ -5,12 +5,8 @@ |
| 5 | 5 | //! This also includes code for pattern bindings in `let` statements and |
| 6 | 6 | //! function parameters. |
| 7 | 7 | |
| 8 | use crate::build::expr::as_place::PlaceBuilder; | |
| 9 | use crate::build::scope::DropKind; | |
| 10 | use crate::build::ForGuard::{self, OutsideGuard, RefWithinGuard}; | |
| 11 | use crate::build::{BlockAnd, BlockAndExtension, Builder}; | |
| 12 | use crate::build::{GuardFrame, GuardFrameLocal, LocalsForNode}; | |
| 13 | use rustc_data_structures::{fx::FxIndexMap, stack::ensure_sufficient_stack}; | |
| 8 | use rustc_data_structures::fx::FxIndexMap; | |
| 9 | use rustc_data_structures::stack::ensure_sufficient_stack; | |
| 14 | 10 | use rustc_hir::{BindingMode, ByRef}; |
| 15 | 11 | use rustc_middle::bug; |
| 16 | 12 | use rustc_middle::middle::region; |
| ... | ... | @@ -23,6 +19,13 @@ use rustc_target::abi::VariantIdx; |
| 23 | 19 | use tracing::{debug, instrument}; |
| 24 | 20 | use util::visit_bindings; |
| 25 | 21 | |
| 22 | use crate::build::expr::as_place::PlaceBuilder; | |
| 23 | use crate::build::scope::DropKind; | |
| 24 | use crate::build::ForGuard::{self, OutsideGuard, RefWithinGuard}; | |
| 25 | use crate::build::{ | |
| 26 | BlockAnd, BlockAndExtension, Builder, GuardFrame, GuardFrameLocal, LocalsForNode, | |
| 27 | }; | |
| 28 | ||
| 26 | 29 | // helper functions, broken out by category: |
| 27 | 30 | mod match_pair; |
| 28 | 31 | mod simplify; |
compiler/rustc_mir_build/src/build/matches/simplify.rs+4-3| ... | ... | @@ -12,11 +12,12 @@ |
| 12 | 12 | //! sort of test: for example, testing which variant an enum is, or |
| 13 | 13 | //! testing a value against a constant. |
| 14 | 14 | |
| 15 | use crate::build::matches::{MatchPairTree, PatternExtraData, TestCase}; | |
| 16 | use crate::build::Builder; | |
| 15 | use std::mem; | |
| 16 | ||
| 17 | 17 | use tracing::{debug, instrument}; |
| 18 | 18 | |
| 19 | use std::mem; | |
| 19 | use crate::build::matches::{MatchPairTree, PatternExtraData, TestCase}; | |
| 20 | use crate::build::Builder; | |
| 20 | 21 | |
| 21 | 22 | impl<'a, 'tcx> Builder<'a, 'tcx> { |
| 22 | 23 | /// Simplify a list of match pairs so they all require a test. Stores relevant bindings and |
compiler/rustc_mir_build/src/build/matches/test.rs+6-5| ... | ... | @@ -5,14 +5,14 @@ |
| 5 | 5 | // identify what tests are needed, perform the tests, and then filter |
| 6 | 6 | // the candidates based on the result. |
| 7 | 7 | |
| 8 | use crate::build::matches::{Candidate, MatchPairTree, Test, TestBranch, TestCase, TestKind}; | |
| 9 | use crate::build::Builder; | |
| 8 | use std::cmp::Ordering; | |
| 9 | ||
| 10 | 10 | use rustc_data_structures::fx::FxIndexMap; |
| 11 | 11 | use rustc_hir::{LangItem, RangeEnd}; |
| 12 | 12 | use rustc_middle::mir::*; |
| 13 | use rustc_middle::ty::adjustment::PointerCoercion; | |
| 13 | 14 | use rustc_middle::ty::util::IntTypeExt; |
| 14 | use rustc_middle::ty::GenericArg; | |
| 15 | use rustc_middle::ty::{self, adjustment::PointerCoercion, Ty, TyCtxt}; | |
| 15 | use rustc_middle::ty::{self, GenericArg, Ty, TyCtxt}; | |
| 16 | 16 | use rustc_middle::{bug, span_bug}; |
| 17 | 17 | use rustc_span::def_id::DefId; |
| 18 | 18 | use rustc_span::source_map::Spanned; |
| ... | ... | @@ -20,7 +20,8 @@ use rustc_span::symbol::{sym, Symbol}; |
| 20 | 20 | use rustc_span::{Span, DUMMY_SP}; |
| 21 | 21 | use tracing::{debug, instrument}; |
| 22 | 22 | |
| 23 | use std::cmp::Ordering; | |
| 23 | use crate::build::matches::{Candidate, MatchPairTree, Test, TestBranch, TestCase, TestKind}; | |
| 24 | use crate::build::Builder; | |
| 24 | 25 | |
| 25 | 26 | impl<'a, 'tcx> Builder<'a, 'tcx> { |
| 26 | 27 | /// Identifies what test is needed to decide if `match_pair` is applicable. |
compiler/rustc_mir_build/src/build/matches/util.rs+4-3| ... | ... | @@ -1,14 +1,15 @@ |
| 1 | 1 | use std::marker::PhantomData; |
| 2 | 2 | |
| 3 | use crate::build::expr::as_place::PlaceBase; | |
| 4 | use crate::build::matches::{Binding, Candidate, FlatPat, MatchPairTree, TestCase}; | |
| 5 | use crate::build::Builder; | |
| 6 | 3 | use rustc_data_structures::fx::FxIndexMap; |
| 7 | 4 | use rustc_middle::mir::*; |
| 8 | 5 | use rustc_middle::ty::Ty; |
| 9 | 6 | use rustc_span::Span; |
| 10 | 7 | use tracing::debug; |
| 11 | 8 | |
| 9 | use crate::build::expr::as_place::PlaceBase; | |
| 10 | use crate::build::matches::{Binding, Candidate, FlatPat, MatchPairTree, TestCase}; | |
| 11 | use crate::build::Builder; | |
| 12 | ||
| 12 | 13 | impl<'a, 'tcx> Builder<'a, 'tcx> { |
| 13 | 14 | /// Creates a false edge to `imaginary_target` and a real edge to |
| 14 | 15 | /// real_target. If `imaginary_target` is none, or is the same as the real |
compiler/rustc_mir_build/src/build/misc.rs+2-2| ... | ... | @@ -1,14 +1,14 @@ |
| 1 | 1 | //! Miscellaneous builder routines that are not specific to building any particular |
| 2 | 2 | //! kind of thing. |
| 3 | 3 | |
| 4 | use crate::build::Builder; | |
| 5 | ||
| 6 | 4 | use rustc_middle::mir::*; |
| 7 | 5 | use rustc_middle::ty::{self, Ty}; |
| 8 | 6 | use rustc_span::Span; |
| 9 | 7 | use rustc_trait_selection::infer::InferCtxtExt; |
| 10 | 8 | use tracing::debug; |
| 11 | 9 | |
| 10 | use crate::build::Builder; | |
| 11 | ||
| 12 | 12 | impl<'a, 'tcx> Builder<'a, 'tcx> { |
| 13 | 13 | /// Adds a new temporary value of type `ty` storing the result of |
| 14 | 14 | /// evaluating `expr`. |
compiler/rustc_mir_build/src/build/mod.rs+3-4| ... | ... | @@ -1,5 +1,3 @@ |
| 1 | use crate::build::expr::as_place::PlaceBuilder; | |
| 2 | use crate::build::scope::DropKind; | |
| 3 | 1 | use itertools::Itertools; |
| 4 | 2 | use rustc_apfloat::ieee::{Double, Half, Quad, Single}; |
| 5 | 3 | use rustc_apfloat::Float; |
| ... | ... | @@ -21,12 +19,13 @@ use rustc_middle::thir::{self, ExprId, LintLevel, LocalVarId, Param, ParamId, Pa |
| 21 | 19 | use rustc_middle::ty::{self, ScalarInt, Ty, TyCtxt, TypeVisitableExt}; |
| 22 | 20 | use rustc_middle::{bug, span_bug}; |
| 23 | 21 | use rustc_span::symbol::sym; |
| 24 | use rustc_span::Span; | |
| 25 | use rustc_span::Symbol; | |
| 22 | use rustc_span::{Span, Symbol}; | |
| 26 | 23 | use rustc_target::abi::FieldIdx; |
| 27 | 24 | use rustc_target::spec::abi::Abi; |
| 28 | 25 | |
| 29 | 26 | use super::lints; |
| 27 | use crate::build::expr::as_place::PlaceBuilder; | |
| 28 | use crate::build::scope::DropKind; | |
| 30 | 29 | |
| 31 | 30 | pub(crate) fn closure_saved_names_of_captured_variables<'tcx>( |
| 32 | 31 | tcx: TyCtxt<'tcx>, |
compiler/rustc_mir_build/src/build/scope.rs+2-1| ... | ... | @@ -83,7 +83,6 @@ that contains only loops and breakable blocks. It tracks where a `break`, |
| 83 | 83 | |
| 84 | 84 | use std::mem; |
| 85 | 85 | |
| 86 | use crate::build::{BlockAnd, BlockAndExtension, BlockFrame, Builder, CFG}; | |
| 87 | 86 | use rustc_data_structures::fx::FxHashMap; |
| 88 | 87 | use rustc_hir::HirId; |
| 89 | 88 | use rustc_index::{IndexSlice, IndexVec}; |
| ... | ... | @@ -96,6 +95,8 @@ use rustc_span::source_map::Spanned; |
| 96 | 95 | use rustc_span::{Span, DUMMY_SP}; |
| 97 | 96 | use tracing::{debug, instrument}; |
| 98 | 97 | |
| 98 | use crate::build::{BlockAnd, BlockAndExtension, BlockFrame, Builder, CFG}; | |
| 99 | ||
| 99 | 100 | #[derive(Debug)] |
| 100 | 101 | pub(crate) struct Scopes<'tcx> { |
| 101 | 102 | scopes: Vec<Scope>, |
compiler/rustc_mir_build/src/check_unsafety.rs+5-5| ... | ... | @@ -1,5 +1,6 @@ |
| 1 | use crate::build::ExprCategory; | |
| 2 | use crate::errors::*; | |
| 1 | use std::borrow::Cow; | |
| 2 | use std::mem; | |
| 3 | use std::ops::Bound; | |
| 3 | 4 | |
| 4 | 5 | use rustc_errors::DiagArgValue; |
| 5 | 6 | use rustc_hir::def::DefKind; |
| ... | ... | @@ -16,9 +17,8 @@ use rustc_span::def_id::{DefId, LocalDefId}; |
| 16 | 17 | use rustc_span::symbol::Symbol; |
| 17 | 18 | use rustc_span::{sym, Span}; |
| 18 | 19 | |
| 19 | use std::borrow::Cow; | |
| 20 | use std::mem; | |
| 21 | use std::ops::Bound; | |
| 20 | use crate::build::ExprCategory; | |
| 21 | use crate::errors::*; | |
| 22 | 22 | |
| 23 | 23 | struct UnsafetyVisitor<'a, 'tcx> { |
| 24 | 24 | tcx: TyCtxt<'tcx>, |
compiler/rustc_mir_build/src/errors.rs+7-5| ... | ... | @@ -1,15 +1,17 @@ |
| 1 | use crate::fluent_generated as fluent; | |
| 1 | use rustc_errors::codes::*; | |
| 2 | 2 | use rustc_errors::{ |
| 3 | codes::*, Applicability, Diag, Diagnostic, EmissionGuarantee, Level, MultiSpan, | |
| 4 | SubdiagMessageOp, Subdiagnostic, | |
| 3 | Applicability, Diag, DiagArgValue, DiagCtxtHandle, Diagnostic, EmissionGuarantee, Level, | |
| 4 | MultiSpan, SubdiagMessageOp, Subdiagnostic, | |
| 5 | 5 | }; |
| 6 | use rustc_errors::{DiagArgValue, DiagCtxtHandle}; | |
| 7 | 6 | use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic}; |
| 8 | 7 | use rustc_middle::ty::{self, Ty}; |
| 9 | use rustc_pattern_analysis::{errors::Uncovered, rustc::RustcPatCtxt}; | |
| 8 | use rustc_pattern_analysis::errors::Uncovered; | |
| 9 | use rustc_pattern_analysis::rustc::RustcPatCtxt; | |
| 10 | 10 | use rustc_span::symbol::Symbol; |
| 11 | 11 | use rustc_span::Span; |
| 12 | 12 | |
| 13 | use crate::fluent_generated as fluent; | |
| 14 | ||
| 13 | 15 | #[derive(LintDiagnostic)] |
| 14 | 16 | #[diag(mir_build_unconditional_recursion)] |
| 15 | 17 | #[help] |
compiler/rustc_mir_build/src/lints.rs+5-4| ... | ... | @@ -1,14 +1,15 @@ |
| 1 | use crate::errors::UnconditionalRecursion; | |
| 1 | use std::ops::ControlFlow; | |
| 2 | ||
| 2 | 3 | use rustc_data_structures::graph::iterate::{ |
| 3 | 4 | NodeStatus, TriColorDepthFirstSearch, TriColorVisitor, |
| 4 | 5 | }; |
| 5 | 6 | use rustc_hir::def::DefKind; |
| 6 | 7 | use rustc_middle::mir::{self, BasicBlock, BasicBlocks, Body, Terminator, TerminatorKind}; |
| 7 | use rustc_middle::ty::{self, Instance, Ty, TyCtxt}; | |
| 8 | use rustc_middle::ty::{GenericArg, GenericArgs}; | |
| 8 | use rustc_middle::ty::{self, GenericArg, GenericArgs, Instance, Ty, TyCtxt}; | |
| 9 | 9 | use rustc_session::lint::builtin::UNCONDITIONAL_RECURSION; |
| 10 | 10 | use rustc_span::Span; |
| 11 | use std::ops::ControlFlow; | |
| 11 | ||
| 12 | use crate::errors::UnconditionalRecursion; | |
| 12 | 13 | |
| 13 | 14 | pub(crate) fn check<'tcx>(tcx: TyCtxt<'tcx>, body: &Body<'tcx>) { |
| 14 | 15 | check_call_recursion(tcx, body); |
compiler/rustc_mir_build/src/thir/cx/block.rs+2-2| ... | ... | @@ -1,5 +1,3 @@ |
| 1 | use crate::thir::cx::Cx; | |
| 2 | ||
| 3 | 1 | use rustc_hir as hir; |
| 4 | 2 | use rustc_index::Idx; |
| 5 | 3 | use rustc_middle::middle::region; |
| ... | ... | @@ -8,6 +6,8 @@ use rustc_middle::ty; |
| 8 | 6 | use rustc_middle::ty::CanonicalUserTypeAnnotation; |
| 9 | 7 | use tracing::debug; |
| 10 | 8 | |
| 9 | use crate::thir::cx::Cx; | |
| 10 | ||
| 11 | 11 | impl<'tcx> Cx<'tcx> { |
| 12 | 12 | pub(crate) fn mirror_block(&mut self, block: &'tcx hir::Block<'tcx>) -> BlockId { |
| 13 | 13 | // We have to eagerly lower the "spine" of the statements |
compiler/rustc_mir_build/src/thir/cx/expr.rs+10-9| ... | ... | @@ -1,30 +1,31 @@ |
| 1 | use crate::errors; | |
| 2 | use crate::thir::cx::region::Scope; | |
| 3 | use crate::thir::cx::Cx; | |
| 4 | use crate::thir::util::UserAnnotatedTyHelpers; | |
| 5 | 1 | use itertools::Itertools; |
| 6 | 2 | use rustc_data_structures::stack::ensure_sufficient_stack; |
| 7 | 3 | use rustc_hir as hir; |
| 8 | 4 | use rustc_hir::def::{CtorKind, CtorOf, DefKind, Res}; |
| 9 | 5 | use rustc_index::Idx; |
| 10 | use rustc_middle::hir::place::Place as HirPlace; | |
| 11 | use rustc_middle::hir::place::PlaceBase as HirPlaceBase; | |
| 12 | use rustc_middle::hir::place::ProjectionKind as HirProjectionKind; | |
| 6 | use rustc_middle::hir::place::{ | |
| 7 | Place as HirPlace, PlaceBase as HirPlaceBase, ProjectionKind as HirProjectionKind, | |
| 8 | }; | |
| 13 | 9 | use rustc_middle::middle::region; |
| 14 | 10 | use rustc_middle::mir::{self, BinOp, BorrowKind, UnOp}; |
| 15 | 11 | use rustc_middle::thir::*; |
| 16 | 12 | use rustc_middle::ty::adjustment::{ |
| 17 | 13 | Adjust, Adjustment, AutoBorrow, AutoBorrowMutability, PointerCoercion, |
| 18 | 14 | }; |
| 19 | use rustc_middle::ty::GenericArgs; | |
| 20 | 15 | use rustc_middle::ty::{ |
| 21 | self, AdtKind, InlineConstArgs, InlineConstArgsParts, ScalarInt, Ty, UpvarArgs, UserType, | |
| 16 | self, AdtKind, GenericArgs, InlineConstArgs, InlineConstArgsParts, ScalarInt, Ty, UpvarArgs, | |
| 17 | UserType, | |
| 22 | 18 | }; |
| 23 | 19 | use rustc_middle::{bug, span_bug}; |
| 24 | 20 | use rustc_span::{sym, Span}; |
| 25 | 21 | use rustc_target::abi::{FieldIdx, FIRST_VARIANT}; |
| 26 | 22 | use tracing::{debug, info, instrument, trace}; |
| 27 | 23 | |
| 24 | use crate::errors; | |
| 25 | use crate::thir::cx::region::Scope; | |
| 26 | use crate::thir::cx::Cx; | |
| 27 | use crate::thir::util::UserAnnotatedTyHelpers; | |
| 28 | ||
| 28 | 29 | impl<'tcx> Cx<'tcx> { |
| 29 | 30 | pub(crate) fn mirror_expr(&mut self, expr: &'tcx hir::Expr<'tcx>) -> ExprId { |
| 30 | 31 | // `mirror_expr` is recursing very deep. Make sure the stack doesn't overflow. |
compiler/rustc_mir_build/src/thir/cx/mod.rs+4-5| ... | ... | @@ -2,23 +2,22 @@ |
| 2 | 2 | //! structures into the THIR. The `builder` is generally ignorant of the tcx, |
| 3 | 3 | //! etc., and instead goes through the `Cx` for most of its work. |
| 4 | 4 | |
| 5 | use crate::thir::pattern::pat_from_hir; | |
| 6 | use crate::thir::util::UserAnnotatedTyHelpers; | |
| 7 | ||
| 8 | 5 | use rustc_data_structures::steal::Steal; |
| 9 | 6 | use rustc_errors::ErrorGuaranteed; |
| 10 | 7 | use rustc_hir as hir; |
| 11 | 8 | use rustc_hir::def::DefKind; |
| 12 | 9 | use rustc_hir::def_id::{DefId, LocalDefId}; |
| 13 | 10 | use rustc_hir::lang_items::LangItem; |
| 14 | use rustc_hir::HirId; | |
| 15 | use rustc_hir::Node; | |
| 11 | use rustc_hir::{HirId, Node}; | |
| 16 | 12 | use rustc_middle::bug; |
| 17 | 13 | use rustc_middle::middle::region; |
| 18 | 14 | use rustc_middle::thir::*; |
| 19 | 15 | use rustc_middle::ty::{self, RvalueScopes, TyCtxt}; |
| 20 | 16 | use tracing::instrument; |
| 21 | 17 | |
| 18 | use crate::thir::pattern::pat_from_hir; | |
| 19 | use crate::thir::util::UserAnnotatedTyHelpers; | |
| 20 | ||
| 22 | 21 | pub(crate) fn thir_body( |
| 23 | 22 | tcx: TyCtxt<'_>, |
| 24 | 23 | owner_def: LocalDefId, |
compiler/rustc_mir_build/src/thir/pattern/check_match.rs+5-4| ... | ... | @@ -1,11 +1,9 @@ |
| 1 | use crate::errors::*; | |
| 2 | use crate::fluent_generated as fluent; | |
| 3 | ||
| 4 | 1 | use rustc_arena::{DroplessArena, TypedArena}; |
| 5 | 2 | use rustc_ast::Mutability; |
| 6 | 3 | use rustc_data_structures::fx::FxIndexSet; |
| 7 | 4 | use rustc_data_structures::stack::ensure_sufficient_stack; |
| 8 | use rustc_errors::{codes::*, struct_span_code_err, Applicability, ErrorGuaranteed, MultiSpan}; | |
| 5 | use rustc_errors::codes::*; | |
| 6 | use rustc_errors::{struct_span_code_err, Applicability, ErrorGuaranteed, MultiSpan}; | |
| 9 | 7 | use rustc_hir::def::*; |
| 10 | 8 | use rustc_hir::def_id::LocalDefId; |
| 11 | 9 | use rustc_hir::{self as hir, BindingMode, ByRef, HirId}; |
| ... | ... | @@ -27,6 +25,9 @@ use rustc_span::hygiene::DesugaringKind; |
| 27 | 25 | use rustc_span::{sym, Span}; |
| 28 | 26 | use tracing::instrument; |
| 29 | 27 | |
| 28 | use crate::errors::*; | |
| 29 | use crate::fluent_generated as fluent; | |
| 30 | ||
| 30 | 31 | pub(crate) fn check_match(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(), ErrorGuaranteed> { |
| 31 | 32 | let typeck_results = tcx.typeck(def_id); |
| 32 | 33 | let (thir, expr) = tcx.thir_body(def_id)?; |
compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs+1-2| ... | ... | @@ -7,8 +7,7 @@ use rustc_infer::traits::Obligation; |
| 7 | 7 | use rustc_middle::mir; |
| 8 | 8 | use rustc_middle::mir::interpret::ErrorHandled; |
| 9 | 9 | use rustc_middle::thir::{FieldPat, Pat, PatKind}; |
| 10 | use rustc_middle::ty::TypeVisitableExt; | |
| 11 | use rustc_middle::ty::{self, Ty, TyCtxt, ValTree}; | |
| 10 | use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitableExt, ValTree}; | |
| 12 | 11 | use rustc_span::Span; |
| 13 | 12 | use rustc_target::abi::{FieldIdx, VariantIdx}; |
| 14 | 13 | use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt; |
compiler/rustc_mir_build/src/thir/pattern/mod.rs+4-5| ... | ... | @@ -3,10 +3,7 @@ |
| 3 | 3 | mod check_match; |
| 4 | 4 | mod const_to_pat; |
| 5 | 5 | |
| 6 | pub(crate) use self::check_match::check_match; | |
| 7 | ||
| 8 | use crate::errors::*; | |
| 9 | use crate::thir::util::UserAnnotatedTyHelpers; | |
| 6 | use std::cmp::Ordering; | |
| 10 | 7 | |
| 11 | 8 | use rustc_errors::codes::*; |
| 12 | 9 | use rustc_hir::def::{CtorOf, DefKind, Res}; |
| ... | ... | @@ -26,7 +23,9 @@ use rustc_span::{ErrorGuaranteed, Span}; |
| 26 | 23 | use rustc_target::abi::{FieldIdx, Integer}; |
| 27 | 24 | use tracing::{debug, instrument}; |
| 28 | 25 | |
| 29 | use std::cmp::Ordering; | |
| 26 | pub(crate) use self::check_match::check_match; | |
| 27 | use crate::errors::*; | |
| 28 | use crate::thir::util::UserAnnotatedTyHelpers; | |
| 30 | 29 | |
| 31 | 30 | struct PatCtxt<'a, 'tcx> { |
| 32 | 31 | tcx: TyCtxt<'tcx>, |
compiler/rustc_mir_build/src/thir/print.rs+2-1| ... | ... | @@ -1,8 +1,9 @@ |
| 1 | use std::fmt::{self, Write}; | |
| 2 | ||
| 1 | 3 | use rustc_middle::query::TyCtxtAt; |
| 2 | 4 | use rustc_middle::thir::*; |
| 3 | 5 | use rustc_middle::ty; |
| 4 | 6 | use rustc_span::def_id::LocalDefId; |
| 5 | use std::fmt::{self, Write}; | |
| 6 | 7 | |
| 7 | 8 | pub(crate) fn thir_tree(tcx: TyCtxtAt<'_>, owner_def: LocalDefId) -> String { |
| 8 | 9 | match super::cx::thir_body(*tcx, owner_def) { |
compiler/rustc_mir_dataflow/src/drop_flag_effects.rs+1-1| ... | ... | @@ -1,10 +1,10 @@ |
| 1 | use crate::elaborate_drops::DropFlagState; | |
| 2 | 1 | use rustc_middle::mir::{self, Body, Location, Terminator, TerminatorKind}; |
| 3 | 2 | use rustc_target::abi::VariantIdx; |
| 4 | 3 | use tracing::debug; |
| 5 | 4 | |
| 6 | 5 | use super::move_paths::{InitKind, LookupResult, MoveData, MovePathIndex}; |
| 7 | 6 | use super::MoveDataParamEnv; |
| 7 | use crate::elaborate_drops::DropFlagState; | |
| 8 | 8 | |
| 9 | 9 | pub fn move_path_children_matching<'tcx, F>( |
| 10 | 10 | move_data: &MoveData<'tcx>, |
compiler/rustc_mir_dataflow/src/elaborate_drops.rs+3-3| ... | ... | @@ -1,3 +1,5 @@ |
| 1 | use std::{fmt, iter}; | |
| 2 | ||
| 1 | 3 | use rustc_hir::lang_items::LangItem; |
| 2 | 4 | use rustc_index::Idx; |
| 3 | 5 | use rustc_middle::mir::patch::MirPatch; |
| ... | ... | @@ -5,12 +7,10 @@ use rustc_middle::mir::*; |
| 5 | 7 | use rustc_middle::span_bug; |
| 6 | 8 | use rustc_middle::traits::Reveal; |
| 7 | 9 | use rustc_middle::ty::util::IntTypeExt; |
| 8 | use rustc_middle::ty::GenericArgsRef; | |
| 9 | use rustc_middle::ty::{self, Ty, TyCtxt}; | |
| 10 | use rustc_middle::ty::{self, GenericArgsRef, Ty, TyCtxt}; | |
| 10 | 11 | use rustc_span::source_map::Spanned; |
| 11 | 12 | use rustc_span::DUMMY_SP; |
| 12 | 13 | use rustc_target::abi::{FieldIdx, VariantIdx, FIRST_VARIANT}; |
| 13 | use std::{fmt, iter}; | |
| 14 | 14 | use tracing::{debug, instrument}; |
| 15 | 15 | |
| 16 | 16 | /// The value of an inserted drop flag. |
compiler/rustc_mir_dataflow/src/framework/cursor.rs+1-2| ... | ... | @@ -1,7 +1,5 @@ |
| 1 | 1 | //! Random access inspection of the results of a dataflow analysis. |
| 2 | 2 | |
| 3 | use crate::framework::BitSetExt; | |
| 4 | ||
| 5 | 3 | use std::cmp::Ordering; |
| 6 | 4 | |
| 7 | 5 | #[cfg(debug_assertions)] |
| ... | ... | @@ -9,6 +7,7 @@ use rustc_index::bit_set::BitSet; |
| 9 | 7 | use rustc_middle::mir::{self, BasicBlock, Location}; |
| 10 | 8 | |
| 11 | 9 | use super::{Analysis, Direction, Effect, EffectIndex, Results}; |
| 10 | use crate::framework::BitSetExt; | |
| 12 | 11 | |
| 13 | 12 | /// Allows random access inspection of the results of a dataflow analysis. |
| 14 | 13 | /// |
compiler/rustc_mir_dataflow/src/framework/direction.rs+2-1| ... | ... | @@ -1,7 +1,8 @@ |
| 1 | use std::ops::RangeInclusive; | |
| 2 | ||
| 1 | 3 | use rustc_middle::mir::{ |
| 2 | 4 | self, BasicBlock, CallReturnPlaces, Location, SwitchTargets, TerminatorEdges, |
| 3 | 5 | }; |
| 4 | use std::ops::RangeInclusive; | |
| 5 | 6 | |
| 6 | 7 | use super::visitor::{ResultsVisitable, ResultsVisitor}; |
| 7 | 8 | use super::{Analysis, Effect, EffectIndex, GenKillAnalysis, GenKillSet, SwitchIntTarget}; |
compiler/rustc_mir_dataflow/src/framework/engine.rs+8-12| ... | ... | @@ -1,32 +1,28 @@ |
| 1 | 1 | //! A solver for dataflow problems. |
| 2 | 2 | |
| 3 | use crate::errors::{ | |
| 4 | DuplicateValuesFor, PathMustEndInFilename, RequiresAnArgument, UnknownFormatter, | |
| 5 | }; | |
| 6 | use crate::framework::BitSetExt; | |
| 7 | ||
| 8 | 3 | use std::ffi::OsString; |
| 9 | 4 | use std::path::PathBuf; |
| 10 | 5 | |
| 11 | use rustc_ast as ast; | |
| 12 | 6 | use rustc_data_structures::work_queue::WorkQueue; |
| 13 | use rustc_graphviz as dot; | |
| 14 | 7 | use rustc_hir::def_id::DefId; |
| 15 | 8 | use rustc_index::{Idx, IndexVec}; |
| 16 | 9 | use rustc_middle::bug; |
| 17 | use rustc_middle::mir::{self, traversal, BasicBlock}; | |
| 18 | use rustc_middle::mir::{create_dump_file, dump_enabled}; | |
| 10 | use rustc_middle::mir::{self, create_dump_file, dump_enabled, traversal, BasicBlock}; | |
| 19 | 11 | use rustc_middle::ty::print::with_no_trimmed_paths; |
| 20 | 12 | use rustc_middle::ty::TyCtxt; |
| 21 | 13 | use rustc_span::symbol::{sym, Symbol}; |
| 22 | 14 | use tracing::{debug, error}; |
| 15 | use {rustc_ast as ast, rustc_graphviz as dot}; | |
| 23 | 16 | |
| 24 | 17 | use super::fmt::DebugWithContext; |
| 25 | use super::graphviz; | |
| 26 | 18 | use super::{ |
| 27 | visit_results, Analysis, AnalysisDomain, Direction, GenKill, GenKillAnalysis, GenKillSet, | |
| 28 | JoinSemiLattice, ResultsCursor, ResultsVisitor, | |
| 19 | graphviz, visit_results, Analysis, AnalysisDomain, Direction, GenKill, GenKillAnalysis, | |
| 20 | GenKillSet, JoinSemiLattice, ResultsCursor, ResultsVisitor, | |
| 29 | 21 | }; |
| 22 | use crate::errors::{ | |
| 23 | DuplicateValuesFor, PathMustEndInFilename, RequiresAnArgument, UnknownFormatter, | |
| 24 | }; | |
| 25 | use crate::framework::BitSetExt; | |
| 30 | 26 | |
| 31 | 27 | pub type EntrySets<'tcx, A> = IndexVec<BasicBlock, <A as AnalysisDomain<'tcx>>::Domain>; |
| 32 | 28 |
compiler/rustc_mir_dataflow/src/framework/fmt.rs+4-2| ... | ... | @@ -1,10 +1,12 @@ |
| 1 | 1 | //! Custom formatting traits used when outputting Graphviz diagrams with the results of a dataflow |
| 2 | 2 | //! analysis. |
| 3 | 3 | |
| 4 | use super::lattice::MaybeReachable; | |
| 4 | use std::fmt; | |
| 5 | ||
| 5 | 6 | use rustc_index::bit_set::{BitSet, ChunkedBitSet, HybridBitSet}; |
| 6 | 7 | use rustc_index::Idx; |
| 7 | use std::fmt; | |
| 8 | ||
| 9 | use super::lattice::MaybeReachable; | |
| 8 | 10 | |
| 9 | 11 | /// An extension to `fmt::Debug` for data that can be better printed with some auxiliary data `C`. |
| 10 | 12 | pub trait DebugWithContext<C>: Eq + fmt::Debug { |
compiler/rustc_mir_dataflow/src/framework/graphviz.rs+1-2| ... | ... | @@ -8,8 +8,7 @@ use std::{io, ops, str}; |
| 8 | 8 | use regex::Regex; |
| 9 | 9 | use rustc_graphviz as dot; |
| 10 | 10 | use rustc_index::bit_set::BitSet; |
| 11 | use rustc_middle::mir::graphviz_safe_def_name; | |
| 12 | use rustc_middle::mir::{self, BasicBlock, Body, Location}; | |
| 11 | use rustc_middle::mir::{self, graphviz_safe_def_name, BasicBlock, Body, Location}; | |
| 13 | 12 | |
| 14 | 13 | use super::fmt::{DebugDiffWithAdapter, DebugWithAdapter, DebugWithContext}; |
| 15 | 14 | use super::{Analysis, CallReturnPlaces, Direction, Results, ResultsCursor, ResultsVisitor}; |
compiler/rustc_mir_dataflow/src/framework/lattice.rs+4-2| ... | ... | @@ -38,10 +38,12 @@ |
| 38 | 38 | //! [Hasse diagram]: https://en.wikipedia.org/wiki/Hasse_diagram |
| 39 | 39 | //! [poset]: https://en.wikipedia.org/wiki/Partially_ordered_set |
| 40 | 40 | |
| 41 | use crate::framework::BitSetExt; | |
| 41 | use std::iter; | |
| 42 | ||
| 42 | 43 | use rustc_index::bit_set::{BitSet, ChunkedBitSet, HybridBitSet}; |
| 43 | 44 | use rustc_index::{Idx, IndexVec}; |
| 44 | use std::iter; | |
| 45 | ||
| 46 | use crate::framework::BitSetExt; | |
| 45 | 47 | |
| 46 | 48 | /// A [partially ordered set][poset] that has a [least upper bound][lub] for any pair of elements |
| 47 | 49 | /// in the set. |
compiler/rustc_mir_dataflow/src/impls/initialized.rs+5-6| ... | ... | @@ -5,15 +5,14 @@ use rustc_middle::mir::{self, Body, CallReturnPlaces, Location, TerminatorEdges} |
| 5 | 5 | use rustc_middle::ty::{self, TyCtxt}; |
| 6 | 6 | use tracing::{debug, instrument}; |
| 7 | 7 | |
| 8 | use crate::drop_flag_effects_for_function_entry; | |
| 9 | use crate::drop_flag_effects_for_location; | |
| 10 | 8 | use crate::elaborate_drops::DropFlagState; |
| 11 | 9 | use crate::framework::SwitchIntEdgeEffects; |
| 12 | 10 | use crate::move_paths::{HasMoveData, InitIndex, InitKind, LookupResult, MoveData, MovePathIndex}; |
| 13 | use crate::on_lookup_result_bits; | |
| 14 | use crate::MoveDataParamEnv; | |
| 15 | use crate::{drop_flag_effects, on_all_children_bits}; | |
| 16 | use crate::{lattice, AnalysisDomain, GenKill, GenKillAnalysis, MaybeReachable}; | |
| 11 | use crate::{ | |
| 12 | drop_flag_effects, drop_flag_effects_for_function_entry, drop_flag_effects_for_location, | |
| 13 | lattice, on_all_children_bits, on_lookup_result_bits, AnalysisDomain, GenKill, GenKillAnalysis, | |
| 14 | MaybeReachable, MoveDataParamEnv, | |
| 15 | }; | |
| 17 | 16 | |
| 18 | 17 | /// `MaybeInitializedPlaces` tracks all places that might be |
| 19 | 18 | /// initialized upon reaching a particular point in the control flow |
compiler/rustc_mir_dataflow/src/impls/mod.rs+4-5| ... | ... | @@ -7,13 +7,12 @@ mod initialized; |
| 7 | 7 | mod liveness; |
| 8 | 8 | mod storage_liveness; |
| 9 | 9 | |
| 10 | pub use self::borrowed_locals::borrowed_locals; | |
| 11 | pub use self::borrowed_locals::MaybeBorrowedLocals; | |
| 10 | pub use self::borrowed_locals::{borrowed_locals, MaybeBorrowedLocals}; | |
| 12 | 11 | pub use self::initialized::{ |
| 13 | 12 | DefinitelyInitializedPlaces, EverInitializedPlaces, MaybeInitializedPlaces, |
| 14 | 13 | MaybeUninitializedPlaces, |
| 15 | 14 | }; |
| 16 | pub use self::liveness::MaybeLiveLocals; | |
| 17 | pub use self::liveness::MaybeTransitiveLiveLocals; | |
| 18 | pub use self::liveness::TransferFunction as LivenessTransferFunction; | |
| 15 | pub use self::liveness::{ | |
| 16 | MaybeLiveLocals, MaybeTransitiveLiveLocals, TransferFunction as LivenessTransferFunction, | |
| 17 | }; | |
| 19 | 18 | pub use self::storage_liveness::{MaybeRequiresStorage, MaybeStorageDead, MaybeStorageLive}; |
compiler/rustc_mir_dataflow/src/impls/storage_liveness.rs+2-2| ... | ... | @@ -1,9 +1,9 @@ |
| 1 | use std::borrow::Cow; | |
| 2 | ||
| 1 | 3 | use rustc_index::bit_set::BitSet; |
| 2 | 4 | use rustc_middle::mir::visit::{NonMutatingUseContext, PlaceContext, Visitor}; |
| 3 | 5 | use rustc_middle::mir::*; |
| 4 | 6 | |
| 5 | use std::borrow::Cow; | |
| 6 | ||
| 7 | 7 | use super::MaybeBorrowedLocals; |
| 8 | 8 | use crate::{GenKill, ResultsCursor}; |
| 9 | 9 |
compiler/rustc_mir_dataflow/src/move_paths/builder.rs+4-4| ... | ... | @@ -1,3 +1,5 @@ |
| 1 | use std::mem; | |
| 2 | ||
| 1 | 3 | use rustc_index::IndexVec; |
| 2 | 4 | use rustc_middle::mir::tcx::{PlaceTy, RvalueInitializationState}; |
| 3 | 5 | use rustc_middle::mir::*; |
| ... | ... | @@ -6,12 +8,10 @@ use rustc_middle::{bug, span_bug}; |
| 6 | 8 | use smallvec::{smallvec, SmallVec}; |
| 7 | 9 | use tracing::debug; |
| 8 | 10 | |
| 9 | use std::mem; | |
| 10 | ||
| 11 | 11 | use super::abs_domain::Lift; |
| 12 | use super::{Init, InitIndex, InitKind, InitLocation, LookupResult}; | |
| 13 | 12 | use super::{ |
| 14 | LocationMap, MoveData, MoveOut, MoveOutIndex, MovePath, MovePathIndex, MovePathLookup, | |
| 13 | Init, InitIndex, InitKind, InitLocation, LocationMap, LookupResult, MoveData, MoveOut, | |
| 14 | MoveOutIndex, MovePath, MovePathIndex, MovePathLookup, | |
| 15 | 15 | }; |
| 16 | 16 | |
| 17 | 17 | struct MoveDataBuilder<'a, 'tcx, F> { |
compiler/rustc_mir_dataflow/src/move_paths/mod.rs+4-4| ... | ... | @@ -1,4 +1,6 @@ |
| 1 | use crate::un_derefer::UnDerefer; | |
| 1 | use std::fmt; | |
| 2 | use std::ops::{Index, IndexMut}; | |
| 3 | ||
| 2 | 4 | use rustc_data_structures::fx::FxHashMap; |
| 3 | 5 | use rustc_index::{IndexSlice, IndexVec}; |
| 4 | 6 | use rustc_middle::mir::*; |
| ... | ... | @@ -6,10 +8,8 @@ use rustc_middle::ty::{ParamEnv, Ty, TyCtxt}; |
| 6 | 8 | use rustc_span::Span; |
| 7 | 9 | use smallvec::SmallVec; |
| 8 | 10 | |
| 9 | use std::fmt; | |
| 10 | use std::ops::{Index, IndexMut}; | |
| 11 | ||
| 12 | 11 | use self::abs_domain::{AbstractElem, Lift}; |
| 12 | use crate::un_derefer::UnDerefer; | |
| 13 | 13 | |
| 14 | 14 | mod abs_domain; |
| 15 | 15 |
compiler/rustc_mir_dataflow/src/points.rs+3-3| ... | ... | @@ -1,10 +1,10 @@ |
| 1 | use crate::framework::{visit_results, ResultsVisitable, ResultsVisitor}; | |
| 2 | 1 | use rustc_index::bit_set::BitSet; |
| 3 | 2 | use rustc_index::interval::SparseIntervalMatrix; |
| 4 | use rustc_index::Idx; | |
| 5 | use rustc_index::IndexVec; | |
| 3 | use rustc_index::{Idx, IndexVec}; | |
| 6 | 4 | use rustc_middle::mir::{self, BasicBlock, Body, Location}; |
| 7 | 5 | |
| 6 | use crate::framework::{visit_results, ResultsVisitable, ResultsVisitor}; | |
| 7 | ||
| 8 | 8 | /// Maps between a `Location` and a `PointIndex` (and vice versa). |
| 9 | 9 | pub struct DenseLocationMap { |
| 10 | 10 | /// For each basic block, how many points are contained within? |
compiler/rustc_mir_dataflow/src/rustc_peek.rs+11-13| ... | ... | @@ -1,3 +1,12 @@ |
| 1 | use rustc_ast::MetaItem; | |
| 2 | use rustc_hir::def_id::DefId; | |
| 3 | use rustc_index::bit_set::BitSet; | |
| 4 | use rustc_middle::mir::{self, Body, Local, Location, MirPass}; | |
| 5 | use rustc_middle::ty::{self, Ty, TyCtxt}; | |
| 6 | use rustc_span::symbol::{sym, Symbol}; | |
| 7 | use rustc_span::Span; | |
| 8 | use tracing::{debug, info}; | |
| 9 | ||
| 1 | 10 | use crate::errors::{ |
| 2 | 11 | PeekArgumentNotALocal, PeekArgumentUntracked, PeekBitNotSet, PeekMustBeNotTemporary, |
| 3 | 12 | PeekMustBePlaceOrRefPlace, StopAfterDataFlowEndedCompilation, |
| ... | ... | @@ -6,19 +15,8 @@ use crate::framework::BitSetExt; |
| 6 | 15 | use crate::impls::{ |
| 7 | 16 | DefinitelyInitializedPlaces, MaybeInitializedPlaces, MaybeLiveLocals, MaybeUninitializedPlaces, |
| 8 | 17 | }; |
| 9 | use crate::move_paths::{HasMoveData, MoveData}; | |
| 10 | use crate::move_paths::{LookupResult, MovePathIndex}; | |
| 11 | use crate::MoveDataParamEnv; | |
| 12 | use crate::{Analysis, JoinSemiLattice, ResultsCursor}; | |
| 13 | use rustc_ast::MetaItem; | |
| 14 | use rustc_hir::def_id::DefId; | |
| 15 | use rustc_index::bit_set::BitSet; | |
| 16 | use rustc_middle::mir::MirPass; | |
| 17 | use rustc_middle::mir::{self, Body, Local, Location}; | |
| 18 | use rustc_middle::ty::{self, Ty, TyCtxt}; | |
| 19 | use rustc_span::symbol::{sym, Symbol}; | |
| 20 | use rustc_span::Span; | |
| 21 | use tracing::{debug, info}; | |
| 18 | use crate::move_paths::{HasMoveData, LookupResult, MoveData, MovePathIndex}; | |
| 19 | use crate::{Analysis, JoinSemiLattice, MoveDataParamEnv, ResultsCursor}; | |
| 22 | 20 | |
| 23 | 21 | pub struct SanityCheck; |
| 24 | 22 |
compiler/rustc_mir_dataflow/src/value_analysis.rs+2-3| ... | ... | @@ -48,10 +48,9 @@ use rustc_middle::ty::{self, Ty, TyCtxt}; |
| 48 | 48 | use rustc_target::abi::{FieldIdx, VariantIdx}; |
| 49 | 49 | use tracing::debug; |
| 50 | 50 | |
| 51 | use crate::fmt::DebugWithContext; | |
| 51 | 52 | use crate::lattice::{HasBottom, HasTop}; |
| 52 | use crate::{ | |
| 53 | fmt::DebugWithContext, Analysis, AnalysisDomain, JoinSemiLattice, SwitchIntEdgeEffects, | |
| 54 | }; | |
| 53 | use crate::{Analysis, AnalysisDomain, JoinSemiLattice, SwitchIntEdgeEffects}; | |
| 55 | 54 | |
| 56 | 55 | pub trait ValueAnalysis<'tcx> { |
| 57 | 56 | /// For each place of interest, the analysis tracks a value of the given type. |
compiler/rustc_mir_transform/src/abort_unwinding_calls.rs+1-2| ... | ... | @@ -1,8 +1,7 @@ |
| 1 | 1 | use rustc_ast::InlineAsmOptions; |
| 2 | 2 | use rustc_middle::mir::*; |
| 3 | 3 | use rustc_middle::span_bug; |
| 4 | use rustc_middle::ty::layout; | |
| 5 | use rustc_middle::ty::{self, TyCtxt}; | |
| 4 | use rustc_middle::ty::{self, layout, TyCtxt}; | |
| 6 | 5 | use rustc_target::spec::abi::Abi; |
| 7 | 6 | use rustc_target::spec::PanicStrategy; |
| 8 | 7 |
compiler/rustc_mir_transform/src/add_moves_for_packed_drops.rs+1-1| ... | ... | @@ -1,8 +1,8 @@ |
| 1 | use rustc_middle::mir::patch::MirPatch; | |
| 1 | 2 | use rustc_middle::mir::*; |
| 2 | 3 | use rustc_middle::ty::TyCtxt; |
| 3 | 4 | |
| 4 | 5 | use crate::util; |
| 5 | use rustc_middle::mir::patch::MirPatch; | |
| 6 | 6 | |
| 7 | 7 | /// This pass moves values being dropped that are within a packed |
| 8 | 8 | /// struct to a separate local before dropping them, to ensure that |
compiler/rustc_mir_transform/src/check_alignment.rs+2-4| ... | ... | @@ -1,10 +1,8 @@ |
| 1 | 1 | use rustc_hir::lang_items::LangItem; |
| 2 | 2 | use rustc_index::IndexVec; |
| 3 | use rustc_middle::mir::interpret::Scalar; | |
| 4 | use rustc_middle::mir::visit::{MutatingUseContext, NonMutatingUseContext, PlaceContext, Visitor}; | |
| 3 | 5 | use rustc_middle::mir::*; |
| 4 | use rustc_middle::mir::{ | |
| 5 | interpret::Scalar, | |
| 6 | visit::{MutatingUseContext, NonMutatingUseContext, PlaceContext, Visitor}, | |
| 7 | }; | |
| 8 | 6 | use rustc_middle::ty::{self, ParamEnv, Ty, TyCtxt}; |
| 9 | 7 | use rustc_session::Session; |
| 10 | 8 |
compiler/rustc_mir_transform/src/check_packed_ref.rs+1-2| ... | ... | @@ -3,8 +3,7 @@ use rustc_middle::mir::*; |
| 3 | 3 | use rustc_middle::span_bug; |
| 4 | 4 | use rustc_middle::ty::{self, TyCtxt}; |
| 5 | 5 | |
| 6 | use crate::MirLint; | |
| 7 | use crate::{errors, util}; | |
| 6 | use crate::{errors, util, MirLint}; | |
| 8 | 7 | |
| 9 | 8 | pub struct CheckPackedRef; |
| 10 | 9 |
compiler/rustc_mir_transform/src/cleanup_post_borrowck.rs+2-1| ... | ... | @@ -16,12 +16,13 @@ |
| 16 | 16 | //! [`BlockMarker`]: rustc_middle::mir::coverage::CoverageKind::BlockMarker |
| 17 | 17 | //! [`SpanMarker`]: rustc_middle::mir::coverage::CoverageKind::SpanMarker |
| 18 | 18 | |
| 19 | use crate::MirPass; | |
| 20 | 19 | use rustc_middle::mir::coverage::CoverageKind; |
| 21 | 20 | use rustc_middle::mir::{Body, BorrowKind, CastKind, Rvalue, StatementKind, TerminatorKind}; |
| 22 | 21 | use rustc_middle::ty::adjustment::PointerCoercion; |
| 23 | 22 | use rustc_middle::ty::TyCtxt; |
| 24 | 23 | |
| 24 | use crate::MirPass; | |
| 25 | ||
| 25 | 26 | pub struct CleanupPostBorrowck; |
| 26 | 27 | |
| 27 | 28 | impl<'tcx> MirPass<'tcx> for CleanupPostBorrowck { |
compiler/rustc_mir_transform/src/coroutine.rs+9-13| ... | ... | @@ -51,13 +51,9 @@ |
| 51 | 51 | //! Otherwise it drops all the values in scope at the last suspension point. |
| 52 | 52 | |
| 53 | 53 | mod by_move_body; |
| 54 | pub use by_move_body::ByMoveBody; | |
| 54 | use std::{iter, ops}; | |
| 55 | 55 | |
| 56 | use crate::abort_unwinding_calls; | |
| 57 | use crate::deref_separator::deref_finder; | |
| 58 | use crate::errors; | |
| 59 | use crate::pass_manager as pm; | |
| 60 | use crate::simplify; | |
| 56 | pub use by_move_body::ByMoveBody; | |
| 61 | 57 | use rustc_data_structures::fx::FxHashSet; |
| 62 | 58 | use rustc_errors::pluralize; |
| 63 | 59 | use rustc_hir as hir; |
| ... | ... | @@ -67,9 +63,7 @@ use rustc_index::bit_set::{BitMatrix, BitSet, GrowableBitSet}; |
| 67 | 63 | use rustc_index::{Idx, IndexVec}; |
| 68 | 64 | use rustc_middle::mir::visit::{MutVisitor, PlaceContext, Visitor}; |
| 69 | 65 | use rustc_middle::mir::*; |
| 70 | use rustc_middle::ty::CoroutineArgs; | |
| 71 | use rustc_middle::ty::InstanceKind; | |
| 72 | use rustc_middle::ty::{self, CoroutineArgsExt, Ty, TyCtxt}; | |
| 66 | use rustc_middle::ty::{self, CoroutineArgs, CoroutineArgsExt, InstanceKind, Ty, TyCtxt}; | |
| 73 | 67 | use rustc_middle::{bug, span_bug}; |
| 74 | 68 | use rustc_mir_dataflow::impls::{ |
| 75 | 69 | MaybeBorrowedLocals, MaybeLiveLocals, MaybeRequiresStorage, MaybeStorageLive, |
| ... | ... | @@ -83,9 +77,10 @@ use rustc_target::abi::{FieldIdx, VariantIdx}; |
| 83 | 77 | use rustc_target::spec::PanicStrategy; |
| 84 | 78 | use rustc_trait_selection::error_reporting::InferCtxtErrorExt; |
| 85 | 79 | use rustc_trait_selection::infer::TyCtxtInferExt as _; |
| 86 | use rustc_trait_selection::traits::ObligationCtxt; | |
| 87 | use rustc_trait_selection::traits::{ObligationCause, ObligationCauseCode}; | |
| 88 | use std::{iter, ops}; | |
| 80 | use rustc_trait_selection::traits::{ObligationCause, ObligationCauseCode, ObligationCtxt}; | |
| 81 | ||
| 82 | use crate::deref_separator::deref_finder; | |
| 83 | use crate::{abort_unwinding_calls, errors, pass_manager as pm, simplify}; | |
| 89 | 84 | |
| 90 | 85 | pub struct StateTransform; |
| 91 | 86 | |
| ... | ... | @@ -1167,10 +1162,11 @@ fn insert_switch<'tcx>( |
| 1167 | 1162 | } |
| 1168 | 1163 | |
| 1169 | 1164 | fn elaborate_coroutine_drops<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { |
| 1170 | use crate::shim::DropShimElaborator; | |
| 1171 | 1165 | use rustc_middle::mir::patch::MirPatch; |
| 1172 | 1166 | use rustc_mir_dataflow::elaborate_drops::{elaborate_drop, Unwind}; |
| 1173 | 1167 | |
| 1168 | use crate::shim::DropShimElaborator; | |
| 1169 | ||
| 1174 | 1170 | // Note that `elaborate_drops` only drops the upvars of a coroutine, and |
| 1175 | 1171 | // this is ok because `open_drop` can only be reached within that own |
| 1176 | 1172 | // coroutine's resume function. |
compiler/rustc_mir_transform/src/coverage/graph.rs+4-4| ... | ... | @@ -1,3 +1,7 @@ |
| 1 | use std::cmp::Ordering; | |
| 2 | use std::collections::VecDeque; | |
| 3 | use std::ops::{Index, IndexMut}; | |
| 4 | ||
| 1 | 5 | use rustc_data_structures::captures::Captures; |
| 2 | 6 | use rustc_data_structures::fx::FxHashSet; |
| 3 | 7 | use rustc_data_structures::graph::dominators::{self, Dominators}; |
| ... | ... | @@ -7,10 +11,6 @@ use rustc_index::IndexVec; |
| 7 | 11 | use rustc_middle::bug; |
| 8 | 12 | use rustc_middle::mir::{self, BasicBlock, Terminator, TerminatorKind}; |
| 9 | 13 | |
| 10 | use std::cmp::Ordering; | |
| 11 | use std::collections::VecDeque; | |
| 12 | use std::ops::{Index, IndexMut}; | |
| 13 | ||
| 14 | 14 | /// A coverage-specific simplification of the MIR control flow graph (CFG). The `CoverageGraph`s |
| 15 | 15 | /// nodes are `BasicCoverageBlock`s, which encompass one or more MIR `BasicBlock`s. |
| 16 | 16 | #[derive(Debug)] |
compiler/rustc_mir_transform/src/coverage/mod.rs+2-1| ... | ... | @@ -147,7 +147,8 @@ fn create_mappings<'tcx>( |
| 147 | 147 | |
| 148 | 148 | let source_file = source_map.lookup_source_file(body_span.lo()); |
| 149 | 149 | |
| 150 | use rustc_session::{config::RemapPathScopeComponents, RemapFileNameExt}; | |
| 150 | use rustc_session::config::RemapPathScopeComponents; | |
| 151 | use rustc_session::RemapFileNameExt; | |
| 151 | 152 | let file_name = Symbol::intern( |
| 152 | 153 | &source_file.name.for_scope(tcx.sess, RemapPathScopeComponents::MACRO).to_string_lossy(), |
| 153 | 154 | ); |
compiler/rustc_mir_transform/src/coverage/spans.rs+1-2| ... | ... | @@ -6,11 +6,10 @@ use rustc_middle::mir; |
| 6 | 6 | use rustc_span::Span; |
| 7 | 7 | |
| 8 | 8 | use crate::coverage::graph::{BasicCoverageBlock, CoverageGraph}; |
| 9 | use crate::coverage::mappings; | |
| 10 | 9 | use crate::coverage::spans::from_mir::{ |
| 11 | 10 | extract_covspans_from_mir, ExtractedCovspans, Hole, SpanFromMir, |
| 12 | 11 | }; |
| 13 | use crate::coverage::ExtractedHirInfo; | |
| 12 | use crate::coverage::{mappings, ExtractedHirInfo}; | |
| 14 | 13 | |
| 15 | 14 | mod from_mir; |
| 16 | 15 |
compiler/rustc_mir_transform/src/coverage/tests.rs+3-4| ... | ... | @@ -24,16 +24,15 @@ |
| 24 | 24 | //! globals is comparatively simpler. The easiest way is to wrap the test in a closure argument |
| 25 | 25 | //! to: `rustc_span::create_default_session_globals_then(|| { test_here(); })`. |
| 26 | 26 | |
| 27 | use super::graph::{self, BasicCoverageBlock}; | |
| 28 | ||
| 29 | 27 | use itertools::Itertools; |
| 30 | 28 | use rustc_data_structures::graph::{DirectedGraph, Successors}; |
| 31 | 29 | use rustc_index::{Idx, IndexVec}; |
| 32 | use rustc_middle::bug; | |
| 33 | 30 | use rustc_middle::mir::*; |
| 34 | use rustc_middle::ty; | |
| 31 | use rustc_middle::{bug, ty}; | |
| 35 | 32 | use rustc_span::{BytePos, Pos, Span, DUMMY_SP}; |
| 36 | 33 | |
| 34 | use super::graph::{self, BasicCoverageBlock}; | |
| 35 | ||
| 37 | 36 | fn bcb(index: u32) -> BasicCoverageBlock { |
| 38 | 37 | BasicCoverageBlock::from_u32(index) |
| 39 | 38 | } |
compiler/rustc_mir_transform/src/cross_crate_inline.rs+3-4| ... | ... | @@ -1,5 +1,3 @@ |
| 1 | use crate::inline; | |
| 2 | use crate::pass_manager as pm; | |
| 3 | 1 | use rustc_attr::InlineAttr; |
| 4 | 2 | use rustc_hir::def::DefKind; |
| 5 | 3 | use rustc_hir::def_id::LocalDefId; |
| ... | ... | @@ -7,10 +5,11 @@ use rustc_middle::mir::visit::Visitor; |
| 7 | 5 | use rustc_middle::mir::*; |
| 8 | 6 | use rustc_middle::query::Providers; |
| 9 | 7 | use rustc_middle::ty::TyCtxt; |
| 10 | use rustc_session::config::InliningThreshold; | |
| 11 | use rustc_session::config::OptLevel; | |
| 8 | use rustc_session::config::{InliningThreshold, OptLevel}; | |
| 12 | 9 | use rustc_span::sym; |
| 13 | 10 | |
| 11 | use crate::{inline, pass_manager as pm}; | |
| 12 | ||
| 14 | 13 | pub fn provide(providers: &mut Providers) { |
| 15 | 14 | providers.cross_crate_inlinable = cross_crate_inlinable; |
| 16 | 15 | } |
compiler/rustc_mir_transform/src/ctfe_limit.rs+2-2| ... | ... | @@ -1,14 +1,14 @@ |
| 1 | 1 | //! A pass that inserts the `ConstEvalCounter` instruction into any blocks that have a back edge |
| 2 | 2 | //! (thus indicating there is a loop in the CFG), or whose terminator is a function call. |
| 3 | 3 | |
| 4 | use crate::MirPass; | |
| 5 | ||
| 6 | 4 | use rustc_data_structures::graph::dominators::Dominators; |
| 7 | 5 | use rustc_middle::mir::{ |
| 8 | 6 | BasicBlock, BasicBlockData, Body, Statement, StatementKind, TerminatorKind, |
| 9 | 7 | }; |
| 10 | 8 | use rustc_middle::ty::TyCtxt; |
| 11 | 9 | |
| 10 | use crate::MirPass; | |
| 11 | ||
| 12 | 12 | pub struct CtfeLimit; |
| 13 | 13 | |
| 14 | 14 | impl<'tcx> MirPass<'tcx> for CtfeLimit { |
compiler/rustc_mir_transform/src/dataflow_const_prop.rs+2-1| ... | ... | @@ -12,10 +12,11 @@ use rustc_middle::mir::visit::{MutVisitor, PlaceContext, Visitor}; |
| 12 | 12 | use rustc_middle::mir::*; |
| 13 | 13 | use rustc_middle::ty::layout::{HasParamEnv, LayoutOf}; |
| 14 | 14 | use rustc_middle::ty::{self, Ty, TyCtxt}; |
| 15 | use rustc_mir_dataflow::lattice::FlatSet; | |
| 15 | 16 | use rustc_mir_dataflow::value_analysis::{ |
| 16 | 17 | Map, PlaceIndex, State, TrackElem, ValueAnalysis, ValueAnalysisWrapper, ValueOrPlace, |
| 17 | 18 | }; |
| 18 | use rustc_mir_dataflow::{lattice::FlatSet, Analysis, Results, ResultsVisitor}; | |
| 19 | use rustc_mir_dataflow::{Analysis, Results, ResultsVisitor}; | |
| 19 | 20 | use rustc_span::DUMMY_SP; |
| 20 | 21 | use rustc_target::abi::{Abi, FieldIdx, Size, VariantIdx, FIRST_VARIANT}; |
| 21 | 22 |
compiler/rustc_mir_transform/src/dead_store_elimination.rs+2-1| ... | ... | @@ -12,7 +12,6 @@ |
| 12 | 12 | //! will still not cause any further changes. |
| 13 | 13 | //! |
| 14 | 14 | |
| 15 | use crate::util::is_within_packed; | |
| 16 | 15 | use rustc_middle::bug; |
| 17 | 16 | use rustc_middle::mir::visit::Visitor; |
| 18 | 17 | use rustc_middle::mir::*; |
| ... | ... | @@ -23,6 +22,8 @@ use rustc_mir_dataflow::impls::{ |
| 23 | 22 | }; |
| 24 | 23 | use rustc_mir_dataflow::Analysis; |
| 25 | 24 | |
| 25 | use crate::util::is_within_packed; | |
| 26 | ||
| 26 | 27 | /// Performs the optimization on the body |
| 27 | 28 | /// |
| 28 | 29 | /// The `borrowed` set must be a `BitSet` of all the locals that are ever borrowed in this body. It |
compiler/rustc_mir_transform/src/deduplicate_blocks.rs+3-1| ... | ... | @@ -1,7 +1,9 @@ |
| 1 | 1 | //! This pass finds basic blocks that are completely equal, |
| 2 | 2 | //! and replaces all uses with just one of them. |
| 3 | 3 | |
| 4 | use std::{collections::hash_map::Entry, hash::Hash, hash::Hasher, iter}; | |
| 4 | use std::collections::hash_map::Entry; | |
| 5 | use std::hash::{Hash, Hasher}; | |
| 6 | use std::iter; | |
| 5 | 7 | |
| 6 | 8 | use rustc_data_structures::fx::FxHashMap; |
| 7 | 9 | use rustc_middle::mir::visit::MutVisitor; |
compiler/rustc_mir_transform/src/dest_prop.rs+4-5| ... | ... | @@ -131,23 +131,22 @@ |
| 131 | 131 | //! [attempt 2]: https://github.com/rust-lang/rust/pull/71003 |
| 132 | 132 | //! [attempt 3]: https://github.com/rust-lang/rust/pull/72632 |
| 133 | 133 | |
| 134 | use crate::MirPass; | |
| 135 | 134 | use rustc_data_structures::fx::{FxIndexMap, IndexEntry, IndexOccupiedEntry}; |
| 136 | 135 | use rustc_index::bit_set::BitSet; |
| 137 | 136 | use rustc_index::interval::SparseIntervalMatrix; |
| 138 | 137 | use rustc_middle::bug; |
| 139 | 138 | use rustc_middle::mir::visit::{MutVisitor, PlaceContext, Visitor}; |
| 140 | use rustc_middle::mir::HasLocalDecls; | |
| 141 | use rustc_middle::mir::{dump_mir, PassWhere}; | |
| 142 | 139 | use rustc_middle::mir::{ |
| 143 | traversal, Body, InlineAsmOperand, Local, LocalKind, Location, Operand, Place, Rvalue, | |
| 144 | Statement, StatementKind, TerminatorKind, | |
| 140 | dump_mir, traversal, Body, HasLocalDecls, InlineAsmOperand, Local, LocalKind, Location, | |
| 141 | Operand, PassWhere, Place, Rvalue, Statement, StatementKind, TerminatorKind, | |
| 145 | 142 | }; |
| 146 | 143 | use rustc_middle::ty::TyCtxt; |
| 147 | 144 | use rustc_mir_dataflow::impls::MaybeLiveLocals; |
| 148 | 145 | use rustc_mir_dataflow::points::{save_as_intervals, DenseLocationMap, PointIndex}; |
| 149 | 146 | use rustc_mir_dataflow::Analysis; |
| 150 | 147 | |
| 148 | use crate::MirPass; | |
| 149 | ||
| 151 | 150 | pub struct DestinationPropagation; |
| 152 | 151 | |
| 153 | 152 | impl<'tcx> MirPass<'tcx> for DestinationPropagation { |
compiler/rustc_mir_transform/src/dump_mir.rs+3-3| ... | ... | @@ -3,12 +3,12 @@ |
| 3 | 3 | use std::fs::File; |
| 4 | 4 | use std::io; |
| 5 | 5 | |
| 6 | use crate::MirPass; | |
| 7 | use rustc_middle::mir::write_mir_pretty; | |
| 8 | use rustc_middle::mir::Body; | |
| 6 | use rustc_middle::mir::{write_mir_pretty, Body}; | |
| 9 | 7 | use rustc_middle::ty::TyCtxt; |
| 10 | 8 | use rustc_session::config::{OutFileName, OutputType}; |
| 11 | 9 | |
| 10 | use crate::MirPass; | |
| 11 | ||
| 12 | 12 | pub struct Marker(pub &'static str); |
| 13 | 13 | |
| 14 | 14 | impl<'tcx> MirPass<'tcx> for Marker { |
compiler/rustc_mir_transform/src/early_otherwise_branch.rs+2-1| ... | ... | @@ -1,7 +1,8 @@ |
| 1 | use std::fmt::Debug; | |
| 2 | ||
| 1 | 3 | use rustc_middle::mir::patch::MirPatch; |
| 2 | 4 | use rustc_middle::mir::*; |
| 3 | 5 | use rustc_middle::ty::{Ty, TyCtxt}; |
| 4 | use std::fmt::Debug; | |
| 5 | 6 | |
| 6 | 7 | use super::simplify::simplify_cfg; |
| 7 | 8 |
compiler/rustc_mir_transform/src/elaborate_drops.rs+10-8| ... | ... | @@ -1,20 +1,22 @@ |
| 1 | use crate::deref_separator::deref_finder; | |
| 1 | use std::fmt; | |
| 2 | ||
| 2 | 3 | use rustc_index::bit_set::BitSet; |
| 3 | 4 | use rustc_index::IndexVec; |
| 4 | 5 | use rustc_middle::mir::patch::MirPatch; |
| 5 | 6 | use rustc_middle::mir::*; |
| 6 | 7 | use rustc_middle::ty::{self, TyCtxt}; |
| 7 | use rustc_mir_dataflow::elaborate_drops::{elaborate_drop, DropFlagState, Unwind}; | |
| 8 | use rustc_mir_dataflow::elaborate_drops::{DropElaborator, DropFlagMode, DropStyle}; | |
| 8 | use rustc_mir_dataflow::elaborate_drops::{ | |
| 9 | elaborate_drop, DropElaborator, DropFlagMode, DropFlagState, DropStyle, Unwind, | |
| 10 | }; | |
| 9 | 11 | use rustc_mir_dataflow::impls::{MaybeInitializedPlaces, MaybeUninitializedPlaces}; |
| 10 | 12 | use rustc_mir_dataflow::move_paths::{LookupResult, MoveData, MovePathIndex}; |
| 11 | use rustc_mir_dataflow::on_all_children_bits; | |
| 12 | use rustc_mir_dataflow::on_lookup_result_bits; | |
| 13 | use rustc_mir_dataflow::MoveDataParamEnv; | |
| 14 | use rustc_mir_dataflow::{Analysis, ResultsCursor}; | |
| 13 | use rustc_mir_dataflow::{ | |
| 14 | on_all_children_bits, on_lookup_result_bits, Analysis, MoveDataParamEnv, ResultsCursor, | |
| 15 | }; | |
| 15 | 16 | use rustc_span::Span; |
| 16 | 17 | use rustc_target::abi::{FieldIdx, VariantIdx}; |
| 17 | use std::fmt; | |
| 18 | ||
| 19 | use crate::deref_separator::deref_finder; | |
| 18 | 20 | |
| 19 | 21 | /// During MIR building, Drop terminators are inserted in every place where a drop may occur. |
| 20 | 22 | /// However, in this phase, the presence of these terminators does not guarantee that a destructor will run, |
compiler/rustc_mir_transform/src/errors.rs+2-1| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | use rustc_errors::{codes::*, Diag, LintDiagnostic}; | |
| 1 | use rustc_errors::codes::*; | |
| 2 | use rustc_errors::{Diag, LintDiagnostic}; | |
| 2 | 3 | use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic}; |
| 3 | 4 | use rustc_middle::mir::AssertKind; |
| 4 | 5 | use rustc_middle::ty::TyCtxt; |
compiler/rustc_mir_transform/src/ffi_unwind_calls.rs+2-4| ... | ... | @@ -1,9 +1,7 @@ |
| 1 | 1 | use rustc_hir::def_id::{LocalDefId, LOCAL_CRATE}; |
| 2 | 2 | use rustc_middle::mir::*; |
| 3 | use rustc_middle::query::LocalCrate; | |
| 4 | use rustc_middle::query::Providers; | |
| 5 | use rustc_middle::ty::layout; | |
| 6 | use rustc_middle::ty::{self, TyCtxt}; | |
| 3 | use rustc_middle::query::{LocalCrate, Providers}; | |
| 4 | use rustc_middle::ty::{self, layout, TyCtxt}; | |
| 7 | 5 | use rustc_middle::{bug, span_bug}; |
| 8 | 6 | use rustc_session::lint::builtin::FFI_UNWIND_CALLS; |
| 9 | 7 | use rustc_target::spec::abi::Abi; |
compiler/rustc_mir_transform/src/function_item_references.rs+2-1| ... | ... | @@ -5,7 +5,8 @@ use rustc_middle::mir::*; |
| 5 | 5 | use rustc_middle::ty::{self, EarlyBinder, GenericArgsRef, Ty, TyCtxt}; |
| 6 | 6 | use rustc_session::lint::builtin::FUNCTION_ITEM_REFERENCES; |
| 7 | 7 | use rustc_span::source_map::Spanned; |
| 8 | use rustc_span::{symbol::sym, Span}; | |
| 8 | use rustc_span::symbol::sym; | |
| 9 | use rustc_span::Span; | |
| 9 | 10 | use rustc_target::spec::abi::Abi; |
| 10 | 11 | |
| 11 | 12 | use crate::{errors, MirLint}; |
compiler/rustc_mir_transform/src/gvn.rs+8-6| ... | ... | @@ -82,15 +82,19 @@ |
| 82 | 82 | //! Second, when writing constants in MIR, we do not write `Const::Slice` or `Const` |
| 83 | 83 | //! that contain `AllocId`s. |
| 84 | 84 | |
| 85 | use std::borrow::Cow; | |
| 86 | ||
| 87 | use either::Either; | |
| 85 | 88 | use rustc_const_eval::const_eval::DummyMachine; |
| 86 | use rustc_const_eval::interpret::{intern_const_alloc_for_constprop, MemPlaceMeta, MemoryKind}; | |
| 87 | use rustc_const_eval::interpret::{ImmTy, Immediate, InterpCx, OpTy, Projectable, Scalar}; | |
| 89 | use rustc_const_eval::interpret::{ | |
| 90 | intern_const_alloc_for_constprop, ImmTy, Immediate, InterpCx, MemPlaceMeta, MemoryKind, OpTy, | |
| 91 | Projectable, Scalar, | |
| 92 | }; | |
| 88 | 93 | use rustc_data_structures::fx::FxIndexSet; |
| 89 | 94 | use rustc_data_structures::graph::dominators::Dominators; |
| 90 | 95 | use rustc_hir::def::DefKind; |
| 91 | 96 | use rustc_index::bit_set::BitSet; |
| 92 | use rustc_index::newtype_index; | |
| 93 | use rustc_index::IndexVec; | |
| 97 | use rustc_index::{newtype_index, IndexVec}; | |
| 94 | 98 | use rustc_middle::bug; |
| 95 | 99 | use rustc_middle::mir::interpret::GlobalAlloc; |
| 96 | 100 | use rustc_middle::mir::visit::*; |
| ... | ... | @@ -101,10 +105,8 @@ use rustc_span::def_id::DefId; |
| 101 | 105 | use rustc_span::DUMMY_SP; |
| 102 | 106 | use rustc_target::abi::{self, Abi, FieldIdx, Size, VariantIdx, FIRST_VARIANT}; |
| 103 | 107 | use smallvec::SmallVec; |
| 104 | use std::borrow::Cow; | |
| 105 | 108 | |
| 106 | 109 | use crate::ssa::{AssignedValue, SsaLocals}; |
| 107 | use either::Either; | |
| 108 | 110 | |
| 109 | 111 | pub struct GVN; |
| 110 | 112 |
compiler/rustc_mir_transform/src/inline.rs+7-5| ... | ... | @@ -1,6 +1,8 @@ |
| 1 | 1 | //! Inlining pass for MIR functions. |
| 2 | 2 | |
| 3 | use crate::deref_separator::deref_finder; | |
| 3 | use std::iter; | |
| 4 | use std::ops::{Range, RangeFrom}; | |
| 5 | ||
| 4 | 6 | use rustc_attr::InlineAttr; |
| 5 | 7 | use rustc_hir::def::DefKind; |
| 6 | 8 | use rustc_hir::def_id::DefId; |
| ... | ... | @@ -10,8 +12,9 @@ use rustc_middle::bug; |
| 10 | 12 | use rustc_middle::middle::codegen_fn_attrs::{CodegenFnAttrFlags, CodegenFnAttrs}; |
| 11 | 13 | use rustc_middle::mir::visit::*; |
| 12 | 14 | use rustc_middle::mir::*; |
| 13 | use rustc_middle::ty::TypeVisitableExt; | |
| 14 | use rustc_middle::ty::{self, Instance, InstanceKind, ParamEnv, Ty, TyCtxt, TypeFlags}; | |
| 15 | use rustc_middle::ty::{ | |
| 16 | self, Instance, InstanceKind, ParamEnv, Ty, TyCtxt, TypeFlags, TypeVisitableExt, | |
| 17 | }; | |
| 15 | 18 | use rustc_session::config::{DebugInfo, OptLevel}; |
| 16 | 19 | use rustc_span::source_map::Spanned; |
| 17 | 20 | use rustc_span::sym; |
| ... | ... | @@ -19,11 +22,10 @@ use rustc_target::abi::FieldIdx; |
| 19 | 22 | use rustc_target::spec::abi::Abi; |
| 20 | 23 | |
| 21 | 24 | use crate::cost_checker::CostChecker; |
| 25 | use crate::deref_separator::deref_finder; | |
| 22 | 26 | use crate::simplify::simplify_cfg; |
| 23 | 27 | use crate::util; |
| 24 | 28 | use crate::validate::validate_types; |
| 25 | use std::iter; | |
| 26 | use std::ops::{Range, RangeFrom}; | |
| 27 | 29 | |
| 28 | 30 | pub(crate) mod cycle; |
| 29 | 31 |
compiler/rustc_mir_transform/src/inline/cycle.rs+1-2| ... | ... | @@ -2,8 +2,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexSet}; |
| 2 | 2 | use rustc_data_structures::stack::ensure_sufficient_stack; |
| 3 | 3 | use rustc_hir::def_id::{DefId, LocalDefId}; |
| 4 | 4 | use rustc_middle::mir::TerminatorKind; |
| 5 | use rustc_middle::ty::TypeVisitableExt; | |
| 6 | use rustc_middle::ty::{self, GenericArgsRef, InstanceKind, TyCtxt}; | |
| 5 | use rustc_middle::ty::{self, GenericArgsRef, InstanceKind, TyCtxt, TypeVisitableExt}; | |
| 7 | 6 | use rustc_session::Limit; |
| 8 | 7 | use rustc_span::sym; |
| 9 | 8 |
compiler/rustc_mir_transform/src/instsimplify.rs+4-4| ... | ... | @@ -1,18 +1,18 @@ |
| 1 | 1 | //! Performs various peephole optimizations. |
| 2 | 2 | |
| 3 | use crate::simplify::simplify_duplicate_switch_targets; | |
| 4 | use crate::take_array; | |
| 5 | 3 | use rustc_ast::attr; |
| 6 | 4 | use rustc_hir::LangItem; |
| 7 | 5 | use rustc_middle::bug; |
| 8 | 6 | use rustc_middle::mir::*; |
| 9 | use rustc_middle::ty::layout; | |
| 10 | 7 | use rustc_middle::ty::layout::ValidityRequirement; |
| 11 | use rustc_middle::ty::{self, GenericArgsRef, ParamEnv, Ty, TyCtxt}; | |
| 8 | use rustc_middle::ty::{self, layout, GenericArgsRef, ParamEnv, Ty, TyCtxt}; | |
| 12 | 9 | use rustc_span::sym; |
| 13 | 10 | use rustc_span::symbol::Symbol; |
| 14 | 11 | use rustc_target::spec::abi::Abi; |
| 15 | 12 | |
| 13 | use crate::simplify::simplify_duplicate_switch_targets; | |
| 14 | use crate::take_array; | |
| 15 | ||
| 16 | 16 | pub struct InstSimplify; |
| 17 | 17 | |
| 18 | 18 | impl<'tcx> MirPass<'tcx> for InstSimplify { |
compiler/rustc_mir_transform/src/known_panics_lint.rs+2-1| ... | ... | @@ -13,7 +13,8 @@ use rustc_const_eval::interpret::{ |
| 13 | 13 | use rustc_data_structures::fx::FxHashSet; |
| 14 | 14 | use rustc_hir::def::DefKind; |
| 15 | 15 | use rustc_hir::HirId; |
| 16 | use rustc_index::{bit_set::BitSet, IndexVec}; | |
| 16 | use rustc_index::bit_set::BitSet; | |
| 17 | use rustc_index::IndexVec; | |
| 17 | 18 | use rustc_middle::bug; |
| 18 | 19 | use rustc_middle::mir::visit::{MutatingUseContext, NonMutatingUseContext, PlaceContext, Visitor}; |
| 19 | 20 | use rustc_middle::mir::*; |
compiler/rustc_mir_transform/src/lib.rs+3-3| ... | ... | @@ -34,11 +34,11 @@ use rustc_middle::mir::{ |
| 34 | 34 | LocalDecl, MirPass, MirPhase, Operand, Place, ProjectionElem, Promoted, RuntimePhase, Rvalue, |
| 35 | 35 | SourceInfo, Statement, StatementKind, TerminatorKind, START_BLOCK, |
| 36 | 36 | }; |
| 37 | use rustc_middle::query; | |
| 38 | 37 | use rustc_middle::ty::{self, TyCtxt, TypeVisitableExt}; |
| 39 | 38 | use rustc_middle::util::Providers; |
| 40 | use rustc_middle::{bug, span_bug}; | |
| 41 | use rustc_span::{source_map::Spanned, sym, DUMMY_SP}; | |
| 39 | use rustc_middle::{bug, query, span_bug}; | |
| 40 | use rustc_span::source_map::Spanned; | |
| 41 | use rustc_span::{sym, DUMMY_SP}; | |
| 42 | 42 | use rustc_trait_selection::traits; |
| 43 | 43 | |
| 44 | 44 | #[macro_use] |
compiler/rustc_mir_transform/src/lint.rs+2-1| ... | ... | @@ -2,6 +2,8 @@ |
| 2 | 2 | //! It can be used to locate problems in MIR building or optimizations. It assumes that all code |
| 3 | 3 | //! can be executed, so it has false positives. |
| 4 | 4 | |
| 5 | use std::borrow::Cow; | |
| 6 | ||
| 5 | 7 | use rustc_data_structures::fx::FxHashSet; |
| 6 | 8 | use rustc_index::bit_set::BitSet; |
| 7 | 9 | use rustc_middle::mir::visit::{PlaceContext, Visitor}; |
| ... | ... | @@ -10,7 +12,6 @@ use rustc_middle::ty::TyCtxt; |
| 10 | 12 | use rustc_mir_dataflow::impls::{MaybeStorageDead, MaybeStorageLive}; |
| 11 | 13 | use rustc_mir_dataflow::storage::always_storage_live_locals; |
| 12 | 14 | use rustc_mir_dataflow::{Analysis, ResultsCursor}; |
| 13 | use std::borrow::Cow; | |
| 14 | 15 | |
| 15 | 16 | pub fn lint_body<'tcx>(tcx: TyCtxt<'tcx>, body: &Body<'tcx>, when: String) { |
| 16 | 17 | let always_live_locals = &always_storage_live_locals(body); |
compiler/rustc_mir_transform/src/lower_intrinsics.rs+2-1| ... | ... | @@ -1,11 +1,12 @@ |
| 1 | 1 | //! Lowers intrinsic calls |
| 2 | 2 | |
| 3 | use crate::take_array; | |
| 4 | 3 | use rustc_middle::mir::*; |
| 5 | 4 | use rustc_middle::ty::{self, TyCtxt}; |
| 6 | 5 | use rustc_middle::{bug, span_bug}; |
| 7 | 6 | use rustc_span::symbol::sym; |
| 8 | 7 | |
| 8 | use crate::take_array; | |
| 9 | ||
| 9 | 10 | pub struct LowerIntrinsics; |
| 10 | 11 | |
| 11 | 12 | impl<'tcx> MirPass<'tcx> for LowerIntrinsics { |
compiler/rustc_mir_transform/src/match_branches.rs+2-1| ... | ... | @@ -1,9 +1,10 @@ |
| 1 | use std::iter; | |
| 2 | ||
| 1 | 3 | use rustc_index::IndexSlice; |
| 2 | 4 | use rustc_middle::mir::patch::MirPatch; |
| 3 | 5 | use rustc_middle::mir::*; |
| 4 | 6 | use rustc_middle::ty::{ParamEnv, ScalarInt, Ty, TyCtxt}; |
| 5 | 7 | use rustc_target::abi::Size; |
| 6 | use std::iter; | |
| 7 | 8 | |
| 8 | 9 | use super::simplify::simplify_cfg; |
| 9 | 10 |
compiler/rustc_mir_transform/src/mentioned_items.rs+2-1| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | 1 | use rustc_middle::mir::visit::Visitor; |
| 2 | 2 | use rustc_middle::mir::{self, Location, MentionedItem, MirPass}; |
| 3 | use rustc_middle::ty::{self, adjustment::PointerCoercion, TyCtxt}; | |
| 3 | use rustc_middle::ty::adjustment::PointerCoercion; | |
| 4 | use rustc_middle::ty::{self, TyCtxt}; | |
| 4 | 5 | use rustc_session::Session; |
| 5 | 6 | use rustc_span::source_map::Spanned; |
| 6 | 7 |
compiler/rustc_mir_transform/src/multiple_return_terminators.rs+2-1| ... | ... | @@ -1,11 +1,12 @@ |
| 1 | 1 | //! This pass removes jumps to basic blocks containing only a return, and replaces them with a |
| 2 | 2 | //! return instead. |
| 3 | 3 | |
| 4 | use crate::simplify; | |
| 5 | 4 | use rustc_index::bit_set::BitSet; |
| 6 | 5 | use rustc_middle::mir::*; |
| 7 | 6 | use rustc_middle::ty::TyCtxt; |
| 8 | 7 | |
| 8 | use crate::simplify; | |
| 9 | ||
| 9 | 10 | pub struct MultipleReturnTerminators; |
| 10 | 11 | |
| 11 | 12 | impl<'tcx> MirPass<'tcx> for MultipleReturnTerminators { |
compiler/rustc_mir_transform/src/pass_manager.rs+2-1| ... | ... | @@ -2,7 +2,8 @@ use rustc_middle::mir::{self, Body, MirPhase, RuntimePhase}; |
| 2 | 2 | use rustc_middle::ty::TyCtxt; |
| 3 | 3 | use rustc_session::Session; |
| 4 | 4 | |
| 5 | use crate::{lint::lint_body, validate, MirPass}; | |
| 5 | use crate::lint::lint_body; | |
| 6 | use crate::{validate, MirPass}; | |
| 6 | 7 | |
| 7 | 8 | /// Just like `MirPass`, except it cannot mutate `Body`. |
| 8 | 9 | pub trait MirLint<'tcx> { |
compiler/rustc_mir_transform/src/prettify.rs+2-1| ... | ... | @@ -4,7 +4,8 @@ |
| 4 | 4 | //! (`-Zmir-enable-passes=+ReorderBasicBlocks,+ReorderLocals`) |
| 5 | 5 | //! to make the MIR easier to read for humans. |
| 6 | 6 | |
| 7 | use rustc_index::{bit_set::BitSet, IndexSlice, IndexVec}; | |
| 7 | use rustc_index::bit_set::BitSet; | |
| 8 | use rustc_index::{IndexSlice, IndexVec}; | |
| 8 | 9 | use rustc_middle::mir::visit::{MutVisitor, PlaceContext, Visitor}; |
| 9 | 10 | use rustc_middle::mir::*; |
| 10 | 11 | use rustc_middle::ty::TyCtxt; |
compiler/rustc_mir_transform/src/promote_consts.rs+9-13| ... | ... | @@ -12,25 +12,21 @@ |
| 12 | 12 | //! initialization and can otherwise silence errors, if |
| 13 | 13 | //! move analysis runs after promotion on broken MIR. |
| 14 | 14 | |
| 15 | use std::assert_matches::assert_matches; | |
| 16 | use std::cell::Cell; | |
| 17 | use std::{cmp, iter, mem}; | |
| 18 | ||
| 15 | 19 | use either::{Left, Right}; |
| 20 | use rustc_const_eval::check_consts::{qualifs, ConstCx}; | |
| 16 | 21 | use rustc_data_structures::fx::FxHashSet; |
| 17 | 22 | use rustc_hir as hir; |
| 18 | use rustc_middle::mir; | |
| 23 | use rustc_index::{Idx, IndexSlice, IndexVec}; | |
| 19 | 24 | use rustc_middle::mir::visit::{MutVisitor, MutatingUseContext, PlaceContext, Visitor}; |
| 20 | 25 | use rustc_middle::mir::*; |
| 21 | use rustc_middle::ty::GenericArgs; | |
| 22 | use rustc_middle::ty::{self, List, Ty, TyCtxt, TypeVisitableExt}; | |
| 23 | use rustc_middle::{bug, span_bug}; | |
| 24 | use rustc_span::Span; | |
| 25 | ||
| 26 | use rustc_index::{Idx, IndexSlice, IndexVec}; | |
| 26 | use rustc_middle::ty::{self, GenericArgs, List, Ty, TyCtxt, TypeVisitableExt}; | |
| 27 | use rustc_middle::{bug, mir, span_bug}; | |
| 27 | 28 | use rustc_span::source_map::Spanned; |
| 28 | ||
| 29 | use std::assert_matches::assert_matches; | |
| 30 | use std::cell::Cell; | |
| 31 | use std::{cmp, iter, mem}; | |
| 32 | ||
| 33 | use rustc_const_eval::check_consts::{qualifs, ConstCx}; | |
| 29 | use rustc_span::Span; | |
| 34 | 30 | |
| 35 | 31 | /// A `MirPass` for promotion. |
| 36 | 32 | /// |
compiler/rustc_mir_transform/src/ref_prop.rs+2-1| ... | ... | @@ -1,3 +1,5 @@ |
| 1 | use std::borrow::Cow; | |
| 2 | ||
| 1 | 3 | use rustc_data_structures::fx::FxHashSet; |
| 2 | 4 | use rustc_index::bit_set::BitSet; |
| 3 | 5 | use rustc_index::IndexVec; |
| ... | ... | @@ -8,7 +10,6 @@ use rustc_middle::ty::TyCtxt; |
| 8 | 10 | use rustc_mir_dataflow::impls::MaybeStorageDead; |
| 9 | 11 | use rustc_mir_dataflow::storage::always_storage_live_locals; |
| 10 | 12 | use rustc_mir_dataflow::Analysis; |
| 11 | use std::borrow::Cow; | |
| 12 | 13 | |
| 13 | 14 | use crate::ssa::{SsaLocals, StorageLiveLocals}; |
| 14 | 15 |
compiler/rustc_mir_transform/src/remove_uninit_drops.rs+1-2| ... | ... | @@ -1,7 +1,6 @@ |
| 1 | 1 | use rustc_index::bit_set::ChunkedBitSet; |
| 2 | 2 | use rustc_middle::mir::{Body, TerminatorKind}; |
| 3 | use rustc_middle::ty::GenericArgsRef; | |
| 4 | use rustc_middle::ty::{self, ParamEnv, Ty, TyCtxt, VariantDef}; | |
| 3 | use rustc_middle::ty::{self, GenericArgsRef, ParamEnv, Ty, TyCtxt, VariantDef}; | |
| 5 | 4 | use rustc_mir_dataflow::impls::MaybeInitializedPlaces; |
| 6 | 5 | use rustc_mir_dataflow::move_paths::{LookupResult, MoveData, MovePathIndex}; |
| 7 | 6 | use rustc_mir_dataflow::{move_path_children_matching, Analysis, MaybeReachable, MoveDataParamEnv}; |
compiler/rustc_mir_transform/src/shim.rs+10-9| ... | ... | @@ -1,26 +1,27 @@ |
| 1 | use std::assert_matches::assert_matches; | |
| 2 | use std::{fmt, iter}; | |
| 3 | ||
| 1 | 4 | use rustc_hir as hir; |
| 2 | 5 | use rustc_hir::def_id::DefId; |
| 3 | 6 | use rustc_hir::lang_items::LangItem; |
| 4 | 7 | use rustc_index::{Idx, IndexVec}; |
| 8 | use rustc_middle::mir::patch::MirPatch; | |
| 5 | 9 | use rustc_middle::mir::*; |
| 6 | 10 | use rustc_middle::query::Providers; |
| 7 | use rustc_middle::ty::GenericArgs; | |
| 8 | use rustc_middle::ty::{self, CoroutineArgs, CoroutineArgsExt, EarlyBinder, Ty, TyCtxt}; | |
| 11 | use rustc_middle::ty::{ | |
| 12 | self, CoroutineArgs, CoroutineArgsExt, EarlyBinder, GenericArgs, Ty, TyCtxt, | |
| 13 | }; | |
| 9 | 14 | use rustc_middle::{bug, span_bug}; |
| 10 | use rustc_span::{source_map::Spanned, Span, DUMMY_SP}; | |
| 15 | use rustc_mir_dataflow::elaborate_drops::{self, DropElaborator, DropFlagMode, DropStyle}; | |
| 16 | use rustc_span::source_map::Spanned; | |
| 17 | use rustc_span::{Span, DUMMY_SP}; | |
| 11 | 18 | use rustc_target::abi::{FieldIdx, VariantIdx, FIRST_VARIANT}; |
| 12 | 19 | use rustc_target::spec::abi::Abi; |
| 13 | 20 | |
| 14 | use std::assert_matches::assert_matches; | |
| 15 | use std::fmt; | |
| 16 | use std::iter; | |
| 17 | ||
| 18 | 21 | use crate::{ |
| 19 | 22 | abort_unwinding_calls, add_call_guards, add_moves_for_packed_drops, deref_separator, |
| 20 | 23 | instsimplify, mentioned_items, pass_manager as pm, remove_noop_landing_pads, simplify, |
| 21 | 24 | }; |
| 22 | use rustc_middle::mir::patch::MirPatch; | |
| 23 | use rustc_mir_dataflow::elaborate_drops::{self, DropElaborator, DropFlagMode, DropStyle}; | |
| 24 | 25 | |
| 25 | 26 | mod async_destructor_ctor; |
| 26 | 27 |
compiler/rustc_mir_transform/src/simplify_comparison_integral.rs+8-8| ... | ... | @@ -1,14 +1,14 @@ |
| 1 | 1 | use std::iter; |
| 2 | 2 | |
| 3 | use super::MirPass; | |
| 4 | use rustc_middle::{ | |
| 5 | bug, | |
| 6 | mir::{ | |
| 7 | interpret::Scalar, BasicBlock, BinOp, Body, Operand, Place, Rvalue, Statement, | |
| 8 | StatementKind, SwitchTargets, TerminatorKind, | |
| 9 | }, | |
| 10 | ty::{Ty, TyCtxt}, | |
| 3 | use rustc_middle::bug; | |
| 4 | use rustc_middle::mir::interpret::Scalar; | |
| 5 | use rustc_middle::mir::{ | |
| 6 | BasicBlock, BinOp, Body, Operand, Place, Rvalue, Statement, StatementKind, SwitchTargets, | |
| 7 | TerminatorKind, | |
| 11 | 8 | }; |
| 9 | use rustc_middle::ty::{Ty, TyCtxt}; | |
| 10 | ||
| 11 | use super::MirPass; | |
| 12 | 12 | |
| 13 | 13 | /// Pass to convert `if` conditions on integrals into switches on the integral. |
| 14 | 14 | /// For an example, it turns something like |
compiler/rustc_mir_transform/src/single_use_consts.rs+2-1| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | use rustc_index::{bit_set::BitSet, IndexVec}; | |
| 1 | use rustc_index::bit_set::BitSet; | |
| 2 | use rustc_index::IndexVec; | |
| 2 | 3 | use rustc_middle::bug; |
| 3 | 4 | use rustc_middle::mir::visit::{MutVisitor, PlaceContext, Visitor}; |
| 4 | 5 | use rustc_middle::mir::*; |
compiler/rustc_mir_transform/src/unreachable_enum_branching.rs+2-1| ... | ... | @@ -1,6 +1,5 @@ |
| 1 | 1 | //! A pass that eliminates branches on uninhabited or unreachable enum variants. |
| 2 | 2 | |
| 3 | use crate::MirPass; | |
| 4 | 3 | use rustc_data_structures::fx::FxHashSet; |
| 5 | 4 | use rustc_middle::bug; |
| 6 | 5 | use rustc_middle::mir::patch::MirPatch; |
| ... | ... | @@ -12,6 +11,8 @@ use rustc_middle::ty::layout::TyAndLayout; |
| 12 | 11 | use rustc_middle::ty::{Ty, TyCtxt}; |
| 13 | 12 | use rustc_target::abi::{Abi, Variants}; |
| 14 | 13 | |
| 14 | use crate::MirPass; | |
| 15 | ||
| 15 | 16 | pub struct UnreachableEnumBranching; |
| 16 | 17 | |
| 17 | 18 | fn get_discriminant_local(terminator: &TerminatorKind<'_>) -> Option<Local> { |
compiler/rustc_mir_transform/src/validate.rs+1-3| ... | ... | @@ -17,9 +17,7 @@ use rustc_middle::{bug, span_bug}; |
| 17 | 17 | use rustc_target::abi::{Size, FIRST_VARIANT}; |
| 18 | 18 | use rustc_target::spec::abi::Abi; |
| 19 | 19 | |
| 20 | use crate::util::is_within_packed; | |
| 21 | ||
| 22 | use crate::util::relate_types; | |
| 20 | use crate::util::{is_within_packed, relate_types}; | |
| 23 | 21 | |
| 24 | 22 | #[derive(Copy, Clone, Debug, PartialEq, Eq)] |
| 25 | 23 | enum EdgeKind { |
compiler/rustc_monomorphize/src/collector.rs+6-7| ... | ... | @@ -207,6 +207,9 @@ |
| 207 | 207 | |
| 208 | 208 | mod move_check; |
| 209 | 209 | |
| 210 | use std::path::PathBuf; | |
| 211 | ||
| 212 | use move_check::MoveCheckState; | |
| 210 | 213 | use rustc_data_structures::sync::{par_for_each_in, LRef, MTLock}; |
| 211 | 214 | use rustc_data_structures::unord::{UnordMap, UnordSet}; |
| 212 | 215 | use rustc_hir as hir; |
| ... | ... | @@ -216,17 +219,15 @@ use rustc_hir::lang_items::LangItem; |
| 216 | 219 | use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags; |
| 217 | 220 | use rustc_middle::mir::interpret::{AllocId, ErrorHandled, GlobalAlloc, Scalar}; |
| 218 | 221 | use rustc_middle::mir::mono::{InstantiationMode, MonoItem}; |
| 219 | use rustc_middle::mir::traversal; | |
| 220 | 222 | use rustc_middle::mir::visit::Visitor as MirVisitor; |
| 221 | use rustc_middle::mir::{self, Location, MentionedItem}; | |
| 223 | use rustc_middle::mir::{self, traversal, Location, MentionedItem}; | |
| 222 | 224 | use rustc_middle::query::TyCtxtAt; |
| 223 | 225 | use rustc_middle::ty::adjustment::{CustomCoerceUnsized, PointerCoercion}; |
| 224 | 226 | use rustc_middle::ty::layout::ValidityRequirement; |
| 225 | 227 | use rustc_middle::ty::print::{shrunk_instance_name, with_no_trimmed_paths}; |
| 226 | use rustc_middle::ty::GenericArgs; | |
| 227 | 228 | use rustc_middle::ty::{ |
| 228 | self, AssocKind, GenericParamDefKind, Instance, InstanceKind, Ty, TyCtxt, TypeFoldable, | |
| 229 | TypeVisitableExt, VtblEntry, | |
| 229 | self, AssocKind, GenericArgs, GenericParamDefKind, Instance, InstanceKind, Ty, TyCtxt, | |
| 230 | TypeFoldable, TypeVisitableExt, VtblEntry, | |
| 230 | 231 | }; |
| 231 | 232 | use rustc_middle::util::Providers; |
| 232 | 233 | use rustc_middle::{bug, span_bug}; |
| ... | ... | @@ -236,11 +237,9 @@ use rustc_span::source_map::{dummy_spanned, respan, Spanned}; |
| 236 | 237 | use rustc_span::symbol::{sym, Ident}; |
| 237 | 238 | use rustc_span::{Span, DUMMY_SP}; |
| 238 | 239 | use rustc_target::abi::Size; |
| 239 | use std::path::PathBuf; | |
| 240 | 240 | use tracing::{debug, instrument, trace}; |
| 241 | 241 | |
| 242 | 242 | use crate::errors::{self, EncounteredErrorWhileInstantiating, NoOptimizedMir, RecursionLimit}; |
| 243 | use move_check::MoveCheckState; | |
| 244 | 243 | |
| 245 | 244 | #[derive(PartialEq)] |
| 246 | 245 | pub enum MonoItemCollectionStrategy { |
compiler/rustc_monomorphize/src/errors.rs+2-1| ... | ... | @@ -1,10 +1,11 @@ |
| 1 | 1 | use std::path::PathBuf; |
| 2 | 2 | |
| 3 | use crate::fluent_generated as fluent; | |
| 4 | 3 | use rustc_errors::{Diag, DiagCtxtHandle, Diagnostic, EmissionGuarantee, Level}; |
| 5 | 4 | use rustc_macros::{Diagnostic, LintDiagnostic}; |
| 6 | 5 | use rustc_span::{Span, Symbol}; |
| 7 | 6 | |
| 7 | use crate::fluent_generated as fluent; | |
| 8 | ||
| 8 | 9 | #[derive(Diagnostic)] |
| 9 | 10 | #[diag(monomorphize_recursion_limit)] |
| 10 | 11 | pub struct RecursionLimit { |
compiler/rustc_monomorphize/src/lib.rs+1-2| ... | ... | @@ -3,12 +3,11 @@ |
| 3 | 3 | // tidy-alphabetical-end |
| 4 | 4 | |
| 5 | 5 | use rustc_hir::lang_items::LangItem; |
| 6 | use rustc_middle::bug; | |
| 7 | 6 | use rustc_middle::query::TyCtxtAt; |
| 8 | use rustc_middle::traits; | |
| 9 | 7 | use rustc_middle::ty::adjustment::CustomCoerceUnsized; |
| 10 | 8 | use rustc_middle::ty::{self, Ty}; |
| 11 | 9 | use rustc_middle::util::Providers; |
| 10 | use rustc_middle::{bug, traits}; | |
| 12 | 11 | use rustc_span::ErrorGuaranteed; |
| 13 | 12 | |
| 14 | 13 | mod collector; |
compiler/rustc_monomorphize/src/partitioning.rs+3-3| ... | ... | @@ -113,15 +113,15 @@ use rustc_middle::mir::mono::{ |
| 113 | 113 | Visibility, |
| 114 | 114 | }; |
| 115 | 115 | use rustc_middle::ty::print::{characteristic_def_id_of_type, with_no_trimmed_paths}; |
| 116 | use rustc_middle::ty::{self, visit::TypeVisitableExt, InstanceKind, TyCtxt}; | |
| 116 | use rustc_middle::ty::visit::TypeVisitableExt; | |
| 117 | use rustc_middle::ty::{self, InstanceKind, TyCtxt}; | |
| 117 | 118 | use rustc_middle::util::Providers; |
| 118 | 119 | use rustc_session::config::{DumpMonoStatsFormat, SwitchWithOptPath}; |
| 119 | 120 | use rustc_session::CodegenUnits; |
| 120 | 121 | use rustc_span::symbol::Symbol; |
| 121 | 122 | use tracing::debug; |
| 122 | 123 | |
| 123 | use crate::collector::UsageMap; | |
| 124 | use crate::collector::{self, MonoItemCollectionStrategy}; | |
| 124 | use crate::collector::{self, MonoItemCollectionStrategy, UsageMap}; | |
| 125 | 125 | use crate::errors::{CouldntDumpMonoStats, SymbolAlreadyDefined, UnknownCguCollectionMode}; |
| 126 | 126 | |
| 127 | 127 | struct PartitioningCx<'a, 'tcx> { |
compiler/rustc_monomorphize/src/polymorphize.rs+7-11| ... | ... | @@ -5,18 +5,14 @@ |
| 5 | 5 | //! generic parameters are unused (and eventually, in what ways generic parameters are used - only |
| 6 | 6 | //! for their size, offset of a field, etc.). |
| 7 | 7 | |
| 8 | use rustc_hir::{def::DefKind, def_id::DefId, ConstContext}; | |
| 9 | use rustc_middle::mir::{ | |
| 10 | self, | |
| 11 | visit::{TyContext, Visitor}, | |
| 12 | Local, LocalDecl, Location, | |
| 13 | }; | |
| 8 | use rustc_hir::def::DefKind; | |
| 9 | use rustc_hir::def_id::DefId; | |
| 10 | use rustc_hir::ConstContext; | |
| 11 | use rustc_middle::mir::visit::{TyContext, Visitor}; | |
| 12 | use rustc_middle::mir::{self, Local, LocalDecl, Location}; | |
| 14 | 13 | use rustc_middle::query::Providers; |
| 15 | use rustc_middle::ty::{ | |
| 16 | self, | |
| 17 | visit::{TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor}, | |
| 18 | GenericArgsRef, Ty, TyCtxt, UnusedGenericParams, | |
| 19 | }; | |
| 14 | use rustc_middle::ty::visit::{TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor}; | |
| 15 | use rustc_middle::ty::{self, GenericArgsRef, Ty, TyCtxt, UnusedGenericParams}; | |
| 20 | 16 | use rustc_span::symbol::sym; |
| 21 | 17 | use tracing::{debug, instrument}; |
| 22 | 18 |
compiler/rustc_monomorphize/src/util.rs+2-1| ... | ... | @@ -1,7 +1,8 @@ |
| 1 | use rustc_middle::ty::{self, ClosureSizeProfileData, Instance, TyCtxt}; | |
| 2 | 1 | use std::fs::OpenOptions; |
| 3 | 2 | use std::io::prelude::*; |
| 4 | 3 | |
| 4 | use rustc_middle::ty::{self, ClosureSizeProfileData, Instance, TyCtxt}; | |
| 5 | ||
| 5 | 6 | /// For a given closure, writes out the data for the profiling the impact of RFC 2229 on |
| 6 | 7 | /// closure size into a CSV. |
| 7 | 8 | /// |
compiler/rustc_next_trait_solver/src/resolve.rs+2-1| ... | ... | @@ -1,9 +1,10 @@ |
| 1 | use crate::delegate::SolverDelegate; | |
| 2 | 1 | use rustc_type_ir::fold::{TypeFoldable, TypeFolder, TypeSuperFoldable}; |
| 3 | 2 | use rustc_type_ir::inherent::*; |
| 4 | 3 | use rustc_type_ir::visit::TypeVisitableExt; |
| 5 | 4 | use rustc_type_ir::{self as ty, InferCtxtLike, Interner}; |
| 6 | 5 | |
| 6 | use crate::delegate::SolverDelegate; | |
| 7 | ||
| 7 | 8 | /////////////////////////////////////////////////////////////////////////// |
| 8 | 9 | // EAGER RESOLUTION |
| 9 | 10 |
compiler/rustc_next_trait_solver/src/solve/assembly/mod.rs+1-2| ... | ... | @@ -3,12 +3,11 @@ |
| 3 | 3 | pub(super) mod structural_traits; |
| 4 | 4 | |
| 5 | 5 | use derive_where::derive_where; |
| 6 | use rustc_type_ir::elaborate; | |
| 7 | 6 | use rustc_type_ir::fold::TypeFoldable; |
| 8 | 7 | use rustc_type_ir::inherent::*; |
| 9 | 8 | use rustc_type_ir::lang_items::TraitSolverLangItem; |
| 10 | 9 | use rustc_type_ir::visit::TypeVisitableExt as _; |
| 11 | use rustc_type_ir::{self as ty, Interner, Upcast as _}; | |
| 10 | use rustc_type_ir::{self as ty, elaborate, Interner, Upcast as _}; | |
| 12 | 11 | use tracing::{debug, instrument}; |
| 13 | 12 | |
| 14 | 13 | use crate::delegate::SolverDelegate; |
compiler/rustc_next_trait_solver/src/solve/eval_ctxt/canonical.rs+1-2| ... | ... | @@ -21,9 +21,8 @@ use crate::canonicalizer::{CanonicalizeMode, Canonicalizer}; |
| 21 | 21 | use crate::delegate::SolverDelegate; |
| 22 | 22 | use crate::resolve::EagerResolver; |
| 23 | 23 | use crate::solve::eval_ctxt::NestedGoals; |
| 24 | use crate::solve::inspect; | |
| 25 | 24 | use crate::solve::{ |
| 26 | response_no_constraints_raw, CanonicalInput, CanonicalResponse, Certainty, EvalCtxt, | |
| 25 | inspect, response_no_constraints_raw, CanonicalInput, CanonicalResponse, Certainty, EvalCtxt, | |
| 27 | 26 | ExternalConstraintsData, Goal, MaybeCause, NestedNormalizationGoals, NoSolution, |
| 28 | 27 | PredefinedOpaquesData, QueryInput, QueryResult, Response, |
| 29 | 28 | }; |
compiler/rustc_next_trait_solver/src/solve/eval_ctxt/probe.rs+3-2| ... | ... | @@ -5,8 +5,9 @@ use tracing::instrument; |
| 5 | 5 | |
| 6 | 6 | use crate::delegate::SolverDelegate; |
| 7 | 7 | use crate::solve::assembly::Candidate; |
| 8 | use crate::solve::inspect; | |
| 9 | use crate::solve::{BuiltinImplSource, CandidateSource, EvalCtxt, NoSolution, QueryResult}; | |
| 8 | use crate::solve::{ | |
| 9 | inspect, BuiltinImplSource, CandidateSource, EvalCtxt, NoSolution, QueryResult, | |
| 10 | }; | |
| 10 | 11 | |
| 11 | 12 | pub(in crate::solve) struct ProbeCtxt<'me, 'a, D, I, F, T> |
| 12 | 13 | where |
compiler/rustc_next_trait_solver/src/solve/inspect/build.rs+2-3| ... | ... | @@ -13,10 +13,9 @@ use rustc_type_ir::{self as ty, search_graph, Interner}; |
| 13 | 13 | |
| 14 | 14 | use crate::delegate::SolverDelegate; |
| 15 | 15 | use crate::solve::eval_ctxt::canonical; |
| 16 | use crate::solve::inspect; | |
| 17 | 16 | use crate::solve::{ |
| 18 | CanonicalInput, Certainty, GenerateProofTree, Goal, GoalEvaluationKind, GoalSource, QueryInput, | |
| 19 | QueryResult, | |
| 17 | inspect, CanonicalInput, Certainty, GenerateProofTree, Goal, GoalEvaluationKind, GoalSource, | |
| 18 | QueryInput, QueryResult, | |
| 20 | 19 | }; |
| 21 | 20 | |
| 22 | 21 | /// The core data structure when building proof trees. |
compiler/rustc_next_trait_solver/src/solve/normalizes_to/mod.rs+1-2| ... | ... | @@ -6,8 +6,7 @@ mod weak_types; |
| 6 | 6 | use rustc_type_ir::fast_reject::{DeepRejectCtxt, TreatParams}; |
| 7 | 7 | use rustc_type_ir::inherent::*; |
| 8 | 8 | use rustc_type_ir::lang_items::TraitSolverLangItem; |
| 9 | use rustc_type_ir::Upcast as _; | |
| 10 | use rustc_type_ir::{self as ty, Interner, NormalizesTo}; | |
| 9 | use rustc_type_ir::{self as ty, Interner, NormalizesTo, Upcast as _}; | |
| 11 | 10 | use tracing::instrument; |
| 12 | 11 | |
| 13 | 12 | use crate::delegate::SolverDelegate; |
compiler/rustc_parse/src/errors.rs+3-2| ... | ... | @@ -2,9 +2,10 @@ use std::borrow::Cow; |
| 2 | 2 | |
| 3 | 3 | use rustc_ast::token::Token; |
| 4 | 4 | use rustc_ast::{Path, Visibility}; |
| 5 | use rustc_errors::codes::*; | |
| 5 | 6 | use rustc_errors::{ |
| 6 | codes::*, Applicability, Diag, DiagCtxtHandle, Diagnostic, EmissionGuarantee, Level, | |
| 7 | SubdiagMessageOp, Subdiagnostic, | |
| 7 | Applicability, Diag, DiagCtxtHandle, Diagnostic, EmissionGuarantee, Level, SubdiagMessageOp, | |
| 8 | Subdiagnostic, | |
| 8 | 9 | }; |
| 9 | 10 | use rustc_macros::{Diagnostic, Subdiagnostic}; |
| 10 | 11 | use rustc_session::errors::ExprParenthesesNeeded; |
compiler/rustc_parse/src/lexer/diagnostics.rs+2-1| ... | ... | @@ -1,9 +1,10 @@ |
| 1 | use super::UnmatchedDelim; | |
| 2 | 1 | use rustc_ast::token::Delimiter; |
| 3 | 2 | use rustc_errors::Diag; |
| 4 | 3 | use rustc_span::source_map::SourceMap; |
| 5 | 4 | use rustc_span::Span; |
| 6 | 5 | |
| 6 | use super::UnmatchedDelim; | |
| 7 | ||
| 7 | 8 | #[derive(Default)] |
| 8 | 9 | pub(super) struct TokenTreeDiagInfo { |
| 9 | 10 | /// Stack of open delimiters and their spans. Used for error message. |
compiler/rustc_parse/src/lexer/mod.rs+8-7| ... | ... | @@ -1,25 +1,26 @@ |
| 1 | 1 | use std::ops::Range; |
| 2 | 2 | |
| 3 | use crate::errors; | |
| 4 | use crate::lexer::unicode_chars::UNICODE_ARRAY; | |
| 5 | use crate::make_unclosed_delims_error; | |
| 6 | 3 | use rustc_ast::ast::{self, AttrStyle}; |
| 7 | 4 | use rustc_ast::token::{self, CommentKind, Delimiter, IdentIsRaw, Token, TokenKind}; |
| 8 | 5 | use rustc_ast::tokenstream::TokenStream; |
| 9 | 6 | use rustc_ast::util::unicode::contains_text_flow_control_chars; |
| 10 | use rustc_errors::{codes::*, Applicability, Diag, DiagCtxtHandle, StashKey}; | |
| 7 | use rustc_errors::codes::*; | |
| 8 | use rustc_errors::{Applicability, Diag, DiagCtxtHandle, StashKey}; | |
| 11 | 9 | use rustc_lexer::unescape::{self, EscapeError, Mode}; |
| 12 | use rustc_lexer::{Base, DocStyle, RawStrError}; | |
| 13 | use rustc_lexer::{Cursor, LiteralKind}; | |
| 10 | use rustc_lexer::{Base, Cursor, DocStyle, LiteralKind, RawStrError}; | |
| 14 | 11 | use rustc_session::lint::builtin::{ |
| 15 | 12 | RUST_2021_PREFIXES_INCOMPATIBLE_SYNTAX, TEXT_DIRECTION_CODEPOINT_IN_COMMENT, |
| 16 | 13 | }; |
| 17 | 14 | use rustc_session::lint::BuiltinLintDiag; |
| 18 | 15 | use rustc_session::parse::ParseSess; |
| 16 | use rustc_span::edition::Edition; | |
| 19 | 17 | use rustc_span::symbol::Symbol; |
| 20 | use rustc_span::{edition::Edition, BytePos, Pos, Span}; | |
| 18 | use rustc_span::{BytePos, Pos, Span}; | |
| 21 | 19 | use tracing::debug; |
| 22 | 20 | |
| 21 | use crate::lexer::unicode_chars::UNICODE_ARRAY; | |
| 22 | use crate::{errors, make_unclosed_delims_error}; | |
| 23 | ||
| 23 | 24 | mod diagnostics; |
| 24 | 25 | mod tokentrees; |
| 25 | 26 | mod unescape_error_reporting; |
compiler/rustc_parse/src/lexer/tokentrees.rs+6-5| ... | ... | @@ -1,14 +1,15 @@ |
| 1 | use super::diagnostics::report_suspicious_mismatch_block; | |
| 2 | use super::diagnostics::same_indentation_level; | |
| 3 | use super::diagnostics::TokenTreeDiagInfo; | |
| 4 | use super::{StringReader, UnmatchedDelim}; | |
| 5 | use crate::Parser; | |
| 6 | 1 | use rustc_ast::token::{self, Delimiter, Token}; |
| 7 | 2 | use rustc_ast::tokenstream::{DelimSpacing, DelimSpan, Spacing, TokenStream, TokenTree}; |
| 8 | 3 | use rustc_ast_pretty::pprust::token_to_string; |
| 9 | 4 | use rustc_errors::{Applicability, PErr}; |
| 10 | 5 | use rustc_span::symbol::kw; |
| 11 | 6 | |
| 7 | use super::diagnostics::{ | |
| 8 | report_suspicious_mismatch_block, same_indentation_level, TokenTreeDiagInfo, | |
| 9 | }; | |
| 10 | use super::{StringReader, UnmatchedDelim}; | |
| 11 | use crate::Parser; | |
| 12 | ||
| 12 | 13 | pub(super) struct TokenTreesReader<'psess, 'src> { |
| 13 | 14 | string_reader: StringReader<'psess, 'src>, |
| 14 | 15 | /// The "next" token, which has been obtained from the `StringReader` but |
compiler/rustc_parse/src/lexer/unescape_error_reporting.rs+2-1| ... | ... | @@ -40,7 +40,8 @@ pub(crate) fn emit_unescape_error( |
| 40 | 40 | dcx.emit_err(UnescapeError::InvalidUnicodeEscape { span: err_span, surrogate: false }) |
| 41 | 41 | } |
| 42 | 42 | EscapeError::MoreThanOneChar => { |
| 43 | use unicode_normalization::{char::is_combining_mark, UnicodeNormalization}; | |
| 43 | use unicode_normalization::char::is_combining_mark; | |
| 44 | use unicode_normalization::UnicodeNormalization; | |
| 44 | 45 | let mut sugg = None; |
| 45 | 46 | let mut note = None; |
| 46 | 47 |
compiler/rustc_parse/src/lexer/unicode_chars.rs+5-5| ... | ... | @@ -1,12 +1,12 @@ |
| 1 | 1 | //! Characters and their corresponding confusables were collected from |
| 2 | 2 | //! <https://www.unicode.org/Public/security/10.0.0/confusables.txt> |
| 3 | 3 | |
| 4 | use rustc_span::symbol::kw; | |
| 5 | use rustc_span::{BytePos, Pos, Span}; | |
| 6 | ||
| 4 | 7 | use super::StringReader; |
| 5 | use crate::{ | |
| 6 | errors::TokenSubstitution, | |
| 7 | token::{self, Delimiter}, | |
| 8 | }; | |
| 9 | use rustc_span::{symbol::kw, BytePos, Pos, Span}; | |
| 8 | use crate::errors::TokenSubstitution; | |
| 9 | use crate::token::{self, Delimiter}; | |
| 10 | 10 | |
| 11 | 11 | #[rustfmt::skip] // for line breaks |
| 12 | 12 | pub(super) const UNICODE_ARRAY: &[(char, &str, &str)] = &[ |
compiler/rustc_parse/src/lib.rs+3-4| ... | ... | @@ -12,18 +12,17 @@ |
| 12 | 12 | #![feature(let_chains)] |
| 13 | 13 | // tidy-alphabetical-end |
| 14 | 14 | |
| 15 | use std::path::Path; | |
| 16 | ||
| 15 | 17 | use rustc_ast as ast; |
| 16 | use rustc_ast::token; | |
| 17 | 18 | use rustc_ast::tokenstream::TokenStream; |
| 18 | use rustc_ast::{AttrItem, Attribute, MetaItem}; | |
| 19 | use rustc_ast::{token, AttrItem, Attribute, MetaItem}; | |
| 19 | 20 | use rustc_ast_pretty::pprust; |
| 20 | 21 | use rustc_data_structures::sync::Lrc; |
| 21 | 22 | use rustc_errors::{Diag, FatalError, PResult}; |
| 22 | 23 | use rustc_session::parse::ParseSess; |
| 23 | 24 | use rustc_span::{FileName, SourceFile, Span}; |
| 24 | 25 | |
| 25 | use std::path::Path; | |
| 26 | ||
| 27 | 26 | pub const MACRO_ARGUMENTS: Option<&str> = Some("macro arguments"); |
| 28 | 27 | |
| 29 | 28 | #[macro_use] |
compiler/rustc_parse/src/parser/attr.rs+7-7| ... | ... | @@ -1,16 +1,16 @@ |
| 1 | use crate::errors; | |
| 2 | use crate::fluent_generated as fluent; | |
| 3 | use crate::maybe_whole; | |
| 4 | ||
| 5 | use super::{AttrWrapper, Capturing, FnParseMode, ForceCollect, Parser, PathStyle}; | |
| 6 | 1 | use rustc_ast as ast; |
| 7 | 2 | use rustc_ast::attr; |
| 8 | 3 | use rustc_ast::token::{self, Delimiter}; |
| 9 | use rustc_errors::{codes::*, Diag, PResult}; | |
| 10 | use rustc_span::{sym, symbol::kw, BytePos, Span}; | |
| 4 | use rustc_errors::codes::*; | |
| 5 | use rustc_errors::{Diag, PResult}; | |
| 6 | use rustc_span::symbol::kw; | |
| 7 | use rustc_span::{sym, BytePos, Span}; | |
| 11 | 8 | use thin_vec::ThinVec; |
| 12 | 9 | use tracing::debug; |
| 13 | 10 | |
| 11 | use super::{AttrWrapper, Capturing, FnParseMode, ForceCollect, Parser, PathStyle}; | |
| 12 | use crate::{errors, fluent_generated as fluent, maybe_whole}; | |
| 13 | ||
| 14 | 14 | // Public for rustfmt usage |
| 15 | 15 | #[derive(Debug)] |
| 16 | 16 | pub enum InnerAttrPolicy { |
compiler/rustc_parse/src/parser/attr_wrapper.rs+10-7| ... | ... | @@ -1,14 +1,16 @@ |
| 1 | use super::{Capturing, FlatToken, ForceCollect, Parser, ReplaceRange, TokenCursor}; | |
| 1 | use std::{iter, mem}; | |
| 2 | ||
| 2 | 3 | use rustc_ast::token::{Delimiter, Token, TokenKind}; |
| 3 | use rustc_ast::tokenstream::{AttrTokenStream, AttrTokenTree, AttrsTarget, DelimSpacing}; | |
| 4 | use rustc_ast::tokenstream::{DelimSpan, LazyAttrTokenStream, Spacing, ToAttrTokenStream}; | |
| 5 | use rustc_ast::{self as ast}; | |
| 6 | use rustc_ast::{AttrVec, Attribute, HasAttrs, HasTokens}; | |
| 4 | use rustc_ast::tokenstream::{ | |
| 5 | AttrTokenStream, AttrTokenTree, AttrsTarget, DelimSpacing, DelimSpan, LazyAttrTokenStream, | |
| 6 | Spacing, ToAttrTokenStream, | |
| 7 | }; | |
| 8 | use rustc_ast::{self as ast, AttrVec, Attribute, HasAttrs, HasTokens}; | |
| 7 | 9 | use rustc_errors::PResult; |
| 8 | 10 | use rustc_session::parse::ParseSess; |
| 9 | 11 | use rustc_span::{sym, Span, DUMMY_SP}; |
| 10 | 12 | |
| 11 | use std::{iter, mem}; | |
| 13 | use super::{Capturing, FlatToken, ForceCollect, Parser, ReplaceRange, TokenCursor}; | |
| 12 | 14 | |
| 13 | 15 | /// A wrapper type to ensure that the parser handles outer attributes correctly. |
| 14 | 16 | /// When we parse outer attributes, we need to ensure that we capture tokens |
| ... | ... | @@ -469,8 +471,9 @@ fn needs_tokens(attrs: &[ast::Attribute]) -> bool { |
| 469 | 471 | // Some types are used a lot. Make sure they don't unintentionally get bigger. |
| 470 | 472 | #[cfg(target_pointer_width = "64")] |
| 471 | 473 | mod size_asserts { |
| 472 | use super::*; | |
| 473 | 474 | use rustc_data_structures::static_assert_size; |
| 475 | ||
| 476 | use super::*; | |
| 474 | 477 | // tidy-alphabetical-start |
| 475 | 478 | static_assert_size!(AttrWrapper, 16); |
| 476 | 479 | static_assert_size!(LazyAttrTokenStreamImpl, 96); |
compiler/rustc_parse/src/parser/diagnostics.rs+25-24| ... | ... | @@ -1,25 +1,6 @@ |
| 1 | use super::pat::Expected; | |
| 2 | use super::{ | |
| 3 | BlockMode, CommaRecoveryMode, Parser, PathStyle, Restrictions, SemiColonMode, SeqSep, TokenType, | |
| 4 | }; | |
| 5 | use crate::errors::{ | |
| 6 | AddParen, AmbiguousPlus, AsyncMoveBlockIn2015, AttributeOnParamType, AwaitSuggestion, | |
| 7 | BadQPathStage2, BadTypePlus, BadTypePlusSub, ColonAsSemi, ComparisonOperatorsCannotBeChained, | |
| 8 | ComparisonOperatorsCannotBeChainedSugg, ConstGenericWithoutBraces, | |
| 9 | ConstGenericWithoutBracesSugg, DocCommentDoesNotDocumentAnything, DocCommentOnParamType, | |
| 10 | DoubleColonInBound, ExpectedIdentifier, ExpectedSemi, ExpectedSemiSugg, | |
| 11 | GenericParamsWithoutAngleBrackets, GenericParamsWithoutAngleBracketsSugg, | |
| 12 | HelpIdentifierStartsWithNumber, HelpUseLatestEdition, InInTypo, IncorrectAwait, | |
| 13 | IncorrectSemicolon, IncorrectUseOfAwait, PatternMethodParamWithoutBody, QuestionMarkInType, | |
| 14 | QuestionMarkInTypeSugg, SelfParamNotFirst, StructLiteralBodyWithoutPath, | |
| 15 | StructLiteralBodyWithoutPathSugg, StructLiteralNeedingParens, StructLiteralNeedingParensSugg, | |
| 16 | SuggAddMissingLetStmt, SuggEscapeIdentifier, SuggRemoveComma, TernaryOperator, | |
| 17 | UnexpectedConstInGenericParam, UnexpectedConstParamDeclaration, | |
| 18 | UnexpectedConstParamDeclarationSugg, UnmatchedAngleBrackets, UseEqInstead, WrapType, | |
| 19 | }; | |
| 20 | use crate::fluent_generated as fluent; | |
| 21 | use crate::parser; | |
| 22 | use crate::parser::attr::InnerAttrPolicy; | |
| 1 | use std::mem::take; | |
| 2 | use std::ops::{Deref, DerefMut}; | |
| 3 | ||
| 23 | 4 | use ast::token::IdentIsRaw; |
| 24 | 5 | use rustc_ast as ast; |
| 25 | 6 | use rustc_ast::ptr::P; |
| ... | ... | @@ -41,11 +22,31 @@ use rustc_session::errors::ExprParenthesesNeeded; |
| 41 | 22 | use rustc_span::source_map::Spanned; |
| 42 | 23 | use rustc_span::symbol::{kw, sym, Ident}; |
| 43 | 24 | use rustc_span::{BytePos, Span, SpanSnippetError, Symbol, DUMMY_SP}; |
| 44 | use std::mem::take; | |
| 45 | use std::ops::{Deref, DerefMut}; | |
| 46 | 25 | use thin_vec::{thin_vec, ThinVec}; |
| 47 | 26 | use tracing::{debug, trace}; |
| 48 | 27 | |
| 28 | use super::pat::Expected; | |
| 29 | use super::{ | |
| 30 | BlockMode, CommaRecoveryMode, Parser, PathStyle, Restrictions, SemiColonMode, SeqSep, TokenType, | |
| 31 | }; | |
| 32 | use crate::errors::{ | |
| 33 | AddParen, AmbiguousPlus, AsyncMoveBlockIn2015, AttributeOnParamType, AwaitSuggestion, | |
| 34 | BadQPathStage2, BadTypePlus, BadTypePlusSub, ColonAsSemi, ComparisonOperatorsCannotBeChained, | |
| 35 | ComparisonOperatorsCannotBeChainedSugg, ConstGenericWithoutBraces, | |
| 36 | ConstGenericWithoutBracesSugg, DocCommentDoesNotDocumentAnything, DocCommentOnParamType, | |
| 37 | DoubleColonInBound, ExpectedIdentifier, ExpectedSemi, ExpectedSemiSugg, | |
| 38 | GenericParamsWithoutAngleBrackets, GenericParamsWithoutAngleBracketsSugg, | |
| 39 | HelpIdentifierStartsWithNumber, HelpUseLatestEdition, InInTypo, IncorrectAwait, | |
| 40 | IncorrectSemicolon, IncorrectUseOfAwait, PatternMethodParamWithoutBody, QuestionMarkInType, | |
| 41 | QuestionMarkInTypeSugg, SelfParamNotFirst, StructLiteralBodyWithoutPath, | |
| 42 | StructLiteralBodyWithoutPathSugg, StructLiteralNeedingParens, StructLiteralNeedingParensSugg, | |
| 43 | SuggAddMissingLetStmt, SuggEscapeIdentifier, SuggRemoveComma, TernaryOperator, | |
| 44 | UnexpectedConstInGenericParam, UnexpectedConstParamDeclaration, | |
| 45 | UnexpectedConstParamDeclarationSugg, UnmatchedAngleBrackets, UseEqInstead, WrapType, | |
| 46 | }; | |
| 47 | use crate::parser::attr::InnerAttrPolicy; | |
| 48 | use crate::{fluent_generated as fluent, parser}; | |
| 49 | ||
| 49 | 50 | /// Creates a placeholder argument. |
| 50 | 51 | pub(super) fn dummy_arg(ident: Ident, guar: ErrorGuaranteed) -> Param { |
| 51 | 52 | let pat = P(Pat { |
compiler/rustc_parse/src/parser/expr.rs+16-15| ... | ... | @@ -1,30 +1,22 @@ |
| 1 | 1 | // ignore-tidy-filelength |
| 2 | 2 | |
| 3 | use super::diagnostics::SnapshotParser; | |
| 4 | use super::pat::{CommaRecoveryMode, Expected, RecoverColon, RecoverComma}; | |
| 5 | use super::ty::{AllowPlus, RecoverQPath, RecoverReturnSign}; | |
| 6 | use super::{ | |
| 7 | AttrWrapper, BlockMode, ClosureSpans, ForceCollect, Parser, PathStyle, Restrictions, | |
| 8 | SemiColonMode, SeqSep, TokenType, Trailing, | |
| 9 | }; | |
| 3 | use core::mem; | |
| 4 | use core::ops::ControlFlow; | |
| 10 | 5 | |
| 11 | use crate::errors; | |
| 12 | use crate::maybe_recover_from_interpolated_ty_qpath; | |
| 13 | 6 | use ast::mut_visit::{self, MutVisitor}; |
| 14 | 7 | use ast::token::IdentIsRaw; |
| 15 | 8 | use ast::{CoroutineKind, ForLoopKind, GenBlockKind, MatchKind, Pat, Path, PathSegment, Recovered}; |
| 16 | use core::mem; | |
| 17 | use core::ops::ControlFlow; | |
| 18 | 9 | use rustc_ast::ptr::P; |
| 19 | 10 | use rustc_ast::token::{self, Delimiter, Token, TokenKind}; |
| 20 | 11 | use rustc_ast::util::case::Case; |
| 21 | 12 | use rustc_ast::util::classify; |
| 22 | 13 | use rustc_ast::util::parser::{prec_let_scrutinee_needs_par, AssocOp, Fixity}; |
| 23 | 14 | use rustc_ast::visit::{walk_expr, Visitor}; |
| 24 | use rustc_ast::{self as ast, AttrStyle, AttrVec, CaptureBy, ExprField, UnOp, DUMMY_NODE_ID}; | |
| 25 | use rustc_ast::{AnonConst, BinOp, BinOpKind, FnDecl, FnRetTy, MacCall, Param, Ty, TyKind}; | |
| 26 | use rustc_ast::{Arm, BlockCheckMode, Expr, ExprKind, Label, Movability, RangeLimits}; | |
| 27 | use rustc_ast::{ClosureBinder, MetaItemLit, StmtKind}; | |
| 15 | use rustc_ast::{ | |
| 16 | self as ast, AnonConst, Arm, AttrStyle, AttrVec, BinOp, BinOpKind, BlockCheckMode, CaptureBy, | |
| 17 | ClosureBinder, Expr, ExprField, ExprKind, FnDecl, FnRetTy, Label, MacCall, MetaItemLit, | |
| 18 | Movability, Param, RangeLimits, StmtKind, Ty, TyKind, UnOp, DUMMY_NODE_ID, | |
| 19 | }; | |
| 28 | 20 | use rustc_ast_pretty::pprust; |
| 29 | 21 | use rustc_data_structures::stack::ensure_sufficient_stack; |
| 30 | 22 | use rustc_errors::{Applicability, Diag, PResult, StashKey, Subdiagnostic}; |
| ... | ... | @@ -39,6 +31,15 @@ use rustc_span::{BytePos, ErrorGuaranteed, Pos, Span}; |
| 39 | 31 | use thin_vec::{thin_vec, ThinVec}; |
| 40 | 32 | use tracing::instrument; |
| 41 | 33 | |
| 34 | use super::diagnostics::SnapshotParser; | |
| 35 | use super::pat::{CommaRecoveryMode, Expected, RecoverColon, RecoverComma}; | |
| 36 | use super::ty::{AllowPlus, RecoverQPath, RecoverReturnSign}; | |
| 37 | use super::{ | |
| 38 | AttrWrapper, BlockMode, ClosureSpans, ForceCollect, Parser, PathStyle, Restrictions, | |
| 39 | SemiColonMode, SeqSep, TokenType, Trailing, | |
| 40 | }; | |
| 41 | use crate::{errors, maybe_recover_from_interpolated_ty_qpath}; | |
| 42 | ||
| 42 | 43 | #[derive(Debug)] |
| 43 | 44 | pub(super) enum LhsExpr { |
| 44 | 45 | // Already parsed just the outer attributes. |
compiler/rustc_parse/src/parser/generics.rs+8-10| ... | ... | @@ -1,21 +1,19 @@ |
| 1 | use crate::errors::{ | |
| 2 | self, MultipleWhereClauses, UnexpectedDefaultValueForLifetimeInGenericParameters, | |
| 3 | UnexpectedSelfInGenericParameters, WhereClauseBeforeTupleStructBody, | |
| 4 | WhereClauseBeforeTupleStructBodySugg, | |
| 5 | }; | |
| 6 | ||
| 7 | use super::{ForceCollect, Parser}; | |
| 8 | ||
| 9 | 1 | use ast::token::Delimiter; |
| 10 | use rustc_ast::token; | |
| 11 | 2 | use rustc_ast::{ |
| 12 | self as ast, AttrVec, GenericBounds, GenericParam, GenericParamKind, TyKind, WhereClause, | |
| 3 | self as ast, token, AttrVec, GenericBounds, GenericParam, GenericParamKind, TyKind, WhereClause, | |
| 13 | 4 | }; |
| 14 | 5 | use rustc_errors::{Applicability, PResult}; |
| 15 | 6 | use rustc_span::symbol::{kw, Ident}; |
| 16 | 7 | use rustc_span::Span; |
| 17 | 8 | use thin_vec::ThinVec; |
| 18 | 9 | |
| 10 | use super::{ForceCollect, Parser}; | |
| 11 | use crate::errors::{ | |
| 12 | self, MultipleWhereClauses, UnexpectedDefaultValueForLifetimeInGenericParameters, | |
| 13 | UnexpectedSelfInGenericParameters, WhereClauseBeforeTupleStructBody, | |
| 14 | WhereClauseBeforeTupleStructBodySugg, | |
| 15 | }; | |
| 16 | ||
| 19 | 17 | enum PredicateOrStructBody { |
| 20 | 18 | Predicate(ast::WherePredicate), |
| 21 | 19 | StructBody(ThinVec<ast::FieldDef>), |
compiler/rustc_parse/src/parser/item.rs+12-12| ... | ... | @@ -1,9 +1,6 @@ |
| 1 | use super::diagnostics::{dummy_arg, ConsumeClosingDelim}; | |
| 2 | use super::ty::{AllowPlus, RecoverQPath, RecoverReturnSign}; | |
| 3 | use super::{AttrWrapper, FollowedByType, ForceCollect, Parser, PathStyle, Trailing}; | |
| 4 | use crate::errors::{self, MacroExpandsToAdtField}; | |
| 5 | use crate::fluent_generated as fluent; | |
| 6 | use crate::maybe_whole; | |
| 1 | use std::fmt::Write; | |
| 2 | use std::mem; | |
| 3 | ||
| 7 | 4 | use ast::token::IdentIsRaw; |
| 8 | 5 | use rustc_ast::ast::*; |
| 9 | 6 | use rustc_ast::ptr::P; |
| ... | ... | @@ -12,18 +9,21 @@ use rustc_ast::tokenstream::{DelimSpan, TokenStream, TokenTree}; |
| 12 | 9 | use rustc_ast::util::case::Case; |
| 13 | 10 | use rustc_ast::{self as ast}; |
| 14 | 11 | use rustc_ast_pretty::pprust; |
| 15 | use rustc_errors::{codes::*, struct_span_code_err, Applicability, PResult, StashKey}; | |
| 12 | use rustc_errors::codes::*; | |
| 13 | use rustc_errors::{struct_span_code_err, Applicability, PResult, StashKey}; | |
| 16 | 14 | use rustc_span::edit_distance::edit_distance; |
| 17 | 15 | use rustc_span::edition::Edition; |
| 18 | use rustc_span::source_map; | |
| 19 | 16 | use rustc_span::symbol::{kw, sym, Ident, Symbol}; |
| 20 | use rustc_span::ErrorGuaranteed; | |
| 21 | use rustc_span::{Span, DUMMY_SP}; | |
| 22 | use std::fmt::Write; | |
| 23 | use std::mem; | |
| 17 | use rustc_span::{source_map, ErrorGuaranteed, Span, DUMMY_SP}; | |
| 24 | 18 | use thin_vec::{thin_vec, ThinVec}; |
| 25 | 19 | use tracing::debug; |
| 26 | 20 | |
| 21 | use super::diagnostics::{dummy_arg, ConsumeClosingDelim}; | |
| 22 | use super::ty::{AllowPlus, RecoverQPath, RecoverReturnSign}; | |
| 23 | use super::{AttrWrapper, FollowedByType, ForceCollect, Parser, PathStyle, Trailing}; | |
| 24 | use crate::errors::{self, MacroExpandsToAdtField}; | |
| 25 | use crate::{fluent_generated as fluent, maybe_whole}; | |
| 26 | ||
| 27 | 27 | impl<'a> Parser<'a> { |
| 28 | 28 | /// Parses a source module as a crate. This is the main entry point for the parser. |
| 29 | 29 | pub fn parse_crate_mod(&mut self) -> PResult<'a, ast::Crate> { |
compiler/rustc_parse/src/parser/mod.rs+7-6| ... | ... | @@ -10,18 +10,20 @@ mod path; |
| 10 | 10 | mod stmt; |
| 11 | 11 | mod ty; |
| 12 | 12 | |
| 13 | use crate::lexer::UnmatchedDelim; | |
| 13 | use std::ops::Range; | |
| 14 | use std::{fmt, mem, slice}; | |
| 15 | ||
| 14 | 16 | use attr_wrapper::AttrWrapper; |
| 15 | 17 | pub use diagnostics::AttemptLocalParseRecovery; |
| 16 | 18 | pub(crate) use expr::ForbiddenLetReason; |
| 17 | 19 | pub(crate) use item::FnParseMode; |
| 18 | 20 | pub use pat::{CommaRecoveryMode, RecoverColon, RecoverComma}; |
| 19 | 21 | use path::PathStyle; |
| 20 | ||
| 21 | 22 | use rustc_ast::ptr::P; |
| 22 | 23 | use rustc_ast::token::{self, Delimiter, IdentIsRaw, Nonterminal, Token, TokenKind}; |
| 23 | use rustc_ast::tokenstream::{AttrsTarget, DelimSpacing, DelimSpan, Spacing}; | |
| 24 | use rustc_ast::tokenstream::{TokenStream, TokenTree, TokenTreeCursor}; | |
| 24 | use rustc_ast::tokenstream::{ | |
| 25 | AttrsTarget, DelimSpacing, DelimSpan, Spacing, TokenStream, TokenTree, TokenTreeCursor, | |
| 26 | }; | |
| 25 | 27 | use rustc_ast::util::case::Case; |
| 26 | 28 | use rustc_ast::{ |
| 27 | 29 | self as ast, AnonConst, AttrArgs, AttrArgsEq, AttrId, ByRef, Const, CoroutineKind, DelimArgs, |
| ... | ... | @@ -35,14 +37,13 @@ use rustc_errors::{Applicability, Diag, FatalError, MultiSpan, PResult}; |
| 35 | 37 | use rustc_session::parse::ParseSess; |
| 36 | 38 | use rustc_span::symbol::{kw, sym, Ident, Symbol}; |
| 37 | 39 | use rustc_span::{Span, DUMMY_SP}; |
| 38 | use std::ops::Range; | |
| 39 | use std::{fmt, mem, slice}; | |
| 40 | 40 | use thin_vec::ThinVec; |
| 41 | 41 | use tracing::debug; |
| 42 | 42 | |
| 43 | 43 | use crate::errors::{ |
| 44 | 44 | self, IncorrectVisibilityRestriction, MismatchedClosingDelimiter, NonStringAbiLiteral, |
| 45 | 45 | }; |
| 46 | use crate::lexer::UnmatchedDelim; | |
| 46 | 47 | |
| 47 | 48 | #[cfg(test)] |
| 48 | 49 | mod tests; |
compiler/rustc_parse/src/parser/mut_visit/tests.rs+2-1| ... | ... | @@ -1,10 +1,11 @@ |
| 1 | use crate::parser::tests::{matches_codepattern, string_to_crate}; | |
| 2 | 1 | use rustc_ast as ast; |
| 3 | 2 | use rustc_ast::mut_visit::MutVisitor; |
| 4 | 3 | use rustc_ast_pretty::pprust; |
| 5 | 4 | use rustc_span::create_default_session_globals_then; |
| 6 | 5 | use rustc_span::symbol::Ident; |
| 7 | 6 | |
| 7 | use crate::parser::tests::{matches_codepattern, string_to_crate}; | |
| 8 | ||
| 8 | 9 | // This version doesn't care about getting comments or doc-strings in. |
| 9 | 10 | fn print_crate_items(krate: &ast::Crate) -> String { |
| 10 | 11 | krate.items.iter().map(|i| pprust::item_to_string(i)).collect::<Vec<_>>().join(" ") |
compiler/rustc_parse/src/parser/nonterminal.rs+4-3| ... | ... | @@ -1,7 +1,8 @@ |
| 1 | 1 | use rustc_ast::ptr::P; |
| 2 | use rustc_ast::token::{ | |
| 3 | self, Delimiter, Nonterminal::*, NonterminalKind, NtExprKind::*, NtPatKind::*, Token, | |
| 4 | }; | |
| 2 | use rustc_ast::token::Nonterminal::*; | |
| 3 | use rustc_ast::token::NtExprKind::*; | |
| 4 | use rustc_ast::token::NtPatKind::*; | |
| 5 | use rustc_ast::token::{self, Delimiter, NonterminalKind, Token}; | |
| 5 | 6 | use rustc_ast::HasTokens; |
| 6 | 7 | use rustc_ast_pretty::pprust; |
| 7 | 8 | use rustc_data_structures::sync::Lrc; |
compiler/rustc_parse/src/parser/pat.rs+15-14| ... | ... | @@ -1,17 +1,3 @@ |
| 1 | use super::{ForceCollect, Parser, PathStyle, Restrictions, Trailing}; | |
| 2 | use crate::errors::{ | |
| 3 | self, AmbiguousRangePattern, DotDotDotForRemainingFields, DotDotDotRangeToPatternNotAllowed, | |
| 4 | DotDotDotRestPattern, EnumPatternInsteadOfIdentifier, ExpectedBindingLeftOfAt, | |
| 5 | ExpectedCommaAfterPatternField, GenericArgsInPatRequireTurbofishSyntax, | |
| 6 | InclusiveRangeExtraEquals, InclusiveRangeMatchArrow, InclusiveRangeNoEnd, InvalidMutInPattern, | |
| 7 | ParenRangeSuggestion, PatternOnWrongSideOfAt, RemoveLet, RepeatedMutInPattern, | |
| 8 | SwitchRefBoxOrder, TopLevelOrPatternNotAllowed, TopLevelOrPatternNotAllowedSugg, | |
| 9 | TrailingVertNotAllowed, UnexpectedExpressionInPattern, UnexpectedLifetimeInPattern, | |
| 10 | UnexpectedParenInRangePat, UnexpectedParenInRangePatSugg, | |
| 11 | UnexpectedVertVertBeforeFunctionParam, UnexpectedVertVertInPattern, WrapInParens, | |
| 12 | }; | |
| 13 | use crate::parser::expr::{could_be_unclosed_char_literal, LhsExpr}; | |
| 14 | use crate::{maybe_recover_from_interpolated_ty_qpath, maybe_whole}; | |
| 15 | 1 | use rustc_ast::mut_visit::{walk_pat, MutVisitor}; |
| 16 | 2 | use rustc_ast::ptr::P; |
| 17 | 3 | use rustc_ast::token::{self, BinOpToken, Delimiter, Token}; |
| ... | ... | @@ -27,6 +13,21 @@ use rustc_span::symbol::{kw, sym, Ident}; |
| 27 | 13 | use rustc_span::{BytePos, ErrorGuaranteed, Span}; |
| 28 | 14 | use thin_vec::{thin_vec, ThinVec}; |
| 29 | 15 | |
| 16 | use super::{ForceCollect, Parser, PathStyle, Restrictions, Trailing}; | |
| 17 | use crate::errors::{ | |
| 18 | self, AmbiguousRangePattern, DotDotDotForRemainingFields, DotDotDotRangeToPatternNotAllowed, | |
| 19 | DotDotDotRestPattern, EnumPatternInsteadOfIdentifier, ExpectedBindingLeftOfAt, | |
| 20 | ExpectedCommaAfterPatternField, GenericArgsInPatRequireTurbofishSyntax, | |
| 21 | InclusiveRangeExtraEquals, InclusiveRangeMatchArrow, InclusiveRangeNoEnd, InvalidMutInPattern, | |
| 22 | ParenRangeSuggestion, PatternOnWrongSideOfAt, RemoveLet, RepeatedMutInPattern, | |
| 23 | SwitchRefBoxOrder, TopLevelOrPatternNotAllowed, TopLevelOrPatternNotAllowedSugg, | |
| 24 | TrailingVertNotAllowed, UnexpectedExpressionInPattern, UnexpectedLifetimeInPattern, | |
| 25 | UnexpectedParenInRangePat, UnexpectedParenInRangePatSugg, | |
| 26 | UnexpectedVertVertBeforeFunctionParam, UnexpectedVertVertInPattern, WrapInParens, | |
| 27 | }; | |
| 28 | use crate::parser::expr::{could_be_unclosed_char_literal, LhsExpr}; | |
| 29 | use crate::{maybe_recover_from_interpolated_ty_qpath, maybe_whole}; | |
| 30 | ||
| 30 | 31 | #[derive(PartialEq, Copy, Clone)] |
| 31 | 32 | pub enum Expected { |
| 32 | 33 | ParameterName, |
compiler/rustc_parse/src/parser/path.rs+8-6| ... | ... | @@ -1,8 +1,5 @@ |
| 1 | use super::ty::{AllowPlus, RecoverQPath, RecoverReturnSign}; | |
| 2 | use super::{Parser, Restrictions, TokenType}; | |
| 3 | use crate::errors::PathSingleColon; | |
| 4 | use crate::parser::{CommaRecoveryMode, RecoverColon, RecoverComma}; | |
| 5 | use crate::{errors, maybe_whole}; | |
| 1 | use std::mem; | |
| 2 | ||
| 6 | 3 | use ast::token::IdentIsRaw; |
| 7 | 4 | use rustc_ast::ptr::P; |
| 8 | 5 | use rustc_ast::token::{self, Delimiter, Token, TokenKind}; |
| ... | ... | @@ -14,10 +11,15 @@ use rustc_ast::{ |
| 14 | 11 | use rustc_errors::{Applicability, Diag, PResult}; |
| 15 | 12 | use rustc_span::symbol::{kw, sym, Ident}; |
| 16 | 13 | use rustc_span::{BytePos, Span}; |
| 17 | use std::mem; | |
| 18 | 14 | use thin_vec::ThinVec; |
| 19 | 15 | use tracing::debug; |
| 20 | 16 | |
| 17 | use super::ty::{AllowPlus, RecoverQPath, RecoverReturnSign}; | |
| 18 | use super::{Parser, Restrictions, TokenType}; | |
| 19 | use crate::errors::PathSingleColon; | |
| 20 | use crate::parser::{CommaRecoveryMode, RecoverColon, RecoverComma}; | |
| 21 | use crate::{errors, maybe_whole}; | |
| 22 | ||
| 21 | 23 | /// Specifies how to parse a path. |
| 22 | 24 | #[derive(Copy, Clone, PartialEq)] |
| 23 | 25 | pub(super) enum PathStyle { |
compiler/rustc_parse/src/parser/stmt.rs+17-17| ... | ... | @@ -1,31 +1,31 @@ |
| 1 | use super::attr::InnerAttrForbiddenReason; | |
| 2 | use super::diagnostics::AttemptLocalParseRecovery; | |
| 3 | use super::expr::LhsExpr; | |
| 4 | use super::pat::{PatternLocation, RecoverComma}; | |
| 5 | use super::path::PathStyle; | |
| 6 | use super::{ | |
| 7 | AttrWrapper, BlockMode, FnParseMode, ForceCollect, Parser, Restrictions, SemiColonMode, | |
| 8 | }; | |
| 9 | use crate::errors; | |
| 10 | use crate::maybe_whole; | |
| 1 | use std::borrow::Cow; | |
| 2 | use std::mem; | |
| 11 | 3 | |
| 12 | use crate::errors::MalformedLoopLabel; | |
| 13 | 4 | use ast::Label; |
| 14 | 5 | use rustc_ast as ast; |
| 15 | 6 | use rustc_ast::ptr::P; |
| 16 | 7 | use rustc_ast::token::{self, Delimiter, TokenKind}; |
| 17 | 8 | use rustc_ast::util::classify::{self, TrailingBrace}; |
| 18 | use rustc_ast::{AttrStyle, AttrVec, LocalKind, MacCall, MacCallStmt, MacStmtStyle}; | |
| 19 | use rustc_ast::{Block, BlockCheckMode, Expr, ExprKind, HasAttrs, Local, Recovered, Stmt}; | |
| 20 | use rustc_ast::{StmtKind, DUMMY_NODE_ID}; | |
| 9 | use rustc_ast::{ | |
| 10 | AttrStyle, AttrVec, Block, BlockCheckMode, Expr, ExprKind, HasAttrs, Local, LocalKind, MacCall, | |
| 11 | MacCallStmt, MacStmtStyle, Recovered, Stmt, StmtKind, DUMMY_NODE_ID, | |
| 12 | }; | |
| 21 | 13 | use rustc_errors::{Applicability, Diag, PResult}; |
| 22 | 14 | use rustc_span::symbol::{kw, sym, Ident}; |
| 23 | 15 | use rustc_span::{BytePos, ErrorGuaranteed, Span}; |
| 24 | ||
| 25 | use std::borrow::Cow; | |
| 26 | use std::mem; | |
| 27 | 16 | use thin_vec::{thin_vec, ThinVec}; |
| 28 | 17 | |
| 18 | use super::attr::InnerAttrForbiddenReason; | |
| 19 | use super::diagnostics::AttemptLocalParseRecovery; | |
| 20 | use super::expr::LhsExpr; | |
| 21 | use super::pat::{PatternLocation, RecoverComma}; | |
| 22 | use super::path::PathStyle; | |
| 23 | use super::{ | |
| 24 | AttrWrapper, BlockMode, FnParseMode, ForceCollect, Parser, Restrictions, SemiColonMode, | |
| 25 | }; | |
| 26 | use crate::errors::MalformedLoopLabel; | |
| 27 | use crate::{errors, maybe_whole}; | |
| 28 | ||
| 29 | 29 | impl<'a> Parser<'a> { |
| 30 | 30 | /// Parses a statement. This stops just before trailing semicolons on everything but items. |
| 31 | 31 | /// e.g., a `StmtKind::Semi` parses to a `StmtKind::Expr`, leaving the trailing `;` unconsumed. |
compiler/rustc_parse/src/parser/tests.rs+11-14| ... | ... | @@ -1,30 +1,27 @@ |
| 1 | use crate::parser::ForceCollect; | |
| 2 | use crate::{ | |
| 3 | new_parser_from_source_str, parser::Parser, source_str_to_stream, unwrap_or_emit_fatal, | |
| 4 | }; | |
| 1 | use std::io::prelude::*; | |
| 2 | use std::iter::Peekable; | |
| 3 | use std::path::{Path, PathBuf}; | |
| 4 | use std::sync::{Arc, Mutex}; | |
| 5 | use std::{io, str}; | |
| 6 | ||
| 5 | 7 | use ast::token::IdentIsRaw; |
| 6 | 8 | use rustc_ast::ptr::P; |
| 7 | 9 | use rustc_ast::token::{self, Delimiter, Token}; |
| 8 | 10 | use rustc_ast::tokenstream::{DelimSpacing, DelimSpan, Spacing, TokenStream, TokenTree}; |
| 9 | use rustc_ast::visit; | |
| 10 | use rustc_ast::{self as ast, PatKind}; | |
| 11 | use rustc_ast::{self as ast, visit, PatKind}; | |
| 11 | 12 | use rustc_ast_pretty::pprust::item_to_string; |
| 12 | 13 | use rustc_data_structures::sync::Lrc; |
| 13 | 14 | use rustc_errors::emitter::HumanEmitter; |
| 14 | 15 | use rustc_errors::{DiagCtxt, MultiSpan, PResult}; |
| 15 | 16 | use rustc_session::parse::ParseSess; |
| 16 | use rustc_span::create_default_session_globals_then; | |
| 17 | 17 | use rustc_span::source_map::{FilePathMapping, SourceMap}; |
| 18 | 18 | use rustc_span::symbol::{kw, sym, Symbol}; |
| 19 | use rustc_span::{BytePos, FileName, Pos, Span}; | |
| 20 | use std::io; | |
| 21 | use std::io::prelude::*; | |
| 22 | use std::iter::Peekable; | |
| 23 | use std::path::{Path, PathBuf}; | |
| 24 | use std::str; | |
| 25 | use std::sync::{Arc, Mutex}; | |
| 19 | use rustc_span::{create_default_session_globals_then, BytePos, FileName, Pos, Span}; | |
| 26 | 20 | use termcolor::WriteColor; |
| 27 | 21 | |
| 22 | use crate::parser::{ForceCollect, Parser}; | |
| 23 | use crate::{new_parser_from_source_str, source_str_to_stream, unwrap_or_emit_fatal}; | |
| 24 | ||
| 28 | 25 | fn psess() -> ParseSess { |
| 29 | 26 | ParseSess::new(vec![crate::DEFAULT_LOCALE_RESOURCE, crate::DEFAULT_LOCALE_RESOURCE]) |
| 30 | 27 | } |
compiler/rustc_parse/src/parser/tokenstream/tests.rs+3-3| ... | ... | @@ -1,8 +1,8 @@ |
| 1 | use crate::parser::tests::string_to_stream; | |
| 2 | 1 | use rustc_ast::token::{self, IdentIsRaw}; |
| 3 | 2 | use rustc_ast::tokenstream::{TokenStream, TokenTree}; |
| 4 | use rustc_span::create_default_session_globals_then; | |
| 5 | use rustc_span::{BytePos, Span, Symbol}; | |
| 3 | use rustc_span::{create_default_session_globals_then, BytePos, Span, Symbol}; | |
| 4 | ||
| 5 | use crate::parser::tests::string_to_stream; | |
| 6 | 6 | |
| 7 | 7 | fn string_to_ts(string: &str) -> TokenStream { |
| 8 | 8 | string_to_stream(string.to_owned()) |
compiler/rustc_parse/src/parser/ty.rs+9-10| ... | ... | @@ -1,13 +1,3 @@ |
| 1 | use super::{Parser, PathStyle, SeqSep, TokenType, Trailing}; | |
| 2 | ||
| 3 | use crate::errors::{ | |
| 4 | self, DynAfterMut, ExpectedFnPathFoundFnKeyword, ExpectedMutOrConstInRawPointerType, | |
| 5 | FnPointerCannotBeAsync, FnPointerCannotBeConst, FnPtrWithGenerics, FnPtrWithGenericsSugg, | |
| 6 | HelpUseLatestEdition, InvalidDynKeyword, LifetimeAfterMut, NeedPlusAfterTraitObjectLifetime, | |
| 7 | NestedCVariadicType, ReturnTypesUseThinArrow, | |
| 8 | }; | |
| 9 | use crate::{maybe_recover_from_interpolated_ty_qpath, maybe_whole}; | |
| 10 | ||
| 11 | 1 | use rustc_ast::ptr::P; |
| 12 | 2 | use rustc_ast::token::{self, BinOpToken, Delimiter, Token, TokenKind}; |
| 13 | 3 | use rustc_ast::util::case::Case; |
| ... | ... | @@ -21,6 +11,15 @@ use rustc_span::symbol::{kw, sym, Ident}; |
| 21 | 11 | use rustc_span::{ErrorGuaranteed, Span, Symbol}; |
| 22 | 12 | use thin_vec::{thin_vec, ThinVec}; |
| 23 | 13 | |
| 14 | use super::{Parser, PathStyle, SeqSep, TokenType, Trailing}; | |
| 15 | use crate::errors::{ | |
| 16 | self, DynAfterMut, ExpectedFnPathFoundFnKeyword, ExpectedMutOrConstInRawPointerType, | |
| 17 | FnPointerCannotBeAsync, FnPointerCannotBeConst, FnPtrWithGenerics, FnPtrWithGenericsSugg, | |
| 18 | HelpUseLatestEdition, InvalidDynKeyword, LifetimeAfterMut, NeedPlusAfterTraitObjectLifetime, | |
| 19 | NestedCVariadicType, ReturnTypesUseThinArrow, | |
| 20 | }; | |
| 21 | use crate::{maybe_recover_from_interpolated_ty_qpath, maybe_whole}; | |
| 22 | ||
| 24 | 23 | /// Signals whether parsing a type should allow `+`. |
| 25 | 24 | /// |
| 26 | 25 | /// For example, let T be the type `impl Default + 'static` |
compiler/rustc_parse/src/validate_attr.rs+2-2| ... | ... | @@ -1,7 +1,5 @@ |
| 1 | 1 | //! Meta-syntax validation logic of attributes for post-expansion. |
| 2 | 2 | |
| 3 | use crate::{errors, parse_in}; | |
| 4 | ||
| 5 | 3 | use rustc_ast::token::Delimiter; |
| 6 | 4 | use rustc_ast::tokenstream::DelimSpan; |
| 7 | 5 | use rustc_ast::{ |
| ... | ... | @@ -18,6 +16,8 @@ use rustc_session::lint::BuiltinLintDiag; |
| 18 | 16 | use rustc_session::parse::ParseSess; |
| 19 | 17 | use rustc_span::{sym, BytePos, Span, Symbol}; |
| 20 | 18 | |
| 19 | use crate::{errors, parse_in}; | |
| 20 | ||
| 21 | 21 | pub fn check_attr(features: &Features, psess: &ParseSess, attr: &Attribute) { |
| 22 | 22 | if attr.is_doc_comment() { |
| 23 | 23 | return; |
compiler/rustc_parse_format/src/lib.rs+2-4| ... | ... | @@ -15,16 +15,14 @@ |
| 15 | 15 | )] |
| 16 | 16 | // tidy-alphabetical-end |
| 17 | 17 | |
| 18 | use std::{iter, str, string}; | |
| 19 | ||
| 18 | 20 | use rustc_lexer::unescape; |
| 19 | 21 | pub use Alignment::*; |
| 20 | 22 | pub use Count::*; |
| 21 | 23 | pub use Piece::*; |
| 22 | 24 | pub use Position::*; |
| 23 | 25 | |
| 24 | use std::iter; | |
| 25 | use std::str; | |
| 26 | use std::string; | |
| 27 | ||
| 28 | 26 | // Note: copied from rustc_span |
| 29 | 27 | /// Range inside of a `Span` used for diagnostics when we only have access to relative positions. |
| 30 | 28 | #[derive(Copy, Clone, PartialEq, Eq, Debug)] |
compiler/rustc_passes/src/check_attr.rs+11-10| ... | ... | @@ -4,20 +4,21 @@ |
| 4 | 4 | //! conflicts between multiple such attributes attached to the same |
| 5 | 5 | //! item. |
| 6 | 6 | |
| 7 | use crate::{errors, fluent_generated as fluent}; | |
| 8 | use rustc_ast::{ast, AttrKind, AttrStyle, Attribute, LitKind}; | |
| 9 | use rustc_ast::{MetaItemKind, MetaItemLit, NestedMetaItem}; | |
| 7 | use std::cell::Cell; | |
| 8 | use std::collections::hash_map::Entry; | |
| 9 | ||
| 10 | use rustc_ast::{ | |
| 11 | ast, AttrKind, AttrStyle, Attribute, LitKind, MetaItemKind, MetaItemLit, NestedMetaItem, | |
| 12 | }; | |
| 10 | 13 | use rustc_data_structures::fx::FxHashMap; |
| 11 | use rustc_errors::{Applicability, IntoDiagArg, MultiSpan}; | |
| 12 | use rustc_errors::{DiagCtxtHandle, StashKey}; | |
| 14 | use rustc_errors::{Applicability, DiagCtxtHandle, IntoDiagArg, MultiSpan, StashKey}; | |
| 13 | 15 | use rustc_feature::{AttributeDuplicates, AttributeType, BuiltinAttribute, BUILTIN_ATTRIBUTE_MAP}; |
| 14 | 16 | use rustc_hir::def_id::LocalModDefId; |
| 15 | 17 | use rustc_hir::intravisit::{self, Visitor}; |
| 16 | use rustc_hir::{self as hir}; | |
| 17 | 18 | use rustc_hir::{ |
| 18 | self, FnSig, ForeignItem, HirId, Item, ItemKind, TraitItem, CRATE_HIR_ID, CRATE_OWNER_ID, | |
| 19 | self as hir, self, FnSig, ForeignItem, HirId, Item, ItemKind, MethodKind, Safety, Target, | |
| 20 | TraitItem, CRATE_HIR_ID, CRATE_OWNER_ID, | |
| 19 | 21 | }; |
| 20 | use rustc_hir::{MethodKind, Safety, Target}; | |
| 21 | 22 | use rustc_macros::LintDiagnostic; |
| 22 | 23 | use rustc_middle::bug; |
| 23 | 24 | use rustc_middle::hir::nested_filter; |
| ... | ... | @@ -37,10 +38,10 @@ use rustc_target::spec::abi::Abi; |
| 37 | 38 | use rustc_trait_selection::error_reporting::InferCtxtErrorExt; |
| 38 | 39 | use rustc_trait_selection::infer::{TyCtxtInferExt, ValuePairs}; |
| 39 | 40 | use rustc_trait_selection::traits::ObligationCtxt; |
| 40 | use std::cell::Cell; | |
| 41 | use std::collections::hash_map::Entry; | |
| 42 | 41 | use tracing::debug; |
| 43 | 42 | |
| 43 | use crate::{errors, fluent_generated as fluent}; | |
| 44 | ||
| 44 | 45 | #[derive(LintDiagnostic)] |
| 45 | 46 | #[diag(passes_diagnostic_diagnostic_on_unimplemented_only_for_traits)] |
| 46 | 47 | struct DiagnosticOnUnimplementedOnlyForTraits; |
compiler/rustc_passes/src/check_const.rs+1-2| ... | ... | @@ -7,8 +7,6 @@ |
| 7 | 7 | //! errors. We still look for those primitives in the MIR const-checker to ensure nothing slips |
| 8 | 8 | //! through, but errors for structured control flow in a `const` should be emitted here. |
| 9 | 9 | |
| 10 | use rustc_attr as attr; | |
| 11 | use rustc_hir as hir; | |
| 12 | 10 | use rustc_hir::def_id::{LocalDefId, LocalModDefId}; |
| 13 | 11 | use rustc_hir::intravisit::{self, Visitor}; |
| 14 | 12 | use rustc_middle::hir::nested_filter; |
| ... | ... | @@ -17,6 +15,7 @@ use rustc_middle::span_bug; |
| 17 | 15 | use rustc_middle::ty::TyCtxt; |
| 18 | 16 | use rustc_session::parse::feature_err; |
| 19 | 17 | use rustc_span::{sym, Span, Symbol}; |
| 18 | use {rustc_attr as attr, rustc_hir as hir}; | |
| 20 | 19 | |
| 21 | 20 | use crate::errors::SkippingConstChecks; |
| 22 | 21 |
compiler/rustc_passes/src/dead.rs+2-1| ... | ... | @@ -3,6 +3,8 @@ |
| 3 | 3 | // expectations such as `#[expect(unused)]` and `#[expect(dead_code)]` is live, and everything else |
| 4 | 4 | // is dead. |
| 5 | 5 | |
| 6 | use std::mem; | |
| 7 | ||
| 6 | 8 | use hir::def_id::{LocalDefIdMap, LocalDefIdSet}; |
| 7 | 9 | use hir::ItemKind; |
| 8 | 10 | use rustc_data_structures::unord::UnordSet; |
| ... | ... | @@ -21,7 +23,6 @@ use rustc_session::lint; |
| 21 | 23 | use rustc_session::lint::builtin::DEAD_CODE; |
| 22 | 24 | use rustc_span::symbol::{sym, Symbol}; |
| 23 | 25 | use rustc_target::abi::FieldIdx; |
| 24 | use std::mem; | |
| 25 | 26 | |
| 26 | 27 | use crate::errors::{ |
| 27 | 28 | ChangeFields, IgnoredDerivedImpls, MultipleDeadCodes, ParentInfo, UselessAssignment, |
compiler/rustc_passes/src/debugger_visualizer.rs+3-5| ... | ... | @@ -3,11 +3,9 @@ |
| 3 | 3 | use rustc_ast::Attribute; |
| 4 | 4 | use rustc_data_structures::sync::Lrc; |
| 5 | 5 | use rustc_expand::base::resolve_path; |
| 6 | use rustc_middle::{ | |
| 7 | middle::debugger_visualizer::{DebuggerVisualizerFile, DebuggerVisualizerType}, | |
| 8 | query::{LocalCrate, Providers}, | |
| 9 | ty::TyCtxt, | |
| 10 | }; | |
| 6 | use rustc_middle::middle::debugger_visualizer::{DebuggerVisualizerFile, DebuggerVisualizerType}; | |
| 7 | use rustc_middle::query::{LocalCrate, Providers}; | |
| 8 | use rustc_middle::ty::TyCtxt; | |
| 11 | 9 | use rustc_session::Session; |
| 12 | 10 | use rustc_span::sym; |
| 13 | 11 |
compiler/rustc_passes/src/diagnostic_items.rs+1-2| ... | ... | @@ -12,8 +12,7 @@ |
| 12 | 12 | use rustc_ast as ast; |
| 13 | 13 | use rustc_hir::diagnostic_items::DiagnosticItems; |
| 14 | 14 | use rustc_hir::OwnerId; |
| 15 | use rustc_middle::query::LocalCrate; | |
| 16 | use rustc_middle::query::Providers; | |
| 15 | use rustc_middle::query::{LocalCrate, Providers}; | |
| 17 | 16 | use rustc_middle::ty::TyCtxt; |
| 18 | 17 | use rustc_span::def_id::{DefId, LOCAL_CRATE}; |
| 19 | 18 | use rustc_span::symbol::{sym, Symbol}; |
compiler/rustc_passes/src/entry.rs+2-2| ... | ... | @@ -6,8 +6,8 @@ use rustc_hir::def_id::{DefId, LocalDefId, CRATE_DEF_ID, LOCAL_CRATE}; |
| 6 | 6 | use rustc_hir::{ItemId, Node, CRATE_HIR_ID}; |
| 7 | 7 | use rustc_middle::query::Providers; |
| 8 | 8 | use rustc_middle::ty::TyCtxt; |
| 9 | use rustc_session::config::{sigpipe, CrateType, EntryFnType}; | |
| 10 | use rustc_session::{config::RemapPathScopeComponents, RemapFileNameExt}; | |
| 9 | use rustc_session::config::{sigpipe, CrateType, EntryFnType, RemapPathScopeComponents}; | |
| 10 | use rustc_session::RemapFileNameExt; | |
| 11 | 11 | use rustc_span::symbol::sym; |
| 12 | 12 | use rustc_span::{Span, Symbol}; |
| 13 | 13 |
compiler/rustc_passes/src/errors.rs+6-7| ... | ... | @@ -1,13 +1,11 @@ |
| 1 | use std::{ | |
| 2 | io::Error, | |
| 3 | path::{Path, PathBuf}, | |
| 4 | }; | |
| 1 | use std::io::Error; | |
| 2 | use std::path::{Path, PathBuf}; | |
| 5 | 3 | |
| 6 | use crate::fluent_generated as fluent; | |
| 7 | 4 | use rustc_ast::Label; |
| 5 | use rustc_errors::codes::*; | |
| 8 | 6 | use rustc_errors::{ |
| 9 | codes::*, Applicability, Diag, DiagCtxtHandle, DiagSymbolList, Diagnostic, EmissionGuarantee, | |
| 10 | Level, MultiSpan, SubdiagMessageOp, Subdiagnostic, | |
| 7 | Applicability, Diag, DiagCtxtHandle, DiagSymbolList, Diagnostic, EmissionGuarantee, Level, | |
| 8 | MultiSpan, SubdiagMessageOp, Subdiagnostic, | |
| 11 | 9 | }; |
| 12 | 10 | use rustc_hir::{self as hir, ExprKind, Target}; |
| 13 | 11 | use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic}; |
| ... | ... | @@ -15,6 +13,7 @@ use rustc_middle::ty::{MainDefinition, Ty}; |
| 15 | 13 | use rustc_span::{Span, Symbol, DUMMY_SP}; |
| 16 | 14 | |
| 17 | 15 | use crate::check_attr::ProcMacroKind; |
| 16 | use crate::fluent_generated as fluent; | |
| 18 | 17 | use crate::lang_items::Duplicate; |
| 19 | 18 | |
| 20 | 19 | #[derive(LintDiagnostic)] |
compiler/rustc_passes/src/hir_stats.rs+2-4| ... | ... | @@ -2,13 +2,11 @@ |
| 2 | 2 | // pieces of AST and HIR. The resulting numbers are good approximations but not |
| 3 | 3 | // completely accurate (some things might be counted twice, others missed). |
| 4 | 4 | |
| 5 | use rustc_ast::visit as ast_visit; | |
| 6 | 5 | use rustc_ast::visit::BoundKind; |
| 7 | use rustc_ast::{self as ast, AttrId, NodeId}; | |
| 6 | use rustc_ast::{self as ast, visit as ast_visit, AttrId, NodeId}; | |
| 8 | 7 | use rustc_data_structures::fx::{FxHashMap, FxHashSet}; |
| 9 | 8 | use rustc_hir as hir; |
| 10 | use rustc_hir::intravisit as hir_visit; | |
| 11 | use rustc_hir::HirId; | |
| 9 | use rustc_hir::{intravisit as hir_visit, HirId}; | |
| 12 | 10 | use rustc_middle::hir::map::Map; |
| 13 | 11 | use rustc_middle::ty::TyCtxt; |
| 14 | 12 | use rustc_middle::util::common::to_readable_str; |
compiler/rustc_passes/src/lang_items.rs+5-6| ... | ... | @@ -7,23 +7,22 @@ |
| 7 | 7 | //! * Traits that represent operators; e.g., `Add`, `Sub`, `Index`. |
| 8 | 8 | //! * Functions called by the compiler itself. |
| 9 | 9 | |
| 10 | use crate::errors::{ | |
| 11 | DuplicateLangItem, IncorrectTarget, LangItemOnIncorrectTarget, UnknownLangItem, | |
| 12 | }; | |
| 13 | use crate::weak_lang_items; | |
| 14 | ||
| 15 | 10 | use rustc_ast as ast; |
| 16 | 11 | use rustc_ast::visit; |
| 17 | 12 | use rustc_data_structures::fx::FxHashMap; |
| 18 | 13 | use rustc_hir::def_id::{DefId, LocalDefId}; |
| 19 | 14 | use rustc_hir::lang_items::{extract, GenericRequirement}; |
| 20 | 15 | use rustc_hir::{LangItem, LanguageItems, MethodKind, Target}; |
| 16 | use rustc_middle::query::Providers; | |
| 21 | 17 | use rustc_middle::ty::{ResolverAstLowering, TyCtxt}; |
| 22 | 18 | use rustc_session::cstore::ExternCrate; |
| 23 | 19 | use rustc_span::symbol::kw::Empty; |
| 24 | 20 | use rustc_span::Span; |
| 25 | 21 | |
| 26 | use rustc_middle::query::Providers; | |
| 22 | use crate::errors::{ | |
| 23 | DuplicateLangItem, IncorrectTarget, LangItemOnIncorrectTarget, UnknownLangItem, | |
| 24 | }; | |
| 25 | use crate::weak_lang_items; | |
| 27 | 26 | |
| 28 | 27 | pub(crate) enum Duplicate { |
| 29 | 28 | Plain, |
compiler/rustc_passes/src/layout_test.rs+2-1| ... | ... | @@ -9,7 +9,8 @@ use rustc_span::symbol::sym; |
| 9 | 9 | use rustc_span::Span; |
| 10 | 10 | use rustc_target::abi::{HasDataLayout, TargetDataLayout}; |
| 11 | 11 | use rustc_trait_selection::error_reporting::InferCtxtErrorExt; |
| 12 | use rustc_trait_selection::{infer::TyCtxtInferExt, traits}; | |
| 12 | use rustc_trait_selection::infer::TyCtxtInferExt; | |
| 13 | use rustc_trait_selection::traits; | |
| 13 | 14 | |
| 14 | 15 | use crate::errors::{ |
| 15 | 16 | LayoutAbi, LayoutAlign, LayoutHomogeneousAggregate, LayoutInvalidAttribute, LayoutOf, |
compiler/rustc_passes/src/liveness.rs+7-7| ... | ... | @@ -81,10 +81,9 @@ |
| 81 | 81 | //! We generate various special nodes for various, well, special purposes. |
| 82 | 82 | //! These are described in the `Liveness` struct. |
| 83 | 83 | |
| 84 | use crate::errors; | |
| 85 | ||
| 86 | use self::LiveNodeKind::*; | |
| 87 | use self::VarKind::*; | |
| 84 | use std::io; | |
| 85 | use std::io::prelude::*; | |
| 86 | use std::rc::Rc; | |
| 88 | 87 | |
| 89 | 88 | use rustc_data_structures::fx::FxIndexMap; |
| 90 | 89 | use rustc_hir as hir; |
| ... | ... | @@ -99,11 +98,12 @@ use rustc_middle::ty::{self, RootVariableMinCaptureList, Ty, TyCtxt}; |
| 99 | 98 | use rustc_session::lint; |
| 100 | 99 | use rustc_span::symbol::{kw, sym, Symbol}; |
| 101 | 100 | use rustc_span::{BytePos, Span}; |
| 102 | use std::io; | |
| 103 | use std::io::prelude::*; | |
| 104 | use std::rc::Rc; | |
| 105 | 101 | use tracing::{debug, instrument}; |
| 106 | 102 | |
| 103 | use self::LiveNodeKind::*; | |
| 104 | use self::VarKind::*; | |
| 105 | use crate::errors; | |
| 106 | ||
| 107 | 107 | mod rwu_table; |
| 108 | 108 | |
| 109 | 109 | rustc_index::newtype_index! { |
compiler/rustc_passes/src/liveness/rwu_table.rs+2-1| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | use crate::liveness::{LiveNode, Variable}; | |
| 2 | 1 | use std::iter; |
| 3 | 2 | |
| 3 | use crate::liveness::{LiveNode, Variable}; | |
| 4 | ||
| 4 | 5 | #[derive(Clone, Copy)] |
| 5 | 6 | pub(super) struct RWU { |
| 6 | 7 | pub(super) reader: bool, |
compiler/rustc_passes/src/loops.rs+1-1| ... | ... | @@ -1,6 +1,5 @@ |
| 1 | 1 | use std::collections::BTreeMap; |
| 2 | 2 | use std::fmt; |
| 3 | use Context::*; | |
| 4 | 3 | |
| 5 | 4 | use rustc_hir as hir; |
| 6 | 5 | use rustc_hir::def_id::{LocalDefId, LocalModDefId}; |
| ... | ... | @@ -13,6 +12,7 @@ use rustc_middle::ty::TyCtxt; |
| 13 | 12 | use rustc_session::Session; |
| 14 | 13 | use rustc_span::hygiene::DesugaringKind; |
| 15 | 14 | use rustc_span::{BytePos, Span}; |
| 15 | use Context::*; | |
| 16 | 16 | |
| 17 | 17 | use crate::errors::{ |
| 18 | 18 | BreakInsideClosure, BreakInsideCoroutine, BreakNonLoop, ContinueLabeledBlock, OutsideLoop, |
compiler/rustc_passes/src/stability.rs+5-3| ... | ... | @@ -1,7 +1,9 @@ |
| 1 | 1 | //! A pass that annotates every item and method with its stability level, |
| 2 | 2 | //! propagating default levels lexically from parent to children ast nodes. |
| 3 | 3 | |
| 4 | use crate::errors; | |
| 4 | use std::mem::replace; | |
| 5 | use std::num::NonZero; | |
| 6 | ||
| 5 | 7 | use rustc_attr::{ |
| 6 | 8 | self as attr, ConstStability, DeprecatedSince, Stability, StabilityLevel, StableSince, |
| 7 | 9 | Unstable, UnstableReason, VERSION_PLACEHOLDER, |
| ... | ... | @@ -25,10 +27,10 @@ use rustc_session::lint::builtin::{INEFFECTIVE_UNSTABLE_TRAIT_IMPL, USELESS_DEPR |
| 25 | 27 | use rustc_span::symbol::{sym, Symbol}; |
| 26 | 28 | use rustc_span::Span; |
| 27 | 29 | use rustc_target::spec::abi::Abi; |
| 28 | use std::mem::replace; | |
| 29 | use std::num::NonZero; | |
| 30 | 30 | use tracing::{debug, info}; |
| 31 | 31 | |
| 32 | use crate::errors; | |
| 33 | ||
| 32 | 34 | #[derive(PartialEq)] |
| 33 | 35 | enum AnnotationKind { |
| 34 | 36 | /// Annotation is required if not inherited from unstable parents. |
compiler/rustc_pattern_analysis/src/constructor.rs+1-3| ... | ... | @@ -180,16 +180,14 @@ use std::cmp::{self, max, min, Ordering}; |
| 180 | 180 | use std::fmt; |
| 181 | 181 | use std::iter::once; |
| 182 | 182 | |
| 183 | use smallvec::SmallVec; | |
| 184 | ||
| 185 | 183 | use rustc_apfloat::ieee::{DoubleS, HalfS, IeeeFloat, QuadS, SingleS}; |
| 186 | 184 | use rustc_index::bit_set::{BitSet, GrowableBitSet}; |
| 187 | 185 | use rustc_index::IndexVec; |
| 186 | use smallvec::SmallVec; | |
| 188 | 187 | |
| 189 | 188 | use self::Constructor::*; |
| 190 | 189 | use self::MaybeInfiniteInt::*; |
| 191 | 190 | use self::SliceKind::*; |
| 192 | ||
| 193 | 191 | use crate::PatCx; |
| 194 | 192 | |
| 195 | 193 | /// Whether we have seen a constructor in the column or not. |
compiler/rustc_pattern_analysis/src/lints.rs+4-3| ... | ... | @@ -1,11 +1,12 @@ |
| 1 | use rustc_session::lint::builtin::NON_EXHAUSTIVE_OMITTED_PATTERNS; | |
| 2 | use rustc_span::ErrorGuaranteed; | |
| 3 | use tracing::instrument; | |
| 4 | ||
| 1 | 5 | use crate::constructor::Constructor; |
| 2 | 6 | use crate::errors::{NonExhaustiveOmittedPattern, NonExhaustiveOmittedPatternLintOnArm, Uncovered}; |
| 3 | 7 | use crate::pat_column::PatternColumn; |
| 4 | 8 | use crate::rustc::{RevealedTy, RustcPatCtxt, WitnessPat}; |
| 5 | 9 | use crate::MatchArm; |
| 6 | use rustc_session::lint::builtin::NON_EXHAUSTIVE_OMITTED_PATTERNS; | |
| 7 | use rustc_span::ErrorGuaranteed; | |
| 8 | use tracing::instrument; | |
| 9 | 10 | |
| 10 | 11 | /// Traverse the patterns to collect any variants of a non_exhaustive enum that fail to be mentioned |
| 11 | 12 | /// in a given column. |
compiler/rustc_pattern_analysis/src/pat.rs+1-2| ... | ... | @@ -5,11 +5,10 @@ use std::fmt; |
| 5 | 5 | |
| 6 | 6 | use smallvec::{smallvec, SmallVec}; |
| 7 | 7 | |
| 8 | use self::Constructor::*; | |
| 8 | 9 | use crate::constructor::{Constructor, Slice, SliceKind}; |
| 9 | 10 | use crate::{PatCx, PrivateUninhabitedField}; |
| 10 | 11 | |
| 11 | use self::Constructor::*; | |
| 12 | ||
| 13 | 12 | /// A globally unique id to distinguish patterns. |
| 14 | 13 | #[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] |
| 15 | 14 | pub(crate) struct PatId(u32); |
compiler/rustc_pattern_analysis/src/rustc.rs+1-2| ... | ... | @@ -17,6 +17,7 @@ use rustc_session::lint; |
| 17 | 17 | use rustc_span::{ErrorGuaranteed, Span, DUMMY_SP}; |
| 18 | 18 | use rustc_target::abi::{FieldIdx, Integer, VariantIdx, FIRST_VARIANT}; |
| 19 | 19 | |
| 20 | use crate::constructor::Constructor::*; | |
| 20 | 21 | use crate::constructor::{ |
| 21 | 22 | IntRange, MaybeInfiniteInt, OpaqueId, RangeEnd, Slice, SliceKind, VariantVisibility, |
| 22 | 23 | }; |
| ... | ... | @@ -25,8 +26,6 @@ use crate::pat_column::PatternColumn; |
| 25 | 26 | use crate::usefulness::{compute_match_usefulness, PlaceValidity}; |
| 26 | 27 | use crate::{errors, Captures, PatCx, PrivateUninhabitedField}; |
| 27 | 28 | |
| 28 | use crate::constructor::Constructor::*; | |
| 29 | ||
| 30 | 29 | // Re-export rustc-specific versions of all these types. |
| 31 | 30 | pub type Constructor<'p, 'tcx> = crate::constructor::Constructor<RustcPatCtxt<'p, 'tcx>>; |
| 32 | 31 | pub type ConstructorSet<'p, 'tcx> = crate::constructor::ConstructorSet<RustcPatCtxt<'p, 'tcx>>; |
compiler/rustc_pattern_analysis/src/usefulness.rs+8-7| ... | ... | @@ -709,18 +709,19 @@ |
| 709 | 709 | //! I (Nadrieril) prefer to put new tests in `ui/pattern/usefulness` unless there's a specific |
| 710 | 710 | //! reason not to, for example if they crucially depend on a particular feature like `or_patterns`. |
| 711 | 711 | |
| 712 | use self::PlaceValidity::*; | |
| 713 | use crate::constructor::{Constructor, ConstructorSet, IntRange}; | |
| 714 | use crate::pat::{DeconstructedPat, PatId, PatOrWild, WitnessPat}; | |
| 715 | use crate::{Captures, MatchArm, PatCx, PrivateUninhabitedField}; | |
| 712 | use std::fmt; | |
| 713 | ||
| 714 | #[cfg(feature = "rustc")] | |
| 715 | use rustc_data_structures::stack::ensure_sufficient_stack; | |
| 716 | 716 | use rustc_hash::{FxHashMap, FxHashSet}; |
| 717 | 717 | use rustc_index::bit_set::BitSet; |
| 718 | 718 | use smallvec::{smallvec, SmallVec}; |
| 719 | use std::fmt; | |
| 720 | 719 | use tracing::{debug, instrument}; |
| 721 | 720 | |
| 722 | #[cfg(feature = "rustc")] | |
| 723 | use rustc_data_structures::stack::ensure_sufficient_stack; | |
| 721 | use self::PlaceValidity::*; | |
| 722 | use crate::constructor::{Constructor, ConstructorSet, IntRange}; | |
| 723 | use crate::pat::{DeconstructedPat, PatId, PatOrWild, WitnessPat}; | |
| 724 | use crate::{Captures, MatchArm, PatCx, PrivateUninhabitedField}; | |
| 724 | 725 | #[cfg(not(feature = "rustc"))] |
| 725 | 726 | pub fn ensure_sufficient_stack<R>(f: impl FnOnce() -> R) -> R { |
| 726 | 727 | f() |
compiler/rustc_pattern_analysis/tests/common/mod.rs+4-6| ... | ... | @@ -1,10 +1,8 @@ |
| 1 | use rustc_pattern_analysis::{ | |
| 2 | constructor::{ | |
| 3 | Constructor, ConstructorSet, IntRange, MaybeInfiniteInt, RangeEnd, VariantVisibility, | |
| 4 | }, | |
| 5 | usefulness::{PlaceValidity, UsefulnessReport}, | |
| 6 | Captures, MatchArm, PatCx, PrivateUninhabitedField, | |
| 1 | use rustc_pattern_analysis::constructor::{ | |
| 2 | Constructor, ConstructorSet, IntRange, MaybeInfiniteInt, RangeEnd, VariantVisibility, | |
| 7 | 3 | }; |
| 4 | use rustc_pattern_analysis::usefulness::{PlaceValidity, UsefulnessReport}; | |
| 5 | use rustc_pattern_analysis::{Captures, MatchArm, PatCx, PrivateUninhabitedField}; | |
| 8 | 6 | |
| 9 | 7 | /// Sets up `tracing` for easier debugging. Tries to look like the `rustc` setup. |
| 10 | 8 | pub fn init_tracing() { |
compiler/rustc_pattern_analysis/tests/complexity.rs+3-1| ... | ... | @@ -1,7 +1,9 @@ |
| 1 | 1 | //! Test the pattern complexity limit. |
| 2 | 2 | |
| 3 | 3 | use common::*; |
| 4 | use rustc_pattern_analysis::{pat::DeconstructedPat, usefulness::PlaceValidity, MatchArm}; | |
| 4 | use rustc_pattern_analysis::pat::DeconstructedPat; | |
| 5 | use rustc_pattern_analysis::usefulness::PlaceValidity; | |
| 6 | use rustc_pattern_analysis::MatchArm; | |
| 5 | 7 | |
| 6 | 8 | #[macro_use] |
| 7 | 9 | mod common; |
compiler/rustc_pattern_analysis/tests/exhaustiveness.rs+3-5| ... | ... | @@ -1,11 +1,9 @@ |
| 1 | 1 | //! Test exhaustiveness checking. |
| 2 | 2 | |
| 3 | 3 | use common::*; |
| 4 | use rustc_pattern_analysis::{ | |
| 5 | pat::{DeconstructedPat, WitnessPat}, | |
| 6 | usefulness::PlaceValidity, | |
| 7 | MatchArm, | |
| 8 | }; | |
| 4 | use rustc_pattern_analysis::pat::{DeconstructedPat, WitnessPat}; | |
| 5 | use rustc_pattern_analysis::usefulness::PlaceValidity; | |
| 6 | use rustc_pattern_analysis::MatchArm; | |
| 9 | 7 | |
| 10 | 8 | #[macro_use] |
| 11 | 9 | mod common; |
compiler/rustc_pattern_analysis/tests/intersection.rs+3-1| ... | ... | @@ -1,7 +1,9 @@ |
| 1 | 1 | //! Test the computation of arm intersections. |
| 2 | 2 | |
| 3 | 3 | use common::*; |
| 4 | use rustc_pattern_analysis::{pat::DeconstructedPat, usefulness::PlaceValidity, MatchArm}; | |
| 4 | use rustc_pattern_analysis::pat::DeconstructedPat; | |
| 5 | use rustc_pattern_analysis::usefulness::PlaceValidity; | |
| 6 | use rustc_pattern_analysis::MatchArm; | |
| 5 | 7 | |
| 6 | 8 | #[macro_use] |
| 7 | 9 | mod common; |
compiler/rustc_privacy/src/errors.rs+2-1| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | use rustc_errors::{codes::*, DiagArgFromDisplay}; | |
| 1 | use rustc_errors::codes::*; | |
| 2 | use rustc_errors::DiagArgFromDisplay; | |
| 2 | 3 | use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic}; |
| 3 | 4 | use rustc_span::{Span, Symbol}; |
| 4 | 5 |
compiler/rustc_privacy/src/lib.rs+14-15| ... | ... | @@ -10,12 +10,19 @@ |
| 10 | 10 | |
| 11 | 11 | mod errors; |
| 12 | 12 | |
| 13 | use std::fmt; | |
| 14 | use std::marker::PhantomData; | |
| 15 | use std::ops::ControlFlow; | |
| 16 | ||
| 17 | use errors::{ | |
| 18 | FieldIsPrivate, FieldIsPrivateLabel, FromPrivateDependencyInPublicInterface, InPublicInterface, | |
| 19 | ItemIsPrivate, PrivateInterfacesOrBoundsLint, ReportEffectiveVisibility, UnnameableTypesLint, | |
| 20 | UnnamedItemIsPrivate, | |
| 21 | }; | |
| 13 | 22 | use rustc_ast::visit::{try_visit, VisitorResult}; |
| 14 | 23 | use rustc_ast::MacroDef; |
| 15 | use rustc_attr as attr; | |
| 16 | 24 | use rustc_data_structures::fx::FxHashSet; |
| 17 | 25 | use rustc_data_structures::intern::Interned; |
| 18 | use rustc_hir as hir; | |
| 19 | 26 | use rustc_hir::def::{DefKind, Res}; |
| 20 | 27 | use rustc_hir::def_id::{DefId, LocalDefId, LocalModDefId, CRATE_DEF_ID}; |
| 21 | 28 | use rustc_hir::intravisit::{self, Visitor}; |
| ... | ... | @@ -23,25 +30,17 @@ use rustc_hir::{AssocItemKind, ForeignItemKind, ItemId, ItemKind, PatKind}; |
| 23 | 30 | use rustc_middle::middle::privacy::{EffectiveVisibilities, EffectiveVisibility, Level}; |
| 24 | 31 | use rustc_middle::query::Providers; |
| 25 | 32 | use rustc_middle::ty::print::PrintTraitRefExt as _; |
| 26 | use rustc_middle::ty::GenericArgs; | |
| 27 | use rustc_middle::ty::{self, Const, GenericParamDefKind}; | |
| 28 | use rustc_middle::ty::{TraitRef, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitor}; | |
| 33 | use rustc_middle::ty::{ | |
| 34 | self, Const, GenericArgs, GenericParamDefKind, TraitRef, Ty, TyCtxt, TypeSuperVisitable, | |
| 35 | TypeVisitable, TypeVisitor, | |
| 36 | }; | |
| 29 | 37 | use rustc_middle::{bug, span_bug}; |
| 30 | 38 | use rustc_session::lint; |
| 31 | 39 | use rustc_span::hygiene::Transparency; |
| 32 | 40 | use rustc_span::symbol::{kw, sym, Ident}; |
| 33 | 41 | use rustc_span::Span; |
| 34 | 42 | use tracing::debug; |
| 35 | ||
| 36 | use std::fmt; | |
| 37 | use std::marker::PhantomData; | |
| 38 | use std::ops::ControlFlow; | |
| 39 | ||
| 40 | use errors::{ | |
| 41 | FieldIsPrivate, FieldIsPrivateLabel, FromPrivateDependencyInPublicInterface, InPublicInterface, | |
| 42 | ItemIsPrivate, PrivateInterfacesOrBoundsLint, ReportEffectiveVisibility, UnnameableTypesLint, | |
| 43 | UnnamedItemIsPrivate, | |
| 44 | }; | |
| 43 | use {rustc_attr as attr, rustc_hir as hir}; | |
| 45 | 44 | |
| 46 | 45 | rustc_fluent_macro::fluent_messages! { "../messages.ftl" } |
| 47 | 46 |
compiler/rustc_query_impl/src/lib.rs+7-8| ... | ... | @@ -10,20 +10,17 @@ |
| 10 | 10 | #![feature(rustdoc_internals)] |
| 11 | 11 | // tidy-alphabetical-end |
| 12 | 12 | |
| 13 | use crate::plumbing::{__rust_begin_short_backtrace, encode_all_query_results, try_mark_green}; | |
| 14 | use crate::profiling_support::QueryKeyStringCache; | |
| 15 | 13 | use field_offset::offset_of; |
| 16 | 14 | use rustc_data_structures::stable_hasher::HashStable; |
| 17 | 15 | use rustc_data_structures::sync::AtomicU64; |
| 18 | 16 | use rustc_middle::arena::Arena; |
| 19 | use rustc_middle::dep_graph::DepNodeIndex; | |
| 20 | use rustc_middle::dep_graph::{self, DepKind, DepKindStruct}; | |
| 17 | use rustc_middle::dep_graph::{self, DepKind, DepKindStruct, DepNodeIndex}; | |
| 21 | 18 | use rustc_middle::query::erase::{erase, restore, Erase}; |
| 22 | 19 | use rustc_middle::query::on_disk_cache::{CacheEncoder, EncodedDepNodeIndex, OnDiskCache}; |
| 23 | 20 | use rustc_middle::query::plumbing::{DynamicQuery, QuerySystem, QuerySystemFns}; |
| 24 | use rustc_middle::query::AsLocalKey; | |
| 25 | 21 | use rustc_middle::query::{ |
| 26 | queries, DynamicQueries, ExternProviders, Providers, QueryCaches, QueryEngine, QueryStates, | |
| 22 | queries, AsLocalKey, DynamicQueries, ExternProviders, Providers, QueryCaches, QueryEngine, | |
| 23 | QueryStates, | |
| 27 | 24 | }; |
| 28 | 25 | use rustc_middle::ty::TyCtxt; |
| 29 | 26 | use rustc_query_system::dep_graph::SerializedDepNodeIndex; |
| ... | ... | @@ -32,10 +29,12 @@ use rustc_query_system::query::{ |
| 32 | 29 | get_query_incr, get_query_non_incr, CycleError, HashResult, QueryCache, QueryConfig, QueryMap, |
| 33 | 30 | QueryMode, QueryState, |
| 34 | 31 | }; |
| 35 | use rustc_query_system::HandleCycleError; | |
| 36 | use rustc_query_system::Value; | |
| 32 | use rustc_query_system::{HandleCycleError, Value}; | |
| 37 | 33 | use rustc_span::{ErrorGuaranteed, Span}; |
| 38 | 34 | |
| 35 | use crate::plumbing::{__rust_begin_short_backtrace, encode_all_query_results, try_mark_green}; | |
| 36 | use crate::profiling_support::QueryKeyStringCache; | |
| 37 | ||
| 39 | 38 | #[macro_use] |
| 40 | 39 | mod plumbing; |
| 41 | 40 | pub use crate::plumbing::{query_key_hash_verify_all, QueryCtxt}; |
compiler/rustc_query_impl/src/plumbing.rs+10-8| ... | ... | @@ -2,19 +2,21 @@ |
| 2 | 2 | //! generate the actual methods on tcx which find and execute the provider, |
| 3 | 3 | //! manage the caches, and so forth. |
| 4 | 4 | |
| 5 | use crate::QueryConfigRestored; | |
| 5 | use std::num::NonZero; | |
| 6 | ||
| 6 | 7 | use rustc_data_structures::stable_hasher::{Hash64, HashStable, StableHasher}; |
| 7 | 8 | use rustc_data_structures::sync::Lock; |
| 8 | 9 | use rustc_data_structures::unord::UnordMap; |
| 9 | 10 | use rustc_errors::DiagInner; |
| 10 | 11 | use rustc_index::Idx; |
| 11 | 12 | use rustc_middle::bug; |
| 12 | use rustc_middle::dep_graph::dep_kinds; | |
| 13 | 13 | use rustc_middle::dep_graph::{ |
| 14 | self, DepContext, DepKind, DepKindStruct, DepNode, DepNodeIndex, SerializedDepNodeIndex, | |
| 14 | self, dep_kinds, DepContext, DepKind, DepKindStruct, DepNode, DepNodeIndex, | |
| 15 | SerializedDepNodeIndex, | |
| 16 | }; | |
| 17 | use rustc_middle::query::on_disk_cache::{ | |
| 18 | AbsoluteBytePos, CacheDecoder, CacheEncoder, EncodedDepNodeIndex, | |
| 15 | 19 | }; |
| 16 | use rustc_middle::query::on_disk_cache::AbsoluteBytePos; | |
| 17 | use rustc_middle::query::on_disk_cache::{CacheDecoder, CacheEncoder, EncodedDepNodeIndex}; | |
| 18 | 20 | use rustc_middle::query::Key; |
| 19 | 21 | use rustc_middle::ty::print::with_reduced_queries; |
| 20 | 22 | use rustc_middle::ty::tls::{self, ImplicitCtxt}; |
| ... | ... | @@ -26,13 +28,13 @@ use rustc_query_system::query::{ |
| 26 | 28 | QueryStackFrame, |
| 27 | 29 | }; |
| 28 | 30 | use rustc_query_system::{LayoutOfDepth, QueryOverflow}; |
| 29 | use rustc_serialize::Decodable; | |
| 30 | use rustc_serialize::Encodable; | |
| 31 | use rustc_serialize::{Decodable, Encodable}; | |
| 31 | 32 | use rustc_session::Limit; |
| 32 | 33 | use rustc_span::def_id::LOCAL_CRATE; |
| 33 | use std::num::NonZero; | |
| 34 | 34 | use thin_vec::ThinVec; |
| 35 | 35 | |
| 36 | use crate::QueryConfigRestored; | |
| 37 | ||
| 36 | 38 | #[derive(Copy, Clone)] |
| 37 | 39 | pub struct QueryCtxt<'tcx> { |
| 38 | 40 | pub tcx: TyCtxt<'tcx>, |
compiler/rustc_query_impl/src/profiling_support.rs+3-2| ... | ... | @@ -1,3 +1,6 @@ |
| 1 | use std::fmt::Debug; | |
| 2 | use std::io::Write; | |
| 3 | ||
| 1 | 4 | use measureme::{StringComponent, StringId}; |
| 2 | 5 | use rustc_data_structures::fx::FxHashMap; |
| 3 | 6 | use rustc_data_structures::profiling::SelfProfiler; |
| ... | ... | @@ -5,8 +8,6 @@ use rustc_hir::def_id::{CrateNum, DefId, DefIndex, LocalDefId, LOCAL_CRATE}; |
| 5 | 8 | use rustc_hir::definitions::DefPathData; |
| 6 | 9 | use rustc_middle::ty::TyCtxt; |
| 7 | 10 | use rustc_query_system::query::QueryCache; |
| 8 | use std::fmt::Debug; | |
| 9 | use std::io::Write; | |
| 10 | 11 | |
| 11 | 12 | pub(crate) struct QueryKeyStringCache { |
| 12 | 13 | def_id_cache: FxHashMap<DefId, StringId>, |
compiler/rustc_query_system/src/cache.rs+2-2| ... | ... | @@ -1,11 +1,11 @@ |
| 1 | 1 | //! Cache for candidate selection. |
| 2 | 2 | |
| 3 | use crate::dep_graph::{DepContext, DepNodeIndex}; | |
| 3 | use std::hash::Hash; | |
| 4 | 4 | |
| 5 | 5 | use rustc_data_structures::fx::FxHashMap; |
| 6 | 6 | use rustc_data_structures::sync::Lock; |
| 7 | 7 | |
| 8 | use std::hash::Hash; | |
| 8 | use crate::dep_graph::{DepContext, DepNodeIndex}; | |
| 9 | 9 | |
| 10 | 10 | pub struct Cache<Key, Value> { |
| 11 | 11 | hashmap: Lock<FxHashMap<Key, WithDepNode<Value>>>, |
compiler/rustc_query_system/src/dep_graph/debug.rs+4-2| ... | ... | @@ -1,9 +1,11 @@ |
| 1 | 1 | //! Code for debugging the dep-graph. |
| 2 | 2 | |
| 3 | use super::{DepNode, DepNodeIndex}; | |
| 3 | use std::error::Error; | |
| 4 | ||
| 4 | 5 | use rustc_data_structures::fx::FxHashMap; |
| 5 | 6 | use rustc_data_structures::sync::Lock; |
| 6 | use std::error::Error; | |
| 7 | ||
| 8 | use super::{DepNode, DepNodeIndex}; | |
| 7 | 9 | |
| 8 | 10 | /// A dep-node filter goes from a user-defined string to a query over |
| 9 | 11 | /// nodes. Right now the format is like this: |
compiler/rustc_query_system/src/dep_graph/dep_node.rs+7-5| ... | ... | @@ -42,16 +42,17 @@ |
| 42 | 42 | //! `DefId` it was computed from. In other cases, too much information gets |
| 43 | 43 | //! lost during fingerprint computation. |
| 44 | 44 | |
| 45 | use super::{DepContext, FingerprintStyle}; | |
| 46 | use crate::ich::StableHashingContext; | |
| 45 | use std::fmt; | |
| 46 | use std::hash::Hash; | |
| 47 | 47 | |
| 48 | 48 | use rustc_data_structures::fingerprint::{Fingerprint, PackedFingerprint}; |
| 49 | 49 | use rustc_data_structures::stable_hasher::{HashStable, StableHasher, StableOrd, ToStableHashKey}; |
| 50 | 50 | use rustc_data_structures::AtomicRef; |
| 51 | 51 | use rustc_hir::definitions::DefPathHash; |
| 52 | 52 | use rustc_macros::{Decodable, Encodable}; |
| 53 | use std::fmt; | |
| 54 | use std::hash::Hash; | |
| 53 | ||
| 54 | use super::{DepContext, FingerprintStyle}; | |
| 55 | use crate::ich::StableHashingContext; | |
| 55 | 56 | |
| 56 | 57 | /// This serves as an index into arrays built by `make_dep_kind_array`. |
| 57 | 58 | #[derive(Clone, Copy, PartialEq, Eq, Hash)] |
| ... | ... | @@ -312,8 +313,9 @@ impl StableOrd for WorkProductId { |
| 312 | 313 | // Some types are used a lot. Make sure they don't unintentionally get bigger. |
| 313 | 314 | #[cfg(target_pointer_width = "64")] |
| 314 | 315 | mod size_asserts { |
| 315 | use super::*; | |
| 316 | 316 | use rustc_data_structures::static_assert_size; |
| 317 | ||
| 318 | use super::*; | |
| 317 | 319 | // tidy-alphabetical-start |
| 318 | 320 | static_assert_size!(DepKind, 2); |
| 319 | 321 | #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] |
compiler/rustc_query_system/src/dep_graph/edges.rs+4-2| ... | ... | @@ -1,8 +1,10 @@ |
| 1 | use crate::dep_graph::DepNodeIndex; | |
| 2 | use smallvec::SmallVec; | |
| 3 | 1 | use std::hash::{Hash, Hasher}; |
| 4 | 2 | use std::ops::Deref; |
| 5 | 3 | |
| 4 | use smallvec::SmallVec; | |
| 5 | ||
| 6 | use crate::dep_graph::DepNodeIndex; | |
| 7 | ||
| 6 | 8 | #[derive(Default, Debug)] |
| 7 | 9 | pub(crate) struct EdgesVec { |
| 8 | 10 | max: u32, |
compiler/rustc_query_system/src/dep_graph/graph.rs+10-10| ... | ... | @@ -1,3 +1,11 @@ |
| 1 | use std::assert_matches::assert_matches; | |
| 2 | use std::collections::hash_map::Entry; | |
| 3 | use std::fmt::Debug; | |
| 4 | use std::hash::Hash; | |
| 5 | use std::marker::PhantomData; | |
| 6 | use std::sync::atomic::Ordering; | |
| 7 | use std::sync::Arc; | |
| 8 | ||
| 1 | 9 | use rustc_data_structures::fingerprint::Fingerprint; |
| 2 | 10 | use rustc_data_structures::fx::{FxHashMap, FxHashSet}; |
| 3 | 11 | use rustc_data_structures::profiling::{QueryInvocationId, SelfProfilerRef}; |
| ... | ... | @@ -8,14 +16,9 @@ use rustc_data_structures::unord::UnordMap; |
| 8 | 16 | use rustc_index::IndexVec; |
| 9 | 17 | use rustc_macros::{Decodable, Encodable}; |
| 10 | 18 | use rustc_serialize::opaque::{FileEncodeResult, FileEncoder}; |
| 11 | use std::assert_matches::assert_matches; | |
| 12 | use std::collections::hash_map::Entry; | |
| 13 | use std::fmt::Debug; | |
| 14 | use std::hash::Hash; | |
| 15 | use std::marker::PhantomData; | |
| 16 | use std::sync::atomic::Ordering; | |
| 17 | use std::sync::Arc; | |
| 18 | 19 | use tracing::{debug, instrument}; |
| 20 | #[cfg(debug_assertions)] | |
| 21 | use {super::debug::EdgeFilter, std::env}; | |
| 19 | 22 | |
| 20 | 23 | use super::query::DepGraphQuery; |
| 21 | 24 | use super::serialized::{GraphEncoder, SerializedDepGraph, SerializedDepNodeIndex}; |
| ... | ... | @@ -24,9 +27,6 @@ use crate::dep_graph::edges::EdgesVec; |
| 24 | 27 | use crate::ich::StableHashingContext; |
| 25 | 28 | use crate::query::{QueryContext, QuerySideEffects}; |
| 26 | 29 | |
| 27 | #[cfg(debug_assertions)] | |
| 28 | use {super::debug::EdgeFilter, std::env}; | |
| 29 | ||
| 30 | 30 | #[derive(Clone)] |
| 31 | 31 | pub struct DepGraph<D: Deps> { |
| 32 | 32 | data: Option<Lrc<DepGraphData<D>>>, |
compiler/rustc_query_system/src/dep_graph/mod.rs+5-4| ... | ... | @@ -5,18 +5,19 @@ mod graph; |
| 5 | 5 | mod query; |
| 6 | 6 | mod serialized; |
| 7 | 7 | |
| 8 | use std::panic; | |
| 9 | ||
| 8 | 10 | pub use dep_node::{DepKind, DepKindStruct, DepNode, DepNodeParams, WorkProductId}; |
| 9 | 11 | pub(crate) use graph::DepGraphData; |
| 10 | 12 | pub use graph::{hash_result, DepGraph, DepNodeIndex, TaskDepsRef, WorkProduct, WorkProductMap}; |
| 11 | 13 | pub use query::DepGraphQuery; |
| 14 | use rustc_data_structures::profiling::SelfProfilerRef; | |
| 15 | use rustc_session::Session; | |
| 12 | 16 | pub use serialized::{SerializedDepGraph, SerializedDepNodeIndex}; |
| 17 | use tracing::instrument; | |
| 13 | 18 | |
| 14 | 19 | use self::graph::{print_markframe_trace, MarkFrame}; |
| 15 | 20 | use crate::ich::StableHashingContext; |
| 16 | use rustc_data_structures::profiling::SelfProfilerRef; | |
| 17 | use rustc_session::Session; | |
| 18 | use std::panic; | |
| 19 | use tracing::instrument; | |
| 20 | 21 | |
| 21 | 22 | pub trait DepContext: Copy { |
| 22 | 23 | type Deps: Deps; |
compiler/rustc_query_system/src/dep_graph/serialized.rs+9-8| ... | ... | @@ -35,11 +35,11 @@ |
| 35 | 35 | //! If the number of edges in this node does not fit in the bits available in the header, we |
| 36 | 36 | //! store it directly after the header with leb128. |
| 37 | 37 | |
| 38 | use super::query::DepGraphQuery; | |
| 39 | use super::{DepKind, DepNode, DepNodeIndex, Deps}; | |
| 40 | use crate::dep_graph::edges::EdgesVec; | |
| 41 | use rustc_data_structures::fingerprint::Fingerprint; | |
| 42 | use rustc_data_structures::fingerprint::PackedFingerprint; | |
| 38 | use std::iter; | |
| 39 | use std::marker::PhantomData; | |
| 40 | use std::sync::Arc; | |
| 41 | ||
| 42 | use rustc_data_structures::fingerprint::{Fingerprint, PackedFingerprint}; | |
| 43 | 43 | use rustc_data_structures::fx::FxHashMap; |
| 44 | 44 | use rustc_data_structures::outline; |
| 45 | 45 | use rustc_data_structures::profiling::SelfProfilerRef; |
| ... | ... | @@ -48,11 +48,12 @@ use rustc_data_structures::unhash::UnhashMap; |
| 48 | 48 | use rustc_index::{Idx, IndexVec}; |
| 49 | 49 | use rustc_serialize::opaque::{FileEncodeResult, FileEncoder, IntEncodedWithFixedSize, MemDecoder}; |
| 50 | 50 | use rustc_serialize::{Decodable, Decoder, Encodable, Encoder}; |
| 51 | use std::iter; | |
| 52 | use std::marker::PhantomData; | |
| 53 | use std::sync::Arc; | |
| 54 | 51 | use tracing::{debug, instrument}; |
| 55 | 52 | |
| 53 | use super::query::DepGraphQuery; | |
| 54 | use super::{DepKind, DepNode, DepNodeIndex, Deps}; | |
| 55 | use crate::dep_graph::edges::EdgesVec; | |
| 56 | ||
| 56 | 57 | // The maximum value of `SerializedDepNodeIndex` leaves the upper two bits |
| 57 | 58 | // unused so that we can store multiple index types in `CompressedHybridIndex`, |
| 58 | 59 | // and use those bits to encode which index type it contains. |
compiler/rustc_query_system/src/ich/hcx.rs+2-2| ... | ... | @@ -1,5 +1,3 @@ |
| 1 | use crate::ich; | |
| 2 | ||
| 3 | 1 | use rustc_ast as ast; |
| 4 | 2 | use rustc_data_structures::stable_hasher::{HashStable, HashingControls, StableHasher}; |
| 5 | 3 | use rustc_data_structures::sync::Lrc; |
| ... | ... | @@ -11,6 +9,8 @@ use rustc_span::source_map::SourceMap; |
| 11 | 9 | use rustc_span::symbol::Symbol; |
| 12 | 10 | use rustc_span::{BytePos, CachingSourceMapView, SourceFile, Span, SpanData, DUMMY_SP}; |
| 13 | 11 | |
| 12 | use crate::ich; | |
| 13 | ||
| 14 | 14 | /// This is the context state available during incr. comp. hashing. It contains |
| 15 | 15 | /// enough information to transform `DefId`s and `HirId`s into stable `DefPath`s (i.e., |
| 16 | 16 | /// a reference to the `TyCtxt`) and it holds a few caches for speeding up various |
compiler/rustc_query_system/src/ich/impls_syntax.rs+3-3| ... | ... | @@ -1,15 +1,15 @@ |
| 1 | 1 | //! This module contains `HashStable` implementations for various data types |
| 2 | 2 | //! from `rustc_ast` in no particular order. |
| 3 | 3 | |
| 4 | use crate::ich::StableHashingContext; | |
| 4 | use std::assert_matches::assert_matches; | |
| 5 | 5 | |
| 6 | 6 | use rustc_ast as ast; |
| 7 | 7 | use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; |
| 8 | 8 | use rustc_span::SourceFile; |
| 9 | use std::assert_matches::assert_matches; | |
| 10 | ||
| 11 | 9 | use smallvec::SmallVec; |
| 12 | 10 | |
| 11 | use crate::ich::StableHashingContext; | |
| 12 | ||
| 13 | 13 | impl<'ctx> rustc_target::HashStableContext for StableHashingContext<'ctx> {} |
| 14 | 14 | |
| 15 | 15 | impl<'a> HashStable<StableHashingContext<'a>> for [ast::Attribute] { |
compiler/rustc_query_system/src/ich/mod.rs+2-1| ... | ... | @@ -1,8 +1,9 @@ |
| 1 | 1 | //! ICH - Incremental Compilation Hash |
| 2 | 2 | |
| 3 | pub use self::hcx::StableHashingContext; | |
| 4 | 3 | use rustc_span::symbol::{sym, Symbol}; |
| 5 | 4 | |
| 5 | pub use self::hcx::StableHashingContext; | |
| 6 | ||
| 6 | 7 | mod hcx; |
| 7 | 8 | mod impls_syntax; |
| 8 | 9 |
compiler/rustc_query_system/src/lib.rs+1-3| ... | ... | @@ -14,9 +14,7 @@ pub mod ich; |
| 14 | 14 | pub mod query; |
| 15 | 15 | mod values; |
| 16 | 16 | |
| 17 | pub use error::HandleCycleError; | |
| 18 | pub use error::LayoutOfDepth; | |
| 19 | pub use error::QueryOverflow; | |
| 17 | pub use error::{HandleCycleError, LayoutOfDepth, QueryOverflow}; | |
| 20 | 18 | pub use values::Value; |
| 21 | 19 | |
| 22 | 20 | rustc_fluent_macro::fluent_messages! { "../messages.ftl" } |
compiler/rustc_query_system/src/query/caches.rs+5-5| ... | ... | @@ -1,14 +1,14 @@ |
| 1 | use crate::dep_graph::DepNodeIndex; | |
| 1 | use std::fmt::Debug; | |
| 2 | use std::hash::Hash; | |
| 2 | 3 | |
| 3 | 4 | use rustc_data_structures::fx::FxHashMap; |
| 4 | 5 | use rustc_data_structures::sharded::{self, Sharded}; |
| 5 | 6 | use rustc_data_structures::sync::{Lock, OnceLock}; |
| 6 | 7 | use rustc_hir::def_id::LOCAL_CRATE; |
| 7 | 8 | use rustc_index::{Idx, IndexVec}; |
| 8 | use rustc_span::def_id::DefId; | |
| 9 | use rustc_span::def_id::DefIndex; | |
| 10 | use std::fmt::Debug; | |
| 11 | use std::hash::Hash; | |
| 9 | use rustc_span::def_id::{DefId, DefIndex}; | |
| 10 | ||
| 11 | use crate::dep_graph::DepNodeIndex; | |
| 12 | 12 | |
| 13 | 13 | pub trait QueryCache: Sized { |
| 14 | 14 | type Key: Hash + Eq + Copy + Debug; |
compiler/rustc_query_system/src/query/config.rs+7-7| ... | ... | @@ -1,16 +1,16 @@ |
| 1 | 1 | //! Query configuration and description traits. |
| 2 | 2 | |
| 3 | use std::fmt::Debug; | |
| 4 | use std::hash::Hash; | |
| 5 | ||
| 6 | use rustc_data_structures::fingerprint::Fingerprint; | |
| 7 | use rustc_span::ErrorGuaranteed; | |
| 8 | ||
| 3 | 9 | use crate::dep_graph::{DepKind, DepNode, DepNodeParams, SerializedDepNodeIndex}; |
| 4 | 10 | use crate::error::HandleCycleError; |
| 5 | 11 | use crate::ich::StableHashingContext; |
| 6 | 12 | use crate::query::caches::QueryCache; |
| 7 | use crate::query::DepNodeIndex; | |
| 8 | use crate::query::{CycleError, QueryContext, QueryState}; | |
| 9 | ||
| 10 | use rustc_data_structures::fingerprint::Fingerprint; | |
| 11 | use rustc_span::ErrorGuaranteed; | |
| 12 | use std::fmt::Debug; | |
| 13 | use std::hash::Hash; | |
| 13 | use crate::query::{CycleError, DepNodeIndex, QueryContext, QueryState}; | |
| 14 | 14 | |
| 15 | 15 | pub type HashResult<V> = Option<fn(&mut StableHashingContext<'_>, &V) -> Fingerprint>; |
| 16 | 16 |
compiler/rustc_query_system/src/query/job.rs+9-10| ... | ... | @@ -1,18 +1,12 @@ |
| 1 | use crate::dep_graph::DepContext; | |
| 2 | use crate::error::CycleStack; | |
| 3 | use crate::query::plumbing::CycleError; | |
| 4 | use crate::query::DepKind; | |
| 5 | use crate::query::{QueryContext, QueryStackFrame}; | |
| 1 | use std::hash::Hash; | |
| 2 | use std::io::Write; | |
| 3 | use std::num::NonZero; | |
| 4 | ||
| 6 | 5 | use rustc_data_structures::fx::FxHashMap; |
| 7 | 6 | use rustc_errors::{Diag, DiagCtxtHandle}; |
| 8 | 7 | use rustc_hir::def::DefKind; |
| 9 | 8 | use rustc_session::Session; |
| 10 | 9 | use rustc_span::Span; |
| 11 | ||
| 12 | use std::hash::Hash; | |
| 13 | use std::io::Write; | |
| 14 | use std::num::NonZero; | |
| 15 | ||
| 16 | 10 | #[cfg(parallel_compiler)] |
| 17 | 11 | use { |
| 18 | 12 | parking_lot::{Condvar, Mutex}, |
| ... | ... | @@ -23,6 +17,11 @@ use { |
| 23 | 17 | std::sync::Arc, |
| 24 | 18 | }; |
| 25 | 19 | |
| 20 | use crate::dep_graph::DepContext; | |
| 21 | use crate::error::CycleStack; | |
| 22 | use crate::query::plumbing::CycleError; | |
| 23 | use crate::query::{DepKind, QueryContext, QueryStackFrame}; | |
| 24 | ||
| 26 | 25 | /// Represents a span and a query key. |
| 27 | 26 | #[derive(Clone, Debug)] |
| 28 | 27 | pub struct QueryInfo { |
compiler/rustc_query_system/src/query/mod.rs+3-4| ... | ... | @@ -12,10 +12,6 @@ mod caches; |
| 12 | 12 | pub use self::caches::{DefIdCache, DefaultCache, QueryCache, SingleCache, VecCache}; |
| 13 | 13 | |
| 14 | 14 | mod config; |
| 15 | pub use self::config::{HashResult, QueryConfig}; | |
| 16 | ||
| 17 | use crate::dep_graph::DepKind; | |
| 18 | use crate::dep_graph::{DepNodeIndex, HasDepContext, SerializedDepNodeIndex}; | |
| 19 | 15 | use rustc_data_structures::stable_hasher::Hash64; |
| 20 | 16 | use rustc_data_structures::sync::Lock; |
| 21 | 17 | use rustc_errors::DiagInner; |
| ... | ... | @@ -25,6 +21,9 @@ use rustc_span::def_id::DefId; |
| 25 | 21 | use rustc_span::Span; |
| 26 | 22 | use thin_vec::ThinVec; |
| 27 | 23 | |
| 24 | pub use self::config::{HashResult, QueryConfig}; | |
| 25 | use crate::dep_graph::{DepKind, DepNodeIndex, HasDepContext, SerializedDepNodeIndex}; | |
| 26 | ||
| 28 | 27 | /// Description of a frame in the query stack. |
| 29 | 28 | /// |
| 30 | 29 | /// This is mostly used in case of cycles for error reporting. |
compiler/rustc_query_system/src/query/plumbing.rs+16-15| ... | ... | @@ -2,16 +2,12 @@ |
| 2 | 2 | //! generate the actual methods on tcx which find and execute the provider, |
| 3 | 3 | //! manage the caches, and so forth. |
| 4 | 4 | |
| 5 | use crate::dep_graph::DepGraphData; | |
| 6 | use crate::dep_graph::{DepContext, DepNode, DepNodeIndex, DepNodeParams}; | |
| 7 | use crate::ich::StableHashingContext; | |
| 8 | use crate::query::caches::QueryCache; | |
| 9 | #[cfg(parallel_compiler)] | |
| 10 | use crate::query::job::QueryLatch; | |
| 11 | use crate::query::job::{report_cycle, QueryInfo, QueryJob, QueryJobId, QueryJobInfo}; | |
| 12 | use crate::query::SerializedDepNodeIndex; | |
| 13 | use crate::query::{QueryContext, QueryMap, QuerySideEffects, QueryStackFrame}; | |
| 14 | use crate::HandleCycleError; | |
| 5 | use std::cell::Cell; | |
| 6 | use std::collections::hash_map::Entry; | |
| 7 | use std::fmt::Debug; | |
| 8 | use std::hash::Hash; | |
| 9 | use std::mem; | |
| 10 | ||
| 15 | 11 | use rustc_data_structures::fingerprint::Fingerprint; |
| 16 | 12 | use rustc_data_structures::fx::FxHashMap; |
| 17 | 13 | use rustc_data_structures::sharded::Sharded; |
| ... | ... | @@ -21,15 +17,20 @@ use rustc_data_structures::sync::Lock; |
| 21 | 17 | use rustc_data_structures::{outline, sync}; |
| 22 | 18 | use rustc_errors::{Diag, FatalError, StashKey}; |
| 23 | 19 | use rustc_span::{Span, DUMMY_SP}; |
| 24 | use std::cell::Cell; | |
| 25 | use std::collections::hash_map::Entry; | |
| 26 | use std::fmt::Debug; | |
| 27 | use std::hash::Hash; | |
| 28 | use std::mem; | |
| 29 | 20 | use thin_vec::ThinVec; |
| 30 | 21 | use tracing::instrument; |
| 31 | 22 | |
| 32 | 23 | use super::QueryConfig; |
| 24 | use crate::dep_graph::{DepContext, DepGraphData, DepNode, DepNodeIndex, DepNodeParams}; | |
| 25 | use crate::ich::StableHashingContext; | |
| 26 | use crate::query::caches::QueryCache; | |
| 27 | #[cfg(parallel_compiler)] | |
| 28 | use crate::query::job::QueryLatch; | |
| 29 | use crate::query::job::{report_cycle, QueryInfo, QueryJob, QueryJobId, QueryJobInfo}; | |
| 30 | use crate::query::{ | |
| 31 | QueryContext, QueryMap, QuerySideEffects, QueryStackFrame, SerializedDepNodeIndex, | |
| 32 | }; | |
| 33 | use crate::HandleCycleError; | |
| 33 | 34 | |
| 34 | 35 | pub struct QueryState<K> { |
| 35 | 36 | active: Sharded<FxHashMap<K, QueryResult>>, |
compiler/rustc_resolve/src/build_reduced_graph.rs+15-13| ... | ... | @@ -5,18 +5,13 @@ |
| 5 | 5 | //! unexpanded macros in the fragment are visited and registered. |
| 6 | 6 | //! Imports are also considered items and placed into modules here, but not resolved yet. |
| 7 | 7 | |
| 8 | use crate::def_collector::collect_definitions; | |
| 9 | use crate::imports::{ImportData, ImportKind}; | |
| 10 | use crate::macros::{MacroRulesBinding, MacroRulesScope, MacroRulesScopeRef}; | |
| 11 | use crate::Namespace::{MacroNS, TypeNS, ValueNS}; | |
| 12 | use crate::{errors, BindingKey, MacroData, NameBindingData}; | |
| 13 | use crate::{Determinacy, ExternPreludeEntry, Finalize, Module, ModuleKind, ModuleOrUniformRoot}; | |
| 14 | use crate::{NameBinding, NameBindingKind, ParentScope, PathResult, ResolutionError}; | |
| 15 | use crate::{Resolver, ResolverArenas, Segment, ToNameBinding, Used, VisResolutionError}; | |
| 8 | use std::cell::Cell; | |
| 16 | 9 | |
| 17 | 10 | use rustc_ast::visit::{self, AssocCtxt, Visitor, WalkItemKind}; |
| 18 | use rustc_ast::{self as ast, AssocItem, AssocItemKind, MetaItemKind, StmtKind}; | |
| 19 | use rustc_ast::{Block, ForeignItem, ForeignItemKind, Impl, Item, ItemKind, NodeId}; | |
| 11 | use rustc_ast::{ | |
| 12 | self as ast, AssocItem, AssocItemKind, Block, ForeignItem, ForeignItemKind, Impl, Item, | |
| 13 | ItemKind, MetaItemKind, NodeId, StmtKind, | |
| 14 | }; | |
| 20 | 15 | use rustc_attr as attr; |
| 21 | 16 | use rustc_data_structures::sync::Lrc; |
| 22 | 17 | use rustc_expand::base::ResolverExpand; |
| ... | ... | @@ -30,11 +25,18 @@ use rustc_middle::{bug, ty}; |
| 30 | 25 | use rustc_span::hygiene::{ExpnId, LocalExpnId, MacroKind}; |
| 31 | 26 | use rustc_span::symbol::{kw, sym, Ident, Symbol}; |
| 32 | 27 | use rustc_span::Span; |
| 33 | ||
| 34 | use std::cell::Cell; | |
| 35 | ||
| 36 | 28 | use tracing::debug; |
| 37 | 29 | |
| 30 | use crate::def_collector::collect_definitions; | |
| 31 | use crate::imports::{ImportData, ImportKind}; | |
| 32 | use crate::macros::{MacroRulesBinding, MacroRulesScope, MacroRulesScopeRef}; | |
| 33 | use crate::Namespace::{MacroNS, TypeNS, ValueNS}; | |
| 34 | use crate::{ | |
| 35 | errors, BindingKey, Determinacy, ExternPreludeEntry, Finalize, MacroData, Module, ModuleKind, | |
| 36 | ModuleOrUniformRoot, NameBinding, NameBindingData, NameBindingKind, ParentScope, PathResult, | |
| 37 | ResolutionError, Resolver, ResolverArenas, Segment, ToNameBinding, Used, VisResolutionError, | |
| 38 | }; | |
| 39 | ||
| 38 | 40 | type Res = def::Res<NodeId>; |
| 39 | 41 | |
| 40 | 42 | impl<'a, Id: Into<DefId>> ToNameBinding<'a> |
compiler/rustc_resolve/src/check_unused.rs+6-7| ... | ... | @@ -23,23 +23,22 @@ |
| 23 | 23 | // - `check_unused` finally emits the diagnostics based on the data generated |
| 24 | 24 | // in the last step |
| 25 | 25 | |
| 26 | use crate::imports::{Import, ImportKind}; | |
| 27 | use crate::module_to_string; | |
| 28 | use crate::Resolver; | |
| 29 | ||
| 30 | use crate::{LexicalScopeBinding, NameBindingKind}; | |
| 31 | 26 | use rustc_ast as ast; |
| 32 | 27 | use rustc_ast::visit::{self, Visitor}; |
| 33 | 28 | use rustc_data_structures::fx::{FxHashMap, FxIndexMap, FxIndexSet}; |
| 34 | 29 | use rustc_data_structures::unord::UnordSet; |
| 35 | 30 | use rustc_errors::MultiSpan; |
| 36 | 31 | use rustc_hir::def::{DefKind, Res}; |
| 37 | use rustc_session::lint::builtin::{MACRO_USE_EXTERN_CRATE, UNUSED_EXTERN_CRATES}; | |
| 38 | use rustc_session::lint::builtin::{UNUSED_IMPORTS, UNUSED_QUALIFICATIONS}; | |
| 32 | use rustc_session::lint::builtin::{ | |
| 33 | MACRO_USE_EXTERN_CRATE, UNUSED_EXTERN_CRATES, UNUSED_IMPORTS, UNUSED_QUALIFICATIONS, | |
| 34 | }; | |
| 39 | 35 | use rustc_session::lint::BuiltinLintDiag; |
| 40 | 36 | use rustc_span::symbol::{kw, Ident}; |
| 41 | 37 | use rustc_span::{Span, DUMMY_SP}; |
| 42 | 38 | |
| 39 | use crate::imports::{Import, ImportKind}; | |
| 40 | use crate::{module_to_string, LexicalScopeBinding, NameBindingKind, Resolver}; | |
| 41 | ||
| 43 | 42 | struct UnusedImport { |
| 44 | 43 | use_tree: ast::UseTree, |
| 45 | 44 | use_tree_id: ast::NodeId, |
compiler/rustc_resolve/src/def_collector.rs+4-2| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | use crate::{ImplTraitContext, Resolver}; | |
| 1 | use std::mem; | |
| 2 | ||
| 2 | 3 | use rustc_ast::visit::FnKind; |
| 3 | 4 | use rustc_ast::*; |
| 4 | 5 | use rustc_expand::expand::AstFragment; |
| ... | ... | @@ -8,9 +9,10 @@ use rustc_hir::def_id::LocalDefId; |
| 8 | 9 | use rustc_span::hygiene::LocalExpnId; |
| 9 | 10 | use rustc_span::symbol::{kw, sym, Symbol}; |
| 10 | 11 | use rustc_span::Span; |
| 11 | use std::mem; | |
| 12 | 12 | use tracing::debug; |
| 13 | 13 | |
| 14 | use crate::{ImplTraitContext, Resolver}; | |
| 15 | ||
| 14 | 16 | pub(crate) fn collect_definitions( |
| 15 | 17 | resolver: &mut Resolver<'_, '_>, |
| 16 | 18 | fragment: &AstFragment, |
compiler/rustc_resolve/src/diagnostics.rs+17-13| ... | ... | @@ -1,12 +1,15 @@ |
| 1 | 1 | use rustc_ast::expand::StrippedCfgItem; |
| 2 | 2 | use rustc_ast::ptr::P; |
| 3 | 3 | use rustc_ast::visit::{self, Visitor}; |
| 4 | use rustc_ast::{self as ast, Crate, ItemKind, ModKind, NodeId, Path, CRATE_NODE_ID}; | |
| 5 | use rustc_ast::{MetaItemKind, NestedMetaItem}; | |
| 4 | use rustc_ast::{ | |
| 5 | self as ast, Crate, ItemKind, MetaItemKind, ModKind, NestedMetaItem, NodeId, Path, | |
| 6 | CRATE_NODE_ID, | |
| 7 | }; | |
| 6 | 8 | use rustc_ast_pretty::pprust; |
| 7 | 9 | use rustc_data_structures::fx::FxHashSet; |
| 10 | use rustc_errors::codes::*; | |
| 8 | 11 | use rustc_errors::{ |
| 9 | codes::*, report_ambiguity_error, struct_span_code_err, Applicability, Diag, DiagCtxtHandle, | |
| 12 | report_ambiguity_error, struct_span_code_err, Applicability, Diag, DiagCtxtHandle, | |
| 10 | 13 | ErrorGuaranteed, MultiSpan, SuggestionStyle, |
| 11 | 14 | }; |
| 12 | 15 | use rustc_feature::BUILTIN_ATTRIBUTES; |
| ... | ... | @@ -16,9 +19,10 @@ use rustc_hir::def_id::{DefId, CRATE_DEF_ID}; |
| 16 | 19 | use rustc_hir::PrimTy; |
| 17 | 20 | use rustc_middle::bug; |
| 18 | 21 | use rustc_middle::ty::TyCtxt; |
| 19 | use rustc_session::lint::builtin::ABSOLUTE_PATHS_NOT_STARTING_WITH_CRATE; | |
| 20 | use rustc_session::lint::builtin::AMBIGUOUS_GLOB_IMPORTS; | |
| 21 | use rustc_session::lint::builtin::MACRO_EXPANDED_MACRO_EXPORTS_ACCESSED_BY_ABSOLUTE_PATHS; | |
| 22 | use rustc_session::lint::builtin::{ | |
| 23 | ABSOLUTE_PATHS_NOT_STARTING_WITH_CRATE, AMBIGUOUS_GLOB_IMPORTS, | |
| 24 | MACRO_EXPANDED_MACRO_EXPORTS_ACCESSED_BY_ABSOLUTE_PATHS, | |
| 25 | }; | |
| 22 | 26 | use rustc_session::lint::{AmbiguityErrorDiag, BuiltinLintDiag}; |
| 23 | 27 | use rustc_session::Session; |
| 24 | 28 | use rustc_span::edit_distance::find_best_match_for_name; |
| ... | ... | @@ -36,13 +40,13 @@ use crate::errors::{ |
| 36 | 40 | }; |
| 37 | 41 | use crate::imports::{Import, ImportKind}; |
| 38 | 42 | use crate::late::{PatternSource, Rib}; |
| 39 | use crate::{errors as errs, BindingKey}; | |
| 40 | use crate::{path_names_to_string, Used}; | |
| 41 | use crate::{AmbiguityError, AmbiguityErrorMisc, AmbiguityKind, BindingError, Finalize}; | |
| 42 | use crate::{HasGenericParams, MacroRulesScope, Module, ModuleKind, ModuleOrUniformRoot}; | |
| 43 | use crate::{LexicalScopeBinding, NameBinding, NameBindingKind, PrivacyError, VisResolutionError}; | |
| 44 | use crate::{ParentScope, PathResult, ResolutionError, Resolver, Scope, ScopeSet}; | |
| 45 | use crate::{Segment, UseError}; | |
| 43 | use crate::{ | |
| 44 | errors as errs, path_names_to_string, AmbiguityError, AmbiguityErrorMisc, AmbiguityKind, | |
| 45 | BindingError, BindingKey, Finalize, HasGenericParams, LexicalScopeBinding, MacroRulesScope, | |
| 46 | Module, ModuleKind, ModuleOrUniformRoot, NameBinding, NameBindingKind, ParentScope, PathResult, | |
| 47 | PrivacyError, ResolutionError, Resolver, Scope, ScopeSet, Segment, UseError, Used, | |
| 48 | VisResolutionError, | |
| 49 | }; | |
| 46 | 50 | |
| 47 | 51 | type Res = def::Res<ast::NodeId>; |
| 48 | 52 |
compiler/rustc_resolve/src/effective_visibilities.rs+7-10| ... | ... | @@ -1,18 +1,15 @@ |
| 1 | use crate::{NameBinding, NameBindingKind, Resolver}; | |
| 2 | use rustc_ast::ast; | |
| 3 | use rustc_ast::visit; | |
| 1 | use std::mem; | |
| 2 | ||
| 4 | 3 | use rustc_ast::visit::Visitor; |
| 5 | use rustc_ast::Crate; | |
| 6 | use rustc_ast::EnumDef; | |
| 4 | use rustc_ast::{ast, visit, Crate, EnumDef}; | |
| 7 | 5 | use rustc_data_structures::fx::FxHashSet; |
| 8 | use rustc_hir::def_id::LocalDefId; | |
| 9 | use rustc_hir::def_id::CRATE_DEF_ID; | |
| 10 | use rustc_middle::middle::privacy::Level; | |
| 11 | use rustc_middle::middle::privacy::{EffectiveVisibilities, EffectiveVisibility}; | |
| 6 | use rustc_hir::def_id::{LocalDefId, CRATE_DEF_ID}; | |
| 7 | use rustc_middle::middle::privacy::{EffectiveVisibilities, EffectiveVisibility, Level}; | |
| 12 | 8 | use rustc_middle::ty::Visibility; |
| 13 | use std::mem; | |
| 14 | 9 | use tracing::info; |
| 15 | 10 | |
| 11 | use crate::{NameBinding, NameBindingKind, Resolver}; | |
| 12 | ||
| 16 | 13 | #[derive(Clone, Copy)] |
| 17 | 14 | enum ParentId<'a> { |
| 18 | 15 | Def(LocalDefId), |
compiler/rustc_resolve/src/errors.rs+6-6| ... | ... | @@ -1,11 +1,11 @@ |
| 1 | use rustc_errors::{codes::*, Applicability, ElidedLifetimeInPathSubdiag, MultiSpan}; | |
| 1 | use rustc_errors::codes::*; | |
| 2 | use rustc_errors::{Applicability, ElidedLifetimeInPathSubdiag, MultiSpan}; | |
| 2 | 3 | use rustc_macros::{Diagnostic, Subdiagnostic}; |
| 3 | use rustc_span::{ | |
| 4 | symbol::{Ident, Symbol}, | |
| 5 | Span, | |
| 6 | }; | |
| 4 | use rustc_span::symbol::{Ident, Symbol}; | |
| 5 | use rustc_span::Span; | |
| 7 | 6 | |
| 8 | use crate::{late::PatternSource, Res}; | |
| 7 | use crate::late::PatternSource; | |
| 8 | use crate::Res; | |
| 9 | 9 | |
| 10 | 10 | #[derive(Diagnostic)] |
| 11 | 11 | #[diag(resolve_generic_params_from_outer_item, code = E0401)] |
compiler/rustc_resolve/src/ident.rs+10-12| ... | ... | @@ -1,29 +1,27 @@ |
| 1 | 1 | use rustc_ast::{self as ast, NodeId}; |
| 2 | 2 | use rustc_errors::ErrorGuaranteed; |
| 3 | 3 | use rustc_hir::def::{DefKind, Namespace, NonMacroAttrKind, PartialRes, PerNS}; |
| 4 | use rustc_middle::bug; | |
| 5 | use rustc_middle::ty; | |
| 4 | use rustc_middle::{bug, ty}; | |
| 6 | 5 | use rustc_session::lint::builtin::PROC_MACRO_DERIVE_RESOLUTION_FALLBACK; |
| 7 | 6 | use rustc_session::lint::BuiltinLintDiag; |
| 8 | 7 | use rustc_session::parse::feature_err; |
| 9 | 8 | use rustc_span::def_id::LocalDefId; |
| 10 | 9 | use rustc_span::hygiene::{ExpnId, ExpnKind, LocalExpnId, MacroKind, SyntaxContext}; |
| 11 | use rustc_span::sym; | |
| 12 | 10 | use rustc_span::symbol::{kw, Ident}; |
| 13 | use rustc_span::Span; | |
| 11 | use rustc_span::{sym, Span}; | |
| 14 | 12 | use tracing::{debug, instrument}; |
| 13 | use Determinacy::*; | |
| 14 | use Namespace::*; | |
| 15 | 15 | |
| 16 | 16 | use crate::errors::{ParamKindInEnumDiscriminant, ParamKindInNonTrivialAnonConst}; |
| 17 | 17 | use crate::late::{ConstantHasGenerics, NoConstantGenericsReason, PathSource, Rib, RibKind}; |
| 18 | 18 | use crate::macros::{sub_namespace_match, MacroRulesScope}; |
| 19 | use crate::{errors, AmbiguityError, AmbiguityErrorMisc, AmbiguityKind, Determinacy, Finalize}; | |
| 20 | use crate::{BindingKey, Used}; | |
| 21 | use crate::{ImportKind, LexicalScopeBinding, Module, ModuleKind, ModuleOrUniformRoot}; | |
| 22 | use crate::{NameBinding, NameBindingKind, ParentScope, PathResult, PrivacyError, Res}; | |
| 23 | use crate::{ResolutionError, Resolver, Scope, ScopeSet, Segment, ToNameBinding, Weak}; | |
| 24 | ||
| 25 | use Determinacy::*; | |
| 26 | use Namespace::*; | |
| 19 | use crate::{ | |
| 20 | errors, AmbiguityError, AmbiguityErrorMisc, AmbiguityKind, BindingKey, Determinacy, Finalize, | |
| 21 | ImportKind, LexicalScopeBinding, Module, ModuleKind, ModuleOrUniformRoot, NameBinding, | |
| 22 | NameBindingKind, ParentScope, PathResult, PrivacyError, Res, ResolutionError, Resolver, Scope, | |
| 23 | ScopeSet, Segment, ToNameBinding, Used, Weak, | |
| 24 | }; | |
| 27 | 25 | |
| 28 | 26 | type Visibility = ty::Visibility<LocalDefId>; |
| 29 | 27 |
compiler/rustc_resolve/src/imports.rs+20-20| ... | ... | @@ -1,29 +1,17 @@ |
| 1 | 1 | //! A bunch of methods and structures more or less related to resolving imports. |
| 2 | 2 | |
| 3 | use crate::diagnostics::{import_candidates, DiagMode, Suggestion}; | |
| 4 | use crate::errors::{ | |
| 5 | CannotBeReexportedCratePublic, CannotBeReexportedCratePublicNS, CannotBeReexportedPrivate, | |
| 6 | CannotBeReexportedPrivateNS, CannotDetermineImportResolution, CannotGlobImportAllCrates, | |
| 7 | ConsiderAddingMacroExport, ConsiderMarkingAsPub, IsNotDirectlyImportable, | |
| 8 | ItemsInTraitsAreNotImportable, | |
| 9 | }; | |
| 10 | use crate::Determinacy::{self, *}; | |
| 11 | use crate::{module_to_string, names_to_string, ImportSuggestion}; | |
| 12 | use crate::{AmbiguityError, Namespace::*}; | |
| 13 | use crate::{AmbiguityKind, BindingKey, ResolutionError, Resolver, Segment}; | |
| 14 | use crate::{Finalize, Module, ModuleOrUniformRoot, ParentScope, PerNS, ScopeSet}; | |
| 15 | use crate::{NameBinding, NameBindingData, NameBindingKind, PathResult, Used}; | |
| 3 | use std::cell::Cell; | |
| 4 | use std::mem; | |
| 16 | 5 | |
| 17 | 6 | use rustc_ast::NodeId; |
| 18 | 7 | use rustc_data_structures::fx::FxHashSet; |
| 19 | 8 | use rustc_data_structures::intern::Interned; |
| 20 | use rustc_errors::{codes::*, pluralize, struct_span_code_err, Applicability, MultiSpan}; | |
| 9 | use rustc_errors::codes::*; | |
| 10 | use rustc_errors::{pluralize, struct_span_code_err, Applicability, MultiSpan}; | |
| 21 | 11 | use rustc_hir::def::{self, DefKind, PartialRes}; |
| 22 | 12 | use rustc_hir::def_id::DefId; |
| 23 | use rustc_middle::metadata::ModChild; | |
| 24 | use rustc_middle::metadata::Reexport; | |
| 25 | use rustc_middle::span_bug; | |
| 26 | use rustc_middle::ty; | |
| 13 | use rustc_middle::metadata::{ModChild, Reexport}; | |
| 14 | use rustc_middle::{span_bug, ty}; | |
| 27 | 15 | use rustc_session::lint::builtin::{ |
| 28 | 16 | AMBIGUOUS_GLOB_REEXPORTS, HIDDEN_GLOB_REEXPORTS, PUB_USE_OF_PRIVATE_EXTERN_CRATE, |
| 29 | 17 | UNUSED_IMPORTS, |
| ... | ... | @@ -36,8 +24,20 @@ use rustc_span::Span; |
| 36 | 24 | use smallvec::SmallVec; |
| 37 | 25 | use tracing::debug; |
| 38 | 26 | |
| 39 | use std::cell::Cell; | |
| 40 | use std::mem; | |
| 27 | use crate::diagnostics::{import_candidates, DiagMode, Suggestion}; | |
| 28 | use crate::errors::{ | |
| 29 | CannotBeReexportedCratePublic, CannotBeReexportedCratePublicNS, CannotBeReexportedPrivate, | |
| 30 | CannotBeReexportedPrivateNS, CannotDetermineImportResolution, CannotGlobImportAllCrates, | |
| 31 | ConsiderAddingMacroExport, ConsiderMarkingAsPub, IsNotDirectlyImportable, | |
| 32 | ItemsInTraitsAreNotImportable, | |
| 33 | }; | |
| 34 | use crate::Determinacy::{self, *}; | |
| 35 | use crate::Namespace::*; | |
| 36 | use crate::{ | |
| 37 | module_to_string, names_to_string, AmbiguityError, AmbiguityKind, BindingKey, Finalize, | |
| 38 | ImportSuggestion, Module, ModuleOrUniformRoot, NameBinding, NameBindingData, NameBindingKind, | |
| 39 | ParentScope, PathResult, PerNS, ResolutionError, Resolver, ScopeSet, Segment, Used, | |
| 40 | }; | |
| 41 | 41 | |
| 42 | 42 | type Res = def::Res<NodeId>; |
| 43 | 43 |
compiler/rustc_resolve/src/late.rs+12-9| ... | ... | @@ -6,16 +6,18 @@ |
| 6 | 6 | //! If you wonder why there's no `early.rs`, that's because it's split into three files - |
| 7 | 7 | //! `build_reduced_graph.rs`, `macros.rs` and `imports.rs`. |
| 8 | 8 | |
| 9 | use crate::{errors, path_names_to_string, rustdoc, BindingError, Finalize, LexicalScopeBinding}; | |
| 10 | use crate::{BindingKey, Used}; | |
| 11 | use crate::{Module, ModuleOrUniformRoot, NameBinding, ParentScope, PathResult}; | |
| 12 | use crate::{ResolutionError, Resolver, Segment, TyCtxt, UseError}; | |
| 9 | use std::assert_matches::debug_assert_matches; | |
| 10 | use std::borrow::Cow; | |
| 11 | use std::collections::hash_map::Entry; | |
| 12 | use std::collections::BTreeSet; | |
| 13 | use std::mem::{replace, swap, take}; | |
| 13 | 14 | |
| 14 | 15 | use rustc_ast::ptr::P; |
| 15 | 16 | use rustc_ast::visit::{visit_opt, walk_list, AssocCtxt, BoundKind, FnCtxt, FnKind, Visitor}; |
| 16 | 17 | use rustc_ast::*; |
| 17 | 18 | use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap}; |
| 18 | use rustc_errors::{codes::*, Applicability, DiagArgValue, IntoDiagArg, StashKey}; | |
| 19 | use rustc_errors::codes::*; | |
| 20 | use rustc_errors::{Applicability, DiagArgValue, IntoDiagArg, StashKey}; | |
| 19 | 21 | use rustc_hir::def::Namespace::{self, *}; |
| 20 | 22 | use rustc_hir::def::{self, CtorKind, DefKind, LifetimeRes, NonMacroAttrKind, PartialRes, PerNS}; |
| 21 | 23 | use rustc_hir::def_id::{DefId, LocalDefId, CRATE_DEF_ID, LOCAL_CRATE}; |
| ... | ... | @@ -32,10 +34,11 @@ use rustc_span::{BytePos, Span, SyntaxContext}; |
| 32 | 34 | use smallvec::{smallvec, SmallVec}; |
| 33 | 35 | use tracing::{debug, instrument, trace}; |
| 34 | 36 | |
| 35 | use std::assert_matches::debug_assert_matches; | |
| 36 | use std::borrow::Cow; | |
| 37 | use std::collections::{hash_map::Entry, BTreeSet}; | |
| 38 | use std::mem::{replace, swap, take}; | |
| 37 | use crate::{ | |
| 38 | errors, path_names_to_string, rustdoc, BindingError, BindingKey, Finalize, LexicalScopeBinding, | |
| 39 | Module, ModuleOrUniformRoot, NameBinding, ParentScope, PathResult, ResolutionError, Resolver, | |
| 40 | Segment, TyCtxt, UseError, Used, | |
| 41 | }; | |
| 39 | 42 | |
| 40 | 43 | mod diagnostics; |
| 41 | 44 |
compiler/rustc_resolve/src/late/diagnostics.rs+19-20| ... | ... | @@ -1,13 +1,8 @@ |
| 1 | 1 | // ignore-tidy-filelength |
| 2 | 2 | |
| 3 | use crate::diagnostics::{ImportSuggestion, LabelSuggestion, TypoSuggestion}; | |
| 4 | use crate::late::{AliasPossibility, LateResolutionVisitor, RibKind}; | |
| 5 | use crate::late::{LifetimeBinderKind, LifetimeRes, LifetimeRibKind, LifetimeUseSet}; | |
| 6 | use crate::ty::fast_reject::SimplifiedType; | |
| 7 | use crate::{errors, path_names_to_string}; | |
| 8 | use crate::{Module, ModuleKind, ModuleOrUniformRoot}; | |
| 9 | use crate::{PathResult, PathSource, Segment}; | |
| 10 | use rustc_hir::def::Namespace::{self, *}; | |
| 3 | use std::borrow::Cow; | |
| 4 | use std::iter; | |
| 5 | use std::ops::Deref; | |
| 11 | 6 | |
| 12 | 7 | use rustc_ast::ptr::P; |
| 13 | 8 | use rustc_ast::visit::{walk_ty, FnCtxt, FnKind, LifetimeCtxt, Visitor}; |
| ... | ... | @@ -16,34 +11,38 @@ use rustc_ast::{ |
| 16 | 11 | MethodCall, NodeId, Path, Ty, TyKind, DUMMY_NODE_ID, |
| 17 | 12 | }; |
| 18 | 13 | use rustc_ast_pretty::pprust::where_bound_predicate_to_string; |
| 19 | use rustc_data_structures::fx::FxHashSet; | |
| 20 | use rustc_data_structures::fx::FxIndexSet; | |
| 14 | use rustc_data_structures::fx::{FxHashSet, FxIndexSet}; | |
| 15 | use rustc_errors::codes::*; | |
| 21 | 16 | use rustc_errors::{ |
| 22 | codes::*, pluralize, struct_span_code_err, Applicability, Diag, ErrorGuaranteed, MultiSpan, | |
| 17 | pluralize, struct_span_code_err, Applicability, Diag, ErrorGuaranteed, MultiSpan, | |
| 23 | 18 | SuggestionStyle, |
| 24 | 19 | }; |
| 25 | 20 | use rustc_hir as hir; |
| 21 | use rustc_hir::def::Namespace::{self, *}; | |
| 26 | 22 | use rustc_hir::def::{self, CtorKind, CtorOf, DefKind}; |
| 27 | 23 | use rustc_hir::def_id::{DefId, CRATE_DEF_ID}; |
| 28 | 24 | use rustc_hir::{MissingLifetimeKind, PrimTy}; |
| 29 | use rustc_session::lint; | |
| 30 | use rustc_session::Session; | |
| 25 | use rustc_middle::ty; | |
| 26 | use rustc_session::{lint, Session}; | |
| 31 | 27 | use rustc_span::edit_distance::find_best_match_for_name; |
| 32 | 28 | use rustc_span::edition::Edition; |
| 33 | 29 | use rustc_span::hygiene::MacroKind; |
| 34 | 30 | use rustc_span::symbol::{kw, sym, Ident, Symbol}; |
| 35 | 31 | use rustc_span::{Span, DUMMY_SP}; |
| 36 | ||
| 37 | use rustc_middle::ty; | |
| 38 | ||
| 39 | use std::borrow::Cow; | |
| 40 | use std::iter; | |
| 41 | use std::ops::Deref; | |
| 42 | ||
| 43 | 32 | use thin_vec::ThinVec; |
| 44 | 33 | use tracing::debug; |
| 45 | 34 | |
| 46 | 35 | use super::NoConstantGenericsReason; |
| 36 | use crate::diagnostics::{ImportSuggestion, LabelSuggestion, TypoSuggestion}; | |
| 37 | use crate::late::{ | |
| 38 | AliasPossibility, LateResolutionVisitor, LifetimeBinderKind, LifetimeRes, LifetimeRibKind, | |
| 39 | LifetimeUseSet, RibKind, | |
| 40 | }; | |
| 41 | use crate::ty::fast_reject::SimplifiedType; | |
| 42 | use crate::{ | |
| 43 | errors, path_names_to_string, Module, ModuleKind, ModuleOrUniformRoot, PathResult, PathSource, | |
| 44 | Segment, | |
| 45 | }; | |
| 47 | 46 | |
| 48 | 47 | type Res = def::Res<ast::NodeId>; |
| 49 | 48 |
compiler/rustc_resolve/src/lib.rs+24-20| ... | ... | @@ -23,11 +23,25 @@ |
| 23 | 23 | #![feature(rustdoc_internals)] |
| 24 | 24 | // tidy-alphabetical-end |
| 25 | 25 | |
| 26 | use std::cell::{Cell, RefCell}; | |
| 27 | use std::collections::BTreeSet; | |
| 28 | use std::fmt; | |
| 29 | ||
| 30 | use diagnostics::{ImportSuggestion, LabelSuggestion, Suggestion}; | |
| 31 | use effective_visibilities::EffectiveVisibilitiesVisitor; | |
| 32 | use errors::{ | |
| 33 | ParamKindInEnumDiscriminant, ParamKindInNonTrivialAnonConst, ParamKindInTyOfConstParam, | |
| 34 | }; | |
| 35 | use imports::{Import, ImportData, ImportKind, NameResolution}; | |
| 36 | use late::{HasGenericParams, PathSource, PatternSource, UnnecessaryQualification}; | |
| 37 | use macros::{MacroRulesBinding, MacroRulesScope, MacroRulesScopeRef}; | |
| 26 | 38 | use rustc_arena::{DroplessArena, TypedArena}; |
| 27 | 39 | use rustc_ast::expand::StrippedCfgItem; |
| 28 | 40 | use rustc_ast::node_id::NodeMap; |
| 29 | use rustc_ast::{self as ast, attr, NodeId, CRATE_NODE_ID}; | |
| 30 | use rustc_ast::{AngleBracketedArg, Crate, Expr, ExprKind, GenericArg, GenericArgs, LitKind, Path}; | |
| 41 | use rustc_ast::{ | |
| 42 | self as ast, attr, AngleBracketedArg, Crate, Expr, ExprKind, GenericArg, GenericArgs, LitKind, | |
| 43 | NodeId, Path, CRATE_NODE_ID, | |
| 44 | }; | |
| 31 | 45 | use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap, FxIndexSet}; |
| 32 | 46 | use rustc_data_structures::intern::Interned; |
| 33 | 47 | use rustc_data_structures::steal::Steal; |
| ... | ... | @@ -36,10 +50,10 @@ use rustc_errors::{Applicability, Diag, ErrCode, ErrorGuaranteed}; |
| 36 | 50 | use rustc_expand::base::{DeriveResolution, SyntaxExtension, SyntaxExtensionKind}; |
| 37 | 51 | use rustc_feature::BUILTIN_ATTRIBUTES; |
| 38 | 52 | use rustc_hir::def::Namespace::{self, *}; |
| 39 | use rustc_hir::def::NonMacroAttrKind; | |
| 40 | use rustc_hir::def::{self, CtorOf, DefKind, DocLinkResMap, LifetimeRes, PartialRes, PerNS}; | |
| 41 | use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, LocalDefIdMap}; | |
| 42 | use rustc_hir::def_id::{CRATE_DEF_ID, LOCAL_CRATE}; | |
| 53 | use rustc_hir::def::{ | |
| 54 | self, CtorOf, DefKind, DocLinkResMap, LifetimeRes, NonMacroAttrKind, PartialRes, PerNS, | |
| 55 | }; | |
| 56 | use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, LocalDefIdMap, CRATE_DEF_ID, LOCAL_CRATE}; | |
| 43 | 57 | use rustc_hir::{PrimTy, TraitCandidate}; |
| 44 | 58 | use rustc_index::IndexVec; |
| 45 | 59 | use rustc_metadata::creader::{CStore, CrateLoader}; |
| ... | ... | @@ -47,8 +61,10 @@ use rustc_middle::metadata::ModChild; |
| 47 | 61 | use rustc_middle::middle::privacy::EffectiveVisibilities; |
| 48 | 62 | use rustc_middle::query::Providers; |
| 49 | 63 | use rustc_middle::span_bug; |
| 50 | use rustc_middle::ty::{self, DelegationFnSig, Feed, MainDefinition, RegisteredTools}; | |
| 51 | use rustc_middle::ty::{ResolverGlobalCtxt, ResolverOutputs, TyCtxt, TyCtxtFeed}; | |
| 64 | use rustc_middle::ty::{ | |
| 65 | self, DelegationFnSig, Feed, MainDefinition, RegisteredTools, ResolverGlobalCtxt, | |
| 66 | ResolverOutputs, TyCtxt, TyCtxtFeed, | |
| 67 | }; | |
| 52 | 68 | use rustc_query_system::ich::StableHashingContext; |
| 53 | 69 | use rustc_session::lint::builtin::PRIVATE_MACRO_USE; |
| 54 | 70 | use rustc_session::lint::{BuiltinLintDiag, LintBuffer}; |
| ... | ... | @@ -56,20 +72,8 @@ use rustc_span::hygiene::{ExpnId, LocalExpnId, MacroKind, SyntaxContext, Transpa |
| 56 | 72 | use rustc_span::symbol::{kw, sym, Ident, Symbol}; |
| 57 | 73 | use rustc_span::{Span, DUMMY_SP}; |
| 58 | 74 | use smallvec::{smallvec, SmallVec}; |
| 59 | use std::cell::{Cell, RefCell}; | |
| 60 | use std::collections::BTreeSet; | |
| 61 | use std::fmt; | |
| 62 | 75 | use tracing::debug; |
| 63 | 76 | |
| 64 | use diagnostics::{ImportSuggestion, LabelSuggestion, Suggestion}; | |
| 65 | use effective_visibilities::EffectiveVisibilitiesVisitor; | |
| 66 | use errors::{ | |
| 67 | ParamKindInEnumDiscriminant, ParamKindInNonTrivialAnonConst, ParamKindInTyOfConstParam, | |
| 68 | }; | |
| 69 | use imports::{Import, ImportData, ImportKind, NameResolution}; | |
| 70 | use late::{HasGenericParams, PathSource, PatternSource, UnnecessaryQualification}; | |
| 71 | use macros::{MacroRulesBinding, MacroRulesScope, MacroRulesScopeRef}; | |
| 72 | ||
| 73 | 77 | type Res = def::Res<NodeId>; |
| 74 | 78 | |
| 75 | 79 | mod build_reduced_graph; |
compiler/rustc_resolve/src/macros.rs+20-15| ... | ... | @@ -1,13 +1,9 @@ |
| 1 | 1 | //! A bunch of methods and structures more or less related to resolving macros and |
| 2 | 2 | //! interface provided by `Resolver` to macro expander. |
| 3 | 3 | |
| 4 | use crate::errors::CannotDetermineMacroResolution; | |
| 5 | use crate::errors::{self, AddAsNonDerive, CannotFindIdentInThisScope}; | |
| 6 | use crate::errors::{MacroExpectedFound, RemoveSurroundingDerive}; | |
| 7 | use crate::Namespace::*; | |
| 8 | use crate::{BindingKey, BuiltinMacroState, Determinacy, MacroData, NameBindingKind, Used}; | |
| 9 | use crate::{DeriveData, Finalize, ParentScope, ResolutionError, Resolver, ScopeSet}; | |
| 10 | use crate::{ModuleKind, ModuleOrUniformRoot, NameBinding, PathResult, Segment, ToNameBinding}; | |
| 4 | use std::cell::Cell; | |
| 5 | use std::mem; | |
| 6 | ||
| 11 | 7 | use rustc_ast::expand::StrippedCfgItem; |
| 12 | 8 | use rustc_ast::{self as ast, attr, Crate, Inline, ItemKind, ModKind, NodeId}; |
| 13 | 9 | use rustc_ast_pretty::pprust; |
| ... | ... | @@ -15,8 +11,10 @@ use rustc_attr::StabilityLevel; |
| 15 | 11 | use rustc_data_structures::intern::Interned; |
| 16 | 12 | use rustc_data_structures::sync::Lrc; |
| 17 | 13 | use rustc_errors::{Applicability, StashKey}; |
| 18 | use rustc_expand::base::{Annotatable, DeriveResolution, Indeterminate, ResolverExpand}; | |
| 19 | use rustc_expand::base::{SyntaxExtension, SyntaxExtensionKind}; | |
| 14 | use rustc_expand::base::{ | |
| 15 | Annotatable, DeriveResolution, Indeterminate, ResolverExpand, SyntaxExtension, | |
| 16 | SyntaxExtensionKind, | |
| 17 | }; | |
| 20 | 18 | use rustc_expand::compile_declarative_macro; |
| 21 | 19 | use rustc_expand::expand::{ |
| 22 | 20 | AstFragment, AstFragmentKind, Invocation, InvocationKind, SupportsMacroExpansion, |
| ... | ... | @@ -24,8 +22,7 @@ use rustc_expand::expand::{ |
| 24 | 22 | use rustc_hir::def::{self, DefKind, Namespace, NonMacroAttrKind}; |
| 25 | 23 | use rustc_hir::def_id::{CrateNum, DefId, LocalDefId}; |
| 26 | 24 | use rustc_middle::middle::stability; |
| 27 | use rustc_middle::ty::RegisteredTools; | |
| 28 | use rustc_middle::ty::{TyCtxt, Visibility}; | |
| 25 | use rustc_middle::ty::{RegisteredTools, TyCtxt, Visibility}; | |
| 29 | 26 | use rustc_session::lint::builtin::{ |
| 30 | 27 | LEGACY_DERIVE_HELPERS, OUT_OF_SCOPE_MACRO_CALLS, SOFT_UNSTABLE, |
| 31 | 28 | UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES, UNUSED_MACROS, UNUSED_MACRO_RULES, |
| ... | ... | @@ -34,12 +31,20 @@ use rustc_session::lint::BuiltinLintDiag; |
| 34 | 31 | use rustc_session::parse::feature_err; |
| 35 | 32 | use rustc_span::edit_distance::edit_distance; |
| 36 | 33 | use rustc_span::edition::Edition; |
| 37 | use rustc_span::hygiene::{self, ExpnData, ExpnKind, LocalExpnId}; | |
| 38 | use rustc_span::hygiene::{AstPass, MacroKind}; | |
| 34 | use rustc_span::hygiene::{self, AstPass, ExpnData, ExpnKind, LocalExpnId, MacroKind}; | |
| 39 | 35 | use rustc_span::symbol::{kw, sym, Ident, Symbol}; |
| 40 | 36 | use rustc_span::{Span, DUMMY_SP}; |
| 41 | use std::cell::Cell; | |
| 42 | use std::mem; | |
| 37 | ||
| 38 | use crate::errors::{ | |
| 39 | self, AddAsNonDerive, CannotDetermineMacroResolution, CannotFindIdentInThisScope, | |
| 40 | MacroExpectedFound, RemoveSurroundingDerive, | |
| 41 | }; | |
| 42 | use crate::Namespace::*; | |
| 43 | use crate::{ | |
| 44 | BindingKey, BuiltinMacroState, DeriveData, Determinacy, Finalize, MacroData, ModuleKind, | |
| 45 | ModuleOrUniformRoot, NameBinding, NameBindingKind, ParentScope, PathResult, ResolutionError, | |
| 46 | Resolver, ScopeSet, Segment, ToNameBinding, Used, | |
| 47 | }; | |
| 43 | 48 | |
| 44 | 49 | type Res = def::Res<NodeId>; |
| 45 | 50 |
compiler/rustc_resolve/src/rustdoc.rs+3-2| ... | ... | @@ -1,3 +1,6 @@ |
| 1 | use std::mem; | |
| 2 | use std::ops::Range; | |
| 3 | ||
| 1 | 4 | use pulldown_cmark::{ |
| 2 | 5 | BrokenLink, BrokenLinkCallback, CowStr, Event, LinkType, Options, Parser, Tag, |
| 3 | 6 | }; |
| ... | ... | @@ -8,8 +11,6 @@ use rustc_middle::ty::TyCtxt; |
| 8 | 11 | use rustc_span::def_id::DefId; |
| 9 | 12 | use rustc_span::symbol::{kw, sym, Symbol}; |
| 10 | 13 | use rustc_span::{InnerSpan, Span, DUMMY_SP}; |
| 11 | use std::mem; | |
| 12 | use std::ops::Range; | |
| 13 | 14 | use tracing::{debug, trace}; |
| 14 | 15 | |
| 15 | 16 | #[derive(Clone, Copy, PartialEq, Eq, Debug)] |
compiler/rustc_sanitizers/src/cfi/typeid/itanium_cxx_abi/encode.rs+3-4| ... | ... | @@ -5,9 +5,9 @@ |
| 5 | 5 | //! For more information about LLVM CFI and cross-language LLVM CFI support for the Rust compiler, |
| 6 | 6 | //! see design document in the tracking issue #89653. |
| 7 | 7 | |
| 8 | use rustc_data_structures::base_n::ToBaseN; | |
| 9 | use rustc_data_structures::base_n::ALPHANUMERIC_ONLY; | |
| 10 | use rustc_data_structures::base_n::CASE_INSENSITIVE; | |
| 8 | use std::fmt::Write as _; | |
| 9 | ||
| 10 | use rustc_data_structures::base_n::{ToBaseN, ALPHANUMERIC_ONLY, CASE_INSENSITIVE}; | |
| 11 | 11 | use rustc_data_structures::fx::FxHashMap; |
| 12 | 12 | use rustc_hir as hir; |
| 13 | 13 | use rustc_middle::bug; |
| ... | ... | @@ -20,7 +20,6 @@ use rustc_span::def_id::DefId; |
| 20 | 20 | use rustc_span::sym; |
| 21 | 21 | use rustc_target::abi::Integer; |
| 22 | 22 | use rustc_target::spec::abi::Abi; |
| 23 | use std::fmt::Write as _; | |
| 24 | 23 | use tracing::instrument; |
| 25 | 24 | |
| 26 | 25 | use crate::cfi::typeid::itanium_cxx_abi::transform::{TransformTy, TransformTyOptions}; |
compiler/rustc_sanitizers/src/cfi/typeid/itanium_cxx_abi/transform.rs+4-2| ... | ... | @@ -4,6 +4,8 @@ |
| 4 | 4 | //! For more information about LLVM CFI and cross-language LLVM CFI support for the Rust compiler, |
| 5 | 5 | //! see design document in the tracking issue #89653. |
| 6 | 6 | |
| 7 | use std::iter; | |
| 8 | ||
| 7 | 9 | use rustc_hir as hir; |
| 8 | 10 | use rustc_hir::LangItem; |
| 9 | 11 | use rustc_middle::bug; |
| ... | ... | @@ -12,9 +14,9 @@ use rustc_middle::ty::{ |
| 12 | 14 | self, ExistentialPredicateStableCmpExt as _, Instance, InstanceKind, IntTy, List, TraitRef, Ty, |
| 13 | 15 | TyCtxt, TypeFoldable, TypeVisitableExt, UintTy, |
| 14 | 16 | }; |
| 15 | use rustc_span::{def_id::DefId, sym}; | |
| 17 | use rustc_span::def_id::DefId; | |
| 18 | use rustc_span::sym; | |
| 16 | 19 | use rustc_trait_selection::traits; |
| 17 | use std::iter; | |
| 18 | 20 | use tracing::{debug, instrument}; |
| 19 | 21 | |
| 20 | 22 | use crate::cfi::typeid::itanium_cxx_abi::encode::EncodeTyOptions; |
compiler/rustc_sanitizers/src/kcfi/typeid/mod.rs+2-1| ... | ... | @@ -4,9 +4,10 @@ |
| 4 | 4 | //! For more information about LLVM KCFI and cross-language LLVM KCFI support for the Rust compiler, |
| 5 | 5 | //! see the tracking issue #123479. |
| 6 | 6 | |
| 7 | use std::hash::Hasher; | |
| 8 | ||
| 7 | 9 | use rustc_middle::ty::{Instance, InstanceKind, ReifyReason, Ty, TyCtxt}; |
| 8 | 10 | use rustc_target::abi::call::FnAbi; |
| 9 | use std::hash::Hasher; | |
| 10 | 11 | use twox_hash::XxHash64; |
| 11 | 12 | |
| 12 | 13 | pub use crate::cfi::typeid::{itanium_cxx_abi, TypeIdOptions}; |
compiler/rustc_serialize/src/leb128.rs+2-3| ... | ... | @@ -1,9 +1,8 @@ |
| 1 | use crate::opaque::MemDecoder; | |
| 2 | use crate::serialize::Decoder; | |
| 3 | ||
| 4 | 1 | // This code is very hot and uses lots of arithmetic, avoid overflow checks for performance. |
| 5 | 2 | // See https://github.com/rust-lang/rust/pull/119440#issuecomment-1874255727 |
| 6 | 3 | use crate::int_overflow::DebugStrictAdd; |
| 4 | use crate::opaque::MemDecoder; | |
| 5 | use crate::serialize::Decoder; | |
| 7 | 6 | |
| 8 | 7 | /// Returns the length of the longest LEB128 encoding for `T`, assuming `T` is an integer type |
| 9 | 8 | pub const fn max_leb128_len<T>() -> usize { |
compiler/rustc_serialize/src/opaque.rs+3-4| ... | ... | @@ -1,15 +1,14 @@ |
| 1 | use crate::leb128; | |
| 2 | use crate::serialize::{Decodable, Decoder, Encodable, Encoder}; | |
| 3 | 1 | use std::fs::File; |
| 4 | 2 | use std::io::{self, Write}; |
| 5 | 3 | use std::marker::PhantomData; |
| 6 | 4 | use std::ops::Range; |
| 7 | use std::path::Path; | |
| 8 | use std::path::PathBuf; | |
| 5 | use std::path::{Path, PathBuf}; | |
| 9 | 6 | |
| 10 | 7 | // This code is very hot and uses lots of arithmetic, avoid overflow checks for performance. |
| 11 | 8 | // See https://github.com/rust-lang/rust/pull/119440#issuecomment-1874255727 |
| 12 | 9 | use crate::int_overflow::DebugStrictAdd; |
| 10 | use crate::leb128; | |
| 11 | use crate::serialize::{Decodable, Decoder, Encodable, Encoder}; | |
| 13 | 12 | |
| 14 | 13 | // ----------------------------------------------------------------------------- |
| 15 | 14 | // Encoder |
compiler/rustc_serialize/src/serialize.rs+2-1| ... | ... | @@ -1,6 +1,5 @@ |
| 1 | 1 | //! Support code for encoding and decoding types. |
| 2 | 2 | |
| 3 | use smallvec::{Array, SmallVec}; | |
| 4 | 3 | use std::borrow::Cow; |
| 5 | 4 | use std::cell::{Cell, RefCell}; |
| 6 | 5 | use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet, VecDeque}; |
| ... | ... | @@ -10,6 +9,8 @@ use std::num::NonZero; |
| 10 | 9 | use std::path; |
| 11 | 10 | use std::rc::Rc; |
| 12 | 11 | use std::sync::Arc; |
| 12 | ||
| 13 | use smallvec::{Array, SmallVec}; | |
| 13 | 14 | use thin_vec::ThinVec; |
| 14 | 15 | |
| 15 | 16 | /// A byte that [cannot occur in UTF8 sequences][utf8]. Used to mark the end of a string. |
compiler/rustc_serialize/tests/leb128.rs+1-2| ... | ... | @@ -1,6 +1,5 @@ |
| 1 | 1 | use rustc_serialize::leb128::*; |
| 2 | use rustc_serialize::opaque::MemDecoder; | |
| 3 | use rustc_serialize::opaque::MAGIC_END_BYTES; | |
| 2 | use rustc_serialize::opaque::{MemDecoder, MAGIC_END_BYTES}; | |
| 4 | 3 | use rustc_serialize::Decoder; |
| 5 | 4 | |
| 6 | 5 | macro_rules! impl_test_unsigned_leb128 { |
compiler/rustc_serialize/tests/opaque.rs+3-2| ... | ... | @@ -1,10 +1,11 @@ |
| 1 | 1 | #![allow(rustc::internal)] |
| 2 | 2 | |
| 3 | use std::fmt::Debug; | |
| 4 | use std::fs; | |
| 5 | ||
| 3 | 6 | use rustc_macros::{Decodable_Generic, Encodable_Generic}; |
| 4 | 7 | use rustc_serialize::opaque::{FileEncoder, MemDecoder}; |
| 5 | 8 | use rustc_serialize::{Decodable, Encodable}; |
| 6 | use std::fmt::Debug; | |
| 7 | use std::fs; | |
| 8 | 9 | |
| 9 | 10 | #[derive(PartialEq, Clone, Debug, Encodable_Generic, Decodable_Generic)] |
| 10 | 11 | struct Struct { |
compiler/rustc_session/src/code_stats.rs+2-1| ... | ... | @@ -1,9 +1,10 @@ |
| 1 | use std::cmp; | |
| 2 | ||
| 1 | 3 | use rustc_data_structures::fx::{FxHashMap, FxHashSet}; |
| 2 | 4 | use rustc_data_structures::sync::Lock; |
| 3 | 5 | use rustc_span::def_id::DefId; |
| 4 | 6 | use rustc_span::Symbol; |
| 5 | 7 | use rustc_target::abi::{Align, Size}; |
| 6 | use std::cmp; | |
| 7 | 8 | |
| 8 | 9 | #[derive(Clone, PartialEq, Eq, Hash, Debug)] |
| 9 | 10 | pub struct VariantInfo { |
compiler/rustc_session/src/config.rs+36-34| ... | ... | @@ -3,13 +3,17 @@ |
| 3 | 3 | |
| 4 | 4 | #![allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable |
| 5 | 5 | |
| 6 | pub use crate::options::*; | |
| 6 | use std::collections::btree_map::{ | |
| 7 | Iter as BTreeMapIter, Keys as BTreeMapKeysIter, Values as BTreeMapValuesIter, | |
| 8 | }; | |
| 9 | use std::collections::{BTreeMap, BTreeSet}; | |
| 10 | use std::ffi::OsStr; | |
| 11 | use std::hash::Hash; | |
| 12 | use std::path::{Path, PathBuf}; | |
| 13 | use std::str::{self, FromStr}; | |
| 14 | use std::sync::LazyLock; | |
| 15 | use std::{fmt, fs, iter}; | |
| 7 | 16 | |
| 8 | use crate::errors::FileWriteFail; | |
| 9 | use crate::search_paths::SearchPath; | |
| 10 | use crate::utils::{CanonicalizedPath, NativeLib, NativeLibKind}; | |
| 11 | use crate::{filesearch, lint, HashStableContext}; | |
| 12 | use crate::{EarlyDiagCtxt, Session}; | |
| 13 | 17 | use rustc_data_structures::fx::{FxHashSet, FxIndexMap}; |
| 14 | 18 | use rustc_data_structures::stable_hasher::{StableOrd, ToStableHashKey}; |
| 15 | 19 | use rustc_errors::emitter::HumanReadableErrorType; |
| ... | ... | @@ -19,22 +23,17 @@ use rustc_macros::{Decodable, Encodable, HashStable_Generic}; |
| 19 | 23 | use rustc_span::edition::{Edition, DEFAULT_EDITION, EDITION_NAME_LIST, LATEST_STABLE_EDITION}; |
| 20 | 24 | use rustc_span::source_map::FilePathMapping; |
| 21 | 25 | use rustc_span::{FileName, FileNameDisplayPreference, RealFileName, SourceFileHashAlgorithm}; |
| 22 | use rustc_target::spec::{FramePointer, LinkSelfContainedComponents, LinkerFeatures}; | |
| 23 | use rustc_target::spec::{SplitDebuginfo, Target, TargetTriple}; | |
| 24 | use std::collections::btree_map::{ | |
| 25 | Iter as BTreeMapIter, Keys as BTreeMapKeysIter, Values as BTreeMapValuesIter, | |
| 26 | use rustc_target::spec::{ | |
| 27 | FramePointer, LinkSelfContainedComponents, LinkerFeatures, SplitDebuginfo, Target, TargetTriple, | |
| 26 | 28 | }; |
| 27 | use std::collections::{BTreeMap, BTreeSet}; | |
| 28 | use std::ffi::OsStr; | |
| 29 | use std::fmt; | |
| 30 | use std::fs; | |
| 31 | use std::hash::Hash; | |
| 32 | use std::iter; | |
| 33 | use std::path::{Path, PathBuf}; | |
| 34 | use std::str::{self, FromStr}; | |
| 35 | use std::sync::LazyLock; | |
| 36 | 29 | use tracing::debug; |
| 37 | 30 | |
| 31 | use crate::errors::FileWriteFail; | |
| 32 | pub use crate::options::*; | |
| 33 | use crate::search_paths::SearchPath; | |
| 34 | use crate::utils::{CanonicalizedPath, NativeLib, NativeLibKind}; | |
| 35 | use crate::{filesearch, lint, EarlyDiagCtxt, HashStableContext, Session}; | |
| 36 | ||
| 38 | 37 | mod cfg; |
| 39 | 38 | pub mod sigpipe; |
| 40 | 39 | |
| ... | ... | @@ -2765,9 +2764,10 @@ pub fn parse_crate_types_from_list(list_list: Vec<String>) -> Result<Vec<CrateTy |
| 2765 | 2764 | } |
| 2766 | 2765 | |
| 2767 | 2766 | pub mod nightly_options { |
| 2767 | use rustc_feature::UnstableFeatures; | |
| 2768 | ||
| 2768 | 2769 | use super::{OptionStability, RustcOptGroup}; |
| 2769 | 2770 | use crate::EarlyDiagCtxt; |
| 2770 | use rustc_feature::UnstableFeatures; | |
| 2771 | 2771 | |
| 2772 | 2772 | pub fn is_unstable_enabled(matches: &getopts::Matches) -> bool { |
| 2773 | 2773 | match_is_nightly_build(matches) |
| ... | ... | @@ -2960,6 +2960,22 @@ pub enum WasiExecModel { |
| 2960 | 2960 | /// we have an opt-in scheme here, so one is hopefully forced to think about |
| 2961 | 2961 | /// how the hash should be calculated when adding a new command-line argument. |
| 2962 | 2962 | pub(crate) mod dep_tracking { |
| 2963 | use std::collections::BTreeMap; | |
| 2964 | use std::hash::{DefaultHasher, Hash}; | |
| 2965 | use std::num::NonZero; | |
| 2966 | use std::path::PathBuf; | |
| 2967 | ||
| 2968 | use rustc_data_structures::fx::FxIndexMap; | |
| 2969 | use rustc_data_structures::stable_hasher::Hash64; | |
| 2970 | use rustc_errors::LanguageIdentifier; | |
| 2971 | use rustc_feature::UnstableFeatures; | |
| 2972 | use rustc_span::edition::Edition; | |
| 2973 | use rustc_span::RealFileName; | |
| 2974 | use rustc_target::spec::{ | |
| 2975 | CodeModel, FramePointer, MergeFunctions, OnBrokenPipe, PanicStrategy, RelocModel, | |
| 2976 | RelroLevel, SanitizerSet, SplitDebuginfo, StackProtector, TargetTriple, TlsModel, WasmCAbi, | |
| 2977 | }; | |
| 2978 | ||
| 2963 | 2979 | use super::{ |
| 2964 | 2980 | BranchProtection, CFGuard, CFProtection, CollapseMacroDebuginfo, CoverageOptions, |
| 2965 | 2981 | CrateType, DebugInfo, DebugInfoCompression, ErrorOutputType, FunctionReturn, |
| ... | ... | @@ -2971,20 +2987,6 @@ pub(crate) mod dep_tracking { |
| 2971 | 2987 | }; |
| 2972 | 2988 | use crate::lint; |
| 2973 | 2989 | use crate::utils::NativeLib; |
| 2974 | use rustc_data_structures::fx::FxIndexMap; | |
| 2975 | use rustc_data_structures::stable_hasher::Hash64; | |
| 2976 | use rustc_errors::LanguageIdentifier; | |
| 2977 | use rustc_feature::UnstableFeatures; | |
| 2978 | use rustc_span::edition::Edition; | |
| 2979 | use rustc_span::RealFileName; | |
| 2980 | use rustc_target::spec::{ | |
| 2981 | CodeModel, FramePointer, MergeFunctions, OnBrokenPipe, PanicStrategy, RelocModel, | |
| 2982 | RelroLevel, SanitizerSet, SplitDebuginfo, StackProtector, TargetTriple, TlsModel, WasmCAbi, | |
| 2983 | }; | |
| 2984 | use std::collections::BTreeMap; | |
| 2985 | use std::hash::{DefaultHasher, Hash}; | |
| 2986 | use std::num::NonZero; | |
| 2987 | use std::path::PathBuf; | |
| 2988 | 2990 | |
| 2989 | 2991 | pub(crate) trait DepTrackingHash { |
| 2990 | 2992 | fn hash( |
compiler/rustc_session/src/config/cfg.rs+4-5| ... | ... | @@ -19,18 +19,17 @@ |
| 19 | 19 | //! so that the compiler can know the cfg is expected |
| 20 | 20 | //! - Add the feature gating in `compiler/rustc_feature/src/builtin_attrs.rs` |
| 21 | 21 | |
| 22 | use std::hash::Hash; | |
| 23 | use std::iter; | |
| 24 | ||
| 22 | 25 | use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexSet}; |
| 23 | 26 | use rustc_span::symbol::{sym, Symbol}; |
| 24 | 27 | use rustc_target::abi::Align; |
| 25 | use rustc_target::spec::{PanicStrategy, RelocModel, SanitizerSet}; | |
| 26 | use rustc_target::spec::{Target, TargetTriple, TARGETS}; | |
| 28 | use rustc_target::spec::{PanicStrategy, RelocModel, SanitizerSet, Target, TargetTriple, TARGETS}; | |
| 27 | 29 | |
| 28 | 30 | use crate::config::CrateType; |
| 29 | 31 | use crate::Session; |
| 30 | 32 | |
| 31 | use std::hash::Hash; | |
| 32 | use std::iter; | |
| 33 | ||
| 34 | 33 | /// The parsed `--cfg` options that define the compilation environment of the |
| 35 | 34 | /// crate, used to drive conditional compilation. |
| 36 | 35 | /// |
compiler/rustc_session/src/cstore.rs+5-4| ... | ... | @@ -2,8 +2,9 @@ |
| 2 | 2 | //! are *mostly* used as a part of that interface, but these should |
| 3 | 3 | //! probably get a better home if someone can find one. |
| 4 | 4 | |
| 5 | use crate::search_paths::PathKind; | |
| 6 | use crate::utils::NativeLibKind; | |
| 5 | use std::any::Any; | |
| 6 | use std::path::PathBuf; | |
| 7 | ||
| 7 | 8 | use rustc_ast as ast; |
| 8 | 9 | use rustc_data_structures::sync::{self, AppendOnlyIndexVec, FreezeLock}; |
| 9 | 10 | use rustc_hir::def_id::{ |
| ... | ... | @@ -15,8 +16,8 @@ use rustc_span::symbol::Symbol; |
| 15 | 16 | use rustc_span::Span; |
| 16 | 17 | use rustc_target::spec::abi::Abi; |
| 17 | 18 | |
| 18 | use std::any::Any; | |
| 19 | use std::path::PathBuf; | |
| 19 | use crate::search_paths::PathKind; | |
| 20 | use crate::utils::NativeLibKind; | |
| 20 | 21 | |
| 21 | 22 | // lonely orphan structs and enums looking for a better home |
| 22 | 23 |
compiler/rustc_session/src/errors.rs+5-3| ... | ... | @@ -2,15 +2,17 @@ use std::num::NonZero; |
| 2 | 2 | |
| 3 | 3 | use rustc_ast::token; |
| 4 | 4 | use rustc_ast::util::literal::LitError; |
| 5 | use rustc_errors::codes::*; | |
| 5 | 6 | use rustc_errors::{ |
| 6 | codes::*, Diag, DiagCtxtHandle, DiagMessage, Diagnostic, EmissionGuarantee, ErrorGuaranteed, | |
| 7 | Level, MultiSpan, | |
| 7 | Diag, DiagCtxtHandle, DiagMessage, Diagnostic, EmissionGuarantee, ErrorGuaranteed, Level, | |
| 8 | MultiSpan, | |
| 8 | 9 | }; |
| 9 | 10 | use rustc_macros::{Diagnostic, Subdiagnostic}; |
| 10 | 11 | use rustc_span::{Span, Symbol}; |
| 11 | 12 | use rustc_target::spec::{SplitDebuginfo, StackProtector, TargetTriple}; |
| 12 | 13 | |
| 13 | use crate::{config::CrateType, parse::ParseSess}; | |
| 14 | use crate::config::CrateType; | |
| 15 | use crate::parse::ParseSess; | |
| 14 | 16 | |
| 15 | 17 | pub(crate) struct FeatureGateError { |
| 16 | 18 | pub(crate) span: MultiSpan, |
compiler/rustc_session/src/filesearch.rs+9-10| ... | ... | @@ -1,13 +1,14 @@ |
| 1 | 1 | //! A module for searching for libraries |
| 2 | 2 | |
| 3 | use crate::search_paths::{PathKind, SearchPath}; | |
| 3 | use std::path::{Path, PathBuf}; | |
| 4 | use std::{env, fs}; | |
| 5 | ||
| 4 | 6 | use rustc_fs_util::{fix_windows_verbatim_for_gcc, try_canonicalize}; |
| 5 | 7 | use smallvec::{smallvec, SmallVec}; |
| 6 | use std::env; | |
| 7 | use std::fs; | |
| 8 | use std::path::{Path, PathBuf}; | |
| 9 | 8 | use tracing::debug; |
| 10 | 9 | |
| 10 | use crate::search_paths::{PathKind, SearchPath}; | |
| 11 | ||
| 11 | 12 | #[derive(Clone)] |
| 12 | 13 | pub struct FileSearch<'a> { |
| 13 | 14 | sysroot: &'a Path, |
| ... | ... | @@ -129,12 +130,10 @@ fn current_dll_path() -> Result<PathBuf, String> { |
| 129 | 130 | use std::io; |
| 130 | 131 | use std::os::windows::prelude::*; |
| 131 | 132 | |
| 132 | use windows::{ | |
| 133 | core::PCWSTR, | |
| 134 | Win32::Foundation::HMODULE, | |
| 135 | Win32::System::LibraryLoader::{ | |
| 136 | GetModuleFileNameW, GetModuleHandleExW, GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, | |
| 137 | }, | |
| 133 | use windows::core::PCWSTR; | |
| 134 | use windows::Win32::Foundation::HMODULE; | |
| 135 | use windows::Win32::System::LibraryLoader::{ | |
| 136 | GetModuleFileNameW, GetModuleHandleExW, GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, | |
| 138 | 137 | }; |
| 139 | 138 | |
| 140 | 139 | let mut module = HMODULE::default(); |
compiler/rustc_session/src/options.rs+15-14| ... | ... | @@ -1,26 +1,26 @@ |
| 1 | use crate::config::*; | |
| 2 | use crate::search_paths::SearchPath; | |
| 3 | use crate::utils::NativeLib; | |
| 4 | use crate::{lint, EarlyDiagCtxt}; | |
| 1 | use std::collections::BTreeMap; | |
| 2 | use std::hash::{DefaultHasher, Hasher}; | |
| 3 | use std::num::{IntErrorKind, NonZero}; | |
| 4 | use std::path::PathBuf; | |
| 5 | use std::str; | |
| 6 | ||
| 5 | 7 | use rustc_data_structures::fx::FxIndexMap; |
| 6 | 8 | use rustc_data_structures::profiling::TimePassesFormat; |
| 7 | 9 | use rustc_data_structures::stable_hasher::Hash64; |
| 8 | use rustc_errors::ColorConfig; | |
| 9 | use rustc_errors::{LanguageIdentifier, TerminalUrl}; | |
| 10 | use rustc_errors::{ColorConfig, LanguageIdentifier, TerminalUrl}; | |
| 10 | 11 | use rustc_feature::UnstableFeatures; |
| 11 | 12 | use rustc_span::edition::Edition; |
| 12 | use rustc_span::RealFileName; | |
| 13 | use rustc_span::SourceFileHashAlgorithm; | |
| 13 | use rustc_span::{RealFileName, SourceFileHashAlgorithm}; | |
| 14 | 14 | use rustc_target::spec::{ |
| 15 | 15 | CodeModel, FramePointer, LinkerFlavorCli, MergeFunctions, OnBrokenPipe, PanicStrategy, |
| 16 | 16 | RelocModel, RelroLevel, SanitizerSet, SplitDebuginfo, StackProtector, TargetTriple, TlsModel, |
| 17 | 17 | WasmCAbi, |
| 18 | 18 | }; |
| 19 | use std::collections::BTreeMap; | |
| 20 | use std::hash::{DefaultHasher, Hasher}; | |
| 21 | use std::num::{IntErrorKind, NonZero}; | |
| 22 | use std::path::PathBuf; | |
| 23 | use std::str; | |
| 19 | ||
| 20 | use crate::config::*; | |
| 21 | use crate::search_paths::SearchPath; | |
| 22 | use crate::utils::NativeLib; | |
| 23 | use crate::{lint, EarlyDiagCtxt}; | |
| 24 | 24 | |
| 25 | 25 | macro_rules! insert { |
| 26 | 26 | ($opt_name:ident, $opt_expr:expr, $sub_hashes:expr) => { |
| ... | ... | @@ -447,9 +447,10 @@ mod desc { |
| 447 | 447 | } |
| 448 | 448 | |
| 449 | 449 | mod parse { |
| 450 | pub(crate) use super::*; | |
| 451 | 450 | use std::str::FromStr; |
| 452 | 451 | |
| 452 | pub(crate) use super::*; | |
| 453 | ||
| 453 | 454 | /// This is for boolean options that don't take a value and start with |
| 454 | 455 | /// `no-`. This style of option is deprecated. |
| 455 | 456 | pub(crate) fn parse_no_flag(slot: &mut bool, v: Option<&str>) -> bool { |
compiler/rustc_session/src/output.rs+7-5| ... | ... | @@ -1,16 +1,18 @@ |
| 1 | 1 | //! Related to out filenames of compilation (e.g. binaries). |
| 2 | 2 | |
| 3 | use std::path::Path; | |
| 4 | ||
| 5 | use rustc_ast::{self as ast, attr}; | |
| 6 | use rustc_errors::FatalError; | |
| 7 | use rustc_span::symbol::sym; | |
| 8 | use rustc_span::{Span, Symbol}; | |
| 9 | ||
| 3 | 10 | use crate::config::{self, CrateType, Input, OutFileName, OutputFilenames, OutputType}; |
| 4 | 11 | use crate::errors::{ |
| 5 | 12 | self, CrateNameDoesNotMatch, CrateNameEmpty, CrateNameInvalid, FileIsNotWriteable, |
| 6 | 13 | InvalidCharacterInCrateName, InvalidCrateNameHelp, |
| 7 | 14 | }; |
| 8 | 15 | use crate::Session; |
| 9 | use rustc_ast::{self as ast, attr}; | |
| 10 | use rustc_errors::FatalError; | |
| 11 | use rustc_span::symbol::sym; | |
| 12 | use rustc_span::{Span, Symbol}; | |
| 13 | use std::path::Path; | |
| 14 | 16 | |
| 15 | 17 | pub fn out_filename( |
| 16 | 18 | sess: &Session, |
compiler/rustc_session/src/parse.rs+11-11| ... | ... | @@ -1,15 +1,9 @@ |
| 1 | 1 | //! Contains `ParseSess` which holds state living beyond what one `Parser` might. |
| 2 | 2 | //! It also serves as an input to the parser itself. |
| 3 | 3 | |
| 4 | use crate::config::{Cfg, CheckCfg}; | |
| 5 | use crate::errors::{ | |
| 6 | CliFeatureDiagnosticHelp, FeatureDiagnosticForIssue, FeatureDiagnosticHelp, | |
| 7 | FeatureDiagnosticSuggestion, FeatureGateError, SuggestUpgradeCompiler, | |
| 8 | }; | |
| 9 | use crate::lint::{ | |
| 10 | builtin::UNSTABLE_SYNTAX_PRE_EXPANSION, BufferedEarlyLint, BuiltinLintDiag, Lint, LintId, | |
| 11 | }; | |
| 12 | use crate::Session; | |
| 4 | use std::str; | |
| 5 | ||
| 6 | use rustc_ast::attr::AttrIdGenerator; | |
| 13 | 7 | use rustc_ast::node_id::NodeId; |
| 14 | 8 | use rustc_data_structures::fx::{FxHashMap, FxIndexMap, FxIndexSet}; |
| 15 | 9 | use rustc_data_structures::sync::{AppendOnlyVec, Lock, Lrc}; |
| ... | ... | @@ -24,8 +18,14 @@ use rustc_span::hygiene::ExpnId; |
| 24 | 18 | use rustc_span::source_map::{FilePathMapping, SourceMap}; |
| 25 | 19 | use rustc_span::{Span, Symbol}; |
| 26 | 20 | |
| 27 | use rustc_ast::attr::AttrIdGenerator; | |
| 28 | use std::str; | |
| 21 | use crate::config::{Cfg, CheckCfg}; | |
| 22 | use crate::errors::{ | |
| 23 | CliFeatureDiagnosticHelp, FeatureDiagnosticForIssue, FeatureDiagnosticHelp, | |
| 24 | FeatureDiagnosticSuggestion, FeatureGateError, SuggestUpgradeCompiler, | |
| 25 | }; | |
| 26 | use crate::lint::builtin::UNSTABLE_SYNTAX_PRE_EXPANSION; | |
| 27 | use crate::lint::{BufferedEarlyLint, BuiltinLintDiag, Lint, LintId}; | |
| 28 | use crate::Session; | |
| 29 | 29 | |
| 30 | 30 | /// Collected spans during parsing for places where a certain feature was |
| 31 | 31 | /// used and should be feature gated accordingly in `check_crate`. |
compiler/rustc_session/src/search_paths.rs+5-3| ... | ... | @@ -1,8 +1,10 @@ |
| 1 | use crate::filesearch::make_target_lib_path; | |
| 2 | use crate::EarlyDiagCtxt; | |
| 1 | use std::path::{Path, PathBuf}; | |
| 2 | ||
| 3 | 3 | use rustc_macros::{Decodable, Encodable, HashStable_Generic}; |
| 4 | 4 | use rustc_target::spec::TargetTriple; |
| 5 | use std::path::{Path, PathBuf}; | |
| 5 | ||
| 6 | use crate::filesearch::make_target_lib_path; | |
| 7 | use crate::EarlyDiagCtxt; | |
| 6 | 8 | |
| 7 | 9 | #[derive(Clone, Debug)] |
| 8 | 10 | pub struct SearchPath { |
compiler/rustc_session/src/session.rs+22-24| ... | ... | @@ -1,14 +1,11 @@ |
| 1 | use crate::code_stats::CodeStats; | |
| 2 | pub use crate::code_stats::{DataTypeKind, FieldInfo, FieldKind, SizeKind, VariantInfo}; | |
| 3 | use crate::config::{ | |
| 4 | self, CoverageLevel, CrateType, FunctionReturn, InstrumentCoverage, OptLevel, OutFileName, | |
| 5 | OutputType, RemapPathScopeComponents, SwitchWithOptPath, | |
| 6 | }; | |
| 7 | use crate::config::{ErrorOutputType, Input}; | |
| 8 | use crate::errors; | |
| 9 | use crate::parse::{add_feature_diagnostics, ParseSess}; | |
| 10 | use crate::search_paths::{PathKind, SearchPath}; | |
| 11 | use crate::{filesearch, lint}; | |
| 1 | use std::any::Any; | |
| 2 | use std::ops::{Div, Mul}; | |
| 3 | use std::path::{Path, PathBuf}; | |
| 4 | use std::str::FromStr; | |
| 5 | use std::sync::atomic::AtomicBool; | |
| 6 | use std::sync::atomic::Ordering::SeqCst; | |
| 7 | use std::sync::Arc; | |
| 8 | use std::{env, fmt, io}; | |
| 12 | 9 | |
| 13 | 10 | use rustc_data_structures::flock; |
| 14 | 11 | use rustc_data_structures::fx::{FxHashMap, FxIndexSet}; |
| ... | ... | @@ -18,33 +15,34 @@ use rustc_data_structures::sync::{ |
| 18 | 15 | AtomicU64, DynSend, DynSync, Lock, Lrc, MappedReadGuard, ReadGuard, RwLock, |
| 19 | 16 | }; |
| 20 | 17 | use rustc_errors::annotate_snippet_emitter_writer::AnnotateSnippetEmitter; |
| 18 | use rustc_errors::codes::*; | |
| 21 | 19 | use rustc_errors::emitter::{stderr_destination, DynEmitter, HumanEmitter, HumanReadableErrorType}; |
| 22 | 20 | use rustc_errors::json::JsonEmitter; |
| 23 | 21 | use rustc_errors::registry::Registry; |
| 24 | 22 | use rustc_errors::{ |
| 25 | codes::*, fallback_fluent_bundle, Diag, DiagCtxt, DiagCtxtHandle, DiagMessage, Diagnostic, | |
| 23 | fallback_fluent_bundle, Diag, DiagCtxt, DiagCtxtHandle, DiagMessage, Diagnostic, | |
| 26 | 24 | ErrorGuaranteed, FatalAbort, FluentBundle, LazyFallbackBundle, TerminalUrl, |
| 27 | 25 | }; |
| 28 | 26 | use rustc_macros::HashStable_Generic; |
| 29 | 27 | pub use rustc_span::def_id::StableCrateId; |
| 30 | 28 | use rustc_span::edition::Edition; |
| 31 | 29 | use rustc_span::source_map::{FilePathMapping, SourceMap}; |
| 32 | use rustc_span::{FileNameDisplayPreference, RealFileName}; | |
| 33 | use rustc_span::{Span, Symbol}; | |
| 30 | use rustc_span::{FileNameDisplayPreference, RealFileName, Span, Symbol}; | |
| 34 | 31 | use rustc_target::asm::InlineAsmArch; |
| 35 | use rustc_target::spec::{CodeModel, PanicStrategy, RelocModel, RelroLevel}; | |
| 36 | 32 | use rustc_target::spec::{ |
| 37 | DebuginfoKind, SanitizerSet, SplitDebuginfo, StackProtector, Target, TargetTriple, TlsModel, | |
| 33 | CodeModel, DebuginfoKind, PanicStrategy, RelocModel, RelroLevel, SanitizerSet, SplitDebuginfo, | |
| 34 | StackProtector, Target, TargetTriple, TlsModel, | |
| 38 | 35 | }; |
| 39 | 36 | |
| 40 | use std::any::Any; | |
| 41 | use std::env; | |
| 42 | use std::fmt; | |
| 43 | use std::io; | |
| 44 | use std::ops::{Div, Mul}; | |
| 45 | use std::path::{Path, PathBuf}; | |
| 46 | use std::str::FromStr; | |
| 47 | use std::sync::{atomic::AtomicBool, atomic::Ordering::SeqCst, Arc}; | |
| 37 | use crate::code_stats::CodeStats; | |
| 38 | pub use crate::code_stats::{DataTypeKind, FieldInfo, FieldKind, SizeKind, VariantInfo}; | |
| 39 | use crate::config::{ | |
| 40 | self, CoverageLevel, CrateType, ErrorOutputType, FunctionReturn, Input, InstrumentCoverage, | |
| 41 | OptLevel, OutFileName, OutputType, RemapPathScopeComponents, SwitchWithOptPath, | |
| 42 | }; | |
| 43 | use crate::parse::{add_feature_diagnostics, ParseSess}; | |
| 44 | use crate::search_paths::{PathKind, SearchPath}; | |
| 45 | use crate::{errors, filesearch, lint}; | |
| 48 | 46 | |
| 49 | 47 | struct OptimizationFuel { |
| 50 | 48 | /// If `-zfuel=crate=n` is specified, initially set to `n`, otherwise `0`. |
compiler/rustc_session/src/utils.rs+5-5| ... | ... | @@ -1,11 +1,11 @@ |
| 1 | use crate::session::Session; | |
| 1 | use std::path::{Path, PathBuf}; | |
| 2 | use std::sync::OnceLock; | |
| 3 | ||
| 2 | 4 | use rustc_data_structures::profiling::VerboseTimingGuard; |
| 3 | 5 | use rustc_fs_util::try_canonicalize; |
| 4 | 6 | use rustc_macros::{Decodable, Encodable, HashStable_Generic}; |
| 5 | use std::{ | |
| 6 | path::{Path, PathBuf}, | |
| 7 | sync::OnceLock, | |
| 8 | }; | |
| 7 | ||
| 8 | use crate::session::Session; | |
| 9 | 9 | |
| 10 | 10 | impl Session { |
| 11 | 11 | pub fn timer(&self, what: &'static str) -> VerboseTimingGuard<'_> { |
compiler/rustc_session/src/version.rs+3-5| ... | ... | @@ -1,10 +1,8 @@ |
| 1 | use rustc_macros::{current_rustc_version, Decodable, Encodable, HashStable_Generic}; | |
| 2 | use std::{ | |
| 3 | borrow::Cow, | |
| 4 | fmt::{self, Display}, | |
| 5 | }; | |
| 1 | use std::borrow::Cow; | |
| 2 | use std::fmt::{self, Display}; | |
| 6 | 3 | |
| 7 | 4 | use rustc_errors::IntoDiagArg; |
| 5 | use rustc_macros::{current_rustc_version, Decodable, Encodable, HashStable_Generic}; | |
| 8 | 6 | |
| 9 | 7 | #[derive(Encodable, Decodable, Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] |
| 10 | 8 | #[derive(HashStable_Generic)] |
compiler/rustc_smir/src/rustc_internal/internal.rs+1-1| ... | ... | @@ -5,7 +5,6 @@ |
| 5 | 5 | |
| 6 | 6 | // Prefer importing stable_mir over internal rustc constructs to make this file more readable. |
| 7 | 7 | |
| 8 | use crate::rustc_smir::Tables; | |
| 9 | 8 | use rustc_middle::ty::{self as rustc_ty, Const as InternalConst, Ty as InternalTy, TyCtxt}; |
| 10 | 9 | use rustc_span::Symbol; |
| 11 | 10 | use stable_mir::abi::Layout; |
| ... | ... | @@ -21,6 +20,7 @@ use stable_mir::ty::{ |
| 21 | 20 | use stable_mir::{CrateItem, CrateNum, DefId}; |
| 22 | 21 | |
| 23 | 22 | use super::RustcInternal; |
| 23 | use crate::rustc_smir::Tables; | |
| 24 | 24 | |
| 25 | 25 | impl RustcInternal for CrateItem { |
| 26 | 26 | type T<'tcx> = rustc_span::def_id::DefId; |
compiler/rustc_smir/src/rustc_internal/mod.rs+8-6| ... | ... | @@ -3,7 +3,11 @@ |
| 3 | 3 | //! For that, we define APIs that will temporarily be public to 3P that exposes rustc internal APIs |
| 4 | 4 | //! until stable MIR is complete. |
| 5 | 5 | |
| 6 | use crate::rustc_smir::{context::TablesWrapper, Stable, Tables}; | |
| 6 | use std::cell::{Cell, RefCell}; | |
| 7 | use std::fmt::Debug; | |
| 8 | use std::hash::Hash; | |
| 9 | use std::ops::Index; | |
| 10 | ||
| 7 | 11 | use rustc_data_structures::fx; |
| 8 | 12 | use rustc_data_structures::fx::FxIndexMap; |
| 9 | 13 | use rustc_middle::mir::interpret::AllocId; |
| ... | ... | @@ -15,11 +19,9 @@ use scoped_tls::scoped_thread_local; |
| 15 | 19 | use stable_mir::abi::Layout; |
| 16 | 20 | use stable_mir::ty::IndexedVal; |
| 17 | 21 | use stable_mir::Error; |
| 18 | use std::cell::Cell; | |
| 19 | use std::cell::RefCell; | |
| 20 | use std::fmt::Debug; | |
| 21 | use std::hash::Hash; | |
| 22 | use std::ops::Index; | |
| 22 | ||
| 23 | use crate::rustc_smir::context::TablesWrapper; | |
| 24 | use crate::rustc_smir::{Stable, Tables}; | |
| 23 | 25 | |
| 24 | 26 | mod internal; |
| 25 | 27 | pub mod pretty; |
compiler/rustc_smir/src/rustc_internal/pretty.rs+2-1| ... | ... | @@ -1,8 +1,9 @@ |
| 1 | 1 | use std::io; |
| 2 | 2 | |
| 3 | use super::run; | |
| 4 | 3 | use rustc_middle::ty::TyCtxt; |
| 5 | 4 | |
| 5 | use super::run; | |
| 6 | ||
| 6 | 7 | pub fn write_smir_pretty<'tcx, W: io::Write>(tcx: TyCtxt<'tcx>, w: &mut W) -> io::Result<()> { |
| 7 | 8 | writeln!( |
| 8 | 9 | w, |
compiler/rustc_smir/src/rustc_smir/alloc.rs+4-6| ... | ... | @@ -1,12 +1,10 @@ |
| 1 | use rustc_middle::mir::{ | |
| 2 | interpret::{alloc_range, AllocRange, Pointer}, | |
| 3 | ConstValue, | |
| 4 | }; | |
| 1 | use rustc_middle::mir::interpret::{alloc_range, AllocRange, Pointer}; | |
| 2 | use rustc_middle::mir::ConstValue; | |
| 3 | use stable_mir::mir::Mutability; | |
| 4 | use stable_mir::ty::{Allocation, ProvenanceMap}; | |
| 5 | 5 | use stable_mir::Error; |
| 6 | 6 | |
| 7 | 7 | use crate::rustc_smir::{Stable, Tables}; |
| 8 | use stable_mir::mir::Mutability; | |
| 9 | use stable_mir::ty::{Allocation, ProvenanceMap}; | |
| 10 | 8 | |
| 11 | 9 | /// Creates new empty `Allocation` from given `Align`. |
| 12 | 10 | fn new_empty_allocation(align: rustc_target::abi::Align) -> Allocation { |
compiler/rustc_smir/src/rustc_smir/builder.rs+2-1| ... | ... | @@ -4,12 +4,13 @@ |
| 4 | 4 | //! monomorphic body using internal representation. |
| 5 | 5 | //! After that, we convert the internal representation into a stable one. |
| 6 | 6 | |
| 7 | use crate::rustc_smir::{Stable, Tables}; | |
| 8 | 7 | use rustc_hir::def::DefKind; |
| 9 | 8 | use rustc_middle::mir; |
| 10 | 9 | use rustc_middle::mir::visit::MutVisitor; |
| 11 | 10 | use rustc_middle::ty::{self, TyCtxt}; |
| 12 | 11 | |
| 12 | use crate::rustc_smir::{Stable, Tables}; | |
| 13 | ||
| 13 | 14 | /// Builds a monomorphic body for a given instance. |
| 14 | 15 | pub struct BodyBuilder<'tcx> { |
| 15 | 16 | tcx: TyCtxt<'tcx>, |
compiler/rustc_smir/src/rustc_smir/context.rs+3-2| ... | ... | @@ -5,6 +5,9 @@ |
| 5 | 5 | |
| 6 | 6 | #![allow(rustc::usage_of_qualified_ty)] |
| 7 | 7 | |
| 8 | use std::cell::RefCell; | |
| 9 | use std::iter; | |
| 10 | ||
| 8 | 11 | use rustc_abi::HasDataLayout; |
| 9 | 12 | use rustc_hir::LangItem; |
| 10 | 13 | use rustc_middle::ty::layout::{ |
| ... | ... | @@ -28,8 +31,6 @@ use stable_mir::ty::{ |
| 28 | 31 | TyConst, TyKind, UintTy, VariantDef, |
| 29 | 32 | }; |
| 30 | 33 | use stable_mir::{Crate, CrateDef, CrateItem, CrateNum, DefId, Error, Filename, ItemKind, Symbol}; |
| 31 | use std::cell::RefCell; | |
| 32 | use std::iter; | |
| 33 | 34 | |
| 34 | 35 | use crate::rustc_internal::RustcInternal; |
| 35 | 36 | use crate::rustc_smir::builder::BodyBuilder; |
compiler/rustc_smir/src/rustc_smir/convert/abi.rs+2-1| ... | ... | @@ -2,7 +2,6 @@ |
| 2 | 2 | |
| 3 | 3 | #![allow(rustc::usage_of_qualified_ty)] |
| 4 | 4 | |
| 5 | use crate::rustc_smir::{Stable, Tables}; | |
| 6 | 5 | use rustc_middle::ty; |
| 7 | 6 | use rustc_target::abi::call::Conv; |
| 8 | 7 | use stable_mir::abi::{ |
| ... | ... | @@ -14,6 +13,8 @@ use stable_mir::opaque; |
| 14 | 13 | use stable_mir::target::MachineSize as Size; |
| 15 | 14 | use stable_mir::ty::{Align, IndexedVal, VariantIdx}; |
| 16 | 15 | |
| 16 | use crate::rustc_smir::{Stable, Tables}; | |
| 17 | ||
| 17 | 18 | impl<'tcx> Stable<'tcx> for rustc_target::abi::VariantIdx { |
| 18 | 19 | type T = VariantIdx; |
| 19 | 20 | fn stable(&self, _: &mut Tables<'_>) -> Self::T { |
compiler/rustc_smir/src/rustc_smir/convert/error.rs+2-1| ... | ... | @@ -2,10 +2,11 @@ |
| 2 | 2 | //! |
| 3 | 3 | //! Currently we encode everything as [stable_mir::Error], which is represented as a string. |
| 4 | 4 | |
| 5 | use crate::rustc_smir::{Stable, Tables}; | |
| 6 | 5 | use rustc_middle::mir::interpret::AllocError; |
| 7 | 6 | use rustc_middle::ty::layout::LayoutError; |
| 8 | 7 | |
| 8 | use crate::rustc_smir::{Stable, Tables}; | |
| 9 | ||
| 9 | 10 | impl<'tcx> Stable<'tcx> for LayoutError<'tcx> { |
| 10 | 11 | type T = stable_mir::Error; |
| 11 | 12 |
compiler/rustc_smir/src/rustc_smir/convert/mir.rs+1-2| ... | ... | @@ -1,9 +1,8 @@ |
| 1 | 1 | //! Conversion of internal Rust compiler `mir` items to stable ones. |
| 2 | 2 | |
| 3 | use rustc_middle::bug; | |
| 4 | use rustc_middle::mir; | |
| 5 | 3 | use rustc_middle::mir::interpret::alloc_range; |
| 6 | 4 | use rustc_middle::mir::mono::MonoItem; |
| 5 | use rustc_middle::{bug, mir}; | |
| 7 | 6 | use stable_mir::mir::alloc::GlobalAlloc; |
| 8 | 7 | use stable_mir::mir::{ConstOperand, Statement, UserTypeProjection, VarDebugInfoFragment}; |
| 9 | 8 | use stable_mir::ty::{Allocation, ConstantKind, MirConst}; |
compiler/rustc_smir/src/rustc_smir/mod.rs+2-1| ... | ... | @@ -7,6 +7,8 @@ |
| 7 | 7 | //! |
| 8 | 8 | //! For now, we are developing everything inside `rustc`, thus, we keep this module private. |
| 9 | 9 | |
| 10 | use std::ops::RangeInclusive; | |
| 11 | ||
| 10 | 12 | use rustc_hir::def::DefKind; |
| 11 | 13 | use rustc_middle::mir; |
| 12 | 14 | use rustc_middle::mir::interpret::AllocId; |
| ... | ... | @@ -16,7 +18,6 @@ use stable_mir::abi::Layout; |
| 16 | 18 | use stable_mir::mir::mono::InstanceDef; |
| 17 | 19 | use stable_mir::ty::{MirConstId, Span, TyConstId}; |
| 18 | 20 | use stable_mir::{CtorKind, ItemKind}; |
| 19 | use std::ops::RangeInclusive; | |
| 20 | 21 | use tracing::debug; |
| 21 | 22 | |
| 22 | 23 | use crate::rustc_internal::IndexMap; |
compiler/rustc_span/src/caching_source_map_view.rs+4-2| ... | ... | @@ -1,7 +1,9 @@ |
| 1 | use std::ops::Range; | |
| 2 | ||
| 3 | use rustc_data_structures::sync::Lrc; | |
| 4 | ||
| 1 | 5 | use crate::source_map::SourceMap; |
| 2 | 6 | use crate::{BytePos, Pos, RelativeBytePos, SourceFile, SpanData}; |
| 3 | use rustc_data_structures::sync::Lrc; | |
| 4 | use std::ops::Range; | |
| 5 | 7 | |
| 6 | 8 | #[derive(Clone)] |
| 7 | 9 | struct CacheEntry { |
compiler/rustc_span/src/def_id.rs+5-3| ... | ... | @@ -1,4 +1,6 @@ |
| 1 | use crate::{HashStableContext, SpanDecoder, SpanEncoder, Symbol}; | |
| 1 | use std::fmt; | |
| 2 | use std::hash::{BuildHasherDefault, Hash, Hasher}; | |
| 3 | ||
| 2 | 4 | use rustc_data_structures::fingerprint::Fingerprint; |
| 3 | 5 | use rustc_data_structures::stable_hasher::{ |
| 4 | 6 | Hash64, HashStable, StableHasher, StableOrd, ToStableHashKey, |
| ... | ... | @@ -8,8 +10,8 @@ use rustc_data_structures::AtomicRef; |
| 8 | 10 | use rustc_index::Idx; |
| 9 | 11 | use rustc_macros::{Decodable, Encodable, HashStable_Generic}; |
| 10 | 12 | use rustc_serialize::{Decodable, Encodable}; |
| 11 | use std::fmt; | |
| 12 | use std::hash::{BuildHasherDefault, Hash, Hasher}; | |
| 13 | ||
| 14 | use crate::{HashStableContext, SpanDecoder, SpanEncoder, Symbol}; | |
| 13 | 15 | |
| 14 | 16 | pub type StableCrateIdMap = |
| 15 | 17 | indexmap::IndexMap<StableCrateId, CrateNum, BuildHasherDefault<Unhasher>>; |
compiler/rustc_span/src/edit_distance.rs+2-1| ... | ... | @@ -9,9 +9,10 @@ |
| 9 | 9 | // algorithm should not matter to the caller of the methods, which is why it is not noted in the |
| 10 | 10 | // documentation. |
| 11 | 11 | |
| 12 | use crate::symbol::Symbol; | |
| 13 | 12 | use std::{cmp, mem}; |
| 14 | 13 | |
| 14 | use crate::symbol::Symbol; | |
| 15 | ||
| 15 | 16 | #[cfg(test)] |
| 16 | 17 | mod tests; |
| 17 | 18 |
compiler/rustc_span/src/hygiene.rs+10-8| ... | ... | @@ -24,10 +24,11 @@ |
| 24 | 24 | // because getting it wrong can lead to nested `HygieneData::with` calls that |
| 25 | 25 | // trigger runtime aborts. (Fortunately these are obvious and easy to fix.) |
| 26 | 26 | |
| 27 | use crate::def_id::{CrateNum, DefId, StableCrateId, CRATE_DEF_ID, LOCAL_CRATE}; | |
| 28 | use crate::edition::Edition; | |
| 29 | use crate::symbol::{kw, sym, Symbol}; | |
| 30 | use crate::{with_session_globals, HashStableContext, Span, SpanDecoder, SpanEncoder, DUMMY_SP}; | |
| 27 | use std::cell::RefCell; | |
| 28 | use std::collections::hash_map::Entry; | |
| 29 | use std::fmt; | |
| 30 | use std::hash::Hash; | |
| 31 | ||
| 31 | 32 | use rustc_data_structures::fingerprint::Fingerprint; |
| 32 | 33 | use rustc_data_structures::fx::{FxHashMap, FxHashSet}; |
| 33 | 34 | use rustc_data_structures::stable_hasher::{Hash64, HashStable, HashingControls, StableHasher}; |
| ... | ... | @@ -36,12 +37,13 @@ use rustc_data_structures::unhash::UnhashMap; |
| 36 | 37 | use rustc_index::IndexVec; |
| 37 | 38 | use rustc_macros::{Decodable, Encodable, HashStable_Generic}; |
| 38 | 39 | use rustc_serialize::{Decodable, Decoder, Encodable, Encoder}; |
| 39 | use std::cell::RefCell; | |
| 40 | use std::collections::hash_map::Entry; | |
| 41 | use std::fmt; | |
| 42 | use std::hash::Hash; | |
| 43 | 40 | use tracing::{debug, trace}; |
| 44 | 41 | |
| 42 | use crate::def_id::{CrateNum, DefId, StableCrateId, CRATE_DEF_ID, LOCAL_CRATE}; | |
| 43 | use crate::edition::Edition; | |
| 44 | use crate::symbol::{kw, sym, Symbol}; | |
| 45 | use crate::{with_session_globals, HashStableContext, Span, SpanDecoder, SpanEncoder, DUMMY_SP}; | |
| 46 | ||
| 45 | 47 | /// A `SyntaxContext` represents a chain of pairs `(ExpnId, Transparency)` named "marks". |
| 46 | 48 | #[derive(Clone, Copy, PartialEq, Eq, Hash)] |
| 47 | 49 | pub struct SyntaxContext(u32); |
compiler/rustc_span/src/lib.rs+9-9| ... | ... | @@ -47,15 +47,17 @@ use tracing::debug; |
| 47 | 47 | |
| 48 | 48 | mod caching_source_map_view; |
| 49 | 49 | pub mod source_map; |
| 50 | pub use self::caching_source_map_view::CachingSourceMapView; | |
| 51 | 50 | use source_map::{SourceMap, SourceMapInputs}; |
| 52 | 51 | |
| 52 | pub use self::caching_source_map_view::CachingSourceMapView; | |
| 53 | ||
| 53 | 54 | pub mod edition; |
| 54 | 55 | use edition::Edition; |
| 55 | 56 | pub mod hygiene; |
| 56 | 57 | use hygiene::Transparency; |
| 57 | pub use hygiene::{DesugaringKind, ExpnKind, MacroKind}; | |
| 58 | pub use hygiene::{ExpnData, ExpnHash, ExpnId, LocalExpnId, SyntaxContext}; | |
| 58 | pub use hygiene::{ | |
| 59 | DesugaringKind, ExpnData, ExpnHash, ExpnId, ExpnKind, LocalExpnId, MacroKind, SyntaxContext, | |
| 60 | }; | |
| 59 | 61 | use rustc_data_structures::stable_hasher::HashingControls; |
| 60 | 62 | pub mod def_id; |
| 61 | 63 | use def_id::{CrateNum, DefId, DefIndex, DefPathHash, LocalDefId, StableCrateId, LOCAL_CRATE}; |
| ... | ... | @@ -71,10 +73,6 @@ pub mod fatal_error; |
| 71 | 73 | |
| 72 | 74 | pub mod profiling; |
| 73 | 75 | |
| 74 | use rustc_data_structures::fx::FxHashMap; | |
| 75 | use rustc_data_structures::stable_hasher::{Hash128, Hash64, HashStable, StableHasher}; | |
| 76 | use rustc_data_structures::sync::{FreezeLock, FreezeWriteGuard, Lock, Lrc}; | |
| 77 | ||
| 78 | 76 | use std::borrow::Cow; |
| 79 | 77 | use std::cmp::{self, Ordering}; |
| 80 | 78 | use std::hash::Hash; |
| ... | ... | @@ -83,8 +81,10 @@ use std::path::{Path, PathBuf}; |
| 83 | 81 | use std::str::FromStr; |
| 84 | 82 | use std::{fmt, iter}; |
| 85 | 83 | |
| 86 | use md5::Digest; | |
| 87 | use md5::Md5; | |
| 84 | use md5::{Digest, Md5}; | |
| 85 | use rustc_data_structures::fx::FxHashMap; | |
| 86 | use rustc_data_structures::stable_hasher::{Hash128, Hash64, HashStable, StableHasher}; | |
| 87 | use rustc_data_structures::sync::{FreezeLock, FreezeWriteGuard, Lock, Lrc}; | |
| 88 | 88 | use sha1::Sha1; |
| 89 | 89 | use sha2::Sha256; |
| 90 | 90 |
compiler/rustc_span/src/profiling.rs+2-2| ... | ... | @@ -1,9 +1,9 @@ |
| 1 | use crate::source_map::SourceMap; | |
| 2 | ||
| 3 | 1 | use std::borrow::Borrow; |
| 4 | 2 | |
| 5 | 3 | use rustc_data_structures::profiling::EventArgRecorder; |
| 6 | 4 | |
| 5 | use crate::source_map::SourceMap; | |
| 6 | ||
| 7 | 7 | /// Extension trait for self-profiling purposes: allows to record spans within a generic activity's |
| 8 | 8 | /// event arguments. |
| 9 | 9 | pub trait SpannedEventArgRecorder { |
compiler/rustc_span/src/source_map.rs+5-4| ... | ... | @@ -9,15 +9,16 @@ |
| 9 | 9 | //! within the `SourceMap`, which upon request can be converted to line and column |
| 10 | 10 | //! information, source code snippets, etc. |
| 11 | 11 | |
| 12 | use crate::*; | |
| 12 | use std::io::{self, BorrowedBuf, Read}; | |
| 13 | use std::{fs, path}; | |
| 14 | ||
| 13 | 15 | use rustc_data_structures::sync::{IntoDynSyncSend, MappedReadGuard, ReadGuard, RwLock}; |
| 14 | 16 | use rustc_data_structures::unhash::UnhashMap; |
| 15 | 17 | use rustc_macros::{Decodable, Encodable}; |
| 16 | use std::fs; | |
| 17 | use std::io::{self, BorrowedBuf, Read}; | |
| 18 | use std::path; | |
| 19 | 18 | use tracing::{debug, instrument, trace}; |
| 20 | 19 | |
| 20 | use crate::*; | |
| 21 | ||
| 21 | 22 | #[cfg(test)] |
| 22 | 23 | mod tests; |
| 23 | 24 |
compiler/rustc_span/src/span_encoding.rs+4-6| ... | ... | @@ -1,14 +1,12 @@ |
| 1 | use crate::def_id::{DefIndex, LocalDefId}; | |
| 2 | use crate::hygiene::SyntaxContext; | |
| 3 | use crate::SPAN_TRACK; | |
| 4 | use crate::{BytePos, SpanData}; | |
| 5 | ||
| 6 | 1 | use rustc_data_structures::fx::FxIndexSet; |
| 7 | ||
| 8 | 2 | // This code is very hot and uses lots of arithmetic, avoid overflow checks for performance. |
| 9 | 3 | // See https://github.com/rust-lang/rust/pull/119440#issuecomment-1874255727 |
| 10 | 4 | use rustc_serialize::int_overflow::DebugStrictAdd; |
| 11 | 5 | |
| 6 | use crate::def_id::{DefIndex, LocalDefId}; | |
| 7 | use crate::hygiene::SyntaxContext; | |
| 8 | use crate::{BytePos, SpanData, SPAN_TRACK}; | |
| 9 | ||
| 12 | 10 | /// A compressed span. |
| 13 | 11 | /// |
| 14 | 12 | /// [`SpanData`] is 16 bytes, which is too big to stick everywhere. `Span` only |
compiler/rustc_span/src/symbol.rs+6-9| ... | ... | @@ -2,6 +2,9 @@ |
| 2 | 2 | //! allows bidirectional lookup; i.e., given a value, one can easily find the |
| 3 | 3 | //! type, and vice versa. |
| 4 | 4 | |
| 5 | use std::hash::{Hash, Hasher}; | |
| 6 | use std::{fmt, str}; | |
| 7 | ||
| 5 | 8 | use rustc_arena::DroplessArena; |
| 6 | 9 | use rustc_data_structures::fx::FxIndexSet; |
| 7 | 10 | use rustc_data_structures::stable_hasher::{ |
| ... | ... | @@ -10,10 +13,6 @@ use rustc_data_structures::stable_hasher::{ |
| 10 | 13 | use rustc_data_structures::sync::Lock; |
| 11 | 14 | use rustc_macros::{symbols, Decodable, Encodable, HashStable_Generic}; |
| 12 | 15 | |
| 13 | use std::fmt; | |
| 14 | use std::hash::{Hash, Hasher}; | |
| 15 | use std::str; | |
| 16 | ||
| 17 | 16 | use crate::{with_session_globals, Edition, Span, DUMMY_SP}; |
| 18 | 17 | |
| 19 | 18 | #[cfg(test)] |
| ... | ... | @@ -2446,13 +2445,11 @@ pub mod kw { |
| 2446 | 2445 | /// Given that `sym` is imported, use them like `sym::symbol_name`. |
| 2447 | 2446 | /// For example `sym::rustfmt` or `sym::u8`. |
| 2448 | 2447 | pub mod sym { |
| 2449 | use super::Symbol; | |
| 2450 | ||
| 2451 | #[doc(inline)] | |
| 2452 | pub use super::sym_generated::*; | |
| 2453 | ||
| 2454 | 2448 | // Used from a macro in `librustc_feature/accepted.rs` |
| 2455 | 2449 | pub use super::kw::MacroRules as macro_rules; |
| 2450 | #[doc(inline)] | |
| 2451 | pub use super::sym_generated::*; | |
| 2452 | use super::Symbol; | |
| 2456 | 2453 | |
| 2457 | 2454 | /// Get the symbol for an integer. |
| 2458 | 2455 | /// |
compiler/rustc_span/src/symbol/tests.rs-1| ... | ... | @@ -1,5 +1,4 @@ |
| 1 | 1 | use super::*; |
| 2 | ||
| 3 | 2 | use crate::create_default_session_globals_then; |
| 4 | 3 | |
| 5 | 4 | #[test] |
compiler/rustc_symbol_mangling/src/errors.rs+2-1| ... | ... | @@ -1,8 +1,9 @@ |
| 1 | 1 | //! Errors emitted by symbol_mangling. |
| 2 | 2 | |
| 3 | use std::fmt; | |
| 4 | ||
| 3 | 5 | use rustc_errors::{Diag, DiagCtxtHandle, Diagnostic, EmissionGuarantee, Level}; |
| 4 | 6 | use rustc_span::Span; |
| 5 | use std::fmt; | |
| 6 | 7 | |
| 7 | 8 | pub struct TestOutput { |
| 8 | 9 | pub span: Span, |
compiler/rustc_symbol_mangling/src/hashed.rs+3-2| ... | ... | @@ -1,9 +1,10 @@ |
| 1 | use crate::v0; | |
| 1 | use std::fmt::Write; | |
| 2 | ||
| 2 | 3 | use rustc_data_structures::stable_hasher::{Hash64, HashStable, StableHasher}; |
| 3 | 4 | use rustc_hir::def_id::CrateNum; |
| 4 | 5 | use rustc_middle::ty::{Instance, TyCtxt}; |
| 5 | 6 | |
| 6 | use std::fmt::Write; | |
| 7 | use crate::v0; | |
| 7 | 8 | |
| 8 | 9 | pub(super) fn mangle<'tcx>( |
| 9 | 10 | tcx: TyCtxt<'tcx>, |
compiler/rustc_symbol_mangling/src/legacy.rs+6-4| ... | ... | @@ -1,12 +1,14 @@ |
| 1 | use std::fmt::{self, Write}; | |
| 2 | use std::mem::{self, discriminant}; | |
| 3 | ||
| 1 | 4 | use rustc_data_structures::stable_hasher::{Hash64, HashStable, StableHasher}; |
| 2 | 5 | use rustc_hir::def_id::CrateNum; |
| 3 | 6 | use rustc_hir::definitions::{DefPathData, DisambiguatedDefPathData}; |
| 4 | 7 | use rustc_middle::bug; |
| 5 | 8 | use rustc_middle::ty::print::{PrettyPrinter, Print, PrintError, Printer}; |
| 6 | use rustc_middle::ty::{self, Instance, ReifyReason, Ty, TyCtxt, TypeVisitableExt}; | |
| 7 | use rustc_middle::ty::{GenericArg, GenericArgKind}; | |
| 8 | use std::fmt::{self, Write}; | |
| 9 | use std::mem::{self, discriminant}; | |
| 9 | use rustc_middle::ty::{ | |
| 10 | self, GenericArg, GenericArgKind, Instance, ReifyReason, Ty, TyCtxt, TypeVisitableExt, | |
| 11 | }; | |
| 10 | 12 | use tracing::debug; |
| 11 | 13 | |
| 12 | 14 | pub(super) fn mangle<'tcx>( |
compiler/rustc_symbol_mangling/src/lib.rs+1-2| ... | ... | @@ -97,8 +97,7 @@ |
| 97 | 97 | |
| 98 | 98 | use rustc_hir::def::DefKind; |
| 99 | 99 | use rustc_hir::def_id::{CrateNum, LOCAL_CRATE}; |
| 100 | use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags; | |
| 101 | use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrs; | |
| 100 | use rustc_middle::middle::codegen_fn_attrs::{CodegenFnAttrFlags, CodegenFnAttrs}; | |
| 102 | 101 | use rustc_middle::mir::mono::{InstantiationMode, MonoItem}; |
| 103 | 102 | use rustc_middle::query::Providers; |
| 104 | 103 | use rustc_middle::ty::{self, Instance, TyCtxt}; |
compiler/rustc_symbol_mangling/src/test.rs+2-1| ... | ... | @@ -4,12 +4,13 @@ |
| 4 | 4 | //! def-path. This is used for unit testing the code that generates |
| 5 | 5 | //! paths etc in all kinds of annoying scenarios. |
| 6 | 6 | |
| 7 | use crate::errors::{Kind, TestOutput}; | |
| 8 | 7 | use rustc_hir::def_id::LocalDefId; |
| 9 | 8 | use rustc_middle::ty::print::with_no_trimmed_paths; |
| 10 | 9 | use rustc_middle::ty::{GenericArgs, Instance, TyCtxt}; |
| 11 | 10 | use rustc_span::symbol::{sym, Symbol}; |
| 12 | 11 | |
| 12 | use crate::errors::{Kind, TestOutput}; | |
| 13 | ||
| 13 | 14 | const SYMBOL_NAME: Symbol = sym::rustc_symbol_name; |
| 14 | 15 | const DEF_PATH: Symbol = sym::rustc_def_path; |
| 15 | 16 |
compiler/rustc_symbol_mangling/src/v0.rs+6-7| ... | ... | @@ -1,3 +1,7 @@ |
| 1 | use std::fmt::Write; | |
| 2 | use std::iter; | |
| 3 | use std::ops::Range; | |
| 4 | ||
| 1 | 5 | use rustc_data_structures::base_n::ToBaseN; |
| 2 | 6 | use rustc_data_structures::fx::FxHashMap; |
| 3 | 7 | use rustc_data_structures::intern::Interned; |
| ... | ... | @@ -9,18 +13,13 @@ use rustc_middle::bug; |
| 9 | 13 | use rustc_middle::ty::layout::IntegerExt; |
| 10 | 14 | use rustc_middle::ty::print::{Print, PrintError, Printer}; |
| 11 | 15 | use rustc_middle::ty::{ |
| 12 | self, EarlyBinder, FloatTy, Instance, IntTy, ReifyReason, Ty, TyCtxt, TypeVisitable, | |
| 13 | TypeVisitableExt, UintTy, | |
| 16 | self, EarlyBinder, FloatTy, GenericArg, GenericArgKind, Instance, IntTy, ReifyReason, Ty, | |
| 17 | TyCtxt, TypeVisitable, TypeVisitableExt, UintTy, | |
| 14 | 18 | }; |
| 15 | use rustc_middle::ty::{GenericArg, GenericArgKind}; | |
| 16 | 19 | use rustc_span::symbol::kw; |
| 17 | 20 | use rustc_target::abi::Integer; |
| 18 | 21 | use rustc_target::spec::abi::Abi; |
| 19 | 22 | |
| 20 | use std::fmt::Write; | |
| 21 | use std::iter; | |
| 22 | use std::ops::Range; | |
| 23 | ||
| 24 | 23 | pub(super) fn mangle<'tcx>( |
| 25 | 24 | tcx: TyCtxt<'tcx>, |
| 26 | 25 | instance: Instance<'tcx>, |
compiler/rustc_target/src/abi/call/mod.rs+8-6| ... | ... | @@ -1,11 +1,12 @@ |
| 1 | use crate::abi::{self, Abi, Align, FieldsShape, Size}; | |
| 2 | use crate::abi::{HasDataLayout, TyAbiInterface, TyAndLayout}; | |
| 3 | use crate::spec::{self, HasTargetSpec, HasWasmCAbiOpt, WasmCAbi}; | |
| 4 | use rustc_macros::HashStable_Generic; | |
| 5 | use rustc_span::Symbol; | |
| 6 | 1 | use std::fmt; |
| 7 | 2 | use std::str::FromStr; |
| 8 | 3 | |
| 4 | use rustc_macros::HashStable_Generic; | |
| 5 | use rustc_span::Symbol; | |
| 6 | ||
| 7 | use crate::abi::{self, Abi, Align, FieldsShape, HasDataLayout, Size, TyAbiInterface, TyAndLayout}; | |
| 8 | use crate::spec::{self, HasTargetSpec, HasWasmCAbiOpt, WasmCAbi}; | |
| 9 | ||
| 9 | 10 | mod aarch64; |
| 10 | 11 | mod amdgpu; |
| 11 | 12 | mod arm; |
| ... | ... | @@ -967,8 +968,9 @@ impl FromStr for Conv { |
| 967 | 968 | // Some types are used a lot. Make sure they don't unintentionally get bigger. |
| 968 | 969 | #[cfg(target_pointer_width = "64")] |
| 969 | 970 | mod size_asserts { |
| 970 | use super::*; | |
| 971 | 971 | use rustc_data_structures::static_assert_size; |
| 972 | ||
| 973 | use super::*; | |
| 972 | 974 | // tidy-alphabetical-start |
| 973 | 975 | static_assert_size!(ArgAbi<'_, usize>, 56); |
| 974 | 976 | static_assert_size!(FnAbi<'_, usize>, 80); |
compiler/rustc_target/src/abi/call/nvptx64.rs+1-2| ... | ... | @@ -1,8 +1,7 @@ |
| 1 | use super::{ArgAttribute, ArgAttributes, ArgExtension, CastTarget}; | |
| 1 | 2 | use crate::abi::call::{ArgAbi, FnAbi, PassMode, Reg, Size, Uniform}; |
| 2 | 3 | use crate::abi::{HasDataLayout, TyAbiInterface}; |
| 3 | 4 | |
| 4 | use super::{ArgAttribute, ArgAttributes, ArgExtension, CastTarget}; | |
| 5 | ||
| 6 | 5 | fn classify_ret<Ty>(ret: &mut ArgAbi<'_, Ty>) { |
| 7 | 6 | if ret.layout.is_aggregate() && ret.layout.is_sized() { |
| 8 | 7 | classify_aggregate(ret) |
compiler/rustc_target/src/abi/mod.rs+4-5| ... | ... | @@ -1,15 +1,14 @@ |
| 1 | use std::fmt; | |
| 2 | use std::ops::Deref; | |
| 3 | ||
| 1 | 4 | use rustc_data_structures::intern::Interned; |
| 5 | use rustc_macros::HashStable_Generic; | |
| 2 | 6 | pub use Float::*; |
| 3 | 7 | pub use Integer::*; |
| 4 | 8 | pub use Primitive::*; |
| 5 | 9 | |
| 6 | 10 | use crate::json::{Json, ToJson}; |
| 7 | 11 | |
| 8 | use std::fmt; | |
| 9 | use std::ops::Deref; | |
| 10 | ||
| 11 | use rustc_macros::HashStable_Generic; | |
| 12 | ||
| 13 | 12 | pub mod call; |
| 14 | 13 | |
| 15 | 14 | // Explicitly import `Float` to avoid ambiguity with `Primitive::Float`. |
compiler/rustc_target/src/asm/aarch64.rs+5-3| ... | ... | @@ -1,8 +1,10 @@ |
| 1 | use super::{InlineAsmArch, InlineAsmType, ModifierInfo}; | |
| 2 | use crate::spec::{RelocModel, Target}; | |
| 1 | use std::fmt; | |
| 2 | ||
| 3 | 3 | use rustc_data_structures::fx::FxIndexSet; |
| 4 | 4 | use rustc_span::Symbol; |
| 5 | use std::fmt; | |
| 5 | ||
| 6 | use super::{InlineAsmArch, InlineAsmType, ModifierInfo}; | |
| 7 | use crate::spec::{RelocModel, Target}; | |
| 6 | 8 | |
| 7 | 9 | def_reg_class! { |
| 8 | 10 | AArch64 AArch64InlineAsmRegClass { |
compiler/rustc_target/src/asm/arm.rs+5-3| ... | ... | @@ -1,8 +1,10 @@ |
| 1 | use super::{InlineAsmArch, InlineAsmType, ModifierInfo}; | |
| 2 | use crate::spec::{RelocModel, Target}; | |
| 1 | use std::fmt; | |
| 2 | ||
| 3 | 3 | use rustc_data_structures::fx::FxIndexSet; |
| 4 | 4 | use rustc_span::{sym, Symbol}; |
| 5 | use std::fmt; | |
| 5 | ||
| 6 | use super::{InlineAsmArch, InlineAsmType, ModifierInfo}; | |
| 7 | use crate::spec::{RelocModel, Target}; | |
| 6 | 8 | |
| 7 | 9 | def_reg_class! { |
| 8 | 10 | Arm ArmInlineAsmRegClass { |
compiler/rustc_target/src/asm/avr.rs+4-2| ... | ... | @@ -1,7 +1,9 @@ |
| 1 | use super::{InlineAsmArch, InlineAsmType, ModifierInfo}; | |
| 2 | use rustc_span::Symbol; | |
| 3 | 1 | use std::fmt; |
| 4 | 2 | |
| 3 | use rustc_span::Symbol; | |
| 4 | ||
| 5 | use super::{InlineAsmArch, InlineAsmType, ModifierInfo}; | |
| 6 | ||
| 5 | 7 | def_reg_class! { |
| 6 | 8 | Avr AvrInlineAsmRegClass { |
| 7 | 9 | reg, |
compiler/rustc_target/src/asm/bpf.rs+4-2| ... | ... | @@ -1,7 +1,9 @@ |
| 1 | use super::{InlineAsmArch, InlineAsmType, ModifierInfo}; | |
| 2 | use rustc_span::Symbol; | |
| 3 | 1 | use std::fmt; |
| 4 | 2 | |
| 3 | use rustc_span::Symbol; | |
| 4 | ||
| 5 | use super::{InlineAsmArch, InlineAsmType, ModifierInfo}; | |
| 6 | ||
| 5 | 7 | def_reg_class! { |
| 6 | 8 | Bpf BpfInlineAsmRegClass { |
| 7 | 9 | reg, |
compiler/rustc_target/src/asm/csky.rs+4-2| ... | ... | @@ -1,7 +1,9 @@ |
| 1 | use super::{InlineAsmArch, InlineAsmType, ModifierInfo}; | |
| 2 | use rustc_span::Symbol; | |
| 3 | 1 | use std::fmt; |
| 4 | 2 | |
| 3 | use rustc_span::Symbol; | |
| 4 | ||
| 5 | use super::{InlineAsmArch, InlineAsmType, ModifierInfo}; | |
| 6 | ||
| 5 | 7 | def_reg_class! { |
| 6 | 8 | CSKY CSKYInlineAsmRegClass { |
| 7 | 9 | reg, |
compiler/rustc_target/src/asm/hexagon.rs+4-2| ... | ... | @@ -1,7 +1,9 @@ |
| 1 | use super::{InlineAsmArch, InlineAsmType, ModifierInfo}; | |
| 2 | use rustc_span::Symbol; | |
| 3 | 1 | use std::fmt; |
| 4 | 2 | |
| 3 | use rustc_span::Symbol; | |
| 4 | ||
| 5 | use super::{InlineAsmArch, InlineAsmType, ModifierInfo}; | |
| 6 | ||
| 5 | 7 | def_reg_class! { |
| 6 | 8 | Hexagon HexagonInlineAsmRegClass { |
| 7 | 9 | reg, |
compiler/rustc_target/src/asm/loongarch.rs+4-2| ... | ... | @@ -1,7 +1,9 @@ |
| 1 | use super::{InlineAsmArch, InlineAsmType, ModifierInfo}; | |
| 2 | use rustc_span::Symbol; | |
| 3 | 1 | use std::fmt; |
| 4 | 2 | |
| 3 | use rustc_span::Symbol; | |
| 4 | ||
| 5 | use super::{InlineAsmArch, InlineAsmType, ModifierInfo}; | |
| 6 | ||
| 5 | 7 | def_reg_class! { |
| 6 | 8 | LoongArch LoongArchInlineAsmRegClass { |
| 7 | 9 | reg, |
compiler/rustc_target/src/asm/m68k.rs+4-2| ... | ... | @@ -1,7 +1,9 @@ |
| 1 | use super::{InlineAsmArch, InlineAsmType, ModifierInfo}; | |
| 2 | use rustc_span::Symbol; | |
| 3 | 1 | use std::fmt; |
| 4 | 2 | |
| 3 | use rustc_span::Symbol; | |
| 4 | ||
| 5 | use super::{InlineAsmArch, InlineAsmType, ModifierInfo}; | |
| 6 | ||
| 5 | 7 | def_reg_class! { |
| 6 | 8 | M68k M68kInlineAsmRegClass { |
| 7 | 9 | reg, |
compiler/rustc_target/src/asm/mips.rs+4-2| ... | ... | @@ -1,7 +1,9 @@ |
| 1 | use super::{InlineAsmArch, InlineAsmType, ModifierInfo}; | |
| 2 | use rustc_span::Symbol; | |
| 3 | 1 | use std::fmt; |
| 4 | 2 | |
| 3 | use rustc_span::Symbol; | |
| 4 | ||
| 5 | use super::{InlineAsmArch, InlineAsmType, ModifierInfo}; | |
| 6 | ||
| 5 | 7 | def_reg_class! { |
| 6 | 8 | Mips MipsInlineAsmRegClass { |
| 7 | 9 | reg, |
compiler/rustc_target/src/asm/mod.rs+6-4| ... | ... | @@ -1,10 +1,12 @@ |
| 1 | use crate::spec::Target; | |
| 2 | use crate::{abi::Size, spec::RelocModel}; | |
| 1 | use std::fmt; | |
| 2 | use std::str::FromStr; | |
| 3 | ||
| 3 | 4 | use rustc_data_structures::fx::{FxHashMap, FxIndexSet}; |
| 4 | 5 | use rustc_macros::{Decodable, Encodable, HashStable_Generic}; |
| 5 | 6 | use rustc_span::Symbol; |
| 6 | use std::fmt; | |
| 7 | use std::str::FromStr; | |
| 7 | ||
| 8 | use crate::abi::Size; | |
| 9 | use crate::spec::{RelocModel, Target}; | |
| 8 | 10 | |
| 9 | 11 | pub struct ModifierInfo { |
| 10 | 12 | pub modifier: char, |
compiler/rustc_target/src/asm/msp430.rs+4-2| ... | ... | @@ -1,7 +1,9 @@ |
| 1 | use super::{InlineAsmArch, InlineAsmType, ModifierInfo}; | |
| 2 | use rustc_span::Symbol; | |
| 3 | 1 | use std::fmt; |
| 4 | 2 | |
| 3 | use rustc_span::Symbol; | |
| 4 | ||
| 5 | use super::{InlineAsmArch, InlineAsmType, ModifierInfo}; | |
| 6 | ||
| 5 | 7 | def_reg_class! { |
| 6 | 8 | Msp430 Msp430InlineAsmRegClass { |
| 7 | 9 | reg, |
compiler/rustc_target/src/asm/nvptx.rs+2-1| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | use super::{InlineAsmArch, InlineAsmType, ModifierInfo}; | |
| 2 | 1 | use rustc_span::Symbol; |
| 3 | 2 | |
| 3 | use super::{InlineAsmArch, InlineAsmType, ModifierInfo}; | |
| 4 | ||
| 4 | 5 | def_reg_class! { |
| 5 | 6 | Nvptx NvptxInlineAsmRegClass { |
| 6 | 7 | reg16, |
compiler/rustc_target/src/asm/powerpc.rs+4-2| ... | ... | @@ -1,7 +1,9 @@ |
| 1 | use super::{InlineAsmArch, InlineAsmType, ModifierInfo}; | |
| 2 | use rustc_span::Symbol; | |
| 3 | 1 | use std::fmt; |
| 4 | 2 | |
| 3 | use rustc_span::Symbol; | |
| 4 | ||
| 5 | use super::{InlineAsmArch, InlineAsmType, ModifierInfo}; | |
| 6 | ||
| 5 | 7 | def_reg_class! { |
| 6 | 8 | PowerPC PowerPCInlineAsmRegClass { |
| 7 | 9 | reg, |
compiler/rustc_target/src/asm/riscv.rs+5-3| ... | ... | @@ -1,8 +1,10 @@ |
| 1 | use super::{InlineAsmArch, InlineAsmType, ModifierInfo}; | |
| 2 | use crate::spec::{RelocModel, Target}; | |
| 1 | use std::fmt; | |
| 2 | ||
| 3 | 3 | use rustc_data_structures::fx::FxIndexSet; |
| 4 | 4 | use rustc_span::{sym, Symbol}; |
| 5 | use std::fmt; | |
| 5 | ||
| 6 | use super::{InlineAsmArch, InlineAsmType, ModifierInfo}; | |
| 7 | use crate::spec::{RelocModel, Target}; | |
| 6 | 8 | |
| 7 | 9 | def_reg_class! { |
| 8 | 10 | RiscV RiscVInlineAsmRegClass { |
compiler/rustc_target/src/asm/s390x.rs+4-2| ... | ... | @@ -1,7 +1,9 @@ |
| 1 | use super::{InlineAsmArch, InlineAsmType, ModifierInfo}; | |
| 2 | use rustc_span::Symbol; | |
| 3 | 1 | use std::fmt; |
| 4 | 2 | |
| 3 | use rustc_span::Symbol; | |
| 4 | ||
| 5 | use super::{InlineAsmArch, InlineAsmType, ModifierInfo}; | |
| 6 | ||
| 5 | 7 | def_reg_class! { |
| 6 | 8 | S390x S390xInlineAsmRegClass { |
| 7 | 9 | reg, |
compiler/rustc_target/src/asm/spirv.rs+2-1| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | use super::{InlineAsmArch, InlineAsmType, ModifierInfo}; | |
| 2 | 1 | use rustc_span::Symbol; |
| 3 | 2 | |
| 3 | use super::{InlineAsmArch, InlineAsmType, ModifierInfo}; | |
| 4 | ||
| 4 | 5 | def_reg_class! { |
| 5 | 6 | SpirV SpirVInlineAsmRegClass { |
| 6 | 7 | reg, |
compiler/rustc_target/src/asm/wasm.rs+2-1| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | use super::{InlineAsmArch, InlineAsmType, ModifierInfo}; | |
| 2 | 1 | use rustc_span::Symbol; |
| 3 | 2 | |
| 3 | use super::{InlineAsmArch, InlineAsmType, ModifierInfo}; | |
| 4 | ||
| 4 | 5 | def_reg_class! { |
| 5 | 6 | Wasm WasmInlineAsmRegClass { |
| 6 | 7 | local, |
compiler/rustc_target/src/asm/x86.rs+5-3| ... | ... | @@ -1,8 +1,10 @@ |
| 1 | use super::{InlineAsmArch, InlineAsmType, ModifierInfo}; | |
| 2 | use crate::spec::{RelocModel, Target}; | |
| 1 | use std::fmt; | |
| 2 | ||
| 3 | 3 | use rustc_data_structures::fx::FxIndexSet; |
| 4 | 4 | use rustc_span::Symbol; |
| 5 | use std::fmt; | |
| 5 | ||
| 6 | use super::{InlineAsmArch, InlineAsmType, ModifierInfo}; | |
| 7 | use crate::spec::{RelocModel, Target}; | |
| 6 | 8 | |
| 7 | 9 | def_reg_class! { |
| 8 | 10 | X86 X86InlineAsmRegClass { |
compiler/rustc_target/src/spec/base/apple/mod.rs+6-4| ... | ... | @@ -1,8 +1,10 @@ |
| 1 | use std::{borrow::Cow, env}; | |
| 1 | use std::borrow::Cow; | |
| 2 | use std::env; | |
| 2 | 3 | |
| 3 | use crate::spec::{add_link_args, add_link_args_iter}; | |
| 4 | use crate::spec::{cvs, Cc, DebuginfoKind, FramePointer, LinkArgs, LinkerFlavor, Lld}; | |
| 5 | use crate::spec::{SplitDebuginfo, StackProbeType, StaticCow, Target, TargetOptions}; | |
| 4 | use crate::spec::{ | |
| 5 | add_link_args, add_link_args_iter, cvs, Cc, DebuginfoKind, FramePointer, LinkArgs, | |
| 6 | LinkerFlavor, Lld, SplitDebuginfo, StackProbeType, StaticCow, Target, TargetOptions, | |
| 7 | }; | |
| 6 | 8 | |
| 7 | 9 | #[cfg(test)] |
| 8 | 10 | mod tests; |
compiler/rustc_target/src/spec/base/avr_gnu.rs+2-1| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | use crate::spec::{Cc, LinkerFlavor, Lld, RelocModel, Target, TargetOptions}; | |
| 2 | 1 | use object::elf; |
| 3 | 2 | |
| 3 | use crate::spec::{Cc, LinkerFlavor, Lld, RelocModel, Target, TargetOptions}; | |
| 4 | ||
| 4 | 5 | /// A base target for AVR devices using the GNU toolchain. |
| 5 | 6 | /// |
| 6 | 7 | /// Requires GNU avr-gcc and avr-binutils on the host system. |
compiler/rustc_target/src/spec/base/linux.rs+2-1| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | use crate::spec::{cvs, RelroLevel, SplitDebuginfo, TargetOptions}; | |
| 2 | 1 | use std::borrow::Cow; |
| 3 | 2 | |
| 3 | use crate::spec::{cvs, RelroLevel, SplitDebuginfo, TargetOptions}; | |
| 4 | ||
| 4 | 5 | pub fn opts() -> TargetOptions { |
| 5 | 6 | TargetOptions { |
| 6 | 7 | os: "linux".into(), |
compiler/rustc_target/src/spec/base/linux_musl.rs+1-2| ... | ... | @@ -1,5 +1,4 @@ |
| 1 | use crate::spec::crt_objects; | |
| 2 | use crate::spec::{base, LinkSelfContainedDefault, TargetOptions}; | |
| 1 | use crate::spec::{base, crt_objects, LinkSelfContainedDefault, TargetOptions}; | |
| 3 | 2 | |
| 4 | 3 | pub fn opts() -> TargetOptions { |
| 5 | 4 | let mut base = base::linux::opts(); |
compiler/rustc_target/src/spec/base/msvc.rs+2-1| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | use crate::spec::{DebuginfoKind, LinkerFlavor, Lld, SplitDebuginfo, TargetOptions}; | |
| 2 | 1 | use std::borrow::Cow; |
| 3 | 2 | |
| 3 | use crate::spec::{DebuginfoKind, LinkerFlavor, Lld, SplitDebuginfo, TargetOptions}; | |
| 4 | ||
| 4 | 5 | pub fn opts() -> TargetOptions { |
| 5 | 6 | // Suppress the verbose logo and authorship debugging output, which would needlessly |
| 6 | 7 | // clog any log files. |
compiler/rustc_target/src/spec/base/windows_gnu.rs+5-3| ... | ... | @@ -1,8 +1,10 @@ |
| 1 | use crate::spec::LinkSelfContainedDefault; | |
| 2 | use crate::spec::{add_link_args, crt_objects}; | |
| 3 | use crate::spec::{cvs, Cc, DebuginfoKind, LinkerFlavor, Lld, SplitDebuginfo, TargetOptions}; | |
| 4 | 1 | use std::borrow::Cow; |
| 5 | 2 | |
| 3 | use crate::spec::{ | |
| 4 | add_link_args, crt_objects, cvs, Cc, DebuginfoKind, LinkSelfContainedDefault, LinkerFlavor, | |
| 5 | Lld, SplitDebuginfo, TargetOptions, | |
| 6 | }; | |
| 7 | ||
| 6 | 8 | pub fn opts() -> TargetOptions { |
| 7 | 9 | let mut pre_link_args = TargetOptions::link_args( |
| 8 | 10 | LinkerFlavor::Gnu(Cc::No, Lld::No), |
compiler/rustc_target/src/spec/base/windows_gnullvm.rs+2-1| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | use crate::spec::{cvs, Cc, DebuginfoKind, LinkerFlavor, Lld, SplitDebuginfo, TargetOptions}; | |
| 2 | 1 | use std::borrow::Cow; |
| 3 | 2 | |
| 3 | use crate::spec::{cvs, Cc, DebuginfoKind, LinkerFlavor, Lld, SplitDebuginfo, TargetOptions}; | |
| 4 | ||
| 4 | 5 | pub fn opts() -> TargetOptions { |
| 5 | 6 | // We cannot use `-nodefaultlibs` because compiler-rt has to be passed |
| 6 | 7 | // as a path since it's not added to linker search path by the default. |
compiler/rustc_target/src/spec/crt_objects.rs+2-1| ... | ... | @@ -40,10 +40,11 @@ |
| 40 | 40 | //! but not gcc's. As a result rustc cannot link with C++ static libraries (#36710) |
| 41 | 41 | //! when linking in self-contained mode. |
| 42 | 42 | |
| 43 | use crate::spec::LinkOutputKind; | |
| 44 | 43 | use std::borrow::Cow; |
| 45 | 44 | use std::collections::BTreeMap; |
| 46 | 45 | |
| 46 | use crate::spec::LinkOutputKind; | |
| 47 | ||
| 47 | 48 | pub type CrtObjects = BTreeMap<LinkOutputKind, Vec<Cow<'static, str>>>; |
| 48 | 49 | |
| 49 | 50 | pub(super) fn new(obj_table: &[(LinkOutputKind, &[&'static str])]) -> CrtObjects { |
compiler/rustc_target/src/spec/mod.rs+17-15| ... | ... | @@ -34,16 +34,6 @@ |
| 34 | 34 | //! the target's settings, though `target-feature` and `link-args` will *add* |
| 35 | 35 | //! to the list specified by the target, rather than replace. |
| 36 | 36 | |
| 37 | use crate::abi::call::Conv; | |
| 38 | use crate::abi::{Endian, Integer, Size, TargetDataLayout, TargetDataLayoutErrors}; | |
| 39 | use crate::json::{Json, ToJson}; | |
| 40 | use crate::spec::abi::Abi; | |
| 41 | use crate::spec::crt_objects::CrtObjects; | |
| 42 | use rustc_fs_util::try_canonicalize; | |
| 43 | use rustc_macros::{Decodable, Encodable, HashStable_Generic}; | |
| 44 | use rustc_serialize::{Decodable, Decoder, Encodable, Encoder}; | |
| 45 | use rustc_span::symbol::{kw, sym, Symbol}; | |
| 46 | use serde_json::Value; | |
| 47 | 37 | use std::borrow::Cow; |
| 48 | 38 | use std::collections::BTreeMap; |
| 49 | 39 | use std::hash::{Hash, Hasher}; |
| ... | ... | @@ -51,15 +41,28 @@ use std::ops::{Deref, DerefMut}; |
| 51 | 41 | use std::path::{Path, PathBuf}; |
| 52 | 42 | use std::str::FromStr; |
| 53 | 43 | use std::{fmt, io}; |
| 44 | ||
| 45 | use rustc_fs_util::try_canonicalize; | |
| 46 | use rustc_macros::{Decodable, Encodable, HashStable_Generic}; | |
| 47 | use rustc_serialize::{Decodable, Decoder, Encodable, Encoder}; | |
| 48 | use rustc_span::symbol::{kw, sym, Symbol}; | |
| 49 | use serde_json::Value; | |
| 54 | 50 | use tracing::debug; |
| 55 | 51 | |
| 52 | use crate::abi::call::Conv; | |
| 53 | use crate::abi::{Endian, Integer, Size, TargetDataLayout, TargetDataLayoutErrors}; | |
| 54 | use crate::json::{Json, ToJson}; | |
| 55 | use crate::spec::abi::Abi; | |
| 56 | use crate::spec::crt_objects::CrtObjects; | |
| 57 | ||
| 56 | 58 | pub mod abi; |
| 57 | 59 | pub mod crt_objects; |
| 58 | 60 | |
| 59 | 61 | mod base; |
| 60 | pub use base::apple::deployment_target as current_apple_deployment_target; | |
| 61 | pub use base::apple::platform as current_apple_platform; | |
| 62 | pub use base::apple::sdk_version as current_apple_sdk_version; | |
| 62 | pub use base::apple::{ | |
| 63 | deployment_target as current_apple_deployment_target, platform as current_apple_platform, | |
| 64 | sdk_version as current_apple_sdk_version, | |
| 65 | }; | |
| 63 | 66 | pub use base::avr_gnu::ef_avr_arch; |
| 64 | 67 | |
| 65 | 68 | /// Linker is called through a C/C++ compiler. |
| ... | ... | @@ -3353,8 +3356,7 @@ impl Target { |
| 3353 | 3356 | target_triple: &TargetTriple, |
| 3354 | 3357 | sysroot: &Path, |
| 3355 | 3358 | ) -> Result<(Target, TargetWarnings), String> { |
| 3356 | use std::env; | |
| 3357 | use std::fs; | |
| 3359 | use std::{env, fs}; | |
| 3358 | 3360 | |
| 3359 | 3361 | fn load_file(path: &Path) -> Result<(Target, TargetWarnings), String> { |
| 3360 | 3362 | let contents = fs::read_to_string(path).map_err(|e| e.to_string())?; |
compiler/rustc_target/src/spec/targets/aarch64_unknown_linux_ohos.rs+1-2| ... | ... | @@ -1,5 +1,4 @@ |
| 1 | use crate::spec::SanitizerSet; | |
| 2 | use crate::spec::{base, StackProbeType, Target, TargetOptions}; | |
| 1 | use crate::spec::{base, SanitizerSet, StackProbeType, Target, TargetOptions}; | |
| 3 | 2 | |
| 4 | 3 | pub fn target() -> Target { |
| 5 | 4 | let mut base = base::linux_ohos::opts(); |
compiler/rustc_target/src/spec/targets/bpfeb_unknown_none.rs+2-2| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | use crate::spec::Target; | |
| 2 | use crate::{abi::Endian, spec::base}; | |
| 1 | use crate::abi::Endian; | |
| 2 | use crate::spec::{base, Target}; | |
| 3 | 3 | |
| 4 | 4 | pub fn target() -> Target { |
| 5 | 5 | Target { |
compiler/rustc_target/src/spec/targets/bpfel_unknown_none.rs+2-2| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | use crate::spec::Target; | |
| 2 | use crate::{abi::Endian, spec::base}; | |
| 1 | use crate::abi::Endian; | |
| 2 | use crate::spec::{base, Target}; | |
| 3 | 3 | |
| 4 | 4 | pub fn target() -> Target { |
| 5 | 5 | Target { |
compiler/rustc_target/src/spec/targets/loongarch64_unknown_none.rs+3-2| ... | ... | @@ -1,5 +1,6 @@ |
| 1 | use crate::spec::{Cc, CodeModel, LinkerFlavor, Lld, PanicStrategy, RelocModel}; | |
| 2 | use crate::spec::{Target, TargetOptions}; | |
| 1 | use crate::spec::{ | |
| 2 | Cc, CodeModel, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions, | |
| 3 | }; | |
| 3 | 4 | |
| 4 | 5 | pub fn target() -> Target { |
| 5 | 6 | Target { |
compiler/rustc_target/src/spec/targets/loongarch64_unknown_none_softfloat.rs+3-2| ... | ... | @@ -1,5 +1,6 @@ |
| 1 | use crate::spec::{Cc, CodeModel, LinkerFlavor, Lld, PanicStrategy, RelocModel}; | |
| 2 | use crate::spec::{Target, TargetOptions}; | |
| 1 | use crate::spec::{ | |
| 2 | Cc, CodeModel, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions, | |
| 3 | }; | |
| 3 | 4 | |
| 4 | 5 | pub fn target() -> Target { |
| 5 | 6 | Target { |
compiler/rustc_target/src/spec/targets/nvptx64_nvidia_cuda.rs+3-2| ... | ... | @@ -1,5 +1,6 @@ |
| 1 | use crate::spec::LinkSelfContainedDefault; | |
| 2 | use crate::spec::{LinkerFlavor, MergeFunctions, PanicStrategy, Target, TargetOptions}; | |
| 1 | use crate::spec::{ | |
| 2 | LinkSelfContainedDefault, LinkerFlavor, MergeFunctions, PanicStrategy, Target, TargetOptions, | |
| 3 | }; | |
| 3 | 4 | |
| 4 | 5 | pub fn target() -> Target { |
| 5 | 6 | Target { |
compiler/rustc_target/src/spec/targets/riscv32im_risc0_zkvm_elf.rs+1-2| ... | ... | @@ -1,5 +1,4 @@ |
| 1 | use crate::spec::{Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel}; | |
| 2 | use crate::spec::{Target, TargetOptions}; | |
| 1 | use crate::spec::{Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions}; | |
| 3 | 2 | |
| 4 | 3 | pub fn target() -> Target { |
| 5 | 4 | Target { |
compiler/rustc_target/src/spec/targets/riscv64gc_unknown_none_elf.rs+4-3| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | use crate::spec::SanitizerSet; | |
| 2 | use crate::spec::{Cc, CodeModel, LinkerFlavor, Lld, PanicStrategy}; | |
| 3 | use crate::spec::{RelocModel, Target, TargetOptions}; | |
| 1 | use crate::spec::{ | |
| 2 | Cc, CodeModel, LinkerFlavor, Lld, PanicStrategy, RelocModel, SanitizerSet, Target, | |
| 3 | TargetOptions, | |
| 4 | }; | |
| 4 | 5 | |
| 5 | 6 | pub fn target() -> Target { |
| 6 | 7 | Target { |
compiler/rustc_target/src/spec/targets/riscv64gc_unknown_nuttx_elf.rs+4-3| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | use crate::spec::SanitizerSet; | |
| 2 | use crate::spec::{cvs, Cc, CodeModel, LinkerFlavor, Lld, PanicStrategy}; | |
| 3 | use crate::spec::{RelocModel, Target, TargetOptions}; | |
| 1 | use crate::spec::{ | |
| 2 | cvs, Cc, CodeModel, LinkerFlavor, Lld, PanicStrategy, RelocModel, SanitizerSet, Target, | |
| 3 | TargetOptions, | |
| 4 | }; | |
| 4 | 5 | |
| 5 | 6 | pub fn target() -> Target { |
| 6 | 7 | Target { |
compiler/rustc_target/src/spec/targets/riscv64imac_unknown_none_elf.rs+4-2| ... | ... | @@ -1,5 +1,7 @@ |
| 1 | use crate::spec::{Cc, CodeModel, LinkerFlavor, Lld, PanicStrategy}; | |
| 2 | use crate::spec::{RelocModel, SanitizerSet, Target, TargetOptions}; | |
| 1 | use crate::spec::{ | |
| 2 | Cc, CodeModel, LinkerFlavor, Lld, PanicStrategy, RelocModel, SanitizerSet, Target, | |
| 3 | TargetOptions, | |
| 4 | }; | |
| 3 | 5 | |
| 4 | 6 | pub fn target() -> Target { |
| 5 | 7 | Target { |
compiler/rustc_target/src/spec/targets/riscv64imac_unknown_nuttx_elf.rs+4-3| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | use crate::spec::SanitizerSet; | |
| 2 | use crate::spec::{cvs, Cc, CodeModel, LinkerFlavor, Lld, PanicStrategy}; | |
| 3 | use crate::spec::{RelocModel, Target, TargetOptions}; | |
| 1 | use crate::spec::{ | |
| 2 | cvs, Cc, CodeModel, LinkerFlavor, Lld, PanicStrategy, RelocModel, SanitizerSet, Target, | |
| 3 | TargetOptions, | |
| 4 | }; | |
| 4 | 5 | |
| 5 | 6 | pub fn target() -> Target { |
| 6 | 7 | Target { |
compiler/rustc_target/src/spec/targets/thumbv4t_none_eabi.rs+1-2| ... | ... | @@ -9,8 +9,7 @@ |
| 9 | 9 | //! The default link script is very likely wrong, so you should use |
| 10 | 10 | //! `-Clink-arg=-Tmy_script.ld` to override that with a correct linker script. |
| 11 | 11 | |
| 12 | use crate::spec::{base, PanicStrategy, RelocModel, Target, TargetOptions}; | |
| 13 | use crate::spec::{cvs, FramePointer}; | |
| 12 | use crate::spec::{base, cvs, FramePointer, PanicStrategy, RelocModel, Target, TargetOptions}; | |
| 14 | 13 | |
| 15 | 14 | pub fn target() -> Target { |
| 16 | 15 | Target { |
compiler/rustc_target/src/spec/targets/wasm32_wasip1.rs+1-3| ... | ... | @@ -10,9 +10,7 @@ |
| 10 | 10 | //! was since renamed to `wasm32-wasip1` after the preview2 target was |
| 11 | 11 | //! introduced. |
| 12 | 12 | |
| 13 | use crate::spec::crt_objects; | |
| 14 | use crate::spec::LinkSelfContainedDefault; | |
| 15 | use crate::spec::{base, Cc, LinkerFlavor, Target}; | |
| 13 | use crate::spec::{base, crt_objects, Cc, LinkSelfContainedDefault, LinkerFlavor, Target}; | |
| 16 | 14 | |
| 17 | 15 | pub fn target() -> Target { |
| 18 | 16 | let mut options = base::wasm::options(); |
compiler/rustc_target/src/spec/targets/wasm32_wasip2.rs+1-3| ... | ... | @@ -16,9 +16,7 @@ |
| 16 | 16 | //! You can see more about wasi at <https://wasi.dev> and the component model at |
| 17 | 17 | //! <https://github.com/WebAssembly/component-model>. |
| 18 | 18 | |
| 19 | use crate::spec::crt_objects; | |
| 20 | use crate::spec::LinkSelfContainedDefault; | |
| 21 | use crate::spec::{base, RelocModel, Target}; | |
| 19 | use crate::spec::{base, crt_objects, LinkSelfContainedDefault, RelocModel, Target}; | |
| 22 | 20 | |
| 23 | 21 | pub fn target() -> Target { |
| 24 | 22 | let mut options = base::wasm::options(); |
compiler/rustc_target/src/spec/targets/x86_64_apple_darwin.rs+1-2| ... | ... | @@ -1,6 +1,5 @@ |
| 1 | 1 | use crate::spec::base::apple::{macos_llvm_target, opts, Arch, TargetAbi}; |
| 2 | use crate::spec::{Cc, FramePointer, LinkerFlavor, Lld, SanitizerSet}; | |
| 3 | use crate::spec::{Target, TargetOptions}; | |
| 2 | use crate::spec::{Cc, FramePointer, LinkerFlavor, Lld, SanitizerSet, Target, TargetOptions}; | |
| 4 | 3 | |
| 5 | 4 | pub fn target() -> Target { |
| 6 | 5 | let arch = Arch::X86_64; |
compiler/rustc_target/src/spec/targets/x86_64_unknown_none.rs+4-2| ... | ... | @@ -4,8 +4,10 @@ |
| 4 | 4 | // `target-cpu` compiler flags to opt-in more hardware-specific |
| 5 | 5 | // features. |
| 6 | 6 | |
| 7 | use crate::spec::{Cc, CodeModel, LinkerFlavor, Lld, PanicStrategy}; | |
| 8 | use crate::spec::{RelroLevel, SanitizerSet, StackProbeType, Target, TargetOptions}; | |
| 7 | use crate::spec::{ | |
| 8 | Cc, CodeModel, LinkerFlavor, Lld, PanicStrategy, RelroLevel, SanitizerSet, StackProbeType, | |
| 9 | Target, TargetOptions, | |
| 10 | }; | |
| 9 | 11 | |
| 10 | 12 | pub fn target() -> Target { |
| 11 | 13 | let opts = TargetOptions { |
compiler/rustc_target/src/spec/targets/x86_64_unknown_uefi.rs+2-4| ... | ... | @@ -5,10 +5,8 @@ |
| 5 | 5 | // The win64 ABI is used. It differs from the sysv64 ABI, so we must use a windows target with |
| 6 | 6 | // LLVM. "x86_64-unknown-windows" is used to get the minimal subset of windows-specific features. |
| 7 | 7 | |
| 8 | use crate::{ | |
| 9 | abi::call::Conv, | |
| 10 | spec::{base, Target}, | |
| 11 | }; | |
| 8 | use crate::abi::call::Conv; | |
| 9 | use crate::spec::{base, Target}; | |
| 12 | 10 | |
| 13 | 11 | pub fn target() -> Target { |
| 14 | 12 | let mut base = base::uefi_msvc::opts(); |
compiler/rustc_target/src/spec/targets/x86_64h_apple_darwin.rs+1-2| ... | ... | @@ -1,6 +1,5 @@ |
| 1 | 1 | use crate::spec::base::apple::{macos_llvm_target, opts, Arch, TargetAbi}; |
| 2 | use crate::spec::{Cc, FramePointer, LinkerFlavor, Lld, SanitizerSet}; | |
| 3 | use crate::spec::{Target, TargetOptions}; | |
| 2 | use crate::spec::{Cc, FramePointer, LinkerFlavor, Lld, SanitizerSet, Target, TargetOptions}; | |
| 4 | 3 | |
| 5 | 4 | pub fn target() -> Target { |
| 6 | 5 | let arch = Arch::X86_64h; |
compiler/rustc_target/src/spec/targets/xtensa_esp32_espidf.rs+2-1| ... | ... | @@ -1,5 +1,6 @@ |
| 1 | 1 | use crate::abi::Endian; |
| 2 | use crate::spec::{base::xtensa, cvs, Target, TargetOptions}; | |
| 2 | use crate::spec::base::xtensa; | |
| 3 | use crate::spec::{cvs, Target, TargetOptions}; | |
| 3 | 4 | |
| 4 | 5 | pub fn target() -> Target { |
| 5 | 6 | Target { |
compiler/rustc_target/src/spec/targets/xtensa_esp32_none_elf.rs+2-1| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | use crate::spec::{base::xtensa, Target, TargetOptions}; | |
| 1 | use crate::spec::base::xtensa; | |
| 2 | use crate::spec::{Target, TargetOptions}; | |
| 2 | 3 | |
| 3 | 4 | pub fn target() -> Target { |
| 4 | 5 | Target { |
compiler/rustc_target/src/spec/targets/xtensa_esp32s2_espidf.rs+2-1| ... | ... | @@ -1,5 +1,6 @@ |
| 1 | 1 | use crate::abi::Endian; |
| 2 | use crate::spec::{base::xtensa, cvs, Target, TargetOptions}; | |
| 2 | use crate::spec::base::xtensa; | |
| 3 | use crate::spec::{cvs, Target, TargetOptions}; | |
| 3 | 4 | |
| 4 | 5 | pub fn target() -> Target { |
| 5 | 6 | Target { |
compiler/rustc_target/src/spec/targets/xtensa_esp32s2_none_elf.rs+2-1| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | use crate::spec::{base::xtensa, Target, TargetOptions}; | |
| 1 | use crate::spec::base::xtensa; | |
| 2 | use crate::spec::{Target, TargetOptions}; | |
| 2 | 3 | |
| 3 | 4 | pub fn target() -> Target { |
| 4 | 5 | Target { |
compiler/rustc_target/src/spec/targets/xtensa_esp32s3_espidf.rs+2-1| ... | ... | @@ -1,5 +1,6 @@ |
| 1 | 1 | use crate::abi::Endian; |
| 2 | use crate::spec::{base::xtensa, cvs, Target, TargetOptions}; | |
| 2 | use crate::spec::base::xtensa; | |
| 3 | use crate::spec::{cvs, Target, TargetOptions}; | |
| 3 | 4 | |
| 4 | 5 | pub fn target() -> Target { |
| 5 | 6 | Target { |
compiler/rustc_target/src/spec/targets/xtensa_esp32s3_none_elf.rs+2-1| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | use crate::spec::{base::xtensa, Target, TargetOptions}; | |
| 1 | use crate::spec::base::xtensa; | |
| 2 | use crate::spec::{Target, TargetOptions}; | |
| 2 | 3 | |
| 3 | 4 | pub fn target() -> Target { |
| 4 | 5 | Target { |
compiler/rustc_target/src/spec/tests/tests_impl.rs+2-1| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | use super::super::*; | |
| 2 | 1 | use std::assert_matches::assert_matches; |
| 3 | 2 | |
| 3 | use super::super::*; | |
| 4 | ||
| 4 | 5 | // Test target self-consistency and JSON encoding/decoding roundtrip. |
| 5 | 6 | pub(super) fn test_target(mut target: Target) { |
| 6 | 7 | let recycled_target = Target::from_json(target.to_json()).map(|(j, _)| j); |
compiler/rustc_target/src/target_features.rs+1-2| ... | ... | @@ -1,5 +1,4 @@ |
| 1 | use rustc_span::symbol::sym; | |
| 2 | use rustc_span::symbol::Symbol; | |
| 1 | use rustc_span::symbol::{sym, Symbol}; | |
| 3 | 2 | |
| 4 | 3 | /// Features that control behaviour of rustc, rather than the codegen. |
| 5 | 4 | pub const RUSTC_SPECIFIC_FEATURES: &[&str] = &["crt-static"]; |
compiler/rustc_trait_selection/src/error_reporting/infer/mod.rs+3-4| ... | ... | @@ -60,12 +60,11 @@ use rustc_hir::{self as hir}; |
| 60 | 60 | use rustc_macros::extension; |
| 61 | 61 | use rustc_middle::bug; |
| 62 | 62 | use rustc_middle::dep_graph::DepContext; |
| 63 | use rustc_middle::ty::error::ExpectedFound; | |
| 64 | use rustc_middle::ty::error::TypeErrorToStringExt; | |
| 63 | use rustc_middle::ty::error::{ExpectedFound, TypeError, TypeErrorToStringExt}; | |
| 65 | 64 | use rustc_middle::ty::print::{with_forced_trimmed_paths, PrintError, PrintTraitRefExt as _}; |
| 66 | 65 | use rustc_middle::ty::{ |
| 67 | self, error::TypeError, List, Region, Ty, TyCtxt, TypeFoldable, TypeSuperVisitable, | |
| 68 | TypeVisitable, TypeVisitableExt, | |
| 66 | self, List, Region, Ty, TyCtxt, TypeFoldable, TypeSuperVisitable, TypeVisitable, | |
| 67 | TypeVisitableExt, | |
| 69 | 68 | }; |
| 70 | 69 | use rustc_span::{sym, BytePos, DesugaringKind, Pos, Span}; |
| 71 | 70 | use rustc_target::spec::abi; |
compiler/rustc_trait_selection/src/error_reporting/infer/need_type_info.rs+14-12| ... | ... | @@ -1,13 +1,11 @@ |
| 1 | use crate::error_reporting::TypeErrCtxt; | |
| 2 | use crate::errors::{ | |
| 3 | AmbiguousImpl, AmbiguousReturn, AnnotationRequired, InferenceBadError, | |
| 4 | SourceKindMultiSuggestion, SourceKindSubdiag, | |
| 5 | }; | |
| 6 | use crate::infer::InferCtxt; | |
| 7 | use rustc_errors::{codes::*, Diag, IntoDiagArg}; | |
| 1 | use std::borrow::Cow; | |
| 2 | use std::iter; | |
| 3 | use std::path::PathBuf; | |
| 4 | ||
| 5 | use rustc_errors::codes::*; | |
| 6 | use rustc_errors::{Diag, IntoDiagArg}; | |
| 8 | 7 | use rustc_hir as hir; |
| 9 | use rustc_hir::def::Res; | |
| 10 | use rustc_hir::def::{CtorOf, DefKind, Namespace}; | |
| 8 | use rustc_hir::def::{CtorOf, DefKind, Namespace, Res}; | |
| 11 | 9 | use rustc_hir::def_id::{DefId, LocalDefId}; |
| 12 | 10 | use rustc_hir::intravisit::{self, Visitor}; |
| 13 | 11 | use rustc_hir::{Body, Closure, Expr, ExprKind, FnRetTy, HirId, LetStmt, LocalSource}; |
| ... | ... | @@ -21,9 +19,13 @@ use rustc_middle::ty::{ |
| 21 | 19 | }; |
| 22 | 20 | use rustc_span::symbol::{sym, Ident}; |
| 23 | 21 | use rustc_span::{BytePos, Span, DUMMY_SP}; |
| 24 | use std::borrow::Cow; | |
| 25 | use std::iter; | |
| 26 | use std::path::PathBuf; | |
| 22 | ||
| 23 | use crate::error_reporting::TypeErrCtxt; | |
| 24 | use crate::errors::{ | |
| 25 | AmbiguousImpl, AmbiguousReturn, AnnotationRequired, InferenceBadError, | |
| 26 | SourceKindMultiSuggestion, SourceKindSubdiag, | |
| 27 | }; | |
| 28 | use crate::infer::InferCtxt; | |
| 27 | 29 | |
| 28 | 30 | pub enum TypeAnnotationNeeded { |
| 29 | 31 | /// ```compile_fail,E0282 |
compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/different_lifetimes.rs+7-11| ... | ... | @@ -1,21 +1,17 @@ |
| 1 | 1 | //! Error Reporting for Anonymous Region Lifetime Errors |
| 2 | 2 | //! where both the regions are anonymous. |
| 3 | 3 | |
| 4 | use crate::error_reporting::infer::nice_region_error::find_anon_type::find_anon_type; | |
| 5 | use crate::error_reporting::infer::nice_region_error::util::AnonymousParamInfo; | |
| 6 | use crate::error_reporting::infer::nice_region_error::NiceRegionError; | |
| 7 | use crate::errors::AddLifetimeParamsSuggestion; | |
| 8 | use crate::errors::LifetimeMismatch; | |
| 9 | use crate::errors::LifetimeMismatchLabels; | |
| 10 | use crate::infer::RegionResolutionError; | |
| 11 | use crate::infer::SubregionOrigin; | |
| 12 | ||
| 13 | use rustc_errors::Subdiagnostic; | |
| 14 | use rustc_errors::{Diag, ErrorGuaranteed}; | |
| 4 | use rustc_errors::{Diag, ErrorGuaranteed, Subdiagnostic}; | |
| 15 | 5 | use rustc_hir::def_id::LocalDefId; |
| 16 | 6 | use rustc_hir::Ty; |
| 17 | 7 | use rustc_middle::ty::{Region, TyCtxt}; |
| 18 | 8 | |
| 9 | use crate::error_reporting::infer::nice_region_error::find_anon_type::find_anon_type; | |
| 10 | use crate::error_reporting::infer::nice_region_error::util::AnonymousParamInfo; | |
| 11 | use crate::error_reporting::infer::nice_region_error::NiceRegionError; | |
| 12 | use crate::errors::{AddLifetimeParamsSuggestion, LifetimeMismatch, LifetimeMismatchLabels}; | |
| 13 | use crate::infer::{RegionResolutionError, SubregionOrigin}; | |
| 14 | ||
| 19 | 15 | impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { |
| 20 | 16 | /// Print the error message for lifetime errors when both the concerned regions are anonymous. |
| 21 | 17 | /// |
compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/find_anon_type.rs+1| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | 1 | use core::ops::ControlFlow; |
| 2 | ||
| 2 | 3 | use rustc_hir as hir; |
| 3 | 4 | use rustc_hir::def_id::LocalDefId; |
| 4 | 5 | use rustc_hir::intravisit::{self, Visitor}; |
compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/mismatched_static_lifetime.rs+8-8| ... | ... | @@ -1,14 +1,6 @@ |
| 1 | 1 | //! Error Reporting for when the lifetime for a type doesn't match the `impl` selected for a predicate |
| 2 | 2 | //! to hold. |
| 3 | 3 | |
| 4 | use crate::error_reporting::infer::nice_region_error::NiceRegionError; | |
| 5 | use crate::errors::{note_and_explain, IntroducesStaticBecauseUnmetLifetimeReq}; | |
| 6 | use crate::errors::{ | |
| 7 | DoesNotOutliveStaticFromImpl, ImplicitStaticLifetimeSubdiag, MismatchedStaticLifetime, | |
| 8 | }; | |
| 9 | use crate::infer::RegionResolutionError; | |
| 10 | use crate::infer::{SubregionOrigin, TypeTrace}; | |
| 11 | use crate::traits::ObligationCauseCode; | |
| 12 | 4 | use rustc_data_structures::fx::FxIndexSet; |
| 13 | 5 | use rustc_errors::{ErrorGuaranteed, MultiSpan}; |
| 14 | 6 | use rustc_hir as hir; |
| ... | ... | @@ -16,6 +8,14 @@ use rustc_hir::intravisit::Visitor; |
| 16 | 8 | use rustc_middle::bug; |
| 17 | 9 | use rustc_middle::ty::TypeVisitor; |
| 18 | 10 | |
| 11 | use crate::error_reporting::infer::nice_region_error::NiceRegionError; | |
| 12 | use crate::errors::{ | |
| 13 | note_and_explain, DoesNotOutliveStaticFromImpl, ImplicitStaticLifetimeSubdiag, | |
| 14 | IntroducesStaticBecauseUnmetLifetimeReq, MismatchedStaticLifetime, | |
| 15 | }; | |
| 16 | use crate::infer::{RegionResolutionError, SubregionOrigin, TypeTrace}; | |
| 17 | use crate::traits::ObligationCauseCode; | |
| 18 | ||
| 19 | 19 | impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { |
| 20 | 20 | pub(super) fn try_report_mismatched_static_lifetime(&self) -> Option<ErrorGuaranteed> { |
| 21 | 21 | let error = self.error.as_ref()?; |
compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/mod.rs+4-3| ... | ... | @@ -1,11 +1,12 @@ |
| 1 | use crate::error_reporting::TypeErrCtxt; | |
| 2 | use crate::infer::RegionResolutionError; | |
| 3 | use crate::infer::RegionResolutionError::*; | |
| 4 | 1 | use rustc_errors::{Diag, ErrorGuaranteed}; |
| 5 | 2 | use rustc_hir::def_id::LocalDefId; |
| 6 | 3 | use rustc_middle::ty::{self, TyCtxt}; |
| 7 | 4 | use rustc_span::Span; |
| 8 | 5 | |
| 6 | use crate::error_reporting::TypeErrCtxt; | |
| 7 | use crate::infer::RegionResolutionError; | |
| 8 | use crate::infer::RegionResolutionError::*; | |
| 9 | ||
| 9 | 10 | mod different_lifetimes; |
| 10 | 11 | pub mod find_anon_type; |
| 11 | 12 | mod mismatched_static_lifetime; |
compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/named_anon_conflict.rs+4-3| ... | ... | @@ -1,13 +1,14 @@ |
| 1 | 1 | //! Error Reporting for Anonymous Region Lifetime Errors |
| 2 | 2 | //! where one region is named and the other is anonymous. |
| 3 | 3 | |
| 4 | use crate::error_reporting::infer::nice_region_error::find_anon_type::find_anon_type; | |
| 5 | use crate::error_reporting::infer::nice_region_error::NiceRegionError; | |
| 6 | use crate::errors::ExplicitLifetimeRequired; | |
| 7 | 4 | use rustc_errors::Diag; |
| 8 | 5 | use rustc_middle::ty; |
| 9 | 6 | use rustc_span::symbol::kw; |
| 10 | 7 | |
| 8 | use crate::error_reporting::infer::nice_region_error::find_anon_type::find_anon_type; | |
| 9 | use crate::error_reporting::infer::nice_region_error::NiceRegionError; | |
| 10 | use crate::errors::ExplicitLifetimeRequired; | |
| 11 | ||
| 11 | 12 | impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { |
| 12 | 13 | /// When given a `ConcreteFailure` for a function with parameters containing a named region and |
| 13 | 14 | /// an anonymous region, emit an descriptive diagnostic error. |
compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/placeholder_error.rs+10-12| ... | ... | @@ -1,12 +1,5 @@ |
| 1 | use crate::error_reporting::infer::nice_region_error::NiceRegionError; | |
| 2 | use crate::errors::{ | |
| 3 | ActualImplExpectedKind, ActualImplExpectedLifetimeKind, ActualImplExplNotes, | |
| 4 | TraitPlaceholderMismatch, TyOrSig, | |
| 5 | }; | |
| 6 | use crate::infer::RegionResolutionError; | |
| 7 | use crate::infer::ValuePairs; | |
| 8 | use crate::infer::{SubregionOrigin, TypeTrace}; | |
| 9 | use crate::traits::{ObligationCause, ObligationCauseCode}; | |
| 1 | use std::fmt; | |
| 2 | ||
| 10 | 3 | use rustc_data_structures::intern::Interned; |
| 11 | 4 | use rustc_errors::{Diag, IntoDiagArg}; |
| 12 | 5 | use rustc_hir::def::Namespace; |
| ... | ... | @@ -14,10 +7,15 @@ use rustc_hir::def_id::{DefId, CRATE_DEF_ID}; |
| 14 | 7 | use rustc_middle::bug; |
| 15 | 8 | use rustc_middle::ty::error::ExpectedFound; |
| 16 | 9 | use rustc_middle::ty::print::{FmtPrinter, Print, PrintTraitRefExt as _, RegionHighlightMode}; |
| 17 | use rustc_middle::ty::GenericArgsRef; | |
| 18 | use rustc_middle::ty::{self, RePlaceholder, Region, TyCtxt}; | |
| 10 | use rustc_middle::ty::{self, GenericArgsRef, RePlaceholder, Region, TyCtxt}; | |
| 19 | 11 | |
| 20 | use std::fmt; | |
| 12 | use crate::error_reporting::infer::nice_region_error::NiceRegionError; | |
| 13 | use crate::errors::{ | |
| 14 | ActualImplExpectedKind, ActualImplExpectedLifetimeKind, ActualImplExplNotes, | |
| 15 | TraitPlaceholderMismatch, TyOrSig, | |
| 16 | }; | |
| 17 | use crate::infer::{RegionResolutionError, SubregionOrigin, TypeTrace, ValuePairs}; | |
| 18 | use crate::traits::{ObligationCause, ObligationCauseCode}; | |
| 21 | 19 | |
| 22 | 20 | // HACK(eddyb) maybe move this in a more central location. |
| 23 | 21 | #[derive(Copy, Clone)] |
compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/placeholder_relation.rs+4-3| ... | ... | @@ -1,10 +1,11 @@ |
| 1 | use crate::error_reporting::infer::nice_region_error::NiceRegionError; | |
| 2 | use crate::errors::PlaceholderRelationLfNotSatisfied; | |
| 3 | use crate::infer::{RegionResolutionError, SubregionOrigin}; | |
| 4 | 1 | use rustc_data_structures::intern::Interned; |
| 5 | 2 | use rustc_errors::Diag; |
| 6 | 3 | use rustc_middle::ty::{self, RePlaceholder, Region}; |
| 7 | 4 | |
| 5 | use crate::error_reporting::infer::nice_region_error::NiceRegionError; | |
| 6 | use crate::errors::PlaceholderRelationLfNotSatisfied; | |
| 7 | use crate::infer::{RegionResolutionError, SubregionOrigin}; | |
| 8 | ||
| 8 | 9 | impl<'tcx> NiceRegionError<'_, 'tcx> { |
| 9 | 10 | /// Emitted wwhen given a `ConcreteFailure` when relating two placeholders. |
| 10 | 11 | pub(super) fn try_report_placeholder_relation(&self) -> Option<Diag<'tcx>> { |
compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/static_impl_trait.rs+8-9| ... | ... | @@ -1,13 +1,5 @@ |
| 1 | 1 | //! Error Reporting for static impl Traits. |
| 2 | 2 | |
| 3 | use crate::error_reporting::infer::nice_region_error::NiceRegionError; | |
| 4 | use crate::errors::{ | |
| 5 | ButCallingIntroduces, ButNeedsToSatisfy, DynTraitConstraintSuggestion, MoreTargeted, | |
| 6 | ReqIntroducedLocations, | |
| 7 | }; | |
| 8 | use crate::infer::RegionResolutionError; | |
| 9 | use crate::infer::{SubregionOrigin, TypeTrace}; | |
| 10 | use crate::traits::{ObligationCauseCode, UnifyReceiverContext}; | |
| 11 | 3 | use rustc_data_structures::fx::FxIndexSet; |
| 12 | 4 | use rustc_errors::{Applicability, Diag, ErrorGuaranteed, MultiSpan, Subdiagnostic}; |
| 13 | 5 | use rustc_hir::def_id::DefId; |
| ... | ... | @@ -19,10 +11,17 @@ use rustc_hir::{ |
| 19 | 11 | use rustc_middle::ty::{ |
| 20 | 12 | self, AssocItemContainer, StaticLifetimeVisitor, Ty, TyCtxt, TypeSuperVisitable, TypeVisitor, |
| 21 | 13 | }; |
| 14 | use rustc_span::def_id::LocalDefId; | |
| 22 | 15 | use rustc_span::symbol::Ident; |
| 23 | 16 | use rustc_span::Span; |
| 24 | 17 | |
| 25 | use rustc_span::def_id::LocalDefId; | |
| 18 | use crate::error_reporting::infer::nice_region_error::NiceRegionError; | |
| 19 | use crate::errors::{ | |
| 20 | ButCallingIntroduces, ButNeedsToSatisfy, DynTraitConstraintSuggestion, MoreTargeted, | |
| 21 | ReqIntroducedLocations, | |
| 22 | }; | |
| 23 | use crate::infer::{RegionResolutionError, SubregionOrigin, TypeTrace}; | |
| 24 | use crate::traits::{ObligationCauseCode, UnifyReceiverContext}; | |
| 26 | 25 | |
| 27 | 26 | impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { |
| 28 | 27 | /// Print the error message for lifetime errors when the return type is a static `impl Trait`, |
compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/trait_impl_difference.rs+4-4| ... | ... | @@ -1,9 +1,5 @@ |
| 1 | 1 | //! Error Reporting for `impl` items that do not match the obligations from their `trait`. |
| 2 | 2 | |
| 3 | use crate::error_reporting::infer::nice_region_error::NiceRegionError; | |
| 4 | use crate::errors::{ConsiderBorrowingParamHelp, RelationshipHelp, TraitImplDiff}; | |
| 5 | use crate::infer::RegionResolutionError; | |
| 6 | use crate::infer::{Subtype, ValuePairs}; | |
| 7 | 3 | use rustc_errors::ErrorGuaranteed; |
| 8 | 4 | use rustc_hir as hir; |
| 9 | 5 | use rustc_hir::def::Res; |
| ... | ... | @@ -16,6 +12,10 @@ use rustc_middle::ty::print::RegionHighlightMode; |
| 16 | 12 | use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitor}; |
| 17 | 13 | use rustc_span::Span; |
| 18 | 14 | |
| 15 | use crate::error_reporting::infer::nice_region_error::NiceRegionError; | |
| 16 | use crate::errors::{ConsiderBorrowingParamHelp, RelationshipHelp, TraitImplDiff}; | |
| 17 | use crate::infer::{RegionResolutionError, Subtype, ValuePairs}; | |
| 18 | ||
| 19 | 19 | impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { |
| 20 | 20 | /// Print the error message for lifetime errors when the `impl` doesn't conform to the `trait`. |
| 21 | 21 | pub(super) fn try_report_impl_not_conforming_to_trait(&self) -> Option<ErrorGuaranteed> { |
compiler/rustc_trait_selection/src/error_reporting/infer/note.rs+7-7| ... | ... | @@ -1,10 +1,3 @@ |
| 1 | use crate::error_reporting::infer::{note_and_explain_region, TypeErrCtxt}; | |
| 2 | use crate::errors::{ | |
| 3 | note_and_explain, FulfillReqLifetime, LfBoundNotSatisfied, OutlivesBound, OutlivesContent, | |
| 4 | RefLongerThanData, RegionOriginNote, WhereClauseSuggestions, | |
| 5 | }; | |
| 6 | use crate::fluent_generated as fluent; | |
| 7 | use crate::infer::{self, SubregionOrigin}; | |
| 8 | 1 | use rustc_errors::{Diag, Subdiagnostic}; |
| 9 | 2 | use rustc_hir::def_id::{DefId, LocalDefId}; |
| 10 | 3 | use rustc_middle::traits::ObligationCauseCode; |
| ... | ... | @@ -13,6 +6,13 @@ use rustc_middle::ty::{self, IsSuggestable, Region, Ty}; |
| 13 | 6 | use rustc_span::symbol::kw; |
| 14 | 7 | |
| 15 | 8 | use super::ObligationCauseAsDiagArg; |
| 9 | use crate::error_reporting::infer::{note_and_explain_region, TypeErrCtxt}; | |
| 10 | use crate::errors::{ | |
| 11 | note_and_explain, FulfillReqLifetime, LfBoundNotSatisfied, OutlivesBound, OutlivesContent, | |
| 12 | RefLongerThanData, RegionOriginNote, WhereClauseSuggestions, | |
| 13 | }; | |
| 14 | use crate::fluent_generated as fluent; | |
| 15 | use crate::infer::{self, SubregionOrigin}; | |
| 16 | 16 | |
| 17 | 17 | impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { |
| 18 | 18 | pub(super) fn note_region_origin(&self, err: &mut Diag<'_>, origin: &SubregionOrigin<'tcx>) { |
compiler/rustc_trait_selection/src/error_reporting/infer/note_and_explain.rs+6-8| ... | ... | @@ -2,14 +2,12 @@ use rustc_errors::Applicability::{MachineApplicable, MaybeIncorrect}; |
| 2 | 2 | use rustc_errors::{pluralize, Diag, MultiSpan}; |
| 3 | 3 | use rustc_hir as hir; |
| 4 | 4 | use rustc_hir::def::DefKind; |
| 5 | use rustc_middle::traits::ObligationCauseCode; | |
| 6 | use rustc_middle::ty::error::ExpectedFound; | |
| 7 | use rustc_middle::ty::print::Printer; | |
| 8 | use rustc_middle::{ | |
| 9 | traits::ObligationCause, | |
| 10 | ty::{self, error::TypeError, print::FmtPrinter, suggest_constraining_type_param, Ty}, | |
| 11 | }; | |
| 12 | use rustc_span::{def_id::DefId, sym, BytePos, Span, Symbol}; | |
| 5 | use rustc_middle::traits::{ObligationCause, ObligationCauseCode}; | |
| 6 | use rustc_middle::ty::error::{ExpectedFound, TypeError}; | |
| 7 | use rustc_middle::ty::print::{FmtPrinter, Printer}; | |
| 8 | use rustc_middle::ty::{self, suggest_constraining_type_param, Ty}; | |
| 9 | use rustc_span::def_id::DefId; | |
| 10 | use rustc_span::{sym, BytePos, Span, Symbol}; | |
| 13 | 11 | |
| 14 | 12 | use crate::error_reporting::TypeErrCtxt; |
| 15 | 13 | use crate::infer::InferCtxtExt; |
compiler/rustc_trait_selection/src/error_reporting/infer/suggest.rs+3-3| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | use crate::error_reporting::infer::hir::Path; | |
| 2 | 1 | use core::ops::ControlFlow; |
| 2 | ||
| 3 | 3 | use hir::def::CtorKind; |
| 4 | 4 | use hir::intravisit::{walk_expr, walk_stmt, Visitor}; |
| 5 | 5 | use hir::{LetStmt, QPath}; |
| ... | ... | @@ -7,8 +7,7 @@ use rustc_data_structures::fx::FxIndexSet; |
| 7 | 7 | use rustc_errors::{Applicability, Diag}; |
| 8 | 8 | use rustc_hir as hir; |
| 9 | 9 | use rustc_hir::def::Res; |
| 10 | use rustc_hir::MatchSource; | |
| 11 | use rustc_hir::Node; | |
| 10 | use rustc_hir::{MatchSource, Node}; | |
| 12 | 11 | use rustc_middle::traits::{ |
| 13 | 12 | IfExpressionCause, MatchExpressionArmCause, ObligationCause, ObligationCauseCode, |
| 14 | 13 | StatementAsExpression, |
| ... | ... | @@ -17,6 +16,7 @@ use rustc_middle::ty::print::with_no_trimmed_paths; |
| 17 | 16 | use rustc_middle::ty::{self as ty, GenericArgKind, IsSuggestable, Ty, TypeVisitableExt}; |
| 18 | 17 | use rustc_span::{sym, Span}; |
| 19 | 18 | |
| 19 | use crate::error_reporting::infer::hir::Path; | |
| 20 | 20 | use crate::error_reporting::TypeErrCtxt; |
| 21 | 21 | use crate::errors::{ |
| 22 | 22 | ConsiderAddingAwait, FnConsiderCasting, FnItemsAreDistinct, FnUniqTypes, |
compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs+21-22| ... | ... | @@ -1,31 +1,16 @@ |
| 1 | use super::on_unimplemented::{AppendConstMessage, OnUnimplementedNote}; | |
| 2 | use super::suggestions::get_explanation_based_on_obligation; | |
| 3 | use crate::error_reporting::infer::TyCategory; | |
| 4 | use crate::error_reporting::traits::report_object_safety_error; | |
| 5 | use crate::error_reporting::TypeErrCtxt; | |
| 6 | use crate::errors::{ | |
| 7 | AsyncClosureNotFn, ClosureFnMutLabel, ClosureFnOnceLabel, ClosureKindMismatch, | |
| 8 | }; | |
| 9 | use crate::infer::InferCtxtExt as _; | |
| 10 | use crate::infer::{self, InferCtxt}; | |
| 11 | use crate::traits::query::evaluate_obligation::InferCtxtExt as _; | |
| 12 | use crate::traits::NormalizeExt; | |
| 13 | use crate::traits::{ | |
| 14 | elaborate, MismatchedProjectionTypes, Obligation, ObligationCause, ObligationCauseCode, | |
| 15 | ObligationCtxt, Overflow, PredicateObligation, SelectionError, SignatureMismatch, | |
| 16 | TraitNotObjectSafe, | |
| 17 | }; | |
| 18 | 1 | use core::ops::ControlFlow; |
| 2 | use std::borrow::Cow; | |
| 3 | ||
| 19 | 4 | use rustc_data_structures::fx::FxHashMap; |
| 20 | 5 | use rustc_data_structures::unord::UnordSet; |
| 21 | 6 | use rustc_errors::codes::*; |
| 22 | use rustc_errors::{pluralize, struct_span_code_err, Applicability, StringPart}; | |
| 23 | use rustc_errors::{Diag, ErrorGuaranteed, StashKey}; | |
| 7 | use rustc_errors::{ | |
| 8 | pluralize, struct_span_code_err, Applicability, Diag, ErrorGuaranteed, StashKey, StringPart, | |
| 9 | }; | |
| 24 | 10 | use rustc_hir::def::Namespace; |
| 25 | 11 | use rustc_hir::def_id::{DefId, LocalDefId}; |
| 26 | 12 | use rustc_hir::intravisit::Visitor; |
| 27 | use rustc_hir::Node; | |
| 28 | use rustc_hir::{self as hir, LangItem}; | |
| 13 | use rustc_hir::{self as hir, LangItem, Node}; | |
| 29 | 14 | use rustc_infer::infer::{InferOk, TypeTrace}; |
| 30 | 15 | use rustc_middle::traits::select::OverflowError; |
| 31 | 16 | use rustc_middle::traits::SignatureMismatchData; |
| ... | ... | @@ -42,11 +27,25 @@ use rustc_middle::ty::{ |
| 42 | 27 | use rustc_middle::{bug, span_bug}; |
| 43 | 28 | use rustc_span::symbol::sym; |
| 44 | 29 | use rustc_span::{BytePos, Span, Symbol, DUMMY_SP}; |
| 45 | use std::borrow::Cow; | |
| 46 | 30 | |
| 31 | use super::on_unimplemented::{AppendConstMessage, OnUnimplementedNote}; | |
| 32 | use super::suggestions::get_explanation_based_on_obligation; | |
| 47 | 33 | use super::{ |
| 48 | 34 | ArgKind, CandidateSimilarity, GetSafeTransmuteErrorAndReason, ImplCandidate, UnsatisfiedConst, |
| 49 | 35 | }; |
| 36 | use crate::error_reporting::infer::TyCategory; | |
| 37 | use crate::error_reporting::traits::report_object_safety_error; | |
| 38 | use crate::error_reporting::TypeErrCtxt; | |
| 39 | use crate::errors::{ | |
| 40 | AsyncClosureNotFn, ClosureFnMutLabel, ClosureFnOnceLabel, ClosureKindMismatch, | |
| 41 | }; | |
| 42 | use crate::infer::{self, InferCtxt, InferCtxtExt as _}; | |
| 43 | use crate::traits::query::evaluate_obligation::InferCtxtExt as _; | |
| 44 | use crate::traits::{ | |
| 45 | elaborate, MismatchedProjectionTypes, NormalizeExt, Obligation, ObligationCause, | |
| 46 | ObligationCauseCode, ObligationCtxt, Overflow, PredicateObligation, SelectionError, | |
| 47 | SignatureMismatch, TraitNotObjectSafe, | |
| 48 | }; | |
| 50 | 49 | |
| 51 | 50 | impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { |
| 52 | 51 | /// The `root_obligation` parameter should be the `root_obligation` field |
compiler/rustc_trait_selection/src/error_reporting/traits/mod.rs+1-2| ... | ... | @@ -19,11 +19,10 @@ use rustc_middle::ty::print::{with_no_trimmed_paths, PrintTraitRefExt as _}; |
| 19 | 19 | use rustc_middle::ty::{self, Ty, TyCtxt}; |
| 20 | 20 | use rustc_span::{ErrorGuaranteed, ExpnKind, Span}; |
| 21 | 21 | |
| 22 | pub use self::overflow::*; | |
| 22 | 23 | use crate::error_reporting::TypeErrCtxt; |
| 23 | 24 | use crate::traits::{FulfillmentError, FulfillmentErrorCode}; |
| 24 | 25 | |
| 25 | pub use self::overflow::*; | |
| 26 | ||
| 27 | 26 | // When outputting impl candidates, prefer showing those that are more similar. |
| 28 | 27 | // |
| 29 | 28 | // We also compare candidates after skipping lifetimes, which has a lower |
compiler/rustc_trait_selection/src/error_reporting/traits/on_unimplemented.rs+15-17| ... | ... | @@ -1,29 +1,27 @@ |
| 1 | use super::{ObligationCauseCode, PredicateObligation}; | |
| 2 | use crate::error_reporting::TypeErrCtxt; | |
| 3 | use crate::errors::{ | |
| 4 | EmptyOnClauseInOnUnimplemented, InvalidOnClauseInOnUnimplemented, NoValueInOnUnimplemented, | |
| 5 | }; | |
| 6 | use crate::infer::InferCtxtExt; | |
| 7 | use rustc_ast::AttrArgs; | |
| 8 | use rustc_ast::AttrArgsEq; | |
| 9 | use rustc_ast::AttrKind; | |
| 10 | use rustc_ast::{Attribute, MetaItem, NestedMetaItem}; | |
| 11 | use rustc_attr as attr; | |
| 1 | use std::iter; | |
| 2 | use std::path::PathBuf; | |
| 3 | ||
| 4 | use rustc_ast::{AttrArgs, AttrArgsEq, AttrKind, Attribute, MetaItem, NestedMetaItem}; | |
| 12 | 5 | use rustc_data_structures::fx::FxHashMap; |
| 13 | use rustc_errors::{codes::*, struct_span_code_err, ErrorGuaranteed}; | |
| 14 | use rustc_hir as hir; | |
| 6 | use rustc_errors::codes::*; | |
| 7 | use rustc_errors::{struct_span_code_err, ErrorGuaranteed}; | |
| 15 | 8 | use rustc_hir::def_id::{DefId, LocalDefId}; |
| 16 | 9 | use rustc_macros::LintDiagnostic; |
| 17 | 10 | use rustc_middle::bug; |
| 18 | 11 | use rustc_middle::ty::print::PrintTraitRefExt as _; |
| 19 | use rustc_middle::ty::GenericArgsRef; | |
| 20 | use rustc_middle::ty::{self, GenericParamDefKind, TyCtxt}; | |
| 12 | use rustc_middle::ty::{self, GenericArgsRef, GenericParamDefKind, TyCtxt}; | |
| 21 | 13 | use rustc_parse_format::{ParseMode, Parser, Piece, Position}; |
| 22 | 14 | use rustc_session::lint::builtin::UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES; |
| 23 | 15 | use rustc_span::symbol::{kw, sym, Symbol}; |
| 24 | 16 | use rustc_span::Span; |
| 25 | use std::iter; | |
| 26 | use std::path::PathBuf; | |
| 17 | use {rustc_attr as attr, rustc_hir as hir}; | |
| 18 | ||
| 19 | use super::{ObligationCauseCode, PredicateObligation}; | |
| 20 | use crate::error_reporting::TypeErrCtxt; | |
| 21 | use crate::errors::{ | |
| 22 | EmptyOnClauseInOnUnimplemented, InvalidOnClauseInOnUnimplemented, NoValueInOnUnimplemented, | |
| 23 | }; | |
| 24 | use crate::infer::InferCtxtExt; | |
| 27 | 25 | |
| 28 | 26 | /// The symbols which are always allowed in a format string |
| 29 | 27 | static ALLOWED_FORMAT_SYMBOLS: &[Symbol] = &[ |
compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs+23-27| ... | ... | @@ -1,34 +1,33 @@ |
| 1 | 1 | // ignore-tidy-filelength |
| 2 | 2 | |
| 3 | use super::{ | |
| 4 | DefIdOrName, FindExprBySpan, ImplCandidate, Obligation, ObligationCause, ObligationCauseCode, | |
| 5 | PredicateObligation, | |
| 6 | }; | |
| 7 | ||
| 8 | use crate::error_reporting::TypeErrCtxt; | |
| 9 | use crate::errors; | |
| 10 | use crate::traits::{ImplDerivedCause, NormalizeExt, ObligationCtxt}; | |
| 3 | use std::assert_matches::debug_assert_matches; | |
| 4 | use std::borrow::Cow; | |
| 5 | use std::iter; | |
| 11 | 6 | |
| 7 | use itertools::{EitherOrBoth, Itertools}; | |
| 12 | 8 | use rustc_data_structures::fx::FxHashSet; |
| 13 | 9 | use rustc_data_structures::stack::ensure_sufficient_stack; |
| 10 | use rustc_errors::codes::*; | |
| 14 | 11 | use rustc_errors::{ |
| 15 | codes::*, pluralize, struct_span_code_err, Applicability, Diag, EmissionGuarantee, MultiSpan, | |
| 16 | Style, SuggestionStyle, | |
| 12 | pluralize, struct_span_code_err, Applicability, Diag, EmissionGuarantee, MultiSpan, Style, | |
| 13 | SuggestionStyle, | |
| 17 | 14 | }; |
| 18 | 15 | use rustc_hir as hir; |
| 19 | use rustc_hir::def::CtorOf; | |
| 20 | use rustc_hir::def::{DefKind, Res}; | |
| 16 | use rustc_hir::def::{CtorOf, DefKind, Res}; | |
| 21 | 17 | use rustc_hir::def_id::DefId; |
| 22 | 18 | use rustc_hir::intravisit::Visitor; |
| 23 | use rustc_hir::is_range_literal; | |
| 24 | 19 | use rustc_hir::lang_items::LangItem; |
| 25 | use rustc_hir::{CoroutineDesugaring, CoroutineKind, CoroutineSource, Expr, HirId, Node}; | |
| 26 | use rustc_infer::infer::InferCtxt; | |
| 27 | use rustc_infer::infer::{BoundRegionConversionTime, DefineOpaqueTypes, InferOk}; | |
| 20 | use rustc_hir::{ | |
| 21 | is_range_literal, CoroutineDesugaring, CoroutineKind, CoroutineSource, Expr, HirId, Node, | |
| 22 | }; | |
| 23 | use rustc_infer::infer::{BoundRegionConversionTime, DefineOpaqueTypes, InferCtxt, InferOk}; | |
| 28 | 24 | use rustc_middle::hir::map; |
| 29 | 25 | use rustc_middle::traits::IsConstable; |
| 30 | 26 | use rustc_middle::ty::error::TypeError; |
| 31 | use rustc_middle::ty::print::PrintPolyTraitRefExt; | |
| 27 | use rustc_middle::ty::print::{ | |
| 28 | with_forced_trimmed_paths, with_no_trimmed_paths, PrintPolyTraitPredicateExt as _, | |
| 29 | PrintPolyTraitRefExt, PrintTraitPredicateExt as _, | |
| 30 | }; | |
| 32 | 31 | use rustc_middle::ty::{ |
| 33 | 32 | self, suggest_arbitrary_trait_bound, suggest_constraining_type_param, AdtKind, GenericArgs, |
| 34 | 33 | InferTy, IsSuggestable, ToPolyTraitRef, Ty, TyCtxt, TypeFoldable, TypeFolder, |
| ... | ... | @@ -39,19 +38,16 @@ use rustc_span::def_id::LocalDefId; |
| 39 | 38 | use rustc_span::symbol::{kw, sym, Ident, Symbol}; |
| 40 | 39 | use rustc_span::{BytePos, DesugaringKind, ExpnKind, MacroKind, Span, DUMMY_SP}; |
| 41 | 40 | use rustc_target::spec::abi; |
| 42 | use std::assert_matches::debug_assert_matches; | |
| 43 | use std::borrow::Cow; | |
| 44 | use std::iter; | |
| 45 | 41 | |
| 42 | use super::{ | |
| 43 | DefIdOrName, FindExprBySpan, ImplCandidate, Obligation, ObligationCause, ObligationCauseCode, | |
| 44 | PredicateObligation, | |
| 45 | }; | |
| 46 | use crate::error_reporting::TypeErrCtxt; | |
| 47 | use crate::errors; | |
| 46 | 48 | use crate::infer::InferCtxtExt as _; |
| 47 | 49 | use crate::traits::query::evaluate_obligation::InferCtxtExt as _; |
| 48 | use rustc_middle::ty::print::{ | |
| 49 | with_forced_trimmed_paths, with_no_trimmed_paths, PrintPolyTraitPredicateExt as _, | |
| 50 | PrintTraitPredicateExt as _, | |
| 51 | }; | |
| 52 | ||
| 53 | use itertools::EitherOrBoth; | |
| 54 | use itertools::Itertools; | |
| 50 | use crate::traits::{ImplDerivedCause, NormalizeExt, ObligationCtxt}; | |
| 55 | 51 | |
| 56 | 52 | #[derive(Debug)] |
| 57 | 53 | pub enum CoroutineInteriorOrUpvar { |
compiler/rustc_trait_selection/src/errors.rs+7-10| ... | ... | @@ -1,19 +1,18 @@ |
| 1 | use std::path::PathBuf; | |
| 2 | ||
| 1 | 3 | use rustc_data_structures::fx::FxHashSet; |
| 4 | use rustc_errors::codes::*; | |
| 2 | 5 | use rustc_errors::{ |
| 3 | codes::*, Applicability, Diag, DiagCtxtHandle, DiagMessage, DiagStyledString, Diagnostic, | |
| 6 | Applicability, Diag, DiagCtxtHandle, DiagMessage, DiagStyledString, Diagnostic, | |
| 4 | 7 | EmissionGuarantee, IntoDiagArg, Level, MultiSpan, SubdiagMessageOp, Subdiagnostic, |
| 5 | 8 | }; |
| 6 | 9 | use rustc_hir as hir; |
| 7 | 10 | use rustc_hir::def_id::LocalDefId; |
| 8 | 11 | use rustc_hir::intravisit::{walk_ty, Visitor}; |
| 9 | use rustc_hir::FnRetTy; | |
| 10 | use rustc_hir::GenericParamKind; | |
| 12 | use rustc_hir::{FnRetTy, GenericParamKind}; | |
| 11 | 13 | use rustc_macros::{Diagnostic, Subdiagnostic}; |
| 12 | use rustc_middle::ty::print::TraitRefPrintOnlyTraitPath; | |
| 13 | use rustc_middle::ty::{ | |
| 14 | self, print::PrintTraitRefExt as _, Binder, ClosureKind, FnSig, PolyTraitRef, Region, Ty, | |
| 15 | TyCtxt, | |
| 16 | }; | |
| 14 | use rustc_middle::ty::print::{PrintTraitRefExt as _, TraitRefPrintOnlyTraitPath}; | |
| 15 | use rustc_middle::ty::{self, Binder, ClosureKind, FnSig, PolyTraitRef, Region, Ty, TyCtxt}; | |
| 17 | 16 | use rustc_span::symbol::{kw, Ident, Symbol}; |
| 18 | 17 | use rustc_span::{BytePos, Span}; |
| 19 | 18 | |
| ... | ... | @@ -22,8 +21,6 @@ use crate::error_reporting::infer::nice_region_error::placeholder_error::Highlig |
| 22 | 21 | use crate::error_reporting::infer::ObligationCauseAsDiagArg; |
| 23 | 22 | use crate::fluent_generated as fluent; |
| 24 | 23 | |
| 25 | use std::path::PathBuf; | |
| 26 | ||
| 27 | 24 | pub mod note_and_explain; |
| 28 | 25 | |
| 29 | 26 | #[derive(Diagnostic)] |
compiler/rustc_trait_selection/src/errors/note_and_explain.rs+5-3| ... | ... | @@ -1,10 +1,12 @@ |
| 1 | use crate::error_reporting::infer::nice_region_error::find_anon_type; | |
| 2 | use crate::fluent_generated as fluent; | |
| 3 | 1 | use rustc_errors::{Diag, EmissionGuarantee, IntoDiagArg, SubdiagMessageOp, Subdiagnostic}; |
| 4 | 2 | use rustc_hir::def_id::LocalDefId; |
| 5 | 3 | use rustc_middle::bug; |
| 6 | 4 | use rustc_middle::ty::{self, TyCtxt}; |
| 7 | use rustc_span::{symbol::kw, Span}; | |
| 5 | use rustc_span::symbol::kw; | |
| 6 | use rustc_span::Span; | |
| 7 | ||
| 8 | use crate::error_reporting::infer::nice_region_error::find_anon_type; | |
| 9 | use crate::fluent_generated as fluent; | |
| 8 | 10 | |
| 9 | 11 | struct DescriptionCtx<'a> { |
| 10 | 12 | span: Option<Span>, |
compiler/rustc_trait_selection/src/infer.rs+6-8| ... | ... | @@ -1,20 +1,18 @@ |
| 1 | use crate::infer::at::ToTrace; | |
| 2 | use crate::traits::query::evaluate_obligation::InferCtxtExt as _; | |
| 3 | use crate::traits::{self, Obligation, ObligationCause, ObligationCtxt, SelectionContext}; | |
| 1 | use std::fmt::Debug; | |
| 4 | 2 | |
| 5 | 3 | use rustc_hir::def_id::DefId; |
| 6 | 4 | use rustc_hir::lang_items::LangItem; |
| 5 | pub use rustc_infer::infer::*; | |
| 7 | 6 | use rustc_macros::extension; |
| 8 | 7 | use rustc_middle::arena::ArenaAllocatable; |
| 9 | 8 | use rustc_middle::infer::canonical::{Canonical, CanonicalQueryResponse, QueryResponse}; |
| 10 | 9 | use rustc_middle::traits::query::NoSolution; |
| 11 | use rustc_middle::ty::{self, Ty, TyCtxt, TypeFoldable, TypeVisitableExt}; | |
| 12 | use rustc_middle::ty::{GenericArg, Upcast}; | |
| 10 | use rustc_middle::ty::{self, GenericArg, Ty, TyCtxt, TypeFoldable, TypeVisitableExt, Upcast}; | |
| 13 | 11 | use rustc_span::DUMMY_SP; |
| 14 | 12 | |
| 15 | use std::fmt::Debug; | |
| 16 | ||
| 17 | pub use rustc_infer::infer::*; | |
| 13 | use crate::infer::at::ToTrace; | |
| 14 | use crate::traits::query::evaluate_obligation::InferCtxtExt as _; | |
| 15 | use crate::traits::{self, Obligation, ObligationCause, ObligationCtxt, SelectionContext}; | |
| 18 | 16 | |
| 19 | 17 | #[extension(pub trait InferCtxtExt<'tcx>)] |
| 20 | 18 | impl<'tcx> InferCtxt<'tcx> { |
compiler/rustc_trait_selection/src/regions.rs+2-1| ... | ... | @@ -1,10 +1,11 @@ |
| 1 | use crate::traits::ScrubbedTraitError; | |
| 2 | 1 | use rustc_infer::infer::outlives::env::OutlivesEnvironment; |
| 3 | 2 | use rustc_infer::infer::{InferCtxt, RegionResolutionError}; |
| 4 | 3 | use rustc_macros::extension; |
| 5 | 4 | use rustc_middle::traits::query::NoSolution; |
| 6 | 5 | use rustc_middle::traits::ObligationCause; |
| 7 | 6 | |
| 7 | use crate::traits::ScrubbedTraitError; | |
| 8 | ||
| 8 | 9 | #[extension(pub trait InferCtxtRegionExt<'tcx>)] |
| 9 | 10 | impl<'tcx> InferCtxt<'tcx> { |
| 10 | 11 | /// Resolve regions, using the deep normalizer to normalize any type-outlives |
compiler/rustc_trait_selection/src/solve/fulfill.rs+1-2| ... | ... | @@ -15,11 +15,10 @@ use rustc_middle::ty::{self, TyCtxt}; |
| 15 | 15 | use rustc_next_trait_solver::solve::{GenerateProofTree, SolverDelegateEvalExt as _}; |
| 16 | 16 | use rustc_span::symbol::sym; |
| 17 | 17 | |
| 18 | use crate::traits::{FulfillmentError, FulfillmentErrorCode, ScrubbedTraitError}; | |
| 19 | ||
| 20 | 18 | use super::delegate::SolverDelegate; |
| 21 | 19 | use super::inspect::{self, ProofTreeInferCtxtExt, ProofTreeVisitor}; |
| 22 | 20 | use super::Certainty; |
| 21 | use crate::traits::{FulfillmentError, FulfillmentErrorCode, ScrubbedTraitError}; | |
| 23 | 22 | |
| 24 | 23 | /// A trait engine using the new trait solver. |
| 25 | 24 | /// |
compiler/rustc_trait_selection/src/solve/normalize.rs+8-7| ... | ... | @@ -1,20 +1,21 @@ |
| 1 | 1 | use std::fmt::Debug; |
| 2 | 2 | use std::marker::PhantomData; |
| 3 | 3 | |
| 4 | use crate::error_reporting::traits::OverflowCause; | |
| 5 | use crate::error_reporting::InferCtxtErrorExt; | |
| 6 | use crate::traits::query::evaluate_obligation::InferCtxtExt; | |
| 7 | use crate::traits::{BoundVarReplacer, PlaceholderReplacer, ScrubbedTraitError}; | |
| 8 | 4 | use rustc_data_structures::stack::ensure_sufficient_stack; |
| 9 | 5 | use rustc_infer::infer::at::At; |
| 10 | 6 | use rustc_infer::infer::InferCtxt; |
| 11 | 7 | use rustc_infer::traits::{FromSolverError, Obligation, TraitEngine}; |
| 12 | 8 | use rustc_middle::traits::ObligationCause; |
| 13 | use rustc_middle::ty::{self, Ty, TyCtxt, UniverseIndex}; | |
| 14 | use rustc_middle::ty::{FallibleTypeFolder, TypeFolder, TypeSuperFoldable}; | |
| 15 | use rustc_middle::ty::{TypeFoldable, TypeVisitableExt}; | |
| 9 | use rustc_middle::ty::{ | |
| 10 | self, FallibleTypeFolder, Ty, TyCtxt, TypeFoldable, TypeFolder, TypeSuperFoldable, | |
| 11 | TypeVisitableExt, UniverseIndex, | |
| 12 | }; | |
| 16 | 13 | |
| 17 | 14 | use super::{FulfillmentCtxt, NextSolverError}; |
| 15 | use crate::error_reporting::traits::OverflowCause; | |
| 16 | use crate::error_reporting::InferCtxtErrorExt; | |
| 17 | use crate::traits::query::evaluate_obligation::InferCtxtExt; | |
| 18 | use crate::traits::{BoundVarReplacer, PlaceholderReplacer, ScrubbedTraitError}; | |
| 18 | 19 | |
| 19 | 20 | /// Deeply normalize all aliases in `value`. This does not handle inference and expects |
| 20 | 21 | /// its input to be already fully resolved. |
compiler/rustc_trait_selection/src/traits/auto_trait.rs+6-7| ... | ... | @@ -1,11 +1,8 @@ |
| 1 | 1 | //! Support code for rustdoc and external tools. |
| 2 | 2 | //! You really don't want to be using this unless you need to. |
| 3 | 3 | |
| 4 | use super::*; | |
| 5 | ||
| 6 | use crate::errors::UnableToConstructConstantValue; | |
| 7 | use crate::infer::region_constraints::{Constraint, RegionConstraintData}; | |
| 8 | use crate::traits::project::ProjectAndUnifyResult; | |
| 4 | use std::collections::VecDeque; | |
| 5 | use std::iter; | |
| 9 | 6 | |
| 10 | 7 | use rustc_data_structures::fx::{FxIndexMap, FxIndexSet, IndexEntry}; |
| 11 | 8 | use rustc_data_structures::unord::UnordSet; |
| ... | ... | @@ -13,8 +10,10 @@ use rustc_infer::infer::DefineOpaqueTypes; |
| 13 | 10 | use rustc_middle::mir::interpret::ErrorHandled; |
| 14 | 11 | use rustc_middle::ty::{Region, RegionVid}; |
| 15 | 12 | |
| 16 | use std::collections::VecDeque; | |
| 17 | use std::iter; | |
| 13 | use super::*; | |
| 14 | use crate::errors::UnableToConstructConstantValue; | |
| 15 | use crate::infer::region_constraints::{Constraint, RegionConstraintData}; | |
| 16 | use crate::traits::project::ProjectAndUnifyResult; | |
| 18 | 17 | |
| 19 | 18 | // FIXME(twk): this is obviously not nice to duplicate like that |
| 20 | 19 | #[derive(Eq, PartialEq, Hash, Copy, Clone, Debug)] |
compiler/rustc_trait_selection/src/traits/coherence.rs+11-10| ... | ... | @@ -4,15 +4,8 @@ |
| 4 | 4 | //! [trait-resolution]: https://rustc-dev-guide.rust-lang.org/traits/resolution.html |
| 5 | 5 | //! [trait-specialization]: https://rustc-dev-guide.rust-lang.org/traits/specialization.html |
| 6 | 6 | |
| 7 | use crate::infer::outlives::env::OutlivesEnvironment; | |
| 8 | use crate::infer::InferOk; | |
| 9 | use crate::solve::inspect::{InspectGoal, ProofTreeInferCtxtExt, ProofTreeVisitor}; | |
| 10 | use crate::solve::{deeply_normalize_for_diagnostics, inspect}; | |
| 11 | use crate::traits::select::IntercrateAmbiguityCause; | |
| 12 | use crate::traits::NormalizeExt; | |
| 13 | use crate::traits::SkipLeakCheck; | |
| 14 | use crate::traits::{util, FulfillmentErrorCode}; | |
| 15 | use crate::traits::{Obligation, ObligationCause, PredicateObligation, SelectionContext}; | |
| 7 | use std::fmt::Debug; | |
| 8 | ||
| 16 | 9 | use rustc_data_structures::fx::FxIndexSet; |
| 17 | 10 | use rustc_errors::{Diag, EmissionGuarantee}; |
| 18 | 11 | use rustc_hir::def::DefKind; |
| ... | ... | @@ -28,10 +21,18 @@ use rustc_middle::ty::{self, Ty, TyCtxt}; |
| 28 | 21 | pub use rustc_next_trait_solver::coherence::*; |
| 29 | 22 | use rustc_span::symbol::sym; |
| 30 | 23 | use rustc_span::{Span, DUMMY_SP}; |
| 31 | use std::fmt::Debug; | |
| 32 | 24 | |
| 33 | 25 | use super::ObligationCtxt; |
| 34 | 26 | use crate::error_reporting::traits::suggest_new_overflow_limit; |
| 27 | use crate::infer::outlives::env::OutlivesEnvironment; | |
| 28 | use crate::infer::InferOk; | |
| 29 | use crate::solve::inspect::{InspectGoal, ProofTreeInferCtxtExt, ProofTreeVisitor}; | |
| 30 | use crate::solve::{deeply_normalize_for_diagnostics, inspect}; | |
| 31 | use crate::traits::select::IntercrateAmbiguityCause; | |
| 32 | use crate::traits::{ | |
| 33 | util, FulfillmentErrorCode, NormalizeExt, Obligation, ObligationCause, PredicateObligation, | |
| 34 | SelectionContext, SkipLeakCheck, | |
| 35 | }; | |
| 35 | 36 | |
| 36 | 37 | pub struct OverlapResult<'tcx> { |
| 37 | 38 | pub impl_header: ty::ImplHeader<'tcx>, |
compiler/rustc_trait_selection/src/traits/engine.rs+12-16| ... | ... | @@ -1,16 +1,6 @@ |
| 1 | 1 | use std::cell::RefCell; |
| 2 | 2 | use std::fmt::Debug; |
| 3 | 3 | |
| 4 | use super::{FromSolverError, TraitEngine}; | |
| 5 | use super::{FulfillmentContext, ScrubbedTraitError}; | |
| 6 | use crate::error_reporting::InferCtxtErrorExt; | |
| 7 | use crate::regions::InferCtxtRegionExt; | |
| 8 | use crate::solve::FulfillmentCtxt as NextFulfillmentCtxt; | |
| 9 | use crate::solve::NextSolverError; | |
| 10 | use crate::traits::fulfill::OldSolverError; | |
| 11 | use crate::traits::NormalizeExt; | |
| 12 | use crate::traits::StructurallyNormalizeExt; | |
| 13 | use crate::traits::{FulfillmentError, Obligation, ObligationCause, PredicateObligation}; | |
| 14 | 4 | use rustc_data_structures::fx::FxIndexSet; |
| 15 | 5 | use rustc_errors::ErrorGuaranteed; |
| 16 | 6 | use rustc_hir::def_id::{DefId, LocalDefId}; |
| ... | ... | @@ -19,16 +9,22 @@ use rustc_infer::infer::canonical::{ |
| 19 | 9 | Canonical, CanonicalQueryResponse, CanonicalVarValues, QueryResponse, |
| 20 | 10 | }; |
| 21 | 11 | use rustc_infer::infer::outlives::env::OutlivesEnvironment; |
| 22 | use rustc_infer::infer::RegionResolutionError; | |
| 23 | use rustc_infer::infer::{DefineOpaqueTypes, InferCtxt, InferOk}; | |
| 12 | use rustc_infer::infer::{DefineOpaqueTypes, InferCtxt, InferOk, RegionResolutionError}; | |
| 24 | 13 | use rustc_macros::extension; |
| 25 | 14 | use rustc_middle::arena::ArenaAllocatable; |
| 26 | 15 | use rustc_middle::traits::query::NoSolution; |
| 27 | 16 | use rustc_middle::ty::error::TypeError; |
| 28 | use rustc_middle::ty::TypeFoldable; | |
| 29 | use rustc_middle::ty::Upcast; | |
| 30 | use rustc_middle::ty::Variance; | |
| 31 | use rustc_middle::ty::{self, Ty, TyCtxt}; | |
| 17 | use rustc_middle::ty::{self, Ty, TyCtxt, TypeFoldable, Upcast, Variance}; | |
| 18 | ||
| 19 | use super::{FromSolverError, FulfillmentContext, ScrubbedTraitError, TraitEngine}; | |
| 20 | use crate::error_reporting::InferCtxtErrorExt; | |
| 21 | use crate::regions::InferCtxtRegionExt; | |
| 22 | use crate::solve::{FulfillmentCtxt as NextFulfillmentCtxt, NextSolverError}; | |
| 23 | use crate::traits::fulfill::OldSolverError; | |
| 24 | use crate::traits::{ | |
| 25 | FulfillmentError, NormalizeExt, Obligation, ObligationCause, PredicateObligation, | |
| 26 | StructurallyNormalizeExt, | |
| 27 | }; | |
| 32 | 28 | |
| 33 | 29 | #[extension(pub trait TraitEngineExt<'tcx, E>)] |
| 34 | 30 | impl<'tcx, E> dyn TraitEngine<'tcx, E> |
compiler/rustc_trait_selection/src/traits/fulfill.rs+16-19| ... | ... | @@ -1,32 +1,29 @@ |
| 1 | use crate::infer::{InferCtxt, TyOrConstInferVar}; | |
| 2 | use crate::traits::normalize::normalize_with_depth_to; | |
| 1 | use std::marker::PhantomData; | |
| 2 | ||
| 3 | 3 | use rustc_data_structures::captures::Captures; |
| 4 | use rustc_data_structures::obligation_forest::ProcessResult; | |
| 5 | use rustc_data_structures::obligation_forest::{Error, ForestObligation, Outcome}; | |
| 6 | use rustc_data_structures::obligation_forest::{ObligationForest, ObligationProcessor}; | |
| 4 | use rustc_data_structures::obligation_forest::{ | |
| 5 | Error, ForestObligation, ObligationForest, ObligationProcessor, Outcome, ProcessResult, | |
| 6 | }; | |
| 7 | 7 | use rustc_infer::infer::DefineOpaqueTypes; |
| 8 | use rustc_infer::traits::{FromSolverError, ProjectionCacheKey}; | |
| 9 | use rustc_infer::traits::{PolyTraitObligation, SelectionError, TraitEngine}; | |
| 8 | use rustc_infer::traits::{ | |
| 9 | FromSolverError, PolyTraitObligation, ProjectionCacheKey, SelectionError, TraitEngine, | |
| 10 | }; | |
| 10 | 11 | use rustc_middle::bug; |
| 11 | 12 | use rustc_middle::mir::interpret::ErrorHandled; |
| 12 | 13 | use rustc_middle::ty::abstract_const::NotConstEvaluatable; |
| 13 | 14 | use rustc_middle::ty::error::{ExpectedFound, TypeError}; |
| 14 | use rustc_middle::ty::GenericArgsRef; | |
| 15 | use rustc_middle::ty::{self, Binder, Const, TypeVisitableExt}; | |
| 16 | use std::marker::PhantomData; | |
| 15 | use rustc_middle::ty::{self, Binder, Const, GenericArgsRef, TypeVisitableExt}; | |
| 17 | 16 | |
| 18 | 17 | use super::project::{self, ProjectAndUnifyResult}; |
| 19 | 18 | use super::select::SelectionContext; |
| 20 | use super::wf; | |
| 21 | use super::EvaluationResult; | |
| 22 | use super::PredicateObligation; | |
| 23 | use super::Unimplemented; | |
| 24 | use super::{const_evaluatable, ScrubbedTraitError}; | |
| 25 | use super::{FulfillmentError, FulfillmentErrorCode}; | |
| 26 | ||
| 19 | use super::{ | |
| 20 | const_evaluatable, wf, EvaluationResult, FulfillmentError, FulfillmentErrorCode, | |
| 21 | PredicateObligation, ScrubbedTraitError, Unimplemented, | |
| 22 | }; | |
| 27 | 23 | use crate::error_reporting::InferCtxtErrorExt; |
| 28 | use crate::traits::project::PolyProjectionObligation; | |
| 29 | use crate::traits::project::ProjectionCacheKeyExt as _; | |
| 24 | use crate::infer::{InferCtxt, TyOrConstInferVar}; | |
| 25 | use crate::traits::normalize::normalize_with_depth_to; | |
| 26 | use crate::traits::project::{PolyProjectionObligation, ProjectionCacheKeyExt as _}; | |
| 30 | 27 | use crate::traits::query::evaluate_obligation::InferCtxtExt; |
| 31 | 28 | |
| 32 | 29 | impl<'tcx> ForestObligation for PendingPredicateObligation<'tcx> { |
compiler/rustc_trait_selection/src/traits/misc.rs+2-3| ... | ... | @@ -1,8 +1,5 @@ |
| 1 | 1 | //! Miscellaneous type-system utilities that are too small to deserve their own modules. |
| 2 | 2 | |
| 3 | use crate::regions::InferCtxtRegionExt; | |
| 4 | use crate::traits::{self, FulfillmentError, ObligationCause}; | |
| 5 | ||
| 6 | 3 | use hir::LangItem; |
| 7 | 4 | use rustc_ast::Mutability; |
| 8 | 5 | use rustc_data_structures::fx::FxIndexSet; |
| ... | ... | @@ -12,6 +9,8 @@ use rustc_infer::infer::{RegionResolutionError, TyCtxtInferExt}; |
| 12 | 9 | use rustc_middle::ty::{self, AdtDef, Ty, TyCtxt, TypeVisitableExt}; |
| 13 | 10 | |
| 14 | 11 | use super::outlives_bounds::InferCtxtExt; |
| 12 | use crate::regions::InferCtxtRegionExt; | |
| 13 | use crate::traits::{self, FulfillmentError, ObligationCause}; | |
| 15 | 14 | |
| 16 | 15 | pub enum CopyImplementationError<'tcx> { |
| 17 | 16 | InfringingFields(Vec<(&'tcx ty::FieldDef, Ty<'tcx>, InfringingFieldsReason<'tcx>)>), |
compiler/rustc_trait_selection/src/traits/mod.rs+32-28| ... | ... | @@ -22,51 +22,55 @@ mod util; |
| 22 | 22 | pub mod vtable; |
| 23 | 23 | pub mod wf; |
| 24 | 24 | |
| 25 | use crate::error_reporting::InferCtxtErrorExt; | |
| 26 | use crate::infer::outlives::env::OutlivesEnvironment; | |
| 27 | use crate::infer::{InferCtxt, TyCtxtInferExt}; | |
| 28 | use crate::regions::InferCtxtRegionExt; | |
| 29 | use crate::traits::query::evaluate_obligation::InferCtxtExt as _; | |
| 25 | use std::fmt::Debug; | |
| 26 | use std::ops::ControlFlow; | |
| 27 | ||
| 30 | 28 | use rustc_errors::ErrorGuaranteed; |
| 29 | pub use rustc_infer::traits::*; | |
| 31 | 30 | use rustc_middle::query::Providers; |
| 32 | 31 | use rustc_middle::span_bug; |
| 33 | 32 | use rustc_middle::ty::error::{ExpectedFound, TypeError}; |
| 34 | 33 | use rustc_middle::ty::fold::TypeFoldable; |
| 35 | 34 | use rustc_middle::ty::visit::{TypeVisitable, TypeVisitableExt}; |
| 36 | use rustc_middle::ty::{self, Ty, TyCtxt, TypeFolder, TypeSuperVisitable, Upcast}; | |
| 37 | use rustc_middle::ty::{GenericArgs, GenericArgsRef}; | |
| 35 | use rustc_middle::ty::{ | |
| 36 | self, GenericArgs, GenericArgsRef, Ty, TyCtxt, TypeFolder, TypeSuperVisitable, Upcast, | |
| 37 | }; | |
| 38 | 38 | use rustc_span::def_id::DefId; |
| 39 | 39 | use rustc_span::Span; |
| 40 | 40 | |
| 41 | use std::fmt::Debug; | |
| 42 | use std::ops::ControlFlow; | |
| 43 | ||
| 44 | pub use self::coherence::{add_placeholder_note, orphan_check_trait_ref, overlapping_impls}; | |
| 45 | pub use self::coherence::{InCrate, IsFirstInputType, UncoveredTyParams}; | |
| 46 | pub use self::coherence::{OrphanCheckErr, OrphanCheckMode, OverlapResult}; | |
| 41 | pub use self::coherence::{ | |
| 42 | add_placeholder_note, orphan_check_trait_ref, overlapping_impls, InCrate, IsFirstInputType, | |
| 43 | OrphanCheckErr, OrphanCheckMode, OverlapResult, UncoveredTyParams, | |
| 44 | }; | |
| 47 | 45 | pub use self::engine::{ObligationCtxt, TraitEngineExt}; |
| 48 | 46 | pub use self::fulfill::{FulfillmentContext, OldSolverError, PendingPredicateObligation}; |
| 49 | 47 | pub use self::normalize::NormalizeExt; |
| 50 | pub use self::object_safety::hir_ty_lowering_object_safety_violations; | |
| 51 | pub use self::object_safety::is_vtable_safe_method; | |
| 52 | pub use self::object_safety::object_safety_violations_for_assoc_item; | |
| 53 | pub use self::object_safety::ObjectSafetyViolation; | |
| 48 | pub use self::object_safety::{ | |
| 49 | hir_ty_lowering_object_safety_violations, is_vtable_safe_method, | |
| 50 | object_safety_violations_for_assoc_item, ObjectSafetyViolation, | |
| 51 | }; | |
| 54 | 52 | pub use self::project::{normalize_inherent_projection, normalize_projection_ty}; |
| 55 | pub use self::select::{EvaluationCache, SelectionCache, SelectionContext}; | |
| 56 | pub use self::select::{EvaluationResult, IntercrateAmbiguityCause, OverflowError}; | |
| 57 | pub use self::specialize::specialization_graph::FutureCompatOverlapError; | |
| 58 | pub use self::specialize::specialization_graph::FutureCompatOverlapErrorKind; | |
| 53 | pub use self::select::{ | |
| 54 | EvaluationCache, EvaluationResult, IntercrateAmbiguityCause, OverflowError, SelectionCache, | |
| 55 | SelectionContext, | |
| 56 | }; | |
| 57 | pub use self::specialize::specialization_graph::{ | |
| 58 | FutureCompatOverlapError, FutureCompatOverlapErrorKind, | |
| 59 | }; | |
| 59 | 60 | pub use self::specialize::{ |
| 60 | 61 | specialization_graph, translate_args, translate_args_with_cause, OverlapError, |
| 61 | 62 | }; |
| 62 | 63 | pub use self::structural_normalize::StructurallyNormalizeExt; |
| 63 | pub use self::util::elaborate; | |
| 64 | pub use self::util::{expand_trait_aliases, TraitAliasExpander, TraitAliasExpansionInfo}; | |
| 65 | pub use self::util::{impl_item_is_final, upcast_choices}; | |
| 66 | pub use self::util::{supertraits, transitive_bounds, transitive_bounds_that_define_assoc_item}; | |
| 67 | pub use self::util::{with_replaced_escaping_bound_vars, BoundVarReplacer, PlaceholderReplacer}; | |
| 68 | ||
| 69 | pub use rustc_infer::traits::*; | |
| 64 | pub use self::util::{ | |
| 65 | elaborate, expand_trait_aliases, impl_item_is_final, supertraits, transitive_bounds, | |
| 66 | transitive_bounds_that_define_assoc_item, upcast_choices, with_replaced_escaping_bound_vars, | |
| 67 | BoundVarReplacer, PlaceholderReplacer, TraitAliasExpander, TraitAliasExpansionInfo, | |
| 68 | }; | |
| 69 | use crate::error_reporting::InferCtxtErrorExt; | |
| 70 | use crate::infer::outlives::env::OutlivesEnvironment; | |
| 71 | use crate::infer::{InferCtxt, TyCtxtInferExt}; | |
| 72 | use crate::regions::InferCtxtRegionExt; | |
| 73 | use crate::traits::query::evaluate_obligation::InferCtxtExt as _; | |
| 70 | 74 | |
| 71 | 75 | pub struct FulfillmentError<'tcx> { |
| 72 | 76 | pub obligation: PredicateObligation<'tcx>, |
compiler/rustc_trait_selection/src/traits/normalize.rs+14-10| ... | ... | @@ -1,20 +1,24 @@ |
| 1 | 1 | //! Deeply normalize types using the old trait solver. |
| 2 | 2 | |
| 3 | use super::SelectionContext; | |
| 4 | use super::{project, with_replaced_escaping_bound_vars, BoundVarReplacer, PlaceholderReplacer}; | |
| 5 | use crate::error_reporting::traits::OverflowCause; | |
| 6 | use crate::error_reporting::InferCtxtErrorExt; | |
| 7 | use crate::solve::NextSolverError; | |
| 8 | 3 | use rustc_data_structures::stack::ensure_sufficient_stack; |
| 9 | 4 | use rustc_infer::infer::at::At; |
| 10 | 5 | use rustc_infer::infer::InferOk; |
| 11 | use rustc_infer::traits::FromSolverError; | |
| 12 | use rustc_infer::traits::PredicateObligation; | |
| 13 | use rustc_infer::traits::{Normalized, Obligation, TraitEngine}; | |
| 6 | use rustc_infer::traits::{ | |
| 7 | FromSolverError, Normalized, Obligation, PredicateObligation, TraitEngine, | |
| 8 | }; | |
| 14 | 9 | use rustc_macros::extension; |
| 15 | 10 | use rustc_middle::traits::{ObligationCause, ObligationCauseCode, Reveal}; |
| 16 | use rustc_middle::ty::{self, Ty, TyCtxt, TypeFolder}; | |
| 17 | use rustc_middle::ty::{TypeFoldable, TypeSuperFoldable, TypeVisitable, TypeVisitableExt}; | |
| 11 | use rustc_middle::ty::{ | |
| 12 | self, Ty, TyCtxt, TypeFoldable, TypeFolder, TypeSuperFoldable, TypeVisitable, TypeVisitableExt, | |
| 13 | }; | |
| 14 | ||
| 15 | use super::{ | |
| 16 | project, with_replaced_escaping_bound_vars, BoundVarReplacer, PlaceholderReplacer, | |
| 17 | SelectionContext, | |
| 18 | }; | |
| 19 | use crate::error_reporting::traits::OverflowCause; | |
| 20 | use crate::error_reporting::InferCtxtErrorExt; | |
| 21 | use crate::solve::NextSolverError; | |
| 18 | 22 | |
| 19 | 23 | #[extension(pub trait NormalizeExt<'tcx>)] |
| 20 | 24 | impl<'tcx> At<'_, 'tcx> { |
compiler/rustc_trait_selection/src/traits/object_safety.rs+6-7| ... | ... | @@ -8,11 +8,9 @@ |
| 8 | 8 | //! - not reference the erased type `Self` except for in this receiver; |
| 9 | 9 | //! - not have generic type parameters. |
| 10 | 10 | |
| 11 | use super::elaborate; | |
| 11 | use std::iter; | |
| 12 | use std::ops::ControlFlow; | |
| 12 | 13 | |
| 13 | use crate::infer::TyCtxtInferExt; | |
| 14 | use crate::traits::query::evaluate_obligation::InferCtxtExt; | |
| 15 | use crate::traits::{util, Obligation, ObligationCause}; | |
| 16 | 14 | use rustc_errors::FatalError; |
| 17 | 15 | use rustc_hir as hir; |
| 18 | 16 | use rustc_hir::def_id::DefId; |
| ... | ... | @@ -27,9 +25,10 @@ use rustc_span::Span; |
| 27 | 25 | use rustc_target::abi::Abi; |
| 28 | 26 | use smallvec::SmallVec; |
| 29 | 27 | |
| 30 | use std::iter; | |
| 31 | use std::ops::ControlFlow; | |
| 32 | ||
| 28 | use super::elaborate; | |
| 29 | use crate::infer::TyCtxtInferExt; | |
| 30 | use crate::traits::query::evaluate_obligation::InferCtxtExt; | |
| 31 | use crate::traits::{util, Obligation, ObligationCause}; | |
| 33 | 32 | pub use crate::traits::{MethodViolationCode, ObjectSafetyViolation}; |
| 34 | 33 | |
| 35 | 34 | /// Returns the object safety violations that affect HIR ty lowering. |
compiler/rustc_trait_selection/src/traits/outlives_bounds.rs+3-3| ... | ... | @@ -1,15 +1,15 @@ |
| 1 | use crate::infer::InferCtxt; | |
| 2 | use crate::traits::{ObligationCause, ObligationCtxt}; | |
| 3 | 1 | use rustc_data_structures::fx::FxIndexSet; |
| 4 | 2 | use rustc_infer::infer::resolve::OpportunisticRegionResolver; |
| 5 | 3 | use rustc_infer::infer::InferOk; |
| 6 | 4 | use rustc_macros::extension; |
| 7 | 5 | use rustc_middle::infer::canonical::{OriginalQueryValues, QueryRegionConstraints}; |
| 8 | 6 | use rustc_middle::span_bug; |
| 7 | pub use rustc_middle::traits::query::OutlivesBound; | |
| 9 | 8 | use rustc_middle::ty::{self, ParamEnv, Ty, TypeFolder, TypeVisitableExt}; |
| 10 | 9 | use rustc_span::def_id::LocalDefId; |
| 11 | 10 | |
| 12 | pub use rustc_middle::traits::query::OutlivesBound; | |
| 11 | use crate::infer::InferCtxt; | |
| 12 | use crate::traits::{ObligationCause, ObligationCtxt}; | |
| 13 | 13 | |
| 14 | 14 | pub type BoundsCompat<'a, 'tcx: 'a> = impl Iterator<Item = OutlivesBound<'tcx>> + 'a; |
| 15 | 15 | pub type Bounds<'a, 'tcx: 'a> = impl Iterator<Item = OutlivesBound<'tcx>> + 'a; |
compiler/rustc_trait_selection/src/traits/project.rs+14-24| ... | ... | @@ -2,29 +2,6 @@ |
| 2 | 2 | |
| 3 | 3 | use std::ops::ControlFlow; |
| 4 | 4 | |
| 5 | use super::specialization_graph; | |
| 6 | use super::translate_args; | |
| 7 | use super::util; | |
| 8 | use super::MismatchedProjectionTypes; | |
| 9 | use super::Obligation; | |
| 10 | use super::ObligationCause; | |
| 11 | use super::PredicateObligation; | |
| 12 | use super::Selection; | |
| 13 | use super::SelectionContext; | |
| 14 | use super::SelectionError; | |
| 15 | use super::{Normalized, NormalizedTerm, ProjectionCacheEntry, ProjectionCacheKey}; | |
| 16 | use rustc_infer::traits::ObligationCauseCode; | |
| 17 | use rustc_middle::traits::BuiltinImplSource; | |
| 18 | use rustc_middle::traits::ImplSource; | |
| 19 | use rustc_middle::traits::ImplSourceUserDefinedData; | |
| 20 | use rustc_middle::{bug, span_bug}; | |
| 21 | ||
| 22 | use crate::errors::InherentProjectionNormalizationOverflow; | |
| 23 | use crate::infer::{BoundRegionConversionTime, InferOk}; | |
| 24 | use crate::traits::normalize::normalize_with_depth; | |
| 25 | use crate::traits::normalize::normalize_with_depth_to; | |
| 26 | use crate::traits::query::evaluate_obligation::InferCtxtExt as _; | |
| 27 | use crate::traits::select::ProjectionMatchesProjection; | |
| 28 | 5 | use rustc_data_structures::sso::SsoHashSet; |
| 29 | 6 | use rustc_data_structures::stack::ensure_sufficient_stack; |
| 30 | 7 | use rustc_errors::ErrorGuaranteed; |
| ... | ... | @@ -32,13 +9,26 @@ use rustc_hir::def::DefKind; |
| 32 | 9 | use rustc_hir::lang_items::LangItem; |
| 33 | 10 | use rustc_infer::infer::resolve::OpportunisticRegionResolver; |
| 34 | 11 | use rustc_infer::infer::DefineOpaqueTypes; |
| 12 | use rustc_infer::traits::ObligationCauseCode; | |
| 35 | 13 | use rustc_middle::traits::select::OverflowError; |
| 14 | pub use rustc_middle::traits::Reveal; | |
| 15 | use rustc_middle::traits::{BuiltinImplSource, ImplSource, ImplSourceUserDefinedData}; | |
| 36 | 16 | use rustc_middle::ty::fold::TypeFoldable; |
| 37 | 17 | use rustc_middle::ty::visit::{MaxUniverse, TypeVisitable, TypeVisitableExt}; |
| 38 | 18 | use rustc_middle::ty::{self, Term, Ty, TyCtxt, Upcast}; |
| 19 | use rustc_middle::{bug, span_bug}; | |
| 39 | 20 | use rustc_span::symbol::sym; |
| 40 | 21 | |
| 41 | pub use rustc_middle::traits::Reveal; | |
| 22 | use super::{ | |
| 23 | specialization_graph, translate_args, util, MismatchedProjectionTypes, Normalized, | |
| 24 | NormalizedTerm, Obligation, ObligationCause, PredicateObligation, ProjectionCacheEntry, | |
| 25 | ProjectionCacheKey, Selection, SelectionContext, SelectionError, | |
| 26 | }; | |
| 27 | use crate::errors::InherentProjectionNormalizationOverflow; | |
| 28 | use crate::infer::{BoundRegionConversionTime, InferOk}; | |
| 29 | use crate::traits::normalize::{normalize_with_depth, normalize_with_depth_to}; | |
| 30 | use crate::traits::query::evaluate_obligation::InferCtxtExt as _; | |
| 31 | use crate::traits::select::ProjectionMatchesProjection; | |
| 42 | 32 | |
| 43 | 33 | pub type PolyProjectionObligation<'tcx> = Obligation<'tcx, ty::PolyProjectionPredicate<'tcx>>; |
| 44 | 34 |
compiler/rustc_trait_selection/src/traits/query/dropck_outlives.rs+4-4| ... | ... | @@ -1,12 +1,12 @@ |
| 1 | use crate::traits::query::normalize::QueryNormalizeExt; | |
| 2 | use crate::traits::query::NoSolution; | |
| 3 | use crate::traits::{Normalized, ObligationCause, ObligationCtxt}; | |
| 4 | ||
| 5 | 1 | use rustc_data_structures::fx::FxHashSet; |
| 6 | 2 | use rustc_middle::traits::query::{DropckConstraint, DropckOutlivesResult}; |
| 7 | 3 | use rustc_middle::ty::{self, EarlyBinder, ParamEnvAnd, Ty, TyCtxt}; |
| 8 | 4 | use rustc_span::{Span, DUMMY_SP}; |
| 9 | 5 | |
| 6 | use crate::traits::query::normalize::QueryNormalizeExt; | |
| 7 | use crate::traits::query::NoSolution; | |
| 8 | use crate::traits::{Normalized, ObligationCause, ObligationCtxt}; | |
| 9 | ||
| 10 | 10 | /// This returns true if the type `ty` is "trivial" for |
| 11 | 11 | /// dropck-outlives -- that is, if it doesn't require any types to |
| 12 | 12 | /// outlive. This is similar but not *quite* the same as the |
compiler/rustc_trait_selection/src/traits/query/normalize.rs+11-11| ... | ... | @@ -2,26 +2,26 @@ |
| 2 | 2 | //! which folds deeply, invoking the underlying |
| 3 | 3 | //! `normalize_canonicalized_projection_ty` query when it encounters projections. |
| 4 | 4 | |
| 5 | use crate::error_reporting::traits::OverflowCause; | |
| 6 | use crate::error_reporting::InferCtxtErrorExt; | |
| 7 | use crate::infer::at::At; | |
| 8 | use crate::infer::canonical::OriginalQueryValues; | |
| 9 | use crate::infer::{InferCtxt, InferOk}; | |
| 10 | use crate::traits::normalize::needs_normalization; | |
| 11 | use crate::traits::Normalized; | |
| 12 | use crate::traits::{BoundVarReplacer, PlaceholderReplacer, ScrubbedTraitError}; | |
| 13 | use crate::traits::{ObligationCause, PredicateObligation, Reveal}; | |
| 14 | 5 | use rustc_data_structures::sso::SsoHashMap; |
| 15 | 6 | use rustc_data_structures::stack::ensure_sufficient_stack; |
| 16 | 7 | use rustc_macros::extension; |
| 8 | pub use rustc_middle::traits::query::NormalizationResult; | |
| 17 | 9 | use rustc_middle::ty::fold::{FallibleTypeFolder, TypeFoldable, TypeSuperFoldable}; |
| 18 | 10 | use rustc_middle::ty::visit::{TypeSuperVisitable, TypeVisitable, TypeVisitableExt}; |
| 19 | 11 | use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitor}; |
| 20 | 12 | use rustc_span::DUMMY_SP; |
| 21 | 13 | |
| 22 | 14 | use super::NoSolution; |
| 23 | ||
| 24 | pub use rustc_middle::traits::query::NormalizationResult; | |
| 15 | use crate::error_reporting::traits::OverflowCause; | |
| 16 | use crate::error_reporting::InferCtxtErrorExt; | |
| 17 | use crate::infer::at::At; | |
| 18 | use crate::infer::canonical::OriginalQueryValues; | |
| 19 | use crate::infer::{InferCtxt, InferOk}; | |
| 20 | use crate::traits::normalize::needs_normalization; | |
| 21 | use crate::traits::{ | |
| 22 | BoundVarReplacer, Normalized, ObligationCause, PlaceholderReplacer, PredicateObligation, | |
| 23 | Reveal, ScrubbedTraitError, | |
| 24 | }; | |
| 25 | 25 | |
| 26 | 26 | #[extension(pub trait QueryNormalizeExt<'tcx>)] |
| 27 | 27 | impl<'cx, 'tcx> At<'cx, 'tcx> { |
compiler/rustc_trait_selection/src/traits/query/type_op/ascribe_user_type.rs+4-4| ... | ... | @@ -1,14 +1,14 @@ |
| 1 | use crate::infer::canonical::{Canonical, CanonicalQueryResponse}; | |
| 2 | use crate::traits::ObligationCtxt; | |
| 3 | 1 | use rustc_hir::def_id::{DefId, CRATE_DEF_ID}; |
| 4 | 2 | use rustc_infer::traits::Obligation; |
| 3 | pub use rustc_middle::traits::query::type_op::AscribeUserType; | |
| 5 | 4 | use rustc_middle::traits::query::NoSolution; |
| 6 | 5 | use rustc_middle::traits::{ObligationCause, ObligationCauseCode}; |
| 7 | 6 | use rustc_middle::ty::{self, ParamEnvAnd, Ty, TyCtxt, UserArgs, UserSelfTy, UserType}; |
| 8 | ||
| 9 | pub use rustc_middle::traits::query::type_op::AscribeUserType; | |
| 10 | 7 | use rustc_span::{Span, DUMMY_SP}; |
| 11 | 8 | |
| 9 | use crate::infer::canonical::{Canonical, CanonicalQueryResponse}; | |
| 10 | use crate::traits::ObligationCtxt; | |
| 11 | ||
| 12 | 12 | impl<'tcx> super::QueryTypeOp<'tcx> for AscribeUserType<'tcx> { |
| 13 | 13 | type QueryResponse = (); |
| 14 | 14 |
compiler/rustc_trait_selection/src/traits/query/type_op/custom.rs+6-5| ... | ... | @@ -1,14 +1,15 @@ |
| 1 | use crate::infer::canonical::query_response; | |
| 2 | use crate::infer::InferCtxt; | |
| 3 | use crate::traits::query::type_op::TypeOpOutput; | |
| 4 | use crate::traits::ObligationCtxt; | |
| 1 | use std::fmt; | |
| 2 | ||
| 5 | 3 | use rustc_errors::ErrorGuaranteed; |
| 6 | 4 | use rustc_infer::infer::region_constraints::RegionConstraintData; |
| 7 | 5 | use rustc_middle::traits::query::NoSolution; |
| 8 | 6 | use rustc_middle::ty::{TyCtxt, TypeFoldable}; |
| 9 | 7 | use rustc_span::Span; |
| 10 | 8 | |
| 11 | use std::fmt; | |
| 9 | use crate::infer::canonical::query_response; | |
| 10 | use crate::infer::InferCtxt; | |
| 11 | use crate::traits::query::type_op::TypeOpOutput; | |
| 12 | use crate::traits::ObligationCtxt; | |
| 12 | 13 | |
| 13 | 14 | pub struct CustomTypeOp<F> { |
| 14 | 15 | closure: F, |
compiler/rustc_trait_selection/src/traits/query/type_op/eq.rs+3-3| ... | ... | @@ -1,10 +1,10 @@ |
| 1 | use crate::infer::canonical::{Canonical, CanonicalQueryResponse}; | |
| 2 | use crate::traits::ObligationCtxt; | |
| 1 | pub use rustc_middle::traits::query::type_op::Eq; | |
| 3 | 2 | use rustc_middle::traits::query::NoSolution; |
| 4 | 3 | use rustc_middle::traits::ObligationCause; |
| 5 | 4 | use rustc_middle::ty::{ParamEnvAnd, TyCtxt}; |
| 6 | 5 | |
| 7 | pub use rustc_middle::traits::query::type_op::Eq; | |
| 6 | use crate::infer::canonical::{Canonical, CanonicalQueryResponse}; | |
| 7 | use crate::traits::ObligationCtxt; | |
| 8 | 8 | |
| 9 | 9 | impl<'tcx> super::QueryTypeOp<'tcx> for Eq<'tcx> { |
| 10 | 10 | type QueryResponse = (); |
compiler/rustc_trait_selection/src/traits/query/type_op/implied_outlives_bounds.rs+3-4| ... | ... | @@ -1,7 +1,3 @@ |
| 1 | use crate::traits::query::NoSolution; | |
| 2 | use crate::traits::wf; | |
| 3 | use crate::traits::ObligationCtxt; | |
| 4 | ||
| 5 | 1 | use rustc_infer::infer::canonical::Canonical; |
| 6 | 2 | use rustc_infer::infer::resolve::OpportunisticRegionResolver; |
| 7 | 3 | use rustc_infer::traits::query::OutlivesBound; |
| ... | ... | @@ -14,6 +10,9 @@ use rustc_span::DUMMY_SP; |
| 14 | 10 | use rustc_type_ir::outlives::{push_outlives_components, Component}; |
| 15 | 11 | use smallvec::{smallvec, SmallVec}; |
| 16 | 12 | |
| 13 | use crate::traits::query::NoSolution; | |
| 14 | use crate::traits::{wf, ObligationCtxt}; | |
| 15 | ||
| 17 | 16 | #[derive(Copy, Clone, Debug, HashStable, TypeFoldable, TypeVisitable)] |
| 18 | 17 | pub struct ImpliedOutlivesBounds<'tcx> { |
| 19 | 18 | pub ty: Ty<'tcx>, |
compiler/rustc_trait_selection/src/traits/query/type_op/mod.rs+8-6| ... | ... | @@ -1,8 +1,5 @@ |
| 1 | use crate::infer::canonical::{ | |
| 2 | Canonical, CanonicalQueryResponse, OriginalQueryValues, QueryRegionConstraints, | |
| 3 | }; | |
| 4 | use crate::infer::{InferCtxt, InferOk}; | |
| 5 | use crate::traits::{ObligationCause, ObligationCtxt}; | |
| 1 | use std::fmt; | |
| 2 | ||
| 6 | 3 | use rustc_errors::ErrorGuaranteed; |
| 7 | 4 | use rustc_infer::infer::canonical::Certainty; |
| 8 | 5 | use rustc_infer::traits::PredicateObligation; |
| ... | ... | @@ -10,7 +7,12 @@ use rustc_middle::traits::query::NoSolution; |
| 10 | 7 | use rustc_middle::ty::fold::TypeFoldable; |
| 11 | 8 | use rustc_middle::ty::{ParamEnvAnd, TyCtxt}; |
| 12 | 9 | use rustc_span::Span; |
| 13 | use std::fmt; | |
| 10 | ||
| 11 | use crate::infer::canonical::{ | |
| 12 | Canonical, CanonicalQueryResponse, OriginalQueryValues, QueryRegionConstraints, | |
| 13 | }; | |
| 14 | use crate::infer::{InferCtxt, InferOk}; | |
| 15 | use crate::traits::{ObligationCause, ObligationCtxt}; | |
| 14 | 16 | |
| 15 | 17 | pub mod ascribe_user_type; |
| 16 | 18 | pub mod custom; |
compiler/rustc_trait_selection/src/traits/query/type_op/normalize.rs+5-4| ... | ... | @@ -1,12 +1,13 @@ |
| 1 | use crate::infer::canonical::{Canonical, CanonicalQueryResponse}; | |
| 2 | use crate::traits::ObligationCtxt; | |
| 1 | use std::fmt; | |
| 2 | ||
| 3 | pub use rustc_middle::traits::query::type_op::Normalize; | |
| 3 | 4 | use rustc_middle::traits::query::NoSolution; |
| 4 | 5 | use rustc_middle::traits::ObligationCause; |
| 5 | 6 | use rustc_middle::ty::fold::TypeFoldable; |
| 6 | 7 | use rustc_middle::ty::{self, Lift, ParamEnvAnd, Ty, TyCtxt, TypeVisitableExt}; |
| 7 | use std::fmt; | |
| 8 | 8 | |
| 9 | pub use rustc_middle::traits::query::type_op::Normalize; | |
| 9 | use crate::infer::canonical::{Canonical, CanonicalQueryResponse}; | |
| 10 | use crate::traits::ObligationCtxt; | |
| 10 | 11 | |
| 11 | 12 | impl<'tcx, T> super::QueryTypeOp<'tcx> for Normalize<T> |
| 12 | 13 | where |
compiler/rustc_trait_selection/src/traits/query/type_op/outlives.rs+4-3| ... | ... | @@ -1,11 +1,12 @@ |
| 1 | use rustc_macros::{HashStable, TypeFoldable, TypeVisitable}; | |
| 2 | use rustc_middle::traits::query::{DropckOutlivesResult, NoSolution}; | |
| 3 | use rustc_middle::ty::{ParamEnvAnd, Ty, TyCtxt}; | |
| 4 | ||
| 1 | 5 | use crate::infer::canonical::{Canonical, CanonicalQueryResponse}; |
| 2 | 6 | use crate::traits::query::dropck_outlives::{ |
| 3 | 7 | compute_dropck_outlives_inner, trivial_dropck_outlives, |
| 4 | 8 | }; |
| 5 | 9 | use crate::traits::ObligationCtxt; |
| 6 | use rustc_macros::{HashStable, TypeFoldable, TypeVisitable}; | |
| 7 | use rustc_middle::traits::query::{DropckOutlivesResult, NoSolution}; | |
| 8 | use rustc_middle::ty::{ParamEnvAnd, Ty, TyCtxt}; | |
| 9 | 10 | |
| 10 | 11 | #[derive(Copy, Clone, Debug, HashStable, TypeFoldable, TypeVisitable)] |
| 11 | 12 | pub struct DropckOutlives<'tcx> { |
compiler/rustc_trait_selection/src/traits/query/type_op/prove_predicate.rs+3-3| ... | ... | @@ -1,11 +1,11 @@ |
| 1 | use crate::infer::canonical::{Canonical, CanonicalQueryResponse}; | |
| 2 | use crate::traits::ObligationCtxt; | |
| 3 | 1 | use rustc_infer::traits::Obligation; |
| 2 | pub use rustc_middle::traits::query::type_op::ProvePredicate; | |
| 4 | 3 | use rustc_middle::traits::query::NoSolution; |
| 5 | 4 | use rustc_middle::traits::ObligationCause; |
| 6 | 5 | use rustc_middle::ty::{self, ParamEnvAnd, TyCtxt}; |
| 7 | 6 | |
| 8 | pub use rustc_middle::traits::query::type_op::ProvePredicate; | |
| 7 | use crate::infer::canonical::{Canonical, CanonicalQueryResponse}; | |
| 8 | use crate::traits::ObligationCtxt; | |
| 9 | 9 | |
| 10 | 10 | impl<'tcx> super::QueryTypeOp<'tcx> for ProvePredicate<'tcx> { |
| 11 | 11 | type QueryResponse = (); |
compiler/rustc_trait_selection/src/traits/query/type_op/subtype.rs+3-3| ... | ... | @@ -1,10 +1,10 @@ |
| 1 | use crate::infer::canonical::{Canonical, CanonicalQueryResponse}; | |
| 2 | use crate::traits::ObligationCtxt; | |
| 1 | pub use rustc_middle::traits::query::type_op::Subtype; | |
| 3 | 2 | use rustc_middle::traits::query::NoSolution; |
| 4 | 3 | use rustc_middle::traits::ObligationCause; |
| 5 | 4 | use rustc_middle::ty::{ParamEnvAnd, TyCtxt}; |
| 6 | 5 | |
| 7 | pub use rustc_middle::traits::query::type_op::Subtype; | |
| 6 | use crate::infer::canonical::{Canonical, CanonicalQueryResponse}; | |
| 7 | use crate::traits::ObligationCtxt; | |
| 8 | 8 | |
| 9 | 9 | impl<'tcx> super::QueryTypeOp<'tcx> for Subtype<'tcx> { |
| 10 | 10 | type QueryResponse = (); |
compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs+3-6| ... | ... | @@ -12,20 +12,17 @@ use hir::def_id::DefId; |
| 12 | 12 | use hir::LangItem; |
| 13 | 13 | use rustc_data_structures::fx::{FxHashSet, FxIndexSet}; |
| 14 | 14 | use rustc_hir as hir; |
| 15 | use rustc_infer::traits::ObligationCause; | |
| 16 | use rustc_infer::traits::{Obligation, PolyTraitObligation, SelectionError}; | |
| 15 | use rustc_infer::traits::{Obligation, ObligationCause, PolyTraitObligation, SelectionError}; | |
| 17 | 16 | use rustc_middle::ty::fast_reject::{DeepRejectCtxt, TreatParams}; |
| 18 | 17 | use rustc_middle::ty::{self, ToPolyTraitRef, Ty, TypeVisitableExt}; |
| 19 | 18 | use rustc_middle::{bug, span_bug}; |
| 20 | 19 | |
| 20 | use super::SelectionCandidate::*; | |
| 21 | use super::{BuiltinImplConditions, SelectionCandidateSet, SelectionContext, TraitObligationStack}; | |
| 21 | 22 | use crate::traits; |
| 22 | 23 | use crate::traits::query::evaluate_obligation::InferCtxtExt; |
| 23 | 24 | use crate::traits::util; |
| 24 | 25 | |
| 25 | use super::BuiltinImplConditions; | |
| 26 | use super::SelectionCandidate::*; | |
| 27 | use super::{SelectionCandidateSet, SelectionContext, TraitObligationStack}; | |
| 28 | ||
| 29 | 26 | impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { |
| 30 | 27 | #[instrument(skip(self, stack), level = "debug")] |
| 31 | 28 | pub(super) fn assemble_candidates<'o>( |
compiler/rustc_trait_selection/src/traits/select/confirmation.rs+6-9| ... | ... | @@ -7,11 +7,13 @@ |
| 7 | 7 | //! [rustc dev guide]: |
| 8 | 8 | //! https://rustc-dev-guide.rust-lang.org/traits/resolution.html#confirmation |
| 9 | 9 | |
| 10 | use std::iter; | |
| 11 | use std::ops::ControlFlow; | |
| 12 | ||
| 10 | 13 | use rustc_ast::Mutability; |
| 11 | 14 | use rustc_data_structures::stack::ensure_sufficient_stack; |
| 12 | 15 | use rustc_hir::lang_items::LangItem; |
| 13 | use rustc_infer::infer::HigherRankedType; | |
| 14 | use rustc_infer::infer::{DefineOpaqueTypes, InferOk}; | |
| 16 | use rustc_infer::infer::{DefineOpaqueTypes, HigherRankedType, InferOk}; | |
| 15 | 17 | use rustc_infer::traits::ObligationCauseCode; |
| 16 | 18 | use rustc_middle::traits::{BuiltinImplSource, SignatureMismatchData}; |
| 17 | 19 | use rustc_middle::ty::{ |
| ... | ... | @@ -21,6 +23,8 @@ use rustc_middle::ty::{ |
| 21 | 23 | use rustc_middle::{bug, span_bug}; |
| 22 | 24 | use rustc_span::def_id::DefId; |
| 23 | 25 | |
| 26 | use super::SelectionCandidate::{self, *}; | |
| 27 | use super::{BuiltinImplConditions, SelectionContext}; | |
| 24 | 28 | use crate::traits::normalize::{normalize_with_depth, normalize_with_depth_to}; |
| 25 | 29 | use crate::traits::util::{self, closure_trait_ref_and_return_type}; |
| 26 | 30 | use crate::traits::{ |
| ... | ... | @@ -29,13 +33,6 @@ use crate::traits::{ |
| 29 | 33 | SignatureMismatch, TraitNotObjectSafe, TraitObligation, Unimplemented, |
| 30 | 34 | }; |
| 31 | 35 | |
| 32 | use super::BuiltinImplConditions; | |
| 33 | use super::SelectionCandidate::{self, *}; | |
| 34 | use super::SelectionContext; | |
| 35 | ||
| 36 | use std::iter; | |
| 37 | use std::ops::ControlFlow; | |
| 38 | ||
| 39 | 36 | impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { |
| 40 | 37 | #[instrument(level = "debug", skip(self))] |
| 41 | 38 | pub(super) fn confirm_candidate( |
compiler/rustc_trait_selection/src/traits/select/mod.rs+28-40| ... | ... | @@ -2,31 +2,11 @@ |
| 2 | 2 | //! |
| 3 | 3 | //! [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/traits/resolution.html#selection |
| 4 | 4 | |
| 5 | use self::EvaluationResult::*; | |
| 6 | use self::SelectionCandidate::*; | |
| 7 | ||
| 8 | use super::coherence::{self, Conflict}; | |
| 9 | use super::const_evaluatable; | |
| 10 | use super::project; | |
| 11 | use super::project::ProjectionTermObligation; | |
| 12 | use super::util; | |
| 13 | use super::util::closure_trait_ref_and_return_type; | |
| 14 | use super::wf; | |
| 15 | use super::{ | |
| 16 | ImplDerivedCause, Normalized, Obligation, ObligationCause, ObligationCauseCode, Overflow, | |
| 17 | PolyTraitObligation, PredicateObligation, Selection, SelectionError, SelectionResult, | |
| 18 | TraitQueryMode, | |
| 19 | }; | |
| 5 | use std::cell::{Cell, RefCell}; | |
| 6 | use std::fmt::{self, Display}; | |
| 7 | use std::ops::ControlFlow; | |
| 8 | use std::{cmp, iter}; | |
| 20 | 9 | |
| 21 | use crate::error_reporting::InferCtxtErrorExt; | |
| 22 | use crate::infer::{InferCtxt, InferCtxtExt, InferOk, TypeFreshener}; | |
| 23 | use crate::solve::InferCtxtSelectExt as _; | |
| 24 | use crate::traits::normalize::normalize_with_depth; | |
| 25 | use crate::traits::normalize::normalize_with_depth_to; | |
| 26 | use crate::traits::project::ProjectAndUnifyResult; | |
| 27 | use crate::traits::project::ProjectionCacheKeyExt; | |
| 28 | use crate::traits::ProjectionCacheKey; | |
| 29 | use crate::traits::Unimplemented; | |
| 30 | 10 | use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet}; |
| 31 | 11 | use rustc_data_structures::stack::ensure_sufficient_stack; |
| 32 | 12 | use rustc_errors::{Diag, EmissionGuarantee}; |
| ... | ... | @@ -34,31 +14,39 @@ use rustc_hir as hir; |
| 34 | 14 | use rustc_hir::def_id::DefId; |
| 35 | 15 | use rustc_hir::LangItem; |
| 36 | 16 | use rustc_infer::infer::relate::TypeRelation; |
| 37 | use rustc_infer::infer::BoundRegionConversionTime; | |
| 38 | 17 | use rustc_infer::infer::BoundRegionConversionTime::HigherRankedType; |
| 39 | use rustc_infer::infer::DefineOpaqueTypes; | |
| 18 | use rustc_infer::infer::{BoundRegionConversionTime, DefineOpaqueTypes}; | |
| 40 | 19 | use rustc_infer::traits::TraitObligation; |
| 41 | 20 | use rustc_middle::bug; |
| 42 | use rustc_middle::dep_graph::dep_kinds; | |
| 43 | use rustc_middle::dep_graph::DepNodeIndex; | |
| 21 | use rustc_middle::dep_graph::{dep_kinds, DepNodeIndex}; | |
| 44 | 22 | use rustc_middle::mir::interpret::ErrorHandled; |
| 23 | pub use rustc_middle::traits::select::*; | |
| 45 | 24 | use rustc_middle::ty::abstract_const::NotConstEvaluatable; |
| 46 | 25 | use rustc_middle::ty::error::TypeErrorToStringExt; |
| 47 | use rustc_middle::ty::print::PrintTraitRefExt as _; | |
| 48 | use rustc_middle::ty::GenericArgsRef; | |
| 49 | use rustc_middle::ty::{self, PolyProjectionPredicate, Upcast}; | |
| 50 | use rustc_middle::ty::{Ty, TyCtxt, TypeFoldable, TypeVisitableExt}; | |
| 26 | use rustc_middle::ty::print::{with_no_trimmed_paths, PrintTraitRefExt as _}; | |
| 27 | use rustc_middle::ty::{ | |
| 28 | self, GenericArgsRef, PolyProjectionPredicate, Ty, TyCtxt, TypeFoldable, TypeVisitableExt, | |
| 29 | Upcast, | |
| 30 | }; | |
| 51 | 31 | use rustc_span::symbol::sym; |
| 52 | 32 | use rustc_span::Symbol; |
| 53 | 33 | |
| 54 | use std::cell::{Cell, RefCell}; | |
| 55 | use std::cmp; | |
| 56 | use std::fmt::{self, Display}; | |
| 57 | use std::iter; | |
| 58 | use std::ops::ControlFlow; | |
| 59 | ||
| 60 | pub use rustc_middle::traits::select::*; | |
| 61 | use rustc_middle::ty::print::with_no_trimmed_paths; | |
| 34 | use self::EvaluationResult::*; | |
| 35 | use self::SelectionCandidate::*; | |
| 36 | use super::coherence::{self, Conflict}; | |
| 37 | use super::project::ProjectionTermObligation; | |
| 38 | use super::util::closure_trait_ref_and_return_type; | |
| 39 | use super::{ | |
| 40 | const_evaluatable, project, util, wf, ImplDerivedCause, Normalized, Obligation, | |
| 41 | ObligationCause, ObligationCauseCode, Overflow, PolyTraitObligation, PredicateObligation, | |
| 42 | Selection, SelectionError, SelectionResult, TraitQueryMode, | |
| 43 | }; | |
| 44 | use crate::error_reporting::InferCtxtErrorExt; | |
| 45 | use crate::infer::{InferCtxt, InferCtxtExt, InferOk, TypeFreshener}; | |
| 46 | use crate::solve::InferCtxtSelectExt as _; | |
| 47 | use crate::traits::normalize::{normalize_with_depth, normalize_with_depth_to}; | |
| 48 | use crate::traits::project::{ProjectAndUnifyResult, ProjectionCacheKeyExt}; | |
| 49 | use crate::traits::{ProjectionCacheKey, Unimplemented}; | |
| 62 | 50 | |
| 63 | 51 | mod _match; |
| 64 | 52 | mod candidate_assembly; |
compiler/rustc_trait_selection/src/traits/specialize/mod.rs+10-13| ... | ... | @@ -10,28 +10,25 @@ |
| 10 | 10 | //! [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/traits/specialization.html |
| 11 | 11 | |
| 12 | 12 | pub mod specialization_graph; |
| 13 | use rustc_data_structures::fx::FxIndexSet; | |
| 14 | use rustc_errors::codes::*; | |
| 15 | use rustc_errors::{Diag, EmissionGuarantee}; | |
| 16 | use rustc_hir::def_id::{DefId, LocalDefId}; | |
| 13 | 17 | use rustc_infer::infer::DefineOpaqueTypes; |
| 18 | use rustc_middle::bug; | |
| 19 | use rustc_middle::query::LocalCrate; | |
| 14 | 20 | use rustc_middle::ty::print::PrintTraitRefExt as _; |
| 21 | use rustc_middle::ty::{self, GenericArgsRef, ImplSubject, Ty, TyCtxt, TypeVisitableExt}; | |
| 22 | use rustc_session::lint::builtin::{COHERENCE_LEAK_CHECK, ORDER_DEPENDENT_TRAIT_OBJECTS}; | |
| 23 | use rustc_span::{sym, ErrorGuaranteed, Span, DUMMY_SP}; | |
| 15 | 24 | use specialization_graph::GraphExt; |
| 16 | 25 | |
| 26 | use super::{util, SelectionContext}; | |
| 17 | 27 | use crate::error_reporting::traits::to_pretty_impl_header; |
| 18 | 28 | use crate::errors::NegativePositiveConflict; |
| 19 | 29 | use crate::infer::{InferCtxt, InferOk, TyCtxtInferExt}; |
| 20 | 30 | use crate::traits::select::IntercrateAmbiguityCause; |
| 21 | 31 | use crate::traits::{coherence, FutureCompatOverlapErrorKind, ObligationCause, ObligationCtxt}; |
| 22 | use rustc_data_structures::fx::FxIndexSet; | |
| 23 | use rustc_errors::{codes::*, Diag, EmissionGuarantee}; | |
| 24 | use rustc_hir::def_id::{DefId, LocalDefId}; | |
| 25 | use rustc_middle::bug; | |
| 26 | use rustc_middle::query::LocalCrate; | |
| 27 | use rustc_middle::ty::GenericArgsRef; | |
| 28 | use rustc_middle::ty::{self, ImplSubject, Ty, TyCtxt, TypeVisitableExt}; | |
| 29 | use rustc_session::lint::builtin::COHERENCE_LEAK_CHECK; | |
| 30 | use rustc_session::lint::builtin::ORDER_DEPENDENT_TRAIT_OBJECTS; | |
| 31 | use rustc_span::{sym, ErrorGuaranteed, Span, DUMMY_SP}; | |
| 32 | ||
| 33 | use super::util; | |
| 34 | use super::SelectionContext; | |
| 35 | 32 | |
| 36 | 33 | /// Information pertinent to an overlapping impl error. |
| 37 | 34 | #[derive(Debug)] |
compiler/rustc_trait_selection/src/traits/specialize/specialization_graph.rs+3-4| ... | ... | @@ -1,14 +1,13 @@ |
| 1 | use super::OverlapError; | |
| 2 | ||
| 3 | use crate::traits; | |
| 4 | 1 | use rustc_errors::ErrorGuaranteed; |
| 5 | 2 | use rustc_hir::def_id::DefId; |
| 6 | 3 | use rustc_macros::extension; |
| 7 | 4 | use rustc_middle::bug; |
| 5 | pub use rustc_middle::traits::specialization_graph::*; | |
| 8 | 6 | use rustc_middle::ty::fast_reject::{self, SimplifiedType, TreatParams}; |
| 9 | 7 | use rustc_middle::ty::{self, TyCtxt, TypeVisitableExt}; |
| 10 | 8 | |
| 11 | pub use rustc_middle::traits::specialization_graph::*; | |
| 9 | use super::OverlapError; | |
| 10 | use crate::traits; | |
| 12 | 11 | |
| 13 | 12 | #[derive(Copy, Clone, Debug)] |
| 14 | 13 | pub enum FutureCompatOverlapErrorKind { |
compiler/rustc_trait_selection/src/traits/util.rs+6-6| ... | ... | @@ -1,19 +1,19 @@ |
| 1 | 1 | use std::collections::BTreeMap; |
| 2 | 2 | |
| 3 | use super::NormalizeExt; | |
| 4 | use super::{ObligationCause, PredicateObligation, SelectionContext}; | |
| 5 | 3 | use rustc_data_structures::fx::FxIndexMap; |
| 6 | 4 | use rustc_errors::Diag; |
| 7 | 5 | use rustc_hir::def_id::DefId; |
| 8 | 6 | use rustc_infer::infer::{InferCtxt, InferOk}; |
| 7 | pub use rustc_infer::traits::util::*; | |
| 9 | 8 | use rustc_middle::bug; |
| 10 | use rustc_middle::ty::GenericArgsRef; | |
| 11 | use rustc_middle::ty::{self, ImplSubject, Ty, TyCtxt, TypeVisitableExt, Upcast}; | |
| 12 | use rustc_middle::ty::{TypeFoldable, TypeFolder, TypeSuperFoldable}; | |
| 9 | use rustc_middle::ty::{ | |
| 10 | self, GenericArgsRef, ImplSubject, Ty, TyCtxt, TypeFoldable, TypeFolder, TypeSuperFoldable, | |
| 11 | TypeVisitableExt, Upcast, | |
| 12 | }; | |
| 13 | 13 | use rustc_span::Span; |
| 14 | 14 | use smallvec::{smallvec, SmallVec}; |
| 15 | 15 | |
| 16 | pub use rustc_infer::traits::util::*; | |
| 16 | use super::{NormalizeExt, ObligationCause, PredicateObligation, SelectionContext}; | |
| 17 | 17 | |
| 18 | 18 | /////////////////////////////////////////////////////////////////////////// |
| 19 | 19 | // `TraitAliasExpander` iterator |
compiler/rustc_trait_selection/src/traits/vtable.rs+8-6| ... | ... | @@ -1,16 +1,18 @@ |
| 1 | use crate::errors::DumpVTableEntries; | |
| 2 | use crate::traits::{impossible_predicates, is_vtable_safe_method}; | |
| 1 | use std::fmt::Debug; | |
| 2 | use std::ops::ControlFlow; | |
| 3 | ||
| 3 | 4 | use rustc_hir::def_id::DefId; |
| 4 | 5 | use rustc_infer::traits::util::PredicateSet; |
| 5 | 6 | use rustc_middle::bug; |
| 6 | 7 | use rustc_middle::query::Providers; |
| 7 | use rustc_middle::ty::{self, GenericParamDefKind, Ty, TyCtxt, Upcast, VtblEntry}; | |
| 8 | use rustc_middle::ty::{GenericArgs, TypeVisitableExt}; | |
| 8 | use rustc_middle::ty::{ | |
| 9 | self, GenericArgs, GenericParamDefKind, Ty, TyCtxt, TypeVisitableExt, Upcast, VtblEntry, | |
| 10 | }; | |
| 9 | 11 | use rustc_span::{sym, Span, DUMMY_SP}; |
| 10 | 12 | use smallvec::{smallvec, SmallVec}; |
| 11 | 13 | |
| 12 | use std::fmt::Debug; | |
| 13 | use std::ops::ControlFlow; | |
| 14 | use crate::errors::DumpVTableEntries; | |
| 15 | use crate::traits::{impossible_predicates, is_vtable_safe_method}; | |
| 14 | 16 | |
| 15 | 17 | #[derive(Clone, Debug)] |
| 16 | 18 | pub enum VtblSegment<'tcx> { |
compiler/rustc_trait_selection/src/traits/wf.rs+6-5| ... | ... | @@ -1,17 +1,18 @@ |
| 1 | use crate::infer::InferCtxt; | |
| 2 | use crate::traits; | |
| 1 | use std::iter; | |
| 2 | ||
| 3 | 3 | use rustc_hir as hir; |
| 4 | 4 | use rustc_hir::lang_items::LangItem; |
| 5 | 5 | use rustc_infer::traits::ObligationCauseCode; |
| 6 | 6 | use rustc_middle::bug; |
| 7 | 7 | use rustc_middle::ty::{ |
| 8 | self, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor, | |
| 8 | self, GenericArg, GenericArgKind, GenericArgsRef, Ty, TyCtxt, TypeSuperVisitable, | |
| 9 | TypeVisitable, TypeVisitableExt, TypeVisitor, | |
| 9 | 10 | }; |
| 10 | use rustc_middle::ty::{GenericArg, GenericArgKind, GenericArgsRef}; | |
| 11 | 11 | use rustc_span::def_id::{DefId, LocalDefId, CRATE_DEF_ID}; |
| 12 | 12 | use rustc_span::{Span, DUMMY_SP}; |
| 13 | 13 | |
| 14 | use std::iter; | |
| 14 | use crate::infer::InferCtxt; | |
| 15 | use crate::traits; | |
| 15 | 16 | /// Returns the set of obligations needed to make `arg` well-formed. |
| 16 | 17 | /// If `arg` contains unresolved inference variables, this may include |
| 17 | 18 | /// further WF obligations. However, if `arg` IS an unresolved |
compiler/rustc_traits/src/dropck_outlives.rs+1-2| ... | ... | @@ -5,8 +5,7 @@ use rustc_infer::infer::TyCtxtInferExt; |
| 5 | 5 | use rustc_middle::bug; |
| 6 | 6 | use rustc_middle::query::Providers; |
| 7 | 7 | use rustc_middle::traits::query::{DropckConstraint, DropckOutlivesResult}; |
| 8 | use rustc_middle::ty::GenericArgs; | |
| 9 | use rustc_middle::ty::TyCtxt; | |
| 8 | use rustc_middle::ty::{GenericArgs, TyCtxt}; | |
| 10 | 9 | use rustc_trait_selection::infer::InferCtxtBuilderExt; |
| 11 | 10 | use rustc_trait_selection::traits::query::dropck_outlives::{ |
| 12 | 11 | compute_dropck_outlives_inner, dtorck_constraint_for_ty_inner, |
compiler/rustc_traits/src/lib.rs+1-2| ... | ... | @@ -12,11 +12,10 @@ mod normalize_erasing_regions; |
| 12 | 12 | mod normalize_projection_ty; |
| 13 | 13 | mod type_op; |
| 14 | 14 | |
| 15 | use rustc_middle::query::Providers; | |
| 15 | 16 | pub use rustc_trait_selection::traits::query::type_op::ascribe_user_type::type_op_ascribe_user_type_with_span; |
| 16 | 17 | pub use type_op::type_op_prove_predicate_with_cause; |
| 17 | 18 | |
| 18 | use rustc_middle::query::Providers; | |
| 19 | ||
| 20 | 19 | pub fn provide(p: &mut Providers) { |
| 21 | 20 | dropck_outlives::provide(p); |
| 22 | 21 | evaluate_obligation::provide(p); |
compiler/rustc_traits/src/normalize_projection_ty.rs+2-3| ... | ... | @@ -4,9 +4,8 @@ use rustc_middle::query::Providers; |
| 4 | 4 | use rustc_middle::ty::{ParamEnvAnd, TyCtxt}; |
| 5 | 5 | use rustc_trait_selection::error_reporting::InferCtxtErrorExt; |
| 6 | 6 | use rustc_trait_selection::infer::InferCtxtBuilderExt; |
| 7 | use rustc_trait_selection::traits::query::{ | |
| 8 | normalize::NormalizationResult, CanonicalAliasGoal, NoSolution, | |
| 9 | }; | |
| 7 | use rustc_trait_selection::traits::query::normalize::NormalizationResult; | |
| 8 | use rustc_trait_selection::traits::query::{CanonicalAliasGoal, NoSolution}; | |
| 10 | 9 | use rustc_trait_selection::traits::{self, ObligationCause, ScrubbedTraitError, SelectionContext}; |
| 11 | 10 | use tracing::debug; |
| 12 | 11 |
compiler/rustc_traits/src/type_op.rs+3-3| ... | ... | @@ -1,9 +1,10 @@ |
| 1 | use std::fmt; | |
| 2 | ||
| 1 | 3 | use rustc_infer::infer::canonical::{Canonical, QueryResponse}; |
| 2 | 4 | use rustc_infer::infer::TyCtxtInferExt; |
| 3 | 5 | use rustc_middle::query::Providers; |
| 4 | 6 | use rustc_middle::traits::query::NoSolution; |
| 5 | use rustc_middle::ty::{Clause, ParamEnvAnd}; | |
| 6 | use rustc_middle::ty::{FnSig, PolyFnSig, Ty, TyCtxt, TypeFoldable}; | |
| 7 | use rustc_middle::ty::{Clause, FnSig, ParamEnvAnd, PolyFnSig, Ty, TyCtxt, TypeFoldable}; | |
| 7 | 8 | use rustc_trait_selection::infer::InferCtxtBuilderExt; |
| 8 | 9 | use rustc_trait_selection::traits::query::normalize::QueryNormalizeExt; |
| 9 | 10 | use rustc_trait_selection::traits::query::type_op::ascribe_user_type::{ |
| ... | ... | @@ -14,7 +15,6 @@ use rustc_trait_selection::traits::query::type_op::normalize::Normalize; |
| 14 | 15 | use rustc_trait_selection::traits::query::type_op::prove_predicate::ProvePredicate; |
| 15 | 16 | use rustc_trait_selection::traits::query::type_op::subtype::Subtype; |
| 16 | 17 | use rustc_trait_selection::traits::{Normalized, Obligation, ObligationCause, ObligationCtxt}; |
| 17 | use std::fmt; | |
| 18 | 18 | |
| 19 | 19 | pub(crate) fn provide(p: &mut Providers) { |
| 20 | 20 | *p = Providers { |
compiler/rustc_transmute/src/layout/dfa.rs+4-2| ... | ... | @@ -1,9 +1,11 @@ |
| 1 | use super::{nfa, Byte, Nfa, Ref}; | |
| 2 | use crate::Map; | |
| 3 | 1 | use std::fmt; |
| 4 | 2 | use std::sync::atomic::{AtomicU32, Ordering}; |
| 3 | ||
| 5 | 4 | use tracing::instrument; |
| 6 | 5 | |
| 6 | use super::{nfa, Byte, Nfa, Ref}; | |
| 7 | use crate::Map; | |
| 8 | ||
| 7 | 9 | #[derive(PartialEq, Clone, Debug)] |
| 8 | 10 | pub(crate) struct Dfa<R> |
| 9 | 11 | where |
compiler/rustc_transmute/src/layout/mod.rs+2-1| ... | ... | @@ -60,9 +60,10 @@ impl Ref for ! { |
| 60 | 60 | |
| 61 | 61 | #[cfg(feature = "rustc")] |
| 62 | 62 | pub mod rustc { |
| 63 | use std::fmt::{self, Write}; | |
| 64 | ||
| 63 | 65 | use rustc_middle::mir::Mutability; |
| 64 | 66 | use rustc_middle::ty::{self, Ty}; |
| 65 | use std::fmt::{self, Write}; | |
| 66 | 67 | |
| 67 | 68 | /// A reference in the layout. |
| 68 | 69 | #[derive(Debug, Hash, Eq, PartialEq, Clone, Copy)] |
compiler/rustc_transmute/src/layout/nfa.rs+3-2| ... | ... | @@ -1,8 +1,9 @@ |
| 1 | use super::{Byte, Ref, Tree, Uninhabited}; | |
| 2 | use crate::{Map, Set}; | |
| 3 | 1 | use std::fmt; |
| 4 | 2 | use std::sync::atomic::{AtomicU32, Ordering}; |
| 5 | 3 | |
| 4 | use super::{Byte, Ref, Tree, Uninhabited}; | |
| 5 | use crate::{Map, Set}; | |
| 6 | ||
| 6 | 7 | /// A non-deterministic finite automaton (NFA) that represents the layout of a type. |
| 7 | 8 | /// The transmutability of two given types is computed by comparing their `Nfa`s. |
| 8 | 9 | #[derive(PartialEq, Debug)] |
compiler/rustc_transmute/src/layout/tree.rs+7-16| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | use super::{Byte, Def, Ref}; | |
| 2 | 1 | use std::ops::ControlFlow; |
| 3 | 2 | |
| 3 | use super::{Byte, Def, Ref}; | |
| 4 | ||
| 4 | 5 | #[cfg(test)] |
| 5 | 6 | mod tests; |
| 6 | 7 | |
| ... | ... | @@ -170,24 +171,14 @@ where |
| 170 | 171 | |
| 171 | 172 | #[cfg(feature = "rustc")] |
| 172 | 173 | pub(crate) mod rustc { |
| 174 | use rustc_middle::ty::layout::{HasTyCtxt, LayoutCx, LayoutError, LayoutOf}; | |
| 175 | use rustc_middle::ty::{self, AdtDef, AdtKind, List, ScalarInt, Ty, TyCtxt, TypeVisitableExt}; | |
| 176 | use rustc_span::ErrorGuaranteed; | |
| 177 | use rustc_target::abi::{FieldsShape, Size, TyAndLayout, Variants}; | |
| 178 | ||
| 173 | 179 | use super::Tree; |
| 174 | 180 | use crate::layout::rustc::{Def, Ref}; |
| 175 | 181 | |
| 176 | use rustc_middle::ty::layout::HasTyCtxt; | |
| 177 | use rustc_middle::ty::layout::LayoutCx; | |
| 178 | use rustc_middle::ty::layout::LayoutError; | |
| 179 | use rustc_middle::ty::layout::LayoutOf; | |
| 180 | use rustc_middle::ty::AdtDef; | |
| 181 | use rustc_middle::ty::AdtKind; | |
| 182 | use rustc_middle::ty::List; | |
| 183 | use rustc_middle::ty::ScalarInt; | |
| 184 | use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitableExt}; | |
| 185 | use rustc_span::ErrorGuaranteed; | |
| 186 | use rustc_target::abi::FieldsShape; | |
| 187 | use rustc_target::abi::Size; | |
| 188 | use rustc_target::abi::TyAndLayout; | |
| 189 | use rustc_target::abi::Variants; | |
| 190 | ||
| 191 | 182 | #[derive(Debug, Copy, Clone)] |
| 192 | 183 | pub(crate) enum Err { |
| 193 | 184 | /// The layout of the type is not yet supported. |
compiler/rustc_transmute/src/lib.rs+3-7| ... | ... | @@ -79,19 +79,15 @@ pub enum Reason<T> { |
| 79 | 79 | |
| 80 | 80 | #[cfg(feature = "rustc")] |
| 81 | 81 | mod rustc { |
| 82 | use super::*; | |
| 83 | ||
| 84 | 82 | use rustc_hir::lang_items::LangItem; |
| 85 | 83 | use rustc_infer::infer::InferCtxt; |
| 86 | 84 | use rustc_macros::TypeVisitable; |
| 87 | 85 | use rustc_middle::traits::ObligationCause; |
| 88 | use rustc_middle::ty::Const; | |
| 89 | use rustc_middle::ty::ParamEnv; | |
| 90 | use rustc_middle::ty::Ty; | |
| 91 | use rustc_middle::ty::TyCtxt; | |
| 92 | use rustc_middle::ty::ValTree; | |
| 86 | use rustc_middle::ty::{Const, ParamEnv, Ty, TyCtxt, ValTree}; | |
| 93 | 87 | use rustc_span::DUMMY_SP; |
| 94 | 88 | |
| 89 | use super::*; | |
| 90 | ||
| 95 | 91 | /// The source and destination types of a transmutation. |
| 96 | 92 | #[derive(TypeVisitable, Debug, Clone, Copy)] |
| 97 | 93 | pub struct Types<'tcx> { |
compiler/rustc_transmute/src/maybe_transmutable/mod.rs+6-11| ... | ... | @@ -4,11 +4,9 @@ pub(crate) mod query_context; |
| 4 | 4 | #[cfg(test)] |
| 5 | 5 | mod tests; |
| 6 | 6 | |
| 7 | use crate::{ | |
| 8 | layout::{self, dfa, Byte, Def, Dfa, Nfa, Ref, Tree, Uninhabited}, | |
| 9 | maybe_transmutable::query_context::QueryContext, | |
| 10 | Answer, Condition, Map, Reason, | |
| 11 | }; | |
| 7 | use crate::layout::{self, dfa, Byte, Def, Dfa, Nfa, Ref, Tree, Uninhabited}; | |
| 8 | use crate::maybe_transmutable::query_context::QueryContext; | |
| 9 | use crate::{Answer, Condition, Map, Reason}; | |
| 12 | 10 | |
| 13 | 11 | pub(crate) struct MaybeTransmutableQuery<L, C> |
| 14 | 12 | where |
| ... | ... | @@ -32,15 +30,12 @@ where |
| 32 | 30 | // FIXME: Nix this cfg, so we can write unit tests independently of rustc |
| 33 | 31 | #[cfg(feature = "rustc")] |
| 34 | 32 | mod rustc { |
| 33 | use rustc_middle::ty::layout::{LayoutCx, LayoutOf}; | |
| 34 | use rustc_middle::ty::{ParamEnv, Ty, TyCtxt}; | |
| 35 | ||
| 35 | 36 | use super::*; |
| 36 | 37 | use crate::layout::tree::rustc::Err; |
| 37 | 38 | |
| 38 | use rustc_middle::ty::layout::LayoutCx; | |
| 39 | use rustc_middle::ty::layout::LayoutOf; | |
| 40 | use rustc_middle::ty::ParamEnv; | |
| 41 | use rustc_middle::ty::Ty; | |
| 42 | use rustc_middle::ty::TyCtxt; | |
| 43 | ||
| 44 | 39 | impl<'tcx> MaybeTransmutableQuery<Ty<'tcx>, TyCtxt<'tcx>> { |
| 45 | 40 | /// This method begins by converting `src` and `dst` from `Ty`s to `Tree`s, |
| 46 | 41 | /// then computes an answer using those trees. |
compiler/rustc_transmute/src/maybe_transmutable/query_context.rs+2-1| ... | ... | @@ -34,9 +34,10 @@ pub(crate) mod test { |
| 34 | 34 | |
| 35 | 35 | #[cfg(feature = "rustc")] |
| 36 | 36 | mod rustc { |
| 37 | use super::*; | |
| 38 | 37 | use rustc_middle::ty::{Ty, TyCtxt}; |
| 39 | 38 | |
| 39 | use super::*; | |
| 40 | ||
| 40 | 41 | impl<'tcx> super::QueryContext for TyCtxt<'tcx> { |
| 41 | 42 | type Def = layout::rustc::Def<'tcx>; |
| 42 | 43 | type Ref = layout::rustc::Ref<'tcx>; |
compiler/rustc_transmute/src/maybe_transmutable/tests.rs+4-5| ... | ... | @@ -1,12 +1,12 @@ |
| 1 | use itertools::Itertools; | |
| 2 | ||
| 1 | 3 | use super::query_context::test::{Def, UltraMinimal}; |
| 2 | 4 | use crate::maybe_transmutable::MaybeTransmutableQuery; |
| 3 | 5 | use crate::{layout, Reason}; |
| 4 | use itertools::Itertools; | |
| 5 | 6 | |
| 6 | 7 | mod safety { |
| 7 | use crate::Answer; | |
| 8 | ||
| 9 | 8 | use super::*; |
| 9 | use crate::Answer; | |
| 10 | 10 | |
| 11 | 11 | type Tree = layout::Tree<Def, !>; |
| 12 | 12 | |
| ... | ... | @@ -63,9 +63,8 @@ mod safety { |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | mod bool { |
| 66 | use crate::Answer; | |
| 67 | ||
| 68 | 66 | use super::*; |
| 67 | use crate::Answer; | |
| 69 | 68 | |
| 70 | 69 | #[test] |
| 71 | 70 | fn should_permit_identity_transmutation_tree() { |
compiler/rustc_ty_utils/src/abi.rs+2-2| ... | ... | @@ -1,3 +1,5 @@ |
| 1 | use std::iter; | |
| 2 | ||
| 1 | 3 | use rustc_hir as hir; |
| 2 | 4 | use rustc_hir::lang_items::LangItem; |
| 3 | 5 | use rustc_middle::bug; |
| ... | ... | @@ -16,8 +18,6 @@ use rustc_target::abi::*; |
| 16 | 18 | use rustc_target::spec::abi::Abi as SpecAbi; |
| 17 | 19 | use tracing::debug; |
| 18 | 20 | |
| 19 | use std::iter; | |
| 20 | ||
| 21 | 21 | pub(crate) fn provide(providers: &mut Providers) { |
| 22 | 22 | *providers = Providers { fn_abi_of_fn_ptr, fn_abi_of_instance, ..*providers }; |
| 23 | 23 | } |
compiler/rustc_ty_utils/src/consts.rs+3-4| ... | ... | @@ -1,20 +1,19 @@ |
| 1 | use std::iter; | |
| 2 | ||
| 1 | 3 | use rustc_errors::ErrorGuaranteed; |
| 2 | 4 | use rustc_hir::def::DefKind; |
| 3 | 5 | use rustc_hir::def_id::LocalDefId; |
| 4 | use rustc_middle::bug; | |
| 5 | 6 | use rustc_middle::mir::interpret::{LitToConstError, LitToConstInput}; |
| 6 | 7 | use rustc_middle::query::Providers; |
| 7 | 8 | use rustc_middle::thir::visit; |
| 8 | 9 | use rustc_middle::thir::visit::Visitor; |
| 9 | 10 | use rustc_middle::ty::abstract_const::CastKind; |
| 10 | 11 | use rustc_middle::ty::{self, Expr, TyCtxt, TypeVisitableExt}; |
| 11 | use rustc_middle::{mir, thir}; | |
| 12 | use rustc_middle::{bug, mir, thir}; | |
| 12 | 13 | use rustc_span::Span; |
| 13 | 14 | use rustc_target::abi::{VariantIdx, FIRST_VARIANT}; |
| 14 | 15 | use tracing::{debug, instrument}; |
| 15 | 16 | |
| 16 | use std::iter; | |
| 17 | ||
| 18 | 17 | use crate::errors::{GenericConstantTooComplex, GenericConstantTooComplexSub}; |
| 19 | 18 | |
| 20 | 19 | /// Destructures array, ADT or tuple constants into the constants |
compiler/rustc_ty_utils/src/implied_bounds.rs+2-1| ... | ... | @@ -1,3 +1,5 @@ |
| 1 | use std::iter; | |
| 2 | ||
| 1 | 3 | use rustc_data_structures::fx::FxHashMap; |
| 2 | 4 | use rustc_hir as hir; |
| 3 | 5 | use rustc_hir::def::DefKind; |
| ... | ... | @@ -6,7 +8,6 @@ use rustc_middle::bug; |
| 6 | 8 | use rustc_middle::query::Providers; |
| 7 | 9 | use rustc_middle::ty::{self, Ty, TyCtxt}; |
| 8 | 10 | use rustc_span::Span; |
| 9 | use std::iter; | |
| 10 | 11 | |
| 11 | 12 | pub(crate) fn provide(providers: &mut Providers) { |
| 12 | 13 | *providers = Providers { |
compiler/rustc_ty_utils/src/instance.rs+1-2| ... | ... | @@ -6,8 +6,7 @@ use rustc_middle::bug; |
| 6 | 6 | use rustc_middle::query::Providers; |
| 7 | 7 | use rustc_middle::traits::{BuiltinImplSource, CodegenObligationError}; |
| 8 | 8 | use rustc_middle::ty::util::AsyncDropGlueMorphology; |
| 9 | use rustc_middle::ty::GenericArgsRef; | |
| 10 | use rustc_middle::ty::{self, Instance, TyCtxt, TypeVisitableExt}; | |
| 9 | use rustc_middle::ty::{self, GenericArgsRef, Instance, TyCtxt, TypeVisitableExt}; | |
| 11 | 10 | use rustc_span::sym; |
| 12 | 11 | use rustc_trait_selection::traits; |
| 13 | 12 | use rustc_type_ir::ClosureKind; |
compiler/rustc_ty_utils/src/layout.rs+3-3| ... | ... | @@ -1,3 +1,6 @@ |
| 1 | use std::fmt::Debug; | |
| 2 | use std::iter; | |
| 3 | ||
| 1 | 4 | use hir::def_id::DefId; |
| 2 | 5 | use rustc_hir as hir; |
| 3 | 6 | use rustc_index::bit_set::BitSet; |
| ... | ... | @@ -19,9 +22,6 @@ use rustc_span::symbol::Symbol; |
| 19 | 22 | use rustc_target::abi::*; |
| 20 | 23 | use tracing::{debug, instrument, trace}; |
| 21 | 24 | |
| 22 | use std::fmt::Debug; | |
| 23 | use std::iter; | |
| 24 | ||
| 25 | 25 | use crate::errors::{ |
| 26 | 26 | MultipleArrayFieldsSimdType, NonPrimitiveSimdType, OversizedSimdType, ZeroLengthSimdType, |
| 27 | 27 | }; |
compiler/rustc_ty_utils/src/layout_sanity_check.rs+4-6| ... | ... | @@ -1,12 +1,10 @@ |
| 1 | use std::assert_matches::assert_matches; | |
| 2 | ||
| 1 | 3 | use rustc_middle::bug; |
| 2 | use rustc_middle::ty::{ | |
| 3 | layout::{LayoutCx, TyAndLayout}, | |
| 4 | TyCtxt, | |
| 5 | }; | |
| 4 | use rustc_middle::ty::layout::{LayoutCx, TyAndLayout}; | |
| 5 | use rustc_middle::ty::TyCtxt; | |
| 6 | 6 | use rustc_target::abi::*; |
| 7 | 7 | |
| 8 | use std::assert_matches::assert_matches; | |
| 9 | ||
| 10 | 8 | /// Enforce some basic invariants on layouts. |
| 11 | 9 | pub(super) fn sanity_check_layout<'tcx>( |
| 12 | 10 | cx: &LayoutCx<'tcx, TyCtxt<'tcx>>, |
compiler/rustc_ty_utils/src/needs_drop.rs+1-2| ... | ... | @@ -5,8 +5,7 @@ use rustc_hir::def_id::DefId; |
| 5 | 5 | use rustc_middle::bug; |
| 6 | 6 | use rustc_middle::query::Providers; |
| 7 | 7 | use rustc_middle::ty::util::{needs_drop_components, AlwaysRequiresDrop}; |
| 8 | use rustc_middle::ty::GenericArgsRef; | |
| 9 | use rustc_middle::ty::{self, EarlyBinder, Ty, TyCtxt}; | |
| 8 | use rustc_middle::ty::{self, EarlyBinder, GenericArgsRef, Ty, TyCtxt}; | |
| 10 | 9 | use rustc_session::Limit; |
| 11 | 10 | use rustc_span::sym; |
| 12 | 11 | use tracing::debug; |
compiler/rustc_ty_utils/src/opaque_types.rs+3-3| ... | ... | @@ -1,12 +1,12 @@ |
| 1 | 1 | use rustc_data_structures::fx::FxHashSet; |
| 2 | use rustc_hir::def::DefKind; | |
| 3 | use rustc_hir::def_id::LocalDefId; | |
| 2 | 4 | use rustc_hir::intravisit::Visitor; |
| 3 | use rustc_hir::{def::DefKind, def_id::LocalDefId}; | |
| 4 | 5 | use rustc_hir::{intravisit, CRATE_HIR_ID}; |
| 5 | 6 | use rustc_middle::bug; |
| 6 | 7 | use rustc_middle::query::Providers; |
| 7 | 8 | use rustc_middle::ty::util::{CheckRegions, NotUniqueParam}; |
| 8 | use rustc_middle::ty::{self, Ty, TyCtxt}; | |
| 9 | use rustc_middle::ty::{TypeSuperVisitable, TypeVisitable, TypeVisitor}; | |
| 9 | use rustc_middle::ty::{self, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitor}; | |
| 10 | 10 | use rustc_span::Span; |
| 11 | 11 | use tracing::{instrument, trace}; |
| 12 | 12 |
compiler/rustc_ty_utils/src/sig_types.rs+2-1| ... | ... | @@ -3,7 +3,8 @@ |
| 3 | 3 | |
| 4 | 4 | use rustc_ast_ir::try_visit; |
| 5 | 5 | use rustc_ast_ir::visit::VisitorResult; |
| 6 | use rustc_hir::{def::DefKind, def_id::LocalDefId}; | |
| 6 | use rustc_hir::def::DefKind; | |
| 7 | use rustc_hir::def_id::LocalDefId; | |
| 7 | 8 | use rustc_middle::span_bug; |
| 8 | 9 | use rustc_middle::ty::{self, TyCtxt}; |
| 9 | 10 | use rustc_span::Span; |
compiler/rustc_ty_utils/src/structural_match.rs+1-2| ... | ... | @@ -1,8 +1,7 @@ |
| 1 | 1 | use rustc_hir::lang_items::LangItem; |
| 2 | use rustc_infer::infer::TyCtxtInferExt; | |
| 2 | 3 | use rustc_middle::query::Providers; |
| 3 | 4 | use rustc_middle::ty::{self, Ty, TyCtxt}; |
| 4 | ||
| 5 | use rustc_infer::infer::TyCtxtInferExt; | |
| 6 | 5 | use rustc_trait_selection::traits::{ObligationCause, ObligationCtxt}; |
| 7 | 6 | |
| 8 | 7 | /// This method returns true if and only if `adt_ty` itself has been marked as |
compiler/rustc_ty_utils/src/ty.rs+4-2| ... | ... | @@ -5,8 +5,10 @@ use rustc_hir::LangItem; |
| 5 | 5 | use rustc_index::bit_set::BitSet; |
| 6 | 6 | use rustc_middle::bug; |
| 7 | 7 | use rustc_middle::query::Providers; |
| 8 | use rustc_middle::ty::{self, EarlyBinder, Ty, TyCtxt, TypeVisitableExt, TypeVisitor}; | |
| 9 | use rustc_middle::ty::{TypeSuperVisitable, TypeVisitable, Upcast}; | |
| 8 | use rustc_middle::ty::{ | |
| 9 | self, EarlyBinder, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitableExt, | |
| 10 | TypeVisitor, Upcast, | |
| 11 | }; | |
| 10 | 12 | use rustc_span::def_id::{DefId, LocalDefId, CRATE_DEF_ID}; |
| 11 | 13 | use rustc_span::DUMMY_SP; |
| 12 | 14 | use rustc_trait_selection::traits; |
compiler/rustc_type_ir/src/canonical.rs+4-3| ... | ... | @@ -1,10 +1,11 @@ |
| 1 | use std::fmt; | |
| 2 | use std::hash::Hash; | |
| 3 | use std::ops::Index; | |
| 4 | ||
| 1 | 5 | use derive_where::derive_where; |
| 2 | 6 | #[cfg(feature = "nightly")] |
| 3 | 7 | use rustc_macros::{HashStable_NoContext, TyDecodable, TyEncodable}; |
| 4 | 8 | use rustc_type_ir_macros::{Lift_Generic, TypeFoldable_Generic, TypeVisitable_Generic}; |
| 5 | use std::fmt; | |
| 6 | use std::hash::Hash; | |
| 7 | use std::ops::Index; | |
| 8 | 9 | |
| 9 | 10 | use crate::inherent::*; |
| 10 | 11 | use crate::{self as ty, Interner, UniverseIndex}; |
compiler/rustc_type_ir/src/codec.rs+2-2| ... | ... | @@ -1,8 +1,8 @@ |
| 1 | use crate::{Interner, PredicateKind}; | |
| 2 | ||
| 3 | 1 | use rustc_data_structures::fx::FxHashMap; |
| 4 | 2 | use rustc_span::{SpanDecoder, SpanEncoder}; |
| 5 | 3 | |
| 4 | use crate::{Interner, PredicateKind}; | |
| 5 | ||
| 6 | 6 | /// The shorthand encoding uses an enum's variant index `usize` |
| 7 | 7 | /// and is offset by this value so it never matches a real variant. |
| 8 | 8 | /// This offset is also chosen so that the first byte is never < 0x80. |
compiler/rustc_type_ir/src/const_kind.rs+2-1| ... | ... | @@ -1,10 +1,11 @@ |
| 1 | use std::fmt; | |
| 2 | ||
| 1 | 3 | use derive_where::derive_where; |
| 2 | 4 | #[cfg(feature = "nightly")] |
| 3 | 5 | use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; |
| 4 | 6 | #[cfg(feature = "nightly")] |
| 5 | 7 | use rustc_macros::{HashStable_NoContext, TyDecodable, TyEncodable}; |
| 6 | 8 | use rustc_type_ir_macros::{Lift_Generic, TypeFoldable_Generic, TypeVisitable_Generic}; |
| 7 | use std::fmt; | |
| 8 | 9 | |
| 9 | 10 | use crate::{self as ty, DebruijnIndex, Interner}; |
| 10 | 11 |
compiler/rustc_type_ir/src/data_structures.rs+7-12| ... | ... | @@ -1,25 +1,20 @@ |
| 1 | 1 | #[cfg(feature = "nightly")] |
| 2 | 2 | mod impl_ { |
| 3 | pub use rustc_data_structures::fx::FxHashMap as HashMap; | |
| 4 | pub use rustc_data_structures::fx::FxHashSet as HashSet; | |
| 5 | pub use rustc_data_structures::fx::FxIndexMap as IndexMap; | |
| 6 | pub use rustc_data_structures::fx::FxIndexSet as IndexSet; | |
| 7 | pub use rustc_data_structures::sso::SsoHashMap; | |
| 8 | pub use rustc_data_structures::sso::SsoHashSet; | |
| 3 | pub use rustc_data_structures::fx::{ | |
| 4 | FxHashMap as HashMap, FxHashSet as HashSet, FxIndexMap as IndexMap, FxIndexSet as IndexSet, | |
| 5 | }; | |
| 6 | pub use rustc_data_structures::sso::{SsoHashMap, SsoHashSet}; | |
| 9 | 7 | pub use rustc_data_structures::stack::ensure_sufficient_stack; |
| 10 | 8 | pub use rustc_data_structures::sync::Lrc; |
| 11 | 9 | } |
| 12 | 10 | |
| 13 | 11 | #[cfg(not(feature = "nightly"))] |
| 14 | 12 | mod impl_ { |
| 15 | pub use indexmap::IndexMap; | |
| 16 | pub use indexmap::IndexSet; | |
| 17 | pub use std::collections::HashMap; | |
| 18 | pub use std::collections::HashMap as SsoHashMap; | |
| 19 | pub use std::collections::HashSet; | |
| 20 | pub use std::collections::HashSet as SsoHashSet; | |
| 13 | pub use std::collections::{HashMap, HashMap as SsoHashMap, HashSet, HashSet as SsoHashSet}; | |
| 21 | 14 | pub use std::sync::Arc as Lrc; |
| 22 | 15 | |
| 16 | pub use indexmap::{IndexMap, IndexSet}; | |
| 17 | ||
| 23 | 18 | #[inline] |
| 24 | 19 | pub fn ensure_sufficient_stack<R>(f: impl FnOnce() -> R) -> R { |
| 25 | 20 | f() |
compiler/rustc_type_ir/src/elaborate.rs+2-2| ... | ... | @@ -3,9 +3,9 @@ use std::marker::PhantomData; |
| 3 | 3 | use smallvec::smallvec; |
| 4 | 4 | |
| 5 | 5 | use crate::data_structures::HashSet; |
| 6 | use crate::inherent::*; | |
| 6 | 7 | use crate::outlives::{push_outlives_components, Component}; |
| 7 | use crate::{self as ty, Interner}; | |
| 8 | use crate::{inherent::*, Upcast as _}; | |
| 8 | use crate::{self as ty, Interner, Upcast as _}; | |
| 9 | 9 | |
| 10 | 10 | /// "Elaboration" is the process of identifying all the predicates that |
| 11 | 11 | /// are implied by a source predicate. Currently, this basically means |
compiler/rustc_type_ir/src/fold.rs+2-1| ... | ... | @@ -45,8 +45,9 @@ |
| 45 | 45 | //! - u.fold_with(folder) |
| 46 | 46 | //! ``` |
| 47 | 47 | |
| 48 | use rustc_index::{Idx, IndexVec}; | |
| 49 | 48 | use std::mem; |
| 49 | ||
| 50 | use rustc_index::{Idx, IndexVec}; | |
| 50 | 51 | use tracing::debug; |
| 51 | 52 | |
| 52 | 53 | use crate::data_structures::Lrc; |
compiler/rustc_type_ir/src/interner.rs+7-5| ... | ... | @@ -1,22 +1,24 @@ |
| 1 | use rustc_ast_ir::Movability; | |
| 2 | use rustc_index::bit_set::BitSet; | |
| 3 | use smallvec::SmallVec; | |
| 4 | 1 | use std::fmt::Debug; |
| 5 | 2 | use std::hash::Hash; |
| 6 | 3 | use std::ops::Deref; |
| 7 | 4 | |
| 5 | use rustc_ast_ir::Movability; | |
| 6 | use rustc_index::bit_set::BitSet; | |
| 7 | use smallvec::SmallVec; | |
| 8 | ||
| 8 | 9 | use crate::fold::TypeFoldable; |
| 9 | 10 | use crate::inherent::*; |
| 10 | 11 | use crate::ir_print::IrPrint; |
| 11 | 12 | use crate::lang_items::TraitSolverLangItem; |
| 12 | 13 | use crate::relate::Relate; |
| 13 | use crate::search_graph; | |
| 14 | 14 | use crate::solve::inspect::CanonicalGoalEvaluationStep; |
| 15 | 15 | use crate::solve::{ |
| 16 | 16 | CanonicalInput, ExternalConstraintsData, PredefinedOpaquesData, QueryResult, SolverMode, |
| 17 | 17 | }; |
| 18 | 18 | use crate::visit::{Flags, TypeSuperVisitable, TypeVisitable}; |
| 19 | use crate::{self as ty}; | |
| 19 | use crate::{ | |
| 20 | search_graph, {self as ty}, | |
| 21 | }; | |
| 20 | 22 | |
| 21 | 23 | pub trait Interner: |
| 22 | 24 | Sized |
compiler/rustc_type_ir/src/lib.rs+3-2| ... | ... | @@ -9,11 +9,12 @@ |
| 9 | 9 | |
| 10 | 10 | extern crate self as rustc_type_ir; |
| 11 | 11 | |
| 12 | #[cfg(feature = "nightly")] | |
| 13 | use rustc_macros::{Decodable, Encodable, HashStable_NoContext}; | |
| 14 | 12 | use std::fmt; |
| 15 | 13 | use std::hash::Hash; |
| 16 | 14 | |
| 15 | #[cfg(feature = "nightly")] | |
| 16 | use rustc_macros::{Decodable, Encodable, HashStable_NoContext}; | |
| 17 | ||
| 17 | 18 | // These modules are `pub` since they are not glob-imported. |
| 18 | 19 | #[macro_use] |
| 19 | 20 | pub mod visit; |
compiler/rustc_type_ir/src/predicate_kind.rs+2-1| ... | ... | @@ -1,8 +1,9 @@ |
| 1 | use std::fmt; | |
| 2 | ||
| 1 | 3 | use derive_where::derive_where; |
| 2 | 4 | #[cfg(feature = "nightly")] |
| 3 | 5 | use rustc_macros::{Decodable, Encodable, HashStable_NoContext, TyDecodable, TyEncodable}; |
| 4 | 6 | use rustc_type_ir_macros::{TypeFoldable_Generic, TypeVisitable_Generic}; |
| 5 | use std::fmt; | |
| 6 | 7 | |
| 7 | 8 | use crate::{self as ty, Interner}; |
| 8 | 9 |
compiler/rustc_type_ir/src/region_kind.rs+3-3| ... | ... | @@ -1,13 +1,13 @@ |
| 1 | use std::fmt; | |
| 2 | ||
| 1 | 3 | use derive_where::derive_where; |
| 2 | 4 | #[cfg(feature = "nightly")] |
| 3 | 5 | use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; |
| 4 | 6 | #[cfg(feature = "nightly")] |
| 5 | 7 | use rustc_macros::{HashStable_NoContext, TyDecodable, TyEncodable}; |
| 6 | use std::fmt; | |
| 7 | ||
| 8 | use crate::{DebruijnIndex, Interner}; | |
| 9 | 8 | |
| 10 | 9 | use self::RegionKind::*; |
| 10 | use crate::{DebruijnIndex, Interner}; | |
| 11 | 11 | |
| 12 | 12 | rustc_index::newtype_index! { |
| 13 | 13 | /// A **region** **v**ariable **ID**. |
compiler/rustc_type_ir/src/solve/inspect.rs+6-4| ... | ... | @@ -17,14 +17,16 @@ |
| 17 | 17 | //! |
| 18 | 18 | //! [canonicalized]: https://rustc-dev-guide.rust-lang.org/solve/canonicalization.html |
| 19 | 19 | |
| 20 | use std::fmt::Debug; | |
| 21 | use std::hash::Hash; | |
| 22 | ||
| 23 | use derive_where::derive_where; | |
| 24 | use rustc_type_ir_macros::{TypeFoldable_Generic, TypeVisitable_Generic}; | |
| 25 | ||
| 20 | 26 | use crate::solve::{ |
| 21 | 27 | CandidateSource, CanonicalInput, Certainty, Goal, GoalSource, QueryInput, QueryResult, |
| 22 | 28 | }; |
| 23 | 29 | use crate::{Canonical, CanonicalVarValues, Interner}; |
| 24 | use derive_where::derive_where; | |
| 25 | use rustc_type_ir_macros::{TypeFoldable_Generic, TypeVisitable_Generic}; | |
| 26 | use std::fmt::Debug; | |
| 27 | use std::hash::Hash; | |
| 28 | 30 | |
| 29 | 31 | /// Some `data` together with information about how they relate to the input |
| 30 | 32 | /// of the canonical query. |
compiler/rustc_type_ir/src/ty_info.rs+4-3| ... | ... | @@ -1,10 +1,11 @@ |
| 1 | use std::cmp::Ordering; | |
| 2 | use std::hash::{Hash, Hasher}; | |
| 3 | use std::ops::Deref; | |
| 4 | ||
| 1 | 5 | #[cfg(feature = "nightly")] |
| 2 | 6 | use rustc_data_structures::fingerprint::Fingerprint; |
| 3 | 7 | #[cfg(feature = "nightly")] |
| 4 | 8 | use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; |
| 5 | use std::cmp::Ordering; | |
| 6 | use std::hash::{Hash, Hasher}; | |
| 7 | use std::ops::Deref; | |
| 8 | 9 | |
| 9 | 10 | use crate::{DebruijnIndex, TypeFlags}; |
| 10 | 11 |
compiler/rustc_type_ir/src/ty_kind.rs+3-4| ... | ... | @@ -1,5 +1,7 @@ |
| 1 | use derive_where::derive_where; | |
| 1 | use std::fmt; | |
| 2 | 2 | |
| 3 | use derive_where::derive_where; | |
| 4 | use rustc_ast_ir::Mutability; | |
| 3 | 5 | #[cfg(feature = "nightly")] |
| 4 | 6 | use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; |
| 5 | 7 | #[cfg(feature = "nightly")] |
| ... | ... | @@ -7,15 +9,12 @@ use rustc_data_structures::unify::{NoError, UnifyKey, UnifyValue}; |
| 7 | 9 | #[cfg(feature = "nightly")] |
| 8 | 10 | use rustc_macros::{Decodable, Encodable, HashStable_NoContext, TyDecodable, TyEncodable}; |
| 9 | 11 | use rustc_type_ir_macros::{Lift_Generic, TypeFoldable_Generic, TypeVisitable_Generic}; |
| 10 | use std::fmt; | |
| 11 | 12 | |
| 12 | 13 | pub use self::closure::*; |
| 13 | 14 | use self::TyKind::*; |
| 14 | 15 | use crate::inherent::*; |
| 15 | 16 | use crate::{self as ty, DebruijnIndex, Interner}; |
| 16 | 17 | |
| 17 | use rustc_ast_ir::Mutability; | |
| 18 | ||
| 19 | 18 | mod closure; |
| 20 | 19 | |
| 21 | 20 | /// Specifies how a trait object is represented. |
compiler/rustc_type_ir/src/visit.rs+3-2| ... | ... | @@ -41,11 +41,12 @@ |
| 41 | 41 | //! - u.visit_with(visitor) |
| 42 | 42 | //! ``` |
| 43 | 43 | |
| 44 | use std::fmt; | |
| 45 | use std::ops::ControlFlow; | |
| 46 | ||
| 44 | 47 | use rustc_ast_ir::visit::VisitorResult; |
| 45 | 48 | use rustc_ast_ir::{try_visit, walk_visitable_list}; |
| 46 | 49 | use rustc_index::{Idx, IndexVec}; |
| 47 | use std::fmt; | |
| 48 | use std::ops::ControlFlow; | |
| 49 | 50 | |
| 50 | 51 | use crate::data_structures::Lrc; |
| 51 | 52 | use crate::inherent::*; |
compiler/rustc_type_ir_macros/src/lib.rs+2-1| ... | ... | @@ -1,5 +1,6 @@ |
| 1 | 1 | use quote::quote; |
| 2 | use syn::{parse_quote, visit_mut::VisitMut}; | |
| 2 | use syn::parse_quote; | |
| 3 | use syn::visit_mut::VisitMut; | |
| 3 | 4 | use synstructure::decl_derive; |
| 4 | 5 | |
| 5 | 6 | decl_derive!( |
compiler/stable_mir/src/abi.rs+7-7| ... | ... | @@ -1,14 +1,14 @@ |
| 1 | use std::fmt::{self, Debug}; | |
| 2 | use std::num::NonZero; | |
| 3 | use std::ops::RangeInclusive; | |
| 4 | ||
| 5 | use serde::Serialize; | |
| 6 | ||
| 1 | 7 | use crate::compiler_interface::with; |
| 2 | use crate::error; | |
| 3 | 8 | use crate::mir::FieldIdx; |
| 4 | 9 | use crate::target::{MachineInfo, MachineSize as Size}; |
| 5 | 10 | use crate::ty::{Align, IndexedVal, Ty, VariantIdx}; |
| 6 | use crate::Error; | |
| 7 | use crate::Opaque; | |
| 8 | use serde::Serialize; | |
| 9 | use std::fmt::{self, Debug}; | |
| 10 | use std::num::NonZero; | |
| 11 | use std::ops::RangeInclusive; | |
| 11 | use crate::{error, Error, Opaque}; | |
| 12 | 12 | |
| 13 | 13 | /// A function ABI definition. |
| 14 | 14 | #[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize)] |
compiler/stable_mir/src/crate_def.rs+2-1| ... | ... | @@ -1,9 +1,10 @@ |
| 1 | 1 | //! Module that define a common trait for things that represent a crate definition, |
| 2 | 2 | //! such as, a function, a trait, an enum, and any other definitions. |
| 3 | 3 | |
| 4 | use serde::Serialize; | |
| 5 | ||
| 4 | 6 | use crate::ty::{GenericArgs, Span, Ty}; |
| 5 | 7 | use crate::{with, Crate, Symbol}; |
| 6 | use serde::Serialize; | |
| 7 | 8 | |
| 8 | 9 | /// A unique identification number for each item accessible for the current compilation unit. |
| 9 | 10 | #[derive(Clone, Copy, PartialEq, Eq, Hash, Serialize)] |
compiler/stable_mir/src/lib.rs+4-5| ... | ... | @@ -17,17 +17,16 @@ |
| 17 | 17 | //! The goal is to eventually be published on |
| 18 | 18 | //! [crates.io](https://crates.io). |
| 19 | 19 | |
| 20 | use std::fmt; | |
| 21 | 20 | use std::fmt::Debug; |
| 22 | use std::io; | |
| 21 | use std::{fmt, io}; | |
| 22 | ||
| 23 | use serde::Serialize; | |
| 23 | 24 | |
| 24 | 25 | use crate::compiler_interface::with; |
| 25 | 26 | pub use crate::crate_def::{CrateDef, CrateDefType, DefId}; |
| 26 | 27 | pub use crate::error::*; |
| 27 | use crate::mir::Body; | |
| 28 | use crate::mir::Mutability; | |
| 28 | use crate::mir::{Body, Mutability}; | |
| 29 | 29 | use crate::ty::{ForeignModuleDef, ImplDef, IndexedVal, Span, TraitDef, Ty}; |
| 30 | use serde::Serialize; | |
| 31 | 30 | |
| 32 | 31 | pub mod abi; |
| 33 | 32 | #[macro_use] |
compiler/stable_mir/src/mir/alloc.rs+4-2| ... | ... | @@ -1,11 +1,13 @@ |
| 1 | 1 | //! This module provides methods to retrieve allocation information, such as static variables. |
| 2 | 2 | |
| 3 | use std::io::Read; | |
| 4 | ||
| 5 | use serde::Serialize; | |
| 6 | ||
| 3 | 7 | use crate::mir::mono::{Instance, StaticDef}; |
| 4 | 8 | use crate::target::{Endian, MachineInfo}; |
| 5 | 9 | use crate::ty::{Allocation, Binder, ExistentialTraitRef, IndexedVal, Ty}; |
| 6 | 10 | use crate::{with, Error}; |
| 7 | use serde::Serialize; | |
| 8 | use std::io::Read; | |
| 9 | 11 | |
| 10 | 12 | /// An allocation in the SMIR global memory can be either a function pointer, |
| 11 | 13 | /// a static, or a "real" allocation with some data in it. |
compiler/stable_mir/src/mir/body.rs+4-2| ... | ... | @@ -1,3 +1,7 @@ |
| 1 | use std::io; | |
| 2 | ||
| 3 | use serde::Serialize; | |
| 4 | ||
| 1 | 5 | use crate::compiler_interface::with; |
| 2 | 6 | use crate::mir::pretty::function_body; |
| 3 | 7 | use crate::ty::{ |
| ... | ... | @@ -5,8 +9,6 @@ use crate::ty::{ |
| 5 | 9 | TyConst, TyKind, VariantIdx, |
| 6 | 10 | }; |
| 7 | 11 | use crate::{Error, Opaque, Span, Symbol}; |
| 8 | use serde::Serialize; | |
| 9 | use std::io; | |
| 10 | 12 | |
| 11 | 13 | /// The SMIR representation of a single function. |
| 12 | 14 | #[derive(Clone, Debug, Serialize)] |
compiler/stable_mir/src/mir/mono.rs+5-3| ... | ... | @@ -1,11 +1,13 @@ |
| 1 | use std::fmt::{Debug, Formatter}; | |
| 2 | use std::io; | |
| 3 | ||
| 4 | use serde::Serialize; | |
| 5 | ||
| 1 | 6 | use crate::abi::FnAbi; |
| 2 | 7 | use crate::crate_def::CrateDef; |
| 3 | 8 | use crate::mir::Body; |
| 4 | 9 | use crate::ty::{Allocation, ClosureDef, ClosureKind, FnDef, GenericArgs, IndexedVal, Ty}; |
| 5 | 10 | use crate::{with, CrateItem, DefId, Error, ItemKind, Opaque, Symbol}; |
| 6 | use serde::Serialize; | |
| 7 | use std::fmt::{Debug, Formatter}; | |
| 8 | use std::io; | |
| 9 | 11 | |
| 10 | 12 | #[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize)] |
| 11 | 13 | pub enum MonoItem { |
compiler/stable_mir/src/mir/pretty.rs+5-6| ... | ... | @@ -1,14 +1,13 @@ |
| 1 | use crate::mir::{Operand, Place, Rvalue, StatementKind, UnwindAction, VarDebugInfoContents}; | |
| 2 | use crate::ty::{IndexedVal, MirConst, Ty, TyConst}; | |
| 3 | use crate::{with, Body, Mutability}; | |
| 4 | use fmt::{Display, Formatter}; | |
| 5 | 1 | use std::fmt::Debug; |
| 6 | 2 | use std::io::Write; |
| 7 | 3 | use std::{fmt, io, iter}; |
| 8 | 4 | |
| 9 | use super::{AssertMessage, BinOp, TerminatorKind}; | |
| 5 | use fmt::{Display, Formatter}; | |
| 10 | 6 | |
| 11 | use super::{BorrowKind, FakeBorrowKind}; | |
| 7 | use super::{AssertMessage, BinOp, BorrowKind, FakeBorrowKind, TerminatorKind}; | |
| 8 | use crate::mir::{Operand, Place, Rvalue, StatementKind, UnwindAction, VarDebugInfoContents}; | |
| 9 | use crate::ty::{IndexedVal, MirConst, Ty, TyConst}; | |
| 10 | use crate::{with, Body, Mutability}; | |
| 12 | 11 | |
| 13 | 12 | impl Display for Ty { |
| 14 | 13 | fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { |
compiler/stable_mir/src/target.rs+2-1| ... | ... | @@ -1,8 +1,9 @@ |
| 1 | 1 | //! Provide information about the machine that this is being compiled into. |
| 2 | 2 | |
| 3 | use crate::compiler_interface::with; | |
| 4 | 3 | use serde::Serialize; |
| 5 | 4 | |
| 5 | use crate::compiler_interface::with; | |
| 6 | ||
| 6 | 7 | /// The properties of the target machine being compiled into. |
| 7 | 8 | #[derive(Clone, PartialEq, Eq, Serialize)] |
| 8 | 9 | pub struct MachineInfo { |
compiler/stable_mir/src/ty.rs+7-7| ... | ... | @@ -1,16 +1,16 @@ |
| 1 | use super::{ | |
| 2 | mir::{Body, Mutability, Safety}, | |
| 3 | with, DefId, Error, Symbol, | |
| 4 | }; | |
| 1 | use std::fmt::{self, Debug, Display, Formatter}; | |
| 2 | use std::ops::Range; | |
| 3 | ||
| 4 | use serde::Serialize; | |
| 5 | ||
| 6 | use super::mir::{Body, Mutability, Safety}; | |
| 7 | use super::{with, DefId, Error, Symbol}; | |
| 5 | 8 | use crate::abi::{FnAbi, Layout}; |
| 6 | 9 | use crate::crate_def::{CrateDef, CrateDefType}; |
| 7 | 10 | use crate::mir::alloc::{read_target_int, read_target_uint, AllocId}; |
| 8 | 11 | use crate::mir::mono::StaticDef; |
| 9 | 12 | use crate::target::MachineInfo; |
| 10 | 13 | use crate::{Filename, Opaque}; |
| 11 | use serde::Serialize; | |
| 12 | use std::fmt::{self, Debug, Display, Formatter}; | |
| 13 | use std::ops::Range; | |
| 14 | 14 | |
| 15 | 15 | #[derive(Copy, Clone, Eq, PartialEq, Hash, Serialize)] |
| 16 | 16 | pub struct Ty(usize); |
compiler/stable_mir/src/visitor.rs+2-2| ... | ... | @@ -1,11 +1,11 @@ |
| 1 | 1 | use std::ops::ControlFlow; |
| 2 | 2 | |
| 3 | use crate::{ty::TyConst, Opaque}; | |
| 4 | ||
| 5 | 3 | use super::ty::{ |
| 6 | 4 | Allocation, Binder, ConstDef, ExistentialPredicate, FnSig, GenericArgKind, GenericArgs, |
| 7 | 5 | MirConst, Promoted, Region, RigidTy, TermKind, Ty, UnevaluatedConst, |
| 8 | 6 | }; |
| 7 | use crate::ty::TyConst; | |
| 8 | use crate::Opaque; | |
| 9 | 9 | |
| 10 | 10 | pub trait Visitor: Sized { |
| 11 | 11 | type Break; |
library/alloc/benches/btree/map.rs+2-1| ... | ... | @@ -1,7 +1,8 @@ |
| 1 | 1 | use std::collections::BTreeMap; |
| 2 | 2 | use std::ops::RangeBounds; |
| 3 | 3 | |
| 4 | use rand::{seq::SliceRandom, Rng}; | |
| 4 | use rand::seq::SliceRandom; | |
| 5 | use rand::Rng; | |
| 5 | 6 | use test::{black_box, Bencher}; |
| 6 | 7 | |
| 7 | 8 | macro_rules! map_insert_rand_bench { |
library/alloc/benches/linked_list.rs+1| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | 1 | use std::collections::LinkedList; |
| 2 | ||
| 2 | 3 | use test::Bencher; |
| 3 | 4 | |
| 4 | 5 | #[bench] |
library/alloc/benches/string.rs+1| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | 1 | use std::iter::repeat; |
| 2 | ||
| 2 | 3 | use test::{black_box, Bencher}; |
| 3 | 4 | |
| 4 | 5 | #[bench] |
library/alloc/benches/vec.rs+2-1| ... | ... | @@ -1,5 +1,6 @@ |
| 1 | use rand::RngCore; | |
| 2 | 1 | use std::iter::repeat; |
| 2 | ||
| 3 | use rand::RngCore; | |
| 3 | 4 | use test::{black_box, Bencher}; |
| 4 | 5 | |
| 5 | 6 | #[bench] |
library/alloc/benches/vec_deque.rs+3-4| ... | ... | @@ -1,7 +1,6 @@ |
| 1 | use std::{ | |
| 2 | collections::{vec_deque, VecDeque}, | |
| 3 | mem, | |
| 4 | }; | |
| 1 | use std::collections::{vec_deque, VecDeque}; | |
| 2 | use std::mem; | |
| 3 | ||
| 5 | 4 | use test::{black_box, Bencher}; |
| 6 | 5 | |
| 7 | 6 | #[bench] |
library/alloc/benches/vec_deque_append.rs+2-1| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | use std::{collections::VecDeque, time::Instant}; | |
| 1 | use std::collections::VecDeque; | |
| 2 | use std::time::Instant; | |
| 2 | 3 | |
| 3 | 4 | const VECDEQUE_LEN: i32 = 100000; |
| 4 | 5 | const WARMUP_N: usize = 100; |
library/alloc/src/alloc.rs+3-5| ... | ... | @@ -2,16 +2,14 @@ |
| 2 | 2 | |
| 3 | 3 | #![stable(feature = "alloc_module", since = "1.28.0")] |
| 4 | 4 | |
| 5 | #[stable(feature = "alloc_module", since = "1.28.0")] | |
| 6 | #[doc(inline)] | |
| 7 | pub use core::alloc::*; | |
| 5 | 8 | #[cfg(not(test))] |
| 6 | 9 | use core::hint; |
| 7 | ||
| 8 | 10 | #[cfg(not(test))] |
| 9 | 11 | use core::ptr::{self, NonNull}; |
| 10 | 12 | |
| 11 | #[stable(feature = "alloc_module", since = "1.28.0")] | |
| 12 | #[doc(inline)] | |
| 13 | pub use core::alloc::*; | |
| 14 | ||
| 15 | 13 | #[cfg(test)] |
| 16 | 14 | mod tests; |
| 17 | 15 |
library/alloc/src/alloc/tests.rs+2-1| ... | ... | @@ -1,9 +1,10 @@ |
| 1 | 1 | use super::*; |
| 2 | 2 | |
| 3 | 3 | extern crate test; |
| 4 | use crate::boxed::Box; | |
| 5 | 4 | use test::Bencher; |
| 6 | 5 | |
| 6 | use crate::boxed::Box; | |
| 7 | ||
| 7 | 8 | #[test] |
| 8 | 9 | fn allocate_zeroed() { |
| 9 | 10 | unsafe { |
library/alloc/src/borrow.rs+3-4| ... | ... | @@ -2,21 +2,20 @@ |
| 2 | 2 | |
| 3 | 3 | #![stable(feature = "rust1", since = "1.0.0")] |
| 4 | 4 | |
| 5 | #[stable(feature = "rust1", since = "1.0.0")] | |
| 6 | pub use core::borrow::{Borrow, BorrowMut}; | |
| 5 | 7 | use core::cmp::Ordering; |
| 6 | 8 | use core::hash::{Hash, Hasher}; |
| 7 | 9 | #[cfg(not(no_global_oom_handling))] |
| 8 | 10 | use core::ops::{Add, AddAssign}; |
| 9 | 11 | use core::ops::{Deref, DerefPure}; |
| 10 | 12 | |
| 11 | #[stable(feature = "rust1", since = "1.0.0")] | |
| 12 | pub use core::borrow::{Borrow, BorrowMut}; | |
| 13 | use Cow::*; | |
| 13 | 14 | |
| 14 | 15 | use crate::fmt; |
| 15 | 16 | #[cfg(not(no_global_oom_handling))] |
| 16 | 17 | use crate::string::String; |
| 17 | 18 | |
| 18 | use Cow::*; | |
| 19 | ||
| 20 | 19 | #[stable(feature = "rust1", since = "1.0.0")] |
| 21 | 20 | impl<'a, B: ?Sized> Borrow<B> for Cow<'a, B> |
| 22 | 21 | where |
library/alloc/src/boxed.rs+7-10| ... | ... | @@ -187,26 +187,26 @@ |
| 187 | 187 | |
| 188 | 188 | use core::any::Any; |
| 189 | 189 | use core::async_iter::AsyncIterator; |
| 190 | use core::borrow; | |
| 191 | 190 | #[cfg(not(no_global_oom_handling))] |
| 192 | 191 | use core::clone::CloneToUninit; |
| 193 | 192 | use core::cmp::Ordering; |
| 194 | 193 | use core::error::Error; |
| 195 | use core::fmt; | |
| 196 | 194 | use core::future::Future; |
| 197 | 195 | use core::hash::{Hash, Hasher}; |
| 198 | 196 | use core::iter::FusedIterator; |
| 199 | use core::marker::Tuple; | |
| 200 | use core::marker::Unsize; | |
| 197 | use core::marker::{Tuple, Unsize}; | |
| 201 | 198 | use core::mem::{self, SizedTypeProperties}; |
| 202 | use core::ops::{AsyncFn, AsyncFnMut, AsyncFnOnce}; | |
| 203 | 199 | use core::ops::{ |
| 204 | CoerceUnsized, Coroutine, CoroutineState, Deref, DerefMut, DerefPure, DispatchFromDyn, Receiver, | |
| 200 | AsyncFn, AsyncFnMut, AsyncFnOnce, CoerceUnsized, Coroutine, CoroutineState, Deref, DerefMut, | |
| 201 | DerefPure, DispatchFromDyn, Receiver, | |
| 205 | 202 | }; |
| 206 | 203 | use core::pin::Pin; |
| 207 | 204 | use core::ptr::{self, addr_of_mut, NonNull, Unique}; |
| 208 | use core::slice; | |
| 209 | 205 | use core::task::{Context, Poll}; |
| 206 | use core::{borrow, fmt, slice}; | |
| 207 | ||
| 208 | #[unstable(feature = "thin_box", issue = "92791")] | |
| 209 | pub use thin::ThinBox; | |
| 210 | 210 | |
| 211 | 211 | #[cfg(not(no_global_oom_handling))] |
| 212 | 212 | use crate::alloc::handle_alloc_error; |
| ... | ... | @@ -222,9 +222,6 @@ use crate::vec; |
| 222 | 222 | #[cfg(not(no_global_oom_handling))] |
| 223 | 223 | use crate::vec::Vec; |
| 224 | 224 | |
| 225 | #[unstable(feature = "thin_box", issue = "92791")] | |
| 226 | pub use thin::ThinBox; | |
| 227 | ||
| 228 | 225 | mod thin; |
| 229 | 226 | |
| 230 | 227 | /// A pointer type that uniquely owns a heap allocation of type `T`. |
library/alloc/src/boxed/thin.rs+3-3| ... | ... | @@ -2,7 +2,6 @@ |
| 2 | 2 | //! <https://github.com/matthieu-m/rfc2580/blob/b58d1d3cba0d4b5e859d3617ea2d0943aaa31329/examples/thin.rs> |
| 3 | 3 | //! by matthieu-m |
| 4 | 4 | |
| 5 | use crate::alloc::{self, Layout, LayoutError}; | |
| 6 | 5 | use core::error::Error; |
| 7 | 6 | use core::fmt::{self, Debug, Display, Formatter}; |
| 8 | 7 | #[cfg(not(no_global_oom_handling))] |
| ... | ... | @@ -14,8 +13,9 @@ use core::mem; |
| 14 | 13 | #[cfg(not(no_global_oom_handling))] |
| 15 | 14 | use core::mem::SizedTypeProperties; |
| 16 | 15 | use core::ops::{Deref, DerefMut}; |
| 17 | use core::ptr::Pointee; | |
| 18 | use core::ptr::{self, NonNull}; | |
| 16 | use core::ptr::{self, NonNull, Pointee}; | |
| 17 | ||
| 18 | use crate::alloc::{self, Layout, LayoutError}; | |
| 19 | 19 | |
| 20 | 20 | /// ThinBox. |
| 21 | 21 | /// |
library/alloc/src/collections/binary_heap/mod.rs+1-2| ... | ... | @@ -144,12 +144,11 @@ |
| 144 | 144 | #![stable(feature = "rust1", since = "1.0.0")] |
| 145 | 145 | |
| 146 | 146 | use core::alloc::Allocator; |
| 147 | use core::fmt; | |
| 148 | 147 | use core::iter::{FusedIterator, InPlaceIterable, SourceIter, TrustedFused, TrustedLen}; |
| 149 | 148 | use core::mem::{self, swap, ManuallyDrop}; |
| 150 | 149 | use core::num::NonZero; |
| 151 | 150 | use core::ops::{Deref, DerefMut}; |
| 152 | use core::ptr; | |
| 151 | use core::{fmt, ptr}; | |
| 153 | 152 | |
| 154 | 153 | use crate::alloc::Global; |
| 155 | 154 | use crate::collections::TryReserveError; |
library/alloc/src/collections/binary_heap/tests.rs+4-2| ... | ... | @@ -1,7 +1,8 @@ |
| 1 | use std::panic::{catch_unwind, AssertUnwindSafe}; | |
| 2 | ||
| 1 | 3 | use super::*; |
| 2 | 4 | use crate::boxed::Box; |
| 3 | 5 | use crate::testing::crash_test::{CrashTestDummy, Panic}; |
| 4 | use std::panic::{catch_unwind, AssertUnwindSafe}; | |
| 5 | 6 | |
| 6 | 7 | #[test] |
| 7 | 8 | fn test_iterator() { |
| ... | ... | @@ -504,11 +505,12 @@ fn test_retain_catch_unwind() { |
| 504 | 505 | #[cfg(not(target_os = "emscripten"))] |
| 505 | 506 | #[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")] |
| 506 | 507 | fn panic_safe() { |
| 507 | use rand::seq::SliceRandom; | |
| 508 | 508 | use std::cmp; |
| 509 | 509 | use std::panic::{self, AssertUnwindSafe}; |
| 510 | 510 | use std::sync::atomic::{AtomicUsize, Ordering}; |
| 511 | 511 | |
| 512 | use rand::seq::SliceRandom; | |
| 513 | ||
| 512 | 514 | static DROP_COUNTER: AtomicUsize = AtomicUsize::new(0); |
| 513 | 515 | |
| 514 | 516 | #[derive(Eq, PartialEq, Ord, Clone, Debug)] |
library/alloc/src/collections/btree/append.rs+3-2| ... | ... | @@ -1,8 +1,9 @@ |
| 1 | use super::merge_iter::MergeIterInner; | |
| 2 | use super::node::{self, Root}; | |
| 3 | 1 | use core::alloc::Allocator; |
| 4 | 2 | use core::iter::FusedIterator; |
| 5 | 3 | |
| 4 | use super::merge_iter::MergeIterInner; | |
| 5 | use super::node::{self, Root}; | |
| 6 | ||
| 6 | 7 | impl<K, V> Root<K, V> { |
| 7 | 8 | /// Appends all key-value pairs from the union of two ascending iterators, |
| 8 | 9 | /// incrementing a `length` variable along the way. The latter makes it |
library/alloc/src/collections/btree/fix.rs+5-2| ... | ... | @@ -1,7 +1,10 @@ |
| 1 | use super::map::MIN_LEN; | |
| 2 | use super::node::{marker, ForceResult::*, Handle, LeftOrRight::*, NodeRef, Root}; | |
| 3 | 1 | use core::alloc::Allocator; |
| 4 | 2 | |
| 3 | use super::map::MIN_LEN; | |
| 4 | use super::node::ForceResult::*; | |
| 5 | use super::node::LeftOrRight::*; | |
| 6 | use super::node::{marker, Handle, NodeRef, Root}; | |
| 7 | ||
| 5 | 8 | impl<'a, K: 'a, V: 'a> NodeRef<marker::Mut<'a>, K, V, marker::LeafOrInternal> { |
| 6 | 9 | /// Stocks up a possibly underfull node by merging with or stealing from a |
| 7 | 10 | /// sibling. If successful but at the cost of shrinking the parent node, |
library/alloc/src/collections/btree/map.rs+6-6| ... | ... | @@ -1,4 +1,3 @@ |
| 1 | use crate::vec::Vec; | |
| 2 | 1 | use core::borrow::Borrow; |
| 3 | 2 | use core::cmp::Ordering; |
| 4 | 3 | use core::error::Error; |
| ... | ... | @@ -10,20 +9,21 @@ use core::mem::{self, ManuallyDrop}; |
| 10 | 9 | use core::ops::{Bound, Index, RangeBounds}; |
| 11 | 10 | use core::ptr; |
| 12 | 11 | |
| 13 | use crate::alloc::{Allocator, Global}; | |
| 14 | ||
| 15 | 12 | use super::borrow::DormantMutRef; |
| 16 | 13 | use super::dedup_sorted_iter::DedupSortedIter; |
| 17 | 14 | use super::navigate::{LazyLeafRange, LeafRange}; |
| 18 | use super::node::{self, marker, ForceResult::*, Handle, NodeRef, Root}; | |
| 19 | use super::search::{SearchBound, SearchResult::*}; | |
| 15 | use super::node::ForceResult::*; | |
| 16 | use super::node::{self, marker, Handle, NodeRef, Root}; | |
| 17 | use super::search::SearchBound; | |
| 18 | use super::search::SearchResult::*; | |
| 20 | 19 | use super::set_val::SetValZST; |
| 20 | use crate::alloc::{Allocator, Global}; | |
| 21 | use crate::vec::Vec; | |
| 21 | 22 | |
| 22 | 23 | mod entry; |
| 23 | 24 | |
| 24 | 25 | #[stable(feature = "rust1", since = "1.0.0")] |
| 25 | 26 | pub use entry::{Entry, OccupiedEntry, OccupiedError, VacantEntry}; |
| 26 | ||
| 27 | 27 | use Entry::*; |
| 28 | 28 | |
| 29 | 29 | /// Minimum number of elements in a node that is not a root. |
library/alloc/src/collections/btree/map/entry.rs+2-3| ... | ... | @@ -2,13 +2,12 @@ use core::fmt::{self, Debug}; |
| 2 | 2 | use core::marker::PhantomData; |
| 3 | 3 | use core::mem; |
| 4 | 4 | |
| 5 | use crate::alloc::{Allocator, Global}; | |
| 5 | use Entry::*; | |
| 6 | 6 | |
| 7 | 7 | use super::super::borrow::DormantMutRef; |
| 8 | 8 | use super::super::node::{marker, Handle, NodeRef}; |
| 9 | 9 | use super::BTreeMap; |
| 10 | ||
| 11 | use Entry::*; | |
| 10 | use crate::alloc::{Allocator, Global}; | |
| 12 | 11 | |
| 13 | 12 | /// A view into a single entry in a map, which may either be vacant or occupied. |
| 14 | 13 | /// |
library/alloc/src/collections/btree/map/tests.rs+7-5| ... | ... | @@ -1,3 +1,10 @@ |
| 1 | use core::assert_matches::assert_matches; | |
| 2 | use std::iter; | |
| 3 | use std::ops::Bound::{Excluded, Included, Unbounded}; | |
| 4 | use std::panic::{catch_unwind, AssertUnwindSafe}; | |
| 5 | use std::sync::atomic::AtomicUsize; | |
| 6 | use std::sync::atomic::Ordering::SeqCst; | |
| 7 | ||
| 1 | 8 | use super::*; |
| 2 | 9 | use crate::boxed::Box; |
| 3 | 10 | use crate::fmt::Debug; |
| ... | ... | @@ -6,11 +13,6 @@ use crate::string::{String, ToString}; |
| 6 | 13 | use crate::testing::crash_test::{CrashTestDummy, Panic}; |
| 7 | 14 | use crate::testing::ord_chaos::{Cyclic3, Governed, Governor}; |
| 8 | 15 | use crate::testing::rng::DeterministicRng; |
| 9 | use core::assert_matches::assert_matches; | |
| 10 | use std::iter; | |
| 11 | use std::ops::Bound::{Excluded, Included, Unbounded}; | |
| 12 | use std::panic::{catch_unwind, AssertUnwindSafe}; | |
| 13 | use std::sync::atomic::{AtomicUsize, Ordering::SeqCst}; | |
| 14 | 16 | |
| 15 | 17 | // Minimum number of elements to insert, to guarantee a tree with 2 levels, |
| 16 | 18 | // i.e., a tree who's root is an internal node at height 1, with edges to leaf nodes. |
library/alloc/src/collections/btree/mem.rs+1-3| ... | ... | @@ -1,6 +1,4 @@ |
| 1 | use core::intrinsics; | |
| 2 | use core::mem; | |
| 3 | use core::ptr; | |
| 1 | use core::{intrinsics, mem, ptr}; | |
| 4 | 2 | |
| 5 | 3 | /// This replaces the value behind the `v` unique reference by calling the |
| 6 | 4 | /// relevant function. |
library/alloc/src/collections/btree/navigate.rs+3-4| ... | ... | @@ -1,11 +1,10 @@ |
| 1 | 1 | use core::borrow::Borrow; |
| 2 | use core::hint; | |
| 3 | 2 | use core::ops::RangeBounds; |
| 4 | use core::ptr; | |
| 3 | use core::{hint, ptr}; | |
| 5 | 4 | |
| 6 | use super::node::{marker, ForceResult::*, Handle, NodeRef}; | |
| 5 | use super::node::ForceResult::*; | |
| 6 | use super::node::{marker, Handle, NodeRef}; | |
| 7 | 7 | use super::search::SearchBound; |
| 8 | ||
| 9 | 8 | use crate::alloc::Allocator; |
| 10 | 9 | // `front` and `back` are always both `None` or both `Some`. |
| 11 | 10 | pub struct LeafRange<BorrowType, K, V> { |
library/alloc/src/collections/btree/remove.rs+5-2| ... | ... | @@ -1,7 +1,10 @@ |
| 1 | use super::map::MIN_LEN; | |
| 2 | use super::node::{marker, ForceResult::*, Handle, LeftOrRight::*, NodeRef}; | |
| 3 | 1 | use core::alloc::Allocator; |
| 4 | 2 | |
| 3 | use super::map::MIN_LEN; | |
| 4 | use super::node::ForceResult::*; | |
| 5 | use super::node::LeftOrRight::*; | |
| 6 | use super::node::{marker, Handle, NodeRef}; | |
| 7 | ||
| 5 | 8 | impl<'a, K: 'a, V: 'a> Handle<NodeRef<marker::Mut<'a>, K, V, marker::LeafOrInternal>, marker::KV> { |
| 6 | 9 | /// Removes a key-value pair from the tree, and returns that pair, as well as |
| 7 | 10 | /// the leaf edge corresponding to that former pair. It's possible this empties |
library/alloc/src/collections/btree/search.rs+3-2| ... | ... | @@ -2,11 +2,12 @@ use core::borrow::Borrow; |
| 2 | 2 | use core::cmp::Ordering; |
| 3 | 3 | use core::ops::{Bound, RangeBounds}; |
| 4 | 4 | |
| 5 | use super::node::{marker, ForceResult::*, Handle, NodeRef}; | |
| 6 | ||
| 7 | 5 | use SearchBound::*; |
| 8 | 6 | use SearchResult::*; |
| 9 | 7 | |
| 8 | use super::node::ForceResult::*; | |
| 9 | use super::node::{marker, Handle, NodeRef}; | |
| 10 | ||
| 10 | 11 | pub enum SearchBound<T> { |
| 11 | 12 | /// An inclusive bound to look for, just like `Bound::Included(T)`. |
| 12 | 13 | Included(T), |
library/alloc/src/collections/btree/set.rs+1-2| ... | ... | @@ -1,4 +1,3 @@ |
| 1 | use crate::vec::Vec; | |
| 2 | 1 | use core::borrow::Borrow; |
| 3 | 2 | use core::cmp::Ordering::{self, Equal, Greater, Less}; |
| 4 | 3 | use core::cmp::{max, min}; |
| ... | ... | @@ -12,8 +11,8 @@ use super::map::{BTreeMap, Keys}; |
| 12 | 11 | use super::merge_iter::MergeIterInner; |
| 13 | 12 | use super::set_val::SetValZST; |
| 14 | 13 | use super::Recover; |
| 15 | ||
| 16 | 14 | use crate::alloc::{Allocator, Global}; |
| 15 | use crate::vec::Vec; | |
| 17 | 16 | |
| 18 | 17 | /// An ordered set based on a B-Tree. |
| 19 | 18 | /// |
library/alloc/src/collections/btree/set/tests.rs+3-2| ... | ... | @@ -1,8 +1,9 @@ |
| 1 | use std::ops::Bound::{Excluded, Included}; | |
| 2 | use std::panic::{catch_unwind, AssertUnwindSafe}; | |
| 3 | ||
| 1 | 4 | use super::*; |
| 2 | 5 | use crate::testing::crash_test::{CrashTestDummy, Panic}; |
| 3 | 6 | use crate::testing::rng::DeterministicRng; |
| 4 | use std::ops::Bound::{Excluded, Included}; | |
| 5 | use std::panic::{catch_unwind, AssertUnwindSafe}; | |
| 6 | 7 | |
| 7 | 8 | #[test] |
| 8 | 9 | fn test_clone_eq() { |
library/alloc/src/collections/btree/split.rs+4-2| ... | ... | @@ -1,8 +1,10 @@ |
| 1 | use super::node::{ForceResult::*, Root}; | |
| 2 | use super::search::SearchResult::*; | |
| 3 | 1 | use core::alloc::Allocator; |
| 4 | 2 | use core::borrow::Borrow; |
| 5 | 3 | |
| 4 | use super::node::ForceResult::*; | |
| 5 | use super::node::Root; | |
| 6 | use super::search::SearchResult::*; | |
| 7 | ||
| 6 | 8 | impl<K, V> Root<K, V> { |
| 7 | 9 | /// Calculates the length of both trees that result from splitting up |
| 8 | 10 | /// a given number of distinct key-value pairs. |
library/alloc/src/collections/linked_list.rs+1-2| ... | ... | @@ -13,12 +13,11 @@ |
| 13 | 13 | #![stable(feature = "rust1", since = "1.0.0")] |
| 14 | 14 | |
| 15 | 15 | use core::cmp::Ordering; |
| 16 | use core::fmt; | |
| 17 | 16 | use core::hash::{Hash, Hasher}; |
| 18 | 17 | use core::iter::FusedIterator; |
| 19 | 18 | use core::marker::PhantomData; |
| 20 | use core::mem; | |
| 21 | 19 | use core::ptr::NonNull; |
| 20 | use core::{fmt, mem}; | |
| 22 | 21 | |
| 23 | 22 | use super::SpecExtend; |
| 24 | 23 | use crate::alloc::{Allocator, Global}; |
library/alloc/src/collections/linked_list/tests.rs+5-7| ... | ... | @@ -1,12 +1,12 @@ |
| 1 | use super::*; | |
| 2 | use crate::testing::crash_test::{CrashTestDummy, Panic}; | |
| 3 | use crate::vec::Vec; | |
| 4 | ||
| 5 | 1 | use std::panic::{catch_unwind, AssertUnwindSafe}; |
| 6 | 2 | use std::thread; |
| 7 | 3 | |
| 8 | 4 | use rand::RngCore; |
| 9 | 5 | |
| 6 | use super::*; | |
| 7 | use crate::testing::crash_test::{CrashTestDummy, Panic}; | |
| 8 | use crate::vec::Vec; | |
| 9 | ||
| 10 | 10 | #[test] |
| 11 | 11 | fn test_basic() { |
| 12 | 12 | let mut m = LinkedList::<Box<_>>::new(); |
| ... | ... | @@ -1167,9 +1167,7 @@ fn test_drop_panic() { |
| 1167 | 1167 | |
| 1168 | 1168 | #[test] |
| 1169 | 1169 | fn test_allocator() { |
| 1170 | use core::alloc::AllocError; | |
| 1171 | use core::alloc::Allocator; | |
| 1172 | use core::alloc::Layout; | |
| 1170 | use core::alloc::{AllocError, Allocator, Layout}; | |
| 1173 | 1171 | use core::cell::Cell; |
| 1174 | 1172 | |
| 1175 | 1173 | struct A { |
library/alloc/src/collections/mod.rs+2-5| ... | ... | @@ -27,33 +27,30 @@ pub mod btree_set { |
| 27 | 27 | pub use super::btree::set::*; |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | use core::fmt::Display; | |
| 31 | ||
| 30 | 32 | #[cfg(not(no_global_oom_handling))] |
| 31 | 33 | #[stable(feature = "rust1", since = "1.0.0")] |
| 32 | 34 | #[doc(no_inline)] |
| 33 | 35 | pub use binary_heap::BinaryHeap; |
| 34 | ||
| 35 | 36 | #[cfg(not(no_global_oom_handling))] |
| 36 | 37 | #[stable(feature = "rust1", since = "1.0.0")] |
| 37 | 38 | #[doc(no_inline)] |
| 38 | 39 | pub use btree_map::BTreeMap; |
| 39 | ||
| 40 | 40 | #[cfg(not(no_global_oom_handling))] |
| 41 | 41 | #[stable(feature = "rust1", since = "1.0.0")] |
| 42 | 42 | #[doc(no_inline)] |
| 43 | 43 | pub use btree_set::BTreeSet; |
| 44 | ||
| 45 | 44 | #[cfg(not(no_global_oom_handling))] |
| 46 | 45 | #[stable(feature = "rust1", since = "1.0.0")] |
| 47 | 46 | #[doc(no_inline)] |
| 48 | 47 | pub use linked_list::LinkedList; |
| 49 | ||
| 50 | 48 | #[cfg(not(no_global_oom_handling))] |
| 51 | 49 | #[stable(feature = "rust1", since = "1.0.0")] |
| 52 | 50 | #[doc(no_inline)] |
| 53 | 51 | pub use vec_deque::VecDeque; |
| 54 | 52 | |
| 55 | 53 | use crate::alloc::{Layout, LayoutError}; |
| 56 | use core::fmt::Display; | |
| 57 | 54 | |
| 58 | 55 | /// The error type for `try_reserve` methods. |
| 59 | 56 | #[derive(Clone, PartialEq, Eq, Debug)] |
library/alloc/src/collections/vec_deque/drain.rs+1-2| ... | ... | @@ -4,9 +4,8 @@ use core::mem::{self, SizedTypeProperties}; |
| 4 | 4 | use core::ptr::NonNull; |
| 5 | 5 | use core::{fmt, ptr}; |
| 6 | 6 | |
| 7 | use crate::alloc::{Allocator, Global}; | |
| 8 | ||
| 9 | 7 | use super::VecDeque; |
| 8 | use crate::alloc::{Allocator, Global}; | |
| 10 | 9 | |
| 11 | 10 | /// A draining iterator over the elements of a `VecDeque`. |
| 12 | 11 | /// |
library/alloc/src/collections/vec_deque/into_iter.rs+4-3| ... | ... | @@ -1,10 +1,11 @@ |
| 1 | 1 | use core::iter::{FusedIterator, TrustedLen}; |
| 2 | use core::mem::MaybeUninit; | |
| 2 | 3 | use core::num::NonZero; |
| 3 | use core::{array, fmt, mem::MaybeUninit, ops::Try, ptr}; | |
| 4 | ||
| 5 | use crate::alloc::{Allocator, Global}; | |
| 4 | use core::ops::Try; | |
| 5 | use core::{array, fmt, ptr}; | |
| 6 | 6 | |
| 7 | 7 | use super::VecDeque; |
| 8 | use crate::alloc::{Allocator, Global}; | |
| 8 | 9 | |
| 9 | 10 | /// An owning iterator over the elements of a `VecDeque`. |
| 10 | 11 | /// |
library/alloc/src/collections/vec_deque/mod.rs+4-8| ... | ... | @@ -8,23 +8,19 @@ |
| 8 | 8 | #![stable(feature = "rust1", since = "1.0.0")] |
| 9 | 9 | |
| 10 | 10 | use core::cmp::{self, Ordering}; |
| 11 | use core::fmt; | |
| 12 | 11 | use core::hash::{Hash, Hasher}; |
| 13 | 12 | use core::iter::{repeat_n, repeat_with, ByRefSized}; |
| 14 | use core::mem::{ManuallyDrop, SizedTypeProperties}; | |
| 15 | use core::ops::{Index, IndexMut, Range, RangeBounds}; | |
| 16 | use core::ptr; | |
| 17 | use core::slice; | |
| 18 | ||
| 19 | 13 | // This is used in a bunch of intra-doc links. |
| 20 | 14 | // FIXME: For some reason, `#[cfg(doc)]` wasn't sufficient, resulting in |
| 21 | 15 | // failures in linkchecker even though rustdoc built the docs just fine. |
| 22 | 16 | #[allow(unused_imports)] |
| 23 | 17 | use core::mem; |
| 18 | use core::mem::{ManuallyDrop, SizedTypeProperties}; | |
| 19 | use core::ops::{Index, IndexMut, Range, RangeBounds}; | |
| 20 | use core::{fmt, ptr, slice}; | |
| 24 | 21 | |
| 25 | 22 | use crate::alloc::{Allocator, Global}; |
| 26 | use crate::collections::TryReserveError; | |
| 27 | use crate::collections::TryReserveErrorKind; | |
| 23 | use crate::collections::{TryReserveError, TryReserveErrorKind}; | |
| 28 | 24 | use crate::raw_vec::RawVec; |
| 29 | 25 | use crate::vec::Vec; |
| 30 | 26 |
library/alloc/src/collections/vec_deque/spec_extend.rs+2-2| ... | ... | @@ -1,9 +1,9 @@ |
| 1 | use crate::alloc::Allocator; | |
| 2 | use crate::vec; | |
| 3 | 1 | use core::iter::TrustedLen; |
| 4 | 2 | use core::slice; |
| 5 | 3 | |
| 6 | 4 | use super::VecDeque; |
| 5 | use crate::alloc::Allocator; | |
| 6 | use crate::vec; | |
| 7 | 7 | |
| 8 | 8 | // Specialization trait used for VecDeque::extend |
| 9 | 9 | pub(super) trait SpecExtend<T, I> { |
library/alloc/src/ffi/c_str.rs+7-11| ... | ... | @@ -3,25 +3,21 @@ |
| 3 | 3 | #[cfg(test)] |
| 4 | 4 | mod tests; |
| 5 | 5 | |
| 6 | use crate::borrow::{Cow, ToOwned}; | |
| 7 | use crate::boxed::Box; | |
| 8 | use crate::rc::Rc; | |
| 9 | use crate::slice::hack::into_vec; | |
| 10 | use crate::string::String; | |
| 11 | use crate::vec::Vec; | |
| 12 | 6 | use core::borrow::Borrow; |
| 13 | 7 | use core::ffi::{c_char, CStr}; |
| 14 | use core::fmt; | |
| 15 | use core::mem; | |
| 16 | 8 | use core::num::NonZero; |
| 17 | use core::ops; | |
| 18 | use core::ptr; | |
| 19 | use core::slice; | |
| 20 | 9 | use core::slice::memchr; |
| 21 | 10 | use core::str::{self, Utf8Error}; |
| 11 | use core::{fmt, mem, ops, ptr, slice}; | |
| 22 | 12 | |
| 13 | use crate::borrow::{Cow, ToOwned}; | |
| 14 | use crate::boxed::Box; | |
| 15 | use crate::rc::Rc; | |
| 16 | use crate::slice::hack::into_vec; | |
| 17 | use crate::string::String; | |
| 23 | 18 | #[cfg(target_has_atomic = "ptr")] |
| 24 | 19 | use crate::sync::Arc; |
| 20 | use crate::vec::Vec; | |
| 25 | 21 | |
| 26 | 22 | /// A type representing an owned, C-compatible, nul-terminated string with no nul bytes in the |
| 27 | 23 | /// middle. |
library/alloc/src/ffi/c_str/tests.rs+3-3| ... | ... | @@ -1,10 +1,10 @@ |
| 1 | use super::*; | |
| 2 | 1 | use core::assert_matches::assert_matches; |
| 3 | 2 | use core::ffi::FromBytesUntilNulError; |
| 4 | use core::hash::{Hash, Hasher}; | |
| 5 | ||
| 6 | 3 | #[allow(deprecated)] |
| 7 | 4 | use core::hash::SipHasher13 as DefaultHasher; |
| 5 | use core::hash::{Hash, Hasher}; | |
| 6 | ||
| 7 | use super::*; | |
| 8 | 8 | |
| 9 | 9 | #[test] |
| 10 | 10 | fn c_to_rust() { |
library/alloc/src/ffi/mod.rs+3-4| ... | ... | @@ -80,13 +80,12 @@ |
| 80 | 80 | |
| 81 | 81 | #![stable(feature = "alloc_ffi", since = "1.64.0")] |
| 82 | 82 | |
| 83 | #[doc(no_inline)] | |
| 84 | #[stable(feature = "alloc_c_string", since = "1.64.0")] | |
| 85 | pub use self::c_str::{FromVecWithNulError, IntoStringError, NulError}; | |
| 86 | ||
| 87 | 83 | #[doc(inline)] |
| 88 | 84 | #[stable(feature = "alloc_c_string", since = "1.64.0")] |
| 89 | 85 | pub use self::c_str::CString; |
| 86 | #[doc(no_inline)] | |
| 87 | #[stable(feature = "alloc_c_string", since = "1.64.0")] | |
| 88 | pub use self::c_str::{FromVecWithNulError, IntoStringError, NulError}; | |
| 90 | 89 | |
| 91 | 90 | #[unstable(feature = "c_str_module", issue = "112134")] |
| 92 | 91 | pub mod c_str; |
library/alloc/src/raw_vec.rs+1-2| ... | ... | @@ -1,10 +1,9 @@ |
| 1 | 1 | #![unstable(feature = "raw_vec_internals", reason = "unstable const warnings", issue = "none")] |
| 2 | 2 | |
| 3 | 3 | use core::alloc::LayoutError; |
| 4 | use core::cmp; | |
| 5 | use core::hint; | |
| 6 | 4 | use core::mem::{self, ManuallyDrop, MaybeUninit, SizedTypeProperties}; |
| 7 | 5 | use core::ptr::{self, NonNull, Unique}; |
| 6 | use core::{cmp, hint}; | |
| 8 | 7 | |
| 9 | 8 | #[cfg(not(no_global_oom_handling))] |
| 10 | 9 | use crate::alloc::handle_alloc_error; |
library/alloc/src/raw_vec/tests.rs+2-1| ... | ... | @@ -1,7 +1,8 @@ |
| 1 | use super::*; | |
| 2 | 1 | use core::mem::size_of; |
| 3 | 2 | use std::cell::Cell; |
| 4 | 3 | |
| 4 | use super::*; | |
| 5 | ||
| 5 | 6 | #[test] |
| 6 | 7 | fn allocator_param() { |
| 7 | 8 | use crate::alloc::AllocError; |
library/alloc/src/rc.rs+5-8| ... | ... | @@ -241,20 +241,12 @@ |
| 241 | 241 | |
| 242 | 242 | #![stable(feature = "rust1", since = "1.0.0")] |
| 243 | 243 | |
| 244 | #[cfg(not(test))] | |
| 245 | use crate::boxed::Box; | |
| 246 | #[cfg(test)] | |
| 247 | use std::boxed::Box; | |
| 248 | ||
| 249 | 244 | use core::any::Any; |
| 250 | use core::borrow; | |
| 251 | 245 | use core::cell::Cell; |
| 252 | 246 | #[cfg(not(no_global_oom_handling))] |
| 253 | 247 | use core::clone::CloneToUninit; |
| 254 | 248 | use core::cmp::Ordering; |
| 255 | use core::fmt; | |
| 256 | 249 | use core::hash::{Hash, Hasher}; |
| 257 | use core::hint; | |
| 258 | 250 | use core::intrinsics::abort; |
| 259 | 251 | #[cfg(not(no_global_oom_handling))] |
| 260 | 252 | use core::iter; |
| ... | ... | @@ -267,11 +259,16 @@ use core::pin::Pin; |
| 267 | 259 | use core::ptr::{self, drop_in_place, NonNull}; |
| 268 | 260 | #[cfg(not(no_global_oom_handling))] |
| 269 | 261 | use core::slice::from_raw_parts_mut; |
| 262 | use core::{borrow, fmt, hint}; | |
| 263 | #[cfg(test)] | |
| 264 | use std::boxed::Box; | |
| 270 | 265 | |
| 271 | 266 | #[cfg(not(no_global_oom_handling))] |
| 272 | 267 | use crate::alloc::handle_alloc_error; |
| 273 | 268 | use crate::alloc::{AllocError, Allocator, Global, Layout}; |
| 274 | 269 | use crate::borrow::{Cow, ToOwned}; |
| 270 | #[cfg(not(test))] | |
| 271 | use crate::boxed::Box; | |
| 275 | 272 | #[cfg(not(no_global_oom_handling))] |
| 276 | 273 | use crate::string::String; |
| 277 | 274 | #[cfg(not(no_global_oom_handling))] |
library/alloc/src/rc/tests.rs+2-2| ... | ... | @@ -1,8 +1,8 @@ |
| 1 | use super::*; | |
| 2 | ||
| 3 | 1 | use std::cell::RefCell; |
| 4 | 2 | use std::clone::Clone; |
| 5 | 3 | |
| 4 | use super::*; | |
| 5 | ||
| 6 | 6 | #[test] |
| 7 | 7 | fn test_clone() { |
| 8 | 8 | let x = Rc::new(RefCell::new(5)); |
library/alloc/src/slice.rs-1| ... | ... | @@ -78,7 +78,6 @@ pub use core::slice::{SplitInclusive, SplitInclusiveMut}; |
| 78 | 78 | // N.B., see the `hack` module in this file for more details. |
| 79 | 79 | #[cfg(test)] |
| 80 | 80 | pub use hack::into_vec; |
| 81 | ||
| 82 | 81 | // HACK(japaric) needed for the implementation of `Vec::clone` during testing |
| 83 | 82 | // N.B., see the `hack` module in this file for more details. |
| 84 | 83 | #[cfg(test)] |
library/alloc/src/slice/tests.rs+12-9| ... | ... | @@ -1,18 +1,21 @@ |
| 1 | use core::cell::Cell; | |
| 2 | use core::cmp::Ordering::{self, Equal, Greater, Less}; | |
| 3 | use core::convert::identity; | |
| 4 | use core::sync::atomic::AtomicUsize; | |
| 5 | use core::sync::atomic::Ordering::Relaxed; | |
| 6 | use core::{fmt, mem}; | |
| 7 | use std::panic; | |
| 8 | ||
| 9 | use rand::distributions::Standard; | |
| 10 | use rand::prelude::*; | |
| 11 | use rand::{Rng, RngCore}; | |
| 12 | ||
| 1 | 13 | use crate::borrow::ToOwned; |
| 2 | 14 | use crate::rc::Rc; |
| 3 | 15 | use crate::string::ToString; |
| 4 | 16 | use crate::test_helpers::test_rng; |
| 5 | 17 | use crate::vec::Vec; |
| 6 | 18 | |
| 7 | use core::cell::Cell; | |
| 8 | use core::cmp::Ordering::{self, Equal, Greater, Less}; | |
| 9 | use core::convert::identity; | |
| 10 | use core::fmt; | |
| 11 | use core::mem; | |
| 12 | use core::sync::atomic::{AtomicUsize, Ordering::Relaxed}; | |
| 13 | use rand::{distributions::Standard, prelude::*, Rng, RngCore}; | |
| 14 | use std::panic; | |
| 15 | ||
| 16 | 19 | macro_rules! do_test { |
| 17 | 20 | ($input:ident, $func:ident) => { |
| 18 | 21 | let len = $input.len(); |
library/alloc/src/str.rs+9-11| ... | ... | @@ -9,19 +9,9 @@ |
| 9 | 9 | |
| 10 | 10 | use core::borrow::{Borrow, BorrowMut}; |
| 11 | 11 | use core::iter::FusedIterator; |
| 12 | use core::mem; | |
| 13 | use core::ptr; | |
| 14 | use core::str::pattern::{DoubleEndedSearcher, Pattern, ReverseSearcher, Searcher}; | |
| 15 | use core::unicode::conversions; | |
| 16 | ||
| 17 | use crate::borrow::ToOwned; | |
| 18 | use crate::boxed::Box; | |
| 19 | use crate::slice::{Concat, Join, SliceIndex}; | |
| 20 | use crate::string::String; | |
| 21 | use crate::vec::Vec; | |
| 22 | ||
| 23 | 12 | #[stable(feature = "rust1", since = "1.0.0")] |
| 24 | 13 | pub use core::str::pattern; |
| 14 | use core::str::pattern::{DoubleEndedSearcher, Pattern, ReverseSearcher, Searcher}; | |
| 25 | 15 | #[stable(feature = "encode_utf16", since = "1.8.0")] |
| 26 | 16 | pub use core::str::EncodeUtf16; |
| 27 | 17 | #[stable(feature = "split_ascii_whitespace", since = "1.34.0")] |
| ... | ... | @@ -55,6 +45,14 @@ pub use core::str::{RSplitN, SplitN}; |
| 55 | 45 | pub use core::str::{RSplitTerminator, SplitTerminator}; |
| 56 | 46 | #[stable(feature = "utf8_chunks", since = "1.79.0")] |
| 57 | 47 | pub use core::str::{Utf8Chunk, Utf8Chunks}; |
| 48 | use core::unicode::conversions; | |
| 49 | use core::{mem, ptr}; | |
| 50 | ||
| 51 | use crate::borrow::ToOwned; | |
| 52 | use crate::boxed::Box; | |
| 53 | use crate::slice::{Concat, Join, SliceIndex}; | |
| 54 | use crate::string::String; | |
| 55 | use crate::vec::Vec; | |
| 58 | 56 | |
| 59 | 57 | /// Note: `str` in `Concat<str>` is not meaningful here. |
| 60 | 58 | /// This type parameter of the trait only exists to enable another impl. |
library/alloc/src/string.rs+1-4| ... | ... | @@ -43,8 +43,6 @@ |
| 43 | 43 | #![stable(feature = "rust1", since = "1.0.0")] |
| 44 | 44 | |
| 45 | 45 | use core::error::Error; |
| 46 | use core::fmt; | |
| 47 | use core::hash; | |
| 48 | 46 | #[cfg(not(no_global_oom_handling))] |
| 49 | 47 | use core::iter::from_fn; |
| 50 | 48 | use core::iter::FusedIterator; |
| ... | ... | @@ -55,9 +53,8 @@ use core::ops::AddAssign; |
| 55 | 53 | #[cfg(not(no_global_oom_handling))] |
| 56 | 54 | use core::ops::Bound::{Excluded, Included, Unbounded}; |
| 57 | 55 | use core::ops::{self, Range, RangeBounds}; |
| 58 | use core::ptr; | |
| 59 | use core::slice; | |
| 60 | 56 | use core::str::pattern::Pattern; |
| 57 | use core::{fmt, hash, ptr, slice}; | |
| 61 | 58 | |
| 62 | 59 | #[cfg(not(no_global_oom_handling))] |
| 63 | 60 | use crate::alloc::Allocator; |
library/alloc/src/sync.rs+1-3| ... | ... | @@ -9,13 +9,10 @@ |
| 9 | 9 | //! `#[cfg(target_has_atomic = "ptr")]`. |
| 10 | 10 | |
| 11 | 11 | use core::any::Any; |
| 12 | use core::borrow; | |
| 13 | 12 | #[cfg(not(no_global_oom_handling))] |
| 14 | 13 | use core::clone::CloneToUninit; |
| 15 | 14 | use core::cmp::Ordering; |
| 16 | use core::fmt; | |
| 17 | 15 | use core::hash::{Hash, Hasher}; |
| 18 | use core::hint; | |
| 19 | 16 | use core::intrinsics::abort; |
| 20 | 17 | #[cfg(not(no_global_oom_handling))] |
| 21 | 18 | use core::iter; |
| ... | ... | @@ -29,6 +26,7 @@ use core::ptr::{self, NonNull}; |
| 29 | 26 | use core::slice::from_raw_parts_mut; |
| 30 | 27 | use core::sync::atomic; |
| 31 | 28 | use core::sync::atomic::Ordering::{Acquire, Relaxed, Release}; |
| 29 | use core::{borrow, fmt, hint}; | |
| 32 | 30 | |
| 33 | 31 | #[cfg(not(no_global_oom_handling))] |
| 34 | 32 | use crate::alloc::handle_alloc_error; |
library/alloc/src/sync/tests.rs+2-2| ... | ... | @@ -1,5 +1,3 @@ |
| 1 | use super::*; | |
| 2 | ||
| 3 | 1 | use std::clone::Clone; |
| 4 | 2 | use std::mem::MaybeUninit; |
| 5 | 3 | use std::option::Option::None; |
| ... | ... | @@ -9,6 +7,8 @@ use std::sync::mpsc::channel; |
| 9 | 7 | use std::sync::Mutex; |
| 10 | 8 | use std::thread; |
| 11 | 9 | |
| 10 | use super::*; | |
| 11 | ||
| 12 | 12 | struct Canary(*mut AtomicUsize); |
| 13 | 13 | |
| 14 | 14 | impl Drop for Canary { |
library/alloc/src/task.rs+3-3| ... | ... | @@ -7,14 +7,14 @@ |
| 7 | 7 | //! This may be detected at compile time using |
| 8 | 8 | //! `#[cfg(target_has_atomic = "ptr")]`. |
| 9 | 9 | |
| 10 | use crate::rc::Rc; | |
| 11 | 10 | use core::mem::ManuallyDrop; |
| 11 | #[cfg(target_has_atomic = "ptr")] | |
| 12 | use core::task::Waker; | |
| 12 | 13 | use core::task::{LocalWaker, RawWaker, RawWakerVTable}; |
| 13 | 14 | |
| 15 | use crate::rc::Rc; | |
| 14 | 16 | #[cfg(target_has_atomic = "ptr")] |
| 15 | 17 | use crate::sync::Arc; |
| 16 | #[cfg(target_has_atomic = "ptr")] | |
| 17 | use core::task::Waker; | |
| 18 | 18 | |
| 19 | 19 | /// The implementation of waking a task on an executor. |
| 20 | 20 | /// |
library/alloc/src/testing/crash_test.rs+4-2| ... | ... | @@ -1,6 +1,8 @@ |
| 1 | use crate::fmt::Debug; // the `Debug` trait is the only thing we use from `crate::fmt` | |
| 2 | 1 | use std::cmp::Ordering; |
| 3 | use std::sync::atomic::{AtomicUsize, Ordering::SeqCst}; | |
| 2 | use std::sync::atomic::AtomicUsize; | |
| 3 | use std::sync::atomic::Ordering::SeqCst; | |
| 4 | ||
| 5 | use crate::fmt::Debug; // the `Debug` trait is the only thing we use from `crate::fmt` | |
| 4 | 6 | |
| 5 | 7 | /// A blueprint for crash test dummy instances that monitor particular events. |
| 6 | 8 | /// Some instances may be configured to panic at some point. |
library/alloc/src/tests.rs-1| ... | ... | @@ -2,7 +2,6 @@ |
| 2 | 2 | |
| 3 | 3 | use core::any::Any; |
| 4 | 4 | use core::ops::Deref; |
| 5 | ||
| 6 | 5 | use std::boxed::Box; |
| 7 | 6 | |
| 8 | 7 | #[test] |
library/alloc/src/vec/cow.rs+1-2| ... | ... | @@ -1,6 +1,5 @@ |
| 1 | use crate::borrow::Cow; | |
| 2 | ||
| 3 | 1 | use super::Vec; |
| 2 | use crate::borrow::Cow; | |
| 4 | 3 | |
| 5 | 4 | #[stable(feature = "cow_from_vec", since = "1.8.0")] |
| 6 | 5 | impl<'a, T: Clone> From<&'a [T]> for Cow<'a, [T]> { |
library/alloc/src/vec/drain.rs+1-1| ... | ... | @@ -1,4 +1,3 @@ |
| 1 | use crate::alloc::{Allocator, Global}; | |
| 2 | 1 | use core::fmt; |
| 3 | 2 | use core::iter::{FusedIterator, TrustedLen}; |
| 4 | 3 | use core::mem::{self, ManuallyDrop, SizedTypeProperties}; |
| ... | ... | @@ -6,6 +5,7 @@ use core::ptr::{self, NonNull}; |
| 6 | 5 | use core::slice::{self}; |
| 7 | 6 | |
| 8 | 7 | use super::Vec; |
| 8 | use crate::alloc::{Allocator, Global}; | |
| 9 | 9 | |
| 10 | 10 | /// A draining iterator for `Vec<T>`. |
| 11 | 11 | /// |
library/alloc/src/vec/extract_if.rs+2-3| ... | ... | @@ -1,8 +1,7 @@ |
| 1 | use crate::alloc::{Allocator, Global}; | |
| 2 | use core::ptr; | |
| 3 | use core::slice; | |
| 1 | use core::{ptr, slice}; | |
| 4 | 2 | |
| 5 | 3 | use super::Vec; |
| 4 | use crate::alloc::{Allocator, Global}; | |
| 6 | 5 | |
| 7 | 6 | /// An iterator which uses a closure to determine if an element should be removed. |
| 8 | 7 | /// |
library/alloc/src/vec/in_place_collect.rs+2-3| ... | ... | @@ -155,9 +155,7 @@ |
| 155 | 155 | //! vec.truncate(write_idx); |
| 156 | 156 | //! ``` |
| 157 | 157 | |
| 158 | use crate::alloc::{handle_alloc_error, Global}; | |
| 159 | use core::alloc::Allocator; | |
| 160 | use core::alloc::Layout; | |
| 158 | use core::alloc::{Allocator, Layout}; | |
| 161 | 159 | use core::iter::{InPlaceIterable, SourceIter, TrustedRandomAccessNoCoerce}; |
| 162 | 160 | use core::marker::PhantomData; |
| 163 | 161 | use core::mem::{self, ManuallyDrop, SizedTypeProperties}; |
| ... | ... | @@ -165,6 +163,7 @@ use core::num::NonZero; |
| 165 | 163 | use core::ptr; |
| 166 | 164 | |
| 167 | 165 | use super::{InPlaceDrop, InPlaceDstDataSrcBufDrop, SpecFromIter, SpecFromIterNested, Vec}; |
| 166 | use crate::alloc::{handle_alloc_error, Global}; | |
| 168 | 167 | |
| 169 | 168 | const fn in_place_collectible<DEST, SRC>( |
| 170 | 169 | step_merge: Option<NonZero<usize>>, |
library/alloc/src/vec/in_place_drop.rs+1-2| ... | ... | @@ -1,6 +1,5 @@ |
| 1 | 1 | use core::marker::PhantomData; |
| 2 | use core::ptr::NonNull; | |
| 3 | use core::ptr::{self, drop_in_place}; | |
| 2 | use core::ptr::{self, drop_in_place, NonNull}; | |
| 4 | 3 | use core::slice::{self}; |
| 5 | 4 | |
| 6 | 5 | use crate::alloc::Global; |
library/alloc/src/vec/into_iter.rs+8-8| ... | ... | @@ -1,11 +1,3 @@ |
| 1 | #[cfg(not(no_global_oom_handling))] | |
| 2 | use super::AsVecIntoIter; | |
| 3 | use crate::alloc::{Allocator, Global}; | |
| 4 | #[cfg(not(no_global_oom_handling))] | |
| 5 | use crate::collections::VecDeque; | |
| 6 | use crate::raw_vec::RawVec; | |
| 7 | use core::array; | |
| 8 | use core::fmt; | |
| 9 | 1 | use core::iter::{ |
| 10 | 2 | FusedIterator, InPlaceIterable, SourceIter, TrustedFused, TrustedLen, |
| 11 | 3 | TrustedRandomAccessNoCoerce, |
| ... | ... | @@ -17,6 +9,14 @@ use core::num::NonZero; |
| 17 | 9 | use core::ops::Deref; |
| 18 | 10 | use core::ptr::{self, NonNull}; |
| 19 | 11 | use core::slice::{self}; |
| 12 | use core::{array, fmt}; | |
| 13 | ||
| 14 | #[cfg(not(no_global_oom_handling))] | |
| 15 | use super::AsVecIntoIter; | |
| 16 | use crate::alloc::{Allocator, Global}; | |
| 17 | #[cfg(not(no_global_oom_handling))] | |
| 18 | use crate::collections::VecDeque; | |
| 19 | use crate::raw_vec::RawVec; | |
| 20 | 20 | |
| 21 | 21 | macro non_null { |
| 22 | 22 | (mut $place:expr, $t:ident) => {{ |
library/alloc/src/vec/mod.rs+2-3| ... | ... | @@ -66,15 +66,14 @@ use core::ops::{self, Index, IndexMut, Range, RangeBounds}; |
| 66 | 66 | use core::ptr::{self, NonNull}; |
| 67 | 67 | use core::slice::{self, SliceIndex}; |
| 68 | 68 | |
| 69 | #[unstable(feature = "extract_if", reason = "recently added", issue = "43244")] | |
| 70 | pub use self::extract_if::ExtractIf; | |
| 69 | 71 | use crate::alloc::{Allocator, Global}; |
| 70 | 72 | use crate::borrow::{Cow, ToOwned}; |
| 71 | 73 | use crate::boxed::Box; |
| 72 | 74 | use crate::collections::TryReserveError; |
| 73 | 75 | use crate::raw_vec::RawVec; |
| 74 | 76 | |
| 75 | #[unstable(feature = "extract_if", reason = "recently added", issue = "43244")] | |
| 76 | pub use self::extract_if::ExtractIf; | |
| 77 | ||
| 78 | 77 | mod extract_if; |
| 79 | 78 | |
| 80 | 79 | #[cfg(not(no_global_oom_handling))] |
library/alloc/src/vec/partial_eq.rs+1-2| ... | ... | @@ -1,9 +1,8 @@ |
| 1 | use super::Vec; | |
| 1 | 2 | use crate::alloc::Allocator; |
| 2 | 3 | #[cfg(not(no_global_oom_handling))] |
| 3 | 4 | use crate::borrow::Cow; |
| 4 | 5 | |
| 5 | use super::Vec; | |
| 6 | ||
| 7 | 6 | macro_rules! __impl_slice_eq1 { |
| 8 | 7 | ([$($vars:tt)*] $lhs:ty, $rhs:ty $(where $ty:ty: $bound:ident)?, #[$stability:meta]) => { |
| 9 | 8 | #[$stability] |
library/alloc/src/vec/spec_extend.rs+1-1| ... | ... | @@ -1,8 +1,8 @@ |
| 1 | use crate::alloc::Allocator; | |
| 2 | 1 | use core::iter::TrustedLen; |
| 3 | 2 | use core::slice::{self}; |
| 4 | 3 | |
| 5 | 4 | use super::{IntoIter, Vec}; |
| 5 | use crate::alloc::Allocator; | |
| 6 | 6 | |
| 7 | 7 | // Specialization trait used for Vec::extend |
| 8 | 8 | pub(super) trait SpecExtend<T, I> { |
library/alloc/src/vec/spec_from_elem.rs+1-2| ... | ... | @@ -1,10 +1,9 @@ |
| 1 | 1 | use core::ptr; |
| 2 | 2 | |
| 3 | use super::{IsZero, Vec}; | |
| 3 | 4 | use crate::alloc::Allocator; |
| 4 | 5 | use crate::raw_vec::RawVec; |
| 5 | 6 | |
| 6 | use super::{IsZero, Vec}; | |
| 7 | ||
| 8 | 7 | // Specialization trait used for Vec::from_elem |
| 9 | 8 | pub(super) trait SpecFromElem: Sized { |
| 10 | 9 | fn from_elem<A: Allocator>(elem: Self, n: usize, alloc: A) -> Vec<Self, A>; |
library/alloc/src/vec/spec_from_iter_nested.rs+2-4| ... | ... | @@ -1,10 +1,8 @@ |
| 1 | use core::cmp; | |
| 2 | 1 | use core::iter::TrustedLen; |
| 3 | use core::ptr; | |
| 4 | ||
| 5 | use crate::raw_vec::RawVec; | |
| 2 | use core::{cmp, ptr}; | |
| 6 | 3 | |
| 7 | 4 | use super::{SpecExtend, Vec}; |
| 5 | use crate::raw_vec::RawVec; | |
| 8 | 6 | |
| 9 | 7 | /// Another specialization trait for Vec::from_iter |
| 10 | 8 | /// necessary to manually prioritize overlapping specializations |
library/alloc/src/vec/splice.rs+1-1| ... | ... | @@ -1,8 +1,8 @@ |
| 1 | use crate::alloc::{Allocator, Global}; | |
| 2 | 1 | use core::ptr::{self}; |
| 3 | 2 | use core::slice::{self}; |
| 4 | 3 | |
| 5 | 4 | use super::{Drain, Vec}; |
| 5 | use crate::alloc::{Allocator, Global}; | |
| 6 | 6 | |
| 7 | 7 | /// A splicing iterator for `Vec`. |
| 8 | 8 | /// |
library/alloc/tests/btree_set_hash.rs+2-1| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | use crate::hash; | |
| 2 | 1 | use std::collections::BTreeSet; |
| 3 | 2 | |
| 3 | use crate::hash; | |
| 4 | ||
| 4 | 5 | #[test] |
| 5 | 6 | fn test_hash() { |
| 6 | 7 | let mut x = BTreeSet::new(); |
library/alloc/tests/slice.rs+2-5| ... | ... | @@ -1,9 +1,7 @@ |
| 1 | 1 | use std::cmp::Ordering::{Equal, Greater, Less}; |
| 2 | 2 | use std::convert::identity; |
| 3 | use std::fmt; | |
| 4 | use std::mem; | |
| 5 | use std::panic; | |
| 6 | 3 | use std::rc::Rc; |
| 4 | use std::{fmt, mem, panic}; | |
| 7 | 5 | |
| 8 | 6 | fn square(n: usize) -> usize { |
| 9 | 7 | n * n |
| ... | ... | @@ -911,8 +909,7 @@ fn test_split_iterators_size_hint() { |
| 911 | 909 | // become maximally long, so the size_hint upper bounds are tight |
| 912 | 910 | ((|_| true) as fn(&_) -> _, Bounds::Upper), |
| 913 | 911 | ] { |
| 914 | use assert_tight_size_hints as a; | |
| 915 | use format_args as f; | |
| 912 | use {assert_tight_size_hints as a, format_args as f}; | |
| 916 | 913 | |
| 917 | 914 | a(v.split(p), b, "split"); |
| 918 | 915 | a(v.split_mut(p), b, "split_mut"); |
library/alloc/tests/str.rs+2-1| ... | ... | @@ -165,7 +165,8 @@ fn test_join_for_different_lengths_with_long_separator() { |
| 165 | 165 | |
| 166 | 166 | #[test] |
| 167 | 167 | fn test_join_issue_80335() { |
| 168 | use core::{borrow::Borrow, cell::Cell}; | |
| 168 | use core::borrow::Borrow; | |
| 169 | use core::cell::Cell; | |
| 169 | 170 | |
| 170 | 171 | struct WeirdBorrow { |
| 171 | 172 | state: Cell<bool>, |
library/alloc/tests/string.rs+2-4| ... | ... | @@ -2,11 +2,9 @@ use std::assert_matches::assert_matches; |
| 2 | 2 | use std::borrow::Cow; |
| 3 | 3 | use std::cell::Cell; |
| 4 | 4 | use std::collections::TryReserveErrorKind::*; |
| 5 | use std::ops::Bound; | |
| 6 | 5 | use std::ops::Bound::*; |
| 7 | use std::ops::RangeBounds; | |
| 8 | use std::panic; | |
| 9 | use std::str; | |
| 6 | use std::ops::{Bound, RangeBounds}; | |
| 7 | use std::{panic, str}; | |
| 10 | 8 | |
| 11 | 9 | pub trait IntoCow<'a, B: ?Sized> |
| 12 | 10 | where |
library/alloc/tests/vec.rs+3-3| ... | ... | @@ -8,15 +8,14 @@ use std::borrow::Cow; |
| 8 | 8 | use std::cell::Cell; |
| 9 | 9 | use std::collections::TryReserveErrorKind::*; |
| 10 | 10 | use std::fmt::Debug; |
| 11 | use std::hint; | |
| 12 | 11 | use std::iter::InPlaceIterable; |
| 13 | use std::mem; | |
| 14 | 12 | use std::mem::{size_of, swap}; |
| 15 | 13 | use std::ops::Bound::*; |
| 16 | 14 | use std::panic::{catch_unwind, AssertUnwindSafe}; |
| 17 | 15 | use std::rc::Rc; |
| 18 | 16 | use std::sync::atomic::{AtomicU32, Ordering}; |
| 19 | 17 | use std::vec::{Drain, IntoIter}; |
| 18 | use std::{hint, mem}; | |
| 20 | 19 | |
| 21 | 20 | struct DropCounter<'a> { |
| 22 | 21 | count: &'a mut u32, |
| ... | ... | @@ -2572,7 +2571,8 @@ fn test_into_flattened_size_overflow() { |
| 2572 | 2571 | |
| 2573 | 2572 | #[test] |
| 2574 | 2573 | fn test_box_zero_allocator() { |
| 2575 | use core::{alloc::AllocError, cell::RefCell}; | |
| 2574 | use core::alloc::AllocError; | |
| 2575 | use core::cell::RefCell; | |
| 2576 | 2576 | use std::collections::HashSet; |
| 2577 | 2577 | |
| 2578 | 2578 | // Track ZST allocations and ensure that they all have a matching free. |
library/alloc/tests/vec_deque.rs+4-3| ... | ... | @@ -1,16 +1,17 @@ |
| 1 | 1 | use core::num::NonZero; |
| 2 | 2 | use std::assert_matches::assert_matches; |
| 3 | use std::collections::vec_deque::Drain; | |
| 3 | 4 | use std::collections::TryReserveErrorKind::*; |
| 4 | use std::collections::{vec_deque::Drain, VecDeque}; | |
| 5 | use std::collections::VecDeque; | |
| 5 | 6 | use std::fmt::Debug; |
| 6 | 7 | use std::ops::Bound::*; |
| 7 | 8 | use std::panic::{catch_unwind, AssertUnwindSafe}; |
| 8 | 9 | |
| 9 | use crate::hash; | |
| 10 | ||
| 11 | 10 | use Taggy::*; |
| 12 | 11 | use Taggypar::*; |
| 13 | 12 | |
| 13 | use crate::hash; | |
| 14 | ||
| 14 | 15 | #[test] |
| 15 | 16 | fn test_simple() { |
| 16 | 17 | let mut d = VecDeque::new(); |
library/alloc/tests/vec_deque_alloc_error.rs+4-6| ... | ... | @@ -1,11 +1,9 @@ |
| 1 | 1 | #![feature(alloc_error_hook, allocator_api)] |
| 2 | 2 | |
| 3 | use std::{ | |
| 4 | alloc::{set_alloc_error_hook, AllocError, Allocator, Layout, System}, | |
| 5 | collections::VecDeque, | |
| 6 | panic::{catch_unwind, AssertUnwindSafe}, | |
| 7 | ptr::NonNull, | |
| 8 | }; | |
| 3 | use std::alloc::{set_alloc_error_hook, AllocError, Allocator, Layout, System}; | |
| 4 | use std::collections::VecDeque; | |
| 5 | use std::panic::{catch_unwind, AssertUnwindSafe}; | |
| 6 | use std::ptr::NonNull; | |
| 9 | 7 | |
| 10 | 8 | #[test] |
| 11 | 9 | #[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")] |
library/core/benches/any.rs+1| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | 1 | use core::any::*; |
| 2 | ||
| 2 | 3 | use test::{black_box, Bencher}; |
| 3 | 4 | |
| 4 | 5 | #[bench] |
library/core/benches/array.rs+1-2| ... | ... | @@ -1,5 +1,4 @@ |
| 1 | use test::black_box; | |
| 2 | use test::Bencher; | |
| 1 | use test::{black_box, Bencher}; | |
| 3 | 2 | |
| 4 | 3 | macro_rules! map_array { |
| 5 | 4 | ($func_name:ident, $start_item: expr, $map_item: expr, $arr_size: expr) => { |
library/core/benches/ascii.rs+2-2| ... | ... | @@ -64,8 +64,8 @@ macro_rules! benches { |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | use std::fmt::Write; |
| 67 | use test::black_box; | |
| 68 | use test::Bencher; | |
| 67 | ||
| 68 | use test::{black_box, Bencher}; | |
| 69 | 69 | |
| 70 | 70 | const ASCII_CASE_MASK: u8 = 0b0010_0000; |
| 71 | 71 |
library/core/benches/ascii/is_ascii.rs+2-2| ... | ... | @@ -1,6 +1,6 @@ |
| 1 | use test::{black_box, Bencher}; | |
| 2 | ||
| 1 | 3 | use super::{LONG, MEDIUM, SHORT}; |
| 2 | use test::black_box; | |
| 3 | use test::Bencher; | |
| 4 | 4 | |
| 5 | 5 | macro_rules! benches { |
| 6 | 6 | ($( fn $name: ident($arg: ident: &[u8]) $body: block )+) => { |
library/core/benches/fmt.rs+1| ... | ... | @@ -1,5 +1,6 @@ |
| 1 | 1 | use std::fmt::{self, Write as FmtWrite}; |
| 2 | 2 | use std::io::{self, Write as IoWrite}; |
| 3 | ||
| 3 | 4 | use test::{black_box, Bencher}; |
| 4 | 5 | |
| 5 | 6 | #[bench] |
library/core/benches/hash/sip.rs+1| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | 1 | #![allow(deprecated)] |
| 2 | 2 | |
| 3 | 3 | use core::hash::*; |
| 4 | ||
| 4 | 5 | use test::{black_box, Bencher}; |
| 5 | 6 | |
| 6 | 7 | fn hash_bytes<H: Hasher>(mut s: H, x: &[u8]) -> u64 { |
library/core/benches/iter.rs+1| ... | ... | @@ -3,6 +3,7 @@ use core::iter::*; |
| 3 | 3 | use core::mem; |
| 4 | 4 | use core::num::Wrapping; |
| 5 | 5 | use core::ops::Range; |
| 6 | ||
| 6 | 7 | use test::{black_box, Bencher}; |
| 7 | 8 | |
| 8 | 9 | #[bench] |
library/core/benches/num/flt2dec/mod.rs+2-2| ... | ... | @@ -3,9 +3,9 @@ mod strategy { |
| 3 | 3 | mod grisu; |
| 4 | 4 | } |
| 5 | 5 | |
| 6 | use core::num::flt2dec::MAX_SIG_DIGITS; | |
| 7 | use core::num::flt2dec::{decode, DecodableFloat, Decoded, FullDecoded}; | |
| 6 | use core::num::flt2dec::{decode, DecodableFloat, Decoded, FullDecoded, MAX_SIG_DIGITS}; | |
| 8 | 7 | use std::io::Write; |
| 8 | ||
| 9 | 9 | use test::{black_box, Bencher}; |
| 10 | 10 | |
| 11 | 11 | pub fn decode_finite<T: DecodableFloat>(v: T) -> Decoded { |
library/core/benches/num/flt2dec/strategy/dragon.rs+2-1| ... | ... | @@ -1,7 +1,8 @@ |
| 1 | use super::super::*; | |
| 2 | 1 | use core::num::flt2dec::strategy::dragon::*; |
| 3 | 2 | use std::mem::MaybeUninit; |
| 4 | 3 | |
| 4 | use super::super::*; | |
| 5 | ||
| 5 | 6 | #[bench] |
| 6 | 7 | fn bench_small_shortest(b: &mut Bencher) { |
| 7 | 8 | let decoded = decode_finite(3.141592f64); |
library/core/benches/num/flt2dec/strategy/grisu.rs+2-1| ... | ... | @@ -1,7 +1,8 @@ |
| 1 | use super::super::*; | |
| 2 | 1 | use core::num::flt2dec::strategy::grisu::*; |
| 3 | 2 | use std::mem::MaybeUninit; |
| 4 | 3 | |
| 4 | use super::super::*; | |
| 5 | ||
| 5 | 6 | pub fn decode_finite<T: DecodableFloat>(v: T) -> Decoded { |
| 6 | 7 | match decode(v).1 { |
| 7 | 8 | FullDecoded::Finite(decoded) => decoded, |
library/core/benches/num/mod.rs+1| ... | ... | @@ -4,6 +4,7 @@ mod int_log; |
| 4 | 4 | mod int_pow; |
| 5 | 5 | |
| 6 | 6 | use std::str::FromStr; |
| 7 | ||
| 7 | 8 | use test::{black_box, Bencher}; |
| 8 | 9 | |
| 9 | 10 | const ASCII_NUMBERS: [&str; 19] = [ |
library/core/benches/ops.rs+1| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | 1 | use core::ops::*; |
| 2 | ||
| 2 | 3 | use test::Bencher; |
| 3 | 4 | |
| 4 | 5 | // Overhead of dtors |
library/core/benches/pattern.rs+1-2| ... | ... | @@ -1,5 +1,4 @@ |
| 1 | use test::black_box; | |
| 2 | use test::Bencher; | |
| 1 | use test::{black_box, Bencher}; | |
| 3 | 2 | |
| 4 | 3 | #[bench] |
| 5 | 4 | fn starts_with_char(b: &mut Bencher) { |
library/core/benches/slice.rs+2-2| ... | ... | @@ -1,6 +1,6 @@ |
| 1 | 1 | use core::ptr::NonNull; |
| 2 | use test::black_box; | |
| 3 | use test::Bencher; | |
| 2 | ||
| 3 | use test::{black_box, Bencher}; | |
| 4 | 4 | |
| 5 | 5 | enum Cache { |
| 6 | 6 | L1, |
library/core/benches/str.rs+1| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | 1 | use std::str; |
| 2 | ||
| 2 | 3 | use test::{black_box, Bencher}; |
| 3 | 4 | |
| 4 | 5 | mod char_count; |
library/core/benches/str/char_count.rs+2-1| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | use super::corpora::*; | |
| 2 | 1 | use test::{black_box, Bencher}; |
| 3 | 2 | |
| 3 | use super::corpora::*; | |
| 4 | ||
| 4 | 5 | macro_rules! define_benches { |
| 5 | 6 | ($( fn $name: ident($arg: ident: &str) $body: block )+) => { |
| 6 | 7 | define_benches!(mod en_tiny, en::TINY, $($name $arg $body)+); |
library/core/benches/str/debug.rs+1| ... | ... | @@ -4,6 +4,7 @@ |
| 4 | 4 | //! we should still try to minimize those calls over time rather than regress them. |
| 5 | 5 | |
| 6 | 6 | use std::fmt::{self, Write}; |
| 7 | ||
| 7 | 8 | use test::{black_box, Bencher}; |
| 8 | 9 | |
| 9 | 10 | #[derive(Default)] |
library/core/benches/str/iter.rs+2-1| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | use super::corpora; | |
| 2 | 1 | use test::{black_box, Bencher}; |
| 3 | 2 | |
| 3 | use super::corpora; | |
| 4 | ||
| 4 | 5 | #[bench] |
| 5 | 6 | fn chars_advance_by_1000(b: &mut Bencher) { |
| 6 | 7 | b.iter(|| black_box(corpora::ru::LARGE).chars().advance_by(1000)); |
library/core/src/alloc/global.rs+1-2| ... | ... | @@ -1,6 +1,5 @@ |
| 1 | 1 | use crate::alloc::Layout; |
| 2 | use crate::cmp; | |
| 3 | use crate::ptr; | |
| 2 | use crate::{cmp, ptr}; | |
| 4 | 3 | |
| 5 | 4 | /// A memory allocator that can be registered as the standard library’s default |
| 6 | 5 | /// through the `#[global_allocator]` attribute. |
library/core/src/alloc/layout.rs+1-3| ... | ... | @@ -4,11 +4,9 @@ |
| 4 | 4 | // collections, resulting in having to optimize down excess IR multiple times. |
| 5 | 5 | // Your performance intuition is useless. Run perf. |
| 6 | 6 | |
| 7 | use crate::cmp; | |
| 8 | 7 | use crate::error::Error; |
| 9 | use crate::fmt; | |
| 10 | use crate::mem; | |
| 11 | 8 | use crate::ptr::{Alignment, NonNull}; |
| 9 | use crate::{cmp, fmt, mem}; | |
| 12 | 10 | |
| 13 | 11 | // While this function is used in one place and its implementation |
| 14 | 12 | // could be inlined, the previous attempts to do so made rustc |
library/core/src/alloc/mod.rs-2| ... | ... | @@ -17,10 +17,8 @@ pub use self::layout::Layout; |
| 17 | 17 | )] |
| 18 | 18 | #[allow(deprecated, deprecated_in_future)] |
| 19 | 19 | pub use self::layout::LayoutErr; |
| 20 | ||
| 21 | 20 | #[stable(feature = "alloc_layout_error", since = "1.50.0")] |
| 22 | 21 | pub use self::layout::LayoutError; |
| 23 | ||
| 24 | 22 | use crate::error::Error; |
| 25 | 23 | use crate::fmt; |
| 26 | 24 | use crate::ptr::{self, NonNull}; |
library/core/src/any.rs+1-3| ... | ... | @@ -86,9 +86,7 @@ |
| 86 | 86 | |
| 87 | 87 | #![stable(feature = "rust1", since = "1.0.0")] |
| 88 | 88 | |
| 89 | use crate::fmt; | |
| 90 | use crate::hash; | |
| 91 | use crate::intrinsics; | |
| 89 | use crate::{fmt, hash, intrinsics}; | |
| 92 | 90 | |
| 93 | 91 | /////////////////////////////////////////////////////////////////////////////// |
| 94 | 92 | // Any trait |
library/core/src/array/iter.rs+5-8| ... | ... | @@ -1,14 +1,11 @@ |
| 1 | 1 | //! Defines the `IntoIter` owned iterator for arrays. |
| 2 | 2 | |
| 3 | use crate::intrinsics::transmute_unchecked; | |
| 4 | use crate::iter::{self, FusedIterator, TrustedLen, TrustedRandomAccessNoCoerce}; | |
| 5 | use crate::mem::MaybeUninit; | |
| 3 | 6 | use crate::num::NonZero; |
| 4 | use crate::{ | |
| 5 | fmt, | |
| 6 | intrinsics::transmute_unchecked, | |
| 7 | iter::{self, FusedIterator, TrustedLen, TrustedRandomAccessNoCoerce}, | |
| 8 | mem::MaybeUninit, | |
| 9 | ops::{IndexRange, Range}, | |
| 10 | ptr, | |
| 11 | }; | |
| 7 | use crate::ops::{IndexRange, Range}; | |
| 8 | use crate::{fmt, ptr}; | |
| 12 | 9 | |
| 13 | 10 | /// A by-value [array] iterator. |
| 14 | 11 | #[stable(feature = "array_value_iter", since = "1.51.0")] |
library/core/src/array/mod.rs-1| ... | ... | @@ -23,7 +23,6 @@ mod equality; |
| 23 | 23 | mod iter; |
| 24 | 24 | |
| 25 | 25 | pub(crate) use drain::drain_array_with; |
| 26 | ||
| 27 | 26 | #[stable(feature = "array_value_iter", since = "1.51.0")] |
| 28 | 27 | pub use iter::IntoIter; |
| 29 | 28 |
library/core/src/ascii.rs+1-2| ... | ... | @@ -9,10 +9,9 @@ |
| 9 | 9 | |
| 10 | 10 | #![stable(feature = "core_ascii", since = "1.26.0")] |
| 11 | 11 | |
| 12 | use crate::escape; | |
| 13 | use crate::fmt; | |
| 14 | 12 | use crate::iter::FusedIterator; |
| 15 | 13 | use crate::num::NonZero; |
| 14 | use crate::{escape, fmt}; | |
| 16 | 15 | |
| 17 | 16 | mod ascii_char; |
| 18 | 17 | #[unstable(feature = "ascii_char", issue = "110998")] |
library/core/src/asserting.rs+2-4| ... | ... | @@ -9,10 +9,8 @@ |
| 9 | 9 | #![doc(hidden)] |
| 10 | 10 | #![unstable(feature = "generic_assert_internals", issue = "44838")] |
| 11 | 11 | |
| 12 | use crate::{ | |
| 13 | fmt::{Debug, Formatter}, | |
| 14 | marker::PhantomData, | |
| 15 | }; | |
| 12 | use crate::fmt::{Debug, Formatter}; | |
| 13 | use crate::marker::PhantomData; | |
| 16 | 14 | |
| 17 | 15 | // ***** TryCapture - Generic ***** |
| 18 | 16 |
library/core/src/async_iter/from_iter.rs+1-2| ... | ... | @@ -1,6 +1,5 @@ |
| 1 | use crate::pin::Pin; | |
| 2 | ||
| 3 | 1 | use crate::async_iter::AsyncIterator; |
| 2 | use crate::pin::Pin; | |
| 4 | 3 | use crate::task::{Context, Poll}; |
| 5 | 4 | |
| 6 | 5 | /// An async iterator that was created from iterator. |
library/core/src/cell/lazy.rs+1-2| ... | ... | @@ -1,8 +1,7 @@ |
| 1 | use super::UnsafeCell; | |
| 1 | 2 | use crate::ops::Deref; |
| 2 | 3 | use crate::{fmt, mem}; |
| 3 | 4 | |
| 4 | use super::UnsafeCell; | |
| 5 | ||
| 6 | 5 | enum State<T, F> { |
| 7 | 6 | Uninit(F), |
| 8 | 7 | Init(T), |
library/core/src/cell/once.rs+1-2| ... | ... | @@ -1,6 +1,5 @@ |
| 1 | 1 | use crate::cell::UnsafeCell; |
| 2 | use crate::fmt; | |
| 3 | use crate::mem; | |
| 2 | use crate::{fmt, mem}; | |
| 4 | 3 | |
| 5 | 4 | /// A cell which can nominally be written to only once. |
| 6 | 5 | /// |
library/core/src/char/methods.rs+1-2| ... | ... | @@ -1,12 +1,11 @@ |
| 1 | 1 | //! impl char {} |
| 2 | 2 | |
| 3 | use super::*; | |
| 3 | 4 | use crate::slice; |
| 4 | 5 | use crate::str::from_utf8_unchecked_mut; |
| 5 | 6 | use crate::unicode::printable::is_printable; |
| 6 | 7 | use crate::unicode::{self, conversions}; |
| 7 | 8 | |
| 8 | use super::*; | |
| 9 | ||
| 10 | 9 | impl char { |
| 11 | 10 | /// The lowest valid code point a `char` can have, `'\0'`. |
| 12 | 11 | /// |
library/core/src/char/mod.rs+1-2| ... | ... | @@ -42,14 +42,13 @@ pub use self::methods::encode_utf8_raw; // perma-unstable |
| 42 | 42 | |
| 43 | 43 | #[rustfmt::skip] |
| 44 | 44 | use crate::ascii; |
| 45 | pub(crate) use self::methods::EscapeDebugExtArgs; | |
| 45 | 46 | use crate::error::Error; |
| 46 | 47 | use crate::escape; |
| 47 | 48 | use crate::fmt::{self, Write}; |
| 48 | 49 | use crate::iter::{FusedIterator, TrustedLen, TrustedRandomAccess, TrustedRandomAccessNoCoerce}; |
| 49 | 50 | use crate::num::NonZero; |
| 50 | 51 | |
| 51 | pub(crate) use self::methods::EscapeDebugExtArgs; | |
| 52 | ||
| 53 | 52 | // UTF-8 ranges and tags for encoding characters |
| 54 | 53 | const TAG_CONT: u8 = 0b1000_0000; |
| 55 | 54 | const TAG_TWO_B: u8 = 0b1100_0000; |
library/core/src/ffi/c_str.rs+2-7| ... | ... | @@ -3,16 +3,11 @@ |
| 3 | 3 | use crate::cmp::Ordering; |
| 4 | 4 | use crate::error::Error; |
| 5 | 5 | use crate::ffi::c_char; |
| 6 | use crate::fmt; | |
| 7 | use crate::intrinsics; | |
| 8 | 6 | use crate::iter::FusedIterator; |
| 9 | 7 | use crate::marker::PhantomData; |
| 10 | use crate::ops; | |
| 11 | use crate::ptr::addr_of; | |
| 12 | use crate::ptr::NonNull; | |
| 13 | use crate::slice; | |
| 8 | use crate::ptr::{addr_of, NonNull}; | |
| 14 | 9 | use crate::slice::memchr; |
| 15 | use crate::str; | |
| 10 | use crate::{fmt, intrinsics, ops, slice, str}; | |
| 16 | 11 | |
| 17 | 12 | // FIXME: because this is doc(inline)d, we *have* to use intra-doc links because the actual link |
| 18 | 13 | // depends on where the item is being documented. however, since this is libcore, we can't |
library/core/src/ffi/mod.rs+5-8| ... | ... | @@ -9,19 +9,16 @@ |
| 9 | 9 | #![stable(feature = "core_ffi", since = "1.30.0")] |
| 10 | 10 | #![allow(non_camel_case_types)] |
| 11 | 11 | |
| 12 | use crate::fmt; | |
| 13 | ||
| 14 | #[doc(no_inline)] | |
| 12 | #[doc(inline)] | |
| 15 | 13 | #[stable(feature = "core_c_str", since = "1.64.0")] |
| 16 | pub use self::c_str::FromBytesWithNulError; | |
| 17 | ||
| 14 | pub use self::c_str::CStr; | |
| 18 | 15 | #[doc(no_inline)] |
| 19 | 16 | #[stable(feature = "cstr_from_bytes_until_nul", since = "1.69.0")] |
| 20 | 17 | pub use self::c_str::FromBytesUntilNulError; |
| 21 | ||
| 22 | #[doc(inline)] | |
| 18 | #[doc(no_inline)] | |
| 23 | 19 | #[stable(feature = "core_c_str", since = "1.64.0")] |
| 24 | pub use self::c_str::CStr; | |
| 20 | pub use self::c_str::FromBytesWithNulError; | |
| 21 | use crate::fmt; | |
| 25 | 22 | |
| 26 | 23 | #[unstable(feature = "c_str_module", issue = "112134")] |
| 27 | 24 | pub mod c_str; |
library/core/src/ffi/va_list.rs-1| ... | ... | @@ -3,7 +3,6 @@ |
| 3 | 3 | //! Better known as "varargs". |
| 4 | 4 | |
| 5 | 5 | use crate::ffi::c_void; |
| 6 | ||
| 7 | 6 | #[allow(unused_imports)] |
| 8 | 7 | use crate::fmt; |
| 9 | 8 | use crate::marker::PhantomData; |
library/core/src/fmt/float.rs+1-2| ... | ... | @@ -1,7 +1,6 @@ |
| 1 | 1 | use crate::fmt::{Debug, Display, Formatter, LowerExp, Result, UpperExp}; |
| 2 | 2 | use crate::mem::MaybeUninit; |
| 3 | use crate::num::flt2dec; | |
| 4 | use crate::num::fmt as numfmt; | |
| 3 | use crate::num::{flt2dec, fmt as numfmt}; | |
| 5 | 4 | |
| 6 | 5 | #[doc(hidden)] |
| 7 | 6 | trait GeneralFormat: PartialOrd { |
library/core/src/fmt/mod.rs+3-7| ... | ... | @@ -4,13 +4,10 @@ |
| 4 | 4 | |
| 5 | 5 | use crate::cell::{Cell, Ref, RefCell, RefMut, SyncUnsafeCell, UnsafeCell}; |
| 6 | 6 | use crate::char::EscapeDebugExtArgs; |
| 7 | use crate::iter; | |
| 8 | 7 | use crate::marker::PhantomData; |
| 9 | use crate::mem; | |
| 10 | 8 | use crate::num::fmt as numfmt; |
| 11 | 9 | use crate::ops::Deref; |
| 12 | use crate::result; | |
| 13 | use crate::str; | |
| 10 | use crate::{iter, mem, result, str}; | |
| 14 | 11 | |
| 15 | 12 | mod builders; |
| 16 | 13 | #[cfg(not(no_fp_fmt_parse))] |
| ... | ... | @@ -36,11 +33,10 @@ pub enum Alignment { |
| 36 | 33 | Center, |
| 37 | 34 | } |
| 38 | 35 | |
| 39 | #[stable(feature = "debug_builders", since = "1.2.0")] | |
| 40 | pub use self::builders::{DebugList, DebugMap, DebugSet, DebugStruct, DebugTuple}; | |
| 41 | ||
| 42 | 36 | #[unstable(feature = "debug_closure_helpers", issue = "117729")] |
| 43 | 37 | pub use self::builders::FormatterFn; |
| 38 | #[stable(feature = "debug_builders", since = "1.2.0")] | |
| 39 | pub use self::builders::{DebugList, DebugMap, DebugSet, DebugStruct, DebugTuple}; | |
| 44 | 40 | |
| 45 | 41 | /// The type returned by formatter methods. |
| 46 | 42 | /// |
library/core/src/fmt/num.rs+1-4| ... | ... | @@ -1,12 +1,9 @@ |
| 1 | 1 | //! Integer and floating-point number formatting |
| 2 | 2 | |
| 3 | use crate::fmt; | |
| 4 | 3 | use crate::mem::MaybeUninit; |
| 5 | 4 | use crate::num::fmt as numfmt; |
| 6 | 5 | use crate::ops::{Div, Rem, Sub}; |
| 7 | use crate::ptr; | |
| 8 | use crate::slice; | |
| 9 | use crate::str; | |
| 6 | use crate::{fmt, ptr, slice, str}; | |
| 10 | 7 | |
| 11 | 8 | #[doc(hidden)] |
| 12 | 9 | trait DisplayInt: |
library/core/src/future/mod.rs+8-12| ... | ... | @@ -20,25 +20,21 @@ mod pending; |
| 20 | 20 | mod poll_fn; |
| 21 | 21 | mod ready; |
| 22 | 22 | |
| 23 | #[stable(feature = "futures_api", since = "1.36.0")] | |
| 24 | pub use self::future::Future; | |
| 25 | ||
| 26 | #[unstable(feature = "future_join", issue = "91642")] | |
| 27 | pub use self::join::join; | |
| 28 | ||
| 23 | #[unstable(feature = "async_drop", issue = "126482")] | |
| 24 | pub use async_drop::{async_drop, async_drop_in_place, AsyncDrop, AsyncDropInPlace}; | |
| 29 | 25 | #[stable(feature = "into_future", since = "1.64.0")] |
| 30 | 26 | pub use into_future::IntoFuture; |
| 31 | ||
| 32 | 27 | #[stable(feature = "future_readiness_fns", since = "1.48.0")] |
| 33 | 28 | pub use pending::{pending, Pending}; |
| 34 | #[stable(feature = "future_readiness_fns", since = "1.48.0")] | |
| 35 | pub use ready::{ready, Ready}; | |
| 36 | ||
| 37 | 29 | #[stable(feature = "future_poll_fn", since = "1.64.0")] |
| 38 | 30 | pub use poll_fn::{poll_fn, PollFn}; |
| 31 | #[stable(feature = "future_readiness_fns", since = "1.48.0")] | |
| 32 | pub use ready::{ready, Ready}; | |
| 39 | 33 | |
| 40 | #[unstable(feature = "async_drop", issue = "126482")] | |
| 41 | pub use async_drop::{async_drop, async_drop_in_place, AsyncDrop, AsyncDropInPlace}; | |
| 34 | #[stable(feature = "futures_api", since = "1.36.0")] | |
| 35 | pub use self::future::Future; | |
| 36 | #[unstable(feature = "future_join", issue = "91642")] | |
| 37 | pub use self::join::join; | |
| 42 | 38 | |
| 43 | 39 | /// This type is needed because: |
| 44 | 40 | /// |
library/core/src/hash/mod.rs+2-7| ... | ... | @@ -83,17 +83,14 @@ |
| 83 | 83 | |
| 84 | 84 | #![stable(feature = "rust1", since = "1.0.0")] |
| 85 | 85 | |
| 86 | use crate::fmt; | |
| 87 | use crate::marker; | |
| 88 | ||
| 89 | 86 | #[stable(feature = "rust1", since = "1.0.0")] |
| 90 | 87 | #[allow(deprecated)] |
| 91 | 88 | pub use self::sip::SipHasher; |
| 92 | ||
| 93 | 89 | #[unstable(feature = "hashmap_internals", issue = "none")] |
| 94 | 90 | #[allow(deprecated)] |
| 95 | 91 | #[doc(hidden)] |
| 96 | 92 | pub use self::sip::SipHasher13; |
| 93 | use crate::{fmt, marker}; | |
| 97 | 94 | |
| 98 | 95 | mod sip; |
| 99 | 96 | |
| ... | ... | @@ -806,10 +803,8 @@ impl<H> PartialEq for BuildHasherDefault<H> { |
| 806 | 803 | impl<H> Eq for BuildHasherDefault<H> {} |
| 807 | 804 | |
| 808 | 805 | mod impls { |
| 809 | use crate::mem; | |
| 810 | use crate::slice; | |
| 811 | ||
| 812 | 806 | use super::*; |
| 807 | use crate::{mem, slice}; | |
| 813 | 808 | |
| 814 | 809 | macro_rules! impl_write { |
| 815 | 810 | ($(($ty:ident, $meth:ident),)*) => {$( |
library/core/src/hash/sip.rs+1-3| ... | ... | @@ -2,10 +2,8 @@ |
| 2 | 2 | |
| 3 | 3 | #![allow(deprecated)] // the types in this module are deprecated |
| 4 | 4 | |
| 5 | use crate::cmp; | |
| 6 | 5 | use crate::marker::PhantomData; |
| 7 | use crate::mem; | |
| 8 | use crate::ptr; | |
| 6 | use crate::{cmp, mem, ptr}; | |
| 9 | 7 | |
| 10 | 8 | /// An implementation of SipHash 1-3. |
| 11 | 9 | /// |
library/core/src/hint.rs+1-2| ... | ... | @@ -3,8 +3,7 @@ |
| 3 | 3 | //! Hints to compiler that affects how code should be emitted or optimized. |
| 4 | 4 | //! Hints may be compile time or runtime. |
| 5 | 5 | |
| 6 | use crate::intrinsics; | |
| 7 | use crate::ub_checks; | |
| 6 | use crate::{intrinsics, ub_checks}; | |
| 8 | 7 | |
| 9 | 8 | /// Informs the compiler that the site which is calling this function is not |
| 10 | 9 | /// reachable, possibly enabling further optimizations. |
library/core/src/intrinsics.rs+2-4| ... | ... | @@ -63,10 +63,8 @@ |
| 63 | 63 | )] |
| 64 | 64 | #![allow(missing_docs)] |
| 65 | 65 | |
| 66 | use crate::marker::DiscriminantKind; | |
| 67 | use crate::marker::Tuple; | |
| 68 | use crate::ptr; | |
| 69 | use crate::ub_checks; | |
| 66 | use crate::marker::{DiscriminantKind, Tuple}; | |
| 67 | use crate::{ptr, ub_checks}; | |
| 70 | 68 | |
| 71 | 69 | pub mod mir; |
| 72 | 70 | pub mod simd; |
library/core/src/intrinsics/mir.rs+1-2| ... | ... | @@ -276,8 +276,7 @@ pub enum UnwindTerminateReason { |
| 276 | 276 | InCleanup, |
| 277 | 277 | } |
| 278 | 278 | |
| 279 | pub use UnwindTerminateReason::Abi as ReasonAbi; | |
| 280 | pub use UnwindTerminateReason::InCleanup as ReasonInCleanup; | |
| 279 | pub use UnwindTerminateReason::{Abi as ReasonAbi, InCleanup as ReasonInCleanup}; | |
| 281 | 280 | |
| 282 | 281 | macro_rules! define { |
| 283 | 282 | ($name:literal, $( #[ $meta:meta ] )* fn $($sig:tt)*) => { |
library/core/src/iter/adapters/cloned.rs+4-4| ... | ... | @@ -1,9 +1,9 @@ |
| 1 | use crate::iter::adapters::{ | |
| 2 | zip::try_get_unchecked, SourceIter, TrustedRandomAccess, TrustedRandomAccessNoCoerce, | |
| 3 | }; | |
| 1 | use core::num::NonZero; | |
| 2 | ||
| 3 | use crate::iter::adapters::zip::try_get_unchecked; | |
| 4 | use crate::iter::adapters::{SourceIter, TrustedRandomAccess, TrustedRandomAccessNoCoerce}; | |
| 4 | 5 | use crate::iter::{FusedIterator, InPlaceIterable, TrustedLen, UncheckedIterator}; |
| 5 | 6 | use crate::ops::Try; |
| 6 | use core::num::NonZero; | |
| 7 | 7 | |
| 8 | 8 | /// An iterator that clones the elements of an underlying iterator. |
| 9 | 9 | /// |
library/core/src/iter/adapters/copied.rs+3-5| ... | ... | @@ -1,9 +1,7 @@ |
| 1 | use crate::iter::adapters::{ | |
| 2 | zip::try_get_unchecked, SourceIter, TrustedRandomAccess, TrustedRandomAccessNoCoerce, | |
| 3 | }; | |
| 1 | use crate::iter::adapters::zip::try_get_unchecked; | |
| 2 | use crate::iter::adapters::{SourceIter, TrustedRandomAccess, TrustedRandomAccessNoCoerce}; | |
| 4 | 3 | use crate::iter::{FusedIterator, InPlaceIterable, TrustedLen}; |
| 5 | use crate::mem::MaybeUninit; | |
| 6 | use crate::mem::SizedTypeProperties; | |
| 4 | use crate::mem::{MaybeUninit, SizedTypeProperties}; | |
| 7 | 5 | use crate::num::NonZero; |
| 8 | 6 | use crate::ops::Try; |
| 9 | 7 | use crate::{array, ptr}; |
library/core/src/iter/adapters/cycle.rs+2-1| ... | ... | @@ -1,5 +1,6 @@ |
| 1 | use crate::iter::FusedIterator; | |
| 1 | 2 | use crate::num::NonZero; |
| 2 | use crate::{iter::FusedIterator, ops::Try}; | |
| 3 | use crate::ops::Try; | |
| 3 | 4 | |
| 4 | 5 | /// An iterator that repeats endlessly. |
| 5 | 6 | /// |
library/core/src/iter/adapters/enumerate.rs+2-3| ... | ... | @@ -1,6 +1,5 @@ |
| 1 | use crate::iter::adapters::{ | |
| 2 | zip::try_get_unchecked, SourceIter, TrustedRandomAccess, TrustedRandomAccessNoCoerce, | |
| 3 | }; | |
| 1 | use crate::iter::adapters::zip::try_get_unchecked; | |
| 2 | use crate::iter::adapters::{SourceIter, TrustedRandomAccess, TrustedRandomAccessNoCoerce}; | |
| 4 | 3 | use crate::iter::{FusedIterator, InPlaceIterable, TrustedFused, TrustedLen}; |
| 5 | 4 | use crate::num::NonZero; |
| 6 | 5 | use crate::ops::Try; |
library/core/src/iter/adapters/filter.rs+6-4| ... | ... | @@ -1,11 +1,13 @@ |
| 1 | use crate::fmt; | |
| 2 | use crate::iter::{adapters::SourceIter, FusedIterator, InPlaceIterable, TrustedFused}; | |
| 3 | use crate::num::NonZero; | |
| 4 | use crate::ops::Try; | |
| 5 | 1 | use core::array; |
| 6 | 2 | use core::mem::MaybeUninit; |
| 7 | 3 | use core::ops::ControlFlow; |
| 8 | 4 | |
| 5 | use crate::fmt; | |
| 6 | use crate::iter::adapters::SourceIter; | |
| 7 | use crate::iter::{FusedIterator, InPlaceIterable, TrustedFused}; | |
| 8 | use crate::num::NonZero; | |
| 9 | use crate::ops::Try; | |
| 10 | ||
| 9 | 11 | /// An iterator that filters the elements of `iter` with `predicate`. |
| 10 | 12 | /// |
| 11 | 13 | /// This `struct` is created by the [`filter`] method on [`Iterator`]. See its |
library/core/src/iter/adapters/filter_map.rs+2-1| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | use crate::iter::{adapters::SourceIter, FusedIterator, InPlaceIterable, TrustedFused}; | |
| 1 | use crate::iter::adapters::SourceIter; | |
| 2 | use crate::iter::{FusedIterator, InPlaceIterable, TrustedFused}; | |
| 2 | 3 | use crate::mem::{ManuallyDrop, MaybeUninit}; |
| 3 | 4 | use crate::num::NonZero; |
| 4 | 5 | use crate::ops::{ControlFlow, Try}; |
library/core/src/iter/adapters/flatten.rs+3-5| ... | ... | @@ -1,13 +1,11 @@ |
| 1 | 1 | use crate::iter::adapters::SourceIter; |
| 2 | 2 | use crate::iter::{ |
| 3 | Cloned, Copied, Filter, FilterMap, Fuse, FusedIterator, InPlaceIterable, Map, TrustedFused, | |
| 4 | TrustedLen, | |
| 3 | Cloned, Copied, Empty, Filter, FilterMap, Fuse, FusedIterator, InPlaceIterable, Map, Once, | |
| 4 | OnceWith, TrustedFused, TrustedLen, | |
| 5 | 5 | }; |
| 6 | use crate::iter::{Empty, Once, OnceWith}; | |
| 7 | 6 | use crate::num::NonZero; |
| 8 | 7 | use crate::ops::{ControlFlow, Try}; |
| 9 | use crate::result; | |
| 10 | use crate::{array, fmt, option}; | |
| 8 | use crate::{array, fmt, option, result}; | |
| 11 | 9 | |
| 12 | 10 | /// An iterator that maps each element to an iterator, and yields the elements |
| 13 | 11 | /// of the produced iterators. |
library/core/src/iter/adapters/inspect.rs+2-1| ... | ... | @@ -1,5 +1,6 @@ |
| 1 | 1 | use crate::fmt; |
| 2 | use crate::iter::{adapters::SourceIter, FusedIterator, InPlaceIterable, TrustedFused}; | |
| 2 | use crate::iter::adapters::SourceIter; | |
| 3 | use crate::iter::{FusedIterator, InPlaceIterable, TrustedFused}; | |
| 3 | 4 | use crate::num::NonZero; |
| 4 | 5 | use crate::ops::Try; |
| 5 | 6 |
library/core/src/iter/adapters/map.rs+2-3| ... | ... | @@ -1,7 +1,6 @@ |
| 1 | 1 | use crate::fmt; |
| 2 | use crate::iter::adapters::{ | |
| 3 | zip::try_get_unchecked, SourceIter, TrustedRandomAccess, TrustedRandomAccessNoCoerce, | |
| 4 | }; | |
| 2 | use crate::iter::adapters::zip::try_get_unchecked; | |
| 3 | use crate::iter::adapters::{SourceIter, TrustedRandomAccess, TrustedRandomAccessNoCoerce}; | |
| 5 | 4 | use crate::iter::{FusedIterator, InPlaceIterable, TrustedFused, TrustedLen, UncheckedIterator}; |
| 6 | 5 | use crate::num::NonZero; |
| 7 | 6 | use crate::ops::Try; |
library/core/src/iter/adapters/map_while.rs+2-1| ... | ... | @@ -1,5 +1,6 @@ |
| 1 | 1 | use crate::fmt; |
| 2 | use crate::iter::{adapters::SourceIter, InPlaceIterable}; | |
| 2 | use crate::iter::adapters::SourceIter; | |
| 3 | use crate::iter::InPlaceIterable; | |
| 3 | 4 | use crate::num::NonZero; |
| 4 | 5 | use crate::ops::{ControlFlow, Try}; |
| 5 | 6 |
library/core/src/iter/adapters/map_windows.rs+3-6| ... | ... | @@ -1,9 +1,6 @@ |
| 1 | use crate::{ | |
| 2 | fmt, | |
| 3 | iter::FusedIterator, | |
| 4 | mem::{self, MaybeUninit}, | |
| 5 | ptr, | |
| 6 | }; | |
| 1 | use crate::iter::FusedIterator; | |
| 2 | use crate::mem::{self, MaybeUninit}; | |
| 3 | use crate::{fmt, ptr}; | |
| 7 | 4 | |
| 8 | 5 | /// An iterator over the mapped windows of another iterator. |
| 9 | 6 | /// |
library/core/src/iter/adapters/mod.rs+12-25| ... | ... | @@ -28,51 +28,38 @@ mod take; |
| 28 | 28 | mod take_while; |
| 29 | 29 | mod zip; |
| 30 | 30 | |
| 31 | #[stable(feature = "rust1", since = "1.0.0")] | |
| 32 | pub use self::{ | |
| 33 | chain::Chain, cycle::Cycle, enumerate::Enumerate, filter::Filter, filter_map::FilterMap, | |
| 34 | flatten::FlatMap, fuse::Fuse, inspect::Inspect, map::Map, peekable::Peekable, rev::Rev, | |
| 35 | scan::Scan, skip::Skip, skip_while::SkipWhile, take::Take, take_while::TakeWhile, zip::Zip, | |
| 36 | }; | |
| 37 | ||
| 38 | 31 | #[unstable(feature = "iter_array_chunks", reason = "recently added", issue = "100450")] |
| 39 | 32 | pub use self::array_chunks::ArrayChunks; |
| 40 | ||
| 41 | 33 | #[unstable(feature = "std_internals", issue = "none")] |
| 42 | 34 | pub use self::by_ref_sized::ByRefSized; |
| 43 | ||
| 44 | 35 | #[unstable(feature = "iter_chain", reason = "recently added", issue = "125964")] |
| 45 | 36 | pub use self::chain::chain; |
| 46 | ||
| 47 | 37 | #[stable(feature = "iter_cloned", since = "1.1.0")] |
| 48 | 38 | pub use self::cloned::Cloned; |
| 49 | ||
| 50 | #[stable(feature = "iterator_step_by", since = "1.28.0")] | |
| 51 | pub use self::step_by::StepBy; | |
| 52 | ||
| 53 | #[stable(feature = "iterator_flatten", since = "1.29.0")] | |
| 54 | pub use self::flatten::Flatten; | |
| 55 | ||
| 56 | 39 | #[stable(feature = "iter_copied", since = "1.36.0")] |
| 57 | 40 | pub use self::copied::Copied; |
| 58 | ||
| 41 | #[stable(feature = "iterator_flatten", since = "1.29.0")] | |
| 42 | pub use self::flatten::Flatten; | |
| 59 | 43 | #[unstable(feature = "iter_intersperse", reason = "recently added", issue = "79524")] |
| 60 | 44 | pub use self::intersperse::{Intersperse, IntersperseWith}; |
| 61 | ||
| 62 | 45 | #[stable(feature = "iter_map_while", since = "1.57.0")] |
| 63 | 46 | pub use self::map_while::MapWhile; |
| 64 | ||
| 65 | 47 | #[unstable(feature = "iter_map_windows", reason = "recently added", issue = "87155")] |
| 66 | 48 | pub use self::map_windows::MapWindows; |
| 67 | ||
| 49 | #[stable(feature = "iterator_step_by", since = "1.28.0")] | |
| 50 | pub use self::step_by::StepBy; | |
| 51 | #[stable(feature = "iter_zip", since = "1.59.0")] | |
| 52 | pub use self::zip::zip; | |
| 68 | 53 | #[unstable(feature = "trusted_random_access", issue = "none")] |
| 69 | 54 | pub use self::zip::TrustedRandomAccess; |
| 70 | ||
| 71 | 55 | #[unstable(feature = "trusted_random_access", issue = "none")] |
| 72 | 56 | pub use self::zip::TrustedRandomAccessNoCoerce; |
| 73 | ||
| 74 | #[stable(feature = "iter_zip", since = "1.59.0")] | |
| 75 | pub use self::zip::zip; | |
| 57 | #[stable(feature = "rust1", since = "1.0.0")] | |
| 58 | pub use self::{ | |
| 59 | chain::Chain, cycle::Cycle, enumerate::Enumerate, filter::Filter, filter_map::FilterMap, | |
| 60 | flatten::FlatMap, fuse::Fuse, inspect::Inspect, map::Map, peekable::Peekable, rev::Rev, | |
| 61 | scan::Scan, skip::Skip, skip_while::SkipWhile, take::Take, take_while::TakeWhile, zip::Zip, | |
| 62 | }; | |
| 76 | 63 | |
| 77 | 64 | /// This trait provides transitive access to source-stage in an iterator-adapter pipeline |
| 78 | 65 | /// under the conditions that |
library/core/src/iter/adapters/peekable.rs+2-1| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | use crate::iter::{adapters::SourceIter, FusedIterator, TrustedLen}; | |
| 1 | use crate::iter::adapters::SourceIter; | |
| 2 | use crate::iter::{FusedIterator, TrustedLen}; | |
| 2 | 3 | use crate::ops::{ControlFlow, Try}; |
| 3 | 4 | |
| 4 | 5 | /// An iterator with a `peek()` that returns an optional reference to the next |
library/core/src/iter/adapters/scan.rs+2-1| ... | ... | @@ -1,5 +1,6 @@ |
| 1 | 1 | use crate::fmt; |
| 2 | use crate::iter::{adapters::SourceIter, InPlaceIterable}; | |
| 2 | use crate::iter::adapters::SourceIter; | |
| 3 | use crate::iter::InPlaceIterable; | |
| 3 | 4 | use crate::num::NonZero; |
| 4 | 5 | use crate::ops::{ControlFlow, Try}; |
| 5 | 6 |
library/core/src/iter/adapters/skip.rs+2-2| ... | ... | @@ -1,8 +1,8 @@ |
| 1 | 1 | use crate::intrinsics::unlikely; |
| 2 | 2 | use crate::iter::adapters::zip::try_get_unchecked; |
| 3 | use crate::iter::TrustedFused; | |
| 3 | use crate::iter::adapters::SourceIter; | |
| 4 | 4 | use crate::iter::{ |
| 5 | adapters::SourceIter, FusedIterator, InPlaceIterable, TrustedLen, TrustedRandomAccess, | |
| 5 | FusedIterator, InPlaceIterable, TrustedFused, TrustedLen, TrustedRandomAccess, | |
| 6 | 6 | TrustedRandomAccessNoCoerce, |
| 7 | 7 | }; |
| 8 | 8 | use crate::num::NonZero; |
library/core/src/iter/adapters/skip_while.rs+2-1| ... | ... | @@ -1,5 +1,6 @@ |
| 1 | 1 | use crate::fmt; |
| 2 | use crate::iter::{adapters::SourceIter, FusedIterator, InPlaceIterable, TrustedFused}; | |
| 2 | use crate::iter::adapters::SourceIter; | |
| 3 | use crate::iter::{FusedIterator, InPlaceIterable, TrustedFused}; | |
| 3 | 4 | use crate::num::NonZero; |
| 4 | 5 | use crate::ops::Try; |
| 5 | 6 |
library/core/src/iter/adapters/step_by.rs+4-6| ... | ... | @@ -1,9 +1,7 @@ |
| 1 | use crate::{ | |
| 2 | intrinsics, | |
| 3 | iter::{from_fn, TrustedLen, TrustedRandomAccess}, | |
| 4 | num::NonZero, | |
| 5 | ops::{Range, Try}, | |
| 6 | }; | |
| 1 | use crate::intrinsics; | |
| 2 | use crate::iter::{from_fn, TrustedLen, TrustedRandomAccess}; | |
| 3 | use crate::num::NonZero; | |
| 4 | use crate::ops::{Range, Try}; | |
| 7 | 5 | |
| 8 | 6 | /// An iterator for stepping iterators by a custom amount. |
| 9 | 7 | /// |
library/core/src/iter/adapters/take.rs+2-4| ... | ... | @@ -1,8 +1,6 @@ |
| 1 | 1 | use crate::cmp; |
| 2 | use crate::iter::{ | |
| 3 | adapters::SourceIter, FusedIterator, InPlaceIterable, TrustedFused, TrustedLen, | |
| 4 | TrustedRandomAccess, | |
| 5 | }; | |
| 2 | use crate::iter::adapters::SourceIter; | |
| 3 | use crate::iter::{FusedIterator, InPlaceIterable, TrustedFused, TrustedLen, TrustedRandomAccess}; | |
| 6 | 4 | use crate::num::NonZero; |
| 7 | 5 | use crate::ops::{ControlFlow, Try}; |
| 8 | 6 |
library/core/src/iter/adapters/take_while.rs+2-1| ... | ... | @@ -1,5 +1,6 @@ |
| 1 | 1 | use crate::fmt; |
| 2 | use crate::iter::{adapters::SourceIter, FusedIterator, InPlaceIterable, TrustedFused}; | |
| 2 | use crate::iter::adapters::SourceIter; | |
| 3 | use crate::iter::{FusedIterator, InPlaceIterable, TrustedFused}; | |
| 3 | 4 | use crate::num::NonZero; |
| 4 | 5 | use crate::ops::{ControlFlow, Try}; |
| 5 | 6 |
library/core/src/iter/adapters/zip.rs+3-2| ... | ... | @@ -1,7 +1,8 @@ |
| 1 | 1 | use crate::cmp; |
| 2 | 2 | use crate::fmt::{self, Debug}; |
| 3 | use crate::iter::{FusedIterator, TrustedFused}; | |
| 4 | use crate::iter::{InPlaceIterable, SourceIter, TrustedLen, UncheckedIterator}; | |
| 3 | use crate::iter::{ | |
| 4 | FusedIterator, InPlaceIterable, SourceIter, TrustedFused, TrustedLen, UncheckedIterator, | |
| 5 | }; | |
| 5 | 6 | use crate::num::NonZero; |
| 6 | 7 | |
| 7 | 8 | /// An iterator that iterates two other iterators simultaneously. |
library/core/src/iter/mod.rs+36-41| ... | ... | @@ -380,16 +380,46 @@ macro_rules! impl_fold_via_try_fold { |
| 380 | 380 | }; |
| 381 | 381 | } |
| 382 | 382 | |
| 383 | #[unstable(feature = "iter_chain", reason = "recently added", issue = "125964")] | |
| 384 | pub use self::adapters::chain; | |
| 385 | pub(crate) use self::adapters::try_process; | |
| 386 | #[stable(feature = "iter_zip", since = "1.59.0")] | |
| 387 | pub use self::adapters::zip; | |
| 388 | #[unstable(feature = "iter_array_chunks", reason = "recently added", issue = "100450")] | |
| 389 | pub use self::adapters::ArrayChunks; | |
| 390 | #[unstable(feature = "std_internals", issue = "none")] | |
| 391 | pub use self::adapters::ByRefSized; | |
| 392 | #[stable(feature = "iter_cloned", since = "1.1.0")] | |
| 393 | pub use self::adapters::Cloned; | |
| 394 | #[stable(feature = "iter_copied", since = "1.36.0")] | |
| 395 | pub use self::adapters::Copied; | |
| 396 | #[stable(feature = "iterator_flatten", since = "1.29.0")] | |
| 397 | pub use self::adapters::Flatten; | |
| 398 | #[stable(feature = "iter_map_while", since = "1.57.0")] | |
| 399 | pub use self::adapters::MapWhile; | |
| 400 | #[unstable(feature = "iter_map_windows", reason = "recently added", issue = "87155")] | |
| 401 | pub use self::adapters::MapWindows; | |
| 402 | #[unstable(feature = "inplace_iteration", issue = "none")] | |
| 403 | pub use self::adapters::SourceIter; | |
| 404 | #[stable(feature = "iterator_step_by", since = "1.28.0")] | |
| 405 | pub use self::adapters::StepBy; | |
| 406 | #[unstable(feature = "trusted_random_access", issue = "none")] | |
| 407 | pub use self::adapters::TrustedRandomAccess; | |
| 408 | #[unstable(feature = "trusted_random_access", issue = "none")] | |
| 409 | pub use self::adapters::TrustedRandomAccessNoCoerce; | |
| 383 | 410 | #[stable(feature = "rust1", since = "1.0.0")] |
| 384 | pub use self::traits::Iterator; | |
| 385 | ||
| 411 | pub use self::adapters::{ | |
| 412 | Chain, Cycle, Enumerate, Filter, FilterMap, FlatMap, Fuse, Inspect, Map, Peekable, Rev, Scan, | |
| 413 | Skip, SkipWhile, Take, TakeWhile, Zip, | |
| 414 | }; | |
| 415 | #[unstable(feature = "iter_intersperse", reason = "recently added", issue = "79524")] | |
| 416 | pub use self::adapters::{Intersperse, IntersperseWith}; | |
| 386 | 417 | #[unstable( |
| 387 | 418 | feature = "step_trait", |
| 388 | 419 | reason = "likely to be replaced by finer-grained traits", |
| 389 | 420 | issue = "42168" |
| 390 | 421 | )] |
| 391 | 422 | pub use self::range::Step; |
| 392 | ||
| 393 | 423 | #[unstable( |
| 394 | 424 | feature = "iter_from_coroutine", |
| 395 | 425 | issue = "43122", |
| ... | ... | @@ -412,59 +442,24 @@ pub use self::sources::{repeat_n, RepeatN}; |
| 412 | 442 | pub use self::sources::{repeat_with, RepeatWith}; |
| 413 | 443 | #[stable(feature = "iter_successors", since = "1.34.0")] |
| 414 | 444 | pub use self::sources::{successors, Successors}; |
| 415 | ||
| 416 | 445 | #[stable(feature = "fused", since = "1.26.0")] |
| 417 | 446 | pub use self::traits::FusedIterator; |
| 418 | 447 | #[unstable(issue = "none", feature = "inplace_iteration")] |
| 419 | 448 | pub use self::traits::InPlaceIterable; |
| 449 | #[stable(feature = "rust1", since = "1.0.0")] | |
| 450 | pub use self::traits::Iterator; | |
| 420 | 451 | #[unstable(issue = "none", feature = "trusted_fused")] |
| 421 | 452 | pub use self::traits::TrustedFused; |
| 422 | 453 | #[unstable(feature = "trusted_len", issue = "37572")] |
| 423 | 454 | pub use self::traits::TrustedLen; |
| 424 | 455 | #[unstable(feature = "trusted_step", issue = "85731")] |
| 425 | 456 | pub use self::traits::TrustedStep; |
| 457 | pub(crate) use self::traits::UncheckedIterator; | |
| 426 | 458 | #[stable(feature = "rust1", since = "1.0.0")] |
| 427 | 459 | pub use self::traits::{ |
| 428 | 460 | DoubleEndedIterator, ExactSizeIterator, Extend, FromIterator, IntoIterator, Product, Sum, |
| 429 | 461 | }; |
| 430 | 462 | |
| 431 | #[unstable(feature = "iter_chain", reason = "recently added", issue = "125964")] | |
| 432 | pub use self::adapters::chain; | |
| 433 | #[stable(feature = "iter_zip", since = "1.59.0")] | |
| 434 | pub use self::adapters::zip; | |
| 435 | #[unstable(feature = "iter_array_chunks", reason = "recently added", issue = "100450")] | |
| 436 | pub use self::adapters::ArrayChunks; | |
| 437 | #[unstable(feature = "std_internals", issue = "none")] | |
| 438 | pub use self::adapters::ByRefSized; | |
| 439 | #[stable(feature = "iter_cloned", since = "1.1.0")] | |
| 440 | pub use self::adapters::Cloned; | |
| 441 | #[stable(feature = "iter_copied", since = "1.36.0")] | |
| 442 | pub use self::adapters::Copied; | |
| 443 | #[stable(feature = "iterator_flatten", since = "1.29.0")] | |
| 444 | pub use self::adapters::Flatten; | |
| 445 | #[stable(feature = "iter_map_while", since = "1.57.0")] | |
| 446 | pub use self::adapters::MapWhile; | |
| 447 | #[unstable(feature = "iter_map_windows", reason = "recently added", issue = "87155")] | |
| 448 | pub use self::adapters::MapWindows; | |
| 449 | #[unstable(feature = "inplace_iteration", issue = "none")] | |
| 450 | pub use self::adapters::SourceIter; | |
| 451 | #[stable(feature = "iterator_step_by", since = "1.28.0")] | |
| 452 | pub use self::adapters::StepBy; | |
| 453 | #[unstable(feature = "trusted_random_access", issue = "none")] | |
| 454 | pub use self::adapters::TrustedRandomAccess; | |
| 455 | #[unstable(feature = "trusted_random_access", issue = "none")] | |
| 456 | pub use self::adapters::TrustedRandomAccessNoCoerce; | |
| 457 | #[stable(feature = "rust1", since = "1.0.0")] | |
| 458 | pub use self::adapters::{ | |
| 459 | Chain, Cycle, Enumerate, Filter, FilterMap, FlatMap, Fuse, Inspect, Map, Peekable, Rev, Scan, | |
| 460 | Skip, SkipWhile, Take, TakeWhile, Zip, | |
| 461 | }; | |
| 462 | #[unstable(feature = "iter_intersperse", reason = "recently added", issue = "79524")] | |
| 463 | pub use self::adapters::{Intersperse, IntersperseWith}; | |
| 464 | ||
| 465 | pub(crate) use self::adapters::try_process; | |
| 466 | pub(crate) use self::traits::UncheckedIterator; | |
| 467 | ||
| 468 | 463 | mod adapters; |
| 469 | 464 | mod range; |
| 470 | 465 | mod sources; |
library/core/src/iter/range.rs+3-4| ... | ... | @@ -1,13 +1,12 @@ |
| 1 | use super::{ | |
| 2 | FusedIterator, TrustedLen, TrustedRandomAccess, TrustedRandomAccessNoCoerce, TrustedStep, | |
| 3 | }; | |
| 1 | 4 | use crate::ascii::Char as AsciiChar; |
| 2 | 5 | use crate::mem; |
| 3 | 6 | use crate::net::{Ipv4Addr, Ipv6Addr}; |
| 4 | 7 | use crate::num::NonZero; |
| 5 | 8 | use crate::ops::{self, Try}; |
| 6 | 9 | |
| 7 | use super::{ | |
| 8 | FusedIterator, TrustedLen, TrustedRandomAccess, TrustedRandomAccessNoCoerce, TrustedStep, | |
| 9 | }; | |
| 10 | ||
| 11 | 10 | // Safety: All invariants are upheld. |
| 12 | 11 | macro_rules! unsafe_impl_trusted_step { |
| 13 | 12 | ($($type:ty)*) => {$( |
library/core/src/iter/sources.rs+12-20| ... | ... | @@ -8,33 +8,25 @@ mod repeat_n; |
| 8 | 8 | mod repeat_with; |
| 9 | 9 | mod successors; |
| 10 | 10 | |
| 11 | #[stable(feature = "rust1", since = "1.0.0")] | |
| 12 | pub use self::repeat::{repeat, Repeat}; | |
| 13 | ||
| 14 | 11 | #[stable(feature = "iter_empty", since = "1.2.0")] |
| 15 | 12 | pub use self::empty::{empty, Empty}; |
| 16 | ||
| 17 | #[stable(feature = "iter_once", since = "1.2.0")] | |
| 18 | pub use self::once::{once, Once}; | |
| 19 | ||
| 20 | #[unstable(feature = "iter_repeat_n", issue = "104434")] | |
| 21 | pub use self::repeat_n::{repeat_n, RepeatN}; | |
| 22 | ||
| 23 | #[stable(feature = "iterator_repeat_with", since = "1.28.0")] | |
| 24 | pub use self::repeat_with::{repeat_with, RepeatWith}; | |
| 25 | ||
| 26 | #[stable(feature = "iter_from_fn", since = "1.34.0")] | |
| 27 | pub use self::from_fn::{from_fn, FromFn}; | |
| 28 | ||
| 29 | 13 | #[unstable( |
| 30 | 14 | feature = "iter_from_coroutine", |
| 31 | 15 | issue = "43122", |
| 32 | 16 | reason = "coroutines are unstable" |
| 33 | 17 | )] |
| 34 | 18 | pub use self::from_coroutine::from_coroutine; |
| 35 | ||
| 36 | #[stable(feature = "iter_successors", since = "1.34.0")] | |
| 37 | pub use self::successors::{successors, Successors}; | |
| 38 | ||
| 19 | #[stable(feature = "iter_from_fn", since = "1.34.0")] | |
| 20 | pub use self::from_fn::{from_fn, FromFn}; | |
| 21 | #[stable(feature = "iter_once", since = "1.2.0")] | |
| 22 | pub use self::once::{once, Once}; | |
| 39 | 23 | #[stable(feature = "iter_once_with", since = "1.43.0")] |
| 40 | 24 | pub use self::once_with::{once_with, OnceWith}; |
| 25 | #[stable(feature = "rust1", since = "1.0.0")] | |
| 26 | pub use self::repeat::{repeat, Repeat}; | |
| 27 | #[unstable(feature = "iter_repeat_n", issue = "104434")] | |
| 28 | pub use self::repeat_n::{repeat_n, RepeatN}; | |
| 29 | #[stable(feature = "iterator_repeat_with", since = "1.28.0")] | |
| 30 | pub use self::repeat_with::{repeat_with, RepeatWith}; | |
| 31 | #[stable(feature = "iter_successors", since = "1.34.0")] | |
| 32 | pub use self::successors::{successors, Successors}; |
library/core/src/iter/sources/empty.rs+1-2| ... | ... | @@ -1,6 +1,5 @@ |
| 1 | use crate::fmt; | |
| 2 | 1 | use crate::iter::{FusedIterator, TrustedLen}; |
| 3 | use crate::marker; | |
| 2 | use crate::{fmt, marker}; | |
| 4 | 3 | |
| 5 | 4 | /// Creates an iterator that yields nothing. |
| 6 | 5 | /// |
library/core/src/iter/sources/successors.rs+2-1| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | use crate::{fmt, iter::FusedIterator}; | |
| 1 | use crate::fmt; | |
| 2 | use crate::iter::FusedIterator; | |
| 2 | 3 | |
| 3 | 4 | /// Creates a new iterator where each successive item is computed based on the preceding one. |
| 4 | 5 | /// |
library/core/src/iter/traits/iterator.rs+6-11| ... | ... | @@ -1,19 +1,14 @@ |
| 1 | use super::super::{ | |
| 2 | try_process, ArrayChunks, ByRefSized, Chain, Cloned, Copied, Cycle, Enumerate, Filter, | |
| 3 | FilterMap, FlatMap, Flatten, Fuse, Inspect, Intersperse, IntersperseWith, Map, MapWhile, | |
| 4 | MapWindows, Peekable, Product, Rev, Scan, Skip, SkipWhile, StepBy, Sum, Take, TakeWhile, | |
| 5 | TrustedRandomAccessNoCoerce, Zip, | |
| 6 | }; | |
| 1 | 7 | use crate::array; |
| 2 | 8 | use crate::cmp::{self, Ordering}; |
| 3 | 9 | use crate::num::NonZero; |
| 4 | 10 | use crate::ops::{ChangeOutputType, ControlFlow, FromResidual, Residual, Try}; |
| 5 | 11 | |
| 6 | use super::super::try_process; | |
| 7 | use super::super::ByRefSized; | |
| 8 | use super::super::TrustedRandomAccessNoCoerce; | |
| 9 | use super::super::{ArrayChunks, Chain, Cloned, Copied, Cycle, Enumerate, Filter, FilterMap, Fuse}; | |
| 10 | use super::super::{FlatMap, Flatten}; | |
| 11 | use super::super::{ | |
| 12 | Inspect, Map, MapWhile, MapWindows, Peekable, Rev, Scan, Skip, SkipWhile, StepBy, Take, | |
| 13 | TakeWhile, | |
| 14 | }; | |
| 15 | use super::super::{Intersperse, IntersperseWith, Product, Sum, Zip}; | |
| 16 | ||
| 17 | 12 | fn _assert_is_object_safe(_: &dyn Iterator<Item = ()>) {} |
| 18 | 13 | |
| 19 | 14 | /// A trait for dealing with iterators. |
library/core/src/iter/traits/mod.rs+7-9| ... | ... | @@ -6,6 +6,13 @@ mod iterator; |
| 6 | 6 | mod marker; |
| 7 | 7 | mod unchecked_iterator; |
| 8 | 8 | |
| 9 | #[unstable(issue = "none", feature = "inplace_iteration")] | |
| 10 | pub use self::marker::InPlaceIterable; | |
| 11 | #[unstable(issue = "none", feature = "trusted_fused")] | |
| 12 | pub use self::marker::TrustedFused; | |
| 13 | #[unstable(feature = "trusted_step", issue = "85731")] | |
| 14 | pub use self::marker::TrustedStep; | |
| 15 | pub(crate) use self::unchecked_iterator::UncheckedIterator; | |
| 9 | 16 | #[stable(feature = "rust1", since = "1.0.0")] |
| 10 | 17 | pub use self::{ |
| 11 | 18 | accum::{Product, Sum}, |
| ... | ... | @@ -15,12 +22,3 @@ pub use self::{ |
| 15 | 22 | iterator::Iterator, |
| 16 | 23 | marker::{FusedIterator, TrustedLen}, |
| 17 | 24 | }; |
| 18 | ||
| 19 | #[unstable(issue = "none", feature = "inplace_iteration")] | |
| 20 | pub use self::marker::InPlaceIterable; | |
| 21 | #[unstable(issue = "none", feature = "trusted_fused")] | |
| 22 | pub use self::marker::TrustedFused; | |
| 23 | #[unstable(feature = "trusted_step", issue = "85731")] | |
| 24 | pub use self::marker::TrustedStep; | |
| 25 | ||
| 26 | pub(crate) use self::unchecked_iterator::UncheckedIterator; |
library/core/src/marker.rs+1-2| ... | ... | @@ -9,8 +9,7 @@ |
| 9 | 9 | use crate::cell::UnsafeCell; |
| 10 | 10 | use crate::cmp; |
| 11 | 11 | use crate::fmt::Debug; |
| 12 | use crate::hash::Hash; | |
| 13 | use crate::hash::Hasher; | |
| 12 | use crate::hash::{Hash, Hasher}; | |
| 14 | 13 | |
| 15 | 14 | /// Implements a given marker trait for multiple types at the same time. |
| 16 | 15 | /// |
library/core/src/mem/maybe_uninit.rs+1-4| ... | ... | @@ -1,9 +1,6 @@ |
| 1 | 1 | use crate::any::type_name; |
| 2 | use crate::fmt; | |
| 3 | use crate::intrinsics; | |
| 4 | 2 | use crate::mem::{self, ManuallyDrop}; |
| 5 | use crate::ptr; | |
| 6 | use crate::slice; | |
| 3 | use crate::{fmt, intrinsics, ptr, slice}; | |
| 7 | 4 | |
| 8 | 5 | /// A wrapper type to construct uninitialized instances of `T`. |
| 9 | 6 | /// |
library/core/src/mem/mod.rs+1-6| ... | ... | @@ -5,13 +5,8 @@ |
| 5 | 5 | |
| 6 | 6 | #![stable(feature = "rust1", since = "1.0.0")] |
| 7 | 7 | |
| 8 | use crate::clone; | |
| 9 | use crate::cmp; | |
| 10 | use crate::fmt; | |
| 11 | use crate::hash; | |
| 12 | use crate::intrinsics; | |
| 13 | 8 | use crate::marker::DiscriminantKind; |
| 14 | use crate::ptr; | |
| 9 | use crate::{clone, cmp, fmt, hash, intrinsics, ptr}; | |
| 15 | 10 | |
| 16 | 11 | mod manually_drop; |
| 17 | 12 | #[stable(feature = "manually_drop", since = "1.20.0")] |
library/core/src/net/display_buffer.rs+1-2| ... | ... | @@ -1,6 +1,5 @@ |
| 1 | use crate::fmt; | |
| 2 | 1 | use crate::mem::MaybeUninit; |
| 3 | use crate::str; | |
| 2 | use crate::{fmt, str}; | |
| 4 | 3 | |
| 5 | 4 | /// Used for slow path in `Display` implementations when alignment is required. |
| 6 | 5 | pub struct DisplayBuffer<const SIZE: usize> { |
library/core/src/net/ip_addr.rs+1-2| ... | ... | @@ -1,11 +1,10 @@ |
| 1 | use super::display_buffer::DisplayBuffer; | |
| 1 | 2 | use crate::cmp::Ordering; |
| 2 | 3 | use crate::fmt::{self, Write}; |
| 3 | 4 | use crate::iter; |
| 4 | 5 | use crate::mem::transmute; |
| 5 | 6 | use crate::ops::{BitAnd, BitAndAssign, BitOr, BitOrAssign, Not}; |
| 6 | 7 | |
| 7 | use super::display_buffer::DisplayBuffer; | |
| 8 | ||
| 9 | 8 | /// An IP address, either IPv4 or IPv6. |
| 10 | 9 | /// |
| 11 | 10 | /// This enum can contain either an [`Ipv4Addr`] or an [`Ipv6Addr`], see their |
library/core/src/net/socket_addr.rs+1-2| ... | ... | @@ -1,8 +1,7 @@ |
| 1 | use super::display_buffer::DisplayBuffer; | |
| 1 | 2 | use crate::fmt::{self, Write}; |
| 2 | 3 | use crate::net::{IpAddr, Ipv4Addr, Ipv6Addr}; |
| 3 | 4 | |
| 4 | use super::display_buffer::DisplayBuffer; | |
| 5 | ||
| 6 | 5 | /// An internet socket address, either IPv4 or IPv6. |
| 7 | 6 | /// |
| 8 | 7 | /// Internet socket addresses consist of an [IP address], a 16-bit port number, as well |
library/core/src/num/bignum.rs+2-4| ... | ... | @@ -145,8 +145,7 @@ macro_rules! define_bignum { |
| 145 | 145 | |
| 146 | 146 | /// Adds `other` to itself and returns its own mutable reference. |
| 147 | 147 | pub fn add<'a>(&'a mut self, other: &$name) -> &'a mut $name { |
| 148 | use crate::cmp; | |
| 149 | use crate::iter; | |
| 148 | use crate::{cmp, iter}; | |
| 150 | 149 | |
| 151 | 150 | let mut sz = cmp::max(self.size, other.size); |
| 152 | 151 | let mut carry = false; |
| ... | ... | @@ -181,8 +180,7 @@ macro_rules! define_bignum { |
| 181 | 180 | |
| 182 | 181 | /// Subtracts `other` from itself and returns its own mutable reference. |
| 183 | 182 | pub fn sub<'a>(&'a mut self, other: &$name) -> &'a mut $name { |
| 184 | use crate::cmp; | |
| 185 | use crate::iter; | |
| 183 | use crate::{cmp, iter}; | |
| 186 | 184 | |
| 187 | 185 | let sz = cmp::max(self.size, other.size); |
| 188 | 186 | let mut noborrow = true; |
library/core/src/num/dec2flt/mod.rs+3-4| ... | ... | @@ -75,15 +75,14 @@ |
| 75 | 75 | issue = "none" |
| 76 | 76 | )] |
| 77 | 77 | |
| 78 | use crate::error::Error; | |
| 79 | use crate::fmt; | |
| 80 | use crate::str::FromStr; | |
| 81 | ||
| 82 | 78 | use self::common::BiasedFp; |
| 83 | 79 | use self::float::RawFloat; |
| 84 | 80 | use self::lemire::compute_float; |
| 85 | 81 | use self::parse::{parse_inf_nan, parse_number}; |
| 86 | 82 | use self::slow::parse_long_mantissa; |
| 83 | use crate::error::Error; | |
| 84 | use crate::fmt; | |
| 85 | use crate::str::FromStr; | |
| 87 | 86 | |
| 88 | 87 | mod common; |
| 89 | 88 | mod decimal; |
library/core/src/num/flt2dec/mod.rs-1| ... | ... | @@ -123,7 +123,6 @@ functions. |
| 123 | 123 | )] |
| 124 | 124 | |
| 125 | 125 | pub use self::decoder::{decode, DecodableFloat, Decoded, FullDecoded}; |
| 126 | ||
| 127 | 126 | use super::fmt::{Formatted, Part}; |
| 128 | 127 | use crate::mem::MaybeUninit; |
| 129 | 128 |
library/core/src/num/flt2dec/strategy/dragon.rs+1-3| ... | ... | @@ -6,9 +6,7 @@ |
| 6 | 6 | |
| 7 | 7 | use crate::cmp::Ordering; |
| 8 | 8 | use crate::mem::MaybeUninit; |
| 9 | ||
| 10 | use crate::num::bignum::Big32x40 as Big; | |
| 11 | use crate::num::bignum::Digit32 as Digit; | |
| 9 | use crate::num::bignum::{Big32x40 as Big, Digit32 as Digit}; | |
| 12 | 10 | use crate::num::flt2dec::estimator::estimate_scaling_factor; |
| 13 | 11 | use crate::num::flt2dec::{round_up, Decoded, MAX_SIG_DIGITS}; |
| 14 | 12 |
library/core/src/num/mod.rs+11-21| ... | ... | @@ -2,11 +2,9 @@ |
| 2 | 2 | |
| 3 | 3 | #![stable(feature = "rust1", since = "1.0.0")] |
| 4 | 4 | |
| 5 | use crate::ascii; | |
| 6 | use crate::intrinsics; | |
| 7 | use crate::mem; | |
| 8 | 5 | use crate::str::FromStr; |
| 9 | 6 | use crate::ub_checks::assert_unsafe_precondition; |
| 7 | use crate::{ascii, intrinsics, mem}; | |
| 10 | 8 | |
| 11 | 9 | // Used because the `?` operator is not allowed in a const context. |
| 12 | 10 | macro_rules! try_opt { |
| ... | ... | @@ -48,39 +46,31 @@ mod overflow_panic; |
| 48 | 46 | mod saturating; |
| 49 | 47 | mod wrapping; |
| 50 | 48 | |
| 51 | #[stable(feature = "saturating_int_impl", since = "1.74.0")] | |
| 52 | pub use saturating::Saturating; | |
| 53 | #[stable(feature = "rust1", since = "1.0.0")] | |
| 54 | pub use wrapping::Wrapping; | |
| 55 | ||
| 56 | 49 | #[stable(feature = "rust1", since = "1.0.0")] |
| 57 | 50 | #[cfg(not(no_fp_fmt_parse))] |
| 58 | 51 | pub use dec2flt::ParseFloatError; |
| 59 | ||
| 52 | #[stable(feature = "int_error_matching", since = "1.55.0")] | |
| 53 | pub use error::IntErrorKind; | |
| 60 | 54 | #[stable(feature = "rust1", since = "1.0.0")] |
| 61 | 55 | pub use error::ParseIntError; |
| 62 | ||
| 56 | #[stable(feature = "try_from", since = "1.34.0")] | |
| 57 | pub use error::TryFromIntError; | |
| 58 | #[stable(feature = "generic_nonzero", since = "1.79.0")] | |
| 59 | pub use nonzero::NonZero; | |
| 63 | 60 | #[unstable( |
| 64 | 61 | feature = "nonzero_internals", |
| 65 | 62 | reason = "implementation detail which may disappear or be replaced at any time", |
| 66 | 63 | issue = "none" |
| 67 | 64 | )] |
| 68 | 65 | pub use nonzero::ZeroablePrimitive; |
| 69 | ||
| 70 | #[stable(feature = "generic_nonzero", since = "1.79.0")] | |
| 71 | pub use nonzero::NonZero; | |
| 72 | ||
| 73 | 66 | #[stable(feature = "signed_nonzero", since = "1.34.0")] |
| 74 | 67 | pub use nonzero::{NonZeroI128, NonZeroI16, NonZeroI32, NonZeroI64, NonZeroI8, NonZeroIsize}; |
| 75 | ||
| 76 | 68 | #[stable(feature = "nonzero", since = "1.28.0")] |
| 77 | 69 | pub use nonzero::{NonZeroU128, NonZeroU16, NonZeroU32, NonZeroU64, NonZeroU8, NonZeroUsize}; |
| 78 | ||
| 79 | #[stable(feature = "try_from", since = "1.34.0")] | |
| 80 | pub use error::TryFromIntError; | |
| 81 | ||
| 82 | #[stable(feature = "int_error_matching", since = "1.55.0")] | |
| 83 | pub use error::IntErrorKind; | |
| 70 | #[stable(feature = "saturating_int_impl", since = "1.74.0")] | |
| 71 | pub use saturating::Saturating; | |
| 72 | #[stable(feature = "rust1", since = "1.0.0")] | |
| 73 | pub use wrapping::Wrapping; | |
| 84 | 74 | |
| 85 | 75 | macro_rules! usize_isize_to_xe_bytes_doc { |
| 86 | 76 | () => { |
library/core/src/num/nonzero.rs+2-7| ... | ... | @@ -1,18 +1,13 @@ |
| 1 | 1 | //! Definitions of integer that is known not to equal zero. |
| 2 | 2 | |
| 3 | use super::{IntErrorKind, ParseIntError}; | |
| 3 | 4 | use crate::cmp::Ordering; |
| 4 | use crate::fmt; | |
| 5 | 5 | use crate::hash::{Hash, Hasher}; |
| 6 | use crate::hint; | |
| 7 | use crate::intrinsics; | |
| 8 | 6 | use crate::marker::{Freeze, StructuralPartialEq}; |
| 9 | 7 | use crate::ops::{BitOr, BitOrAssign, Div, DivAssign, Neg, Rem, RemAssign}; |
| 10 | 8 | use crate::panic::{RefUnwindSafe, UnwindSafe}; |
| 11 | use crate::ptr; | |
| 12 | 9 | use crate::str::FromStr; |
| 13 | use crate::ub_checks; | |
| 14 | ||
| 15 | use super::{IntErrorKind, ParseIntError}; | |
| 10 | use crate::{fmt, hint, intrinsics, ptr, ub_checks}; | |
| 16 | 11 | |
| 17 | 12 | /// A marker trait for primitive types which can be zero. |
| 18 | 13 | /// |
library/core/src/num/saturating.rs+4-4| ... | ... | @@ -1,10 +1,10 @@ |
| 1 | 1 | //! Definitions of `Saturating<T>`. |
| 2 | 2 | |
| 3 | 3 | use crate::fmt; |
| 4 | use crate::ops::{Add, AddAssign, BitAnd, BitAndAssign, BitOr, BitOrAssign}; | |
| 5 | use crate::ops::{BitXor, BitXorAssign, Div, DivAssign}; | |
| 6 | use crate::ops::{Mul, MulAssign, Neg, Not, Rem, RemAssign}; | |
| 7 | use crate::ops::{Sub, SubAssign}; | |
| 4 | use crate::ops::{ | |
| 5 | Add, AddAssign, BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign, Div, DivAssign, | |
| 6 | Mul, MulAssign, Neg, Not, Rem, RemAssign, Sub, SubAssign, | |
| 7 | }; | |
| 8 | 8 | |
| 9 | 9 | /// Provides intentionally-saturating arithmetic on `T`. |
| 10 | 10 | /// |
library/core/src/num/wrapping.rs+4-4| ... | ... | @@ -1,10 +1,10 @@ |
| 1 | 1 | //! Definitions of `Wrapping<T>`. |
| 2 | 2 | |
| 3 | 3 | use crate::fmt; |
| 4 | use crate::ops::{Add, AddAssign, BitAnd, BitAndAssign, BitOr, BitOrAssign}; | |
| 5 | use crate::ops::{BitXor, BitXorAssign, Div, DivAssign}; | |
| 6 | use crate::ops::{Mul, MulAssign, Neg, Not, Rem, RemAssign}; | |
| 7 | use crate::ops::{Shl, ShlAssign, Shr, ShrAssign, Sub, SubAssign}; | |
| 4 | use crate::ops::{ | |
| 5 | Add, AddAssign, BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign, Div, DivAssign, | |
| 6 | Mul, MulAssign, Neg, Not, Rem, RemAssign, Shl, ShlAssign, Shr, ShrAssign, Sub, SubAssign, | |
| 7 | }; | |
| 8 | 8 | |
| 9 | 9 | /// Provides intentionally-wrapped arithmetic on `T`. |
| 10 | 10 | /// |
library/core/src/ops/mod.rs+17-38| ... | ... | @@ -156,65 +156,44 @@ mod unsize; |
| 156 | 156 | pub use self::arith::{Add, Div, Mul, Neg, Rem, Sub}; |
| 157 | 157 | #[stable(feature = "op_assign_traits", since = "1.8.0")] |
| 158 | 158 | pub use self::arith::{AddAssign, DivAssign, MulAssign, RemAssign, SubAssign}; |
| 159 | ||
| 159 | #[unstable(feature = "async_fn_traits", issue = "none")] | |
| 160 | pub use self::async_function::{AsyncFn, AsyncFnMut, AsyncFnOnce}; | |
| 160 | 161 | #[stable(feature = "rust1", since = "1.0.0")] |
| 161 | 162 | pub use self::bit::{BitAnd, BitOr, BitXor, Not, Shl, Shr}; |
| 162 | 163 | #[stable(feature = "op_assign_traits", since = "1.8.0")] |
| 163 | 164 | pub use self::bit::{BitAndAssign, BitOrAssign, BitXorAssign, ShlAssign, ShrAssign}; |
| 164 | ||
| 165 | #[stable(feature = "rust1", since = "1.0.0")] | |
| 166 | pub use self::deref::{Deref, DerefMut}; | |
| 167 | ||
| 165 | #[unstable(feature = "control_flow_enum", reason = "new API", issue = "75744")] | |
| 166 | pub use self::control_flow::ControlFlow; | |
| 167 | #[unstable(feature = "coroutine_trait", issue = "43122")] | |
| 168 | pub use self::coroutine::{Coroutine, CoroutineState}; | |
| 168 | 169 | #[unstable(feature = "deref_pure_trait", issue = "87121")] |
| 169 | 170 | pub use self::deref::DerefPure; |
| 170 | ||
| 171 | 171 | #[unstable(feature = "receiver_trait", issue = "none")] |
| 172 | 172 | pub use self::deref::Receiver; |
| 173 | ||
| 174 | 173 | #[stable(feature = "rust1", since = "1.0.0")] |
| 175 | pub use self::drop::Drop; | |
| 176 | ||
| 174 | pub use self::deref::{Deref, DerefMut}; | |
| 177 | 175 | pub(crate) use self::drop::fallback_surface_drop; |
| 178 | ||
| 176 | #[stable(feature = "rust1", since = "1.0.0")] | |
| 177 | pub use self::drop::Drop; | |
| 179 | 178 | #[stable(feature = "rust1", since = "1.0.0")] |
| 180 | 179 | pub use self::function::{Fn, FnMut, FnOnce}; |
| 181 | ||
| 182 | #[unstable(feature = "async_fn_traits", issue = "none")] | |
| 183 | pub use self::async_function::{AsyncFn, AsyncFnMut, AsyncFnOnce}; | |
| 184 | ||
| 185 | 180 | #[stable(feature = "rust1", since = "1.0.0")] |
| 186 | 181 | pub use self::index::{Index, IndexMut}; |
| 187 | ||
| 188 | #[stable(feature = "rust1", since = "1.0.0")] | |
| 189 | pub use self::range::{Range, RangeFrom, RangeFull, RangeTo}; | |
| 190 | ||
| 191 | 182 | pub(crate) use self::index_range::IndexRange; |
| 192 | ||
| 193 | #[stable(feature = "inclusive_range", since = "1.26.0")] | |
| 194 | pub use self::range::{Bound, RangeBounds, RangeInclusive, RangeToInclusive}; | |
| 195 | ||
| 196 | 183 | #[unstable(feature = "one_sided_range", issue = "69780")] |
| 197 | 184 | pub use self::range::OneSidedRange; |
| 198 | ||
| 199 | #[unstable(feature = "try_trait_v2", issue = "84277")] | |
| 200 | pub use self::try_trait::{FromResidual, Try}; | |
| 201 | ||
| 202 | #[unstable(feature = "try_trait_v2_yeet", issue = "96374")] | |
| 203 | pub use self::try_trait::Yeet; | |
| 204 | ||
| 185 | #[stable(feature = "inclusive_range", since = "1.26.0")] | |
| 186 | pub use self::range::{Bound, RangeBounds, RangeInclusive, RangeToInclusive}; | |
| 187 | #[stable(feature = "rust1", since = "1.0.0")] | |
| 188 | pub use self::range::{Range, RangeFrom, RangeFull, RangeTo}; | |
| 205 | 189 | #[unstable(feature = "try_trait_v2_residual", issue = "91285")] |
| 206 | 190 | pub use self::try_trait::Residual; |
| 207 | ||
| 191 | #[unstable(feature = "try_trait_v2_yeet", issue = "96374")] | |
| 192 | pub use self::try_trait::Yeet; | |
| 208 | 193 | pub(crate) use self::try_trait::{ChangeOutputType, NeverShortCircuit}; |
| 209 | ||
| 210 | #[unstable(feature = "coroutine_trait", issue = "43122")] | |
| 211 | pub use self::coroutine::{Coroutine, CoroutineState}; | |
| 212 | ||
| 194 | #[unstable(feature = "try_trait_v2", issue = "84277")] | |
| 195 | pub use self::try_trait::{FromResidual, Try}; | |
| 213 | 196 | #[unstable(feature = "coerce_unsized", issue = "18598")] |
| 214 | 197 | pub use self::unsize::CoerceUnsized; |
| 215 | ||
| 216 | 198 | #[unstable(feature = "dispatch_from_dyn", issue = "none")] |
| 217 | 199 | pub use self::unsize::DispatchFromDyn; |
| 218 | ||
| 219 | #[unstable(feature = "control_flow_enum", reason = "new API", issue = "75744")] | |
| 220 | pub use self::control_flow::ControlFlow; |
library/core/src/option.rs+2-5| ... | ... | @@ -557,13 +557,10 @@ |
| 557 | 557 | #![stable(feature = "rust1", since = "1.0.0")] |
| 558 | 558 | |
| 559 | 559 | use crate::iter::{self, FusedIterator, TrustedLen}; |
| 560 | use crate::ops::{self, ControlFlow, Deref, DerefMut}; | |
| 560 | 561 | use crate::panicking::{panic, panic_display}; |
| 561 | 562 | use crate::pin::Pin; |
| 562 | use crate::{ | |
| 563 | cmp, convert, hint, mem, | |
| 564 | ops::{self, ControlFlow, Deref, DerefMut}, | |
| 565 | slice, | |
| 566 | }; | |
| 563 | use crate::{cmp, convert, hint, mem, slice}; | |
| 567 | 564 | |
| 568 | 565 | /// The `Option` type. See [the module level documentation](self) for more. |
| 569 | 566 | #[derive(Copy, Eq, Debug, Hash)] |
library/core/src/panic.rs+1-2| ... | ... | @@ -6,8 +6,6 @@ mod location; |
| 6 | 6 | mod panic_info; |
| 7 | 7 | mod unwind_safe; |
| 8 | 8 | |
| 9 | use crate::any::Any; | |
| 10 | ||
| 11 | 9 | #[stable(feature = "panic_hooks", since = "1.10.0")] |
| 12 | 10 | pub use self::location::Location; |
| 13 | 11 | #[stable(feature = "panic_hooks", since = "1.10.0")] |
| ... | ... | @@ -16,6 +14,7 @@ pub use self::panic_info::PanicInfo; |
| 16 | 14 | pub use self::panic_info::PanicMessage; |
| 17 | 15 | #[stable(feature = "catch_unwind", since = "1.9.0")] |
| 18 | 16 | pub use self::unwind_safe::{AssertUnwindSafe, RefUnwindSafe, UnwindSafe}; |
| 17 | use crate::any::Any; | |
| 19 | 18 | |
| 20 | 19 | #[doc(hidden)] |
| 21 | 20 | #[unstable(feature = "edition_panic", issue = "none", reason = "use panic!() instead")] |
library/core/src/pin.rs+1-3| ... | ... | @@ -920,11 +920,8 @@ |
| 920 | 920 | |
| 921 | 921 | #![stable(feature = "pin", since = "1.33.0")] |
| 922 | 922 | |
| 923 | use crate::cmp; | |
| 924 | use crate::fmt; | |
| 925 | 923 | use crate::hash::{Hash, Hasher}; |
| 926 | 924 | use crate::ops::{CoerceUnsized, Deref, DerefMut, DerefPure, DispatchFromDyn, Receiver}; |
| 927 | ||
| 928 | 925 | #[allow(unused_imports)] |
| 929 | 926 | use crate::{ |
| 930 | 927 | cell::{RefCell, UnsafeCell}, |
| ... | ... | @@ -932,6 +929,7 @@ use crate::{ |
| 932 | 929 | marker::PhantomPinned, |
| 933 | 930 | mem, ptr, |
| 934 | 931 | }; |
| 932 | use crate::{cmp, fmt}; | |
| 935 | 933 | |
| 936 | 934 | /// A pointer which pins its pointee in place. |
| 937 | 935 | /// |
library/core/src/ptr/metadata.rs+1-2| ... | ... | @@ -2,8 +2,7 @@ |
| 2 | 2 | |
| 3 | 3 | use crate::fmt; |
| 4 | 4 | use crate::hash::{Hash, Hasher}; |
| 5 | use crate::intrinsics::aggregate_raw_ptr; | |
| 6 | use crate::intrinsics::ptr_metadata; | |
| 5 | use crate::intrinsics::{aggregate_raw_ptr, ptr_metadata}; | |
| 7 | 6 | use crate::marker::Freeze; |
| 8 | 7 | use crate::ptr::NonNull; |
| 9 | 8 |
library/core/src/ptr/mod.rs+3-9| ... | ... | @@ -409,13 +409,9 @@ |
| 409 | 409 | #![allow(clippy::not_unsafe_ptr_arg_deref)] |
| 410 | 410 | |
| 411 | 411 | use crate::cmp::Ordering; |
| 412 | use crate::fmt; | |
| 413 | use crate::hash; | |
| 414 | use crate::intrinsics; | |
| 415 | 412 | use crate::marker::FnPtr; |
| 416 | use crate::ub_checks; | |
| 417 | ||
| 418 | 413 | use crate::mem::{self, MaybeUninit}; |
| 414 | use crate::{fmt, hash, intrinsics, ub_checks}; | |
| 419 | 415 | |
| 420 | 416 | mod alignment; |
| 421 | 417 | #[unstable(feature = "ptr_alignment_type", issue = "102070")] |
| ... | ... | @@ -423,12 +419,10 @@ pub use alignment::Alignment; |
| 423 | 419 | |
| 424 | 420 | #[stable(feature = "rust1", since = "1.0.0")] |
| 425 | 421 | #[doc(inline)] |
| 426 | pub use crate::intrinsics::copy_nonoverlapping; | |
| 427 | ||
| 422 | pub use crate::intrinsics::copy; | |
| 428 | 423 | #[stable(feature = "rust1", since = "1.0.0")] |
| 429 | 424 | #[doc(inline)] |
| 430 | pub use crate::intrinsics::copy; | |
| 431 | ||
| 425 | pub use crate::intrinsics::copy_nonoverlapping; | |
| 432 | 426 | #[stable(feature = "rust1", since = "1.0.0")] |
| 433 | 427 | #[doc(inline)] |
| 434 | 428 | pub use crate::intrinsics::write_bytes; |
library/core/src/ptr/non_null.rs+1-4| ... | ... | @@ -1,15 +1,12 @@ |
| 1 | 1 | use crate::cmp::Ordering; |
| 2 | use crate::fmt; | |
| 3 | use crate::hash; | |
| 4 | use crate::intrinsics; | |
| 5 | 2 | use crate::marker::Unsize; |
| 6 | 3 | use crate::mem::{MaybeUninit, SizedTypeProperties}; |
| 7 | 4 | use crate::num::NonZero; |
| 8 | 5 | use crate::ops::{CoerceUnsized, DispatchFromDyn}; |
| 9 | use crate::ptr; | |
| 10 | 6 | use crate::ptr::Unique; |
| 11 | 7 | use crate::slice::{self, SliceIndex}; |
| 12 | 8 | use crate::ub_checks::assert_unsafe_precondition; |
| 9 | use crate::{fmt, hash, intrinsics, ptr}; | |
| 13 | 10 | |
| 14 | 11 | /// `*mut T` but non-zero and [covariant]. |
| 15 | 12 | /// |
library/core/src/range.rs+2-4| ... | ... | @@ -25,15 +25,13 @@ mod iter; |
| 25 | 25 | pub mod legacy; |
| 26 | 26 | |
| 27 | 27 | #[doc(inline)] |
| 28 | pub use crate::ops::{Bound, OneSidedRange, RangeBounds, RangeFull, RangeTo, RangeToInclusive}; | |
| 29 | ||
| 28 | pub use iter::{IterRange, IterRangeFrom, IterRangeInclusive}; | |
| 30 | 29 | use Bound::{Excluded, Included, Unbounded}; |
| 31 | 30 | |
| 32 | 31 | #[doc(inline)] |
| 33 | 32 | pub use crate::iter::Step; |
| 34 | ||
| 35 | 33 | #[doc(inline)] |
| 36 | pub use iter::{IterRange, IterRangeFrom, IterRangeInclusive}; | |
| 34 | pub use crate::ops::{Bound, OneSidedRange, RangeBounds, RangeFull, RangeTo, RangeToInclusive}; | |
| 37 | 35 | |
| 38 | 36 | /// A (half-open) range bounded inclusively below and exclusively above |
| 39 | 37 | /// (`start..end` in a future edition). |
library/core/src/range/iter.rs+2-3| ... | ... | @@ -1,9 +1,8 @@ |
| 1 | use crate::num::NonZero; | |
| 2 | use crate::range::{legacy, Range, RangeFrom, RangeInclusive}; | |
| 3 | ||
| 4 | 1 | use crate::iter::{ |
| 5 | 2 | FusedIterator, Step, TrustedLen, TrustedRandomAccess, TrustedRandomAccessNoCoerce, TrustedStep, |
| 6 | 3 | }; |
| 4 | use crate::num::NonZero; | |
| 5 | use crate::range::{legacy, Range, RangeFrom, RangeInclusive}; | |
| 7 | 6 | |
| 8 | 7 | /// By-value [`Range`] iterator. |
| 9 | 8 | #[unstable(feature = "new_range_api", issue = "125687")] |
library/core/src/slice/ascii.rs+3-5| ... | ... | @@ -1,12 +1,10 @@ |
| 1 | 1 | //! Operations on ASCII `[u8]`. |
| 2 | 2 | |
| 3 | use crate::ascii; | |
| 4 | use crate::fmt::{self, Write}; | |
| 5 | use crate::iter; | |
| 6 | use crate::mem; | |
| 7 | use crate::ops; | |
| 8 | 3 | use core::ascii::EscapeDefault; |
| 9 | 4 | |
| 5 | use crate::fmt::{self, Write}; | |
| 6 | use crate::{ascii, iter, mem, ops}; | |
| 7 | ||
| 10 | 8 | #[cfg(not(test))] |
| 11 | 9 | impl [u8] { |
| 12 | 10 | /// Checks if all bytes in this slice are within the ASCII range. |
library/core/src/slice/cmp.rs+1-3| ... | ... | @@ -1,12 +1,10 @@ |
| 1 | 1 | //! Comparison traits for `[T]`. |
| 2 | 2 | |
| 3 | use super::{from_raw_parts, memchr}; | |
| 3 | 4 | use crate::cmp::{self, BytewiseEq, Ordering}; |
| 4 | 5 | use crate::intrinsics::compare_bytes; |
| 5 | 6 | use crate::mem; |
| 6 | 7 | |
| 7 | use super::from_raw_parts; | |
| 8 | use super::memchr; | |
| 9 | ||
| 10 | 8 | #[stable(feature = "rust1", since = "1.0.0")] |
| 11 | 9 | impl<T, U> PartialEq<[U]> for [T] |
| 12 | 10 | where |
library/core/src/slice/index.rs+1-2| ... | ... | @@ -1,9 +1,8 @@ |
| 1 | 1 | //! Indexing implementations for `[T]`. |
| 2 | 2 | |
| 3 | 3 | use crate::intrinsics::const_eval_select; |
| 4 | use crate::ops; | |
| 5 | use crate::range; | |
| 6 | 4 | use crate::ub_checks::assert_unsafe_precondition; |
| 5 | use crate::{ops, range}; | |
| 7 | 6 | |
| 8 | 7 | #[stable(feature = "rust1", since = "1.0.0")] |
| 9 | 8 | impl<T, I> ops::Index<I> for [T] |
library/core/src/slice/iter.rs+2-4| ... | ... | @@ -3,8 +3,7 @@ |
| 3 | 3 | #[macro_use] // import iterator! and forward_iterator! |
| 4 | 4 | mod macros; |
| 5 | 5 | |
| 6 | use crate::cmp; | |
| 7 | use crate::fmt; | |
| 6 | use super::{from_raw_parts, from_raw_parts_mut}; | |
| 8 | 7 | use crate::hint::assert_unchecked; |
| 9 | 8 | use crate::iter::{ |
| 10 | 9 | FusedIterator, TrustedLen, TrustedRandomAccess, TrustedRandomAccessNoCoerce, UncheckedIterator, |
| ... | ... | @@ -13,8 +12,7 @@ use crate::marker::PhantomData; |
| 13 | 12 | use crate::mem::{self, SizedTypeProperties}; |
| 14 | 13 | use crate::num::NonZero; |
| 15 | 14 | use crate::ptr::{self, without_provenance, without_provenance_mut, NonNull}; |
| 16 | ||
| 17 | use super::{from_raw_parts, from_raw_parts_mut}; | |
| 15 | use crate::{cmp, fmt}; | |
| 18 | 16 | |
| 19 | 17 | #[stable(feature = "boxed_slice_into_iter", since = "1.80.0")] |
| 20 | 18 | impl<T> !Iterator for [T] {} |
library/core/src/slice/mod.rs+21-38| ... | ... | @@ -7,16 +7,13 @@ |
| 7 | 7 | #![stable(feature = "rust1", since = "1.0.0")] |
| 8 | 8 | |
| 9 | 9 | use crate::cmp::Ordering::{self, Equal, Greater, Less}; |
| 10 | use crate::fmt; | |
| 11 | use crate::hint; | |
| 12 | 10 | use crate::intrinsics::{exact_div, unchecked_sub}; |
| 13 | 11 | use crate::mem::{self, SizedTypeProperties}; |
| 14 | 12 | use crate::num::NonZero; |
| 15 | 13 | use crate::ops::{Bound, OneSidedRange, Range, RangeBounds}; |
| 16 | use crate::ptr; | |
| 17 | 14 | use crate::simd::{self, Simd}; |
| 18 | use crate::slice; | |
| 19 | 15 | use crate::ub_checks::assert_unsafe_precondition; |
| 16 | use crate::{fmt, hint, ptr, slice}; | |
| 20 | 17 | |
| 21 | 18 | #[unstable( |
| 22 | 19 | feature = "slice_internals", |
| ... | ... | @@ -44,52 +41,38 @@ mod specialize; |
| 44 | 41 | #[unstable(feature = "str_internals", issue = "none")] |
| 45 | 42 | #[doc(hidden)] |
| 46 | 43 | pub use ascii::is_ascii_simple; |
| 47 | ||
| 44 | #[stable(feature = "inherent_ascii_escape", since = "1.60.0")] | |
| 45 | pub use ascii::EscapeAscii; | |
| 46 | #[stable(feature = "slice_get_slice", since = "1.28.0")] | |
| 47 | pub use index::SliceIndex; | |
| 48 | #[unstable(feature = "slice_range", issue = "76393")] | |
| 49 | pub use index::{range, try_range}; | |
| 50 | #[unstable(feature = "array_windows", issue = "75027")] | |
| 51 | pub use iter::ArrayWindows; | |
| 52 | #[unstable(feature = "array_chunks", issue = "74985")] | |
| 53 | pub use iter::{ArrayChunks, ArrayChunksMut}; | |
| 54 | #[stable(feature = "slice_group_by", since = "1.77.0")] | |
| 55 | pub use iter::{ChunkBy, ChunkByMut}; | |
| 48 | 56 | #[stable(feature = "rust1", since = "1.0.0")] |
| 49 | 57 | pub use iter::{Chunks, ChunksMut, Windows}; |
| 50 | #[stable(feature = "rust1", since = "1.0.0")] | |
| 51 | pub use iter::{Iter, IterMut}; | |
| 52 | #[stable(feature = "rust1", since = "1.0.0")] | |
| 53 | pub use iter::{RSplitN, RSplitNMut, Split, SplitMut, SplitN, SplitNMut}; | |
| 54 | ||
| 55 | #[stable(feature = "slice_rsplit", since = "1.27.0")] | |
| 56 | pub use iter::{RSplit, RSplitMut}; | |
| 57 | ||
| 58 | 58 | #[stable(feature = "chunks_exact", since = "1.31.0")] |
| 59 | 59 | pub use iter::{ChunksExact, ChunksExactMut}; |
| 60 | ||
| 60 | #[stable(feature = "rust1", since = "1.0.0")] | |
| 61 | pub use iter::{Iter, IterMut}; | |
| 61 | 62 | #[stable(feature = "rchunks", since = "1.31.0")] |
| 62 | 63 | pub use iter::{RChunks, RChunksExact, RChunksExactMut, RChunksMut}; |
| 63 | ||
| 64 | #[unstable(feature = "array_chunks", issue = "74985")] | |
| 65 | pub use iter::{ArrayChunks, ArrayChunksMut}; | |
| 66 | ||
| 67 | #[unstable(feature = "array_windows", issue = "75027")] | |
| 68 | pub use iter::ArrayWindows; | |
| 69 | ||
| 70 | #[stable(feature = "slice_group_by", since = "1.77.0")] | |
| 71 | pub use iter::{ChunkBy, ChunkByMut}; | |
| 72 | ||
| 64 | #[stable(feature = "slice_rsplit", since = "1.27.0")] | |
| 65 | pub use iter::{RSplit, RSplitMut}; | |
| 66 | #[stable(feature = "rust1", since = "1.0.0")] | |
| 67 | pub use iter::{RSplitN, RSplitNMut, Split, SplitMut, SplitN, SplitNMut}; | |
| 73 | 68 | #[stable(feature = "split_inclusive", since = "1.51.0")] |
| 74 | 69 | pub use iter::{SplitInclusive, SplitInclusiveMut}; |
| 75 | ||
| 76 | #[stable(feature = "rust1", since = "1.0.0")] | |
| 77 | pub use raw::{from_raw_parts, from_raw_parts_mut}; | |
| 78 | ||
| 79 | 70 | #[stable(feature = "from_ref", since = "1.28.0")] |
| 80 | 71 | pub use raw::{from_mut, from_ref}; |
| 81 | ||
| 82 | 72 | #[unstable(feature = "slice_from_ptr_range", issue = "89792")] |
| 83 | 73 | pub use raw::{from_mut_ptr_range, from_ptr_range}; |
| 84 | ||
| 85 | #[stable(feature = "slice_get_slice", since = "1.28.0")] | |
| 86 | pub use index::SliceIndex; | |
| 87 | ||
| 88 | #[unstable(feature = "slice_range", issue = "76393")] | |
| 89 | pub use index::{range, try_range}; | |
| 90 | ||
| 91 | #[stable(feature = "inherent_ascii_escape", since = "1.60.0")] | |
| 92 | pub use ascii::EscapeAscii; | |
| 74 | #[stable(feature = "rust1", since = "1.0.0")] | |
| 75 | pub use raw::{from_raw_parts, from_raw_parts_mut}; | |
| 93 | 76 | |
| 94 | 77 | /// Calculates the direction and split point of a one-sided range. |
| 95 | 78 | /// |
library/core/src/slice/raw.rs+1-3| ... | ... | @@ -1,9 +1,7 @@ |
| 1 | 1 | //! Free functions to create `&[T]` and `&mut [T]`. |
| 2 | 2 | |
| 3 | use crate::array; | |
| 4 | 3 | use crate::ops::Range; |
| 5 | use crate::ptr; | |
| 6 | use crate::ub_checks; | |
| 4 | use crate::{array, ptr, ub_checks}; | |
| 7 | 5 | |
| 8 | 6 | /// Forms a slice from a pointer and a length. |
| 9 | 7 | /// |
library/core/src/slice/rotate.rs+1-2| ... | ... | @@ -1,6 +1,5 @@ |
| 1 | use crate::cmp; | |
| 2 | 1 | use crate::mem::{self, MaybeUninit, SizedTypeProperties}; |
| 3 | use crate::ptr; | |
| 2 | use crate::{cmp, ptr}; | |
| 4 | 3 | |
| 5 | 4 | /// Rotates the range `[mid-left, mid+right)` such that the element at `mid` becomes the first |
| 6 | 5 | /// element. Equivalently, rotates the range `left` elements to the left or `right` elements to the |
library/core/src/slice/sort/select.rs-1| ... | ... | @@ -7,7 +7,6 @@ |
| 7 | 7 | //! better performance than one would get using heapsort as fallback. |
| 8 | 8 | |
| 9 | 9 | use crate::mem::{self, SizedTypeProperties}; |
| 10 | ||
| 11 | 10 | use crate::slice::sort::shared::pivot::choose_pivot; |
| 12 | 11 | use crate::slice::sort::shared::smallsort::insertion_sort_shift_left; |
| 13 | 12 | use crate::slice::sort::unstable::quicksort::partition; |
library/core/src/slice/sort/shared/smallsort.rs+1-4| ... | ... | @@ -1,11 +1,8 @@ |
| 1 | 1 | //! This module contains a variety of sort implementations that are optimized for small lengths. |
| 2 | 2 | |
| 3 | use crate::intrinsics; | |
| 4 | 3 | use crate::mem::{self, ManuallyDrop, MaybeUninit}; |
| 5 | use crate::ptr; | |
| 6 | use crate::slice; | |
| 7 | ||
| 8 | 4 | use crate::slice::sort::shared::FreezeMarker; |
| 5 | use crate::{intrinsics, ptr, slice}; | |
| 9 | 6 | |
| 10 | 7 | // It's important to differentiate between SMALL_SORT_THRESHOLD performance for |
| 11 | 8 | // small slices and small-sort performance sorting small sub-slices as part of |
library/core/src/slice/sort/stable/drift.rs+1-3| ... | ... | @@ -1,14 +1,12 @@ |
| 1 | 1 | //! This module contains the hybrid top-level loop combining bottom-up Mergesort with top-down |
| 2 | 2 | //! Quicksort. |
| 3 | 3 | |
| 4 | use crate::cmp; | |
| 5 | use crate::intrinsics; | |
| 6 | 4 | use crate::mem::MaybeUninit; |
| 7 | ||
| 8 | 5 | use crate::slice::sort::shared::find_existing_run; |
| 9 | 6 | use crate::slice::sort::shared::smallsort::StableSmallSortTypeImpl; |
| 10 | 7 | use crate::slice::sort::stable::merge::merge; |
| 11 | 8 | use crate::slice::sort::stable::quicksort::quicksort; |
| 9 | use crate::{cmp, intrinsics}; | |
| 12 | 10 | |
| 13 | 11 | /// Sorts `v` based on comparison function `is_less`. If `eager_sort` is true, |
| 14 | 12 | /// it will only do small-sorts and physical merges, ensuring O(N * log(N)) |
library/core/src/slice/sort/stable/merge.rs+1-2| ... | ... | @@ -1,8 +1,7 @@ |
| 1 | 1 | //! This module contains logic for performing a merge of two sorted sub-slices. |
| 2 | 2 | |
| 3 | use crate::cmp; | |
| 4 | 3 | use crate::mem::MaybeUninit; |
| 5 | use crate::ptr; | |
| 4 | use crate::{cmp, ptr}; | |
| 6 | 5 | |
| 7 | 6 | /// Merges non-decreasing runs `v[..mid]` and `v[mid..]` using `scratch` as |
| 8 | 7 | /// temporary storage, and stores the result into `v[..]`. |
library/core/src/slice/sort/stable/mod.rs+1-3| ... | ... | @@ -1,12 +1,10 @@ |
| 1 | 1 | //! This module contains the entry points for `slice::sort`. |
| 2 | 2 | |
| 3 | use crate::cmp; | |
| 4 | use crate::intrinsics; | |
| 5 | 3 | use crate::mem::{self, MaybeUninit, SizedTypeProperties}; |
| 6 | ||
| 7 | 4 | use crate::slice::sort::shared::smallsort::{ |
| 8 | 5 | insertion_sort_shift_left, StableSmallSortTypeImpl, SMALL_SORT_GENERAL_SCRATCH_LEN, |
| 9 | 6 | }; |
| 7 | use crate::{cmp, intrinsics}; | |
| 10 | 8 | |
| 11 | 9 | pub(crate) mod drift; |
| 12 | 10 | pub(crate) mod merge; |
library/core/src/slice/sort/stable/quicksort.rs+1-3| ... | ... | @@ -1,12 +1,10 @@ |
| 1 | 1 | //! This module contains a stable quicksort and partition implementation. |
| 2 | 2 | |
| 3 | use crate::intrinsics; | |
| 4 | 3 | use crate::mem::{self, ManuallyDrop, MaybeUninit}; |
| 5 | use crate::ptr; | |
| 6 | ||
| 7 | 4 | use crate::slice::sort::shared::pivot::choose_pivot; |
| 8 | 5 | use crate::slice::sort::shared::smallsort::StableSmallSortTypeImpl; |
| 9 | 6 | use crate::slice::sort::shared::FreezeMarker; |
| 7 | use crate::{intrinsics, ptr}; | |
| 10 | 8 | |
| 11 | 9 | /// Sorts `v` recursively using quicksort. |
| 12 | 10 | /// |
library/core/src/slice/sort/unstable/heapsort.rs+1-2| ... | ... | @@ -1,7 +1,6 @@ |
| 1 | 1 | //! This module contains a branchless heapsort as fallback for unstable quicksort. |
| 2 | 2 | |
| 3 | use crate::intrinsics; | |
| 4 | use crate::ptr; | |
| 3 | use crate::{intrinsics, ptr}; | |
| 5 | 4 | |
| 6 | 5 | /// Sorts `v` using heapsort, which guarantees *O*(*n* \* log(*n*)) worst-case. |
| 7 | 6 | /// |
library/core/src/slice/sort/unstable/mod.rs-1| ... | ... | @@ -2,7 +2,6 @@ |
| 2 | 2 | |
| 3 | 3 | use crate::intrinsics; |
| 4 | 4 | use crate::mem::SizedTypeProperties; |
| 5 | ||
| 6 | 5 | use crate::slice::sort::shared::find_existing_run; |
| 7 | 6 | use crate::slice::sort::shared::smallsort::insertion_sort_shift_left; |
| 8 | 7 |
library/core/src/slice/sort/unstable/quicksort.rs+1-3| ... | ... | @@ -1,11 +1,9 @@ |
| 1 | 1 | //! This module contains an unstable quicksort and two partition implementations. |
| 2 | 2 | |
| 3 | use crate::intrinsics; | |
| 4 | 3 | use crate::mem::{self, ManuallyDrop}; |
| 5 | use crate::ptr; | |
| 6 | ||
| 7 | 4 | use crate::slice::sort::shared::pivot::choose_pivot; |
| 8 | 5 | use crate::slice::sort::shared::smallsort::UnstableSmallSortTypeImpl; |
| 6 | use crate::{intrinsics, ptr}; | |
| 9 | 7 | |
| 10 | 8 | /// Sorts `v` recursively. |
| 11 | 9 | /// |
library/core/src/str/converts.rs+1-2| ... | ... | @@ -1,9 +1,8 @@ |
| 1 | 1 | //! Ways to create a `str` from bytes slice. |
| 2 | 2 | |
| 3 | use crate::{mem, ptr}; | |
| 4 | ||
| 5 | 3 | use super::validations::run_utf8_validation; |
| 6 | 4 | use super::Utf8Error; |
| 5 | use crate::{mem, ptr}; | |
| 7 | 6 | |
| 8 | 7 | /// Converts a slice of bytes to a string slice. |
| 9 | 8 | /// |
library/core/src/str/iter.rs+11-14| ... | ... | @@ -1,23 +1,20 @@ |
| 1 | 1 | //! Iterators for `str` methods. |
| 2 | 2 | |
| 3 | use crate::char as char_mod; | |
| 3 | use super::pattern::{DoubleEndedSearcher, Pattern, ReverseSearcher, Searcher}; | |
| 4 | use super::validations::{next_code_point, next_code_point_reverse}; | |
| 5 | use super::{ | |
| 6 | from_utf8_unchecked, BytesIsNotEmpty, CharEscapeDebugContinue, CharEscapeDefault, | |
| 7 | CharEscapeUnicode, IsAsciiWhitespace, IsNotEmpty, IsWhitespace, LinesMap, UnsafeBytesToStr, | |
| 8 | }; | |
| 4 | 9 | use crate::fmt::{self, Write}; |
| 5 | use crate::iter::{Chain, FlatMap, Flatten}; | |
| 6 | use crate::iter::{Copied, Filter, FusedIterator, Map, TrustedLen}; | |
| 7 | use crate::iter::{TrustedRandomAccess, TrustedRandomAccessNoCoerce}; | |
| 10 | use crate::iter::{ | |
| 11 | Chain, Copied, Filter, FlatMap, Flatten, FusedIterator, Map, TrustedLen, TrustedRandomAccess, | |
| 12 | TrustedRandomAccessNoCoerce, | |
| 13 | }; | |
| 8 | 14 | use crate::num::NonZero; |
| 9 | 15 | use crate::ops::Try; |
| 10 | use crate::option; | |
| 11 | 16 | use crate::slice::{self, Split as SliceSplit}; |
| 12 | ||
| 13 | use super::from_utf8_unchecked; | |
| 14 | use super::pattern::Pattern; | |
| 15 | use super::pattern::{DoubleEndedSearcher, ReverseSearcher, Searcher}; | |
| 16 | use super::validations::{next_code_point, next_code_point_reverse}; | |
| 17 | use super::LinesMap; | |
| 18 | use super::{BytesIsNotEmpty, UnsafeBytesToStr}; | |
| 19 | use super::{CharEscapeDebugContinue, CharEscapeDefault, CharEscapeUnicode}; | |
| 20 | use super::{IsAsciiWhitespace, IsNotEmpty, IsWhitespace}; | |
| 17 | use crate::{char as char_mod, option}; | |
| 21 | 18 | |
| 22 | 19 | /// An iterator over the [`char`]s of a string slice. |
| 23 | 20 | /// |
library/core/src/str/lossy.rs+3-5| ... | ... | @@ -1,10 +1,8 @@ |
| 1 | use crate::fmt; | |
| 2 | use crate::fmt::Formatter; | |
| 3 | use crate::fmt::Write; | |
| 4 | use crate::iter::FusedIterator; | |
| 5 | ||
| 6 | 1 | use super::from_utf8_unchecked; |
| 7 | 2 | use super::validations::utf8_char_width; |
| 3 | use crate::fmt; | |
| 4 | use crate::fmt::{Formatter, Write}; | |
| 5 | use crate::iter::FusedIterator; | |
| 8 | 6 | |
| 9 | 7 | impl [u8] { |
| 10 | 8 | /// Creates an iterator over the contiguous valid UTF-8 ranges of this |
library/core/src/str/mod.rs+23-45| ... | ... | @@ -13,74 +13,52 @@ mod iter; |
| 13 | 13 | mod traits; |
| 14 | 14 | mod validations; |
| 15 | 15 | |
| 16 | use self::pattern::Pattern; | |
| 17 | use self::pattern::{DoubleEndedSearcher, ReverseSearcher, Searcher}; | |
| 18 | ||
| 19 | use crate::ascii; | |
| 16 | use self::pattern::{DoubleEndedSearcher, Pattern, ReverseSearcher, Searcher}; | |
| 20 | 17 | use crate::char::{self, EscapeDebugExtArgs}; |
| 21 | use crate::mem; | |
| 22 | 18 | use crate::ops::Range; |
| 23 | 19 | use crate::slice::{self, SliceIndex}; |
| 20 | use crate::{ascii, mem}; | |
| 24 | 21 | |
| 25 | 22 | pub mod pattern; |
| 26 | 23 | |
| 27 | 24 | mod lossy; |
| 28 | #[stable(feature = "utf8_chunks", since = "1.79.0")] | |
| 29 | pub use lossy::{Utf8Chunk, Utf8Chunks}; | |
| 30 | ||
| 25 | #[unstable(feature = "str_from_raw_parts", issue = "119206")] | |
| 26 | pub use converts::{from_raw_parts, from_raw_parts_mut}; | |
| 31 | 27 | #[stable(feature = "rust1", since = "1.0.0")] |
| 32 | 28 | pub use converts::{from_utf8, from_utf8_unchecked}; |
| 33 | ||
| 34 | 29 | #[stable(feature = "str_mut_extras", since = "1.20.0")] |
| 35 | 30 | pub use converts::{from_utf8_mut, from_utf8_unchecked_mut}; |
| 36 | ||
| 37 | #[unstable(feature = "str_from_raw_parts", issue = "119206")] | |
| 38 | pub use converts::{from_raw_parts, from_raw_parts_mut}; | |
| 39 | ||
| 40 | 31 | #[stable(feature = "rust1", since = "1.0.0")] |
| 41 | 32 | pub use error::{ParseBoolError, Utf8Error}; |
| 42 | ||
| 43 | #[stable(feature = "rust1", since = "1.0.0")] | |
| 44 | pub use traits::FromStr; | |
| 45 | ||
| 46 | #[stable(feature = "rust1", since = "1.0.0")] | |
| 47 | pub use iter::{Bytes, CharIndices, Chars, Lines, SplitWhitespace}; | |
| 48 | ||
| 33 | #[stable(feature = "encode_utf16", since = "1.8.0")] | |
| 34 | pub use iter::EncodeUtf16; | |
| 49 | 35 | #[stable(feature = "rust1", since = "1.0.0")] |
| 50 | 36 | #[allow(deprecated)] |
| 51 | 37 | pub use iter::LinesAny; |
| 52 | ||
| 53 | #[stable(feature = "rust1", since = "1.0.0")] | |
| 54 | pub use iter::{RSplit, RSplitTerminator, Split, SplitTerminator}; | |
| 55 | ||
| 56 | #[stable(feature = "rust1", since = "1.0.0")] | |
| 57 | pub use iter::{RSplitN, SplitN}; | |
| 58 | ||
| 59 | #[stable(feature = "str_matches", since = "1.2.0")] | |
| 60 | pub use iter::{Matches, RMatches}; | |
| 61 | ||
| 62 | #[stable(feature = "str_match_indices", since = "1.5.0")] | |
| 63 | pub use iter::{MatchIndices, RMatchIndices}; | |
| 64 | ||
| 65 | #[stable(feature = "encode_utf16", since = "1.8.0")] | |
| 66 | pub use iter::EncodeUtf16; | |
| 67 | ||
| 68 | #[stable(feature = "str_escape", since = "1.34.0")] | |
| 69 | pub use iter::{EscapeDebug, EscapeDefault, EscapeUnicode}; | |
| 70 | ||
| 71 | 38 | #[stable(feature = "split_ascii_whitespace", since = "1.34.0")] |
| 72 | 39 | pub use iter::SplitAsciiWhitespace; |
| 73 | ||
| 74 | 40 | #[stable(feature = "split_inclusive", since = "1.51.0")] |
| 75 | 41 | pub use iter::SplitInclusive; |
| 76 | ||
| 42 | #[stable(feature = "rust1", since = "1.0.0")] | |
| 43 | pub use iter::{Bytes, CharIndices, Chars, Lines, SplitWhitespace}; | |
| 44 | #[stable(feature = "str_escape", since = "1.34.0")] | |
| 45 | pub use iter::{EscapeDebug, EscapeDefault, EscapeUnicode}; | |
| 46 | #[stable(feature = "str_match_indices", since = "1.5.0")] | |
| 47 | pub use iter::{MatchIndices, RMatchIndices}; | |
| 48 | use iter::{MatchIndicesInternal, MatchesInternal, SplitInternal, SplitNInternal}; | |
| 49 | #[stable(feature = "str_matches", since = "1.2.0")] | |
| 50 | pub use iter::{Matches, RMatches}; | |
| 51 | #[stable(feature = "rust1", since = "1.0.0")] | |
| 52 | pub use iter::{RSplit, RSplitTerminator, Split, SplitTerminator}; | |
| 53 | #[stable(feature = "rust1", since = "1.0.0")] | |
| 54 | pub use iter::{RSplitN, SplitN}; | |
| 55 | #[stable(feature = "utf8_chunks", since = "1.79.0")] | |
| 56 | pub use lossy::{Utf8Chunk, Utf8Chunks}; | |
| 57 | #[stable(feature = "rust1", since = "1.0.0")] | |
| 58 | pub use traits::FromStr; | |
| 77 | 59 | #[unstable(feature = "str_internals", issue = "none")] |
| 78 | 60 | pub use validations::{next_code_point, utf8_char_width}; |
| 79 | 61 | |
| 80 | use iter::MatchIndicesInternal; | |
| 81 | use iter::SplitInternal; | |
| 82 | use iter::{MatchesInternal, SplitNInternal}; | |
| 83 | ||
| 84 | 62 | #[inline(never)] |
| 85 | 63 | #[cold] |
| 86 | 64 | #[track_caller] |
library/core/src/str/pattern.rs+2-4| ... | ... | @@ -38,11 +38,10 @@ |
| 38 | 38 | issue = "27721" |
| 39 | 39 | )] |
| 40 | 40 | |
| 41 | use crate::cmp; | |
| 42 | 41 | use crate::cmp::Ordering; |
| 43 | 42 | use crate::convert::TryInto as _; |
| 44 | use crate::fmt; | |
| 45 | 43 | use crate::slice::memchr; |
| 44 | use crate::{cmp, fmt}; | |
| 46 | 45 | |
| 47 | 46 | // Pattern |
| 48 | 47 | |
| ... | ... | @@ -1759,8 +1758,7 @@ fn simd_contains(needle: &str, haystack: &str) -> Option<bool> { |
| 1759 | 1758 | |
| 1760 | 1759 | use crate::ops::BitAnd; |
| 1761 | 1760 | use crate::simd::cmp::SimdPartialEq; |
| 1762 | use crate::simd::mask8x16 as Mask; | |
| 1763 | use crate::simd::u8x16 as Block; | |
| 1761 | use crate::simd::{mask8x16 as Mask, u8x16 as Block}; | |
| 1764 | 1762 | |
| 1765 | 1763 | let first_probe = needle[0]; |
| 1766 | 1764 | let last_byte_offset = needle.len() - 1; |
library/core/src/str/traits.rs+2-5| ... | ... | @@ -1,14 +1,11 @@ |
| 1 | 1 | //! Trait implementations for `str`. |
| 2 | 2 | |
| 3 | use super::ParseBoolError; | |
| 3 | 4 | use crate::cmp::Ordering; |
| 4 | 5 | use crate::intrinsics::unchecked_sub; |
| 5 | use crate::ops; | |
| 6 | use crate::ptr; | |
| 7 | use crate::range; | |
| 8 | 6 | use crate::slice::SliceIndex; |
| 9 | 7 | use crate::ub_checks::assert_unsafe_precondition; |
| 10 | ||
| 11 | use super::ParseBoolError; | |
| 8 | use crate::{ops, ptr, range}; | |
| 12 | 9 | |
| 13 | 10 | /// Implements ordering of strings. |
| 14 | 11 | /// |
library/core/src/str/validations.rs+1-2| ... | ... | @@ -1,8 +1,7 @@ |
| 1 | 1 | //! Operations related to UTF-8 validation. |
| 2 | 2 | |
| 3 | use crate::mem; | |
| 4 | ||
| 5 | 3 | use super::Utf8Error; |
| 4 | use crate::mem; | |
| 6 | 5 | |
| 7 | 6 | /// Returns the initial codepoint accumulator for the first byte. |
| 8 | 7 | /// The first byte is special, only want bottom 5 bits for width 2, 4 bits |
library/core/src/sync/atomic.rs+1-4| ... | ... | @@ -223,12 +223,9 @@ |
| 223 | 223 | #![allow(clippy::not_unsafe_ptr_arg_deref)] |
| 224 | 224 | |
| 225 | 225 | use self::Ordering::*; |
| 226 | ||
| 227 | 226 | use crate::cell::UnsafeCell; |
| 228 | use crate::fmt; | |
| 229 | use crate::intrinsics; | |
| 230 | ||
| 231 | 227 | use crate::hint::spin_loop; |
| 228 | use crate::{fmt, intrinsics}; | |
| 232 | 229 | |
| 233 | 230 | // Some architectures don't have byte-sized atomics, which results in LLVM |
| 234 | 231 | // emulating them using a LL/SC loop. However for AtomicBool we can take |
library/core/src/task/wake.rs+1-2| ... | ... | @@ -1,11 +1,10 @@ |
| 1 | 1 | #![stable(feature = "futures_api", since = "1.36.0")] |
| 2 | 2 | |
| 3 | 3 | use crate::any::Any; |
| 4 | use crate::fmt; | |
| 5 | 4 | use crate::marker::PhantomData; |
| 6 | 5 | use crate::mem::{transmute, ManuallyDrop}; |
| 7 | 6 | use crate::panic::AssertUnwindSafe; |
| 8 | use crate::ptr; | |
| 7 | use crate::{fmt, ptr}; | |
| 9 | 8 | |
| 10 | 9 | /// A `RawWaker` allows the implementor of a task executor to create a [`Waker`] |
| 11 | 10 | /// or a [`LocalWaker`] which provides customized wakeup behavior. |
library/core/src/tuple.rs+1-3| ... | ... | @@ -1,9 +1,7 @@ |
| 1 | 1 | // See core/src/primitive_docs.rs for documentation. |
| 2 | 2 | |
| 3 | 3 | use crate::cmp::Ordering::{self, *}; |
| 4 | use crate::marker::ConstParamTy_; | |
| 5 | use crate::marker::StructuralPartialEq; | |
| 6 | use crate::marker::UnsizedConstParamTy; | |
| 4 | use crate::marker::{ConstParamTy_, StructuralPartialEq, UnsizedConstParamTy}; | |
| 7 | 5 | |
| 8 | 6 | // Recursive macro for implementing n-ary tuple functions and operations |
| 9 | 7 | // |
library/core/src/ub_checks.rs-1| ... | ... | @@ -81,7 +81,6 @@ macro_rules! assert_unsafe_precondition { |
| 81 | 81 | } |
| 82 | 82 | #[unstable(feature = "ub_checks", issue = "none")] |
| 83 | 83 | pub use assert_unsafe_precondition; |
| 84 | ||
| 85 | 84 | /// Checking library UB is always enabled when UB-checking is done |
| 86 | 85 | /// (and we use a reexport so that there is no unnecessary wrapper function). |
| 87 | 86 | #[unstable(feature = "ub_checks", issue = "none")] |
library/core/tests/array.rs+2-1| ... | ... | @@ -259,7 +259,8 @@ fn iterator_drops() { |
| 259 | 259 | #[test] |
| 260 | 260 | #[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")] |
| 261 | 261 | fn array_default_impl_avoids_leaks_on_panic() { |
| 262 | use core::sync::atomic::{AtomicUsize, Ordering::Relaxed}; | |
| 262 | use core::sync::atomic::AtomicUsize; | |
| 263 | use core::sync::atomic::Ordering::Relaxed; | |
| 263 | 264 | static COUNTER: AtomicUsize = AtomicUsize::new(0); |
| 264 | 265 | #[derive(Debug)] |
| 265 | 266 | struct Bomb(#[allow(dead_code)] usize); |
library/core/tests/clone.rs+2-1| ... | ... | @@ -36,7 +36,8 @@ fn test_clone_to_uninit_slice_success() { |
| 36 | 36 | #[test] |
| 37 | 37 | #[cfg(panic = "unwind")] |
| 38 | 38 | fn test_clone_to_uninit_slice_drops_on_panic() { |
| 39 | use core::sync::atomic::{AtomicUsize, Ordering::Relaxed}; | |
| 39 | use core::sync::atomic::AtomicUsize; | |
| 40 | use core::sync::atomic::Ordering::Relaxed; | |
| 40 | 41 | |
| 41 | 42 | /// A static counter is OK to use as long as _this one test_ isn't run several times in |
| 42 | 43 | /// multiple threads. |
library/core/tests/cmp.rs+2-4| ... | ... | @@ -1,7 +1,5 @@ |
| 1 | use core::cmp::{ | |
| 2 | self, | |
| 3 | Ordering::{self, *}, | |
| 4 | }; | |
| 1 | use core::cmp::Ordering::{self, *}; | |
| 2 | use core::cmp::{self}; | |
| 5 | 3 | |
| 6 | 4 | #[test] |
| 7 | 5 | fn test_int_totalord() { |
library/core/tests/hash/sip.rs+1-2| ... | ... | @@ -1,7 +1,6 @@ |
| 1 | 1 | #![allow(deprecated)] |
| 2 | 2 | |
| 3 | use core::hash::{Hash, Hasher}; | |
| 4 | use core::hash::{SipHasher, SipHasher13}; | |
| 3 | use core::hash::{Hash, Hasher, SipHasher, SipHasher13}; | |
| 5 | 4 | use core::{mem, slice}; |
| 6 | 5 | |
| 7 | 6 | // Hash just the bytes of the slice, without length prefix |
library/core/tests/iter/adapters/chain.rs+2-1| ... | ... | @@ -1,7 +1,8 @@ |
| 1 | use super::*; | |
| 2 | 1 | use core::iter::*; |
| 3 | 2 | use core::num::NonZero; |
| 4 | 3 | |
| 4 | use super::*; | |
| 5 | ||
| 5 | 6 | #[test] |
| 6 | 7 | fn test_chain() { |
| 7 | 8 | let xs = [0, 1, 2, 3, 4, 5]; |
library/core/tests/iter/adapters/flatten.rs+2-1| ... | ... | @@ -1,8 +1,9 @@ |
| 1 | use super::*; | |
| 2 | 1 | use core::assert_eq; |
| 3 | 2 | use core::iter::*; |
| 4 | 3 | use core::num::NonZero; |
| 5 | 4 | |
| 5 | use super::*; | |
| 6 | ||
| 6 | 7 | #[test] |
| 7 | 8 | fn test_iterator_flatten() { |
| 8 | 9 | let xs = [0, 3, 6]; |
library/core/tests/iter/adapters/map_windows.rs+4-2| ... | ... | @@ -1,10 +1,12 @@ |
| 1 | use std::sync::atomic::{AtomicUsize, Ordering::SeqCst}; | |
| 1 | use std::sync::atomic::AtomicUsize; | |
| 2 | use std::sync::atomic::Ordering::SeqCst; | |
| 2 | 3 | |
| 3 | 4 | #[cfg(not(panic = "abort"))] |
| 4 | 5 | mod drop_checks { |
| 5 | 6 | //! These tests mainly make sure the elements are correctly dropped. |
| 6 | 7 | |
| 7 | use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering::SeqCst}; | |
| 8 | use std::sync::atomic::Ordering::SeqCst; | |
| 9 | use std::sync::atomic::{AtomicBool, AtomicUsize}; | |
| 8 | 10 | |
| 9 | 11 | #[derive(Debug)] |
| 10 | 12 | struct DropInfo { |
library/core/tests/iter/adapters/peekable.rs+2-1| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | use super::*; | |
| 2 | 1 | use core::iter::*; |
| 3 | 2 | |
| 3 | use super::*; | |
| 4 | ||
| 4 | 5 | #[test] |
| 5 | 6 | fn test_iterator_peekable() { |
| 6 | 7 | let xs = vec![0, 1, 2, 3, 4, 5]; |
library/core/tests/iter/adapters/zip.rs+3-3| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | use super::*; | |
| 2 | 1 | use core::iter::*; |
| 3 | 2 | |
| 3 | use super::*; | |
| 4 | ||
| 4 | 5 | #[test] |
| 5 | 6 | fn test_zip_nth() { |
| 6 | 7 | let xs = [0, 1, 2, 4, 5]; |
| ... | ... | @@ -239,8 +240,7 @@ fn test_zip_trusted_random_access_composition() { |
| 239 | 240 | #[test] |
| 240 | 241 | #[cfg(panic = "unwind")] |
| 241 | 242 | fn test_zip_trusted_random_access_next_back_drop() { |
| 242 | use std::panic::catch_unwind; | |
| 243 | use std::panic::AssertUnwindSafe; | |
| 243 | use std::panic::{catch_unwind, AssertUnwindSafe}; | |
| 244 | 244 | |
| 245 | 245 | let mut counter = 0; |
| 246 | 246 |
library/core/tests/iter/range.rs+2-1| ... | ... | @@ -1,7 +1,8 @@ |
| 1 | use super::*; | |
| 2 | 1 | use core::ascii::Char as AsciiChar; |
| 3 | 2 | use core::num::NonZero; |
| 4 | 3 | |
| 4 | use super::*; | |
| 5 | ||
| 5 | 6 | #[test] |
| 6 | 7 | fn test_range() { |
| 7 | 8 | assert_eq!((0..5).collect::<Vec<_>>(), [0, 1, 2, 3, 4]); |
library/core/tests/iter/sources.rs+2-1| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | use super::*; | |
| 2 | 1 | use core::iter::*; |
| 3 | 2 | |
| 3 | use super::*; | |
| 4 | ||
| 4 | 5 | #[test] |
| 5 | 6 | fn test_repeat() { |
| 6 | 7 | let mut it = repeat(42); |
library/core/tests/lazy.rs+3-4| ... | ... | @@ -1,7 +1,6 @@ |
| 1 | use core::{ | |
| 2 | cell::{Cell, LazyCell, OnceCell}, | |
| 3 | sync::atomic::{AtomicUsize, Ordering::SeqCst}, | |
| 4 | }; | |
| 1 | use core::cell::{Cell, LazyCell, OnceCell}; | |
| 2 | use core::sync::atomic::AtomicUsize; | |
| 3 | use core::sync::atomic::Ordering::SeqCst; | |
| 5 | 4 | |
| 6 | 5 | #[test] |
| 7 | 6 | fn once_cell() { |
library/core/tests/mem.rs-1| ... | ... | @@ -1,6 +1,5 @@ |
| 1 | 1 | use core::mem::*; |
| 2 | 2 | use core::ptr; |
| 3 | ||
| 4 | 3 | #[cfg(panic = "unwind")] |
| 5 | 4 | use std::rc::Rc; |
| 6 | 5 |
library/core/tests/net/ip_addr.rs+2-1| ... | ... | @@ -1,9 +1,10 @@ |
| 1 | use super::{sa4, sa6}; | |
| 2 | 1 | use core::net::{ |
| 3 | 2 | IpAddr, Ipv4Addr, Ipv6Addr, Ipv6MulticastScope, SocketAddr, SocketAddrV4, SocketAddrV6, |
| 4 | 3 | }; |
| 5 | 4 | use core::str::FromStr; |
| 6 | 5 | |
| 6 | use super::{sa4, sa6}; | |
| 7 | ||
| 7 | 8 | #[test] |
| 8 | 9 | fn test_from_str_ipv4() { |
| 9 | 10 | assert_eq!(Ok(Ipv4Addr::new(127, 0, 0, 1)), "127.0.0.1".parse()); |
library/core/tests/num/flt2dec/mod.rs+4-6| ... | ... | @@ -1,12 +1,10 @@ |
| 1 | use std::mem::MaybeUninit; | |
| 2 | use std::{fmt, str}; | |
| 3 | ||
| 4 | use core::num::flt2dec::{decode, DecodableFloat, Decoded, FullDecoded}; | |
| 5 | use core::num::flt2dec::{round_up, Sign, MAX_SIG_DIGITS}; | |
| 6 | 1 | use core::num::flt2dec::{ |
| 7 | to_exact_exp_str, to_exact_fixed_str, to_shortest_exp_str, to_shortest_str, | |
| 2 | decode, round_up, to_exact_exp_str, to_exact_fixed_str, to_shortest_exp_str, to_shortest_str, | |
| 3 | DecodableFloat, Decoded, FullDecoded, Sign, MAX_SIG_DIGITS, | |
| 8 | 4 | }; |
| 9 | 5 | use core::num::fmt::{Formatted, Part}; |
| 6 | use std::mem::MaybeUninit; | |
| 7 | use std::{fmt, str}; | |
| 10 | 8 | |
| 11 | 9 | mod estimator; |
| 12 | 10 | mod strategy { |
library/core/tests/num/flt2dec/random.rs+2-5| ... | ... | @@ -1,13 +1,10 @@ |
| 1 | 1 | #![cfg(not(target_arch = "wasm32"))] |
| 2 | 2 | |
| 3 | use core::num::flt2dec::strategy::grisu::{format_exact_opt, format_shortest_opt}; | |
| 4 | use core::num::flt2dec::{decode, DecodableFloat, Decoded, FullDecoded, MAX_SIG_DIGITS}; | |
| 3 | 5 | use std::mem::MaybeUninit; |
| 4 | 6 | use std::str; |
| 5 | 7 | |
| 6 | use core::num::flt2dec::strategy::grisu::format_exact_opt; | |
| 7 | use core::num::flt2dec::strategy::grisu::format_shortest_opt; | |
| 8 | use core::num::flt2dec::MAX_SIG_DIGITS; | |
| 9 | use core::num::flt2dec::{decode, DecodableFloat, Decoded, FullDecoded}; | |
| 10 | ||
| 11 | 8 | use rand::distributions::{Distribution, Uniform}; |
| 12 | 9 | |
| 13 | 10 | pub fn decode_finite<T: DecodableFloat>(v: T) -> Decoded { |
library/core/tests/num/flt2dec/strategy/dragon.rs+2-1| ... | ... | @@ -1,7 +1,8 @@ |
| 1 | use super::super::*; | |
| 2 | 1 | use core::num::bignum::Big32x40 as Big; |
| 3 | 2 | use core::num::flt2dec::strategy::dragon::*; |
| 4 | 3 | |
| 4 | use super::super::*; | |
| 5 | ||
| 5 | 6 | #[test] |
| 6 | 7 | fn test_mul_pow10() { |
| 7 | 8 | let mut prevpow10 = Big::from_small(1); |
library/core/tests/num/flt2dec/strategy/grisu.rs+2-1| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | use super::super::*; | |
| 2 | 1 | use core::num::flt2dec::strategy::grisu::*; |
| 3 | 2 | |
| 3 | use super::super::*; | |
| 4 | ||
| 4 | 5 | #[test] |
| 5 | 6 | #[cfg_attr(miri, ignore)] // Miri is too slow |
| 6 | 7 | fn test_cached_power() { |
library/core/tests/ops.rs+3-2| ... | ... | @@ -1,7 +1,8 @@ |
| 1 | 1 | mod control_flow; |
| 2 | 2 | |
| 3 | use core::ops::{Bound, Range, RangeFrom, RangeFull, RangeInclusive, RangeTo, RangeToInclusive}; | |
| 4 | use core::ops::{Deref, DerefMut}; | |
| 3 | use core::ops::{ | |
| 4 | Bound, Deref, DerefMut, Range, RangeFrom, RangeFull, RangeInclusive, RangeTo, RangeToInclusive, | |
| 5 | }; | |
| 5 | 6 | |
| 6 | 7 | // Test the Range structs and syntax. |
| 7 | 8 |
library/core/tests/pin_macro.rs+3-5| ... | ... | @@ -1,10 +1,8 @@ |
| 1 | 1 | // edition:2021 |
| 2 | 2 | |
| 3 | use core::{ | |
| 4 | marker::PhantomPinned, | |
| 5 | mem::{drop as stuff, transmute}, | |
| 6 | pin::{pin, Pin}, | |
| 7 | }; | |
| 3 | use core::marker::PhantomPinned; | |
| 4 | use core::mem::{drop as stuff, transmute}; | |
| 5 | use core::pin::{pin, Pin}; | |
| 8 | 6 | |
| 9 | 7 | #[test] |
| 10 | 8 | fn basic() { |
library/core/tests/result.rs+2-1| ... | ... | @@ -410,7 +410,8 @@ fn result_opt_conversions() { |
| 410 | 410 | #[test] |
| 411 | 411 | fn result_try_trait_v2_branch() { |
| 412 | 412 | use core::num::NonZero; |
| 413 | use core::ops::{ControlFlow::*, Try}; | |
| 413 | use core::ops::ControlFlow::*; | |
| 414 | use core::ops::Try; | |
| 414 | 415 | |
| 415 | 416 | assert_eq!(Ok::<i32, i32>(4).branch(), Continue(4)); |
| 416 | 417 | assert_eq!(Err::<i32, i32>(4).branch(), Break(Err(4))); |
library/core/tests/slice.rs+1| ... | ... | @@ -1856,6 +1856,7 @@ fn sort_unstable() { |
| 1856 | 1856 | #[cfg_attr(miri, ignore)] // Miri is too slow |
| 1857 | 1857 | fn select_nth_unstable() { |
| 1858 | 1858 | use core::cmp::Ordering::{Equal, Greater, Less}; |
| 1859 | ||
| 1859 | 1860 | use rand::seq::SliceRandom; |
| 1860 | 1861 | use rand::Rng; |
| 1861 | 1862 |
library/core/tests/waker.rs+3-5| ... | ... | @@ -23,11 +23,9 @@ static WAKER_VTABLE: RawWakerVTable = RawWakerVTable::new( |
| 23 | 23 | |
| 24 | 24 | // https://github.com/rust-lang/rust/issues/102012#issuecomment-1915282956 |
| 25 | 25 | mod nop_waker { |
| 26 | use core::{ | |
| 27 | future::{ready, Future}, | |
| 28 | pin::Pin, | |
| 29 | task::{Context, Poll, RawWaker, RawWakerVTable, Waker}, | |
| 30 | }; | |
| 26 | use core::future::{ready, Future}; | |
| 27 | use core::pin::Pin; | |
| 28 | use core::task::{Context, Poll, RawWaker, RawWakerVTable, Waker}; | |
| 31 | 29 | |
| 32 | 30 | const NOP_RAWWAKER: RawWaker = { |
| 33 | 31 | fn nop(_: *const ()) {} |
library/panic_unwind/src/emcc.rs+2-3| ... | ... | @@ -8,10 +8,9 @@ |
| 8 | 8 | |
| 9 | 9 | use alloc::boxed::Box; |
| 10 | 10 | use core::any::Any; |
| 11 | use core::intrinsics; | |
| 12 | use core::mem; | |
| 13 | use core::ptr; | |
| 14 | 11 | use core::sync::atomic::{AtomicBool, Ordering}; |
| 12 | use core::{intrinsics, mem, ptr}; | |
| 13 | ||
| 15 | 14 | use unwind as uw; |
| 16 | 15 | |
| 17 | 16 | // This matches the layout of std::type_info in C++ |
library/proc_macro/src/bridge/arena.rs+1-4| ... | ... | @@ -5,12 +5,9 @@ |
| 5 | 5 | //! being built at the same time as `std`. |
| 6 | 6 | |
| 7 | 7 | use std::cell::{Cell, RefCell}; |
| 8 | use std::cmp; | |
| 9 | 8 | use std::mem::MaybeUninit; |
| 10 | 9 | use std::ops::Range; |
| 11 | use std::ptr; | |
| 12 | use std::slice; | |
| 13 | use std::str; | |
| 10 | use std::{cmp, ptr, slice, str}; | |
| 14 | 11 | |
| 15 | 12 | // The arenas start with PAGE-sized chunks, and then each new chunk is twice as |
| 16 | 13 | // big as its predecessor, up until we reach HUGE_PAGE-sized chunks, whereupon |
library/proc_macro/src/bridge/client.rs+4-3| ... | ... | @@ -1,11 +1,11 @@ |
| 1 | 1 | //! Client-side types. |
| 2 | 2 | |
| 3 | use super::*; | |
| 4 | ||
| 5 | 3 | use std::cell::RefCell; |
| 6 | 4 | use std::marker::PhantomData; |
| 7 | 5 | use std::sync::atomic::AtomicU32; |
| 8 | 6 | |
| 7 | use super::*; | |
| 8 | ||
| 9 | 9 | macro_rules! define_client_handles { |
| 10 | 10 | ( |
| 11 | 11 | 'owned: $($oty:ident,)* |
| ... | ... | @@ -190,10 +190,11 @@ impl<'a> !Sync for Bridge<'a> {} |
| 190 | 190 | |
| 191 | 191 | #[allow(unsafe_code)] |
| 192 | 192 | mod state { |
| 193 | use super::Bridge; | |
| 194 | 193 | use std::cell::{Cell, RefCell}; |
| 195 | 194 | use std::ptr; |
| 196 | 195 | |
| 196 | use super::Bridge; | |
| 197 | ||
| 197 | 198 | thread_local! { |
| 198 | 199 | static BRIDGE_STATE: Cell<*const ()> = const { Cell::new(ptr::null()) }; |
| 199 | 200 | } |
library/proc_macro/src/bridge/fxhash.rs+1-2| ... | ... | @@ -5,8 +5,7 @@ |
| 5 | 5 | //! on the `rustc_hash` crate. |
| 6 | 6 | |
| 7 | 7 | use std::collections::HashMap; |
| 8 | use std::hash::BuildHasherDefault; | |
| 9 | use std::hash::Hasher; | |
| 8 | use std::hash::{BuildHasherDefault, Hasher}; | |
| 10 | 9 | use std::ops::BitXor; |
| 11 | 10 | |
| 12 | 11 | /// Type alias for a hashmap using the `fx` hash algorithm. |
library/proc_macro/src/bridge/mod.rs+4-8| ... | ... | @@ -8,16 +8,12 @@ |
| 8 | 8 | |
| 9 | 9 | #![deny(unsafe_code)] |
| 10 | 10 | |
| 11 | use crate::{Delimiter, Level, Spacing}; | |
| 12 | use std::fmt; | |
| 13 | 11 | use std::hash::Hash; |
| 14 | use std::marker; | |
| 15 | use std::mem; | |
| 16 | use std::ops::Bound; | |
| 17 | use std::ops::Range; | |
| 18 | use std::panic; | |
| 12 | use std::ops::{Bound, Range}; | |
| 19 | 13 | use std::sync::Once; |
| 20 | use std::thread; | |
| 14 | use std::{fmt, marker, mem, panic, thread}; | |
| 15 | ||
| 16 | use crate::{Delimiter, Level, Spacing}; | |
| 21 | 17 | |
| 22 | 18 | /// Higher-order macro describing the server RPC API, allowing automatic |
| 23 | 19 | /// generation of type-safe Rust APIs, both client-side and server-side. |
library/proc_macro/src/bridge/server.rs+2-2| ... | ... | @@ -1,10 +1,10 @@ |
| 1 | 1 | //! Server-side traits. |
| 2 | 2 | |
| 3 | use super::*; | |
| 4 | ||
| 5 | 3 | use std::cell::Cell; |
| 6 | 4 | use std::marker::PhantomData; |
| 7 | 5 | |
| 6 | use super::*; | |
| 7 | ||
| 8 | 8 | macro_rules! define_server_handles { |
| 9 | 9 | ( |
| 10 | 10 | 'owned: $($oty:ident,)* |
library/proc_macro/src/lib.rs+5-4| ... | ... | @@ -45,16 +45,17 @@ pub mod bridge; |
| 45 | 45 | mod diagnostic; |
| 46 | 46 | mod escape; |
| 47 | 47 | |
| 48 | #[unstable(feature = "proc_macro_diagnostic", issue = "54140")] | |
| 49 | pub use diagnostic::{Diagnostic, Level, MultiSpan}; | |
| 50 | ||
| 51 | use crate::escape::{escape_bytes, EscapeOptions}; | |
| 52 | 48 | use std::ffi::CStr; |
| 53 | 49 | use std::ops::{Range, RangeBounds}; |
| 54 | 50 | use std::path::PathBuf; |
| 55 | 51 | use std::str::FromStr; |
| 56 | 52 | use std::{error, fmt}; |
| 57 | 53 | |
| 54 | #[unstable(feature = "proc_macro_diagnostic", issue = "54140")] | |
| 55 | pub use diagnostic::{Diagnostic, Level, MultiSpan}; | |
| 56 | ||
| 57 | use crate::escape::{escape_bytes, EscapeOptions}; | |
| 58 | ||
| 58 | 59 | /// Determines whether proc_macro has been made accessible to the currently |
| 59 | 60 | /// running program. |
| 60 | 61 | /// |
library/std/benches/hash/map.rs+1| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | 1 | #![cfg(test)] |
| 2 | 2 | |
| 3 | 3 | use std::collections::HashMap; |
| 4 | ||
| 4 | 5 | use test::Bencher; |
| 5 | 6 | |
| 6 | 7 | #[bench] |
library/std/benches/hash/set_ops.rs+1| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | 1 | use std::collections::HashSet; |
| 2 | ||
| 2 | 3 | use test::Bencher; |
| 3 | 4 | |
| 4 | 5 | #[bench] |
library/std/src/alloc.rs+1-2| ... | ... | @@ -56,10 +56,9 @@ |
| 56 | 56 | #![deny(unsafe_op_in_unsafe_fn)] |
| 57 | 57 | #![stable(feature = "alloc_module", since = "1.28.0")] |
| 58 | 58 | |
| 59 | use core::hint; | |
| 60 | 59 | use core::ptr::NonNull; |
| 61 | 60 | use core::sync::atomic::{AtomicPtr, Ordering}; |
| 62 | use core::{mem, ptr}; | |
| 61 | use core::{hint, mem, ptr}; | |
| 63 | 62 | |
| 64 | 63 | #[stable(feature = "alloc_module", since = "1.28.0")] |
| 65 | 64 | #[doc(inline)] |
library/std/src/ascii.rs+2-3| ... | ... | @@ -13,11 +13,10 @@ |
| 13 | 13 | |
| 14 | 14 | #![stable(feature = "rust1", since = "1.0.0")] |
| 15 | 15 | |
| 16 | #[stable(feature = "rust1", since = "1.0.0")] | |
| 17 | pub use core::ascii::{escape_default, EscapeDefault}; | |
| 18 | ||
| 19 | 16 | #[unstable(feature = "ascii_char", issue = "110998")] |
| 20 | 17 | pub use core::ascii::Char; |
| 18 | #[stable(feature = "rust1", since = "1.0.0")] | |
| 19 | pub use core::ascii::{escape_default, EscapeDefault}; | |
| 21 | 20 | |
| 22 | 21 | /// Extension methods for ASCII-subset only operations. |
| 23 | 22 | /// |
library/std/src/backtrace.rs+3-3| ... | ... | @@ -89,13 +89,13 @@ mod tests; |
| 89 | 89 | // a backtrace or actually symbolizing it. |
| 90 | 90 | |
| 91 | 91 | use crate::backtrace_rs::{self, BytesOrWideString}; |
| 92 | use crate::env; | |
| 93 | 92 | use crate::ffi::c_void; |
| 94 | use crate::fmt; | |
| 95 | 93 | use crate::panic::UnwindSafe; |
| 96 | use crate::sync::atomic::{AtomicU8, Ordering::Relaxed}; | |
| 94 | use crate::sync::atomic::AtomicU8; | |
| 95 | use crate::sync::atomic::Ordering::Relaxed; | |
| 97 | 96 | use crate::sync::LazyLock; |
| 98 | 97 | use crate::sys::backtrace::{lock, output_filename, set_image_base}; |
| 98 | use crate::{env, fmt}; | |
| 99 | 99 | |
| 100 | 100 | /// A captured OS thread stack backtrace. |
| 101 | 101 | /// |
library/std/src/collections/hash/map.rs+2-4| ... | ... | @@ -1,13 +1,11 @@ |
| 1 | 1 | #[cfg(test)] |
| 2 | 2 | mod tests; |
| 3 | 3 | |
| 4 | use self::Entry::*; | |
| 5 | ||
| 6 | 4 | use hashbrown::hash_map as base; |
| 7 | 5 | |
| 6 | use self::Entry::*; | |
| 8 | 7 | use crate::borrow::Borrow; |
| 9 | use crate::collections::TryReserveError; | |
| 10 | use crate::collections::TryReserveErrorKind; | |
| 8 | use crate::collections::{TryReserveError, TryReserveErrorKind}; | |
| 11 | 9 | use crate::error::Error; |
| 12 | 10 | use crate::fmt::{self, Debug}; |
| 13 | 11 | use crate::hash::{BuildHasher, Hash, RandomState}; |
library/std/src/collections/hash/map/tests.rs+3-3| ... | ... | @@ -1,11 +1,12 @@ |
| 1 | use rand::Rng; | |
| 2 | use realstd::collections::TryReserveErrorKind::*; | |
| 3 | ||
| 1 | 4 | use super::Entry::{Occupied, Vacant}; |
| 2 | 5 | use super::HashMap; |
| 3 | 6 | use crate::assert_matches::assert_matches; |
| 4 | 7 | use crate::cell::RefCell; |
| 5 | 8 | use crate::hash::RandomState; |
| 6 | 9 | use crate::test_helpers::test_rng; |
| 7 | use rand::Rng; | |
| 8 | use realstd::collections::TryReserveErrorKind::*; | |
| 9 | 10 | |
| 10 | 11 | // https://github.com/rust-lang/rust/issues/62301 |
| 11 | 12 | fn _assert_hashmap_is_unwind_safe() { |
| ... | ... | @@ -946,7 +947,6 @@ fn test_raw_entry() { |
| 946 | 947 | |
| 947 | 948 | mod test_extract_if { |
| 948 | 949 | use super::*; |
| 949 | ||
| 950 | 950 | use crate::panic::{catch_unwind, AssertUnwindSafe}; |
| 951 | 951 | use crate::sync::atomic::{AtomicUsize, Ordering}; |
| 952 | 952 |
library/std/src/collections/hash/set.rs+1-2| ... | ... | @@ -3,6 +3,7 @@ mod tests; |
| 3 | 3 | |
| 4 | 4 | use hashbrown::hash_set as base; |
| 5 | 5 | |
| 6 | use super::map::map_try_reserve_error; | |
| 6 | 7 | use crate::borrow::Borrow; |
| 7 | 8 | use crate::collections::TryReserveError; |
| 8 | 9 | use crate::fmt; |
| ... | ... | @@ -10,8 +11,6 @@ use crate::hash::{BuildHasher, Hash, RandomState}; |
| 10 | 11 | use crate::iter::{Chain, FusedIterator}; |
| 11 | 12 | use crate::ops::{BitAnd, BitOr, BitXor, Sub}; |
| 12 | 13 | |
| 13 | use super::map::map_try_reserve_error; | |
| 14 | ||
| 15 | 14 | /// A [hash set] implemented as a `HashMap` where the value is `()`. |
| 16 | 15 | /// |
| 17 | 16 | /// As with the [`HashMap`] type, a `HashSet` requires that the elements |
library/std/src/collections/hash/set/tests.rs-1| ... | ... | @@ -1,5 +1,4 @@ |
| 1 | 1 | use super::HashSet; |
| 2 | ||
| 3 | 2 | use crate::hash::RandomState; |
| 4 | 3 | use crate::panic::{catch_unwind, AssertUnwindSafe}; |
| 5 | 4 | use crate::sync::atomic::{AtomicU32, Ordering}; |
library/std/src/collections/mod.rs+13-16| ... | ... | @@ -401,12 +401,14 @@ |
| 401 | 401 | |
| 402 | 402 | #![stable(feature = "rust1", since = "1.0.0")] |
| 403 | 403 | |
| 404 | #[stable(feature = "rust1", since = "1.0.0")] | |
| 405 | // FIXME(#82080) The deprecation here is only theoretical, and does not actually produce a warning. | |
| 406 | #[deprecated(note = "moved to `std::ops::Bound`", since = "1.26.0")] | |
| 407 | #[doc(hidden)] | |
| 408 | pub use crate::ops::Bound; | |
| 409 | ||
| 404 | #[stable(feature = "try_reserve", since = "1.57.0")] | |
| 405 | pub use alloc_crate::collections::TryReserveError; | |
| 406 | #[unstable( | |
| 407 | feature = "try_reserve_kind", | |
| 408 | reason = "Uncertain how much info should be exposed", | |
| 409 | issue = "48043" | |
| 410 | )] | |
| 411 | pub use alloc_crate::collections::TryReserveErrorKind; | |
| 410 | 412 | #[stable(feature = "rust1", since = "1.0.0")] |
| 411 | 413 | pub use alloc_crate::collections::{binary_heap, btree_map, btree_set}; |
| 412 | 414 | #[stable(feature = "rust1", since = "1.0.0")] |
| ... | ... | @@ -422,15 +424,11 @@ pub use self::hash_map::HashMap; |
| 422 | 424 | #[stable(feature = "rust1", since = "1.0.0")] |
| 423 | 425 | #[doc(inline)] |
| 424 | 426 | pub use self::hash_set::HashSet; |
| 425 | ||
| 426 | #[stable(feature = "try_reserve", since = "1.57.0")] | |
| 427 | pub use alloc_crate::collections::TryReserveError; | |
| 428 | #[unstable( | |
| 429 | feature = "try_reserve_kind", | |
| 430 | reason = "Uncertain how much info should be exposed", | |
| 431 | issue = "48043" | |
| 432 | )] | |
| 433 | pub use alloc_crate::collections::TryReserveErrorKind; | |
| 427 | #[stable(feature = "rust1", since = "1.0.0")] | |
| 428 | // FIXME(#82080) The deprecation here is only theoretical, and does not actually produce a warning. | |
| 429 | #[deprecated(note = "moved to `std::ops::Bound`", since = "1.26.0")] | |
| 430 | #[doc(hidden)] | |
| 431 | pub use crate::ops::Bound; | |
| 434 | 432 | |
| 435 | 433 | mod hash; |
| 436 | 434 | |
| ... | ... | @@ -439,7 +437,6 @@ pub mod hash_map { |
| 439 | 437 | //! A hash map implemented with quadratic probing and SIMD lookup. |
| 440 | 438 | #[stable(feature = "rust1", since = "1.0.0")] |
| 441 | 439 | pub use super::hash::map::*; |
| 442 | ||
| 443 | 440 | #[stable(feature = "hashmap_build_hasher", since = "1.7.0")] |
| 444 | 441 | pub use crate::hash::random::DefaultHasher; |
| 445 | 442 | #[stable(feature = "hashmap_build_hasher", since = "1.7.0")] |
library/std/src/env.rs+1-3| ... | ... | @@ -15,11 +15,9 @@ mod tests; |
| 15 | 15 | |
| 16 | 16 | use crate::error::Error; |
| 17 | 17 | use crate::ffi::{OsStr, OsString}; |
| 18 | use crate::fmt; | |
| 19 | use crate::io; | |
| 20 | 18 | use crate::path::{Path, PathBuf}; |
| 21 | use crate::sys; | |
| 22 | 19 | use crate::sys::os as os_imp; |
| 20 | use crate::{fmt, io, sys}; | |
| 23 | 21 | |
| 24 | 22 | /// Returns the current working directory as a [`PathBuf`]. |
| 25 | 23 | /// |
library/std/src/error.rs+3-3| ... | ... | @@ -4,14 +4,14 @@ |
| 4 | 4 | #[cfg(test)] |
| 5 | 5 | mod tests; |
| 6 | 6 | |
| 7 | use crate::backtrace::Backtrace; | |
| 8 | use crate::fmt::{self, Write}; | |
| 9 | ||
| 10 | 7 | #[stable(feature = "rust1", since = "1.0.0")] |
| 11 | 8 | pub use core::error::Error; |
| 12 | 9 | #[unstable(feature = "error_generic_member_access", issue = "99301")] |
| 13 | 10 | pub use core::error::{request_ref, request_value, Request}; |
| 14 | 11 | |
| 12 | use crate::backtrace::Backtrace; | |
| 13 | use crate::fmt::{self, Write}; | |
| 14 | ||
| 15 | 15 | /// An error reporter that prints an error and its sources. |
| 16 | 16 | /// |
| 17 | 17 | /// Report also exposes configuration options for formatting the error sources, either entirely on a |
library/std/src/error/tests.rs+2-1| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | use core::error::Request; | |
| 2 | ||
| 1 | 3 | use super::Error; |
| 2 | 4 | use crate::fmt; |
| 3 | use core::error::Request; | |
| 4 | 5 | |
| 5 | 6 | #[derive(Debug, PartialEq)] |
| 6 | 7 | struct A; |
library/std/src/f128.rs+3-3| ... | ... | @@ -7,12 +7,12 @@ |
| 7 | 7 | #[cfg(test)] |
| 8 | 8 | mod tests; |
| 9 | 9 | |
| 10 | #[cfg(not(test))] | |
| 11 | use crate::intrinsics; | |
| 12 | ||
| 13 | 10 | #[unstable(feature = "f128", issue = "116909")] |
| 14 | 11 | pub use core::f128::consts; |
| 15 | 12 | |
| 13 | #[cfg(not(test))] | |
| 14 | use crate::intrinsics; | |
| 15 | ||
| 16 | 16 | #[cfg(not(test))] |
| 17 | 17 | impl f128 { |
| 18 | 18 | /// Raises a number to an integer power. |
library/std/src/f128/tests.rs+1-2| ... | ... | @@ -3,8 +3,7 @@ |
| 3 | 3 | #![cfg(reliable_f128)] |
| 4 | 4 | |
| 5 | 5 | use crate::f128::consts; |
| 6 | use crate::num::FpCategory as Fp; | |
| 7 | use crate::num::*; | |
| 6 | use crate::num::{FpCategory as Fp, *}; | |
| 8 | 7 | |
| 9 | 8 | /// Smallest number |
| 10 | 9 | const TINY_BITS: u128 = 0x1; |
library/std/src/f16.rs+3-3| ... | ... | @@ -7,12 +7,12 @@ |
| 7 | 7 | #[cfg(test)] |
| 8 | 8 | mod tests; |
| 9 | 9 | |
| 10 | #[cfg(not(test))] | |
| 11 | use crate::intrinsics; | |
| 12 | ||
| 13 | 10 | #[unstable(feature = "f16", issue = "116909")] |
| 14 | 11 | pub use core::f16::consts; |
| 15 | 12 | |
| 13 | #[cfg(not(test))] | |
| 14 | use crate::intrinsics; | |
| 15 | ||
| 16 | 16 | #[cfg(not(test))] |
| 17 | 17 | impl f16 { |
| 18 | 18 | /// Raises a number to an integer power. |
library/std/src/f16/tests.rs+1-2| ... | ... | @@ -3,8 +3,7 @@ |
| 3 | 3 | #![cfg(reliable_f16)] |
| 4 | 4 | |
| 5 | 5 | use crate::f16::consts; |
| 6 | use crate::num::FpCategory as Fp; | |
| 7 | use crate::num::*; | |
| 6 | use crate::num::{FpCategory as Fp, *}; | |
| 8 | 7 | |
| 9 | 8 | // We run out of precision pretty quickly with f16 |
| 10 | 9 | // const F16_APPROX_L1: f16 = 0.001; |
library/std/src/f32.rs+5-5| ... | ... | @@ -15,11 +15,6 @@ |
| 15 | 15 | #[cfg(test)] |
| 16 | 16 | mod tests; |
| 17 | 17 | |
| 18 | #[cfg(not(test))] | |
| 19 | use crate::intrinsics; | |
| 20 | #[cfg(not(test))] | |
| 21 | use crate::sys::cmath; | |
| 22 | ||
| 23 | 18 | #[stable(feature = "rust1", since = "1.0.0")] |
| 24 | 19 | #[allow(deprecated, deprecated_in_future)] |
| 25 | 20 | pub use core::f32::{ |
| ... | ... | @@ -27,6 +22,11 @@ pub use core::f32::{ |
| 27 | 22 | MIN_EXP, MIN_POSITIVE, NAN, NEG_INFINITY, RADIX, |
| 28 | 23 | }; |
| 29 | 24 | |
| 25 | #[cfg(not(test))] | |
| 26 | use crate::intrinsics; | |
| 27 | #[cfg(not(test))] | |
| 28 | use crate::sys::cmath; | |
| 29 | ||
| 30 | 30 | #[cfg(not(test))] |
| 31 | 31 | impl f32 { |
| 32 | 32 | /// Returns the largest integer less than or equal to `self`. |
library/std/src/f32/tests.rs+1-2| ... | ... | @@ -1,6 +1,5 @@ |
| 1 | 1 | use crate::f32::consts; |
| 2 | use crate::num::FpCategory as Fp; | |
| 3 | use crate::num::*; | |
| 2 | use crate::num::{FpCategory as Fp, *}; | |
| 4 | 3 | |
| 5 | 4 | /// Smallest number |
| 6 | 5 | #[allow(dead_code)] // unused on x86 |
library/std/src/f64.rs+5-5| ... | ... | @@ -15,11 +15,6 @@ |
| 15 | 15 | #[cfg(test)] |
| 16 | 16 | mod tests; |
| 17 | 17 | |
| 18 | #[cfg(not(test))] | |
| 19 | use crate::intrinsics; | |
| 20 | #[cfg(not(test))] | |
| 21 | use crate::sys::cmath; | |
| 22 | ||
| 23 | 18 | #[stable(feature = "rust1", since = "1.0.0")] |
| 24 | 19 | #[allow(deprecated, deprecated_in_future)] |
| 25 | 20 | pub use core::f64::{ |
| ... | ... | @@ -27,6 +22,11 @@ pub use core::f64::{ |
| 27 | 22 | MIN_EXP, MIN_POSITIVE, NAN, NEG_INFINITY, RADIX, |
| 28 | 23 | }; |
| 29 | 24 | |
| 25 | #[cfg(not(test))] | |
| 26 | use crate::intrinsics; | |
| 27 | #[cfg(not(test))] | |
| 28 | use crate::sys::cmath; | |
| 29 | ||
| 30 | 30 | #[cfg(not(test))] |
| 31 | 31 | impl f64 { |
| 32 | 32 | /// Returns the largest integer less than or equal to `self`. |
library/std/src/f64/tests.rs+1-2| ... | ... | @@ -1,6 +1,5 @@ |
| 1 | 1 | use crate::f64::consts; |
| 2 | use crate::num::FpCategory as Fp; | |
| 3 | use crate::num::*; | |
| 2 | use crate::num::{FpCategory as Fp, *}; | |
| 4 | 3 | |
| 5 | 4 | /// Smallest number |
| 6 | 5 | #[allow(dead_code)] // unused on x86 |
library/std/src/ffi/c_str.rs+8-13| ... | ... | @@ -1,19 +1,14 @@ |
| 1 | 1 | //! [`CStr`], [`CString`], and related types. |
| 2 | 2 | |
| 3 | #[stable(feature = "rust1", since = "1.0.0")] | |
| 4 | pub use core::ffi::c_str::CStr; | |
| 5 | ||
| 6 | #[stable(feature = "cstr_from_bytes", since = "1.10.0")] | |
| 7 | pub use core::ffi::c_str::FromBytesWithNulError; | |
| 8 | ||
| 9 | #[stable(feature = "cstr_from_bytes_until_nul", since = "1.69.0")] | |
| 10 | pub use core::ffi::c_str::FromBytesUntilNulError; | |
| 11 | ||
| 12 | #[stable(feature = "rust1", since = "1.0.0")] | |
| 13 | pub use alloc::ffi::c_str::{CString, NulError}; | |
| 14 | ||
| 15 | 3 | #[stable(feature = "cstring_from_vec_with_nul", since = "1.58.0")] |
| 16 | 4 | pub use alloc::ffi::c_str::FromVecWithNulError; |
| 17 | ||
| 18 | 5 | #[stable(feature = "cstring_into", since = "1.7.0")] |
| 19 | 6 | pub use alloc::ffi::c_str::IntoStringError; |
| 7 | #[stable(feature = "rust1", since = "1.0.0")] | |
| 8 | pub use alloc::ffi::c_str::{CString, NulError}; | |
| 9 | #[stable(feature = "rust1", since = "1.0.0")] | |
| 10 | pub use core::ffi::c_str::CStr; | |
| 11 | #[stable(feature = "cstr_from_bytes_until_nul", since = "1.69.0")] | |
| 12 | pub use core::ffi::c_str::FromBytesUntilNulError; | |
| 13 | #[stable(feature = "cstr_from_bytes", since = "1.10.0")] | |
| 14 | pub use core::ffi::c_str::FromBytesWithNulError; |
library/std/src/ffi/mod.rs+22-30| ... | ... | @@ -164,50 +164,42 @@ |
| 164 | 164 | #[unstable(feature = "c_str_module", issue = "112134")] |
| 165 | 165 | pub mod c_str; |
| 166 | 166 | |
| 167 | #[doc(inline)] | |
| 168 | #[stable(feature = "rust1", since = "1.0.0")] | |
| 169 | pub use self::c_str::{CStr, CString}; | |
| 170 | ||
| 171 | #[doc(no_inline)] | |
| 172 | #[stable(feature = "cstr_from_bytes", since = "1.10.0")] | |
| 173 | pub use self::c_str::FromBytesWithNulError; | |
| 167 | #[stable(feature = "core_c_void", since = "1.30.0")] | |
| 168 | pub use core::ffi::c_void; | |
| 169 | #[stable(feature = "core_ffi_c", since = "1.64.0")] | |
| 170 | pub use core::ffi::{ | |
| 171 | c_char, c_double, c_float, c_int, c_long, c_longlong, c_schar, c_short, c_uchar, c_uint, | |
| 172 | c_ulong, c_ulonglong, c_ushort, | |
| 173 | }; | |
| 174 | #[unstable( | |
| 175 | feature = "c_variadic", | |
| 176 | reason = "the `c_variadic` feature has not been properly tested on \ | |
| 177 | all supported platforms", | |
| 178 | issue = "44930" | |
| 179 | )] | |
| 180 | pub use core::ffi::{VaList, VaListImpl}; | |
| 174 | 181 | |
| 175 | 182 | #[doc(no_inline)] |
| 176 | 183 | #[stable(feature = "cstr_from_bytes_until_nul", since = "1.69.0")] |
| 177 | 184 | pub use self::c_str::FromBytesUntilNulError; |
| 178 | ||
| 179 | 185 | #[doc(no_inline)] |
| 180 | #[stable(feature = "rust1", since = "1.0.0")] | |
| 181 | pub use self::c_str::NulError; | |
| 182 | ||
| 186 | #[stable(feature = "cstr_from_bytes", since = "1.10.0")] | |
| 187 | pub use self::c_str::FromBytesWithNulError; | |
| 183 | 188 | #[doc(no_inline)] |
| 184 | 189 | #[stable(feature = "cstring_from_vec_with_nul", since = "1.58.0")] |
| 185 | 190 | pub use self::c_str::FromVecWithNulError; |
| 186 | ||
| 187 | 191 | #[doc(no_inline)] |
| 188 | 192 | #[stable(feature = "cstring_into", since = "1.7.0")] |
| 189 | 193 | pub use self::c_str::IntoStringError; |
| 190 | ||
| 194 | #[doc(no_inline)] | |
| 195 | #[stable(feature = "rust1", since = "1.0.0")] | |
| 196 | pub use self::c_str::NulError; | |
| 197 | #[doc(inline)] | |
| 198 | #[stable(feature = "rust1", since = "1.0.0")] | |
| 199 | pub use self::c_str::{CStr, CString}; | |
| 191 | 200 | #[stable(feature = "rust1", since = "1.0.0")] |
| 192 | 201 | #[doc(inline)] |
| 193 | 202 | pub use self::os_str::{OsStr, OsString}; |
| 194 | 203 | |
| 195 | #[stable(feature = "core_ffi_c", since = "1.64.0")] | |
| 196 | pub use core::ffi::{ | |
| 197 | c_char, c_double, c_float, c_int, c_long, c_longlong, c_schar, c_short, c_uchar, c_uint, | |
| 198 | c_ulong, c_ulonglong, c_ushort, | |
| 199 | }; | |
| 200 | ||
| 201 | #[stable(feature = "core_c_void", since = "1.30.0")] | |
| 202 | pub use core::ffi::c_void; | |
| 203 | ||
| 204 | #[unstable( | |
| 205 | feature = "c_variadic", | |
| 206 | reason = "the `c_variadic` feature has not been properly tested on \ | |
| 207 | all supported platforms", | |
| 208 | issue = "44930" | |
| 209 | )] | |
| 210 | pub use core::ffi::{VaList, VaListImpl}; | |
| 211 | ||
| 212 | 204 | #[unstable(feature = "os_str_display", issue = "120048")] |
| 213 | 205 | pub mod os_str; |
library/std/src/ffi/os_str.rs+1-4| ... | ... | @@ -4,18 +4,15 @@ |
| 4 | 4 | mod tests; |
| 5 | 5 | |
| 6 | 6 | use crate::borrow::{Borrow, Cow}; |
| 7 | use crate::cmp; | |
| 8 | 7 | use crate::collections::TryReserveError; |
| 9 | use crate::fmt; | |
| 10 | 8 | use crate::hash::{Hash, Hasher}; |
| 11 | 9 | use crate::ops::{self, Range}; |
| 12 | 10 | use crate::rc::Rc; |
| 13 | use crate::slice; | |
| 14 | 11 | use crate::str::FromStr; |
| 15 | 12 | use crate::sync::Arc; |
| 16 | ||
| 17 | 13 | use crate::sys::os_str::{Buf, Slice}; |
| 18 | 14 | use crate::sys_common::{AsInner, FromInner, IntoInner}; |
| 15 | use crate::{cmp, fmt, slice}; | |
| 19 | 16 | |
| 20 | 17 | /// A type that can represent owned, mutable platform-native strings, but is |
| 21 | 18 | /// cheaply inter-convertible with Rust strings. |
library/std/src/fs/tests.rs+12-14| ... | ... | @@ -1,20 +1,11 @@ |
| 1 | use crate::io::prelude::*; | |
| 2 | ||
| 3 | use crate::env; | |
| 4 | use crate::fs::{self, File, FileTimes, OpenOptions}; | |
| 5 | use crate::io::{BorrowedBuf, ErrorKind, SeekFrom}; | |
| 6 | use crate::mem::MaybeUninit; | |
| 7 | use crate::path::Path; | |
| 8 | use crate::str; | |
| 9 | use crate::sync::Arc; | |
| 10 | use crate::sys_common::io::test::{tmpdir, TempDir}; | |
| 11 | use crate::thread; | |
| 12 | use crate::time::{Duration, Instant, SystemTime}; | |
| 13 | ||
| 14 | 1 | use rand::RngCore; |
| 15 | 2 | |
| 16 | 3 | #[cfg(target_os = "macos")] |
| 17 | 4 | use crate::ffi::{c_char, c_int}; |
| 5 | use crate::fs::{self, File, FileTimes, OpenOptions}; | |
| 6 | use crate::io::prelude::*; | |
| 7 | use crate::io::{BorrowedBuf, ErrorKind, SeekFrom}; | |
| 8 | use crate::mem::MaybeUninit; | |
| 18 | 9 | #[cfg(unix)] |
| 19 | 10 | use crate::os::unix::fs::symlink as symlink_dir; |
| 20 | 11 | #[cfg(unix)] |
| ... | ... | @@ -23,8 +14,13 @@ use crate::os::unix::fs::symlink as symlink_file; |
| 23 | 14 | use crate::os::unix::fs::symlink as junction_point; |
| 24 | 15 | #[cfg(windows)] |
| 25 | 16 | use crate::os::windows::fs::{junction_point, symlink_dir, symlink_file, OpenOptionsExt}; |
| 17 | use crate::path::Path; | |
| 18 | use crate::sync::Arc; | |
| 26 | 19 | #[cfg(target_os = "macos")] |
| 27 | 20 | use crate::sys::weak::weak; |
| 21 | use crate::sys_common::io::test::{tmpdir, TempDir}; | |
| 22 | use crate::time::{Duration, Instant, SystemTime}; | |
| 23 | use crate::{env, str, thread}; | |
| 28 | 24 | |
| 29 | 25 | macro_rules! check { |
| 30 | 26 | ($e:expr) => { |
| ... | ... | @@ -1514,7 +1510,9 @@ fn symlink_hard_link() { |
| 1514 | 1510 | #[test] |
| 1515 | 1511 | #[cfg(windows)] |
| 1516 | 1512 | fn create_dir_long_paths() { |
| 1517 | use crate::{ffi::OsStr, iter, os::windows::ffi::OsStrExt}; | |
| 1513 | use crate::ffi::OsStr; | |
| 1514 | use crate::iter; | |
| 1515 | use crate::os::windows::ffi::OsStrExt; | |
| 1518 | 1516 | const PATH_LEN: usize = 247; |
| 1519 | 1517 | |
| 1520 | 1518 | let tmpdir = tmpdir(); |
library/std/src/hash/random.rs+1-2| ... | ... | @@ -10,8 +10,7 @@ |
| 10 | 10 | #[allow(deprecated)] |
| 11 | 11 | use super::{BuildHasher, Hasher, SipHasher13}; |
| 12 | 12 | use crate::cell::Cell; |
| 13 | use crate::fmt; | |
| 14 | use crate::sys; | |
| 13 | use crate::{fmt, sys}; | |
| 15 | 14 | |
| 16 | 15 | /// `RandomState` is the default state for [`HashMap`] types. |
| 17 | 16 | /// |
library/std/src/io/buffered/bufreader.rs+2-1| ... | ... | @@ -1,11 +1,12 @@ |
| 1 | 1 | mod buffer; |
| 2 | 2 | |
| 3 | use buffer::Buffer; | |
| 4 | ||
| 3 | 5 | use crate::fmt; |
| 4 | 6 | use crate::io::{ |
| 5 | 7 | self, uninlined_slow_read_byte, BorrowedCursor, BufRead, IoSliceMut, Read, Seek, SeekFrom, |
| 6 | 8 | SizeHint, SpecReadByte, DEFAULT_BUF_SIZE, |
| 7 | 9 | }; |
| 8 | use buffer::Buffer; | |
| 9 | 10 | |
| 10 | 11 | /// The `BufReader<R>` struct adds buffering to any reader. |
| 11 | 12 | /// |
library/std/src/io/buffered/bufwriter.rs+1-3| ... | ... | @@ -1,10 +1,8 @@ |
| 1 | use crate::error; | |
| 2 | use crate::fmt; | |
| 3 | 1 | use crate::io::{ |
| 4 | 2 | self, ErrorKind, IntoInnerError, IoSlice, Seek, SeekFrom, Write, DEFAULT_BUF_SIZE, |
| 5 | 3 | }; |
| 6 | 4 | use crate::mem::{self, ManuallyDrop}; |
| 7 | use crate::ptr; | |
| 5 | use crate::{error, fmt, ptr}; | |
| 8 | 6 | |
| 9 | 7 | /// Wraps a writer and buffers its output. |
| 10 | 8 | /// |
library/std/src/io/buffered/linewriter.rs+2-1| ... | ... | @@ -1,5 +1,6 @@ |
| 1 | 1 | use crate::fmt; |
| 2 | use crate::io::{self, buffered::LineWriterShim, BufWriter, IntoInnerError, IoSlice, Write}; | |
| 2 | use crate::io::buffered::LineWriterShim; | |
| 3 | use crate::io::{self, BufWriter, IntoInnerError, IoSlice, Write}; | |
| 3 | 4 | |
| 4 | 5 | /// Wraps a writer and buffers output to it, flushing whenever a newline |
| 5 | 6 | /// (`0x0a`, `'\n'`) is detected. |
library/std/src/io/buffered/linewritershim.rs+2-1| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | use crate::io::{self, BufWriter, IoSlice, Write}; | |
| 2 | 1 | use core::slice::memchr; |
| 3 | 2 | |
| 3 | use crate::io::{self, BufWriter, IoSlice, Write}; | |
| 4 | ||
| 4 | 5 | /// Private helper struct for implementing the line-buffered writing logic. |
| 5 | 6 | /// |
| 6 | 7 | /// This shim temporarily wraps a BufWriter, and uses its internals to |
library/std/src/io/buffered/mod.rs+5-7| ... | ... | @@ -8,16 +8,14 @@ mod linewritershim; |
| 8 | 8 | #[cfg(test)] |
| 9 | 9 | mod tests; |
| 10 | 10 | |
| 11 | use crate::error; | |
| 12 | use crate::fmt; | |
| 13 | use crate::io::Error; | |
| 11 | #[stable(feature = "bufwriter_into_parts", since = "1.56.0")] | |
| 12 | pub use bufwriter::WriterPanicked; | |
| 13 | use linewritershim::LineWriterShim; | |
| 14 | 14 | |
| 15 | 15 | #[stable(feature = "rust1", since = "1.0.0")] |
| 16 | 16 | pub use self::{bufreader::BufReader, bufwriter::BufWriter, linewriter::LineWriter}; |
| 17 | use linewritershim::LineWriterShim; | |
| 18 | ||
| 19 | #[stable(feature = "bufwriter_into_parts", since = "1.56.0")] | |
| 20 | pub use bufwriter::WriterPanicked; | |
| 17 | use crate::io::Error; | |
| 18 | use crate::{error, fmt}; | |
| 21 | 19 | |
| 22 | 20 | /// An error returned by [`BufWriter::into_inner`] which combines an error that |
| 23 | 21 | /// happened while writing out the buffer, and the buffered writer object |
library/std/src/io/buffered/tests.rs+1-2| ... | ... | @@ -3,9 +3,8 @@ use crate::io::{ |
| 3 | 3 | self, BorrowedBuf, BufReader, BufWriter, ErrorKind, IoSlice, LineWriter, SeekFrom, |
| 4 | 4 | }; |
| 5 | 5 | use crate::mem::MaybeUninit; |
| 6 | use crate::panic; | |
| 7 | 6 | use crate::sync::atomic::{AtomicUsize, Ordering}; |
| 8 | use crate::thread; | |
| 7 | use crate::{panic, thread}; | |
| 9 | 8 | |
| 10 | 9 | /// A dummy reader intended at testing short-reads propagation. |
| 11 | 10 | pub struct ShortReader { |
library/std/src/io/copy/tests.rs+3-4| ... | ... | @@ -119,13 +119,12 @@ fn copy_specializes_from_slice() { |
| 119 | 119 | |
| 120 | 120 | #[cfg(unix)] |
| 121 | 121 | mod io_benches { |
| 122 | use crate::fs::File; | |
| 123 | use crate::fs::OpenOptions; | |
| 122 | use test::Bencher; | |
| 123 | ||
| 124 | use crate::fs::{File, OpenOptions}; | |
| 124 | 125 | use crate::io::prelude::*; |
| 125 | 126 | use crate::io::BufReader; |
| 126 | 127 | |
| 127 | use test::Bencher; | |
| 128 | ||
| 129 | 128 | #[bench] |
| 130 | 129 | fn bench_copy_buf_reader(b: &mut Bencher) { |
| 131 | 130 | let mut file_in = File::open("/dev/zero").expect("opening /dev/zero failed"); |
library/std/src/io/cursor.rs+1-2| ... | ... | @@ -1,10 +1,9 @@ |
| 1 | 1 | #[cfg(test)] |
| 2 | 2 | mod tests; |
| 3 | 3 | |
| 4 | use crate::io::prelude::*; | |
| 5 | ||
| 6 | 4 | use crate::alloc::Allocator; |
| 7 | 5 | use crate::cmp; |
| 6 | use crate::io::prelude::*; | |
| 8 | 7 | use crate::io::{self, BorrowedCursor, ErrorKind, IoSlice, IoSliceMut, SeekFrom}; |
| 9 | 8 | |
| 10 | 9 | /// A `Cursor` wraps an in-memory buffer and provides it with a |
library/std/src/io/error.rs+1-4| ... | ... | @@ -11,10 +11,7 @@ mod repr_unpacked; |
| 11 | 11 | #[cfg(any(not(target_pointer_width = "64"), target_os = "uefi"))] |
| 12 | 12 | use repr_unpacked::Repr; |
| 13 | 13 | |
| 14 | use crate::error; | |
| 15 | use crate::fmt; | |
| 16 | use crate::result; | |
| 17 | use crate::sys; | |
| 14 | use crate::{error, fmt, result, sys}; | |
| 18 | 15 | |
| 19 | 16 | /// A specialized [`Result`] type for I/O operations. |
| 20 | 17 | /// |
library/std/src/io/error/repr_bitpacked.rs+2-1| ... | ... | @@ -102,10 +102,11 @@ |
| 102 | 102 | //! to use a pointer type to store something that may hold an integer, some of |
| 103 | 103 | //! the time. |
| 104 | 104 | |
| 105 | use super::{Custom, ErrorData, ErrorKind, RawOsError, SimpleMessage}; | |
| 106 | 105 | use core::marker::PhantomData; |
| 107 | 106 | use core::ptr::{self, NonNull}; |
| 108 | 107 | |
| 108 | use super::{Custom, ErrorData, ErrorKind, RawOsError, SimpleMessage}; | |
| 109 | ||
| 109 | 110 | // The 2 least-significant bits are used as tag. |
| 110 | 111 | const TAG_MASK: usize = 0b11; |
| 111 | 112 | const TAG_SIMPLE_MESSAGE: usize = 0b00; |
library/std/src/io/error/tests.rs+3-3| ... | ... | @@ -1,10 +1,9 @@ |
| 1 | 1 | use super::{const_io_error, Custom, Error, ErrorData, ErrorKind, Repr, SimpleMessage}; |
| 2 | 2 | use crate::assert_matches::assert_matches; |
| 3 | use crate::error; | |
| 4 | use crate::fmt; | |
| 5 | 3 | use crate::mem::size_of; |
| 6 | 4 | use crate::sys::decode_error_kind; |
| 7 | 5 | use crate::sys::os::error_string; |
| 6 | use crate::{error, fmt}; | |
| 8 | 7 | |
| 9 | 8 | #[test] |
| 10 | 9 | fn test_size() { |
| ... | ... | @@ -95,7 +94,8 @@ fn test_errorkind_packing() { |
| 95 | 94 | |
| 96 | 95 | #[test] |
| 97 | 96 | fn test_simple_message_packing() { |
| 98 | use super::{ErrorKind::*, SimpleMessage}; | |
| 97 | use super::ErrorKind::*; | |
| 98 | use super::SimpleMessage; | |
| 99 | 99 | macro_rules! check_simple_msg { |
| 100 | 100 | ($err:expr, $kind:ident, $msg:literal) => {{ |
| 101 | 101 | let e = &$err; |
library/std/src/io/impls.rs+1-4| ... | ... | @@ -2,12 +2,9 @@ |
| 2 | 2 | mod tests; |
| 3 | 3 | |
| 4 | 4 | use crate::alloc::Allocator; |
| 5 | use crate::cmp; | |
| 6 | 5 | use crate::collections::VecDeque; |
| 7 | use crate::fmt; | |
| 8 | 6 | use crate::io::{self, BorrowedCursor, BufRead, IoSlice, IoSliceMut, Read, Seek, SeekFrom, Write}; |
| 9 | use crate::mem; | |
| 10 | use crate::str; | |
| 7 | use crate::{cmp, fmt, mem, str}; | |
| 11 | 8 | |
| 12 | 9 | // ============================================================================= |
| 13 | 10 | // Forwarding implementations |
library/std/src/io/mod.rs+7-11| ... | ... | @@ -297,15 +297,12 @@ |
| 297 | 297 | #[cfg(test)] |
| 298 | 298 | mod tests; |
| 299 | 299 | |
| 300 | use crate::cmp; | |
| 301 | use crate::fmt; | |
| 302 | use crate::mem::take; | |
| 303 | use crate::ops::{Deref, DerefMut}; | |
| 304 | use crate::slice; | |
| 305 | use crate::str; | |
| 306 | use crate::sys; | |
| 300 | #[unstable(feature = "read_buf", issue = "78485")] | |
| 301 | pub use core::io::{BorrowedBuf, BorrowedCursor}; | |
| 307 | 302 | use core::slice::memchr; |
| 308 | 303 | |
| 304 | pub(crate) use error::const_io_error; | |
| 305 | ||
| 309 | 306 | #[stable(feature = "bufwriter_into_parts", since = "1.56.0")] |
| 310 | 307 | pub use self::buffered::WriterPanicked; |
| 311 | 308 | #[unstable(feature = "raw_os_error_ty", issue = "107792")] |
| ... | ... | @@ -328,10 +325,9 @@ pub use self::{ |
| 328 | 325 | stdio::{stderr, stdin, stdout, Stderr, StderrLock, Stdin, StdinLock, Stdout, StdoutLock}, |
| 329 | 326 | util::{empty, repeat, sink, Empty, Repeat, Sink}, |
| 330 | 327 | }; |
| 331 | ||
| 332 | #[unstable(feature = "read_buf", issue = "78485")] | |
| 333 | pub use core::io::{BorrowedBuf, BorrowedCursor}; | |
| 334 | pub(crate) use error::const_io_error; | |
| 328 | use crate::mem::take; | |
| 329 | use crate::ops::{Deref, DerefMut}; | |
| 330 | use crate::{cmp, fmt, slice, str, sys}; | |
| 335 | 331 | |
| 336 | 332 | mod buffered; |
| 337 | 333 | pub(crate) mod copy; |
library/std/src/io/stdio.rs+1-2| ... | ... | @@ -3,11 +3,10 @@ |
| 3 | 3 | #[cfg(test)] |
| 4 | 4 | mod tests; |
| 5 | 5 | |
| 6 | use crate::io::prelude::*; | |
| 7 | ||
| 8 | 6 | use crate::cell::{Cell, RefCell}; |
| 9 | 7 | use crate::fmt; |
| 10 | 8 | use crate::fs::File; |
| 9 | use crate::io::prelude::*; | |
| 11 | 10 | use crate::io::{ |
| 12 | 11 | self, BorrowedCursor, BufReader, IoSlice, IoSliceMut, LineWriter, Lines, SpecReadByte, |
| 13 | 12 | }; |
library/std/src/io/tests.rs+3-2| ... | ... | @@ -1,7 +1,8 @@ |
| 1 | 1 | use super::{repeat, BorrowedBuf, Cursor, SeekFrom}; |
| 2 | 2 | use crate::cmp::{self, min}; |
| 3 | use crate::io::{self, IoSlice, IoSliceMut, DEFAULT_BUF_SIZE}; | |
| 4 | use crate::io::{BufRead, BufReader, Read, Seek, Write}; | |
| 3 | use crate::io::{ | |
| 4 | self, BufRead, BufReader, IoSlice, IoSliceMut, Read, Seek, Write, DEFAULT_BUF_SIZE, | |
| 5 | }; | |
| 5 | 6 | use crate::mem::MaybeUninit; |
| 6 | 7 | use crate::ops::Deref; |
| 7 | 8 |
library/std/src/io/util/tests.rs-1| ... | ... | @@ -1,6 +1,5 @@ |
| 1 | 1 | use crate::io::prelude::*; |
| 2 | 2 | use crate::io::{empty, repeat, sink, BorrowedBuf, Empty, Repeat, SeekFrom, Sink}; |
| 3 | ||
| 4 | 3 | use crate::mem::MaybeUninit; |
| 5 | 4 | |
| 6 | 5 | #[test] |
library/std/src/lib.rs+41-44| ... | ... | @@ -470,24 +470,6 @@ pub mod rt; |
| 470 | 470 | // The Rust prelude |
| 471 | 471 | pub mod prelude; |
| 472 | 472 | |
| 473 | #[stable(feature = "rust1", since = "1.0.0")] | |
| 474 | pub use alloc_crate::borrow; | |
| 475 | #[stable(feature = "rust1", since = "1.0.0")] | |
| 476 | pub use alloc_crate::boxed; | |
| 477 | #[stable(feature = "rust1", since = "1.0.0")] | |
| 478 | pub use alloc_crate::fmt; | |
| 479 | #[stable(feature = "rust1", since = "1.0.0")] | |
| 480 | pub use alloc_crate::format; | |
| 481 | #[stable(feature = "rust1", since = "1.0.0")] | |
| 482 | pub use alloc_crate::rc; | |
| 483 | #[stable(feature = "rust1", since = "1.0.0")] | |
| 484 | pub use alloc_crate::slice; | |
| 485 | #[stable(feature = "rust1", since = "1.0.0")] | |
| 486 | pub use alloc_crate::str; | |
| 487 | #[stable(feature = "rust1", since = "1.0.0")] | |
| 488 | pub use alloc_crate::string; | |
| 489 | #[stable(feature = "rust1", since = "1.0.0")] | |
| 490 | pub use alloc_crate::vec; | |
| 491 | 473 | #[stable(feature = "rust1", since = "1.0.0")] |
| 492 | 474 | pub use core::any; |
| 493 | 475 | #[stable(feature = "core_array", since = "1.36.0")] |
| ... | ... | @@ -565,6 +547,25 @@ pub use core::u8; |
| 565 | 547 | #[allow(deprecated, deprecated_in_future)] |
| 566 | 548 | pub use core::usize; |
| 567 | 549 | |
| 550 | #[stable(feature = "rust1", since = "1.0.0")] | |
| 551 | pub use alloc_crate::borrow; | |
| 552 | #[stable(feature = "rust1", since = "1.0.0")] | |
| 553 | pub use alloc_crate::boxed; | |
| 554 | #[stable(feature = "rust1", since = "1.0.0")] | |
| 555 | pub use alloc_crate::fmt; | |
| 556 | #[stable(feature = "rust1", since = "1.0.0")] | |
| 557 | pub use alloc_crate::format; | |
| 558 | #[stable(feature = "rust1", since = "1.0.0")] | |
| 559 | pub use alloc_crate::rc; | |
| 560 | #[stable(feature = "rust1", since = "1.0.0")] | |
| 561 | pub use alloc_crate::slice; | |
| 562 | #[stable(feature = "rust1", since = "1.0.0")] | |
| 563 | pub use alloc_crate::str; | |
| 564 | #[stable(feature = "rust1", since = "1.0.0")] | |
| 565 | pub use alloc_crate::string; | |
| 566 | #[stable(feature = "rust1", since = "1.0.0")] | |
| 567 | pub use alloc_crate::vec; | |
| 568 | ||
| 568 | 569 | #[unstable(feature = "f128", issue = "116909")] |
| 569 | 570 | pub mod f128; |
| 570 | 571 | #[unstable(feature = "f16", issue = "116909")] |
| ... | ... | @@ -608,23 +609,23 @@ mod std_float; |
| 608 | 609 | pub mod simd { |
| 609 | 610 | #![doc = include_str!("../../portable-simd/crates/core_simd/src/core_simd_docs.md")] |
| 610 | 611 | |
| 611 | #[doc(inline)] | |
| 612 | pub use crate::std_float::StdFloat; | |
| 613 | 612 | #[doc(inline)] |
| 614 | 613 | pub use core::simd::*; |
| 614 | ||
| 615 | #[doc(inline)] | |
| 616 | pub use crate::std_float::StdFloat; | |
| 615 | 617 | } |
| 616 | 618 | |
| 617 | 619 | #[stable(feature = "futures_api", since = "1.36.0")] |
| 618 | 620 | pub mod task { |
| 619 | 621 | //! Types and Traits for working with asynchronous tasks. |
| 620 | 622 | |
| 621 | #[doc(inline)] | |
| 622 | #[stable(feature = "futures_api", since = "1.36.0")] | |
| 623 | pub use core::task::*; | |
| 624 | ||
| 625 | 623 | #[doc(inline)] |
| 626 | 624 | #[stable(feature = "wake_trait", since = "1.51.0")] |
| 627 | 625 | pub use alloc::task::*; |
| 626 | #[doc(inline)] | |
| 627 | #[stable(feature = "futures_api", since = "1.36.0")] | |
| 628 | pub use core::task::*; | |
| 628 | 629 | } |
| 629 | 630 | |
| 630 | 631 | #[doc = include_str!("../../stdarch/crates/core_arch/src/core_arch_docs.md")] |
| ... | ... | @@ -670,34 +671,30 @@ mod panicking; |
| 670 | 671 | mod backtrace_rs; |
| 671 | 672 | |
| 672 | 673 | // Re-export macros defined in core. |
| 673 | #[stable(feature = "rust1", since = "1.0.0")] | |
| 674 | #[allow(deprecated, deprecated_in_future)] | |
| 675 | pub use core::{ | |
| 676 | assert_eq, assert_ne, debug_assert, debug_assert_eq, debug_assert_ne, matches, todo, r#try, | |
| 677 | unimplemented, unreachable, write, writeln, | |
| 678 | }; | |
| 679 | ||
| 680 | // Re-export built-in macros defined through core. | |
| 681 | #[stable(feature = "builtin_macro_prelude", since = "1.38.0")] | |
| 682 | #[allow(deprecated)] | |
| 683 | pub use core::{ | |
| 684 | assert, assert_matches, cfg, column, compile_error, concat, concat_idents, const_format_args, | |
| 685 | env, file, format_args, format_args_nl, include, include_bytes, include_str, line, log_syntax, | |
| 686 | module_path, option_env, stringify, trace_macros, | |
| 687 | }; | |
| 688 | ||
| 674 | #[unstable(feature = "cfg_match", issue = "115585")] | |
| 675 | pub use core::cfg_match; | |
| 689 | 676 | #[unstable( |
| 690 | 677 | feature = "concat_bytes", |
| 691 | 678 | issue = "87555", |
| 692 | 679 | reason = "`concat_bytes` is not stable enough for use and is subject to change" |
| 693 | 680 | )] |
| 694 | 681 | pub use core::concat_bytes; |
| 695 | ||
| 696 | #[unstable(feature = "cfg_match", issue = "115585")] | |
| 697 | pub use core::cfg_match; | |
| 698 | ||
| 699 | 682 | #[stable(feature = "core_primitive", since = "1.43.0")] |
| 700 | 683 | pub use core::primitive; |
| 684 | // Re-export built-in macros defined through core. | |
| 685 | #[stable(feature = "builtin_macro_prelude", since = "1.38.0")] | |
| 686 | #[allow(deprecated)] | |
| 687 | pub use core::{ | |
| 688 | assert, assert_matches, cfg, column, compile_error, concat, concat_idents, const_format_args, | |
| 689 | env, file, format_args, format_args_nl, include, include_bytes, include_str, line, log_syntax, | |
| 690 | module_path, option_env, stringify, trace_macros, | |
| 691 | }; | |
| 692 | #[stable(feature = "rust1", since = "1.0.0")] | |
| 693 | #[allow(deprecated, deprecated_in_future)] | |
| 694 | pub use core::{ | |
| 695 | assert_eq, assert_ne, debug_assert, debug_assert_eq, debug_assert_ne, matches, todo, r#try, | |
| 696 | unimplemented, unreachable, write, writeln, | |
| 697 | }; | |
| 701 | 698 | |
| 702 | 699 | // Include a number of private modules that exist solely to provide |
| 703 | 700 | // the rustdoc documentation for primitive types. Using `include!` |
library/std/src/net/ip_addr.rs+4-6| ... | ... | @@ -2,17 +2,15 @@ |
| 2 | 2 | #[cfg(all(test, not(target_os = "emscripten")))] |
| 3 | 3 | mod tests; |
| 4 | 4 | |
| 5 | use crate::sys::net::netc as c; | |
| 6 | use crate::sys_common::{FromInner, IntoInner}; | |
| 7 | ||
| 8 | 5 | #[stable(feature = "ip_addr", since = "1.7.0")] |
| 9 | 6 | pub use core::net::IpAddr; |
| 10 | ||
| 7 | #[unstable(feature = "ip", issue = "27709")] | |
| 8 | pub use core::net::Ipv6MulticastScope; | |
| 11 | 9 | #[stable(feature = "rust1", since = "1.0.0")] |
| 12 | 10 | pub use core::net::{Ipv4Addr, Ipv6Addr}; |
| 13 | 11 | |
| 14 | #[unstable(feature = "ip", issue = "27709")] | |
| 15 | pub use core::net::Ipv6MulticastScope; | |
| 12 | use crate::sys::net::netc as c; | |
| 13 | use crate::sys_common::{FromInner, IntoInner}; | |
| 16 | 14 | |
| 17 | 15 | impl IntoInner<c::in_addr> for Ipv4Addr { |
| 18 | 16 | #[inline] |
library/std/src/net/mod.rs+3-3| ... | ... | @@ -21,7 +21,8 @@ |
| 21 | 21 | |
| 22 | 22 | #![stable(feature = "rust1", since = "1.0.0")] |
| 23 | 23 | |
| 24 | use crate::io::{self, ErrorKind}; | |
| 24 | #[stable(feature = "rust1", since = "1.0.0")] | |
| 25 | pub use core::net::AddrParseError; | |
| 25 | 26 | |
| 26 | 27 | #[stable(feature = "rust1", since = "1.0.0")] |
| 27 | 28 | pub use self::ip_addr::{IpAddr, Ipv4Addr, Ipv6Addr, Ipv6MulticastScope}; |
| ... | ... | @@ -33,8 +34,7 @@ pub use self::tcp::IntoIncoming; |
| 33 | 34 | pub use self::tcp::{Incoming, TcpListener, TcpStream}; |
| 34 | 35 | #[stable(feature = "rust1", since = "1.0.0")] |
| 35 | 36 | pub use self::udp::UdpSocket; |
| 36 | #[stable(feature = "rust1", since = "1.0.0")] | |
| 37 | pub use core::net::AddrParseError; | |
| 37 | use crate::io::{self, ErrorKind}; | |
| 38 | 38 | |
| 39 | 39 | mod ip_addr; |
| 40 | 40 | mod socket_addr; |
library/std/src/net/socket_addr.rs+4-9| ... | ... | @@ -2,19 +2,14 @@ |
| 2 | 2 | #[cfg(all(test, not(target_os = "emscripten")))] |
| 3 | 3 | mod tests; |
| 4 | 4 | |
| 5 | use crate::io; | |
| 6 | use crate::iter; | |
| 7 | use crate::mem; | |
| 5 | #[stable(feature = "rust1", since = "1.0.0")] | |
| 6 | pub use core::net::{SocketAddr, SocketAddrV4, SocketAddrV6}; | |
| 7 | ||
| 8 | 8 | use crate::net::{IpAddr, Ipv4Addr, Ipv6Addr}; |
| 9 | use crate::option; | |
| 10 | use crate::slice; | |
| 11 | 9 | use crate::sys::net::netc as c; |
| 12 | 10 | use crate::sys_common::net::LookupHost; |
| 13 | 11 | use crate::sys_common::{FromInner, IntoInner}; |
| 14 | use crate::vec; | |
| 15 | ||
| 16 | #[stable(feature = "rust1", since = "1.0.0")] | |
| 17 | pub use core::net::{SocketAddr, SocketAddrV4, SocketAddrV6}; | |
| 12 | use crate::{io, iter, mem, option, slice, vec}; | |
| 18 | 13 | |
| 19 | 14 | impl FromInner<c::sockaddr_in> for SocketAddrV4 { |
| 20 | 15 | fn from_inner(addr: c::sockaddr_in) -> SocketAddrV4 { |
library/std/src/net/tcp.rs+2-4| ... | ... | @@ -3,14 +3,12 @@ |
| 3 | 3 | #[cfg(all(test, not(any(target_os = "emscripten", target_os = "xous"))))] |
| 4 | 4 | mod tests; |
| 5 | 5 | |
| 6 | use crate::io::prelude::*; | |
| 7 | ||
| 8 | 6 | use crate::fmt; |
| 7 | use crate::io::prelude::*; | |
| 9 | 8 | use crate::io::{self, BorrowedCursor, IoSlice, IoSliceMut}; |
| 10 | 9 | use crate::iter::FusedIterator; |
| 11 | 10 | use crate::net::{Shutdown, SocketAddr, ToSocketAddrs}; |
| 12 | use crate::sys_common::net as net_imp; | |
| 13 | use crate::sys_common::{AsInner, FromInner, IntoInner}; | |
| 11 | use crate::sys_common::{net as net_imp, AsInner, FromInner, IntoInner}; | |
| 14 | 12 | use crate::time::Duration; |
| 15 | 13 | |
| 16 | 14 | /// A TCP stream between a local and a remote socket. |
library/std/src/net/tcp/tests.rs+1-2| ... | ... | @@ -1,12 +1,11 @@ |
| 1 | use crate::fmt; | |
| 2 | 1 | use crate::io::prelude::*; |
| 3 | 2 | use crate::io::{BorrowedBuf, IoSlice, IoSliceMut}; |
| 4 | 3 | use crate::mem::MaybeUninit; |
| 5 | 4 | use crate::net::test::{next_test_ip4, next_test_ip6}; |
| 6 | 5 | use crate::net::*; |
| 7 | 6 | use crate::sync::mpsc::channel; |
| 8 | use crate::thread; | |
| 9 | 7 | use crate::time::{Duration, Instant}; |
| 8 | use crate::{fmt, thread}; | |
| 10 | 9 | |
| 11 | 10 | fn each_ip(f: &mut dyn FnMut(SocketAddr)) { |
| 12 | 11 | f(next_test_ip4()); |
library/std/src/net/udp.rs+1-2| ... | ... | @@ -4,8 +4,7 @@ mod tests; |
| 4 | 4 | use crate::fmt; |
| 5 | 5 | use crate::io::{self, ErrorKind}; |
| 6 | 6 | use crate::net::{Ipv4Addr, Ipv6Addr, SocketAddr, ToSocketAddrs}; |
| 7 | use crate::sys_common::net as net_imp; | |
| 8 | use crate::sys_common::{AsInner, FromInner, IntoInner}; | |
| 7 | use crate::sys_common::{net as net_imp, AsInner, FromInner, IntoInner}; | |
| 9 | 8 | use crate::time::Duration; |
| 10 | 9 | |
| 11 | 10 | /// A UDP socket. |
library/std/src/num.rs+6-11| ... | ... | @@ -9,32 +9,27 @@ |
| 9 | 9 | #[cfg(test)] |
| 10 | 10 | mod tests; |
| 11 | 11 | |
| 12 | #[stable(feature = "int_error_matching", since = "1.55.0")] | |
| 13 | pub use core::num::IntErrorKind; | |
| 14 | #[stable(feature = "generic_nonzero", since = "1.79.0")] | |
| 15 | pub use core::num::NonZero; | |
| 12 | 16 | #[stable(feature = "saturating_int_impl", since = "1.74.0")] |
| 13 | 17 | pub use core::num::Saturating; |
| 14 | 18 | #[stable(feature = "rust1", since = "1.0.0")] |
| 15 | 19 | pub use core::num::Wrapping; |
| 16 | #[stable(feature = "rust1", since = "1.0.0")] | |
| 17 | pub use core::num::{FpCategory, ParseFloatError, ParseIntError, TryFromIntError}; | |
| 18 | ||
| 19 | 20 | #[unstable( |
| 20 | 21 | feature = "nonzero_internals", |
| 21 | 22 | reason = "implementation detail which may disappear or be replaced at any time", |
| 22 | 23 | issue = "none" |
| 23 | 24 | )] |
| 24 | 25 | pub use core::num::ZeroablePrimitive; |
| 25 | ||
| 26 | #[stable(feature = "generic_nonzero", since = "1.79.0")] | |
| 27 | pub use core::num::NonZero; | |
| 28 | ||
| 26 | #[stable(feature = "rust1", since = "1.0.0")] | |
| 27 | pub use core::num::{FpCategory, ParseFloatError, ParseIntError, TryFromIntError}; | |
| 29 | 28 | #[stable(feature = "signed_nonzero", since = "1.34.0")] |
| 30 | 29 | pub use core::num::{NonZeroI128, NonZeroI16, NonZeroI32, NonZeroI64, NonZeroI8, NonZeroIsize}; |
| 31 | ||
| 32 | 30 | #[stable(feature = "nonzero", since = "1.28.0")] |
| 33 | 31 | pub use core::num::{NonZeroU128, NonZeroU16, NonZeroU32, NonZeroU64, NonZeroU8, NonZeroUsize}; |
| 34 | 32 | |
| 35 | #[stable(feature = "int_error_matching", since = "1.55.0")] | |
| 36 | pub use core::num::IntErrorKind; | |
| 37 | ||
| 38 | 33 | #[cfg(test)] |
| 39 | 34 | use crate::fmt; |
| 40 | 35 | #[cfg(test)] |
library/std/src/os/aix/raw.rs-1| ... | ... | @@ -4,6 +4,5 @@ |
| 4 | 4 | |
| 5 | 5 | #[stable(feature = "pthread_t", since = "1.8.0")] |
| 6 | 6 | pub use libc::pthread_t; |
| 7 | ||
| 8 | 7 | #[stable(feature = "raw_ext", since = "1.1.0")] |
| 9 | 8 | pub use libc::{blkcnt_t, blksize_t, dev_t, ino_t, mode_t, nlink_t, off_t, stat, time_t}; |
library/std/src/os/android/fs.rs+1-2| ... | ... | @@ -1,10 +1,9 @@ |
| 1 | 1 | #![stable(feature = "metadata_ext", since = "1.1.0")] |
| 2 | 2 | |
| 3 | 3 | use crate::fs::Metadata; |
| 4 | use crate::sys_common::AsInner; | |
| 5 | ||
| 6 | 4 | #[allow(deprecated)] |
| 7 | 5 | use crate::os::android::raw; |
| 6 | use crate::sys_common::AsInner; | |
| 8 | 7 | |
| 9 | 8 | /// OS-specific extensions to [`fs::Metadata`]. |
| 10 | 9 | /// |
library/std/src/os/android/net.rs-2| ... | ... | @@ -4,9 +4,7 @@ |
| 4 | 4 | |
| 5 | 5 | #[stable(feature = "unix_socket_abstract", since = "1.70.0")] |
| 6 | 6 | pub use crate::os::net::linux_ext::addr::SocketAddrExt; |
| 7 | ||
| 8 | 7 | #[unstable(feature = "unix_socket_ancillary_data", issue = "76915")] |
| 9 | 8 | pub use crate::os::net::linux_ext::socket::UnixSocketExt; |
| 10 | ||
| 11 | 9 | #[unstable(feature = "tcp_quickack", issue = "96256")] |
| 12 | 10 | pub use crate::os::net::linux_ext::tcp::TcpStreamExt; |
library/std/src/os/darwin/fs.rs+2-3| ... | ... | @@ -1,13 +1,12 @@ |
| 1 | 1 | #![allow(dead_code)] |
| 2 | 2 | |
| 3 | #[allow(deprecated)] | |
| 4 | use super::raw; | |
| 3 | 5 | use crate::fs::{self, Metadata}; |
| 4 | 6 | use crate::sealed::Sealed; |
| 5 | 7 | use crate::sys_common::{AsInner, AsInnerMut, IntoInner}; |
| 6 | 8 | use crate::time::SystemTime; |
| 7 | 9 | |
| 8 | #[allow(deprecated)] | |
| 9 | use super::raw; | |
| 10 | ||
| 11 | 10 | /// OS-specific extensions to [`fs::Metadata`]. |
| 12 | 11 | /// |
| 13 | 12 | /// [`fs::Metadata`]: crate::fs::Metadata |
library/std/src/os/dragonfly/fs.rs+1-2| ... | ... | @@ -1,10 +1,9 @@ |
| 1 | 1 | #![stable(feature = "metadata_ext", since = "1.1.0")] |
| 2 | 2 | |
| 3 | 3 | use crate::fs::Metadata; |
| 4 | use crate::sys_common::AsInner; | |
| 5 | ||
| 6 | 4 | #[allow(deprecated)] |
| 7 | 5 | use crate::os::dragonfly::raw; |
| 6 | use crate::sys_common::AsInner; | |
| 8 | 7 | |
| 9 | 8 | /// OS-specific extensions to [`fs::Metadata`]. |
| 10 | 9 | /// |
library/std/src/os/emscripten/fs.rs+1-2| ... | ... | @@ -1,10 +1,9 @@ |
| 1 | 1 | #![stable(feature = "metadata_ext", since = "1.1.0")] |
| 2 | 2 | |
| 3 | 3 | use crate::fs::Metadata; |
| 4 | use crate::sys_common::AsInner; | |
| 5 | ||
| 6 | 4 | #[allow(deprecated)] |
| 7 | 5 | use crate::os::emscripten::raw; |
| 6 | use crate::sys_common::AsInner; | |
| 8 | 7 | |
| 9 | 8 | /// OS-specific extensions to [`fs::Metadata`]. |
| 10 | 9 | /// |
library/std/src/os/espidf/fs.rs+1-2| ... | ... | @@ -1,10 +1,9 @@ |
| 1 | 1 | #![stable(feature = "metadata_ext", since = "1.1.0")] |
| 2 | 2 | |
| 3 | 3 | use crate::fs::Metadata; |
| 4 | use crate::sys_common::AsInner; | |
| 5 | ||
| 6 | 4 | #[allow(deprecated)] |
| 7 | 5 | use crate::os::espidf::raw; |
| 6 | use crate::sys_common::AsInner; | |
| 8 | 7 | |
| 9 | 8 | /// OS-specific extensions to [`fs::Metadata`]. |
| 10 | 9 | /// |
library/std/src/os/fd/owned.rs+1-3| ... | ... | @@ -4,14 +4,12 @@ |
| 4 | 4 | #![deny(unsafe_op_in_unsafe_fn)] |
| 5 | 5 | |
| 6 | 6 | use super::raw::{AsRawFd, FromRawFd, IntoRawFd, RawFd}; |
| 7 | use crate::fmt; | |
| 8 | use crate::fs; | |
| 9 | use crate::io; | |
| 10 | 7 | use crate::marker::PhantomData; |
| 11 | 8 | use crate::mem::ManuallyDrop; |
| 12 | 9 | #[cfg(not(any(target_arch = "wasm32", target_env = "sgx", target_os = "hermit")))] |
| 13 | 10 | use crate::sys::cvt; |
| 14 | 11 | use crate::sys_common::{AsInner, FromInner, IntoInner}; |
| 12 | use crate::{fmt, fs, io}; | |
| 15 | 13 | |
| 16 | 14 | /// A borrowed file descriptor. |
| 17 | 15 | /// |
library/std/src/os/fd/raw.rs+4-4| ... | ... | @@ -2,8 +2,9 @@ |
| 2 | 2 | |
| 3 | 3 | #![stable(feature = "rust1", since = "1.0.0")] |
| 4 | 4 | |
| 5 | use crate::fs; | |
| 6 | use crate::io; | |
| 5 | #[cfg(target_os = "hermit")] | |
| 6 | use hermit_abi as libc; | |
| 7 | ||
| 7 | 8 | #[cfg(target_os = "hermit")] |
| 8 | 9 | use crate::os::hermit::io::OwnedFd; |
| 9 | 10 | #[cfg(not(target_os = "hermit"))] |
| ... | ... | @@ -15,8 +16,7 @@ use crate::os::unix::io::OwnedFd; |
| 15 | 16 | #[cfg(target_os = "wasi")] |
| 16 | 17 | use crate::os::wasi::io::OwnedFd; |
| 17 | 18 | use crate::sys_common::{AsInner, IntoInner}; |
| 18 | #[cfg(target_os = "hermit")] | |
| 19 | use hermit_abi as libc; | |
| 19 | use crate::{fs, io}; | |
| 20 | 20 | |
| 21 | 21 | /// Raw file descriptors. |
| 22 | 22 | #[rustc_allowed_through_unstable_modules] |
library/std/src/os/fortanix_sgx/arch.rs+2-1| ... | ... | @@ -4,9 +4,10 @@ |
| 4 | 4 | //! Software Developer's Manual, Volume 3, Chapter 40. |
| 5 | 5 | #![unstable(feature = "sgx_platform", issue = "56975")] |
| 6 | 6 | |
| 7 | use crate::mem::MaybeUninit; | |
| 8 | 7 | use core::arch::asm; |
| 9 | 8 | |
| 9 | use crate::mem::MaybeUninit; | |
| 10 | ||
| 10 | 11 | /// Wrapper struct to force 16-byte alignment. |
| 11 | 12 | #[repr(align(16))] |
| 12 | 13 | #[unstable(feature = "sgx_platform", issue = "56975")] |
library/std/src/os/fortanix_sgx/mod.rs+6-14| ... | ... | @@ -22,20 +22,12 @@ pub mod usercalls { |
| 22 | 22 | /// Lowest-level interfaces to usercalls and usercall ABI type definitions. |
| 23 | 23 | pub mod raw { |
| 24 | 24 | pub use crate::sys::abi::usercalls::raw::{ |
| 25 | accept_stream, alloc, async_queues, bind_stream, close, connect_stream, exit, flush, | |
| 26 | free, insecure_time, launch_thread, read, read_alloc, send, wait, write, | |
| 27 | }; | |
| 28 | pub use crate::sys::abi::usercalls::raw::{do_usercall, Usercalls as UsercallNrs}; | |
| 29 | pub use crate::sys::abi::usercalls::raw::{Register, RegisterArgument, ReturnValue}; | |
| 30 | ||
| 31 | pub use crate::sys::abi::usercalls::raw::Error; | |
| 32 | pub use crate::sys::abi::usercalls::raw::{ | |
| 33 | ByteBuffer, Cancel, FifoDescriptor, Return, Usercall, | |
| 34 | }; | |
| 35 | pub use crate::sys::abi::usercalls::raw::{Fd, Result, Tcs}; | |
| 36 | pub use crate::sys::abi::usercalls::raw::{ | |
| 37 | EV_RETURNQ_NOT_EMPTY, EV_UNPARK, EV_USERCALLQ_NOT_FULL, FD_STDERR, FD_STDIN, FD_STDOUT, | |
| 38 | RESULT_SUCCESS, USERCALL_USER_DEFINED, WAIT_INDEFINITE, WAIT_NO, | |
| 25 | accept_stream, alloc, async_queues, bind_stream, close, connect_stream, do_usercall, | |
| 26 | exit, flush, free, insecure_time, launch_thread, read, read_alloc, send, wait, write, | |
| 27 | ByteBuffer, Cancel, Error, Fd, FifoDescriptor, Register, RegisterArgument, Result, | |
| 28 | Return, ReturnValue, Tcs, Usercall, Usercalls as UsercallNrs, EV_RETURNQ_NOT_EMPTY, | |
| 29 | EV_UNPARK, EV_USERCALLQ_NOT_FULL, FD_STDERR, FD_STDIN, FD_STDOUT, RESULT_SUCCESS, | |
| 30 | USERCALL_USER_DEFINED, WAIT_INDEFINITE, WAIT_NO, | |
| 39 | 31 | }; |
| 40 | 32 | } |
| 41 | 33 | } |
library/std/src/os/freebsd/fs.rs+1-2| ... | ... | @@ -1,10 +1,9 @@ |
| 1 | 1 | #![stable(feature = "metadata_ext", since = "1.1.0")] |
| 2 | 2 | |
| 3 | 3 | use crate::fs::Metadata; |
| 4 | use crate::sys_common::AsInner; | |
| 5 | ||
| 6 | 4 | #[allow(deprecated)] |
| 7 | 5 | use crate::os::freebsd::raw; |
| 6 | use crate::sys_common::AsInner; | |
| 8 | 7 | |
| 9 | 8 | /// OS-specific extensions to [`fs::Metadata`]. |
| 10 | 9 | /// |
library/std/src/os/haiku/fs.rs+1-2| ... | ... | @@ -1,10 +1,9 @@ |
| 1 | 1 | #![stable(feature = "metadata_ext", since = "1.1.0")] |
| 2 | 2 | |
| 3 | 3 | use crate::fs::Metadata; |
| 4 | use crate::sys_common::AsInner; | |
| 5 | ||
| 6 | 4 | #[allow(deprecated)] |
| 7 | 5 | use crate::os::haiku::raw; |
| 6 | use crate::sys_common::AsInner; | |
| 8 | 7 | |
| 9 | 8 | /// OS-specific extensions to [`fs::Metadata`]. |
| 10 | 9 | /// |
library/std/src/os/hermit/io/net.rs+1-2| ... | ... | @@ -1,5 +1,4 @@ |
| 1 | use crate::os::hermit::io::OwnedFd; | |
| 2 | use crate::os::hermit::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd}; | |
| 1 | use crate::os::hermit::io::{AsRawFd, FromRawFd, IntoRawFd, OwnedFd, RawFd}; | |
| 3 | 2 | use crate::sys_common::{self, AsInner, FromInner, IntoInner}; |
| 4 | 3 | use crate::{net, sys}; |
| 5 | 4 |
library/std/src/os/illumos/fs.rs+1-2| ... | ... | @@ -1,10 +1,9 @@ |
| 1 | 1 | #![stable(feature = "metadata_ext", since = "1.1.0")] |
| 2 | 2 | |
| 3 | 3 | use crate::fs::Metadata; |
| 4 | use crate::sys_common::AsInner; | |
| 5 | ||
| 6 | 4 | #[allow(deprecated)] |
| 7 | 5 | use crate::os::illumos::raw; |
| 6 | use crate::sys_common::AsInner; | |
| 8 | 7 | |
| 9 | 8 | /// OS-specific extensions to [`fs::Metadata`]. |
| 10 | 9 | /// |
library/std/src/os/ios/mod.rs-1| ... | ... | @@ -7,7 +7,6 @@ pub mod fs { |
| 7 | 7 | #[doc(inline)] |
| 8 | 8 | #[stable(feature = "file_set_times", since = "1.75.0")] |
| 9 | 9 | pub use crate::os::darwin::fs::FileTimesExt; |
| 10 | ||
| 11 | 10 | #[doc(inline)] |
| 12 | 11 | #[stable(feature = "metadata_ext", since = "1.1.0")] |
| 13 | 12 | pub use crate::os::darwin::fs::MetadataExt; |
library/std/src/os/l4re/fs.rs+1-2| ... | ... | @@ -5,10 +5,9 @@ |
| 5 | 5 | #![stable(feature = "metadata_ext", since = "1.1.0")] |
| 6 | 6 | |
| 7 | 7 | use crate::fs::Metadata; |
| 8 | use crate::sys_common::AsInner; | |
| 9 | ||
| 10 | 8 | #[allow(deprecated)] |
| 11 | 9 | use crate::os::l4re::raw; |
| 10 | use crate::sys_common::AsInner; | |
| 12 | 11 | |
| 13 | 12 | /// OS-specific extensions to [`fs::Metadata`]. |
| 14 | 13 | /// |
library/std/src/os/linux/fs.rs+1-2| ... | ... | @@ -5,10 +5,9 @@ |
| 5 | 5 | #![stable(feature = "metadata_ext", since = "1.1.0")] |
| 6 | 6 | |
| 7 | 7 | use crate::fs::Metadata; |
| 8 | use crate::sys_common::AsInner; | |
| 9 | ||
| 10 | 8 | #[allow(deprecated)] |
| 11 | 9 | use crate::os::linux::raw; |
| 10 | use crate::sys_common::AsInner; | |
| 12 | 11 | |
| 13 | 12 | /// OS-specific extensions to [`fs::Metadata`]. |
| 14 | 13 | /// |
library/std/src/os/linux/net.rs-2| ... | ... | @@ -4,9 +4,7 @@ |
| 4 | 4 | |
| 5 | 5 | #[stable(feature = "unix_socket_abstract", since = "1.70.0")] |
| 6 | 6 | pub use crate::os::net::linux_ext::addr::SocketAddrExt; |
| 7 | ||
| 8 | 7 | #[unstable(feature = "unix_socket_ancillary_data", issue = "76915")] |
| 9 | 8 | pub use crate::os::net::linux_ext::socket::UnixSocketExt; |
| 10 | ||
| 11 | 9 | #[unstable(feature = "tcp_quickack", issue = "96256")] |
| 12 | 10 | pub use crate::os::net::linux_ext::tcp::TcpStreamExt; |
library/std/src/os/macos/mod.rs-1| ... | ... | @@ -7,7 +7,6 @@ pub mod fs { |
| 7 | 7 | #[doc(inline)] |
| 8 | 8 | #[stable(feature = "file_set_times", since = "1.75.0")] |
| 9 | 9 | pub use crate::os::darwin::fs::FileTimesExt; |
| 10 | ||
| 11 | 10 | #[doc(inline)] |
| 12 | 11 | #[stable(feature = "metadata_ext", since = "1.1.0")] |
| 13 | 12 | pub use crate::os::darwin::fs::MetadataExt; |
library/std/src/os/net/linux_ext/tcp.rs+1-2| ... | ... | @@ -2,10 +2,9 @@ |
| 2 | 2 | //! |
| 3 | 3 | //! [`std::net`]: crate::net |
| 4 | 4 | |
| 5 | use crate::io; | |
| 6 | use crate::net; | |
| 7 | 5 | use crate::sealed::Sealed; |
| 8 | 6 | use crate::sys_common::AsInner; |
| 7 | use crate::{io, net}; | |
| 9 | 8 | |
| 10 | 9 | /// Os-specific extensions for [`TcpStream`] |
| 11 | 10 | /// |
library/std/src/os/net/linux_ext/tests.rs+6-8| ... | ... | @@ -1,9 +1,8 @@ |
| 1 | 1 | #[test] |
| 2 | 2 | fn quickack() { |
| 3 | use crate::{ | |
| 4 | net::{test::next_test_ip4, TcpListener, TcpStream}, | |
| 5 | os::net::linux_ext::tcp::TcpStreamExt, | |
| 6 | }; | |
| 3 | use crate::net::test::next_test_ip4; | |
| 4 | use crate::net::{TcpListener, TcpStream}; | |
| 5 | use crate::os::net::linux_ext::tcp::TcpStreamExt; | |
| 7 | 6 | |
| 8 | 7 | macro_rules! t { |
| 9 | 8 | ($e:expr) => { |
| ... | ... | @@ -30,10 +29,9 @@ fn quickack() { |
| 30 | 29 | #[test] |
| 31 | 30 | #[cfg(target_os = "linux")] |
| 32 | 31 | fn deferaccept() { |
| 33 | use crate::{ | |
| 34 | net::{test::next_test_ip4, TcpListener, TcpStream}, | |
| 35 | os::net::linux_ext::tcp::TcpStreamExt, | |
| 36 | }; | |
| 32 | use crate::net::test::next_test_ip4; | |
| 33 | use crate::net::{TcpListener, TcpStream}; | |
| 34 | use crate::os::net::linux_ext::tcp::TcpStreamExt; | |
| 37 | 35 | |
| 38 | 36 | macro_rules! t { |
| 39 | 37 | ($e:expr) => { |
library/std/src/os/netbsd/fs.rs+1-2| ... | ... | @@ -1,10 +1,9 @@ |
| 1 | 1 | #![stable(feature = "metadata_ext", since = "1.1.0")] |
| 2 | 2 | |
| 3 | 3 | use crate::fs::Metadata; |
| 4 | use crate::sys_common::AsInner; | |
| 5 | ||
| 6 | 4 | #[allow(deprecated)] |
| 7 | 5 | use crate::os::netbsd::raw; |
| 6 | use crate::sys_common::AsInner; | |
| 8 | 7 | |
| 9 | 8 | /// OS-specific extensions to [`fs::Metadata`]. |
| 10 | 9 | /// |
library/std/src/os/openbsd/fs.rs+1-2| ... | ... | @@ -1,10 +1,9 @@ |
| 1 | 1 | #![stable(feature = "metadata_ext", since = "1.1.0")] |
| 2 | 2 | |
| 3 | 3 | use crate::fs::Metadata; |
| 4 | use crate::sys_common::AsInner; | |
| 5 | ||
| 6 | 4 | #[allow(deprecated)] |
| 7 | 5 | use crate::os::openbsd::raw; |
| 6 | use crate::sys_common::AsInner; | |
| 8 | 7 | |
| 9 | 8 | /// OS-specific extensions to [`fs::Metadata`]. |
| 10 | 9 | /// |
library/std/src/os/redox/fs.rs+1-2| ... | ... | @@ -1,10 +1,9 @@ |
| 1 | 1 | #![stable(feature = "metadata_ext", since = "1.1.0")] |
| 2 | 2 | |
| 3 | 3 | use crate::fs::Metadata; |
| 4 | use crate::sys_common::AsInner; | |
| 5 | ||
| 6 | 4 | #[allow(deprecated)] |
| 7 | 5 | use crate::os::redox::raw; |
| 6 | use crate::sys_common::AsInner; | |
| 8 | 7 | |
| 9 | 8 | /// OS-specific extensions to [`fs::Metadata`]. |
| 10 | 9 | /// |
library/std/src/os/solaris/fs.rs+1-2| ... | ... | @@ -1,10 +1,9 @@ |
| 1 | 1 | #![stable(feature = "metadata_ext", since = "1.1.0")] |
| 2 | 2 | |
| 3 | 3 | use crate::fs::Metadata; |
| 4 | use crate::sys_common::AsInner; | |
| 5 | ||
| 6 | 4 | #[allow(deprecated)] |
| 7 | 5 | use crate::os::solaris::raw; |
| 6 | use crate::sys_common::AsInner; | |
| 8 | 7 | |
| 9 | 8 | /// OS-specific extensions to [`fs::Metadata`]. |
| 10 | 9 | /// |
library/std/src/os/solid/io.rs+1-3| ... | ... | @@ -46,12 +46,10 @@ |
| 46 | 46 | |
| 47 | 47 | #![unstable(feature = "solid_ext", issue = "none")] |
| 48 | 48 | |
| 49 | use crate::fmt; | |
| 50 | 49 | use crate::marker::PhantomData; |
| 51 | 50 | use crate::mem::ManuallyDrop; |
| 52 | use crate::net; | |
| 53 | use crate::sys; | |
| 54 | 51 | use crate::sys_common::{self, AsInner, FromInner, IntoInner}; |
| 52 | use crate::{fmt, net, sys}; | |
| 55 | 53 | |
| 56 | 54 | /// Raw file descriptors. |
| 57 | 55 | pub type RawFd = i32; |
library/std/src/os/uefi/env.rs+2-1| ... | ... | @@ -2,8 +2,9 @@ |
| 2 | 2 | |
| 3 | 3 | #![unstable(feature = "uefi_std", issue = "100499")] |
| 4 | 4 | |
| 5 | use crate::ffi::c_void; | |
| 6 | use crate::ptr::NonNull; | |
| 5 | 7 | use crate::sync::atomic::{AtomicBool, AtomicPtr, Ordering}; |
| 6 | use crate::{ffi::c_void, ptr::NonNull}; | |
| 7 | 8 | |
| 8 | 9 | static SYSTEM_TABLE: AtomicPtr<c_void> = AtomicPtr::new(crate::ptr::null_mut()); |
| 9 | 10 | static IMAGE_HANDLE: AtomicPtr<c_void> = AtomicPtr::new(crate::ptr::null_mut()); |
library/std/src/os/unix/fs.rs+7-7| ... | ... | @@ -4,18 +4,18 @@ |
| 4 | 4 | |
| 5 | 5 | #![stable(feature = "rust1", since = "1.0.0")] |
| 6 | 6 | |
| 7 | #[allow(unused_imports)] | |
| 8 | use io::{Read, Write}; | |
| 9 | ||
| 7 | 10 | use super::platform::fs::MetadataExt as _; |
| 11 | // Used for `File::read` on intra-doc links | |
| 12 | use crate::ffi::OsStr; | |
| 8 | 13 | use crate::fs::{self, OpenOptions, Permissions}; |
| 9 | use crate::io; | |
| 10 | 14 | use crate::os::unix::io::{AsFd, AsRawFd}; |
| 11 | 15 | use crate::path::Path; |
| 12 | use crate::sys; | |
| 13 | use crate::sys_common::{AsInner, AsInnerMut, FromInner}; | |
| 14 | // Used for `File::read` on intra-doc links | |
| 15 | use crate::ffi::OsStr; | |
| 16 | 16 | use crate::sealed::Sealed; |
| 17 | #[allow(unused_imports)] | |
| 18 | use io::{Read, Write}; | |
| 17 | use crate::sys_common::{AsInner, AsInnerMut, FromInner}; | |
| 18 | use crate::{io, sys}; | |
| 19 | 19 | |
| 20 | 20 | // Tests for this module |
| 21 | 21 | #[cfg(test)] |
library/std/src/os/unix/net/datagram.rs+14-14| ... | ... | @@ -1,3 +1,17 @@ |
| 1 | #[cfg(any( | |
| 2 | target_os = "linux", | |
| 3 | target_os = "android", | |
| 4 | target_os = "dragonfly", | |
| 5 | target_os = "freebsd", | |
| 6 | target_os = "openbsd", | |
| 7 | target_os = "netbsd", | |
| 8 | target_os = "solaris", | |
| 9 | target_os = "illumos", | |
| 10 | target_os = "haiku", | |
| 11 | target_os = "nto", | |
| 12 | ))] | |
| 13 | use libc::MSG_NOSIGNAL; | |
| 14 | ||
| 1 | 15 | #[cfg(any(doc, target_os = "android", target_os = "linux"))] |
| 2 | 16 | use super::{recv_vectored_with_ancillary_from, send_vectored_with_ancillary_to, SocketAncillary}; |
| 3 | 17 | use super::{sockaddr_un, SocketAddr}; |
| ... | ... | @@ -12,20 +26,6 @@ use crate::sys::net::Socket; |
| 12 | 26 | use crate::sys_common::{AsInner, FromInner, IntoInner}; |
| 13 | 27 | use crate::time::Duration; |
| 14 | 28 | use crate::{fmt, io}; |
| 15 | ||
| 16 | #[cfg(any( | |
| 17 | target_os = "linux", | |
| 18 | target_os = "android", | |
| 19 | target_os = "dragonfly", | |
| 20 | target_os = "freebsd", | |
| 21 | target_os = "openbsd", | |
| 22 | target_os = "netbsd", | |
| 23 | target_os = "solaris", | |
| 24 | target_os = "illumos", | |
| 25 | target_os = "haiku", | |
| 26 | target_os = "nto", | |
| 27 | ))] | |
| 28 | use libc::MSG_NOSIGNAL; | |
| 29 | 29 | #[cfg(not(any( |
| 30 | 30 | target_os = "linux", |
| 31 | 31 | target_os = "android", |
library/std/src/os/unix/net/tests.rs+4-6| ... | ... | @@ -1,18 +1,16 @@ |
| 1 | 1 | use super::*; |
| 2 | 2 | use crate::io::prelude::*; |
| 3 | 3 | use crate::io::{self, ErrorKind, IoSlice, IoSliceMut}; |
| 4 | #[cfg(target_os = "android")] | |
| 5 | use crate::os::android::net::{SocketAddrExt, UnixSocketExt}; | |
| 6 | #[cfg(target_os = "linux")] | |
| 7 | use crate::os::linux::net::{SocketAddrExt, UnixSocketExt}; | |
| 4 | 8 | #[cfg(any(target_os = "android", target_os = "linux"))] |
| 5 | 9 | use crate::os::unix::io::AsRawFd; |
| 6 | 10 | use crate::sys_common::io::test::tmpdir; |
| 7 | 11 | use crate::thread; |
| 8 | 12 | use crate::time::Duration; |
| 9 | 13 | |
| 10 | #[cfg(target_os = "android")] | |
| 11 | use crate::os::android::net::{SocketAddrExt, UnixSocketExt}; | |
| 12 | ||
| 13 | #[cfg(target_os = "linux")] | |
| 14 | use crate::os::linux::net::{SocketAddrExt, UnixSocketExt}; | |
| 15 | ||
| 16 | 14 | macro_rules! or_panic { |
| 17 | 15 | ($e:expr) => { |
| 18 | 16 | match $e { |
library/std/src/os/unix/net/ucred.rs+8-8| ... | ... | @@ -23,9 +23,8 @@ pub struct UCred { |
| 23 | 23 | pub pid: Option<pid_t>, |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | #[cfg(any(target_os = "android", target_os = "linux"))] | |
| 27 | pub(super) use self::impl_linux::peer_cred; | |
| 28 | ||
| 26 | #[cfg(target_vendor = "apple")] | |
| 27 | pub(super) use self::impl_apple::peer_cred; | |
| 29 | 28 | #[cfg(any( |
| 30 | 29 | target_os = "dragonfly", |
| 31 | 30 | target_os = "freebsd", |
| ... | ... | @@ -34,17 +33,17 @@ pub(super) use self::impl_linux::peer_cred; |
| 34 | 33 | target_os = "nto" |
| 35 | 34 | ))] |
| 36 | 35 | pub(super) use self::impl_bsd::peer_cred; |
| 37 | ||
| 38 | #[cfg(target_vendor = "apple")] | |
| 39 | pub(super) use self::impl_apple::peer_cred; | |
| 36 | #[cfg(any(target_os = "android", target_os = "linux"))] | |
| 37 | pub(super) use self::impl_linux::peer_cred; | |
| 40 | 38 | |
| 41 | 39 | #[cfg(any(target_os = "linux", target_os = "android"))] |
| 42 | 40 | mod impl_linux { |
| 41 | use libc::{c_void, getsockopt, socklen_t, ucred, SOL_SOCKET, SO_PEERCRED}; | |
| 42 | ||
| 43 | 43 | use super::UCred; |
| 44 | 44 | use crate::os::unix::io::AsRawFd; |
| 45 | 45 | use crate::os::unix::net::UnixStream; |
| 46 | 46 | use crate::{io, mem}; |
| 47 | use libc::{c_void, getsockopt, socklen_t, ucred, SOL_SOCKET, SO_PEERCRED}; | |
| 48 | 47 | |
| 49 | 48 | pub fn peer_cred(socket: &UnixStream) -> io::Result<UCred> { |
| 50 | 49 | let ucred_size = mem::size_of::<ucred>(); |
| ... | ... | @@ -99,11 +98,12 @@ mod impl_bsd { |
| 99 | 98 | |
| 100 | 99 | #[cfg(target_vendor = "apple")] |
| 101 | 100 | mod impl_apple { |
| 101 | use libc::{c_void, getpeereid, getsockopt, pid_t, socklen_t, LOCAL_PEERPID, SOL_LOCAL}; | |
| 102 | ||
| 102 | 103 | use super::UCred; |
| 103 | 104 | use crate::os::unix::io::AsRawFd; |
| 104 | 105 | use crate::os::unix::net::UnixStream; |
| 105 | 106 | use crate::{io, mem}; |
| 106 | use libc::{c_void, getpeereid, getsockopt, pid_t, socklen_t, LOCAL_PEERPID, SOL_LOCAL}; | |
| 107 | 107 | |
| 108 | 108 | pub fn peer_cred(socket: &UnixStream) -> io::Result<UCred> { |
| 109 | 109 | let mut cred = UCred { uid: 1, gid: 1, pid: None }; |
library/std/src/os/unix/net/ucred/tests.rs+2-1| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | use crate::os::unix::net::UnixStream; | |
| 2 | 1 | use libc::{getegid, geteuid, getpid}; |
| 3 | 2 | |
| 3 | use crate::os::unix::net::UnixStream; | |
| 4 | ||
| 4 | 5 | #[test] |
| 5 | 6 | #[cfg(any( |
| 6 | 7 | target_os = "android", |
library/std/src/os/unix/process.rs+3-5| ... | ... | @@ -4,15 +4,13 @@ |
| 4 | 4 | |
| 5 | 5 | #![stable(feature = "rust1", since = "1.0.0")] |
| 6 | 6 | |
| 7 | use cfg_if::cfg_if; | |
| 8 | ||
| 7 | 9 | use crate::ffi::OsStr; |
| 8 | use crate::io; | |
| 9 | 10 | use crate::os::unix::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, OwnedFd, RawFd}; |
| 10 | use crate::process; | |
| 11 | 11 | use crate::sealed::Sealed; |
| 12 | use crate::sys; | |
| 13 | 12 | use crate::sys_common::{AsInner, AsInnerMut, FromInner, IntoInner}; |
| 14 | ||
| 15 | use cfg_if::cfg_if; | |
| 13 | use crate::{io, process, sys}; | |
| 16 | 14 | |
| 17 | 15 | cfg_if! { |
| 18 | 16 | if #[cfg(any(target_os = "vxworks", target_os = "espidf", target_os = "horizon", target_os = "vita"))] { |
library/std/src/os/wasi/fs.rs+4-3| ... | ... | @@ -5,14 +5,15 @@ |
| 5 | 5 | #![deny(unsafe_op_in_unsafe_fn)] |
| 6 | 6 | #![unstable(feature = "wasi_ext", issue = "71213")] |
| 7 | 7 | |
| 8 | // Used for `File::read` on intra-doc links | |
| 9 | #[allow(unused_imports)] | |
| 10 | use io::{Read, Write}; | |
| 11 | ||
| 8 | 12 | use crate::ffi::OsStr; |
| 9 | 13 | use crate::fs::{self, File, Metadata, OpenOptions}; |
| 10 | 14 | use crate::io::{self, IoSlice, IoSliceMut}; |
| 11 | 15 | use crate::path::{Path, PathBuf}; |
| 12 | 16 | use crate::sys_common::{AsInner, AsInnerMut, FromInner}; |
| 13 | // Used for `File::read` on intra-doc links | |
| 14 | #[allow(unused_imports)] | |
| 15 | use io::{Read, Write}; | |
| 16 | 17 | |
| 17 | 18 | /// WASI-specific extensions to [`File`]. |
| 18 | 19 | pub trait FileExt { |
library/std/src/os/wasi/net/mod.rs+1-2| ... | ... | @@ -2,9 +2,8 @@ |
| 2 | 2 | |
| 3 | 3 | #![unstable(feature = "wasi_ext", issue = "71213")] |
| 4 | 4 | |
| 5 | use crate::io; | |
| 6 | use crate::net; | |
| 7 | 5 | use crate::sys_common::AsInner; |
| 6 | use crate::{io, net}; | |
| 8 | 7 | |
| 9 | 8 | /// WASI-specific extensions to [`std::net::TcpListener`]. |
| 10 | 9 | /// |
library/std/src/os/windows/ffi.rs+2-3| ... | ... | @@ -56,11 +56,10 @@ |
| 56 | 56 | use crate::ffi::{OsStr, OsString}; |
| 57 | 57 | use crate::sealed::Sealed; |
| 58 | 58 | use crate::sys::os_str::Buf; |
| 59 | use crate::sys_common::wtf8::Wtf8Buf; | |
| 60 | use crate::sys_common::{AsInner, FromInner}; | |
| 61 | ||
| 62 | 59 | #[stable(feature = "rust1", since = "1.0.0")] |
| 63 | 60 | pub use crate::sys_common::wtf8::EncodeWide; |
| 61 | use crate::sys_common::wtf8::Wtf8Buf; | |
| 62 | use crate::sys_common::{AsInner, FromInner}; | |
| 64 | 63 | |
| 65 | 64 | /// Windows-specific extensions to [`OsString`]. |
| 66 | 65 | /// |
library/std/src/os/windows/fs.rs+1-2| ... | ... | @@ -5,12 +5,11 @@ |
| 5 | 5 | #![stable(feature = "rust1", since = "1.0.0")] |
| 6 | 6 | |
| 7 | 7 | use crate::fs::{self, Metadata, OpenOptions}; |
| 8 | use crate::io; | |
| 9 | 8 | use crate::path::Path; |
| 10 | 9 | use crate::sealed::Sealed; |
| 11 | use crate::sys; | |
| 12 | 10 | use crate::sys_common::{AsInner, AsInnerMut, IntoInner}; |
| 13 | 11 | use crate::time::SystemTime; |
| 12 | use crate::{io, sys}; | |
| 14 | 13 | |
| 15 | 14 | /// Windows-specific extensions to [`fs::File`]. |
| 16 | 15 | #[stable(feature = "file_offset", since = "1.15.0")] |
library/std/src/os/windows/io/handle.rs+1-5| ... | ... | @@ -3,15 +3,11 @@ |
| 3 | 3 | #![stable(feature = "io_safety", since = "1.63.0")] |
| 4 | 4 | |
| 5 | 5 | use super::raw::{AsRawHandle, FromRawHandle, IntoRawHandle, RawHandle}; |
| 6 | use crate::fmt; | |
| 7 | use crate::fs; | |
| 8 | use crate::io; | |
| 9 | 6 | use crate::marker::PhantomData; |
| 10 | 7 | use crate::mem::ManuallyDrop; |
| 11 | use crate::ptr; | |
| 12 | use crate::sys; | |
| 13 | 8 | use crate::sys::cvt; |
| 14 | 9 | use crate::sys_common::{AsInner, FromInner, IntoInner}; |
| 10 | use crate::{fmt, fs, io, ptr, sys}; | |
| 15 | 11 | |
| 16 | 12 | /// A borrowed handle. |
| 17 | 13 | /// |
library/std/src/os/windows/io/raw.rs+1-5| ... | ... | @@ -2,16 +2,12 @@ |
| 2 | 2 | |
| 3 | 3 | #![stable(feature = "rust1", since = "1.0.0")] |
| 4 | 4 | |
| 5 | use crate::fs; | |
| 6 | use crate::io; | |
| 7 | use crate::net; | |
| 8 | 5 | #[cfg(doc)] |
| 9 | 6 | use crate::os::windows::io::{AsHandle, AsSocket}; |
| 10 | 7 | use crate::os::windows::io::{OwnedHandle, OwnedSocket}; |
| 11 | 8 | use crate::os::windows::raw; |
| 12 | use crate::ptr; | |
| 13 | use crate::sys; | |
| 14 | 9 | use crate::sys_common::{self, AsInner, FromInner, IntoInner}; |
| 10 | use crate::{fs, io, net, ptr, sys}; | |
| 15 | 11 | |
| 16 | 12 | /// Raw HANDLEs. |
| 17 | 13 | #[stable(feature = "rust1", since = "1.0.0")] |
library/std/src/os/windows/io/socket.rs+1-3| ... | ... | @@ -3,13 +3,11 @@ |
| 3 | 3 | #![stable(feature = "io_safety", since = "1.63.0")] |
| 4 | 4 | |
| 5 | 5 | use super::raw::{AsRawSocket, FromRawSocket, IntoRawSocket, RawSocket}; |
| 6 | use crate::fmt; | |
| 7 | use crate::io; | |
| 8 | 6 | use crate::marker::PhantomData; |
| 9 | 7 | use crate::mem::{self, ManuallyDrop}; |
| 10 | use crate::sys; | |
| 11 | 8 | #[cfg(not(target_vendor = "uwp"))] |
| 12 | 9 | use crate::sys::cvt; |
| 10 | use crate::{fmt, io, sys}; | |
| 13 | 11 | |
| 14 | 12 | /// A borrowed socket. |
| 15 | 13 | /// |
library/std/src/os/windows/process.rs+1-2| ... | ... | @@ -8,10 +8,9 @@ use crate::ffi::OsStr; |
| 8 | 8 | use crate::os::windows::io::{ |
| 9 | 9 | AsHandle, AsRawHandle, BorrowedHandle, FromRawHandle, IntoRawHandle, OwnedHandle, RawHandle, |
| 10 | 10 | }; |
| 11 | use crate::process; | |
| 12 | 11 | use crate::sealed::Sealed; |
| 13 | use crate::sys; | |
| 14 | 12 | use crate::sys_common::{AsInner, AsInnerMut, FromInner, IntoInner}; |
| 13 | use crate::{process, sys}; | |
| 15 | 14 | |
| 16 | 15 | #[stable(feature = "process_extensions", since = "1.2.0")] |
| 17 | 16 | impl FromRawHandle for process::Stdio { |
library/std/src/os/xous/services.rs+2-1| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | use crate::os::xous::ffi::Connection; | |
| 2 | 1 | use core::sync::atomic::{AtomicU32, Ordering}; |
| 3 | 2 | |
| 3 | use crate::os::xous::ffi::Connection; | |
| 4 | ||
| 4 | 5 | mod dns; |
| 5 | 6 | pub(crate) use dns::*; |
| 6 | 7 |
library/std/src/os/xous/services/dns.rs+2-1| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | use core::sync::atomic::{AtomicU32, Ordering}; | |
| 2 | ||
| 1 | 3 | use crate::os::xous::ffi::Connection; |
| 2 | 4 | use crate::os::xous::services::connect; |
| 3 | use core::sync::atomic::{AtomicU32, Ordering}; | |
| 4 | 5 | |
| 5 | 6 | #[repr(usize)] |
| 6 | 7 | pub(crate) enum DnsLendMut { |
library/std/src/os/xous/services/log.rs+2-1| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | use crate::os::xous::ffi::Connection; | |
| 2 | 1 | use core::sync::atomic::{AtomicU32, Ordering}; |
| 3 | 2 | |
| 3 | use crate::os::xous::ffi::Connection; | |
| 4 | ||
| 4 | 5 | /// Group a `usize` worth of bytes into a `usize` and return it, beginning from |
| 5 | 6 | /// `offset` * sizeof(usize) bytes from the start. For example, |
| 6 | 7 | /// `group_or_null([1,2,3,4,5,6,7,8], 1)` on a 32-bit system will return a |
library/std/src/os/xous/services/net.rs+2-1| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | use core::sync::atomic::{AtomicU32, Ordering}; | |
| 2 | ||
| 1 | 3 | use crate::os::xous::ffi::Connection; |
| 2 | 4 | use crate::os::xous::services::connect; |
| 3 | use core::sync::atomic::{AtomicU32, Ordering}; | |
| 4 | 5 | |
| 5 | 6 | pub(crate) enum NetBlockingScalar { |
| 6 | 7 | StdGetTtlUdp(u16 /* fd */), /* 36 */ |
library/std/src/os/xous/services/systime.rs+2-1| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | use crate::os::xous::ffi::{connect, Connection}; | |
| 2 | 1 | use core::sync::atomic::{AtomicU32, Ordering}; |
| 3 | 2 | |
| 3 | use crate::os::xous::ffi::{connect, Connection}; | |
| 4 | ||
| 4 | 5 | pub(crate) enum SystimeScalar { |
| 5 | 6 | GetUtcTimeMs, |
| 6 | 7 | } |
library/std/src/os/xous/services/ticktimer.rs+2-1| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | use crate::os::xous::ffi::Connection; | |
| 2 | 1 | use core::sync::atomic::{AtomicU32, Ordering}; |
| 3 | 2 | |
| 3 | use crate::os::xous::ffi::Connection; | |
| 4 | ||
| 4 | 5 | pub(crate) enum TicktimerScalar { |
| 5 | 6 | ElapsedMs, |
| 6 | 7 | SleepMs(usize), |
library/std/src/panic.rs+5-10| ... | ... | @@ -3,12 +3,10 @@ |
| 3 | 3 | #![stable(feature = "std_panic", since = "1.9.0")] |
| 4 | 4 | |
| 5 | 5 | use crate::any::Any; |
| 6 | use crate::collections; | |
| 7 | use crate::fmt; | |
| 8 | use crate::panicking; | |
| 9 | 6 | use crate::sync::atomic::{AtomicU8, Ordering}; |
| 10 | 7 | use crate::sync::{Condvar, Mutex, RwLock}; |
| 11 | 8 | use crate::thread::Result; |
| 9 | use crate::{collections, fmt, panicking}; | |
| 12 | 10 | |
| 13 | 11 | #[stable(feature = "panic_hooks", since = "1.10.0")] |
| 14 | 12 | #[deprecated( |
| ... | ... | @@ -236,18 +234,15 @@ pub macro panic_2015 { |
| 236 | 234 | #[doc(hidden)] |
| 237 | 235 | #[unstable(feature = "edition_panic", issue = "none", reason = "use panic!() instead")] |
| 238 | 236 | pub use core::panic::panic_2021; |
| 239 | ||
| 240 | 237 | #[stable(feature = "panic_hooks", since = "1.10.0")] |
| 241 | pub use crate::panicking::{set_hook, take_hook}; | |
| 238 | pub use core::panic::Location; | |
| 239 | #[stable(feature = "catch_unwind", since = "1.9.0")] | |
| 240 | pub use core::panic::{AssertUnwindSafe, RefUnwindSafe, UnwindSafe}; | |
| 242 | 241 | |
| 243 | 242 | #[unstable(feature = "panic_update_hook", issue = "92649")] |
| 244 | 243 | pub use crate::panicking::update_hook; |
| 245 | ||
| 246 | 244 | #[stable(feature = "panic_hooks", since = "1.10.0")] |
| 247 | pub use core::panic::Location; | |
| 248 | ||
| 249 | #[stable(feature = "catch_unwind", since = "1.9.0")] | |
| 250 | pub use core::panic::{AssertUnwindSafe, RefUnwindSafe, UnwindSafe}; | |
| 245 | pub use crate::panicking::{set_hook, take_hook}; | |
| 251 | 246 | |
| 252 | 247 | /// Panics the current thread with the given message as the panic payload. |
| 253 | 248 | /// |
library/std/src/panicking.rs+9-12| ... | ... | @@ -9,26 +9,23 @@ |
| 9 | 9 | |
| 10 | 10 | #![deny(unsafe_op_in_unsafe_fn)] |
| 11 | 11 | |
| 12 | use crate::panic::{BacktraceStyle, PanicHookInfo}; | |
| 13 | 12 | use core::panic::{Location, PanicPayload}; |
| 14 | 13 | |
| 14 | // make sure to use the stderr output configured | |
| 15 | // by libtest in the real copy of std | |
| 16 | #[cfg(test)] | |
| 17 | use realstd::io::try_set_output_capture; | |
| 18 | ||
| 15 | 19 | use crate::any::Any; |
| 16 | use crate::fmt; | |
| 17 | use crate::intrinsics; | |
| 20 | #[cfg(not(test))] | |
| 21 | use crate::io::try_set_output_capture; | |
| 18 | 22 | use crate::mem::{self, ManuallyDrop}; |
| 19 | use crate::process; | |
| 23 | use crate::panic::{BacktraceStyle, PanicHookInfo}; | |
| 20 | 24 | use crate::sync::atomic::{AtomicBool, Ordering}; |
| 21 | 25 | use crate::sync::{PoisonError, RwLock}; |
| 22 | 26 | use crate::sys::backtrace; |
| 23 | 27 | use crate::sys::stdio::panic_output; |
| 24 | use crate::thread; | |
| 25 | ||
| 26 | #[cfg(not(test))] | |
| 27 | use crate::io::try_set_output_capture; | |
| 28 | // make sure to use the stderr output configured | |
| 29 | // by libtest in the real copy of std | |
| 30 | #[cfg(test)] | |
| 31 | use realstd::io::try_set_output_capture; | |
| 28 | use crate::{fmt, intrinsics, process, thread}; | |
| 32 | 29 | |
| 33 | 30 | // Binary interface to the panic runtime that the standard library depends on. |
| 34 | 31 | // |
library/std/src/path.rs+2-7| ... | ... | @@ -71,22 +71,17 @@ |
| 71 | 71 | mod tests; |
| 72 | 72 | |
| 73 | 73 | use crate::borrow::{Borrow, Cow}; |
| 74 | use crate::cmp; | |
| 75 | 74 | use crate::collections::TryReserveError; |
| 76 | 75 | use crate::error::Error; |
| 77 | use crate::fmt; | |
| 78 | use crate::fs; | |
| 76 | use crate::ffi::{os_str, OsStr, OsString}; | |
| 79 | 77 | use crate::hash::{Hash, Hasher}; |
| 80 | use crate::io; | |
| 81 | 78 | use crate::iter::FusedIterator; |
| 82 | 79 | use crate::ops::{self, Deref}; |
| 83 | 80 | use crate::rc::Rc; |
| 84 | 81 | use crate::str::FromStr; |
| 85 | 82 | use crate::sync::Arc; |
| 86 | ||
| 87 | use crate::ffi::{os_str, OsStr, OsString}; | |
| 88 | use crate::sys; | |
| 89 | 83 | use crate::sys::path::{is_sep_byte, is_verbatim_sep, parse_prefix, MAIN_SEP_STR}; |
| 84 | use crate::{cmp, fmt, fs, io, sys}; | |
| 90 | 85 | |
| 91 | 86 | //////////////////////////////////////////////////////////////////////////////// |
| 92 | 87 | // GENERAL NOTES |
library/std/src/path/tests.rs+2-2| ... | ... | @@ -1,8 +1,8 @@ |
| 1 | use super::*; | |
| 1 | use core::hint::black_box; | |
| 2 | 2 | |
| 3 | use super::*; | |
| 3 | 4 | use crate::collections::{BTreeSet, HashSet}; |
| 4 | 5 | use crate::hash::DefaultHasher; |
| 5 | use core::hint::black_box; | |
| 6 | 6 | |
| 7 | 7 | #[allow(unknown_lints, unused_macro_rules)] |
| 8 | 8 | macro_rules! t ( |
library/std/src/pipe.rs+2-4| ... | ... | @@ -11,10 +11,8 @@ |
| 11 | 11 | //! # } |
| 12 | 12 | //! ``` |
| 13 | 13 | |
| 14 | use crate::{ | |
| 15 | io, | |
| 16 | sys::anonymous_pipe::{pipe as pipe_inner, AnonPipe}, | |
| 17 | }; | |
| 14 | use crate::io; | |
| 15 | use crate::sys::anonymous_pipe::{pipe as pipe_inner, AnonPipe}; | |
| 18 | 16 | |
| 19 | 17 | /// Create anonymous pipe that is close-on-exec and blocking. |
| 20 | 18 | #[unstable(feature = "anonymous_pipe", issue = "127154")] |
library/std/src/process.rs+2-5| ... | ... | @@ -151,21 +151,18 @@ |
| 151 | 151 | #[cfg(all(test, not(any(target_os = "emscripten", target_env = "sgx", target_os = "xous"))))] |
| 152 | 152 | mod tests; |
| 153 | 153 | |
| 154 | use crate::io::prelude::*; | |
| 155 | ||
| 156 | 154 | use crate::convert::Infallible; |
| 157 | 155 | use crate::ffi::OsStr; |
| 158 | use crate::fmt; | |
| 159 | use crate::fs; | |
| 156 | use crate::io::prelude::*; | |
| 160 | 157 | use crate::io::{self, BorrowedCursor, IoSlice, IoSliceMut}; |
| 161 | 158 | use crate::num::NonZero; |
| 162 | 159 | use crate::path::Path; |
| 163 | use crate::str; | |
| 164 | 160 | use crate::sys::pipe::{read2, AnonPipe}; |
| 165 | 161 | use crate::sys::process as imp; |
| 166 | 162 | #[stable(feature = "command_access", since = "1.57.0")] |
| 167 | 163 | pub use crate::sys_common::process::CommandEnvs; |
| 168 | 164 | use crate::sys_common::{AsInner, AsInnerMut, FromInner, IntoInner}; |
| 165 | use crate::{fmt, fs, str}; | |
| 169 | 166 | |
| 170 | 167 | /// Representation of a running or exited child process. |
| 171 | 168 | /// |
library/std/src/process/tests.rs+1-2| ... | ... | @@ -1,6 +1,5 @@ |
| 1 | use crate::io::prelude::*; | |
| 2 | ||
| 3 | 1 | use super::{Command, Output, Stdio}; |
| 2 | use crate::io::prelude::*; | |
| 4 | 3 | use crate::io::{BorrowedBuf, ErrorKind}; |
| 5 | 4 | use crate::mem::MaybeUninit; |
| 6 | 5 | use crate::str; |
library/std/src/sync/lazy_lock.rs+1-2| ... | ... | @@ -1,3 +1,4 @@ |
| 1 | use super::once::ExclusiveState; | |
| 1 | 2 | use crate::cell::UnsafeCell; |
| 2 | 3 | use crate::mem::ManuallyDrop; |
| 3 | 4 | use crate::ops::Deref; |
| ... | ... | @@ -5,8 +6,6 @@ use crate::panic::{RefUnwindSafe, UnwindSafe}; |
| 5 | 6 | use crate::sync::Once; |
| 6 | 7 | use crate::{fmt, ptr}; |
| 7 | 8 | |
| 8 | use super::once::ExclusiveState; | |
| 9 | ||
| 10 | 9 | // We use the state of a Once as discriminant value. Upon creation, the state is |
| 11 | 10 | // "incomplete" and `f` contains the initialization closure. In the first call to |
| 12 | 11 | // `call_once`, `f` is taken and run. If it succeeds, `value` is set and the state |
library/std/src/sync/lazy_lock/tests.rs+5-10| ... | ... | @@ -1,13 +1,8 @@ |
| 1 | use crate::{ | |
| 2 | cell::LazyCell, | |
| 3 | panic, | |
| 4 | sync::{ | |
| 5 | atomic::{AtomicUsize, Ordering::SeqCst}, | |
| 6 | Mutex, | |
| 7 | }, | |
| 8 | sync::{LazyLock, OnceLock}, | |
| 9 | thread, | |
| 10 | }; | |
| 1 | use crate::cell::LazyCell; | |
| 2 | use crate::sync::atomic::AtomicUsize; | |
| 3 | use crate::sync::atomic::Ordering::SeqCst; | |
| 4 | use crate::sync::{LazyLock, Mutex, OnceLock}; | |
| 5 | use crate::{panic, thread}; | |
| 11 | 6 | |
| 12 | 7 | fn spawn_and_wait<R: Send + 'static>(f: impl FnOnce() -> R + Send + 'static) -> R { |
| 13 | 8 | thread::spawn(f).join().unwrap() |
library/std/src/sync/mod.rs+9-10| ... | ... | @@ -158,17 +158,20 @@ |
| 158 | 158 | |
| 159 | 159 | #![stable(feature = "rust1", since = "1.0.0")] |
| 160 | 160 | |
| 161 | #[stable(feature = "rust1", since = "1.0.0")] | |
| 162 | pub use alloc_crate::sync::{Arc, Weak}; | |
| 163 | 161 | #[stable(feature = "rust1", since = "1.0.0")] |
| 164 | 162 | pub use core::sync::atomic; |
| 165 | 163 | #[unstable(feature = "exclusive_wrapper", issue = "98407")] |
| 166 | 164 | pub use core::sync::Exclusive; |
| 167 | 165 | |
| 166 | #[stable(feature = "rust1", since = "1.0.0")] | |
| 167 | pub use alloc_crate::sync::{Arc, Weak}; | |
| 168 | ||
| 168 | 169 | #[stable(feature = "rust1", since = "1.0.0")] |
| 169 | 170 | pub use self::barrier::{Barrier, BarrierWaitResult}; |
| 170 | 171 | #[stable(feature = "rust1", since = "1.0.0")] |
| 171 | 172 | pub use self::condvar::{Condvar, WaitTimeoutResult}; |
| 173 | #[stable(feature = "lazy_cell", since = "1.80.0")] | |
| 174 | pub use self::lazy_lock::LazyLock; | |
| 172 | 175 | #[unstable(feature = "mapped_lock_guards", issue = "117108")] |
| 173 | 176 | pub use self::mutex::MappedMutexGuard; |
| 174 | 177 | #[stable(feature = "rust1", since = "1.0.0")] |
| ... | ... | @@ -176,21 +179,17 @@ pub use self::mutex::{Mutex, MutexGuard}; |
| 176 | 179 | #[stable(feature = "rust1", since = "1.0.0")] |
| 177 | 180 | #[allow(deprecated)] |
| 178 | 181 | pub use self::once::{Once, OnceState, ONCE_INIT}; |
| 182 | #[stable(feature = "once_cell", since = "1.70.0")] | |
| 183 | pub use self::once_lock::OnceLock; | |
| 179 | 184 | #[stable(feature = "rust1", since = "1.0.0")] |
| 180 | 185 | pub use self::poison::{LockResult, PoisonError, TryLockError, TryLockResult}; |
| 186 | #[unstable(feature = "reentrant_lock", issue = "121440")] | |
| 187 | pub use self::reentrant_lock::{ReentrantLock, ReentrantLockGuard}; | |
| 181 | 188 | #[unstable(feature = "mapped_lock_guards", issue = "117108")] |
| 182 | 189 | pub use self::rwlock::{MappedRwLockReadGuard, MappedRwLockWriteGuard}; |
| 183 | 190 | #[stable(feature = "rust1", since = "1.0.0")] |
| 184 | 191 | pub use self::rwlock::{RwLock, RwLockReadGuard, RwLockWriteGuard}; |
| 185 | 192 | |
| 186 | #[stable(feature = "lazy_cell", since = "1.80.0")] | |
| 187 | pub use self::lazy_lock::LazyLock; | |
| 188 | #[stable(feature = "once_cell", since = "1.70.0")] | |
| 189 | pub use self::once_lock::OnceLock; | |
| 190 | ||
| 191 | #[unstable(feature = "reentrant_lock", issue = "121440")] | |
| 192 | pub use self::reentrant_lock::{ReentrantLock, ReentrantLockGuard}; | |
| 193 | ||
| 194 | 193 | pub mod mpsc; |
| 195 | 194 | |
| 196 | 195 | mod barrier; |
library/std/src/sync/mpmc/array.rs-1| ... | ... | @@ -13,7 +13,6 @@ use super::error::*; |
| 13 | 13 | use super::select::{Operation, Selected, Token}; |
| 14 | 14 | use super::utils::{Backoff, CachePadded}; |
| 15 | 15 | use super::waker::SyncWaker; |
| 16 | ||
| 17 | 16 | use crate::cell::UnsafeCell; |
| 18 | 17 | use crate::mem::MaybeUninit; |
| 19 | 18 | use crate::ptr; |
library/std/src/sync/mpmc/context.rs-1| ... | ... | @@ -2,7 +2,6 @@ |
| 2 | 2 | |
| 3 | 3 | use super::select::Selected; |
| 4 | 4 | use super::waker::current_thread_id; |
| 5 | ||
| 6 | 5 | use crate::cell::Cell; |
| 7 | 6 | use crate::ptr; |
| 8 | 7 | use crate::sync::atomic::{AtomicPtr, AtomicUsize, Ordering}; |
library/std/src/sync/mpmc/counter.rs+1-2| ... | ... | @@ -1,6 +1,5 @@ |
| 1 | use crate::ops; | |
| 2 | use crate::process; | |
| 3 | 1 | use crate::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; |
| 2 | use crate::{ops, process}; | |
| 4 | 3 | |
| 5 | 4 | /// Reference counter internals. |
| 6 | 5 | struct Counter<C> { |
library/std/src/sync/mpmc/error.rs+1-3| ... | ... | @@ -1,7 +1,5 @@ |
| 1 | use crate::error; | |
| 2 | use crate::fmt; | |
| 3 | ||
| 4 | 1 | pub use crate::sync::mpsc::{RecvError, RecvTimeoutError, SendError, TryRecvError, TrySendError}; |
| 2 | use crate::{error, fmt}; | |
| 5 | 3 | |
| 6 | 4 | /// An error returned from the [`send_timeout`] method. |
| 7 | 5 | /// |
library/std/src/sync/mpmc/list.rs-1| ... | ... | @@ -5,7 +5,6 @@ use super::error::*; |
| 5 | 5 | use super::select::{Operation, Selected, Token}; |
| 6 | 6 | use super::utils::{Backoff, CachePadded}; |
| 7 | 7 | use super::waker::SyncWaker; |
| 8 | ||
| 9 | 8 | use crate::cell::UnsafeCell; |
| 10 | 9 | use crate::marker::PhantomData; |
| 11 | 10 | use crate::mem::MaybeUninit; |
library/std/src/sync/mpmc/mod.rs+2-1| ... | ... | @@ -40,10 +40,11 @@ mod utils; |
| 40 | 40 | mod waker; |
| 41 | 41 | mod zero; |
| 42 | 42 | |
| 43 | pub use error::*; | |
| 44 | ||
| 43 | 45 | use crate::fmt; |
| 44 | 46 | use crate::panic::{RefUnwindSafe, UnwindSafe}; |
| 45 | 47 | use crate::time::{Duration, Instant}; |
| 46 | pub use error::*; | |
| 47 | 48 | |
| 48 | 49 | /// Creates a channel of unbounded capacity. |
| 49 | 50 | /// |
library/std/src/sync/mpmc/waker.rs-1| ... | ... | @@ -2,7 +2,6 @@ |
| 2 | 2 | |
| 3 | 3 | use super::context::Context; |
| 4 | 4 | use super::select::{Operation, Selected}; |
| 5 | ||
| 6 | 5 | use crate::ptr; |
| 7 | 6 | use crate::sync::atomic::{AtomicBool, Ordering}; |
| 8 | 7 | use crate::sync::Mutex; |
library/std/src/sync/mpmc/zero.rs-1| ... | ... | @@ -7,7 +7,6 @@ use super::error::*; |
| 7 | 7 | use super::select::{Operation, Selected, Token}; |
| 8 | 8 | use super::utils::Backoff; |
| 9 | 9 | use super::waker::Waker; |
| 10 | ||
| 11 | 10 | use crate::cell::UnsafeCell; |
| 12 | 11 | use crate::marker::PhantomData; |
| 13 | 12 | use crate::sync::atomic::{AtomicBool, Ordering}; |
library/std/src/sync/mpsc/mod.rs+1-2| ... | ... | @@ -148,10 +148,9 @@ mod sync_tests; |
| 148 | 148 | // not exposed publicly, but if you are curious about the implementation, |
| 149 | 149 | // that's where everything is. |
| 150 | 150 | |
| 151 | use crate::error; | |
| 152 | use crate::fmt; | |
| 153 | 151 | use crate::sync::mpmc; |
| 154 | 152 | use crate::time::{Duration, Instant}; |
| 153 | use crate::{error, fmt}; | |
| 155 | 154 | |
| 156 | 155 | /// The receiving half of Rust's [`channel`] (or [`sync_channel`]) type. |
| 157 | 156 | /// This half can only be owned by one thread. |
library/std/src/sync/mpsc/sync_tests.rs+1-2| ... | ... | @@ -1,8 +1,7 @@ |
| 1 | 1 | use super::*; |
| 2 | use crate::env; | |
| 3 | 2 | use crate::rc::Rc; |
| 4 | 3 | use crate::sync::mpmc::SendTimeoutError; |
| 5 | use crate::thread; | |
| 4 | use crate::{env, thread}; | |
| 6 | 5 | |
| 7 | 6 | pub fn stress_factor() -> usize { |
| 8 | 7 | match env::var("RUST_TEST_STRESS") { |
library/std/src/sync/mpsc/tests.rs+1-2| ... | ... | @@ -1,6 +1,5 @@ |
| 1 | 1 | use super::*; |
| 2 | use crate::env; | |
| 3 | use crate::thread; | |
| 2 | use crate::{env, thread}; | |
| 4 | 3 | |
| 5 | 4 | pub fn stress_factor() -> usize { |
| 6 | 5 | match env::var("RUST_TEST_STRESS") { |
library/std/src/sync/once/tests.rs+1-2| ... | ... | @@ -1,7 +1,6 @@ |
| 1 | 1 | use super::Once; |
| 2 | use crate::panic; | |
| 3 | 2 | use crate::sync::mpsc::channel; |
| 4 | use crate::thread; | |
| 3 | use crate::{panic, thread}; | |
| 5 | 4 | |
| 6 | 5 | #[test] |
| 7 | 6 | fn smoke_once() { |
library/std/src/sync/once_lock/tests.rs+5-9| ... | ... | @@ -1,12 +1,8 @@ |
| 1 | use crate::{ | |
| 2 | panic, | |
| 3 | sync::OnceLock, | |
| 4 | sync::{ | |
| 5 | atomic::{AtomicUsize, Ordering::SeqCst}, | |
| 6 | mpsc::channel, | |
| 7 | }, | |
| 8 | thread, | |
| 9 | }; | |
| 1 | use crate::sync::atomic::AtomicUsize; | |
| 2 | use crate::sync::atomic::Ordering::SeqCst; | |
| 3 | use crate::sync::mpsc::channel; | |
| 4 | use crate::sync::OnceLock; | |
| 5 | use crate::{panic, thread}; | |
| 10 | 6 | |
| 11 | 7 | fn spawn_and_wait<R: Send + 'static>(f: impl FnOnce() -> R + Send + 'static) -> R { |
| 12 | 8 | thread::spawn(f).join().unwrap() |
library/std/src/sync/poison.rs-1| ... | ... | @@ -1,6 +1,5 @@ |
| 1 | 1 | use crate::error::Error; |
| 2 | 2 | use crate::fmt; |
| 3 | ||
| 4 | 3 | #[cfg(panic = "unwind")] |
| 5 | 4 | use crate::sync::atomic::{AtomicBool, Ordering}; |
| 6 | 5 | #[cfg(panic = "unwind")] |
library/std/src/sync/rwlock/tests.rs+2-1| ... | ... | @@ -1,3 +1,5 @@ |
| 1 | use rand::Rng; | |
| 2 | ||
| 1 | 3 | use crate::sync::atomic::{AtomicUsize, Ordering}; |
| 2 | 4 | use crate::sync::mpsc::channel; |
| 3 | 5 | use crate::sync::{ |
| ... | ... | @@ -5,7 +7,6 @@ use crate::sync::{ |
| 5 | 7 | TryLockError, |
| 6 | 8 | }; |
| 7 | 9 | use crate::thread; |
| 8 | use rand::Rng; | |
| 9 | 10 | |
| 10 | 11 | #[derive(Eq, PartialEq, Debug)] |
| 11 | 12 | struct NonCopy(i32); |
library/std/src/sys/anonymous_pipe/tests.rs+2-4| ... | ... | @@ -1,7 +1,5 @@ |
| 1 | use crate::{ | |
| 2 | io::{Read, Write}, | |
| 3 | pipe::pipe, | |
| 4 | }; | |
| 1 | use crate::io::{Read, Write}; | |
| 2 | use crate::pipe::pipe; | |
| 5 | 3 | |
| 6 | 4 | #[test] |
| 7 | 5 | fn pipe_creation_clone_and_rw() { |
library/std/src/sys/anonymous_pipe/unix.rs+7-8| ... | ... | @@ -1,11 +1,10 @@ |
| 1 | use crate::{ | |
| 2 | io, | |
| 3 | os::fd::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, OwnedFd, RawFd}, | |
| 4 | pipe::{PipeReader, PipeWriter}, | |
| 5 | process::Stdio, | |
| 6 | sys::{fd::FileDesc, pipe::anon_pipe}, | |
| 7 | sys_common::{FromInner, IntoInner}, | |
| 8 | }; | |
| 1 | use crate::io; | |
| 2 | use crate::os::fd::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, OwnedFd, RawFd}; | |
| 3 | use crate::pipe::{PipeReader, PipeWriter}; | |
| 4 | use crate::process::Stdio; | |
| 5 | use crate::sys::fd::FileDesc; | |
| 6 | use crate::sys::pipe::anon_pipe; | |
| 7 | use crate::sys_common::{FromInner, IntoInner}; | |
| 9 | 8 | |
| 10 | 9 | pub(crate) type AnonPipe = FileDesc; |
| 11 | 10 |
library/std/src/sys/anonymous_pipe/unsupported.rs+3-6| ... | ... | @@ -1,9 +1,6 @@ |
| 1 | use crate::{ | |
| 2 | io, | |
| 3 | pipe::{PipeReader, PipeWriter}, | |
| 4 | process::Stdio, | |
| 5 | }; | |
| 6 | ||
| 1 | use crate::io; | |
| 2 | use crate::pipe::{PipeReader, PipeWriter}; | |
| 3 | use crate::process::Stdio; | |
| 7 | 4 | pub(crate) use crate::sys::pipe::AnonPipe; |
| 8 | 5 | |
| 9 | 6 | #[inline] |
library/std/src/sys/anonymous_pipe/windows.rs+8-9| ... | ... | @@ -1,13 +1,12 @@ |
| 1 | use crate::{ | |
| 2 | io, | |
| 3 | os::windows::io::{ | |
| 4 | AsHandle, AsRawHandle, BorrowedHandle, FromRawHandle, IntoRawHandle, OwnedHandle, RawHandle, | |
| 5 | }, | |
| 6 | pipe::{PipeReader, PipeWriter}, | |
| 7 | process::Stdio, | |
| 8 | sys::{handle::Handle, pipe::unnamed_anon_pipe}, | |
| 9 | sys_common::{FromInner, IntoInner}, | |
| 1 | use crate::io; | |
| 2 | use crate::os::windows::io::{ | |
| 3 | AsHandle, AsRawHandle, BorrowedHandle, FromRawHandle, IntoRawHandle, OwnedHandle, RawHandle, | |
| 10 | 4 | }; |
| 5 | use crate::pipe::{PipeReader, PipeWriter}; | |
| 6 | use crate::process::Stdio; | |
| 7 | use crate::sys::handle::Handle; | |
| 8 | use crate::sys::pipe::unnamed_anon_pipe; | |
| 9 | use crate::sys_common::{FromInner, IntoInner}; | |
| 11 | 10 | |
| 12 | 11 | pub(crate) type AnonPipe = Handle; |
| 13 | 12 |
library/std/src/sys/backtrace.rs+1-3| ... | ... | @@ -3,12 +3,10 @@ |
| 3 | 3 | |
| 4 | 4 | use crate::backtrace_rs::{self, BacktraceFmt, BytesOrWideString, PrintFmt}; |
| 5 | 5 | use crate::borrow::Cow; |
| 6 | use crate::env; | |
| 7 | use crate::fmt; | |
| 8 | use crate::io; | |
| 9 | 6 | use crate::io::prelude::*; |
| 10 | 7 | use crate::path::{self, Path, PathBuf}; |
| 11 | 8 | use crate::sync::{Mutex, MutexGuard, PoisonError}; |
| 9 | use crate::{env, fmt, io}; | |
| 12 | 10 | |
| 13 | 11 | /// Max number of frames to print. |
| 14 | 12 | const MAX_NB_FRAMES: usize = 100; |
library/std/src/sys/os_str/bytes.rs+1-3| ... | ... | @@ -3,13 +3,11 @@ |
| 3 | 3 | |
| 4 | 4 | use crate::borrow::Cow; |
| 5 | 5 | use crate::collections::TryReserveError; |
| 6 | use crate::fmt; | |
| 7 | 6 | use crate::fmt::Write; |
| 8 | use crate::mem; | |
| 9 | 7 | use crate::rc::Rc; |
| 10 | use crate::str; | |
| 11 | 8 | use crate::sync::Arc; |
| 12 | 9 | use crate::sys_common::{AsInner, IntoInner}; |
| 10 | use crate::{fmt, mem, str}; | |
| 13 | 11 | |
| 14 | 12 | #[cfg(test)] |
| 15 | 13 | mod tests; |
library/std/src/sys/os_str/wtf8.rs+1-2| ... | ... | @@ -2,12 +2,11 @@ |
| 2 | 2 | //! wrapper around the "WTF-8" encoding; see the `wtf8` module for more. |
| 3 | 3 | use crate::borrow::Cow; |
| 4 | 4 | use crate::collections::TryReserveError; |
| 5 | use crate::fmt; | |
| 6 | use crate::mem; | |
| 7 | 5 | use crate::rc::Rc; |
| 8 | 6 | use crate::sync::Arc; |
| 9 | 7 | use crate::sys_common::wtf8::{check_utf8_boundary, Wtf8, Wtf8Buf}; |
| 10 | 8 | use crate::sys_common::{AsInner, FromInner, IntoInner}; |
| 9 | use crate::{fmt, mem}; | |
| 11 | 10 | |
| 12 | 11 | #[derive(Clone, Hash)] |
| 13 | 12 | pub struct Buf { |
library/std/src/sys/pal/common/alloc.rs+1-2| ... | ... | @@ -1,7 +1,6 @@ |
| 1 | 1 | #![forbid(unsafe_op_in_unsafe_fn)] |
| 2 | 2 | use crate::alloc::{GlobalAlloc, Layout, System}; |
| 3 | use crate::cmp; | |
| 4 | use crate::ptr; | |
| 3 | use crate::{cmp, ptr}; | |
| 5 | 4 | |
| 6 | 5 | // The minimum alignment guaranteed by the architecture. This value is used to |
| 7 | 6 | // add fast paths for low alignment values. |
library/std/src/sys/pal/common/small_c_string.rs+1-2| ... | ... | @@ -1,8 +1,7 @@ |
| 1 | 1 | use crate::ffi::{CStr, CString}; |
| 2 | 2 | use crate::mem::MaybeUninit; |
| 3 | 3 | use crate::path::Path; |
| 4 | use crate::slice; | |
| 5 | use crate::{io, ptr}; | |
| 4 | use crate::{io, ptr, slice}; | |
| 6 | 5 | |
| 7 | 6 | // Make sure to stay under 4096 so the compiler doesn't insert a probe frame: |
| 8 | 7 | // https://docs.rs/compiler_builtins/latest/compiler_builtins/probestack/index.html |
library/std/src/sys/pal/common/tests.rs+2-1| ... | ... | @@ -1,8 +1,9 @@ |
| 1 | use core::iter::repeat; | |
| 2 | ||
| 1 | 3 | use crate::ffi::CString; |
| 2 | 4 | use crate::hint::black_box; |
| 3 | 5 | use crate::path::Path; |
| 4 | 6 | use crate::sys::common::small_c_string::run_path_with_cstr; |
| 5 | use core::iter::repeat; | |
| 6 | 7 | |
| 7 | 8 | #[test] |
| 8 | 9 | fn stack_allocation_works() { |
library/std/src/sys/pal/hermit/args.rs+3-7| ... | ... | @@ -1,12 +1,8 @@ |
| 1 | 1 | use crate::ffi::{c_char, CStr, OsString}; |
| 2 | use crate::fmt; | |
| 3 | 2 | use crate::os::hermit::ffi::OsStringExt; |
| 4 | use crate::ptr; | |
| 5 | use crate::sync::atomic::{ | |
| 6 | AtomicIsize, AtomicPtr, | |
| 7 | Ordering::{Acquire, Relaxed, Release}, | |
| 8 | }; | |
| 9 | use crate::vec; | |
| 3 | use crate::sync::atomic::Ordering::{Acquire, Relaxed, Release}; | |
| 4 | use crate::sync::atomic::{AtomicIsize, AtomicPtr}; | |
| 5 | use crate::{fmt, ptr, vec}; | |
| 10 | 6 | |
| 11 | 7 | static ARGC: AtomicIsize = AtomicIsize::new(0); |
| 12 | 8 | static ARGV: AtomicPtr<*const u8> = AtomicPtr::new(ptr::null_mut()); |
library/std/src/sys/pal/hermit/fd.rs+2-5| ... | ... | @@ -3,13 +3,10 @@ |
| 3 | 3 | use super::hermit_abi; |
| 4 | 4 | use crate::cmp; |
| 5 | 5 | use crate::io::{self, IoSlice, IoSliceMut, Read}; |
| 6 | use crate::os::hermit::io::{FromRawFd, OwnedFd, RawFd}; | |
| 7 | use crate::sys::cvt; | |
| 8 | use crate::sys::unsupported; | |
| 6 | use crate::os::hermit::io::{FromRawFd, OwnedFd, RawFd, *}; | |
| 7 | use crate::sys::{cvt, unsupported}; | |
| 9 | 8 | use crate::sys_common::{AsInner, FromInner, IntoInner}; |
| 10 | 9 | |
| 11 | use crate::os::hermit::io::*; | |
| 12 | ||
| 13 | 10 | const fn max_iov() -> usize { |
| 14 | 11 | hermit_abi::IOV_MAX |
| 15 | 12 | } |
library/std/src/sys/pal/hermit/fs.rs+4-8| ... | ... | @@ -4,21 +4,17 @@ use super::hermit_abi::{ |
| 4 | 4 | O_DIRECTORY, O_EXCL, O_RDONLY, O_RDWR, O_TRUNC, O_WRONLY, S_IFDIR, S_IFLNK, S_IFMT, S_IFREG, |
| 5 | 5 | }; |
| 6 | 6 | use crate::ffi::{CStr, OsStr, OsString}; |
| 7 | use crate::fmt; | |
| 8 | use crate::io::{self, Error, ErrorKind}; | |
| 9 | use crate::io::{BorrowedCursor, IoSlice, IoSliceMut, SeekFrom}; | |
| 10 | use crate::mem; | |
| 7 | use crate::io::{self, BorrowedCursor, Error, ErrorKind, IoSlice, IoSliceMut, SeekFrom}; | |
| 11 | 8 | use crate::os::hermit::ffi::OsStringExt; |
| 12 | 9 | use crate::os::hermit::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, RawFd}; |
| 13 | 10 | use crate::path::{Path, PathBuf}; |
| 14 | 11 | use crate::sync::Arc; |
| 15 | 12 | use crate::sys::common::small_c_string::run_path_with_cstr; |
| 16 | use crate::sys::cvt; | |
| 17 | 13 | use crate::sys::time::SystemTime; |
| 18 | use crate::sys::unsupported; | |
| 19 | use crate::sys_common::{AsInner, AsInnerMut, FromInner, IntoInner}; | |
| 20 | ||
| 14 | use crate::sys::{cvt, unsupported}; | |
| 21 | 15 | pub use crate::sys_common::fs::{copy, exists}; |
| 16 | use crate::sys_common::{AsInner, AsInnerMut, FromInner, IntoInner}; | |
| 17 | use crate::{fmt, mem}; | |
| 22 | 18 | |
| 23 | 19 | #[derive(Debug)] |
| 24 | 20 | pub struct File(FileDesc); |
library/std/src/sys/pal/hermit/io.rs+2-2| ... | ... | @@ -1,9 +1,9 @@ |
| 1 | use hermit_abi::{c_void, iovec}; | |
| 2 | ||
| 1 | 3 | use crate::marker::PhantomData; |
| 2 | 4 | use crate::os::hermit::io::{AsFd, AsRawFd}; |
| 3 | 5 | use crate::slice; |
| 4 | 6 | |
| 5 | use hermit_abi::{c_void, iovec}; | |
| 6 | ||
| 7 | 7 | #[derive(Copy, Clone)] |
| 8 | 8 | #[repr(transparent)] |
| 9 | 9 | pub struct IoSlice<'a> { |
library/std/src/sys/pal/hermit/net.rs+3-4| ... | ... | @@ -1,17 +1,16 @@ |
| 1 | 1 | #![allow(dead_code)] |
| 2 | 2 | |
| 3 | use core::ffi::c_int; | |
| 4 | ||
| 3 | 5 | use super::fd::FileDesc; |
| 4 | use crate::cmp; | |
| 5 | 6 | use crate::io::{self, BorrowedBuf, BorrowedCursor, IoSlice, IoSliceMut}; |
| 6 | use crate::mem; | |
| 7 | 7 | use crate::net::{Shutdown, SocketAddr}; |
| 8 | 8 | use crate::os::hermit::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, RawFd}; |
| 9 | 9 | use crate::sys::time::Instant; |
| 10 | 10 | use crate::sys_common::net::{getsockopt, setsockopt, sockaddr_to_addr}; |
| 11 | 11 | use crate::sys_common::{AsInner, FromInner, IntoInner}; |
| 12 | 12 | use crate::time::Duration; |
| 13 | ||
| 14 | use core::ffi::c_int; | |
| 13 | use crate::{cmp, mem}; | |
| 15 | 14 | |
| 16 | 15 | #[allow(unused_extern_crates)] |
| 17 | 16 | pub extern crate hermit_abi as netc; |
library/std/src/sys/pal/hermit/os.rs+3-5| ... | ... | @@ -1,17 +1,15 @@ |
| 1 | use core::slice::memchr; | |
| 2 | ||
| 1 | 3 | use super::hermit_abi; |
| 2 | 4 | use crate::collections::HashMap; |
| 3 | 5 | use crate::error::Error as StdError; |
| 4 | 6 | use crate::ffi::{CStr, OsStr, OsString}; |
| 5 | use crate::fmt; | |
| 6 | use crate::io; | |
| 7 | 7 | use crate::marker::PhantomData; |
| 8 | 8 | use crate::os::hermit::ffi::OsStringExt; |
| 9 | 9 | use crate::path::{self, PathBuf}; |
| 10 | use crate::str; | |
| 11 | 10 | use crate::sync::Mutex; |
| 12 | 11 | use crate::sys::unsupported; |
| 13 | use crate::vec; | |
| 14 | use core::slice::memchr; | |
| 12 | use crate::{fmt, io, str, vec}; | |
| 15 | 13 | |
| 16 | 14 | pub fn errno() -> i32 { |
| 17 | 15 | unsafe { hermit_abi::get_errno() } |
library/std/src/sys/pal/hermit/thread.rs+1-2| ... | ... | @@ -2,11 +2,10 @@ |
| 2 | 2 | |
| 3 | 3 | use super::hermit_abi; |
| 4 | 4 | use crate::ffi::CStr; |
| 5 | use crate::io; | |
| 6 | 5 | use crate::mem::ManuallyDrop; |
| 7 | 6 | use crate::num::NonZero; |
| 8 | use crate::ptr; | |
| 9 | 7 | use crate::time::Duration; |
| 8 | use crate::{io, ptr}; | |
| 10 | 9 | |
| 11 | 10 | pub type Tid = hermit_abi::Tid; |
| 12 | 11 |
library/std/src/sys/pal/hermit/time.rs+2-1| ... | ... | @@ -1,10 +1,11 @@ |
| 1 | 1 | #![allow(dead_code)] |
| 2 | 2 | |
| 3 | use core::hash::{Hash, Hasher}; | |
| 4 | ||
| 3 | 5 | use super::hermit_abi::{self, timespec, CLOCK_MONOTONIC, CLOCK_REALTIME}; |
| 4 | 6 | use crate::cmp::Ordering; |
| 5 | 7 | use crate::ops::{Add, AddAssign, Sub, SubAssign}; |
| 6 | 8 | use crate::time::Duration; |
| 7 | use core::hash::{Hash, Hasher}; | |
| 8 | 9 | |
| 9 | 10 | const NSEC_PER_SEC: i32 = 1_000_000_000; |
| 10 | 11 |
library/std/src/sys/pal/itron/error.rs+2-2| ... | ... | @@ -1,6 +1,6 @@ |
| 1 | use crate::{fmt, io::ErrorKind}; | |
| 2 | ||
| 3 | 1 | use super::abi; |
| 2 | use crate::fmt; | |
| 3 | use crate::io::ErrorKind; | |
| 4 | 4 | |
| 5 | 5 | /// Wraps a μITRON error code. |
| 6 | 6 | #[derive(Debug, Copy, Clone)] |
library/std/src/sys/pal/itron/spin.rs+3-5| ... | ... | @@ -1,9 +1,7 @@ |
| 1 | 1 | use super::abi; |
| 2 | use crate::{ | |
| 3 | cell::UnsafeCell, | |
| 4 | mem::MaybeUninit, | |
| 5 | sync::atomic::{AtomicBool, AtomicUsize, Ordering}, | |
| 6 | }; | |
| 2 | use crate::cell::UnsafeCell; | |
| 3 | use crate::mem::MaybeUninit; | |
| 4 | use crate::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; | |
| 7 | 5 | |
| 8 | 6 | /// A mutex implemented by `dis_dsp` (for intra-core synchronization) and a |
| 9 | 7 | /// spinlock (for inter-core synchronization). |
library/std/src/sys/pal/itron/task.rs+2-5| ... | ... | @@ -1,8 +1,5 @@ |
| 1 | use super::{ | |
| 2 | abi, | |
| 3 | error::{fail, fail_aborting, ItronError}, | |
| 4 | }; | |
| 5 | ||
| 1 | use super::abi; | |
| 2 | use super::error::{fail, fail_aborting, ItronError}; | |
| 6 | 3 | use crate::mem::MaybeUninit; |
| 7 | 4 | |
| 8 | 5 | /// Gets the ID of the task in Running state. Panics on failure. |
library/std/src/sys/pal/itron/thread.rs+11-16| ... | ... | @@ -1,22 +1,17 @@ |
| 1 | 1 | //! Thread implementation backed by μITRON tasks. Assumes `acre_tsk` and |
| 2 | 2 | //! `exd_tsk` are available. |
| 3 | 3 | |
| 4 | use super::{ | |
| 5 | abi, | |
| 6 | error::{expect_success, expect_success_aborting, ItronError}, | |
| 7 | task, | |
| 8 | time::dur2reltims, | |
| 9 | }; | |
| 10 | use crate::{ | |
| 11 | cell::UnsafeCell, | |
| 12 | ffi::CStr, | |
| 13 | hint, io, | |
| 14 | mem::ManuallyDrop, | |
| 15 | num::NonZero, | |
| 16 | ptr::NonNull, | |
| 17 | sync::atomic::{AtomicUsize, Ordering}, | |
| 18 | time::Duration, | |
| 19 | }; | |
| 4 | use super::error::{expect_success, expect_success_aborting, ItronError}; | |
| 5 | use super::time::dur2reltims; | |
| 6 | use super::{abi, task}; | |
| 7 | use crate::cell::UnsafeCell; | |
| 8 | use crate::ffi::CStr; | |
| 9 | use crate::mem::ManuallyDrop; | |
| 10 | use crate::num::NonZero; | |
| 11 | use crate::ptr::NonNull; | |
| 12 | use crate::sync::atomic::{AtomicUsize, Ordering}; | |
| 13 | use crate::time::Duration; | |
| 14 | use crate::{hint, io}; | |
| 20 | 15 | |
| 21 | 16 | pub struct Thread { |
| 22 | 17 | p_inner: NonNull<ThreadInner>, |
library/std/src/sys/pal/itron/time.rs+4-2| ... | ... | @@ -1,5 +1,7 @@ |
| 1 | use super::{abi, error::expect_success}; | |
| 2 | use crate::{mem::MaybeUninit, time::Duration}; | |
| 1 | use super::abi; | |
| 2 | use super::error::expect_success; | |
| 3 | use crate::mem::MaybeUninit; | |
| 4 | use crate::time::Duration; | |
| 3 | 5 | |
| 4 | 6 | #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)] |
| 5 | 7 | pub struct Instant(abi::SYSTIM); |
library/std/src/sys/pal/sgx/abi/mod.rs+2-1| ... | ... | @@ -1,9 +1,10 @@ |
| 1 | 1 | #![cfg_attr(test, allow(unused))] // RT initialization logic is not compiled for test |
| 2 | 2 | |
| 3 | use crate::io::Write; | |
| 4 | 3 | use core::arch::global_asm; |
| 5 | 4 | use core::sync::atomic::{AtomicUsize, Ordering}; |
| 6 | 5 | |
| 6 | use crate::io::Write; | |
| 7 | ||
| 7 | 8 | // runtime features |
| 8 | 9 | pub(super) mod panic; |
| 9 | 10 | mod reloc; |
library/std/src/sys/pal/sgx/abi/panic.rs+1-2| ... | ... | @@ -1,7 +1,6 @@ |
| 1 | 1 | use super::usercalls::alloc::UserRef; |
| 2 | use crate::cmp; | |
| 3 | 2 | use crate::io::{self, Write}; |
| 4 | use crate::mem; | |
| 3 | use crate::{cmp, mem}; | |
| 5 | 4 | |
| 6 | 5 | extern "C" { |
| 7 | 6 | fn take_debug_panic_buf_ptr() -> *mut u8; |
library/std/src/sys/pal/sgx/abi/tls/mod.rs+1-2| ... | ... | @@ -2,10 +2,9 @@ mod sync_bitset; |
| 2 | 2 | |
| 3 | 3 | use self::sync_bitset::*; |
| 4 | 4 | use crate::cell::Cell; |
| 5 | use crate::mem; | |
| 6 | 5 | use crate::num::NonZero; |
| 7 | use crate::ptr; | |
| 8 | 6 | use crate::sync::atomic::{AtomicUsize, Ordering}; |
| 7 | use crate::{mem, ptr}; | |
| 9 | 8 | |
| 10 | 9 | #[cfg(target_pointer_width = "64")] |
| 11 | 10 | const USIZE_BITS: usize = 64; |
library/std/src/sys/pal/sgx/abi/usercalls/alloc.rs+4-6| ... | ... | @@ -1,18 +1,16 @@ |
| 1 | 1 | #![allow(unused)] |
| 2 | 2 | |
| 3 | use fortanix_sgx_abi::*; | |
| 4 | ||
| 5 | use super::super::mem::{is_enclave_range, is_user_range}; | |
| 3 | 6 | use crate::arch::asm; |
| 4 | 7 | use crate::cell::UnsafeCell; |
| 5 | use crate::cmp; | |
| 6 | 8 | use crate::convert::TryInto; |
| 7 | use crate::intrinsics; | |
| 8 | 9 | use crate::mem::{self, ManuallyDrop}; |
| 9 | 10 | use crate::ops::{CoerceUnsized, Deref, DerefMut, Index, IndexMut}; |
| 10 | 11 | use crate::ptr::{self, NonNull}; |
| 11 | use crate::slice; | |
| 12 | 12 | use crate::slice::SliceIndex; |
| 13 | ||
| 14 | use super::super::mem::{is_enclave_range, is_user_range}; | |
| 15 | use fortanix_sgx_abi::*; | |
| 13 | use crate::{cmp, intrinsics, slice}; | |
| 16 | 14 | |
| 17 | 15 | /// A type that can be safely read from or written to userspace. |
| 18 | 16 | /// |
library/std/src/sys/pal/sgx/abi/usercalls/tests.rs+1-2| ... | ... | @@ -1,5 +1,4 @@ |
| 1 | use super::alloc::User; | |
| 2 | use super::alloc::{copy_from_userspace, copy_to_userspace}; | |
| 1 | use super::alloc::{copy_from_userspace, copy_to_userspace, User}; | |
| 3 | 2 | |
| 4 | 3 | #[test] |
| 5 | 4 | fn test_copy_to_userspace_function() { |
library/std/src/sys/pal/sgx/alloc.rs+2-2| ... | ... | @@ -1,9 +1,9 @@ |
| 1 | use crate::alloc::{GlobalAlloc, Layout, System}; | |
| 2 | use crate::ptr; | |
| 3 | 1 | use core::sync::atomic::{AtomicBool, Ordering}; |
| 4 | 2 | |
| 5 | 3 | use super::abi::mem as sgx_mem; |
| 6 | 4 | use super::waitqueue::SpinMutex; |
| 5 | use crate::alloc::{GlobalAlloc, Layout, System}; | |
| 6 | use crate::ptr; | |
| 7 | 7 | |
| 8 | 8 | // Using a SpinMutex because we never want to exit the enclave waiting for the |
| 9 | 9 | // allocator. |
library/std/src/sys/pal/sgx/args.rs+3-3| ... | ... | @@ -1,10 +1,10 @@ |
| 1 | use super::abi::usercalls::{alloc, raw::ByteBuffer}; | |
| 1 | use super::abi::usercalls::alloc; | |
| 2 | use super::abi::usercalls::raw::ByteBuffer; | |
| 2 | 3 | use crate::ffi::OsString; |
| 3 | use crate::fmt; | |
| 4 | use crate::slice; | |
| 5 | 4 | use crate::sync::atomic::{AtomicUsize, Ordering}; |
| 6 | 5 | use crate::sys::os_str::Buf; |
| 7 | 6 | use crate::sys_common::FromInner; |
| 7 | use crate::{fmt, slice}; | |
| 8 | 8 | |
| 9 | 9 | #[cfg_attr(test, linkage = "available_externally")] |
| 10 | 10 | #[export_name = "_ZN16__rust_internals3std3sys3sgx4args4ARGSE"] |
library/std/src/sys/pal/sgx/net.rs+2-4| ... | ... | @@ -1,13 +1,11 @@ |
| 1 | use crate::error; | |
| 2 | use crate::fmt; | |
| 1 | use super::abi::usercalls; | |
| 3 | 2 | use crate::io::{self, BorrowedCursor, IoSlice, IoSliceMut}; |
| 4 | 3 | use crate::net::{Ipv4Addr, Ipv6Addr, Shutdown, SocketAddr, ToSocketAddrs}; |
| 5 | 4 | use crate::sync::Arc; |
| 6 | 5 | use crate::sys::fd::FileDesc; |
| 7 | 6 | use crate::sys::{sgx_ineffective, unsupported, AsInner, FromInner, IntoInner, TryIntoInner}; |
| 8 | 7 | use crate::time::Duration; |
| 9 | ||
| 10 | use super::abi::usercalls; | |
| 8 | use crate::{error, fmt}; | |
| 11 | 9 | |
| 12 | 10 | const DEFAULT_FAKE_TTL: u32 = 64; |
| 13 | 11 |
library/std/src/sys/pal/sgx/os.rs+2-6| ... | ... | @@ -3,16 +3,12 @@ use fortanix_sgx_abi::{Error, RESULT_SUCCESS}; |
| 3 | 3 | use crate::collections::HashMap; |
| 4 | 4 | use crate::error::Error as StdError; |
| 5 | 5 | use crate::ffi::{OsStr, OsString}; |
| 6 | use crate::fmt; | |
| 7 | use crate::io; | |
| 8 | 6 | use crate::marker::PhantomData; |
| 9 | 7 | use crate::path::{self, PathBuf}; |
| 10 | use crate::str; | |
| 11 | 8 | use crate::sync::atomic::{AtomicUsize, Ordering}; |
| 12 | use crate::sync::Mutex; | |
| 13 | use crate::sync::Once; | |
| 9 | use crate::sync::{Mutex, Once}; | |
| 14 | 10 | use crate::sys::{decode_error_kind, sgx_ineffective, unsupported}; |
| 15 | use crate::vec; | |
| 11 | use crate::{fmt, io, str, vec}; | |
| 16 | 12 | |
| 17 | 13 | pub fn errno() -> i32 { |
| 18 | 14 | RESULT_SUCCESS |
library/std/src/sys/pal/sgx/thread.rs+1-2| ... | ... | @@ -1,12 +1,11 @@ |
| 1 | 1 | #![cfg_attr(test, allow(dead_code))] // why is this necessary? |
| 2 | use super::abi::usercalls; | |
| 2 | 3 | use super::unsupported; |
| 3 | 4 | use crate::ffi::CStr; |
| 4 | 5 | use crate::io; |
| 5 | 6 | use crate::num::NonZero; |
| 6 | 7 | use crate::time::Duration; |
| 7 | 8 | |
| 8 | use super::abi::usercalls; | |
| 9 | ||
| 10 | 9 | pub struct Thread(task_queue::JoinHandle); |
| 11 | 10 | |
| 12 | 11 | pub const DEFAULT_MIN_STACK_SIZE: usize = 4096; |
library/std/src/sys/pal/sgx/thread_parking.rs+2-1| ... | ... | @@ -1,7 +1,8 @@ |
| 1 | use fortanix_sgx_abi::{EV_UNPARK, WAIT_INDEFINITE}; | |
| 2 | ||
| 1 | 3 | use super::abi::usercalls; |
| 2 | 4 | use crate::io::ErrorKind; |
| 3 | 5 | use crate::time::Duration; |
| 4 | use fortanix_sgx_abi::{EV_UNPARK, WAIT_INDEFINITE}; | |
| 5 | 6 | |
| 6 | 7 | pub type ThreadId = fortanix_sgx_abi::Tcs; |
| 7 | 8 |
library/std/src/sys/pal/sgx/waitqueue/mod.rs+5-7| ... | ... | @@ -16,17 +16,15 @@ mod tests; |
| 16 | 16 | mod spin_mutex; |
| 17 | 17 | mod unsafe_list; |
| 18 | 18 | |
| 19 | use crate::num::NonZero; | |
| 20 | use crate::ops::{Deref, DerefMut}; | |
| 21 | use crate::panic::{self, AssertUnwindSafe}; | |
| 22 | use crate::time::Duration; | |
| 23 | ||
| 24 | use super::abi::thread; | |
| 25 | use super::abi::usercalls; | |
| 26 | 19 | use fortanix_sgx_abi::{Tcs, EV_UNPARK, WAIT_INDEFINITE}; |
| 27 | 20 | |
| 28 | 21 | pub use self::spin_mutex::{try_lock_or_false, SpinMutex, SpinMutexGuard}; |
| 29 | 22 | use self::unsafe_list::{UnsafeList, UnsafeListEntry}; |
| 23 | use super::abi::{thread, usercalls}; | |
| 24 | use crate::num::NonZero; | |
| 25 | use crate::ops::{Deref, DerefMut}; | |
| 26 | use crate::panic::{self, AssertUnwindSafe}; | |
| 27 | use crate::time::Duration; | |
| 30 | 28 | |
| 31 | 29 | /// An queue entry in a `WaitQueue`. |
| 32 | 30 | struct WaitEntry { |
library/std/src/sys/pal/solid/abi/fs.rs+2-1| ... | ... | @@ -1,11 +1,12 @@ |
| 1 | 1 | //! `solid_fs.h` |
| 2 | 2 | |
| 3 | use crate::os::raw::{c_char, c_int, c_uchar}; | |
| 4 | 3 | pub use libc::{ |
| 5 | 4 | ino_t, off_t, stat, time_t, O_APPEND, O_CREAT, O_EXCL, O_RDONLY, O_RDWR, O_TRUNC, O_WRONLY, |
| 6 | 5 | SEEK_CUR, SEEK_END, SEEK_SET, S_IFBLK, S_IFCHR, S_IFDIR, S_IFIFO, S_IFMT, S_IFREG, S_IWRITE, |
| 7 | 6 | }; |
| 8 | 7 | |
| 8 | use crate::os::raw::{c_char, c_int, c_uchar}; | |
| 9 | ||
| 9 | 10 | pub const O_ACCMODE: c_int = 0x3; |
| 10 | 11 | |
| 11 | 12 | pub const SOLID_MAX_PATH: usize = 256; |
library/std/src/sys/pal/solid/abi/mod.rs-1| ... | ... | @@ -3,7 +3,6 @@ use crate::os::raw::c_int; |
| 3 | 3 | mod fs; |
| 4 | 4 | pub mod sockets; |
| 5 | 5 | pub use self::fs::*; |
| 6 | ||
| 7 | 6 | // `solid_types.h` |
| 8 | 7 | pub use super::itron::abi::{ER, ER_ID, E_TMOUT, ID}; |
| 9 | 8 |
library/std/src/sys/pal/solid/abi/sockets.rs+2-1| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | use crate::os::raw::{c_char, c_uint, c_void}; | |
| 2 | 1 | pub use libc::{c_int, c_long, size_t, ssize_t, timeval}; |
| 3 | 2 | |
| 3 | use crate::os::raw::{c_char, c_uint, c_void}; | |
| 4 | ||
| 4 | 5 | pub const SOLID_NET_ERR_BASE: c_int = -2000; |
| 5 | 6 | pub const EINPROGRESS: c_int = SOLID_NET_ERR_BASE - libc::EINPROGRESS; |
| 6 | 7 |
library/std/src/sys/pal/solid/alloc.rs+2-4| ... | ... | @@ -1,7 +1,5 @@ |
| 1 | use crate::{ | |
| 2 | alloc::{GlobalAlloc, Layout, System}, | |
| 3 | sys::common::alloc::{realloc_fallback, MIN_ALIGN}, | |
| 4 | }; | |
| 1 | use crate::alloc::{GlobalAlloc, Layout, System}; | |
| 2 | use crate::sys::common::alloc::{realloc_fallback, MIN_ALIGN}; | |
| 5 | 3 | |
| 6 | 4 | #[stable(feature = "alloc_system_type", since = "1.28.0")] |
| 7 | 5 | unsafe impl GlobalAlloc for System { |
library/std/src/sys/pal/solid/error.rs+1-2| ... | ... | @@ -1,8 +1,7 @@ |
| 1 | pub use self::itron::error::{expect_success, ItronError as SolidError}; | |
| 1 | 2 | use super::{abi, itron, net}; |
| 2 | 3 | use crate::io::ErrorKind; |
| 3 | 4 | |
| 4 | pub use self::itron::error::{expect_success, ItronError as SolidError}; | |
| 5 | ||
| 6 | 5 | /// Describe the specified SOLID error code. Returns `None` if it's an |
| 7 | 6 | /// undefined error code. |
| 8 | 7 | /// |
library/std/src/sys/pal/solid/fs.rs+10-13| ... | ... | @@ -1,17 +1,14 @@ |
| 1 | 1 | use super::{abi, error}; |
| 2 | use crate::{ | |
| 3 | ffi::{CStr, CString, OsStr, OsString}, | |
| 4 | fmt, | |
| 5 | io::{self, BorrowedCursor, IoSlice, IoSliceMut, SeekFrom}, | |
| 6 | mem::MaybeUninit, | |
| 7 | os::raw::{c_int, c_short}, | |
| 8 | os::solid::ffi::OsStrExt, | |
| 9 | path::{Path, PathBuf}, | |
| 10 | sync::Arc, | |
| 11 | sys::time::SystemTime, | |
| 12 | sys::unsupported, | |
| 13 | }; | |
| 14 | ||
| 2 | use crate::ffi::{CStr, CString, OsStr, OsString}; | |
| 3 | use crate::fmt; | |
| 4 | use crate::io::{self, BorrowedCursor, IoSlice, IoSliceMut, SeekFrom}; | |
| 5 | use crate::mem::MaybeUninit; | |
| 6 | use crate::os::raw::{c_int, c_short}; | |
| 7 | use crate::os::solid::ffi::OsStrExt; | |
| 8 | use crate::path::{Path, PathBuf}; | |
| 9 | use crate::sync::Arc; | |
| 10 | use crate::sys::time::SystemTime; | |
| 11 | use crate::sys::unsupported; | |
| 15 | 12 | pub use crate::sys_common::fs::exists; |
| 16 | 13 | |
| 17 | 14 | /// A file descriptor. |
library/std/src/sys/pal/solid/io.rs+3-3| ... | ... | @@ -1,8 +1,8 @@ |
| 1 | use crate::marker::PhantomData; | |
| 2 | use crate::slice; | |
| 1 | use libc::c_void; | |
| 3 | 2 | |
| 4 | 3 | use super::abi::sockets::iovec; |
| 5 | use libc::c_void; | |
| 4 | use crate::marker::PhantomData; | |
| 5 | use crate::slice; | |
| 6 | 6 | |
| 7 | 7 | #[derive(Copy, Clone)] |
| 8 | 8 | #[repr(transparent)] |
library/std/src/sys/pal/solid/mod.rs+1-2| ... | ... | @@ -32,8 +32,7 @@ pub mod pipe; |
| 32 | 32 | #[path = "../unsupported/process.rs"] |
| 33 | 33 | pub mod process; |
| 34 | 34 | pub mod stdio; |
| 35 | pub use self::itron::thread; | |
| 36 | pub use self::itron::thread_parking; | |
| 35 | pub use self::itron::{thread, thread_parking}; | |
| 37 | 36 | pub mod time; |
| 38 | 37 | |
| 39 | 38 | // SAFETY: must be called only once during runtime initialization. |
library/std/src/sys/pal/solid/net.rs+10-14| ... | ... | @@ -1,19 +1,15 @@ |
| 1 | use super::abi; | |
| 2 | use crate::{ | |
| 3 | cmp, | |
| 4 | ffi::CStr, | |
| 5 | io::{self, BorrowedBuf, BorrowedCursor, ErrorKind, IoSlice, IoSliceMut}, | |
| 6 | mem, | |
| 7 | net::{Shutdown, SocketAddr}, | |
| 8 | os::solid::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, OwnedFd}, | |
| 9 | ptr, str, | |
| 10 | sys_common::net::{getsockopt, setsockopt, sockaddr_to_addr}, | |
| 11 | sys_common::{FromInner, IntoInner}, | |
| 12 | time::Duration, | |
| 13 | }; | |
| 1 | use libc::{c_int, c_void, size_t}; | |
| 14 | 2 | |
| 15 | 3 | use self::netc::{sockaddr, socklen_t, MSG_PEEK}; |
| 16 | use libc::{c_int, c_void, size_t}; | |
| 4 | use super::abi; | |
| 5 | use crate::ffi::CStr; | |
| 6 | use crate::io::{self, BorrowedBuf, BorrowedCursor, ErrorKind, IoSlice, IoSliceMut}; | |
| 7 | use crate::net::{Shutdown, SocketAddr}; | |
| 8 | use crate::os::solid::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, OwnedFd}; | |
| 9 | use crate::sys_common::net::{getsockopt, setsockopt, sockaddr_to_addr}; | |
| 10 | use crate::sys_common::{FromInner, IntoInner}; | |
| 11 | use crate::time::Duration; | |
| 12 | use crate::{cmp, mem, ptr, str}; | |
| 17 | 13 | |
| 18 | 14 | pub mod netc { |
| 19 | 15 | pub use super::super::abi::sockets::*; |
library/std/src/sys/pal/solid/os.rs+6-12| ... | ... | @@ -1,20 +1,14 @@ |
| 1 | use super::unsupported; | |
| 1 | use core::slice::memchr; | |
| 2 | ||
| 3 | use super::{error, itron, unsupported}; | |
| 2 | 4 | use crate::error::Error as StdError; |
| 3 | 5 | use crate::ffi::{CStr, OsStr, OsString}; |
| 4 | use crate::fmt; | |
| 5 | use crate::io; | |
| 6 | use crate::os::{ | |
| 7 | raw::{c_char, c_int}, | |
| 8 | solid::ffi::{OsStrExt, OsStringExt}, | |
| 9 | }; | |
| 6 | use crate::os::raw::{c_char, c_int}; | |
| 7 | use crate::os::solid::ffi::{OsStrExt, OsStringExt}; | |
| 10 | 8 | use crate::path::{self, PathBuf}; |
| 11 | 9 | use crate::sync::{PoisonError, RwLock}; |
| 12 | 10 | use crate::sys::common::small_c_string::run_with_cstr; |
| 13 | use crate::vec; | |
| 14 | ||
| 15 | use super::{error, itron}; | |
| 16 | ||
| 17 | use core::slice::memchr; | |
| 11 | use crate::{fmt, io, vec}; | |
| 18 | 12 | |
| 19 | 13 | // `solid` directly maps `errno`s to μITRON error codes. |
| 20 | 14 | impl itron::error::ItronError { |
library/std/src/sys/pal/solid/time.rs+4-3| ... | ... | @@ -1,7 +1,8 @@ |
| 1 | use super::{abi, error::expect_success}; | |
| 2 | use crate::{mem::MaybeUninit, time::Duration}; | |
| 3 | ||
| 1 | use super::abi; | |
| 2 | use super::error::expect_success; | |
| 4 | 3 | pub use super::itron::time::Instant; |
| 4 | use crate::mem::MaybeUninit; | |
| 5 | use crate::time::Duration; | |
| 5 | 6 | |
| 6 | 7 | #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)] |
| 7 | 8 | pub struct SystemTime(abi::time_t); |
library/std/src/sys/pal/teeos/os.rs+2-5| ... | ... | @@ -2,14 +2,11 @@ |
| 2 | 2 | |
| 3 | 3 | use core::marker::PhantomData; |
| 4 | 4 | |
| 5 | use super::unsupported; | |
| 5 | 6 | use crate::error::Error as StdError; |
| 6 | 7 | use crate::ffi::{OsStr, OsString}; |
| 7 | use crate::fmt; | |
| 8 | use crate::io; | |
| 9 | use crate::path; | |
| 10 | 8 | use crate::path::PathBuf; |
| 11 | ||
| 12 | use super::unsupported; | |
| 9 | use crate::{fmt, io, path}; | |
| 13 | 10 | |
| 14 | 11 | pub fn errno() -> i32 { |
| 15 | 12 | unsafe { (*libc::__errno_location()) as i32 } |
library/std/src/sys/pal/teeos/stdio.rs+2-1| ... | ... | @@ -1,8 +1,9 @@ |
| 1 | 1 | #![deny(unsafe_op_in_unsafe_fn)] |
| 2 | 2 | |
| 3 | use crate::io; | |
| 4 | 3 | use core::arch::asm; |
| 5 | 4 | |
| 5 | use crate::io; | |
| 6 | ||
| 6 | 7 | pub struct Stdin; |
| 7 | 8 | pub struct Stdout; |
| 8 | 9 | pub struct Stderr; |
library/std/src/sys/pal/teeos/thread.rs+1-3| ... | ... | @@ -1,11 +1,9 @@ |
| 1 | use crate::cmp; | |
| 2 | 1 | use crate::ffi::CStr; |
| 3 | use crate::io; | |
| 4 | 2 | use crate::mem::{self, ManuallyDrop}; |
| 5 | 3 | use crate::num::NonZero; |
| 6 | use crate::ptr; | |
| 7 | 4 | use crate::sys::os; |
| 8 | 5 | use crate::time::Duration; |
| 6 | use crate::{cmp, io, ptr}; | |
| 9 | 7 | |
| 10 | 8 | pub const DEFAULT_MIN_STACK_SIZE: usize = 8 * 1024; |
| 11 | 9 |
library/std/src/sys/pal/uefi/args.rs+1-2| ... | ... | @@ -3,10 +3,9 @@ use r_efi::protocols::loaded_image; |
| 3 | 3 | use super::helpers; |
| 4 | 4 | use crate::env::current_exe; |
| 5 | 5 | use crate::ffi::OsString; |
| 6 | use crate::fmt; | |
| 7 | 6 | use crate::iter::Iterator; |
| 8 | 7 | use crate::mem::size_of; |
| 9 | use crate::vec; | |
| 8 | use crate::{fmt, vec}; | |
| 10 | 9 | |
| 11 | 10 | pub struct Args { |
| 12 | 11 | parsed_args_list: vec::IntoIter<OsString>, |
library/std/src/sys/pal/uefi/helpers.rs+3-1| ... | ... | @@ -15,7 +15,9 @@ use r_efi::protocols::{device_path, device_path_to_text}; |
| 15 | 15 | use crate::ffi::{OsStr, OsString}; |
| 16 | 16 | use crate::io::{self, const_io_error}; |
| 17 | 17 | use crate::mem::{size_of, MaybeUninit}; |
| 18 | use crate::os::uefi::{self, env::boot_services, ffi::OsStrExt, ffi::OsStringExt}; | |
| 18 | use crate::os::uefi::env::boot_services; | |
| 19 | use crate::os::uefi::ffi::{OsStrExt, OsStringExt}; | |
| 20 | use crate::os::uefi::{self}; | |
| 19 | 21 | use crate::ptr::NonNull; |
| 20 | 22 | use crate::slice; |
| 21 | 23 | use crate::sync::atomic::{AtomicPtr, Ordering}; |
library/std/src/sys/pal/uefi/mod.rs+2-1| ... | ... | @@ -101,9 +101,10 @@ pub const fn unsupported_err() -> std_io::Error { |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | pub fn decode_error_kind(code: RawOsError) -> crate::io::ErrorKind { |
| 104 | use crate::io::ErrorKind; | |
| 105 | 104 | use r_efi::efi::Status; |
| 106 | 105 | |
| 106 | use crate::io::ErrorKind; | |
| 107 | ||
| 107 | 108 | match r_efi::efi::Status::from_usize(code) { |
| 108 | 109 | Status::ALREADY_STARTED |
| 109 | 110 | | Status::COMPROMISED_DATA |
library/std/src/sys/pal/uefi/os.rs+4-4| ... | ... | @@ -1,14 +1,14 @@ |
| 1 | use r_efi::efi::protocols::{device_path, loaded_image_device_path}; | |
| 2 | use r_efi::efi::Status; | |
| 3 | ||
| 1 | 4 | use super::{helpers, unsupported, RawOsError}; |
| 2 | 5 | use crate::error::Error as StdError; |
| 3 | 6 | use crate::ffi::{OsStr, OsString}; |
| 4 | use crate::fmt; | |
| 5 | use crate::io; | |
| 6 | 7 | use crate::marker::PhantomData; |
| 7 | 8 | use crate::os::uefi; |
| 8 | 9 | use crate::path::{self, PathBuf}; |
| 9 | 10 | use crate::ptr::NonNull; |
| 10 | use r_efi::efi::protocols::{device_path, loaded_image_device_path}; | |
| 11 | use r_efi::efi::Status; | |
| 11 | use crate::{fmt, io}; | |
| 12 | 12 | |
| 13 | 13 | pub fn errno() -> RawOsError { |
| 14 | 14 | 0 |
library/std/src/sys/pal/uefi/process.rs+5-10| ... | ... | @@ -1,20 +1,15 @@ |
| 1 | 1 | use r_efi::protocols::simple_text_output; |
| 2 | 2 | |
| 3 | use crate::ffi::OsStr; | |
| 4 | use crate::ffi::OsString; | |
| 5 | use crate::fmt; | |
| 6 | use crate::io; | |
| 7 | use crate::num::NonZero; | |
| 8 | use crate::num::NonZeroI32; | |
| 3 | use super::helpers; | |
| 4 | pub use crate::ffi::OsString as EnvKey; | |
| 5 | use crate::ffi::{OsStr, OsString}; | |
| 6 | use crate::num::{NonZero, NonZeroI32}; | |
| 9 | 7 | use crate::path::Path; |
| 10 | 8 | use crate::sys::fs::File; |
| 11 | 9 | use crate::sys::pipe::AnonPipe; |
| 12 | 10 | use crate::sys::unsupported; |
| 13 | 11 | use crate::sys_common::process::{CommandEnv, CommandEnvs}; |
| 14 | ||
| 15 | pub use crate::ffi::OsString as EnvKey; | |
| 16 | ||
| 17 | use super::helpers; | |
| 12 | use crate::{fmt, io}; | |
| 18 | 13 | |
| 19 | 14 | //////////////////////////////////////////////////////////////////////////////// |
| 20 | 15 | // Command |
library/std/src/sys/pal/uefi/time.rs+4-2| ... | ... | @@ -59,11 +59,12 @@ impl SystemTime { |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | pub(crate) mod system_time_internal { |
| 62 | use r_efi::efi::{RuntimeServices, Time}; | |
| 63 | ||
| 62 | 64 | use super::super::helpers; |
| 63 | 65 | use super::*; |
| 64 | 66 | use crate::mem::MaybeUninit; |
| 65 | 67 | use crate::ptr::NonNull; |
| 66 | use r_efi::efi::{RuntimeServices, Time}; | |
| 67 | 68 | |
| 68 | 69 | pub fn now() -> Option<SystemTime> { |
| 69 | 70 | let runtime_services: NonNull<RuntimeServices> = helpers::runtime_services()?; |
| ... | ... | @@ -114,13 +115,14 @@ pub(crate) mod system_time_internal { |
| 114 | 115 | } |
| 115 | 116 | |
| 116 | 117 | pub(crate) mod instant_internal { |
| 118 | use r_efi::protocols::timestamp; | |
| 119 | ||
| 117 | 120 | use super::super::helpers; |
| 118 | 121 | use super::*; |
| 119 | 122 | use crate::mem::MaybeUninit; |
| 120 | 123 | use crate::ptr::NonNull; |
| 121 | 124 | use crate::sync::atomic::{AtomicPtr, Ordering}; |
| 122 | 125 | use crate::sys_common::mul_div_u64; |
| 123 | use r_efi::protocols::timestamp; | |
| 124 | 126 | |
| 125 | 127 | const NS_PER_SEC: u64 = 1_000_000_000; |
| 126 | 128 |
library/std/src/sys/pal/unix/args.rs+1-2| ... | ... | @@ -6,9 +6,8 @@ |
| 6 | 6 | #![allow(dead_code)] // runtime init functions not used during testing |
| 7 | 7 | |
| 8 | 8 | use crate::ffi::{CStr, OsString}; |
| 9 | use crate::fmt; | |
| 10 | 9 | use crate::os::unix::ffi::OsStringExt; |
| 11 | use crate::vec; | |
| 10 | use crate::{fmt, vec}; | |
| 12 | 11 | |
| 13 | 12 | /// One-time global initialization. |
| 14 | 13 | pub unsafe fn init(argc: isize, argv: *const *const u8) { |
library/std/src/sys/pal/unix/fd.rs+6-6| ... | ... | @@ -3,12 +3,6 @@ |
| 3 | 3 | #[cfg(test)] |
| 4 | 4 | mod tests; |
| 5 | 5 | |
| 6 | use crate::cmp; | |
| 7 | use crate::io::{self, BorrowedCursor, IoSlice, IoSliceMut, Read}; | |
| 8 | use crate::os::unix::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, OwnedFd, RawFd}; | |
| 9 | use crate::sys::cvt; | |
| 10 | use crate::sys_common::{AsInner, FromInner, IntoInner}; | |
| 11 | ||
| 12 | 6 | #[cfg(any( |
| 13 | 7 | target_os = "android", |
| 14 | 8 | target_os = "linux", |
| ... | ... | @@ -26,6 +20,12 @@ use libc::off64_t; |
| 26 | 20 | )))] |
| 27 | 21 | use libc::off_t as off64_t; |
| 28 | 22 | |
| 23 | use crate::cmp; | |
| 24 | use crate::io::{self, BorrowedCursor, IoSlice, IoSliceMut, Read}; | |
| 25 | use crate::os::unix::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, OwnedFd, RawFd}; | |
| 26 | use crate::sys::cvt; | |
| 27 | use crate::sys_common::{AsInner, FromInner, IntoInner}; | |
| 28 | ||
| 29 | 29 | #[derive(Debug)] |
| 30 | 30 | pub struct FileDesc(OwnedFd); |
| 31 | 31 |
library/std/src/sys/pal/unix/fd/tests.rs+2-1| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | use core::mem::ManuallyDrop; | |
| 2 | ||
| 1 | 3 | use super::{FileDesc, IoSlice}; |
| 2 | 4 | use crate::os::unix::io::FromRawFd; |
| 3 | use core::mem::ManuallyDrop; | |
| 4 | 5 | |
| 5 | 6 | #[test] |
| 6 | 7 | fn limit_vector_count() { |
library/std/src/sys/pal/unix/fs.rs+23-28| ... | ... | @@ -4,29 +4,6 @@ |
| 4 | 4 | #[cfg(test)] |
| 5 | 5 | mod tests; |
| 6 | 6 | |
| 7 | use crate::os::unix::prelude::*; | |
| 8 | ||
| 9 | use crate::ffi::{CStr, OsStr, OsString}; | |
| 10 | use crate::fmt::{self, Write as _}; | |
| 11 | use crate::io::{self, BorrowedCursor, Error, IoSlice, IoSliceMut, SeekFrom}; | |
| 12 | use crate::mem; | |
| 13 | use crate::os::unix::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd}; | |
| 14 | use crate::path::{Path, PathBuf}; | |
| 15 | use crate::ptr; | |
| 16 | use crate::sync::Arc; | |
| 17 | use crate::sys::common::small_c_string::run_path_with_cstr; | |
| 18 | use crate::sys::fd::FileDesc; | |
| 19 | use crate::sys::time::SystemTime; | |
| 20 | use crate::sys::{cvt, cvt_r}; | |
| 21 | use crate::sys_common::{AsInner, AsInnerMut, FromInner, IntoInner}; | |
| 22 | ||
| 23 | #[cfg(all(target_os = "linux", target_env = "gnu"))] | |
| 24 | use crate::sys::weak::syscall; | |
| 25 | #[cfg(target_os = "android")] | |
| 26 | use crate::sys::weak::weak; | |
| 27 | ||
| 28 | use libc::{c_int, mode_t}; | |
| 29 | ||
| 30 | 7 | #[cfg(all(target_os = "linux", target_env = "gnu"))] |
| 31 | 8 | use libc::c_char; |
| 32 | 9 | #[cfg(any( |
| ... | ... | @@ -73,6 +50,7 @@ use libc::readdir64_r; |
| 73 | 50 | target_os = "hurd", |
| 74 | 51 | )))] |
| 75 | 52 | use libc::readdir_r as readdir64_r; |
| 53 | use libc::{c_int, mode_t}; | |
| 76 | 54 | #[cfg(target_os = "android")] |
| 77 | 55 | use libc::{ |
| 78 | 56 | dirent as dirent64, fstat as fstat64, fstatat as fstatat64, ftruncate64, lseek64, |
| ... | ... | @@ -97,7 +75,24 @@ use libc::{ |
| 97 | 75 | ))] |
| 98 | 76 | use libc::{dirent64, fstat64, ftruncate64, lseek64, lstat64, off64_t, open64, stat64}; |
| 99 | 77 | |
| 78 | use crate::ffi::{CStr, OsStr, OsString}; | |
| 79 | use crate::fmt::{self, Write as _}; | |
| 80 | use crate::io::{self, BorrowedCursor, Error, IoSlice, IoSliceMut, SeekFrom}; | |
| 81 | use crate::os::unix::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd}; | |
| 82 | use crate::os::unix::prelude::*; | |
| 83 | use crate::path::{Path, PathBuf}; | |
| 84 | use crate::sync::Arc; | |
| 85 | use crate::sys::common::small_c_string::run_path_with_cstr; | |
| 86 | use crate::sys::fd::FileDesc; | |
| 87 | use crate::sys::time::SystemTime; | |
| 88 | #[cfg(all(target_os = "linux", target_env = "gnu"))] | |
| 89 | use crate::sys::weak::syscall; | |
| 90 | #[cfg(target_os = "android")] | |
| 91 | use crate::sys::weak::weak; | |
| 92 | use crate::sys::{cvt, cvt_r}; | |
| 100 | 93 | pub use crate::sys_common::fs::exists; |
| 94 | use crate::sys_common::{AsInner, AsInnerMut, FromInner, IntoInner}; | |
| 95 | use crate::{mem, ptr}; | |
| 101 | 96 | |
| 102 | 97 | pub struct File(FileDesc); |
| 103 | 98 | |
| ... | ... | @@ -2021,6 +2016,11 @@ mod remove_dir_impl { |
| 2021 | 2016 | miri |
| 2022 | 2017 | )))] |
| 2023 | 2018 | mod remove_dir_impl { |
| 2019 | #[cfg(not(all(target_os = "linux", target_env = "gnu")))] | |
| 2020 | use libc::{fdopendir, openat, unlinkat}; | |
| 2021 | #[cfg(all(target_os = "linux", target_env = "gnu"))] | |
| 2022 | use libc::{fdopendir, openat64 as openat, unlinkat}; | |
| 2023 | ||
| 2024 | 2024 | use super::{lstat, Dir, DirEntry, InnerReadDir, ReadDir}; |
| 2025 | 2025 | use crate::ffi::CStr; |
| 2026 | 2026 | use crate::io; |
| ... | ... | @@ -2030,11 +2030,6 @@ mod remove_dir_impl { |
| 2030 | 2030 | use crate::sys::common::small_c_string::run_path_with_cstr; |
| 2031 | 2031 | use crate::sys::{cvt, cvt_r}; |
| 2032 | 2032 | |
| 2033 | #[cfg(not(all(target_os = "linux", target_env = "gnu")))] | |
| 2034 | use libc::{fdopendir, openat, unlinkat}; | |
| 2035 | #[cfg(all(target_os = "linux", target_env = "gnu"))] | |
| 2036 | use libc::{fdopendir, openat64 as openat, unlinkat}; | |
| 2037 | ||
| 2038 | 2033 | pub fn openat_nofollow_dironly(parent_fd: Option<RawFd>, p: &CStr) -> io::Result<OwnedFd> { |
| 2039 | 2034 | let fd = cvt_r(|| unsafe { |
| 2040 | 2035 | openat( |
library/std/src/sys/pal/unix/io.rs+2-2| ... | ... | @@ -1,9 +1,9 @@ |
| 1 | use libc::{c_void, iovec}; | |
| 2 | ||
| 1 | 3 | use crate::marker::PhantomData; |
| 2 | 4 | use crate::os::fd::{AsFd, AsRawFd}; |
| 3 | 5 | use crate::slice; |
| 4 | 6 | |
| 5 | use libc::{c_void, iovec}; | |
| 6 | ||
| 7 | 7 | #[derive(Copy, Clone)] |
| 8 | 8 | #[repr(transparent)] |
| 9 | 9 | pub struct IoSlice<'a> { |
library/std/src/sys/pal/unix/kernel_copy.rs+6-5| ... | ... | @@ -42,6 +42,12 @@ |
| 42 | 42 | //! progress, they can hit a performance cliff. |
| 43 | 43 | //! * complexity |
| 44 | 44 | |
| 45 | #[cfg(not(any(all(target_os = "linux", target_env = "gnu"), target_os = "hurd")))] | |
| 46 | use libc::sendfile as sendfile64; | |
| 47 | #[cfg(any(all(target_os = "linux", target_env = "gnu"), target_os = "hurd"))] | |
| 48 | use libc::sendfile64; | |
| 49 | use libc::{EBADF, EINVAL, ENOSYS, EOPNOTSUPP, EOVERFLOW, EPERM, EXDEV}; | |
| 50 | ||
| 45 | 51 | use crate::cmp::min; |
| 46 | 52 | use crate::fs::{File, Metadata}; |
| 47 | 53 | use crate::io::copy::generic_copy; |
| ... | ... | @@ -59,11 +65,6 @@ use crate::ptr; |
| 59 | 65 | use crate::sync::atomic::{AtomicBool, AtomicU8, Ordering}; |
| 60 | 66 | use crate::sys::cvt; |
| 61 | 67 | use crate::sys::weak::syscall; |
| 62 | #[cfg(not(any(all(target_os = "linux", target_env = "gnu"), target_os = "hurd")))] | |
| 63 | use libc::sendfile as sendfile64; | |
| 64 | #[cfg(any(all(target_os = "linux", target_env = "gnu"), target_os = "hurd"))] | |
| 65 | use libc::sendfile64; | |
| 66 | use libc::{EBADF, EINVAL, ENOSYS, EOPNOTSUPP, EOVERFLOW, EPERM, EXDEV}; | |
| 67 | 68 | |
| 68 | 69 | #[cfg(test)] |
| 69 | 70 | mod tests; |
library/std/src/sys/pal/unix/kernel_copy/tests.rs+1-3| ... | ... | @@ -1,8 +1,6 @@ |
| 1 | 1 | use crate::fs::OpenOptions; |
| 2 | 2 | use crate::io; |
| 3 | use crate::io::Result; | |
| 4 | use crate::io::SeekFrom; | |
| 5 | use crate::io::{BufRead, Read, Seek, Write}; | |
| 3 | use crate::io::{BufRead, Read, Result, Seek, SeekFrom, Write}; | |
| 6 | 4 | use crate::os::unix::io::AsRawFd; |
| 7 | 5 | use crate::sys_common::io::test::tmpdir; |
| 8 | 6 |
library/std/src/sys/pal/unix/mod.rs+8-6| ... | ... | @@ -1,8 +1,7 @@ |
| 1 | 1 | #![allow(missing_docs, nonstandard_style)] |
| 2 | 2 | |
| 3 | use crate::io::ErrorKind; | |
| 4 | ||
| 5 | 3 | pub use self::rand::hashmap_random_keys; |
| 4 | use crate::io::ErrorKind; | |
| 6 | 5 | |
| 7 | 6 | #[cfg(not(target_os = "espidf"))] |
| 8 | 7 | #[macro_use] |
| ... | ... | @@ -86,11 +85,12 @@ pub unsafe fn init(argc: isize, argv: *const *const u8, sigpipe: u8) { |
| 86 | 85 | target_vendor = "apple", |
| 87 | 86 | )))] |
| 88 | 87 | 'poll: { |
| 89 | use crate::sys::os::errno; | |
| 90 | 88 | #[cfg(not(all(target_os = "linux", target_env = "gnu")))] |
| 91 | 89 | use libc::open as open64; |
| 92 | 90 | #[cfg(all(target_os = "linux", target_env = "gnu"))] |
| 93 | 91 | use libc::open64; |
| 92 | ||
| 93 | use crate::sys::os::errno; | |
| 94 | 94 | let pfds: &mut [_] = &mut [ |
| 95 | 95 | libc::pollfd { fd: 0, events: 0, revents: 0 }, |
| 96 | 96 | libc::pollfd { fd: 1, events: 0, revents: 0 }, |
| ... | ... | @@ -140,11 +140,12 @@ pub unsafe fn init(argc: isize, argv: *const *const u8, sigpipe: u8) { |
| 140 | 140 | target_os = "vita", |
| 141 | 141 | )))] |
| 142 | 142 | { |
| 143 | use crate::sys::os::errno; | |
| 144 | 143 | #[cfg(not(all(target_os = "linux", target_env = "gnu")))] |
| 145 | 144 | use libc::open as open64; |
| 146 | 145 | #[cfg(all(target_os = "linux", target_env = "gnu"))] |
| 147 | 146 | use libc::open64; |
| 147 | ||
| 148 | use crate::sys::os::errno; | |
| 148 | 149 | for fd in 0..3 { |
| 149 | 150 | if libc::fcntl(fd, libc::F_GETFD) == -1 && errno() == libc::EBADF { |
| 150 | 151 | if open64(c"/dev/null".as_ptr().cast(), libc::O_RDWR, 0) == -1 { |
| ... | ... | @@ -232,12 +233,13 @@ pub unsafe fn cleanup() { |
| 232 | 233 | stack_overflow::cleanup(); |
| 233 | 234 | } |
| 234 | 235 | |
| 235 | #[cfg(target_os = "android")] | |
| 236 | pub use crate::sys::android::signal; | |
| 237 | 236 | #[allow(unused_imports)] |
| 238 | 237 | #[cfg(not(target_os = "android"))] |
| 239 | 238 | pub use libc::signal; |
| 240 | 239 | |
| 240 | #[cfg(target_os = "android")] | |
| 241 | pub use crate::sys::android::signal; | |
| 242 | ||
| 241 | 243 | #[inline] |
| 242 | 244 | pub(crate) fn is_interrupted(errno: i32) -> bool { |
| 243 | 245 | errno == libc::EINTR |
library/std/src/sys/pal/unix/net.rs+3-4| ... | ... | @@ -1,7 +1,7 @@ |
| 1 | use crate::cmp; | |
| 1 | use libc::{c_int, c_void, size_t, sockaddr, socklen_t, MSG_PEEK}; | |
| 2 | ||
| 2 | 3 | use crate::ffi::CStr; |
| 3 | 4 | use crate::io::{self, BorrowedBuf, BorrowedCursor, IoSlice, IoSliceMut}; |
| 4 | use crate::mem; | |
| 5 | 5 | use crate::net::{Shutdown, SocketAddr}; |
| 6 | 6 | use crate::os::unix::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, RawFd}; |
| 7 | 7 | use crate::sys::fd::FileDesc; |
| ... | ... | @@ -9,8 +9,7 @@ use crate::sys::pal::unix::IsMinusOne; |
| 9 | 9 | use crate::sys_common::net::{getsockopt, setsockopt, sockaddr_to_addr}; |
| 10 | 10 | use crate::sys_common::{AsInner, FromInner, IntoInner}; |
| 11 | 11 | use crate::time::{Duration, Instant}; |
| 12 | ||
| 13 | use libc::{c_int, c_void, size_t, sockaddr, socklen_t, MSG_PEEK}; | |
| 12 | use crate::{cmp, mem}; | |
| 14 | 13 | |
| 15 | 14 | cfg_if::cfg_if! { |
| 16 | 15 | if #[cfg(target_vendor = "apple")] { |
library/std/src/sys/pal/unix/os.rs+8-19| ... | ... | @@ -5,29 +5,20 @@ |
| 5 | 5 | #[cfg(test)] |
| 6 | 6 | mod tests; |
| 7 | 7 | |
| 8 | use crate::os::unix::prelude::*; | |
| 8 | use core::slice::memchr; | |
| 9 | ||
| 10 | use libc::{c_char, c_int, c_void}; | |
| 9 | 11 | |
| 10 | 12 | use crate::error::Error as StdError; |
| 11 | 13 | use crate::ffi::{CStr, CString, OsStr, OsString}; |
| 12 | use crate::fmt; | |
| 13 | use crate::io; | |
| 14 | use crate::iter; | |
| 15 | use crate::mem; | |
| 14 | use crate::os::unix::prelude::*; | |
| 16 | 15 | use crate::path::{self, PathBuf}; |
| 17 | use crate::ptr; | |
| 18 | use crate::slice; | |
| 19 | use crate::str; | |
| 20 | 16 | use crate::sync::{PoisonError, RwLock}; |
| 21 | 17 | use crate::sys::common::small_c_string::{run_path_with_cstr, run_with_cstr}; |
| 22 | use crate::sys::cvt; | |
| 23 | use crate::sys::fd; | |
| 24 | use crate::vec; | |
| 25 | use core::slice::memchr; | |
| 26 | ||
| 27 | 18 | #[cfg(all(target_env = "gnu", not(target_os = "vxworks")))] |
| 28 | 19 | use crate::sys::weak::weak; |
| 29 | ||
| 30 | use libc::{c_char, c_int, c_void}; | |
| 20 | use crate::sys::{cvt, fd}; | |
| 21 | use crate::{fmt, io, iter, mem, ptr, slice, str, vec}; | |
| 31 | 22 | |
| 32 | 23 | const TMPBUF_SZ: usize = 128; |
| 33 | 24 | |
| ... | ... | @@ -248,13 +239,12 @@ impl StdError for JoinPathsError { |
| 248 | 239 | |
| 249 | 240 | #[cfg(target_os = "aix")] |
| 250 | 241 | pub fn current_exe() -> io::Result<PathBuf> { |
| 251 | use crate::io::ErrorKind; | |
| 252 | ||
| 253 | 242 | #[cfg(test)] |
| 254 | 243 | use realstd::env; |
| 255 | 244 | |
| 256 | 245 | #[cfg(not(test))] |
| 257 | 246 | use crate::env; |
| 247 | use crate::io::ErrorKind; | |
| 258 | 248 | |
| 259 | 249 | let exe_path = env::args().next().ok_or(io::const_io_error!( |
| 260 | 250 | ErrorKind::NotFound, |
| ... | ... | @@ -513,13 +503,12 @@ pub fn current_exe() -> io::Result<PathBuf> { |
| 513 | 503 | |
| 514 | 504 | #[cfg(target_os = "fuchsia")] |
| 515 | 505 | pub fn current_exe() -> io::Result<PathBuf> { |
| 516 | use crate::io::ErrorKind; | |
| 517 | ||
| 518 | 506 | #[cfg(test)] |
| 519 | 507 | use realstd::env; |
| 520 | 508 | |
| 521 | 509 | #[cfg(not(test))] |
| 522 | 510 | use crate::env; |
| 511 | use crate::io::ErrorKind; | |
| 523 | 512 | |
| 524 | 513 | let exe_path = env::args().next().ok_or(io::const_io_error!( |
| 525 | 514 | ErrorKind::Uncategorized, |
library/std/src/sys/pal/unix/process/process_common.rs+5-9| ... | ... | @@ -1,24 +1,20 @@ |
| 1 | 1 | #[cfg(all(test, not(target_os = "emscripten")))] |
| 2 | 2 | mod tests; |
| 3 | 3 | |
| 4 | use crate::os::unix::prelude::*; | |
| 4 | use libc::{c_char, c_int, gid_t, pid_t, uid_t, EXIT_FAILURE, EXIT_SUCCESS}; | |
| 5 | 5 | |
| 6 | 6 | use crate::collections::BTreeMap; |
| 7 | 7 | use crate::ffi::{CStr, CString, OsStr, OsString}; |
| 8 | use crate::fmt; | |
| 9 | use crate::io; | |
| 8 | use crate::os::unix::prelude::*; | |
| 10 | 9 | use crate::path::Path; |
| 11 | use crate::ptr; | |
| 12 | 10 | use crate::sys::fd::FileDesc; |
| 13 | 11 | use crate::sys::fs::File; |
| 12 | #[cfg(not(target_os = "fuchsia"))] | |
| 13 | use crate::sys::fs::OpenOptions; | |
| 14 | 14 | use crate::sys::pipe::{self, AnonPipe}; |
| 15 | 15 | use crate::sys_common::process::{CommandEnv, CommandEnvs}; |
| 16 | 16 | use crate::sys_common::{FromInner, IntoInner}; |
| 17 | ||
| 18 | #[cfg(not(target_os = "fuchsia"))] | |
| 19 | use crate::sys::fs::OpenOptions; | |
| 20 | ||
| 21 | use libc::{c_char, c_int, gid_t, pid_t, uid_t, EXIT_FAILURE, EXIT_SUCCESS}; | |
| 17 | use crate::{fmt, io, ptr}; | |
| 22 | 18 | |
| 23 | 19 | cfg_if::cfg_if! { |
| 24 | 20 | if #[cfg(target_os = "fuchsia")] { |
library/std/src/sys/pal/unix/process/process_common/tests.rs+1-3| ... | ... | @@ -1,9 +1,7 @@ |
| 1 | 1 | use super::*; |
| 2 | ||
| 3 | 2 | use crate::ffi::OsStr; |
| 4 | use crate::mem; | |
| 5 | use crate::ptr; | |
| 6 | 3 | use crate::sys::{cvt, cvt_nz}; |
| 4 | use crate::{mem, ptr}; | |
| 7 | 5 | |
| 8 | 6 | macro_rules! t { |
| 9 | 7 | ($e:expr) => { |
library/std/src/sys/pal/unix/process/process_fuchsia.rs+3-7| ... | ... | @@ -1,13 +1,9 @@ |
| 1 | use crate::fmt; | |
| 2 | use crate::io; | |
| 3 | use crate::mem; | |
| 4 | use crate::num::NonZero; | |
| 5 | use crate::ptr; | |
| 1 | use libc::{c_int, size_t}; | |
| 6 | 2 | |
| 3 | use crate::num::NonZero; | |
| 7 | 4 | use crate::sys::process::process_common::*; |
| 8 | 5 | use crate::sys::process::zircon::{zx_handle_t, Handle}; |
| 9 | ||
| 10 | use libc::{c_int, size_t}; | |
| 6 | use crate::{fmt, io, mem, ptr}; | |
| 11 | 7 | |
| 12 | 8 | //////////////////////////////////////////////////////////////////////////////// |
| 13 | 9 | // Command |
library/std/src/sys/pal/unix/process/process_unix.rs+16-20| ... | ... | @@ -1,20 +1,7 @@ |
| 1 | use crate::fmt; | |
| 2 | use crate::io::{self, Error, ErrorKind}; | |
| 3 | use crate::mem; | |
| 4 | use crate::num::NonZero; | |
| 5 | use crate::sys; | |
| 6 | use crate::sys::cvt; | |
| 7 | use crate::sys::process::process_common::*; | |
| 8 | ||
| 9 | #[cfg(target_os = "linux")] | |
| 10 | use crate::sys::pal::unix::linux::pidfd::PidFd; | |
| 11 | ||
| 12 | 1 | #[cfg(target_os = "vxworks")] |
| 13 | 2 | use libc::RTP_ID as pid_t; |
| 14 | ||
| 15 | 3 | #[cfg(not(target_os = "vxworks"))] |
| 16 | 4 | use libc::{c_int, pid_t}; |
| 17 | ||
| 18 | 5 | #[cfg(not(any( |
| 19 | 6 | target_os = "vxworks", |
| 20 | 7 | target_os = "l4re", |
| ... | ... | @@ -23,6 +10,14 @@ use libc::{c_int, pid_t}; |
| 23 | 10 | )))] |
| 24 | 11 | use libc::{gid_t, uid_t}; |
| 25 | 12 | |
| 13 | use crate::io::{self, Error, ErrorKind}; | |
| 14 | use crate::num::NonZero; | |
| 15 | use crate::sys::cvt; | |
| 16 | #[cfg(target_os = "linux")] | |
| 17 | use crate::sys::pal::unix::linux::pidfd::PidFd; | |
| 18 | use crate::sys::process::process_common::*; | |
| 19 | use crate::{fmt, mem, sys}; | |
| 20 | ||
| 26 | 21 | cfg_if::cfg_if! { |
| 27 | 22 | if #[cfg(all(target_os = "nto", target_env = "nto71"))] { |
| 28 | 23 | use crate::thread; |
| ... | ... | @@ -446,11 +441,12 @@ impl Command { |
| 446 | 441 | stdio: &ChildPipes, |
| 447 | 442 | envp: Option<&CStringArray>, |
| 448 | 443 | ) -> io::Result<Option<Process>> { |
| 444 | #[cfg(target_os = "linux")] | |
| 445 | use core::sync::atomic::{AtomicU8, Ordering}; | |
| 446 | ||
| 449 | 447 | use crate::mem::MaybeUninit; |
| 450 | 448 | use crate::sys::weak::weak; |
| 451 | 449 | use crate::sys::{self, cvt_nz, on_broken_pipe_flag_used}; |
| 452 | #[cfg(target_os = "linux")] | |
| 453 | use core::sync::atomic::{AtomicU8, Ordering}; | |
| 454 | 450 | |
| 455 | 451 | if self.get_gid().is_some() |
| 456 | 452 | || self.get_uid().is_some() |
| ... | ... | @@ -762,10 +758,11 @@ impl Command { |
| 762 | 758 | |
| 763 | 759 | #[cfg(target_os = "linux")] |
| 764 | 760 | fn send_pidfd(&self, sock: &crate::sys::net::Socket) { |
| 761 | use libc::{CMSG_DATA, CMSG_FIRSTHDR, CMSG_LEN, CMSG_SPACE, SCM_RIGHTS, SOL_SOCKET}; | |
| 762 | ||
| 765 | 763 | use crate::io::IoSlice; |
| 766 | 764 | use crate::os::fd::RawFd; |
| 767 | 765 | use crate::sys::cvt_r; |
| 768 | use libc::{CMSG_DATA, CMSG_FIRSTHDR, CMSG_LEN, CMSG_SPACE, SCM_RIGHTS, SOL_SOCKET}; | |
| 769 | 766 | |
| 770 | 767 | unsafe { |
| 771 | 768 | let child_pid = libc::getpid(); |
| ... | ... | @@ -819,11 +816,11 @@ impl Command { |
| 819 | 816 | |
| 820 | 817 | #[cfg(target_os = "linux")] |
| 821 | 818 | fn recv_pidfd(&self, sock: &crate::sys::net::Socket) -> pid_t { |
| 819 | use libc::{CMSG_DATA, CMSG_FIRSTHDR, CMSG_LEN, CMSG_SPACE, SCM_RIGHTS, SOL_SOCKET}; | |
| 820 | ||
| 822 | 821 | use crate::io::IoSliceMut; |
| 823 | 822 | use crate::sys::cvt_r; |
| 824 | 823 | |
| 825 | use libc::{CMSG_DATA, CMSG_FIRSTHDR, CMSG_LEN, CMSG_SPACE, SCM_RIGHTS, SOL_SOCKET}; | |
| 826 | ||
| 827 | 824 | unsafe { |
| 828 | 825 | const SCM_MSG_LEN: usize = mem::size_of::<[c_int; 1]>(); |
| 829 | 826 | |
| ... | ... | @@ -1189,12 +1186,11 @@ impl ExitStatusError { |
| 1189 | 1186 | #[cfg(target_os = "linux")] |
| 1190 | 1187 | mod linux_child_ext { |
| 1191 | 1188 | |
| 1192 | use crate::io; | |
| 1193 | use crate::mem; | |
| 1194 | 1189 | use crate::os::linux::process as os; |
| 1195 | 1190 | use crate::sys::pal::unix::linux::pidfd as imp; |
| 1196 | 1191 | use crate::sys::pal::unix::ErrorKind; |
| 1197 | 1192 | use crate::sys_common::FromInner; |
| 1193 | use crate::{io, mem}; | |
| 1198 | 1194 | |
| 1199 | 1195 | #[unstable(feature = "linux_pidfd", issue = "82971")] |
| 1200 | 1196 | impl crate::os::linux::process::ChildExt for crate::process::Child { |
library/std/src/sys/pal/unix/process/process_unsupported.rs+2-2| ... | ... | @@ -1,10 +1,10 @@ |
| 1 | use libc::{c_int, pid_t}; | |
| 2 | ||
| 1 | 3 | use crate::io; |
| 2 | 4 | use crate::num::NonZero; |
| 3 | 5 | use crate::sys::pal::unix::unsupported::*; |
| 4 | 6 | use crate::sys::process::process_common::*; |
| 5 | 7 | |
| 6 | use libc::{c_int, pid_t}; | |
| 7 | ||
| 8 | 8 | //////////////////////////////////////////////////////////////////////////////// |
| 9 | 9 | // Command |
| 10 | 10 | //////////////////////////////////////////////////////////////////////////////// |
library/std/src/sys/pal/unix/process/process_unsupported/wait_status.rs+1-2| ... | ... | @@ -2,12 +2,11 @@ |
| 2 | 2 | //! |
| 3 | 3 | //! Separate module to facilitate testing against a real Unix implementation. |
| 4 | 4 | |
| 5 | use super::ExitStatusError; | |
| 5 | 6 | use crate::ffi::c_int; |
| 6 | 7 | use crate::fmt; |
| 7 | 8 | use crate::num::NonZero; |
| 8 | 9 | |
| 9 | use super::ExitStatusError; | |
| 10 | ||
| 11 | 10 | /// Emulated wait status for use by `process_unsupported.rs` |
| 12 | 11 | /// |
| 13 | 12 | /// Uses the "traditional unix" encoding. For use on platfors which are `#[cfg(unix)]` |
library/std/src/sys/pal/unix/process/process_vxworks.rs+3-4| ... | ... | @@ -1,12 +1,11 @@ |
| 1 | use crate::fmt; | |
| 1 | use libc::{self, c_char, c_int, RTP_ID}; | |
| 2 | ||
| 2 | 3 | use crate::io::{self, ErrorKind}; |
| 3 | 4 | use crate::num::NonZero; |
| 4 | use crate::sys; | |
| 5 | 5 | use crate::sys::cvt; |
| 6 | 6 | use crate::sys::pal::unix::thread; |
| 7 | 7 | use crate::sys::process::process_common::*; |
| 8 | use libc::RTP_ID; | |
| 9 | use libc::{self, c_char, c_int}; | |
| 8 | use crate::{fmt, sys}; | |
| 10 | 9 | |
| 11 | 10 | //////////////////////////////////////////////////////////////////////////////// |
| 12 | 11 | // Command |
library/std/src/sys/pal/unix/process/zircon.rs+2-2| ... | ... | @@ -1,11 +1,11 @@ |
| 1 | 1 | #![allow(non_camel_case_types, unused)] |
| 2 | 2 | |
| 3 | use libc::{c_int, c_void, size_t}; | |
| 4 | ||
| 3 | 5 | use crate::io; |
| 4 | 6 | use crate::mem::MaybeUninit; |
| 5 | 7 | use crate::os::raw::c_char; |
| 6 | 8 | |
| 7 | use libc::{c_int, c_void, size_t}; | |
| 8 | ||
| 9 | 9 | pub type zx_handle_t = u32; |
| 10 | 10 | pub type zx_vaddr_t = usize; |
| 11 | 11 | pub type zx_rights_t = u32; |
library/std/src/sys/pal/unix/rand.rs+5-3| ... | ... | @@ -24,7 +24,6 @@ pub fn hashmap_random_keys() -> (u64, u64) { |
| 24 | 24 | mod imp { |
| 25 | 25 | use crate::fs::File; |
| 26 | 26 | use crate::io::Read; |
| 27 | ||
| 28 | 27 | #[cfg(any(target_os = "linux", target_os = "android"))] |
| 29 | 28 | use crate::sys::weak::syscall; |
| 30 | 29 | |
| ... | ... | @@ -178,9 +177,10 @@ mod imp { |
| 178 | 177 | |
| 179 | 178 | #[cfg(target_vendor = "apple")] |
| 180 | 179 | mod imp { |
| 181 | use crate::io; | |
| 182 | 180 | use libc::{c_int, c_void, size_t}; |
| 183 | 181 | |
| 182 | use crate::io; | |
| 183 | ||
| 184 | 184 | #[inline(always)] |
| 185 | 185 | fn random_failure() -> ! { |
| 186 | 186 | panic!("unexpected random generation error: {}", io::Error::last_os_error()); |
| ... | ... | @@ -311,8 +311,10 @@ mod imp { |
| 311 | 311 | |
| 312 | 312 | #[cfg(target_os = "vxworks")] |
| 313 | 313 | mod imp { |
| 314 | use core::sync::atomic::AtomicBool; | |
| 315 | use core::sync::atomic::Ordering::Relaxed; | |
| 316 | ||
| 314 | 317 | use crate::io; |
| 315 | use core::sync::atomic::{AtomicBool, Ordering::Relaxed}; | |
| 316 | 318 | |
| 317 | 319 | pub fn fill_bytes(v: &mut [u8]) { |
| 318 | 320 | static RNG_INIT: AtomicBool = AtomicBool::new(false); |
library/std/src/sys/pal/unix/stack_overflow.rs+12-15| ... | ... | @@ -1,10 +1,8 @@ |
| 1 | 1 | #![cfg_attr(test, allow(dead_code))] |
| 2 | 2 | |
| 3 | pub use self::imp::{cleanup, init}; | |
| 3 | 4 | use self::imp::{drop_handler, make_handler}; |
| 4 | 5 | |
| 5 | pub use self::imp::cleanup; | |
| 6 | pub use self::imp::init; | |
| 7 | ||
| 8 | 6 | pub struct Handler { |
| 9 | 7 | data: *mut libc::c_void, |
| 10 | 8 | } |
| ... | ... | @@ -37,24 +35,23 @@ impl Drop for Handler { |
| 37 | 35 | target_os = "solaris" |
| 38 | 36 | ))] |
| 39 | 37 | mod imp { |
| 38 | #[cfg(not(all(target_os = "linux", target_env = "gnu")))] | |
| 39 | use libc::{mmap as mmap64, mprotect, munmap}; | |
| 40 | #[cfg(all(target_os = "linux", target_env = "gnu"))] | |
| 41 | use libc::{mmap64, mprotect, munmap}; | |
| 42 | use libc::{ | |
| 43 | sigaction, sigaltstack, sighandler_t, MAP_ANON, MAP_FAILED, MAP_FIXED, MAP_PRIVATE, | |
| 44 | PROT_NONE, PROT_READ, PROT_WRITE, SA_ONSTACK, SA_SIGINFO, SIGBUS, SIGSEGV, SIG_DFL, | |
| 45 | SS_DISABLE, | |
| 46 | }; | |
| 47 | ||
| 40 | 48 | use super::Handler; |
| 41 | 49 | use crate::cell::Cell; |
| 42 | use crate::io; | |
| 43 | use crate::mem; | |
| 44 | 50 | use crate::ops::Range; |
| 45 | use crate::ptr; | |
| 46 | 51 | use crate::sync::atomic::{AtomicBool, AtomicPtr, AtomicUsize, Ordering}; |
| 47 | 52 | use crate::sync::OnceLock; |
| 48 | 53 | use crate::sys::pal::unix::os; |
| 49 | use crate::thread; | |
| 50 | ||
| 51 | #[cfg(not(all(target_os = "linux", target_env = "gnu")))] | |
| 52 | use libc::{mmap as mmap64, mprotect, munmap}; | |
| 53 | #[cfg(all(target_os = "linux", target_env = "gnu"))] | |
| 54 | use libc::{mmap64, mprotect, munmap}; | |
| 55 | use libc::{sigaction, sighandler_t, SA_ONSTACK, SA_SIGINFO, SIGBUS, SIGSEGV, SIG_DFL}; | |
| 56 | use libc::{sigaltstack, SS_DISABLE}; | |
| 57 | use libc::{MAP_ANON, MAP_FAILED, MAP_FIXED, MAP_PRIVATE, PROT_NONE, PROT_READ, PROT_WRITE}; | |
| 54 | use crate::{io, mem, ptr, thread}; | |
| 58 | 55 | |
| 59 | 56 | // We use a TLS variable to store the address of the guard page. While TLS |
| 60 | 57 | // variables are not guaranteed to be signal-safe, this works out in practice |
library/std/src/sys/pal/unix/thread.rs+5-10| ... | ... | @@ -1,16 +1,13 @@ |
| 1 | use crate::cmp; | |
| 2 | 1 | use crate::ffi::CStr; |
| 3 | use crate::io; | |
| 4 | 2 | use crate::mem::{self, ManuallyDrop}; |
| 5 | 3 | use crate::num::NonZero; |
| 6 | use crate::ptr; | |
| 7 | use crate::sys::{os, stack_overflow}; | |
| 8 | use crate::time::Duration; | |
| 9 | ||
| 10 | 4 | #[cfg(all(target_os = "linux", target_env = "gnu"))] |
| 11 | 5 | use crate::sys::weak::dlsym; |
| 12 | 6 | #[cfg(any(target_os = "solaris", target_os = "illumos", target_os = "nto"))] |
| 13 | 7 | use crate::sys::weak::weak; |
| 8 | use crate::sys::{os, stack_overflow}; | |
| 9 | use crate::time::Duration; | |
| 10 | use crate::{cmp, io, ptr}; | |
| 14 | 11 | #[cfg(not(any(target_os = "l4re", target_os = "vxworks", target_os = "espidf")))] |
| 15 | 12 | pub const DEFAULT_MIN_STACK_SIZE: usize = 2 * 1024 * 1024; |
| 16 | 13 | #[cfg(target_os = "l4re")] |
| ... | ... | @@ -475,11 +472,9 @@ mod cgroups { |
| 475 | 472 | use crate::borrow::Cow; |
| 476 | 473 | use crate::ffi::OsString; |
| 477 | 474 | use crate::fs::{exists, File}; |
| 478 | use crate::io::Read; | |
| 479 | use crate::io::{BufRead, BufReader}; | |
| 475 | use crate::io::{BufRead, BufReader, Read}; | |
| 480 | 476 | use crate::os::unix::ffi::OsStringExt; |
| 481 | use crate::path::Path; | |
| 482 | use crate::path::PathBuf; | |
| 477 | use crate::path::{Path, PathBuf}; | |
| 483 | 478 | use crate::str::from_utf8; |
| 484 | 479 | |
| 485 | 480 | #[derive(PartialEq)] |
library/std/src/sys/pal/unix/thread_parking.rs+2-1| ... | ... | @@ -2,10 +2,11 @@ |
| 2 | 2 | // separate modules for each platform. |
| 3 | 3 | #![cfg(target_os = "netbsd")] |
| 4 | 4 | |
| 5 | use libc::{_lwp_self, c_long, clockid_t, lwpid_t, time_t, timespec, CLOCK_MONOTONIC}; | |
| 6 | ||
| 5 | 7 | use crate::ffi::{c_int, c_void}; |
| 6 | 8 | use crate::ptr; |
| 7 | 9 | use crate::time::Duration; |
| 8 | use libc::{_lwp_self, c_long, clockid_t, lwpid_t, time_t, timespec, CLOCK_MONOTONIC}; | |
| 9 | 10 | |
| 10 | 11 | extern "C" { |
| 11 | 12 | fn ___lwp_park60( |
library/std/src/sys/pal/unix/weak.rs+1-2| ... | ... | @@ -23,9 +23,8 @@ |
| 23 | 23 | |
| 24 | 24 | use crate::ffi::CStr; |
| 25 | 25 | use crate::marker::PhantomData; |
| 26 | use crate::mem; | |
| 27 | use crate::ptr; | |
| 28 | 26 | use crate::sync::atomic::{self, AtomicPtr, Ordering}; |
| 27 | use crate::{mem, ptr}; | |
| 29 | 28 | |
| 30 | 29 | // We can use true weak linkage on ELF targets. |
| 31 | 30 | #[cfg(all(unix, not(target_vendor = "apple")))] |
library/std/src/sys/pal/unsupported/os.rs+1-2| ... | ... | @@ -1,10 +1,9 @@ |
| 1 | 1 | use super::unsupported; |
| 2 | 2 | use crate::error::Error as StdError; |
| 3 | 3 | use crate::ffi::{OsStr, OsString}; |
| 4 | use crate::fmt; | |
| 5 | use crate::io; | |
| 6 | 4 | use crate::marker::PhantomData; |
| 7 | 5 | use crate::path::{self, PathBuf}; |
| 6 | use crate::{fmt, io}; | |
| 8 | 7 | |
| 9 | 8 | pub fn errno() -> i32 { |
| 10 | 9 | 0 |
library/std/src/sys/pal/unsupported/pipe.rs+2-4| ... | ... | @@ -1,7 +1,5 @@ |
| 1 | use crate::{ | |
| 2 | fmt, | |
| 3 | io::{self, BorrowedCursor, IoSlice, IoSliceMut}, | |
| 4 | }; | |
| 1 | use crate::fmt; | |
| 2 | use crate::io::{self, BorrowedCursor, IoSlice, IoSliceMut}; | |
| 5 | 3 | |
| 6 | 4 | pub struct AnonPipe(!); |
| 7 | 5 |
library/std/src/sys/pal/unsupported/process.rs+2-4| ... | ... | @@ -1,14 +1,12 @@ |
| 1 | pub use crate::ffi::OsString as EnvKey; | |
| 1 | 2 | use crate::ffi::{OsStr, OsString}; |
| 2 | use crate::fmt; | |
| 3 | use crate::io; | |
| 4 | 3 | use crate::num::NonZero; |
| 5 | 4 | use crate::path::Path; |
| 6 | 5 | use crate::sys::fs::File; |
| 7 | 6 | use crate::sys::pipe::AnonPipe; |
| 8 | 7 | use crate::sys::unsupported; |
| 9 | 8 | use crate::sys_common::process::{CommandEnv, CommandEnvs}; |
| 10 | ||
| 11 | pub use crate::ffi::OsString as EnvKey; | |
| 9 | use crate::{fmt, io}; | |
| 12 | 10 | |
| 13 | 11 | //////////////////////////////////////////////////////////////////////////////// |
| 14 | 12 | // Command |
library/std/src/sys/pal/wasi/args.rs+1-2| ... | ... | @@ -1,9 +1,8 @@ |
| 1 | 1 | #![deny(unsafe_op_in_unsafe_fn)] |
| 2 | 2 | |
| 3 | 3 | use crate::ffi::{CStr, OsStr, OsString}; |
| 4 | use crate::fmt; | |
| 5 | 4 | use crate::os::wasi::ffi::OsStrExt; |
| 6 | use crate::vec; | |
| 5 | use crate::{fmt, vec}; | |
| 7 | 6 | |
| 8 | 7 | pub struct Args { |
| 9 | 8 | iter: vec::IntoIter<OsString>, |
library/std/src/sys/pal/wasi/fs.rs+2-5| ... | ... | @@ -2,22 +2,19 @@ |
| 2 | 2 | |
| 3 | 3 | use super::fd::WasiFd; |
| 4 | 4 | use crate::ffi::{CStr, OsStr, OsString}; |
| 5 | use crate::fmt; | |
| 6 | 5 | use crate::io::{self, BorrowedCursor, IoSlice, IoSliceMut, SeekFrom}; |
| 7 | use crate::iter; | |
| 8 | 6 | use crate::mem::{self, ManuallyDrop}; |
| 9 | 7 | use crate::os::raw::c_int; |
| 10 | 8 | use crate::os::wasi::ffi::{OsStrExt, OsStringExt}; |
| 11 | 9 | use crate::os::wasi::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, RawFd}; |
| 12 | 10 | use crate::path::{Path, PathBuf}; |
| 13 | use crate::ptr; | |
| 14 | 11 | use crate::sync::Arc; |
| 15 | 12 | use crate::sys::common::small_c_string::run_path_with_cstr; |
| 16 | 13 | use crate::sys::time::SystemTime; |
| 17 | 14 | use crate::sys::unsupported; |
| 18 | use crate::sys_common::{AsInner, FromInner, IntoInner}; | |
| 19 | ||
| 20 | 15 | pub use crate::sys_common::fs::exists; |
| 16 | use crate::sys_common::{AsInner, FromInner, IntoInner}; | |
| 17 | use crate::{fmt, iter, ptr}; | |
| 21 | 18 | |
| 22 | 19 | pub struct File { |
| 23 | 20 | fd: WasiFd, |
library/std/src/sys/pal/wasi/helpers.rs+1-2| ... | ... | @@ -1,5 +1,4 @@ |
| 1 | use crate::io as std_io; | |
| 2 | use crate::mem; | |
| 1 | use crate::{io as std_io, mem}; | |
| 3 | 2 | |
| 4 | 3 | #[inline] |
| 5 | 4 | pub fn is_interrupted(errno: i32) -> bool { |
library/std/src/sys/pal/wasi/mod.rs+1-4| ... | ... | @@ -48,8 +48,5 @@ mod helpers; |
| 48 | 48 | // import conflict rules. If we glob export `helpers` and `common` together, |
| 49 | 49 | // then the compiler complains about conflicts. |
| 50 | 50 | |
| 51 | pub use helpers::abort_internal; | |
| 52 | pub use helpers::decode_error_kind; | |
| 53 | 51 | use helpers::err2io; |
| 54 | pub use helpers::hashmap_random_keys; | |
| 55 | pub use helpers::is_interrupted; | |
| 52 | pub use helpers::{abort_internal, decode_error_kind, hashmap_random_keys, is_interrupted}; |
library/std/src/sys/pal/wasi/os.rs+3-5| ... | ... | @@ -1,18 +1,16 @@ |
| 1 | 1 | #![deny(unsafe_op_in_unsafe_fn)] |
| 2 | 2 | |
| 3 | use core::slice::memchr; | |
| 4 | ||
| 3 | 5 | use crate::error::Error as StdError; |
| 4 | 6 | use crate::ffi::{CStr, OsStr, OsString}; |
| 5 | use crate::fmt; | |
| 6 | use crate::io; | |
| 7 | 7 | use crate::marker::PhantomData; |
| 8 | 8 | use crate::ops::Drop; |
| 9 | 9 | use crate::os::wasi::prelude::*; |
| 10 | 10 | use crate::path::{self, PathBuf}; |
| 11 | use crate::str; | |
| 12 | 11 | use crate::sys::common::small_c_string::{run_path_with_cstr, run_with_cstr}; |
| 13 | 12 | use crate::sys::unsupported; |
| 14 | use crate::vec; | |
| 15 | use core::slice::memchr; | |
| 13 | use crate::{fmt, io, str, vec}; | |
| 16 | 14 | |
| 17 | 15 | // Add a few symbols not in upstream `libc` just yet. |
| 18 | 16 | mod libc { |
library/std/src/sys/pal/wasi/thread.rs+1-2| ... | ... | @@ -1,9 +1,8 @@ |
| 1 | 1 | use crate::ffi::CStr; |
| 2 | use crate::io; | |
| 3 | use crate::mem; | |
| 4 | 2 | use crate::num::NonZero; |
| 5 | 3 | use crate::sys::unsupported; |
| 6 | 4 | use crate::time::Duration; |
| 5 | use crate::{io, mem}; | |
| 7 | 6 | |
| 8 | 7 | cfg_if::cfg_if! { |
| 9 | 8 | if #[cfg(target_feature = "atomics")] { |
library/std/src/sys/pal/wasip2/mod.rs+1-4| ... | ... | @@ -51,10 +51,7 @@ mod helpers; |
| 51 | 51 | // import conflict rules. If we glob export `helpers` and `common` together, |
| 52 | 52 | // then the compiler complains about conflicts. |
| 53 | 53 | |
| 54 | pub use helpers::abort_internal; | |
| 55 | pub use helpers::decode_error_kind; | |
| 56 | 54 | use helpers::err2io; |
| 57 | pub use helpers::hashmap_random_keys; | |
| 58 | pub use helpers::is_interrupted; | |
| 55 | pub use helpers::{abort_internal, decode_error_kind, hashmap_random_keys, is_interrupted}; | |
| 59 | 56 | |
| 60 | 57 | mod cabi_realloc; |
library/std/src/sys/pal/wasm/alloc.rs+2-4| ... | ... | @@ -57,10 +57,8 @@ unsafe impl GlobalAlloc for System { |
| 57 | 57 | |
| 58 | 58 | #[cfg(target_feature = "atomics")] |
| 59 | 59 | mod lock { |
| 60 | use crate::sync::atomic::{ | |
| 61 | AtomicI32, | |
| 62 | Ordering::{Acquire, Release}, | |
| 63 | }; | |
| 60 | use crate::sync::atomic::AtomicI32; | |
| 61 | use crate::sync::atomic::Ordering::{Acquire, Release}; | |
| 64 | 62 | |
| 65 | 63 | static LOCKED: AtomicI32 = AtomicI32::new(0); |
| 66 | 64 |
library/std/src/sys/pal/windows/alloc.rs+2-1| ... | ... | @@ -1,10 +1,11 @@ |
| 1 | use core::mem::MaybeUninit; | |
| 2 | ||
| 1 | 3 | use crate::alloc::{GlobalAlloc, Layout, System}; |
| 2 | 4 | use crate::ffi::c_void; |
| 3 | 5 | use crate::ptr; |
| 4 | 6 | use crate::sync::atomic::{AtomicPtr, Ordering}; |
| 5 | 7 | use crate::sys::c::{self, windows_targets}; |
| 6 | 8 | use crate::sys::common::alloc::{realloc_fallback, MIN_ALIGN}; |
| 7 | use core::mem::MaybeUninit; | |
| 8 | 9 | |
| 9 | 10 | #[cfg(test)] |
| 10 | 11 | mod tests; |
library/std/src/sys/pal/windows/args.rs+1-5| ... | ... | @@ -8,8 +8,6 @@ mod tests; |
| 8 | 8 | |
| 9 | 9 | use super::os::current_exe; |
| 10 | 10 | use crate::ffi::{OsStr, OsString}; |
| 11 | use crate::fmt; | |
| 12 | use crate::io; | |
| 13 | 11 | use crate::num::NonZero; |
| 14 | 12 | use crate::os::windows::prelude::*; |
| 15 | 13 | use crate::path::{Path, PathBuf}; |
| ... | ... | @@ -18,9 +16,7 @@ use crate::sys::process::ensure_no_nuls; |
| 18 | 16 | use crate::sys::{c, to_u16s}; |
| 19 | 17 | use crate::sys_common::wstr::WStrUnits; |
| 20 | 18 | use crate::sys_common::AsInner; |
| 21 | use crate::vec; | |
| 22 | ||
| 23 | use crate::iter; | |
| 19 | use crate::{fmt, io, iter, vec}; | |
| 24 | 20 | |
| 25 | 21 | /// This is the const equivalent to `NonZero::new(n).unwrap()` |
| 26 | 22 | /// |
library/std/src/sys/pal/windows/c.rs+1-2| ... | ... | @@ -6,8 +6,7 @@ |
| 6 | 6 | #![allow(clippy::style)] |
| 7 | 7 | |
| 8 | 8 | use core::ffi::{c_uint, c_ulong, c_ushort, c_void, CStr}; |
| 9 | use core::mem; | |
| 10 | use core::ptr; | |
| 9 | use core::{mem, ptr}; | |
| 11 | 10 | |
| 12 | 11 | pub(super) mod windows_targets; |
| 13 | 12 |
library/std/src/sys/pal/windows/fs.rs+5-10| ... | ... | @@ -1,26 +1,21 @@ |
| 1 | 1 | use core::ptr::addr_of; |
| 2 | 2 | |
| 3 | use crate::os::windows::prelude::*; | |
| 4 | ||
| 3 | use super::api::{self, WinError}; | |
| 4 | use super::{to_u16s, IoResult}; | |
| 5 | 5 | use crate::borrow::Cow; |
| 6 | 6 | use crate::ffi::{c_void, OsStr, OsString}; |
| 7 | use crate::fmt; | |
| 8 | 7 | use crate::io::{self, BorrowedCursor, Error, IoSlice, IoSliceMut, SeekFrom}; |
| 9 | 8 | use crate::mem::{self, MaybeUninit}; |
| 10 | 9 | use crate::os::windows::io::{AsHandle, BorrowedHandle}; |
| 10 | use crate::os::windows::prelude::*; | |
| 11 | 11 | use crate::path::{Path, PathBuf}; |
| 12 | use crate::ptr; | |
| 13 | use crate::slice; | |
| 14 | 12 | use crate::sync::Arc; |
| 15 | 13 | use crate::sys::handle::Handle; |
| 14 | use crate::sys::path::maybe_verbatim; | |
| 16 | 15 | use crate::sys::time::SystemTime; |
| 17 | 16 | use crate::sys::{c, cvt, Align8}; |
| 18 | 17 | use crate::sys_common::{AsInner, FromInner, IntoInner}; |
| 19 | use crate::thread; | |
| 20 | ||
| 21 | use super::api::{self, WinError}; | |
| 22 | use super::{to_u16s, IoResult}; | |
| 23 | use crate::sys::path::maybe_verbatim; | |
| 18 | use crate::{fmt, ptr, slice, thread}; | |
| 24 | 19 | |
| 25 | 20 | pub struct File { |
| 26 | 21 | handle: Handle, |
library/std/src/sys/pal/windows/futex.rs+4-5| ... | ... | @@ -1,14 +1,13 @@ |
| 1 | use super::api::{self, WinError}; | |
| 2 | use crate::sys::c; | |
| 3 | use crate::sys::dur2timeout; | |
| 4 | 1 | use core::ffi::c_void; |
| 5 | use core::mem; | |
| 6 | use core::ptr; | |
| 7 | 2 | use core::sync::atomic::{ |
| 8 | 3 | AtomicBool, AtomicI16, AtomicI32, AtomicI64, AtomicI8, AtomicIsize, AtomicPtr, AtomicU16, |
| 9 | 4 | AtomicU32, AtomicU64, AtomicU8, AtomicUsize, |
| 10 | 5 | }; |
| 11 | 6 | use core::time::Duration; |
| 7 | use core::{mem, ptr}; | |
| 8 | ||
| 9 | use super::api::{self, WinError}; | |
| 10 | use crate::sys::{c, dur2timeout}; | |
| 12 | 11 | |
| 13 | 12 | /// An atomic for use as a futex that is at least 8-bits but may be larger. |
| 14 | 13 | pub type SmallAtomic = AtomicU8; |
library/std/src/sys/pal/windows/handle.rs+4-6| ... | ... | @@ -3,17 +3,15 @@ |
| 3 | 3 | #[cfg(test)] |
| 4 | 4 | mod tests; |
| 5 | 5 | |
| 6 | use core::ffi::c_void; | |
| 7 | use core::{cmp, mem, ptr}; | |
| 8 | ||
| 6 | 9 | use crate::io::{self, BorrowedCursor, ErrorKind, IoSlice, IoSliceMut, Read}; |
| 7 | 10 | use crate::os::windows::io::{ |
| 8 | 11 | AsHandle, AsRawHandle, BorrowedHandle, FromRawHandle, IntoRawHandle, OwnedHandle, RawHandle, |
| 9 | 12 | }; |
| 10 | use crate::sys::c; | |
| 11 | use crate::sys::cvt; | |
| 13 | use crate::sys::{c, cvt}; | |
| 12 | 14 | use crate::sys_common::{AsInner, FromInner, IntoInner}; |
| 13 | use core::cmp; | |
| 14 | use core::ffi::c_void; | |
| 15 | use core::mem; | |
| 16 | use core::ptr; | |
| 17 | 15 | |
| 18 | 16 | /// An owned container for `HANDLE` object, closing them on Drop. |
| 19 | 17 | /// |
library/std/src/sys/pal/windows/io.rs+2-1| ... | ... | @@ -1,9 +1,10 @@ |
| 1 | use core::ffi::c_void; | |
| 2 | ||
| 1 | 3 | use crate::marker::PhantomData; |
| 2 | 4 | use crate::mem::size_of; |
| 3 | 5 | use crate::os::windows::io::{AsHandle, AsRawHandle, BorrowedHandle}; |
| 4 | 6 | use crate::slice; |
| 5 | 7 | use crate::sys::c; |
| 6 | use core::ffi::c_void; | |
| 7 | 8 | |
| 8 | 9 | #[derive(Copy, Clone)] |
| 9 | 10 | #[repr(transparent)] |
library/std/src/sys/pal/windows/mod.rs+1-2| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | 1 | #![allow(missing_docs, nonstandard_style)] |
| 2 | 2 | #![forbid(unsafe_op_in_unsafe_fn)] |
| 3 | 3 | |
| 4 | pub use self::rand::hashmap_random_keys; | |
| 4 | 5 | use crate::ffi::{OsStr, OsString}; |
| 5 | 6 | use crate::io::ErrorKind; |
| 6 | 7 | use crate::mem::MaybeUninit; |
| ... | ... | @@ -9,8 +10,6 @@ use crate::path::PathBuf; |
| 9 | 10 | use crate::sys::pal::windows::api::wide_str; |
| 10 | 11 | use crate::time::Duration; |
| 11 | 12 | |
| 12 | pub use self::rand::hashmap_random_keys; | |
| 13 | ||
| 14 | 13 | #[macro_use] |
| 15 | 14 | pub mod compat; |
| 16 | 15 |
library/std/src/sys/pal/windows/net.rs+5-9| ... | ... | @@ -1,21 +1,17 @@ |
| 1 | 1 | #![unstable(issue = "none", feature = "windows_net")] |
| 2 | 2 | |
| 3 | use crate::cmp; | |
| 3 | use core::ffi::{c_int, c_long, c_ulong, c_ushort}; | |
| 4 | ||
| 4 | 5 | use crate::io::{self, BorrowedBuf, BorrowedCursor, IoSlice, IoSliceMut, Read}; |
| 5 | use crate::mem; | |
| 6 | 6 | use crate::net::{Shutdown, SocketAddr}; |
| 7 | 7 | use crate::os::windows::io::{ |
| 8 | 8 | AsRawSocket, AsSocket, BorrowedSocket, FromRawSocket, IntoRawSocket, OwnedSocket, RawSocket, |
| 9 | 9 | }; |
| 10 | use crate::ptr; | |
| 11 | 10 | use crate::sync::OnceLock; |
| 12 | use crate::sys; | |
| 13 | 11 | use crate::sys::c; |
| 14 | use crate::sys_common::net; | |
| 15 | use crate::sys_common::{AsInner, FromInner, IntoInner}; | |
| 12 | use crate::sys_common::{net, AsInner, FromInner, IntoInner}; | |
| 16 | 13 | use crate::time::Duration; |
| 17 | ||
| 18 | use core::ffi::{c_int, c_long, c_ulong, c_ushort}; | |
| 14 | use crate::{cmp, mem, ptr, sys}; | |
| 19 | 15 | |
| 20 | 16 | #[allow(non_camel_case_types)] |
| 21 | 17 | pub type wrlen_t = i32; |
| ... | ... | @@ -25,9 +21,9 @@ pub mod netc { |
| 25 | 21 | //! |
| 26 | 22 | //! Some Windows API types are not quite what's expected by our cross-platform |
| 27 | 23 | //! net code. E.g. naming differences or different pointer types. |
| 28 | use crate::sys::c::{self, ADDRESS_FAMILY, ADDRINFOA, SOCKADDR, SOCKET}; | |
| 29 | 24 | use core::ffi::{c_char, c_int, c_uint, c_ulong, c_ushort, c_void}; |
| 30 | 25 | |
| 26 | use crate::sys::c::{self, ADDRESS_FAMILY, ADDRINFOA, SOCKADDR, SOCKET}; | |
| 31 | 27 | // re-exports from Windows API bindings. |
| 32 | 28 | pub use crate::sys::c::{ |
| 33 | 29 | bind, connect, freeaddrinfo, getpeername, getsockname, getsockopt, listen, setsockopt, |
library/std/src/sys/pal/windows/os.rs+4-9| ... | ... | @@ -5,20 +5,15 @@ |
| 5 | 5 | #[cfg(test)] |
| 6 | 6 | mod tests; |
| 7 | 7 | |
| 8 | use crate::os::windows::prelude::*; | |
| 9 | ||
| 8 | use super::api::{self, WinError}; | |
| 9 | use super::to_u16s; | |
| 10 | 10 | use crate::error::Error as StdError; |
| 11 | 11 | use crate::ffi::{OsStr, OsString}; |
| 12 | use crate::fmt; | |
| 13 | use crate::io; | |
| 14 | 12 | use crate::os::windows::ffi::EncodeWide; |
| 13 | use crate::os::windows::prelude::*; | |
| 15 | 14 | use crate::path::{self, PathBuf}; |
| 16 | use crate::ptr; | |
| 17 | use crate::slice; | |
| 18 | 15 | use crate::sys::{c, cvt}; |
| 19 | ||
| 20 | use super::api::{self, WinError}; | |
| 21 | use super::to_u16s; | |
| 16 | use crate::{fmt, io, ptr, slice}; | |
| 22 | 17 | |
| 23 | 18 | pub fn errno() -> i32 { |
| 24 | 19 | api::get_last_error().code as i32 |
library/std/src/sys/pal/windows/pipe.rs+3-6| ... | ... | @@ -1,18 +1,15 @@ |
| 1 | use crate::os::windows::prelude::*; | |
| 2 | ||
| 3 | 1 | use crate::ffi::OsStr; |
| 4 | 2 | use crate::io::{self, BorrowedCursor, IoSlice, IoSliceMut}; |
| 5 | use crate::mem; | |
| 3 | use crate::os::windows::prelude::*; | |
| 6 | 4 | use crate::path::Path; |
| 7 | use crate::ptr; | |
| 8 | 5 | use crate::sync::atomic::AtomicUsize; |
| 9 | 6 | use crate::sync::atomic::Ordering::Relaxed; |
| 10 | use crate::sys::c; | |
| 11 | 7 | use crate::sys::fs::{File, OpenOptions}; |
| 12 | 8 | use crate::sys::handle::Handle; |
| 13 | use crate::sys::hashmap_random_keys; | |
| 14 | 9 | use crate::sys::pal::windows::api::{self, WinError}; |
| 10 | use crate::sys::{c, hashmap_random_keys}; | |
| 15 | 11 | use crate::sys_common::{FromInner, IntoInner}; |
| 12 | use crate::{mem, ptr}; | |
| 16 | 13 | |
| 17 | 14 | //////////////////////////////////////////////////////////////////////////////// |
| 18 | 15 | // Anonymous pipes |
library/std/src/sys/pal/windows/process.rs+5-12| ... | ... | @@ -3,35 +3,28 @@ |
| 3 | 3 | #[cfg(test)] |
| 4 | 4 | mod tests; |
| 5 | 5 | |
| 6 | use crate::cmp; | |
| 6 | use core::ffi::c_void; | |
| 7 | ||
| 8 | use super::api::{self, WinError}; | |
| 7 | 9 | use crate::collections::BTreeMap; |
| 8 | use crate::env; | |
| 9 | 10 | use crate::env::consts::{EXE_EXTENSION, EXE_SUFFIX}; |
| 10 | 11 | use crate::ffi::{OsStr, OsString}; |
| 11 | use crate::fmt; | |
| 12 | 12 | use crate::io::{self, Error, ErrorKind}; |
| 13 | use crate::mem; | |
| 14 | 13 | use crate::mem::MaybeUninit; |
| 15 | 14 | use crate::num::NonZero; |
| 16 | 15 | use crate::os::windows::ffi::{OsStrExt, OsStringExt}; |
| 17 | 16 | use crate::os::windows::io::{AsHandle, AsRawHandle, BorrowedHandle, FromRawHandle, IntoRawHandle}; |
| 18 | 17 | use crate::path::{Path, PathBuf}; |
| 19 | use crate::ptr; | |
| 20 | 18 | use crate::sync::Mutex; |
| 21 | 19 | use crate::sys::args::{self, Arg}; |
| 22 | 20 | use crate::sys::c::{self, EXIT_FAILURE, EXIT_SUCCESS}; |
| 23 | use crate::sys::cvt; | |
| 24 | 21 | use crate::sys::fs::{File, OpenOptions}; |
| 25 | 22 | use crate::sys::handle::Handle; |
| 26 | use crate::sys::path; | |
| 27 | 23 | use crate::sys::pipe::{self, AnonPipe}; |
| 28 | use crate::sys::stdio; | |
| 24 | use crate::sys::{cvt, path, stdio}; | |
| 29 | 25 | use crate::sys_common::process::{CommandEnv, CommandEnvs}; |
| 30 | 26 | use crate::sys_common::IntoInner; |
| 31 | ||
| 32 | use core::ffi::c_void; | |
| 33 | ||
| 34 | use super::api::{self, WinError}; | |
| 27 | use crate::{cmp, env, fmt, mem, ptr}; | |
| 35 | 28 | |
| 36 | 29 | //////////////////////////////////////////////////////////////////////////////// |
| 37 | 30 | // Command |
library/std/src/sys/pal/windows/process/tests.rs+1-2| ... | ... | @@ -1,5 +1,4 @@ |
| 1 | use super::make_command_line; | |
| 2 | use super::Arg; | |
| 1 | use super::{make_command_line, Arg}; | |
| 3 | 2 | use crate::env; |
| 4 | 3 | use crate::ffi::{OsStr, OsString}; |
| 5 | 4 | use crate::process::Command; |
library/std/src/sys/pal/windows/stdio.rs+4-7| ... | ... | @@ -1,16 +1,13 @@ |
| 1 | 1 | #![unstable(issue = "none", feature = "windows_stdio")] |
| 2 | 2 | |
| 3 | use core::str::utf8_char_width; | |
| 4 | ||
| 3 | 5 | use super::api::{self, WinError}; |
| 4 | use crate::cmp; | |
| 5 | use crate::io; | |
| 6 | 6 | use crate::mem::MaybeUninit; |
| 7 | 7 | use crate::os::windows::io::{FromRawHandle, IntoRawHandle}; |
| 8 | use crate::ptr; | |
| 9 | use crate::str; | |
| 10 | use crate::sys::c; | |
| 11 | use crate::sys::cvt; | |
| 12 | 8 | use crate::sys::handle::Handle; |
| 13 | use core::str::utf8_char_width; | |
| 9 | use crate::sys::{c, cvt}; | |
| 10 | use crate::{cmp, io, ptr, str}; | |
| 14 | 11 | |
| 15 | 12 | #[cfg(test)] |
| 16 | 13 | mod tests; |
library/std/src/sys/pal/windows/thread.rs+7-10| ... | ... | @@ -1,18 +1,15 @@ |
| 1 | use core::ffi::c_void; | |
| 2 | ||
| 3 | use super::time::WaitableTimer; | |
| 4 | use super::to_u16s; | |
| 1 | 5 | use crate::ffi::CStr; |
| 2 | use crate::io; | |
| 3 | 6 | use crate::num::NonZero; |
| 4 | use crate::os::windows::io::AsRawHandle; | |
| 5 | use crate::os::windows::io::HandleOrNull; | |
| 6 | use crate::ptr; | |
| 7 | use crate::sys::c; | |
| 7 | use crate::os::windows::io::{AsRawHandle, HandleOrNull}; | |
| 8 | 8 | use crate::sys::handle::Handle; |
| 9 | use crate::sys::stack_overflow; | |
| 9 | use crate::sys::{c, stack_overflow}; | |
| 10 | 10 | use crate::sys_common::FromInner; |
| 11 | 11 | use crate::time::Duration; |
| 12 | use core::ffi::c_void; | |
| 13 | ||
| 14 | use super::time::WaitableTimer; | |
| 15 | use super::to_u16s; | |
| 12 | use crate::{io, ptr}; | |
| 16 | 13 | |
| 17 | 14 | pub const DEFAULT_MIN_STACK_SIZE: usize = 2 * 1024 * 1024; |
| 18 | 15 |
library/std/src/sys/pal/windows/time.rs+5-7| ... | ... | @@ -1,13 +1,12 @@ |
| 1 | use core::hash::{Hash, Hasher}; | |
| 2 | use core::ops::Neg; | |
| 3 | ||
| 1 | 4 | use crate::cmp::Ordering; |
| 2 | use crate::fmt; | |
| 3 | use crate::mem; | |
| 4 | 5 | use crate::ptr::null; |
| 5 | 6 | use crate::sys::c; |
| 6 | 7 | use crate::sys_common::IntoInner; |
| 7 | 8 | use crate::time::Duration; |
| 8 | ||
| 9 | use core::hash::{Hash, Hasher}; | |
| 10 | use core::ops::Neg; | |
| 9 | use crate::{fmt, mem}; | |
| 11 | 10 | |
| 12 | 11 | const NANOS_PER_SEC: u64 = 1_000_000_000; |
| 13 | 12 | const INTERVALS_PER_SEC: u64 = NANOS_PER_SEC / 100; |
| ... | ... | @@ -166,8 +165,7 @@ fn intervals2dur(intervals: u64) -> Duration { |
| 166 | 165 | mod perf_counter { |
| 167 | 166 | use super::NANOS_PER_SEC; |
| 168 | 167 | use crate::sync::atomic::{AtomicU64, Ordering}; |
| 169 | use crate::sys::c; | |
| 170 | use crate::sys::cvt; | |
| 168 | use crate::sys::{c, cvt}; | |
| 171 | 169 | use crate::sys_common::mul_div_u64; |
| 172 | 170 | use crate::time::Duration; |
| 173 | 171 |
library/std/src/sys/pal/xous/alloc.rs+2-4| ... | ... | @@ -46,10 +46,8 @@ unsafe impl GlobalAlloc for System { |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | mod lock { |
| 49 | use crate::sync::atomic::{ | |
| 50 | AtomicI32, | |
| 51 | Ordering::{Acquire, Release}, | |
| 52 | }; | |
| 49 | use crate::sync::atomic::AtomicI32; | |
| 50 | use crate::sync::atomic::Ordering::{Acquire, Release}; | |
| 53 | 51 | |
| 54 | 52 | static LOCKED: AtomicI32 = AtomicI32::new(0); |
| 55 | 53 |
library/std/src/sys/pal/xous/net/dns.rs+2-1| ... | ... | @@ -1,8 +1,9 @@ |
| 1 | use core::convert::{TryFrom, TryInto}; | |
| 2 | ||
| 1 | 3 | use crate::io; |
| 2 | 4 | use crate::net::{Ipv4Addr, SocketAddr, SocketAddrV4, SocketAddrV6}; |
| 3 | 5 | use crate::os::xous::ffi::lend_mut; |
| 4 | 6 | use crate::os::xous::services::{dns_server, DnsLendMut}; |
| 5 | use core::convert::{TryFrom, TryInto}; | |
| 6 | 7 | |
| 7 | 8 | pub struct DnsError { |
| 8 | 9 | pub code: u8, |
library/std/src/sys/pal/xous/net/tcplistener.rs+4-4| ... | ... | @@ -1,11 +1,11 @@ |
| 1 | use core::convert::TryInto; | |
| 2 | use core::sync::atomic::{AtomicBool, AtomicU16, AtomicUsize, Ordering}; | |
| 3 | ||
| 1 | 4 | use super::*; |
| 2 | use crate::fmt; | |
| 3 | use crate::io; | |
| 4 | 5 | use crate::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr}; |
| 5 | 6 | use crate::os::xous::services; |
| 6 | 7 | use crate::sync::Arc; |
| 7 | use core::convert::TryInto; | |
| 8 | use core::sync::atomic::{AtomicBool, AtomicU16, AtomicUsize, Ordering}; | |
| 8 | use crate::{fmt, io}; | |
| 9 | 9 | |
| 10 | 10 | macro_rules! unimpl { |
| 11 | 11 | () => { |
library/std/src/sys/pal/xous/net/tcpstream.rs+2-1| ... | ... | @@ -1,3 +1,5 @@ |
| 1 | use core::sync::atomic::{AtomicBool, AtomicU32, AtomicUsize, Ordering}; | |
| 2 | ||
| 1 | 3 | use super::*; |
| 2 | 4 | use crate::fmt; |
| 3 | 5 | use crate::io::{self, BorrowedCursor, IoSlice, IoSliceMut}; |
| ... | ... | @@ -5,7 +7,6 @@ use crate::net::{IpAddr, Ipv4Addr, Shutdown, SocketAddr, SocketAddrV4, SocketAdd |
| 5 | 7 | use crate::os::xous::services; |
| 6 | 8 | use crate::sync::Arc; |
| 7 | 9 | use crate::time::Duration; |
| 8 | use core::sync::atomic::{AtomicBool, AtomicU32, AtomicUsize, Ordering}; | |
| 9 | 10 | |
| 10 | 11 | macro_rules! unimpl { |
| 11 | 12 | () => { |
library/std/src/sys/pal/xous/net/udp.rs+4-4| ... | ... | @@ -1,13 +1,13 @@ |
| 1 | use core::convert::TryInto; | |
| 2 | use core::sync::atomic::{AtomicUsize, Ordering}; | |
| 3 | ||
| 1 | 4 | use super::*; |
| 2 | 5 | use crate::cell::Cell; |
| 3 | use crate::fmt; | |
| 4 | use crate::io; | |
| 5 | 6 | use crate::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr}; |
| 6 | 7 | use crate::os::xous::services; |
| 7 | 8 | use crate::sync::Arc; |
| 8 | 9 | use crate::time::Duration; |
| 9 | use core::convert::TryInto; | |
| 10 | use core::sync::atomic::{AtomicUsize, Ordering}; | |
| 10 | use crate::{fmt, io}; | |
| 11 | 11 | |
| 12 | 12 | macro_rules! unimpl { |
| 13 | 13 | () => { |
library/std/src/sys/pal/xous/os.rs+1-2| ... | ... | @@ -1,11 +1,10 @@ |
| 1 | 1 | use super::unsupported; |
| 2 | 2 | use crate::error::Error as StdError; |
| 3 | 3 | use crate::ffi::{OsStr, OsString}; |
| 4 | use crate::fmt; | |
| 5 | use crate::io; | |
| 6 | 4 | use crate::marker::PhantomData; |
| 7 | 5 | use crate::os::xous::ffi::Error as XousError; |
| 8 | 6 | use crate::path::{self, PathBuf}; |
| 7 | use crate::{fmt, io}; | |
| 9 | 8 | |
| 10 | 9 | #[cfg(not(test))] |
| 11 | 10 | #[cfg(feature = "panic_unwind")] |
library/std/src/sys/pal/xous/thread.rs+2-1| ... | ... | @@ -1,3 +1,5 @@ |
| 1 | use core::arch::asm; | |
| 2 | ||
| 1 | 3 | use crate::ffi::CStr; |
| 2 | 4 | use crate::io; |
| 3 | 5 | use crate::num::NonZero; |
| ... | ... | @@ -7,7 +9,6 @@ use crate::os::xous::ffi::{ |
| 7 | 9 | }; |
| 8 | 10 | use crate::os::xous::services::{ticktimer_server, TicktimerScalar}; |
| 9 | 11 | use crate::time::Duration; |
| 10 | use core::arch::asm; | |
| 11 | 12 | |
| 12 | 13 | pub struct Thread { |
| 13 | 14 | tid: ThreadId, |
library/std/src/sys/pal/xous/time.rs+3-3| ... | ... | @@ -1,7 +1,7 @@ |
| 1 | 1 | use crate::os::xous::ffi::blocking_scalar; |
| 2 | use crate::os::xous::services::{ | |
| 3 | systime_server, ticktimer_server, SystimeScalar::GetUtcTimeMs, TicktimerScalar::ElapsedMs, | |
| 4 | }; | |
| 2 | use crate::os::xous::services::SystimeScalar::GetUtcTimeMs; | |
| 3 | use crate::os::xous::services::TicktimerScalar::ElapsedMs; | |
| 4 | use crate::os::xous::services::{systime_server, ticktimer_server}; | |
| 5 | 5 | use crate::time::Duration; |
| 6 | 6 | |
| 7 | 7 | #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)] |
library/std/src/sys/pal/zkvm/os.rs+1-2| ... | ... | @@ -1,12 +1,11 @@ |
| 1 | 1 | use super::{abi, unsupported, WORD_SIZE}; |
| 2 | 2 | use crate::error::Error as StdError; |
| 3 | 3 | use crate::ffi::{OsStr, OsString}; |
| 4 | use crate::fmt; | |
| 5 | use crate::io; | |
| 6 | 4 | use crate::marker::PhantomData; |
| 7 | 5 | use crate::path::{self, PathBuf}; |
| 8 | 6 | use crate::sys::os_str; |
| 9 | 7 | use crate::sys_common::FromInner; |
| 8 | use crate::{fmt, io}; | |
| 10 | 9 | |
| 11 | 10 | pub fn errno() -> i32 { |
| 12 | 11 | 0 |
library/std/src/sys/pal/zkvm/stdio.rs+2-1| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | use super::{abi, abi::fileno}; | |
| 1 | use super::abi; | |
| 2 | use super::abi::fileno; | |
| 2 | 3 | use crate::io; |
| 3 | 4 | |
| 4 | 5 | pub struct Stdin; |
library/std/src/sys/path/unix.rs+1-2| ... | ... | @@ -1,7 +1,6 @@ |
| 1 | use crate::env; | |
| 2 | 1 | use crate::ffi::OsStr; |
| 3 | use crate::io; | |
| 4 | 2 | use crate::path::{Path, PathBuf, Prefix}; |
| 3 | use crate::{env, io}; | |
| 5 | 4 | |
| 6 | 5 | #[inline] |
| 7 | 6 | pub fn is_sep_byte(b: u8) -> bool { |
library/std/src/sys/path/windows.rs+1-2| ... | ... | @@ -1,8 +1,7 @@ |
| 1 | 1 | use crate::ffi::{OsStr, OsString}; |
| 2 | use crate::io; | |
| 3 | 2 | use crate::path::{Path, PathBuf, Prefix}; |
| 4 | use crate::ptr; | |
| 5 | 3 | use crate::sys::pal::{c, fill_utf16_buf, os2path, to_u16s}; |
| 4 | use crate::{io, ptr}; | |
| 6 | 5 | |
| 7 | 6 | #[cfg(test)] |
| 8 | 7 | mod tests; |
library/std/src/sys/personality/dwarf/eh.rs+2-2| ... | ... | @@ -12,9 +12,9 @@ |
| 12 | 12 | #![allow(non_upper_case_globals)] |
| 13 | 13 | #![allow(unused)] |
| 14 | 14 | |
| 15 | use core::{mem, ptr}; | |
| 16 | ||
| 15 | 17 | use super::DwarfReader; |
| 16 | use core::mem; | |
| 17 | use core::ptr; | |
| 18 | 18 | |
| 19 | 19 | pub const DW_EH_PE_omit: u8 = 0xFF; |
| 20 | 20 | pub const DW_EH_PE_absptr: u8 = 0x00; |
library/std/src/sys/personality/emcc.rs+2-1| ... | ... | @@ -1,9 +1,10 @@ |
| 1 | 1 | //! On Emscripten Rust panics are wrapped in C++ exceptions, so we just forward |
| 2 | 2 | //! to `__gxx_personality_v0` which is provided by Emscripten. |
| 3 | 3 | |
| 4 | use crate::ffi::c_int; | |
| 5 | 4 | use unwind as uw; |
| 6 | 5 | |
| 6 | use crate::ffi::c_int; | |
| 7 | ||
| 7 | 8 | // This is required by the compiler to exist (e.g., it's a lang item), but it's |
| 8 | 9 | // never actually called by the compiler. Emscripten EH doesn't use a |
| 9 | 10 | // personality function at all, it instead uses __cxa_find_matching_catch. |
library/std/src/sys/personality/gcc.rs+2-1| ... | ... | @@ -37,9 +37,10 @@ |
| 37 | 37 | //! and the last personality routine transfers control to the catch block. |
| 38 | 38 | #![forbid(unsafe_op_in_unsafe_fn)] |
| 39 | 39 | |
| 40 | use unwind as uw; | |
| 41 | ||
| 40 | 42 | use super::dwarf::eh::{self, EHAction, EHContext}; |
| 41 | 43 | use crate::ffi::c_int; |
| 42 | use unwind as uw; | |
| 43 | 44 | |
| 44 | 45 | // Register ids were lifted from LLVM's TargetLowering::getExceptionPointerRegister() |
| 45 | 46 | // and TargetLowering::getExceptionSelectorRegister() for each architecture, |
library/std/src/sys/sync/condvar/futex.rs+2-1| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | use crate::sync::atomic::{AtomicU32, Ordering::Relaxed}; | |
| 1 | use crate::sync::atomic::AtomicU32; | |
| 2 | use crate::sync::atomic::Ordering::Relaxed; | |
| 2 | 3 | use crate::sys::futex::{futex_wait, futex_wake, futex_wake_all}; |
| 3 | 4 | use crate::sys::sync::Mutex; |
| 4 | 5 | use crate::time::Duration; |
library/std/src/sys/sync/condvar/itron.rs+8-4| ... | ... | @@ -1,9 +1,13 @@ |
| 1 | 1 | //! POSIX conditional variable implementation based on user-space wait queues. |
| 2 | 2 | |
| 3 | use crate::sys::pal::itron::{ | |
| 4 | abi, error::expect_success_aborting, spin::SpinMutex, task, time::with_tmos_strong, | |
| 5 | }; | |
| 6 | use crate::{mem::replace, ptr::NonNull, sys::sync::Mutex, time::Duration}; | |
| 3 | use crate::mem::replace; | |
| 4 | use crate::ptr::NonNull; | |
| 5 | use crate::sys::pal::itron::error::expect_success_aborting; | |
| 6 | use crate::sys::pal::itron::spin::SpinMutex; | |
| 7 | use crate::sys::pal::itron::time::with_tmos_strong; | |
| 8 | use crate::sys::pal::itron::{abi, task}; | |
| 9 | use crate::sys::sync::Mutex; | |
| 10 | use crate::time::Duration; | |
| 7 | 11 | |
| 8 | 12 | // The implementation is inspired by the queue-based implementation shown in |
| 9 | 13 | // Andrew D. Birrell's paper "Implementing Condition Variables with Semaphores" |
library/std/src/sys/sync/condvar/pthread.rs+2-1| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | 1 | use crate::cell::UnsafeCell; |
| 2 | 2 | use crate::ptr; |
| 3 | use crate::sync::atomic::{AtomicPtr, Ordering::Relaxed}; | |
| 3 | use crate::sync::atomic::AtomicPtr; | |
| 4 | use crate::sync::atomic::Ordering::Relaxed; | |
| 4 | 5 | use crate::sys::sync::{mutex, Mutex}; |
| 5 | 6 | #[cfg(not(target_os = "nto"))] |
| 6 | 7 | use crate::sys::time::TIMESPEC_MAX; |
library/std/src/sys/sync/condvar/teeos.rs+2-1| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | 1 | use crate::cell::UnsafeCell; |
| 2 | 2 | use crate::ptr; |
| 3 | use crate::sync::atomic::{AtomicPtr, Ordering::Relaxed}; | |
| 3 | use crate::sync::atomic::AtomicPtr; | |
| 4 | use crate::sync::atomic::Ordering::Relaxed; | |
| 4 | 5 | use crate::sys::sync::mutex::{self, Mutex}; |
| 5 | 6 | use crate::sys::time::TIMESPEC_MAX; |
| 6 | 7 | use crate::sys_common::lazy_box::{LazyBox, LazyInit}; |
library/std/src/sys/sync/condvar/windows7.rs+1-2| ... | ... | @@ -1,7 +1,6 @@ |
| 1 | 1 | use crate::cell::UnsafeCell; |
| 2 | use crate::sys::c; | |
| 3 | use crate::sys::os; | |
| 4 | 2 | use crate::sys::sync::{mutex, Mutex}; |
| 3 | use crate::sys::{c, os}; | |
| 5 | 4 | use crate::time::Duration; |
| 6 | 5 | |
| 7 | 6 | pub struct Condvar { |
library/std/src/sys/sync/condvar/xous.rs+2-1| ... | ... | @@ -1,8 +1,9 @@ |
| 1 | use core::sync::atomic::{AtomicUsize, Ordering}; | |
| 2 | ||
| 1 | 3 | use crate::os::xous::ffi::{blocking_scalar, scalar}; |
| 2 | 4 | use crate::os::xous::services::{ticktimer_server, TicktimerScalar}; |
| 3 | 5 | use crate::sys::sync::Mutex; |
| 4 | 6 | use crate::time::Duration; |
| 5 | use core::sync::atomic::{AtomicUsize, Ordering}; | |
| 6 | 7 | |
| 7 | 8 | // The implementation is inspired by Andrew D. Birrell's paper |
| 8 | 9 | // "Implementing Condition Variables with Semaphores" |
library/std/src/sys/sync/mutex/fuchsia.rs+2-4| ... | ... | @@ -37,10 +37,8 @@ |
| 37 | 37 | //! |
| 38 | 38 | //! [mutex in Fuchsia's libsync]: https://cs.opensource.google/fuchsia/fuchsia/+/main:zircon/system/ulib/sync/mutex.c |
| 39 | 39 | |
| 40 | use crate::sync::atomic::{ | |
| 41 | AtomicU32, | |
| 42 | Ordering::{Acquire, Relaxed, Release}, | |
| 43 | }; | |
| 40 | use crate::sync::atomic::AtomicU32; | |
| 41 | use crate::sync::atomic::Ordering::{Acquire, Relaxed, Release}; | |
| 44 | 42 | use crate::sys::futex::zircon::{ |
| 45 | 43 | zx_futex_wait, zx_futex_wake_single_owner, zx_handle_t, zx_thread_self, ZX_ERR_BAD_HANDLE, |
| 46 | 44 | ZX_ERR_BAD_STATE, ZX_ERR_INVALID_ARGS, ZX_ERR_TIMED_OUT, ZX_ERR_WRONG_TYPE, ZX_OK, |
library/std/src/sys/sync/mutex/itron.rs+3-5| ... | ... | @@ -2,11 +2,9 @@ |
| 2 | 2 | //! `TA_INHERIT` are available. |
| 3 | 3 | #![forbid(unsafe_op_in_unsafe_fn)] |
| 4 | 4 | |
| 5 | use crate::sys::pal::itron::{ | |
| 6 | abi, | |
| 7 | error::{expect_success, expect_success_aborting, fail, ItronError}, | |
| 8 | spin::SpinIdOnceCell, | |
| 9 | }; | |
| 5 | use crate::sys::pal::itron::abi; | |
| 6 | use crate::sys::pal::itron::error::{expect_success, expect_success_aborting, fail, ItronError}; | |
| 7 | use crate::sys::pal::itron::spin::SpinIdOnceCell; | |
| 10 | 8 | |
| 11 | 9 | pub struct Mutex { |
| 12 | 10 | /// The ID of the underlying mutex object |
library/std/src/sys/sync/mutex/xous.rs+2-4| ... | ... | @@ -1,9 +1,7 @@ |
| 1 | 1 | use crate::os::xous::ffi::{blocking_scalar, do_yield}; |
| 2 | 2 | use crate::os::xous::services::{ticktimer_server, TicktimerScalar}; |
| 3 | use crate::sync::atomic::{ | |
| 4 | AtomicBool, AtomicUsize, | |
| 5 | Ordering::{Acquire, Relaxed, Release}, | |
| 6 | }; | |
| 3 | use crate::sync::atomic::Ordering::{Acquire, Relaxed, Release}; | |
| 4 | use crate::sync::atomic::{AtomicBool, AtomicUsize}; | |
| 7 | 5 | |
| 8 | 6 | pub struct Mutex { |
| 9 | 7 | /// The "locked" value indicates how many threads are waiting on this |
library/std/src/sys/sync/once/futex.rs+2-4| ... | ... | @@ -1,9 +1,7 @@ |
| 1 | 1 | use crate::cell::Cell; |
| 2 | 2 | use crate::sync as public; |
| 3 | use crate::sync::atomic::{ | |
| 4 | AtomicU32, | |
| 5 | Ordering::{Acquire, Relaxed, Release}, | |
| 6 | }; | |
| 3 | use crate::sync::atomic::AtomicU32; | |
| 4 | use crate::sync::atomic::Ordering::{Acquire, Relaxed, Release}; | |
| 7 | 5 | use crate::sync::once::ExclusiveState; |
| 8 | 6 | use crate::sys::futex::{futex_wait, futex_wake_all}; |
| 9 | 7 |
library/std/src/sys/sync/once/queue.rs+1-3| ... | ... | @@ -56,12 +56,10 @@ |
| 56 | 56 | // allowed, so no need for `SeqCst`. |
| 57 | 57 | |
| 58 | 58 | use crate::cell::Cell; |
| 59 | use crate::fmt; | |
| 60 | use crate::ptr; | |
| 61 | use crate::sync as public; | |
| 62 | 59 | use crate::sync::atomic::{AtomicBool, AtomicPtr, Ordering}; |
| 63 | 60 | use crate::sync::once::ExclusiveState; |
| 64 | 61 | use crate::thread::{self, Thread}; |
| 62 | use crate::{fmt, ptr, sync as public}; | |
| 65 | 63 | |
| 66 | 64 | type Masked = (); |
| 67 | 65 |
library/std/src/sys/sync/rwlock/futex.rs+2-4| ... | ... | @@ -1,7 +1,5 @@ |
| 1 | use crate::sync::atomic::{ | |
| 2 | AtomicU32, | |
| 3 | Ordering::{Acquire, Relaxed, Release}, | |
| 4 | }; | |
| 1 | use crate::sync::atomic::AtomicU32; | |
| 2 | use crate::sync::atomic::Ordering::{Acquire, Relaxed, Release}; | |
| 5 | 3 | use crate::sys::futex::{futex_wait, futex_wake, futex_wake_all}; |
| 6 | 4 | |
| 7 | 5 | pub struct RwLock { |
library/std/src/sys/sync/rwlock/queue.rs+2-4| ... | ... | @@ -111,10 +111,8 @@ use crate::cell::OnceCell; |
| 111 | 111 | use crate::hint::spin_loop; |
| 112 | 112 | use crate::mem; |
| 113 | 113 | use crate::ptr::{self, null_mut, without_provenance_mut, NonNull}; |
| 114 | use crate::sync::atomic::{ | |
| 115 | AtomicBool, AtomicPtr, | |
| 116 | Ordering::{AcqRel, Acquire, Relaxed, Release}, | |
| 117 | }; | |
| 114 | use crate::sync::atomic::Ordering::{AcqRel, Acquire, Relaxed, Release}; | |
| 115 | use crate::sync::atomic::{AtomicBool, AtomicPtr}; | |
| 118 | 116 | use crate::thread::{self, Thread}; |
| 119 | 117 | |
| 120 | 118 | // Locking uses exponential backoff. `SPIN_COUNT` indicates how many times the |
library/std/src/sys/sync/rwlock/solid.rs+3-7| ... | ... | @@ -1,13 +1,9 @@ |
| 1 | 1 | //! A readers-writer lock implementation backed by the SOLID kernel extension. |
| 2 | 2 | #![forbid(unsafe_op_in_unsafe_fn)] |
| 3 | 3 | |
| 4 | use crate::sys::pal::{ | |
| 5 | abi, | |
| 6 | itron::{ | |
| 7 | error::{expect_success, expect_success_aborting, fail, ItronError}, | |
| 8 | spin::SpinIdOnceCell, | |
| 9 | }, | |
| 10 | }; | |
| 4 | use crate::sys::pal::abi; | |
| 5 | use crate::sys::pal::itron::error::{expect_success, expect_success_aborting, fail, ItronError}; | |
| 6 | use crate::sys::pal::itron::spin::SpinIdOnceCell; | |
| 11 | 7 | |
| 12 | 8 | pub struct RwLock { |
| 13 | 9 | /// The ID of the underlying mutex object |
library/std/src/sys/sync/thread_parking/darwin.rs+2-4| ... | ... | @@ -13,10 +13,8 @@ |
| 13 | 13 | #![allow(non_camel_case_types)] |
| 14 | 14 | |
| 15 | 15 | use crate::pin::Pin; |
| 16 | use crate::sync::atomic::{ | |
| 17 | AtomicI8, | |
| 18 | Ordering::{Acquire, Release}, | |
| 19 | }; | |
| 16 | use crate::sync::atomic::AtomicI8; | |
| 17 | use crate::sync::atomic::Ordering::{Acquire, Release}; | |
| 20 | 18 | use crate::time::Duration; |
| 21 | 19 | |
| 22 | 20 | type dispatch_semaphore_t = *mut crate::ffi::c_void; |
library/std/src/sys/sync/thread_parking/id.rs+2-4| ... | ... | @@ -9,10 +9,8 @@ |
| 9 | 9 | |
| 10 | 10 | use crate::cell::UnsafeCell; |
| 11 | 11 | use crate::pin::Pin; |
| 12 | use crate::sync::atomic::{ | |
| 13 | fence, AtomicI8, | |
| 14 | Ordering::{Acquire, Relaxed, Release}, | |
| 15 | }; | |
| 12 | use crate::sync::atomic::Ordering::{Acquire, Relaxed, Release}; | |
| 13 | use crate::sync::atomic::{fence, AtomicI8}; | |
| 16 | 14 | use crate::sys::thread_parking::{current, park, park_timeout, unpark, ThreadId}; |
| 17 | 15 | use crate::time::Duration; |
| 18 | 16 |
library/std/src/sys/sync/thread_parking/windows7.rs+9-11| ... | ... | @@ -57,14 +57,13 @@ |
| 57 | 57 | // [3]: https://docs.microsoft.com/en-us/archive/msdn-magazine/2012/november/windows-with-c-the-evolution-of-synchronization-in-windows-and-c |
| 58 | 58 | // [4]: Windows Internals, Part 1, ISBN 9780735671300 |
| 59 | 59 | |
| 60 | use core::ffi::c_void; | |
| 61 | ||
| 60 | 62 | use crate::pin::Pin; |
| 61 | use crate::sync::atomic::{ | |
| 62 | AtomicI8, | |
| 63 | Ordering::{Acquire, Release}, | |
| 64 | }; | |
| 63 | use crate::sync::atomic::AtomicI8; | |
| 64 | use crate::sync::atomic::Ordering::{Acquire, Release}; | |
| 65 | 65 | use crate::sys::{c, dur2timeout}; |
| 66 | 66 | use crate::time::Duration; |
| 67 | use core::ffi::c_void; | |
| 68 | 67 | |
| 69 | 68 | pub struct Parker { |
| 70 | 69 | state: AtomicI8, |
| ... | ... | @@ -185,16 +184,15 @@ impl Parker { |
| 185 | 184 | |
| 186 | 185 | #[cfg(target_vendor = "win7")] |
| 187 | 186 | mod keyed_events { |
| 188 | use super::{Parker, EMPTY, NOTIFIED}; | |
| 189 | use crate::sys::c; | |
| 190 | 187 | use core::pin::Pin; |
| 191 | 188 | use core::ptr; |
| 192 | use core::sync::atomic::{ | |
| 193 | AtomicPtr, | |
| 194 | Ordering::{Acquire, Relaxed}, | |
| 195 | }; | |
| 189 | use core::sync::atomic::AtomicPtr; | |
| 190 | use core::sync::atomic::Ordering::{Acquire, Relaxed}; | |
| 196 | 191 | use core::time::Duration; |
| 197 | 192 | |
| 193 | use super::{Parker, EMPTY, NOTIFIED}; | |
| 194 | use crate::sys::c; | |
| 195 | ||
| 198 | 196 | pub unsafe fn park(parker: Pin<&Parker>) { |
| 199 | 197 | // Wait for unpark() to produce this event. |
| 200 | 198 | c::NtWaitForKeyedEvent(keyed_event_handle(), parker.ptr(), 0, ptr::null_mut()); |
library/std/src/sys/sync/thread_parking/xous.rs+2-4| ... | ... | @@ -2,10 +2,8 @@ use crate::os::xous::ffi::{blocking_scalar, scalar}; |
| 2 | 2 | use crate::os::xous::services::{ticktimer_server, TicktimerScalar}; |
| 3 | 3 | use crate::pin::Pin; |
| 4 | 4 | use crate::ptr; |
| 5 | use crate::sync::atomic::{ | |
| 6 | AtomicI8, | |
| 7 | Ordering::{Acquire, Release}, | |
| 8 | }; | |
| 5 | use crate::sync::atomic::AtomicI8; | |
| 6 | use crate::sync::atomic::Ordering::{Acquire, Release}; | |
| 9 | 7 | use crate::time::Duration; |
| 10 | 8 | |
| 11 | 9 | const NOTIFIED: i8 = 1; |
library/std/src/sys/thread_local/guard/solid.rs+2-1| ... | ... | @@ -3,7 +3,8 @@ |
| 3 | 3 | //! destructors for terminated tasks, we still keep our own list. |
| 4 | 4 | |
| 5 | 5 | use crate::cell::Cell; |
| 6 | use crate::sys::pal::{abi, itron::task}; | |
| 6 | use crate::sys::pal::abi; | |
| 7 | use crate::sys::pal::itron::task; | |
| 7 | 8 | use crate::sys::thread_local::destructors; |
| 8 | 9 | |
| 9 | 10 | pub fn enable() { |
library/std/src/sys/thread_local/guard/windows.rs+2-1| ... | ... | @@ -63,9 +63,10 @@ |
| 63 | 63 | //! [1]: https://www.codeproject.com/Articles/8113/Thread-Local-Storage-The-C-Way |
| 64 | 64 | //! [2]: https://github.com/ChromiumWebApps/chromium/blob/master/base/threading/thread_local_storage_win.cc#L42 |
| 65 | 65 | |
| 66 | use core::ffi::c_void; | |
| 67 | ||
| 66 | 68 | use crate::ptr; |
| 67 | 69 | use crate::sys::c; |
| 68 | use core::ffi::c_void; | |
| 69 | 70 | |
| 70 | 71 | pub fn enable() { |
| 71 | 72 | // When destructors are used, we don't want LLVM eliminating CALLBACK for any |
library/std/src/sys/thread_local/key/windows.rs+2-4| ... | ... | @@ -26,10 +26,8 @@ |
| 26 | 26 | |
| 27 | 27 | use crate::cell::UnsafeCell; |
| 28 | 28 | use crate::ptr; |
| 29 | use crate::sync::atomic::{ | |
| 30 | AtomicPtr, AtomicU32, | |
| 31 | Ordering::{AcqRel, Acquire, Relaxed, Release}, | |
| 32 | }; | |
| 29 | use crate::sync::atomic::Ordering::{AcqRel, Acquire, Relaxed, Release}; | |
| 30 | use crate::sync::atomic::{AtomicPtr, AtomicU32}; | |
| 33 | 31 | use crate::sys::c; |
| 34 | 32 | use crate::sys::thread_local::guard; |
| 35 | 33 |
library/std/src/sys/thread_local/key/xous.rs+4-5| ... | ... | @@ -36,14 +36,13 @@ |
| 36 | 36 | |
| 37 | 37 | // FIXME(joboet): implement support for native TLS instead. |
| 38 | 38 | |
| 39 | use crate::mem::ManuallyDrop; | |
| 40 | use crate::ptr; | |
| 41 | use crate::sync::atomic::AtomicPtr; | |
| 42 | use crate::sync::atomic::AtomicUsize; | |
| 43 | use crate::sync::atomic::Ordering::{Acquire, Relaxed, Release}; | |
| 44 | 39 | use core::arch::asm; |
| 45 | 40 | |
| 41 | use crate::mem::ManuallyDrop; | |
| 46 | 42 | use crate::os::xous::ffi::{map_memory, unmap_memory, MemoryFlags}; |
| 43 | use crate::ptr; | |
| 44 | use crate::sync::atomic::Ordering::{Acquire, Relaxed, Release}; | |
| 45 | use crate::sync::atomic::{AtomicPtr, AtomicUsize}; | |
| 47 | 46 | |
| 48 | 47 | pub type Key = usize; |
| 49 | 48 | pub type Dtor = unsafe extern "C" fn(*mut u8); |
library/std/src/sys/thread_local/native/eager.rs+1-2| ... | ... | @@ -1,7 +1,6 @@ |
| 1 | 1 | use crate::cell::{Cell, UnsafeCell}; |
| 2 | 2 | use crate::ptr::{self, drop_in_place}; |
| 3 | use crate::sys::thread_local::abort_on_dtor_unwind; | |
| 4 | use crate::sys::thread_local::destructors; | |
| 3 | use crate::sys::thread_local::{abort_on_dtor_unwind, destructors}; | |
| 5 | 4 | |
| 6 | 5 | #[derive(Clone, Copy)] |
| 7 | 6 | enum State { |
library/std/src/sys/thread_local/native/lazy.rs+1-2| ... | ... | @@ -1,8 +1,7 @@ |
| 1 | 1 | use crate::cell::UnsafeCell; |
| 2 | 2 | use crate::hint::unreachable_unchecked; |
| 3 | 3 | use crate::ptr; |
| 4 | use crate::sys::thread_local::abort_on_dtor_unwind; | |
| 5 | use crate::sys::thread_local::destructors; | |
| 4 | use crate::sys::thread_local::{abort_on_dtor_unwind, destructors}; | |
| 6 | 5 | |
| 7 | 6 | pub unsafe trait DestroyedState: Sized { |
| 8 | 7 | fn register_dtor<T>(s: &Storage<T, Self>); |
library/std/src/sys_common/io.rs+3-4| ... | ... | @@ -5,12 +5,11 @@ pub const DEFAULT_BUF_SIZE: usize = if cfg!(target_os = "espidf") { 512 } else { |
| 5 | 5 | #[cfg(test)] |
| 6 | 6 | #[allow(dead_code)] // not used on emscripten |
| 7 | 7 | pub mod test { |
| 8 | use crate::env; | |
| 9 | use crate::fs; | |
| 10 | use crate::path::{Path, PathBuf}; | |
| 11 | use crate::thread; | |
| 12 | 8 | use rand::RngCore; |
| 13 | 9 | |
| 10 | use crate::path::{Path, PathBuf}; | |
| 11 | use crate::{env, fs, thread}; | |
| 12 | ||
| 14 | 13 | pub struct TempDir(PathBuf); |
| 15 | 14 | |
| 16 | 15 | impl TempDir { |
library/std/src/sys_common/lazy_box.rs+2-4| ... | ... | @@ -5,10 +5,8 @@ |
| 5 | 5 | use crate::marker::PhantomData; |
| 6 | 6 | use crate::ops::{Deref, DerefMut}; |
| 7 | 7 | use crate::ptr::null_mut; |
| 8 | use crate::sync::atomic::{ | |
| 9 | AtomicPtr, | |
| 10 | Ordering::{AcqRel, Acquire}, | |
| 11 | }; | |
| 8 | use crate::sync::atomic::AtomicPtr; | |
| 9 | use crate::sync::atomic::Ordering::{AcqRel, Acquire}; | |
| 12 | 10 | |
| 13 | 11 | pub(crate) struct LazyBox<T: LazyInit> { |
| 14 | 12 | ptr: AtomicPtr<T>, |
library/std/src/sys_common/net.rs+3-8| ... | ... | @@ -1,19 +1,14 @@ |
| 1 | 1 | #[cfg(test)] |
| 2 | 2 | mod tests; |
| 3 | 3 | |
| 4 | use crate::cmp; | |
| 5 | use crate::fmt; | |
| 4 | use crate::ffi::{c_int, c_void}; | |
| 6 | 5 | use crate::io::{self, BorrowedCursor, ErrorKind, IoSlice, IoSliceMut}; |
| 7 | use crate::mem; | |
| 8 | 6 | use crate::net::{Ipv4Addr, Ipv6Addr, Shutdown, SocketAddr}; |
| 9 | use crate::ptr; | |
| 10 | 7 | use crate::sys::common::small_c_string::run_with_cstr; |
| 11 | use crate::sys::net::netc as c; | |
| 12 | use crate::sys::net::{cvt, cvt_gai, cvt_r, init, wrlen_t, Socket}; | |
| 8 | use crate::sys::net::{cvt, cvt_gai, cvt_r, init, netc as c, wrlen_t, Socket}; | |
| 13 | 9 | use crate::sys_common::{AsInner, FromInner, IntoInner}; |
| 14 | 10 | use crate::time::Duration; |
| 15 | ||
| 16 | use crate::ffi::{c_int, c_void}; | |
| 11 | use crate::{cmp, fmt, mem, ptr}; | |
| 17 | 12 | |
| 18 | 13 | cfg_if::cfg_if! { |
| 19 | 14 | if #[cfg(any( |
library/std/src/sys_common/process.rs+1-3| ... | ... | @@ -2,12 +2,10 @@ |
| 2 | 2 | #![unstable(feature = "process_internals", issue = "none")] |
| 3 | 3 | |
| 4 | 4 | use crate::collections::BTreeMap; |
| 5 | use crate::env; | |
| 6 | 5 | use crate::ffi::{OsStr, OsString}; |
| 7 | use crate::fmt; | |
| 8 | use crate::io; | |
| 9 | 6 | use crate::sys::pipe::read2; |
| 10 | 7 | use crate::sys::process::{EnvKey, ExitStatus, Process, StdioPipes}; |
| 8 | use crate::{env, fmt, io}; | |
| 11 | 9 | |
| 12 | 10 | // Stores a set of changes to an environment |
| 13 | 11 | #[derive(Clone)] |
library/std/src/sys_common/wtf8.rs+1-5| ... | ... | @@ -23,16 +23,12 @@ use core::str::next_code_point; |
| 23 | 23 | |
| 24 | 24 | use crate::borrow::Cow; |
| 25 | 25 | use crate::collections::TryReserveError; |
| 26 | use crate::fmt; | |
| 27 | 26 | use crate::hash::{Hash, Hasher}; |
| 28 | 27 | use crate::iter::FusedIterator; |
| 29 | use crate::mem; | |
| 30 | use crate::ops; | |
| 31 | 28 | use crate::rc::Rc; |
| 32 | use crate::slice; | |
| 33 | use crate::str; | |
| 34 | 29 | use crate::sync::Arc; |
| 35 | 30 | use crate::sys_common::AsInner; |
| 31 | use crate::{fmt, mem, ops, slice, str}; | |
| 36 | 32 | |
| 37 | 33 | const UTF8_REPLACEMENT_CHARACTER: &str = "\u{FFFD}"; |
| 38 | 34 |
library/std/src/thread/mod.rs+3-7| ... | ... | @@ -160,24 +160,19 @@ mod tests; |
| 160 | 160 | |
| 161 | 161 | use crate::any::Any; |
| 162 | 162 | use crate::cell::{Cell, OnceCell, UnsafeCell}; |
| 163 | use crate::env; | |
| 164 | 163 | use crate::ffi::CStr; |
| 165 | use crate::fmt; | |
| 166 | use crate::io; | |
| 167 | 164 | use crate::marker::PhantomData; |
| 168 | 165 | use crate::mem::{self, forget, ManuallyDrop}; |
| 169 | 166 | use crate::num::NonZero; |
| 170 | use crate::panic; | |
| 171 | use crate::panicking; | |
| 172 | 167 | use crate::pin::Pin; |
| 173 | 168 | use crate::ptr::addr_of_mut; |
| 174 | use crate::str; | |
| 175 | 169 | use crate::sync::atomic::{AtomicUsize, Ordering}; |
| 176 | 170 | use crate::sync::Arc; |
| 177 | 171 | use crate::sys::sync::Parker; |
| 178 | 172 | use crate::sys::thread as imp; |
| 179 | 173 | use crate::sys_common::{AsInner, IntoInner}; |
| 180 | 174 | use crate::time::{Duration, Instant}; |
| 175 | use crate::{env, fmt, io, panic, panicking, str}; | |
| 181 | 176 | |
| 182 | 177 | #[stable(feature = "scoped_threads", since = "1.63.0")] |
| 183 | 178 | mod scoped; |
| ... | ... | @@ -1292,9 +1287,10 @@ enum ThreadName { |
| 1292 | 1287 | |
| 1293 | 1288 | // This module ensures private fields are kept private, which is necessary to enforce the safety requirements. |
| 1294 | 1289 | mod thread_name_string { |
| 1290 | use core::str; | |
| 1291 | ||
| 1295 | 1292 | use super::ThreadName; |
| 1296 | 1293 | use crate::ffi::{CStr, CString}; |
| 1297 | use core::str; | |
| 1298 | 1294 | |
| 1299 | 1295 | /// Like a `String` it's guaranteed UTF-8 and like a `CString` it's null terminated. |
| 1300 | 1296 | pub(crate) struct ThreadNameString { |
library/std/src/thread/scoped.rs+1-2| ... | ... | @@ -1,10 +1,9 @@ |
| 1 | 1 | use super::{current, park, Builder, JoinInner, Result, Thread}; |
| 2 | use crate::fmt; | |
| 3 | use crate::io; | |
| 4 | 2 | use crate::marker::PhantomData; |
| 5 | 3 | use crate::panic::{catch_unwind, resume_unwind, AssertUnwindSafe}; |
| 6 | 4 | use crate::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; |
| 7 | 5 | use crate::sync::Arc; |
| 6 | use crate::{fmt, io}; | |
| 8 | 7 | |
| 9 | 8 | /// A scope to spawn scoped threads in. |
| 10 | 9 | /// |
library/std/src/thread/tests.rs+5-9| ... | ... | @@ -1,16 +1,12 @@ |
| 1 | 1 | use super::Builder; |
| 2 | 2 | use crate::any::Any; |
| 3 | use crate::mem; | |
| 4 | 3 | use crate::panic::panic_any; |
| 5 | use crate::result; | |
| 6 | use crate::sync::{ | |
| 7 | atomic::{AtomicBool, Ordering}, | |
| 8 | mpsc::{channel, Sender}, | |
| 9 | Arc, Barrier, | |
| 10 | }; | |
| 4 | use crate::sync::atomic::{AtomicBool, Ordering}; | |
| 5 | use crate::sync::mpsc::{channel, Sender}; | |
| 6 | use crate::sync::{Arc, Barrier}; | |
| 11 | 7 | use crate::thread::{self, Scope, ThreadId}; |
| 12 | use crate::time::Duration; | |
| 13 | use crate::time::Instant; | |
| 8 | use crate::time::{Duration, Instant}; | |
| 9 | use crate::{mem, result}; | |
| 14 | 10 | |
| 15 | 11 | // !!! These tests are dangerous. If something is buggy, they will hang, !!! |
| 16 | 12 | // !!! instead of exiting cleanly. This might wedge the buildbots. !!! |
library/std/src/time.rs+5-6| ... | ... | @@ -34,18 +34,17 @@ |
| 34 | 34 | #[cfg(test)] |
| 35 | 35 | mod tests; |
| 36 | 36 | |
| 37 | #[stable(feature = "time", since = "1.3.0")] | |
| 38 | pub use core::time::Duration; | |
| 39 | #[stable(feature = "duration_checked_float", since = "1.66.0")] | |
| 40 | pub use core::time::TryFromFloatSecsError; | |
| 41 | ||
| 37 | 42 | use crate::error::Error; |
| 38 | 43 | use crate::fmt; |
| 39 | 44 | use crate::ops::{Add, AddAssign, Sub, SubAssign}; |
| 40 | 45 | use crate::sys::time; |
| 41 | 46 | use crate::sys_common::{FromInner, IntoInner}; |
| 42 | 47 | |
| 43 | #[stable(feature = "time", since = "1.3.0")] | |
| 44 | pub use core::time::Duration; | |
| 45 | ||
| 46 | #[stable(feature = "duration_checked_float", since = "1.66.0")] | |
| 47 | pub use core::time::TryFromFloatSecsError; | |
| 48 | ||
| 49 | 48 | /// A measurement of a monotonically nondecreasing clock. |
| 50 | 49 | /// Opaque and useful only with [`Duration`]. |
| 51 | 50 | /// |
library/std/src/time/tests.rs+3-1| ... | ... | @@ -1,8 +1,10 @@ |
| 1 | use super::{Duration, Instant, SystemTime, UNIX_EPOCH}; | |
| 2 | 1 | use core::fmt::Debug; |
| 2 | ||
| 3 | 3 | #[cfg(not(target_arch = "wasm32"))] |
| 4 | 4 | use test::{black_box, Bencher}; |
| 5 | 5 | |
| 6 | use super::{Duration, Instant, SystemTime, UNIX_EPOCH}; | |
| 7 | ||
| 6 | 8 | macro_rules! assert_almost_eq { |
| 7 | 9 | ($a:expr, $b:expr) => {{ |
| 8 | 10 | let (a, b) = ($a, $b); |
library/std/tests/common/mod.rs+3-4| ... | ... | @@ -1,10 +1,9 @@ |
| 1 | 1 | #![allow(unused)] |
| 2 | 2 | |
| 3 | use rand::RngCore; | |
| 4 | use std::env; | |
| 5 | use std::fs; | |
| 6 | 3 | use std::path::{Path, PathBuf}; |
| 7 | use std::thread; | |
| 4 | use std::{env, fs, thread}; | |
| 5 | ||
| 6 | use rand::RngCore; | |
| 8 | 7 | |
| 9 | 8 | /// Copied from `std::test_helpers::test_rng`, since these tests rely on the |
| 10 | 9 | /// seed not being the same for every RNG invocation too. |
library/std/tests/create_dir_all_bare.rs+1-2| ... | ... | @@ -3,9 +3,8 @@ |
| 3 | 3 | //! Note that this test changes the current directory so |
| 4 | 4 | //! should not be in the same process as other tests. |
| 5 | 5 | |
| 6 | use std::env; | |
| 7 | use std::fs; | |
| 8 | 6 | use std::path::{Path, PathBuf}; |
| 7 | use std::{env, fs}; | |
| 9 | 8 | |
| 10 | 9 | mod common; |
| 11 | 10 |
library/std/tests/env.rs+2-1| ... | ... | @@ -4,9 +4,10 @@ use std::ffi::{OsStr, OsString}; |
| 4 | 4 | use rand::distributions::{Alphanumeric, DistString}; |
| 5 | 5 | |
| 6 | 6 | mod common; |
| 7 | use common::test_rng; | |
| 8 | 7 | use std::thread; |
| 9 | 8 | |
| 9 | use common::test_rng; | |
| 10 | ||
| 10 | 11 | #[track_caller] |
| 11 | 12 | fn make_rand_name() -> OsString { |
| 12 | 13 | let n = format!("TEST{}", Alphanumeric.sample_string(&mut test_rng(), 10)); |
library/std/tests/pipe_subprocess.rs+3-1| ... | ... | @@ -3,7 +3,9 @@ |
| 3 | 3 | fn main() { |
| 4 | 4 | #[cfg(all(not(miri), any(unix, windows)))] |
| 5 | 5 | { |
| 6 | use std::{env, io::Read, pipe::pipe, process}; | |
| 6 | use std::io::Read; | |
| 7 | use std::pipe::pipe; | |
| 8 | use std::{env, process}; | |
| 7 | 9 | |
| 8 | 10 | if env::var("I_AM_THE_CHILD").is_ok() { |
| 9 | 11 | child(); |
library/std/tests/process_spawning.rs+1-4| ... | ... | @@ -1,9 +1,6 @@ |
| 1 | 1 | #![cfg(not(target_env = "sgx"))] |
| 2 | 2 | |
| 3 | use std::env; | |
| 4 | use std::fs; | |
| 5 | use std::process; | |
| 6 | use std::str; | |
| 3 | use std::{env, fs, process, str}; | |
| 7 | 4 | |
| 8 | 5 | mod common; |
| 9 | 6 |
library/std/tests/switch-stdout.rs+2-3| ... | ... | @@ -5,11 +5,10 @@ use std::io::{Read, Write}; |
| 5 | 5 | |
| 6 | 6 | mod common; |
| 7 | 7 | |
| 8 | #[cfg(windows)] | |
| 9 | use std::os::windows::io::OwnedHandle; | |
| 10 | ||
| 11 | 8 | #[cfg(unix)] |
| 12 | 9 | use std::os::fd::OwnedFd; |
| 10 | #[cfg(windows)] | |
| 11 | use std::os::windows::io::OwnedHandle; | |
| 13 | 12 | |
| 14 | 13 | #[cfg(unix)] |
| 15 | 14 | fn switch_stdout_to(file: OwnedFd) -> OwnedFd { |
library/std/tests/windows.rs+3-1| ... | ... | @@ -1,7 +1,9 @@ |
| 1 | 1 | #![cfg(windows)] |
| 2 | 2 | //! An external tests |
| 3 | 3 | |
| 4 | use std::{ffi::OsString, os::windows::ffi::OsStringExt, path::PathBuf}; | |
| 4 | use std::ffi::OsString; | |
| 5 | use std::os::windows::ffi::OsStringExt; | |
| 6 | use std::path::PathBuf; | |
| 5 | 7 | |
| 6 | 8 | #[test] |
| 7 | 9 | #[should_panic] |
library/test/src/bench.rs+8-11| ... | ... | @@ -1,19 +1,16 @@ |
| 1 | 1 | //! Benchmarking module. |
| 2 | 2 | |
| 3 | use super::{ | |
| 4 | event::CompletedTest, | |
| 5 | options::BenchMode, | |
| 6 | test_result::TestResult, | |
| 7 | types::{TestDesc, TestId}, | |
| 8 | Sender, | |
| 9 | }; | |
| 10 | ||
| 11 | use crate::stats; | |
| 12 | use std::cmp; | |
| 13 | use std::io; | |
| 14 | 3 | use std::panic::{catch_unwind, AssertUnwindSafe}; |
| 15 | 4 | use std::sync::{Arc, Mutex}; |
| 16 | 5 | use std::time::{Duration, Instant}; |
| 6 | use std::{cmp, io}; | |
| 7 | ||
| 8 | use super::event::CompletedTest; | |
| 9 | use super::options::BenchMode; | |
| 10 | use super::test_result::TestResult; | |
| 11 | use super::types::{TestDesc, TestId}; | |
| 12 | use super::Sender; | |
| 13 | use crate::stats; | |
| 17 | 14 | |
| 18 | 15 | /// An identity function that *__hints__* to the compiler to be maximally pessimistic about what |
| 19 | 16 | /// `black_box` could do. |
library/test/src/cli.rs+1-1| ... | ... | @@ -1,11 +1,11 @@ |
| 1 | 1 | //! Module converting command-line arguments into test configuration. |
| 2 | 2 | |
| 3 | 3 | use std::env; |
| 4 | use std::io::{self, IsTerminal}; | |
| 4 | 5 | use std::path::PathBuf; |
| 5 | 6 | |
| 6 | 7 | use super::options::{ColorConfig, Options, OutputFormat, RunIgnored}; |
| 7 | 8 | use super::time::TestTimeOptions; |
| 8 | use std::io::{self, IsTerminal}; | |
| 9 | 9 | |
| 10 | 10 | #[derive(Debug)] |
| 11 | 11 | pub struct TestOpts { |
library/test/src/console.rs+12-12| ... | ... | @@ -5,19 +5,19 @@ use std::io; |
| 5 | 5 | use std::io::prelude::Write; |
| 6 | 6 | use std::time::Instant; |
| 7 | 7 | |
| 8 | use super::{ | |
| 9 | bench::fmt_bench_samples, | |
| 10 | cli::TestOpts, | |
| 11 | event::{CompletedTest, TestEvent}, | |
| 12 | filter_tests, | |
| 13 | formatters::{JsonFormatter, JunitFormatter, OutputFormatter, PrettyFormatter, TerseFormatter}, | |
| 14 | helpers::{concurrency::get_concurrency, metrics::MetricMap}, | |
| 15 | options::{Options, OutputFormat}, | |
| 16 | run_tests, term, | |
| 17 | test_result::TestResult, | |
| 18 | time::{TestExecTime, TestSuiteExecTime}, | |
| 19 | types::{NamePadding, TestDesc, TestDescAndFn}, | |
| 8 | use super::bench::fmt_bench_samples; | |
| 9 | use super::cli::TestOpts; | |
| 10 | use super::event::{CompletedTest, TestEvent}; | |
| 11 | use super::formatters::{ | |
| 12 | JsonFormatter, JunitFormatter, OutputFormatter, PrettyFormatter, TerseFormatter, | |
| 20 | 13 | }; |
| 14 | use super::helpers::concurrency::get_concurrency; | |
| 15 | use super::helpers::metrics::MetricMap; | |
| 16 | use super::options::{Options, OutputFormat}; | |
| 17 | use super::test_result::TestResult; | |
| 18 | use super::time::{TestExecTime, TestSuiteExecTime}; | |
| 19 | use super::types::{NamePadding, TestDesc, TestDescAndFn}; | |
| 20 | use super::{filter_tests, run_tests, term}; | |
| 21 | 21 | |
| 22 | 22 | /// Generic wrapper over stdout. |
| 23 | 23 | pub enum OutputLocation<T> { |
library/test/src/formatters/json.rs+7-7| ... | ... | @@ -1,12 +1,12 @@ |
| 1 | use std::{borrow::Cow, io, io::prelude::Write}; | |
| 1 | use std::borrow::Cow; | |
| 2 | use std::io; | |
| 3 | use std::io::prelude::Write; | |
| 2 | 4 | |
| 3 | 5 | use super::OutputFormatter; |
| 4 | use crate::{ | |
| 5 | console::{ConsoleTestDiscoveryState, ConsoleTestState, OutputLocation}, | |
| 6 | test_result::TestResult, | |
| 7 | time, | |
| 8 | types::TestDesc, | |
| 9 | }; | |
| 6 | use crate::console::{ConsoleTestDiscoveryState, ConsoleTestState, OutputLocation}; | |
| 7 | use crate::test_result::TestResult; | |
| 8 | use crate::time; | |
| 9 | use crate::types::TestDesc; | |
| 10 | 10 | |
| 11 | 11 | pub(crate) struct JsonFormatter<T> { |
| 12 | 12 | out: OutputLocation<T>, |
library/test/src/formatters/junit.rs+6-7| ... | ... | @@ -1,13 +1,12 @@ |
| 1 | use std::io::{self, prelude::Write}; | |
| 1 | use std::io::prelude::Write; | |
| 2 | use std::io::{self}; | |
| 2 | 3 | use std::time::Duration; |
| 3 | 4 | |
| 4 | 5 | use super::OutputFormatter; |
| 5 | use crate::{ | |
| 6 | console::{ConsoleTestDiscoveryState, ConsoleTestState, OutputLocation}, | |
| 7 | test_result::TestResult, | |
| 8 | time, | |
| 9 | types::{TestDesc, TestType}, | |
| 10 | }; | |
| 6 | use crate::console::{ConsoleTestDiscoveryState, ConsoleTestState, OutputLocation}; | |
| 7 | use crate::test_result::TestResult; | |
| 8 | use crate::time; | |
| 9 | use crate::types::{TestDesc, TestType}; | |
| 11 | 10 | |
| 12 | 11 | pub struct JunitFormatter<T> { |
| 13 | 12 | out: OutputLocation<T>, |
library/test/src/formatters/mod.rs+6-7| ... | ... | @@ -1,11 +1,10 @@ |
| 1 | use std::{io, io::prelude::Write}; | |
| 1 | use std::io; | |
| 2 | use std::io::prelude::Write; | |
| 2 | 3 | |
| 3 | use crate::{ | |
| 4 | console::{ConsoleTestDiscoveryState, ConsoleTestState}, | |
| 5 | test_result::TestResult, | |
| 6 | time, | |
| 7 | types::{TestDesc, TestName}, | |
| 8 | }; | |
| 4 | use crate::console::{ConsoleTestDiscoveryState, ConsoleTestState}; | |
| 5 | use crate::test_result::TestResult; | |
| 6 | use crate::time; | |
| 7 | use crate::types::{TestDesc, TestName}; | |
| 9 | 8 | |
| 10 | 9 | mod json; |
| 11 | 10 | mod junit; |
library/test/src/formatters/pretty.rs+7-9| ... | ... | @@ -1,14 +1,12 @@ |
| 1 | use std::{io, io::prelude::Write}; | |
| 1 | use std::io; | |
| 2 | use std::io::prelude::Write; | |
| 2 | 3 | |
| 3 | 4 | use super::OutputFormatter; |
| 4 | use crate::{ | |
| 5 | bench::fmt_bench_samples, | |
| 6 | console::{ConsoleTestDiscoveryState, ConsoleTestState, OutputLocation}, | |
| 7 | term, | |
| 8 | test_result::TestResult, | |
| 9 | time, | |
| 10 | types::TestDesc, | |
| 11 | }; | |
| 5 | use crate::bench::fmt_bench_samples; | |
| 6 | use crate::console::{ConsoleTestDiscoveryState, ConsoleTestState, OutputLocation}; | |
| 7 | use crate::test_result::TestResult; | |
| 8 | use crate::types::TestDesc; | |
| 9 | use crate::{term, time}; | |
| 12 | 10 | |
| 13 | 11 | pub(crate) struct PrettyFormatter<T> { |
| 14 | 12 | out: OutputLocation<T>, |
library/test/src/formatters/terse.rs+7-10| ... | ... | @@ -1,15 +1,12 @@ |
| 1 | use std::{io, io::prelude::Write}; | |
| 1 | use std::io; | |
| 2 | use std::io::prelude::Write; | |
| 2 | 3 | |
| 3 | 4 | use super::OutputFormatter; |
| 4 | use crate::{ | |
| 5 | bench::fmt_bench_samples, | |
| 6 | console::{ConsoleTestDiscoveryState, ConsoleTestState, OutputLocation}, | |
| 7 | term, | |
| 8 | test_result::TestResult, | |
| 9 | time, | |
| 10 | types::NamePadding, | |
| 11 | types::TestDesc, | |
| 12 | }; | |
| 5 | use crate::bench::fmt_bench_samples; | |
| 6 | use crate::console::{ConsoleTestDiscoveryState, ConsoleTestState, OutputLocation}; | |
| 7 | use crate::test_result::TestResult; | |
| 8 | use crate::types::{NamePadding, TestDesc}; | |
| 9 | use crate::{term, time}; | |
| 13 | 10 | |
| 14 | 11 | // We insert a '\n' when the output hits 100 columns in quiet mode. 88 test |
| 15 | 12 | // result chars leaves 12 chars for a progress count like " 11704/12853". |
library/test/src/helpers/concurrency.rs+2-1| ... | ... | @@ -1,7 +1,8 @@ |
| 1 | 1 | //! Helper module which helps to determine amount of threads to be used |
| 2 | 2 | //! during tests execution. |
| 3 | 3 | |
| 4 | use std::{env, num::NonZero, thread}; | |
| 4 | use std::num::NonZero; | |
| 5 | use std::{env, thread}; | |
| 5 | 6 | |
| 6 | 7 | pub fn get_concurrency() -> usize { |
| 7 | 8 | if let Ok(value) = env::var("RUST_TEST_THREADS") { |
library/test/src/helpers/shuffle.rs+3-2| ... | ... | @@ -1,8 +1,9 @@ |
| 1 | use crate::cli::TestOpts; | |
| 2 | use crate::types::{TestDescAndFn, TestId, TestName}; | |
| 3 | 1 | use std::hash::{DefaultHasher, Hasher}; |
| 4 | 2 | use std::time::{SystemTime, UNIX_EPOCH}; |
| 5 | 3 | |
| 4 | use crate::cli::TestOpts; | |
| 5 | use crate::types::{TestDescAndFn, TestId, TestName}; | |
| 6 | ||
| 6 | 7 | pub fn get_shuffle_seed(opts: &TestOpts) -> Option<u64> { |
| 7 | 8 | opts.shuffle_seed.or_else(|| { |
| 8 | 9 | if opts.shuffle { |
library/test/src/lib.rs+22-27| ... | ... | @@ -25,45 +25,39 @@ |
| 25 | 25 | #![feature(test)] |
| 26 | 26 | #![allow(internal_features)] |
| 27 | 27 | |
| 28 | pub use cli::TestOpts; | |
| 29 | ||
| 28 | 30 | pub use self::bench::{black_box, Bencher}; |
| 29 | 31 | pub use self::console::run_tests_console; |
| 30 | 32 | pub use self::options::{ColorConfig, Options, OutputFormat, RunIgnored, ShouldPanic}; |
| 31 | 33 | pub use self::types::TestName::*; |
| 32 | 34 | pub use self::types::*; |
| 33 | 35 | pub use self::ColorConfig::*; |
| 34 | pub use cli::TestOpts; | |
| 35 | 36 | |
| 36 | 37 | // Module to be used by rustc to compile tests in libtest |
| 37 | 38 | pub mod test { |
| 38 | pub use crate::{ | |
| 39 | assert_test_result, | |
| 40 | bench::Bencher, | |
| 41 | cli::{parse_opts, TestOpts}, | |
| 42 | filter_tests, | |
| 43 | helpers::metrics::{Metric, MetricMap}, | |
| 44 | options::{Options, RunIgnored, RunStrategy, ShouldPanic}, | |
| 45 | run_test, test_main, test_main_static, | |
| 46 | test_result::{TestResult, TrFailed, TrFailedMsg, TrIgnored, TrOk}, | |
| 47 | time::{TestExecTime, TestTimeOptions}, | |
| 48 | types::{ | |
| 49 | DynTestFn, DynTestName, StaticBenchFn, StaticTestFn, StaticTestName, TestDesc, | |
| 50 | TestDescAndFn, TestId, TestName, TestType, | |
| 51 | }, | |
| 39 | pub use crate::bench::Bencher; | |
| 40 | pub use crate::cli::{parse_opts, TestOpts}; | |
| 41 | pub use crate::helpers::metrics::{Metric, MetricMap}; | |
| 42 | pub use crate::options::{Options, RunIgnored, RunStrategy, ShouldPanic}; | |
| 43 | pub use crate::test_result::{TestResult, TrFailed, TrFailedMsg, TrIgnored, TrOk}; | |
| 44 | pub use crate::time::{TestExecTime, TestTimeOptions}; | |
| 45 | pub use crate::types::{ | |
| 46 | DynTestFn, DynTestName, StaticBenchFn, StaticTestFn, StaticTestName, TestDesc, | |
| 47 | TestDescAndFn, TestId, TestName, TestType, | |
| 52 | 48 | }; |
| 49 | pub use crate::{assert_test_result, filter_tests, run_test, test_main, test_main_static}; | |
| 53 | 50 | } |
| 54 | 51 | |
| 55 | use std::{ | |
| 56 | collections::VecDeque, | |
| 57 | env, io, | |
| 58 | io::prelude::Write, | |
| 59 | mem::ManuallyDrop, | |
| 60 | panic::{self, catch_unwind, AssertUnwindSafe, PanicHookInfo}, | |
| 61 | process::{self, Command, Termination}, | |
| 62 | sync::mpsc::{channel, Sender}, | |
| 63 | sync::{Arc, Mutex}, | |
| 64 | thread, | |
| 65 | time::{Duration, Instant}, | |
| 66 | }; | |
| 52 | use std::collections::VecDeque; | |
| 53 | use std::io::prelude::Write; | |
| 54 | use std::mem::ManuallyDrop; | |
| 55 | use std::panic::{self, catch_unwind, AssertUnwindSafe, PanicHookInfo}; | |
| 56 | use std::process::{self, Command, Termination}; | |
| 57 | use std::sync::mpsc::{channel, Sender}; | |
| 58 | use std::sync::{Arc, Mutex}; | |
| 59 | use std::time::{Duration, Instant}; | |
| 60 | use std::{env, io, thread}; | |
| 67 | 61 | |
| 68 | 62 | pub mod bench; |
| 69 | 63 | mod cli; |
| ... | ... | @@ -82,6 +76,7 @@ mod types; |
| 82 | 76 | mod tests; |
| 83 | 77 | |
| 84 | 78 | use core::any::Any; |
| 79 | ||
| 85 | 80 | use event::{CompletedTest, TestEvent}; |
| 86 | 81 | use helpers::concurrency::get_concurrency; |
| 87 | 82 | use helpers::shuffle::{get_shuffle_seed, shuffle_tests}; |
library/test/src/stats/tests.rs+2-1| ... | ... | @@ -1,10 +1,11 @@ |
| 1 | 1 | use super::*; |
| 2 | 2 | |
| 3 | 3 | extern crate test; |
| 4 | use self::test::test::Bencher; | |
| 5 | 4 | use std::io; |
| 6 | 5 | use std::io::prelude::*; |
| 7 | 6 | |
| 7 | use self::test::test::Bencher; | |
| 8 | ||
| 8 | 9 | // Test vectors generated from R, using the script src/etc/stat-test-vectors.r. |
| 9 | 10 | |
| 10 | 11 | macro_rules! assert_approx_eq { |
library/test/src/term.rs+2-1| ... | ... | @@ -12,7 +12,8 @@ |
| 12 | 12 | |
| 13 | 13 | #![deny(missing_docs)] |
| 14 | 14 | |
| 15 | use std::io::{self, prelude::*}; | |
| 15 | use std::io::prelude::*; | |
| 16 | use std::io::{self}; | |
| 16 | 17 | |
| 17 | 18 | pub(crate) use terminfo::TerminfoTerminal; |
| 18 | 19 | #[cfg(windows)] |
library/test/src/term/terminfo/mod.rs+5-7| ... | ... | @@ -1,20 +1,18 @@ |
| 1 | 1 | //! Terminfo database interface. |
| 2 | 2 | |
| 3 | 3 | use std::collections::HashMap; |
| 4 | use std::env; | |
| 5 | use std::error; | |
| 6 | use std::fmt; | |
| 7 | 4 | use std::fs::File; |
| 8 | use std::io::{self, prelude::*, BufReader}; | |
| 5 | use std::io::prelude::*; | |
| 6 | use std::io::{self, BufReader}; | |
| 9 | 7 | use std::path::Path; |
| 10 | ||
| 11 | use super::color; | |
| 12 | use super::Terminal; | |
| 8 | use std::{env, error, fmt}; | |
| 13 | 9 | |
| 14 | 10 | use parm::{expand, Param, Variables}; |
| 15 | 11 | use parser::compiled::{msys_terminfo, parse}; |
| 16 | 12 | use searcher::get_dbpath_for_term; |
| 17 | 13 | |
| 14 | use super::{color, Terminal}; | |
| 15 | ||
| 18 | 16 | /// A parsed terminfo database entry. |
| 19 | 17 | #[allow(unused)] |
| 20 | 18 | #[derive(Debug)] |
library/test/src/term/terminfo/parm.rs+2-2| ... | ... | @@ -1,10 +1,10 @@ |
| 1 | 1 | //! Parameterized string expansion |
| 2 | 2 | |
| 3 | use std::iter::repeat; | |
| 4 | ||
| 3 | 5 | use self::Param::*; |
| 4 | 6 | use self::States::*; |
| 5 | 7 | |
| 6 | use std::iter::repeat; | |
| 7 | ||
| 8 | 8 | #[cfg(test)] |
| 9 | 9 | mod tests; |
| 10 | 10 |
library/test/src/term/terminfo/parser/compiled.rs+2-1| ... | ... | @@ -2,11 +2,12 @@ |
| 2 | 2 | |
| 3 | 3 | //! ncurses-compatible compiled terminfo format parsing (term(5)) |
| 4 | 4 | |
| 5 | use super::super::TermInfo; | |
| 6 | 5 | use std::collections::HashMap; |
| 7 | 6 | use std::io; |
| 8 | 7 | use std::io::prelude::*; |
| 9 | 8 | |
| 9 | use super::super::TermInfo; | |
| 10 | ||
| 10 | 11 | #[cfg(test)] |
| 11 | 12 | mod tests; |
| 12 | 13 |
library/test/src/term/terminfo/searcher.rs+1-2| ... | ... | @@ -2,9 +2,8 @@ |
| 2 | 2 | //! |
| 3 | 3 | //! Does not support hashed database, only filesystem! |
| 4 | 4 | |
| 5 | use std::env; | |
| 6 | use std::fs; | |
| 7 | 5 | use std::path::PathBuf; |
| 6 | use std::{env, fs}; | |
| 8 | 7 | |
| 9 | 8 | #[cfg(test)] |
| 10 | 9 | mod tests; |
library/test/src/term/win.rs+1-2| ... | ... | @@ -5,8 +5,7 @@ |
| 5 | 5 | use std::io; |
| 6 | 6 | use std::io::prelude::*; |
| 7 | 7 | |
| 8 | use super::color; | |
| 9 | use super::Terminal; | |
| 8 | use super::{color, Terminal}; | |
| 10 | 9 | |
| 11 | 10 | /// A Terminal implementation that uses the Win32 Console API. |
| 12 | 11 | pub(crate) struct WinConsole<T> { |
library/test/src/test_result.rs+2-4| ... | ... | @@ -1,16 +1,14 @@ |
| 1 | 1 | use std::any::Any; |
| 2 | use std::process::ExitStatus; | |
| 3 | ||
| 4 | 2 | #[cfg(unix)] |
| 5 | 3 | use std::os::unix::process::ExitStatusExt; |
| 4 | use std::process::ExitStatus; | |
| 6 | 5 | |
| 6 | pub use self::TestResult::*; | |
| 7 | 7 | use super::bench::BenchSamples; |
| 8 | 8 | use super::options::ShouldPanic; |
| 9 | 9 | use super::time; |
| 10 | 10 | use super::types::TestDesc; |
| 11 | 11 | |
| 12 | pub use self::TestResult::*; | |
| 13 | ||
| 14 | 12 | // Return code for secondary process. |
| 15 | 13 | // Start somewhere other than 0 so we know the return code means what we think |
| 16 | 14 | // it means. |
library/test/src/tests.rs+2-2| ... | ... | @@ -1,5 +1,4 @@ |
| 1 | 1 | use super::*; |
| 2 | ||
| 3 | 2 | use crate::{ |
| 4 | 3 | console::OutputLocation, |
| 5 | 4 | formatters::PrettyFormatter, |
| ... | ... | @@ -237,8 +236,9 @@ fn test_should_panic_bad_message() { |
| 237 | 236 | #[cfg(not(target_os = "emscripten"))] |
| 238 | 237 | #[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")] |
| 239 | 238 | fn test_should_panic_non_string_message_type() { |
| 240 | use crate::tests::TrFailedMsg; | |
| 241 | 239 | use std::any::TypeId; |
| 240 | ||
| 241 | use crate::tests::TrFailedMsg; | |
| 242 | 242 | fn f() -> Result<(), String> { |
| 243 | 243 | std::panic::panic_any(1i32); |
| 244 | 244 | } |
library/test/src/time.rs+3-3| ... | ... | @@ -5,10 +5,9 @@ |
| 5 | 5 | //! - Provide helpers for `report-time` and `measure-time` options. |
| 6 | 6 | //! - Provide newtypes for executions times. |
| 7 | 7 | |
| 8 | use std::env; | |
| 9 | use std::fmt; | |
| 10 | 8 | use std::str::FromStr; |
| 11 | 9 | use std::time::{Duration, Instant}; |
| 10 | use std::{env, fmt}; | |
| 12 | 11 | |
| 13 | 12 | use super::types::{TestDesc, TestType}; |
| 14 | 13 | |
| ... | ... | @@ -24,9 +23,10 @@ pub const TEST_WARN_TIMEOUT_S: u64 = 60; |
| 24 | 23 | /// Example of the expected format is `RUST_TEST_TIME_xxx=100,200`, where 100 means |
| 25 | 24 | /// warn time, and 200 means critical time. |
| 26 | 25 | pub mod time_constants { |
| 27 | use super::TEST_WARN_TIMEOUT_S; | |
| 28 | 26 | use std::time::Duration; |
| 29 | 27 | |
| 28 | use super::TEST_WARN_TIMEOUT_S; | |
| 29 | ||
| 30 | 30 | /// Environment variable for overriding default threshold for unit-tests. |
| 31 | 31 | pub const UNIT_ENV_NAME: &str = "RUST_TEST_TIME_UNIT"; |
| 32 | 32 |
library/test/src/types.rs+4-5| ... | ... | @@ -4,15 +4,14 @@ use std::borrow::Cow; |
| 4 | 4 | use std::fmt; |
| 5 | 5 | use std::sync::mpsc::Sender; |
| 6 | 6 | |
| 7 | use super::__rust_begin_short_backtrace; | |
| 8 | use super::bench::Bencher; | |
| 9 | use super::event::CompletedTest; | |
| 10 | use super::options; | |
| 11 | ||
| 12 | 7 | pub use NamePadding::*; |
| 13 | 8 | pub use TestFn::*; |
| 14 | 9 | pub use TestName::*; |
| 15 | 10 | |
| 11 | use super::bench::Bencher; | |
| 12 | use super::event::CompletedTest; | |
| 13 | use super::{__rust_begin_short_backtrace, options}; | |
| 14 | ||
| 16 | 15 | /// Type of the test according to the [Rust book](https://doc.rust-lang.org/cargo/guide/tests.html) |
| 17 | 16 | /// conventions. |
| 18 | 17 | #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] |
library/unwind/src/unwinding.rs+1-3| ... | ... | @@ -28,9 +28,7 @@ pub enum _Unwind_Reason_Code { |
| 28 | 28 | _URC_FAILURE = 9, // used only by ARM EHABI |
| 29 | 29 | } |
| 30 | 30 | pub use _Unwind_Reason_Code::*; |
| 31 | ||
| 32 | pub use unwinding::abi::UnwindContext; | |
| 33 | pub use unwinding::abi::UnwindException; | |
| 31 | pub use unwinding::abi::{UnwindContext, UnwindException}; | |
| 34 | 32 | pub enum _Unwind_Context {} |
| 35 | 33 | |
| 36 | 34 | pub use unwinding::custom_eh_frame_finder::{ |
rustfmt.toml+2| ... | ... | @@ -2,6 +2,8 @@ |
| 2 | 2 | version = "Two" |
| 3 | 3 | use_small_heuristics = "Max" |
| 4 | 4 | merge_derives = false |
| 5 | group_imports = "StdExternalCrate" | |
| 6 | imports_granularity = "Module" | |
| 5 | 7 | |
| 6 | 8 | # Files to ignore. Each entry uses gitignore syntax, but `!` prefixes aren't allowed. |
| 7 | 9 | ignore = [ |
src/bootstrap/src/bin/main.rs+3-7| ... | ... | @@ -5,14 +5,10 @@ |
| 5 | 5 | //! parent directory, and otherwise documentation can be found throughout the `build` |
| 6 | 6 | //! directory in each respective module. |
| 7 | 7 | |
| 8 | use std::io::Write; | |
| 9 | use std::process; | |
| 8 | use std::fs::{self, OpenOptions}; | |
| 9 | use std::io::{self, BufRead, BufReader, IsTerminal, Write}; | |
| 10 | 10 | use std::str::FromStr; |
| 11 | use std::{ | |
| 12 | env, | |
| 13 | fs::{self, OpenOptions}, | |
| 14 | io::{self, BufRead, BufReader, IsTerminal}, | |
| 15 | }; | |
| 11 | use std::{env, process}; | |
| 16 | 12 | |
| 17 | 13 | use bootstrap::{ |
| 18 | 14 | find_recent_config_change_ids, human_readable_changes, t, Build, Config, Subcommand, |
src/bootstrap/src/bin/rustc.rs+4-6| ... | ... | @@ -315,12 +315,10 @@ fn format_rusage_data(_child: Child) -> Option<String> { |
| 315 | 315 | fn format_rusage_data(child: Child) -> Option<String> { |
| 316 | 316 | use std::os::windows::io::AsRawHandle; |
| 317 | 317 | |
| 318 | use windows::{ | |
| 319 | Win32::Foundation::HANDLE, | |
| 320 | Win32::System::ProcessStatus::{K32GetProcessMemoryInfo, PROCESS_MEMORY_COUNTERS}, | |
| 321 | Win32::System::Threading::GetProcessTimes, | |
| 322 | Win32::System::Time::FileTimeToSystemTime, | |
| 323 | }; | |
| 318 | use windows::Win32::Foundation::HANDLE; | |
| 319 | use windows::Win32::System::ProcessStatus::{K32GetProcessMemoryInfo, PROCESS_MEMORY_COUNTERS}; | |
| 320 | use windows::Win32::System::Threading::GetProcessTimes; | |
| 321 | use windows::Win32::System::Time::FileTimeToSystemTime; | |
| 324 | 322 | |
| 325 | 323 | let handle = HANDLE(child.as_raw_handle() as isize); |
| 326 | 324 |
src/bootstrap/src/core/build_steps/check.rs+2-1| ... | ... | @@ -1,5 +1,7 @@ |
| 1 | 1 | //! Implementation of compiling the compiler and standard library, in "check"-based modes. |
| 2 | 2 | |
| 3 | use std::path::PathBuf; | |
| 4 | ||
| 3 | 5 | use crate::core::build_steps::compile::{ |
| 4 | 6 | add_to_sysroot, run_cargo, rustc_cargo, rustc_cargo_env, std_cargo, |
| 5 | 7 | }; |
| ... | ... | @@ -9,7 +11,6 @@ use crate::core::builder::{ |
| 9 | 11 | }; |
| 10 | 12 | use crate::core::config::TargetSelection; |
| 11 | 13 | use crate::{Compiler, Mode, Subcommand}; |
| 12 | use std::path::PathBuf; | |
| 13 | 14 | |
| 14 | 15 | pub fn cargo_subcommand(kind: Kind) -> &'static str { |
| 15 | 16 | match kind { |
src/bootstrap/src/core/build_steps/clippy.rs+6-20| ... | ... | @@ -1,26 +1,12 @@ |
| 1 | 1 | //! Implementation of running clippy on the compiler, standard library and various tools. |
| 2 | 2 | |
| 3 | use crate::builder::Builder; | |
| 4 | use crate::builder::ShouldRun; | |
| 3 | use super::compile::{librustc_stamp, libstd_stamp, run_cargo, rustc_cargo, std_cargo}; | |
| 4 | use super::tool::{prepare_tool_cargo, SourceType}; | |
| 5 | use super::{check, compile}; | |
| 6 | use crate::builder::{Builder, ShouldRun}; | |
| 5 | 7 | use crate::core::builder; |
| 6 | use crate::core::builder::crate_description; | |
| 7 | use crate::core::builder::Alias; | |
| 8 | use crate::core::builder::Kind; | |
| 9 | use crate::core::builder::RunConfig; | |
| 10 | use crate::core::builder::Step; | |
| 11 | use crate::Mode; | |
| 12 | use crate::Subcommand; | |
| 13 | use crate::TargetSelection; | |
| 14 | ||
| 15 | use super::check; | |
| 16 | use super::compile; | |
| 17 | use super::compile::librustc_stamp; | |
| 18 | use super::compile::libstd_stamp; | |
| 19 | use super::compile::run_cargo; | |
| 20 | use super::compile::rustc_cargo; | |
| 21 | use super::compile::std_cargo; | |
| 22 | use super::tool::prepare_tool_cargo; | |
| 23 | use super::tool::SourceType; | |
| 8 | use crate::core::builder::{crate_description, Alias, Kind, RunConfig, Step}; | |
| 9 | use crate::{Mode, Subcommand, TargetSelection}; | |
| 24 | 10 | |
| 25 | 11 | /// Disable the most spammy clippy lints |
| 26 | 12 | const IGNORED_RULES_FOR_STD_AND_RUSTC: &[&str] = &[ |
src/bootstrap/src/core/build_steps/compile.rs+6-10| ... | ... | @@ -8,31 +8,27 @@ |
| 8 | 8 | |
| 9 | 9 | use std::borrow::Cow; |
| 10 | 10 | use std::collections::HashSet; |
| 11 | use std::env; | |
| 12 | 11 | use std::ffi::OsStr; |
| 13 | use std::fs; | |
| 14 | 12 | use std::io::prelude::*; |
| 15 | 13 | use std::io::BufReader; |
| 16 | 14 | use std::path::{Path, PathBuf}; |
| 17 | 15 | use std::process::Stdio; |
| 18 | use std::str; | |
| 16 | use std::{env, fs, str}; | |
| 19 | 17 | |
| 20 | 18 | use serde_derive::Deserialize; |
| 21 | 19 | |
| 22 | use crate::core::build_steps::dist; | |
| 23 | use crate::core::build_steps::llvm; | |
| 24 | 20 | use crate::core::build_steps::tool::SourceType; |
| 21 | use crate::core::build_steps::{dist, llvm}; | |
| 25 | 22 | use crate::core::builder; |
| 26 | use crate::core::builder::crate_description; | |
| 27 | use crate::core::builder::Cargo; | |
| 28 | use crate::core::builder::{Builder, Kind, PathSet, RunConfig, ShouldRun, Step, TaskPath}; | |
| 23 | use crate::core::builder::{ | |
| 24 | crate_description, Builder, Cargo, Kind, PathSet, RunConfig, ShouldRun, Step, TaskPath, | |
| 25 | }; | |
| 29 | 26 | use crate::core::config::{DebuginfoLevel, LlvmLibunwind, RustcLto, TargetSelection}; |
| 30 | 27 | use crate::utils::exec::command; |
| 31 | 28 | use crate::utils::helpers::{ |
| 32 | 29 | exe, get_clang_cl_resource_dir, is_debug_info, is_dylib, symlink_dir, t, up_to_date, |
| 33 | 30 | }; |
| 34 | use crate::LLVM_TOOLS; | |
| 35 | use crate::{CLang, Compiler, DependencyType, GitRepo, Mode}; | |
| 31 | use crate::{CLang, Compiler, DependencyType, GitRepo, Mode, LLVM_TOOLS}; | |
| 36 | 32 | |
| 37 | 33 | #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] |
| 38 | 34 | pub struct Std { |
src/bootstrap/src/core/build_steps/dist.rs+2-4| ... | ... | @@ -9,19 +9,17 @@ |
| 9 | 9 | //! pieces of `rustup.rs`! |
| 10 | 10 | |
| 11 | 11 | use std::collections::HashSet; |
| 12 | use std::env; | |
| 13 | 12 | use std::ffi::OsStr; |
| 14 | use std::fs; | |
| 15 | 13 | use std::io::Write; |
| 16 | 14 | use std::path::{Path, PathBuf}; |
| 15 | use std::{env, fs}; | |
| 17 | 16 | |
| 18 | 17 | use object::read::archive::ArchiveFile; |
| 19 | 18 | use object::BinaryFormat; |
| 20 | 19 | |
| 21 | use crate::core::build_steps::compile; | |
| 22 | 20 | use crate::core::build_steps::doc::DocumentationFormat; |
| 23 | use crate::core::build_steps::llvm; | |
| 24 | 21 | use crate::core::build_steps::tool::{self, Tool}; |
| 22 | use crate::core::build_steps::{compile, llvm}; | |
| 25 | 23 | use crate::core::builder::{Builder, Kind, RunConfig, ShouldRun, Step}; |
| 26 | 24 | use crate::core::config::TargetSelection; |
| 27 | 25 | use crate::utils::channel::{self, Info}; |
src/bootstrap/src/core/build_steps/doc.rs+3-2| ... | ... | @@ -13,8 +13,9 @@ use std::{env, fs, mem}; |
| 13 | 13 | |
| 14 | 14 | use crate::core::build_steps::compile; |
| 15 | 15 | use crate::core::build_steps::tool::{self, prepare_tool_cargo, SourceType, Tool}; |
| 16 | use crate::core::builder::{self, crate_description}; | |
| 17 | use crate::core::builder::{Alias, Builder, Compiler, Kind, RunConfig, ShouldRun, Step}; | |
| 16 | use crate::core::builder::{ | |
| 17 | self, crate_description, Alias, Builder, Compiler, Kind, RunConfig, ShouldRun, Step, | |
| 18 | }; | |
| 18 | 19 | use crate::core::config::{Config, TargetSelection}; |
| 19 | 20 | use crate::utils::helpers::{symlink_dir, t, up_to_date}; |
| 20 | 21 | use crate::Mode; |
src/bootstrap/src/core/build_steps/format.rs+8-6| ... | ... | @@ -1,17 +1,19 @@ |
| 1 | 1 | //! Runs rustfmt on the repository. |
| 2 | 2 | |
| 3 | use crate::core::builder::Builder; | |
| 4 | use crate::utils::exec::command; | |
| 5 | use crate::utils::helpers::{self, program_out_of_date, t}; | |
| 6 | use build_helper::ci::CiEnv; | |
| 7 | use build_helper::git::get_git_modified_files; | |
| 8 | use ignore::WalkBuilder; | |
| 9 | 3 | use std::collections::VecDeque; |
| 10 | 4 | use std::path::{Path, PathBuf}; |
| 11 | 5 | use std::process::Command; |
| 12 | 6 | use std::sync::mpsc::SyncSender; |
| 13 | 7 | use std::sync::Mutex; |
| 14 | 8 | |
| 9 | use build_helper::ci::CiEnv; | |
| 10 | use build_helper::git::get_git_modified_files; | |
| 11 | use ignore::WalkBuilder; | |
| 12 | ||
| 13 | use crate::core::builder::Builder; | |
| 14 | use crate::utils::exec::command; | |
| 15 | use crate::utils::helpers::{self, program_out_of_date, t}; | |
| 16 | ||
| 15 | 17 | fn rustfmt(src: &Path, rustfmt: &Path, paths: &[PathBuf], check: bool) -> impl FnMut(bool) -> bool { |
| 16 | 18 | let mut cmd = Command::new(rustfmt); |
| 17 | 19 | // Avoid the submodule config paths from coming into play. We only allow a single global config |
src/bootstrap/src/core/build_steps/install.rs+1-2| ... | ... | @@ -3,9 +3,8 @@ |
| 3 | 3 | //! This module is responsible for installing the standard library, |
| 4 | 4 | //! compiler, and documentation. |
| 5 | 5 | |
| 6 | use std::env; | |
| 7 | use std::fs; | |
| 8 | 6 | use std::path::{Component, Path, PathBuf}; |
| 7 | use std::{env, fs}; | |
| 9 | 8 | |
| 10 | 9 | use crate::core::build_steps::dist; |
| 11 | 10 | use crate::core::builder::{Builder, RunConfig, ShouldRun, Step}; |
src/bootstrap/src/core/build_steps/llvm.rs+4-5| ... | ... | @@ -8,25 +8,24 @@ |
| 8 | 8 | //! LLVM and compiler-rt are essentially just wired up to everything else to |
| 9 | 9 | //! ensure that they're always in place if needed. |
| 10 | 10 | |
| 11 | use std::env; | |
| 12 | 11 | use std::env::consts::EXE_EXTENSION; |
| 13 | 12 | use std::ffi::{OsStr, OsString}; |
| 14 | 13 | use std::fs::{self, File}; |
| 15 | use std::io; | |
| 16 | 14 | use std::path::{Path, PathBuf}; |
| 17 | 15 | use std::sync::OnceLock; |
| 16 | use std::{env, io}; | |
| 17 | ||
| 18 | use build_helper::ci::CiEnv; | |
| 18 | 19 | |
| 19 | 20 | use crate::core::builder::{Builder, RunConfig, ShouldRun, Step}; |
| 20 | 21 | use crate::core::config::{Config, TargetSelection}; |
| 21 | 22 | use crate::utils::channel; |
| 23 | use crate::utils::exec::command; | |
| 22 | 24 | use crate::utils::helpers::{ |
| 23 | 25 | self, exe, get_clang_cl_resource_dir, output, t, unhashed_basename, up_to_date, |
| 24 | 26 | }; |
| 25 | 27 | use crate::{generate_smart_stamp_hash, CLang, GitRepo, Kind}; |
| 26 | 28 | |
| 27 | use crate::utils::exec::command; | |
| 28 | use build_helper::ci::CiEnv; | |
| 29 | ||
| 30 | 29 | #[derive(Clone)] |
| 31 | 30 | pub struct LlvmResult { |
| 32 | 31 | /// Path to llvm-config binary. |
src/bootstrap/src/core/build_steps/setup.rs+8-7| ... | ... | @@ -5,13 +5,6 @@ |
| 5 | 5 | //! allows setting up things that cannot be simply captured inside the config.toml, in addition to |
| 6 | 6 | //! leading people away from manually editing most of the config.toml values. |
| 7 | 7 | |
| 8 | use crate::core::builder::{Builder, RunConfig, ShouldRun, Step}; | |
| 9 | use crate::t; | |
| 10 | use crate::utils::change_tracker::CONFIG_CHANGE_HISTORY; | |
| 11 | use crate::utils::exec::command; | |
| 12 | use crate::utils::helpers::{self, hex_encode}; | |
| 13 | use crate::Config; | |
| 14 | use sha2::Digest; | |
| 15 | 8 | use std::env::consts::EXE_SUFFIX; |
| 16 | 9 | use std::fmt::Write as _; |
| 17 | 10 | use std::fs::File; |
| ... | ... | @@ -20,6 +13,14 @@ use std::path::{Path, PathBuf, MAIN_SEPARATOR_STR}; |
| 20 | 13 | use std::str::FromStr; |
| 21 | 14 | use std::{fmt, fs, io}; |
| 22 | 15 | |
| 16 | use sha2::Digest; | |
| 17 | ||
| 18 | use crate::core::builder::{Builder, RunConfig, ShouldRun, Step}; | |
| 19 | use crate::utils::change_tracker::CONFIG_CHANGE_HISTORY; | |
| 20 | use crate::utils::exec::command; | |
| 21 | use crate::utils::helpers::{self, hex_encode}; | |
| 22 | use crate::{t, Config}; | |
| 23 | ||
| 23 | 24 | #[cfg(test)] |
| 24 | 25 | mod tests; |
| 25 | 26 |
src/bootstrap/src/core/build_steps/setup/tests.rs+2-1| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | use sha2::Digest; | |
| 2 | ||
| 1 | 3 | use super::{RUST_ANALYZER_SETTINGS, SETTINGS_HASHES}; |
| 2 | 4 | use crate::utils::helpers::hex_encode; |
| 3 | use sha2::Digest; | |
| 4 | 5 | |
| 5 | 6 | #[test] |
| 6 | 7 | fn check_matching_settings_hash() { |
src/bootstrap/src/core/build_steps/suggest.rs+2-1| ... | ... | @@ -2,10 +2,11 @@ |
| 2 | 2 | |
| 3 | 3 | #![cfg_attr(feature = "build-metrics", allow(unused))] |
| 4 | 4 | |
| 5 | use clap::Parser; | |
| 6 | 5 | use std::path::PathBuf; |
| 7 | 6 | use std::str::FromStr; |
| 8 | 7 | |
| 8 | use clap::Parser; | |
| 9 | ||
| 9 | 10 | use crate::core::build_steps::tool::Tool; |
| 10 | 11 | use crate::core::builder::Builder; |
| 11 | 12 |
src/bootstrap/src/core/build_steps/test.rs+7-12| ... | ... | @@ -3,27 +3,22 @@ |
| 3 | 3 | //! `./x.py test` (aka [`Kind::Test`]) is currently allowed to reach build steps in other modules. |
| 4 | 4 | //! However, this contains ~all test parts we expect people to be able to build and run locally. |
| 5 | 5 | |
| 6 | use std::env; | |
| 7 | use std::ffi::OsStr; | |
| 8 | use std::ffi::OsString; | |
| 9 | use std::fs; | |
| 10 | use std::iter; | |
| 6 | use std::ffi::{OsStr, OsString}; | |
| 11 | 7 | use std::path::{Path, PathBuf}; |
| 8 | use std::{env, fs, iter}; | |
| 12 | 9 | |
| 13 | 10 | use clap_complete::shells; |
| 14 | 11 | |
| 15 | use crate::core::build_steps::compile; | |
| 16 | use crate::core::build_steps::dist; | |
| 17 | 12 | use crate::core::build_steps::doc::DocumentationFormat; |
| 18 | use crate::core::build_steps::llvm; | |
| 19 | 13 | use crate::core::build_steps::synthetic_targets::MirOptPanicAbortSyntheticTarget; |
| 20 | 14 | use crate::core::build_steps::tool::{self, SourceType, Tool}; |
| 21 | 15 | use crate::core::build_steps::toolstate::ToolState; |
| 16 | use crate::core::build_steps::{compile, dist, llvm}; | |
| 22 | 17 | use crate::core::builder; |
| 23 | use crate::core::builder::crate_description; | |
| 24 | use crate::core::builder::{Builder, Compiler, Kind, RunConfig, ShouldRun, Step}; | |
| 25 | use crate::core::config::flags::get_completion; | |
| 26 | use crate::core::config::flags::Subcommand; | |
| 18 | use crate::core::builder::{ | |
| 19 | crate_description, Builder, Compiler, Kind, RunConfig, ShouldRun, Step, | |
| 20 | }; | |
| 21 | use crate::core::config::flags::{get_completion, Subcommand}; | |
| 27 | 22 | use crate::core::config::TargetSelection; |
| 28 | 23 | use crate::utils::exec::{command, BootstrapCommand}; |
| 29 | 24 | use crate::utils::helpers::{ |
src/bootstrap/src/core/build_steps/tool.rs+2-5| ... | ... | @@ -1,6 +1,5 @@ |
| 1 | use std::env; | |
| 2 | use std::fs; | |
| 3 | 1 | use std::path::PathBuf; |
| 2 | use std::{env, fs}; | |
| 4 | 3 | |
| 5 | 4 | use crate::core::build_steps::compile; |
| 6 | 5 | use crate::core::build_steps::toolstate::ToolState; |
| ... | ... | @@ -10,9 +9,7 @@ use crate::core::config::TargetSelection; |
| 10 | 9 | use crate::utils::channel::GitInfo; |
| 11 | 10 | use crate::utils::exec::{command, BootstrapCommand}; |
| 12 | 11 | use crate::utils::helpers::{add_dylib_path, exe, get_closest_merge_base_commit, git, t}; |
| 13 | use crate::Compiler; | |
| 14 | use crate::Mode; | |
| 15 | use crate::{gha, Kind}; | |
| 12 | use crate::{gha, Compiler, Kind, Mode}; | |
| 16 | 13 | |
| 17 | 14 | #[derive(Debug, Clone, Hash, PartialEq, Eq)] |
| 18 | 15 | pub enum SourceType { |
src/bootstrap/src/core/build_steps/toolstate.rs+6-7| ... | ... | @@ -4,16 +4,15 @@ |
| 4 | 4 | //! |
| 5 | 5 | //! [Toolstate]: https://forge.rust-lang.org/infra/toolstate.html |
| 6 | 6 | |
| 7 | use crate::core::builder::{Builder, RunConfig, ShouldRun, Step}; | |
| 8 | use crate::utils::helpers::{self, t}; | |
| 9 | use serde_derive::{Deserialize, Serialize}; | |
| 10 | 7 | use std::collections::HashMap; |
| 11 | use std::env; | |
| 12 | use std::fmt; | |
| 13 | use std::fs; | |
| 14 | 8 | use std::io::{Seek, SeekFrom}; |
| 15 | 9 | use std::path::{Path, PathBuf}; |
| 16 | use std::time; | |
| 10 | use std::{env, fmt, fs, time}; | |
| 11 | ||
| 12 | use serde_derive::{Deserialize, Serialize}; | |
| 13 | ||
| 14 | use crate::core::builder::{Builder, RunConfig, ShouldRun, Step}; | |
| 15 | use crate::utils::helpers::{self, t}; | |
| 17 | 16 | |
| 18 | 17 | // Each cycle is 42 days long (6 weeks); the last week is 35..=42 then. |
| 19 | 18 | const BETA_WEEK_START: u64 = 35; |
src/bootstrap/src/core/build_steps/vendor.rs+2-1| ... | ... | @@ -1,7 +1,8 @@ |
| 1 | use std::path::PathBuf; | |
| 2 | ||
| 1 | 3 | use crate::core::build_steps::tool::SUBMODULES_FOR_RUSTBOOK; |
| 2 | 4 | use crate::core::builder::{Builder, RunConfig, ShouldRun, Step}; |
| 3 | 5 | use crate::utils::exec::command; |
| 4 | use std::path::PathBuf; | |
| 5 | 6 | |
| 6 | 7 | #[derive(Debug, Clone, Hash, PartialEq, Eq)] |
| 7 | 8 | pub(crate) struct Vendor { |
src/bootstrap/src/core/builder.rs+10-10| ... | ... | @@ -1,15 +1,16 @@ |
| 1 | 1 | use std::any::{type_name, Any}; |
| 2 | 2 | use std::cell::{Cell, RefCell}; |
| 3 | 3 | use std::collections::BTreeSet; |
| 4 | use std::env; | |
| 5 | 4 | use std::ffi::{OsStr, OsString}; |
| 6 | 5 | use std::fmt::{Debug, Write}; |
| 7 | use std::fs; | |
| 8 | 6 | use std::hash::Hash; |
| 9 | 7 | use std::ops::Deref; |
| 10 | 8 | use std::path::{Path, PathBuf}; |
| 11 | 9 | use std::sync::LazyLock; |
| 12 | 10 | use std::time::{Duration, Instant}; |
| 11 | use std::{env, fs}; | |
| 12 | ||
| 13 | use clap::ValueEnum; | |
| 13 | 14 | |
| 14 | 15 | use crate::core::build_steps::tool::{self, SourceType}; |
| 15 | 16 | use crate::core::build_steps::{ |
| ... | ... | @@ -17,17 +18,16 @@ use crate::core::build_steps::{ |
| 17 | 18 | }; |
| 18 | 19 | use crate::core::config::flags::{Color, Subcommand}; |
| 19 | 20 | use crate::core::config::{DryRun, SplitDebuginfo, TargetSelection}; |
| 20 | use crate::prepare_behaviour_dump_dir; | |
| 21 | 21 | use crate::utils::cache::Cache; |
| 22 | use crate::utils::helpers::{self, add_dylib_path, add_link_lib_path, exe, linker_args}; | |
| 23 | use crate::utils::helpers::{check_cfg_arg, libdir, linker_flags, t, LldThreads}; | |
| 24 | use crate::EXTRA_CHECK_CFGS; | |
| 25 | use crate::{Build, CLang, Crate, DocTests, GitRepo, Mode}; | |
| 26 | ||
| 27 | 22 | use crate::utils::exec::{command, BootstrapCommand}; |
| 23 | use crate::utils::helpers::{ | |
| 24 | self, add_dylib_path, add_link_lib_path, check_cfg_arg, exe, libdir, linker_args, linker_flags, | |
| 25 | t, LldThreads, | |
| 26 | }; | |
| 28 | 27 | pub use crate::Compiler; |
| 29 | ||
| 30 | use clap::ValueEnum; | |
| 28 | use crate::{ | |
| 29 | prepare_behaviour_dump_dir, Build, CLang, Crate, DocTests, GitRepo, Mode, EXTRA_CHECK_CFGS, | |
| 30 | }; | |
| 31 | 31 | |
| 32 | 32 | #[cfg(test)] |
| 33 | 33 | mod tests; |
src/bootstrap/src/core/builder/tests.rs+6-3| ... | ... | @@ -1,7 +1,8 @@ |
| 1 | use std::thread; | |
| 2 | ||
| 1 | 3 | use super::*; |
| 2 | 4 | use crate::core::build_steps::doc::DocumentationFormat; |
| 3 | 5 | use crate::core::config::Config; |
| 4 | use std::thread; | |
| 5 | 6 | |
| 6 | 7 | fn configure(cmd: &str, host: &[&str], target: &[&str]) -> Config { |
| 7 | 8 | configure_with_args(&[cmd.to_owned()], host, target) |
| ... | ... | @@ -215,10 +216,11 @@ fn alias_and_path_for_library() { |
| 215 | 216 | } |
| 216 | 217 | |
| 217 | 218 | mod defaults { |
| 219 | use pretty_assertions::assert_eq; | |
| 220 | ||
| 218 | 221 | use super::{configure, first, run_build}; |
| 219 | 222 | use crate::core::builder::*; |
| 220 | 223 | use crate::Config; |
| 221 | use pretty_assertions::assert_eq; | |
| 222 | 224 | |
| 223 | 225 | #[test] |
| 224 | 226 | fn build_default() { |
| ... | ... | @@ -326,9 +328,10 @@ mod defaults { |
| 326 | 328 | } |
| 327 | 329 | |
| 328 | 330 | mod dist { |
| 331 | use pretty_assertions::assert_eq; | |
| 332 | ||
| 329 | 333 | use super::{first, run_build, Config}; |
| 330 | 334 | use crate::core::builder::*; |
| 331 | use pretty_assertions::assert_eq; | |
| 332 | 335 | |
| 333 | 336 | fn configure(host: &[&str], target: &[&str]) -> Config { |
| 334 | 337 | Config { stage: 2, ..super::configure("dist", host, target) } |
src/bootstrap/src/core/config/config.rs+7-9| ... | ... | @@ -4,29 +4,27 @@ |
| 4 | 4 | //! how the build runs. |
| 5 | 5 | |
| 6 | 6 | use std::cell::{Cell, RefCell}; |
| 7 | use std::cmp; | |
| 8 | 7 | use std::collections::{HashMap, HashSet}; |
| 9 | use std::env; | |
| 10 | 8 | use std::fmt::{self, Display}; |
| 11 | use std::fs; | |
| 12 | 9 | use std::io::IsTerminal; |
| 13 | 10 | use std::path::{absolute, Path, PathBuf}; |
| 14 | 11 | use std::process::Command; |
| 15 | 12 | use std::str::FromStr; |
| 16 | 13 | use std::sync::OnceLock; |
| 14 | use std::{cmp, env, fs}; | |
| 15 | ||
| 16 | use build_helper::exit; | |
| 17 | use build_helper::git::GitConfig; | |
| 18 | use serde::{Deserialize, Deserializer}; | |
| 19 | use serde_derive::Deserialize; | |
| 17 | 20 | |
| 18 | 21 | use crate::core::build_steps::compile::CODEGEN_BACKEND_PREFIX; |
| 19 | 22 | use crate::core::build_steps::llvm; |
| 23 | pub use crate::core::config::flags::Subcommand; | |
| 20 | 24 | use crate::core::config::flags::{Color, Flags, Warnings}; |
| 21 | 25 | use crate::utils::cache::{Interned, INTERNER}; |
| 22 | 26 | use crate::utils::channel::{self, GitInfo}; |
| 23 | 27 | use crate::utils::helpers::{self, exe, get_closest_merge_base_commit, output, t}; |
| 24 | use build_helper::exit; | |
| 25 | use serde::{Deserialize, Deserializer}; | |
| 26 | use serde_derive::Deserialize; | |
| 27 | ||
| 28 | pub use crate::core::config::flags::Subcommand; | |
| 29 | use build_helper::git::GitConfig; | |
| 30 | 28 | |
| 31 | 29 | macro_rules! check_ci_llvm { |
| 32 | 30 | ($name:expr) => { |
src/bootstrap/src/core/config/tests.rs+9-11| ... | ... | @@ -1,17 +1,15 @@ |
| 1 | use super::{flags::Flags, ChangeIdWrapper, Config}; | |
| 2 | use crate::core::build_steps::clippy::get_clippy_rules_in_order; | |
| 3 | use crate::core::config::Target; | |
| 4 | use crate::core::config::TargetSelection; | |
| 5 | use crate::core::config::{LldMode, TomlConfig}; | |
| 1 | use std::env; | |
| 2 | use std::fs::{remove_file, File}; | |
| 3 | use std::io::Write; | |
| 4 | use std::path::Path; | |
| 6 | 5 | |
| 7 | 6 | use clap::CommandFactory; |
| 8 | 7 | use serde::Deserialize; |
| 9 | use std::{ | |
| 10 | env, | |
| 11 | fs::{remove_file, File}, | |
| 12 | io::Write, | |
| 13 | path::Path, | |
| 14 | }; | |
| 8 | ||
| 9 | use super::flags::Flags; | |
| 10 | use super::{ChangeIdWrapper, Config}; | |
| 11 | use crate::core::build_steps::clippy::get_clippy_rules_in_order; | |
| 12 | use crate::core::config::{LldMode, Target, TargetSelection, TomlConfig}; | |
| 15 | 13 | |
| 16 | 14 | fn parse(config: &str) -> Config { |
| 17 | 15 | Config::parse_inner(&["check".to_string(), "--config=/does/not/exist".to_string()], |&_| { |
src/bootstrap/src/core/download.rs+8-11| ... | ... | @@ -1,19 +1,16 @@ |
| 1 | use std::{ | |
| 2 | env, | |
| 3 | ffi::OsString, | |
| 4 | fs::{self, File}, | |
| 5 | io::{BufRead, BufReader, BufWriter, ErrorKind, Write}, | |
| 6 | path::{Path, PathBuf}, | |
| 7 | process::{Command, Stdio}, | |
| 8 | sync::OnceLock, | |
| 9 | }; | |
| 1 | use std::env; | |
| 2 | use std::ffi::OsString; | |
| 3 | use std::fs::{self, File}; | |
| 4 | use std::io::{BufRead, BufReader, BufWriter, ErrorKind, Write}; | |
| 5 | use std::path::{Path, PathBuf}; | |
| 6 | use std::process::{Command, Stdio}; | |
| 7 | use std::sync::OnceLock; | |
| 10 | 8 | |
| 11 | 9 | use build_helper::ci::CiEnv; |
| 12 | 10 | use xz2::bufread::XzDecoder; |
| 13 | 11 | |
| 14 | 12 | use crate::utils::exec::{command, BootstrapCommand}; |
| 15 | use crate::utils::helpers::hex_encode; | |
| 16 | use crate::utils::helpers::{check_run, exe, move_file, program_out_of_date}; | |
| 13 | use crate::utils::helpers::{check_run, exe, hex_encode, move_file, program_out_of_date}; | |
| 17 | 14 | use crate::{t, Config}; |
| 18 | 15 | |
| 19 | 16 | static SHOULD_FIX_BINS_AND_DYLIBS: OnceLock<bool> = OnceLock::new(); |
src/bootstrap/src/core/sanity.rs+4-6| ... | ... | @@ -9,19 +9,17 @@ |
| 9 | 9 | //! practice that's likely not true! |
| 10 | 10 | |
| 11 | 11 | use std::collections::HashMap; |
| 12 | use std::env; | |
| 12 | #[cfg(not(feature = "bootstrap-self-test"))] | |
| 13 | use std::collections::HashSet; | |
| 13 | 14 | use std::ffi::{OsStr, OsString}; |
| 14 | use std::fs; | |
| 15 | 15 | use std::path::PathBuf; |
| 16 | use std::{env, fs}; | |
| 16 | 17 | |
| 17 | 18 | #[cfg(not(feature = "bootstrap-self-test"))] |
| 18 | 19 | use crate::builder::Builder; |
| 20 | use crate::builder::Kind; | |
| 19 | 21 | #[cfg(not(feature = "bootstrap-self-test"))] |
| 20 | 22 | use crate::core::build_steps::tool; |
| 21 | #[cfg(not(feature = "bootstrap-self-test"))] | |
| 22 | use std::collections::HashSet; | |
| 23 | ||
| 24 | use crate::builder::Kind; | |
| 25 | 23 | use crate::core::config::Target; |
| 26 | 24 | use crate::utils::exec::command; |
| 27 | 25 | use crate::Build; |
src/bootstrap/src/lib.rs+3-6| ... | ... | @@ -18,15 +18,13 @@ |
| 18 | 18 | |
| 19 | 19 | use std::cell::{Cell, RefCell}; |
| 20 | 20 | use std::collections::{HashMap, HashSet}; |
| 21 | use std::env; | |
| 22 | 21 | use std::fmt::Display; |
| 23 | 22 | use std::fs::{self, File}; |
| 24 | use std::io; | |
| 25 | 23 | use std::path::{Path, PathBuf}; |
| 26 | 24 | use std::process::Command; |
| 27 | use std::str; | |
| 28 | 25 | use std::sync::OnceLock; |
| 29 | 26 | use std::time::SystemTime; |
| 27 | use std::{env, io, str}; | |
| 30 | 28 | |
| 31 | 29 | use build_helper::ci::{gha, CiEnv}; |
| 32 | 30 | use build_helper::exit; |
| ... | ... | @@ -37,9 +35,7 @@ use utils::helpers::hex_encode; |
| 37 | 35 | |
| 38 | 36 | use crate::core::builder; |
| 39 | 37 | use crate::core::builder::{Builder, Kind}; |
| 40 | use crate::core::config::{flags, LldMode}; | |
| 41 | use crate::core::config::{DryRun, Target}; | |
| 42 | use crate::core::config::{LlvmLibunwind, TargetSelection}; | |
| 38 | use crate::core::config::{flags, DryRun, LldMode, LlvmLibunwind, Target, TargetSelection}; | |
| 43 | 39 | use crate::utils::exec::{command, BehaviorOnFailure, BootstrapCommand, CommandOutput, OutputMode}; |
| 44 | 40 | use crate::utils::helpers::{self, dir_is_empty, exe, libdir, mtime, output, symlink_dir}; |
| 45 | 41 | |
| ... | ... | @@ -49,6 +45,7 @@ mod utils; |
| 49 | 45 | pub use core::builder::PathSet; |
| 50 | 46 | pub use core::config::flags::Subcommand; |
| 51 | 47 | pub use core::config::Config; |
| 48 | ||
| 52 | 49 | pub use utils::change_tracker::{ |
| 53 | 50 | find_recent_config_change_ids, human_readable_changes, CONFIG_CHANGE_HISTORY, |
| 54 | 51 | }; |
src/bootstrap/src/utils/cache.rs+1-2| ... | ... | @@ -3,13 +3,12 @@ use std::borrow::Borrow; |
| 3 | 3 | use std::cell::RefCell; |
| 4 | 4 | use std::cmp::Ordering; |
| 5 | 5 | use std::collections::HashMap; |
| 6 | use std::fmt; | |
| 7 | 6 | use std::hash::{Hash, Hasher}; |
| 8 | 7 | use std::marker::PhantomData; |
| 9 | use std::mem; | |
| 10 | 8 | use std::ops::Deref; |
| 11 | 9 | use std::path::PathBuf; |
| 12 | 10 | use std::sync::{LazyLock, Mutex}; |
| 11 | use std::{fmt, mem}; | |
| 13 | 12 | |
| 14 | 13 | use crate::core::builder::Step; |
| 15 | 14 |
src/bootstrap/src/utils/channel.rs+1-2| ... | ... | @@ -8,11 +8,10 @@ |
| 8 | 8 | use std::fs; |
| 9 | 9 | use std::path::Path; |
| 10 | 10 | |
| 11 | use super::helpers; | |
| 11 | 12 | use crate::utils::helpers::{output, t}; |
| 12 | 13 | use crate::Build; |
| 13 | 14 | |
| 14 | use super::helpers; | |
| 15 | ||
| 16 | 15 | #[derive(Clone, Default)] |
| 17 | 16 | pub enum GitInfo { |
| 18 | 17 | /// This is not a git repository. |
src/bootstrap/src/utils/exec.rs+5-3| ... | ... | @@ -1,11 +1,13 @@ |
| 1 | use crate::Build; | |
| 2 | use build_helper::ci::CiEnv; | |
| 3 | use build_helper::drop_bomb::DropBomb; | |
| 4 | 1 | use std::ffi::OsStr; |
| 5 | 2 | use std::fmt::{Debug, Formatter}; |
| 6 | 3 | use std::path::Path; |
| 7 | 4 | use std::process::{Command, CommandArgs, CommandEnvs, ExitStatus, Output, Stdio}; |
| 8 | 5 | |
| 6 | use build_helper::ci::CiEnv; | |
| 7 | use build_helper::drop_bomb::DropBomb; | |
| 8 | ||
| 9 | use crate::Build; | |
| 10 | ||
| 9 | 11 | /// What should be done when the command fails. |
| 10 | 12 | #[derive(Debug, Copy, Clone)] |
| 11 | 13 | pub enum BehaviorOnFailure { |
src/bootstrap/src/utils/helpers.rs+7-9| ... | ... | @@ -3,23 +3,20 @@ |
| 3 | 3 | //! Simple things like testing the various filesystem operations here and there, |
| 4 | 4 | //! not a lot of interesting happenings here unfortunately. |
| 5 | 5 | |
| 6 | use build_helper::git::{get_git_merge_base, output_result, GitConfig}; | |
| 7 | use build_helper::util::fail; | |
| 8 | use std::env; | |
| 9 | 6 | use std::ffi::OsStr; |
| 10 | use std::fs; | |
| 11 | use std::io; | |
| 12 | 7 | use std::path::{Path, PathBuf}; |
| 13 | 8 | use std::process::{Command, Stdio}; |
| 14 | use std::str; | |
| 15 | 9 | use std::sync::OnceLock; |
| 16 | 10 | use std::time::{Instant, SystemTime, UNIX_EPOCH}; |
| 11 | use std::{env, fs, io, str}; | |
| 12 | ||
| 13 | use build_helper::git::{get_git_merge_base, output_result, GitConfig}; | |
| 14 | use build_helper::util::fail; | |
| 17 | 15 | |
| 18 | 16 | use crate::core::builder::Builder; |
| 19 | 17 | use crate::core::config::{Config, TargetSelection}; |
| 20 | use crate::LldMode; | |
| 21 | ||
| 22 | 18 | pub use crate::utils::shared_helpers::{dylib_path, dylib_path_var}; |
| 19 | use crate::LldMode; | |
| 23 | 20 | |
| 24 | 21 | #[cfg(test)] |
| 25 | 22 | mod tests; |
| ... | ... | @@ -48,9 +45,10 @@ macro_rules! t { |
| 48 | 45 | } |
| 49 | 46 | }; |
| 50 | 47 | } |
| 51 | use crate::utils::exec::{command, BootstrapCommand}; | |
| 52 | 48 | pub use t; |
| 53 | 49 | |
| 50 | use crate::utils::exec::{command, BootstrapCommand}; | |
| 51 | ||
| 54 | 52 | pub fn exe(name: &str, target: TargetSelection) -> String { |
| 55 | 53 | crate::utils::shared_helpers::exe(name, &target.triple) |
| 56 | 54 | } |
src/bootstrap/src/utils/helpers/tests.rs+7-10| ... | ... | @@ -1,14 +1,11 @@ |
| 1 | use crate::{ | |
| 2 | utils::helpers::{ | |
| 3 | check_cfg_arg, extract_beta_rev, hex_encode, make, program_out_of_date, symlink_dir, | |
| 4 | }, | |
| 5 | Config, | |
| 6 | }; | |
| 7 | use std::{ | |
| 8 | fs::{self, remove_file, File}, | |
| 9 | io::Write, | |
| 10 | path::PathBuf, | |
| 1 | use std::fs::{self, remove_file, File}; | |
| 2 | use std::io::Write; | |
| 3 | use std::path::PathBuf; | |
| 4 | ||
| 5 | use crate::utils::helpers::{ | |
| 6 | check_cfg_arg, extract_beta_rev, hex_encode, make, program_out_of_date, symlink_dir, | |
| 11 | 7 | }; |
| 8 | use crate::Config; | |
| 12 | 9 | |
| 13 | 10 | #[test] |
| 14 | 11 | fn test_make() { |
src/bootstrap/src/utils/job.rs+15-18| ... | ... | @@ -40,28 +40,25 @@ pub unsafe fn setup(build: &mut crate::Build) { |
| 40 | 40 | /// Note that this is a Windows specific module as none of this logic is required on Unix. |
| 41 | 41 | #[cfg(windows)] |
| 42 | 42 | mod for_windows { |
| 43 | use crate::Build; | |
| 44 | use std::env; | |
| 45 | 43 | use std::ffi::c_void; |
| 46 | use std::io; | |
| 47 | use std::mem; | |
| 44 | use std::{env, io, mem}; | |
| 48 | 45 | |
| 49 | use windows::{ | |
| 50 | core::PCWSTR, | |
| 51 | Win32::Foundation::{CloseHandle, DuplicateHandle, DUPLICATE_SAME_ACCESS, HANDLE}, | |
| 52 | Win32::System::Diagnostics::Debug::{ | |
| 53 | SetErrorMode, SEM_NOGPFAULTERRORBOX, THREAD_ERROR_MODE, | |
| 54 | }, | |
| 55 | Win32::System::JobObjects::{ | |
| 56 | AssignProcessToJobObject, CreateJobObjectW, JobObjectExtendedLimitInformation, | |
| 57 | SetInformationJobObject, JOBOBJECT_EXTENDED_LIMIT_INFORMATION, | |
| 58 | JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE, JOB_OBJECT_LIMIT_PRIORITY_CLASS, | |
| 59 | }, | |
| 60 | Win32::System::Threading::{ | |
| 61 | GetCurrentProcess, OpenProcess, BELOW_NORMAL_PRIORITY_CLASS, PROCESS_DUP_HANDLE, | |
| 62 | }, | |
| 46 | use windows::core::PCWSTR; | |
| 47 | use windows::Win32::Foundation::{CloseHandle, DuplicateHandle, DUPLICATE_SAME_ACCESS, HANDLE}; | |
| 48 | use windows::Win32::System::Diagnostics::Debug::{ | |
| 49 | SetErrorMode, SEM_NOGPFAULTERRORBOX, THREAD_ERROR_MODE, | |
| 50 | }; | |
| 51 | use windows::Win32::System::JobObjects::{ | |
| 52 | AssignProcessToJobObject, CreateJobObjectW, JobObjectExtendedLimitInformation, | |
| 53 | SetInformationJobObject, JOBOBJECT_EXTENDED_LIMIT_INFORMATION, | |
| 54 | JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE, JOB_OBJECT_LIMIT_PRIORITY_CLASS, | |
| 55 | }; | |
| 56 | use windows::Win32::System::Threading::{ | |
| 57 | GetCurrentProcess, OpenProcess, BELOW_NORMAL_PRIORITY_CLASS, PROCESS_DUP_HANDLE, | |
| 63 | 58 | }; |
| 64 | 59 | |
| 60 | use crate::Build; | |
| 61 | ||
| 65 | 62 | pub unsafe fn setup(build: &mut Build) { |
| 66 | 63 | // Enable the Windows Error Reporting dialog which msys disables, |
| 67 | 64 | // so we can JIT debug rustc |
src/bootstrap/src/utils/metrics.rs+9-7| ... | ... | @@ -4,19 +4,21 @@ |
| 4 | 4 | //! As this module requires additional dependencies not present during local builds, it's cfg'd |
| 5 | 5 | //! away whenever the `build.metrics` config option is not set to `true`. |
| 6 | 6 | |
| 7 | use crate::core::builder::{Builder, Step}; | |
| 8 | use crate::utils::helpers::t; | |
| 9 | use crate::Build; | |
| 10 | use build_helper::metrics::{ | |
| 11 | JsonInvocation, JsonInvocationSystemStats, JsonNode, JsonRoot, JsonStepSystemStats, Test, | |
| 12 | TestOutcome, TestSuite, TestSuiteMetadata, | |
| 13 | }; | |
| 14 | 7 | use std::cell::RefCell; |
| 15 | 8 | use std::fs::File; |
| 16 | 9 | use std::io::BufWriter; |
| 17 | 10 | use std::time::{Duration, Instant, SystemTime}; |
| 11 | ||
| 12 | use build_helper::metrics::{ | |
| 13 | JsonInvocation, JsonInvocationSystemStats, JsonNode, JsonRoot, JsonStepSystemStats, Test, | |
| 14 | TestOutcome, TestSuite, TestSuiteMetadata, | |
| 15 | }; | |
| 18 | 16 | use sysinfo::System; |
| 19 | 17 | |
| 18 | use crate::core::builder::{Builder, Step}; | |
| 19 | use crate::utils::helpers::t; | |
| 20 | use crate::Build; | |
| 21 | ||
| 20 | 22 | // Update this number whenever a breaking change is made to the build metrics. |
| 21 | 23 | // |
| 22 | 24 | // The output format is versioned for two reasons: |
src/bootstrap/src/utils/render_tests.rs+4-2| ... | ... | @@ -6,13 +6,15 @@ |
| 6 | 6 | //! and rustc) libtest doesn't include the rendered human-readable output as a JSON field. We had |
| 7 | 7 | //! to reimplement all the rendering logic in this module because of that. |
| 8 | 8 | |
| 9 | use crate::core::builder::Builder; | |
| 10 | use crate::utils::exec::BootstrapCommand; | |
| 11 | 9 | use std::io::{BufRead, BufReader, Read, Write}; |
| 12 | 10 | use std::process::{ChildStdout, Stdio}; |
| 13 | 11 | use std::time::Duration; |
| 12 | ||
| 14 | 13 | use termcolor::{Color, ColorSpec, WriteColor}; |
| 15 | 14 | |
| 15 | use crate::core::builder::Builder; | |
| 16 | use crate::utils::exec::BootstrapCommand; | |
| 17 | ||
| 16 | 18 | const TERSE_TESTS_PER_LINE: usize = 88; |
| 17 | 19 | |
| 18 | 20 | pub(crate) fn add_flags_and_try_run_tests( |
src/bootstrap/src/utils/tarball.rs+2-2| ... | ... | @@ -7,8 +7,8 @@ |
| 7 | 7 | |
| 8 | 8 | use std::path::{Path, PathBuf}; |
| 9 | 9 | |
| 10 | use crate::core::builder::Builder; | |
| 11 | use crate::core::{build_steps::dist::distdir, builder::Kind}; | |
| 10 | use crate::core::build_steps::dist::distdir; | |
| 11 | use crate::core::builder::{Builder, Kind}; | |
| 12 | 12 | use crate::utils::exec::BootstrapCommand; |
| 13 | 13 | use crate::utils::helpers::{move_file, t}; |
| 14 | 14 | use crate::utils::{channel, helpers}; |
src/ci/docker/host-x86_64/test-various/uefi_qemu_test/src/main.rs+1| ... | ... | @@ -5,6 +5,7 @@ |
| 5 | 5 | #![no_std] |
| 6 | 6 | |
| 7 | 7 | use core::{panic, ptr}; |
| 8 | ||
| 8 | 9 | use r_efi::efi::{Char16, Handle, Status, SystemTable, RESET_SHUTDOWN}; |
| 9 | 10 | |
| 10 | 11 | #[panic_handler] |
src/librustdoc/clean/auto_trait.rs+2-4| ... | ... | @@ -6,13 +6,11 @@ use rustc_middle::ty::{self, Region, Ty}; |
| 6 | 6 | use rustc_span::def_id::DefId; |
| 7 | 7 | use rustc_span::symbol::{kw, Symbol}; |
| 8 | 8 | use rustc_trait_selection::traits::auto_trait::{self, RegionTarget}; |
| 9 | ||
| 10 | 9 | use thin_vec::ThinVec; |
| 11 | 10 | |
| 12 | use crate::clean::{self, simplify, Lifetime}; | |
| 13 | 11 | use crate::clean::{ |
| 14 | clean_generic_param_def, clean_middle_ty, clean_predicate, clean_trait_ref_with_constraints, | |
| 15 | clean_ty_generics, | |
| 12 | self, clean_generic_param_def, clean_middle_ty, clean_predicate, | |
| 13 | clean_trait_ref_with_constraints, clean_ty_generics, simplify, Lifetime, | |
| 16 | 14 | }; |
| 17 | 15 | use crate::core::DocContext; |
| 18 | 16 |
src/librustdoc/clean/blanket_impl.rs-1| ... | ... | @@ -5,7 +5,6 @@ use rustc_middle::ty::{self, Upcast}; |
| 5 | 5 | use rustc_span::def_id::DefId; |
| 6 | 6 | use rustc_span::DUMMY_SP; |
| 7 | 7 | use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt; |
| 8 | ||
| 9 | 8 | use thin_vec::ThinVec; |
| 10 | 9 | |
| 11 | 10 | use crate::clean; |
src/librustdoc/clean/cfg.rs+1-3| ... | ... | @@ -4,15 +4,13 @@ |
| 4 | 4 | // switch to use those structures instead. |
| 5 | 5 | |
| 6 | 6 | use std::fmt::{self, Write}; |
| 7 | use std::mem; | |
| 8 | use std::ops; | |
| 7 | use std::{mem, ops}; | |
| 9 | 8 | |
| 10 | 9 | use rustc_ast::{LitKind, MetaItem, MetaItemKind, NestedMetaItem}; |
| 11 | 10 | use rustc_data_structures::fx::FxHashSet; |
| 12 | 11 | use rustc_feature::Features; |
| 13 | 12 | use rustc_session::parse::ParseSess; |
| 14 | 13 | use rustc_span::symbol::{sym, Symbol}; |
| 15 | ||
| 16 | 14 | use rustc_span::Span; |
| 17 | 15 | |
| 18 | 16 | use crate::html::escape::Escape; |
src/librustdoc/clean/cfg/tests.rs+3-4| ... | ... | @@ -1,11 +1,10 @@ |
| 1 | use super::*; | |
| 2 | ||
| 3 | 1 | use rustc_ast::{MetaItemLit, Path, Safety, StrStyle}; |
| 4 | use rustc_span::create_default_session_globals_then; | |
| 5 | 2 | use rustc_span::symbol::{kw, Ident}; |
| 6 | use rustc_span::DUMMY_SP; | |
| 3 | use rustc_span::{create_default_session_globals_then, DUMMY_SP}; | |
| 7 | 4 | use thin_vec::thin_vec; |
| 8 | 5 | |
| 6 | use super::*; | |
| 7 | ||
| 9 | 8 | fn word_cfg(s: &str) -> Cfg { |
| 10 | 9 | Cfg::Cfg(Symbol::intern(s), None) |
| 11 | 10 | } |
src/librustdoc/clean/inline.rs+3-6| ... | ... | @@ -3,11 +3,7 @@ |
| 3 | 3 | use std::iter::once; |
| 4 | 4 | use std::sync::Arc; |
| 5 | 5 | |
| 6 | use thin_vec::{thin_vec, ThinVec}; | |
| 7 | ||
| 8 | use rustc_ast as ast; | |
| 9 | 6 | use rustc_data_structures::fx::FxHashSet; |
| 10 | use rustc_hir as hir; | |
| 11 | 7 | use rustc_hir::def::{DefKind, Res}; |
| 12 | 8 | use rustc_hir::def_id::{DefId, DefIdSet, LocalModDefId}; |
| 13 | 9 | use rustc_hir::Mutability; |
| ... | ... | @@ -17,7 +13,10 @@ use rustc_middle::ty::{self, TyCtxt}; |
| 17 | 13 | use rustc_span::def_id::LOCAL_CRATE; |
| 18 | 14 | use rustc_span::hygiene::MacroKind; |
| 19 | 15 | use rustc_span::symbol::{kw, sym, Symbol}; |
| 16 | use thin_vec::{thin_vec, ThinVec}; | |
| 17 | use {rustc_ast as ast, rustc_hir as hir}; | |
| 20 | 18 | |
| 19 | use super::Item; | |
| 21 | 20 | use crate::clean::{ |
| 22 | 21 | self, clean_bound_vars, clean_generics, clean_impl_item, clean_middle_assoc_item, |
| 23 | 22 | clean_middle_field, clean_middle_ty, clean_poly_fn_sig, clean_trait_ref_with_constraints, |
| ... | ... | @@ -27,8 +26,6 @@ use crate::clean::{ |
| 27 | 26 | use crate::core::DocContext; |
| 28 | 27 | use crate::formats::item_type::ItemType; |
| 29 | 28 | |
| 30 | use super::Item; | |
| 31 | ||
| 32 | 29 | /// Attempt to inline a definition into this AST. |
| 33 | 30 | /// |
| 34 | 31 | /// This function will fetch the definition specified, and if it is |
src/librustdoc/clean/mod.rs+11-16| ... | ... | @@ -30,41 +30,36 @@ mod simplify; |
| 30 | 30 | pub(crate) mod types; |
| 31 | 31 | pub(crate) mod utils; |
| 32 | 32 | |
| 33 | use rustc_ast as ast; | |
| 33 | use std::borrow::Cow; | |
| 34 | use std::collections::BTreeMap; | |
| 35 | use std::mem; | |
| 36 | ||
| 34 | 37 | use rustc_ast::token::{Token, TokenKind}; |
| 35 | 38 | use rustc_ast::tokenstream::{TokenStream, TokenTree}; |
| 36 | use rustc_attr as attr; | |
| 37 | 39 | use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap, FxIndexSet, IndexEntry}; |
| 38 | use rustc_errors::{codes::*, struct_span_code_err, FatalError}; | |
| 39 | use rustc_hir as hir; | |
| 40 | use rustc_errors::codes::*; | |
| 41 | use rustc_errors::{struct_span_code_err, FatalError}; | |
| 40 | 42 | use rustc_hir::def::{CtorKind, DefKind, Res}; |
| 41 | 43 | use rustc_hir::def_id::{DefId, DefIdMap, DefIdSet, LocalDefId, LOCAL_CRATE}; |
| 42 | 44 | use rustc_hir::PredicateOrigin; |
| 43 | 45 | use rustc_hir_analysis::lower_ty; |
| 44 | 46 | use rustc_middle::metadata::Reexport; |
| 45 | 47 | use rustc_middle::middle::resolve_bound_vars as rbv; |
| 46 | use rustc_middle::ty::GenericArgsRef; | |
| 47 | use rustc_middle::ty::TypeVisitableExt; | |
| 48 | use rustc_middle::ty::{self, AdtKind, Ty, TyCtxt}; | |
| 48 | use rustc_middle::ty::{self, AdtKind, GenericArgsRef, Ty, TyCtxt, TypeVisitableExt}; | |
| 49 | 49 | use rustc_middle::{bug, span_bug}; |
| 50 | 50 | use rustc_span::hygiene::{AstPass, MacroKind}; |
| 51 | 51 | use rustc_span::symbol::{kw, sym, Ident, Symbol}; |
| 52 | 52 | use rustc_span::ExpnKind; |
| 53 | 53 | use rustc_trait_selection::traits::wf::object_region_bounds; |
| 54 | ||
| 55 | use std::borrow::Cow; | |
| 56 | use std::collections::BTreeMap; | |
| 57 | use std::mem; | |
| 58 | 54 | use thin_vec::ThinVec; |
| 59 | ||
| 60 | use crate::core::DocContext; | |
| 61 | use crate::formats::item_type::ItemType; | |
| 62 | use crate::visit_ast::Module as DocModule; | |
| 63 | ||
| 64 | 55 | use utils::*; |
| 56 | use {rustc_ast as ast, rustc_attr as attr, rustc_hir as hir}; | |
| 65 | 57 | |
| 66 | 58 | pub(crate) use self::types::*; |
| 67 | 59 | pub(crate) use self::utils::{krate, register_res, synthesize_auto_trait_and_blanket_impls}; |
| 60 | use crate::core::DocContext; | |
| 61 | use crate::formats::item_type::ItemType; | |
| 62 | use crate::visit_ast::Module as DocModule; | |
| 68 | 63 | |
| 69 | 64 | pub(crate) fn clean_doc_module<'tcx>(doc: &DocModule<'tcx>, cx: &mut DocContext<'tcx>) -> Item { |
| 70 | 65 | let mut items: Vec<Item> = vec![]; |
src/librustdoc/clean/simplify.rs+1-2| ... | ... | @@ -18,8 +18,7 @@ use rustc_middle::ty; |
| 18 | 18 | use thin_vec::ThinVec; |
| 19 | 19 | |
| 20 | 20 | use crate::clean; |
| 21 | use crate::clean::GenericArgs as PP; | |
| 22 | use crate::clean::WherePredicate as WP; | |
| 21 | use crate::clean::{GenericArgs as PP, WherePredicate as WP}; | |
| 23 | 22 | use crate::core::DocContext; |
| 24 | 23 | |
| 25 | 24 | pub(crate) fn where_clauses(cx: &DocContext<'_>, clauses: ThinVec<WP>) -> ThinVec<WP> { |
src/librustdoc/clean/types.rs+11-14| ... | ... | @@ -3,19 +3,14 @@ use std::cell::RefCell; |
| 3 | 3 | use std::hash::Hash; |
| 4 | 4 | use std::path::PathBuf; |
| 5 | 5 | use std::rc::Rc; |
| 6 | use std::sync::Arc; | |
| 7 | use std::sync::OnceLock as OnceCell; | |
| 6 | use std::sync::{Arc, OnceLock as OnceCell}; | |
| 8 | 7 | use std::{fmt, iter}; |
| 9 | 8 | |
| 10 | 9 | use arrayvec::ArrayVec; |
| 11 | use thin_vec::ThinVec; | |
| 12 | ||
| 13 | use rustc_ast as ast; | |
| 14 | 10 | use rustc_ast_pretty::pprust; |
| 15 | 11 | use rustc_attr::{ConstStability, Deprecation, Stability, StabilityLevel, StableSince}; |
| 16 | 12 | use rustc_const_eval::const_eval::is_unstable_const_fn; |
| 17 | 13 | use rustc_data_structures::fx::{FxHashMap, FxHashSet}; |
| 18 | use rustc_hir as hir; | |
| 19 | 14 | use rustc_hir::def::{CtorKind, DefKind, Res}; |
| 20 | 15 | use rustc_hir::def_id::{CrateNum, DefId, LOCAL_CRATE}; |
| 21 | 16 | use rustc_hir::lang_items::LangItem; |
| ... | ... | @@ -35,7 +30,15 @@ use rustc_span::symbol::{kw, sym, Ident, Symbol}; |
| 35 | 30 | use rustc_span::{FileName, Loc, DUMMY_SP}; |
| 36 | 31 | use rustc_target::abi::VariantIdx; |
| 37 | 32 | use rustc_target::spec::abi::Abi; |
| 33 | use thin_vec::ThinVec; | |
| 34 | use {rustc_ast as ast, rustc_hir as hir}; | |
| 38 | 35 | |
| 36 | pub(crate) use self::ItemKind::*; | |
| 37 | pub(crate) use self::SelfTy::*; | |
| 38 | pub(crate) use self::Type::{ | |
| 39 | Array, BareFunction, BorrowedRef, DynTrait, Generic, ImplTrait, Infer, Primitive, QPath, | |
| 40 | RawPointer, Slice, Tuple, | |
| 41 | }; | |
| 39 | 42 | use crate::clean::cfg::Cfg; |
| 40 | 43 | use crate::clean::clean_middle_path; |
| 41 | 44 | use crate::clean::inline::{self, print_inlined_const}; |
| ... | ... | @@ -46,13 +49,6 @@ use crate::formats::item_type::ItemType; |
| 46 | 49 | use crate::html::render::Context; |
| 47 | 50 | use crate::passes::collect_intra_doc_links::UrlFragment; |
| 48 | 51 | |
| 49 | pub(crate) use self::ItemKind::*; | |
| 50 | pub(crate) use self::SelfTy::*; | |
| 51 | pub(crate) use self::Type::{ | |
| 52 | Array, BareFunction, BorrowedRef, DynTrait, Generic, ImplTrait, Infer, Primitive, QPath, | |
| 53 | RawPointer, Slice, Tuple, | |
| 54 | }; | |
| 55 | ||
| 56 | 52 | #[cfg(test)] |
| 57 | 53 | mod tests; |
| 58 | 54 | |
| ... | ... | @@ -2586,8 +2582,9 @@ pub(crate) enum AssocItemConstraintKind { |
| 2586 | 2582 | // Some nodes are used a lot. Make sure they don't unintentionally get bigger. |
| 2587 | 2583 | #[cfg(target_pointer_width = "64")] |
| 2588 | 2584 | mod size_asserts { |
| 2589 | use super::*; | |
| 2590 | 2585 | use rustc_data_structures::static_assert_size; |
| 2586 | ||
| 2587 | use super::*; | |
| 2591 | 2588 | // tidy-alphabetical-start |
| 2592 | 2589 | static_assert_size!(Crate, 64); // frequently moved by-value |
| 2593 | 2590 | static_assert_size!(DocFragment, 32); |
src/librustdoc/clean/types/tests.rs+2-2| ... | ... | @@ -1,8 +1,8 @@ |
| 1 | use super::*; | |
| 2 | ||
| 3 | 1 | use rustc_resolve::rustdoc::{unindent_doc_fragments, DocFragmentKind}; |
| 4 | 2 | use rustc_span::create_default_session_globals_then; |
| 5 | 3 | |
| 4 | use super::*; | |
| 5 | ||
| 6 | 6 | fn create_doc_fragment(s: &str) -> Vec<DocFragment> { |
| 7 | 7 | vec![DocFragment { |
| 8 | 8 | span: DUMMY_SP, |
src/librustdoc/clean/utils.rs+15-16| ... | ... | @@ -1,3 +1,18 @@ |
| 1 | use std::assert_matches::debug_assert_matches; | |
| 2 | use std::fmt::Write as _; | |
| 3 | use std::mem; | |
| 4 | use std::sync::LazyLock as Lazy; | |
| 5 | ||
| 6 | use rustc_ast::tokenstream::TokenTree; | |
| 7 | use rustc_hir::def::{DefKind, Res}; | |
| 8 | use rustc_hir::def_id::{DefId, LocalDefId, LOCAL_CRATE}; | |
| 9 | use rustc_metadata::rendered_const; | |
| 10 | use rustc_middle::mir; | |
| 11 | use rustc_middle::ty::{self, GenericArgKind, GenericArgsRef, TyCtxt, TypeVisitableExt}; | |
| 12 | use rustc_span::symbol::{kw, sym, Symbol}; | |
| 13 | use thin_vec::{thin_vec, ThinVec}; | |
| 14 | use {rustc_ast as ast, rustc_hir as hir}; | |
| 15 | ||
| 1 | 16 | use crate::clean::auto_trait::synthesize_auto_trait_impls; |
| 2 | 17 | use crate::clean::blanket_impl::synthesize_blanket_impls; |
| 3 | 18 | use crate::clean::render_macro_matchers::render_macro_matcher; |
| ... | ... | @@ -10,22 +25,6 @@ use crate::clean::{ |
| 10 | 25 | use crate::core::DocContext; |
| 11 | 26 | use crate::html::format::visibility_to_src_with_space; |
| 12 | 27 | |
| 13 | use rustc_ast as ast; | |
| 14 | use rustc_ast::tokenstream::TokenTree; | |
| 15 | use rustc_hir as hir; | |
| 16 | use rustc_hir::def::{DefKind, Res}; | |
| 17 | use rustc_hir::def_id::{DefId, LocalDefId, LOCAL_CRATE}; | |
| 18 | use rustc_metadata::rendered_const; | |
| 19 | use rustc_middle::mir; | |
| 20 | use rustc_middle::ty::TypeVisitableExt; | |
| 21 | use rustc_middle::ty::{self, GenericArgKind, GenericArgsRef, TyCtxt}; | |
| 22 | use rustc_span::symbol::{kw, sym, Symbol}; | |
| 23 | use std::assert_matches::debug_assert_matches; | |
| 24 | use std::fmt::Write as _; | |
| 25 | use std::mem; | |
| 26 | use std::sync::LazyLock as Lazy; | |
| 27 | use thin_vec::{thin_vec, ThinVec}; | |
| 28 | ||
| 29 | 28 | #[cfg(test)] |
| 30 | 29 | mod tests; |
| 31 | 30 |
src/librustdoc/config.rs+7-13| ... | ... | @@ -1,38 +1,32 @@ |
| 1 | 1 | use std::collections::BTreeMap; |
| 2 | 2 | use std::ffi::OsStr; |
| 3 | use std::fmt; | |
| 4 | use std::io; | |
| 5 | 3 | use std::io::Read; |
| 6 | use std::path::Path; | |
| 7 | use std::path::PathBuf; | |
| 4 | use std::path::{Path, PathBuf}; | |
| 8 | 5 | use std::str::FromStr; |
| 6 | use std::{fmt, io}; | |
| 9 | 7 | |
| 10 | 8 | use rustc_data_structures::fx::FxHashMap; |
| 11 | 9 | use rustc_errors::DiagCtxtHandle; |
| 12 | 10 | use rustc_session::config::{ |
| 13 | self, parse_crate_types_from_list, parse_externs, parse_target_triple, CrateType, | |
| 11 | self, get_cmd_lint_options, nightly_options, parse_crate_types_from_list, parse_externs, | |
| 12 | parse_target_triple, CodegenOptions, CrateType, ErrorOutputType, Externs, Input, | |
| 13 | JsonUnusedExterns, UnstableOptions, | |
| 14 | 14 | }; |
| 15 | use rustc_session::config::{get_cmd_lint_options, nightly_options}; | |
| 16 | use rustc_session::config::{CodegenOptions, ErrorOutputType, Externs, Input}; | |
| 17 | use rustc_session::config::{JsonUnusedExterns, UnstableOptions}; | |
| 18 | use rustc_session::getopts; | |
| 19 | 15 | use rustc_session::lint::Level; |
| 20 | 16 | use rustc_session::search_paths::SearchPath; |
| 21 | use rustc_session::EarlyDiagCtxt; | |
| 17 | use rustc_session::{getopts, EarlyDiagCtxt}; | |
| 22 | 18 | use rustc_span::edition::Edition; |
| 23 | 19 | use rustc_span::FileName; |
| 24 | 20 | use rustc_target::spec::TargetTriple; |
| 25 | 21 | |
| 26 | 22 | use crate::core::new_dcx; |
| 27 | 23 | use crate::externalfiles::ExternalHtml; |
| 28 | use crate::html; | |
| 29 | 24 | use crate::html::markdown::IdMap; |
| 30 | 25 | use crate::html::render::StylePath; |
| 31 | 26 | use crate::html::static_files; |
| 32 | use crate::opts; | |
| 33 | 27 | use crate::passes::{self, Condition}; |
| 34 | 28 | use crate::scrape_examples::{AllCallLocations, ScrapeExamplesOptions}; |
| 35 | use crate::theme; | |
| 29 | use crate::{html, opts, theme}; | |
| 36 | 30 | |
| 37 | 31 | #[derive(Clone, Copy, PartialEq, Eq, Debug, Default)] |
| 38 | 32 | pub(crate) enum OutputFormat { |
src/librustdoc/core.rs+12-13| ... | ... | @@ -1,9 +1,16 @@ |
| 1 | use std::cell::RefCell; | |
| 2 | use std::rc::Rc; | |
| 3 | use std::sync::atomic::AtomicBool; | |
| 4 | use std::sync::{Arc, LazyLock}; | |
| 5 | use std::{io, mem}; | |
| 6 | ||
| 1 | 7 | use rustc_data_structures::fx::{FxHashMap, FxHashSet}; |
| 2 | 8 | use rustc_data_structures::sync::Lrc; |
| 3 | 9 | use rustc_data_structures::unord::UnordSet; |
| 10 | use rustc_errors::codes::*; | |
| 4 | 11 | use rustc_errors::emitter::{stderr_destination, DynEmitter, HumanEmitter}; |
| 5 | 12 | use rustc_errors::json::JsonEmitter; |
| 6 | use rustc_errors::{codes::*, DiagCtxtHandle, ErrorGuaranteed, TerminalUrl}; | |
| 13 | use rustc_errors::{DiagCtxtHandle, ErrorGuaranteed, TerminalUrl}; | |
| 7 | 14 | use rustc_feature::UnstableFeatures; |
| 8 | 15 | use rustc_hir::def::Res; |
| 9 | 16 | use rustc_hir::def_id::{DefId, DefIdMap, DefIdSet, LocalDefId}; |
| ... | ... | @@ -14,25 +21,17 @@ use rustc_lint::{late_lint_mod, MissingDoc}; |
| 14 | 21 | use rustc_middle::hir::nested_filter; |
| 15 | 22 | use rustc_middle::ty::{ParamEnv, Ty, TyCtxt}; |
| 16 | 23 | use rustc_session::config::{self, CrateType, ErrorOutputType, ResolveDocLinks}; |
| 17 | use rustc_session::lint; | |
| 18 | use rustc_session::Session; | |
| 24 | pub(crate) use rustc_session::config::{Options, UnstableOptions}; | |
| 25 | use rustc_session::{lint, Session}; | |
| 19 | 26 | use rustc_span::symbol::sym; |
| 20 | 27 | use rustc_span::{source_map, Span}; |
| 21 | 28 | |
| 22 | use std::cell::RefCell; | |
| 23 | use std::io; | |
| 24 | use std::mem; | |
| 25 | use std::rc::Rc; | |
| 26 | use std::sync::LazyLock; | |
| 27 | use std::sync::{atomic::AtomicBool, Arc}; | |
| 28 | ||
| 29 | 29 | use crate::clean::inline::build_external_trait; |
| 30 | 30 | use crate::clean::{self, ItemId}; |
| 31 | 31 | use crate::config::{Options as RustdocOptions, OutputFormat, RenderOptions}; |
| 32 | 32 | use crate::formats::cache::Cache; |
| 33 | use crate::passes::{self, Condition::*}; | |
| 34 | ||
| 35 | pub(crate) use rustc_session::config::{Options, UnstableOptions}; | |
| 33 | use crate::passes::Condition::*; | |
| 34 | use crate::passes::{self}; | |
| 36 | 35 | |
| 37 | 36 | pub(crate) struct DocContext<'tcx> { |
| 38 | 37 | pub(crate) tcx: TyCtxt<'tcx>, |
src/librustdoc/docfs.rs+2-2| ... | ... | @@ -9,11 +9,11 @@ |
| 9 | 9 | //! abstraction. |
| 10 | 10 | |
| 11 | 11 | use std::cmp::max; |
| 12 | use std::fs; | |
| 13 | use std::io; | |
| 14 | 12 | use std::path::{Path, PathBuf}; |
| 15 | 13 | use std::sync::mpsc::Sender; |
| 16 | 14 | use std::thread::available_parallelism; |
| 15 | use std::{fs, io}; | |
| 16 | ||
| 17 | 17 | use threadpool::ThreadPool; |
| 18 | 18 | |
| 19 | 19 | pub(crate) trait PathError { |
src/librustdoc/doctest.rs+9-13| ... | ... | @@ -2,9 +2,16 @@ mod make; |
| 2 | 2 | mod markdown; |
| 3 | 3 | mod rust; |
| 4 | 4 | |
| 5 | use std::fs::File; | |
| 6 | use std::io::{self, Write}; | |
| 7 | use std::path::{Path, PathBuf}; | |
| 8 | use std::process::{self, Command, Stdio}; | |
| 9 | use std::sync::atomic::{AtomicUsize, Ordering}; | |
| 10 | use std::sync::{Arc, Mutex}; | |
| 11 | use std::{panic, str}; | |
| 12 | ||
| 5 | 13 | pub(crate) use make::make_test; |
| 6 | 14 | pub(crate) use markdown::test as test_markdown; |
| 7 | ||
| 8 | 15 | use rustc_ast as ast; |
| 9 | 16 | use rustc_data_structures::fx::{FxHashMap, FxHashSet}; |
| 10 | 17 | use rustc_errors::{ColorConfig, DiagCtxtHandle, ErrorGuaranteed, FatalError}; |
| ... | ... | @@ -17,24 +24,13 @@ use rustc_span::edition::Edition; |
| 17 | 24 | use rustc_span::symbol::sym; |
| 18 | 25 | use rustc_span::FileName; |
| 19 | 26 | use rustc_target::spec::{Target, TargetTriple}; |
| 20 | ||
| 21 | use std::fs::File; | |
| 22 | use std::io::{self, Write}; | |
| 23 | use std::panic; | |
| 24 | use std::path::{Path, PathBuf}; | |
| 25 | use std::process::{self, Command, Stdio}; | |
| 26 | use std::str; | |
| 27 | use std::sync::atomic::{AtomicUsize, Ordering}; | |
| 28 | use std::sync::{Arc, Mutex}; | |
| 29 | ||
| 30 | 27 | use tempfile::{Builder as TempFileBuilder, TempDir}; |
| 31 | 28 | |
| 29 | use self::rust::HirCollector; | |
| 32 | 30 | use crate::config::Options as RustdocOptions; |
| 33 | 31 | use crate::html::markdown::{ErrorCodes, Ignore, LangString, MdRelLine}; |
| 34 | 32 | use crate::lint::init_lints; |
| 35 | 33 | |
| 36 | use self::rust::HirCollector; | |
| 37 | ||
| 38 | 34 | /// Options that apply to all doctests in a crate or Markdown file (for `rustdoc foo.md`). |
| 39 | 35 | #[derive(Clone)] |
| 40 | 36 | pub(crate) struct GlobalTestOptions { |
src/librustdoc/doctest/rust.rs+4-2| ... | ... | @@ -2,7 +2,8 @@ |
| 2 | 2 | |
| 3 | 3 | use std::env; |
| 4 | 4 | |
| 5 | use rustc_data_structures::{fx::FxHashSet, sync::Lrc}; | |
| 5 | use rustc_data_structures::fx::FxHashSet; | |
| 6 | use rustc_data_structures::sync::Lrc; | |
| 6 | 7 | use rustc_hir::def_id::{LocalDefId, CRATE_DEF_ID}; |
| 7 | 8 | use rustc_hir::{self as hir, intravisit, CRATE_HIR_ID}; |
| 8 | 9 | use rustc_middle::hir::map::Map; |
| ... | ... | @@ -14,7 +15,8 @@ use rustc_span::source_map::SourceMap; |
| 14 | 15 | use rustc_span::{BytePos, FileName, Pos, Span, DUMMY_SP}; |
| 15 | 16 | |
| 16 | 17 | use super::{DoctestVisitor, ScrapedDoctest}; |
| 17 | use crate::clean::{types::AttributesExt, Attributes}; | |
| 18 | use crate::clean::types::AttributesExt; | |
| 19 | use crate::clean::Attributes; | |
| 18 | 20 | use crate::html::markdown::{self, ErrorCodes, LangString, MdRelLine}; |
| 19 | 21 | |
| 20 | 22 | struct RustCollector { |
src/librustdoc/doctest/tests.rs+2-1| ... | ... | @@ -1,8 +1,9 @@ |
| 1 | 1 | use std::path::PathBuf; |
| 2 | 2 | |
| 3 | use super::{make_test, GlobalTestOptions}; | |
| 4 | 3 | use rustc_span::edition::DEFAULT_EDITION; |
| 5 | 4 | |
| 5 | use super::{make_test, GlobalTestOptions}; | |
| 6 | ||
| 6 | 7 | /// Default [`GlobalTestOptions`] for these unit tests. |
| 7 | 8 | fn default_global_opts(crate_name: impl Into<String>) -> GlobalTestOptions { |
| 8 | 9 | GlobalTestOptions { |
src/librustdoc/externalfiles.rs+5-5| ... | ... | @@ -1,12 +1,12 @@ |
| 1 | use crate::html::markdown::{ErrorCodes, HeadingOffset, IdMap, Markdown, Playground}; | |
| 2 | use rustc_errors::DiagCtxtHandle; | |
| 3 | use rustc_span::edition::Edition; | |
| 4 | use std::fs; | |
| 5 | 1 | use std::path::Path; |
| 6 | use std::str; | |
| 2 | use std::{fs, str}; | |
| 7 | 3 | |
| 4 | use rustc_errors::DiagCtxtHandle; | |
| 5 | use rustc_span::edition::Edition; | |
| 8 | 6 | use serde::Serialize; |
| 9 | 7 | |
| 8 | use crate::html::markdown::{ErrorCodes, HeadingOffset, IdMap, Markdown, Playground}; | |
| 9 | ||
| 10 | 10 | #[derive(Clone, Debug, Serialize)] |
| 11 | 11 | pub(crate) struct ExternalHtml { |
| 12 | 12 | /// Content that will be included inline in the `<head>` section of a |
src/librustdoc/formats/cache.rs+2-1| ... | ... | @@ -5,7 +5,8 @@ use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, DefIdSet}; |
| 5 | 5 | use rustc_middle::ty::{self, TyCtxt}; |
| 6 | 6 | use rustc_span::Symbol; |
| 7 | 7 | |
| 8 | use crate::clean::{self, types::ExternalLocation, ExternalCrate, ItemId, PrimitiveType}; | |
| 8 | use crate::clean::types::ExternalLocation; | |
| 9 | use crate::clean::{self, ExternalCrate, ItemId, PrimitiveType}; | |
| 9 | 10 | use crate::core::DocContext; |
| 10 | 11 | use crate::fold::DocFolder; |
| 11 | 12 | use crate::formats::item_type::ItemType; |
src/librustdoc/formats/item_type.rs+1-2| ... | ... | @@ -2,10 +2,9 @@ |
| 2 | 2 | |
| 3 | 3 | use std::fmt; |
| 4 | 4 | |
| 5 | use serde::{Serialize, Serializer}; | |
| 6 | ||
| 7 | 5 | use rustc_hir::def::{CtorOf, DefKind}; |
| 8 | 6 | use rustc_span::hygiene::MacroKind; |
| 7 | use serde::{Serialize, Serializer}; | |
| 9 | 8 | |
| 10 | 9 | use crate::clean; |
| 11 | 10 |
src/librustdoc/formats/mod.rs+1-2| ... | ... | @@ -2,9 +2,8 @@ pub(crate) mod cache; |
| 2 | 2 | pub(crate) mod item_type; |
| 3 | 3 | pub(crate) mod renderer; |
| 4 | 4 | |
| 5 | use rustc_hir::def_id::DefId; | |
| 6 | ||
| 7 | 5 | pub(crate) use renderer::{run_format, FormatRenderer}; |
| 6 | use rustc_hir::def_id::DefId; | |
| 8 | 7 | |
| 9 | 8 | use crate::clean::{self, ItemId}; |
| 10 | 9 | use crate::html::render::Context; |
src/librustdoc/html/format.rs+6-10| ... | ... | @@ -12,11 +12,10 @@ use std::cell::Cell; |
| 12 | 12 | use std::fmt::{self, Display, Write}; |
| 13 | 13 | use std::iter::{self, once}; |
| 14 | 14 | |
| 15 | use rustc_ast as ast; | |
| 15 | use itertools::Itertools; | |
| 16 | 16 | use rustc_attr::{ConstStability, StabilityLevel, StableSince}; |
| 17 | 17 | use rustc_data_structures::captures::Captures; |
| 18 | 18 | use rustc_data_structures::fx::FxHashSet; |
| 19 | use rustc_hir as hir; | |
| 20 | 19 | use rustc_hir::def::DefKind; |
| 21 | 20 | use rustc_hir::def_id::{DefId, LOCAL_CRATE}; |
| 22 | 21 | use rustc_metadata::creader::{CStore, LoadedMacro}; |
| ... | ... | @@ -25,21 +24,18 @@ use rustc_middle::ty::TyCtxt; |
| 25 | 24 | use rustc_span::symbol::kw; |
| 26 | 25 | use rustc_span::{sym, Symbol}; |
| 27 | 26 | use rustc_target::spec::abi::Abi; |
| 27 | use {rustc_ast as ast, rustc_hir as hir}; | |
| 28 | 28 | |
| 29 | use itertools::Itertools; | |
| 30 | ||
| 31 | use crate::clean::{ | |
| 32 | self, types::ExternalLocation, utils::find_nearest_parent_module, ExternalCrate, PrimitiveType, | |
| 33 | }; | |
| 29 | use super::url_parts_builder::{estimate_item_path_byte_length, UrlPartsBuilder}; | |
| 30 | use crate::clean::types::ExternalLocation; | |
| 31 | use crate::clean::utils::find_nearest_parent_module; | |
| 32 | use crate::clean::{self, ExternalCrate, PrimitiveType}; | |
| 34 | 33 | use crate::formats::cache::Cache; |
| 35 | 34 | use crate::formats::item_type::ItemType; |
| 36 | 35 | use crate::html::escape::Escape; |
| 37 | 36 | use crate::html::render::Context; |
| 38 | 37 | use crate::passes::collect_intra_doc_links::UrlFragment; |
| 39 | 38 | |
| 40 | use super::url_parts_builder::estimate_item_path_byte_length; | |
| 41 | use super::url_parts_builder::UrlPartsBuilder; | |
| 42 | ||
| 43 | 39 | pub(crate) trait Print { |
| 44 | 40 | fn print(self, buffer: &mut Buffer); |
| 45 | 41 | } |
src/librustdoc/html/highlight.rs+3-4| ... | ... | @@ -5,10 +5,6 @@ |
| 5 | 5 | //! |
| 6 | 6 | //! Use the `render_with_highlighting` to highlight some rust code. |
| 7 | 7 | |
| 8 | use crate::clean::PrimitiveType; | |
| 9 | use crate::html::escape::EscapeBodyText; | |
| 10 | use crate::html::render::{Context, LinkFromSrc}; | |
| 11 | ||
| 12 | 8 | use std::collections::VecDeque; |
| 13 | 9 | use std::fmt::{Display, Write}; |
| 14 | 10 | |
| ... | ... | @@ -19,6 +15,9 @@ use rustc_span::symbol::Symbol; |
| 19 | 15 | use rustc_span::{BytePos, Span, DUMMY_SP}; |
| 20 | 16 | |
| 21 | 17 | use super::format::{self, Buffer}; |
| 18 | use crate::clean::PrimitiveType; | |
| 19 | use crate::html::escape::EscapeBodyText; | |
| 20 | use crate::html::render::{Context, LinkFromSrc}; | |
| 22 | 21 | |
| 23 | 22 | /// This type is needed in case we want to render links on items to allow to go to their definition. |
| 24 | 23 | pub(crate) struct HrefContext<'a, 'tcx> { |
src/librustdoc/html/highlight/tests.rs+3-2| ... | ... | @@ -1,9 +1,10 @@ |
| 1 | use super::{write_code, DecorationInfo}; | |
| 2 | use crate::html::format::Buffer; | |
| 3 | 1 | use expect_test::expect_file; |
| 4 | 2 | use rustc_data_structures::fx::FxHashMap; |
| 5 | 3 | use rustc_span::create_default_session_globals_then; |
| 6 | 4 | |
| 5 | use super::{write_code, DecorationInfo}; | |
| 6 | use crate::html::format::Buffer; | |
| 7 | ||
| 7 | 8 | const STYLE: &str = r#" |
| 8 | 9 | <style> |
| 9 | 10 | .kw { color: #8959A8; } |
src/librustdoc/html/layout.rs+2-4| ... | ... | @@ -1,15 +1,13 @@ |
| 1 | 1 | use std::path::PathBuf; |
| 2 | 2 | |
| 3 | use rinja::Template; | |
| 3 | 4 | use rustc_data_structures::fx::FxHashMap; |
| 4 | 5 | |
| 6 | use super::static_files::{StaticFiles, STATIC_FILES}; | |
| 5 | 7 | use crate::externalfiles::ExternalHtml; |
| 6 | 8 | use crate::html::format::{Buffer, Print}; |
| 7 | 9 | use crate::html::render::{ensure_trailing_slash, StylePath}; |
| 8 | 10 | |
| 9 | use rinja::Template; | |
| 10 | ||
| 11 | use super::static_files::{StaticFiles, STATIC_FILES}; | |
| 12 | ||
| 13 | 11 | #[derive(Clone)] |
| 14 | 12 | pub(crate) struct Layout { |
| 15 | 13 | pub(crate) logo: String, |
src/librustdoc/html/markdown.rs+13-14| ... | ... | @@ -25,15 +25,6 @@ |
| 25 | 25 | //! // ... something using html |
| 26 | 26 | //! ``` |
| 27 | 27 | |
| 28 | use rustc_data_structures::fx::FxHashMap; | |
| 29 | use rustc_errors::{Diag, DiagMessage}; | |
| 30 | use rustc_hir::def_id::DefId; | |
| 31 | use rustc_middle::ty::TyCtxt; | |
| 32 | pub(crate) use rustc_resolve::rustdoc::main_body_opts; | |
| 33 | use rustc_resolve::rustdoc::may_be_doc_link; | |
| 34 | use rustc_span::edition::Edition; | |
| 35 | use rustc_span::{Span, Symbol}; | |
| 36 | ||
| 37 | 28 | use std::borrow::Cow; |
| 38 | 29 | use std::collections::VecDeque; |
| 39 | 30 | use std::fmt::Write; |
| ... | ... | @@ -43,6 +34,19 @@ use std::path::PathBuf; |
| 43 | 34 | use std::str::{self, CharIndices}; |
| 44 | 35 | use std::sync::OnceLock; |
| 45 | 36 | |
| 37 | use pulldown_cmark::{ | |
| 38 | html, BrokenLink, BrokenLinkCallback, CodeBlockKind, CowStr, Event, LinkType, OffsetIter, | |
| 39 | Options, Parser, Tag, TagEnd, | |
| 40 | }; | |
| 41 | use rustc_data_structures::fx::FxHashMap; | |
| 42 | use rustc_errors::{Diag, DiagMessage}; | |
| 43 | use rustc_hir::def_id::DefId; | |
| 44 | use rustc_middle::ty::TyCtxt; | |
| 45 | pub(crate) use rustc_resolve::rustdoc::main_body_opts; | |
| 46 | use rustc_resolve::rustdoc::may_be_doc_link; | |
| 47 | use rustc_span::edition::Edition; | |
| 48 | use rustc_span::{Span, Symbol}; | |
| 49 | ||
| 46 | 50 | use crate::clean::RenderedLink; |
| 47 | 51 | use crate::doctest; |
| 48 | 52 | use crate::doctest::GlobalTestOptions; |
| ... | ... | @@ -53,11 +57,6 @@ use crate::html::length_limit::HtmlWithLimit; |
| 53 | 57 | use crate::html::render::small_url_encode; |
| 54 | 58 | use crate::html::toc::TocBuilder; |
| 55 | 59 | |
| 56 | use pulldown_cmark::{ | |
| 57 | html, BrokenLink, BrokenLinkCallback, CodeBlockKind, CowStr, Event, LinkType, OffsetIter, | |
| 58 | Options, Parser, Tag, TagEnd, | |
| 59 | }; | |
| 60 | ||
| 61 | 60 | #[cfg(test)] |
| 62 | 61 | mod tests; |
| 63 | 62 |
src/librustdoc/html/markdown/tests.rs+4-4| ... | ... | @@ -1,9 +1,9 @@ |
| 1 | use super::{find_testable_code, plain_text_summary, short_markdown_summary}; | |
| 1 | use rustc_span::edition::{Edition, DEFAULT_EDITION}; | |
| 2 | ||
| 2 | 3 | use super::{ |
| 3 | ErrorCodes, HeadingOffset, IdMap, Ignore, LangString, LangStringToken, Markdown, | |
| 4 | MarkdownItemInfo, TagIterator, | |
| 4 | find_testable_code, plain_text_summary, short_markdown_summary, ErrorCodes, HeadingOffset, | |
| 5 | IdMap, Ignore, LangString, LangStringToken, Markdown, MarkdownItemInfo, TagIterator, | |
| 5 | 6 | }; |
| 6 | use rustc_span::edition::{Edition, DEFAULT_EDITION}; | |
| 7 | 7 | |
| 8 | 8 | #[test] |
| 9 | 9 | fn test_unique_id() { |
src/librustdoc/html/render/context.rs+5-8| ... | ... | @@ -5,6 +5,7 @@ use std::path::{Path, PathBuf}; |
| 5 | 5 | use std::rc::Rc; |
| 6 | 6 | use std::sync::mpsc::{channel, Receiver}; |
| 7 | 7 | |
| 8 | use rinja::Template; | |
| 8 | 9 | use rustc_data_structures::fx::{FxHashMap, FxHashSet}; |
| 9 | 10 | use rustc_hir::def_id::{DefIdMap, LOCAL_CRATE}; |
| 10 | 11 | use rustc_middle::ty::TyCtxt; |
| ... | ... | @@ -14,15 +15,12 @@ use rustc_span::{sym, FileName, Symbol}; |
| 14 | 15 | |
| 15 | 16 | use super::print_item::{full_path, item_path, print_item}; |
| 16 | 17 | use super::search_index::build_index; |
| 18 | use super::sidebar::{print_sidebar, sidebar_module_like, Sidebar}; | |
| 17 | 19 | use super::write_shared::write_shared; |
| 18 | use super::{ | |
| 19 | collect_spans_and_sources, scrape_examples_help, | |
| 20 | sidebar::print_sidebar, | |
| 21 | sidebar::{sidebar_module_like, Sidebar}, | |
| 22 | AllTypes, LinkFromSrc, StylePath, | |
| 23 | }; | |
| 20 | use super::{collect_spans_and_sources, scrape_examples_help, AllTypes, LinkFromSrc, StylePath}; | |
| 21 | use crate::clean::types::ExternalLocation; | |
| 24 | 22 | use crate::clean::utils::has_doc_flag; |
| 25 | use crate::clean::{self, types::ExternalLocation, ExternalCrate}; | |
| 23 | use crate::clean::{self, ExternalCrate}; | |
| 26 | 24 | use crate::config::{ModuleSorting, RenderOptions}; |
| 27 | 25 | use crate::docfs::{DocFS, PathError}; |
| 28 | 26 | use crate::error::Error; |
| ... | ... | @@ -36,7 +34,6 @@ use crate::html::url_parts_builder::UrlPartsBuilder; |
| 36 | 34 | use crate::html::{layout, sources, static_files}; |
| 37 | 35 | use crate::scrape_examples::AllCallLocations; |
| 38 | 36 | use crate::try_err; |
| 39 | use rinja::Template; | |
| 40 | 37 | |
| 41 | 38 | /// Major driving force in all rustdoc rendering. This contains information |
| 42 | 39 | /// about where in the tree-like hierarchy rendering is occurring and controls |
src/librustdoc/html/render/mod.rs+7-13| ... | ... | @@ -35,16 +35,12 @@ mod span_map; |
| 35 | 35 | mod type_layout; |
| 36 | 36 | mod write_shared; |
| 37 | 37 | |
| 38 | pub(crate) use self::context::*; | |
| 39 | pub(crate) use self::span_map::{collect_spans_and_sources, LinkFromSrc}; | |
| 40 | ||
| 41 | 38 | use std::collections::VecDeque; |
| 42 | 39 | use std::fmt::{self, Write}; |
| 43 | use std::fs; | |
| 44 | 40 | use std::iter::Peekable; |
| 45 | 41 | use std::path::PathBuf; |
| 46 | 42 | use std::rc::Rc; |
| 47 | use std::str; | |
| 43 | use std::{fs, str}; | |
| 48 | 44 | |
| 49 | 45 | use rinja::Template; |
| 50 | 46 | use rustc_attr::{ConstStability, DeprecatedSince, Deprecation, StabilityLevel, StableSince}; |
| ... | ... | @@ -55,13 +51,13 @@ use rustc_hir::Mutability; |
| 55 | 51 | use rustc_middle::ty::print::PrintTraitRefExt; |
| 56 | 52 | use rustc_middle::ty::{self, TyCtxt}; |
| 57 | 53 | use rustc_session::RustcVersion; |
| 58 | use rustc_span::{ | |
| 59 | symbol::{sym, Symbol}, | |
| 60 | BytePos, FileName, RealFileName, DUMMY_SP, | |
| 61 | }; | |
| 54 | use rustc_span::symbol::{sym, Symbol}; | |
| 55 | use rustc_span::{BytePos, FileName, RealFileName, DUMMY_SP}; | |
| 62 | 56 | use serde::ser::SerializeMap; |
| 63 | 57 | use serde::{Serialize, Serializer}; |
| 64 | 58 | |
| 59 | pub(crate) use self::context::*; | |
| 60 | pub(crate) use self::span_map::{collect_spans_and_sources, LinkFromSrc}; | |
| 65 | 61 | use crate::clean::{self, ItemId, RenderedLink, SelfTy}; |
| 66 | 62 | use crate::error::Error; |
| 67 | 63 | use crate::formats::cache::Cache; |
| ... | ... | @@ -73,15 +69,13 @@ use crate::html::format::{ |
| 73 | 69 | print_default_space, print_generic_bounds, print_where_clause, visibility_print_with_space, |
| 74 | 70 | Buffer, Ending, HrefError, PrintWithSpace, |
| 75 | 71 | }; |
| 76 | use crate::html::highlight; | |
| 77 | 72 | use crate::html::markdown::{ |
| 78 | 73 | HeadingOffset, IdMap, Markdown, MarkdownItemInfo, MarkdownSummaryLine, |
| 79 | 74 | }; |
| 80 | use crate::html::sources; | |
| 81 | 75 | use crate::html::static_files::SCRAPE_EXAMPLES_HELP_MD; |
| 76 | use crate::html::{highlight, sources}; | |
| 82 | 77 | use crate::scrape_examples::{CallData, CallLocation}; |
| 83 | use crate::try_none; | |
| 84 | use crate::DOC_RUST_LANG_ORG_CHANNEL; | |
| 78 | use crate::{try_none, DOC_RUST_LANG_ORG_CHANNEL}; | |
| 85 | 79 | |
| 86 | 80 | pub(crate) fn ensure_trailing_slash(v: &str) -> impl fmt::Display + '_ { |
| 87 | 81 | crate::html::format::display_fn(move |f| { |
src/librustdoc/html/render/print_item.rs+7-7| ... | ... | @@ -1,3 +1,10 @@ |
| 1 | use std::cell::{RefCell, RefMut}; | |
| 2 | use std::cmp::Ordering; | |
| 3 | use std::fmt; | |
| 4 | use std::rc::Rc; | |
| 5 | ||
| 6 | use itertools::Itertools; | |
| 7 | use rinja::Template; | |
| 1 | 8 | use rustc_data_structures::captures::Captures; |
| 2 | 9 | use rustc_data_structures::fx::{FxHashMap, FxHashSet}; |
| 3 | 10 | use rustc_hir as hir; |
| ... | ... | @@ -8,10 +15,6 @@ use rustc_middle::ty::{self, TyCtxt}; |
| 8 | 15 | use rustc_span::hygiene::MacroKind; |
| 9 | 16 | use rustc_span::symbol::{kw, sym, Symbol}; |
| 10 | 17 | use rustc_target::abi::VariantIdx; |
| 11 | use std::cell::{RefCell, RefMut}; | |
| 12 | use std::cmp::Ordering; | |
| 13 | use std::fmt; | |
| 14 | use std::rc::Rc; | |
| 15 | 18 | |
| 16 | 19 | use super::type_layout::document_type_layout; |
| 17 | 20 | use super::{ |
| ... | ... | @@ -36,9 +39,6 @@ use crate::html::markdown::{HeadingOffset, MarkdownSummaryLine}; |
| 36 | 39 | use crate::html::render::{document_full, document_item_info}; |
| 37 | 40 | use crate::html::url_parts_builder::UrlPartsBuilder; |
| 38 | 41 | |
| 39 | use itertools::Itertools; | |
| 40 | use rinja::Template; | |
| 41 | ||
| 42 | 42 | /// Generates a Rinja template struct for rendering items with common methods. |
| 43 | 43 | /// |
| 44 | 44 | /// Usage: |
src/librustdoc/html/render/search_index.rs+1-2| ... | ... | @@ -3,6 +3,7 @@ pub(crate) mod encode; |
| 3 | 3 | use std::collections::hash_map::Entry; |
| 4 | 4 | use std::collections::{BTreeMap, VecDeque}; |
| 5 | 5 | |
| 6 | use encode::{bitmap_to_string, write_vlqhex_to_string}; | |
| 6 | 7 | use rustc_data_structures::fx::{FxHashMap, FxIndexMap}; |
| 7 | 8 | use rustc_middle::ty::TyCtxt; |
| 8 | 9 | use rustc_span::def_id::DefId; |
| ... | ... | @@ -19,8 +20,6 @@ use crate::html::format::join_with_double_colon; |
| 19 | 20 | use crate::html::markdown::short_markdown_summary; |
| 20 | 21 | use crate::html::render::{self, IndexItem, IndexItemFunctionType, RenderType, RenderTypeId}; |
| 21 | 22 | |
| 22 | use encode::{bitmap_to_string, write_vlqhex_to_string}; | |
| 23 | ||
| 24 | 23 | /// The serialized search description sharded version |
| 25 | 24 | /// |
| 26 | 25 | /// The `index` is a JSON-encoded list of names and other information. |
src/librustdoc/html/render/sidebar.rs+9-8| ... | ... | @@ -1,17 +1,18 @@ |
| 1 | use std::{borrow::Cow, rc::Rc}; | |
| 1 | use std::borrow::Cow; | |
| 2 | use std::rc::Rc; | |
| 2 | 3 | |
| 3 | 4 | use rinja::Template; |
| 4 | 5 | use rustc_data_structures::fx::FxHashSet; |
| 5 | use rustc_hir::{def::CtorKind, def_id::DefIdSet}; | |
| 6 | use rustc_hir::def::CtorKind; | |
| 7 | use rustc_hir::def_id::DefIdSet; | |
| 6 | 8 | use rustc_middle::ty::{self, TyCtxt}; |
| 7 | 9 | |
| 8 | use crate::{ | |
| 9 | clean, | |
| 10 | formats::{item_type::ItemType, Impl}, | |
| 11 | html::{format::Buffer, markdown::IdMap}, | |
| 12 | }; | |
| 13 | ||
| 14 | 10 | use super::{item_ty_to_section, Context, ItemSection}; |
| 11 | use crate::clean; | |
| 12 | use crate::formats::item_type::ItemType; | |
| 13 | use crate::formats::Impl; | |
| 14 | use crate::html::format::Buffer; | |
| 15 | use crate::html::markdown::IdMap; | |
| 15 | 16 | |
| 16 | 17 | #[derive(Template)] |
| 17 | 18 | #[template(path = "sidebar.html")] |
src/librustdoc/html/render/span_map.rs+3-3| ... | ... | @@ -1,5 +1,4 @@ |
| 1 | use crate::clean::{self, rustc_span, PrimitiveType}; | |
| 2 | use crate::html::sources; | |
| 1 | use std::path::{Path, PathBuf}; | |
| 3 | 2 | |
| 4 | 3 | use rustc_data_structures::fx::FxHashMap; |
| 5 | 4 | use rustc_hir::def::{DefKind, Res}; |
| ... | ... | @@ -11,7 +10,8 @@ use rustc_middle::ty::TyCtxt; |
| 11 | 10 | use rustc_span::hygiene::MacroKind; |
| 12 | 11 | use rustc_span::{BytePos, ExpnKind, Span}; |
| 13 | 12 | |
| 14 | use std::path::{Path, PathBuf}; | |
| 13 | use crate::clean::{self, rustc_span, PrimitiveType}; | |
| 14 | use crate::html::sources; | |
| 15 | 15 | |
| 16 | 16 | /// This enum allows us to store two different kinds of information: |
| 17 | 17 | /// |
src/librustdoc/html/render/type_layout.rs+4-4| ... | ... | @@ -1,14 +1,14 @@ |
| 1 | use rinja::Template; | |
| 1 | use std::fmt; | |
| 2 | 2 | |
| 3 | use rinja::Template; | |
| 3 | 4 | use rustc_data_structures::captures::Captures; |
| 4 | 5 | use rustc_hir::def_id::DefId; |
| 5 | 6 | use rustc_middle::span_bug; |
| 6 | use rustc_middle::ty::{self, layout::LayoutError}; | |
| 7 | use rustc_middle::ty::layout::LayoutError; | |
| 8 | use rustc_middle::ty::{self}; | |
| 7 | 9 | use rustc_span::symbol::Symbol; |
| 8 | 10 | use rustc_target::abi::{Primitive, TagEncoding, Variants}; |
| 9 | 11 | |
| 10 | use std::fmt; | |
| 11 | ||
| 12 | 12 | use crate::html::format::display_fn; |
| 13 | 13 | use crate::html::render::Context; |
| 14 | 14 |
src/librustdoc/html/sources.rs+13-16| ... | ... | @@ -1,12 +1,9 @@ |
| 1 | use crate::clean; | |
| 2 | use crate::clean::utils::has_doc_flag; | |
| 3 | use crate::docfs::PathError; | |
| 4 | use crate::error::Error; | |
| 5 | use crate::html::format; | |
| 6 | use crate::html::highlight; | |
| 7 | use crate::html::layout; | |
| 8 | use crate::html::render::Context; | |
| 9 | use crate::visit::DocVisitor; | |
| 1 | use std::cell::RefCell; | |
| 2 | use std::ffi::OsStr; | |
| 3 | use std::ops::RangeInclusive; | |
| 4 | use std::path::{Component, Path, PathBuf}; | |
| 5 | use std::rc::Rc; | |
| 6 | use std::{fmt, fs}; | |
| 10 | 7 | |
| 11 | 8 | use rinja::Template; |
| 12 | 9 | use rustc_data_structures::fx::{FxHashMap, FxHashSet}; |
| ... | ... | @@ -15,13 +12,13 @@ use rustc_middle::ty::TyCtxt; |
| 15 | 12 | use rustc_session::Session; |
| 16 | 13 | use rustc_span::{sym, FileName}; |
| 17 | 14 | |
| 18 | use std::cell::RefCell; | |
| 19 | use std::ffi::OsStr; | |
| 20 | use std::fmt; | |
| 21 | use std::fs; | |
| 22 | use std::ops::RangeInclusive; | |
| 23 | use std::path::{Component, Path, PathBuf}; | |
| 24 | use std::rc::Rc; | |
| 15 | use crate::clean; | |
| 16 | use crate::clean::utils::has_doc_flag; | |
| 17 | use crate::docfs::PathError; | |
| 18 | use crate::error::Error; | |
| 19 | use crate::html::render::Context; | |
| 20 | use crate::html::{format, highlight, layout}; | |
| 21 | use crate::visit::DocVisitor; | |
| 25 | 22 | |
| 26 | 23 | pub(crate) fn render(cx: &mut Context<'_>, krate: &clean::Crate) -> Result<(), Error> { |
| 27 | 24 | info!("emitting source files"); |
src/librustdoc/html/static_files.rs+2-1| ... | ... | @@ -3,11 +3,12 @@ |
| 3 | 3 | //! All the static files are included here for centralized access in case anything other than the |
| 4 | 4 | //! HTML rendering code (say, the theme checker) needs to access one of these files. |
| 5 | 5 | |
| 6 | use rustc_data_structures::fx::FxHasher; | |
| 7 | 6 | use std::hash::Hasher; |
| 8 | 7 | use std::path::{Path, PathBuf}; |
| 9 | 8 | use std::{fmt, str}; |
| 10 | 9 | |
| 10 | use rustc_data_structures::fx::FxHasher; | |
| 11 | ||
| 11 | 12 | pub(crate) struct StaticFile { |
| 12 | 13 | pub(crate) filename: PathBuf, |
| 13 | 14 | pub(crate) bytes: &'static [u8], |
src/librustdoc/html/tests.rs+2-1| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | use crate::html::format::href_relative_parts; | |
| 2 | 1 | use rustc_span::{sym, Symbol}; |
| 3 | 2 | |
| 3 | use crate::html::format::href_relative_parts; | |
| 4 | ||
| 4 | 5 | fn assert_relative_path(expected: &[Symbol], relative_to_fqp: &[Symbol], fqp: &[Symbol]) { |
| 5 | 6 | // No `create_default_session_globals_then` call is needed here because all |
| 6 | 7 | // the symbols used are static, and no `Symbol::intern` calls occur. |
src/librustdoc/json/conversions.rs+2-2| ... | ... | @@ -8,14 +8,14 @@ use std::fmt; |
| 8 | 8 | |
| 9 | 9 | use rustc_ast::ast; |
| 10 | 10 | use rustc_attr::DeprecatedSince; |
| 11 | use rustc_hir::{def::CtorKind, def::DefKind, def_id::DefId}; | |
| 11 | use rustc_hir::def::{CtorKind, DefKind}; | |
| 12 | use rustc_hir::def_id::DefId; | |
| 12 | 13 | use rustc_metadata::rendered_const; |
| 13 | 14 | use rustc_middle::bug; |
| 14 | 15 | use rustc_middle::ty::{self, TyCtxt}; |
| 15 | 16 | use rustc_span::symbol::sym; |
| 16 | 17 | use rustc_span::{Pos, Symbol}; |
| 17 | 18 | use rustc_target::spec::abi::Abi as RustcAbi; |
| 18 | ||
| 19 | 19 | use rustdoc_json_types::*; |
| 20 | 20 | |
| 21 | 21 | use crate::clean::{self, ItemId}; |
src/librustdoc/json/import_finder.rs+2-4| ... | ... | @@ -1,9 +1,7 @@ |
| 1 | 1 | use rustc_hir::def_id::DefIdSet; |
| 2 | 2 | |
| 3 | use crate::{ | |
| 4 | clean::{self, Import, ImportSource, Item}, | |
| 5 | fold::DocFolder, | |
| 6 | }; | |
| 3 | use crate::clean::{self, Import, ImportSource, Item}; | |
| 4 | use crate::fold::DocFolder; | |
| 7 | 5 | |
| 8 | 6 | /// Get the id's of all items that are `pub use`d in the crate. |
| 9 | 7 | /// |
src/librustdoc/json/mod.rs-1| ... | ... | @@ -18,7 +18,6 @@ use rustc_hir::def_id::{DefId, DefIdSet}; |
| 18 | 18 | use rustc_middle::ty::TyCtxt; |
| 19 | 19 | use rustc_session::Session; |
| 20 | 20 | use rustc_span::def_id::LOCAL_CRATE; |
| 21 | ||
| 22 | 21 | use rustdoc_json_types as types; |
| 23 | 22 | |
| 24 | 23 | use crate::clean::types::{ExternalCrate, ExternalLocation}; |
src/librustdoc/lib.rs+2-1| ... | ... | @@ -75,7 +75,8 @@ extern crate jemalloc_sys; |
| 75 | 75 | use std::env::{self, VarError}; |
| 76 | 76 | use std::io::{self, IsTerminal}; |
| 77 | 77 | use std::process; |
| 78 | use std::sync::{atomic::AtomicBool, Arc}; | |
| 78 | use std::sync::atomic::AtomicBool; | |
| 79 | use std::sync::Arc; | |
| 79 | 80 | |
| 80 | 81 | use rustc_errors::{DiagCtxtHandle, ErrorGuaranteed, FatalError}; |
| 81 | 82 | use rustc_interface::interface; |
src/librustdoc/lint.rs+2-2| ... | ... | @@ -1,10 +1,10 @@ |
| 1 | use std::sync::LazyLock as Lazy; | |
| 2 | ||
| 1 | 3 | use rustc_data_structures::fx::FxHashMap; |
| 2 | 4 | use rustc_lint::LintStore; |
| 3 | 5 | use rustc_lint_defs::{declare_tool_lint, Lint, LintId}; |
| 4 | 6 | use rustc_session::{lint, Session}; |
| 5 | 7 | |
| 6 | use std::sync::LazyLock as Lazy; | |
| 7 | ||
| 8 | 8 | /// This function is used to setup the lint initialization. By default, in rustdoc, everything |
| 9 | 9 | /// is "allowed". Depending if we run in test mode or not, we want some of them to be at their |
| 10 | 10 | /// default level. For example, the "INVALID_CODEBLOCK_ATTRIBUTES" lint is activated in both |
src/librustdoc/passes/calculate_doc_coverage.rs+9-8| ... | ... | @@ -1,11 +1,8 @@ |
| 1 | 1 | //! Calculates information used for the --show-coverage flag. |
| 2 | 2 | |
| 3 | use crate::clean; | |
| 4 | use crate::core::DocContext; | |
| 5 | use crate::html::markdown::{find_testable_code, ErrorCodes}; | |
| 6 | use crate::passes::check_doc_test_visibility::{should_have_doc_example, Tests}; | |
| 7 | use crate::passes::Pass; | |
| 8 | use crate::visit::DocVisitor; | |
| 3 | use std::collections::BTreeMap; | |
| 4 | use std::ops; | |
| 5 | ||
| 9 | 6 | use rustc_hir as hir; |
| 10 | 7 | use rustc_lint::builtin::MISSING_DOCS; |
| 11 | 8 | use rustc_middle::lint::LintLevelSource; |
| ... | ... | @@ -13,8 +10,12 @@ use rustc_session::lint; |
| 13 | 10 | use rustc_span::FileName; |
| 14 | 11 | use serde::Serialize; |
| 15 | 12 | |
| 16 | use std::collections::BTreeMap; | |
| 17 | use std::ops; | |
| 13 | use crate::clean; | |
| 14 | use crate::core::DocContext; | |
| 15 | use crate::html::markdown::{find_testable_code, ErrorCodes}; | |
| 16 | use crate::passes::check_doc_test_visibility::{should_have_doc_example, Tests}; | |
| 17 | use crate::passes::Pass; | |
| 18 | use crate::visit::DocVisitor; | |
| 18 | 19 | |
| 19 | 20 | pub(crate) const CALCULATE_DOC_COVERAGE: Pass = Pass { |
| 20 | 21 | name: "calculate-doc-coverage", |
src/librustdoc/passes/check_doc_test_visibility.rs+4-3| ... | ... | @@ -5,6 +5,10 @@ |
| 5 | 5 | //! - MISSING_DOC_CODE_EXAMPLES: this lint is **UNSTABLE** and looks for public items missing doctests. |
| 6 | 6 | //! - PRIVATE_DOC_TESTS: this lint is **STABLE** and looks for private items with doctests. |
| 7 | 7 | |
| 8 | use rustc_hir as hir; | |
| 9 | use rustc_middle::lint::LintLevelSource; | |
| 10 | use rustc_session::lint; | |
| 11 | ||
| 8 | 12 | use super::Pass; |
| 9 | 13 | use crate::clean; |
| 10 | 14 | use crate::clean::utils::inherits_doc_hidden; |
| ... | ... | @@ -12,9 +16,6 @@ use crate::clean::*; |
| 12 | 16 | use crate::core::DocContext; |
| 13 | 17 | use crate::html::markdown::{find_testable_code, ErrorCodes, Ignore, LangString, MdRelLine}; |
| 14 | 18 | use crate::visit::DocVisitor; |
| 15 | use rustc_hir as hir; | |
| 16 | use rustc_middle::lint::LintLevelSource; | |
| 17 | use rustc_session::lint; | |
| 18 | 19 | |
| 19 | 20 | pub(crate) const CHECK_DOC_TEST_VISIBILITY: Pass = Pass { |
| 20 | 21 | name: "check_doc_test_visibility", |
src/librustdoc/passes/collect_intra_doc_links.rs+11-13| ... | ... | @@ -2,12 +2,15 @@ |
| 2 | 2 | //! |
| 3 | 3 | //! [RFC 1946]: https://github.com/rust-lang/rfcs/blob/master/text/1946-intra-rustdoc-links.md |
| 4 | 4 | |
| 5 | use std::borrow::Cow; | |
| 6 | use std::fmt::Display; | |
| 7 | use std::mem; | |
| 8 | use std::ops::Range; | |
| 9 | ||
| 5 | 10 | use pulldown_cmark::LinkType; |
| 6 | 11 | use rustc_ast::util::comments::may_have_doc_links; |
| 7 | use rustc_data_structures::{ | |
| 8 | fx::{FxHashMap, FxHashSet}, | |
| 9 | intern::Interned, | |
| 10 | }; | |
| 12 | use rustc_data_structures::fx::{FxHashMap, FxHashSet}; | |
| 13 | use rustc_data_structures::intern::Interned; | |
| 11 | 14 | use rustc_errors::{Applicability, Diag, DiagMessage}; |
| 12 | 15 | use rustc_hir::def::Namespace::*; |
| 13 | 16 | use rustc_hir::def::{DefKind, Namespace, PerNS}; |
| ... | ... | @@ -15,9 +18,9 @@ use rustc_hir::def_id::{DefId, CRATE_DEF_ID}; |
| 15 | 18 | use rustc_hir::{Mutability, Safety}; |
| 16 | 19 | use rustc_middle::ty::{Ty, TyCtxt}; |
| 17 | 20 | use rustc_middle::{bug, span_bug, ty}; |
| 18 | use rustc_resolve::rustdoc::{has_primitive_or_keyword_docs, prepare_to_doc_link_resolution}; | |
| 19 | 21 | use rustc_resolve::rustdoc::{ |
| 20 | source_span_for_markdown_range, strip_generics_from_path, MalformedGenerics, | |
| 22 | has_primitive_or_keyword_docs, prepare_to_doc_link_resolution, source_span_for_markdown_range, | |
| 23 | strip_generics_from_path, MalformedGenerics, | |
| 21 | 24 | }; |
| 22 | 25 | use rustc_session::lint::Lint; |
| 23 | 26 | use rustc_span::hygiene::MacroKind; |
| ... | ... | @@ -25,13 +28,8 @@ use rustc_span::symbol::{sym, Ident, Symbol}; |
| 25 | 28 | use rustc_span::BytePos; |
| 26 | 29 | use smallvec::{smallvec, SmallVec}; |
| 27 | 30 | |
| 28 | use std::borrow::Cow; | |
| 29 | use std::fmt::Display; | |
| 30 | use std::mem; | |
| 31 | use std::ops::Range; | |
| 32 | ||
| 33 | use crate::clean::{self, utils::find_nearest_parent_module}; | |
| 34 | use crate::clean::{Crate, Item, ItemLink, PrimitiveType}; | |
| 31 | use crate::clean::utils::find_nearest_parent_module; | |
| 32 | use crate::clean::{self, Crate, Item, ItemLink, PrimitiveType}; | |
| 35 | 33 | use crate::core::DocContext; |
| 36 | 34 | use crate::html::markdown::{markdown_links, MarkdownLink, MarkdownLinkRange}; |
| 37 | 35 | use crate::lint::{BROKEN_INTRA_DOC_LINKS, PRIVATE_INTRA_DOC_LINKS}; |
src/librustdoc/passes/collect_trait_impls.rs+5-5| ... | ... | @@ -2,17 +2,17 @@ |
| 2 | 2 | //! defines a struct that implements a trait, this pass will note that the |
| 3 | 3 | //! struct implements that trait. |
| 4 | 4 | |
| 5 | use rustc_data_structures::fx::FxHashSet; | |
| 6 | use rustc_hir::def_id::{DefId, DefIdMap, DefIdSet, LOCAL_CRATE}; | |
| 7 | use rustc_middle::ty; | |
| 8 | use rustc_span::symbol::sym; | |
| 9 | ||
| 5 | 10 | use super::Pass; |
| 6 | 11 | use crate::clean::*; |
| 7 | 12 | use crate::core::DocContext; |
| 8 | 13 | use crate::formats::cache::Cache; |
| 9 | 14 | use crate::visit::DocVisitor; |
| 10 | 15 | |
| 11 | use rustc_data_structures::fx::FxHashSet; | |
| 12 | use rustc_hir::def_id::{DefId, DefIdMap, DefIdSet, LOCAL_CRATE}; | |
| 13 | use rustc_middle::ty; | |
| 14 | use rustc_span::symbol::sym; | |
| 15 | ||
| 16 | 16 | pub(crate) const COLLECT_TRAIT_IMPLS: Pass = Pass { |
| 17 | 17 | name: "collect-trait-impls", |
| 18 | 18 | run: collect_trait_impls, |
src/librustdoc/passes/lint/bare_urls.rs+7-5| ... | ... | @@ -1,16 +1,18 @@ |
| 1 | 1 | //! Detects links that are not linkified, e.g., in Markdown such as `Go to https://example.com/.` |
| 2 | 2 | //! Suggests wrapping the link with angle brackets: `Go to <https://example.com/>.` to linkify it. |
| 3 | 3 | |
| 4 | use crate::clean::*; | |
| 5 | use crate::core::DocContext; | |
| 6 | use crate::html::markdown::main_body_opts; | |
| 7 | 4 | use core::ops::Range; |
| 5 | use std::mem; | |
| 6 | use std::sync::LazyLock; | |
| 7 | ||
| 8 | 8 | use pulldown_cmark::{Event, Parser, Tag}; |
| 9 | 9 | use regex::Regex; |
| 10 | 10 | use rustc_errors::Applicability; |
| 11 | 11 | use rustc_resolve::rustdoc::source_span_for_markdown_range; |
| 12 | use std::mem; | |
| 13 | use std::sync::LazyLock; | |
| 12 | ||
| 13 | use crate::clean::*; | |
| 14 | use crate::core::DocContext; | |
| 15 | use crate::html::markdown::main_body_opts; | |
| 14 | 16 | |
| 15 | 17 | pub(super) fn visit_item(cx: &DocContext<'_>, item: &Item) { |
| 16 | 18 | let Some(hir_id) = DocContext::as_local_hir_id(cx.tcx, item.item_id) else { |
src/librustdoc/passes/lint/check_code_block_syntax.rs+3-5| ... | ... | @@ -1,11 +1,9 @@ |
| 1 | 1 | //! Validates syntax inside Rust code blocks (\`\`\`rust). |
| 2 | 2 | |
| 3 | 3 | use rustc_data_structures::sync::{Lock, Lrc}; |
| 4 | use rustc_errors::{ | |
| 5 | emitter::Emitter, | |
| 6 | translation::{to_fluent_args, Translate}, | |
| 7 | Applicability, DiagCtxt, DiagInner, LazyFallbackBundle, | |
| 8 | }; | |
| 4 | use rustc_errors::emitter::Emitter; | |
| 5 | use rustc_errors::translation::{to_fluent_args, Translate}; | |
| 6 | use rustc_errors::{Applicability, DiagCtxt, DiagInner, LazyFallbackBundle}; | |
| 9 | 7 | use rustc_parse::{source_str_to_stream, unwrap_or_emit_fatal}; |
| 10 | 8 | use rustc_resolve::rustdoc::source_span_for_markdown_range; |
| 11 | 9 | use rustc_session::parse::ParseSess; |
src/librustdoc/passes/lint/html_tags.rs+6-6| ... | ... | @@ -1,15 +1,15 @@ |
| 1 | 1 | //! Detects invalid HTML (like an unclosed `<span>`) in doc comments. |
| 2 | 2 | |
| 3 | use crate::clean::*; | |
| 4 | use crate::core::DocContext; | |
| 5 | use crate::html::markdown::main_body_opts; | |
| 3 | use std::iter::Peekable; | |
| 4 | use std::ops::Range; | |
| 5 | use std::str::CharIndices; | |
| 6 | 6 | |
| 7 | 7 | use pulldown_cmark::{BrokenLink, Event, LinkType, Parser, Tag, TagEnd}; |
| 8 | 8 | use rustc_resolve::rustdoc::source_span_for_markdown_range; |
| 9 | 9 | |
| 10 | use std::iter::Peekable; | |
| 11 | use std::ops::Range; | |
| 12 | use std::str::CharIndices; | |
| 10 | use crate::clean::*; | |
| 11 | use crate::core::DocContext; | |
| 12 | use crate::html::markdown::main_body_opts; | |
| 13 | 13 | |
| 14 | 14 | pub(crate) fn visit_item(cx: &DocContext<'_>, item: &Item) { |
| 15 | 15 | let tcx = cx.tcx; |
src/librustdoc/passes/lint/redundant_explicit_links.rs+1-2| ... | ... | @@ -12,8 +12,7 @@ use rustc_resolve::rustdoc::{prepare_to_doc_link_resolution, source_span_for_mar |
| 12 | 12 | use rustc_span::def_id::DefId; |
| 13 | 13 | use rustc_span::Symbol; |
| 14 | 14 | |
| 15 | use crate::clean::utils::find_nearest_parent_module; | |
| 16 | use crate::clean::utils::inherits_doc_hidden; | |
| 15 | use crate::clean::utils::{find_nearest_parent_module, inherits_doc_hidden}; | |
| 17 | 16 | use crate::clean::Item; |
| 18 | 17 | use crate::core::DocContext; |
| 19 | 18 | use crate::html::markdown::main_body_opts; |
src/librustdoc/passes/lint/unescaped_backticks.rs+6-4| ... | ... | @@ -1,13 +1,15 @@ |
| 1 | 1 | //! Detects unescaped backticks (\`) in doc comments. |
| 2 | 2 | |
| 3 | use crate::clean::Item; | |
| 4 | use crate::core::DocContext; | |
| 5 | use crate::html::markdown::main_body_opts; | |
| 3 | use std::ops::Range; | |
| 4 | ||
| 6 | 5 | use pulldown_cmark::{BrokenLink, Event, Parser}; |
| 7 | 6 | use rustc_errors::Diag; |
| 8 | 7 | use rustc_lint_defs::Applicability; |
| 9 | 8 | use rustc_resolve::rustdoc::source_span_for_markdown_range; |
| 10 | use std::ops::Range; | |
| 9 | ||
| 10 | use crate::clean::Item; | |
| 11 | use crate::core::DocContext; | |
| 12 | use crate::html::markdown::main_body_opts; | |
| 11 | 13 | |
| 12 | 14 | pub(crate) fn visit_item(cx: &DocContext<'_>, item: &Item) { |
| 13 | 15 | let tcx = cx.tcx; |
src/librustdoc/passes/lint/unportable_markdown.rs+6-5| ... | ... | @@ -10,13 +10,14 @@ |
| 10 | 10 | //! |
| 11 | 11 | //! <https://rustc-dev-guide.rust-lang.org/bug-fix-procedure.html#add-the-lint-to-the-list-of-removed-lists> |
| 12 | 12 | |
| 13 | use crate::clean::Item; | |
| 14 | use crate::core::DocContext; | |
| 15 | use pulldown_cmark as cmarkn; | |
| 16 | use pulldown_cmark_old as cmarko; | |
| 13 | use std::collections::{BTreeMap, BTreeSet}; | |
| 14 | ||
| 17 | 15 | use rustc_lint_defs::Applicability; |
| 18 | 16 | use rustc_resolve::rustdoc::source_span_for_markdown_range; |
| 19 | use std::collections::{BTreeMap, BTreeSet}; | |
| 17 | use {pulldown_cmark as cmarkn, pulldown_cmark_old as cmarko}; | |
| 18 | ||
| 19 | use crate::clean::Item; | |
| 20 | use crate::core::DocContext; | |
| 20 | 21 | |
| 21 | 22 | pub(crate) fn visit_item(cx: &DocContext<'_>, item: &Item) { |
| 22 | 23 | let tcx = cx.tcx; |
src/librustdoc/passes/propagate_doc_cfg.rs+2-2| ... | ... | @@ -2,6 +2,8 @@ |
| 2 | 2 | |
| 3 | 3 | use std::sync::Arc; |
| 4 | 4 | |
| 5 | use rustc_hir::def_id::LocalDefId; | |
| 6 | ||
| 5 | 7 | use crate::clean::cfg::Cfg; |
| 6 | 8 | use crate::clean::inline::{load_attrs, merge_attrs}; |
| 7 | 9 | use crate::clean::{Crate, Item, ItemKind}; |
| ... | ... | @@ -9,8 +11,6 @@ use crate::core::DocContext; |
| 9 | 11 | use crate::fold::DocFolder; |
| 10 | 12 | use crate::passes::Pass; |
| 11 | 13 | |
| 12 | use rustc_hir::def_id::LocalDefId; | |
| 13 | ||
| 14 | 14 | pub(crate) const PROPAGATE_DOC_CFG: Pass = Pass { |
| 15 | 15 | name: "propagate-doc-cfg", |
| 16 | 16 | run: propagate_doc_cfg, |
src/librustdoc/passes/strip_aliased_non_local.rs+1-2| ... | ... | @@ -1,5 +1,4 @@ |
| 1 | use rustc_middle::ty::TyCtxt; | |
| 2 | use rustc_middle::ty::Visibility; | |
| 1 | use rustc_middle::ty::{TyCtxt, Visibility}; | |
| 3 | 2 | |
| 4 | 3 | use crate::clean; |
| 5 | 4 | use crate::clean::Item; |
src/librustdoc/passes/strip_hidden.rs+2-1| ... | ... | @@ -1,9 +1,10 @@ |
| 1 | 1 | //! Strip all doc(hidden) items from the output. |
| 2 | 2 | |
| 3 | use std::mem; | |
| 4 | ||
| 3 | 5 | use rustc_hir::def_id::LocalDefId; |
| 4 | 6 | use rustc_middle::ty::TyCtxt; |
| 5 | 7 | use rustc_span::symbol::sym; |
| 6 | use std::mem; | |
| 7 | 8 | |
| 8 | 9 | use crate::clean; |
| 9 | 10 | use crate::clean::utils::inherits_doc_hidden; |
src/librustdoc/passes/stripper.rs+2-1| ... | ... | @@ -1,8 +1,9 @@ |
| 1 | 1 | //! A collection of utility functions for the `strip_*` passes. |
| 2 | 2 | |
| 3 | use std::mem; | |
| 4 | ||
| 3 | 5 | use rustc_hir::def_id::DefId; |
| 4 | 6 | use rustc_middle::ty::{TyCtxt, Visibility}; |
| 5 | use std::mem; | |
| 6 | 7 | |
| 7 | 8 | use crate::clean::utils::inherits_doc_hidden; |
| 8 | 9 | use crate::clean::{self, Item, ItemId, ItemIdSet}; |
src/librustdoc/scrape_examples.rs+12-20| ... | ... | @@ -1,35 +1,27 @@ |
| 1 | 1 | //! This module analyzes crates to find call sites that can serve as examples in the documentation. |
| 2 | 2 | |
| 3 | use crate::clean; | |
| 4 | use crate::config; | |
| 5 | use crate::formats; | |
| 6 | use crate::formats::renderer::FormatRenderer; | |
| 7 | use crate::html::render::Context; | |
| 3 | use std::fs; | |
| 4 | use std::path::PathBuf; | |
| 8 | 5 | |
| 9 | 6 | use rustc_data_structures::fx::FxHashMap; |
| 10 | 7 | use rustc_errors::DiagCtxtHandle; |
| 11 | use rustc_hir::{ | |
| 12 | self as hir, | |
| 13 | intravisit::{self, Visitor}, | |
| 14 | }; | |
| 8 | use rustc_hir::intravisit::{self, Visitor}; | |
| 9 | use rustc_hir::{self as hir}; | |
| 15 | 10 | use rustc_interface::interface; |
| 16 | 11 | use rustc_macros::{Decodable, Encodable}; |
| 17 | 12 | use rustc_middle::hir::map::Map; |
| 18 | 13 | use rustc_middle::hir::nested_filter; |
| 19 | 14 | use rustc_middle::ty::{self, TyCtxt}; |
| 20 | use rustc_serialize::{ | |
| 21 | opaque::{FileEncoder, MemDecoder}, | |
| 22 | Decodable, Encodable, | |
| 23 | }; | |
| 15 | use rustc_serialize::opaque::{FileEncoder, MemDecoder}; | |
| 16 | use rustc_serialize::{Decodable, Encodable}; | |
| 24 | 17 | use rustc_session::getopts; |
| 25 | use rustc_span::{ | |
| 26 | def_id::{CrateNum, DefPathHash, LOCAL_CRATE}, | |
| 27 | edition::Edition, | |
| 28 | BytePos, FileName, SourceFile, | |
| 29 | }; | |
| 18 | use rustc_span::def_id::{CrateNum, DefPathHash, LOCAL_CRATE}; | |
| 19 | use rustc_span::edition::Edition; | |
| 20 | use rustc_span::{BytePos, FileName, SourceFile}; | |
| 30 | 21 | |
| 31 | use std::fs; | |
| 32 | use std::path::PathBuf; | |
| 22 | use crate::formats::renderer::FormatRenderer; | |
| 23 | use crate::html::render::Context; | |
| 24 | use crate::{clean, config, formats}; | |
| 33 | 25 | |
| 34 | 26 | #[derive(Debug, Clone)] |
| 35 | 27 | pub(crate) struct ScrapeExamplesOptions { |
src/librustdoc/theme.rs+1-1| ... | ... | @@ -1,10 +1,10 @@ |
| 1 | use rustc_data_structures::fx::FxHashMap; | |
| 2 | 1 | use std::collections::hash_map::Entry; |
| 3 | 2 | use std::fs; |
| 4 | 3 | use std::iter::Peekable; |
| 5 | 4 | use std::path::Path; |
| 6 | 5 | use std::str::Chars; |
| 7 | 6 | |
| 7 | use rustc_data_structures::fx::FxHashMap; | |
| 8 | 8 | use rustc_errors::DiagCtxtHandle; |
| 9 | 9 | |
| 10 | 10 | #[cfg(test)] |
src/librustdoc/visit_ast.rs+4-3| ... | ... | @@ -1,6 +1,8 @@ |
| 1 | 1 | //! The Rust AST Visitor. Extracts useful information and massages it into a form |
| 2 | 2 | //! usable for `clean`. |
| 3 | 3 | |
| 4 | use std::mem; | |
| 5 | ||
| 4 | 6 | use rustc_data_structures::fx::{FxHashSet, FxIndexMap}; |
| 5 | 7 | use rustc_hir as hir; |
| 6 | 8 | use rustc_hir::def::{DefKind, Res}; |
| ... | ... | @@ -14,10 +16,9 @@ use rustc_span::hygiene::MacroKind; |
| 14 | 16 | use rustc_span::symbol::{kw, sym, Symbol}; |
| 15 | 17 | use rustc_span::Span; |
| 16 | 18 | |
| 17 | use std::mem; | |
| 18 | ||
| 19 | use crate::clean::cfg::Cfg; | |
| 19 | 20 | use crate::clean::utils::{inherits_doc_hidden, should_ignore_res}; |
| 20 | use crate::clean::{cfg::Cfg, reexport_chain, AttributesExt, NestedAttributesExt}; | |
| 21 | use crate::clean::{reexport_chain, AttributesExt, NestedAttributesExt}; | |
| 21 | 22 | use crate::core; |
| 22 | 23 | |
| 23 | 24 | /// This module is used to store stuff from Rust's AST in a more convenient |
src/librustdoc/visit_lib.rs+2-1| ... | ... | @@ -1,8 +1,9 @@ |
| 1 | use crate::core::DocContext; | |
| 2 | 1 | use rustc_hir::def::DefKind; |
| 3 | 2 | use rustc_hir::def_id::{DefId, DefIdSet}; |
| 4 | 3 | use rustc_middle::ty::TyCtxt; |
| 5 | 4 | |
| 5 | use crate::core::DocContext; | |
| 6 | ||
| 6 | 7 | // FIXME: this may not be exhaustive, but is sufficient for rustdocs current uses |
| 7 | 8 | |
| 8 | 9 | #[derive(Default)] |
src/rustdoc-json-types/lib.rs+2-1| ... | ... | @@ -3,9 +3,10 @@ |
| 3 | 3 | //! These types are the public API exposed through the `--output-format json` flag. The [`Crate`] |
| 4 | 4 | //! struct is the root of the JSON blob and all other items are contained within. |
| 5 | 5 | |
| 6 | use std::path::PathBuf; | |
| 7 | ||
| 6 | 8 | use rustc_hash::FxHashMap; |
| 7 | 9 | use serde::{Deserialize, Serialize}; |
| 8 | use std::path::PathBuf; | |
| 9 | 10 | |
| 10 | 11 | /// rustdoc format-version. |
| 11 | 12 | pub const FORMAT_VERSION: u32 = 32; |
src/tools/build-manifest/src/checksum.rs+5-3| ... | ... | @@ -1,6 +1,3 @@ |
| 1 | use crate::manifest::{FileHash, Manifest}; | |
| 2 | use rayon::prelude::*; | |
| 3 | use sha2::{Digest, Sha256}; | |
| 4 | 1 | use std::collections::{HashMap, HashSet}; |
| 5 | 2 | use std::error::Error; |
| 6 | 3 | use std::fs::File; |
| ... | ... | @@ -9,6 +6,11 @@ use std::path::{Path, PathBuf}; |
| 9 | 6 | use std::sync::Mutex; |
| 10 | 7 | use std::time::Instant; |
| 11 | 8 | |
| 9 | use rayon::prelude::*; | |
| 10 | use sha2::{Digest, Sha256}; | |
| 11 | ||
| 12 | use crate::manifest::{FileHash, Manifest}; | |
| 13 | ||
| 12 | 14 | pub(crate) struct Checksums { |
| 13 | 15 | cache_path: Option<PathBuf>, |
| 14 | 16 | collected: Mutex<HashMap<PathBuf, String>>, |
src/tools/build-manifest/src/main.rs+4-4| ... | ... | @@ -4,13 +4,13 @@ mod checksum; |
| 4 | 4 | mod manifest; |
| 5 | 5 | mod versions; |
| 6 | 6 | |
| 7 | use std::collections::{BTreeMap, HashSet}; | |
| 8 | use std::path::{Path, PathBuf}; | |
| 9 | use std::{env, fs}; | |
| 10 | ||
| 7 | 11 | use crate::checksum::Checksums; |
| 8 | 12 | use crate::manifest::{Component, Manifest, Package, Rename, Target}; |
| 9 | 13 | use crate::versions::{PkgType, Versions}; |
| 10 | use std::collections::{BTreeMap, HashSet}; | |
| 11 | use std::env; | |
| 12 | use std::fs; | |
| 13 | use std::path::{Path, PathBuf}; | |
| 14 | 14 | |
| 15 | 15 | static HOSTS: &[&str] = &[ |
| 16 | 16 | "aarch64-apple-darwin", |
src/tools/build-manifest/src/manifest.rs+5-3| ... | ... | @@ -1,9 +1,11 @@ |
| 1 | use crate::versions::PkgType; | |
| 2 | use crate::Builder; | |
| 3 | use serde::{Serialize, Serializer}; | |
| 4 | 1 | use std::collections::BTreeMap; |
| 5 | 2 | use std::path::{Path, PathBuf}; |
| 6 | 3 | |
| 4 | use serde::{Serialize, Serializer}; | |
| 5 | ||
| 6 | use crate::versions::PkgType; | |
| 7 | use crate::Builder; | |
| 8 | ||
| 7 | 9 | #[derive(Serialize)] |
| 8 | 10 | #[serde(rename_all = "kebab-case")] |
| 9 | 11 | pub(crate) struct Manifest { |
src/tools/build-manifest/src/versions.rs+5-3| ... | ... | @@ -1,9 +1,10 @@ |
| 1 | use anyhow::Error; | |
| 2 | use flate2::read::GzDecoder; | |
| 3 | 1 | use std::collections::HashMap; |
| 4 | 2 | use std::fs::File; |
| 5 | 3 | use std::io::Read; |
| 6 | 4 | use std::path::{Path, PathBuf}; |
| 5 | ||
| 6 | use anyhow::Error; | |
| 7 | use flate2::read::GzDecoder; | |
| 7 | 8 | use tar::Archive; |
| 8 | 9 | use xz2::read::XzDecoder; |
| 9 | 10 | |
| ... | ... | @@ -100,9 +101,10 @@ impl PkgType { |
| 100 | 101 | } |
| 101 | 102 | |
| 102 | 103 | pub(crate) fn targets(&self) -> &[&str] { |
| 103 | use crate::{HOSTS, MINGW, TARGETS}; | |
| 104 | 104 | use PkgType::*; |
| 105 | 105 | |
| 106 | use crate::{HOSTS, MINGW, TARGETS}; | |
| 107 | ||
| 106 | 108 | match self { |
| 107 | 109 | Rust => HOSTS, // doesn't matter in practice, but return something to avoid panicking |
| 108 | 110 | Rustc => HOSTS, |
src/tools/build_helper/src/git.rs+2-2| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | use std::process::Stdio; | |
| 2 | use std::{path::Path, process::Command}; | |
| 1 | use std::path::Path; | |
| 2 | use std::process::{Command, Stdio}; | |
| 3 | 3 | |
| 4 | 4 | pub struct GitConfig<'a> { |
| 5 | 5 | pub git_repository: &'a str, |
src/tools/bump-stage0/src/main.rs+2-1| ... | ... | @@ -1,10 +1,11 @@ |
| 1 | 1 | #![deny(unused_variables)] |
| 2 | 2 | |
| 3 | use std::collections::HashMap; | |
| 4 | ||
| 3 | 5 | use anyhow::{Context, Error}; |
| 4 | 6 | use build_helper::stage0_parser::{parse_stage0_file, Stage0Config, VersionMetadata}; |
| 5 | 7 | use curl::easy::Easy; |
| 6 | 8 | use indexmap::IndexMap; |
| 7 | use std::collections::HashMap; | |
| 8 | 9 | |
| 9 | 10 | const PATH: &str = "src/stage0"; |
| 10 | 11 | const COMPILER_COMPONENTS: &[&str] = &["rustc", "rust-std", "cargo", "clippy-preview"]; |
src/tools/cargotest/main.rs+1-2| ... | ... | @@ -1,7 +1,6 @@ |
| 1 | use std::env; | |
| 2 | use std::fs; | |
| 3 | 1 | use std::path::{Path, PathBuf}; |
| 4 | 2 | use std::process::Command; |
| 3 | use std::{env, fs}; | |
| 5 | 4 | |
| 6 | 5 | struct Test { |
| 7 | 6 | repo: &'static str, |
src/tools/collect-license-metadata/src/main.rs+4-2| ... | ... | @@ -2,10 +2,12 @@ mod licenses; |
| 2 | 2 | mod path_tree; |
| 3 | 3 | mod reuse; |
| 4 | 4 | |
| 5 | use crate::licenses::LicensesInterner; | |
| 6 | use anyhow::Error; | |
| 7 | 5 | use std::path::PathBuf; |
| 8 | 6 | |
| 7 | use anyhow::Error; | |
| 8 | ||
| 9 | use crate::licenses::LicensesInterner; | |
| 10 | ||
| 9 | 11 | fn main() -> Result<(), Error> { |
| 10 | 12 | let reuse_exe: PathBuf = std::env::var_os("REUSE_EXE").expect("Missing REUSE_EXE").into(); |
| 11 | 13 | let dest: PathBuf = std::env::var_os("DEST").expect("Missing DEST").into(); |
src/tools/collect-license-metadata/src/path_tree.rs+2-1| ... | ... | @@ -3,10 +3,11 @@ |
| 3 | 3 | //! responsible for that, by turning the list of paths into a tree and executing simplification |
| 4 | 4 | //! passes over the tree to remove redundant information. |
| 5 | 5 | |
| 6 | use crate::licenses::{License, LicenseId, LicensesInterner}; | |
| 7 | 6 | use std::collections::BTreeMap; |
| 8 | 7 | use std::path::{Path, PathBuf}; |
| 9 | 8 | |
| 9 | use crate::licenses::{License, LicenseId, LicensesInterner}; | |
| 10 | ||
| 10 | 11 | #[derive(serde::Serialize)] |
| 11 | 12 | #[serde(rename_all = "kebab-case", tag = "type")] |
| 12 | 13 | pub(crate) enum Node<L> { |
src/tools/collect-license-metadata/src/reuse.rs+4-2| ... | ... | @@ -1,9 +1,11 @@ |
| 1 | use crate::licenses::{License, LicenseId, LicensesInterner}; | |
| 2 | use anyhow::Error; | |
| 3 | 1 | use std::path::{Path, PathBuf}; |
| 4 | 2 | use std::process::{Command, Stdio}; |
| 5 | 3 | use std::time::Instant; |
| 6 | 4 | |
| 5 | use anyhow::Error; | |
| 6 | ||
| 7 | use crate::licenses::{License, LicenseId, LicensesInterner}; | |
| 8 | ||
| 7 | 9 | pub(crate) fn collect( |
| 8 | 10 | reuse_exe: &Path, |
| 9 | 11 | interner: &mut LicensesInterner, |
src/tools/compiletest/src/common.rs+5-6| ... | ... | @@ -1,19 +1,18 @@ |
| 1 | pub use self::Mode::*; | |
| 2 | ||
| 1 | use std::collections::{HashMap, HashSet}; | |
| 3 | 2 | use std::ffi::OsString; |
| 4 | use std::fmt; | |
| 5 | use std::iter; | |
| 6 | 3 | use std::path::{Path, PathBuf}; |
| 7 | 4 | use std::process::Command; |
| 8 | 5 | use std::str::FromStr; |
| 9 | 6 | use std::sync::OnceLock; |
| 7 | use std::{fmt, iter}; | |
| 10 | 8 | |
| 11 | use crate::util::{add_dylib_path, PathBufExt}; | |
| 12 | 9 | use build_helper::git::GitConfig; |
| 13 | 10 | use serde::de::{Deserialize, Deserializer, Error as _}; |
| 14 | use std::collections::{HashMap, HashSet}; | |
| 15 | 11 | use test::{ColorConfig, OutputFormat}; |
| 16 | 12 | |
| 13 | pub use self::Mode::*; | |
| 14 | use crate::util::{add_dylib_path, PathBufExt}; | |
| 15 | ||
| 17 | 16 | macro_rules! string_enum { |
| 18 | 17 | ($(#[$meta:meta])* $vis:vis enum $name:ident { $($variant:ident => $repr:expr,)* }) => { |
| 19 | 18 | $(#[$meta])* |
src/tools/compiletest/src/errors.rs+2-2| ... | ... | @@ -1,5 +1,3 @@ |
| 1 | use self::WhichLine::*; | |
| 2 | ||
| 3 | 1 | use std::fmt; |
| 4 | 2 | use std::fs::File; |
| 5 | 3 | use std::io::prelude::*; |
| ... | ... | @@ -11,6 +9,8 @@ use std::sync::OnceLock; |
| 11 | 9 | use regex::Regex; |
| 12 | 10 | use tracing::*; |
| 13 | 11 | |
| 12 | use self::WhichLine::*; | |
| 13 | ||
| 14 | 14 | #[derive(Copy, Clone, Debug, PartialEq)] |
| 15 | 15 | pub enum ErrorKind { |
| 16 | 16 | Help, |
src/tools/compiletest/src/header.rs+1-2| ... | ... | @@ -11,8 +11,7 @@ use regex::Regex; |
| 11 | 11 | use tracing::*; |
| 12 | 12 | |
| 13 | 13 | use crate::common::{Config, Debugger, FailMode, Mode, PassMode}; |
| 14 | use crate::header::cfg::parse_cfg_name_directive; | |
| 15 | use crate::header::cfg::MatchOutcome; | |
| 14 | use crate::header::cfg::{parse_cfg_name_directive, MatchOutcome}; | |
| 16 | 15 | use crate::header::needs::CachedNeedsConditions; |
| 17 | 16 | use crate::util::static_regex; |
| 18 | 17 | use crate::{extract_cdb_version, extract_gdb_version}; |
src/tools/compiletest/src/header/cfg.rs+2-1| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | use std::collections::HashSet; | |
| 2 | ||
| 1 | 3 | use crate::common::{CompareMode, Config, Debugger, Mode}; |
| 2 | 4 | use crate::header::IgnoreDecision; |
| 3 | use std::collections::HashSet; | |
| 4 | 5 | |
| 5 | 6 | const EXTRA_ARCHS: &[&str] = &["spirv"]; |
| 6 | 7 |
src/tools/compiletest/src/header/tests.rs+1-2| ... | ... | @@ -2,11 +2,10 @@ use std::io::Read; |
| 2 | 2 | use std::path::Path; |
| 3 | 3 | use std::str::FromStr; |
| 4 | 4 | |
| 5 | use super::iter_header; | |
| 5 | 6 | use crate::common::{Config, Debugger, Mode}; |
| 6 | 7 | use crate::header::{parse_normalize_rule, EarlyProps, HeadersCache}; |
| 7 | 8 | |
| 8 | use super::iter_header; | |
| 9 | ||
| 10 | 9 | fn make_test_description<R: Read>( |
| 11 | 10 | config: &Config, |
| 12 | 11 | name: test::TestName, |
src/tools/compiletest/src/json.rs+5-3| ... | ... | @@ -1,12 +1,14 @@ |
| 1 | 1 | //! These structs are a subset of the ones found in `rustc_errors::json`. |
| 2 | 2 | //! They are only used for deserialization of JSON output provided by libtest. |
| 3 | 3 | |
| 4 | use crate::errors::{Error, ErrorKind}; | |
| 5 | use crate::runtest::ProcRes; | |
| 6 | use serde::Deserialize; | |
| 7 | 4 | use std::path::{Path, PathBuf}; |
| 8 | 5 | use std::str::FromStr; |
| 9 | 6 | |
| 7 | use serde::Deserialize; | |
| 8 | ||
| 9 | use crate::errors::{Error, ErrorKind}; | |
| 10 | use crate::runtest::ProcRes; | |
| 11 | ||
| 10 | 12 | #[derive(Deserialize)] |
| 11 | 13 | struct Diagnostic { |
| 12 | 14 | message: String, |
src/tools/compiletest/src/lib.rs+9-7| ... | ... | @@ -18,27 +18,29 @@ mod read2; |
| 18 | 18 | pub mod runtest; |
| 19 | 19 | pub mod util; |
| 20 | 20 | |
| 21 | use crate::common::{expected_output_path, output_base_dir, output_relative_path, UI_EXTENSIONS}; | |
| 22 | use crate::common::{Config, Debugger, Mode, PassMode, TestPaths}; | |
| 23 | use crate::util::logv; | |
| 24 | use build_helper::git::{get_git_modified_files, get_git_untracked_files}; | |
| 25 | 21 | use core::panic; |
| 26 | use getopts::Options; | |
| 27 | 22 | use std::collections::HashSet; |
| 28 | 23 | use std::ffi::{OsStr, OsString}; |
| 29 | use std::fs; | |
| 30 | 24 | use std::io::{self, ErrorKind}; |
| 31 | 25 | use std::path::{Path, PathBuf}; |
| 32 | 26 | use std::process::{Command, Stdio}; |
| 33 | 27 | use std::sync::{Arc, OnceLock}; |
| 34 | 28 | use std::time::SystemTime; |
| 35 | use std::{env, vec}; | |
| 29 | use std::{env, fs, vec}; | |
| 30 | ||
| 31 | use build_helper::git::{get_git_modified_files, get_git_untracked_files}; | |
| 32 | use getopts::Options; | |
| 36 | 33 | use test::ColorConfig; |
| 37 | 34 | use tracing::*; |
| 38 | 35 | use walkdir::WalkDir; |
| 39 | 36 | |
| 40 | 37 | use self::header::{make_test_description, EarlyProps}; |
| 38 | use crate::common::{ | |
| 39 | expected_output_path, output_base_dir, output_relative_path, Config, Debugger, Mode, PassMode, | |
| 40 | TestPaths, UI_EXTENSIONS, | |
| 41 | }; | |
| 41 | 42 | use crate::header::HeadersCache; |
| 43 | use crate::util::logv; | |
| 42 | 44 | |
| 43 | 45 | pub fn parse_config(args: Vec<String>) -> Config { |
| 44 | 46 | let mut opts = Options::new(); |
src/tools/compiletest/src/main.rs+5-2| ... | ... | @@ -1,6 +1,9 @@ |
| 1 | use std::{env, io::IsTerminal, sync::Arc}; | |
| 1 | use std::env; | |
| 2 | use std::io::IsTerminal; | |
| 3 | use std::sync::Arc; | |
| 2 | 4 | |
| 3 | use compiletest::{common::Mode, log_config, parse_config, run_tests}; | |
| 5 | use compiletest::common::Mode; | |
| 6 | use compiletest::{log_config, parse_config, run_tests}; | |
| 4 | 7 | |
| 5 | 8 | fn main() { |
| 6 | 9 | tracing_subscriber::fmt::init(); |
src/tools/compiletest/src/raise_fd_limit.rs+1-2| ... | ... | @@ -7,10 +7,9 @@ |
| 7 | 7 | #[cfg(target_vendor = "apple")] |
| 8 | 8 | #[allow(non_camel_case_types)] |
| 9 | 9 | pub unsafe fn raise_fd_limit() { |
| 10 | use std::cmp; | |
| 11 | use std::io; | |
| 12 | 10 | use std::mem::size_of_val; |
| 13 | 11 | use std::ptr::null_mut; |
| 12 | use std::{cmp, io}; | |
| 14 | 13 | |
| 15 | 14 | static CTL_KERN: libc::c_int = 1; |
| 16 | 15 | static KERN_MAXFILESPERPROC: libc::c_int = 29; |
src/tools/compiletest/src/read2.rs+4-5| ... | ... | @@ -4,10 +4,11 @@ |
| 4 | 4 | #[cfg(test)] |
| 5 | 5 | mod tests; |
| 6 | 6 | |
| 7 | pub use self::imp::read2; | |
| 8 | 7 | use std::io::{self, Write}; |
| 9 | 8 | use std::process::{Child, Output}; |
| 10 | 9 | |
| 10 | pub use self::imp::read2; | |
| 11 | ||
| 11 | 12 | #[derive(Copy, Clone, Debug)] |
| 12 | 13 | pub enum Truncated { |
| 13 | 14 | Yes, |
| ... | ... | @@ -154,11 +155,10 @@ mod imp { |
| 154 | 155 | |
| 155 | 156 | #[cfg(unix)] |
| 156 | 157 | mod imp { |
| 157 | use std::io; | |
| 158 | 158 | use std::io::prelude::*; |
| 159 | use std::mem; | |
| 160 | 159 | use std::os::unix::prelude::*; |
| 161 | 160 | use std::process::{ChildStderr, ChildStdout}; |
| 161 | use std::{io, mem}; | |
| 162 | 162 | |
| 163 | 163 | pub fn read2( |
| 164 | 164 | mut out_pipe: ChildStdout, |
| ... | ... | @@ -228,10 +228,9 @@ mod imp { |
| 228 | 228 | |
| 229 | 229 | #[cfg(windows)] |
| 230 | 230 | mod imp { |
| 231 | use std::io; | |
| 232 | 231 | use std::os::windows::prelude::*; |
| 233 | 232 | use std::process::{ChildStderr, ChildStdout}; |
| 234 | use std::slice; | |
| 233 | use std::{io, slice}; | |
| 235 | 234 | |
| 236 | 235 | use miow::iocp::{CompletionPort, CompletionStatus}; |
| 237 | 236 | use miow::pipe::NamedPipe; |
src/tools/compiletest/src/runtest.rs+18-26| ... | ... | @@ -1,45 +1,37 @@ |
| 1 | 1 | // ignore-tidy-filelength |
| 2 | 2 | |
| 3 | use crate::common::{ | |
| 4 | expected_output_path, UI_EXTENSIONS, UI_FIXED, UI_STDERR, UI_STDOUT, UI_SVG, UI_WINDOWS_SVG, | |
| 5 | }; | |
| 6 | use crate::common::{incremental_dir, output_base_dir, output_base_name, output_testname_unique}; | |
| 7 | use crate::common::{Assembly, Crashes, Incremental, JsDocTest, MirOpt, RunMake, RustdocJson, Ui}; | |
| 8 | use crate::common::{Codegen, CodegenUnits, DebugInfo, Debugger, Rustdoc}; | |
| 9 | use crate::common::{CompareMode, FailMode, PassMode}; | |
| 10 | use crate::common::{Config, TestPaths}; | |
| 11 | use crate::common::{CoverageMap, CoverageRun, Pretty, RunPassValgrind}; | |
| 12 | use crate::common::{UI_RUN_STDERR, UI_RUN_STDOUT}; | |
| 13 | use crate::compute_diff::{write_diff, write_filtered_diff}; | |
| 14 | use crate::errors::{self, Error, ErrorKind}; | |
| 15 | use crate::header::TestProps; | |
| 16 | use crate::json; | |
| 17 | use crate::read2::{read2_abbreviated, Truncated}; | |
| 18 | use crate::util::{add_dylib_path, copy_dir_all, dylib_env_var, logv, static_regex, PathBufExt}; | |
| 19 | use crate::ColorConfig; | |
| 20 | use colored::Colorize; | |
| 21 | use miropt_test_tools::{files_for_miropt_test, MiroptTest, MiroptTestFile}; | |
| 22 | use regex::{Captures, Regex}; | |
| 23 | use rustfix::{apply_suggestions, get_suggestions_from_json, Filter}; | |
| 24 | 3 | use std::collections::{HashMap, HashSet}; |
| 25 | use std::env; | |
| 26 | 4 | use std::ffi::{OsStr, OsString}; |
| 27 | 5 | use std::fs::{self, create_dir_all, File, OpenOptions}; |
| 28 | 6 | use std::hash::{DefaultHasher, Hash, Hasher}; |
| 29 | 7 | use std::io::prelude::*; |
| 30 | 8 | use std::io::{self, BufReader}; |
| 31 | use std::iter; | |
| 32 | 9 | use std::path::{Path, PathBuf}; |
| 33 | 10 | use std::process::{Child, Command, ExitStatus, Output, Stdio}; |
| 34 | use std::str; | |
| 35 | 11 | use std::sync::Arc; |
| 12 | use std::{env, iter, str}; | |
| 36 | 13 | |
| 37 | 14 | use anyhow::Context; |
| 15 | use colored::Colorize; | |
| 38 | 16 | use glob::glob; |
| 17 | use miropt_test_tools::{files_for_miropt_test, MiroptTest, MiroptTestFile}; | |
| 18 | use regex::{Captures, Regex}; | |
| 19 | use rustfix::{apply_suggestions, get_suggestions_from_json, Filter}; | |
| 39 | 20 | use tracing::*; |
| 40 | 21 | |
| 41 | use crate::extract_gdb_version; | |
| 42 | use crate::is_android_gdb_target; | |
| 22 | use crate::common::{ | |
| 23 | expected_output_path, incremental_dir, output_base_dir, output_base_name, | |
| 24 | output_testname_unique, Assembly, Codegen, CodegenUnits, CompareMode, Config, CoverageMap, | |
| 25 | CoverageRun, Crashes, DebugInfo, Debugger, FailMode, Incremental, JsDocTest, MirOpt, PassMode, | |
| 26 | Pretty, RunMake, RunPassValgrind, Rustdoc, RustdocJson, TestPaths, Ui, UI_EXTENSIONS, UI_FIXED, | |
| 27 | UI_RUN_STDERR, UI_RUN_STDOUT, UI_STDERR, UI_STDOUT, UI_SVG, UI_WINDOWS_SVG, | |
| 28 | }; | |
| 29 | use crate::compute_diff::{write_diff, write_filtered_diff}; | |
| 30 | use crate::errors::{self, Error, ErrorKind}; | |
| 31 | use crate::header::TestProps; | |
| 32 | use crate::read2::{read2_abbreviated, Truncated}; | |
| 33 | use crate::util::{add_dylib_path, copy_dir_all, dylib_env_var, logv, static_regex, PathBufExt}; | |
| 34 | use crate::{extract_gdb_version, is_android_gdb_target, json, ColorConfig}; | |
| 43 | 35 | |
| 44 | 36 | mod coverage; |
| 45 | 37 | mod debugger; |
src/tools/compiletest/src/runtest/debugger.rs+4-4| ... | ... | @@ -1,12 +1,12 @@ |
| 1 | use crate::common::Config; | |
| 2 | use crate::header::line_directive; | |
| 3 | use crate::runtest::ProcRes; | |
| 4 | ||
| 5 | 1 | use std::fmt::Write; |
| 6 | 2 | use std::fs::File; |
| 7 | 3 | use std::io::{BufRead, BufReader}; |
| 8 | 4 | use std::path::{Path, PathBuf}; |
| 9 | 5 | |
| 6 | use crate::common::Config; | |
| 7 | use crate::header::line_directive; | |
| 8 | use crate::runtest::ProcRes; | |
| 9 | ||
| 10 | 10 | /// Representation of information to invoke a debugger and check its output |
| 11 | 11 | pub(super) struct DebuggerCommands { |
| 12 | 12 | /// Commands for the debuuger |
src/tools/compiletest/src/util.rs+2-1| ... | ... | @@ -1,4 +1,3 @@ |
| 1 | use crate::common::Config; | |
| 2 | 1 | use std::env; |
| 3 | 2 | use std::ffi::OsStr; |
| 4 | 3 | use std::path::{Path, PathBuf}; |
| ... | ... | @@ -6,6 +5,8 @@ use std::process::Command; |
| 6 | 5 | |
| 7 | 6 | use tracing::*; |
| 8 | 7 | |
| 8 | use crate::common::Config; | |
| 9 | ||
| 9 | 10 | #[cfg(test)] |
| 10 | 11 | mod tests; |
| 11 | 12 |
src/tools/coverage-dump/src/covfun.rs+5-3| ... | ... | @@ -1,10 +1,12 @@ |
| 1 | use crate::parser::{unescape_llvm_string_contents, Parser}; | |
| 2 | use anyhow::{anyhow, Context}; | |
| 3 | use regex::Regex; | |
| 4 | 1 | use std::collections::HashMap; |
| 5 | 2 | use std::fmt::{self, Debug, Write as _}; |
| 6 | 3 | use std::sync::OnceLock; |
| 7 | 4 | |
| 5 | use anyhow::{anyhow, Context}; | |
| 6 | use regex::Regex; | |
| 7 | ||
| 8 | use crate::parser::{unescape_llvm_string_contents, Parser}; | |
| 9 | ||
| 8 | 10 | pub(crate) fn dump_covfun_mappings( |
| 9 | 11 | llvm_ir: &str, |
| 10 | 12 | function_names: &HashMap<u64, String>, |
src/tools/coverage-dump/src/parser.rs+2-1| ... | ... | @@ -1,9 +1,10 @@ |
| 1 | 1 | #[cfg(test)] |
| 2 | 2 | mod tests; |
| 3 | 3 | |
| 4 | use std::sync::OnceLock; | |
| 5 | ||
| 4 | 6 | use anyhow::ensure; |
| 5 | 7 | use regex::bytes; |
| 6 | use std::sync::OnceLock; | |
| 7 | 8 | |
| 8 | 9 | /// Given the raw contents of a string literal in LLVM IR assembly, decodes any |
| 9 | 10 | /// backslash escapes and returns a vector containing the resulting byte string. |
src/tools/coverage-dump/src/prf_names.rs+5-3| ... | ... | @@ -1,9 +1,11 @@ |
| 1 | use crate::parser::{unescape_llvm_string_contents, Parser}; | |
| 2 | use anyhow::{anyhow, ensure}; | |
| 3 | use regex::Regex; | |
| 4 | 1 | use std::collections::HashMap; |
| 5 | 2 | use std::sync::OnceLock; |
| 6 | 3 | |
| 4 | use anyhow::{anyhow, ensure}; | |
| 5 | use regex::Regex; | |
| 6 | ||
| 7 | use crate::parser::{unescape_llvm_string_contents, Parser}; | |
| 8 | ||
| 7 | 9 | /// Scans through the contents of an LLVM IR assembly file to find `__llvm_prf_names` |
| 8 | 10 | /// entries, decodes them, and creates a table that maps name hash values to |
| 9 | 11 | /// (demangled) function names. |
src/tools/error_index_generator/main.rs+2-4| ... | ... | @@ -5,18 +5,16 @@ extern crate rustc_log; |
| 5 | 5 | extern crate rustc_session; |
| 6 | 6 | |
| 7 | 7 | extern crate rustc_errors; |
| 8 | use rustc_errors::codes::DIAGNOSTICS; | |
| 9 | ||
| 10 | 8 | use std::env; |
| 11 | 9 | use std::error::Error; |
| 12 | 10 | use std::fs::{self, File}; |
| 13 | 11 | use std::io::Write; |
| 14 | use std::path::Path; | |
| 15 | use std::path::PathBuf; | |
| 12 | use std::path::{Path, PathBuf}; | |
| 16 | 13 | use std::str::FromStr; |
| 17 | 14 | |
| 18 | 15 | use mdbook::book::{parse_summary, BookItem, Chapter}; |
| 19 | 16 | use mdbook::{Config, MDBook}; |
| 17 | use rustc_errors::codes::DIAGNOSTICS; | |
| 20 | 18 | |
| 21 | 19 | enum OutputFormat { |
| 22 | 20 | HTML, |
src/tools/generate-copyright/src/main.rs+2-1| ... | ... | @@ -1,7 +1,8 @@ |
| 1 | use anyhow::Error; | |
| 2 | 1 | use std::io::Write; |
| 3 | 2 | use std::path::PathBuf; |
| 4 | 3 | |
| 4 | use anyhow::Error; | |
| 5 | ||
| 5 | 6 | fn main() -> Result<(), Error> { |
| 6 | 7 | let dest = env_path("DEST")?; |
| 7 | 8 | let license_metadata = env_path("LICENSE_METADATA")?; |
src/tools/generate-windows-sys/src/main.rs+1-2| ... | ... | @@ -1,8 +1,7 @@ |
| 1 | use std::env; | |
| 2 | 1 | use std::error::Error; |
| 3 | use std::fs; | |
| 4 | 2 | use std::io::{Read, Seek, SeekFrom, Write}; |
| 5 | 3 | use std::path::PathBuf; |
| 4 | use std::{env, fs}; | |
| 6 | 5 | |
| 7 | 6 | /// 32-bit ARM is not supported by Microsoft so ARM types are not generated. |
| 8 | 7 | /// Therefore we need to inject a few types to make the bindings work. |
src/tools/html-checker/main.rs+2-1| ... | ... | @@ -1,8 +1,9 @@ |
| 1 | use rayon::iter::{ParallelBridge, ParallelIterator}; | |
| 2 | 1 | use std::env; |
| 3 | 2 | use std::path::Path; |
| 4 | 3 | use std::process::{Command, Output}; |
| 5 | 4 | |
| 5 | use rayon::iter::{ParallelBridge, ParallelIterator}; | |
| 6 | ||
| 6 | 7 | fn check_html_file(file: &Path) -> usize { |
| 7 | 8 | let to_mute = &[ |
| 8 | 9 | // "disabled" on <link> or "autocomplete" on <select> emit this warning |
src/tools/jsondocck/src/cache.rs+3-2| ... | ... | @@ -1,9 +1,10 @@ |
| 1 | use crate::config::Config; | |
| 2 | use serde_json::Value; | |
| 3 | 1 | use std::collections::HashMap; |
| 4 | 2 | use std::path::Path; |
| 5 | 3 | |
| 6 | 4 | use fs_err as fs; |
| 5 | use serde_json::Value; | |
| 6 | ||
| 7 | use crate::config::Config; | |
| 7 | 8 | |
| 8 | 9 | #[derive(Debug)] |
| 9 | 10 | pub struct Cache { |
src/tools/jsondocck/src/error.rs+2-1| ... | ... | @@ -1,7 +1,8 @@ |
| 1 | use crate::Command; | |
| 2 | 1 | use std::error::Error; |
| 3 | 2 | use std::fmt; |
| 4 | 3 | |
| 4 | use crate::Command; | |
| 5 | ||
| 5 | 6 | #[derive(Debug)] |
| 6 | 7 | pub enum CkError { |
| 7 | 8 | /// A check failed. File didn't exist or failed to match the command |
src/tools/jsondocck/src/main.rs+4-3| ... | ... | @@ -1,10 +1,11 @@ |
| 1 | use jsonpath_lib::select; | |
| 2 | use regex::{Regex, RegexBuilder}; | |
| 3 | use serde_json::Value; | |
| 4 | 1 | use std::borrow::Cow; |
| 5 | 2 | use std::sync::OnceLock; |
| 6 | 3 | use std::{env, fmt, fs}; |
| 7 | 4 | |
| 5 | use jsonpath_lib::select; | |
| 6 | use regex::{Regex, RegexBuilder}; | |
| 7 | use serde_json::Value; | |
| 8 | ||
| 8 | 9 | mod cache; |
| 9 | 10 | mod config; |
| 10 | 11 | mod error; |
src/tools/jsondoclint/src/validator.rs+2-1| ... | ... | @@ -9,7 +9,8 @@ use rustdoc_json_types::{ |
| 9 | 9 | }; |
| 10 | 10 | use serde_json::Value; |
| 11 | 11 | |
| 12 | use crate::{item_kind::Kind, json_find, Error, ErrorKind}; | |
| 12 | use crate::item_kind::Kind; | |
| 13 | use crate::{json_find, Error, ErrorKind}; | |
| 13 | 14 | |
| 14 | 15 | // This is a rustc implementation detail that we rely on here |
| 15 | 16 | const LOCAL_CRATE_ID: u32 = 0; |
src/tools/jsondoclint/src/validator/tests.rs+1-2| ... | ... | @@ -1,9 +1,8 @@ |
| 1 | 1 | use rustc_hash::FxHashMap; |
| 2 | 2 | use rustdoc_json_types::{Item, ItemKind, Visibility, FORMAT_VERSION}; |
| 3 | 3 | |
| 4 | use crate::json_find::SelectorPart; | |
| 5 | ||
| 6 | 4 | use super::*; |
| 5 | use crate::json_find::SelectorPart; | |
| 7 | 6 | |
| 8 | 7 | #[track_caller] |
| 9 | 8 | fn check(krate: &Crate, errs: &[Error]) { |
src/tools/linkchecker/main.rs+6-6| ... | ... | @@ -14,18 +14,18 @@ |
| 14 | 14 | //! A few exceptions are allowed as there's known bugs in rustdoc, but this |
| 15 | 15 | //! should catch the majority of "broken link" cases. |
| 16 | 16 | |
| 17 | use html5ever::tendril::ByteTendril; | |
| 18 | use html5ever::tokenizer::{ | |
| 19 | BufferQueue, TagToken, Token, TokenSink, TokenSinkResult, Tokenizer, TokenizerOpts, | |
| 20 | }; | |
| 21 | 17 | use std::cell::RefCell; |
| 22 | 18 | use std::collections::{HashMap, HashSet}; |
| 23 | use std::env; | |
| 24 | use std::fs; | |
| 25 | 19 | use std::io::ErrorKind; |
| 26 | 20 | use std::path::{Component, Path, PathBuf}; |
| 27 | 21 | use std::rc::Rc; |
| 28 | 22 | use std::time::Instant; |
| 23 | use std::{env, fs}; | |
| 24 | ||
| 25 | use html5ever::tendril::ByteTendril; | |
| 26 | use html5ever::tokenizer::{ | |
| 27 | BufferQueue, TagToken, Token, TokenSink, TokenSinkResult, Tokenizer, TokenizerOpts, | |
| 28 | }; | |
| 29 | 29 | |
| 30 | 30 | // Add linkcheck exceptions here |
| 31 | 31 | // If at all possible you should use intra-doc links to avoid linkcheck issues. These |
src/tools/lint-docs/src/groups.rs+2-1| ... | ... | @@ -1,10 +1,11 @@ |
| 1 | use crate::{Lint, LintExtractor}; | |
| 2 | 1 | use std::collections::{BTreeMap, BTreeSet}; |
| 3 | 2 | use std::error::Error; |
| 4 | 3 | use std::fmt::Write; |
| 5 | 4 | use std::fs; |
| 6 | 5 | use std::process::Command; |
| 7 | 6 | |
| 7 | use crate::{Lint, LintExtractor}; | |
| 8 | ||
| 8 | 9 | /// Descriptions of rustc lint groups. |
| 9 | 10 | static GROUP_DESCRIPTIONS: &[(&str, &str)] = &[ |
| 10 | 11 | ("unused", "Lints that detect things being declared but not used, or excess syntax"), |
src/tools/lint-docs/src/lib.rs+1| ... | ... | @@ -3,6 +3,7 @@ use std::fmt::Write; |
| 3 | 3 | use std::fs; |
| 4 | 4 | use std::path::{Path, PathBuf}; |
| 5 | 5 | use std::process::Command; |
| 6 | ||
| 6 | 7 | use walkdir::WalkDir; |
| 7 | 8 | |
| 8 | 9 | mod groups; |
src/tools/lld-wrapper/src/main.rs+2-1| ... | ... | @@ -11,7 +11,8 @@ |
| 11 | 11 | //! obtained from the wrapper's name as the first two arguments. |
| 12 | 12 | //! On Windows it spawns a `..\rust-lld.exe` child process. |
| 13 | 13 | |
| 14 | use std::env::{self, consts::EXE_SUFFIX}; | |
| 14 | use std::env::consts::EXE_SUFFIX; | |
| 15 | use std::env::{self}; | |
| 15 | 16 | use std::fmt::Display; |
| 16 | 17 | use std::path::{Path, PathBuf}; |
| 17 | 18 | use std::process; |
src/tools/llvm-bitcode-linker/src/bin/llvm-bitcode-linker.rs-1| ... | ... | @@ -1,7 +1,6 @@ |
| 1 | 1 | use std::path::PathBuf; |
| 2 | 2 | |
| 3 | 3 | use clap::Parser; |
| 4 | ||
| 5 | 4 | use llvm_bitcode_linker::{Optimization, Session, Target}; |
| 6 | 5 | |
| 7 | 6 | #[derive(Debug, Parser)] |
src/tools/llvm-bitcode-linker/src/linker.rs+1-2| ... | ... | @@ -2,8 +2,7 @@ use std::path::PathBuf; |
| 2 | 2 | |
| 3 | 3 | use anyhow::Context; |
| 4 | 4 | |
| 5 | use crate::Optimization; | |
| 6 | use crate::Target; | |
| 5 | use crate::{Optimization, Target}; | |
| 7 | 6 | |
| 8 | 7 | #[derive(Debug)] |
| 9 | 8 | pub struct Session { |
src/tools/llvm-bitcode-linker/src/opt.rs+1-2| ... | ... | @@ -1,5 +1,4 @@ |
| 1 | use std::fmt::Display; | |
| 2 | use std::fmt::Formatter; | |
| 1 | use std::fmt::{Display, Formatter}; | |
| 3 | 2 | |
| 4 | 3 | #[derive(Debug, Clone, Copy, Default, Hash, Eq, PartialEq, clap::ValueEnum)] |
| 5 | 4 | pub enum Optimization { |
src/tools/opt-dist/src/bolt.rs+1-2| ... | ... | @@ -1,9 +1,8 @@ |
| 1 | 1 | use anyhow::Context; |
| 2 | use camino::{Utf8Path, Utf8PathBuf}; | |
| 2 | 3 | |
| 3 | 4 | use crate::exec::cmd; |
| 4 | 5 | use crate::training::BoltProfile; |
| 5 | use camino::{Utf8Path, Utf8PathBuf}; | |
| 6 | ||
| 7 | 6 | use crate::utils::io::copy_file; |
| 8 | 7 | |
| 9 | 8 | /// Instruments an artifact at the given `path` (in-place) with BOLT and then calls `func`. |
src/tools/opt-dist/src/exec.rs+6-4| ... | ... | @@ -1,11 +1,13 @@ |
| 1 | use std::collections::BTreeMap; | |
| 2 | use std::fs::File; | |
| 3 | use std::process::{Command, Stdio}; | |
| 4 | ||
| 5 | use camino::{Utf8Path, Utf8PathBuf}; | |
| 6 | ||
| 1 | 7 | use crate::environment::Environment; |
| 2 | 8 | use crate::metrics::{load_metrics, record_metrics}; |
| 3 | 9 | use crate::timer::TimerSection; |
| 4 | 10 | use crate::training::{BoltProfile, LlvmPGOProfile, RustcPGOProfile}; |
| 5 | use camino::{Utf8Path, Utf8PathBuf}; | |
| 6 | use std::collections::BTreeMap; | |
| 7 | use std::fs::File; | |
| 8 | use std::process::{Command, Stdio}; | |
| 9 | 11 | |
| 10 | 12 | #[derive(Default)] |
| 11 | 13 | pub struct CmdBuilder { |
src/tools/opt-dist/src/main.rs+1-1| ... | ... | @@ -1,10 +1,10 @@ |
| 1 | use crate::bolt::{bolt_optimize, with_bolt_instrumented}; | |
| 2 | 1 | use anyhow::Context; |
| 3 | 2 | use camino::{Utf8Path, Utf8PathBuf}; |
| 4 | 3 | use clap::Parser; |
| 5 | 4 | use log::LevelFilter; |
| 6 | 5 | use utils::io; |
| 7 | 6 | |
| 7 | use crate::bolt::{bolt_optimize, with_bolt_instrumented}; | |
| 8 | 8 | use crate::environment::{Environment, EnvironmentBuilder}; |
| 9 | 9 | use crate::exec::{cmd, Bootstrap}; |
| 10 | 10 | use crate::tests::run_tests; |
src/tools/opt-dist/src/metrics.rs+4-2| ... | ... | @@ -1,7 +1,9 @@ |
| 1 | use crate::timer::TimerSection; | |
| 1 | use std::time::Duration; | |
| 2 | ||
| 2 | 3 | use build_helper::metrics::{JsonNode, JsonRoot}; |
| 3 | 4 | use camino::Utf8Path; |
| 4 | use std::time::Duration; | |
| 5 | ||
| 6 | use crate::timer::TimerSection; | |
| 5 | 7 | |
| 6 | 8 | #[derive(Clone, Debug)] |
| 7 | 9 | pub struct BuildStep { |
src/tools/opt-dist/src/tests.rs+3-2| ... | ... | @@ -1,8 +1,9 @@ |
| 1 | use anyhow::Context; | |
| 2 | use camino::{Utf8Path, Utf8PathBuf}; | |
| 3 | ||
| 1 | 4 | use crate::environment::{executable_extension, Environment}; |
| 2 | 5 | use crate::exec::cmd; |
| 3 | 6 | use crate::utils::io::{copy_directory, find_file_in_dir, unpack_archive}; |
| 4 | use anyhow::Context; | |
| 5 | use camino::{Utf8Path, Utf8PathBuf}; | |
| 6 | 7 | |
| 7 | 8 | /// Run tests on optimized dist artifacts. |
| 8 | 9 | pub fn run_tests(env: &Environment) -> anyhow::Result<()> { |
src/tools/opt-dist/src/training.rs+5-4| ... | ... | @@ -1,12 +1,13 @@ |
| 1 | use crate::environment::{executable_extension, Environment}; | |
| 2 | use crate::exec::{cmd, CmdBuilder}; | |
| 3 | use crate::utils::io::{count_files, delete_directory}; | |
| 4 | use crate::utils::with_log_group; | |
| 5 | 1 | use anyhow::Context; |
| 6 | 2 | use build_helper::{LLVM_PGO_CRATES, RUSTC_PGO_CRATES}; |
| 7 | 3 | use camino::{Utf8Path, Utf8PathBuf}; |
| 8 | 4 | use humansize::BINARY; |
| 9 | 5 | |
| 6 | use crate::environment::{executable_extension, Environment}; | |
| 7 | use crate::exec::{cmd, CmdBuilder}; | |
| 8 | use crate::utils::io::{count_files, delete_directory}; | |
| 9 | use crate::utils::with_log_group; | |
| 10 | ||
| 10 | 11 | fn init_compiler_benchmarks( |
| 11 | 12 | env: &Environment, |
| 12 | 13 | profiles: &[&str], |
src/tools/opt-dist/src/utils/artifact_size.rs+2-2| ... | ... | @@ -9,10 +9,10 @@ use crate::environment::Environment; |
| 9 | 9 | use crate::utils::io::get_files_from_dir; |
| 10 | 10 | |
| 11 | 11 | pub fn print_binary_sizes(env: &Environment) -> anyhow::Result<()> { |
| 12 | use humansize::format_size; | |
| 13 | use humansize::BINARY; | |
| 14 | 12 | use std::fmt::Write; |
| 15 | 13 | |
| 14 | use humansize::{format_size, BINARY}; | |
| 15 | ||
| 16 | 16 | let root = env.build_artifacts().join("stage2"); |
| 17 | 17 | |
| 18 | 18 | let mut files = get_files_from_dir(&root.join("bin"), None)?; |
src/tools/opt-dist/src/utils/io.rs+3-2| ... | ... | @@ -1,8 +1,9 @@ |
| 1 | use std::fs::File; | |
| 2 | use std::path::Path; | |
| 3 | ||
| 1 | 4 | use anyhow::Context; |
| 2 | 5 | use camino::{Utf8Path, Utf8PathBuf}; |
| 3 | 6 | use fs_extra::dir::CopyOptions; |
| 4 | use std::fs::File; | |
| 5 | use std::path::Path; | |
| 6 | 7 | |
| 7 | 8 | /// Delete and re-create the directory. |
| 8 | 9 | pub fn reset_directory(path: &Utf8Path) -> anyhow::Result<()> { |
src/tools/opt-dist/src/utils/mod.rs+3-2| ... | ... | @@ -1,10 +1,11 @@ |
| 1 | use std::time::Duration; | |
| 2 | ||
| 3 | use humansize::BINARY; | |
| 1 | 4 | use sysinfo::Disks; |
| 2 | 5 | |
| 3 | 6 | use crate::environment::Environment; |
| 4 | 7 | use crate::timer::Timer; |
| 5 | 8 | use crate::utils::io::delete_directory; |
| 6 | use humansize::BINARY; | |
| 7 | use std::time::Duration; | |
| 8 | 9 | |
| 9 | 10 | pub mod artifact_size; |
| 10 | 11 | pub mod io; |
src/tools/remote-test-client/src/main.rs+1-2| ... | ... | @@ -5,15 +5,14 @@ |
| 5 | 5 | //! Here is also where we bake in the support to spawn the QEMU emulator as |
| 6 | 6 | //! well. |
| 7 | 7 | |
| 8 | use std::env; | |
| 9 | 8 | use std::fs::{self, File}; |
| 10 | 9 | use std::io::prelude::*; |
| 11 | 10 | use std::io::{self, BufWriter}; |
| 12 | 11 | use std::net::TcpStream; |
| 13 | 12 | use std::path::{Path, PathBuf}; |
| 14 | 13 | use std::process::{Command, Stdio}; |
| 15 | use std::thread; | |
| 16 | 14 | use std::time::Duration; |
| 15 | use std::{env, thread}; | |
| 17 | 16 | |
| 18 | 17 | const REMOTE_ADDR_ENV: &str = "TEST_DEVICE_ADDR"; |
| 19 | 18 | const DEFAULT_ADDR: &str = "127.0.0.1:12345"; |
src/tools/remote-test-server/src/main.rs+4-9| ... | ... | @@ -12,22 +12,17 @@ |
| 12 | 12 | |
| 13 | 13 | #[cfg(not(windows))] |
| 14 | 14 | use std::fs::Permissions; |
| 15 | use std::net::SocketAddr; | |
| 16 | #[cfg(not(windows))] | |
| 17 | use std::os::unix::prelude::*; | |
| 18 | ||
| 19 | use std::cmp; | |
| 20 | use std::env; | |
| 21 | 15 | use std::fs::{self, File}; |
| 22 | 16 | use std::io::prelude::*; |
| 23 | 17 | use std::io::{self, BufReader}; |
| 24 | use std::net::{TcpListener, TcpStream}; | |
| 18 | use std::net::{SocketAddr, TcpListener, TcpStream}; | |
| 19 | #[cfg(not(windows))] | |
| 20 | use std::os::unix::prelude::*; | |
| 25 | 21 | use std::path::{Path, PathBuf}; |
| 26 | 22 | use std::process::{Command, ExitStatus, Stdio}; |
| 27 | use std::str; | |
| 28 | 23 | use std::sync::atomic::{AtomicUsize, Ordering}; |
| 29 | 24 | use std::sync::{Arc, Mutex}; |
| 30 | use std::thread; | |
| 25 | use std::{cmp, env, str, thread}; | |
| 31 | 26 | |
| 32 | 27 | macro_rules! t { |
| 33 | 28 | ($e:expr) => { |
src/tools/replace-version-placeholder/src/main.rs+1| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | 1 | use std::path::PathBuf; |
| 2 | ||
| 2 | 3 | use tidy::{t, walk}; |
| 3 | 4 | |
| 4 | 5 | pub const VERSION_PLACEHOLDER: &str = "CURRENT_RUSTC_VERSION"; |
src/tools/rls/src/main.rs+3-3| ... | ... | @@ -3,10 +3,10 @@ |
| 3 | 3 | //! This is a small stub that replaces RLS to alert the user that RLS is no |
| 4 | 4 | //! longer available. |
| 5 | 5 | |
| 6 | use serde_json::Value; | |
| 7 | 6 | use std::error::Error; |
| 8 | use std::io::BufRead; | |
| 9 | use std::io::Write; | |
| 7 | use std::io::{BufRead, Write}; | |
| 8 | ||
| 9 | use serde_json::Value; | |
| 10 | 10 | |
| 11 | 11 | const ALERT_MSG: &str = "\ |
| 12 | 12 | RLS is no longer available as of Rust 1.65. |
src/tools/run-make-support/src/command.rs+3-4| ... | ... | @@ -1,15 +1,14 @@ |
| 1 | use std::ffi; | |
| 2 | 1 | use std::ffi::OsStr; |
| 3 | 2 | use std::io::Write; |
| 4 | use std::panic; | |
| 5 | 3 | use std::path::Path; |
| 6 | 4 | use std::process::{Command as StdCommand, ExitStatus, Output, Stdio}; |
| 5 | use std::{ffi, panic}; | |
| 6 | ||
| 7 | use build_helper::drop_bomb::DropBomb; | |
| 7 | 8 | |
| 8 | 9 | use crate::util::handle_failed_output; |
| 9 | 10 | use crate::{assert_contains, assert_equals, assert_not_contains}; |
| 10 | 11 | |
| 11 | use build_helper::drop_bomb::DropBomb; | |
| 12 | ||
| 13 | 12 | /// This is a custom command wrapper that simplifies working with commands and makes it easier to |
| 14 | 13 | /// ensure that we check the exit status of executed processes. |
| 15 | 14 | /// |
src/tools/run-make-support/src/diff/mod.rs+1-2| ... | ... | @@ -1,10 +1,9 @@ |
| 1 | 1 | use std::path::{Path, PathBuf}; |
| 2 | 2 | |
| 3 | use build_helper::drop_bomb::DropBomb; | |
| 3 | 4 | use regex::Regex; |
| 4 | 5 | use similar::TextDiff; |
| 5 | 6 | |
| 6 | use build_helper::drop_bomb::DropBomb; | |
| 7 | ||
| 8 | 7 | use crate::fs; |
| 9 | 8 | |
| 10 | 9 | #[cfg(test)] |
src/tools/run-make-support/src/external_deps/cc.rs+2-3| ... | ... | @@ -1,10 +1,9 @@ |
| 1 | 1 | use std::path::Path; |
| 2 | 2 | |
| 3 | use crate::command::Command; | |
| 4 | use crate::{env_var, is_msvc, is_windows, uname}; | |
| 5 | ||
| 6 | 3 | // FIXME(jieyouxu): can we get rid of the `cygpath` external dependency? |
| 7 | 4 | use super::cygpath::get_windows_path; |
| 5 | use crate::command::Command; | |
| 6 | use crate::{env_var, is_msvc, is_windows, uname}; | |
| 8 | 7 | |
| 9 | 8 | /// Construct a new platform-specific C compiler invocation. |
| 10 | 9 | /// |
src/tools/run-make-support/src/external_deps/htmldocck.rs+1-2| ... | ... | @@ -1,8 +1,7 @@ |
| 1 | use super::python::python_command; | |
| 1 | 2 | use crate::command::Command; |
| 2 | 3 | use crate::source_root; |
| 3 | 4 | |
| 4 | use super::python::python_command; | |
| 5 | ||
| 6 | 5 | /// `htmldocck` is a python script which is used for rustdoc test suites, it is assumed to be |
| 7 | 6 | /// available at `$SOURCE_ROOT/src/etc/htmldocck.py`. |
| 8 | 7 | #[track_caller] |
src/tools/run-make-support/src/run.rs+1-2| ... | ... | @@ -1,7 +1,6 @@ |
| 1 | use std::env; | |
| 2 | 1 | use std::ffi::OsStr; |
| 3 | use std::panic; | |
| 4 | 2 | use std::path::{Path, PathBuf}; |
| 3 | use std::{env, panic}; | |
| 5 | 4 | |
| 6 | 5 | use crate::command::{Command, CompletedProcess}; |
| 7 | 6 | use crate::util::{handle_failed_output, set_host_rpath}; |
src/tools/rust-installer/src/combiner.rs+6-7| ... | ... | @@ -1,14 +1,13 @@ |
| 1 | use super::Scripter; | |
| 2 | use super::Tarballer; | |
| 3 | use crate::{ | |
| 4 | compression::{CompressionFormat, CompressionFormats, CompressionProfile}, | |
| 5 | util::*, | |
| 6 | }; | |
| 7 | use anyhow::{bail, Context, Result}; | |
| 8 | 1 | use std::io::{Read, Write}; |
| 9 | 2 | use std::path::Path; |
| 3 | ||
| 4 | use anyhow::{bail, Context, Result}; | |
| 10 | 5 | use tar::Archive; |
| 11 | 6 | |
| 7 | use super::{Scripter, Tarballer}; | |
| 8 | use crate::compression::{CompressionFormat, CompressionFormats, CompressionProfile}; | |
| 9 | use crate::util::*; | |
| 10 | ||
| 12 | 11 | actor! { |
| 13 | 12 | #[derive(Debug)] |
| 14 | 13 | pub struct Combiner { |
src/tools/rust-installer/src/compression.rs+9-3| ... | ... | @@ -1,8 +1,14 @@ |
| 1 | use std::fmt; | |
| 2 | use std::io::{Read, Write}; | |
| 3 | use std::path::Path; | |
| 4 | use std::str::FromStr; | |
| 5 | ||
| 1 | 6 | use anyhow::{Context, Error}; |
| 2 | use flate2::{read::GzDecoder, write::GzEncoder}; | |
| 7 | use flate2::read::GzDecoder; | |
| 8 | use flate2::write::GzEncoder; | |
| 3 | 9 | use rayon::prelude::*; |
| 4 | use std::{fmt, io::Read, io::Write, path::Path, str::FromStr}; | |
| 5 | use xz2::{read::XzDecoder, write::XzEncoder}; | |
| 10 | use xz2::read::XzDecoder; | |
| 11 | use xz2::write::XzEncoder; | |
| 6 | 12 | |
| 7 | 13 | #[derive(Default, Debug, Copy, Clone)] |
| 8 | 14 | pub enum CompressionProfile { |
src/tools/rust-installer/src/generator.rs+6-5| ... | ... | @@ -1,12 +1,13 @@ |
| 1 | use super::Scripter; | |
| 2 | use super::Tarballer; | |
| 3 | use crate::compression::{CompressionFormats, CompressionProfile}; | |
| 4 | use crate::util::*; | |
| 5 | use anyhow::{bail, format_err, Context, Result}; | |
| 6 | 1 | use std::collections::BTreeSet; |
| 7 | 2 | use std::io::Write; |
| 8 | 3 | use std::path::Path; |
| 9 | 4 | |
| 5 | use anyhow::{bail, format_err, Context, Result}; | |
| 6 | ||
| 7 | use super::{Scripter, Tarballer}; | |
| 8 | use crate::compression::{CompressionFormats, CompressionProfile}; | |
| 9 | use crate::util::*; | |
| 10 | ||
| 10 | 11 | actor! { |
| 11 | 12 | #[derive(Debug)] |
| 12 | 13 | pub struct Generator { |
src/tools/rust-installer/src/scripter.rs+4-2| ... | ... | @@ -1,7 +1,9 @@ |
| 1 | use crate::util::*; | |
| 2 | use anyhow::{Context, Result}; | |
| 3 | 1 | use std::io::Write; |
| 4 | 2 | |
| 3 | use anyhow::{Context, Result}; | |
| 4 | ||
| 5 | use crate::util::*; | |
| 6 | ||
| 5 | 7 | const TEMPLATE: &str = include_str!("../install-template.sh"); |
| 6 | 8 | |
| 7 | 9 | actor! { |
src/tools/rust-installer/src/tarballer.rs+4-5| ... | ... | @@ -1,14 +1,13 @@ |
| 1 | use anyhow::{bail, Context, Result}; | |
| 2 | 1 | use std::fs::{read_link, symlink_metadata}; |
| 3 | 2 | use std::io::{BufWriter, Write}; |
| 4 | 3 | use std::path::Path; |
| 4 | ||
| 5 | use anyhow::{bail, Context, Result}; | |
| 5 | 6 | use tar::{Builder, Header, HeaderMode}; |
| 6 | 7 | use walkdir::WalkDir; |
| 7 | 8 | |
| 8 | use crate::{ | |
| 9 | compression::{CombinedEncoder, CompressionFormats, CompressionProfile}, | |
| 10 | util::*, | |
| 11 | }; | |
| 9 | use crate::compression::{CombinedEncoder, CompressionFormats, CompressionProfile}; | |
| 10 | use crate::util::*; | |
| 12 | 11 | |
| 13 | 12 | actor! { |
| 14 | 13 | #[derive(Debug)] |
src/tools/rust-installer/src/util.rs+7-8| ... | ... | @@ -1,17 +1,16 @@ |
| 1 | use anyhow::{format_err, Context, Result}; | |
| 2 | 1 | use std::fs; |
| 3 | use std::path::Path; | |
| 4 | use walkdir::WalkDir; | |
| 5 | ||
| 6 | // Needed to set the script mode to executable. | |
| 7 | #[cfg(unix)] | |
| 8 | use std::os::unix::fs::OpenOptionsExt; | |
| 9 | 2 | // FIXME: what about Windows? Are default ACLs executable? |
| 10 | ||
| 11 | 3 | #[cfg(unix)] |
| 12 | 4 | use std::os::unix::fs::symlink as symlink_file; |
| 5 | // Needed to set the script mode to executable. | |
| 6 | #[cfg(unix)] | |
| 7 | use std::os::unix::fs::OpenOptionsExt; | |
| 13 | 8 | #[cfg(windows)] |
| 14 | 9 | use std::os::windows::fs::symlink_file; |
| 10 | use std::path::Path; | |
| 11 | ||
| 12 | use anyhow::{format_err, Context, Result}; | |
| 13 | use walkdir::WalkDir; | |
| 15 | 14 | |
| 16 | 15 | /// Converts a `&Path` to a UTF-8 `&str`. |
| 17 | 16 | pub fn path_to_str(path: &Path) -> Result<&str> { |
src/tools/rustbook/src/main.rs+1-5| ... | ... | @@ -1,14 +1,10 @@ |
| 1 | use clap::crate_version; | |
| 2 | ||
| 3 | 1 | use std::env; |
| 4 | 2 | use std::path::{Path, PathBuf}; |
| 5 | 3 | |
| 6 | use clap::{arg, ArgMatches, Command}; | |
| 7 | ||
| 4 | use clap::{arg, crate_version, ArgMatches, Command}; | |
| 8 | 5 | use mdbook::errors::Result as Result3; |
| 9 | 6 | use mdbook::MDBook; |
| 10 | 7 | use mdbook_i18n_helpers::preprocessors::Gettext; |
| 11 | ||
| 12 | 8 | use mdbook_spec::Spec; |
| 13 | 9 | use mdbook_trpl_listing::TrplListing; |
| 14 | 10 | use mdbook_trpl_note::TrplNote; |
src/tools/rustc-perf-wrapper/src/main.rs+4-2| ... | ... | @@ -1,8 +1,10 @@ |
| 1 | use crate::config::{Profile, Scenario}; | |
| 2 | use clap::Parser; | |
| 3 | 1 | use std::path::PathBuf; |
| 4 | 2 | use std::process::Command; |
| 5 | 3 | |
| 4 | use clap::Parser; | |
| 5 | ||
| 6 | use crate::config::{Profile, Scenario}; | |
| 7 | ||
| 6 | 8 | mod config; |
| 7 | 9 | |
| 8 | 10 | /// Performs profiling or benchmarking with [`rustc-perf`](https://github.com/rust-lang/rustc-perf) |
src/tools/rustdoc-gui-test/src/config.rs+3-1| ... | ... | @@ -1,5 +1,7 @@ |
| 1 | use std::env; | |
| 2 | use std::path::PathBuf; | |
| 3 | ||
| 1 | 4 | use getopts::Options; |
| 2 | use std::{env, path::PathBuf}; | |
| 3 | 5 | |
| 4 | 6 | pub(crate) struct Config { |
| 5 | 7 | pub(crate) nodejs: PathBuf, |
src/tools/rustdoc-gui-test/src/main.rs+4-3| ... | ... | @@ -1,11 +1,12 @@ |
| 1 | use build_helper::util::try_run; | |
| 2 | use compiletest::header::TestProps; | |
| 3 | use config::Config; | |
| 4 | 1 | use std::path::{Path, PathBuf}; |
| 5 | 2 | use std::process::Command; |
| 6 | 3 | use std::sync::Arc; |
| 7 | 4 | use std::{env, fs}; |
| 8 | 5 | |
| 6 | use build_helper::util::try_run; | |
| 7 | use compiletest::header::TestProps; | |
| 8 | use config::Config; | |
| 9 | ||
| 9 | 10 | mod config; |
| 10 | 11 | |
| 11 | 12 | fn get_browser_ui_test_version_inner(npm: &Path, global: bool) -> Option<String> { |
src/tools/suggest-tests/src/lib.rs+2-4| ... | ... | @@ -1,7 +1,5 @@ |
| 1 | use std::{ | |
| 2 | fmt::{self, Display}, | |
| 3 | path::Path, | |
| 4 | }; | |
| 1 | use std::fmt::{self, Display}; | |
| 2 | use std::path::Path; | |
| 5 | 3 | |
| 6 | 4 | use dynamic_suggestions::DYNAMIC_SUGGESTIONS; |
| 7 | 5 | use glob::Pattern; |
src/tools/suggest-tests/src/static_suggestions.rs+2-1| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | use crate::{sug, Suggestion}; | |
| 2 | 1 | use std::sync::OnceLock; |
| 3 | 2 | |
| 3 | use crate::{sug, Suggestion}; | |
| 4 | ||
| 4 | 5 | // FIXME: perhaps this could use `std::lazy` when it is stablizied |
| 5 | 6 | macro_rules! static_suggestions { |
| 6 | 7 | ($( [ $( $glob:expr ),* $(,)? ] => [ $( $suggestion:expr ),* $(,)? ] ),* $(,)? ) => { |
src/tools/tidy/src/alphabetical/tests.rs+2-1| ... | ... | @@ -1,7 +1,8 @@ |
| 1 | use super::*; | |
| 2 | 1 | use std::io::Write; |
| 3 | 2 | use std::str::from_utf8; |
| 4 | 3 | |
| 4 | use super::*; | |
| 5 | ||
| 5 | 6 | fn test(lines: &str, name: &str, expected_msg: &str, expected_bad: bool) { |
| 6 | 7 | let mut actual_msg = Vec::new(); |
| 7 | 8 | let mut actual_bad = false; |
src/tools/tidy/src/bins.rs+2-1| ... | ... | @@ -21,12 +21,13 @@ mod os_impl { |
| 21 | 21 | |
| 22 | 22 | #[cfg(unix)] |
| 23 | 23 | mod os_impl { |
| 24 | use crate::walk::{filter_dirs, walk_no_read}; | |
| 25 | 24 | use std::fs; |
| 26 | 25 | use std::os::unix::prelude::*; |
| 27 | 26 | use std::path::Path; |
| 28 | 27 | use std::process::{Command, Stdio}; |
| 29 | 28 | |
| 29 | use crate::walk::{filter_dirs, walk_no_read}; | |
| 30 | ||
| 30 | 31 | enum FilesystemSupport { |
| 31 | 32 | Supported, |
| 32 | 33 | Unsupported, |
src/tools/tidy/src/debug_artifacts.rs+2-1| ... | ... | @@ -1,8 +1,9 @@ |
| 1 | 1 | //! Tidy check to prevent creation of unnecessary debug artifacts while running tests. |
| 2 | 2 | |
| 3 | use crate::walk::{filter_dirs, filter_not_rust, walk}; | |
| 4 | 3 | use std::path::Path; |
| 5 | 4 | |
| 5 | use crate::walk::{filter_dirs, filter_not_rust, walk}; | |
| 6 | ||
| 6 | 7 | const GRAPHVIZ_POSTFLOW_MSG: &str = "`borrowck_graphviz_postflow` attribute in test"; |
| 7 | 8 | |
| 8 | 9 | pub fn check(test_dir: &Path, bad: &mut bool) { |
src/tools/tidy/src/deps.rs+3-2| ... | ... | @@ -1,11 +1,12 @@ |
| 1 | 1 | //! Checks the licenses of third-party dependencies. |
| 2 | 2 | |
| 3 | use build_helper::ci::CiEnv; | |
| 4 | use cargo_metadata::{Metadata, Package, PackageId}; | |
| 5 | 3 | use std::collections::HashSet; |
| 6 | 4 | use std::fs::read_dir; |
| 7 | 5 | use std::path::Path; |
| 8 | 6 | |
| 7 | use build_helper::ci::CiEnv; | |
| 8 | use cargo_metadata::{Metadata, Package, PackageId}; | |
| 9 | ||
| 9 | 10 | /// These are licenses that are allowed for all crates, including the runtime, |
| 10 | 11 | /// rustc, tools, etc. |
| 11 | 12 | #[rustfmt::skip] |
src/tools/tidy/src/edition.rs+2-1| ... | ... | @@ -1,8 +1,9 @@ |
| 1 | 1 | //! Tidy check to ensure that crate `edition` is '2018' or '2021'. |
| 2 | 2 | |
| 3 | use crate::walk::{filter_dirs, walk}; | |
| 4 | 3 | use std::path::Path; |
| 5 | 4 | |
| 5 | use crate::walk::{filter_dirs, walk}; | |
| 6 | ||
| 6 | 7 | fn is_edition_2021(mut line: &str) -> bool { |
| 7 | 8 | line = line.trim(); |
| 8 | 9 | line == "edition = \"2021\"" |
src/tools/tidy/src/error_codes.rs+3-1| ... | ... | @@ -16,7 +16,9 @@ |
| 16 | 16 | //! 4. We check that the error code is actually emitted by the compiler. |
| 17 | 17 | //! - This is done by searching `compiler/` with a regex. |
| 18 | 18 | |
| 19 | use std::{ffi::OsStr, fs, path::Path}; | |
| 19 | use std::ffi::OsStr; | |
| 20 | use std::fs; | |
| 21 | use std::path::Path; | |
| 20 | 22 | |
| 21 | 23 | use regex::Regex; |
| 22 | 24 |
src/tools/tidy/src/ext_tool_checks.rs+1-3| ... | ... | @@ -18,11 +18,9 @@ |
| 18 | 18 | //! is set, rerun the tool to print a suggestion diff (for e.g. CI) |
| 19 | 19 | |
| 20 | 20 | use std::ffi::OsStr; |
| 21 | use std::fmt; | |
| 22 | use std::fs; | |
| 23 | use std::io; | |
| 24 | 21 | use std::path::{Path, PathBuf}; |
| 25 | 22 | use std::process::Command; |
| 23 | use std::{fmt, fs, io}; | |
| 26 | 24 | |
| 27 | 25 | const MIN_PY_REV: (u32, u32) = (3, 9); |
| 28 | 26 | const MIN_PY_REV_STR: &str = "≥3.9"; |
src/tools/tidy/src/features.rs+3-3| ... | ... | @@ -9,13 +9,13 @@ |
| 9 | 9 | //! * All unstable lang features have tests to ensure they are actually unstable. |
| 10 | 10 | //! * Language features in a group are sorted by feature name. |
| 11 | 11 | |
| 12 | use crate::walk::{filter_dirs, filter_not_rust, walk, walk_many}; | |
| 13 | 12 | use std::collections::hash_map::{Entry, HashMap}; |
| 14 | 13 | use std::ffi::OsStr; |
| 15 | use std::fmt; | |
| 16 | use std::fs; | |
| 17 | 14 | use std::num::NonZeroU32; |
| 18 | 15 | use std::path::{Path, PathBuf}; |
| 16 | use std::{fmt, fs}; | |
| 17 | ||
| 18 | use crate::walk::{filter_dirs, filter_not_rust, walk, walk_many}; | |
| 19 | 19 | |
| 20 | 20 | #[cfg(test)] |
| 21 | 21 | mod tests; |
src/tools/tidy/src/fluent_alphabetical.rs+5-2| ... | ... | @@ -1,11 +1,14 @@ |
| 1 | 1 | //! Checks that all Flunt files have messages in alphabetical order |
| 2 | 2 | |
| 3 | use crate::walk::{filter_dirs, walk}; | |
| 4 | 3 | use std::collections::HashMap; |
| 5 | use std::{fs::OpenOptions, io::Write, path::Path}; | |
| 4 | use std::fs::OpenOptions; | |
| 5 | use std::io::Write; | |
| 6 | use std::path::Path; | |
| 6 | 7 | |
| 7 | 8 | use regex::Regex; |
| 8 | 9 | |
| 10 | use crate::walk::{filter_dirs, walk}; | |
| 11 | ||
| 9 | 12 | fn message() -> &'static Regex { |
| 10 | 13 | static_regex!(r#"(?m)^([a-zA-Z0-9_]+)\s*=\s*"#) |
| 11 | 14 | } |
src/tools/tidy/src/fluent_period.rs+2-1| ... | ... | @@ -1,9 +1,10 @@ |
| 1 | 1 | //! Checks that no Fluent messages or attributes end in periods (except ellipses) |
| 2 | 2 | |
| 3 | use std::path::Path; | |
| 4 | ||
| 3 | 5 | use fluent_syntax::ast::{Entry, PatternElement}; |
| 4 | 6 | |
| 5 | 7 | use crate::walk::{filter_dirs, walk}; |
| 6 | use std::path::Path; | |
| 7 | 8 | |
| 8 | 9 | fn filter_fluent(path: &Path) -> bool { |
| 9 | 10 | if let Some(ext) = path.extension() { ext.to_str() != Some("ftl") } else { true } |
src/tools/tidy/src/fluent_used.rs+2-1| ... | ... | @@ -1,9 +1,10 @@ |
| 1 | 1 | //! Checks that all Fluent messages appear at least twice |
| 2 | 2 | |
| 3 | use crate::walk::{filter_dirs, walk}; | |
| 4 | 3 | use std::collections::HashMap; |
| 5 | 4 | use std::path::Path; |
| 6 | 5 | |
| 6 | use crate::walk::{filter_dirs, walk}; | |
| 7 | ||
| 7 | 8 | fn filter_used_messages( |
| 8 | 9 | contents: &str, |
| 9 | 10 | msgs_not_appeared_yet: &mut HashMap<String, String>, |
src/tools/tidy/src/known_bug.rs+2-1| ... | ... | @@ -1,8 +1,9 @@ |
| 1 | 1 | //! Tidy check to ensure that tests inside 'tests/crashes' have a '@known-bug' directive. |
| 2 | 2 | |
| 3 | use crate::walk::*; | |
| 4 | 3 | use std::path::Path; |
| 5 | 4 | |
| 5 | use crate::walk::*; | |
| 6 | ||
| 6 | 7 | pub fn check(filepath: &Path, bad: &mut bool) { |
| 7 | 8 | walk(filepath, |path, _is_dir| filter_not_rust(path), &mut |entry, contents| { |
| 8 | 9 | let file = entry.path(); |
src/tools/tidy/src/lib.rs+1| ... | ... | @@ -50,6 +50,7 @@ macro_rules! tidy_error_ext { |
| 50 | 50 | |
| 51 | 51 | fn tidy_error(args: &str) -> std::io::Result<()> { |
| 52 | 52 | use std::io::Write; |
| 53 | ||
| 53 | 54 | use termcolor::{Color, ColorChoice, ColorSpec, StandardStream}; |
| 54 | 55 | |
| 55 | 56 | let mut stderr = StandardStream::stdout(ColorChoice::Auto); |
src/tools/tidy/src/main.rs+3-4| ... | ... | @@ -4,16 +4,15 @@ |
| 4 | 4 | //! etc. This is run by default on `./x.py test` and as part of the auto |
| 5 | 5 | //! builders. The tidy checks can be executed with `./x.py test tidy`. |
| 6 | 6 | |
| 7 | use tidy::*; | |
| 8 | ||
| 9 | 7 | use std::collections::VecDeque; |
| 10 | use std::env; | |
| 11 | 8 | use std::num::NonZeroUsize; |
| 12 | 9 | use std::path::PathBuf; |
| 13 | use std::process; | |
| 14 | 10 | use std::str::FromStr; |
| 15 | 11 | use std::sync::atomic::{AtomicBool, Ordering}; |
| 16 | 12 | use std::thread::{self, scope, ScopedJoinHandle}; |
| 13 | use std::{env, process}; | |
| 14 | ||
| 15 | use tidy::*; | |
| 17 | 16 | |
| 18 | 17 | fn main() { |
| 19 | 18 | // Running Cargo will read the libstd Cargo.toml |
src/tools/tidy/src/mir_opt_tests.rs+2-1| ... | ... | @@ -1,9 +1,10 @@ |
| 1 | 1 | //! Tidy check to ensure that mir opt directories do not have stale files or dashes in file names |
| 2 | 2 | |
| 3 | use miropt_test_tools::PanicStrategy; | |
| 4 | 3 | use std::collections::HashSet; |
| 5 | 4 | use std::path::{Path, PathBuf}; |
| 6 | 5 | |
| 6 | use miropt_test_tools::PanicStrategy; | |
| 7 | ||
| 7 | 8 | use crate::walk::walk_no_read; |
| 8 | 9 | |
| 9 | 10 | fn check_unused_files(path: &Path, bless: bool, bad: &mut bool) { |
src/tools/tidy/src/pal.rs+2-1| ... | ... | @@ -30,9 +30,10 @@ |
| 30 | 30 | //! platform-specific cfgs are allowed. Not sure yet how to deal with |
| 31 | 31 | //! this in the long term. |
| 32 | 32 | |
| 33 | use crate::walk::{filter_dirs, walk}; | |
| 34 | 33 | use std::path::Path; |
| 35 | 34 | |
| 35 | use crate::walk::{filter_dirs, walk}; | |
| 36 | ||
| 36 | 37 | // Paths that may contain platform-specific code. |
| 37 | 38 | const EXCEPTION_PATHS: &[&str] = &[ |
| 38 | 39 | "library/panic_abort", |
src/tools/tidy/src/style.rs+6-2| ... | ... | @@ -17,10 +17,14 @@ |
| 17 | 17 | //! `// ignore-tidy-CHECK-NAME`. |
| 18 | 18 | // ignore-tidy-dbg |
| 19 | 19 | |
| 20 | use crate::walk::{filter_dirs, walk}; | |
| 20 | use std::ffi::OsStr; | |
| 21 | use std::path::Path; | |
| 22 | use std::sync::LazyLock; | |
| 23 | ||
| 21 | 24 | use regex::RegexSetBuilder; |
| 22 | 25 | use rustc_hash::FxHashMap; |
| 23 | use std::{ffi::OsStr, path::Path, sync::LazyLock}; | |
| 26 | ||
| 27 | use crate::walk::{filter_dirs, walk}; | |
| 24 | 28 | |
| 25 | 29 | #[cfg(test)] |
| 26 | 30 | mod tests; |
src/tools/tidy/src/target_policy.rs+3-1| ... | ... | @@ -2,8 +2,10 @@ |
| 2 | 2 | //! |
| 3 | 3 | //! As of writing, only checks that sanity-check assembly test for targets doesn't miss any targets. |
| 4 | 4 | |
| 5 | use std::collections::HashSet; | |
| 6 | use std::path::Path; | |
| 7 | ||
| 5 | 8 | use crate::walk::{filter_not_rust, walk}; |
| 6 | use std::{collections::HashSet, path::Path}; | |
| 7 | 9 | |
| 8 | 10 | const TARGET_DEFINITIONS_PATH: &str = "compiler/rustc_target/src/spec/targets/"; |
| 9 | 11 | const ASSEMBLY_TEST_PATH: &str = "tests/assembly/targets/"; |
src/tools/tidy/src/ui_tests.rs+2-1| ... | ... | @@ -2,13 +2,14 @@ |
| 2 | 2 | //! - the number of entries in each directory must be less than `ENTRY_LIMIT` |
| 3 | 3 | //! - there are no stray `.stderr` files |
| 4 | 4 | |
| 5 | use ignore::Walk; | |
| 6 | 5 | use std::collections::{BTreeSet, HashMap}; |
| 7 | 6 | use std::ffi::OsStr; |
| 8 | 7 | use std::fs; |
| 9 | 8 | use std::io::Write; |
| 10 | 9 | use std::path::{Path, PathBuf}; |
| 11 | 10 | |
| 11 | use ignore::Walk; | |
| 12 | ||
| 12 | 13 | // FIXME: GitHub's UI truncates file lists that exceed 1000 entries, so these |
| 13 | 14 | // should all be 1000 or lower. Limits significantly smaller than 1000 are also |
| 14 | 15 | // desirable, because large numbers of files are unwieldy in general. See issue |
src/tools/tidy/src/unit_tests.rs+2-1| ... | ... | @@ -7,9 +7,10 @@ |
| 7 | 7 | //! named `tests.rs` or `benches.rs`, or directories named `tests` or `benches` unconfigured |
| 8 | 8 | //! during normal build. |
| 9 | 9 | |
| 10 | use crate::walk::{filter_dirs, walk}; | |
| 11 | 10 | use std::path::Path; |
| 12 | 11 | |
| 12 | use crate::walk::{filter_dirs, walk}; | |
| 13 | ||
| 13 | 14 | pub fn check(root_path: &Path, bad: &mut bool) { |
| 14 | 15 | let core = root_path.join("core"); |
| 15 | 16 | let core_copy = core.clone(); |
src/tools/tidy/src/unstable_book.rs+2-1| ... | ... | @@ -1,8 +1,9 @@ |
| 1 | use crate::features::{CollectedFeatures, Features, Status}; | |
| 2 | 1 | use std::collections::BTreeSet; |
| 3 | 2 | use std::fs; |
| 4 | 3 | use std::path::{Path, PathBuf}; |
| 5 | 4 | |
| 5 | use crate::features::{CollectedFeatures, Features, Status}; | |
| 6 | ||
| 6 | 7 | pub const PATH_STR: &str = "doc/unstable-book"; |
| 7 | 8 | |
| 8 | 9 | pub const COMPILER_FLAGS_DIR: &str = "src/compiler-flags"; |
src/tools/tidy/src/walk.rs+5-2| ... | ... | @@ -1,6 +1,9 @@ |
| 1 | use ignore::DirEntry; | |
| 1 | use std::ffi::OsStr; | |
| 2 | use std::fs::File; | |
| 3 | use std::io::Read; | |
| 4 | use std::path::Path; | |
| 2 | 5 | |
| 3 | use std::{ffi::OsStr, fs::File, io::Read, path::Path}; | |
| 6 | use ignore::DirEntry; | |
| 4 | 7 | |
| 5 | 8 | /// The default directory filter. |
| 6 | 9 | pub fn filter_dirs(path: &Path) -> bool { |
src/tools/tidy/src/x_version.rs+2-1| ... | ... | @@ -1,7 +1,8 @@ |
| 1 | use semver::Version; | |
| 2 | 1 | use std::path::Path; |
| 3 | 2 | use std::process::{Command, Stdio}; |
| 4 | 3 | |
| 4 | use semver::Version; | |
| 5 | ||
| 5 | 6 | pub fn check(root: &Path, cargo: &Path, bad: &mut bool) { |
| 6 | 7 | let cargo_list = Command::new(cargo).args(["install", "--list"]).stdout(Stdio::piped()).spawn(); |
| 7 | 8 |
src/tools/unicode-table-generator/src/cascading_map.rs+3-2| ... | ... | @@ -1,9 +1,10 @@ |
| 1 | use crate::fmt_list; | |
| 2 | use crate::raw_emitter::RawEmitter; | |
| 3 | 1 | use std::collections::HashMap; |
| 4 | 2 | use std::fmt::Write as _; |
| 5 | 3 | use std::ops::Range; |
| 6 | 4 | |
| 5 | use crate::fmt_list; | |
| 6 | use crate::raw_emitter::RawEmitter; | |
| 7 | ||
| 7 | 8 | impl RawEmitter { |
| 8 | 9 | pub fn emit_cascading_map(&mut self, ranges: &[Range<u32>]) -> bool { |
| 9 | 10 | let mut map: [u8; 256] = [ |
src/tools/unicode-table-generator/src/case_mapping.rs+4-5| ... | ... | @@ -1,9 +1,8 @@ |
| 1 | use std::char; | |
| 2 | use std::collections::BTreeMap; | |
| 3 | use std::fmt::{self, Write}; | |
| 4 | ||
| 1 | 5 | use crate::{fmt_list, UnicodeData}; |
| 2 | use std::{ | |
| 3 | char, | |
| 4 | collections::BTreeMap, | |
| 5 | fmt::{self, Write}, | |
| 6 | }; | |
| 7 | 6 | |
| 8 | 7 | const INDEX_MASK: u32 = 1 << 22; |
| 9 | 8 |
src/tools/unicode-table-generator/src/main.rs+1| ... | ... | @@ -73,6 +73,7 @@ |
| 73 | 73 | |
| 74 | 74 | use std::collections::{BTreeMap, HashMap}; |
| 75 | 75 | use std::ops::Range; |
| 76 | ||
| 76 | 77 | use ucd_parse::Codepoints; |
| 77 | 78 | |
| 78 | 79 | mod cascading_map; |
src/tools/unicode-table-generator/src/raw_emitter.rs+2-1| ... | ... | @@ -1,8 +1,9 @@ |
| 1 | use crate::fmt_list; | |
| 2 | 1 | use std::collections::{BTreeMap, BTreeSet, HashMap}; |
| 3 | 2 | use std::fmt::{self, Write}; |
| 4 | 3 | use std::ops::Range; |
| 5 | 4 | |
| 5 | use crate::fmt_list; | |
| 6 | ||
| 6 | 7 | #[derive(Clone)] |
| 7 | 8 | pub struct RawEmitter { |
| 8 | 9 | pub file: String, |
src/tools/unicode-table-generator/src/skiplist.rs+3-2| ... | ... | @@ -1,8 +1,9 @@ |
| 1 | use crate::fmt_list; | |
| 2 | use crate::raw_emitter::RawEmitter; | |
| 3 | 1 | use std::fmt::Write as _; |
| 4 | 2 | use std::ops::Range; |
| 5 | 3 | |
| 4 | use crate::fmt_list; | |
| 5 | use crate::raw_emitter::RawEmitter; | |
| 6 | ||
| 6 | 7 | /// This will get packed into a single u32 before inserting into the data set. |
| 7 | 8 | #[derive(Debug, PartialEq)] |
| 8 | 9 | struct ShortOffsetRunHeader { |
src/tools/unicode-table-generator/src/unicode_download.rs+2-1| ... | ... | @@ -1,7 +1,8 @@ |
| 1 | use crate::UNICODE_DIRECTORY; | |
| 2 | 1 | use std::path::Path; |
| 3 | 2 | use std::process::{Command, Output}; |
| 4 | 3 | |
| 4 | use crate::UNICODE_DIRECTORY; | |
| 5 | ||
| 5 | 6 | static URL_PREFIX: &str = "https://www.unicode.org/Public/UCD/latest/ucd/"; |
| 6 | 7 | |
| 7 | 8 | static README: &str = "ReadMe.txt"; |
src/tools/unstable-book-gen/src/main.rs+1| ... | ... | @@ -4,6 +4,7 @@ use std::collections::BTreeSet; |
| 4 | 4 | use std::env; |
| 5 | 5 | use std::fs::{self, write}; |
| 6 | 6 | use std::path::Path; |
| 7 | ||
| 7 | 8 | use tidy::features::{collect_lang_features, collect_lib_features, Features}; |
| 8 | 9 | use tidy::t; |
| 9 | 10 | use tidy::unstable_book::{ |
src/tools/x/src/main.rs+5-6| ... | ... | @@ -8,12 +8,11 @@ |
| 8 | 8 | //! the ones that call `x.py`. We use `sh -c` on Unix, because it is a standard. |
| 9 | 9 | //! We also don't use `pwsh` on Windows, because it is not installed by default; |
| 10 | 10 | |
| 11 | use std::{ | |
| 12 | env::{self, consts::EXE_EXTENSION}, | |
| 13 | io, | |
| 14 | path::Path, | |
| 15 | process::{self, Command, ExitStatus}, | |
| 16 | }; | |
| 11 | use std::env::consts::EXE_EXTENSION; | |
| 12 | use std::env::{self}; | |
| 13 | use std::io; | |
| 14 | use std::path::Path; | |
| 15 | use std::process::{self, Command, ExitStatus}; | |
| 17 | 16 | |
| 18 | 17 | const PYTHON: &str = "python"; |
| 19 | 18 | const PYTHON2: &str = "python2"; |
tests/assembly/asm/aarch64-outline-atomics.rs+2-1| ... | ... | @@ -7,7 +7,8 @@ |
| 7 | 7 | |
| 8 | 8 | #![crate_type = "rlib"] |
| 9 | 9 | |
| 10 | use std::sync::atomic::{AtomicI32, Ordering::*}; | |
| 10 | use std::sync::atomic::AtomicI32; | |
| 11 | use std::sync::atomic::Ordering::*; | |
| 11 | 12 | |
| 12 | 13 | pub fn compare_exchange(a: &AtomicI32) { |
| 13 | 14 | // On AArch64 LLVM should outline atomic operations. |
tests/codegen/atomic-operations.rs+2-1| ... | ... | @@ -2,7 +2,8 @@ |
| 2 | 2 | //@ compile-flags: -O |
| 3 | 3 | #![crate_type = "lib"] |
| 4 | 4 | |
| 5 | use std::sync::atomic::{AtomicI32, Ordering::*}; | |
| 5 | use std::sync::atomic::AtomicI32; | |
| 6 | use std::sync::atomic::Ordering::*; | |
| 6 | 7 | |
| 7 | 8 | // CHECK-LABEL: @compare_exchange |
| 8 | 9 | #[no_mangle] |
tests/codegen/intrinsics/transmute.rs+2-3| ... | ... | @@ -6,11 +6,10 @@ |
| 6 | 6 | #![feature(custom_mir)] |
| 7 | 7 | #![allow(unreachable_code)] |
| 8 | 8 | |
| 9 | use std::intrinsics::{transmute, transmute_unchecked}; | |
| 10 | use std::mem::MaybeUninit; | |
| 11 | ||
| 12 | 9 | // Some of these need custom MIR to not get removed by MIR optimizations. |
| 13 | 10 | use std::intrinsics::mir::*; |
| 11 | use std::intrinsics::{transmute, transmute_unchecked}; | |
| 12 | use std::mem::MaybeUninit; | |
| 14 | 13 | |
| 15 | 14 | pub enum ZstNever {} |
| 16 | 15 |
tests/mir-opt/dont_inline_type_id.rs+1-2| ... | ... | @@ -2,8 +2,7 @@ |
| 2 | 2 | //@ test-mir-pass: Inline |
| 3 | 3 | //@ compile-flags: --crate-type=lib -C panic=abort |
| 4 | 4 | |
| 5 | use std::any::Any; | |
| 6 | use std::any::TypeId; | |
| 5 | use std::any::{Any, TypeId}; | |
| 7 | 6 | |
| 8 | 7 | struct A<T: ?Sized + 'static> { |
| 9 | 8 | a: i32, |
tests/run-make/branch-protection-check-IBT/_rmake.rs+1-3| ... | ... | @@ -8,9 +8,7 @@ |
| 8 | 8 | //@ ignore-test |
| 9 | 9 | // FIXME(jieyouxu): see the FIXME in the Makefile |
| 10 | 10 | |
| 11 | use run_make_support::llvm_readobj; | |
| 12 | use run_make_support::rustc; | |
| 13 | use run_make_support::{cwd, env_var}; | |
| 11 | use run_make_support::{cwd, env_var, llvm_readobj, rustc}; | |
| 14 | 12 | |
| 15 | 13 | fn main() { |
| 16 | 14 | let llvm_components = env_var("LLVM_COMPONENTS"); |
tests/run-make/c-link-to-rust-staticlib/rmake.rs+2-1| ... | ... | @@ -3,9 +3,10 @@ |
| 3 | 3 | |
| 4 | 4 | //@ ignore-cross-compile |
| 5 | 5 | |
| 6 | use std::fs; | |
| 7 | ||
| 6 | 8 | use run_make_support::rfs::remove_file; |
| 7 | 9 | use run_make_support::{cc, extra_c_flags, run, rustc, static_lib_name}; |
| 8 | use std::fs; | |
| 9 | 10 | |
| 10 | 11 | fn main() { |
| 11 | 12 | rustc().input("foo.rs").run(); |
tests/run-make/c-link-to-rust-va-list-fn/checkrust.rs+1-3| ... | ... | @@ -1,9 +1,7 @@ |
| 1 | 1 | #![crate_type = "staticlib"] |
| 2 | 2 | #![feature(c_variadic)] |
| 3 | 3 | |
| 4 | use std::ffi::VaList; | |
| 5 | use std::ffi::{c_char, c_double, c_int, c_long, c_longlong}; | |
| 6 | use std::ffi::{CStr, CString}; | |
| 4 | use std::ffi::{c_char, c_double, c_int, c_long, c_longlong, CStr, CString, VaList}; | |
| 7 | 5 | |
| 8 | 6 | macro_rules! continue_if { |
| 9 | 7 | ($cond:expr) => { |
tests/run-make/comment-section/rmake.rs+1-4| ... | ... | @@ -9,10 +9,7 @@ |
| 9 | 9 | |
| 10 | 10 | use std::path::PathBuf; |
| 11 | 11 | |
| 12 | use run_make_support::llvm_readobj; | |
| 13 | use run_make_support::rfs; | |
| 14 | use run_make_support::rustc; | |
| 15 | use run_make_support::{cwd, env_var, run_in_tmpdir}; | |
| 12 | use run_make_support::{cwd, env_var, llvm_readobj, rfs, run_in_tmpdir, rustc}; | |
| 16 | 13 | |
| 17 | 14 | fn main() { |
| 18 | 15 | let target = env_var("TARGET"); |
tests/run-make/compiler-builtins/rmake.rs+4-5| ... | ... | @@ -14,15 +14,14 @@ |
| 14 | 14 | |
| 15 | 15 | #![deny(warnings)] |
| 16 | 16 | |
| 17 | use std::collections::HashSet; | |
| 18 | use std::path::PathBuf; | |
| 19 | ||
| 17 | 20 | use run_make_support::object::read::archive::ArchiveFile; |
| 18 | 21 | use run_make_support::object::read::Object; |
| 19 | use run_make_support::object::ObjectSection; | |
| 20 | use run_make_support::object::ObjectSymbol; | |
| 21 | use run_make_support::object::RelocationTarget; | |
| 22 | use run_make_support::object::{ObjectSection, ObjectSymbol, RelocationTarget}; | |
| 22 | 23 | use run_make_support::rfs::{read, read_dir}; |
| 23 | 24 | use run_make_support::{cmd, env_var, object}; |
| 24 | use std::collections::HashSet; | |
| 25 | use std::path::PathBuf; | |
| 26 | 25 | |
| 27 | 26 | fn main() { |
| 28 | 27 | let target_dir = PathBuf::from("target"); |
tests/run-make/crate-hash-rustc-version/rmake.rs+1-2| ... | ... | @@ -4,8 +4,7 @@ |
| 4 | 4 | //@ ignore-cross-compile |
| 5 | 5 | //@ only-unix |
| 6 | 6 | |
| 7 | use run_make_support::llvm; | |
| 8 | use run_make_support::{diff, dynamic_lib_name, is_darwin, run, run_fail, rustc}; | |
| 7 | use run_make_support::{diff, dynamic_lib_name, is_darwin, llvm, run, run_fail, rustc}; | |
| 9 | 8 | |
| 10 | 9 | fn llvm_readobj() -> llvm::LlvmReadobj { |
| 11 | 10 | let mut cmd = llvm::llvm_readobj(); |
tests/run-make/cross-lang-lto-riscv-abi/rmake.rs+4-6| ... | ... | @@ -6,13 +6,11 @@ |
| 6 | 6 | // FIXME(#126180): This test doesn't actually run anywhere, because the only |
| 7 | 7 | // CI job that sets RUSTBUILD_FORCE_CLANG_BASED_TESTS runs very few tests. |
| 8 | 8 | |
| 9 | use std::path::PathBuf; | |
| 10 | use std::process::{Command, Output}; | |
| 11 | use std::{env, str}; | |
| 12 | ||
| 9 | 13 | use run_make_support::{bin_name, clang, llvm_readobj, rustc}; |
| 10 | use std::{ | |
| 11 | env, | |
| 12 | path::PathBuf, | |
| 13 | process::{Command, Output}, | |
| 14 | str, | |
| 15 | }; | |
| 16 | 14 | |
| 17 | 15 | fn check_target(target: &str, clang_target: &str, carch: &str, is_double_float: bool) { |
| 18 | 16 | eprintln!("Checking target {target}"); |
tests/run-make/doctests-keep-binaries/rmake.rs+2-1| ... | ... | @@ -1,9 +1,10 @@ |
| 1 | 1 | // Check that valid binaries are persisted by running them, regardless of whether the |
| 2 | 2 | // --run or --no-run option is used. |
| 3 | 3 | |
| 4 | use std::path::Path; | |
| 5 | ||
| 4 | 6 | use run_make_support::rfs::{create_dir, remove_dir_all}; |
| 5 | 7 | use run_make_support::{run, rustc, rustdoc}; |
| 6 | use std::path::Path; | |
| 7 | 8 | |
| 8 | 9 | fn setup_test_env<F: FnOnce(&Path, &Path)>(callback: F) { |
| 9 | 10 | let out_dir = Path::new("doctests"); |
tests/run-make/doctests-runtool/rmake.rs+2-1| ... | ... | @@ -1,8 +1,9 @@ |
| 1 | 1 | // Tests behavior of rustdoc `--runtool`. |
| 2 | 2 | |
| 3 | use std::path::PathBuf; | |
| 4 | ||
| 3 | 5 | use run_make_support::rfs::{create_dir, remove_dir_all}; |
| 4 | 6 | use run_make_support::{rustc, rustdoc}; |
| 5 | use std::path::PathBuf; | |
| 6 | 7 | |
| 7 | 8 | fn mkdir(name: &str) -> PathBuf { |
| 8 | 9 | let dir = PathBuf::from(name); |
tests/run-make/emit-shared-files/rmake.rs+2-1| ... | ... | @@ -5,9 +5,10 @@ |
| 5 | 5 | // `all-shared` should only emit files that can be shared between crates. |
| 6 | 6 | // See https://github.com/rust-lang/rust/pull/83478 |
| 7 | 7 | |
| 8 | use run_make_support::{has_extension, has_prefix, rustdoc, shallow_find_files}; | |
| 9 | 8 | use std::path::Path; |
| 10 | 9 | |
| 10 | use run_make_support::{has_extension, has_prefix, rustdoc, shallow_find_files}; | |
| 11 | ||
| 11 | 12 | fn main() { |
| 12 | 13 | rustdoc() |
| 13 | 14 | .arg("-Zunstable-options") |
tests/run-make/incr-prev-body-beyond-eof/rmake.rs+1-2| ... | ... | @@ -13,8 +13,7 @@ |
| 13 | 13 | //@ ignore-nvptx64-nvidia-cuda |
| 14 | 14 | // FIXME: can't find crate for `std` |
| 15 | 15 | |
| 16 | use run_make_support::rfs; | |
| 17 | use run_make_support::rustc; | |
| 16 | use run_make_support::{rfs, rustc}; | |
| 18 | 17 | |
| 19 | 18 | fn main() { |
| 20 | 19 | rfs::create_dir("src"); |
tests/run-make/incremental-debugger-visualizer/rmake.rs+2-1| ... | ... | @@ -2,9 +2,10 @@ |
| 2 | 2 | // (in this case, foo.py and foo.natvis) are picked up when compiling incrementally. |
| 3 | 3 | // See https://github.com/rust-lang/rust/pull/111641 |
| 4 | 4 | |
| 5 | use run_make_support::{invalid_utf8_contains, invalid_utf8_not_contains, rfs, rustc}; | |
| 6 | 5 | use std::io::Read; |
| 7 | 6 | |
| 7 | use run_make_support::{invalid_utf8_contains, invalid_utf8_not_contains, rfs, rustc}; | |
| 8 | ||
| 8 | 9 | fn main() { |
| 9 | 10 | rfs::create_file("foo.py"); |
| 10 | 11 | rfs::write("foo.py", "GDB script v1"); |
tests/run-make/inline-always-many-cgu/rmake.rs+3-4| ... | ... | @@ -1,9 +1,8 @@ |
| 1 | use run_make_support::regex::Regex; | |
| 2 | use run_make_support::rfs; | |
| 3 | use run_make_support::rustc; | |
| 4 | ||
| 5 | 1 | use std::ffi::OsStr; |
| 6 | 2 | |
| 3 | use run_make_support::regex::Regex; | |
| 4 | use run_make_support::{rfs, rustc}; | |
| 5 | ||
| 7 | 6 | fn main() { |
| 8 | 7 | rustc().input("foo.rs").emit("llvm-ir").codegen_units(2).run(); |
| 9 | 8 | let re = Regex::new(r"\bcall\b").unwrap(); |
tests/run-make/intrinsic-unreachable/exit-unreachable.rs-1| ... | ... | @@ -1,7 +1,6 @@ |
| 1 | 1 | #![feature(core_intrinsics)] |
| 2 | 2 | #![crate_type = "lib"] |
| 3 | 3 | use std::arch::asm; |
| 4 | ||
| 5 | 4 | use std::intrinsics; |
| 6 | 5 | |
| 7 | 6 | #[allow(unreachable_code)] |
tests/run-make/invalid-library/rmake.rs+1-2| ... | ... | @@ -4,8 +4,7 @@ |
| 4 | 4 | // one appearing in stderr in this scenario. |
| 5 | 5 | // See https://github.com/rust-lang/rust/pull/12645 |
| 6 | 6 | |
| 7 | use run_make_support::rfs; | |
| 8 | use run_make_support::{llvm_ar, rustc}; | |
| 7 | use run_make_support::{llvm_ar, rfs, rustc}; | |
| 9 | 8 | |
| 10 | 9 | fn main() { |
| 11 | 10 | rfs::create_file("lib.rmeta"); |
tests/run-make/issue-107495-archive-permissions/rmake.rs+2-2| ... | ... | @@ -3,12 +3,12 @@ |
| 3 | 3 | #[cfg(unix)] |
| 4 | 4 | extern crate libc; |
| 5 | 5 | |
| 6 | use run_make_support::{aux_build, rfs}; | |
| 7 | ||
| 8 | 6 | #[cfg(unix)] |
| 9 | 7 | use std::os::unix::fs::PermissionsExt; |
| 10 | 8 | use std::path::Path; |
| 11 | 9 | |
| 10 | use run_make_support::{aux_build, rfs}; | |
| 11 | ||
| 12 | 12 | fn main() { |
| 13 | 13 | #[cfg(unix)] |
| 14 | 14 | unsafe { |
tests/run-make/lib-trait-for-trait-no-ice/rmake.rs+2-1| ... | ... | @@ -5,9 +5,10 @@ |
| 5 | 5 | // the lib crate-type flag was actually followed. |
| 6 | 6 | // See https://github.com/rust-lang/rust/issues/18943 |
| 7 | 7 | |
| 8 | use run_make_support::{rust_lib_name, rustc}; | |
| 9 | 8 | use std::path::Path; |
| 10 | 9 | |
| 10 | use run_make_support::{rust_lib_name, rustc}; | |
| 11 | ||
| 11 | 12 | fn main() { |
| 12 | 13 | rustc().input("foo.rs").crate_type("lib").run(); |
| 13 | 14 | assert!(Path::new(&rust_lib_name("foo")).exists()); |
tests/run-make/libtest-thread-limit/test.rs+3-5| ... | ... | @@ -1,8 +1,6 @@ |
| 1 | use std::{ | |
| 2 | io::ErrorKind, | |
| 3 | sync::OnceLock, | |
| 4 | thread::{self, Builder, ThreadId}, | |
| 5 | }; | |
| 1 | use std::io::ErrorKind; | |
| 2 | use std::sync::OnceLock; | |
| 3 | use std::thread::{self, Builder, ThreadId}; | |
| 6 | 4 | |
| 7 | 5 | static THREAD_ID: OnceLock<ThreadId> = OnceLock::new(); |
| 8 | 6 |
tests/run-make/llvm-outputs/rmake.rs+2-1| ... | ... | @@ -1,8 +1,9 @@ |
| 1 | 1 | // test that directories get created when emitting llvm bitcode and IR |
| 2 | 2 | |
| 3 | use run_make_support::{cwd, run_in_tmpdir, rustc}; | |
| 4 | 3 | use std::path::PathBuf; |
| 5 | 4 | |
| 5 | use run_make_support::{cwd, run_in_tmpdir, rustc}; | |
| 6 | ||
| 6 | 7 | fn main() { |
| 7 | 8 | let mut path_bc = PathBuf::new(); |
| 8 | 9 | let mut path_ir = PathBuf::new(); |
tests/run-make/ls-metadata/rmake.rs+1-2| ... | ... | @@ -6,8 +6,7 @@ |
| 6 | 6 | |
| 7 | 7 | //@ ignore-cross-compile |
| 8 | 8 | |
| 9 | use run_make_support::rfs; | |
| 10 | use run_make_support::rustc; | |
| 9 | use run_make_support::{rfs, rustc}; | |
| 11 | 10 | |
| 12 | 11 | fn main() { |
| 13 | 12 | rustc().input("foo.rs").run(); |
tests/run-make/lto-readonly-lib/rmake.rs+1-2| ... | ... | @@ -7,8 +7,7 @@ |
| 7 | 7 | |
| 8 | 8 | //@ ignore-cross-compile |
| 9 | 9 | |
| 10 | use run_make_support::rfs; | |
| 11 | use run_make_support::{run, rust_lib_name, rustc, test_while_readonly}; | |
| 10 | use run_make_support::{rfs, run, rust_lib_name, rustc, test_while_readonly}; | |
| 12 | 11 | |
| 13 | 12 | fn main() { |
| 14 | 13 | rustc().input("lib.rs").run(); |
tests/run-make/manual-crate-name/rmake.rs+2-1| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | use run_make_support::rustc; | |
| 2 | 1 | use std::path::Path; |
| 3 | 2 | |
| 3 | use run_make_support::rustc; | |
| 4 | ||
| 4 | 5 | fn main() { |
| 5 | 6 | rustc().input("bar.rs").crate_name("foo").run(); |
| 6 | 7 | assert!(Path::new("libfoo.rlib").is_file()); |
tests/run-make/no-intermediate-extras/rmake.rs+2-1| ... | ... | @@ -5,9 +5,10 @@ |
| 5 | 5 | |
| 6 | 6 | //@ ignore-cross-compile |
| 7 | 7 | |
| 8 | use run_make_support::rustc; | |
| 9 | 8 | use std::fs; |
| 10 | 9 | |
| 10 | use run_make_support::rustc; | |
| 11 | ||
| 11 | 12 | fn main() { |
| 12 | 13 | rustc().crate_type("rlib").arg("--test").input("foo.rs").run(); |
| 13 | 14 | assert!( |
tests/run-make/non-unicode-env/rmake.rs+1-2| ... | ... | @@ -1,5 +1,4 @@ |
| 1 | use run_make_support::rfs; | |
| 2 | use run_make_support::rustc; | |
| 1 | use run_make_support::{rfs, rustc}; | |
| 3 | 2 | |
| 4 | 3 | fn main() { |
| 5 | 4 | #[cfg(unix)] |
tests/run-make/obey-crate-type-flag/rmake.rs+2-1| ... | ... | @@ -5,10 +5,11 @@ |
| 5 | 5 | |
| 6 | 6 | //@ ignore-cross-compile |
| 7 | 7 | |
| 8 | use std::path::Path; | |
| 9 | ||
| 8 | 10 | use run_make_support::{ |
| 9 | 11 | cwd, dynamic_lib_name, has_extension, rfs, rust_lib_name, rustc, shallow_find_files, |
| 10 | 12 | }; |
| 11 | use std::path::Path; | |
| 12 | 13 | |
| 13 | 14 | fn main() { |
| 14 | 15 | rustc().input("test.rs").run(); |
tests/run-make/output-type-permutations/rmake.rs+2-1| ... | ... | @@ -4,11 +4,12 @@ |
| 4 | 4 | // files are exactly what is expected, no more, no less. |
| 5 | 5 | // See https://github.com/rust-lang/rust/pull/12020 |
| 6 | 6 | |
| 7 | use std::path::PathBuf; | |
| 8 | ||
| 7 | 9 | use run_make_support::{ |
| 8 | 10 | bin_name, dynamic_lib_name, filename_not_in_denylist, rfs, rust_lib_name, rustc, |
| 9 | 11 | shallow_find_files, static_lib_name, |
| 10 | 12 | }; |
| 11 | use std::path::PathBuf; | |
| 12 | 13 | |
| 13 | 14 | // Each test takes 4 arguments: |
| 14 | 15 | // `must_exist`: output files which must be found - if any are absent, the test fails |
tests/run-make/parallel-rustc-no-overwrite/rmake.rs+2-1| ... | ... | @@ -5,10 +5,11 @@ |
| 5 | 5 | // conflicts. This test uses this flag and checks for successful compilation. |
| 6 | 6 | // See https://github.com/rust-lang/rust/pull/83846 |
| 7 | 7 | |
| 8 | use run_make_support::{rfs, rustc}; | |
| 9 | 8 | use std::sync::{Arc, Barrier}; |
| 10 | 9 | use std::thread; |
| 11 | 10 | |
| 11 | use run_make_support::{rfs, rustc}; | |
| 12 | ||
| 12 | 13 | fn main() { |
| 13 | 14 | rfs::create_file("lib.rs"); |
| 14 | 15 | let barrier = Arc::new(Barrier::new(2)); |
tests/run-make/pgo-branch-weights/rmake.rs+2-1| ... | ... | @@ -10,9 +10,10 @@ |
| 10 | 10 | //@ needs-profiler-support |
| 11 | 11 | //@ ignore-cross-compile |
| 12 | 12 | |
| 13 | use run_make_support::{llvm_filecheck, llvm_profdata, rfs, run_with_args, rustc}; | |
| 14 | 13 | use std::path::Path; |
| 15 | 14 | |
| 15 | use run_make_support::{llvm_filecheck, llvm_profdata, rfs, run_with_args, rustc}; | |
| 16 | ||
| 16 | 17 | fn main() { |
| 17 | 18 | let path_prof_data_dir = Path::new("prof_data_dir"); |
| 18 | 19 | let path_merged_profdata = path_prof_data_dir.join("merged.profdata"); |
tests/run-make/pretty-print-with-dep-file/rmake.rs+2-1| ... | ... | @@ -5,9 +5,10 @@ |
| 5 | 5 | // does not get an unexpected dep-info file. |
| 6 | 6 | // See https://github.com/rust-lang/rust/issues/112898 |
| 7 | 7 | |
| 8 | use run_make_support::{invalid_utf8_contains, rfs, rustc}; | |
| 9 | 8 | use std::path::Path; |
| 10 | 9 | |
| 10 | use run_make_support::{invalid_utf8_contains, rfs, rustc}; | |
| 11 | ||
| 11 | 12 | fn main() { |
| 12 | 13 | rustc().emit("dep-info").arg("-Zunpretty=expanded").input("with-dep.rs").run(); |
| 13 | 14 | invalid_utf8_contains("with-dep.d", "with-dep.rs"); |
tests/run-make/profile/rmake.rs+2-1| ... | ... | @@ -8,9 +8,10 @@ |
| 8 | 8 | //@ ignore-cross-compile |
| 9 | 9 | //@ needs-profiler-support |
| 10 | 10 | |
| 11 | use run_make_support::{run, rustc}; | |
| 12 | 11 | use std::path::Path; |
| 13 | 12 | |
| 13 | use run_make_support::{run, rustc}; | |
| 14 | ||
| 14 | 15 | fn main() { |
| 15 | 16 | rustc().arg("-g").arg("-Zprofile").input("test.rs").run(); |
| 16 | 17 | run("test"); |
tests/run-make/relro-levels/rmake.rs+1-2| ... | ... | @@ -2,8 +2,7 @@ |
| 2 | 2 | |
| 3 | 3 | //@ only-linux |
| 4 | 4 | |
| 5 | use run_make_support::llvm_readobj; | |
| 6 | use run_make_support::rustc; | |
| 5 | use run_make_support::{llvm_readobj, rustc}; | |
| 7 | 6 | |
| 8 | 7 | fn compile(relro_level: &str) { |
| 9 | 8 | rustc().arg(format!("-Crelro-level={relro_level}")).input("hello.rs").run(); |
tests/run-make/repr128-dwarf/rmake.rs+4-3| ... | ... | @@ -1,13 +1,14 @@ |
| 1 | 1 | //@ ignore-windows |
| 2 | 2 | // This test should be replaced with one in tests/debuginfo once GDB or LLDB support 128-bit enums. |
| 3 | 3 | |
| 4 | use gimli::{AttributeValue, EndianRcSlice, Reader, RunTimeEndian}; | |
| 5 | use object::{Object, ObjectSection}; | |
| 6 | use run_make_support::{gimli, object, rfs, rustc}; | |
| 7 | 4 | use std::collections::HashMap; |
| 8 | 5 | use std::path::PathBuf; |
| 9 | 6 | use std::rc::Rc; |
| 10 | 7 | |
| 8 | use gimli::{AttributeValue, EndianRcSlice, Reader, RunTimeEndian}; | |
| 9 | use object::{Object, ObjectSection}; | |
| 10 | use run_make_support::{gimli, object, rfs, rustc}; | |
| 11 | ||
| 11 | 12 | fn main() { |
| 12 | 13 | let output = PathBuf::from("repr128"); |
| 13 | 14 | rustc().input("main.rs").output(&output).arg("-Cdebuginfo=2").run(); |
tests/run-make/reset-codegen-1/rmake.rs+2-1| ... | ... | @@ -7,9 +7,10 @@ |
| 7 | 7 | |
| 8 | 8 | //@ ignore-cross-compile |
| 9 | 9 | |
| 10 | use run_make_support::{bin_name, rfs, rustc}; | |
| 11 | 10 | use std::path::Path; |
| 12 | 11 | |
| 12 | use run_make_support::{bin_name, rfs, rustc}; | |
| 13 | ||
| 13 | 14 | fn compile(output_file: &str, emit: Option<&str>) { |
| 14 | 15 | let mut rustc = rustc(); |
| 15 | 16 | let rustc = rustc.codegen_units(4).output(output_file).input("foo.rs"); |
tests/run-make/resolve-rename/rmake.rs+1-2| ... | ... | @@ -5,8 +5,7 @@ |
| 5 | 5 | // the renamed library. |
| 6 | 6 | // See https://github.com/rust-lang/rust/pull/49253 |
| 7 | 7 | |
| 8 | use run_make_support::rfs; | |
| 9 | use run_make_support::rustc; | |
| 8 | use run_make_support::{rfs, rustc}; | |
| 10 | 9 | |
| 11 | 10 | fn main() { |
| 12 | 11 | rustc().extra_filename("-hash").input("foo.rs").run(); |
tests/run-make/rust-lld-by-default-beta-stable/rmake.rs+2-1| ... | ... | @@ -4,9 +4,10 @@ |
| 4 | 4 | //@ ignore-nightly |
| 5 | 5 | //@ only-x86_64-unknown-linux-gnu |
| 6 | 6 | |
| 7 | use std::process::Output; | |
| 8 | ||
| 7 | 9 | use run_make_support::regex::Regex; |
| 8 | 10 | use run_make_support::rustc; |
| 9 | use std::process::Output; | |
| 10 | 11 | |
| 11 | 12 | fn main() { |
| 12 | 13 | // A regular compilation should not use rust-lld by default. We'll check that by asking the |
tests/run-make/rust-lld-by-default-nightly/rmake.rs+2-1| ... | ... | @@ -6,9 +6,10 @@ |
| 6 | 6 | //@ ignore-stable |
| 7 | 7 | //@ only-x86_64-unknown-linux-gnu |
| 8 | 8 | |
| 9 | use std::process::Output; | |
| 10 | ||
| 9 | 11 | use run_make_support::regex::Regex; |
| 10 | 12 | use run_make_support::rustc; |
| 11 | use std::process::Output; | |
| 12 | 13 | |
| 13 | 14 | fn main() { |
| 14 | 15 | // A regular compilation should use rust-lld by default. We'll check that by asking the linker |
tests/run-make/rust-lld-custom-target/rmake.rs+2-1| ... | ... | @@ -8,9 +8,10 @@ |
| 8 | 8 | //@ needs-rust-lld |
| 9 | 9 | //@ only-x86_64-unknown-linux-gnu |
| 10 | 10 | |
| 11 | use std::process::Output; | |
| 12 | ||
| 11 | 13 | use run_make_support::regex::Regex; |
| 12 | 14 | use run_make_support::rustc; |
| 13 | use std::process::Output; | |
| 14 | 15 | |
| 15 | 16 | fn main() { |
| 16 | 17 | // Compile to a custom target spec with rust-lld enabled by default. We'll check that by asking |
tests/run-make/rust-lld/rmake.rs+2-1| ... | ... | @@ -5,9 +5,10 @@ |
| 5 | 5 | //@ ignore-msvc |
| 6 | 6 | //@ ignore-s390x lld does not yet support s390x as target |
| 7 | 7 | |
| 8 | use std::process::Output; | |
| 9 | ||
| 8 | 10 | use run_make_support::regex::Regex; |
| 9 | 11 | use run_make_support::rustc; |
| 10 | use std::process::Output; | |
| 11 | 12 | |
| 12 | 13 | fn main() { |
| 13 | 14 | // Opt-in to lld and the self-contained linker, to link with rust-lld. We'll check that by |
tests/run-make/rustdoc-determinism/rmake.rs+2-1| ... | ... | @@ -1,9 +1,10 @@ |
| 1 | 1 | // Assert that the search index is generated deterministically, regardless of the |
| 2 | 2 | // order that crates are documented in. |
| 3 | 3 | |
| 4 | use run_make_support::{diff, rustdoc}; | |
| 5 | 4 | use std::path::Path; |
| 6 | 5 | |
| 6 | use run_make_support::{diff, rustdoc}; | |
| 7 | ||
| 7 | 8 | fn main() { |
| 8 | 9 | let foo_first = Path::new("foo_first"); |
| 9 | 10 | rustdoc().input("foo.rs").output(&foo_first).run(); |
tests/run-make/rustdoc-io-error/rmake.rs+2-1| ... | ... | @@ -14,9 +14,10 @@ |
| 14 | 14 | // `mkfs.ext4 -d`, as well as mounting a loop device for the rootfs. |
| 15 | 15 | //@ ignore-windows - the `set_readonly` functions doesn't work on folders. |
| 16 | 16 | |
| 17 | use run_make_support::{path, rustdoc}; | |
| 18 | 17 | use std::fs; |
| 19 | 18 | |
| 19 | use run_make_support::{path, rustdoc}; | |
| 20 | ||
| 20 | 21 | fn main() { |
| 21 | 22 | let out_dir = path("rustdoc-io-error"); |
| 22 | 23 | let output = fs::create_dir(&out_dir).unwrap(); |
tests/run-make/rustdoc-output-path/rmake.rs+2-1| ... | ... | @@ -1,8 +1,9 @@ |
| 1 | 1 | // Checks that if the output folder doesn't exist, rustdoc will create it. |
| 2 | 2 | |
| 3 | use run_make_support::rustdoc; | |
| 4 | 3 | use std::path::Path; |
| 5 | 4 | |
| 5 | use run_make_support::rustdoc; | |
| 6 | ||
| 6 | 7 | fn main() { |
| 7 | 8 | let out_dir = Path::new("foo/bar/doc"); |
| 8 | 9 | rustdoc().input("foo.rs").output(&out_dir).run(); |
tests/run-make/rustdoc-scrape-examples-remap/scrape.rs+2-1| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | use run_make_support::{htmldocck, rfs, rustc, rustdoc, source_root}; | |
| 2 | 1 | use std::path::Path; |
| 3 | 2 | |
| 3 | use run_make_support::{htmldocck, rfs, rustc, rustdoc, source_root}; | |
| 4 | ||
| 4 | 5 | pub fn scrape(extra_args: &[&str]) { |
| 5 | 6 | let out_dir = Path::new("rustdoc"); |
| 6 | 7 | let crate_name = "foobar"; |
tests/run-make/rustdoc-test-args/rmake.rs+2-1| ... | ... | @@ -1,7 +1,8 @@ |
| 1 | use run_make_support::{rfs, rustdoc}; | |
| 2 | 1 | use std::iter; |
| 3 | 2 | use std::path::Path; |
| 4 | 3 | |
| 4 | use run_make_support::{rfs, rustdoc}; | |
| 5 | ||
| 5 | 6 | fn generate_a_lot_of_cfgs(path: &Path) { |
| 6 | 7 | let content = iter::repeat("--cfg=a\n").take(100_000).collect::<String>(); |
| 7 | 8 | rfs::write(path, content.as_bytes()); |
tests/run-make/rustdoc-themes/rmake.rs+2-1| ... | ... | @@ -1,8 +1,9 @@ |
| 1 | 1 | // Test that rustdoc will properly load in a theme file and display it in the theme selector. |
| 2 | 2 | |
| 3 | use run_make_support::{htmldocck, rfs, rustdoc, source_root}; | |
| 4 | 3 | use std::path::Path; |
| 5 | 4 | |
| 5 | use run_make_support::{htmldocck, rfs, rustdoc, source_root}; | |
| 6 | ||
| 6 | 7 | fn main() { |
| 7 | 8 | let out_dir = Path::new("rustdoc-themes"); |
| 8 | 9 | let test_css = "test.css"; |
tests/run-make/rustdoc-verify-output-files/rmake.rs+1-2| ... | ... | @@ -1,7 +1,6 @@ |
| 1 | use run_make_support::rfs; | |
| 2 | 1 | use std::path::{Path, PathBuf}; |
| 3 | 2 | |
| 4 | use run_make_support::{assert_dirs_are_equal, rustdoc}; | |
| 3 | use run_make_support::{assert_dirs_are_equal, rfs, rustdoc}; | |
| 5 | 4 | |
| 6 | 5 | #[derive(PartialEq)] |
| 7 | 6 | enum JsonOutput { |
tests/run-make/static-pie/rmake.rs+1-3| ... | ... | @@ -7,10 +7,8 @@ |
| 7 | 7 | |
| 8 | 8 | use std::process::Command; |
| 9 | 9 | |
| 10 | use run_make_support::llvm_readobj; | |
| 11 | 10 | use run_make_support::regex::Regex; |
| 12 | use run_make_support::rustc; | |
| 13 | use run_make_support::{cmd, run_with_args, target}; | |
| 11 | use run_make_support::{cmd, llvm_readobj, run_with_args, rustc, target}; | |
| 14 | 12 | |
| 15 | 13 | // Minimum major versions supporting -static-pie |
| 16 | 14 | const GCC_VERSION: u32 = 8; |
tests/run-make/stdin-rustc/rmake.rs+2-1| ... | ... | @@ -1,8 +1,9 @@ |
| 1 | 1 | //! This test checks rustc `-` (stdin) support |
| 2 | 2 | |
| 3 | use run_make_support::{is_windows, rustc}; | |
| 4 | 3 | use std::path::PathBuf; |
| 5 | 4 | |
| 5 | use run_make_support::{is_windows, rustc}; | |
| 6 | ||
| 6 | 7 | const HELLO_WORLD: &str = r#" |
| 7 | 8 | fn main() { |
| 8 | 9 | println!("Hello world!"); |
tests/run-make/stdin-rustdoc/rmake.rs+2-1| ... | ... | @@ -1,8 +1,9 @@ |
| 1 | 1 | //! This test checks rustdoc `-` (stdin) handling |
| 2 | 2 | |
| 3 | use run_make_support::rustdoc; | |
| 4 | 3 | use std::path::PathBuf; |
| 5 | 4 | |
| 5 | use run_make_support::rustdoc; | |
| 6 | ||
| 6 | 7 | static INPUT: &str = r#" |
| 7 | 8 | //! ``` |
| 8 | 9 | //! dbg!(()); |
tests/run-make/suspicious-library/rmake.rs+2-1| ... | ... | @@ -3,9 +3,10 @@ |
| 3 | 3 | |
| 4 | 4 | //@ ignore-cross-compile |
| 5 | 5 | |
| 6 | use run_make_support::{dynamic_lib_name, rustc}; | |
| 7 | 6 | use std::fs::File; |
| 8 | 7 | |
| 8 | use run_make_support::{dynamic_lib_name, rustc}; | |
| 9 | ||
| 9 | 10 | fn main() { |
| 10 | 11 | rustc().input("foo.rs").arg("-Cprefer-dynamic").run(); |
| 11 | 12 | File::create(dynamic_lib_name("foo-something-special")).unwrap(); |
tests/run-make/thumb-none-qemu/example/src/main.rs+2-3| ... | ... | @@ -1,11 +1,10 @@ |
| 1 | 1 | #![no_main] |
| 2 | 2 | #![no_std] |
| 3 | 3 | use core::fmt::Write; |
| 4 | ||
| 4 | 5 | use cortex_m::asm; |
| 5 | 6 | use cortex_m_rt::entry; |
| 6 | use cortex_m_semihosting as semihosting; | |
| 7 | ||
| 8 | use panic_halt as _; | |
| 7 | use {cortex_m_semihosting as semihosting, panic_halt as _}; | |
| 9 | 8 | |
| 10 | 9 | #[entry] |
| 11 | 10 | fn main() -> ! { |
tests/run-make/volatile-intrinsics/rmake.rs+1-2| ... | ... | @@ -1,7 +1,6 @@ |
| 1 | 1 | //@ ignore-cross-compile |
| 2 | 2 | |
| 3 | use run_make_support::rfs; | |
| 4 | use run_make_support::{assert_contains, run, rustc}; | |
| 3 | use run_make_support::{assert_contains, rfs, run, rustc}; | |
| 5 | 4 | |
| 6 | 5 | fn main() { |
| 7 | 6 | // The tests must pass... |
tests/run-make/wasm-custom-section/rmake.rs+2-1| ... | ... | @@ -1,8 +1,9 @@ |
| 1 | 1 | //@ only-wasm32-wasip1 |
| 2 | 2 | |
| 3 | use run_make_support::{rfs, rustc, wasmparser}; | |
| 4 | 3 | use std::collections::HashMap; |
| 5 | 4 | |
| 5 | use run_make_support::{rfs, rustc, wasmparser}; | |
| 6 | ||
| 6 | 7 | fn main() { |
| 7 | 8 | rustc().input("foo.rs").target("wasm32-wasip1").run(); |
| 8 | 9 | rustc().input("bar.rs").target("wasm32-wasip1").arg("-Clto").opt().run(); |
tests/run-make/wasm-custom-sections-opt/rmake.rs+2-1| ... | ... | @@ -1,9 +1,10 @@ |
| 1 | 1 | //@ only-wasm32-wasip1 |
| 2 | 2 | |
| 3 | use run_make_support::{rfs, rustc, wasmparser}; | |
| 4 | 3 | use std::collections::HashMap; |
| 5 | 4 | use std::path::Path; |
| 6 | 5 | |
| 6 | use run_make_support::{rfs, rustc, wasmparser}; | |
| 7 | ||
| 7 | 8 | fn main() { |
| 8 | 9 | rustc().input("foo.rs").target("wasm32-wasip1").opt().run(); |
| 9 | 10 |
tests/run-make/wasm-export-all-symbols/rmake.rs+2-1| ... | ... | @@ -1,8 +1,9 @@ |
| 1 | 1 | //@ only-wasm32-wasip1 |
| 2 | 2 | |
| 3 | use run_make_support::{rfs, rustc, wasmparser}; | |
| 4 | 3 | use std::collections::HashMap; |
| 5 | 4 | use std::path::Path; |
| 5 | ||
| 6 | use run_make_support::{rfs, rustc, wasmparser}; | |
| 6 | 7 | use wasmparser::ExternalKind::*; |
| 7 | 8 | |
| 8 | 9 | fn main() { |
tests/run-make/wasm-import-module/rmake.rs+2-1| ... | ... | @@ -1,7 +1,8 @@ |
| 1 | 1 | //@ only-wasm32-wasip1 |
| 2 | 2 | |
| 3 | use run_make_support::{rfs, rustc, wasmparser}; | |
| 4 | 3 | use std::collections::HashMap; |
| 4 | ||
| 5 | use run_make_support::{rfs, rustc, wasmparser}; | |
| 5 | 6 | use wasmparser::TypeRef::Func; |
| 6 | 7 | |
| 7 | 8 | fn main() { |
tests/run-make/wasm-spurious-import/rmake.rs+2-1| ... | ... | @@ -1,8 +1,9 @@ |
| 1 | 1 | //@ only-wasm32-wasip1 |
| 2 | 2 | |
| 3 | use run_make_support::{rfs, rustc, wasmparser}; | |
| 4 | 3 | use std::collections::HashMap; |
| 5 | 4 | |
| 5 | use run_make_support::{rfs, rustc, wasmparser}; | |
| 6 | ||
| 6 | 7 | fn main() { |
| 7 | 8 | rustc() |
| 8 | 9 | .input("main.rs") |
tests/run-make/wasm-symbols-different-module/rmake.rs+2-1| ... | ... | @@ -1,9 +1,10 @@ |
| 1 | 1 | //@ only-wasm32-wasip1 |
| 2 | 2 | |
| 3 | use run_make_support::{rfs, rustc, wasmparser}; | |
| 4 | 3 | use std::collections::{HashMap, HashSet}; |
| 5 | 4 | use std::path::Path; |
| 6 | 5 | |
| 6 | use run_make_support::{rfs, rustc, wasmparser}; | |
| 7 | ||
| 7 | 8 | fn main() { |
| 8 | 9 | test_file("foo.rs", &[("a", &["foo"]), ("b", &["foo"])]); |
| 9 | 10 | test_file("bar.rs", &[("m1", &["f", "g"]), ("m2", &["f"])]); |
tests/run-make/wasm-symbols-not-exported/rmake.rs+2-1| ... | ... | @@ -1,8 +1,9 @@ |
| 1 | 1 | //@ only-wasm32-wasip1 |
| 2 | 2 | |
| 3 | use run_make_support::{rfs, rustc, wasmparser}; | |
| 4 | 3 | use std::path::Path; |
| 5 | 4 | |
| 5 | use run_make_support::{rfs, rustc, wasmparser}; | |
| 6 | ||
| 6 | 7 | fn main() { |
| 7 | 8 | rustc().input("foo.rs").target("wasm32-wasip1").run(); |
| 8 | 9 | verify_symbols(Path::new("foo.wasm")); |
tests/run-make/wasm-symbols-not-imported/rmake.rs+2-1| ... | ... | @@ -1,8 +1,9 @@ |
| 1 | 1 | //@ only-wasm32-wasip1 |
| 2 | 2 | |
| 3 | use run_make_support::{rfs, rustc, wasmparser}; | |
| 4 | 3 | use std::path::Path; |
| 5 | 4 | |
| 5 | use run_make_support::{rfs, rustc, wasmparser}; | |
| 6 | ||
| 6 | 7 | fn main() { |
| 7 | 8 | rustc().input("foo.rs").target("wasm32-wasip1").run(); |
| 8 | 9 | verify_symbols(Path::new("foo.wasm")); |
tests/run-make/weird-output-filenames/rmake.rs+1-2| ... | ... | @@ -1,6 +1,5 @@ |
| 1 | 1 | use run_make_support::regex::Regex; |
| 2 | use run_make_support::rfs; | |
| 3 | use run_make_support::{cwd, rustc}; | |
| 2 | use run_make_support::{cwd, rfs, rustc}; | |
| 4 | 3 | |
| 5 | 4 | fn main() { |
| 6 | 5 | let invalid_characters = [".foo.rs", ".foo.bar", "+foo+bar.rs"]; |
tests/run-make/windows-binary-no-external-deps/rmake.rs+2-1| ... | ... | @@ -2,10 +2,11 @@ |
| 2 | 2 | //! a "hello world" application by setting `PATH` to `C:\Windows\System32`. |
| 3 | 3 | //@ only-windows |
| 4 | 4 | |
| 5 | use run_make_support::{cwd, env_var, rustc}; | |
| 6 | 5 | use std::path::PathBuf; |
| 7 | 6 | use std::process::Command; |
| 8 | 7 | |
| 8 | use run_make_support::{cwd, env_var, rustc}; | |
| 9 | ||
| 9 | 10 | fn main() { |
| 10 | 11 | rustc().input("hello.rs").run(); |
| 11 | 12 |
tests/run-make/windows-ws2_32/rmake.rs+2-1| ... | ... | @@ -2,7 +2,8 @@ |
| 2 | 2 | |
| 3 | 3 | // Tests that WS2_32.dll is not unnecessarily linked, see issue #85441 |
| 4 | 4 | |
| 5 | use run_make_support::object::{self, read::Object}; | |
| 5 | use run_make_support::object::read::Object; | |
| 6 | use run_make_support::object::{self}; | |
| 6 | 7 | use run_make_support::{rfs, rustc}; |
| 7 | 8 | |
| 8 | 9 | fn main() { |
tests/rustdoc-json/primitives/use_primitive.rs-1| ... | ... | @@ -15,6 +15,5 @@ mod usize {} |
| 15 | 15 | |
| 16 | 16 | //@ is "$.index[*].inner.import[?(@.name=='my_i32')].id" null |
| 17 | 17 | pub use i32 as my_i32; |
| 18 | ||
| 19 | 18 | //@ is "$.index[*].inner.import[?(@.name=='u32')].id" null |
| 20 | 19 | pub use u32; |