authorbors <bors@rust-lang.org> 2024-07-29 02:43:41 UTC
committerbors <bors@rust-lang.org> 2024-07-29 02:43:41 UTC
log2e630267b2bce50af3258ce4817e377fa09c145b
tree29006db815bf547dfd0129910b23b8c54675bd98
parent2cbbe8b8bb2be672b14cf741a2f0ec24a49f3f0b
parent84ac80f1921afc243d71fd0caaa4f2838c294102

Auto merge of #125443 - nnethercote:rustfmt-use-decls, r=lcnr,cuviper,GuillaumeGomez

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 @@
11use std::borrow::{Borrow, Cow};
2use std::cmp;
32use std::fmt::{self, Write};
4use std::iter;
5use std::ops::Bound;
6use std::ops::Deref;
3use std::ops::{Bound, Deref};
4use std::{cmp, iter};
75
86use rustc_index::Idx;
97use tracing::debug;
......@@ -982,7 +980,8 @@ fn univariant<
982980 if repr.can_randomize_type_layout() && cfg!(feature = "randomize") {
983981 #[cfg(feature = "randomize")]
984982 {
985 use rand::{seq::SliceRandom, SeedableRng};
983 use rand::seq::SliceRandom;
984 use rand::SeedableRng;
986985 // `ReprOptions.field_shuffle_seed` is a deterministic seed we can use to randomize field
987986 // ordering.
988987 let mut rng =
compiler/rustc_abi/src/lib.rs+3-4
......@@ -6,21 +6,20 @@
66// tidy-alphabetical-end
77
88use std::fmt;
9#[cfg(feature = "nightly")]
10use std::iter::Step;
911use std::num::{NonZeroUsize, ParseIntError};
1012use std::ops::{Add, AddAssign, Mul, RangeInclusive, Sub};
1113use std::str::FromStr;
1214
1315use bitflags::bitflags;
14use rustc_index::{Idx, IndexSlice, IndexVec};
15
1616#[cfg(feature = "nightly")]
1717use rustc_data_structures::stable_hasher::StableOrd;
18use rustc_index::{Idx, IndexSlice, IndexVec};
1819#[cfg(feature = "nightly")]
1920use rustc_macros::HashStable_Generic;
2021#[cfg(feature = "nightly")]
2122use rustc_macros::{Decodable_Generic, Encodable_Generic};
22#[cfg(feature = "nightly")]
23use std::iter::Step;
2423
2524mod layout;
2625#[cfg(test)]
compiler/rustc_arena/src/lib.rs+3-4
......@@ -27,15 +27,14 @@
2727#![feature(strict_provenance)]
2828// tidy-alphabetical-end
2929
30use smallvec::SmallVec;
31
3230use std::alloc::Layout;
3331use std::cell::{Cell, RefCell};
3432use std::marker::PhantomData;
3533use std::mem::{self, MaybeUninit};
3634use std::ptr::{self, NonNull};
37use std::slice;
38use std::{cmp, intrinsics};
35use std::{cmp, intrinsics, slice};
36
37use smallvec::SmallVec;
3938
4039/// This calls the passed function while ensuring it won't be inlined into the caller.
4140#[inline(never)]
compiler/rustc_arena/src/tests.rs+3-1
......@@ -1,8 +1,10 @@
11extern crate test;
2use super::TypedArena;
32use std::cell::Cell;
3
44use test::Bencher;
55
6use super::TypedArena;
7
68#[allow(dead_code)]
79#[derive(Debug, Eq, PartialEq)]
810struct Point {
compiler/rustc_ast/src/ast.rs+13-13
......@@ -18,15 +18,9 @@
1818//! - [`Attribute`]: Metadata associated with item.
1919//! - [`UnOp`], [`BinOp`], and [`BinOpKind`]: Unary and binary operators.
2020
21pub use crate::format::*;
22pub use crate::util::parser::ExprPrecedence;
23pub use rustc_span::AttrId;
24pub use GenericArgs::*;
25pub use UnsafeSource::*;
21use std::borrow::Cow;
22use std::{cmp, fmt, mem};
2623
27use crate::ptr::P;
28use crate::token::{self, CommentKind, Delimiter};
29use crate::tokenstream::{DelimSpan, LazyAttrTokenStream, TokenStream};
3024pub use rustc_ast_ir::{Movability, Mutability};
3125use rustc_data_structures::packed::Pu128;
3226use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
......@@ -35,12 +29,17 @@ use rustc_data_structures::sync::Lrc;
3529use rustc_macros::{Decodable, Encodable, HashStable_Generic};
3630use rustc_span::source_map::{respan, Spanned};
3731use rustc_span::symbol::{kw, sym, Ident, Symbol};
32pub use rustc_span::AttrId;
3833use rustc_span::{ErrorGuaranteed, Span, DUMMY_SP};
39use std::borrow::Cow;
40use std::cmp;
41use std::fmt;
42use std::mem;
4334use thin_vec::{thin_vec, ThinVec};
35pub use GenericArgs::*;
36pub use UnsafeSource::*;
37
38pub use crate::format::*;
39use crate::ptr::P;
40use crate::token::{self, CommentKind, Delimiter};
41use crate::tokenstream::{DelimSpan, LazyAttrTokenStream, TokenStream};
42pub use crate::util::parser::ExprPrecedence;
4443
4544/// A "Label" is an identifier of some point in sources,
4645/// e.g. in the following code:
......@@ -3491,8 +3490,9 @@ pub type ForeignItem = Item<ForeignItemKind>;
34913490// Some nodes are used a lot. Make sure they don't unintentionally get bigger.
34923491#[cfg(target_pointer_width = "64")]
34933492mod size_asserts {
3494 use super::*;
34953493 use rustc_data_structures::static_assert_size;
3494
3495 use super::*;
34963496 // tidy-alphabetical-start
34973497 static_assert_size!(AssocItem, 88);
34983498 static_assert_size!(AssocItemKind, 16);
compiler/rustc_ast/src/ast_traits.rs+8-7
......@@ -2,16 +2,17 @@
22//! typically those used in AST fragments during macro expansion.
33//! The traits are not implemented exhaustively, only when actually necessary.
44
5use std::fmt;
6use std::marker::PhantomData;
7
58use crate::ptr::P;
69use crate::token::Nonterminal;
710use crate::tokenstream::LazyAttrTokenStream;
8use crate::{Arm, Crate, ExprField, FieldDef, GenericParam, Param, PatField, Variant};
9use crate::{AssocItem, Expr, ForeignItem, Item, NodeId};
10use crate::{AttrItem, AttrKind, Block, Pat, Path, Ty, Visibility};
11use crate::{AttrVec, Attribute, Stmt, StmtKind};
12
13use std::fmt;
14use std::marker::PhantomData;
11use 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};
1516
1617/// A utility trait to reduce boilerplate.
1718/// Standard `Deref(Mut)` cannot be reused due to coherence.
compiler/rustc_ast/src/attr/mod.rs+13-13
......@@ -1,24 +1,24 @@
11//! Functions dealing with attributes and meta items.
22
3use std::iter;
4use std::sync::atomic::{AtomicU32, Ordering};
5
6use rustc_index::bit_set::GrowableBitSet;
7use rustc_span::symbol::{sym, Ident, Symbol};
8use rustc_span::Span;
9use smallvec::{smallvec, SmallVec};
10use thin_vec::{thin_vec, ThinVec};
11
312use 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,
516};
6use crate::ast::{DelimArgs, Expr, ExprKind, LitKind, MetaItemLit};
7use crate::ast::{MetaItem, MetaItemKind, NestedMetaItem, NormalAttr};
8use crate::ast::{Path, PathSegment, DUMMY_NODE_ID};
917use crate::ptr::P;
1018use crate::token::{self, CommentKind, Delimiter, Token};
11use crate::tokenstream::{DelimSpan, Spacing, TokenTree};
12use crate::tokenstream::{LazyAttrTokenStream, TokenStream};
19use crate::tokenstream::{DelimSpan, LazyAttrTokenStream, Spacing, TokenStream, TokenTree};
1320use crate::util::comments;
1421use crate::util::literal::escape_string_symbol;
15use rustc_index::bit_set::GrowableBitSet;
16use rustc_span::symbol::{sym, Ident, Symbol};
17use rustc_span::Span;
18use smallvec::{smallvec, SmallVec};
19use std::iter;
20use std::sync::atomic::{AtomicU32, Ordering};
21use thin_vec::{thin_vec, ThinVec};
2222
2323pub struct MarkedAttrs(GrowableBitSet<AttrId>);
2424
compiler/rustc_ast/src/entry.rs+2-1
......@@ -1,7 +1,8 @@
1use crate::{attr, Attribute};
21use rustc_span::symbol::sym;
32use rustc_span::Symbol;
43
4use crate::{attr, Attribute};
5
56#[derive(Debug)]
67pub enum EntryPointType {
78 /// This function is not an entrypoint.
compiler/rustc_ast/src/expand/mod.rs+2-1
......@@ -1,7 +1,8 @@
11//! Definitions shared by macros / syntax extensions and e.g. `rustc_middle`.
22
33use rustc_macros::{Decodable, Encodable, HashStable_Generic};
4use rustc_span::{def_id::DefId, symbol::Ident};
4use rustc_span::def_id::DefId;
5use rustc_span::symbol::Ident;
56
67use crate::MetaItem;
78
compiler/rustc_ast/src/format.rs+3-2
......@@ -1,10 +1,11 @@
1use crate::ptr::P;
2use crate::Expr;
31use rustc_data_structures::fx::FxHashMap;
42use rustc_macros::{Decodable, Encodable};
53use rustc_span::symbol::{Ident, Symbol};
64use rustc_span::Span;
75
6use crate::ptr::P;
7use crate::Expr;
8
89// Definitions:
910//
1011// format_args!("hello {abc:.xyz$}!!", abc="world");
compiler/rustc_ast/src/lib.rs+2-2
......@@ -43,11 +43,11 @@ pub mod token;
4343pub mod tokenstream;
4444pub mod visit;
4545
46use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
47
4648pub use self::ast::*;
4749pub use self::ast_traits::{AstDeref, AstNodeWrapper, HasAttrs, HasNodeId, HasTokens};
4850
49use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
50
5151/// Requirements for a `StableHashingContext` to be used in this crate.
5252/// This is a hack to allow using the `HashStable_Generic` derive macro
5353/// instead of implementing everything in `rustc_middle`.
compiler/rustc_ast/src/mut_visit.rs+8-7
......@@ -7,11 +7,8 @@
77//! a `MutVisitor` renaming item names in a module will miss all of those
88//! that are created by the expansion of a macro.
99
10use crate::ast::*;
11use crate::ptr::P;
12use crate::token::{self, Token};
13use crate::tokenstream::*;
14use crate::visit::{AssocCtxt, BoundKind};
10use std::ops::DerefMut;
11use std::panic;
1512
1613use rustc_data_structures::flat_map_in_place::FlatMapInPlace;
1714use rustc_data_structures::stack::ensure_sufficient_stack;
......@@ -20,10 +17,14 @@ use rustc_span::source_map::Spanned;
2017use rustc_span::symbol::Ident;
2118use rustc_span::Span;
2219use smallvec::{smallvec, Array, SmallVec};
23use std::ops::DerefMut;
24use std::panic;
2520use thin_vec::ThinVec;
2621
22use crate::ast::*;
23use crate::ptr::P;
24use crate::token::{self, Token};
25use crate::tokenstream::*;
26use crate::visit::{AssocCtxt, BoundKind};
27
2728pub trait ExpectOne<A: Array> {
2829 fn expect_one(self, err: &'static str) -> A::Item;
2930}
compiler/rustc_ast/src/node_id.rs+2-1
......@@ -1,6 +1,7 @@
1use rustc_span::LocalExpnId;
21use std::fmt;
32
3use rustc_span::LocalExpnId;
4
45rustc_index::newtype_index! {
56 /// Identifies an AST node.
67 ///
compiler/rustc_ast/src/ptr.rs+1-2
......@@ -21,9 +21,8 @@ use std::fmt::{self, Debug, Display};
2121use std::ops::{Deref, DerefMut};
2222use std::{slice, vec};
2323
24use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
25
2624use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
25use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
2726/// An owned smart pointer.
2827///
2928/// See the [module level documentation][crate::ptr] for details.
compiler/rustc_ast/src/token.rs+14-12
......@@ -1,3 +1,15 @@
1use std::borrow::Cow;
2use std::fmt;
3
4use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
5use rustc_data_structures::sync::Lrc;
6use rustc_macros::{Decodable, Encodable, HashStable_Generic};
7use rustc_span::edition::Edition;
8use 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)]
11use rustc_span::symbol::{Ident, Symbol};
12use rustc_span::{ErrorGuaranteed, Span, DUMMY_SP};
113pub use BinOpToken::*;
214pub use LitKind::*;
315pub use Nonterminal::*;
......@@ -9,17 +21,6 @@ use crate::ast;
921use crate::ptr::P;
1022use crate::util::case::Case;
1123
12use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
13use rustc_data_structures::sync::Lrc;
14use rustc_macros::{Decodable, Encodable, HashStable_Generic};
15use 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)]
18use rustc_span::symbol::{Ident, Symbol};
19use rustc_span::{edition::Edition, ErrorGuaranteed, Span, DUMMY_SP};
20use std::borrow::Cow;
21use std::fmt;
22
2324#[derive(Clone, Copy, PartialEq, Encodable, Decodable, Debug, HashStable_Generic)]
2425pub enum CommentKind {
2526 Line,
......@@ -1062,8 +1063,9 @@ where
10621063// Some types are used a lot. Make sure they don't unintentionally get bigger.
10631064#[cfg(target_pointer_width = "64")]
10641065mod size_asserts {
1065 use super::*;
10661066 use rustc_data_structures::static_assert_size;
1067
1068 use super::*;
10671069 // tidy-alphabetical-start
10681070 static_assert_size!(Lit, 12);
10691071 static_assert_size!(LitKind, 2);
compiler/rustc_ast/src/tokenstream.rs+8-7
......@@ -13,10 +13,8 @@
1313//! and a borrowed `TokenStream` is sufficient to build an owned `TokenStream` without taking
1414//! ownership of the original.
1515
16use crate::ast::{AttrStyle, StmtKind};
17use crate::ast_traits::{HasAttrs, HasTokens};
18use crate::token::{self, Delimiter, Nonterminal, Token, TokenKind};
19use crate::{AttrVec, Attribute};
16use std::borrow::Cow;
17use std::{cmp, fmt, iter};
2018
2119use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
2220use rustc_data_structures::sync::{self, Lrc};
......@@ -24,8 +22,10 @@ use rustc_macros::{Decodable, Encodable, HashStable_Generic};
2422use rustc_serialize::{Decodable, Encodable};
2523use rustc_span::{sym, Span, SpanDecoder, SpanEncoder, Symbol, DUMMY_SP};
2624
27use std::borrow::Cow;
28use std::{cmp, fmt, iter};
25use crate::ast::{AttrStyle, StmtKind};
26use crate::ast_traits::{HasAttrs, HasTokens};
27use crate::token::{self, Delimiter, Nonterminal, Token, TokenKind};
28use crate::{AttrVec, Attribute};
2929
3030/// Part of a `TokenStream`.
3131#[derive(Debug, Clone, PartialEq, Encodable, Decodable, HashStable_Generic)]
......@@ -767,8 +767,9 @@ impl DelimSpacing {
767767// Some types are used a lot. Make sure they don't unintentionally get bigger.
768768#[cfg(target_pointer_width = "64")]
769769mod size_asserts {
770 use super::*;
771770 use rustc_data_structures::static_assert_size;
771
772 use super::*;
772773 // tidy-alphabetical-start
773774 static_assert_size!(AttrTokenStream, 8);
774775 static_assert_size!(AttrTokenTree, 32);
compiler/rustc_ast/src/util/comments.rs+2-1
......@@ -1,6 +1,7 @@
1use crate::token::CommentKind;
21use rustc_span::{BytePos, Symbol};
32
3use crate::token::CommentKind;
4
45#[cfg(test)]
56mod tests;
67
compiler/rustc_ast/src/util/comments/tests.rs+2-1
......@@ -1,6 +1,7 @@
1use super::*;
21use rustc_span::create_default_session_globals_then;
32
3use super::*;
4
45#[test]
56fn test_block_doc_comment_1() {
67 create_default_session_globals_then(|| {
compiler/rustc_ast/src/util/literal.rs+5-3
......@@ -1,15 +1,17 @@
11//! Code related to parsing literals.
22
3use crate::ast::{self, LitKind, MetaItemLit, StrStyle};
4use crate::token::{self, Token};
3use std::{ascii, fmt, str};
4
55use rustc_lexer::unescape::{
66 byte_from_char, unescape_byte, unescape_char, unescape_mixed, unescape_unicode, MixedUnit, Mode,
77};
88use rustc_span::symbol::{kw, sym, Symbol};
99use rustc_span::Span;
10use std::{ascii, fmt, str};
1110use tracing::debug;
1211
12use crate::ast::{self, LitKind, MetaItemLit, StrStyle};
13use crate::token::{self, Token};
14
1315// Escapes a string, represented as a symbol. Reuses the original symbol,
1416// avoiding interning, if no changes are required.
1517pub fn escape_string_symbol(symbol: Symbol) -> Symbol {
compiler/rustc_ast/src/util/parser.rs+2-1
......@@ -1,6 +1,7 @@
1use rustc_span::symbol::kw;
2
13use crate::ast::{self, BinOpKind};
24use crate::token::{self, BinOpToken, Token};
3use rustc_span::symbol::kw;
45
56/// Associative operator with precedence.
67///
compiler/rustc_ast/src/visit.rs+4-5
......@@ -13,14 +13,13 @@
1313//! instance, a walker looking for item names in a module will miss all of
1414//! those that are created by the expansion of a macro.
1515
16use crate::ast::*;
17use crate::ptr::P;
18
16pub use rustc_ast_ir::visit::VisitorResult;
17pub use rustc_ast_ir::{try_visit, visit_opt, walk_list, walk_visitable_list};
1918use rustc_span::symbol::Ident;
2019use rustc_span::Span;
2120
22pub use rustc_ast_ir::visit::VisitorResult;
23pub use rustc_ast_ir::{try_visit, visit_opt, walk_list, walk_visitable_list};
21use crate::ast::*;
22use crate::ptr::P;
2423
2524#[derive(Copy, Clone, Debug, PartialEq)]
2625pub enum AssocCtxt {
compiler/rustc_ast_lowering/src/asm.rs+12-12
......@@ -1,13 +1,5 @@
1use crate::{ImplTraitContext, ImplTraitPosition, ParamMode, ResolverAstLoweringExt};
2
3use super::errors::{
4 AbiSpecifiedMultipleTimes, AttSyntaxOnlyX86, ClobberAbiNotSupported,
5 InlineAsmUnsupportedTarget, InvalidAbiClobberAbi, InvalidAsmTemplateModifierConst,
6 InvalidAsmTemplateModifierLabel, InvalidAsmTemplateModifierRegClass,
7 InvalidAsmTemplateModifierRegClassSub, InvalidAsmTemplateModifierSym, InvalidRegister,
8 InvalidRegisterClass, RegisterClassOnlyClobber, RegisterConflict,
9};
10use super::LoweringContext;
1use std::collections::hash_map::Entry;
2use std::fmt::Write;
113
124use rustc_ast::ptr::P;
135use rustc_ast::*;
......@@ -18,8 +10,16 @@ use rustc_session::parse::feature_err;
1810use rustc_span::symbol::kw;
1911use rustc_span::{sym, Span};
2012use rustc_target::asm;
21use std::collections::hash_map::Entry;
22use std::fmt::Write;
13
14use super::errors::{
15 AbiSpecifiedMultipleTimes, AttSyntaxOnlyX86, ClobberAbiNotSupported,
16 InlineAsmUnsupportedTarget, InvalidAbiClobberAbi, InvalidAsmTemplateModifierConst,
17 InvalidAsmTemplateModifierLabel, InvalidAsmTemplateModifierRegClass,
18 InvalidAsmTemplateModifierRegClassSub, InvalidAsmTemplateModifierSym, InvalidRegister,
19 InvalidRegisterClass, RegisterClassOnlyClobber, RegisterConflict,
20};
21use super::LoweringContext;
22use crate::{ImplTraitContext, ImplTraitPosition, ParamMode, ResolverAstLoweringExt};
2323
2424impl<'a, 'hir> LoweringContext<'a, 'hir> {
2525 #[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
compiler/rustc_ast_lowering/src/block.rs+2-2
......@@ -1,9 +1,9 @@
1use crate::{ImplTraitContext, ImplTraitPosition, LoweringContext};
21use rustc_ast::{Block, BlockCheckMode, Local, LocalKind, Stmt, StmtKind};
32use rustc_hir as hir;
4
53use smallvec::SmallVec;
64
5use crate::{ImplTraitContext, ImplTraitPosition, LoweringContext};
6
77impl<'a, 'hir> LoweringContext<'a, 'hir> {
88 pub(super) fn lower_block(
99 &mut self,
compiler/rustc_ast_lowering/src/delegation.rs+7-7
......@@ -36,23 +36,23 @@
3636//! In case of discrepancy with callee function the `NotSupportedDelegation` error will
3737//! also be emitted during HIR ty lowering.
3838
39use crate::{ImplTraitPosition, ResolverAstLoweringExt};
40
41use super::{ImplTraitContext, LoweringContext, ParamMode, ParenthesizedGenericArgs};
39use std::iter;
4240
4341use ast::visit::Visitor;
4442use hir::def::{DefKind, PartialRes, Res};
4543use hir::{BodyId, HirId};
46use rustc_ast as ast;
4744use rustc_ast::*;
4845use rustc_errors::ErrorGuaranteed;
49use rustc_hir as hir;
5046use rustc_hir::def_id::DefId;
5147use rustc_middle::span_bug;
5248use rustc_middle::ty::{Asyncness, ResolverAstLowering};
53use rustc_span::{symbol::Ident, Span};
49use rustc_span::symbol::Ident;
50use rustc_span::Span;
5451use rustc_target::spec::abi;
55use std::iter;
52use {rustc_ast as ast, rustc_hir as hir};
53
54use super::{ImplTraitContext, LoweringContext, ParamMode, ParenthesizedGenericArgs};
55use crate::{ImplTraitPosition, ResolverAstLoweringExt};
5656
5757pub(crate) struct DelegationResults<'hir> {
5858 pub body_id: hir::BodyId,
compiler/rustc_ast_lowering/src/errors.rs+4-4
......@@ -1,8 +1,8 @@
1use rustc_errors::{
2 codes::*, Diag, DiagArgFromDisplay, EmissionGuarantee, SubdiagMessageOp, Subdiagnostic,
3};
1use rustc_errors::codes::*;
2use rustc_errors::{Diag, DiagArgFromDisplay, EmissionGuarantee, SubdiagMessageOp, Subdiagnostic};
43use rustc_macros::{Diagnostic, Subdiagnostic};
5use rustc_span::{symbol::Ident, Span, Symbol};
4use rustc_span::symbol::Ident;
5use rustc_span::{Span, Symbol};
66
77#[derive(Diagnostic)]
88#[diag(ast_lowering_generic_type_with_parentheses, code = E0214)]
compiler/rustc_ast_lowering/src/expr.rs+13-12
......@@ -1,15 +1,5 @@
11use std::assert_matches::assert_matches;
22
3use super::errors::{
4 AsyncCoroutinesNotSupported, AwaitOnlyInAsyncFnAndBlocks, BaseExpressionDoubleDot,
5 ClosureCannotBeStatic, CoroutineTooManyParameters,
6 FunctionalRecordUpdateDestructuringAssignment, InclusiveRangeWithNoEnd, MatchArmWithNoBody,
7 NeverPatternWithBody, NeverPatternWithGuard, UnderscoreExprLhsAssign,
8};
9use super::ResolverAstLoweringExt;
10use super::{ImplTraitContext, LoweringContext, ParamMode, ParenthesizedGenericArgs};
11use crate::errors::YieldInClosure;
12use crate::{FnDeclKind, ImplTraitPosition};
133use rustc_ast::ptr::P as AstP;
144use rustc_ast::*;
155use rustc_data_structures::stack::ensure_sufficient_stack;
......@@ -20,10 +10,21 @@ use rustc_middle::span_bug;
2010use rustc_session::errors::report_lit_error;
2111use rustc_span::source_map::{respan, Spanned};
2212use rustc_span::symbol::{kw, sym, Ident, Symbol};
23use rustc_span::DUMMY_SP;
24use rustc_span::{DesugaringKind, Span};
13use rustc_span::{DesugaringKind, Span, DUMMY_SP};
2514use thin_vec::{thin_vec, ThinVec};
2615
16use super::errors::{
17 AsyncCoroutinesNotSupported, AwaitOnlyInAsyncFnAndBlocks, BaseExpressionDoubleDot,
18 ClosureCannotBeStatic, CoroutineTooManyParameters,
19 FunctionalRecordUpdateDestructuringAssignment, InclusiveRangeWithNoEnd, MatchArmWithNoBody,
20 NeverPatternWithBody, NeverPatternWithGuard, UnderscoreExprLhsAssign,
21};
22use super::{
23 ImplTraitContext, LoweringContext, ParamMode, ParenthesizedGenericArgs, ResolverAstLoweringExt,
24};
25use crate::errors::YieldInClosure;
26use crate::{FnDeclKind, ImplTraitPosition};
27
2728impl<'hir> LoweringContext<'_, 'hir> {
2829 fn lower_exprs(&mut self, exprs: &[AstP<Expr>]) -> &'hir [hir::Expr<'hir>] {
2930 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 @@
1use super::LoweringContext;
21use core::ops::ControlFlow;
3use rustc_ast as ast;
2use std::borrow::Cow;
3
44use rustc_ast::visit::Visitor;
55use rustc_ast::*;
66use rustc_data_structures::fx::FxIndexMap;
7use rustc_hir as hir;
8use rustc_span::{
9 sym,
10 symbol::{kw, Ident},
11 Span, Symbol,
12};
13use std::borrow::Cow;
7use rustc_span::symbol::{kw, Ident};
8use rustc_span::{sym, Span, Symbol};
9use {rustc_ast as ast, rustc_hir as hir};
10
11use super::LoweringContext;
1412
1513impl<'hir> LoweringContext<'_, 'hir> {
1614 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 @@
1use super::errors::{InvalidAbi, InvalidAbiReason, InvalidAbiSuggestion, MisplacedRelaxTraitBound};
2use super::ResolverAstLoweringExt;
3use super::{AstOwner, ImplTraitContext, ImplTraitPosition};
4use super::{FnDeclKind, LoweringContext, ParamMode};
5
61use rustc_ast::ptr::P;
72use rustc_ast::visit::AssocCtxt;
83use rustc_ast::*;
......@@ -22,6 +17,12 @@ use smallvec::{smallvec, SmallVec};
2217use thin_vec::ThinVec;
2318use tracing::instrument;
2419
20use super::errors::{InvalidAbi, InvalidAbiReason, InvalidAbiSuggestion, MisplacedRelaxTraitBound};
21use super::{
22 AstOwner, FnDeclKind, ImplTraitContext, ImplTraitPosition, LoweringContext, ParamMode,
23 ResolverAstLoweringExt,
24};
25
2526pub(super) struct ItemLowerer<'a, 'hir> {
2627 pub(super) tcx: TyCtxt<'hir>,
2728 pub(super) resolver: &'a mut ResolverAstLowering,
compiler/rustc_ast_lowering/src/lib.rs+6-4
......@@ -39,7 +39,8 @@
3939#![feature(rustdoc_internals)]
4040// tidy-alphabetical-end
4141
42use crate::errors::{AssocTyParentheses, AssocTyParenthesesSub, MisplacedImplTrait};
42use std::collections::hash_map::Entry;
43
4344use rustc_ast::node_id::NodeMap;
4445use rustc_ast::ptr::P;
4546use rustc_ast::{self as ast, *};
......@@ -53,9 +54,9 @@ use rustc_data_structures::sync::Lrc;
5354use rustc_errors::{DiagArgFromDisplay, DiagCtxtHandle, StashKey};
5455use rustc_hir::def::{DefKind, LifetimeRes, Namespace, PartialRes, PerNS, Res};
5556use rustc_hir::def_id::{LocalDefId, LocalDefIdMap, CRATE_DEF_ID, LOCAL_CRATE};
56use rustc_hir::{self as hir};
5757use rustc_hir::{
58 ConstArg, GenericArg, HirId, ItemLocalMap, MissingLifetimeKind, ParamName, TraitCandidate,
58 self as hir, ConstArg, GenericArg, HirId, ItemLocalMap, MissingLifetimeKind, ParamName,
59 TraitCandidate,
5960};
6061use rustc_index::{Idx, IndexSlice, IndexVec};
6162use rustc_macros::extension;
......@@ -65,10 +66,11 @@ use rustc_session::parse::{add_feature_diagnostics, feature_err};
6566use rustc_span::symbol::{kw, sym, Ident, Symbol};
6667use rustc_span::{DesugaringKind, Span, DUMMY_SP};
6768use smallvec::{smallvec, SmallVec};
68use std::collections::hash_map::Entry;
6969use thin_vec::ThinVec;
7070use tracing::{debug, instrument, trace};
7171
72use crate::errors::{AssocTyParentheses, AssocTyParenthesesSub, MisplacedImplTrait};
73
7274macro_rules! arena_vec {
7375 ($this:expr; $($x:expr),*) => (
7476 $this.arena.alloc_from_iter([$($x),*])
compiler/rustc_ast_lowering/src/lifetime_collector.rs+2-1
......@@ -1,4 +1,3 @@
1use super::ResolverAstLoweringExt;
21use rustc_ast::visit::{self, BoundKind, LifetimeCtxt, Visitor};
32use rustc_ast::{GenericBounds, Lifetime, NodeId, PathSegment, PolyTraitRef, Ty, TyKind};
43use rustc_data_structures::fx::FxIndexSet;
......@@ -8,6 +7,8 @@ use rustc_middle::ty::ResolverAstLowering;
87use rustc_span::symbol::{kw, Ident};
98use rustc_span::Span;
109
10use super::ResolverAstLoweringExt;
11
1112struct LifetimeCollectVisitor<'ast> {
1213 resolver: &'ast ResolverAstLowering,
1314 current_binders: Vec<NodeId>,
compiler/rustc_ast_lowering/src/pat.rs+8-8
......@@ -1,17 +1,17 @@
1use super::errors::{
2 ArbitraryExpressionInPattern, ExtraDoubleDot, MisplacedDoubleDot, SubTupleBinding,
3};
4use super::ResolverAstLoweringExt;
5use super::{ImplTraitContext, LoweringContext, ParamMode};
6use crate::ImplTraitPosition;
7
81use rustc_ast::ptr::P;
92use rustc_ast::*;
103use rustc_data_structures::stack::ensure_sufficient_stack;
114use rustc_hir as hir;
125use rustc_hir::def::Res;
6use rustc_span::source_map::Spanned;
137use rustc_span::symbol::Ident;
14use rustc_span::{source_map::Spanned, Span};
8use rustc_span::Span;
9
10use super::errors::{
11 ArbitraryExpressionInPattern, ExtraDoubleDot, MisplacedDoubleDot, SubTupleBinding,
12};
13use super::{ImplTraitContext, LoweringContext, ParamMode, ResolverAstLoweringExt};
14use crate::ImplTraitPosition;
1515
1616impl<'a, 'hir> LoweringContext<'a, 'hir> {
1717 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 @@
1use crate::ImplTraitPosition;
2
3use super::errors::{
4 AsyncBoundNotOnTrait, AsyncBoundOnlyForFnTraits, BadReturnTypeNotation,
5 GenericTypeWithParentheses, UseAngleBrackets,
6};
7use super::ResolverAstLoweringExt;
8use super::{GenericArgsCtor, LifetimeRes, ParenthesizedGenericArgs};
9use super::{ImplTraitContext, LoweringContext, ParamMode};
10
111use rustc_ast::{self as ast, *};
122use rustc_data_structures::sync::Lrc;
133use rustc_hir as hir;
......@@ -17,10 +7,19 @@ use rustc_hir::GenericArg;
177use rustc_middle::span_bug;
188use rustc_span::symbol::{kw, sym, Ident};
199use rustc_span::{BytePos, DesugaringKind, Span, Symbol, DUMMY_SP};
20
2110use smallvec::{smallvec, SmallVec};
2211use tracing::{debug, instrument};
2312
13use super::errors::{
14 AsyncBoundNotOnTrait, AsyncBoundOnlyForFnTraits, BadReturnTypeNotation,
15 GenericTypeWithParentheses, UseAngleBrackets,
16};
17use super::{
18 GenericArgsCtor, ImplTraitContext, LifetimeRes, LoweringContext, ParamMode,
19 ParenthesizedGenericArgs, ResolverAstLoweringExt,
20};
21use crate::ImplTraitPosition;
22
2423impl<'a, 'hir> LoweringContext<'a, 'hir> {
2524 #[instrument(level = "trace", skip(self))]
2625 pub(crate) fn lower_qpath(
compiler/rustc_ast_passes/src/ast_validation.rs+3-2
......@@ -16,6 +16,9 @@
1616//! constructions produced by proc macros. This pass is only intended for simple checks that do not
1717//! require name resolution or type checking, or other kinds of complex analysis.
1818
19use std::mem;
20use std::ops::{Deref, DerefMut};
21
1922use itertools::{Either, Itertools};
2023use rustc_ast::ptr::P;
2124use rustc_ast::visit::{walk_list, AssocCtxt, BoundKind, FnCtxt, FnKind, Visitor};
......@@ -34,8 +37,6 @@ use rustc_session::Session;
3437use rustc_span::symbol::{kw, sym, Ident};
3538use rustc_span::Span;
3639use rustc_target::spec::abi;
37use std::mem;
38use std::ops::{Deref, DerefMut};
3940use thin_vec::thin_vec;
4041
4142use crate::errors::{self, TildeConstReason};
compiler/rustc_ast_passes/src/errors.rs+4-4
......@@ -1,11 +1,11 @@
11//! Errors emitted by ast_passes.
22
33use rustc_ast::ParamKindOrd;
4use rustc_errors::{
5 codes::*, Applicability, Diag, EmissionGuarantee, SubdiagMessageOp, Subdiagnostic,
6};
4use rustc_errors::codes::*;
5use rustc_errors::{Applicability, Diag, EmissionGuarantee, SubdiagMessageOp, Subdiagnostic};
76use rustc_macros::{Diagnostic, Subdiagnostic};
8use rustc_span::{symbol::Ident, Span, Symbol};
7use rustc_span::symbol::Ident;
8use rustc_span::{Span, Symbol};
99
1010use crate::fluent_generated as fluent;
1111
compiler/rustc_ast_passes/src/feature_gate.rs+1-2
......@@ -1,7 +1,6 @@
11use rustc_ast as ast;
22use rustc_ast::visit::{self, AssocCtxt, FnCtxt, FnKind, Visitor};
3use rustc_ast::{attr, NodeId};
4use rustc_ast::{token, PatKind};
3use rustc_ast::{attr, token, NodeId, PatKind};
54use rustc_feature::{AttributeGate, BuiltinAttribute, Features, GateIssue, BUILTIN_ATTRIBUTE_MAP};
65use rustc_session::parse::{feature_err, feature_err_issue, feature_warn};
76use rustc_session::Session;
compiler/rustc_ast_pretty/src/helpers.rs+2-1
......@@ -1,6 +1,7 @@
1use crate::pp::Printer;
21use std::borrow::Cow;
32
3use crate::pp::Printer;
4
45impl Printer {
56 pub fn word_space<W: Into<Cow<'static, str>>>(&mut self, w: W) {
67 self.word(w);
compiler/rustc_ast_pretty/src/pp.rs+3-3
......@@ -135,11 +135,11 @@
135135mod convenience;
136136mod ring;
137137
138use ring::RingBuffer;
139138use std::borrow::Cow;
140use std::cmp;
141139use std::collections::VecDeque;
142use std::iter;
140use std::{cmp, iter};
141
142use ring::RingBuffer;
143143
144144/// How to break. Described in more detail in the module docs.
145145#[derive(Clone, Copy, PartialEq)]
compiler/rustc_ast_pretty/src/pp/convenience.rs+2-1
......@@ -1,6 +1,7 @@
1use crate::pp::{BeginToken, BreakToken, Breaks, IndentStyle, Printer, Token, SIZE_INFINITY};
21use std::borrow::Cow;
32
3use crate::pp::{BeginToken, BreakToken, Breaks, IndentStyle, Printer, Token, SIZE_INFINITY};
4
45impl Printer {
56 /// "raw box"
67 pub fn rbox(&mut self, indent: isize, breaks: Breaks) {
compiler/rustc_ast_pretty/src/pprust/mod.rs+2-3
......@@ -2,13 +2,12 @@
22mod tests;
33
44pub mod state;
5pub use state::{print_crate, AnnNode, Comments, PpAnn, PrintState, State};
5use std::borrow::Cow;
66
77use rustc_ast as ast;
88use rustc_ast::token::{Nonterminal, Token, TokenKind};
99use rustc_ast::tokenstream::{TokenStream, TokenTree};
10
11use std::borrow::Cow;
10pub use state::{print_crate, AnnNode, Comments, PpAnn, PrintState, State};
1211
1312pub fn nonterminal_to_string(nt: &Nonterminal) -> String {
1413 State::new().nonterminal_to_string(nt)
compiler/rustc_ast_pretty/src/pprust/state.rs+12-11
......@@ -6,9 +6,8 @@ mod expr;
66mod fixup;
77mod item;
88
9use crate::pp::Breaks::{Consistent, Inconsistent};
10use crate::pp::{self, Breaks};
11use crate::pprust::state::fixup::FixupContext;
9use std::borrow::Cow;
10
1211use ast::TraitBoundModifiers;
1312use rustc_ast::attr::AttrIdGenerator;
1413use rustc_ast::ptr::P;
......@@ -16,18 +15,21 @@ use rustc_ast::token::{self, BinOpToken, CommentKind, Delimiter, Nonterminal, To
1615use rustc_ast::tokenstream::{Spacing, TokenStream, TokenTree};
1716use rustc_ast::util::classify;
1817use rustc_ast::util::comments::{Comment, CommentStyle};
19use rustc_ast::{self as ast, AttrArgs, AttrArgsEq, BlockCheckMode, PatKind, Safety};
20use rustc_ast::{attr, BindingMode, ByRef, DelimArgs, RangeEnd, RangeSyntax, Term};
21use rustc_ast::{GenericArg, GenericBound, SelfKind};
22use rustc_ast::{InlineAsmOperand, InlineAsmRegOrRegClass};
23use rustc_ast::{InlineAsmOptions, InlineAsmTemplatePiece};
18use 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};
2423use rustc_span::edition::Edition;
2524use rustc_span::source_map::{SourceMap, Spanned};
2625use rustc_span::symbol::{kw, sym, Ident, IdentPrinter, Symbol};
2726use rustc_span::{BytePos, CharPos, FileName, Pos, Span, DUMMY_SP};
28use std::borrow::Cow;
2927use thin_vec::ThinVec;
3028
29use crate::pp::Breaks::{Consistent, Inconsistent};
30use crate::pp::{self, Breaks};
31use crate::pprust::state::fixup::FixupContext;
32
3133pub enum MacHeader<'a> {
3234 Path(&'a ast::Path),
3335 Keyword(&'static str),
......@@ -290,8 +292,7 @@ pub fn print_crate<'a>(
290292fn space_between(tt1: &TokenTree, tt2: &TokenTree) -> bool {
291293 use token::*;
292294 use Delimiter::*;
293 use TokenTree::Delimited as Del;
294 use TokenTree::Token as Tok;
295 use TokenTree::{Delimited as Del, Token as Tok};
295296
296297 fn is_punct(tt: &TokenTree) -> bool {
297298 matches!(tt, TokenTree::Token(tok, _) if tok.is_punct())
compiler/rustc_ast_pretty/src/pprust/state/expr.rs+8-8
......@@ -1,19 +1,19 @@
1use crate::pp::Breaks::Inconsistent;
2use crate::pprust::state::fixup::FixupContext;
3use crate::pprust::state::{AnnNode, PrintState, State, INDENT_UNIT};
1use std::fmt::Write;
2
43use ast::{ForLoopKind, MatchKind};
54use itertools::{Itertools, Position};
65use rustc_ast::ptr::P;
7use rustc_ast::token;
86use rustc_ast::util::classify;
97use rustc_ast::util::literal::escape_byte_str_symbol;
108use rustc_ast::util::parser::{self, AssocOp, Fixity};
11use rustc_ast::{self as ast, BlockCheckMode};
129use 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,
1512};
16use std::fmt::Write;
13
14use crate::pp::Breaks::Inconsistent;
15use crate::pprust::state::fixup::FixupContext;
16use crate::pprust::state::{AnnNode, PrintState, State, INDENT_UNIT};
1717
1818impl<'a> State<'a> {
1919 fn print_else(&mut self, els: Option<&ast::Expr>) {
compiler/rustc_ast_pretty/src/pprust/state/item.rs+4-4
......@@ -1,7 +1,3 @@
1use crate::pp::Breaks::Inconsistent;
2use crate::pprust::state::fixup::FixupContext;
3use crate::pprust::state::{AnnNode, PrintState, State, INDENT_UNIT};
4
51use ast::StaticItem;
62use itertools::{Itertools, Position};
73use rustc_ast as ast;
......@@ -9,6 +5,10 @@ use rustc_ast::ptr::P;
95use rustc_ast::ModKind;
106use rustc_span::symbol::Ident;
117
8use crate::pp::Breaks::Inconsistent;
9use crate::pprust::state::fixup::FixupContext;
10use crate::pprust::state::{AnnNode, PrintState, State, INDENT_UNIT};
11
1212enum DelegationKind<'a> {
1313 Single,
1414 List(&'a [(Ident, Option<Ident>)]),
compiler/rustc_ast_pretty/src/pprust/tests.rs+3-4
......@@ -1,11 +1,10 @@
1use super::*;
2
31use rustc_ast as ast;
4use rustc_span::create_default_session_globals_then;
52use rustc_span::symbol::Ident;
6use rustc_span::DUMMY_SP;
3use rustc_span::{create_default_session_globals_then, DUMMY_SP};
74use thin_vec::ThinVec;
85
6use super::*;
7
98fn fun_to_string(
109 decl: &ast::FnDecl,
1110 header: ast::FnHeader,
compiler/rustc_attr/src/builtin.rs+8-4
......@@ -1,8 +1,12 @@
11//! Parsing and validation of builtin attributes
22
3use std::num::NonZero;
4
35use rustc_abi::Align;
4use rustc_ast::{self as ast, attr};
5use rustc_ast::{Attribute, LitKind, MetaItem, MetaItemKind, MetaItemLit, NestedMetaItem, NodeId};
6use rustc_ast::{
7 self as ast, attr, Attribute, LitKind, MetaItem, MetaItemKind, MetaItemLit, NestedMetaItem,
8 NodeId,
9};
610use rustc_ast_pretty::pprust;
711use rustc_errors::ErrorGuaranteed;
812use rustc_feature::{find_gated_cfg, is_builtin_attr_name, Features, GatedCfg};
......@@ -13,8 +17,8 @@ use rustc_session::lint::BuiltinLintDiag;
1317use rustc_session::parse::feature_err;
1418use rustc_session::{RustcVersion, Session};
1519use rustc_span::hygiene::Transparency;
16use rustc_span::{symbol::sym, symbol::Symbol, Span};
17use std::num::NonZero;
20use rustc_span::symbol::{sym, Symbol};
21use rustc_span::Span;
1822
1923use crate::session_diagnostics::{self, IncorrectReprFormatGenericCause};
2024
compiler/rustc_attr/src/lib.rs+2-4
......@@ -15,12 +15,10 @@ mod builtin;
1515mod session_diagnostics;
1616
1717pub use builtin::*;
18pub use rustc_ast::attr::*;
19pub(crate) use rustc_session::HashStableContext;
1820pub use IntType::*;
1921pub use ReprAttr::*;
2022pub use StabilityLevel::*;
2123
22pub use rustc_ast::attr::*;
23
24pub(crate) use rustc_session::HashStableContext;
25
2624rustc_fluent_macro::fluent_messages! { "../messages.ftl" }
compiler/rustc_attr/src/session_diagnostics.rs+3-4
......@@ -1,13 +1,12 @@
11use std::num::IntErrorKind;
22
33use rustc_ast as ast;
4use rustc_errors::DiagCtxtHandle;
5use rustc_errors::{codes::*, Applicability, Diag, Diagnostic, EmissionGuarantee, Level};
4use rustc_errors::codes::*;
5use rustc_errors::{Applicability, Diag, DiagCtxtHandle, Diagnostic, EmissionGuarantee, Level};
66use rustc_macros::{Diagnostic, Subdiagnostic};
77use rustc_span::{Span, Symbol};
88
9use crate::fluent_generated as fluent;
10use crate::UnsupportedLiteralReason;
9use crate::{fluent_generated as fluent, UnsupportedLiteralReason};
1110
1211#[derive(Diagnostic)]
1312#[diag(attr_expected_one_cfg_pattern, code = E0536)]
compiler/rustc_borrowck/src/borrow_set.rs+8-7
......@@ -1,16 +1,17 @@
1use crate::path_utils::allow_two_phase_borrow;
2use crate::place_ext::PlaceExt;
3use crate::BorrowIndex;
1use std::fmt;
2use std::ops::Index;
3
44use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
55use rustc_index::bit_set::BitSet;
6use rustc_middle::mir::traversal;
76use rustc_middle::mir::visit::{MutatingUseContext, NonUseContext, PlaceContext, Visitor};
8use rustc_middle::mir::{self, Body, Local, Location};
7use rustc_middle::mir::{self, traversal, Body, Local, Location};
98use rustc_middle::span_bug;
109use rustc_middle::ty::{RegionVid, TyCtxt};
1110use rustc_mir_dataflow::move_paths::MoveData;
12use std::fmt;
13use std::ops::Index;
11
12use crate::path_utils::allow_two_phase_borrow;
13use crate::place_ext::PlaceExt;
14use crate::BorrowIndex;
1415
1516pub struct BorrowSet<'tcx> {
1617 /// The fundamental map relating bitvector indexes to the borrows
compiler/rustc_borrowck/src/borrowck_errors.rs+2-2
......@@ -1,8 +1,8 @@
11#![allow(rustc::diagnostic_outside_of_impl)]
22#![allow(rustc::untranslatable_diagnostic)]
33
4use rustc_errors::Applicability;
5use rustc_errors::{codes::*, struct_span_code_err, Diag, DiagCtxtHandle};
4use rustc_errors::codes::*;
5use rustc_errors::{struct_span_code_err, Applicability, Diag, DiagCtxtHandle};
66use rustc_hir as hir;
77use rustc_middle::span_bug;
88use rustc_middle::ty::{self, Ty, TyCtxt};
compiler/rustc_borrowck/src/constraints/graph.rs+2-5
......@@ -4,11 +4,8 @@ use rustc_middle::mir::ConstraintCategory;
44use rustc_middle::ty::{RegionVid, VarianceDiagInfo};
55use rustc_span::DUMMY_SP;
66
7use crate::{
8 constraints::OutlivesConstraintIndex,
9 constraints::{OutlivesConstraint, OutlivesConstraintSet},
10 type_check::Locations,
11};
7use crate::constraints::{OutlivesConstraint, OutlivesConstraintIndex, OutlivesConstraintSet};
8use crate::type_check::Locations;
129
1310/// The construct graph organizes the constraints by their end-points.
1411/// 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 @@
1use crate::region_infer::{ConstraintSccs, RegionDefinition, RegionTracker};
2use crate::type_check::Locations;
3use crate::universal_regions::UniversalRegions;
1use std::fmt;
2use std::ops::Index;
3
44use rustc_index::{IndexSlice, IndexVec};
55use rustc_middle::mir::ConstraintCategory;
66use rustc_middle::ty::{RegionVid, TyCtxt, VarianceDiagInfo};
77use rustc_span::Span;
8use std::fmt;
9use std::ops::Index;
8
9use crate::region_infer::{ConstraintSccs, RegionDefinition, RegionTracker};
10use crate::type_check::Locations;
11use crate::universal_regions::UniversalRegions;
1012
1113pub(crate) mod graph;
1214
compiler/rustc_borrowck/src/consumers.rs+10-12
......@@ -1,24 +1,22 @@
11//! This file provides API for compiler consumers.
22
3use std::rc::Rc;
4
35use rustc_hir::def_id::LocalDefId;
46use rustc_index::{IndexSlice, IndexVec};
57use rustc_middle::mir::{Body, Promoted};
68use rustc_middle::ty::TyCtxt;
7use std::rc::Rc;
89
10pub use super::constraints::OutlivesConstraint;
11pub use super::dataflow::{calculate_borrows_out_of_scope_at_location, BorrowIndex, Borrows};
12pub use super::facts::{AllFacts as PoloniusInput, RustcFacts};
13pub use super::location::{LocationTable, RichLocation};
14pub use super::nll::PoloniusOutput;
15pub use super::place_ext::PlaceExt;
16pub use super::places_conflict::{places_conflict, PlaceConflictBias};
17pub use super::region_infer::RegionInferenceContext;
918use crate::borrow_set::BorrowSet;
1019
11pub 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
2220/// Options determining the output behavior of [`get_body_with_borrowck_facts`].
2321///
2422/// 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 @@
1use std::fmt;
2
13use rustc_data_structures::fx::FxIndexMap;
24use rustc_data_structures::graph;
35use rustc_index::bit_set::BitSet;
46use rustc_middle::mir::{
57 self, BasicBlock, Body, CallReturnPlaces, Location, Place, TerminatorEdges,
68};
7use rustc_middle::ty::RegionVid;
8use rustc_middle::ty::TyCtxt;
9use rustc_middle::ty::{RegionVid, TyCtxt};
10use rustc_mir_dataflow::fmt::DebugWithContext;
911use rustc_mir_dataflow::impls::{EverInitializedPlaces, MaybeUninitializedPlaces};
10use rustc_mir_dataflow::ResultsVisitable;
11use rustc_mir_dataflow::{fmt::DebugWithContext, GenKill};
12use rustc_mir_dataflow::{Analysis, AnalysisDomain, Results};
13use std::fmt;
12use rustc_mir_dataflow::{Analysis, AnalysisDomain, GenKill, Results, ResultsVisitable};
1413
1514use crate::{places_conflict, BorrowSet, PlaceConflictBias, PlaceExt, RegionInferenceContext};
1615
compiler/rustc_borrowck/src/diagnostics/bound_region_errors.rs+13-15
......@@ -1,17 +1,18 @@
1use std::fmt;
2use std::rc::Rc;
3
14use rustc_errors::Diag;
25use rustc_hir::def_id::LocalDefId;
36use rustc_infer::infer::canonical::Canonical;
4use rustc_infer::infer::region_constraints::Constraint;
5use rustc_infer::infer::region_constraints::RegionConstraintData;
6use rustc_infer::infer::RegionVariableOrigin;
7use rustc_infer::infer::{InferCtxt, RegionResolutionError, SubregionOrigin, TyCtxtInferExt as _};
7use rustc_infer::infer::region_constraints::{Constraint, RegionConstraintData};
8use rustc_infer::infer::{
9 InferCtxt, RegionResolutionError, RegionVariableOrigin, SubregionOrigin, TyCtxtInferExt as _,
10};
811use rustc_infer::traits::ObligationCause;
912use rustc_middle::ty::error::TypeError;
10use rustc_middle::ty::RePlaceholder;
11use rustc_middle::ty::Region;
12use rustc_middle::ty::RegionVid;
13use rustc_middle::ty::UniverseIndex;
14use rustc_middle::ty::{self, Ty, TyCtxt, TypeFoldable};
13use rustc_middle::ty::{
14 self, RePlaceholder, Region, RegionVid, Ty, TyCtxt, TypeFoldable, UniverseIndex,
15};
1516use rustc_span::Span;
1617use rustc_trait_selection::error_reporting::infer::nice_region_error::NiceRegionError;
1718use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
......@@ -19,13 +20,10 @@ use rustc_trait_selection::traits::query::type_op;
1920use rustc_trait_selection::traits::ObligationCtxt;
2021use rustc_traits::{type_op_ascribe_user_type_with_span, type_op_prove_predicate_with_cause};
2122
22use std::fmt;
23use std::rc::Rc;
24
2523use crate::region_infer::values::RegionElement;
26use crate::session_diagnostics::HigherRankedErrorCause;
27use crate::session_diagnostics::HigherRankedLifetimeError;
28use crate::session_diagnostics::HigherRankedSubtypeError;
24use crate::session_diagnostics::{
25 HigherRankedErrorCause, HigherRankedLifetimeError, HigherRankedSubtypeError,
26};
2927use crate::MirBorrowckCtxt;
3028
3129#[derive(Clone)]
compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs+14-21
......@@ -3,25 +3,27 @@
33#![allow(rustc::diagnostic_outside_of_impl)]
44#![allow(rustc::untranslatable_diagnostic)]
55
6use std::iter;
7use std::ops::ControlFlow;
8
69use either::Either;
710use hir::{ClosureKind, Path};
811use rustc_data_structures::captures::Captures;
912use rustc_data_structures::fx::FxIndexSet;
10use rustc_errors::{codes::*, struct_span_code_err, Applicability, Diag, MultiSpan};
13use rustc_errors::codes::*;
14use rustc_errors::{struct_span_code_err, Applicability, Diag, MultiSpan};
1115use rustc_hir as hir;
1216use rustc_hir::def::{DefKind, Res};
1317use rustc_hir::intravisit::{walk_block, walk_expr, Map, Visitor};
14use rustc_hir::{CoroutineDesugaring, PatField};
15use rustc_hir::{CoroutineKind, CoroutineSource, LangItem};
18use rustc_hir::{CoroutineDesugaring, CoroutineKind, CoroutineSource, LangItem, PatField};
1619use rustc_middle::bug;
1720use rustc_middle::hir::nested_filter::OnlyBodies;
1821use rustc_middle::mir::tcx::PlaceTy;
19use rustc_middle::mir::VarDebugInfoContents;
2022use rustc_middle::mir::{
2123 self, AggregateKind, BindingForm, BorrowKind, CallSource, ClearCrossCrate, ConstraintCategory,
2224 FakeBorrowKind, FakeReadCause, LocalDecl, LocalInfo, LocalKind, Location, MutBorrowKind,
2325 Operand, Place, PlaceRef, ProjectionElem, Rvalue, Statement, StatementKind, Terminator,
24 TerminatorKind, VarBindingForm,
26 TerminatorKind, VarBindingForm, VarDebugInfoContents,
2527};
2628use rustc_middle::ty::print::PrintTraitRefExt as _;
2729use rustc_middle::ty::{
......@@ -30,8 +32,7 @@ use rustc_middle::ty::{
3032};
3133use rustc_middle::util::CallKind;
3234use rustc_mir_dataflow::move_paths::{InitKind, MoveOutIndex, MovePathIndex};
33use rustc_span::def_id::DefId;
34use rustc_span::def_id::LocalDefId;
35use rustc_span::def_id::{DefId, LocalDefId};
3536use rustc_span::hygiene::DesugaringKind;
3637use rustc_span::symbol::{kw, sym, Ident};
3738use rustc_span::{BytePos, Span, Symbol};
......@@ -39,22 +40,14 @@ use rustc_trait_selection::error_reporting::traits::FindExprBySpan;
3940use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
4041use rustc_trait_selection::infer::InferCtxtExt;
4142use rustc_trait_selection::traits::{Obligation, ObligationCause, ObligationCtxt};
42use std::iter;
43use std::ops::ControlFlow;
4443
45use crate::borrow_set::TwoPhaseActivation;
46use crate::borrowck_errors;
44use super::explain_borrow::{BorrowExplanation, LaterUseKind};
45use super::{DescribePlaceOpt, RegionName, RegionNameSource, UseSpans};
46use crate::borrow_set::{BorrowData, TwoPhaseActivation};
4747use crate::diagnostics::conflict_errors::StorageDeadOrDrop::LocalStorageDead;
48use crate::diagnostics::{find_all_local_uses, CapturedMessageOpt};
49use crate::{
50 borrow_set::BorrowData, diagnostics::Instance, prefixes::IsPrefixOf,
51 InitializationRequiringAction, MirBorrowckCtxt, WriteKind,
52};
53
54use super::{
55 explain_borrow::{BorrowExplanation, LaterUseKind},
56 DescribePlaceOpt, RegionName, RegionNameSource, UseSpans,
57};
48use crate::diagnostics::{find_all_local_uses, CapturedMessageOpt, Instance};
49use crate::prefixes::IsPrefixOf;
50use crate::{borrowck_errors, InitializationRequiringAction, MirBorrowckCtxt, WriteKind};
5851
5952#[derive(Debug)]
6053struct MoveSite {
compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs+4-6
......@@ -19,13 +19,11 @@ use rustc_span::symbol::{kw, Symbol};
1919use rustc_span::{sym, DesugaringKind, Span};
2020use rustc_trait_selection::error_reporting::traits::FindExprBySpan;
2121
22use crate::region_infer::{BlameConstraint, ExtraConstraintInfo};
23use crate::{
24 borrow_set::BorrowData, nll::ConstraintDescription, region_infer::Cause, MirBorrowckCtxt,
25 WriteKind,
26};
27
2822use super::{find_use, RegionName, UseSpans};
23use crate::borrow_set::BorrowData;
24use crate::nll::ConstraintDescription;
25use crate::region_infer::{BlameConstraint, Cause, ExtraConstraintInfo};
26use crate::{MirBorrowckCtxt, WriteKind};
2927
3028#[derive(Debug)]
3129pub(crate) enum BorrowExplanation<'tcx> {
compiler/rustc_borrowck/src/diagnostics/find_use.rs+3-4
......@@ -1,15 +1,14 @@
11use std::collections::VecDeque;
22use std::rc::Rc;
33
4use crate::{
5 def_use::{self, DefUse},
6 region_infer::{Cause, RegionInferenceContext},
7};
84use rustc_data_structures::fx::FxIndexSet;
95use rustc_middle::mir::visit::{MirVisitable, PlaceContext, Visitor};
106use rustc_middle::mir::{self, Body, Local, Location};
117use rustc_middle::ty::{RegionVid, TyCtxt};
128
9use crate::def_use::{self, DefUse};
10use crate::region_infer::{Cause, RegionInferenceContext};
11
1312pub(crate) fn find<'tcx>(
1413 body: &Body<'tcx>,
1514 regioncx: &Rc<RegionInferenceContext<'tcx>>,
compiler/rustc_borrowck/src/diagnostics/mod.rs+11-12
......@@ -1,14 +1,8 @@
11//! Borrow checker diagnostics.
22
3use crate::session_diagnostics::{
4 CaptureArgLabel, CaptureReasonLabel, CaptureReasonNote, CaptureReasonSuggest, CaptureVarCause,
5 CaptureVarKind, CaptureVarPathUseCause, OnClosureNote,
6};
7use rustc_errors::MultiSpan;
8use rustc_errors::{Applicability, Diag};
3use rustc_errors::{Applicability, Diag, MultiSpan};
94use rustc_hir::def::{CtorKind, Namespace};
10use rustc_hir::CoroutineKind;
11use rustc_hir::{self as hir, LangItem};
5use rustc_hir::{self as hir, CoroutineKind, LangItem};
126use rustc_index::IndexSlice;
137use rustc_infer::infer::BoundRegionConversionTime;
148use rustc_infer::traits::SelectionError;
......@@ -25,7 +19,8 @@ use rustc_middle::util::{call_kind, CallDesugaringKind};
2519use rustc_mir_dataflow::move_paths::{InitLocation, LookupResult};
2620use rustc_span::def_id::LocalDefId;
2721use rustc_span::source_map::Spanned;
28use rustc_span::{symbol::sym, Span, Symbol, DUMMY_SP};
22use rustc_span::symbol::sym;
23use rustc_span::{Span, Symbol, DUMMY_SP};
2924use rustc_target::abi::{FieldIdx, VariantIdx};
3025use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
3126use rustc_trait_selection::infer::InferCtxtExt;
......@@ -33,10 +28,13 @@ use rustc_trait_selection::traits::{
3328 type_known_to_meet_bound_modulo_regions, FulfillmentErrorCode,
3429};
3530
36use crate::fluent_generated as fluent;
37
3831use super::borrow_set::BorrowData;
3932use super::MirBorrowckCtxt;
33use crate::fluent_generated as fluent;
34use crate::session_diagnostics::{
35 CaptureArgLabel, CaptureReasonLabel, CaptureReasonNote, CaptureReasonSuggest, CaptureVarCause,
36 CaptureVarKind, CaptureVarPathUseCause, OnClosureNote,
37};
4038
4139mod find_all_local_uses;
4240mod find_use;
......@@ -599,8 +597,9 @@ impl UseSpans<'_> {
599597 err: &mut Diag<'_>,
600598 action: crate::InitializationRequiringAction,
601599 ) {
602 use crate::InitializationRequiringAction::*;
603600 use CaptureVarPathUseCause::*;
601
602 use crate::InitializationRequiringAction::*;
604603 if let UseSpans::ClosureUse { closure_kind, path_span, .. } = self {
605604 match closure_kind {
606605 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};
1111use rustc_span::{BytePos, ExpnKind, MacroKind, Span};
1212use rustc_trait_selection::error_reporting::traits::FindExprBySpan;
1313
14use crate::diagnostics::CapturedMessageOpt;
15use crate::diagnostics::{DescribePlaceOpt, UseSpans};
14use crate::diagnostics::{CapturedMessageOpt, DescribePlaceOpt, UseSpans};
1615use crate::prefixes::PrefixSet;
1716use crate::MirBorrowckCtxt;
1817
compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs+8-9
......@@ -2,17 +2,18 @@
22#![allow(rustc::untranslatable_diagnostic)]
33
44use core::ops::ControlFlow;
5
56use hir::{ExprKind, Param};
67use rustc_errors::{Applicability, Diag};
78use rustc_hir::intravisit::Visitor;
89use rustc_hir::{self as hir, BindingMode, ByRef, Node};
910use rustc_middle::bug;
10use rustc_middle::mir::{Mutability, Place, PlaceRef, ProjectionElem};
11use rustc_middle::ty::{self, InstanceKind, Ty, TyCtxt, Upcast};
12use rustc_middle::{
13 hir::place::PlaceBase,
14 mir::{self, BindingForm, Local, LocalDecl, LocalInfo, LocalKind, Location},
11use rustc_middle::hir::place::PlaceBase;
12use rustc_middle::mir::{
13 self, BindingForm, Local, LocalDecl, LocalInfo, LocalKind, Location, Mutability, Place,
14 PlaceRef, ProjectionElem,
1515};
16use rustc_middle::ty::{self, InstanceKind, Ty, TyCtxt, Upcast};
1617use rustc_span::symbol::{kw, Symbol};
1718use rustc_span::{sym, BytePos, DesugaringKind, Span};
1819use rustc_target::abi::FieldIdx;
......@@ -847,10 +848,8 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
847848 // Attempt to search similar mutable associated items for suggestion.
848849 // In the future, attempt in all path but initially for RHS of for_loop
849850 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};
854853
855854 let hir_map = self.infcx.tcx.hir();
856855 struct Finder {
compiler/rustc_borrowck/src/diagnostics/outlives_suggestion.rs+3-3
......@@ -4,15 +4,15 @@
44#![allow(rustc::diagnostic_outside_of_impl)]
55#![allow(rustc::untranslatable_diagnostic)]
66
7use std::collections::BTreeMap;
8
79use rustc_data_structures::fx::FxIndexSet;
810use rustc_errors::Diag;
911use rustc_middle::ty::RegionVid;
1012use smallvec::SmallVec;
11use std::collections::BTreeMap;
12
13use crate::MirBorrowckCtxt;
1413
1514use super::{ErrorConstraintInfo, RegionName, RegionNameSource};
15use crate::MirBorrowckCtxt;
1616
1717/// The different things we could suggest.
1818enum SuggestedConstraint {
compiler/rustc_borrowck/src/diagnostics/region_errors.rs+7-14
......@@ -14,10 +14,7 @@ use rustc_infer::infer::{NllRegionVariableOrigin, RelateParamBound};
1414use rustc_middle::bug;
1515use rustc_middle::hir::place::PlaceBase;
1616use rustc_middle::mir::{ConstraintCategory, ReturnConstraint};
17use rustc_middle::ty::GenericArgs;
18use rustc_middle::ty::TypeVisitor;
19use rustc_middle::ty::{self, RegionVid, Ty};
20use rustc_middle::ty::{Region, TyCtxt};
17use rustc_middle::ty::{self, GenericArgs, Region, RegionVid, Ty, TyCtxt, TypeVisitor};
2118use rustc_span::symbol::{kw, Ident};
2219use rustc_span::Span;
2320use rustc_trait_selection::error_reporting::infer::nice_region_error::{
......@@ -29,20 +26,16 @@ use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
2926use rustc_trait_selection::infer::InferCtxtExt;
3027use rustc_trait_selection::traits::{Obligation, ObligationCtxt};
3128
32use crate::borrowck_errors;
29use super::{OutlivesSuggestionBuilder, RegionName, RegionNameSource};
30use crate::nll::ConstraintDescription;
31use crate::region_infer::values::RegionElement;
32use crate::region_infer::{BlameConstraint, ExtraConstraintInfo, TypeTest};
3333use crate::session_diagnostics::{
3434 FnMutError, FnMutReturnTypeErr, GenericDoesNotLiveLongEnough, LifetimeOutliveErr,
3535 LifetimeReturnCategoryErr, RequireStaticErr, VarHereDenote,
3636};
37
38use super::{OutlivesSuggestionBuilder, RegionName, RegionNameSource};
39use crate::region_infer::{BlameConstraint, ExtraConstraintInfo};
40use crate::{
41 nll::ConstraintDescription,
42 region_infer::{values::RegionElement, TypeTest},
43 universal_regions::DefiningTy,
44 MirBorrowckCtxt,
45};
37use crate::universal_regions::DefiningTy;
38use crate::{borrowck_errors, MirBorrowckCtxt};
4639
4740impl<'tcx> ConstraintDescription for ConstraintCategory<'tcx> {
4841 fn description(&self) -> &'static str {
compiler/rustc_borrowck/src/diagnostics/region_name.rs+3-3
......@@ -9,14 +9,14 @@ use rustc_errors::Diag;
99use rustc_hir as hir;
1010use rustc_hir::def::{DefKind, Res};
1111use rustc_middle::ty::print::RegionHighlightMode;
12use rustc_middle::ty::{self, RegionVid, Ty};
13use rustc_middle::ty::{GenericArgKind, GenericArgsRef};
12use rustc_middle::ty::{self, GenericArgKind, GenericArgsRef, RegionVid, Ty};
1413use rustc_middle::{bug, span_bug};
1514use rustc_span::symbol::{kw, sym, Symbol};
1615use rustc_span::{Span, DUMMY_SP};
1716use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
1817
19use crate::{universal_regions::DefiningTy, MirBorrowckCtxt};
18use crate::universal_regions::DefiningTy;
19use crate::MirBorrowckCtxt;
2020
2121/// A name for a particular region used in emitting diagnostics. This name could be a generated
2222/// 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 @@
1use crate::region_infer::RegionInferenceContext;
21use rustc_index::IndexSlice;
32use rustc_middle::mir::{Body, Local};
43use rustc_middle::ty::{self, RegionVid, TyCtxt};
54use rustc_span::symbol::Symbol;
65use rustc_span::Span;
76
7use crate::region_infer::RegionInferenceContext;
8
89impl<'tcx> RegionInferenceContext<'tcx> {
910 pub(crate) fn get_var_name_and_span_for_region(
1011 &self,
compiler/rustc_borrowck/src/facts.rs+9-8
......@@ -1,17 +1,18 @@
1use crate::location::{LocationIndex, LocationTable};
2use crate::BorrowIndex;
3use polonius_engine::AllFacts as PoloniusFacts;
4use polonius_engine::Atom;
5use rustc_macros::extension;
6use rustc_middle::mir::Local;
7use rustc_middle::ty::{RegionVid, TyCtxt};
8use rustc_mir_dataflow::move_paths::MovePathIndex;
91use std::error::Error;
102use std::fmt::Debug;
113use std::fs::{self, File};
124use std::io::{BufWriter, Write};
135use std::path::Path;
146
7use polonius_engine::{AllFacts as PoloniusFacts, Atom};
8use rustc_macros::extension;
9use rustc_middle::mir::Local;
10use rustc_middle::ty::{RegionVid, TyCtxt};
11use rustc_mir_dataflow::move_paths::MovePathIndex;
12
13use crate::location::{LocationIndex, LocationTable};
14use crate::BorrowIndex;
15
1516#[derive(Copy, Clone, Debug)]
1617pub struct RustcFacts;
1718
compiler/rustc_borrowck/src/lib.rs+19-21
......@@ -17,6 +17,13 @@
1717#[macro_use]
1818extern crate tracing;
1919
20use std::cell::RefCell;
21use std::collections::BTreeMap;
22use std::marker::PhantomData;
23use std::ops::Deref;
24use std::rc::Rc;
25
26use consumers::{BodyWithBorrowckFacts, ConsumerOptions};
2027use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
2128use rustc_data_structures::graph::dominators::Dominators;
2229use rustc_errors::Diag;
......@@ -24,40 +31,31 @@ use rustc_hir as hir;
2431use rustc_hir::def_id::LocalDefId;
2532use rustc_index::bit_set::{BitSet, ChunkedBitSet};
2633use rustc_index::{IndexSlice, IndexVec};
27use rustc_infer::infer::TyCtxtInferExt;
28use rustc_infer::infer::{InferCtxt, NllRegionVariableOrigin, RegionVariableOrigin};
34use rustc_infer::infer::{
35 InferCtxt, NllRegionVariableOrigin, RegionVariableOrigin, TyCtxtInferExt,
36};
2937use rustc_middle::mir::tcx::PlaceTy;
3038use rustc_middle::mir::*;
3139use rustc_middle::query::Providers;
3240use rustc_middle::ty::{self, ParamEnv, RegionVid, TyCtxt};
3341use rustc_middle::{bug, span_bug};
42use rustc_mir_dataflow::impls::{
43 EverInitializedPlaces, MaybeInitializedPlaces, MaybeUninitializedPlaces,
44};
45use rustc_mir_dataflow::move_paths::{
46 InitIndex, InitLocation, LookupResult, MoveData, MoveOutIndex, MovePathIndex,
47};
48use rustc_mir_dataflow::{Analysis, MoveDataParamEnv};
3449use rustc_session::lint::builtin::UNUSED_MUT;
3550use rustc_span::{Span, Symbol};
3651use rustc_target::abi::FieldIdx;
37
3852use smallvec::SmallVec;
39use std::cell::RefCell;
40use std::collections::BTreeMap;
41use std::marker::PhantomData;
42use std::ops::Deref;
43use std::rc::Rc;
44
45use rustc_mir_dataflow::impls::{
46 EverInitializedPlaces, MaybeInitializedPlaces, MaybeUninitializedPlaces,
47};
48use rustc_mir_dataflow::move_paths::{InitIndex, MoveOutIndex, MovePathIndex};
49use rustc_mir_dataflow::move_paths::{InitLocation, LookupResult, MoveData};
50use rustc_mir_dataflow::Analysis;
51use rustc_mir_dataflow::MoveDataParamEnv;
52
53use crate::session_diagnostics::VarNeedNotMut;
5453
5554use self::diagnostics::{AccessKind, IllegalMoveOriginKind, MoveError, RegionName};
5655use self::location::LocationTable;
57use self::prefixes::PrefixSet;
58use consumers::{BodyWithBorrowckFacts, ConsumerOptions};
59
6056use self::path_utils::*;
57use self::prefixes::PrefixSet;
58use crate::session_diagnostics::VarNeedNotMut;
6159
6260pub mod borrow_set;
6361mod borrowck_errors;
compiler/rustc_borrowck/src/member_constraints.rs+3-2
......@@ -1,11 +1,12 @@
1use std::hash::Hash;
2use std::ops::Index;
3
14use rustc_data_structures::captures::Captures;
25use rustc_data_structures::fx::FxIndexMap;
36use rustc_index::{IndexSlice, IndexVec};
47use rustc_middle::infer::MemberConstraint;
58use rustc_middle::ty::{self, Ty};
69use rustc_span::Span;
7use std::hash::Hash;
8use std::ops::Index;
910
1011/// Compactly stores a set of `R0 member of [R1...Rn]` constraints,
1112/// indexed by the region `R0`.
compiler/rustc_borrowck/src/nll.rs+18-20
......@@ -1,11 +1,18 @@
11//! The entry point of the NLL borrow checker.
22
3use std::path::PathBuf;
4use std::rc::Rc;
5use std::str::FromStr;
6use std::{env, io};
7
38use polonius_engine::{Algorithm, Output};
49use rustc_data_structures::fx::FxIndexMap;
510use rustc_hir::def_id::LocalDefId;
611use rustc_index::IndexSlice;
7use rustc_middle::mir::{create_dump_file, dump_enabled, dump_mir, PassWhere};
8use rustc_middle::mir::{Body, ClosureOutlivesSubject, ClosureRegionRequirements, Promoted};
12use rustc_middle::mir::{
13 create_dump_file, dump_enabled, dump_mir, Body, ClosureOutlivesSubject,
14 ClosureRegionRequirements, PassWhere, Promoted,
15};
916use rustc_middle::ty::print::with_no_trimmed_paths;
1017use rustc_middle::ty::{self, OpaqueHiddenType, TyCtxt};
1118use rustc_mir_dataflow::impls::MaybeInitializedPlaces;
......@@ -13,25 +20,16 @@ use rustc_mir_dataflow::move_paths::MoveData;
1320use rustc_mir_dataflow::points::DenseLocationMap;
1421use rustc_mir_dataflow::ResultsCursor;
1522use rustc_span::symbol::sym;
16use std::env;
17use std::io;
18use std::path::PathBuf;
19use std::rc::Rc;
20use std::str::FromStr;
2123
22use 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};
24use crate::borrow_set::BorrowSet;
25use crate::consumers::ConsumerOptions;
26use crate::diagnostics::RegionErrors;
27use crate::facts::{AllFacts, AllFactsExt, RustcFacts};
28use crate::location::LocationTable;
29use crate::region_infer::RegionInferenceContext;
30use crate::type_check::{self, MirTypeckRegionConstraints, MirTypeckResults};
31use crate::universal_regions::UniversalRegions;
32use crate::{polonius, renumber, BorrowckInferCtxt};
3533
3634pub type PoloniusOutput = Output<RustcFacts>;
3735
compiler/rustc_borrowck/src/path_utils.rs+4-6
......@@ -1,13 +1,11 @@
1use crate::borrow_set::{BorrowData, BorrowSet, TwoPhaseActivation};
2use crate::places_conflict;
3use crate::AccessDepth;
4use crate::BorrowIndex;
51use rustc_data_structures::graph::dominators::Dominators;
6use rustc_middle::mir::BorrowKind;
7use rustc_middle::mir::{BasicBlock, Body, Location, Place, PlaceRef, ProjectionElem};
2use rustc_middle::mir::{BasicBlock, Body, BorrowKind, Location, Place, PlaceRef, ProjectionElem};
83use rustc_middle::ty::TyCtxt;
94use rustc_target::abi::FieldIdx;
105
6use crate::borrow_set::{BorrowData, BorrowSet, TwoPhaseActivation};
7use crate::{places_conflict, AccessDepth, BorrowIndex};
8
119/// Returns `true` if the borrow represented by `kind` is
1210/// allowed to be split into separate Reservation and
1311/// Activation phases.
compiler/rustc_borrowck/src/place_ext.rs+3-3
......@@ -1,10 +1,10 @@
1use crate::borrow_set::LocalsStateAtExit;
21use rustc_hir as hir;
32use rustc_macros::extension;
4use rustc_middle::mir::ProjectionElem;
5use rustc_middle::mir::{Body, Mutability, Place};
3use rustc_middle::mir::{Body, Mutability, Place, ProjectionElem};
64use rustc_middle::ty::{self, TyCtxt};
75
6use crate::borrow_set::LocalsStateAtExit;
7
88#[extension(pub trait PlaceExt<'tcx>)]
99impl<'tcx> Place<'tcx> {
1010 /// Returns `true` if we can safely ignore borrows of this place.
compiler/rustc_borrowck/src/places_conflict.rs+5-5
......@@ -50,17 +50,17 @@
5050//! and either equal or disjoint.
5151//! - If we did run out of access, the borrow can access a part of it.
5252
53use crate::ArtificialField;
54use crate::Overlap;
55use crate::{AccessDepth, Deep, Shallow};
53use std::cmp::max;
54use std::iter;
55
5656use rustc_hir as hir;
5757use rustc_middle::bug;
5858use rustc_middle::mir::{
5959 Body, BorrowKind, FakeBorrowKind, MutBorrowKind, Place, PlaceElem, PlaceRef, ProjectionElem,
6060};
6161use rustc_middle::ty::{self, TyCtxt};
62use std::cmp::max;
63use std::iter;
62
63use crate::{AccessDepth, ArtificialField, Deep, Overlap, Shallow};
6464
6565/// When checking if a place conflicts with another place, this enum is used to influence decisions
6666/// 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;
22use rustc_middle::bug;
33use rustc_middle::mir::visit::Visitor;
44use 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,
68};
7use rustc_middle::mir::{BorrowKind, Mutability, Operand};
8use rustc_middle::mir::{InlineAsmOperand, Terminator, TerminatorKind};
9use rustc_middle::mir::{Statement, StatementKind};
109use rustc_middle::ty::TyCtxt;
1110
11use crate::borrow_set::BorrowSet;
12use crate::facts::AllFacts;
13use crate::location::LocationTable;
14use crate::path_utils::*;
1215use 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,
1618};
1719
1820/// Emit `loan_invalidated_at` facts.
compiler/rustc_borrowck/src/polonius/loan_kills.rs+4-1
......@@ -5,7 +5,10 @@ use rustc_middle::mir::{
55};
66use rustc_middle::ty::TyCtxt;
77
8use crate::{borrow_set::BorrowSet, facts::AllFacts, location::LocationTable, places_conflict};
8use crate::borrow_set::BorrowSet;
9use crate::facts::AllFacts;
10use crate::location::LocationTable;
11use crate::places_conflict;
912
1013/// Emit `loan_killed_at` and `cfg_edge` facts at the same time.
1114pub(super) fn emit_loan_kills<'tcx>(
compiler/rustc_borrowck/src/prefixes.rs+2-2
......@@ -4,10 +4,10 @@
44//! is borrowed. But: writing `a` is legal if `*a` is borrowed,
55//! whether or not `a` is a shared or mutable reference. [...] "
66
7use super::MirBorrowckCtxt;
8
97use rustc_middle::mir::{PlaceRef, ProjectionElem};
108
9use super::MirBorrowckCtxt;
10
1111pub trait IsPrefixOf<'tcx> {
1212 fn is_prefix_of(&self, other: PlaceRef<'tcx>) -> bool;
1313}
compiler/rustc_borrowck/src/region_infer/dump_mir.rs+5-3
......@@ -3,11 +3,13 @@
33//! state of region inference. This code handles emitting the region
44//! context internal state.
55
6use super::{OutlivesConstraint, RegionInferenceContext};
7use crate::type_check::Locations;
6use std::io::{self, Write};
7
88use rustc_infer::infer::NllRegionVariableOrigin;
99use rustc_middle::ty::TyCtxt;
10use std::io::{self, Write};
10
11use super::{OutlivesConstraint, RegionInferenceContext};
12use crate::type_check::Locations;
1113
1214// Room for "'_#NNNNr" before things get misaligned.
1315// 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 @@
55use std::borrow::Cow;
66use std::io::{self, Write};
77
8use super::*;
98use itertools::Itertools;
109use rustc_graphviz as dot;
1110use rustc_middle::ty::UniverseIndex;
1211
12use super::*;
13
1314fn render_outlives_constraint(constraint: &OutlivesConstraint<'_>) -> String {
1415 match constraint.locations {
1516 Locations::All(_) => "All(...)".to_string(),
compiler/rustc_borrowck/src/region_infer/mod.rs+12-14
......@@ -17,27 +17,25 @@ use rustc_middle::mir::{
1717 ClosureRegionRequirements, ConstraintCategory, Local, Location, ReturnConstraint,
1818 TerminatorKind,
1919};
20use rustc_middle::traits::ObligationCause;
21use rustc_middle::traits::ObligationCauseCode;
20use rustc_middle::traits::{ObligationCause, ObligationCauseCode};
2221use rustc_middle::ty::{self, RegionVid, Ty, TyCtxt, TypeFoldable, UniverseIndex};
2322use rustc_mir_dataflow::points::DenseLocationMap;
2423use rustc_span::Span;
2524
2625use crate::constraints::graph::{self, NormalConstraintGraph, RegionGraph};
26use crate::constraints::{ConstraintSccIndex, OutlivesConstraint, OutlivesConstraintSet};
2727use crate::dataflow::BorrowIndex;
28use 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,
28use crate::diagnostics::{RegionErrorKind, RegionErrors, UniverseInfo};
29use crate::member_constraints::{MemberConstraintSet, NllMemberConstraintIndex};
30use crate::nll::PoloniusOutput;
31use crate::region_infer::reverse_sccs::ReverseSccGraph;
32use crate::region_infer::values::{
33 LivenessValues, PlaceholderIndices, RegionElement, RegionValues, ToElementIndex,
4034};
35use crate::type_check::free_region_relations::UniversalRegionRelations;
36use crate::type_check::Locations;
37use crate::universal_regions::UniversalRegions;
38use crate::BorrowckInferCtxt;
4139
4240mod dump_mir;
4341mod graphviz;
compiler/rustc_borrowck/src/region_infer/opaque_types.rs+6-8
......@@ -3,22 +3,20 @@ use rustc_errors::ErrorGuaranteed;
33use rustc_hir::def::DefKind;
44use rustc_hir::def_id::LocalDefId;
55use rustc_hir::OpaqueTyOrigin;
6use rustc_infer::infer::TyCtxtInferExt as _;
7use rustc_infer::infer::{InferCtxt, NllRegionVariableOrigin};
6use rustc_infer::infer::{InferCtxt, NllRegionVariableOrigin, TyCtxtInferExt as _};
87use rustc_infer::traits::{Obligation, ObligationCause};
98use rustc_macros::extension;
109use rustc_middle::ty::visit::TypeVisitableExt;
11use rustc_middle::ty::{self, OpaqueHiddenType, OpaqueTypeKey, Ty, TyCtxt, TypeFoldable};
12use rustc_middle::ty::{GenericArgKind, GenericArgs};
10use rustc_middle::ty::{
11 self, GenericArgKind, GenericArgs, OpaqueHiddenType, OpaqueTypeKey, Ty, TyCtxt, TypeFoldable,
12};
1313use rustc_span::Span;
1414use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
1515use rustc_trait_selection::traits::ObligationCtxt;
1616
17use crate::session_diagnostics::LifetimeMismatchOpaqueParam;
18use crate::session_diagnostics::NonGenericOpaqueTypeParam;
19use crate::universal_regions::RegionClassification;
20
2117use super::RegionInferenceContext;
18use crate::session_diagnostics::{LifetimeMismatchOpaqueParam, NonGenericOpaqueTypeParam};
19use crate::universal_regions::RegionClassification;
2220
2321impl<'tcx> RegionInferenceContext<'tcx> {
2422 /// 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 @@
1use crate::constraints::ConstraintSccIndex;
2use crate::RegionInferenceContext;
1use std::ops::Range;
2
33use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
44use rustc_data_structures::graph;
55use rustc_data_structures::graph::vec_graph::VecGraph;
66use rustc_middle::ty::RegionVid;
7use std::ops::Range;
7
8use crate::constraints::ConstraintSccIndex;
9use crate::RegionInferenceContext;
810
911pub(crate) struct ReverseSccGraph {
1012 graph: VecGraph<ConstraintSccIndex>,
compiler/rustc_borrowck/src/region_infer/values.rs+5-6
......@@ -1,14 +1,13 @@
1use rustc_data_structures::fx::FxHashSet;
2use rustc_data_structures::fx::FxIndexSet;
1use std::fmt::Debug;
2use std::rc::Rc;
3
4use rustc_data_structures::fx::{FxHashSet, FxIndexSet};
35use rustc_index::bit_set::SparseBitMatrix;
4use rustc_index::interval::IntervalSet;
5use rustc_index::interval::SparseIntervalMatrix;
6use rustc_index::interval::{IntervalSet, SparseIntervalMatrix};
67use rustc_index::Idx;
78use rustc_middle::mir::{BasicBlock, Location};
89use rustc_middle::ty::{self, RegionVid};
910use rustc_mir_dataflow::points::{DenseLocationMap, PointIndex};
10use std::fmt::Debug;
11use std::rc::Rc;
1211
1312use crate::BorrowIndex;
1413
compiler/rustc_borrowck/src/renumber.rs+3-3
......@@ -1,12 +1,12 @@
1use crate::BorrowckInferCtxt;
21use rustc_index::IndexSlice;
32use rustc_infer::infer::NllRegionVariableOrigin;
43use rustc_middle::mir::visit::{MutVisitor, TyContext};
54use rustc_middle::mir::{Body, ConstOperand, Location, Promoted};
6use rustc_middle::ty::GenericArgsRef;
7use rustc_middle::ty::{self, Ty, TyCtxt, TypeFoldable};
5use rustc_middle::ty::{self, GenericArgsRef, Ty, TyCtxt, TypeFoldable};
86use rustc_span::Symbol;
97
8use crate::BorrowckInferCtxt;
9
1010/// Replaces all free regions appearing in the MIR with fresh
1111/// inference variables, returning the number of variables created.
1212#[instrument(skip(infcx, body, promoted), level = "debug")]
compiler/rustc_borrowck/src/session_diagnostics.rs+2-1
......@@ -1,4 +1,5 @@
1use rustc_errors::{codes::*, MultiSpan};
1use rustc_errors::codes::*;
2use rustc_errors::MultiSpan;
23use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
34use rustc_middle::ty::{GenericArg, Ty};
45use rustc_span::Span;
compiler/rustc_borrowck/src/type_check/canonical.rs+1-2
......@@ -10,9 +10,8 @@ use rustc_span::Span;
1010use rustc_trait_selection::traits::query::type_op::{self, TypeOpOutput};
1111use rustc_trait_selection::traits::ObligationCause;
1212
13use crate::diagnostics::ToUniverseInfo;
14
1513use super::{Locations, NormalizeLocation, TypeChecker};
14use crate::diagnostics::ToUniverseInfo;
1615
1716impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
1817 /// 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;
1414use rustc_trait_selection::traits::query::type_op::{TypeOp, TypeOpOutput};
1515use rustc_trait_selection::traits::ScrubbedTraitError;
1616
17use crate::{
18 constraints::OutlivesConstraint,
19 region_infer::TypeTest,
20 type_check::{Locations, MirTypeckRegionConstraints},
21 universal_regions::UniversalRegions,
22};
17use crate::constraints::OutlivesConstraint;
18use crate::region_infer::TypeTest;
19use crate::type_check::{Locations, MirTypeckRegionConstraints};
20use crate::universal_regions::UniversalRegions;
2321
2422pub(crate) struct ConstraintConversion<'a, 'tcx> {
2523 infcx: &'a InferCtxt<'tcx>,
compiler/rustc_borrowck/src/type_check/free_region_relations.rs+5-8
......@@ -1,11 +1,12 @@
1use std::rc::Rc;
2
13use rustc_data_structures::frozen::Frozen;
24use rustc_data_structures::transitive_relation::{TransitiveRelation, TransitiveRelationBuilder};
35use rustc_hir::def::DefKind;
46use rustc_infer::infer::canonical::QueryRegionConstraints;
5use rustc_infer::infer::outlives;
67use rustc_infer::infer::outlives::env::RegionBoundPairs;
78use rustc_infer::infer::region_constraints::GenericKind;
8use rustc_infer::infer::InferCtxt;
9use rustc_infer::infer::{outlives, InferCtxt};
910use rustc_middle::mir::ConstraintCategory;
1011use rustc_middle::traits::query::OutlivesBound;
1112use rustc_middle::traits::ObligationCause;
......@@ -14,14 +15,10 @@ use rustc_span::{ErrorGuaranteed, Span};
1415use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
1516use rustc_trait_selection::solve::deeply_normalize;
1617use rustc_trait_selection::traits::query::type_op::{self, TypeOp};
17use std::rc::Rc;
1818use type_op::TypeOpOutput;
1919
20use crate::{
21 type_check::constraint_conversion,
22 type_check::{Locations, MirTypeckRegionConstraints},
23 universal_regions::UniversalRegions,
24};
20use crate::type_check::{constraint_conversion, Locations, MirTypeckRegionConstraints};
21use crate::universal_regions::UniversalRegions;
2522
2623#[derive(Debug)]
2724pub(crate) struct UniversalRegionRelations<'tcx> {
compiler/rustc_borrowck/src/type_check/input_output.rs+1-2
......@@ -16,11 +16,10 @@ use rustc_middle::mir::*;
1616use rustc_middle::ty::{self, Ty};
1717use rustc_span::Span;
1818
19use super::{Locations, TypeChecker};
1920use crate::renumber::RegionCtxt;
2021use crate::universal_regions::{DefiningTy, UniversalRegions};
2122
22use super::{Locations, TypeChecker};
23
2423impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
2524 /// Check explicit closure signature annotation,
2625 /// e.g., `|x: FxIndexMap<_, &'static u32>| ...`.
compiler/rustc_borrowck/src/type_check/liveness/mod.rs+5-6
......@@ -1,3 +1,5 @@
1use std::rc::Rc;
2
13use itertools::{Either, Itertools};
24use rustc_data_structures::fx::FxHashSet;
35use rustc_middle::mir::visit::{TyContext, Visitor};
......@@ -9,14 +11,11 @@ use rustc_mir_dataflow::impls::MaybeInitializedPlaces;
911use rustc_mir_dataflow::move_paths::MoveData;
1012use rustc_mir_dataflow::points::DenseLocationMap;
1113use rustc_mir_dataflow::ResultsCursor;
12use std::rc::Rc;
13
14use crate::{
15 constraints::OutlivesConstraintSet, region_infer::values::LivenessValues,
16 universal_regions::UniversalRegions,
17};
1814
1915use super::TypeChecker;
16use crate::constraints::OutlivesConstraintSet;
17use crate::region_infer::values::LivenessValues;
18use crate::universal_regions::UniversalRegions;
2019
2120mod local_use_map;
2221mod polonius;
compiler/rustc_borrowck/src/type_check/liveness/polonius.rs+2-2
......@@ -1,11 +1,11 @@
1use crate::def_use::{self, DefUse};
2use crate::location::{LocationIndex, LocationTable};
31use rustc_middle::mir::visit::{MutatingUseContext, PlaceContext, Visitor};
42use rustc_middle::mir::{Body, Local, Location, Place};
53use rustc_middle::ty::GenericArg;
64use rustc_mir_dataflow::move_paths::{LookupResult, MoveData, MovePathIndex};
75
86use super::TypeChecker;
7use crate::def_use::{self, DefUse};
8use crate::location::{LocationIndex, LocationTable};
99
1010type VarPointRelation = Vec<(Local, LocationIndex)>;
1111type PathPointRelation = Vec<(MovePathIndex, LocationIndex)>;
compiler/rustc_borrowck/src/type_check/liveness/trace.rs+9-12
......@@ -1,3 +1,5 @@
1use std::rc::Rc;
2
13use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
24use rustc_index::bit_set::BitSet;
35use rustc_index::interval::IntervalSet;
......@@ -6,24 +8,19 @@ use rustc_infer::infer::outlives::for_liveness;
68use rustc_middle::mir::{BasicBlock, Body, ConstraintCategory, Local, Location};
79use rustc_middle::traits::query::DropckOutlivesResult;
810use rustc_middle::ty::{Ty, TyCtxt, TypeVisitable, TypeVisitableExt};
11use rustc_mir_dataflow::impls::MaybeInitializedPlaces;
12use rustc_mir_dataflow::move_paths::{HasMoveData, MoveData, MovePathIndex};
913use rustc_mir_dataflow::points::{DenseLocationMap, PointIndex};
14use rustc_mir_dataflow::ResultsCursor;
1015use rustc_span::DUMMY_SP;
1116use rustc_trait_selection::traits::query::type_op::outlives::DropckOutlives;
1217use rustc_trait_selection::traits::query::type_op::{TypeOp, TypeOpOutput};
13use std::rc::Rc;
14
15use rustc_mir_dataflow::impls::MaybeInitializedPlaces;
16use rustc_mir_dataflow::move_paths::{HasMoveData, MoveData, MovePathIndex};
17use rustc_mir_dataflow::ResultsCursor;
1818
1919use crate::location::RichLocation;
20use 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};
20use crate::region_infer::values::{self, LiveLoans};
21use crate::type_check::liveness::local_use_map::LocalUseMap;
22use crate::type_check::liveness::polonius;
23use crate::type_check::{NormalizeLocation, TypeChecker};
2724
2825/// This is the heart of the liveness computation. For each variable X
2926/// 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;
44use std::{fmt, iter, mem};
55
66use either::Either;
7
87use rustc_data_structures::frozen::Frozen;
98use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
109use rustc_errors::ErrorGuaranteed;
......@@ -28,44 +27,38 @@ use rustc_middle::ty::cast::CastTy;
2827use rustc_middle::ty::visit::TypeVisitableExt;
2928use rustc_middle::ty::{
3029 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,
3332};
34use rustc_middle::ty::{GenericArgsRef, UserArgs};
3533use rustc_middle::{bug, span_bug};
34use rustc_mir_dataflow::impls::MaybeInitializedPlaces;
35use rustc_mir_dataflow::move_paths::MoveData;
3636use rustc_mir_dataflow::points::DenseLocationMap;
37use rustc_mir_dataflow::ResultsCursor;
3738use rustc_span::def_id::CRATE_DEF_ID;
3839use rustc_span::source_map::Spanned;
3940use rustc_span::symbol::sym;
40use rustc_span::Span;
41use rustc_span::DUMMY_SP;
41use rustc_span::{Span, DUMMY_SP};
4242use rustc_target::abi::{FieldIdx, FIRST_VARIANT};
43use rustc_trait_selection::traits::query::type_op::custom::scrape_region_constraints;
44use rustc_trait_selection::traits::query::type_op::custom::CustomTypeOp;
43use rustc_trait_selection::traits::query::type_op::custom::{
44 scrape_region_constraints, CustomTypeOp,
45};
4546use rustc_trait_selection::traits::query::type_op::{TypeOp, TypeOpOutput};
46
4747use rustc_trait_selection::traits::PredicateObligation;
4848
49use rustc_mir_dataflow::impls::MaybeInitializedPlaces;
50use rustc_mir_dataflow::move_paths::MoveData;
51use rustc_mir_dataflow::ResultsCursor;
52
49use crate::borrow_set::BorrowSet;
50use crate::constraints::{OutlivesConstraint, OutlivesConstraintSet};
51use crate::diagnostics::UniverseInfo;
52use crate::facts::AllFacts;
53use crate::location::LocationTable;
54use crate::member_constraints::MemberConstraintSet;
55use crate::region_infer::values::{LivenessValues, PlaceholderIndex, PlaceholderIndices};
56use crate::region_infer::TypeTest;
5357use crate::renumber::RegionCtxt;
5458use crate::session_diagnostics::{MoveUnsized, SimdIntrinsicArgConst};
55use 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};
59use crate::type_check::free_region_relations::{CreateResult, UniversalRegionRelations};
60use crate::universal_regions::{DefiningTy, UniversalRegions};
61use crate::{path_utils, BorrowckInferCtxt};
6962
7063macro_rules! span_mirbug {
7164 ($context:expr, $elem:expr, $($message:tt)*) => ({
compiler/rustc_borrowck/src/universal_regions.rs+6-4
......@@ -15,6 +15,9 @@
1515#![allow(rustc::diagnostic_outside_of_impl)]
1616#![allow(rustc::untranslatable_diagnostic)]
1717
18use std::cell::Cell;
19use std::iter;
20
1821use rustc_data_structures::fx::FxIndexMap;
1922use rustc_errors::Diag;
2023use rustc_hir::def_id::{DefId, LocalDefId};
......@@ -25,13 +28,12 @@ use rustc_infer::infer::NllRegionVariableOrigin;
2528use rustc_macros::extension;
2629use rustc_middle::ty::fold::TypeFoldable;
2730use rustc_middle::ty::print::with_no_trimmed_paths;
28use rustc_middle::ty::{self, InlineConstArgs, InlineConstArgsParts, RegionVid, Ty, TyCtxt};
29use rustc_middle::ty::{GenericArgs, GenericArgsRef};
31use rustc_middle::ty::{
32 self, GenericArgs, GenericArgsRef, InlineConstArgs, InlineConstArgsParts, RegionVid, Ty, TyCtxt,
33};
3034use rustc_middle::{bug, span_bug};
3135use rustc_span::symbol::{kw, sym};
3236use rustc_span::{ErrorGuaranteed, Symbol};
33use std::cell::Cell;
34use std::iter;
3537
3638use crate::renumber::RegionCtxt;
3739use crate::BorrowckInferCtxt;
compiler/rustc_borrowck/src/util/collect_writes.rs+1-2
......@@ -1,5 +1,4 @@
1use rustc_middle::mir::visit::PlaceContext;
2use rustc_middle::mir::visit::Visitor;
1use rustc_middle::mir::visit::{PlaceContext, Visitor};
32use rustc_middle::mir::{Body, Local, Location};
43
54pub trait FindAssignments {
compiler/rustc_builtin_macros/src/alloc_error_handler.rs+6-5
......@@ -1,14 +1,15 @@
1use crate::errors;
2use crate::util::check_builtin_macro_attribute;
3
41use rustc_ast::ptr::P;
5use rustc_ast::{self as ast, FnHeader, FnSig, Generics, StmtKind};
6use rustc_ast::{Fn, ItemKind, Safety, Stmt, TyKind};
2use rustc_ast::{
3 self as ast, Fn, FnHeader, FnSig, Generics, ItemKind, Safety, Stmt, StmtKind, TyKind,
4};
75use rustc_expand::base::{Annotatable, ExtCtxt};
86use rustc_span::symbol::{kw, sym, Ident};
97use rustc_span::Span;
108use thin_vec::{thin_vec, ThinVec};
119
10use crate::errors;
11use crate::util::check_builtin_macro_attribute;
12
1213pub(crate) fn expand(
1314 ecx: &mut ExtCtxt<'_>,
1415 _span: Span,
compiler/rustc_builtin_macros/src/asm.rs+5-6
......@@ -1,8 +1,5 @@
1use crate::errors;
2use crate::util::expr_to_spanned_string;
31use ast::token::IdentIsRaw;
42use lint::BuiltinLintDiag;
5use rustc_ast as ast;
63use rustc_ast::ptr::P;
74use rustc_ast::token::{self, Delimiter};
85use rustc_ast::tokenstream::TokenStream;
......@@ -11,13 +8,15 @@ use rustc_errors::PResult;
118use rustc_expand::base::*;
129use rustc_index::bit_set::GrowableBitSet;
1310use rustc_parse::parser::Parser;
14use rustc_parse_format as parse;
1511use rustc_session::lint;
16use rustc_span::symbol::Ident;
17use rustc_span::symbol::{kw, sym, Symbol};
12use rustc_span::symbol::{kw, sym, Ident, Symbol};
1813use rustc_span::{ErrorGuaranteed, InnerSpan, Span};
1914use rustc_target::asm::InlineAsmArch;
2015use smallvec::smallvec;
16use {rustc_ast as ast, rustc_parse_format as parse};
17
18use crate::errors;
19use crate::util::expr_to_spanned_string;
2120
2221pub struct AsmArgs {
2322 pub templates: Vec<P<ast::Expr>>,
compiler/rustc_builtin_macros/src/assert.rs+4-4
......@@ -1,12 +1,9 @@
11mod context;
22
3use crate::edition_panic::use_panic_2021;
4use crate::errors;
53use rustc_ast::ptr::P;
6use rustc_ast::token;
74use rustc_ast::token::Delimiter;
85use rustc_ast::tokenstream::{DelimSpan, TokenStream};
9use rustc_ast::{DelimArgs, Expr, ExprKind, MacCall, Path, PathSegment, UnOp};
6use rustc_ast::{token, DelimArgs, Expr, ExprKind, MacCall, Path, PathSegment, UnOp};
107use rustc_ast_pretty::pprust;
118use rustc_errors::PResult;
129use rustc_expand::base::{DummyResult, ExpandResult, ExtCtxt, MacEager, MacroExpanderResult};
......@@ -15,6 +12,9 @@ use rustc_span::symbol::{sym, Ident, Symbol};
1512use rustc_span::{Span, DUMMY_SP};
1613use thin_vec::thin_vec;
1714
15use crate::edition_panic::use_panic_2021;
16use crate::errors;
17
1818pub(crate) fn expand_assert<'cx>(
1919 cx: &'cx mut ExtCtxt<'_>,
2020 span: Span,
compiler/rustc_builtin_macros/src/assert/context.rs+5-7
......@@ -1,17 +1,15 @@
1use rustc_ast::ptr::P;
2use rustc_ast::token::{self, Delimiter, IdentIsRaw};
3use rustc_ast::tokenstream::{DelimSpan, TokenStream, TokenTree};
14use rustc_ast::{
2 ptr::P,
3 token::{self, Delimiter, IdentIsRaw},
4 tokenstream::{DelimSpan, TokenStream, TokenTree},
55 BinOpKind, BorrowKind, DelimArgs, Expr, ExprKind, ItemKind, MacCall, MethodCall, Mutability,
66 Path, PathSegment, Stmt, StructRest, UnOp, UseTree, UseTreeKind, DUMMY_NODE_ID,
77};
88use rustc_ast_pretty::pprust;
99use rustc_data_structures::fx::FxHashSet;
1010use rustc_expand::base::ExtCtxt;
11use rustc_span::{
12 symbol::{sym, Ident, Symbol},
13 Span,
14};
11use rustc_span::symbol::{sym, Ident, Symbol};
12use rustc_span::Span;
1513use thin_vec::{thin_vec, ThinVec};
1614
1715pub(super) struct Context<'cx, 'a> {
compiler/rustc_builtin_macros/src/cfg.rs+3-3
......@@ -2,14 +2,14 @@
22//! a literal `true` or `false` based on whether the given cfg matches the
33//! current compilation environment.
44
5use crate::errors;
6use rustc_ast as ast;
75use rustc_ast::token;
86use rustc_ast::tokenstream::TokenStream;
9use rustc_attr as attr;
107use rustc_errors::PResult;
118use rustc_expand::base::{DummyResult, ExpandResult, ExtCtxt, MacEager, MacroExpanderResult};
129use rustc_span::Span;
10use {rustc_ast as ast, rustc_attr as attr};
11
12use crate::errors;
1313
1414pub(crate) fn expand_cfg(
1515 cx: &mut ExtCtxt<'_>,
compiler/rustc_builtin_macros/src/cfg_accessible.rs+2-1
......@@ -1,6 +1,5 @@
11//! Implementation of the `#[cfg_accessible(path)]` attribute macro.
22
3use crate::errors;
43use rustc_ast as ast;
54use rustc_expand::base::{Annotatable, ExpandResult, ExtCtxt, Indeterminate, MultiItemModifier};
65use rustc_feature::AttributeTemplate;
......@@ -8,6 +7,8 @@ use rustc_parse::validate_attr;
87use rustc_span::symbol::sym;
98use rustc_span::Span;
109
10use crate::errors;
11
1112pub(crate) struct Expander;
1213
1314fn 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 @@
1use crate::util::{check_builtin_macro_attribute, warn_on_duplicate_attribute};
2
31use core::ops::ControlFlow;
2
43use rustc_ast as ast;
54use rustc_ast::mut_visit::MutVisitor;
65use rustc_ast::ptr::P;
76use rustc_ast::visit::{AssocCtxt, Visitor};
8use rustc_ast::NodeId;
9use rustc_ast::{mut_visit, visit};
10use rustc_ast::{Attribute, HasAttrs, HasTokens};
7use rustc_ast::{mut_visit, visit, Attribute, HasAttrs, HasTokens, NodeId};
118use rustc_errors::PResult;
129use rustc_expand::base::{Annotatable, ExtCtxt};
1310use rustc_expand::config::StripUnconfigured;
......@@ -20,6 +17,8 @@ use rustc_span::Span;
2017use smallvec::SmallVec;
2118use tracing::instrument;
2219
20use crate::util::{check_builtin_macro_attribute, warn_on_duplicate_attribute};
21
2322pub(crate) fn expand(
2423 ecx: &mut ExtCtxt<'_>,
2524 _span: Span,
compiler/rustc_builtin_macros/src/cmdline_attrs.rs+3-3
......@@ -1,14 +1,14 @@
11//! Attributes injected into the crate root from command line using `-Z crate-attr`.
22
3use crate::errors;
43use rustc_ast::attr::mk_attr;
5use rustc_ast::token;
6use rustc_ast::{self as ast, AttrItem, AttrStyle};
4use rustc_ast::{self as ast, token, AttrItem, AttrStyle};
75use rustc_parse::parser::ForceCollect;
86use rustc_parse::{new_parser_from_source_str, unwrap_or_emit_fatal};
97use rustc_session::parse::ParseSess;
108use rustc_span::FileName;
119
10use crate::errors;
11
1212pub fn inject(krate: &mut ast::Crate, psess: &ParseSess, attrs: &[String]) {
1313 for raw_attr in attrs {
1414 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 @@
11// The compiler code necessary to support the compile_error! extension.
22
3use crate::util::get_single_str_from_tts;
43use rustc_ast::tokenstream::TokenStream;
54use rustc_expand::base::{DummyResult, ExpandResult, ExtCtxt, MacroExpanderResult};
65use rustc_span::Span;
76
7use crate::util::get_single_str_from_tts;
8
89pub(crate) fn expand_compile_error<'cx>(
910 cx: &'cx mut ExtCtxt<'_>,
1011 sp: Span,
compiler/rustc_builtin_macros/src/concat.rs+3-2
......@@ -1,11 +1,12 @@
1use crate::errors;
2use crate::util::get_exprs_from_tts;
31use rustc_ast::tokenstream::TokenStream;
42use rustc_ast::{ExprKind, LitKind, UnOp};
53use rustc_expand::base::{DummyResult, ExpandResult, ExtCtxt, MacEager, MacroExpanderResult};
64use rustc_session::errors::report_lit_error;
75use rustc_span::symbol::Symbol;
86
7use crate::errors;
8use crate::util::get_exprs_from_tts;
9
910pub(crate) fn expand_concat(
1011 cx: &mut ExtCtxt<'_>,
1112 sp: rustc_span::Span,
compiler/rustc_builtin_macros/src/concat_bytes.rs+6-3
......@@ -1,10 +1,13 @@
1use crate::errors;
2use crate::util::get_exprs_from_tts;
3use rustc_ast::{ptr::P, token, tokenstream::TokenStream, ExprKind, LitIntType, LitKind, UintTy};
1use rustc_ast::ptr::P;
2use rustc_ast::tokenstream::TokenStream;
3use rustc_ast::{token, ExprKind, LitIntType, LitKind, UintTy};
44use rustc_expand::base::{DummyResult, ExpandResult, ExtCtxt, MacEager, MacroExpanderResult};
55use rustc_session::errors::report_lit_error;
66use rustc_span::{ErrorGuaranteed, Span};
77
8use crate::errors;
9use crate::util::get_exprs_from_tts;
10
811/// Emits errors for literal expressions that are invalid inside and outside of an array.
912fn invalid_type_err(
1013 cx: &ExtCtxt<'_>,
compiler/rustc_builtin_macros/src/derive.rs+3-3
......@@ -1,6 +1,3 @@
1use crate::cfg_eval::cfg_eval;
2use crate::errors;
3
41use rustc_ast as ast;
52use rustc_ast::{GenericParamKind, ItemKind, MetaItemKind, NestedMetaItem, Safety, StmtKind};
63use rustc_expand::base::{
......@@ -12,6 +9,9 @@ use rustc_session::Session;
129use rustc_span::symbol::{sym, Ident};
1310use rustc_span::{ErrorGuaranteed, Span};
1411
12use crate::cfg_eval::cfg_eval;
13use crate::errors;
14
1515pub(crate) struct Expander {
1616 pub is_const: bool,
1717}
compiler/rustc_builtin_macros/src/deriving/bounds.rs+3-3
......@@ -1,10 +1,10 @@
1use crate::deriving::generic::*;
2use crate::deriving::path_std;
3
41use rustc_ast::MetaItem;
52use rustc_expand::base::{Annotatable, ExtCtxt};
63use rustc_span::Span;
74
5use crate::deriving::generic::*;
6use crate::deriving::path_std;
7
88pub(crate) fn expand_deriving_copy(
99 cx: &ExtCtxt<'_>,
1010 span: Span,
compiler/rustc_builtin_macros/src/deriving/clone.rs+4-3
......@@ -1,6 +1,3 @@
1use crate::deriving::generic::ty::*;
2use crate::deriving::generic::*;
3use crate::deriving::path_std;
41use rustc_ast::{self as ast, Generics, ItemKind, MetaItem, VariantData};
52use rustc_data_structures::fx::FxHashSet;
63use rustc_expand::base::{Annotatable, ExtCtxt};
......@@ -8,6 +5,10 @@ use rustc_span::symbol::{kw, sym, Ident};
85use rustc_span::Span;
96use thin_vec::{thin_vec, ThinVec};
107
8use crate::deriving::generic::ty::*;
9use crate::deriving::generic::*;
10use crate::deriving::path_std;
11
1112pub(crate) fn expand_deriving_clone(
1213 cx: &ExtCtxt<'_>,
1314 span: Span,
compiler/rustc_builtin_macros/src/deriving/cmp/eq.rs+4-4
......@@ -1,7 +1,3 @@
1use crate::deriving::generic::ty::*;
2use crate::deriving::generic::*;
3use crate::deriving::path_std;
4
51use rustc_ast::{self as ast, MetaItem};
62use rustc_data_structures::fx::FxHashSet;
73use rustc_expand::base::{Annotatable, ExtCtxt};
......@@ -9,6 +5,10 @@ use rustc_span::symbol::sym;
95use rustc_span::Span;
106use thin_vec::{thin_vec, ThinVec};
117
8use crate::deriving::generic::ty::*;
9use crate::deriving::generic::*;
10use crate::deriving::path_std;
11
1212pub(crate) fn expand_deriving_eq(
1313 cx: &ExtCtxt<'_>,
1414 span: Span,
compiler/rustc_builtin_macros/src/deriving/cmp/ord.rs+4-3
......@@ -1,12 +1,13 @@
1use crate::deriving::generic::ty::*;
2use crate::deriving::generic::*;
3use crate::deriving::path_std;
41use rustc_ast::MetaItem;
52use rustc_expand::base::{Annotatable, ExtCtxt};
63use rustc_span::symbol::{sym, Ident};
74use rustc_span::Span;
85use thin_vec::thin_vec;
96
7use crate::deriving::generic::ty::*;
8use crate::deriving::generic::*;
9use crate::deriving::path_std;
10
1011pub(crate) fn expand_deriving_ord(
1112 cx: &ExtCtxt<'_>,
1213 span: Span,
compiler/rustc_builtin_macros/src/deriving/cmp/partial_eq.rs+4-3
......@@ -1,6 +1,3 @@
1use crate::deriving::generic::ty::*;
2use crate::deriving::generic::*;
3use crate::deriving::{path_local, path_std};
41use rustc_ast::ptr::P;
52use rustc_ast::{BinOpKind, BorrowKind, Expr, ExprKind, MetaItem, Mutability};
63use rustc_expand::base::{Annotatable, ExtCtxt};
......@@ -8,6 +5,10 @@ use rustc_span::symbol::sym;
85use rustc_span::Span;
96use thin_vec::thin_vec;
107
8use crate::deriving::generic::ty::*;
9use crate::deriving::generic::*;
10use crate::deriving::{path_local, path_std};
11
1112pub(crate) fn expand_deriving_partial_eq(
1213 cx: &ExtCtxt<'_>,
1314 span: Span,
compiler/rustc_builtin_macros/src/deriving/cmp/partial_ord.rs+4-3
......@@ -1,12 +1,13 @@
1use crate::deriving::generic::ty::*;
2use crate::deriving::generic::*;
3use crate::deriving::{path_std, pathvec_std};
41use rustc_ast::{ExprKind, ItemKind, MetaItem, PatKind};
52use rustc_expand::base::{Annotatable, ExtCtxt};
63use rustc_span::symbol::{sym, Ident};
74use rustc_span::Span;
85use thin_vec::thin_vec;
96
7use crate::deriving::generic::ty::*;
8use crate::deriving::generic::*;
9use crate::deriving::{path_std, pathvec_std};
10
1011pub(crate) fn expand_deriving_partial_ord(
1112 cx: &ExtCtxt<'_>,
1213 span: Span,
compiler/rustc_builtin_macros/src/deriving/debug.rs+4-4
......@@ -1,13 +1,13 @@
1use crate::deriving::generic::ty::*;
2use crate::deriving::generic::*;
3use crate::deriving::path_std;
4
51use rustc_ast::{self as ast, EnumDef, MetaItem};
62use rustc_expand::base::{Annotatable, ExtCtxt};
73use rustc_span::symbol::{sym, Ident, Symbol};
84use rustc_span::Span;
95use thin_vec::{thin_vec, ThinVec};
106
7use crate::deriving::generic::ty::*;
8use crate::deriving::generic::*;
9use crate::deriving::path_std;
10
1111pub(crate) fn expand_deriving_debug(
1212 cx: &ExtCtxt<'_>,
1313 span: Span,
compiler/rustc_builtin_macros/src/deriving/decodable.rs+4-3
......@@ -1,8 +1,5 @@
11//! The compiler code necessary for `#[derive(RustcDecodable)]`. See encodable.rs for more.
22
3use crate::deriving::generic::ty::*;
4use crate::deriving::generic::*;
5use crate::deriving::pathvec_std;
63use rustc_ast::ptr::P;
74use rustc_ast::{self as ast, Expr, MetaItem, Mutability};
85use rustc_expand::base::{Annotatable, ExtCtxt};
......@@ -10,6 +7,10 @@ use rustc_span::symbol::{sym, Ident, Symbol};
107use rustc_span::Span;
118use thin_vec::{thin_vec, ThinVec};
129
10use crate::deriving::generic::ty::*;
11use crate::deriving::generic::*;
12use crate::deriving::pathvec_std;
13
1314pub(crate) fn expand_deriving_rustc_decodable(
1415 cx: &ExtCtxt<'_>,
1516 span: Span,
compiler/rustc_builtin_macros/src/deriving/default.rs+6-5
......@@ -1,17 +1,18 @@
1use crate::deriving::generic::ty::*;
2use crate::deriving::generic::*;
3use crate::errors;
41use core::ops::ControlFlow;
2
53use rustc_ast as ast;
64use rustc_ast::visit::visit_opt;
75use rustc_ast::{attr, EnumDef, VariantData};
86use rustc_expand::base::{Annotatable, DummyResult, ExtCtxt};
9use rustc_span::symbol::Ident;
10use rustc_span::symbol::{kw, sym};
7use rustc_span::symbol::{kw, sym, Ident};
118use rustc_span::{ErrorGuaranteed, Span};
129use smallvec::SmallVec;
1310use thin_vec::{thin_vec, ThinVec};
1411
12use crate::deriving::generic::ty::*;
13use crate::deriving::generic::*;
14use crate::errors;
15
1516pub(crate) fn expand_deriving_default(
1617 cx: &ExtCtxt<'_>,
1718 span: Span,
compiler/rustc_builtin_macros/src/deriving/encodable.rs+4-3
......@@ -85,15 +85,16 @@
8585//! }
8686//! ```
8787
88use crate::deriving::generic::ty::*;
89use crate::deriving::generic::*;
90use crate::deriving::pathvec_std;
9188use rustc_ast::{AttrVec, ExprKind, MetaItem, Mutability};
9289use rustc_expand::base::{Annotatable, ExtCtxt};
9390use rustc_span::symbol::{sym, Ident, Symbol};
9491use rustc_span::Span;
9592use thin_vec::{thin_vec, ThinVec};
9693
94use crate::deriving::generic::ty::*;
95use crate::deriving::generic::*;
96use crate::deriving::pathvec_std;
97
9798pub(crate) fn expand_deriving_rustc_encodable(
9899 cx: &ExtCtxt<'_>,
99100 span: Span,
compiler/rustc_builtin_macros/src/deriving/generic/mod.rs+7-7
......@@ -174,10 +174,10 @@
174174//! )
175175//! ```
176176
177pub(crate) use StaticFields::*;
178pub(crate) use SubstructureFields::*;
177use std::cell::RefCell;
178use std::ops::Not;
179use std::{iter, vec};
179180
180use crate::{deriving, errors};
181181use rustc_ast::ptr::P;
182182use rustc_ast::{
183183 self as ast, BindingMode, ByRef, EnumDef, Expr, GenericArg, GenericParamKind, Generics,
......@@ -188,12 +188,12 @@ use rustc_expand::base::{Annotatable, ExtCtxt};
188188use rustc_session::lint::builtin::BYTE_SLICE_IN_PACKED_STRUCT_WITH_DERIVE;
189189use rustc_span::symbol::{kw, sym, Ident, Symbol};
190190use rustc_span::{Span, DUMMY_SP};
191use std::cell::RefCell;
192use std::iter;
193use std::ops::Not;
194use std::vec;
195191use thin_vec::{thin_vec, ThinVec};
196192use ty::{Bounds, Path, Ref, Self_, Ty};
193pub(crate) use StaticFields::*;
194pub(crate) use SubstructureFields::*;
195
196use crate::{deriving, errors};
197197
198198pub(crate) mod ty;
199199
compiler/rustc_builtin_macros/src/deriving/generic/ty.rs+1-2
......@@ -1,8 +1,6 @@
11//! A mini version of ast::Ty, which is easier to use, and features an explicit `Self` type to use
22//! when specifying impls to be derived.
33
4pub(crate) use Ty::*;
5
64use rustc_ast::ptr::P;
75use rustc_ast::{self as ast, Expr, GenericArg, GenericParamKind, Generics, SelfKind};
86use rustc_expand::base::ExtCtxt;
......@@ -10,6 +8,7 @@ use rustc_span::source_map::respan;
108use rustc_span::symbol::{kw, Ident, Symbol};
119use rustc_span::{Span, DUMMY_SP};
1210use thin_vec::ThinVec;
11pub(crate) use Ty::*;
1312
1413/// A path, e.g., `::std::option::Option::<i32>` (global). Has support
1514/// for type parameters.
compiler/rustc_builtin_macros/src/deriving/hash.rs+4-3
......@@ -1,12 +1,13 @@
1use crate::deriving::generic::ty::*;
2use crate::deriving::generic::*;
3use crate::deriving::{path_std, pathvec_std};
41use rustc_ast::{MetaItem, Mutability};
52use rustc_expand::base::{Annotatable, ExtCtxt};
63use rustc_span::symbol::sym;
74use rustc_span::Span;
85use thin_vec::thin_vec;
96
7use crate::deriving::generic::ty::*;
8use crate::deriving::generic::*;
9use crate::deriving::{path_std, pathvec_std};
10
1011pub(crate) fn expand_deriving_hash(
1112 cx: &ExtCtxt<'_>,
1213 span: Span,
compiler/rustc_builtin_macros/src/env.rs+6-4
......@@ -3,18 +3,20 @@
33// interface.
44//
55
6use crate::errors;
7use crate::util::{expr_to_string, get_exprs_from_tts, get_single_str_from_tts};
6use std::env;
7use std::env::VarError;
8
89use rustc_ast::token::{self, LitKind};
910use rustc_ast::tokenstream::TokenStream;
1011use rustc_ast::{AstDeref, ExprKind, GenericArg, Mutability};
1112use rustc_expand::base::{DummyResult, ExpandResult, ExtCtxt, MacEager, MacroExpanderResult};
1213use rustc_span::symbol::{kw, sym, Ident, Symbol};
1314use rustc_span::Span;
14use std::env;
15use std::env::VarError;
1615use thin_vec::thin_vec;
1716
17use crate::errors;
18use crate::util::{expr_to_string, get_exprs_from_tts, get_single_str_from_tts};
19
1820fn lookup_env<'cx>(cx: &'cx ExtCtxt<'_>, var: Symbol) -> Result<Symbol, VarError> {
1921 let var = var.as_str();
2022 if let Some(value) = cx.sess.opts.logical_env.get(var) {
compiler/rustc_builtin_macros/src/errors.rs+5-3
......@@ -1,9 +1,11 @@
1use rustc_errors::codes::*;
12use 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,
45};
56use rustc_macros::{Diagnostic, Subdiagnostic};
6use rustc_span::{symbol::Ident, Span, Symbol};
7use rustc_span::symbol::Ident;
8use rustc_span::{Span, Symbol};
79
810#[derive(Diagnostic)]
911#[diag(builtin_macros_requires_cfg_pattern)]
compiler/rustc_builtin_macros/src/format.rs+5-5
......@@ -1,13 +1,10 @@
1use crate::errors;
2use crate::util::expr_to_spanned_string;
31use parse::Position::ArgumentNamed;
42use rustc_ast::ptr::P;
53use rustc_ast::tokenstream::TokenStream;
6use rustc_ast::{token, StmtKind};
74use rustc_ast::{
8 Expr, ExprKind, FormatAlignment, FormatArgPosition, FormatArgPositionKind, FormatArgs,
5 token, Expr, ExprKind, FormatAlignment, FormatArgPosition, FormatArgPositionKind, FormatArgs,
96 FormatArgsPiece, FormatArgument, FormatArgumentKind, FormatArguments, FormatCount,
10 FormatDebugHex, FormatOptions, FormatPlaceholder, FormatSign, FormatTrait, Recovered,
7 FormatDebugHex, FormatOptions, FormatPlaceholder, FormatSign, FormatTrait, Recovered, StmtKind,
118};
129use rustc_data_structures::fx::FxHashSet;
1310use rustc_errors::{Applicability, Diag, MultiSpan, PResult, SingleLabelManySpans};
......@@ -18,6 +15,9 @@ use rustc_parse_format as parse;
1815use rustc_span::symbol::{Ident, Symbol};
1916use rustc_span::{BytePos, ErrorGuaranteed, InnerSpan, Span};
2017
18use crate::errors;
19use crate::util::expr_to_spanned_string;
20
2121// The format_args!() macro is expanded in three steps:
2222// 1. First, `parse_args` will parse the `(literal, arg, arg, name=arg, name=arg)` syntax,
2323// but doesn't parse the template (the literal) itself.
compiler/rustc_builtin_macros/src/format_foreign.rs+4-2
......@@ -1,7 +1,8 @@
11pub(crate) mod printf {
2 use super::strcursor::StrCursor as Cur;
32 use rustc_span::InnerSpan;
43
4 use super::strcursor::StrCursor as Cur;
5
56 /// Represents a single `printf`-style substitution.
67 #[derive(Clone, PartialEq, Debug)]
78 pub enum Substitution<'a> {
......@@ -615,9 +616,10 @@ pub(crate) mod printf {
615616}
616617
617618pub mod shell {
618 use super::strcursor::StrCursor as Cur;
619619 use rustc_span::InnerSpan;
620620
621 use super::strcursor::StrCursor as Cur;
622
621623 #[derive(Clone, PartialEq, Debug)]
622624 pub enum Substitution<'a> {
623625 Ordinal(u8, (usize, usize)),
compiler/rustc_builtin_macros/src/global_allocator.rs+7-5
......@@ -1,17 +1,19 @@
1use crate::util::check_builtin_macro_attribute;
2
3use crate::errors;
41use rustc_ast::expand::allocator::{
52 global_fn_name, AllocatorMethod, AllocatorMethodInput, AllocatorTy, ALLOCATOR_METHODS,
63};
74use rustc_ast::ptr::P;
8use rustc_ast::{self as ast, AttrVec, Expr, FnHeader, FnSig, Generics, Param, StmtKind};
9use rustc_ast::{Fn, ItemKind, Mutability, Safety, Stmt, Ty, TyKind};
5use rustc_ast::{
6 self as ast, AttrVec, Expr, Fn, FnHeader, FnSig, Generics, ItemKind, Mutability, Param, Safety,
7 Stmt, StmtKind, Ty, TyKind,
8};
109use rustc_expand::base::{Annotatable, ExtCtxt};
1110use rustc_span::symbol::{kw, sym, Ident, Symbol};
1211use rustc_span::Span;
1312use thin_vec::{thin_vec, ThinVec};
1413
14use crate::errors;
15use crate::util::check_builtin_macro_attribute;
16
1517pub(crate) fn expand(
1618 ecx: &mut ExtCtxt<'_>,
1719 _span: Span,
compiler/rustc_builtin_macros/src/lib.rs+2-1
......@@ -21,11 +21,12 @@
2121
2222extern crate proc_macro;
2323
24use crate::deriving::*;
2524use rustc_expand::base::{MacroExpanderFn, ResolverExpand, SyntaxExtensionKind};
2625use rustc_expand::proc_macro::BangProcMacro;
2726use rustc_span::symbol::sym;
2827
28use crate::deriving::*;
29
2930mod alloc_error_handler;
3031mod assert;
3132mod cfg;
compiler/rustc_builtin_macros/src/pattern_type.rs+3-1
......@@ -1,4 +1,6 @@
1use rustc_ast::{ast, ptr::P, tokenstream::TokenStream, Pat, Ty};
1use rustc_ast::ptr::P;
2use rustc_ast::tokenstream::TokenStream;
3use rustc_ast::{ast, Pat, Ty};
24use rustc_errors::PResult;
35use rustc_expand::base::{self, DummyResult, ExpandResult, ExtCtxt, MacroExpanderResult};
46use rustc_span::{sym, Span};
compiler/rustc_builtin_macros/src/proc_macro_harness.rs+4-2
......@@ -1,4 +1,5 @@
1use crate::errors;
1use std::mem;
2
23use rustc_ast::ptr::P;
34use rustc_ast::visit::{self, Visitor};
45use rustc_ast::{self as ast, attr, NodeId};
......@@ -13,9 +14,10 @@ use rustc_span::source_map::SourceMap;
1314use rustc_span::symbol::{kw, sym, Ident, Symbol};
1415use rustc_span::{Span, DUMMY_SP};
1516use smallvec::smallvec;
16use std::mem;
1717use thin_vec::{thin_vec, ThinVec};
1818
19use crate::errors;
20
1921struct ProcMacroDerive {
2022 id: NodeId,
2123 trait_name: Symbol,
compiler/rustc_builtin_macros/src/source_util.rs+10-7
......@@ -1,7 +1,6 @@
1use crate::errors;
2use crate::util::{
3 check_zero_tts, get_single_str_from_tts, get_single_str_spanned_from_tts, parse_expr,
4};
1use std::path::{Path, PathBuf};
2use std::rc::Rc;
3
54use rustc_ast as ast;
65use rustc_ast::ptr::P;
76use rustc_ast::token;
......@@ -20,8 +19,11 @@ use rustc_span::source_map::SourceMap;
2019use rustc_span::symbol::Symbol;
2120use rustc_span::{Pos, Span};
2221use smallvec::SmallVec;
23use std::path::{Path, PathBuf};
24use std::rc::Rc;
22
23use crate::errors;
24use crate::util::{
25 check_zero_tts, get_single_str_from_tts, get_single_str_spanned_from_tts, parse_expr,
26};
2527
2628// These macros all relate to the file system; they either return
2729// the column/row/filename of the expression, or they include
......@@ -71,7 +73,8 @@ pub(crate) fn expand_file(
7173 let topmost = cx.expansion_cause().unwrap_or(sp);
7274 let loc = cx.source_map().lookup_char_pos(topmost.lo());
7375
74 use rustc_session::{config::RemapPathScopeComponents, RemapFileNameExt};
76 use rustc_session::config::RemapPathScopeComponents;
77 use rustc_session::RemapFileNameExt;
7578 ExpandResult::Ready(MacEager::expr(cx.expr_str(
7679 topmost,
7780 Symbol::intern(
compiler/rustc_builtin_macros/src/test.rs+6-4
......@@ -1,8 +1,9 @@
11//! The expansion from a test function to the appropriate test struct for libtest
22//! Ideally, this code would be in libtest but for efficiency and error messages it lives here.
33
4use crate::errors;
5use crate::util::{check_builtin_macro_attribute, warn_on_duplicate_attribute};
4use std::assert_matches::assert_matches;
5use std::iter;
6
67use rustc_ast::ptr::P;
78use rustc_ast::{self as ast, attr, GenericParamKind};
89use rustc_ast_pretty::pprust;
......@@ -10,11 +11,12 @@ use rustc_errors::{Applicability, Diag, Level};
1011use rustc_expand::base::*;
1112use rustc_span::symbol::{sym, Ident, Symbol};
1213use rustc_span::{ErrorGuaranteed, FileNameDisplayPreference, Span};
13use std::assert_matches::assert_matches;
14use std::iter;
1514use thin_vec::{thin_vec, ThinVec};
1615use tracing::debug;
1716
17use crate::errors;
18use crate::util::{check_builtin_macro_attribute, warn_on_duplicate_attribute};
19
1820/// #[test_case] is used by custom test authors to mark tests
1921/// When building for test, it needs to make the item public and gensym the name
2022/// 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 @@
11// Code that generates a test runner to run all the tests in a crate
22
3use std::{iter, mem};
4
35use rustc_ast as ast;
46use rustc_ast::entry::EntryPointType;
57use rustc_ast::mut_visit::*;
......@@ -21,8 +23,6 @@ use smallvec::{smallvec, SmallVec};
2123use thin_vec::{thin_vec, ThinVec};
2224use tracing::debug;
2325
24use std::{iter, mem};
25
2626use crate::errors;
2727
2828#[derive(Clone)]
compiler/rustc_builtin_macros/src/trace_macros.rs+2-1
......@@ -1,9 +1,10 @@
1use crate::errors;
21use rustc_ast::tokenstream::{TokenStream, TokenTree};
32use rustc_expand::base::{DummyResult, ExpandResult, ExtCtxt, MacroExpanderResult};
43use rustc_span::symbol::kw;
54use rustc_span::Span;
65
6use crate::errors;
7
78pub(crate) fn expand_trace_macros(
89 cx: &mut ExtCtxt<'_>,
910 sp: Span,
compiler/rustc_builtin_macros/src/util.rs+6-3
......@@ -1,15 +1,18 @@
1use crate::errors;
1use rustc_ast::ptr::P;
22use rustc_ast::tokenstream::TokenStream;
3use rustc_ast::{self as ast, attr, ptr::P, token, AttrStyle, Attribute, MetaItem};
3use rustc_ast::{self as ast, attr, token, AttrStyle, Attribute, MetaItem};
44use rustc_errors::{Applicability, Diag, ErrorGuaranteed};
55use rustc_expand::base::{Annotatable, ExpandResult, ExtCtxt};
66use rustc_expand::expand::AstFragment;
77use rustc_feature::AttributeTemplate;
8use rustc_lint_defs::{builtin::DUPLICATE_MACRO_ATTRIBUTES, BuiltinLintDiag};
8use rustc_lint_defs::builtin::DUPLICATE_MACRO_ATTRIBUTES;
9use rustc_lint_defs::BuiltinLintDiag;
910use rustc_parse::{parser, validate_attr};
1011use rustc_session::errors::report_lit_error;
1112use rustc_span::{BytePos, Span, Symbol};
1213
14use crate::errors;
15
1316pub(crate) fn check_builtin_macro_attribute(ecx: &ExtCtxt<'_>, meta_item: &MetaItem, name: Symbol) {
1417 // All the built-in macro attributes are "words" at the moment.
1518 let template = AttributeTemplate { word: true, ..Default::default() };
compiler/rustc_codegen_cranelift/build_system/abi_cafe.rs+1-2
......@@ -1,8 +1,7 @@
1use crate::build_sysroot;
21use crate::path::Dirs;
32use crate::prepare::GitRepo;
43use crate::utils::{spawn_and_wait, CargoProject, Compiler};
5use crate::{CodegenBackend, SysrootKind};
4use crate::{build_sysroot, CodegenBackend, SysrootKind};
65
76static ABI_CAFE_REPO: GitRepo = GitRepo::github(
87 "Gankra",
compiler/rustc_codegen_cranelift/build_system/build_sysroot.rs+1-2
......@@ -1,7 +1,6 @@
1use std::env;
2use std::fs;
31use std::path::{Path, PathBuf};
42use std::process::Command;
3use std::{env, fs};
54
65use crate::path::{Dirs, RelPath};
76use crate::rustc_info::get_file_name;
compiler/rustc_codegen_cranelift/build_system/config.rs+1-2
......@@ -1,5 +1,4 @@
1use std::fs;
2use std::process;
1use std::{fs, process};
32
43fn load_config_file() -> Vec<(String, Option<String>)> {
54 fs::read_to_string("config.txt")
compiler/rustc_codegen_cranelift/build_system/main.rs+1-2
......@@ -2,9 +2,8 @@
22#![warn(unused_lifetimes)]
33#![warn(unreachable_pub)]
44
5use std::env;
65use std::path::PathBuf;
7use std::process;
6use std::{env, process};
87
98use self::utils::Compiler;
109
compiler/rustc_codegen_cranelift/build_system/tests.rs+1-3
......@@ -3,14 +3,12 @@ use std::fs;
33use std::path::PathBuf;
44use std::process::Command;
55
6use crate::build_sysroot;
7use crate::config;
86use crate::path::{Dirs, RelPath};
97use crate::prepare::{apply_patches, GitRepo};
108use crate::rustc_info::get_default_sysroot;
119use crate::shared_utils::rustflags_from_env;
1210use crate::utils::{spawn_and_wait, CargoProject, Compiler, LogGroup};
13use crate::{CodegenBackend, SysrootKind};
11use crate::{build_sysroot, config, CodegenBackend, SysrootKind};
1412
1513static BUILD_EXAMPLE_OUT_DIR: RelPath = RelPath::BUILD.join("example");
1614
compiler/rustc_codegen_cranelift/build_system/utils.rs+1-3
......@@ -1,9 +1,7 @@
1use std::env;
2use std::fs;
3use std::io;
41use std::path::{Path, PathBuf};
52use std::process::{self, Command};
63use std::sync::atomic::{AtomicBool, Ordering};
4use std::{env, fs, io};
75
86use crate::path::{Dirs, RelPath};
97use crate::shared_utils::rustflags_to_cmd_env;
compiler/rustc_codegen_cranelift/example/alloc_system.rs+3-2
......@@ -8,8 +8,7 @@ pub struct System;
88#[cfg(any(windows, unix, target_os = "redox"))]
99mod realloc_fallback {
1010 use core::alloc::{GlobalAlloc, Layout};
11 use core::cmp;
12 use core::ptr;
11 use core::{cmp, ptr};
1312 impl super::System {
1413 pub(crate) unsafe fn realloc_fallback(
1514 &self,
......@@ -34,6 +33,7 @@ mod platform {
3433 use core::alloc::{GlobalAlloc, Layout};
3534 use core::ffi::c_void;
3635 use core::ptr;
36
3737 use System;
3838 extern "C" {
3939 fn posix_memalign(memptr: *mut *mut c_void, align: usize, size: usize) -> i32;
......@@ -71,6 +71,7 @@ mod platform {
7171#[allow(nonstandard_style)]
7272mod platform {
7373 use core::alloc::{GlobalAlloc, Layout};
74
7475 use System;
7576 type LPVOID = *mut u8;
7677 type HANDLE = LPVOID;
compiler/rustc_codegen_cranelift/example/arbitrary_self_types_pointers_and_wrappers.rs+2-4
......@@ -2,10 +2,8 @@
22
33#![feature(arbitrary_self_types, unsize, coerce_unsized, dispatch_from_dyn)]
44
5use std::{
6 marker::Unsize,
7 ops::{CoerceUnsized, Deref, DispatchFromDyn},
8};
5use std::marker::Unsize;
6use std::ops::{CoerceUnsized, Deref, DispatchFromDyn};
97
108struct Ptr<T: ?Sized>(Box<T>);
119
compiler/rustc_codegen_cranelift/rustfmt.toml+2
......@@ -6,3 +6,5 @@ ignore = [
66version = "Two"
77use_small_heuristics = "Max"
88merge_derives = false
9group_imports = "StdExternalCrate"
10imports_granularity = "Module"
compiler/rustc_codegen_cranelift/src/debuginfo/unwind.rs+2-1
......@@ -1,7 +1,8 @@
11//! Unwind info generation (`.eh_frame`)
22
33use cranelift_codegen::ir::Endianness;
4use cranelift_codegen::isa::{unwind::UnwindInfo, TargetIsa};
4use cranelift_codegen::isa::unwind::UnwindInfo;
5use cranelift_codegen::isa::TargetIsa;
56use cranelift_object::ObjectProduct;
67use gimli::write::{CieId, EhFrame, FrameTable, Section};
78use gimli::RunTimeEndian;
compiler/rustc_codegen_cranelift/src/driver/aot.rs+5-3
......@@ -11,8 +11,9 @@ use rustc_codegen_ssa::assert_module_sources::CguReuse;
1111use rustc_codegen_ssa::back::link::ensure_removed;
1212use rustc_codegen_ssa::back::metadata::create_compressed_metadata_file;
1313use rustc_codegen_ssa::base::determine_cgu_reuse;
14use rustc_codegen_ssa::errors as ssa_errors;
15use rustc_codegen_ssa::{CodegenResults, CompiledModule, CrateInfo, ModuleKind};
14use rustc_codegen_ssa::{
15 errors as ssa_errors, CodegenResults, CompiledModule, CrateInfo, ModuleKind,
16};
1617use rustc_data_structures::profiling::SelfProfilerRef;
1718use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
1819use rustc_data_structures::sync::{par_map, IntoDynSyncSend};
......@@ -26,8 +27,9 @@ use rustc_session::Session;
2627use crate::concurrency_limiter::{ConcurrencyLimiter, ConcurrencyLimiterToken};
2728use crate::debuginfo::TypeDebugContext;
2829use crate::global_asm::GlobalAsmConfig;
30use crate::prelude::*;
2931use crate::unwind_module::UnwindModule;
30use crate::{prelude::*, BackendConfig};
32use crate::BackendConfig;
3133
3234struct ModuleCodegenResult {
3335 module_regular: CompiledModule,
compiler/rustc_codegen_cranelift/src/driver/jit.rs+2-2
......@@ -14,9 +14,9 @@ use rustc_session::Session;
1414use rustc_span::Symbol;
1515
1616use crate::debuginfo::TypeDebugContext;
17use crate::prelude::*;
1718use crate::unwind_module::UnwindModule;
18use crate::{prelude::*, BackendConfig};
19use crate::{CodegenCx, CodegenMode};
19use crate::{BackendConfig, CodegenCx, CodegenMode};
2020
2121struct JitState {
2222 jit_module: UnwindModule<JITModule>,
compiler/rustc_codegen_cranelift/src/lib.rs+2-3
......@@ -85,10 +85,9 @@ mod vtable;
8585mod prelude {
8686 pub(crate) use cranelift_codegen::ir::condcodes::{FloatCC, IntCC};
8787 pub(crate) use cranelift_codegen::ir::function::Function;
88 pub(crate) use cranelift_codegen::ir::types;
8988 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,
9291 };
9392 pub(crate) use cranelift_codegen::Context;
9493 pub(crate) use cranelift_module::{self, DataDescription, FuncId, Linkage, Module};
compiler/rustc_codegen_cranelift/src/main_shim.rs+1-2
......@@ -1,7 +1,6 @@
11use cranelift_frontend::{FunctionBuilder, FunctionBuilderContext};
22use rustc_hir::LangItem;
3use rustc_middle::ty::AssocKind;
4use rustc_middle::ty::GenericArg;
3use rustc_middle::ty::{AssocKind, GenericArg};
54use rustc_session::config::{sigpipe, EntryFnType};
65use rustc_span::symbol::Ident;
76use rustc_span::DUMMY_SP;
compiler/rustc_codegen_cranelift/src/optimize/peephole.rs+2-1
......@@ -1,6 +1,7 @@
11//! Peephole optimizations that can be performed while creating clif ir.
22
3use cranelift_codegen::ir::{condcodes::IntCC, InstructionData, Opcode, Value, ValueDef};
3use cranelift_codegen::ir::condcodes::IntCC;
4use cranelift_codegen::ir::{InstructionData, Opcode, Value, ValueDef};
45use cranelift_frontend::FunctionBuilder;
56
67/// 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 @@
1use crate::config::{Channel, ConfigInfo};
2use crate::utils::{
3 copy_file, create_dir, get_sysroot_dir, run_command, run_command_with_output_and_env, walk_dir,
4};
51use std::collections::HashMap;
62use std::ffi::OsStr;
73use std::fs;
84use std::path::Path;
95
6use crate::config::{Channel, ConfigInfo};
7use crate::utils::{
8 copy_file, create_dir, get_sysroot_dir, run_command, run_command_with_output_and_env, walk_dir,
9};
10
1011#[derive(Default)]
1112struct BuildArg {
1213 flags: Vec<String>,
compiler/rustc_codegen_gcc/build_system/src/clean.rs+2-2
......@@ -1,8 +1,8 @@
1use crate::utils::{get_sysroot_dir, remove_file, run_command};
2
31use std::fs::remove_dir_all;
42use std::path::Path;
53
4use crate::utils::{get_sysroot_dir, remove_file, run_command};
5
66#[derive(Default)]
77enum CleanArg {
88 /// `clean all`
compiler/rustc_codegen_gcc/build_system/src/clone_gcc.rs+2-2
......@@ -1,8 +1,8 @@
1use std::path::{Path, PathBuf};
2
13use crate::config::ConfigInfo;
24use crate::utils::{git_clone, run_command_with_output};
35
4use std::path::{Path, PathBuf};
5
66fn show_usage() {
77 println!(
88 r#"
compiler/rustc_codegen_gcc/build_system/src/config.rs+8-7
......@@ -1,14 +1,15 @@
1use crate::utils::{
2 create_dir, create_symlink, get_os_name, get_sysroot_dir, run_command_with_output,
3 rustc_version_info, split_args,
4};
51use std::collections::HashMap;
6use std::env as std_env;
72use std::ffi::OsStr;
8use std::fs;
93use std::path::{Path, PathBuf};
4use std::{env as std_env, fs};
5
6use boml::types::TomlValue;
7use boml::Toml;
108
11use boml::{types::TomlValue, Toml};
9use crate::utils::{
10 create_dir, create_symlink, get_os_name, get_sysroot_dir, run_command_with_output,
11 rustc_version_info, split_args,
12};
1213
1314#[derive(Default, PartialEq, Eq, Clone, Copy, Debug)]
1415pub enum Channel {
compiler/rustc_codegen_gcc/build_system/src/fmt.rs+2-1
......@@ -1,7 +1,8 @@
1use crate::utils::run_command_with_output;
21use std::ffi::OsStr;
32use std::path::Path;
43
4use crate::utils::run_command_with_output;
5
56fn show_usage() {
67 println!(
78 r#"
compiler/rustc_codegen_gcc/build_system/src/main.rs+1-2
......@@ -1,5 +1,4 @@
1use std::env;
2use std::process;
1use std::{env, process};
32
43mod build;
54mod clean;
compiler/rustc_codegen_gcc/build_system/src/prepare.rs+3-3
......@@ -1,12 +1,12 @@
1use std::fs;
2use std::path::{Path, PathBuf};
3
14use crate::rustc_info::get_rustc_path;
25use crate::utils::{
36 cargo_install, create_dir, get_sysroot_dir, git_clone_root_dir, remove_file, run_command,
47 run_command_with_output, walk_dir,
58};
69
7use std::fs;
8use std::path::{Path, PathBuf};
9
1010fn prepare_libcore(
1111 sysroot_path: &Path,
1212 libgccjit12_patches: bool,
compiler/rustc_codegen_gcc/build_system/src/rust_tools.rs+4-4
......@@ -1,13 +1,13 @@
1use std::collections::HashMap;
2use std::ffi::OsStr;
3use std::path::PathBuf;
4
15use crate::config::ConfigInfo;
26use crate::utils::{
37 get_toolchain, run_command_with_output_and_env_no_err, rustc_toolchain_version_info,
48 rustc_version_info,
59};
610
7use std::collections::HashMap;
8use std::ffi::OsStr;
9use std::path::PathBuf;
10
1111fn args(command: &str) -> Result<Option<Vec<String>>, String> {
1212 // We skip the binary and the "cargo"/"rustc" option.
1313 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 @@
1use std::collections::HashMap;
2use std::ffi::OsStr;
3use std::fs::{remove_dir_all, File};
4use std::io::{BufRead, BufReader};
5use std::path::{Path, PathBuf};
6use std::str::FromStr;
7
18use crate::build;
29use crate::config::{Channel, ConfigInfo};
310use crate::utils::{
......@@ -6,13 +13,6 @@ use crate::utils::{
613 split_args, walk_dir,
714};
815
9use std::collections::HashMap;
10use std::ffi::OsStr;
11use std::fs::{remove_dir_all, File};
12use std::io::{BufRead, BufReader};
13use std::path::{Path, PathBuf};
14use std::str::FromStr;
15
1616type Env = HashMap<String, String>;
1717type Runner = fn(&Env, &TestArg) -> Result<(), String>;
1818type 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};
33use rustc_codegen_ssa::back::archive::{
44 ArArchiveBuilder, ArchiveBuilder, ArchiveBuilderBuilder, DEFAULT_OBJECT_READER,
55};
6use rustc_session::Session;
7
86use rustc_session::cstore::DllImport;
7use rustc_session::Session;
98
109pub(crate) struct ArArchiveBuilderBuilder;
1110
compiler/rustc_codegen_gcc/src/asm.rs+4-4
......@@ -1,3 +1,5 @@
1use std::borrow::Cow;
2
13use gccjit::{LValue, RValue, ToRValue, Type};
24use rustc_ast::ast::{InlineAsmOptions, InlineAsmTemplatePiece};
35use rustc_codegen_ssa::mir::operand::OperandValue;
......@@ -6,13 +8,11 @@ use rustc_codegen_ssa::traits::{
68 AsmBuilderMethods, AsmMethods, BaseTypeMethods, BuilderMethods, GlobalAsmOperandRef,
79 InlineAsmOperandRef,
810};
9
10use rustc_middle::{bug, ty::Instance};
11use rustc_middle::bug;
12use rustc_middle::ty::Instance;
1113use rustc_span::Span;
1214use rustc_target::asm::*;
1315
14use std::borrow::Cow;
15
1616use crate::builder::Builder;
1717use crate::callee::get_fn;
1818use crate::context::CodegenCx;
compiler/rustc_codegen_gcc/src/attributes.rs+2-1
......@@ -9,8 +9,9 @@ use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
99use rustc_middle::ty;
1010use rustc_span::symbol::sym;
1111
12use crate::context::CodegenCx;
13use crate::errors::TiedTargetFeatures;
1214use crate::gcc_util::{check_tied_features, to_gcc_features};
13use crate::{context::CodegenCx, errors::TiedTargetFeatures};
1415
1516/// Get GCC attribute for the provided inline heuristic.
1617#[cfg(feature = "master")]
compiler/rustc_codegen_gcc/src/base.rs+1-2
......@@ -19,8 +19,7 @@ use rustc_target::spec::PanicStrategy;
1919
2020use crate::builder::Builder;
2121use crate::context::CodegenCx;
22use crate::{gcc_util, new_context, LockedTargetInfo};
23use crate::{GccContext, SyncContext};
22use crate::{gcc_util, new_context, GccContext, LockedTargetInfo, SyncContext};
2423
2524#[cfg(feature = "master")]
2625pub 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::{
2828use rustc_middle::ty::{Instance, ParamEnv, Ty, TyCtxt};
2929use rustc_span::def_id::DefId;
3030use rustc_span::Span;
31use rustc_target::abi::{
32 self, call::FnAbi, Align, HasDataLayout, Size, TargetDataLayout, WrappingRange,
33};
31use rustc_target::abi::call::FnAbi;
32use rustc_target::abi::{self, Align, HasDataLayout, Size, TargetDataLayout, WrappingRange};
3433use rustc_target::spec::{HasTargetSpec, HasWasmCAbiOpt, Target, WasmCAbi};
3534
3635use crate::common::{type_is_pointer, SignType, TypeReflection};
compiler/rustc_codegen_gcc/src/common.rs+1-2
......@@ -1,5 +1,4 @@
1use gccjit::LValue;
2use gccjit::{RValue, ToRValue, Type};
1use gccjit::{LValue, RValue, ToRValue, Type};
32use rustc_codegen_ssa::traits::{BaseTypeMethods, ConstMethods, MiscMethods, StaticMethods};
43use rustc_middle::mir::interpret::{ConstAllocation, GlobalAlloc, Scalar};
54use rustc_middle::mir::Mutability;
compiler/rustc_codegen_gcc/src/consts.rs+1-2
......@@ -3,14 +3,13 @@ use gccjit::{FnAttribute, VarAttribute, Visibility};
33use gccjit::{Function, GlobalKind, LValue, RValue, ToRValue, Type};
44use rustc_codegen_ssa::traits::{BaseTypeMethods, ConstMethods, StaticMethods};
55use rustc_hir::def::DefKind;
6use rustc_middle::bug;
76use rustc_middle::middle::codegen_fn_attrs::{CodegenFnAttrFlags, CodegenFnAttrs};
87use rustc_middle::mir::interpret::{
98 self, read_target_uint, ConstAllocation, ErrorHandled, Scalar as InterpScalar,
109};
11use rustc_middle::span_bug;
1210use rustc_middle::ty::layout::LayoutOf;
1311use rustc_middle::ty::{self, Instance};
12use rustc_middle::{bug, span_bug};
1413use rustc_span::def_id::DefId;
1514use rustc_target::abi::{self, Align, HasDataLayout, Primitive, Size, WrappingRange};
1615
compiler/rustc_codegen_gcc/src/context.rs+5-6
......@@ -6,8 +6,7 @@ use gccjit::{
66use rustc_codegen_ssa::base::wants_msvc_seh;
77use rustc_codegen_ssa::errors as ssa_errors;
88use rustc_codegen_ssa::traits::{BackendTypes, BaseTypeMethods, MiscMethods};
9use rustc_data_structures::base_n::ToBaseN;
10use rustc_data_structures::base_n::ALPHANUMERIC_ONLY;
9use rustc_data_structures::base_n::{ToBaseN, ALPHANUMERIC_ONLY};
1110use rustc_data_structures::fx::{FxHashMap, FxHashSet};
1211use rustc_middle::mir::mono::CodegenUnit;
1312use rustc_middle::span_bug;
......@@ -17,10 +16,10 @@ use rustc_middle::ty::layout::{
1716};
1817use rustc_middle::ty::{self, Instance, ParamEnv, PolyExistentialTraitRef, Ty, TyCtxt};
1918use rustc_session::Session;
20use rustc_span::{source_map::respan, Span, DUMMY_SP};
21use rustc_target::abi::{
22 call::FnAbi, HasDataLayout, PointeeInfo, Size, TargetDataLayout, VariantIdx,
23};
19use rustc_span::source_map::respan;
20use rustc_span::{Span, DUMMY_SP};
21use rustc_target::abi::call::FnAbi;
22use rustc_target::abi::{HasDataLayout, PointeeInfo, Size, TargetDataLayout, VariantIdx};
2423use rustc_target::spec::{HasTargetSpec, HasWasmCAbiOpt, Target, TlsModel, WasmCAbi};
2524
2625use crate::callee::get_fn;
compiler/rustc_codegen_gcc/src/debuginfo.rs+2-1
......@@ -1,3 +1,5 @@
1use std::ops::Range;
2
13use gccjit::{Location, RValue};
24use rustc_codegen_ssa::mir::debuginfo::{DebugScope, FunctionDebugContext, VariableKind};
35use rustc_codegen_ssa::traits::{DebugInfoBuilderMethods, DebugInfoMethods};
......@@ -10,7 +12,6 @@ use rustc_session::config::DebugInfo;
1012use rustc_span::{BytePos, Pos, SourceFile, SourceFileAndLine, Span, Symbol};
1113use rustc_target::abi::call::FnAbi;
1214use rustc_target::abi::Size;
13use std::ops::Range;
1415
1516use crate::builder::Builder;
1617use crate::context::CodegenCx;
compiler/rustc_codegen_gcc/src/gcc_util.rs+1-2
......@@ -1,11 +1,10 @@
11#[cfg(feature = "master")]
22use gccjit::Context;
3use smallvec::{smallvec, SmallVec};
4
53use rustc_data_structures::fx::FxHashMap;
64use rustc_middle::bug;
75use rustc_session::Session;
86use rustc_target::target_features::RUSTC_SPECIFIC_FEATURES;
7use smallvec::{smallvec, SmallVec};
98
109use crate::errors::{
1110 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
66use rustc_codegen_ssa::common::{IntPredicate, TypeKind};
77use rustc_codegen_ssa::traits::{BackendTypes, BaseTypeMethods, BuilderMethods, OverflowOp};
88use rustc_middle::ty::{ParamEnv, Ty};
9use rustc_target::abi::{
10 call::{ArgAbi, ArgAttributes, Conv, FnAbi, PassMode},
11 Endian,
12};
9use rustc_target::abi::call::{ArgAbi, ArgAttributes, Conv, FnAbi, PassMode};
10use rustc_target::abi::Endian;
1311use rustc_target::spec;
1412
15use crate::builder::ToGccComp;
16use crate::{
17 builder::Builder,
18 common::{SignType, TypeReflection},
19 context::CodegenCx,
20};
13use crate::builder::{Builder, ToGccComp};
14use crate::common::{SignType, TypeReflection};
15use crate::context::CodegenCx;
2116
2217impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
2318 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> {
266261 lhs: <Self as BackendTypes>::Value,
267262 rhs: <Self as BackendTypes>::Value,
268263 ) -> (<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};
270267
271268 let new_kind = match *typ.kind() {
272269 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;
33use gccjit::{Function, FunctionPtrType, RValue, ToRValue, UnaryOp};
44use rustc_codegen_ssa::traits::BuilderMethods;
55
6use crate::{builder::Builder, context::CodegenCx};
6use crate::builder::Builder;
7use crate::context::CodegenCx;
78
89pub fn adjust_intrinsic_arguments<'a, 'b, 'gcc, 'tcx>(
910 builder: &Builder<'a, 'gcc, 'tcx>,
compiler/rustc_codegen_gcc/src/intrinsic/simd.rs+1-3
......@@ -1,10 +1,8 @@
11use std::iter::FromIterator;
22
3use gccjit::ToRValue;
4use gccjit::{BinaryOp, RValue, Type};
3use gccjit::{BinaryOp, RValue, ToRValue, Type};
54#[cfg(feature = "master")]
65use gccjit::{ComparisonOp, UnaryOp};
7
86use rustc_codegen_ssa::base::compare_simd_types;
97use rustc_codegen_ssa::common::{IntPredicate, TypeKind};
108#[cfg(feature = "master")]
compiler/rustc_codegen_gcc/src/lib.rs+3-6
......@@ -79,14 +79,11 @@ use std::ops::Deref;
7979use std::sync::atomic::AtomicBool;
8080#[cfg(not(feature = "master"))]
8181use std::sync::atomic::Ordering;
82use std::sync::Arc;
83use std::sync::Mutex;
82use std::sync::{Arc, Mutex};
8483
85use back::lto::ThinBuffer;
86use back::lto::ThinData;
84use back::lto::{ThinBuffer, ThinData};
8785use errors::LTONotSupported;
88use gccjit::CType;
89use gccjit::{Context, OptimizationLevel};
86use gccjit::{CType, Context, OptimizationLevel};
9087#[cfg(feature = "master")]
9188use gccjit::{TargetInfo, Version};
9289use 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};
99use rustc_middle::ty::layout::{FnAbiOf, LayoutOf};
1010use rustc_middle::ty::{self, Instance, TypeVisitableExt};
1111
12use crate::attributes;
13use crate::base;
1412use crate::context::CodegenCx;
1513use crate::type_of::LayoutGccExt;
14use crate::{attributes, base};
1615
1716impl<'gcc, 'tcx> PreDefineMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
1817 #[cfg_attr(not(feature = "master"), allow(unused_variables))]
compiler/rustc_codegen_llvm/src/abi.rs+9-11
......@@ -1,12 +1,6 @@
1use crate::attributes;
2use crate::builder::Builder;
3use crate::context::CodegenCx;
4use crate::llvm::{self, Attribute, AttributePlace};
5use crate::llvm_util;
6use crate::type_::Type;
7use crate::type_of::LayoutLlvmExt;
8use crate::value::Value;
1use std::cmp;
92
3use libc::c_uint;
104use rustc_codegen_ssa::mir::operand::{OperandRef, OperandValue};
115use rustc_codegen_ssa::mir::place::{PlaceRef, PlaceValue};
126use rustc_codegen_ssa::traits::*;
......@@ -20,11 +14,15 @@ pub use rustc_target::abi::call::*;
2014use rustc_target::abi::{self, HasDataLayout, Int, Size};
2115pub use rustc_target::spec::abi::Abi;
2216use rustc_target::spec::SanitizerSet;
23
24use libc::c_uint;
2517use smallvec::SmallVec;
2618
27use std::cmp;
19use crate::builder::Builder;
20use crate::context::CodegenCx;
21use crate::llvm::{self, Attribute, AttributePlace};
22use crate::type_::Type;
23use crate::type_of::LayoutLlvmExt;
24use crate::value::Value;
25use crate::{attributes, llvm_util};
2826
2927pub trait ArgAttributesExt {
3028 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 @@
1use crate::attributes;
21use libc::c_uint;
32use rustc_ast::expand::allocator::{
43 alloc_error_handler_name, default_fn_name, global_fn_name, AllocatorKind, AllocatorTy,
......@@ -8,9 +7,8 @@ use rustc_middle::bug;
87use rustc_middle::ty::TyCtxt;
98use rustc_session::config::{DebugInfo, OomStrategy};
109
11use crate::debuginfo;
1210use crate::llvm::{self, Context, False, Module, True, Type};
13use crate::ModuleLlvm;
11use crate::{attributes, debuginfo, ModuleLlvm};
1412
1513pub(crate) unsafe fn codegen(
1614 tcx: TyCtxt<'_>,
compiler/rustc_codegen_llvm/src/asm.rs+11-12
......@@ -1,25 +1,24 @@
1use crate::attributes;
2use crate::builder::Builder;
3use crate::common::Funclet;
4use crate::context::CodegenCx;
5use crate::llvm;
6use crate::type_::Type;
7use crate::type_of::LayoutLlvmExt;
8use crate::value::Value;
9
1use libc::{c_char, c_uint};
102use rustc_ast::{InlineAsmOptions, InlineAsmTemplatePiece};
113use rustc_codegen_ssa::mir::operand::OperandValue;
124use rustc_codegen_ssa::traits::*;
135use rustc_data_structures::fx::FxHashMap;
146use rustc_middle::ty::layout::TyAndLayout;
15use rustc_middle::{bug, span_bug, ty::Instance};
7use rustc_middle::ty::Instance;
8use rustc_middle::{bug, span_bug};
169use rustc_span::{sym, Pos, Span, Symbol};
1710use rustc_target::abi::*;
1811use rustc_target::asm::*;
12use smallvec::SmallVec;
1913use tracing::debug;
2014
21use libc::{c_char, c_uint};
22use smallvec::SmallVec;
15use crate::builder::Builder;
16use crate::common::Funclet;
17use crate::context::CodegenCx;
18use crate::type_::Type;
19use crate::type_of::LayoutLlvmExt;
20use crate::value::Value;
21use crate::{attributes, llvm};
2322
2423impl<'ll, 'tcx> AsmBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> {
2524 fn codegen_inline_asm(
compiler/rustc_codegen_llvm/src/attributes.rs+3-5
......@@ -1,5 +1,6 @@
11//! Set and unset common attributes on LLVM values.
22
3pub use rustc_attr::{InlineAttr, InstructionSetAttr, OptimizeAttr};
34use rustc_codegen_ssa::traits::*;
45use rustc_hir::def_id::DefId;
56use rustc_middle::middle::codegen_fn_attrs::{CodegenFnAttrFlags, PatchableFunctionEntry};
......@@ -9,15 +10,12 @@ use rustc_span::symbol::sym;
910use rustc_target::spec::{FramePointer, SanitizerSet, StackProbeType, StackProtector};
1011use smallvec::SmallVec;
1112
12use crate::attributes;
13use crate::context::CodegenCx;
1314use crate::errors::{MissingFeatures, SanitizerMemtagRequiresMte, TargetFeatureDisableOrEnable};
1415use crate::llvm::AttributePlace::Function;
1516use crate::llvm::{self, AllocKindFlags, Attribute, AttributeKind, AttributePlace, MemoryEffects};
16use crate::llvm_util;
17pub use rustc_attr::{InlineAttr, InstructionSetAttr, OptimizeAttr};
18
19use crate::context::CodegenCx;
2017use crate::value::Value;
18use crate::{attributes, llvm_util};
2119
2220pub fn apply_to_llfn(llfn: &Value, idx: AttributePlace, attrs: &[&Attribute]) {
2321 if !attrs.is_empty() {
compiler/rustc_codegen_llvm/src/back/archive.rs+9-13
......@@ -1,27 +1,23 @@
11//! A helper class for dealing with static archives
22
3use std::env;
43use std::ffi::{c_char, c_void, CStr, CString, OsString};
5use std::io;
6use std::mem;
74use std::path::{Path, PathBuf};
8use std::ptr;
9use std::str;
5use std::{env, io, mem, ptr, str};
106
11use crate::common;
12use crate::errors::{
13 DlltoolFailImportLibrary, ErrorCallingDllTool, ErrorCreatingImportLibrary, ErrorWritingDEFFile,
14};
15use crate::llvm::archive_ro::{ArchiveRO, Child};
16use crate::llvm::{self, ArchiveKind, LLVMMachineType, LLVMRustCOFFShortExport};
177use rustc_codegen_ssa::back::archive::{
188 try_extract_macho_fat_archive, ArArchiveBuilder, ArchiveBuildFailure, ArchiveBuilder,
199 ArchiveBuilderBuilder, ObjectReader, UnknownArchiveKind, DEFAULT_OBJECT_READER,
2010};
21use tracing::trace;
22
2311use rustc_session::cstore::DllImport;
2412use rustc_session::Session;
13use tracing::trace;
14
15use crate::common;
16use crate::errors::{
17 DlltoolFailImportLibrary, ErrorCallingDllTool, ErrorCreatingImportLibrary, ErrorWritingDEFFile,
18};
19use crate::llvm::archive_ro::{ArchiveRO, Child};
20use crate::llvm::{self, ArchiveKind, LLVMMachineType, LLVMRustCOFFShortExport};
2521
2622/// Helper for adding many files to an archive.
2723#[must_use = "must call build() to finish building the archive"]
compiler/rustc_codegen_llvm/src/back/lto.rs+16-17
......@@ -1,11 +1,11 @@
1use crate::back::write::{
2 self, bitcode_section_name, save_temp_bitcode, CodegenDiagnosticsStage, DiagnosticHandlers,
3};
4use crate::errors::{
5 DynamicLinkingWithLTO, LlvmError, LtoBitcodeFromRlib, LtoDisallowed, LtoDylib, LtoProcMacro,
6};
7use crate::llvm::{self, build_string};
8use crate::{LlvmCodegenBackend, ModuleLlvm};
1use std::collections::BTreeMap;
2use std::ffi::{CStr, CString};
3use std::fs::File;
4use std::mem::ManuallyDrop;
5use std::path::Path;
6use std::sync::Arc;
7use std::{io, iter, slice};
8
99use object::read::archive::ArchiveFile;
1010use rustc_codegen_ssa::back::lto::{LtoModuleCodegen, SerializedModule, ThinModule, ThinShared};
1111use rustc_codegen_ssa::back::symbol_export;
......@@ -22,15 +22,14 @@ use rustc_middle::middle::exported_symbols::{SymbolExportInfo, SymbolExportLevel
2222use rustc_session::config::{self, CrateType, Lto};
2323use tracing::{debug, info};
2424
25use std::collections::BTreeMap;
26use std::ffi::{CStr, CString};
27use std::fs::File;
28use std::io;
29use std::iter;
30use std::mem::ManuallyDrop;
31use std::path::Path;
32use std::slice;
33use std::sync::Arc;
25use crate::back::write::{
26 self, bitcode_section_name, save_temp_bitcode, CodegenDiagnosticsStage, DiagnosticHandlers,
27};
28use crate::errors::{
29 DynamicLinkingWithLTO, LlvmError, LtoBitcodeFromRlib, LtoDisallowed, LtoDylib, LtoProcMacro,
30};
31use crate::llvm::{self, build_string};
32use crate::{LlvmCodegenBackend, ModuleLlvm};
3433
3534/// We keep track of the computed LTO cache keys from the previous
3635/// session to determine which CGUs we can reuse.
compiler/rustc_codegen_llvm/src/back/owned_target_machine.rs+6-7
......@@ -1,13 +1,12 @@
1use std::{
2 ffi::{c_char, CStr},
3 marker::PhantomData,
4 ops::Deref,
5 ptr::NonNull,
6};
1use std::ffi::{c_char, CStr};
2use std::marker::PhantomData;
3use std::ops::Deref;
4use std::ptr::NonNull;
75
86use rustc_data_structures::small_c_str::SmallCStr;
97
10use crate::{errors::LlvmError, llvm};
8use crate::errors::LlvmError;
9use crate::llvm;
1110
1211/// Responsible for safely creating and disposing llvm::TargetMachine via ffi functions.
1312/// 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 @@
1use measureme::{event_id::SEPARATOR_BYTE, EventId, StringComponent, StringId};
2use rustc_data_structures::profiling::{SelfProfiler, TimingGuard};
31use std::ffi::{c_void, CStr};
42use std::os::raw::c_char;
53use std::sync::Arc;
64
5use measureme::event_id::SEPARATOR_BYTE;
6use measureme::{EventId, StringComponent, StringId};
7use rustc_data_structures::profiling::{SelfProfiler, TimingGuard};
8
79fn llvm_args_to_string_id(profiler: &SelfProfiler, pass_name: &str, ir_name: &str) -> EventId {
810 let pass_name = profiler.get_or_alloc_cached_string(pass_name);
911 let mut components = vec![StringComponent::Ref(pass_name)];
compiler/rustc_codegen_llvm/src/back/write.rs+22-26
......@@ -1,19 +1,10 @@
1use crate::back::lto::ThinBuffer;
2use crate::back::owned_target_machine::OwnedTargetMachine;
3use crate::back::profiling::{
4 selfprofile_after_pass_callback, selfprofile_before_pass_callback, LlvmSelfProfiler,
5};
6use crate::base;
7use crate::common;
8use crate::errors::{
9 CopyBitcode, FromLlvmDiag, FromLlvmOptimizationDiag, LlvmError, UnknownCompression,
10 WithLlvmError, WriteBytecode,
11};
12use crate::llvm::{self, DiagnosticInfo, PassManager};
13use crate::llvm_util;
14use crate::type_::Type;
15use crate::LlvmCodegenBackend;
16use crate::ModuleLlvm;
1use std::ffi::CString;
2use std::io::{self, Write};
3use std::path::{Path, PathBuf};
4use std::sync::Arc;
5use std::{fs, slice, str};
6
7use libc::{c_char, c_int, c_void, size_t};
178use llvm::{
189 LLVMRustLLVMHasZlibCompressionForDebugSymbols, LLVMRustLLVMHasZstdCompressionForDebugSymbols,
1910};
......@@ -29,23 +20,28 @@ use rustc_data_structures::small_c_str::SmallCStr;
2920use rustc_errors::{DiagCtxtHandle, FatalError, Level};
3021use rustc_fs_util::{link_or_copy, path_to_c_string};
3122use rustc_middle::ty::TyCtxt;
32use rustc_session::config::{self, Lto, OutputType, Passes};
33use rustc_session::config::{RemapPathScopeComponents, SplitDwarfKind, SwitchWithOptPath};
23use rustc_session::config::{
24 self, Lto, OutputType, Passes, RemapPathScopeComponents, SplitDwarfKind, SwitchWithOptPath,
25};
3426use rustc_session::Session;
3527use rustc_span::symbol::sym;
3628use rustc_span::InnerSpan;
3729use rustc_target::spec::{CodeModel, RelocModel, SanitizerSet, SplitDebuginfo, TlsModel};
3830use tracing::debug;
3931
32use crate::back::lto::ThinBuffer;
33use crate::back::owned_target_machine::OwnedTargetMachine;
34use crate::back::profiling::{
35 selfprofile_after_pass_callback, selfprofile_before_pass_callback, LlvmSelfProfiler,
36};
37use crate::errors::{
38 CopyBitcode, FromLlvmDiag, FromLlvmOptimizationDiag, LlvmError, UnknownCompression,
39 WithLlvmError, WriteBytecode,
40};
4041use crate::llvm::diagnostic::OptimizationDiagnosticKind;
41use libc::{c_char, c_int, c_void, size_t};
42use std::ffi::CString;
43use std::fs;
44use std::io::{self, Write};
45use std::path::{Path, PathBuf};
46use std::slice;
47use std::str;
48use std::sync::Arc;
42use crate::llvm::{self, DiagnosticInfo, PassManager};
43use crate::type_::Type;
44use crate::{base, common, llvm_util, LlvmCodegenBackend, ModuleLlvm};
4945
5046pub fn llvm_err<'a>(dcx: DiagCtxtHandle<'_>, err: LlvmError<'a>) -> FatalError {
5147 match llvm::last_error() {
compiler/rustc_codegen_llvm/src/base.rs+6-8
......@@ -11,13 +11,7 @@
1111//! [`Ty`]: rustc_middle::ty::Ty
1212//! [`val_ty`]: crate::common::val_ty
1313
14use super::ModuleLlvm;
15
16use crate::attributes;
17use crate::builder::Builder;
18use crate::context::CodegenCx;
19use crate::llvm;
20use crate::value::Value;
14use std::time::Instant;
2115
2216use rustc_codegen_ssa::base::maybe_create_entry_wrapper;
2317use rustc_codegen_ssa::mono_item::MonoItemExt;
......@@ -32,7 +26,11 @@ use rustc_session::config::DebugInfo;
3226use rustc_span::symbol::Symbol;
3327use rustc_target::spec::SanitizerSet;
3428
35use std::time::Instant;
29use super::ModuleLlvm;
30use crate::builder::Builder;
31use crate::context::CodegenCx;
32use crate::value::Value;
33use crate::{attributes, llvm};
3634
3735pub struct ValueIter<'ll> {
3836 cur: Option<&'ll Value>,
compiler/rustc_codegen_llvm/src/builder.rs+17-15
......@@ -1,12 +1,7 @@
1use crate::abi::FnAbiLlvmExt;
2use crate::attributes;
3use crate::common::Funclet;
4use crate::context::CodegenCx;
5use crate::llvm::{self, AtomicOrdering, AtomicRmwBinOp, BasicBlock, False, True};
6use crate::llvm_util;
7use crate::type_::Type;
8use crate::type_of::LayoutLlvmExt;
9use crate::value::Value;
1use std::borrow::Cow;
2use std::ops::Deref;
3use std::{iter, ptr};
4
105use libc::{c_char, c_uint};
116use rustc_codegen_ssa::common::{IntPredicate, RealPredicate, SynchronizationScope, TypeKind};
127use rustc_codegen_ssa::mir::operand::{OperandRef, OperandValue};
......@@ -23,15 +18,21 @@ use rustc_middle::ty::{self, Instance, Ty, TyCtxt};
2318use rustc_sanitizers::{cfi, kcfi};
2419use rustc_session::config::OptLevel;
2520use rustc_span::Span;
26use rustc_target::abi::{self, call::FnAbi, Align, Size, WrappingRange};
21use rustc_target::abi::call::FnAbi;
22use rustc_target::abi::{self, Align, Size, WrappingRange};
2723use rustc_target::spec::{HasTargetSpec, SanitizerSet, Target};
2824use smallvec::SmallVec;
29use std::borrow::Cow;
30use std::iter;
31use std::ops::Deref;
32use std::ptr;
3325use tracing::{debug, instrument};
3426
27use crate::abi::FnAbiLlvmExt;
28use crate::common::Funclet;
29use crate::context::CodegenCx;
30use crate::llvm::{self, AtomicOrdering, AtomicRmwBinOp, BasicBlock, False, True};
31use crate::type_::Type;
32use crate::type_of::LayoutLlvmExt;
33use crate::value::Value;
34use crate::{attributes, llvm_util};
35
3536// All Builders must have an llfn associated with them
3637#[must_use]
3738pub struct Builder<'a, 'll, 'tcx> {
......@@ -390,8 +391,9 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
390391 lhs: Self::Value,
391392 rhs: Self::Value,
392393 ) -> (Self::Value, Self::Value) {
394 use rustc_middle::ty::IntTy::*;
395 use rustc_middle::ty::UintTy::*;
393396 use rustc_middle::ty::{Int, Uint};
394 use rustc_middle::ty::{IntTy::*, UintTy::*};
395397
396398 let new_kind = match ty.kind() {
397399 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 @@
44//! and methods are represented as just a fn ptr and not a full
55//! closure.
66
7use crate::attributes;
8use crate::common;
9use crate::context::CodegenCx;
10use crate::llvm;
11use crate::value::Value;
12
137use rustc_middle::ty::layout::{FnAbiOf, HasTyCtxt};
148use rustc_middle::ty::{self, Instance, TypeVisitableExt};
159use tracing::debug;
1610
11use crate::context::CodegenCx;
12use crate::value::Value;
13use crate::{attributes, common, llvm};
14
1715/// Codegens a reference to a fn/method item, monomorphizing and
1816/// inlining as it goes.
1917///
compiler/rustc_codegen_llvm/src/common.rs+8-8
......@@ -1,11 +1,8 @@
11//! Code that is useful in various codegen modules.
22
3use crate::consts::const_alloc_to_llvm;
4pub use crate::context::CodegenCx;
5use crate::llvm::{self, BasicBlock, Bool, ConstantInt, False, OperandBundleDef, True};
6use crate::type_::Type;
7use crate::value::Value;
3use std::fmt::Write;
84
5use libc::{c_char, c_uint};
96use rustc_ast::Mutability;
107use rustc_codegen_ssa::traits::*;
118use rustc_data_structures::stable_hasher::{Hash128, HashStable, StableHasher};
......@@ -16,11 +13,14 @@ use rustc_middle::ty::TyCtxt;
1613use rustc_session::cstore::{DllCallingConvention, DllImport, PeImportNameType};
1714use rustc_target::abi::{self, AddressSpace, HasDataLayout, Pointer};
1815use rustc_target::spec::Target;
19
20use libc::{c_char, c_uint};
21use std::fmt::Write;
2216use tracing::debug;
2317
18use crate::consts::const_alloc_to_llvm;
19pub use crate::context::CodegenCx;
20use crate::llvm::{self, BasicBlock, Bool, ConstantInt, False, OperandBundleDef, True};
21use crate::type_::Type;
22use crate::value::Value;
23
2424/*
2525* A note on nomenclature of linking: "extern", "foreign", and "upcall".
2626*
compiler/rustc_codegen_llvm/src/consts.rs+12-11
......@@ -1,13 +1,5 @@
1use crate::base;
2use crate::common::{self, CodegenCx};
3use crate::debuginfo;
4use crate::errors::{
5 InvalidMinimumAlignmentNotPowerOfTwo, InvalidMinimumAlignmentTooLarge, SymbolAlreadyDefined,
6};
7use crate::llvm::{self, True};
8use crate::type_::Type;
9use crate::type_of::LayoutLlvmExt;
10use crate::value::Value;
1use std::ops::Range;
2
113use rustc_codegen_ssa::traits::*;
124use rustc_hir::def::DefKind;
135use rustc_hir::def_id::DefId;
......@@ -24,9 +16,18 @@ use rustc_session::config::Lto;
2416use rustc_target::abi::{
2517 Align, AlignFromBytesError, HasDataLayout, Primitive, Scalar, Size, WrappingRange,
2618};
27use std::ops::Range;
2819use tracing::{debug, instrument, trace};
2920
21use crate::common::{self, CodegenCx};
22use crate::errors::{
23 InvalidMinimumAlignmentNotPowerOfTwo, InvalidMinimumAlignmentTooLarge, SymbolAlreadyDefined,
24};
25use crate::llvm::{self, True};
26use crate::type_::Type;
27use crate::type_of::LayoutLlvmExt;
28use crate::value::Value;
29use crate::{base, debuginfo};
30
3031pub fn const_alloc_to_llvm<'ll>(
3132 cx: &CodegenCx<'ll, '_>,
3233 alloc: ConstAllocation<'_>,
compiler/rustc_codegen_llvm/src/context.rs+17-20
......@@ -1,19 +1,13 @@
1use crate::attributes;
2use crate::back::write::to_llvm_code_model;
3use crate::callee::get_fn;
4use crate::coverageinfo;
5use crate::debuginfo;
6use crate::debuginfo::metadata::apply_vcall_visibility_metadata;
7use crate::llvm;
8use crate::llvm_util;
9use crate::type_::Type;
10use crate::value::Value;
1use std::borrow::Borrow;
2use std::cell::{Cell, RefCell};
3use std::ffi::CStr;
4use std::str;
115
6use libc::c_uint;
127use rustc_codegen_ssa::base::{wants_msvc_seh, wants_wasm_eh};
138use rustc_codegen_ssa::errors as ssa_errors;
149use rustc_codegen_ssa::traits::*;
15use rustc_data_structures::base_n::ToBaseN;
16use rustc_data_structures::base_n::ALPHANUMERIC_ONLY;
10use rustc_data_structures::base_n::{ToBaseN, ALPHANUMERIC_ONLY};
1711use rustc_data_structures::fx::FxHashMap;
1812use rustc_data_structures::small_c_str::SmallCStr;
1913use rustc_hir::def_id::DefId;
......@@ -24,20 +18,23 @@ use rustc_middle::ty::layout::{
2418};
2519use rustc_middle::ty::{self, Instance, Ty, TyCtxt};
2620use rustc_middle::{bug, span_bug};
27use rustc_session::config::{BranchProtection, CFGuard, CFProtection};
28use rustc_session::config::{CrateType, DebugInfo, PAuthKey, PacRet};
21use rustc_session::config::{
22 BranchProtection, CFGuard, CFProtection, CrateType, DebugInfo, PAuthKey, PacRet,
23};
2924use rustc_session::Session;
3025use rustc_span::source_map::Spanned;
3126use rustc_span::{Span, DUMMY_SP};
32use rustc_target::abi::{call::FnAbi, HasDataLayout, TargetDataLayout, VariantIdx};
27use rustc_target::abi::call::FnAbi;
28use rustc_target::abi::{HasDataLayout, TargetDataLayout, VariantIdx};
3329use rustc_target::spec::{HasTargetSpec, RelocModel, Target, TlsModel};
3430use smallvec::SmallVec;
3531
36use libc::c_uint;
37use std::borrow::Borrow;
38use std::cell::{Cell, RefCell};
39use std::ffi::CStr;
40use std::str;
32use crate::back::write::to_llvm_code_model;
33use crate::callee::get_fn;
34use crate::debuginfo::metadata::apply_vcall_visibility_metadata;
35use crate::type_::Type;
36use crate::value::Value;
37use crate::{attributes, coverageinfo, debuginfo, llvm, llvm_util};
4138
4239/// There is one `CodegenCx` per compilation unit. Each one has its own LLVM
4340/// `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 @@
1use crate::coverageinfo::ffi::{Counter, CounterExpression, ExprKind};
2
31use rustc_data_structures::captures::Captures;
42use rustc_data_structures::fx::FxIndexSet;
53use rustc_index::bit_set::BitSet;
......@@ -11,6 +9,8 @@ use rustc_middle::ty::Instance;
119use rustc_span::Symbol;
1210use tracing::{debug, instrument};
1311
12use crate::coverageinfo::ffi::{Counter, CounterExpression, ExprKind};
13
1414/// Holds all of the coverage mapping data associated with a function instance,
1515/// collected during traversal of `Coverage` statements in the function's MIR.
1616#[derive(Debug)]
compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs+6-8
......@@ -1,21 +1,19 @@
1use crate::common::CodegenCx;
2use crate::coverageinfo;
3use crate::coverageinfo::ffi::CounterMappingRegion;
4use crate::coverageinfo::map_data::{FunctionCoverage, FunctionCoverageCollector};
5use crate::llvm;
6
71use itertools::Itertools as _;
82use rustc_codegen_ssa::traits::{BaseTypeMethods, ConstMethods};
93use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet};
104use rustc_hir::def_id::{DefId, LocalDefId};
115use rustc_index::IndexVec;
12use rustc_middle::bug;
13use rustc_middle::mir;
146use rustc_middle::ty::{self, TyCtxt};
7use rustc_middle::{bug, mir};
158use rustc_span::def_id::DefIdSet;
169use rustc_span::Symbol;
1710use tracing::debug;
1811
12use crate::common::CodegenCx;
13use crate::coverageinfo::ffi::CounterMappingRegion;
14use crate::coverageinfo::map_data::{FunctionCoverage, FunctionCoverageCollector};
15use crate::{coverageinfo, llvm};
16
1917/// Generates and exports the Coverage Map.
2018///
2119/// Rust Coverage Map generation supports LLVM Coverage Mapping Format versions
compiler/rustc_codegen_llvm/src/coverageinfo/mod.rs+6-7
......@@ -1,9 +1,4 @@
1use crate::llvm;
2
3use crate::builder::Builder;
4use crate::common::CodegenCx;
5use crate::coverageinfo::ffi::{CounterExpression, CounterMappingRegion};
6use crate::coverageinfo::map_data::FunctionCoverageCollector;
1use std::cell::RefCell;
72
83use libc::c_uint;
94use rustc_codegen_ssa::traits::{
......@@ -19,7 +14,11 @@ use rustc_middle::ty::Instance;
1914use rustc_target::abi::{Align, Size};
2015use tracing::{debug, instrument};
2116
22use std::cell::RefCell;
17use crate::builder::Builder;
18use crate::common::CodegenCx;
19use crate::coverageinfo::ffi::{CounterExpression, CounterMappingRegion};
20use crate::coverageinfo::map_data::FunctionCoverageCollector;
21use crate::llvm;
2322
2423pub(crate) mod ffi;
2524pub(crate) mod map_data;
compiler/rustc_codegen_llvm/src/debuginfo/create_scope_map.rs+7-8
......@@ -1,18 +1,17 @@
1use super::metadata::file_metadata;
2use super::utils::DIB;
31use rustc_codegen_ssa::mir::debuginfo::{DebugScope, FunctionDebugContext};
42use rustc_codegen_ssa::traits::*;
5
6use crate::common::CodegenCx;
7use crate::llvm;
8use crate::llvm::debuginfo::{DILocation, DIScope};
3use rustc_index::bit_set::BitSet;
4use rustc_index::Idx;
95use rustc_middle::mir::{Body, SourceScope};
106use rustc_middle::ty::layout::FnAbiOf;
117use rustc_middle::ty::{self, Instance};
128use rustc_session::config::DebugInfo;
139
14use rustc_index::bit_set::BitSet;
15use rustc_index::Idx;
10use super::metadata::file_metadata;
11use super::utils::DIB;
12use crate::common::CodegenCx;
13use crate::llvm;
14use crate::llvm::debuginfo::{DILocation, DIScope};
1615
1716/// Produces DIScope DIEs for each MIR Scope which has variables defined in it.
1817// 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 @@
11// .debug_gdb_scripts binary section.
22
3use crate::llvm;
4
5use crate::builder::Builder;
6use crate::common::CodegenCx;
7use crate::value::Value;
83use rustc_ast::attr;
94use rustc_codegen_ssa::base::collect_debugger_visualizers_transitive;
105use rustc_codegen_ssa::traits::*;
116use rustc_hir::def_id::LOCAL_CRATE;
12use rustc_middle::{bug, middle::debugger_visualizer::DebuggerVisualizerType};
7use rustc_middle::bug;
8use rustc_middle::middle::debugger_visualizer::DebuggerVisualizerType;
139use rustc_session::config::{CrateType, DebugInfo};
1410use rustc_span::symbol::sym;
1511
12use crate::builder::Builder;
13use crate::common::CodegenCx;
14use crate::llvm;
15use crate::value::Value;
16
1617/// Inserts a side-effect free instruction sequence that makes sure that the
1718/// .debug_gdb_scripts global is referenced, so it isn't removed by the linker.
1819pub 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 @@
1use self::type_map::DINodeCreationResult;
2use self::type_map::Stub;
3use self::type_map::UniqueTypeId;
4
5use super::namespace::mangled_name_of_instance;
6use super::type_names::{compute_debuginfo_type_name, compute_debuginfo_vtable_name};
7use super::utils::{
8 create_DIArray, debug_context, get_namespace_for_item, is_node_local_to_unit, DIB,
9};
10use super::CodegenUnitDebugContext;
11
12use crate::abi;
13use crate::common::CodegenCx;
14use crate::debuginfo::metadata::type_map::build_type_with_children;
15use crate::debuginfo::utils::fat_pointer_kind;
16use crate::debuginfo::utils::FatPtrKind;
17use crate::llvm;
18use crate::llvm::debuginfo::{
19 DIDescriptor, DIFile, DIFlags, DILexicalBlock, DIScope, DIType, DebugEmissionKind,
20 DebugNameTableKind,
21};
22use crate::value::Value;
1use std::borrow::Cow;
2use std::fmt::{self, Write};
3use std::hash::{Hash, Hasher};
4use std::path::{Path, PathBuf};
5use std::{iter, ptr};
236
24use rustc_codegen_ssa::debuginfo::type_names::cpp_like_debuginfo;
25use rustc_codegen_ssa::debuginfo::type_names::VTableNameKind;
7use libc::{c_char, c_longlong, c_uint};
8use rustc_codegen_ssa::debuginfo::type_names::{cpp_like_debuginfo, VTableNameKind};
269use rustc_codegen_ssa::traits::*;
2710use rustc_fs_util::path_to_c_string;
28use rustc_hir::def::CtorKind;
29use rustc_hir::def::DefKind;
11use rustc_hir::def::{CtorKind, DefKind};
3012use rustc_hir::def_id::{DefId, LOCAL_CRATE};
3113use rustc_middle::bug;
3214use rustc_middle::ty::layout::{LayoutOf, TyAndLayout};
......@@ -36,21 +18,29 @@ use rustc_middle::ty::{
3618};
3719use rustc_session::config::{self, DebugInfo, Lto};
3820use rustc_span::symbol::Symbol;
39use rustc_span::{hygiene, FileName, DUMMY_SP};
40use rustc_span::{FileNameDisplayPreference, SourceFile};
21use rustc_span::{hygiene, FileName, FileNameDisplayPreference, SourceFile, DUMMY_SP};
4122use rustc_symbol_mangling::typeid_for_trait_ref;
4223use rustc_target::abi::{Align, Size};
4324use rustc_target::spec::DebuginfoKind;
4425use smallvec::smallvec;
4526use tracing::{debug, instrument};
4627
47use libc::{c_char, c_longlong, c_uint};
48use std::borrow::Cow;
49use std::fmt::{self, Write};
50use std::hash::{Hash, Hasher};
51use std::iter;
52use std::path::{Path, PathBuf};
53use std::ptr;
28use self::type_map::{DINodeCreationResult, Stub, UniqueTypeId};
29use super::namespace::mangled_name_of_instance;
30use super::type_names::{compute_debuginfo_type_name, compute_debuginfo_vtable_name};
31use super::utils::{
32 create_DIArray, debug_context, get_namespace_for_item, is_node_local_to_unit, DIB,
33};
34use super::CodegenUnitDebugContext;
35use crate::common::CodegenCx;
36use crate::debuginfo::metadata::type_map::build_type_with_children;
37use crate::debuginfo::utils::{fat_pointer_kind, FatPtrKind};
38use crate::llvm::debuginfo::{
39 DIDescriptor, DIFile, DIFlags, DILexicalBlock, DIScope, DIType, DebugEmissionKind,
40 DebugNameTableKind,
41};
42use crate::value::Value;
43use crate::{abi, llvm};
5444
5545impl PartialEq for llvm::Metadata {
5646 fn eq(&self, other: &Self) -> bool {
......@@ -874,7 +864,8 @@ pub fn build_compile_unit_di_node<'ll, 'tcx>(
874864 codegen_unit_name: &str,
875865 debug_context: &CodegenUnitDebugContext<'ll, 'tcx>,
876866) -> &'ll DIDescriptor {
877 use rustc_session::{config::RemapPathScopeComponents, RemapFileNameExt};
867 use rustc_session::config::RemapPathScopeComponents;
868 use rustc_session::RemapFileNameExt;
878869 let mut name_in_debuginfo = tcx
879870 .sess
880871 .local_crate_source_file()
compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/cpp_like.rs+16-30
......@@ -1,41 +1,27 @@
11use std::borrow::Cow;
22
33use libc::c_uint;
4use rustc_codegen_ssa::{
5 debuginfo::{type_names::compute_debuginfo_type_name, wants_c_like_enum_debuginfo},
6 traits::ConstMethods,
7};
8
4use rustc_codegen_ssa::debuginfo::type_names::compute_debuginfo_type_name;
5use rustc_codegen_ssa::debuginfo::wants_c_like_enum_debuginfo;
6use rustc_codegen_ssa::traits::ConstMethods;
97use rustc_index::IndexVec;
10use rustc_middle::{
11 bug,
12 ty::{
13 self,
14 layout::{LayoutOf, TyAndLayout},
15 AdtDef, CoroutineArgs, CoroutineArgsExt, Ty,
16 },
17};
8use rustc_middle::bug;
9use rustc_middle::ty::layout::{LayoutOf, TyAndLayout};
10use rustc_middle::ty::{self, AdtDef, CoroutineArgs, CoroutineArgsExt, Ty};
1811use rustc_target::abi::{Align, Endian, Size, TagEncoding, VariantIdx, Variants};
1912use smallvec::smallvec;
2013
21use 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 },
14use crate::common::CodegenCx;
15use crate::debuginfo::metadata::enums::{tag_base_type, DiscrResult};
16use crate::debuginfo::metadata::type_map::{self, Stub, UniqueTypeId};
17use 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,
3821};
22use crate::debuginfo::utils::DIB;
23use crate::llvm::debuginfo::{DIFile, DIFlags, DIType};
24use crate::llvm::{self};
3925
4026// The names of the associated constants in each variant wrapper struct.
4127// 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 @@
1use rustc_codegen_ssa::debuginfo::{
2 type_names::{compute_debuginfo_type_name, cpp_like_debuginfo},
3 wants_c_like_enum_debuginfo,
4};
1use std::borrow::Cow;
2
3use rustc_codegen_ssa::debuginfo::type_names::{compute_debuginfo_type_name, cpp_like_debuginfo};
4use rustc_codegen_ssa::debuginfo::wants_c_like_enum_debuginfo;
55use rustc_hir::def::CtorKind;
66use rustc_index::IndexSlice;
7use 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};
7use rustc_middle::bug;
8use rustc_middle::mir::CoroutineLayout;
9use rustc_middle::ty::layout::{IntegerExt, LayoutOf, PrimitiveExt, TyAndLayout};
10use rustc_middle::ty::{self, AdtDef, CoroutineArgs, CoroutineArgsExt, Ty, VariantDef};
1611use rustc_span::Symbol;
1712use rustc_target::abi::{
1813 FieldIdx, HasDataLayout, Integer, Primitive, TagEncoding, VariantIdx, Variants,
1914};
20use std::borrow::Cow;
21
22use 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};
3715
38use super::{
39 size_and_align_of,
40 type_map::{DINodeCreationResult, UniqueTypeId},
41 SmallVec,
16use super::type_map::{DINodeCreationResult, UniqueTypeId};
17use super::{size_and_align_of, SmallVec};
18use crate::common::CodegenCx;
19use crate::debuginfo::metadata::type_map::{self, Stub};
20use crate::debuginfo::metadata::{
21 build_field_di_node, build_generic_type_param_di_nodes, type_di_node, unknown_file_metadata,
22 UNKNOWN_LINE_NUMBER,
4223};
24use crate::debuginfo::utils::{create_DIArray, get_namespace_for_item, DIB};
25use crate::llvm::debuginfo::{DIFlags, DIType};
26use crate::llvm::{self};
4327
4428mod cpp_like;
4529mod native;
compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/native.rs+17-28
......@@ -1,37 +1,26 @@
11use std::borrow::Cow;
22
3use 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};
203use libc::c_uint;
21use rustc_codegen_ssa::{
22 debuginfo::{type_names::compute_debuginfo_type_name, wants_c_like_enum_debuginfo},
23 traits::ConstMethods,
24};
25use rustc_middle::{
26 bug,
27 ty::{
28 self,
29 layout::{LayoutOf, TyAndLayout},
30 },
31};
4use rustc_codegen_ssa::debuginfo::type_names::compute_debuginfo_type_name;
5use rustc_codegen_ssa::debuginfo::wants_c_like_enum_debuginfo;
6use rustc_codegen_ssa::traits::ConstMethods;
7use rustc_middle::bug;
8use rustc_middle::ty::layout::{LayoutOf, TyAndLayout};
9use rustc_middle::ty::{self};
3210use rustc_target::abi::{Size, TagEncoding, VariantIdx, Variants};
3311use smallvec::smallvec;
3412
13use crate::common::CodegenCx;
14use crate::debuginfo::metadata::enums::tag_base_type;
15use crate::debuginfo::metadata::type_map::{self, Stub, StubInfo, UniqueTypeId};
16use 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};
20use crate::debuginfo::utils::{create_DIArray, get_namespace_for_item, DIB};
21use crate::llvm::debuginfo::{DIFile, DIFlags, DIType};
22use crate::llvm::{self};
23
3524/// Build the debuginfo node for an enum type. The listing below shows how such a
3625/// type looks like at the LLVM IR/DWARF level. It is a `DW_TAG_structure_type`
3726/// 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 @@
11use std::cell::RefCell;
22
3use rustc_data_structures::{
4 fingerprint::Fingerprint,
5 fx::FxHashMap,
6 stable_hasher::{HashStable, StableHasher},
7};
3use rustc_data_structures::fingerprint::Fingerprint;
4use rustc_data_structures::fx::FxHashMap;
5use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
86use rustc_macros::HashStable;
9use rustc_middle::{
10 bug,
11 ty::{ParamEnv, PolyExistentialTraitRef, Ty, TyCtxt},
12};
7use rustc_middle::bug;
8use rustc_middle::ty::{ParamEnv, PolyExistentialTraitRef, Ty, TyCtxt};
139use rustc_target::abi::{Align, Size, VariantIdx};
1410
15use crate::{
16 common::CodegenCx,
17 debuginfo::utils::{create_DIArray, debug_context, DIB},
18 llvm::{
19 self,
20 debuginfo::{DIFlags, DIScope, DIType},
21 },
22};
23
2411use super::{unknown_file_metadata, SmallVec, UNKNOWN_LINE_NUMBER};
12use crate::common::CodegenCx;
13use crate::debuginfo::utils::{create_DIArray, debug_context, DIB};
14use crate::llvm::debuginfo::{DIFlags, DIScope, DIType};
15use crate::llvm::{self};
2516
2617mod private {
2718 use rustc_macros::HashStable;
compiler/rustc_codegen_llvm/src/debuginfo/mod.rs+20-25
......@@ -1,33 +1,21 @@
11#![doc = include_str!("doc.md")]
22
3use rustc_codegen_ssa::mir::debuginfo::VariableKind::*;
4use rustc_data_structures::unord::UnordMap;
5
6use self::metadata::{file_metadata, type_di_node};
7use self::metadata::{UNKNOWN_COLUMN_NUMBER, UNKNOWN_LINE_NUMBER};
8use self::namespace::mangled_name_of_instance;
9use self::utils::{create_DIArray, is_node_local_to_unit, DIB};
10
11use crate::abi::FnAbi;
12use crate::builder::Builder;
13use crate::common::CodegenCx;
14use crate::llvm;
15use crate::llvm::debuginfo::{
16 DIArray, DIBuilder, DIFile, DIFlags, DILexicalBlock, DILocation, DISPFlags, DIScope, DIType,
17 DIVariable,
18};
19use crate::value::Value;
3use std::cell::{OnceCell, RefCell};
4use std::iter;
5use std::ops::Range;
206
7use libc::c_uint;
218use rustc_codegen_ssa::debuginfo::type_names;
9use rustc_codegen_ssa::mir::debuginfo::VariableKind::*;
2210use rustc_codegen_ssa::mir::debuginfo::{DebugScope, FunctionDebugContext, VariableKind};
2311use rustc_codegen_ssa::traits::*;
2412use rustc_data_structures::sync::Lrc;
13use rustc_data_structures::unord::UnordMap;
2514use rustc_hir::def_id::{DefId, DefIdMap};
2615use rustc_index::IndexVec;
2716use rustc_middle::mir;
2817use rustc_middle::ty::layout::LayoutOf;
29use rustc_middle::ty::GenericArgsRef;
30use rustc_middle::ty::{self, Instance, ParamEnv, Ty, TypeVisitableExt};
18use rustc_middle::ty::{self, GenericArgsRef, Instance, ParamEnv, Ty, TypeVisitableExt};
3119use rustc_session::config::{self, DebugInfo};
3220use rustc_session::Session;
3321use rustc_span::symbol::Symbol;
......@@ -35,15 +23,22 @@ use rustc_span::{
3523 BytePos, Pos, SourceFile, SourceFileAndLine, SourceFileHash, Span, StableSourceFileId,
3624};
3725use rustc_target::abi::Size;
38
39use libc::c_uint;
4026use smallvec::SmallVec;
41use std::cell::OnceCell;
42use std::cell::RefCell;
43use std::iter;
44use std::ops::Range;
4527use tracing::debug;
4628
29use self::metadata::{file_metadata, type_di_node, UNKNOWN_COLUMN_NUMBER, UNKNOWN_LINE_NUMBER};
30use self::namespace::mangled_name_of_instance;
31use self::utils::{create_DIArray, is_node_local_to_unit, DIB};
32use crate::abi::FnAbi;
33use crate::builder::Builder;
34use crate::common::CodegenCx;
35use crate::llvm;
36use crate::llvm::debuginfo::{
37 DIArray, DIBuilder, DIFile, DIFlags, DILexicalBlock, DILocation, DISPFlags, DIScope, DIType,
38 DIVariable,
39};
40use crate::value::Value;
41
4742mod create_scope_map;
4843pub mod gdb;
4944pub mod metadata;
compiler/rustc_codegen_llvm/src/debuginfo/namespace.rs+2-2
......@@ -1,13 +1,13 @@
11// Namespace Handling.
22
3use super::utils::{debug_context, DIB};
43use rustc_codegen_ssa::debuginfo::type_names;
4use rustc_hir::def_id::DefId;
55use rustc_middle::ty::{self, Instance};
66
7use super::utils::{debug_context, DIB};
78use crate::common::CodegenCx;
89use crate::llvm;
910use crate::llvm::debuginfo::DIScope;
10use rustc_hir::def_id::DefId;
1111
1212pub fn mangled_name_of_instance<'a, 'tcx>(
1313 cx: &CodegenCx<'a, 'tcx>,
compiler/rustc_codegen_llvm/src/debuginfo/utils.rs+2-3
......@@ -1,13 +1,12 @@
11// Utility Functions.
22
3use super::namespace::item_namespace;
4use super::CodegenUnitDebugContext;
5
63use rustc_hir::def_id::DefId;
74use rustc_middle::ty::layout::{HasParamEnv, LayoutOf};
85use rustc_middle::ty::{self, Ty};
96use tracing::trace;
107
8use super::namespace::item_namespace;
9use super::CodegenUnitDebugContext;
1110use crate::common::CodegenCx;
1211use crate::llvm;
1312use crate::llvm::debuginfo::{DIArray, DIBuilder, DIDescriptor, DIScope};
compiler/rustc_codegen_llvm/src/declare.rs+7-7
......@@ -11,13 +11,6 @@
1111//! * Use define_* family of methods when you might be defining the Value.
1212//! * When in doubt, define.
1313
14use crate::abi::{FnAbi, FnAbiLlvmExt};
15use crate::attributes;
16use crate::context::CodegenCx;
17use crate::llvm;
18use crate::llvm::AttributePlace::Function;
19use crate::type_::Type;
20use crate::value::Value;
2114use itertools::Itertools;
2215use rustc_codegen_ssa::traits::TypeMembershipMethods;
2316use rustc_data_structures::fx::FxIndexSet;
......@@ -26,6 +19,13 @@ use rustc_sanitizers::{cfi, kcfi};
2619use smallvec::SmallVec;
2720use tracing::debug;
2821
22use crate::abi::{FnAbi, FnAbiLlvmExt};
23use crate::context::CodegenCx;
24use crate::llvm::AttributePlace::Function;
25use crate::type_::Type;
26use crate::value::Value;
27use crate::{attributes, llvm};
28
2929/// Declare a function.
3030///
3131/// 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;
22use std::ffi::CString;
33use std::path::Path;
44
5use crate::fluent_generated as fluent;
65use rustc_data_structures::small_c_str::SmallCStr;
76use rustc_errors::{Diag, DiagCtxtHandle, Diagnostic, EmissionGuarantee, Level};
87use rustc_macros::{Diagnostic, Subdiagnostic};
98use rustc_span::Span;
109
10use crate::fluent_generated as fluent;
11
1112#[derive(Diagnostic)]
1213#[diag(codegen_llvm_unknown_ctarget_feature_prefix)]
1314#[note]
compiler/rustc_codegen_llvm/src/intrinsic.rs+9-9
......@@ -1,11 +1,4 @@
1use crate::abi::{Abi, FnAbi, FnAbiLlvmExt, LlvmType, PassMode};
2use crate::builder::Builder;
3use crate::context::CodegenCx;
4use crate::llvm;
5use crate::type_::Type;
6use crate::type_of::LayoutLlvmExt;
7use crate::va_arg::emit_va_arg;
8use crate::value::Value;
1use std::cmp::Ordering;
92
103use rustc_codegen_ssa::base::{compare_simd_types, wants_msvc_seh, wants_wasm_eh};
114use rustc_codegen_ssa::common::{IntPredicate, TypeKind};
......@@ -23,7 +16,14 @@ use rustc_target::abi::{self, Align, Float, HasDataLayout, Primitive, Size};
2316use rustc_target::spec::{HasTargetSpec, PanicStrategy};
2417use tracing::debug;
2518
26use std::cmp::Ordering;
19use crate::abi::{Abi, FnAbi, FnAbiLlvmExt, LlvmType, PassMode};
20use crate::builder::Builder;
21use crate::context::CodegenCx;
22use crate::llvm;
23use crate::type_::Type;
24use crate::type_of::LayoutLlvmExt;
25use crate::va_arg::emit_va_arg;
26use crate::value::Value;
2727
2828fn get_simple_intrinsic<'ll>(
2929 cx: &CodegenCx<'ll, '_>,
compiler/rustc_codegen_llvm/src/lib.rs+8-9
......@@ -17,9 +17,13 @@
1717#![feature(rustdoc_internals)]
1818// tidy-alphabetical-end
1919
20use std::any::Any;
21use std::ffi::CStr;
22use std::io::Write;
23use std::mem::ManuallyDrop;
24
2025use back::owned_target_machine::OwnedTargetMachine;
2126use back::write::{create_informational_target_machine, create_target_machine};
22
2327use errors::ParseTargetMachineConfig;
2428pub use llvm_util::target_features;
2529use rustc_ast::expand::allocator::AllocatorKind;
......@@ -28,8 +32,7 @@ use rustc_codegen_ssa::back::write::{
2832 CodegenContext, FatLtoInput, ModuleConfig, TargetMachineFactoryConfig, TargetMachineFactoryFn,
2933};
3034use rustc_codegen_ssa::traits::*;
31use rustc_codegen_ssa::ModuleCodegen;
32use rustc_codegen_ssa::{CodegenResults, CompiledModule};
35use rustc_codegen_ssa::{CodegenResults, CompiledModule, ModuleCodegen};
3336use rustc_data_structures::fx::FxIndexMap;
3437use rustc_errors::{DiagCtxtHandle, ErrorGuaranteed, FatalError};
3538use rustc_metadata::EncodedMetadata;
......@@ -40,11 +43,6 @@ use rustc_session::config::{OptLevel, OutputFilenames, PrintKind, PrintRequest};
4043use rustc_session::Session;
4144use rustc_span::symbol::Symbol;
4245
43use std::any::Any;
44use std::ffi::CStr;
45use std::io::Write;
46use std::mem::ManuallyDrop;
47
4846mod back {
4947 pub mod archive;
5048 pub mod lto;
......@@ -394,9 +392,10 @@ impl CodegenBackend for LlvmCodegenBackend {
394392 codegen_results: CodegenResults,
395393 outputs: &OutputFilenames,
396394 ) -> Result<(), ErrorGuaranteed> {
397 use crate::back::archive::LlvmArchiveBuilderBuilder;
398395 use rustc_codegen_ssa::back::link::link_binary;
399396
397 use crate::back::archive::LlvmArchiveBuilderBuilder;
398
400399 // Run the linker on any artifacts that resulted from the LLVM run.
401400 // This should produce either a finished executable or library.
402401 link_binary(sess, &LlvmArchiveBuilderBuilder, &codegen_results, outputs)
compiler/rustc_codegen_llvm/src/llvm/archive_ro.rs+3-3
......@@ -1,9 +1,9 @@
11//! A wrapper around LLVM's archive (.a) code
22
3use rustc_fs_util::path_to_c_string;
43use std::path::Path;
5use std::slice;
6use std::str;
4use std::{slice, str};
5
6use rustc_fs_util::path_to_c_string;
77
88pub struct ArchiveRO {
99 pub raw: &'static mut super::Archive,
compiler/rustc_codegen_llvm/src/llvm/diagnostic.rs+4-5
......@@ -1,13 +1,12 @@
11//! LLVM diagnostic reports.
22
3pub use self::Diagnostic::*;
4pub use self::OptimizationDiagnosticKind::*;
5
6use crate::value::Value;
73use libc::c_uint;
4use rustc_span::InnerSpan;
85
6pub use self::Diagnostic::*;
7pub use self::OptimizationDiagnosticKind::*;
98use super::{DiagnosticInfo, SMDiagnostic};
10use rustc_span::InnerSpan;
9use crate::value::Value;
1110
1211#[derive(Copy, Clone, Debug)]
1312pub enum OptimizationDiagnosticKind {
compiler/rustc_codegen_llvm/src/llvm/ffi.rs+6-7
......@@ -1,18 +1,16 @@
11#![allow(non_camel_case_types)]
22#![allow(non_upper_case_globals)]
33
4use std::marker::PhantomData;
5
6use libc::{c_char, c_int, c_uint, c_ulonglong, c_void, size_t};
7
48use super::debuginfo::{
59 DIArray, DIBasicType, DIBuilder, DICompositeType, DIDerivedType, DIDescriptor, DIEnumerator,
610 DIFile, DIFlags, DIGlobalVariableExpression, DILexicalBlock, DILocation, DINameSpace,
711 DISPFlags, DIScope, DISubprogram, DISubrange, DITemplateTypeParameter, DIType, DIVariable,
812 DebugEmissionKind, DebugNameTableKind,
913};
10
11use libc::{c_char, c_int, c_uint, size_t};
12use libc::{c_ulonglong, c_void};
13
14use std::marker::PhantomData;
15
1614use super::RustString;
1715
1816pub type Bool = c_uint;
......@@ -697,9 +695,10 @@ pub type DiagnosticHandlerTy = unsafe extern "C" fn(&DiagnosticInfo, *mut c_void
697695pub type InlineAsmDiagHandlerTy = unsafe extern "C" fn(&SMDiagnostic, *const c_void, c_uint);
698696
699697pub mod debuginfo {
700 use super::{InvariantOpaque, Metadata};
701698 use bitflags::bitflags;
702699
700 use super::{InvariantOpaque, Metadata};
701
703702 #[repr(C)]
704703 pub struct DIBuilder<'a>(InvariantOpaque<'a>);
705704
compiler/rustc_codegen_llvm/src/llvm/mod.rs+10-9
......@@ -1,5 +1,15 @@
11#![allow(non_snake_case)]
22
3use std::cell::RefCell;
4use std::ffi::{CStr, CString};
5use std::str::FromStr;
6use std::string::FromUtf8Error;
7
8use libc::c_uint;
9use rustc_data_structures::small_c_str::SmallCStr;
10use rustc_llvm::RustString;
11use rustc_target::abi::Align;
12
313pub use self::AtomicRmwBinOp::*;
414pub use self::CallConv::*;
515pub use self::CodeGenOptSize::*;
......@@ -8,15 +18,6 @@ pub use self::Linkage::*;
818pub use self::MetadataType::*;
919pub use self::RealPredicate::*;
1020
11use libc::c_uint;
12use rustc_data_structures::small_c_str::SmallCStr;
13use rustc_llvm::RustString;
14use rustc_target::abi::Align;
15use std::cell::RefCell;
16use std::ffi::{CStr, CString};
17use std::str::FromStr;
18use std::string::FromUtf8Error;
19
2021pub mod archive_ro;
2122pub mod diagnostic;
2223mod ffi;
compiler/rustc_codegen_llvm/src/llvm_util.rs+12-13
......@@ -1,9 +1,9 @@
1use crate::back::write::create_informational_target_machine;
2use crate::errors::{
3 FixedX18InvalidArch, InvalidTargetFeaturePrefix, PossibleFeature, TargetFeatureDisableOrEnable,
4 UnknownCTargetFeature, UnknownCTargetFeaturePrefix, UnstableCTargetFeature,
5};
6use crate::llvm;
1use std::ffi::{c_char, c_void, CStr, CString};
2use std::fmt::Write;
3use std::path::Path;
4use std::sync::Once;
5use std::{ptr, slice, str};
6
77use libc::c_int;
88use rustc_codegen_ssa::base::wants_wasm_eh;
99use rustc_data_structures::fx::{FxHashMap, FxHashSet};
......@@ -16,13 +16,12 @@ use rustc_span::symbol::Symbol;
1616use rustc_target::spec::{MergeFunctions, PanicStrategy};
1717use rustc_target::target_features::{RUSTC_SPECIAL_FEATURES, RUSTC_SPECIFIC_FEATURES};
1818
19use std::ffi::{c_char, c_void, CStr, CString};
20use std::fmt::Write;
21use std::path::Path;
22use std::ptr;
23use std::slice;
24use std::str;
25use std::sync::Once;
19use crate::back::write::create_informational_target_machine;
20use crate::errors::{
21 FixedX18InvalidArch, InvalidTargetFeaturePrefix, PossibleFeature, TargetFeatureDisableOrEnable,
22 UnknownCTargetFeature, UnknownCTargetFeaturePrefix, UnstableCTargetFeature,
23};
24use crate::llvm;
2625
2726static INIT: Once = Once::new();
2827
compiler/rustc_codegen_llvm/src/mono_item.rs+5-6
......@@ -1,9 +1,3 @@
1use crate::attributes;
2use crate::base;
3use crate::context::CodegenCx;
4use crate::errors::SymbolAlreadyDefined;
5use crate::llvm;
6use crate::type_of::LayoutLlvmExt;
71use rustc_codegen_ssa::traits::*;
82use rustc_hir::def::DefKind;
93use rustc_hir::def_id::{DefId, LOCAL_CRATE};
......@@ -15,6 +9,11 @@ use rustc_session::config::CrateType;
159use rustc_target::spec::RelocModel;
1610use tracing::debug;
1711
12use crate::context::CodegenCx;
13use crate::errors::SymbolAlreadyDefined;
14use crate::type_of::LayoutLlvmExt;
15use crate::{attributes, base, llvm};
16
1817impl<'tcx> PreDefineMethods<'tcx> for CodegenCx<'_, 'tcx> {
1918 fn predefine_static(
2019 &self,
compiler/rustc_codegen_llvm/src/type_.rs+9-12
......@@ -1,12 +1,6 @@
1pub use crate::llvm::Type;
1use std::{fmt, ptr};
22
3use crate::abi::{FnAbiLlvmExt, LlvmType};
4use crate::common;
5use crate::context::CodegenCx;
6use crate::llvm;
7use crate::llvm::{Bool, False, True};
8use crate::type_of::LayoutLlvmExt;
9use crate::value::Value;
3use libc::{c_char, c_uint};
104use rustc_codegen_ssa::common::TypeKind;
115use rustc_codegen_ssa::traits::*;
126use rustc_data_structures::small_c_str::SmallCStr;
......@@ -16,10 +10,13 @@ use rustc_middle::ty::{self, Ty};
1610use rustc_target::abi::call::{CastTarget, FnAbi, Reg};
1711use rustc_target::abi::{AddressSpace, Align, Integer, Size};
1812
19use std::fmt;
20use std::ptr;
21
22use libc::{c_char, c_uint};
13use crate::abi::{FnAbiLlvmExt, LlvmType};
14use crate::context::CodegenCx;
15pub use crate::llvm::Type;
16use crate::llvm::{Bool, False, True};
17use crate::type_of::LayoutLlvmExt;
18use crate::value::Value;
19use crate::{common, llvm};
2320
2421impl PartialEq for Type {
2522 fn eq(&self, other: &Self) -> bool {
compiler/rustc_codegen_llvm/src/type_of.rs+5-6
......@@ -1,16 +1,15 @@
1use crate::common::*;
2use crate::type_::Type;
1use std::fmt::Write;
2
33use rustc_codegen_ssa::traits::*;
44use rustc_middle::bug;
55use rustc_middle::ty::layout::{LayoutOf, TyAndLayout};
66use rustc_middle::ty::print::{with_no_trimmed_paths, with_no_visible_paths};
77use rustc_middle::ty::{self, CoroutineArgsExt, Ty, TypeVisitableExt};
8use rustc_target::abi::{Abi, Align, FieldsShape};
9use rustc_target::abi::{Float, Int, Pointer};
10use rustc_target::abi::{Scalar, Size, Variants};
8use rustc_target::abi::{Abi, Align, FieldsShape, Float, Int, Pointer, Scalar, Size, Variants};
119use tracing::debug;
1210
13use std::fmt::Write;
11use crate::common::*;
12use crate::type_::Type;
1413
1514fn uncached_llvm_type<'a, 'tcx>(
1615 cx: &CodegenCx<'a, 'tcx>,
compiler/rustc_codegen_llvm/src/va_arg.rs+7-8
......@@ -1,16 +1,15 @@
1use crate::builder::Builder;
2use crate::type_::Type;
3use crate::type_of::LayoutLlvmExt;
4use crate::value::Value;
1use rustc_codegen_ssa::common::IntPredicate;
52use rustc_codegen_ssa::mir::operand::OperandRef;
6use rustc_codegen_ssa::{
7 common::IntPredicate,
8 traits::{BaseTypeMethods, BuilderMethods, ConstMethods},
9};
3use rustc_codegen_ssa::traits::{BaseTypeMethods, BuilderMethods, ConstMethods};
104use rustc_middle::ty::layout::{HasTyCtxt, LayoutOf};
115use rustc_middle::ty::Ty;
126use rustc_target::abi::{Align, Endian, HasDataLayout, Size};
137
8use crate::builder::Builder;
9use crate::type_::Type;
10use crate::type_of::LayoutLlvmExt;
11use crate::value::Value;
12
1413fn round_pointer_up_to_alignment<'ll>(
1514 bx: &mut Builder<'_, 'll, '_>,
1615 addr: &'ll Value,
compiler/rustc_codegen_llvm/src/value.rs+3-5
......@@ -1,10 +1,8 @@
1pub use crate::llvm::Value;
1use std::hash::{Hash, Hasher};
2use std::{fmt, ptr};
23
34use crate::llvm;
4
5use std::fmt;
6use std::hash::{Hash, Hasher};
7use std::ptr;
5pub use crate::llvm::Value;
86
97impl PartialEq for Value {
108 fn eq(&self, other: &Self) -> bool {
compiler/rustc_codegen_ssa/src/assert_module_sources.rs+6-5
......@@ -23,10 +23,11 @@
2323//! allows for doing a more fine-grained check to see if pre- or post-lto data
2424//! was re-used.
2525
26use crate::errors;
26use std::borrow::Cow;
27use std::fmt;
28
2729use rustc_ast as ast;
28use rustc_data_structures::unord::UnordMap;
29use rustc_data_structures::unord::UnordSet;
30use rustc_data_structures::unord::{UnordMap, UnordSet};
3031use rustc_errors::{DiagArgValue, IntoDiagArg};
3132use rustc_hir::def_id::LOCAL_CRATE;
3233use rustc_middle::mir::mono::CodegenUnitNameBuilder;
......@@ -34,11 +35,11 @@ use rustc_middle::ty::TyCtxt;
3435use rustc_session::Session;
3536use rustc_span::symbol::sym;
3637use rustc_span::{Span, Symbol};
37use std::borrow::Cow;
38use std::fmt;
3938use thin_vec::ThinVec;
4039use tracing::debug;
4140
41use crate::errors;
42
4243#[allow(missing_docs)]
4344pub fn assert_module_sources(tcx: TyCtxt<'_>, set_reuse: &dyn Fn(&mut CguReuseTracker)) {
4445 tcx.dep_graph.with_ignore(|| {
compiler/rustc_codegen_ssa/src/back/archive.rs+10-12
......@@ -1,22 +1,20 @@
1use rustc_data_structures::fx::FxIndexSet;
2use rustc_data_structures::memmap::Mmap;
3use rustc_session::cstore::DllImport;
4use rustc_session::Session;
5use rustc_span::symbol::Symbol;
6
7use super::metadata::search_for_section;
1use std::error::Error;
2use std::fs::{self, File};
3use std::io::{self, Write};
4use std::path::{Path, PathBuf};
85
96use ar_archive_writer::{write_archive_to_stream, ArchiveKind, NewArchiveMember};
107pub use ar_archive_writer::{ObjectReader, DEFAULT_OBJECT_READER};
118use object::read::archive::ArchiveFile;
129use object::read::macho::FatArch;
10use rustc_data_structures::fx::FxIndexSet;
11use rustc_data_structures::memmap::Mmap;
12use rustc_session::cstore::DllImport;
13use rustc_session::Session;
14use rustc_span::symbol::Symbol;
1315use tempfile::Builder as TempFileBuilder;
1416
15use std::error::Error;
16use std::fs::{self, File};
17use std::io::{self, Write};
18use std::path::{Path, PathBuf};
19
17use super::metadata::search_for_section;
2018// Re-exporting for rustc_codegen_llvm::back::archive
2119pub use crate::errors::{ArchiveBuildFailure, ExtractBundledLibsError, UnknownArchiveKind};
2220
compiler/rustc_codegen_ssa/src/back/command.rs+1-3
......@@ -2,10 +2,8 @@
22//! read the arguments that are built up.
33
44use std::ffi::{OsStr, OsString};
5use std::fmt;
6use std::io;
7use std::mem;
85use std::process::{self, Output};
6use std::{fmt, io, mem};
97
108use rustc_target::spec::LldFlavor;
119
compiler/rustc_codegen_ssa/src/back/link.rs+23-23
......@@ -1,3 +1,15 @@
1use std::collections::BTreeSet;
2use std::ffi::OsString;
3use std::fs::{read, File, OpenOptions};
4use std::io::{BufWriter, Write};
5use std::ops::Deref;
6use std::path::{Path, PathBuf};
7use std::process::{ExitStatus, Output, Stdio};
8use std::{env, fmt, fs, io, mem, str};
9
10use cc::windows_registry;
11use itertools::Itertools;
12use regex::Regex;
113use rustc_arena::TypedArena;
214use rustc_ast::CRATE_NODE_ID;
315use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
......@@ -12,9 +24,10 @@ use rustc_middle::bug;
1224use rustc_middle::middle::debugger_visualizer::DebuggerVisualizerFile;
1325use rustc_middle::middle::dependency_format::Linkage;
1426use rustc_middle::middle::exported_symbols::SymbolExportKind;
15use rustc_session::config::LinkerFeaturesCli;
16use rustc_session::config::{self, CFGuard, CrateType, DebugInfo, OutFileName, Strip};
17use rustc_session::config::{OutputFilenames, OutputType, PrintKind, SplitDwarfKind};
27use rustc_session::config::{
28 self, CFGuard, CrateType, DebugInfo, LinkerFeaturesCli, OutFileName, OutputFilenames,
29 OutputType, PrintKind, SplitDwarfKind, Strip,
30};
1831use rustc_session::cstore::DllImport;
1932use rustc_session::output::{check_file_is_writeable, invalid_output_for_target, out_filename};
2033use rustc_session::search_paths::PathKind;
......@@ -24,11 +37,13 @@ use rustc_session::utils::NativeLibKind;
2437use rustc_session::{filesearch, Session};
2538use rustc_span::symbol::Symbol;
2639use rustc_target::spec::crt_objects::CrtObjects;
27use rustc_target::spec::LinkSelfContainedDefault;
28use rustc_target::spec::LinkerFlavorCli;
29use rustc_target::spec::{Cc, LinkOutputKind, LinkerFlavor, Lld, PanicStrategy};
30use rustc_target::spec::{LinkSelfContainedComponents, LinkerFeatures};
31use rustc_target::spec::{RelocModel, RelroLevel, SanitizerSet, SplitDebuginfo};
40use rustc_target::spec::{
41 Cc, LinkOutputKind, LinkSelfContainedComponents, LinkSelfContainedDefault, LinkerFeatures,
42 LinkerFlavor, LinkerFlavorCli, Lld, PanicStrategy, RelocModel, RelroLevel, SanitizerSet,
43 SplitDebuginfo,
44};
45use tempfile::Builder as TempFileBuilder;
46use tracing::{debug, info, warn};
3247
3348use super::archive::{ArchiveBuilder, ArchiveBuilderBuilder};
3449use super::command::Command;
......@@ -39,21 +54,6 @@ use crate::{
3954 errors, looks_like_rust_object_file, CodegenResults, CompiledModule, CrateInfo, NativeLib,
4055};
4156
42use cc::windows_registry;
43use regex::Regex;
44use tempfile::Builder as TempFileBuilder;
45
46use itertools::Itertools;
47use std::collections::BTreeSet;
48use std::ffi::OsString;
49use std::fs::{read, File, OpenOptions};
50use std::io::{BufWriter, Write};
51use std::ops::Deref;
52use std::path::{Path, PathBuf};
53use std::process::{ExitStatus, Output, Stdio};
54use std::{env, fmt, fs, io, mem, str};
55use tracing::{debug, info, warn};
56
5757pub fn ensure_removed(dcx: DiagCtxtHandle<'_>, path: &Path) {
5858 if let Err(e) = fs::remove_file(path) {
5959 if e.kind() != io::ErrorKind::NotFound {
compiler/rustc_codegen_ssa/src/back/linker.rs+6-7
......@@ -1,8 +1,3 @@
1use super::command::Command;
2use super::symbol_export;
3use crate::errors;
4use rustc_span::symbol::sym;
5
61use std::ffi::{OsStr, OsString};
72use std::fs::{self, File};
83use std::io::prelude::*;
......@@ -10,6 +5,7 @@ use std::io::{self, BufWriter};
105use std::path::{Path, PathBuf};
116use std::{env, iter, mem, str};
127
8use cc::windows_registry;
139use rustc_hir::def_id::{CrateNum, LOCAL_CRATE};
1410use rustc_metadata::find_native_static_library;
1511use rustc_middle::bug;
......@@ -19,11 +15,14 @@ use rustc_middle::middle::exported_symbols::{ExportedSymbol, SymbolExportInfo, S
1915use rustc_middle::ty::TyCtxt;
2016use rustc_session::config::{self, CrateType, DebugInfo, LinkerPluginLto, Lto, OptLevel, Strip};
2117use rustc_session::Session;
18use rustc_span::symbol::sym;
2219use rustc_target::spec::{Cc, LinkOutputKind, LinkerFlavor, Lld};
23
24use cc::windows_registry;
2520use tracing::{debug, warn};
2621
22use super::command::Command;
23use super::symbol_export;
24use crate::errors;
25
2726/// Disables non-English messages from localized linkers.
2827/// Such messages may cause issues with text encoding on Windows (#35785)
2928/// 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 @@
1use super::write::CodegenContext;
2use crate::traits::*;
3use crate::ModuleCodegen;
1use std::ffi::CString;
2use std::sync::Arc;
43
54use rustc_data_structures::memmap::Mmap;
65use rustc_errors::FatalError;
76
8use std::ffi::CString;
9use std::sync::Arc;
7use super::write::CodegenContext;
8use crate::traits::*;
9use crate::ModuleCodegen;
1010
1111pub struct ThinModule<B: WriteBackendMethods> {
1212 pub shared: Arc<ThinShared<B>>,
compiler/rustc_codegen_ssa/src/back/metadata.rs-1
......@@ -10,7 +10,6 @@ use object::{
1010 elf, pe, xcoff, Architecture, BinaryFormat, Endianness, FileFlags, Object, ObjectSection,
1111 ObjectSymbol, SectionFlags, SectionKind, SubArchitecture, SymbolFlags, SymbolKind, SymbolScope,
1212};
13
1413use rustc_data_structures::memmap::Mmap;
1514use rustc_data_structures::owned_slice::{try_slice_owned, OwnedSlice};
1615use rustc_metadata::creader::MetadataLoader;
compiler/rustc_codegen_ssa/src/back/rpath.rs+3-2
......@@ -1,8 +1,9 @@
1use std::ffi::OsString;
2use std::path::{Path, PathBuf};
3
14use pathdiff::diff_paths;
25use rustc_data_structures::fx::FxHashSet;
36use rustc_fs_util::try_canonicalize;
4use std::ffi::OsString;
5use std::path::{Path, PathBuf};
67use tracing::debug;
78
89pub struct RPathConfig<'a> {
compiler/rustc_codegen_ssa/src/back/rpath/tests.rs+2-2
......@@ -1,8 +1,8 @@
1use super::RPathConfig;
2use super::{get_rpath_relative_to_output, minimize_rpaths, rpaths_to_flags};
31use std::ffi::OsString;
42use std::path::{Path, PathBuf};
53
4use super::{get_rpath_relative_to_output, minimize_rpaths, rpaths_to_flags, RPathConfig};
5
66#[test]
77fn test_rpaths_to_flags() {
88 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 @@
1use crate::base::allocator_kind_for_codegen;
2
31use std::collections::hash_map::Entry::*;
42
53use rustc_ast::expand::allocator::{ALLOCATOR_METHODS, NO_ALLOC_SHIM_IS_UNSTABLE};
......@@ -12,14 +10,14 @@ use rustc_middle::middle::exported_symbols::{
1210 metadata_symbol_name, ExportedSymbol, SymbolExportInfo, SymbolExportKind, SymbolExportLevel,
1311};
1412use rustc_middle::query::LocalCrate;
15use rustc_middle::ty::Instance;
16use rustc_middle::ty::{self, SymbolName, TyCtxt};
17use rustc_middle::ty::{GenericArgKind, GenericArgsRef};
13use rustc_middle::ty::{self, GenericArgKind, GenericArgsRef, Instance, SymbolName, TyCtxt};
1814use rustc_middle::util::Providers;
1915use rustc_session::config::{CrateType, OomStrategy};
2016use rustc_target::spec::{SanitizerSet, TlsModel};
2117use tracing::debug;
2218
19use crate::base::allocator_kind_for_codegen;
20
2321pub fn threshold(tcx: TyCtxt<'_>) -> SymbolExportLevel {
2422 crates_export_threshold(tcx.crate_types())
2523}
compiler/rustc_codegen_ssa/src/back/write.rs+18-21
......@@ -1,12 +1,10 @@
1use super::link::{self, ensure_removed};
2use super::lto::{self, SerializedModule};
3use super::symbol_export::symbol_name_for_instance_in_crate;
1use std::any::Any;
2use std::marker::PhantomData;
3use std::path::{Path, PathBuf};
4use std::sync::mpsc::{channel, Receiver, Sender};
5use std::sync::Arc;
6use std::{fs, io, mem, str, thread};
47
5use crate::errors;
6use crate::traits::*;
7use crate::{
8 CachedModuleCodegen, CodegenResults, CompiledModule, CrateInfo, ModuleCodegen, ModuleKind,
9};
108use jobserver::{Acquired, Client};
119use rustc_ast::attr;
1210use rustc_data_structures::fx::{FxHashMap, FxIndexMap};
......@@ -30,26 +28,25 @@ use rustc_middle::bug;
3028use rustc_middle::dep_graph::{WorkProduct, WorkProductId};
3129use rustc_middle::middle::exported_symbols::SymbolExportInfo;
3230use rustc_middle::ty::TyCtxt;
33use rustc_session::config::{self, CrateType, Lto, OutFileName, OutputFilenames, OutputType};
34use rustc_session::config::{Passes, SwitchWithOptPath};
31use rustc_session::config::{
32 self, CrateType, Lto, OutFileName, OutputFilenames, OutputType, Passes, SwitchWithOptPath,
33};
3534use rustc_session::Session;
3635use rustc_span::source_map::SourceMap;
3736use rustc_span::symbol::sym;
3837use rustc_span::{BytePos, FileName, InnerSpan, Pos, Span};
3938use rustc_target::spec::{MergeFunctions, SanitizerSet};
39use tracing::debug;
4040
41use super::link::{self, ensure_removed};
42use super::lto::{self, SerializedModule};
43use super::symbol_export::symbol_name_for_instance_in_crate;
4144use crate::errors::ErrorCreatingRemarkDir;
42use std::any::Any;
43use std::fs;
44use std::io;
45use std::marker::PhantomData;
46use std::mem;
47use std::path::{Path, PathBuf};
48use std::str;
49use std::sync::mpsc::{channel, Receiver, Sender};
50use std::sync::Arc;
51use std::thread;
52use tracing::debug;
45use crate::traits::*;
46use crate::{
47 errors, CachedModuleCodegen, CodegenResults, CompiledModule, CrateInfo, ModuleCodegen,
48 ModuleKind,
49};
5350
5451const PRE_LTO_BC_EXT: &str = "pre-lto.bc";
5552
compiler/rustc_codegen_ssa/src/base.rs+20-23
......@@ -1,19 +1,8 @@
1use crate::assert_module_sources::CguReuse;
2use crate::back::link::are_upstream_rust_objects_already_included;
3use crate::back::metadata::create_compressed_metadata_file;
4use 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};
8use crate::common::{self, IntPredicate, RealPredicate, TypeKind};
9use crate::errors;
10use crate::meth;
11use crate::mir;
12use crate::mir::operand::OperandValue;
13use crate::mir::place::PlaceRef;
14use crate::traits::*;
15use crate::{CachedModuleCodegen, CompiledModule, CrateInfo, ModuleCodegen, ModuleKind};
1use std::cmp;
2use std::collections::BTreeSet;
3use std::time::{Duration, Instant};
164
5use itertools::Itertools;
176use rustc_ast::expand::allocator::{global_fn_name, AllocatorKind, ALLOCATOR_METHODS};
187use rustc_attr as attr;
198use rustc_data_structures::fx::{FxHashMap, FxIndexSet};
......@@ -26,9 +15,8 @@ use rustc_metadata::EncodedMetadata;
2615use rustc_middle::bug;
2716use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrs;
2817use rustc_middle::middle::debugger_visualizer::{DebuggerVisualizerFile, DebuggerVisualizerType};
29use rustc_middle::middle::exported_symbols;
3018use rustc_middle::middle::exported_symbols::SymbolExportKind;
31use rustc_middle::middle::lang_items;
19use rustc_middle::middle::{exported_symbols, lang_items};
3220use rustc_middle::mir::mono::{CodegenUnit, CodegenUnitNameBuilder, MonoItem};
3321use rustc_middle::mir::BinOp;
3422use rustc_middle::query::Providers;
......@@ -39,14 +27,23 @@ use rustc_session::Session;
3927use rustc_span::symbol::sym;
4028use rustc_span::{Symbol, DUMMY_SP};
4129use rustc_target::abi::FIRST_VARIANT;
42
43use std::cmp;
44use std::collections::BTreeSet;
45use std::time::{Duration, Instant};
46
47use itertools::Itertools;
4830use tracing::{debug, info};
4931
32use crate::assert_module_sources::CguReuse;
33use crate::back::link::are_upstream_rust_objects_already_included;
34use crate::back::metadata::create_compressed_metadata_file;
35use 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};
39use crate::common::{self, IntPredicate, RealPredicate, TypeKind};
40use crate::mir::operand::OperandValue;
41use crate::mir::place::PlaceRef;
42use crate::traits::*;
43use crate::{
44 errors, meth, mir, CachedModuleCodegen, CompiledModule, CrateInfo, ModuleCodegen, ModuleKind,
45};
46
5047pub fn bin_op_to_icmp_predicate(op: BinOp, signed: bool) -> IntPredicate {
5148 match op {
5249 BinOp::Eq => IntPredicate::IntEQ,
compiler/rustc_codegen_ssa/src/codegen_attrs.rs+6-3
......@@ -1,17 +1,20 @@
11use rustc_ast::{ast, attr, MetaItemKind, NestedMetaItem};
22use rustc_attr::{list_contains_name, InlineAttr, InstructionSetAttr, OptimizeAttr};
3use rustc_errors::{codes::*, struct_span_code_err, DiagMessage, SubdiagMessage};
3use rustc_errors::codes::*;
4use rustc_errors::{struct_span_code_err, DiagMessage, SubdiagMessage};
45use rustc_hir as hir;
56use rustc_hir::def::DefKind;
67use rustc_hir::def_id::{DefId, LocalDefId, LOCAL_CRATE};
7use rustc_hir::{lang_items, weak_lang_items::WEAK_LANG_ITEMS, LangItem};
8use rustc_hir::weak_lang_items::WEAK_LANG_ITEMS;
9use rustc_hir::{lang_items, LangItem};
810use rustc_middle::middle::codegen_fn_attrs::{
911 CodegenFnAttrFlags, CodegenFnAttrs, PatchableFunctionEntry,
1012};
1113use rustc_middle::mir::mono::Linkage;
1214use rustc_middle::query::Providers;
1315use rustc_middle::ty::{self as ty, TyCtxt};
14use rustc_session::{lint, parse::feature_err};
16use rustc_session::lint;
17use rustc_session::parse::feature_err;
1518use rustc_span::symbol::Ident;
1619use rustc_span::{sym, Span};
1720use rustc_target::spec::{abi, SanitizerSet};
compiler/rustc_codegen_ssa/src/common.rs+5-5
......@@ -1,10 +1,9 @@
11#![allow(non_camel_case_types)]
22
33use rustc_hir::LangItem;
4use rustc_middle::mir;
5use rustc_middle::ty::Instance;
6use rustc_middle::ty::{self, layout::TyAndLayout, TyCtxt};
7use rustc_middle::{bug, span_bug};
4use rustc_middle::ty::layout::TyAndLayout;
5use rustc_middle::ty::{self, Instance, TyCtxt};
6use rustc_middle::{bug, mir, span_bug};
87use rustc_span::Span;
98
109use crate::traits::*;
......@@ -106,9 +105,10 @@ pub enum TypeKind {
106105// for now we content ourselves with providing a no-op HashStable
107106// implementation for CGUs.
108107mod temp_stable_hash_impls {
109 use crate::ModuleCodegen;
110108 use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
111109
110 use crate::ModuleCodegen;
111
112112 impl<HCX, M> HashStable<HCX> for ModuleCodegen<M> {
113113 fn hash_stable(&self, _: &mut HCX, _: &mut StableHasher) {
114114 // do nothing
compiler/rustc_codegen_ssa/src/debuginfo/mod.rs+2-1
......@@ -1,4 +1,5 @@
1use rustc_middle::ty::{self, layout::TyAndLayout};
1use rustc_middle::ty::layout::TyAndLayout;
2use rustc_middle::ty::{self};
23use rustc_target::abi::Size;
34
45// 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 @@
1111// within the brackets).
1212// * `"` is treated as the start of a string.
1313
14use std::fmt::Write;
15
1416use rustc_data_structures::fx::FxHashSet;
1517use rustc_data_structures::stable_hasher::{Hash64, HashStable, StableHasher};
1618use rustc_hir::def_id::DefId;
......@@ -18,14 +20,13 @@ use rustc_hir::definitions::{DefPathData, DefPathDataName, DisambiguatedDefPathD
1820use rustc_hir::{CoroutineDesugaring, CoroutineKind, CoroutineSource, Mutability};
1921use rustc_middle::bug;
2022use rustc_middle::ty::layout::{IntegerExt, TyAndLayout};
21use rustc_middle::ty::{self, ExistentialProjection, ParamEnv, Ty, TyCtxt};
22use rustc_middle::ty::{GenericArgKind, GenericArgsRef};
23use rustc_middle::ty::{
24 self, ExistentialProjection, GenericArgKind, GenericArgsRef, ParamEnv, Ty, TyCtxt,
25};
2326use rustc_span::DUMMY_SP;
2427use rustc_target::abi::Integer;
2528use smallvec::SmallVec;
2629
27use std::fmt::Write;
28
2930use crate::debuginfo::wants_c_like_enum_debuginfo;
3031
3132/// 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 @@
11//! Errors emitted by codegen_ssa
22
3use crate::assert_module_sources::CguReuse;
4use crate::back::command::Command;
5use crate::fluent_generated as fluent;
3use std::borrow::Cow;
4use std::io::Error;
5use std::path::{Path, PathBuf};
6use std::process::ExitStatus;
7
8use rustc_errors::codes::*;
69use rustc_errors::{
7 codes::*, Diag, DiagArgValue, DiagCtxtHandle, Diagnostic, EmissionGuarantee, IntoDiagArg, Level,
10 Diag, DiagArgValue, DiagCtxtHandle, Diagnostic, EmissionGuarantee, IntoDiagArg, Level,
811};
912use rustc_macros::Diagnostic;
1013use rustc_middle::ty::layout::LayoutError;
1114use rustc_middle::ty::Ty;
1215use rustc_span::{Span, Symbol};
1316use rustc_type_ir::FloatTy;
14use std::borrow::Cow;
15use std::io::Error;
16use std::path::{Path, PathBuf};
17use std::process::ExitStatus;
17
18use crate::assert_module_sources::CguReuse;
19use crate::back::command::Command;
20use crate::fluent_generated as fluent;
1821
1922#[derive(Diagnostic)]
2023#[diag(codegen_ssa_incorrect_cgu_reuse_type)]
compiler/rustc_codegen_ssa/src/lib.rs+5-5
......@@ -17,9 +17,12 @@
1717//! The backend-agnostic functions of this crate use functions defined in various traits that
1818//! have to be implemented by each backend.
1919
20use std::collections::BTreeSet;
21use std::io;
22use std::path::{Path, PathBuf};
23
2024use rustc_ast as ast;
21use rustc_data_structures::fx::FxHashSet;
22use rustc_data_structures::fx::FxIndexMap;
25use rustc_data_structures::fx::{FxHashSet, FxIndexMap};
2326use rustc_data_structures::sync::Lrc;
2427use rustc_data_structures::unord::UnordMap;
2528use rustc_hir::def_id::CrateNum;
......@@ -36,9 +39,6 @@ use rustc_session::cstore::{self, CrateSource};
3639use rustc_session::utils::NativeLibKind;
3740use rustc_session::Session;
3841use rustc_span::symbol::Symbol;
39use std::collections::BTreeSet;
40use std::io;
41use std::path::{Path, PathBuf};
4242
4343pub mod assert_module_sources;
4444pub mod back;
compiler/rustc_codegen_ssa/src/meth.rs+2-2
......@@ -1,5 +1,3 @@
1use crate::traits::*;
2
31use rustc_middle::bug;
42use rustc_middle::ty::{self, GenericArgKind, Ty};
53use rustc_session::config::Lto;
......@@ -7,6 +5,8 @@ use rustc_symbol_mangling::typeid_for_trait_ref;
75use rustc_target::abi::call::FnAbi;
86use tracing::{debug, instrument};
97
8use crate::traits::*;
9
1010#[derive(Copy, Clone, Debug)]
1111pub struct VirtualIndex(u64);
1212
compiler/rustc_codegen_ssa/src/mir/analyze.rs+4-4
......@@ -1,18 +1,18 @@
11//! An analysis to determine which locals require allocas and
22//! which do not.
33
4use super::FunctionCx;
5use crate::traits::*;
64use rustc_data_structures::graph::dominators::Dominators;
75use rustc_index::bit_set::BitSet;
86use rustc_index::{IndexSlice, IndexVec};
9use rustc_middle::mir::traversal;
107use rustc_middle::mir::visit::{MutatingUseContext, NonMutatingUseContext, PlaceContext, Visitor};
11use rustc_middle::mir::{self, DefLocation, Location, TerminatorKind};
8use rustc_middle::mir::{self, traversal, DefLocation, Location, TerminatorKind};
129use rustc_middle::ty::layout::{HasTyCtxt, LayoutOf};
1310use rustc_middle::{bug, span_bug};
1411use tracing::debug;
1512
13use super::FunctionCx;
14use crate::traits::*;
15
1616pub fn non_ssa_locals<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
1717 fx: &FunctionCx<'a, 'tcx, Bx>,
1818) -> BitSet<mir::Local> {
compiler/rustc_codegen_ssa/src/mir/block.rs+12-13
......@@ -1,14 +1,4 @@
1use super::operand::OperandRef;
2use super::operand::OperandValue::{Immediate, Pair, Ref, ZeroSized};
3use super::place::{PlaceRef, PlaceValue};
4use super::{CachedLlbb, FunctionCx, LocalRef};
5
6use crate::base::{self, is_call_from_compiler_builtins_to_upstream_monomorphization};
7use crate::common::{self, IntPredicate};
8use crate::errors::CompilerBuiltinsCannotCall;
9use crate::meth;
10use crate::traits::*;
11use crate::MemFlags;
1use std::cmp;
122
133use rustc_ast as ast;
144use rustc_ast::{InlineAsmOptions, InlineAsmTemplatePiece};
......@@ -19,13 +9,22 @@ use rustc_middle::ty::print::{with_no_trimmed_paths, with_no_visible_paths};
199use rustc_middle::ty::{self, Instance, Ty};
2010use rustc_middle::{bug, span_bug};
2111use rustc_session::config::OptLevel;
22use rustc_span::{source_map::Spanned, sym, Span};
12use rustc_span::source_map::Spanned;
13use rustc_span::{sym, Span};
2314use rustc_target::abi::call::{ArgAbi, FnAbi, PassMode, Reg};
2415use rustc_target::abi::{self, HasDataLayout, WrappingRange};
2516use rustc_target::spec::abi::Abi;
2617use tracing::{debug, info};
2718
28use std::cmp;
19use super::operand::OperandRef;
20use super::operand::OperandValue::{Immediate, Pair, Ref, ZeroSized};
21use super::place::{PlaceRef, PlaceValue};
22use super::{CachedLlbb, FunctionCx, LocalRef};
23use crate::base::{self, is_call_from_compiler_builtins_to_upstream_monomorphization};
24use crate::common::{self, IntPredicate};
25use crate::errors::CompilerBuiltinsCannotCall;
26use crate::traits::*;
27use crate::{meth, MemFlags};
2928
3029// Indicates if we are in the middle of merging a BB's successor into it. This
3130// 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 @@
1use crate::errors;
2use crate::mir::operand::OperandRef;
3use crate::traits::*;
4use rustc_middle::mir;
51use rustc_middle::mir::interpret::ErrorHandled;
62use rustc_middle::ty::layout::HasTyCtxt;
73use rustc_middle::ty::{self, Ty};
8use rustc_middle::{bug, span_bug};
4use rustc_middle::{bug, mir, span_bug};
95use rustc_target::abi::Abi;
106
117use super::FunctionCx;
8use crate::errors;
9use crate::mir::operand::OperandRef;
10use crate::traits::*;
1211
1312impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
1413 pub fn eval_mir_constant_to_operand(
compiler/rustc_codegen_ssa/src/mir/coverageinfo.rs+1-2
......@@ -1,9 +1,8 @@
1use crate::traits::*;
2
31use rustc_middle::mir::coverage::CoverageKind;
42use rustc_middle::mir::SourceScope;
53
64use super::FunctionCx;
5use crate::traits::*;
76
87impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
98 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 @@
1use crate::traits::*;
1use std::ops::Range;
2
23use rustc_data_structures::fx::FxHashMap;
34use rustc_index::IndexVec;
4use rustc_middle::bug;
55use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
6use rustc_middle::mir;
7use rustc_middle::ty;
86use rustc_middle::ty::layout::{LayoutOf, TyAndLayout};
9use rustc_middle::ty::Instance;
10use rustc_middle::ty::Ty;
7use rustc_middle::ty::{Instance, Ty};
8use rustc_middle::{bug, mir, ty};
119use rustc_session::config::DebugInfo;
1210use rustc_span::symbol::{kw, Symbol};
1311use rustc_span::{hygiene, BytePos, Span};
......@@ -16,8 +14,7 @@ use rustc_target::abi::{Abi, FieldIdx, FieldsShape, Size, VariantIdx};
1614use super::operand::{OperandRef, OperandValue};
1715use super::place::{PlaceRef, PlaceValue};
1816use super::{FunctionCx, LocalRef};
19
20use std::ops::Range;
17use crate::traits::*;
2118
2219pub struct FunctionDebugContext<'tcx, S, L> {
2320 /// Maps from source code to the corresponding debug info scope.
compiler/rustc_codegen_ssa/src/mir/intrinsic.rs+8-13
......@@ -1,21 +1,16 @@
1use rustc_middle::ty::{self, Ty, TyCtxt};
2use rustc_middle::{bug, span_bug};
3use rustc_session::config::OptLevel;
4use rustc_span::{sym, Span};
5use rustc_target::abi::call::{FnAbi, PassMode};
6use rustc_target::abi::WrappingRange;
7
18use super::operand::OperandRef;
29use super::place::PlaceRef;
310use super::FunctionCx;
4use crate::errors;
511use crate::errors::InvalidMonomorphization;
6use crate::meth;
7use crate::size_of_val;
812use crate::traits::*;
9use crate::MemFlags;
10
11use rustc_middle::ty::{self, Ty, TyCtxt};
12use rustc_middle::{bug, span_bug};
13use rustc_session::config::OptLevel;
14use rustc_span::{sym, Span};
15use rustc_target::abi::{
16 call::{FnAbi, PassMode},
17 WrappingRange,
18};
13use crate::{errors, meth, size_of_val, MemFlags};
1914
2015fn copy_intrinsic<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
2116 bx: &mut Bx,
compiler/rustc_codegen_ssa/src/mir/locals.rs+5-3
......@@ -2,14 +2,16 @@
22//! be careful wrt to subtyping. To deal with this we only allow updates by using
33//! `FunctionCx::overwrite_local` which handles it automatically.
44
5use crate::mir::{FunctionCx, LocalRef};
6use crate::traits::BuilderMethods;
5use std::ops::{Index, IndexMut};
6
77use rustc_index::IndexVec;
88use rustc_middle::mir;
99use rustc_middle::ty::print::with_no_trimmed_paths;
10use std::ops::{Index, IndexMut};
1110use tracing::{debug, warn};
1211
12use crate::mir::{FunctionCx, LocalRef};
13use crate::traits::BuilderMethods;
14
1315pub(super) struct Locals<'tcx, V> {
1416 values: IndexVec<mir::Local, LocalRef<'tcx, V>>,
1517}
compiler/rustc_codegen_ssa/src/mir/mod.rs+6-7
......@@ -1,18 +1,17 @@
1use crate::base;
2use crate::traits::*;
1use std::iter;
2
33use rustc_index::bit_set::BitSet;
44use rustc_index::IndexVec;
55use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
6use rustc_middle::mir;
7use rustc_middle::mir::traversal;
8use rustc_middle::mir::UnwindTerminateReason;
6use rustc_middle::mir::{traversal, UnwindTerminateReason};
97use rustc_middle::ty::layout::{FnAbiOf, HasTyCtxt, TyAndLayout};
108use rustc_middle::ty::{self, Instance, Ty, TyCtxt, TypeFoldable, TypeVisitableExt};
11use rustc_middle::{bug, span_bug};
9use rustc_middle::{bug, mir, span_bug};
1210use rustc_target::abi::call::{FnAbi, PassMode};
1311use tracing::{debug, instrument};
1412
15use std::iter;
13use crate::base;
14use crate::traits::*;
1615
1716mod analyze;
1817mod block;
compiler/rustc_codegen_ssa/src/mir/operand.rs+8-11
......@@ -1,23 +1,20 @@
1use super::place::{PlaceRef, PlaceValue};
2use super::{FunctionCx, LocalRef};
3
4use crate::size_of_val;
5use crate::traits::*;
6use crate::MemFlags;
1use std::fmt;
72
3use arrayvec::ArrayVec;
4use either::Either;
85use rustc_middle::bug;
96use rustc_middle::mir::interpret::{alloc_range, Pointer, Scalar};
107use rustc_middle::mir::{self, ConstValue};
118use rustc_middle::ty::layout::{LayoutOf, TyAndLayout};
129use rustc_middle::ty::Ty;
1310use rustc_target::abi::{self, Abi, Align, Size};
14
15use std::fmt;
16
17use arrayvec::ArrayVec;
18use either::Either;
1911use tracing::debug;
2012
13use super::place::{PlaceRef, PlaceValue};
14use super::{FunctionCx, LocalRef};
15use crate::traits::*;
16use crate::{size_of_val, MemFlags};
17
2118/// The representation of a Rust value. The enum variant is in fact
2219/// uniquely determined by the value's type, but is kept as a
2320/// safety check.
compiler/rustc_codegen_ssa/src/mir/place.rs+9-10
......@@ -1,19 +1,18 @@
1use rustc_middle::mir::tcx::PlaceTy;
2use rustc_middle::ty::layout::{HasTyCtxt, LayoutOf, TyAndLayout};
3use rustc_middle::ty::{self, Ty};
4use rustc_middle::{bug, mir};
5use rustc_target::abi::{
6 Align, FieldsShape, Int, Pointer, Size, TagEncoding, VariantIdx, Variants,
7};
8use tracing::{debug, instrument};
9
110use super::operand::OperandValue;
211use super::{FunctionCx, LocalRef};
3
412use crate::common::IntPredicate;
513use crate::size_of_val;
614use crate::traits::*;
715
8use rustc_middle::bug;
9use rustc_middle::mir;
10use rustc_middle::mir::tcx::PlaceTy;
11use rustc_middle::ty::layout::{HasTyCtxt, LayoutOf, TyAndLayout};
12use rustc_middle::ty::{self, Ty};
13use rustc_target::abi::{Align, FieldsShape, Int, Pointer, Size, TagEncoding};
14use rustc_target::abi::{VariantIdx, Variants};
15use tracing::{debug, instrument};
16
1716/// The location and extra runtime properties of the place.
1817///
1918/// Typically found in a [`PlaceRef`] or an [`OperandValue::Ref`].
compiler/rustc_codegen_ssa/src/mir/rvalue.rs+11-14
......@@ -1,23 +1,20 @@
1use super::operand::{OperandRef, OperandValue};
2use super::place::PlaceRef;
3use super::{FunctionCx, LocalRef};
4
5use crate::base;
6use crate::common::IntPredicate;
7use crate::traits::*;
8use crate::MemFlags;
9
10use rustc_middle::mir;
1use arrayvec::ArrayVec;
2use rustc_middle::ty::adjustment::PointerCoercion;
113use rustc_middle::ty::layout::{HasTyCtxt, LayoutOf, TyAndLayout};
12use rustc_middle::ty::{self, adjustment::PointerCoercion, Instance, Ty, TyCtxt};
13use rustc_middle::{bug, span_bug};
4use rustc_middle::ty::{self, Instance, Ty, TyCtxt};
5use rustc_middle::{bug, mir, span_bug};
146use rustc_session::config::OptLevel;
157use rustc_span::{Span, DUMMY_SP};
168use rustc_target::abi::{self, FieldIdx, FIRST_VARIANT};
17
18use arrayvec::ArrayVec;
199use tracing::{debug, instrument};
2010
11use super::operand::{OperandRef, OperandValue};
12use super::place::PlaceRef;
13use super::{FunctionCx, LocalRef};
14use crate::common::IntPredicate;
15use crate::traits::*;
16use crate::{base, MemFlags};
17
2118impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
2219 #[instrument(level = "trace", skip(self, bx))]
2320 pub fn codegen_rvalue(
compiler/rustc_codegen_ssa/src/mir/statement.rs+1-2
......@@ -3,8 +3,7 @@ use rustc_middle::span_bug;
33use rustc_session::config::OptLevel;
44use tracing::instrument;
55
6use super::FunctionCx;
7use super::LocalRef;
6use super::{FunctionCx, LocalRef};
87use crate::traits::*;
98
109impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
compiler/rustc_codegen_ssa/src/mono_item.rs+5-7
......@@ -1,16 +1,14 @@
1use crate::base;
2use crate::common;
3use crate::traits::*;
41use rustc_hir as hir;
52use rustc_middle::mir::interpret::ErrorHandled;
6use rustc_middle::mir::mono::MonoItem;
7use rustc_middle::mir::mono::{Linkage, Visibility};
8use rustc_middle::span_bug;
9use rustc_middle::ty;
3use rustc_middle::mir::mono::{Linkage, MonoItem, Visibility};
104use rustc_middle::ty::layout::{HasTyCtxt, LayoutOf};
115use rustc_middle::ty::Instance;
6use rustc_middle::{span_bug, ty};
127use tracing::debug;
138
9use crate::traits::*;
10use crate::{base, common};
11
1412pub trait MonoItemExt<'a, 'tcx> {
1513 fn define<Bx: BuilderMethods<'a, 'tcx>>(&self, cx: &'a Bx::CodegenCx);
1614 fn predefine<Bx: BuilderMethods<'a, 'tcx>>(
compiler/rustc_codegen_ssa/src/size_of_val.rs+4-4
......@@ -1,9 +1,5 @@
11//! Computing the size and alignment of a value.
22
3use crate::common;
4use crate::common::IntPredicate;
5use crate::meth;
6use crate::traits::*;
73use rustc_hir::LangItem;
84use rustc_middle::bug;
95use rustc_middle::ty::print::{with_no_trimmed_paths, with_no_visible_paths};
......@@ -11,6 +7,10 @@ use rustc_middle::ty::{self, Ty};
117use rustc_target::abi::WrappingRange;
128use tracing::{debug, trace};
139
10use crate::common::IntPredicate;
11use crate::traits::*;
12use crate::{common, meth};
13
1414pub fn size_and_align_of_dst<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
1515 bx: &mut Bx,
1616 t: Ty<'tcx>,
compiler/rustc_codegen_ssa/src/target_features.rs+4-6
......@@ -1,21 +1,19 @@
1use crate::errors;
21use rustc_ast::ast;
32use rustc_attr::InstructionSetAttr;
43use rustc_data_structures::fx::FxIndexSet;
54use rustc_data_structures::unord::UnordMap;
65use rustc_errors::Applicability;
76use rustc_hir::def::DefKind;
8use rustc_hir::def_id::DefId;
9use rustc_hir::def_id::LocalDefId;
10use rustc_hir::def_id::LOCAL_CRATE;
7use rustc_hir::def_id::{DefId, LocalDefId, LOCAL_CRATE};
118use rustc_middle::bug;
129use rustc_middle::query::Providers;
1310use rustc_middle::ty::TyCtxt;
1411use rustc_session::parse::feature_err;
15use rustc_span::symbol::sym;
16use rustc_span::symbol::Symbol;
12use rustc_span::symbol::{sym, Symbol};
1713use rustc_span::Span;
1814
15use crate::errors;
16
1917pub fn from_target_feature(
2018 tcx: TyCtxt<'_>,
2119 attr: &ast::Attribute,
compiler/rustc_codegen_ssa/src/traits/asm.rs+4-3
......@@ -1,12 +1,13 @@
1use super::BackendTypes;
2use crate::mir::operand::OperandRef;
3use crate::mir::place::PlaceRef;
41use rustc_ast::{InlineAsmOptions, InlineAsmTemplatePiece};
52use rustc_hir::def_id::DefId;
63use rustc_middle::ty::Instance;
74use rustc_span::Span;
85use rustc_target::asm::InlineAsmRegOrRegClass;
96
7use super::BackendTypes;
8use crate::mir::operand::OperandRef;
9use crate::mir::place::PlaceRef;
10
1011#[derive(Debug)]
1112pub enum InlineAsmOperandRef<'tcx, B: BackendTypes + ?Sized> {
1213 In {
compiler/rustc_codegen_ssa/src/traits/backend.rs+7-9
......@@ -1,10 +1,5 @@
11use std::any::Any;
22
3use super::write::WriteBackendMethods;
4use super::CodegenObject;
5use crate::back::write::TargetMachineFactoryFn;
6use crate::{CodegenResults, ModuleCodegen};
7
83use rustc_ast::expand::allocator::AllocatorKind;
94use rustc_data_structures::fx::FxIndexMap;
105use rustc_data_structures::sync::{DynSend, DynSync};
......@@ -15,13 +10,16 @@ use rustc_middle::dep_graph::{WorkProduct, WorkProductId};
1510use rustc_middle::ty::layout::{FnAbiOf, HasTyCtxt, LayoutOf, TyAndLayout};
1611use rustc_middle::ty::{Ty, TyCtxt};
1712use rustc_middle::util::Providers;
18use rustc_session::{
19 config::{self, OutputFilenames, PrintRequest},
20 Session,
21};
13use rustc_session::config::{self, OutputFilenames, PrintRequest};
14use rustc_session::Session;
2215use rustc_span::symbol::Symbol;
2316use rustc_target::abi::call::FnAbi;
2417
18use super::write::WriteBackendMethods;
19use super::CodegenObject;
20use crate::back::write::TargetMachineFactoryFn;
21use crate::{CodegenResults, ModuleCodegen};
22
2523pub trait BackendTypes {
2624 type Value: CodegenObject;
2725 type Function: CodegenObject;
compiler/rustc_codegen_ssa/src/traits/builder.rs+9-10
......@@ -1,3 +1,12 @@
1use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrs;
2use rustc_middle::ty::layout::{HasParamEnv, TyAndLayout};
3use rustc_middle::ty::{Instance, Ty};
4use rustc_session::config::OptLevel;
5use rustc_span::Span;
6use rustc_target::abi::call::FnAbi;
7use rustc_target::abi::{Abi, Align, Scalar, Size, WrappingRange};
8use rustc_target::spec::HasTargetSpec;
9
110use super::abi::AbiBuilderMethods;
211use super::asm::AsmBuilderMethods;
312use super::consts::ConstMethods;
......@@ -7,7 +16,6 @@ use super::intrinsic::IntrinsicCallMethods;
716use super::misc::MiscMethods;
817use super::type_::{ArgAbiMethods, BaseTypeMethods, LayoutTypeMethods};
918use super::{HasCodegen, StaticBuilderMethods};
10
1119use crate::common::{
1220 AtomicOrdering, AtomicRmwBinOp, IntPredicate, RealPredicate, SynchronizationScope, TypeKind,
1321};
......@@ -15,15 +23,6 @@ use crate::mir::operand::{OperandRef, OperandValue};
1523use crate::mir::place::{PlaceRef, PlaceValue};
1624use crate::MemFlags;
1725
18use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrs;
19use rustc_middle::ty::layout::{HasParamEnv, TyAndLayout};
20use rustc_middle::ty::{Instance, Ty};
21use rustc_session::config::OptLevel;
22use rustc_span::Span;
23use rustc_target::abi::call::FnAbi;
24use rustc_target::abi::{Abi, Align, Scalar, Size, WrappingRange};
25use rustc_target::spec::HasTargetSpec;
26
2726#[derive(Copy, Clone)]
2827pub enum OverflowOp {
2928 Add,
compiler/rustc_codegen_ssa/src/traits/consts.rs+2-1
......@@ -1,7 +1,8 @@
1use super::BackendTypes;
21use rustc_middle::mir::interpret::{ConstAllocation, Scalar};
32use rustc_target::abi;
43
4use super::BackendTypes;
5
56pub trait ConstMethods<'tcx>: BackendTypes {
67 // Constant constructors
78 fn const_null(&self, t: Self::Type) -> Self::Value;
compiler/rustc_codegen_ssa/src/traits/coverageinfo.rs+2-1
......@@ -1,7 +1,8 @@
1use super::BackendTypes;
21use rustc_middle::mir::coverage::CoverageKind;
32use rustc_middle::ty::Instance;
43
4use super::BackendTypes;
5
56pub trait CoverageInfoBuilderMethods<'tcx>: BackendTypes {
67 /// Performs any start-of-function codegen needed for coverage instrumentation.
78 ///
compiler/rustc_codegen_ssa/src/traits/debuginfo.rs+4-3
......@@ -1,12 +1,13 @@
1use super::BackendTypes;
2use crate::mir::debuginfo::{FunctionDebugContext, VariableKind};
1use std::ops::Range;
2
33use rustc_middle::mir;
44use rustc_middle::ty::{Instance, PolyExistentialTraitRef, Ty};
55use rustc_span::{SourceFile, Span, Symbol};
66use rustc_target::abi::call::FnAbi;
77use rustc_target::abi::Size;
88
9use std::ops::Range;
9use super::BackendTypes;
10use crate::mir::debuginfo::{FunctionDebugContext, VariableKind};
1011
1112pub trait DebugInfoMethods<'tcx>: BackendTypes {
1213 fn create_vtable_debuginfo(
compiler/rustc_codegen_ssa/src/traits/declare.rs+2-1
......@@ -1,8 +1,9 @@
1use super::BackendTypes;
21use rustc_hir::def_id::DefId;
32use rustc_middle::mir::mono::{Linkage, Visibility};
43use rustc_middle::ty::Instance;
54
5use super::BackendTypes;
6
67pub trait PreDefineMethods<'tcx>: BackendTypes {
78 fn predefine_static(
89 &self,
compiler/rustc_codegen_ssa/src/traits/intrinsic.rs+3-2
......@@ -1,9 +1,10 @@
1use super::BackendTypes;
2use crate::mir::operand::OperandRef;
31use rustc_middle::ty::{self, Ty};
42use rustc_span::Span;
53use rustc_target::abi::call::FnAbi;
64
5use super::BackendTypes;
6use crate::mir::operand::OperandRef;
7
78pub trait IntrinsicCallMethods<'tcx>: BackendTypes {
89 /// Remember to add all intrinsics here, in `compiler/rustc_hir_analysis/src/check/mod.rs`,
910 /// 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 @@
1use super::BackendTypes;
1use std::cell::RefCell;
2
23use rustc_data_structures::fx::FxHashMap;
34use rustc_middle::mir::mono::CodegenUnit;
45use rustc_middle::ty::{self, Instance, Ty};
56use rustc_session::Session;
6use std::cell::RefCell;
7
8use super::BackendTypes;
79
810pub trait MiscMethods<'tcx>: BackendTypes {
911 fn vtables(
compiler/rustc_codegen_ssa/src/traits/mod.rs+5-5
......@@ -28,6 +28,11 @@ mod statics;
2828mod type_;
2929mod write;
3030
31use std::fmt;
32
33use rustc_middle::ty::layout::{HasParamEnv, HasTyCtxt};
34use rustc_target::spec::HasTargetSpec;
35
3136pub use self::abi::AbiBuilderMethods;
3237pub use self::asm::{AsmBuilderMethods, AsmMethods, GlobalAsmOperandRef, InlineAsmOperandRef};
3338pub use self::backend::{Backend, BackendTypes, CodegenBackend, ExtraBackendMethods};
......@@ -45,11 +50,6 @@ pub use self::type_::{
4550};
4651pub use self::write::{ModuleBufferMethods, ThinBufferMethods, WriteBackendMethods};
4752
48use rustc_middle::ty::layout::{HasParamEnv, HasTyCtxt};
49use rustc_target::spec::HasTargetSpec;
50
51use std::fmt;
52
5353pub trait CodegenObject: Copy + PartialEq + fmt::Debug {}
5454impl<T: Copy + PartialEq + fmt::Debug> CodegenObject for T {}
5555
compiler/rustc_codegen_ssa/src/traits/statics.rs+2-1
......@@ -1,7 +1,8 @@
1use super::BackendTypes;
21use rustc_hir::def_id::DefId;
32use rustc_target::abi::Align;
43
4use super::BackendTypes;
5
56pub trait StaticMethods: BackendTypes {
67 fn static_addr_of(&self, cv: Self::Value, align: Align, kind: Option<&str>) -> Self::Value;
78 fn codegen_static(&self, def_id: DefId);
compiler/rustc_codegen_ssa/src/traits/type_.rs+5-5
......@@ -1,14 +1,14 @@
1use super::misc::MiscMethods;
2use super::Backend;
3use super::HasCodegen;
4use crate::common::TypeKind;
5use crate::mir::place::PlaceRef;
61use rustc_middle::bug;
72use rustc_middle::ty::layout::TyAndLayout;
83use rustc_middle::ty::{self, Ty};
94use rustc_target::abi::call::{ArgAbi, CastTarget, FnAbi, Reg};
105use rustc_target::abi::{AddressSpace, Float, Integer};
116
7use super::misc::MiscMethods;
8use super::{Backend, HasCodegen};
9use crate::common::TypeKind;
10use crate::mir::place::PlaceRef;
11
1212// This depends on `Backend` and not `BackendTypes`, because consumers will probably want to use
1313// `LayoutOf` or `HasTyCtxt`. This way, they don't have to add a constraint on it themselves.
1414pub trait BaseTypeMethods<'tcx>: Backend<'tcx> {
compiler/rustc_codegen_ssa/src/traits/write.rs+3-3
......@@ -1,10 +1,10 @@
1use rustc_errors::{DiagCtxtHandle, FatalError};
2use rustc_middle::dep_graph::WorkProduct;
3
14use crate::back::lto::{LtoModuleCodegen, SerializedModule, ThinModule};
25use crate::back::write::{CodegenContext, FatLtoInput, ModuleConfig};
36use crate::{CompiledModule, ModuleCodegen};
47
5use rustc_errors::{DiagCtxtHandle, FatalError};
6use rustc_middle::dep_graph::WorkProduct;
7
88pub trait WriteBackendMethods: 'static + Sized + Clone {
99 type Module: Send + Sync;
1010 type TargetMachine;
compiler/rustc_const_eval/src/check_consts/check.rs+5-6
......@@ -1,5 +1,8 @@
11//! The `Visitor` responsible for actually checking a `mir::Body` for invalid operations.
22
3use std::mem;
4use std::ops::Deref;
5
36use rustc_errors::{Diag, ErrorGuaranteed};
47use rustc_hir::def_id::DefId;
58use rustc_hir::{self as hir, LangItem};
......@@ -9,17 +12,13 @@ use rustc_infer::traits::ObligationCause;
912use rustc_middle::mir::visit::{MutatingUseContext, NonMutatingUseContext, PlaceContext, Visitor};
1013use rustc_middle::mir::*;
1114use rustc_middle::span_bug;
12use rustc_middle::ty::{self, adjustment::PointerCoercion, Ty, TyCtxt};
13use rustc_middle::ty::{Instance, InstanceKind, TypeVisitableExt};
15use rustc_middle::ty::adjustment::PointerCoercion;
16use rustc_middle::ty::{self, Instance, InstanceKind, Ty, TyCtxt, TypeVisitableExt};
1417use rustc_mir_dataflow::Analysis;
1518use rustc_span::{sym, Span, Symbol, DUMMY_SP};
1619use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
1720use rustc_trait_selection::traits::{self, ObligationCauseCode, ObligationCtxt};
1821use rustc_type_ir::visit::{TypeSuperVisitable, TypeVisitor};
19
20use std::mem;
21use std::ops::Deref;
22
2322use tracing::{debug, instrument, trace};
2423
2524use super::ops::{self, NonConstOp, Status};
compiler/rustc_const_eval/src/check_consts/mod.rs+2-4
......@@ -4,14 +4,12 @@
44//! has interior mutability or needs to be dropped, as well as the visitor that emits errors when
55//! it finds operations that are invalid in a certain context.
66
7use rustc_attr as attr;
87use rustc_errors::DiagCtxtHandle;
9use rustc_hir as hir;
108use rustc_hir::def_id::{DefId, LocalDefId};
11use rustc_middle::bug;
12use rustc_middle::mir;
139use rustc_middle::ty::{self, PolyFnSig, TyCtxt};
10use rustc_middle::{bug, mir};
1411use rustc_span::Symbol;
12use {rustc_attr as attr, rustc_hir as hir};
1513
1614pub use self::qualifs::Qualif;
1715
compiler/rustc_const_eval/src/check_consts/ops.rs+2-1
......@@ -2,7 +2,8 @@
22
33use hir::def_id::LocalDefId;
44use hir::{ConstContext, LangItem};
5use rustc_errors::{codes::*, Diag};
5use rustc_errors::codes::*;
6use rustc_errors::Diag;
67use rustc_hir as hir;
78use rustc_hir::def_id::DefId;
89use rustc_infer::infer::TyCtxtInferExt;
compiler/rustc_const_eval/src/check_consts/post_drop_elaboration.rs+2-1
......@@ -1,7 +1,8 @@
11use rustc_middle::mir::visit::Visitor;
22use rustc_middle::mir::{self, BasicBlock, Location};
33use rustc_middle::ty::{Ty, TyCtxt};
4use rustc_span::{symbol::sym, Span};
4use rustc_span::symbol::sym;
5use rustc_span::Span;
56use tracing::trace;
67
78use super::check::Qualifs;
compiler/rustc_const_eval/src/check_consts/qualifs.rs+1-2
......@@ -5,11 +5,10 @@
55use rustc_errors::ErrorGuaranteed;
66use rustc_hir::LangItem;
77use rustc_infer::infer::TyCtxtInferExt;
8use rustc_middle::bug;
9use rustc_middle::mir;
108use rustc_middle::mir::*;
119use rustc_middle::traits::BuiltinImplSource;
1210use rustc_middle::ty::{self, AdtDef, GenericArgsRef, Ty};
11use rustc_middle::{bug, mir};
1312use rustc_trait_selection::traits::{
1413 ImplSource, Obligation, ObligationCause, ObligationCtxt, SelectionContext,
1514};
compiler/rustc_const_eval/src/check_consts/resolver.rs+4-5
......@@ -2,17 +2,16 @@
22//!
33//! This contains the dataflow analysis used to track `Qualif`s on complex control-flow graphs.
44
5use std::fmt;
6use std::marker::PhantomData;
7
58use rustc_index::bit_set::BitSet;
69use rustc_middle::mir::visit::Visitor;
710use rustc_middle::mir::{
811 self, BasicBlock, CallReturnPlaces, Local, Location, Statement, StatementKind, TerminatorEdges,
912};
1013use rustc_mir_dataflow::fmt::DebugWithContext;
11use rustc_mir_dataflow::JoinSemiLattice;
12use rustc_mir_dataflow::{Analysis, AnalysisDomain};
13
14use std::fmt;
15use std::marker::PhantomData;
14use rustc_mir_dataflow::{Analysis, AnalysisDomain, JoinSemiLattice};
1615
1716use super::{qualifs, ConstCx, Qualif};
1817
compiler/rustc_const_eval/src/const_eval/dummy_machine.rs+5-5
......@@ -1,14 +1,14 @@
1use crate::interpret::{
2 self, throw_machine_stop, HasStaticRootDefId, ImmTy, Immediate, InterpCx, PointerArithmetic,
3};
41use rustc_middle::mir::interpret::{AllocId, ConstAllocation, InterpResult};
52use rustc_middle::mir::*;
63use rustc_middle::query::TyCtxtAt;
7use rustc_middle::ty;
84use rustc_middle::ty::layout::TyAndLayout;
9use rustc_middle::{bug, span_bug};
5use rustc_middle::{bug, span_bug, ty};
106use rustc_span::def_id::DefId;
117
8use crate::interpret::{
9 self, throw_machine_stop, HasStaticRootDefId, ImmTy, Immediate, InterpCx, PointerArithmetic,
10};
11
1212/// Macro for machine-specific `InterpError` without allocation.
1313/// (These will never be shown to the user, but they help diagnose ICEs.)
1414pub 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
44use rustc_middle::mir::interpret::{Provenance, ReportedErrorInfo};
55use rustc_middle::mir::AssertKind;
66use rustc_middle::query::TyCtxtAt;
7use rustc_middle::ty::TyCtxt;
8use rustc_middle::ty::{layout::LayoutError, ConstInt};
7use rustc_middle::ty::layout::LayoutError;
8use rustc_middle::ty::{ConstInt, TyCtxt};
99use rustc_span::{Span, Symbol};
1010
1111use super::CompileTimeMachine;
1212use crate::errors::{self, FrameNote, ReportErrorExt};
13use crate::interpret::{err_inval, err_machine_stop};
14use crate::interpret::{ErrorHandled, Frame, InterpError, InterpErrorInfo, MachineStopType};
13use crate::interpret::{
14 err_inval, err_machine_stop, ErrorHandled, Frame, InterpError, InterpErrorInfo, MachineStopType,
15};
1516
1617/// The CTFE machine has some custom error kinds.
1718#[derive(Clone, Debug)]
......@@ -25,8 +26,9 @@ pub enum ConstEvalErrKind {
2526
2627impl MachineStopType for ConstEvalErrKind {
2728 fn diagnostic_message(&self) -> DiagMessage {
28 use crate::fluent_generated::*;
2929 use ConstEvalErrKind::*;
30
31 use crate::fluent_generated::*;
3032 match self {
3133 ConstAccessesMutGlobal => const_eval_const_accesses_mut_global,
3234 ModifiedGlobal => const_eval_modified_global,
compiler/rustc_const_eval/src/const_eval/eval_queries.rs+5-8
......@@ -1,8 +1,6 @@
11use std::sync::atomic::Ordering::Relaxed;
22
33use either::{Left, Right};
4use tracing::{debug, instrument, trace};
5
64use rustc_hir::def::DefKind;
75use rustc_middle::bug;
86use rustc_middle::mir::interpret::{AllocId, ErrorHandled, InterpErrorInfo};
......@@ -16,17 +14,16 @@ use rustc_session::lint;
1614use rustc_span::def_id::LocalDefId;
1715use rustc_span::{Span, DUMMY_SP};
1816use rustc_target::abi::{self, Abi};
17use tracing::{debug, instrument, trace};
1918
2019use super::{CanAccessMutGlobal, CompileTimeInterpCx, CompileTimeMachine};
2120use crate::const_eval::CheckAlignment;
22use crate::errors::ConstEvalError;
23use crate::errors::{self, DanglingPtrInFinal};
21use crate::errors::{self, ConstEvalError, DanglingPtrInFinal};
2422use 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,
2826};
29use crate::interpret::{eval_nullary_intrinsic, throw_exhaust, InternResult};
3027use crate::CTRL_C_RECEIVED;
3128
3229// Returns a pointer to where the result lives
compiler/rustc_const_eval/src/const_eval/fn_queries.rs+1-2
......@@ -1,10 +1,9 @@
1use rustc_attr as attr;
2use rustc_hir as hir;
31use rustc_hir::def::DefKind;
42use rustc_hir::def_id::{DefId, LocalDefId};
53use rustc_middle::query::Providers;
64use rustc_middle::ty::TyCtxt;
75use rustc_span::symbol::Symbol;
6use {rustc_attr as attr, rustc_hir as hir};
87
98/// Whether the `def_id` is an unstable const fn and what feature gate(s) are necessary to enable
109/// it.
compiler/rustc_const_eval/src/const_eval/machine.rs+7-11
......@@ -4,18 +4,14 @@ use std::hash::Hash;
44use std::ops::ControlFlow;
55
66use rustc_ast::Mutability;
7use rustc_data_structures::fx::FxIndexMap;
8use rustc_data_structures::fx::IndexEntry;
9use rustc_hir::def_id::DefId;
10use rustc_hir::def_id::LocalDefId;
11use rustc_hir::LangItem;
12use rustc_hir::{self as hir, CRATE_HIR_ID};
13use rustc_middle::bug;
14use rustc_middle::mir;
7use rustc_data_structures::fx::{FxIndexMap, IndexEntry};
8use rustc_hir::def_id::{DefId, LocalDefId};
9use rustc_hir::{self as hir, LangItem, CRATE_HIR_ID};
1510use rustc_middle::mir::AssertMessage;
1611use rustc_middle::query::TyCtxtAt;
1712use rustc_middle::ty::layout::{FnAbiOf, TyAndLayout};
1813use rustc_middle::ty::{self, TyCtxt};
14use rustc_middle::{bug, mir};
1915use rustc_session::lint::builtin::WRITES_THROUGH_IMMUTABLE_POINTER;
2016use rustc_span::symbol::{sym, Symbol};
2117use rustc_span::Span;
......@@ -23,6 +19,7 @@ use rustc_target::abi::{Align, Size};
2319use rustc_target::spec::abi::Abi as CallAbi;
2420use tracing::debug;
2521
22use super::error::*;
2623use crate::errors::{LongRunning, LongRunningWarn};
2724use crate::fluent_generated as fluent;
2825use crate::interpret::{
......@@ -31,8 +28,6 @@ use crate::interpret::{
3128 GlobalAlloc, ImmTy, InterpCx, InterpResult, MPlaceTy, OpTy, Pointer, PointerArithmetic, Scalar,
3229};
3330
34use super::error::*;
35
3631/// When hitting this many interpreted terminators we emit a deny by default lint
3732/// that notfies the user that their constant takes a long time to evaluate. If that's
3833/// what they intended, they can just allow the lint.
......@@ -201,7 +196,8 @@ impl<'tcx> CompileTimeInterpCx<'tcx> {
201196 let topmost = span.ctxt().outer_expn().expansion_cause().unwrap_or(span);
202197 let caller = self.tcx.sess.source_map().lookup_char_pos(topmost.lo());
203198
204 use rustc_session::{config::RemapPathScopeComponents, RemapFileNameExt};
199 use rustc_session::config::RemapPathScopeComponents;
200 use rustc_session::RemapFileNameExt;
205201 (
206202 Symbol::intern(
207203 &caller
compiler/rustc_const_eval/src/const_eval/mod.rs+1-2
......@@ -1,10 +1,9 @@
11// Not in interpret to make sure we do not use private implementation details
22
3use rustc_middle::bug;
4use rustc_middle::mir;
53use rustc_middle::mir::interpret::InterpErrorInfo;
64use rustc_middle::query::{Key, TyCtxtAt};
75use rustc_middle::ty::{self, Ty, TyCtxt};
6use rustc_middle::{bug, mir};
87use rustc_target::abi::VariantIdx;
98use tracing::instrument;
109
compiler/rustc_const_eval/src/const_eval/valtrees.rs+3-5
......@@ -1,9 +1,8 @@
11use rustc_data_structures::stack::ensure_sufficient_stack;
2use rustc_middle::bug;
3use rustc_middle::mir;
42use rustc_middle::mir::interpret::{EvalToValTreeResult, GlobalId};
53use rustc_middle::ty::layout::{LayoutCx, LayoutOf, TyAndLayout};
64use rustc_middle::ty::{self, ScalarInt, Ty, TyCtxt};
5use rustc_middle::{bug, mir};
76use rustc_span::DUMMY_SP;
87use rustc_target::abi::{Abi, VariantIdx};
98use tracing::{debug, instrument, trace};
......@@ -13,10 +12,9 @@ use super::machine::CompileTimeInterpCx;
1312use super::{ValTreeCreationError, ValTreeCreationResult, VALTREE_MAX_NODES};
1413use crate::const_eval::CanAccessMutGlobal;
1514use crate::errors::MaxNumNodesInConstErr;
16use crate::interpret::MPlaceTy;
1715use 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,
2018};
2119
2220#[instrument(skip(ecx), level = "debug")]
compiler/rustc_const_eval/src/errors.rs+10-6
......@@ -1,8 +1,9 @@
11use std::borrow::Cow;
22
33use either::Either;
4use rustc_errors::codes::*;
45use rustc_errors::{
5 codes::*, Diag, DiagArgValue, DiagCtxtHandle, DiagMessage, Diagnostic, EmissionGuarantee, Level,
6 Diag, DiagArgValue, DiagCtxtHandle, DiagMessage, Diagnostic, EmissionGuarantee, Level,
67};
78use rustc_hir::ConstContext;
89use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
......@@ -468,8 +469,9 @@ fn bad_pointer_message(msg: CheckInAllocMsg, dcx: DiagCtxtHandle<'_>) -> String
468469
469470impl<'a> ReportErrorExt for UndefinedBehaviorInfo<'a> {
470471 fn diagnostic_message(&self) -> DiagMessage {
471 use crate::fluent_generated::*;
472472 use UndefinedBehaviorInfo::*;
473
474 use crate::fluent_generated::*;
473475 match self {
474476 Ub(msg) => msg.clone().into(),
475477 Custom(x) => (x.msg)(),
......@@ -630,8 +632,9 @@ impl<'a> ReportErrorExt for UndefinedBehaviorInfo<'a> {
630632
631633impl<'tcx> ReportErrorExt for ValidationErrorInfo<'tcx> {
632634 fn diagnostic_message(&self) -> DiagMessage {
633 use crate::fluent_generated::*;
634635 use rustc_middle::mir::interpret::ValidationErrorKind::*;
636
637 use crate::fluent_generated::*;
635638 match self.kind {
636639 PtrToUninhabited { ptr_kind: PointerKind::Box, .. } => {
637640 const_eval_validation_box_to_uninhabited
......@@ -702,9 +705,10 @@ impl<'tcx> ReportErrorExt for ValidationErrorInfo<'tcx> {
702705 }
703706
704707 fn add_args<G: EmissionGuarantee>(self, err: &mut Diag<'_, G>) {
705 use crate::fluent_generated as fluent;
706708 use rustc_middle::mir::interpret::ValidationErrorKind::*;
707709
710 use crate::fluent_generated as fluent;
711
708712 if let PointerAsInt { .. } | PartialPointer = self.kind {
709713 err.help(fluent::const_eval_ptr_as_bytes_1);
710714 err.help(fluent::const_eval_ptr_as_bytes_2);
......@@ -835,9 +839,9 @@ impl ReportErrorExt for UnsupportedOpInfo {
835839 }
836840 }
837841 fn add_args<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
838 use crate::fluent_generated::*;
839
840842 use UnsupportedOpInfo::*;
843
844 use crate::fluent_generated::*;
841845 if let ReadPointerAsInt(_) | OverwritePartialPointer(_) | ReadPartialPointer(_) = self {
842846 diag.help(const_eval_ptr_as_bytes_1);
843847 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;
1212use rustc_type_ir::TyKind::*;
1313use tracing::trace;
1414
15use super::util::ensure_monomorphic_enough;
1516use 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,
1818};
19
2019use crate::fluent_generated as fluent;
2120
2221impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
compiler/rustc_const_eval/src/interpret/discriminant.rs+2-4
......@@ -1,11 +1,9 @@
11//! Functions for reading and writing discriminants of multi-variant layouts (enums and coroutines).
22
3use rustc_middle::mir;
4use rustc_middle::span_bug;
53use rustc_middle::ty::layout::{LayoutOf, PrimitiveExt};
64use rustc_middle::ty::{self, CoroutineArgsExt, ScalarInt, Ty};
7use rustc_target::abi::{self, TagEncoding};
8use rustc_target::abi::{VariantIdx, Variants};
5use rustc_middle::{mir, span_bug};
6use rustc_target::abi::{self, TagEncoding, VariantIdx, Variants};
97use tracing::{instrument, trace};
108
119use super::{
compiler/rustc_const_eval/src/interpret/eval_context.rs+11-12
......@@ -2,16 +2,14 @@ use std::cell::Cell;
22use std::{fmt, mem};
33
44use either::{Either, Left, Right};
5use rustc_infer::infer::at::ToTrace;
6use rustc_infer::traits::ObligationCause;
7use rustc_trait_selection::traits::ObligationCtxt;
8use tracing::{debug, info, info_span, instrument, trace};
9
105use rustc_errors::DiagCtxtHandle;
11use rustc_hir::{self as hir, def_id::DefId, definitions::DefPathData};
6use rustc_hir::def_id::DefId;
7use rustc_hir::definitions::DefPathData;
8use rustc_hir::{self as hir};
129use rustc_index::IndexVec;
10use rustc_infer::infer::at::ToTrace;
1311use rustc_infer::infer::TyCtxtInferExt;
14use rustc_middle::mir;
12use rustc_infer::traits::ObligationCause;
1513use rustc_middle::mir::interpret::{
1614 CtfeProvenance, ErrorHandled, InvalidMetaKind, ReportedErrorInfo,
1715};
......@@ -21,11 +19,14 @@ use rustc_middle::ty::layout::{
2119 TyAndLayout,
2220};
2321use rustc_middle::ty::{self, GenericArgsRef, ParamEnv, Ty, TyCtxt, TypeFoldable, Variance};
24use rustc_middle::{bug, span_bug};
22use rustc_middle::{bug, mir, span_bug};
2523use rustc_mir_dataflow::storage::always_storage_live_locals;
2624use rustc_session::Limit;
2725use rustc_span::Span;
28use rustc_target::abi::{call::FnAbi, Align, HasDataLayout, Size, TargetDataLayout};
26use rustc_target::abi::call::FnAbi;
27use rustc_target::abi::{Align, HasDataLayout, Size, TargetDataLayout};
28use rustc_trait_selection::traits::ObligationCtxt;
29use tracing::{debug, info, info_span, instrument, trace};
2930
3031use super::{
3132 err_inval, throw_inval, throw_ub, throw_ub_custom, throw_unsup, GlobalId, Immediate,
......@@ -33,9 +34,7 @@ use super::{
3334 OpTy, Operand, Place, PlaceTy, Pointer, PointerArithmetic, Projectable, Provenance,
3435 ReturnAction, Scalar,
3536};
36use crate::errors;
37use crate::util;
38use crate::{fluent_generated as fluent, ReportErrorExt};
37use crate::{errors, fluent_generated as fluent, util, ReportErrorExt};
3938
4039pub struct InterpCx<'tcx, M: Machine<'tcx>> {
4140 /// Stores the `Machine` instance.
compiler/rustc_const_eval/src/interpret/intrinsics.rs+9-14
......@@ -3,26 +3,21 @@
33//! and miri.
44
55use rustc_hir::def_id::DefId;
6use rustc_middle::ty;
7use rustc_middle::ty::layout::{LayoutOf as _, ValidityRequirement};
8use rustc_middle::ty::GenericArgsRef;
9use rustc_middle::ty::{Ty, TyCtxt};
10use rustc_middle::{
11 bug,
12 mir::{self, BinOp, ConstValue, NonDivergingIntrinsic},
13 ty::layout::TyAndLayout,
14};
6use rustc_middle::mir::{self, BinOp, ConstValue, NonDivergingIntrinsic};
7use rustc_middle::ty::layout::{LayoutOf as _, TyAndLayout, ValidityRequirement};
8use rustc_middle::ty::{GenericArgsRef, Ty, TyCtxt};
9use rustc_middle::{bug, ty};
1510use rustc_span::symbol::{sym, Symbol};
1611use rustc_target::abi::Size;
1712use tracing::trace;
1813
14use super::memory::MemoryKind;
15use super::util::ensure_monomorphic_enough;
1916use 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,
2420};
25
2621use crate::fluent_generated as fluent;
2722
2823/// 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;
88
99use rustc_apfloat::{Float, FloatConvert};
1010use rustc_ast::{InlineAsmOptions, InlineAsmTemplatePiece};
11use rustc_middle::mir;
1211use rustc_middle::query::TyCtxtAt;
13use rustc_middle::ty;
1412use rustc_middle::ty::layout::TyAndLayout;
13use rustc_middle::{mir, ty};
1514use rustc_span::def_id::DefId;
1615use rustc_span::Span;
1716use 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;
1010use std::borrow::Cow;
1111use std::cell::Cell;
1212use std::collections::VecDeque;
13use std::fmt;
14use std::ptr;
13use std::{fmt, ptr};
1514
1615use rustc_ast::Mutability;
1716use rustc_data_structures::fx::{FxHashSet, FxIndexMap};
......@@ -20,17 +19,15 @@ use rustc_middle::bug;
2019use rustc_middle::mir::display_allocation;
2120use rustc_middle::ty::{self, Instance, ParamEnv, Ty, TyCtxt};
2221use rustc_target::abi::{Align, HasDataLayout, Size};
23
2422use tracing::{debug, instrument, trace};
2523
26use crate::fluent_generated as fluent;
27
2824use super::{
2925 alloc_range, err_ub, err_ub_custom, throw_ub, throw_ub_custom, throw_unsup, throw_unsup_format,
3026 AllocBytes, AllocId, AllocMap, AllocRange, Allocation, CheckAlignMsg, CheckInAllocMsg,
3127 CtfeProvenance, GlobalAlloc, InterpCx, InterpResult, Machine, MayLeak, Misalignment, Pointer,
3228 PointerArithmetic, Provenance, Scalar,
3329};
30use crate::fluent_generated as fluent;
3431
3532#[derive(Debug, PartialEq, Copy, Clone)]
3633pub enum MemoryKind<T> {
compiler/rustc_const_eval/src/interpret/mod.rs+5-9
......@@ -18,6 +18,7 @@ mod util;
1818mod validity;
1919mod visitor;
2020
21use eval_context::{from_known_layout, mir_assign_valid_types};
2122#[doc(no_inline)]
2223pub use rustc_middle::mir::interpret::*; // have all the `interpret` symbols in one place: here
2324
......@@ -26,20 +27,15 @@ pub use self::intern::{
2627 intern_const_alloc_for_constprop, intern_const_alloc_recursive, HasStaticRootDefId, InternKind,
2728 InternResult,
2829};
30pub(crate) use self::intrinsics::eval_nullary_intrinsic;
2931pub use self::machine::{compile_time_machine, AllocMap, Machine, MayLeak, ReturnAction};
3032pub use self::memory::{AllocKind, AllocRef, AllocRefMut, FnVal, Memory, MemoryKind};
33use self::operand::Operand;
3134pub use self::operand::{ImmTy, Immediate, OpTy, Readable};
3235pub use self::place::{MPlaceTy, MemPlaceMeta, PlaceTy, Writeable};
36use self::place::{MemPlace, Place};
3337pub use self::projection::{OffsetMode, Projectable};
3438pub use self::terminator::FnArg;
39pub(crate) use self::util::create_static_alloc;
3540pub use self::validity::{CtfeValidationMode, RefTracking};
3641pub use self::visitor::ValueVisitor;
37
38use self::{
39 operand::Operand,
40 place::{MemPlace, Place},
41};
42
43pub(crate) use self::intrinsics::eval_nullary_intrinsic;
44pub(crate) use self::util::create_static_alloc;
45use eval_context::{from_known_layout, mir_assign_valid_types};
compiler/rustc_const_eval/src/interpret/operand.rs+4-5
......@@ -4,16 +4,14 @@
44use std::assert_matches::assert_matches;
55
66use either::{Either, Left, Right};
7use tracing::trace;
8
97use rustc_hir::def::Namespace;
108use rustc_middle::mir::interpret::ScalarSizeMismatch;
119use rustc_middle::ty::layout::{HasParamEnv, HasTyCtxt, LayoutOf, TyAndLayout};
1210use rustc_middle::ty::print::{FmtPrinter, PrettyPrinter};
1311use rustc_middle::ty::{ConstInt, ScalarInt, Ty, TyCtxt};
14use rustc_middle::{bug, span_bug};
15use rustc_middle::{mir, ty};
12use rustc_middle::{bug, mir, span_bug, ty};
1613use rustc_target::abi::{self, Abi, HasDataLayout, Size};
14use tracing::trace;
1715
1816use super::{
1917 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> {
835833// Some nodes are used a lot. Make sure they don't unintentionally get bigger.
836834#[cfg(target_pointer_width = "64")]
837835mod size_asserts {
838 use super::*;
839836 use rustc_data_structures::static_assert_size;
837
838 use super::*;
840839 // tidy-alphabetical-start
841840 static_assert_size!(Immediate, 48);
842841 static_assert_size!(ImmTy<'_>, 64);
compiler/rustc_const_eval/src/interpret/operator.rs+1-3
......@@ -1,11 +1,9 @@
11use either::Either;
2
32use rustc_apfloat::{Float, FloatConvert};
4use rustc_middle::mir;
53use rustc_middle::mir::interpret::{InterpResult, Scalar};
64use rustc_middle::ty::layout::{LayoutOf, TyAndLayout};
75use rustc_middle::ty::{self, FloatTy, ScalarInt};
8use rustc_middle::{bug, span_bug};
6use rustc_middle::{bug, mir, span_bug};
97use rustc_span::symbol::sym;
108use tracing::trace;
119
compiler/rustc_const_eval/src/interpret/place.rs+4-5
......@@ -5,14 +5,12 @@
55use std::assert_matches::assert_matches;
66
77use either::{Either, Left, Right};
8use tracing::{instrument, trace};
9
108use rustc_ast::Mutability;
11use rustc_middle::mir;
129use rustc_middle::ty::layout::{LayoutOf, TyAndLayout};
1310use rustc_middle::ty::Ty;
14use rustc_middle::{bug, span_bug};
11use rustc_middle::{bug, mir, span_bug};
1512use rustc_target::abi::{Abi, Align, HasDataLayout, Size};
13use tracing::{instrument, trace};
1614
1715use super::{
1816 alloc_range, mir_assign_valid_types, throw_ub, AllocRef, AllocRefMut, CheckAlignMsg,
......@@ -1034,8 +1032,9 @@ where
10341032// Some nodes are used a lot. Make sure they don't unintentionally get bigger.
10351033#[cfg(target_pointer_width = "64")]
10361034mod size_asserts {
1037 use super::*;
10381035 use rustc_data_structures::static_assert_size;
1036
1037 use super::*;
10391038 // tidy-alphabetical-start
10401039 static_assert_size!(MemPlace, 48);
10411040 static_assert_size!(MemPlaceMeta, 24);
compiler/rustc_const_eval/src/interpret/projection.rs+2-6
......@@ -10,14 +10,10 @@
1010use std::marker::PhantomData;
1111use std::ops::Range;
1212
13use rustc_middle::mir;
14use rustc_middle::ty;
1513use rustc_middle::ty::layout::{LayoutOf, TyAndLayout};
1614use rustc_middle::ty::Ty;
17use rustc_middle::{bug, span_bug};
18use rustc_target::abi::Size;
19use rustc_target::abi::{self, VariantIdx};
20
15use rustc_middle::{bug, mir, span_bug, ty};
16use rustc_target::abi::{self, Size, VariantIdx};
2117use tracing::{debug, instrument};
2218
2319use super::{
compiler/rustc_const_eval/src/interpret/step.rs+2-4
......@@ -3,13 +3,11 @@
33//! The main entry point is the `step` method.
44
55use either::Either;
6use tracing::{info, instrument, trace};
7
86use rustc_index::IndexSlice;
9use rustc_middle::mir;
107use rustc_middle::ty::layout::LayoutOf;
11use rustc_middle::{bug, span_bug};
8use rustc_middle::{bug, mir, span_bug};
129use rustc_target::abi::{FieldIdx, FIRST_VARIANT};
10use tracing::{info, instrument, trace};
1311
1412use super::{
1513 ImmTy, Immediate, InterpCx, InterpResult, Machine, MemPlaceMeta, PlaceTy, Projectable, Scalar,
compiler/rustc_const_eval/src/interpret/terminator.rs+11-20
......@@ -1,33 +1,24 @@
11use std::borrow::Cow;
22
33use either::Either;
4use tracing::trace;
5
6use rustc_middle::{
7 bug, mir, span_bug,
8 ty::{
9 self,
10 layout::{FnAbiOf, IntegerExt, LayoutOf, TyAndLayout},
11 AdtDef, Instance, Ty,
12 },
13};
14use rustc_span::{source_map::Spanned, sym};
15use rustc_target::abi::{self, FieldIdx};
16use rustc_target::abi::{
17 call::{ArgAbi, FnAbi, PassMode},
18 Integer,
19};
4use rustc_middle::ty::layout::{FnAbiOf, IntegerExt, LayoutOf, TyAndLayout};
5use rustc_middle::ty::{self, AdtDef, Instance, Ty};
6use rustc_middle::{bug, mir, span_bug};
7use rustc_span::source_map::Spanned;
8use rustc_span::sym;
9use rustc_target::abi::call::{ArgAbi, FnAbi, PassMode};
10use rustc_target::abi::{self, FieldIdx, Integer};
2011use rustc_target::spec::abi::Abi;
12use tracing::trace;
2113
2214use super::{
2315 throw_ub, throw_ub_custom, throw_unsup_format, CtfeProvenance, FnVal, ImmTy, InterpCx,
2416 InterpResult, MPlaceTy, Machine, OpTy, PlaceTy, Projectable, Provenance, Scalar,
2517 StackPopCleanup,
2618};
27use crate::{
28 fluent_generated as fluent,
29 interpret::{eval_context::StackPopInfo, ReturnAction},
30};
19use crate::fluent_generated as fluent;
20use crate::interpret::eval_context::StackPopInfo;
21use crate::interpret::ReturnAction;
3122
3223/// An argment passed to a function.
3324#[derive(Clone, Debug)]
compiler/rustc_const_eval/src/interpret/util.rs+3-2
......@@ -1,4 +1,5 @@
1use crate::const_eval::{CompileTimeInterpCx, CompileTimeMachine, InterpretationResult};
1use std::ops::ControlFlow;
2
23use rustc_hir::def_id::LocalDefId;
34use rustc_middle::mir;
45use rustc_middle::mir::interpret::{Allocation, InterpResult, Pointer};
......@@ -6,10 +7,10 @@ use rustc_middle::ty::layout::TyAndLayout;
67use rustc_middle::ty::{
78 self, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor,
89};
9use std::ops::ControlFlow;
1010use tracing::debug;
1111
1212use super::{throw_inval, InterpCx, MPlaceTy, MemPlaceMeta, MemoryKind};
13use crate::const_eval::{CompileTimeInterpCx, CompileTimeMachine, InterpretationResult};
1314
1415/// Checks whether a type contains generic parameters which must be instantiated.
1516///
compiler/rustc_const_eval/src/interpret/validity.rs+6-6
......@@ -9,17 +9,15 @@ use std::hash::Hash;
99use std::num::NonZero;
1010
1111use either::{Left, Right};
12use tracing::trace;
13
1412use hir::def::DefKind;
1513use rustc_ast::Mutability;
1614use rustc_data_structures::fx::FxHashSet;
1715use rustc_hir as hir;
1816use rustc_middle::bug;
17use rustc_middle::mir::interpret::ValidationErrorKind::{self, *};
1918use rustc_middle::mir::interpret::{
2019 ExpectedKind, InterpError, InvalidMetaKind, Misalignment, PointerKind, Provenance,
2120 UnsupportedOpInfo, ValidationErrorInfo,
22 ValidationErrorKind::{self, *},
2321};
2422use rustc_middle::ty::layout::{LayoutOf, TyAndLayout};
2523use rustc_middle::ty::{self, Ty};
......@@ -27,11 +25,13 @@ use rustc_span::symbol::{sym, Symbol};
2725use rustc_target::abi::{
2826 Abi, FieldIdx, Scalar as ScalarAbi, Size, VariantIdx, Variants, WrappingRange,
2927};
28use tracing::trace;
3029
30use super::machine::AllocMap;
3131use 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,
3535};
3636
3737// for the validation errors
compiler/rustc_const_eval/src/interpret/visitor.rs+3-4
......@@ -1,15 +1,14 @@
11//! Visitor for a run-time value with a given layout: Traverse enums, structs and other compound
22//! types until we arrive at the leaves, with custom handling for primitive types.
33
4use std::num::NonZero;
5
46use rustc_index::IndexVec;
57use rustc_middle::mir::interpret::InterpResult;
68use rustc_middle::ty::{self, Ty};
7use rustc_target::abi::FieldIdx;
8use rustc_target::abi::{FieldsShape, VariantIdx, Variants};
9use rustc_target::abi::{FieldIdx, FieldsShape, VariantIdx, Variants};
910use tracing::trace;
1011
11use std::num::NonZero;
12
1312use super::{throw_inval, InterpCx, MPlaceTy, Machine, Projectable};
1413
1514/// 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;
2626use std::sync::atomic::AtomicBool;
2727
2828pub use errors::ReportErrorExt;
29
30use rustc_middle::{ty, util::Providers};
29use rustc_middle::ty;
30use rustc_middle::util::Providers;
3131
3232rustc_fluent_macro::fluent_messages! { "../messages.ftl" }
3333
compiler/rustc_const_eval/src/util/caller_location.rs+1-2
......@@ -1,9 +1,8 @@
11use rustc_hir::LangItem;
2use rustc_middle::bug;
3use rustc_middle::mir;
42use rustc_middle::query::TyCtxtAt;
53use rustc_middle::ty::layout::LayoutOf;
64use rustc_middle::ty::{self, Mutability};
5use rustc_middle::{bug, mir};
76use rustc_span::symbol::Symbol;
87use tracing::trace;
98
compiler/rustc_const_eval/src/util/type_name.rs+4-6
......@@ -1,13 +1,11 @@
1use std::fmt::Write;
2
13use rustc_data_structures::intern::Interned;
24use rustc_hir::def_id::CrateNum;
35use rustc_hir::definitions::DisambiguatedDefPathData;
46use rustc_middle::bug;
5use rustc_middle::ty::{
6 self,
7 print::{PrettyPrinter, Print, PrintError, Printer},
8 GenericArg, GenericArgKind, Ty, TyCtxt,
9};
10use std::fmt::Write;
7use rustc_middle::ty::print::{PrettyPrinter, Print, PrintError, Printer};
8use rustc_middle::ty::{self, GenericArg, GenericArgKind, Ty, TyCtxt};
119
1210struct AbsolutePathPrinter<'tcx> {
1311 tcx: TyCtxt<'tcx>,
compiler/rustc_data_structures/src/base_n.rs+1-2
......@@ -1,8 +1,7 @@
11//! Converts unsigned integers into a string representation with some base.
22//! Bases up to and including 36 can be used for case-insensitive things.
33
4use std::ascii;
5use std::fmt;
4use std::{ascii, fmt};
65
76#[cfg(test)]
87mod tests;
compiler/rustc_data_structures/src/fingerprint.rs+6-3
......@@ -1,8 +1,11 @@
1use crate::stable_hasher::impl_stable_traits_for_trivial_type;
2use crate::stable_hasher::{FromStableHash, Hash64, StableHasherHash};
3use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
41use std::hash::{Hash, Hasher};
52
3use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
4
5use crate::stable_hasher::{
6 impl_stable_traits_for_trivial_type, FromStableHash, Hash64, StableHasherHash,
7};
8
69#[cfg(test)]
710mod tests;
811
compiler/rustc_data_structures/src/flat_map_in_place.rs+2-1
......@@ -1,5 +1,6 @@
1use smallvec::{Array, SmallVec};
21use std::ptr;
2
3use smallvec::{Array, SmallVec};
34use thin_vec::ThinVec;
45
56pub trait FlatMapInPlace<T>: Sized {
compiler/rustc_data_structures/src/flock/unix.rs+1-2
......@@ -1,8 +1,7 @@
11use std::fs::{File, OpenOptions};
2use std::io;
3use std::mem;
42use std::os::unix::prelude::*;
53use std::path::Path;
4use std::{io, mem};
65
76#[derive(Debug)]
87pub struct Lock {
compiler/rustc_data_structures/src/flock/windows.rs+6-8
......@@ -2,16 +2,14 @@ use std::fs::{File, OpenOptions};
22use std::io;
33use std::os::windows::prelude::*;
44use std::path::Path;
5use tracing::debug;
65
7use 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,
6use tracing::debug;
7use windows::Win32::Foundation::{ERROR_INVALID_FUNCTION, HANDLE};
8use 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,
1411};
12use windows::Win32::System::IO::OVERLAPPED;
1513
1614#[derive(Debug)]
1715pub struct Lock {
compiler/rustc_data_structures/src/graph/dominators/mod.rs+3-2
......@@ -9,10 +9,11 @@
99//! Thomas Lengauer and Robert Endre Tarjan.
1010//! <https://www.cs.princeton.edu/courses/archive/spr03/cs423/download/dominators.pdf>
1111
12use super::ControlFlowGraph;
12use std::cmp::Ordering;
13
1314use rustc_index::{Idx, IndexSlice, IndexVec};
1415
15use std::cmp::Ordering;
16use super::ControlFlowGraph;
1617
1718#[cfg(test)]
1819mod tests;
compiler/rustc_data_structures/src/graph/dominators/tests.rs+1-2
......@@ -1,6 +1,5 @@
1use super::*;
2
31use super::super::tests::TestGraph;
2use super::*;
43
54#[test]
65fn diamond() {
compiler/rustc_data_structures/src/graph/implementation/mod.rs+2-1
......@@ -20,8 +20,9 @@
2020//! the field `next_edge`). Each of those fields is an array that should
2121//! be indexed by the direction (see the type `Direction`).
2222
23use rustc_index::bit_set::BitSet;
2423use std::fmt::Debug;
24
25use rustc_index::bit_set::BitSet;
2526use tracing::debug;
2627
2728#[cfg(test)]
compiler/rustc_data_structures/src/graph/implementation/tests.rs+2-1
......@@ -1,6 +1,7 @@
1use crate::graph::implementation::*;
21use tracing::debug;
32
3use crate::graph::implementation::*;
4
45type TestGraph = Graph<&'static str, &'static str>;
56
67fn create_graph() -> TestGraph {
compiler/rustc_data_structures/src/graph/iterate/mod.rs+4-2
......@@ -1,7 +1,9 @@
1use super::{DirectedGraph, StartNode, Successors};
1use std::ops::ControlFlow;
2
23use rustc_index::bit_set::BitSet;
34use rustc_index::{IndexSlice, IndexVec};
4use std::ops::ControlFlow;
5
6use super::{DirectedGraph, StartNode, Successors};
57
68#[cfg(test)]
79mod tests;
compiler/rustc_data_structures/src/graph/iterate/tests.rs-1
......@@ -1,5 +1,4 @@
11use super::super::tests::TestGraph;
2
32use super::*;
43
54#[test]
compiler/rustc_data_structures/src/graph/scc/mod.rs+6-4
......@@ -8,14 +8,16 @@
88//! Typical examples would include: minimum element in SCC, maximum element
99//! reachable from it, etc.
1010
11use crate::fx::FxHashSet;
12use crate::graph::vec_graph::VecGraph;
13use crate::graph::{DirectedGraph, NumEdges, Successors};
14use rustc_index::{Idx, IndexSlice, IndexVec};
1511use std::fmt::Debug;
1612use std::ops::Range;
13
14use rustc_index::{Idx, IndexSlice, IndexVec};
1715use tracing::{debug, instrument};
1816
17use crate::fx::FxHashSet;
18use crate::graph::vec_graph::VecGraph;
19use crate::graph::{DirectedGraph, NumEdges, Successors};
20
1921#[cfg(test)]
2022mod tests;
2123
compiler/rustc_data_structures/src/graph/tests.rs+1-1
......@@ -1,7 +1,7 @@
1use crate::fx::FxHashMap;
21use std::cmp::max;
32
43use super::*;
4use crate::fx::FxHashMap;
55
66pub struct TestGraph {
77 num_nodes: usize,
compiler/rustc_data_structures/src/graph/vec_graph/mod.rs+2-1
......@@ -1,6 +1,7 @@
1use crate::graph::{DirectedGraph, NumEdges, Predecessors, Successors};
21use rustc_index::{Idx, IndexVec};
32
3use crate::graph::{DirectedGraph, NumEdges, Predecessors, Successors};
4
45#[cfg(test)]
56mod tests;
67
compiler/rustc_data_structures/src/graph/vec_graph/tests.rs+1-2
......@@ -1,6 +1,5 @@
1use crate::graph;
2
31use super::*;
2use crate::graph;
43
54fn create_graph() -> VecGraph<usize> {
65 // Create a simple graph
compiler/rustc_data_structures/src/hashes.rs+4-2
......@@ -11,11 +11,13 @@
1111//! connect the fact that they can only be produced by a `StableHasher` to their
1212//! `Encode`/`Decode` impls.
1313
14use crate::stable_hasher::{FromStableHash, StableHasherHash};
15use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
1614use std::fmt;
1715use std::ops::BitXorAssign;
1816
17use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
18
19use crate::stable_hasher::{FromStableHash, StableHasherHash};
20
1921#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
2022pub struct Hash64 {
2123 inner: u64,
compiler/rustc_data_structures/src/intern.rs+2-1
......@@ -1,10 +1,11 @@
1use crate::stable_hasher::{HashStable, StableHasher};
21use std::cmp::Ordering;
32use std::fmt::{self, Debug};
43use std::hash::{Hash, Hasher};
54use std::ops::Deref;
65use std::ptr;
76
7use crate::stable_hasher::{HashStable, StableHasher};
8
89mod private {
910 #[derive(Clone, Copy, Debug)]
1011 pub struct PrivateZst;
compiler/rustc_data_structures/src/jobserver.rs+2-3
......@@ -1,9 +1,8 @@
1pub use jobserver_crate::Client;
1use std::sync::{LazyLock, OnceLock};
22
3pub use jobserver_crate::Client;
34use jobserver_crate::{FromEnv, FromEnvErrorKind};
45
5use std::sync::{LazyLock, OnceLock};
6
76// We can only call `from_env_ext` once per process
87
98// 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 @@
3939#![feature(unwrap_infallible)]
4040// tidy-alphabetical-end
4141
42use std::fmt;
43
4244pub use atomic_ref::AtomicRef;
43pub use ena::snapshot_vec;
44pub use ena::undo_log;
45pub use ena::unify;
45pub use ena::{snapshot_vec, undo_log, unify};
4646pub use rustc_index::static_assert_size;
4747
48use std::fmt;
49
5048pub mod aligned;
5149pub mod base_n;
5250pub mod binary_search_util;
compiler/rustc_data_structures/src/obligation_forest/graphviz.rs+5-4
......@@ -1,11 +1,12 @@
1use crate::obligation_forest::{ForestObligation, ObligationForest};
2use rustc_graphviz as dot;
31use std::env::var_os;
42use std::fs::File;
53use std::io::BufWriter;
64use std::path::Path;
7use std::sync::atomic::AtomicUsize;
8use std::sync::atomic::Ordering;
5use std::sync::atomic::{AtomicUsize, Ordering};
6
7use rustc_graphviz as dot;
8
9use crate::obligation_forest::{ForestObligation, ObligationForest};
910
1011impl<O: ForestObligation> ObligationForest<O> {
1112 /// 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 @@
6969//! step, we compress the vector to remove completed and error nodes, which
7070//! aren't needed anymore.
7171
72use crate::fx::{FxHashMap, FxHashSet};
7372use std::cell::Cell;
7473use std::collections::hash_map::Entry;
7574use std::fmt::Debug;
7675use std::hash;
7776use std::marker::PhantomData;
77
7878use tracing::debug;
7979
80use crate::fx::{FxHashMap, FxHashSet};
81
8082mod graphviz;
8183
8284#[cfg(test)]
compiler/rustc_data_structures/src/obligation_forest/tests.rs+2-2
......@@ -1,7 +1,7 @@
1use super::*;
2
31use std::fmt;
42
3use super::*;
4
55impl<'a> super::ForestObligation for &'a str {
66 type CacheKey = &'a str;
77
compiler/rustc_data_structures/src/owned_slice.rs+3-2
......@@ -1,10 +1,11 @@
1use std::{borrow::Borrow, ops::Deref};
1use std::borrow::Borrow;
2use std::ops::Deref;
23
3use crate::sync::Lrc;
44// Use our fake Send/Sync traits when on not parallel compiler,
55// so that `OwnedSlice` only implements/requires Send/Sync
66// for parallel compiler builds.
77use crate::sync;
8use crate::sync::Lrc;
89
910/// An owned slice.
1011///
compiler/rustc_data_structures/src/owned_slice/tests.rs+6-12
......@@ -1,15 +1,9 @@
1use std::{
2 ops::Deref,
3 sync::{
4 atomic::{self, AtomicBool},
5 Arc,
6 },
7};
8
9use crate::{
10 defer,
11 owned_slice::{slice_owned, try_slice_owned, OwnedSlice},
12};
1use std::ops::Deref;
2use std::sync::atomic::{self, AtomicBool};
3use std::sync::Arc;
4
5use crate::defer;
6use crate::owned_slice::{slice_owned, try_slice_owned, OwnedSlice};
137
148#[test]
159fn smoke() {
compiler/rustc_data_structures/src/packed.rs+4-2
......@@ -1,8 +1,10 @@
1use crate::stable_hasher::{HashStable, StableHasher};
2use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
31use std::cmp::Ordering;
42use std::fmt;
53
4use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
5
6use crate::stable_hasher::{HashStable, StableHasher};
7
68/// A packed 128-bit integer. Useful for reducing the size of structures in
79/// some cases.
810#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
compiler/rustc_data_structures/src/profiling.rs+4-5
......@@ -81,19 +81,15 @@
8181//!
8282//! [mm]: https://github.com/rust-lang/measureme/
8383
84use crate::fx::FxHashMap;
85use crate::outline;
86
8784use std::borrow::Borrow;
8885use std::collections::hash_map::Entry;
8986use std::error::Error;
9087use std::fmt::Display;
91use std::fs;
9288use std::intrinsics::unlikely;
9389use std::path::Path;
94use std::process;
9590use std::sync::Arc;
9691use std::time::{Duration, Instant};
92use std::{fs, process};
9793
9894pub use measureme::EventId;
9995use measureme::{EventIdBuilder, Profiler, SerializableString, StringId};
......@@ -101,6 +97,9 @@ use parking_lot::RwLock;
10197use smallvec::SmallVec;
10298use tracing::warn;
10399
100use crate::fx::FxHashMap;
101use crate::outline;
102
104103bitflags::bitflags! {
105104 #[derive(Clone, Copy)]
106105 struct EventFilter: u16 {
compiler/rustc_data_structures/src/sharded.rs+8-7
......@@ -1,14 +1,15 @@
1use std::borrow::Borrow;
2use std::collections::hash_map::RawEntryMut;
3use std::hash::{Hash, Hasher};
4use std::{iter, mem};
5
6#[cfg(parallel_compiler)]
7use either::Either;
8
19use crate::fx::{FxHashMap, FxHasher};
210#[cfg(parallel_compiler)]
311use crate::sync::{is_dyn_thread_safe, CacheAligned};
412use crate::sync::{Lock, LockGuard, Mode};
5#[cfg(parallel_compiler)]
6use either::Either;
7use std::borrow::Borrow;
8use std::collections::hash_map::RawEntryMut;
9use std::hash::{Hash, Hasher};
10use std::iter;
11use std::mem;
1213
1314// 32 shards is sufficient to reduce contention on an 8-core Ryzen 7 1700,
1415// 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 @@
1use crate::fx::FxHashMap;
2use crate::undo_log::{Rollback, Snapshots, UndoLogs, VecLog};
31use std::borrow::{Borrow, BorrowMut};
42use std::hash::Hash;
53use std::marker::PhantomData;
64use std::ops;
75
6use crate::fx::FxHashMap;
87pub use crate::undo_log::Snapshot;
8use crate::undo_log::{Rollback, Snapshots, UndoLogs, VecLog};
99
1010#[cfg(test)]
1111mod tests;
compiler/rustc_data_structures/src/sorted_map.rs+4-2
......@@ -1,10 +1,12 @@
1use crate::stable_hasher::{HashStable, StableHasher, StableOrd};
2use rustc_macros::{Decodable_Generic, Encodable_Generic};
31use std::borrow::Borrow;
42use std::fmt::Debug;
53use std::mem;
64use std::ops::{Bound, Index, IndexMut, RangeBounds};
75
6use rustc_macros::{Decodable_Generic, Encodable_Generic};
7
8use crate::stable_hasher::{HashStable, StableHasher, StableOrd};
9
810mod index_map;
911
1012pub use index_map::SortedIndexMultiMap;
compiler/rustc_data_structures/src/sorted_map/index_map.rs+2-1
......@@ -2,9 +2,10 @@
22
33use std::hash::{Hash, Hasher};
44
5use crate::stable_hasher::{HashStable, StableHasher};
65use rustc_index::{Idx, IndexVec};
76
7use crate::stable_hasher::{HashStable, StableHasher};
8
89/// An indexed multi-map that preserves insertion order while permitting both *O*(log *n*) lookup of
910/// an item by key and *O*(1) lookup by index.
1011///
compiler/rustc_data_structures/src/sso/map.rs+5-3
......@@ -1,10 +1,12 @@
1use crate::fx::FxHashMap;
2use arrayvec::ArrayVec;
3use either::Either;
41use std::fmt;
52use std::hash::Hash;
63use std::ops::Index;
74
5use arrayvec::ArrayVec;
6use either::Either;
7
8use crate::fx::FxHashMap;
9
810/// For pointer-sized arguments arrays
911/// are faster than set/map for up to 64
1012/// arguments.
compiler/rustc_data_structures/src/stable_hasher.rs+8-7
......@@ -1,19 +1,20 @@
1use rustc_index::bit_set::{self, BitSet};
2use rustc_index::{Idx, IndexSlice, IndexVec};
3use smallvec::SmallVec;
41use std::hash::{BuildHasher, Hash, Hasher};
52use std::marker::PhantomData;
63use std::mem;
74use std::num::NonZero;
85
6use rustc_index::bit_set::{self, BitSet};
7use rustc_index::{Idx, IndexSlice, IndexVec};
8use smallvec::SmallVec;
9
910#[cfg(test)]
1011mod tests;
1112
12pub use crate::hashes::{Hash128, Hash64};
13pub use rustc_stable_hash::{
14 FromStableHash, SipHasher128Hash as StableHasherHash, StableSipHasher128 as StableHasher,
15};
1316
14pub use rustc_stable_hash::FromStableHash;
15pub use rustc_stable_hash::SipHasher128Hash as StableHasherHash;
16pub use rustc_stable_hash::StableSipHasher128 as StableHasher;
17pub use crate::hashes::{Hash128, Hash64};
1718
1819/// Something that implements `HashStable<CTX>` can be hashed in a way that is
1920/// stable across multiple compilation sessions.
compiler/rustc_data_structures/src/svh.rs+4-2
......@@ -5,10 +5,12 @@
55//! mismatches where we have two versions of the same crate that were
66//! compiled from distinct sources.
77
8use std::fmt;
9
10use rustc_macros::{Decodable_Generic, Encodable_Generic};
11
812use crate::fingerprint::Fingerprint;
913use crate::stable_hasher;
10use rustc_macros::{Decodable_Generic, Encodable_Generic};
11use std::fmt;
1214
1315#[derive(Copy, Clone, PartialEq, Eq, Debug, Encodable_Generic, Decodable_Generic, Hash)]
1416pub struct Svh {
compiler/rustc_data_structures/src/sync.rs+2-2
......@@ -41,10 +41,11 @@
4141//!
4242//! [^2]: `MTRef`, `MTLockRef` are type aliases.
4343
44pub use crate::marker::*;
4544use std::collections::HashMap;
4645use std::hash::{BuildHasher, Hash};
4746
47pub use crate::marker::*;
48
4849mod lock;
4950#[doc(no_inline)]
5051pub use lock::{Lock, LockGuard, Mode};
......@@ -56,7 +57,6 @@ mod parallel;
5657#[cfg(parallel_compiler)]
5758pub use parallel::scope;
5859pub use parallel::{join, par_for_each_in, par_map, parallel_guard, try_par_for_each_in};
59
6060pub use vec::{AppendOnlyIndexVec, AppendOnlyVec};
6161
6262mod vec;
compiler/rustc_data_structures/src/sync/freeze.rs+7-8
......@@ -1,14 +1,13 @@
1use std::cell::UnsafeCell;
2use std::intrinsics::likely;
3use std::marker::PhantomData;
4use std::ops::{Deref, DerefMut};
5use std::ptr::NonNull;
6use std::sync::atomic::Ordering;
7
18use crate::sync::{AtomicBool, ReadGuard, RwLock, WriteGuard};
29#[cfg(parallel_compiler)]
310use crate::sync::{DynSend, DynSync};
4use std::{
5 cell::UnsafeCell,
6 intrinsics::likely,
7 marker::PhantomData,
8 ops::{Deref, DerefMut},
9 ptr::NonNull,
10 sync::atomic::Ordering,
11};
1211
1312/// A type which allows mutation using a lock until
1413/// 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 {
1919}
2020
2121mod 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};
3023 use std::intrinsics::unlikely;
3124 use std::marker::PhantomData;
3225 use std::mem::ManuallyDrop;
3326 use std::ops::{Deref, DerefMut};
3427
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
3536 /// A guard holding mutable access to a `Lock` which is in a locked state.
3637 #[must_use = "if unused the Lock will immediately unlock"]
3738 pub struct LockGuard<'a, T> {
......@@ -186,12 +187,12 @@ mod maybe_sync {
186187}
187188
188189mod no_sync {
189 use super::Mode;
190190 use std::cell::RefCell;
191
192191 #[doc(no_inline)]
193192 pub use std::cell::RefMut as LockGuard;
194193
194 use super::Mode;
195
195196 pub struct Lock<T>(RefCell<T>);
196197
197198 impl<T> Lock<T> {
compiler/rustc_data_structures/src/sync/parallel.rs+4-3
......@@ -3,9 +3,6 @@
33
44#![allow(dead_code)]
55
6use crate::sync::IntoDynSyncSend;
7use crate::FatalErrorMarker;
8use parking_lot::Mutex;
96use std::any::Any;
107use std::panic::{catch_unwind, resume_unwind, AssertUnwindSafe};
118
......@@ -13,6 +10,10 @@ use std::panic::{catch_unwind, resume_unwind, AssertUnwindSafe};
1310pub use disabled::*;
1411#[cfg(parallel_compiler)]
1512pub use enabled::*;
13use parking_lot::Mutex;
14
15use crate::sync::IntoDynSyncSend;
16use crate::FatalErrorMarker;
1617
1718/// A guard used to hold panics that occur during a parallel section to later by unwound.
1819/// 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 @@
1use parking_lot::Mutex;
2use std::cell::Cell;
3use std::cell::OnceCell;
1use std::cell::{Cell, OnceCell};
42use std::num::NonZero;
53use std::ops::Deref;
64use std::ptr;
75use std::sync::Arc;
86
7use parking_lot::Mutex;
98#[cfg(parallel_compiler)]
109use {crate::outline, crate::sync::CacheAligned};
1110
compiler/rustc_data_structures/src/tagged_ptr/copy.rs+3-2
......@@ -1,5 +1,3 @@
1use super::{Pointer, Tag};
2use crate::stable_hasher::{HashStable, StableHasher};
31use std::fmt;
42use std::hash::{Hash, Hasher};
53use std::marker::PhantomData;
......@@ -8,6 +6,9 @@ use std::num::NonZero;
86use std::ops::{Deref, DerefMut};
97use std::ptr::NonNull;
108
9use super::{Pointer, Tag};
10use crate::stable_hasher::{HashStable, StableHasher};
11
1112/// A [`Copy`] tagged pointer.
1213///
1314/// 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;
22use std::hash::{Hash, Hasher};
33use std::ops::{Deref, DerefMut};
44
5use super::CopyTaggedPtr;
6use super::{Pointer, Tag};
5use super::{CopyTaggedPtr, Pointer, Tag};
76use crate::stable_hasher::{HashStable, StableHasher};
87
98/// 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 @@
1use std::{ptr, sync::Arc};
1use std::ptr;
2use std::sync::Arc;
23
34use crate::tagged_ptr::{Pointer, Tag, Tag2, TaggedPtr};
45
compiler/rustc_data_structures/src/temp_dir.rs+1
......@@ -1,5 +1,6 @@
11use std::mem::ManuallyDrop;
22use std::path::Path;
3
34use tempfile::TempDir;
45
56/// 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 @@
1use crate::frozen::Frozen;
2use crate::fx::{FxHashSet, FxIndexSet};
3use rustc_index::bit_set::BitMatrix;
41use std::fmt::Debug;
52use std::hash::Hash;
63use std::mem;
74use std::ops::Deref;
85
6use rustc_index::bit_set::BitMatrix;
7
8use crate::frozen::Frozen;
9use crate::fx::{FxHashSet, FxIndexSet};
10
911#[cfg(test)]
1012mod tests;
1113
compiler/rustc_data_structures/src/unord.rs+9-13
......@@ -2,21 +2,17 @@
22//! ordering. This is a useful property for deterministic computations, such
33//! as required by the query system.
44
5use std::borrow::{Borrow, BorrowMut};
6use std::collections::hash_map::{Entry, OccupiedError};
7use std::hash::Hash;
8use std::iter::{Product, Sum};
9use std::ops::Index;
10
511use rustc_hash::{FxHashMap, FxHashSet};
612use rustc_macros::{Decodable_Generic, Encodable_Generic};
7use std::collections::hash_map::OccupiedError;
8use std::{
9 borrow::{Borrow, BorrowMut},
10 collections::hash_map::Entry,
11 hash::Hash,
12 iter::{Product, Sum},
13 ops::Index,
14};
15
16use crate::{
17 fingerprint::Fingerprint,
18 stable_hasher::{HashStable, StableCompare, StableHasher, ToStableHashKey},
19};
13
14use crate::fingerprint::Fingerprint;
15use crate::stable_hasher::{HashStable, StableCompare, StableHasher, ToStableHashKey};
2016
2117/// `UnordItems` is the order-less version of `Iterator`. It only contains methods
2218/// 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 @@
1use std::collections::VecDeque;
2
13use rustc_index::bit_set::BitSet;
24use rustc_index::Idx;
3use std::collections::VecDeque;
45
56/// A work queue is a handy data structure for tracking work left to
67/// 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 @@
1717#![feature(rustdoc_internals)]
1818// tidy-alphabetical-end
1919
20use std::cmp::max;
21use std::collections::BTreeMap;
22use std::ffi::OsString;
23use std::fmt::Write as _;
24use std::fs::{self, File};
25use std::io::{self, IsTerminal, Read, Write};
26use std::panic::{self, catch_unwind, PanicHookInfo};
27use std::path::PathBuf;
28use std::process::{self, Command, Stdio};
29use std::sync::atomic::{AtomicBool, Ordering};
30use std::sync::{Arc, OnceLock};
31use std::time::{Duration, Instant, SystemTime};
32use std::{env, str};
33
2034use rustc_ast as ast;
21use rustc_codegen_ssa::{traits::CodegenBackend, CodegenErrors, CodegenResults};
35use rustc_codegen_ssa::traits::CodegenBackend;
36use rustc_codegen_ssa::{CodegenErrors, CodegenResults};
2237use rustc_const_eval::CTRL_C_RECEIVED;
2338use rustc_data_structures::profiling::{
2439 get_resident_set_size, print_time_passes_entry, TimePassesFormat,
......@@ -35,8 +50,9 @@ use rustc_lint::unerased_lint_store;
3550use rustc_metadata::creader::MetadataLoader;
3651use rustc_metadata::locator;
3752use rustc_parse::{new_parser_from_file, new_parser_from_source_str, unwrap_or_emit_fatal};
38use rustc_session::config::{nightly_options, CG_OPTIONS, Z_OPTIONS};
39use rustc_session::config::{ErrorOutputType, Input, OutFileName, OutputType};
53use rustc_session::config::{
54 nightly_options, ErrorOutputType, Input, OutFileName, OutputType, CG_OPTIONS, Z_OPTIONS,
55};
4056use rustc_session::getopts::{self, Matches};
4157use rustc_session::lint::{Lint, LintId};
4258use rustc_session::output::collect_crate_types;
......@@ -46,20 +62,6 @@ use rustc_span::symbol::sym;
4662use rustc_span::FileName;
4763use rustc_target::json::ToJson;
4864use rustc_target::spec::{Target, TargetTriple};
49use std::cmp::max;
50use std::collections::BTreeMap;
51use std::env;
52use std::ffi::OsString;
53use std::fmt::Write as _;
54use std::fs::{self, File};
55use std::io::{self, IsTerminal, Read, Write};
56use std::panic::{self, catch_unwind, PanicHookInfo};
57use std::path::PathBuf;
58use std::process::{self, Command, Stdio};
59use std::str;
60use std::sync::atomic::{AtomicBool, Ordering};
61use std::sync::{Arc, OnceLock};
62use std::time::{Duration, Instant, SystemTime};
6365use time::OffsetDateTime;
6466use tracing::trace;
6567
......@@ -689,7 +691,6 @@ fn print_crate_info(
689691 parse_attrs: bool,
690692) -> Compilation {
691693 use rustc_session::config::PrintKind::*;
692
693694 // This import prevents the following code from using the printing macros
694695 // used by the rest of the module. Within this function, we only write to
695696 // the output specified by `sess.io.output_file`.
compiler/rustc_driver_impl/src/pretty.rs+4-4
......@@ -1,9 +1,10 @@
11//! The various pretty-printing routines.
22
3use rustc_ast as ast;
3use std::cell::Cell;
4use std::fmt::Write;
5
46use rustc_ast_pretty::pprust as pprust_ast;
57use rustc_errors::FatalError;
6use rustc_hir_pretty as pprust_hir;
78use rustc_middle::bug;
89use rustc_middle::mir::{write_mir_graphviz, write_mir_pretty};
910use rustc_middle::ty::{self, TyCtxt};
......@@ -12,9 +13,8 @@ use rustc_session::Session;
1213use rustc_smir::rustc_internal::pretty::write_smir_pretty;
1314use rustc_span::symbol::Ident;
1415use rustc_span::FileName;
15use std::cell::Cell;
16use std::fmt::Write;
1716use tracing::debug;
17use {rustc_ast as ast, rustc_hir_pretty as pprust_hir};
1818
1919pub use self::PpMode::*;
2020pub use self::PpSourceMode::*;
compiler/rustc_driver_impl/src/signal_handler.rs+2-1
......@@ -1,10 +1,11 @@
11//! Signal handler for rustc
22//! Primarily used to extract a backtrace from stack overflow
33
4use rustc_interface::util::{DEFAULT_STACK_SIZE, STACK_SIZE};
54use std::alloc::{alloc, Layout};
65use std::{fmt, mem, ptr};
76
7use rustc_interface::util::{DEFAULT_STACK_SIZE, STACK_SIZE};
8
89extern "C" {
910 fn backtrace_symbols_fd(buffer: *const *mut libc::c_void, size: libc::c_int, fd: libc::c_int);
1011}
compiler/rustc_error_messages/src/lib.rs+12-15
......@@ -6,31 +6,28 @@
66#![feature(type_alias_impl_trait)]
77// tidy-alphabetical-end
88
9use fluent_bundle::FluentResource;
10use fluent_syntax::parser::ParserError;
11use icu_provider_adapters::fallback::{LocaleFallbackProvider, LocaleFallbacker};
12use rustc_data_structures::sync::{IntoDynSyncSend, Lrc};
13use rustc_macros::{Decodable, Encodable};
14use rustc_span::Span;
159use std::borrow::Cow;
16use std::error::Error;
17use std::fmt;
18use std::fs;
19use std::io;
20use std::path::{Path, PathBuf};
21use tracing::{instrument, trace};
22
2310#[cfg(not(parallel_compiler))]
2411use std::cell::LazyCell as Lazy;
12use std::error::Error;
13use std::path::{Path, PathBuf};
2514#[cfg(parallel_compiler)]
2615use std::sync::LazyLock as Lazy;
16use std::{fmt, fs, io};
2717
18pub use fluent_bundle::types::FluentType;
19use fluent_bundle::FluentResource;
20pub use fluent_bundle::{self, FluentArgs, FluentError, FluentValue};
21use fluent_syntax::parser::ParserError;
22use icu_provider_adapters::fallback::{LocaleFallbackProvider, LocaleFallbacker};
2823#[cfg(parallel_compiler)]
2924use intl_memoizer::concurrent::IntlLangMemoizer;
3025#[cfg(not(parallel_compiler))]
3126use intl_memoizer::IntlLangMemoizer;
32
33pub use fluent_bundle::{self, types::FluentType, FluentArgs, FluentError, FluentValue};
27use rustc_data_structures::sync::{IntoDynSyncSend, Lrc};
28use rustc_macros::{Decodable, Encodable};
29use rustc_span::Span;
30use tracing::{instrument, trace};
3431pub use unic_langid::{langid, LanguageIdentifier};
3532
3633pub type FluentBundle =
compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs+6-5
......@@ -5,6 +5,12 @@
55//!
66//! [annotate_snippets]: https://docs.rs/crate/annotate-snippets/
77
8use annotate_snippets::{Annotation, AnnotationType, Renderer, Slice, Snippet, SourceAnnotation};
9use rustc_data_structures::sync::Lrc;
10use rustc_error_messages::FluentArgs;
11use rustc_span::source_map::SourceMap;
12use rustc_span::SourceFile;
13
814use crate::emitter::FileWithAnnotatedLines;
915use crate::snippet::Line;
1016use crate::translation::{to_fluent_args, Translate};
......@@ -12,11 +18,6 @@ use crate::{
1218 CodeSuggestion, DiagInner, DiagMessage, Emitter, ErrCode, FluentBundle, LazyFallbackBundle,
1319 Level, MultiSpan, Style, Subdiag,
1420};
15use annotate_snippets::{Annotation, AnnotationType, Renderer, Slice, Snippet, SourceAnnotation};
16use rustc_data_structures::sync::Lrc;
17use rustc_error_messages::FluentArgs;
18use rustc_span::source_map::SourceMap;
19use rustc_span::SourceFile;
2021
2122/// Generates diagnostics using annotate-snippet
2223pub struct AnnotateSnippetEmitter {
compiler/rustc_errors/src/diagnostic.rs+14-13
......@@ -1,16 +1,3 @@
1use crate::snippet::Style;
2use crate::{
3 CodeSuggestion, DiagCtxtHandle, DiagMessage, ErrCode, ErrorGuaranteed, ExplicitBug, Level,
4 MultiSpan, StashKey, SubdiagMessage, Substitution, SubstitutionPart, SuggestionStyle,
5};
6use rustc_data_structures::fx::FxIndexMap;
7use rustc_error_messages::fluent_value_from_str_list_sep_by_and;
8use rustc_error_messages::FluentValue;
9use rustc_lint_defs::{Applicability, LintExpectationId};
10use rustc_macros::{Decodable, Encodable};
11use rustc_span::source_map::Spanned;
12use rustc_span::symbol::Symbol;
13use rustc_span::{Span, DUMMY_SP};
141use std::borrow::Cow;
152use std::fmt::{self, Debug};
163use std::hash::{Hash, Hasher};
......@@ -18,8 +5,22 @@ use std::marker::PhantomData;
185use std::ops::{Deref, DerefMut};
196use std::panic;
207use std::thread::panicking;
8
9use rustc_data_structures::fx::FxIndexMap;
10use rustc_error_messages::{fluent_value_from_str_list_sep_by_and, FluentValue};
11use rustc_lint_defs::{Applicability, LintExpectationId};
12use rustc_macros::{Decodable, Encodable};
13use rustc_span::source_map::Spanned;
14use rustc_span::symbol::Symbol;
15use rustc_span::{Span, DUMMY_SP};
2116use tracing::debug;
2217
18use crate::snippet::Style;
19use crate::{
20 CodeSuggestion, DiagCtxtHandle, DiagMessage, ErrCode, ErrorGuaranteed, ExplicitBug, Level,
21 MultiSpan, StashKey, SubdiagMessage, Substitution, SubstitutionPart, SuggestionStyle,
22};
23
2324/// Error type for `DiagInner`'s `suggestions` field, indicating that
2425/// `.disable_suggestions()` was called on the `DiagInner`.
2526#[derive(Clone, Debug, PartialEq, Eq, Hash, Encodable, Decodable)]
compiler/rustc_errors/src/diagnostic_impls.rs+14-14
......@@ -1,12 +1,11 @@
1use crate::diagnostic::DiagLocation;
2use crate::{fluent_generated as fluent, DiagCtxtHandle, Subdiagnostic};
3use crate::{
4 Diag, DiagArgValue, Diagnostic, EmissionGuarantee, ErrCode, IntoDiagArg, Level,
5 SubdiagMessageOp,
6};
7use rustc_ast as ast;
1use std::backtrace::Backtrace;
2use std::borrow::Cow;
3use std::fmt;
4use std::num::ParseIntError;
5use std::path::{Path, PathBuf};
6use std::process::ExitStatus;
7
88use rustc_ast_pretty::pprust;
9use rustc_hir as hir;
109use rustc_macros::Subdiagnostic;
1110use rustc_span::edition::Edition;
1211use rustc_span::symbol::{Ident, MacroRulesNormalizedIdent, Symbol};
......@@ -14,12 +13,13 @@ use rustc_span::Span;
1413use rustc_target::abi::TargetDataLayoutErrors;
1514use rustc_target::spec::{PanicStrategy, SplitDebuginfo, StackProtector, TargetTriple};
1615use rustc_type_ir::{ClosureKind, FloatTy};
17use std::backtrace::Backtrace;
18use std::borrow::Cow;
19use std::fmt;
20use std::num::ParseIntError;
21use std::path::{Path, PathBuf};
22use std::process::ExitStatus;
16use {rustc_ast as ast, rustc_hir as hir};
17
18use crate::diagnostic::DiagLocation;
19use crate::{
20 fluent_generated as fluent, Diag, DiagArgValue, DiagCtxtHandle, Diagnostic, EmissionGuarantee,
21 ErrCode, IntoDiagArg, Level, SubdiagMessageOp, Subdiagnostic,
22};
2323
2424pub struct DiagArgFromDisplay<'a>(pub &'a dyn fmt::Display);
2525
compiler/rustc_errors/src/emitter.rs+19-19
......@@ -7,35 +7,35 @@
77//!
88//! The output types are defined in `rustc_session::config::ErrorOutputType`.
99
10use std::borrow::Cow;
11use std::cmp::{max, min, Reverse};
12use std::error::Report;
13use std::io::prelude::*;
14use std::io::{self, IsTerminal};
15use std::iter;
16use std::path::Path;
17
18use derive_setters::Setters;
19use rustc_data_structures::fx::{FxHashMap, FxIndexMap, FxIndexSet};
20use rustc_data_structures::sync::{DynSend, IntoDynSyncSend, Lrc};
21use rustc_error_messages::{FluentArgs, SpanLabel};
22use rustc_lint_defs::pluralize;
23use rustc_span::hygiene::{ExpnKind, MacroKind};
1024use rustc_span::source_map::SourceMap;
1125use rustc_span::{char_width, FileLines, FileName, SourceFile, Span};
26use termcolor::{Buffer, BufferWriter, Color, ColorChoice, ColorSpec, StandardStream, WriteColor};
27use tracing::{debug, instrument, trace, warn};
1228
29use crate::diagnostic::DiagLocation;
1330use crate::snippet::{
1431 Annotation, AnnotationColumn, AnnotationType, Line, MultilineAnnotation, Style, StyledString,
1532};
1633use crate::styled_buffer::StyledBuffer;
1734use crate::translation::{to_fluent_args, Translate};
1835use 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,
2238};
23use derive_setters::Setters;
24use rustc_data_structures::fx::{FxHashMap, FxIndexMap, FxIndexSet};
25use rustc_data_structures::sync::{DynSend, IntoDynSyncSend, Lrc};
26use rustc_error_messages::{FluentArgs, SpanLabel};
27use rustc_lint_defs::pluralize;
28use rustc_span::hygiene::{ExpnKind, MacroKind};
29use std::borrow::Cow;
30use std::cmp::{max, min, Reverse};
31use std::error::Report;
32use std::io::prelude::*;
33use std::io::{self, IsTerminal};
34use std::iter;
35use std::path::Path;
36use termcolor::{Buffer, BufferWriter, ColorChoice, ColorSpec, StandardStream};
37use termcolor::{Color, WriteColor};
38use tracing::{debug, instrument, trace, warn};
3939
4040/// Default column width, used in tests and when terminal dimensions cannot be determined.
4141const DEFAULT_COLUMN_WIDTH: usize = 140;
compiler/rustc_errors/src/error.rs+3-4
......@@ -1,11 +1,10 @@
1use rustc_error_messages::{
2 fluent_bundle::resolver::errors::{ReferenceKind, ResolverError},
3 FluentArgs, FluentError,
4};
51use std::borrow::Cow;
62use std::error::Error;
73use std::fmt;
84
5use rustc_error_messages::fluent_bundle::resolver::errors::{ReferenceKind, ResolverError};
6use rustc_error_messages::{FluentArgs, FluentError};
7
98#[derive(Debug)]
109pub enum TranslateError<'args> {
1110 One {
compiler/rustc_errors/src/json.rs+17-15
......@@ -9,16 +9,12 @@
99
1010// FIXME: spec the JSON output properly.
1111
12use crate::emitter::{
13 should_show_source_code, ColorConfig, Destination, Emitter, HumanEmitter,
14 HumanReadableErrorType,
15};
16use crate::registry::Registry;
17use crate::translation::{to_fluent_args, Translate};
18use crate::{
19 diagnostic::IsLint, CodeSuggestion, FluentBundle, LazyFallbackBundle, MultiSpan, SpanLabel,
20 Subdiag, TerminalUrl,
21};
12use std::error::Report;
13use std::io::{self, Write};
14use std::path::Path;
15use std::sync::{Arc, Mutex};
16use std::vec;
17
2218use derive_setters::Setters;
2319use rustc_data_structures::sync::{IntoDynSyncSend, Lrc};
2420use rustc_error_messages::FluentArgs;
......@@ -27,13 +23,19 @@ use rustc_span::hygiene::ExpnData;
2723use rustc_span::source_map::SourceMap;
2824use rustc_span::Span;
2925use serde::Serialize;
30use std::error::Report;
31use std::io::{self, Write};
32use std::path::Path;
33use std::sync::{Arc, Mutex};
34use std::vec;
3526use termcolor::{ColorSpec, WriteColor};
3627
28use crate::diagnostic::IsLint;
29use crate::emitter::{
30 should_show_source_code, ColorConfig, Destination, Emitter, HumanEmitter,
31 HumanReadableErrorType,
32};
33use crate::registry::Registry;
34use crate::translation::{to_fluent_args, Translate};
35use crate::{
36 CodeSuggestion, FluentBundle, LazyFallbackBundle, MultiSpan, SpanLabel, Subdiag, TerminalUrl,
37};
38
3739#[cfg(test)]
3840mod tests;
3941
compiler/rustc_errors/src/json/tests.rs+4-5
......@@ -1,13 +1,12 @@
1use super::*;
1use std::str;
22
3use crate::DiagCtxt;
43use rustc_span::source_map::FilePathMapping;
54use rustc_span::BytePos;
6
7use std::str;
8
95use serde::Deserialize;
106
7use super::*;
8use crate::DiagCtxt;
9
1110#[derive(Deserialize, Debug, PartialEq, Eq)]
1211struct TestData {
1312 spans: Vec<SpanTestData>,
compiler/rustc_errors/src/lib.rs+21-24
......@@ -28,6 +28,17 @@
2828
2929extern crate self as rustc_errors;
3030
31use std::backtrace::{Backtrace, BacktraceStatus};
32use std::borrow::Cow;
33use std::cell::Cell;
34use std::error::Report;
35use std::hash::Hash;
36use std::io::Write;
37use std::num::NonZero;
38use std::ops::DerefMut;
39use std::path::{Path, PathBuf};
40use std::{fmt, panic};
41
3142pub use codes::*;
3243pub use diagnostic::{
3344 BugAbort, Diag, DiagArg, DiagArgMap, DiagArgName, DiagArgValue, DiagInner, DiagStyledString,
......@@ -39,42 +50,28 @@ pub use diagnostic_impls::{
3950 IndicateAnonymousLifetime, SingleLabelManySpans,
4051};
4152pub use emitter::ColorConfig;
53use emitter::{is_case_difference, DynEmitter, Emitter};
54use registry::Registry;
55use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet};
56use rustc_data_structures::stable_hasher::{Hash128, StableHasher};
57use rustc_data_structures::sync::{Lock, Lrc};
58use rustc_data_structures::AtomicRef;
4259pub use rustc_error_messages::{
4360 fallback_fluent_bundle, fluent_bundle, DiagMessage, FluentBundle, LanguageIdentifier,
4461 LazyFallbackBundle, MultiSpan, SpanLabel, SubdiagMessage,
4562};
63use rustc_lint_defs::LintExpectationId;
4664pub use rustc_lint_defs::{pluralize, Applicability};
65use rustc_macros::{Decodable, Encodable};
4766pub use rustc_span::fatal_error::{FatalError, FatalErrorMarker};
67use rustc_span::source_map::SourceMap;
4868pub use rustc_span::ErrorGuaranteed;
69use rustc_span::{Loc, Span, DUMMY_SP};
4970pub use snippet::Style;
50
5171// Used by external projects such as `rust-gpu`.
5272// See https://github.com/rust-lang/rust/pull/115393.
5373pub use termcolor::{Color, ColorSpec, WriteColor};
54
55use emitter::{is_case_difference, DynEmitter, Emitter};
56use registry::Registry;
57use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet};
58use rustc_data_structures::stable_hasher::{Hash128, StableHasher};
59use rustc_data_structures::sync::{Lock, Lrc};
60use rustc_data_structures::AtomicRef;
61use rustc_lint_defs::LintExpectationId;
62use rustc_macros::{Decodable, Encodable};
63use rustc_span::source_map::SourceMap;
64use rustc_span::{Loc, Span, DUMMY_SP};
65use std::backtrace::{Backtrace, BacktraceStatus};
66use std::borrow::Cow;
67use std::cell::Cell;
68use std::error::Report;
69use std::fmt;
70use std::hash::Hash;
71use std::io::Write;
72use std::num::NonZero;
73use std::ops::DerefMut;
74use std::panic;
75use std::path::{Path, PathBuf};
7674use tracing::debug;
77
7875use Level::*;
7976
8077pub 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> {
1616 use std::ffi::CString;
1717 use std::io;
1818
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,
2323 };
2424
2525 struct Handle(HANDLE);
compiler/rustc_errors/src/markdown/parse.rs+2-1
......@@ -1,6 +1,7 @@
1use crate::markdown::{MdStream, MdTree};
21use std::{iter, mem, str};
32
3use crate::markdown::{MdStream, MdTree};
4
45/// Short aliases that we can use in match patterns. If an end pattern is not
56/// included, this type may be variable
67const ANC_E: &[u8] = b">";
compiler/rustc_errors/src/markdown/tests/parse.rs+2-1
......@@ -1,6 +1,7 @@
1use super::*;
21use ParseOpt as PO;
32
3use super::*;
4
45#[test]
56fn test_parse_simple() {
67 let buf = "**abcd** rest";
compiler/rustc_errors/src/markdown/tests/term.rs+1
......@@ -1,5 +1,6 @@
11use std::io::BufWriter;
22use std::path::PathBuf;
3
34use termcolor::{BufferWriter, ColorChoice};
45
56use super::*;
compiler/rustc_errors/src/registry.rs+2-1
......@@ -1,6 +1,7 @@
1use crate::ErrCode;
21use rustc_data_structures::fx::FxHashMap;
32
3use crate::ErrCode;
4
45#[derive(Debug)]
56pub struct InvalidErrorCode;
67
compiler/rustc_errors/src/snippet.rs+2-1
......@@ -1,8 +1,9 @@
11// Code for annotating snippets.
22
3use crate::{Level, Loc};
43use rustc_macros::{Decodable, Encodable};
54
5use crate::{Level, Loc};
6
67#[derive(Clone, Debug, PartialOrd, Ord, PartialEq, Eq)]
78pub struct Line {
89 pub line_index: usize,
compiler/rustc_errors/src/tests.rs+4-4
......@@ -1,11 +1,11 @@
1use rustc_data_structures::sync::{IntoDynSyncSend, Lrc};
2use rustc_error_messages::fluent_bundle::resolver::errors::{ReferenceKind, ResolverError};
3use rustc_error_messages::{langid, DiagMessage};
4
15use crate::error::{TranslateError, TranslateErrorKind};
26use crate::fluent_bundle::*;
37use crate::translation::Translate;
48use crate::FluentBundle;
5use rustc_data_structures::sync::{IntoDynSyncSend, Lrc};
6use rustc_error_messages::fluent_bundle::resolver::errors::{ReferenceKind, ResolverError};
7use rustc_error_messages::langid;
8use rustc_error_messages::DiagMessage;
99
1010struct Dummy {
1111 bundle: FluentBundle,
compiler/rustc_errors/src/translation.rs+7-5
......@@ -1,13 +1,15 @@
1use crate::error::{TranslateError, TranslateErrorKind};
2use crate::snippet::Style;
3use crate::{DiagArg, DiagMessage, FluentBundle};
4use rustc_data_structures::sync::Lrc;
5pub use rustc_error_messages::FluentArgs;
61use std::borrow::Cow;
72use std::env;
83use std::error::Report;
4
5use rustc_data_structures::sync::Lrc;
6pub use rustc_error_messages::FluentArgs;
97use tracing::{debug, trace};
108
9use crate::error::{TranslateError, TranslateErrorKind};
10use crate::snippet::Style;
11use crate::{DiagArg, DiagMessage, FluentBundle};
12
1113/// Convert diagnostic arguments (a rustc internal type that exists to implement
1214/// `Encodable`/`Decodable`) into `FluentArgs` which is necessary to perform translation.
1315///
compiler/rustc_expand/src/base.rs+13-10
......@@ -1,7 +1,7 @@
1use crate::base::ast::NestedMetaItem;
2use crate::errors;
3use crate::expand::{self, AstFragment, Invocation};
4use crate::module::DirOwnership;
1use std::default::Default;
2use std::iter;
3use std::path::{Path, PathBuf};
4use std::rc::Rc;
55
66use rustc_ast::attr::MarkedAttrs;
77use rustc_ast::ptr::P;
......@@ -15,9 +15,11 @@ use rustc_data_structures::sync::{self, Lrc};
1515use rustc_errors::{DiagCtxtHandle, ErrorGuaranteed, PResult};
1616use rustc_feature::Features;
1717use rustc_lint_defs::{BufferedEarlyLint, RegisteredTools};
18use rustc_parse::{parser::Parser, MACRO_ARGUMENTS};
18use rustc_parse::parser::Parser;
19use rustc_parse::MACRO_ARGUMENTS;
1920use rustc_session::config::CollapseMacroDebuginfo;
20use rustc_session::{parse::ParseSess, Limit, Session};
21use rustc_session::parse::ParseSess;
22use rustc_session::{Limit, Session};
2123use rustc_span::def_id::{CrateNum, DefId, LocalDefId};
2224use rustc_span::edition::Edition;
2325use rustc_span::hygiene::{AstPass, ExpnData, ExpnKind, LocalExpnId, MacroKind};
......@@ -25,12 +27,13 @@ use rustc_span::source_map::SourceMap;
2527use rustc_span::symbol::{kw, sym, Ident, Symbol};
2628use rustc_span::{FileName, Span, DUMMY_SP};
2729use smallvec::{smallvec, SmallVec};
28use std::default::Default;
29use std::iter;
30use std::path::{Path, PathBuf};
31use std::rc::Rc;
3230use thin_vec::ThinVec;
3331
32use crate::base::ast::NestedMetaItem;
33use crate::errors;
34use crate::expand::{self, AstFragment, Invocation};
35use crate::module::DirOwnership;
36
3437// When adding new variants, make sure to
3538// adjust the `visit_*` / `flat_map_*` calls in `InvocationCollector`
3639// to use `assign_id!`
compiler/rustc_expand/src/build.rs+6-3
......@@ -1,12 +1,15 @@
1use crate::base::ExtCtxt;
21use rustc_ast::ptr::P;
3use rustc_ast::{self as ast, AttrVec, BlockCheckMode, Expr, LocalKind, MatchKind, PatKind, UnOp};
4use rustc_ast::{attr, token, util::literal};
2use rustc_ast::util::literal;
3use rustc_ast::{
4 self as ast, attr, token, AttrVec, BlockCheckMode, Expr, LocalKind, MatchKind, PatKind, UnOp,
5};
56use rustc_span::source_map::Spanned;
67use rustc_span::symbol::{kw, sym, Ident, Symbol};
78use rustc_span::{Span, DUMMY_SP};
89use thin_vec::{thin_vec, ThinVec};
910
11use crate::base::ExtCtxt;
12
1013impl<'a> ExtCtxt<'a> {
1114 pub fn path(&self, span: Span, strs: Vec<Ident>) -> ast::Path {
1215 self.path_all(span, false, strs, vec![])
compiler/rustc_expand/src/config.rs+10-10
......@@ -1,19 +1,14 @@
11//! Conditional compilation stripping.
22
3use crate::errors::{
4 FeatureNotAllowed, FeatureRemoved, FeatureRemovedReason, InvalidCfg, MalformedFeatureAttribute,
5 MalformedFeatureAttributeHelp, RemoveExprNotSupported,
6};
73use rustc_ast::ptr::P;
84use rustc_ast::token::{Delimiter, Token, TokenKind};
9use rustc_ast::tokenstream::{AttrTokenStream, AttrTokenTree, Spacing};
10use rustc_ast::tokenstream::{LazyAttrTokenStream, TokenTree};
11use rustc_ast::NodeId;
12use rustc_ast::{self as ast, AttrStyle, Attribute, HasAttrs, HasTokens, MetaItem};
5use rustc_ast::tokenstream::{
6 AttrTokenStream, AttrTokenTree, LazyAttrTokenStream, Spacing, TokenTree,
7};
8use rustc_ast::{self as ast, AttrStyle, Attribute, HasAttrs, HasTokens, MetaItem, NodeId};
139use rustc_attr as attr;
1410use rustc_data_structures::flat_map_in_place::FlatMapInPlace;
15use rustc_feature::Features;
16use rustc_feature::{ACCEPTED_FEATURES, REMOVED_FEATURES, UNSTABLE_FEATURES};
11use rustc_feature::{Features, ACCEPTED_FEATURES, REMOVED_FEATURES, UNSTABLE_FEATURES};
1712use rustc_lint_defs::BuiltinLintDiag;
1813use rustc_parse::validate_attr;
1914use rustc_session::parse::feature_err;
......@@ -23,6 +18,11 @@ use rustc_span::Span;
2318use thin_vec::ThinVec;
2419use tracing::instrument;
2520
21use crate::errors::{
22 FeatureNotAllowed, FeatureRemoved, FeatureRemovedReason, InvalidCfg, MalformedFeatureAttribute,
23 MalformedFeatureAttributeHelp, RemoveExprNotSupported,
24};
25
2626/// A folder that strips out items that do not belong in the current configuration.
2727pub struct StripUnconfigured<'a> {
2828 pub sess: &'a Session,
compiler/rustc_expand/src/errors.rs+2-1
......@@ -1,10 +1,11 @@
1use std::borrow::Cow;
2
13use rustc_ast::ast;
24use rustc_errors::codes::*;
35use rustc_macros::{Diagnostic, Subdiagnostic};
46use rustc_session::Limit;
57use rustc_span::symbol::{Ident, MacroRulesNormalizedIdent};
68use rustc_span::{Span, Symbol};
7use std::borrow::Cow;
89
910#[derive(Diagnostic)]
1011#[diag(expand_expr_repeat_no_syntax_vars)]
compiler/rustc_expand/src/expand.rs+20-19
......@@ -1,13 +1,7 @@
1use crate::base::*;
2use crate::config::StripUnconfigured;
3use crate::errors::{
4 EmptyDelegationMac, GlobDelegationOutsideImpls, GlobDelegationTraitlessQpath, IncompleteParse,
5 RecursionLimitReached, RemoveExprNotSupported, RemoveNodeNotSupported, UnsupportedKeyValue,
6 WrongFragmentKind,
7};
8use crate::mbe::diagnostics::annotate_err_with_kind;
9use crate::module::{mod_dir_path, parse_external_mod, DirOwnership, ParsedExternalMod};
10use crate::placeholders::{placeholder, PlaceholderExpander};
1use std::ops::Deref;
2use std::path::PathBuf;
3use std::rc::Rc;
4use std::{iter, mem};
115
126use rustc_ast as ast;
137use rustc_ast::mut_visit::*;
......@@ -15,10 +9,11 @@ use rustc_ast::ptr::P;
159use rustc_ast::token::{self, Delimiter};
1610use rustc_ast::tokenstream::TokenStream;
1711use rustc_ast::visit::{self, try_visit, walk_list, AssocCtxt, Visitor, VisitorResult};
18use rustc_ast::{AssocItemKind, AstNodeWrapper, AttrArgs, AttrStyle, AttrVec, ExprKind};
19use rustc_ast::{ForeignItemKind, HasAttrs, HasNodeId};
20use rustc_ast::{Inline, ItemKind, MacStmtStyle, MetaItemKind, ModKind};
21use rustc_ast::{NestedMetaItem, NodeId, PatKind, StmtKind, TyKind};
12use 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};
2217use rustc_ast_pretty::pprust;
2318use rustc_data_structures::flat_map_in_place::FlatMapInPlace;
2419use rustc_data_structures::sync::Lrc;
......@@ -35,12 +30,18 @@ use rustc_session::{Limit, Session};
3530use rustc_span::hygiene::SyntaxContext;
3631use rustc_span::symbol::{sym, Ident};
3732use rustc_span::{ErrorGuaranteed, FileName, LocalExpnId, Span};
38
3933use smallvec::SmallVec;
40use std::ops::Deref;
41use std::path::PathBuf;
42use std::rc::Rc;
43use std::{iter, mem};
34
35use crate::base::*;
36use crate::config::StripUnconfigured;
37use crate::errors::{
38 EmptyDelegationMac, GlobDelegationOutsideImpls, GlobDelegationTraitlessQpath, IncompleteParse,
39 RecursionLimitReached, RemoveExprNotSupported, RemoveNodeNotSupported, UnsupportedKeyValue,
40 WrongFragmentKind,
41};
42use crate::mbe::diagnostics::annotate_err_with_kind;
43use crate::module::{mod_dir_path, parse_external_mod, DirOwnership, ParsedExternalMod};
44use crate::placeholders::{placeholder, PlaceholderExpander};
4445
4546macro_rules! ast_fragments {
4647 (
compiler/rustc_expand/src/mbe/diagnostics.rs+7-7
......@@ -1,9 +1,5 @@
1use crate::base::{DummyResult, ExtCtxt, MacResult};
2use crate::expand::{parse_ast_fragment, AstFragmentKind};
3use crate::mbe::{
4 macro_parser::{MatcherLoc, NamedParseResult, ParseResult::*, TtParser},
5 macro_rules::{try_match_macro, Tracker},
6};
1use std::borrow::Cow;
2
73use rustc_ast::token::{self, Token, TokenKind};
84use rustc_ast::tokenstream::TokenStream;
95use rustc_ast_pretty::pprust;
......@@ -13,10 +9,14 @@ use rustc_parse::parser::{Parser, Recovery};
139use rustc_span::source_map::SourceMap;
1410use rustc_span::symbol::Ident;
1511use rustc_span::{ErrorGuaranteed, Span};
16use std::borrow::Cow;
1712use tracing::debug;
1813
1914use super::macro_rules::{parser_from_cx, NoopTracker};
15use crate::base::{DummyResult, ExtCtxt, MacResult};
16use crate::expand::{parse_ast_fragment, AstFragmentKind};
17use crate::mbe::macro_parser::ParseResult::*;
18use crate::mbe::macro_parser::{MatcherLoc, NamedParseResult, TtParser};
19use crate::mbe::macro_rules::{try_match_macro, Tracker};
2020
2121pub(super) fn failed_to_match_macro<'cx>(
2222 cx: &'cx mut ExtCtxt<'_>,
compiler/rustc_expand/src/mbe/macro_check.rs+5-7
......@@ -105,8 +105,7 @@
105105//! stored when entering a macro definition starting from the state in which the meta-variable is
106106//! bound.
107107
108use crate::errors;
109use crate::mbe::{KleeneToken, TokenTree};
108use std::iter;
110109
111110use rustc_ast::token::{Delimiter, IdentIsRaw, Token, TokenKind};
112111use rustc_ast::{NodeId, DUMMY_NODE_ID};
......@@ -116,14 +115,13 @@ use rustc_lint_defs::BuiltinLintDiag;
116115use rustc_session::lint::builtin::{META_VARIABLE_MISUSE, MISSING_FRAGMENT_SPECIFIER};
117116use rustc_session::parse::ParseSess;
118117use rustc_span::edition::Edition;
119use rustc_span::symbol::kw;
120use rustc_span::{symbol::MacroRulesNormalizedIdent, ErrorGuaranteed, Span};
121
118use rustc_span::symbol::{kw, MacroRulesNormalizedIdent};
119use rustc_span::{ErrorGuaranteed, Span};
122120use smallvec::SmallVec;
123121
124use std::iter;
125
126122use super::quoted::VALID_FRAGMENT_NAMES_MSG_2021;
123use crate::errors;
124use crate::mbe::{KleeneToken, TokenTree};
127125
128126/// Stack represented as linked list.
129127///
compiler/rustc_expand/src/mbe/macro_parser.rs+10-10
......@@ -70,10 +70,10 @@
7070//! eof: [a $( a )* a b ·]
7171//! ```
7272
73pub(crate) use NamedMatch::*;
74pub(crate) use ParseResult::*;
75
76use crate::mbe::{macro_rules::Tracker, KleeneOp, TokenTree};
73use std::borrow::Cow;
74use std::collections::hash_map::Entry::{Occupied, Vacant};
75use std::fmt::Display;
76use std::rc::Rc;
7777
7878use rustc_ast::token::{self, DocComment, NonterminalKind, Token};
7979use rustc_ast_pretty::pprust;
......@@ -81,13 +81,13 @@ use rustc_data_structures::fx::FxHashMap;
8181use rustc_errors::ErrorGuaranteed;
8282use rustc_lint_defs::pluralize;
8383use rustc_parse::parser::{ParseNtResult, Parser};
84use rustc_span::symbol::Ident;
85use rustc_span::symbol::MacroRulesNormalizedIdent;
84use rustc_span::symbol::{Ident, MacroRulesNormalizedIdent};
8685use rustc_span::Span;
87use std::borrow::Cow;
88use std::collections::hash_map::Entry::{Occupied, Vacant};
89use std::fmt::Display;
90use std::rc::Rc;
86pub(crate) use NamedMatch::*;
87pub(crate) use ParseResult::*;
88
89use crate::mbe::macro_rules::Tracker;
90use crate::mbe::{KleeneOp, TokenTree};
9191
9292/// A unit within a matcher that a `MatcherPos` can refer to. Similar to (and derived from)
9393/// `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 @@
1use crate::base::{DummyResult, SyntaxExtension, SyntaxExtensionKind};
2use crate::base::{ExpandResult, ExtCtxt, MacResult, MacroExpanderResult, TTMacroExpander};
3use crate::expand::{ensure_complete_parse, parse_ast_fragment, AstFragment, AstFragmentKind};
4use crate::mbe;
5use crate::mbe::diagnostics::{annotate_doc_comment, parse_failure_msg};
6use crate::mbe::macro_check;
7use crate::mbe::macro_parser::{Error, ErrorReported, Failure, Success, TtParser};
8use crate::mbe::macro_parser::{MatcherLoc, NamedMatch::*};
9use crate::mbe::transcribe::transcribe;
1use std::borrow::Cow;
2use std::collections::hash_map::Entry;
3use std::{mem, slice};
104
115use ast::token::IdentIsRaw;
126use rustc_ast as ast;
13use rustc_ast::token::{
14 self, Delimiter, NonterminalKind, NtPatKind::*, Token, TokenKind, TokenKind::*,
15};
7use rustc_ast::token::NtPatKind::*;
8use rustc_ast::token::TokenKind::*;
9use rustc_ast::token::{self, Delimiter, NonterminalKind, Token, TokenKind};
1610use rustc_ast::tokenstream::{DelimSpan, TokenStream};
1711use rustc_ast::{NodeId, DUMMY_NODE_ID};
1812use rustc_ast_pretty::pprust;
......@@ -33,12 +27,19 @@ use rustc_span::symbol::{kw, sym, Ident, MacroRulesNormalizedIdent};
3327use rustc_span::Span;
3428use tracing::{debug, instrument, trace, trace_span};
3529
36use std::borrow::Cow;
37use std::collections::hash_map::Entry;
38use std::{mem, slice};
39
4030use super::diagnostics;
4131use super::macro_parser::{NamedMatches, NamedParseResult};
32use crate::base::{
33 DummyResult, ExpandResult, ExtCtxt, MacResult, MacroExpanderResult, SyntaxExtension,
34 SyntaxExtensionKind, TTMacroExpander,
35};
36use crate::expand::{ensure_complete_parse, parse_ast_fragment, AstFragment, AstFragmentKind};
37use crate::mbe;
38use crate::mbe::diagnostics::{annotate_doc_comment, parse_failure_msg};
39use crate::mbe::macro_check;
40use crate::mbe::macro_parser::NamedMatch::*;
41use crate::mbe::macro_parser::{Error, ErrorReported, Failure, MatcherLoc, Success, TtParser};
42use crate::mbe::transcribe::transcribe;
4243
4344pub(crate) struct ParserAnyMacro<'a> {
4445 parser: Parser<'a>,
compiler/rustc_expand/src/mbe/quoted.rs+7-7
......@@ -1,18 +1,18 @@
1use crate::errors;
2use crate::mbe::macro_parser::count_metavar_decls;
3use crate::mbe::{Delimited, KleeneOp, KleeneToken, MetaVarExpr, SequenceRepetition, TokenTree};
4
5use rustc_ast::token::{self, Delimiter, IdentIsRaw, NonterminalKind, NtExprKind::*, Token};
1use rustc_ast::token::NtExprKind::*;
2use rustc_ast::token::{self, Delimiter, IdentIsRaw, NonterminalKind, Token};
63use rustc_ast::{tokenstream, NodeId};
74use rustc_ast_pretty::pprust;
85use rustc_feature::Features;
96use rustc_session::parse::feature_err;
107use rustc_session::Session;
11use rustc_span::symbol::{kw, sym, Ident};
12
138use rustc_span::edition::Edition;
9use rustc_span::symbol::{kw, sym, Ident};
1410use rustc_span::Span;
1511
12use crate::errors;
13use crate::mbe::macro_parser::count_metavar_decls;
14use crate::mbe::{Delimited, KleeneOp, KleeneToken, MetaVarExpr, SequenceRepetition, TokenTree};
15
1616const VALID_FRAGMENT_NAMES_MSG: &str = "valid fragment specifiers are \
1717 `ident`, `block`, `stmt`, `expr`, `pat`, `ty`, `lifetime`, \
1818 `literal`, `path`, `meta`, `tt`, `item` and `vis`";
compiler/rustc_expand/src/mbe/transcribe.rs+13-12
......@@ -1,26 +1,27 @@
1use crate::errors::{
2 CountRepetitionMisplaced, MetaVarExprUnrecognizedVar, MetaVarsDifSeqMatchers, MustRepeatOnce,
3 NoSyntaxVarsExprRepeat, VarStillRepeating,
4};
5use crate::mbe::macro_parser::{NamedMatch, NamedMatch::*};
6use crate::mbe::metavar_expr::{MetaVarExprConcatElem, RAW_IDENT_ERR};
7use crate::mbe::{self, KleeneOp, MetaVarExpr};
1use std::mem;
2
83use rustc_ast::mut_visit::{self, MutVisitor};
9use rustc_ast::token::{self, Delimiter, Nonterminal, Token, TokenKind};
10use rustc_ast::token::{IdentIsRaw, Lit, LitKind};
4use rustc_ast::token::{self, Delimiter, IdentIsRaw, Lit, LitKind, Nonterminal, Token, TokenKind};
115use rustc_ast::tokenstream::{DelimSpacing, DelimSpan, Spacing, TokenStream, TokenTree};
126use rustc_ast::ExprKind;
137use rustc_data_structures::fx::FxHashMap;
148use rustc_errors::{pluralize, Diag, DiagCtxtHandle, PResult};
159use rustc_parse::lexer::nfc_normalize;
1610use rustc_parse::parser::ParseNtResult;
17use rustc_session::parse::ParseSess;
18use rustc_session::parse::SymbolGallery;
11use rustc_session::parse::{ParseSess, SymbolGallery};
1912use rustc_span::hygiene::{LocalExpnId, Transparency};
2013use rustc_span::symbol::{sym, Ident, MacroRulesNormalizedIdent};
2114use rustc_span::{with_metavar_spans, Span, Symbol, SyntaxContext};
2215use smallvec::{smallvec, SmallVec};
23use std::mem;
16
17use crate::errors::{
18 CountRepetitionMisplaced, MetaVarExprUnrecognizedVar, MetaVarsDifSeqMatchers, MustRepeatOnce,
19 NoSyntaxVarsExprRepeat, VarStillRepeating,
20};
21use crate::mbe::macro_parser::NamedMatch;
22use crate::mbe::macro_parser::NamedMatch::*;
23use crate::mbe::metavar_expr::{MetaVarExprConcatElem, RAW_IDENT_ERR};
24use crate::mbe::{self, KleeneOp, MetaVarExpr};
2425
2526// A Marker adds the given mark to the syntax context.
2627struct Marker(LocalExpnId, Transparency, FxHashMap<SyntaxContext, SyntaxContext>);
compiler/rustc_expand/src/module.rs+9-8
......@@ -1,20 +1,21 @@
1use crate::base::ModuleData;
2use crate::errors::{
3 ModuleCircular, ModuleFileNotFound, ModuleInBlock, ModuleInBlockName, ModuleMultipleCandidates,
4};
1use std::iter::once;
2use std::path::{self, Path, PathBuf};
3
54use rustc_ast::ptr::P;
65use rustc_ast::{token, AttrVec, Attribute, Inline, Item, ModSpans};
76use rustc_errors::{Diag, ErrorGuaranteed};
8use rustc_parse::validate_attr;
9use rustc_parse::{new_parser_from_file, unwrap_or_emit_fatal};
7use rustc_parse::{new_parser_from_file, unwrap_or_emit_fatal, validate_attr};
108use rustc_session::parse::ParseSess;
119use rustc_session::Session;
1210use rustc_span::symbol::{sym, Ident};
1311use rustc_span::Span;
14use std::iter::once;
15use std::path::{self, Path, PathBuf};
1612use thin_vec::ThinVec;
1713
14use crate::base::ModuleData;
15use crate::errors::{
16 ModuleCircular, ModuleFileNotFound, ModuleInBlock, ModuleInBlockName, ModuleMultipleCandidates,
17};
18
1819#[derive(Copy, Clone)]
1920pub enum DirOwnership {
2021 Owned {
compiler/rustc_expand/src/placeholders.rs+4-2
......@@ -1,14 +1,16 @@
1use crate::expand::{AstFragment, AstFragmentKind};
21use rustc_ast::mut_visit::*;
32use rustc_ast::ptr::P;
43use rustc_ast::token::Delimiter;
5use rustc_ast::{self as ast, visit::AssocCtxt};
4use rustc_ast::visit::AssocCtxt;
5use rustc_ast::{self as ast};
66use rustc_data_structures::fx::FxHashMap;
77use rustc_span::symbol::Ident;
88use rustc_span::DUMMY_SP;
99use smallvec::{smallvec, SmallVec};
1010use thin_vec::ThinVec;
1111
12use crate::expand::{AstFragment, AstFragmentKind};
13
1214pub(crate) fn placeholder(
1315 kind: AstFragmentKind,
1416 id: ast::NodeId,
compiler/rustc_expand/src/proc_macro.rs+3-4
......@@ -1,7 +1,3 @@
1use crate::base::{self, *};
2use crate::errors;
3use crate::proc_macro_server;
4
51use rustc_ast as ast;
62use rustc_ast::ptr::P;
73use rustc_ast::tokenstream::TokenStream;
......@@ -11,6 +7,9 @@ use rustc_session::config::ProcMacroExecutionStrategy;
117use rustc_span::profiling::SpannedEventArgRecorder;
128use rustc_span::Span;
139
10use crate::base::{self, *};
11use crate::{errors, proc_macro_server};
12
1413struct MessagePipe<T> {
1514 tx: std::sync::mpsc::SyncSender<T>,
1615 rx: std::sync::mpsc::Receiver<T>,
compiler/rustc_expand/src/proc_macro_server.rs+4-2
......@@ -1,4 +1,5 @@
1use crate::base::ExtCtxt;
1use std::ops::{Bound, Range};
2
23use ast::token::IdentIsRaw;
34use pm::bridge::{
45 server, DelimSpan, Diagnostic, ExpnGlobals, Group, Ident, LitKind, Literal, Punct, TokenTree,
......@@ -20,7 +21,8 @@ use rustc_span::def_id::CrateNum;
2021use rustc_span::symbol::{self, sym, Symbol};
2122use rustc_span::{BytePos, FileName, Pos, SourceFile, Span};
2223use smallvec::{smallvec, SmallVec};
23use std::ops::{Bound, Range};
24
25use crate::base::ExtCtxt;
2426
2527trait FromInternal<T> {
2628 fn from_internal(x: T) -> Self;
compiler/rustc_feature/src/accepted.rs+2-1
......@@ -1,8 +1,9 @@
11//! List of the accepted feature gates.
22
3use super::{to_nonzero, Feature};
43use rustc_span::symbol::sym;
54
5use super::{to_nonzero, Feature};
6
67macro_rules! declare_features {
78 ($(
89 $(#[doc = $doc:tt])* (accepted, $feature:ident, $ver:expr, $issue:expr),
compiler/rustc_feature/src/builtin_attrs.rs+4-5
......@@ -1,16 +1,15 @@
11//! Built-in attributes and `cfg` flag gating.
22
3use std::sync::LazyLock;
4
5use rustc_data_structures::fx::FxHashMap;
6use rustc_span::symbol::{sym, Symbol};
37use AttributeDuplicates::*;
48use AttributeGate::*;
59use AttributeType::*;
610
711use crate::{Features, Stability};
812
9use rustc_data_structures::fx::FxHashMap;
10use rustc_span::symbol::{sym, Symbol};
11
12use std::sync::LazyLock;
13
1413type GateFn = fn(&Features) -> bool;
1514
1615macro_rules! cfg_fn {
compiler/rustc_feature/src/lib.rs+4-4
......@@ -25,9 +25,10 @@ mod unstable;
2525#[cfg(test)]
2626mod tests;
2727
28use rustc_span::symbol::Symbol;
2928use std::num::NonZero;
3029
30use rustc_span::symbol::Symbol;
31
3132#[derive(Debug, Clone)]
3233pub struct Feature {
3334 pub name: Symbol,
......@@ -126,11 +127,10 @@ pub fn find_feature_issue(feature: Symbol, issue: GateIssue) -> Option<NonZero<u
126127}
127128
128129pub use accepted::ACCEPTED_FEATURES;
129pub use builtin_attrs::AttributeDuplicates;
130130pub use builtin_attrs::{
131131 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,
134134};
135135pub use removed::REMOVED_FEATURES;
136136pub use unstable::{Features, INCOMPATIBLE_FEATURES, UNSTABLE_FEATURES};
compiler/rustc_feature/src/removed.rs+2-1
......@@ -1,8 +1,9 @@
11//! List of the removed feature gates.
22
3use super::{to_nonzero, Feature};
43use rustc_span::symbol::sym;
54
5use super::{to_nonzero, Feature};
6
67pub struct RemovedFeature {
78 pub feature: Feature,
89 pub reason: Option<&'static str>,
compiler/rustc_feature/src/unstable.rs+2-2
......@@ -1,11 +1,11 @@
11//! List of the unstable feature gates.
22
3use super::{to_nonzero, Feature};
4
53use rustc_data_structures::fx::FxHashSet;
64use rustc_span::symbol::{sym, Symbol};
75use rustc_span::Span;
86
7use super::{to_nonzero, Feature};
8
99pub struct UnstableFeature {
1010 pub feature: Feature,
1111 pub set_enabled: fn(&mut Features),
compiler/rustc_fluent_macro/src/fluent.rs+7-11
......@@ -1,20 +1,16 @@
1use std::collections::{HashMap, HashSet};
2use std::fs::read_to_string;
3use std::path::{Path, PathBuf};
4
15use annotate_snippets::{Annotation, AnnotationType, Renderer, Slice, Snippet, SourceAnnotation};
26use fluent_bundle::{FluentBundle, FluentError, FluentResource};
3use fluent_syntax::{
4 ast::{
5 Attribute, Entry, Expression, Identifier, InlineExpression, Message, Pattern,
6 PatternElement,
7 },
8 parser::ParserError,
7use fluent_syntax::ast::{
8 Attribute, Entry, Expression, Identifier, InlineExpression, Message, Pattern, PatternElement,
99};
10use fluent_syntax::parser::ParserError;
1011use proc_macro::{Diagnostic, Level, Span};
1112use proc_macro2::TokenStream;
1213use quote::quote;
13use std::{
14 collections::{HashMap, HashSet},
15 fs::read_to_string,
16 path::{Path, PathBuf},
17};
1814use syn::{parse_macro_input, Ident, LitStr};
1915use unic_langid::langid;
2016
compiler/rustc_fs_util/src/lib.rs+1-2
......@@ -1,7 +1,6 @@
11use std::ffi::CString;
2use std::fs;
3use std::io;
42use std::path::{absolute, Path, PathBuf};
3use std::{fs, io};
54
65// Unfortunately, on windows, it looks like msvcrt.dll is silently translating
76// 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 @@
279279#![feature(rustdoc_internals)]
280280// tidy-alphabetical-end
281281
282use LabelText::*;
283
284282use std::borrow::Cow;
285283use std::io;
286284use std::io::prelude::*;
287285
286use LabelText::*;
287
288288/// The text for a graphviz label on a node or edge.
289289pub enum LabelText<'a> {
290290 /// This kind of label preserves the text directly as is.
compiler/rustc_graphviz/src/tests.rs+4-2
......@@ -1,9 +1,11 @@
1use super::LabelText::{self, EscStr, HtmlStr, LabelStr};
2use super::{render, Edges, GraphWalk, Id, Labeller, Nodes, Style};
31use std::io;
42use std::io::prelude::*;
3
54use NodeLabels::*;
65
6use super::LabelText::{self, EscStr, HtmlStr, LabelStr};
7use super::{render, Edges, GraphWalk, Id, Labeller, Nodes, Style};
8
79/// each node is an index in a vector in the graph.
810type Node = usize;
911struct Edge {
compiler/rustc_hir/src/def.rs+4-4
......@@ -1,5 +1,5 @@
1use crate::definitions::DefPathData;
2use crate::hir;
1use std::array::IntoIter;
2use std::fmt::Debug;
33
44use rustc_ast as ast;
55use rustc_ast::NodeId;
......@@ -11,8 +11,8 @@ use rustc_span::hygiene::MacroKind;
1111use rustc_span::symbol::kw;
1212use rustc_span::Symbol;
1313
14use std::array::IntoIter;
15use std::fmt::Debug;
14use crate::definitions::DefPathData;
15use crate::hir;
1616
1717/// Encodes if a `DefKind::Ctor` is the constructor of an enum variant or a struct.
1818#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug, HashStable_Generic)]
compiler/rustc_hir/src/definitions.rs+7-5
......@@ -4,18 +4,20 @@
44//! There are also some rather random cases (like const initializer
55//! expressions) that are mostly just leftovers.
66
7pub use crate::def_id::DefPathHash;
8use crate::def_id::{CrateNum, DefIndex, LocalDefId, StableCrateId, CRATE_DEF_INDEX, LOCAL_CRATE};
9use crate::def_path_hash_map::DefPathHashMap;
7use std::fmt::{self, Write};
8use std::hash::Hash;
9
1010use rustc_data_structures::stable_hasher::{Hash64, StableHasher};
1111use rustc_data_structures::unord::UnordMap;
1212use rustc_index::IndexVec;
1313use rustc_macros::{Decodable, Encodable};
1414use rustc_span::symbol::{kw, sym, Symbol};
15use std::fmt::{self, Write};
16use std::hash::Hash;
1715use tracing::{debug, instrument};
1816
17pub use crate::def_id::DefPathHash;
18use crate::def_id::{CrateNum, DefIndex, LocalDefId, StableCrateId, CRATE_DEF_INDEX, LOCAL_CRATE};
19use crate::def_path_hash_map::DefPathHashMap;
20
1921/// The `DefPathTable` maps `DefIndex`es to `DefKey`s and vice versa.
2022/// Internally the `DefPathTable` holds a tree of `DefKey`s, where each `DefKey`
2123/// stores the `DefIndex` of its parent.
compiler/rustc_hir/src/diagnostic_items.rs+2-1
......@@ -1,9 +1,10 @@
1use crate::def_id::DefId;
21use rustc_data_structures::fx::FxIndexMap;
32use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
43use rustc_span::def_id::DefIdMap;
54use rustc_span::Symbol;
65
6use crate::def_id::DefId;
7
78#[derive(Debug, Default)]
89pub struct DiagnosticItems {
910 pub id_to_name: DefIdMap<Symbol>,
compiler/rustc_hir/src/hir.rs+20-13
......@@ -1,29 +1,35 @@
1use crate::def::{CtorKind, DefKind, Res};
2use crate::def_id::{DefId, LocalDefIdMap};
3pub(crate) use crate::hir_id::{HirId, ItemLocalId, ItemLocalMap, OwnerId};
4use crate::intravisit::FnKind;
5use crate::LangItem;
1use std::fmt;
2
63use rustc_ast as ast;
74use rustc_ast::util::parser::ExprPrecedence;
8use rustc_ast::{Attribute, FloatTy, IntTy, Label, LitKind, TraitObjectSyntax, UintTy};
9pub use rustc_ast::{BinOp, BinOpKind, BindingMode, BorrowKind, ByRef, CaptureBy};
10pub use rustc_ast::{ImplPolarity, IsAuto, Movability, Mutability, UnOp};
11use rustc_ast::{InlineAsmOptions, InlineAsmTemplatePiece};
5use rustc_ast::{
6 Attribute, FloatTy, InlineAsmOptions, InlineAsmTemplatePiece, IntTy, Label, LitKind,
7 TraitObjectSyntax, UintTy,
8};
9pub use rustc_ast::{
10 BinOp, BinOpKind, BindingMode, BorrowKind, ByRef, CaptureBy, ImplPolarity, IsAuto, Movability,
11 Mutability, UnOp,
12};
1213use rustc_data_structures::fingerprint::Fingerprint;
1314use rustc_data_structures::sorted_map::SortedMap;
1415use rustc_index::IndexVec;
1516use rustc_macros::{Decodable, Encodable, HashStable_Generic};
17use rustc_span::def_id::LocalDefId;
1618use rustc_span::hygiene::MacroKind;
1719use rustc_span::source_map::Spanned;
1820use rustc_span::symbol::{kw, sym, Ident, Symbol};
19use rustc_span::ErrorGuaranteed;
20use rustc_span::{def_id::LocalDefId, BytePos, Span, DUMMY_SP};
21use rustc_span::{BytePos, ErrorGuaranteed, Span, DUMMY_SP};
2122use rustc_target::asm::InlineAsmRegOrRegClass;
2223use rustc_target::spec::abi::Abi;
2324use smallvec::SmallVec;
24use std::fmt;
2525use tracing::debug;
2626
27use crate::def::{CtorKind, DefKind, Res};
28use crate::def_id::{DefId, LocalDefIdMap};
29pub(crate) use crate::hir_id::{HirId, ItemLocalId, ItemLocalMap, OwnerId};
30use crate::intravisit::FnKind;
31use crate::LangItem;
32
2733#[derive(Debug, Copy, Clone, HashStable_Generic)]
2834pub struct Lifetime {
2935 pub hir_id: HirId,
......@@ -4008,8 +4014,9 @@ impl<'hir> Node<'hir> {
40084014// Some nodes are used a lot. Make sure they don't unintentionally get bigger.
40094015#[cfg(target_pointer_width = "64")]
40104016mod size_asserts {
4011 use super::*;
40124017 use rustc_data_structures::static_assert_size;
4018
4019 use super::*;
40134020 // tidy-alphabetical-start
40144021 static_assert_size!(Block<'_>, 48);
40154022 static_assert_size!(Body<'_>, 24);
compiler/rustc_hir/src/hir_id.rs+6-3
......@@ -1,8 +1,11 @@
1use crate::def_id::{DefId, DefIndex, LocalDefId, CRATE_DEF_ID};
1use std::fmt::{self, Debug};
2
23use rustc_data_structures::stable_hasher::{HashStable, StableHasher, StableOrd, ToStableHashKey};
34use rustc_macros::{Decodable, Encodable, HashStable_Generic};
4use rustc_span::{def_id::DefPathHash, HashStableContext};
5use std::fmt::{self, Debug};
5use rustc_span::def_id::DefPathHash;
6use rustc_span::HashStableContext;
7
8use crate::def_id::{DefId, DefIndex, LocalDefId, CRATE_DEF_ID};
69
710#[derive(Copy, Clone, PartialEq, Eq, Hash, Encodable, Decodable)]
811pub struct OwnerId {
compiler/rustc_hir/src/intravisit.rs+2-1
......@@ -64,13 +64,14 @@
6464//! This order consistency is required in a few places in rustc, for
6565//! example coroutine inference, and possibly also HIR borrowck.
6666
67use crate::hir::*;
6867use rustc_ast::visit::{try_visit, visit_opt, walk_list, VisitorResult};
6968use rustc_ast::{Attribute, Label};
7069use rustc_span::def_id::LocalDefId;
7170use rustc_span::symbol::{Ident, Symbol};
7271use rustc_span::Span;
7372
73use crate::hir::*;
74
7475pub trait IntoVisitor<'hir> {
7576 type Visitor: Visitor<'hir>;
7677 fn into_visitor(&self) -> Self::Visitor;
compiler/rustc_hir/src/lang_items.rs+3-3
......@@ -7,9 +7,6 @@
77//! * Traits that represent operators; e.g., `Add`, `Sub`, `Index`.
88//! * Functions called by the compiler itself.
99
10use crate::def_id::DefId;
11use crate::{MethodKind, Target};
12
1310use rustc_ast as ast;
1411use rustc_data_structures::fx::FxIndexMap;
1512use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
......@@ -17,6 +14,9 @@ use rustc_macros::{Decodable, Encodable, HashStable_Generic};
1714use rustc_span::symbol::{kw, sym, Symbol};
1815use rustc_span::Span;
1916
17use crate::def_id::DefId;
18use crate::{MethodKind, Target};
19
2020/// All of the lang items, defined or not.
2121/// Defined lang items can come from the current crate or its dependencies.
2222#[derive(HashStable_Generic, Debug)]
compiler/rustc_hir/src/pat_util.rs+5-4
......@@ -1,10 +1,11 @@
1use crate::def::{CtorOf, DefKind, Res};
2use crate::def_id::{DefId, DefIdSet};
3use crate::hir::{self, BindingMode, ByRef, HirId, PatKind};
1use std::iter::Enumerate;
2
43use rustc_span::symbol::Ident;
54use rustc_span::Span;
65
7use std::iter::Enumerate;
6use crate::def::{CtorOf, DefKind, Res};
7use crate::def_id::{DefId, DefIdSet};
8use crate::hir::{self, BindingMode, ByRef, HirId, PatKind};
89
910pub struct EnumerateAndAdjust<I> {
1011 enumerate: Enumerate<I>,
compiler/rustc_hir/src/stable_hash_impls.rs+1-1
......@@ -1,10 +1,10 @@
11use rustc_data_structures::stable_hasher::{HashStable, StableHasher, ToStableHashKey};
2use rustc_span::def_id::DefPathHash;
23
34use crate::hir::{
45 AttributeMap, BodyId, Crate, ForeignItemId, ImplItemId, ItemId, OwnerNodes, TraitItemId,
56};
67use crate::hir_id::{HirId, ItemLocalId};
7use rustc_span::def_id::DefPathHash;
88
99/// Requirements for a `StableHashingContext` to be used in this crate.
1010/// This is a hack to allow using the `HashStable_Generic` derive macro
compiler/rustc_hir/src/target.rs+2-3
......@@ -4,11 +4,10 @@
44//! conflicts between multiple such attributes attached to the same
55//! item.
66
7use crate::hir;
8use crate::{Item, ItemKind, TraitItem, TraitItemKind};
7use std::fmt::{self, Display};
98
109use crate::def::DefKind;
11use std::fmt::{self, Display};
10use crate::{hir, Item, ItemKind, TraitItem, TraitItemKind};
1211
1312#[derive(Copy, Clone, PartialEq, Debug)]
1413pub enum GenericParamKind {
compiler/rustc_hir/src/tests.rs+2-1
......@@ -1,9 +1,10 @@
1use crate::definitions::{DefKey, DefPathData, DisambiguatedDefPathData};
21use rustc_data_structures::stable_hasher::Hash64;
32use rustc_span::def_id::{DefPathHash, StableCrateId};
43use rustc_span::edition::Edition;
54use rustc_span::{create_session_globals_then, Symbol};
65
6use crate::definitions::{DefKey, DefPathData, DisambiguatedDefPathData};
7
78#[test]
89fn def_path_hash_depends_on_crate_id() {
910 // 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 @@
11//! Validity checking for weak lang items
22
3use crate::LangItem;
4
53use rustc_span::symbol::{sym, Symbol};
64
5use crate::LangItem;
6
77macro_rules! weak_lang_items {
88 ($($item:ident, $sym:ident;)*) => {
99 pub static WEAK_LANG_ITEMS: &[LangItem] = &[$(LangItem::$item,)*];
compiler/rustc_hir_analysis/src/autoderef.rs+6-7
......@@ -1,15 +1,14 @@
1use crate::errors::AutoDerefReachedRecursionLimit;
2use crate::traits;
3use crate::traits::query::evaluate_obligation::InferCtxtExt;
41use rustc_infer::infer::InferCtxt;
5use rustc_middle::ty::TypeVisitableExt;
6use rustc_middle::ty::{self, Ty, TyCtxt};
2use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitableExt};
73use rustc_session::Limit;
8use rustc_span::def_id::LocalDefId;
9use rustc_span::def_id::LOCAL_CRATE;
4use rustc_span::def_id::{LocalDefId, LOCAL_CRATE};
105use rustc_span::Span;
116use rustc_trait_selection::traits::ObligationCtxt;
127
8use crate::errors::AutoDerefReachedRecursionLimit;
9use crate::traits;
10use crate::traits::query::evaluate_obligation::InferCtxtExt;
11
1312#[derive(Copy, Clone, Debug)]
1413pub enum AutoderefKind {
1514 /// A true pointer type, such as `&T` and `*mut T`.
compiler/rustc_hir_analysis/src/check/check.rs+10-11
......@@ -1,12 +1,9 @@
1use crate::check::intrinsicck::InlineAsmCtxt;
1use std::cell::LazyCell;
2use std::ops::ControlFlow;
23
3use super::compare_impl_item::check_type_bounds;
4use super::compare_impl_item::{compare_impl_method, compare_impl_ty};
5use super::*;
6use rustc_attr as attr;
74use rustc_data_structures::unord::{UnordMap, UnordSet};
8use rustc_errors::{codes::*, MultiSpan};
9use rustc_hir as hir;
5use rustc_errors::codes::*;
6use rustc_errors::MultiSpan;
107use rustc_hir::def::{CtorKind, DefKind};
118use rustc_hir::Node;
129use rustc_infer::infer::{RegionVariableOrigin, TyCtxtInferExt};
......@@ -19,9 +16,9 @@ use rustc_middle::ty::error::TypeErrorToStringExt;
1916use rustc_middle::ty::fold::BottomUpFolder;
2017use rustc_middle::ty::layout::{LayoutError, MAX_SIMD_LANES};
2118use rustc_middle::ty::util::{Discr, InspectCoroutineFields, IntTypeExt};
22use rustc_middle::ty::GenericArgKind;
2319use rustc_middle::ty::{
24 AdtDef, ParamEnv, RegionKind, TypeSuperVisitable, TypeVisitable, TypeVisitableExt,
20 AdtDef, GenericArgKind, ParamEnv, RegionKind, TypeSuperVisitable, TypeVisitable,
21 TypeVisitableExt,
2522};
2623use rustc_session::lint::builtin::{UNINHABITED_STATIC, UNSUPPORTED_CALLING_CONVENTIONS};
2724use rustc_target::abi::FieldIdx;
......@@ -30,9 +27,11 @@ use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
3027use rustc_trait_selection::traits;
3128use rustc_trait_selection::traits::outlives_bounds::InferCtxtExt as _;
3229use rustc_type_ir::fold::TypeFoldable;
30use {rustc_attr as attr, rustc_hir as hir};
3331
34use std::cell::LazyCell;
35use std::ops::ControlFlow;
32use super::compare_impl_item::{check_type_bounds, compare_impl_method, compare_impl_ty};
33use super::*;
34use crate::check::intrinsicck::InlineAsmCtxt;
3635
3736pub fn check_abi(tcx: TyCtxt<'_>, hir_id: hir::HirId, span: Span, abi: Abi) {
3837 match tcx.sess.target.is_abi_supported(abi) {
compiler/rustc_hir_analysis/src/check/compare_impl_item.rs+11-10
......@@ -1,24 +1,24 @@
1use super::potentially_plural_count;
2use crate::errors::{LifetimesOrBoundsMismatchOnTrait, MethodShouldReturnFuture};
31use core::ops::ControlFlow;
2use std::borrow::Cow;
3use std::iter;
4
45use hir::def_id::{DefId, DefIdMap, LocalDefId};
56use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet};
6use rustc_errors::{codes::*, pluralize, struct_span_code_err, Applicability, ErrorGuaranteed};
7use rustc_errors::codes::*;
8use rustc_errors::{pluralize, struct_span_code_err, Applicability, ErrorGuaranteed};
79use rustc_hir as hir;
810use rustc_hir::def::{DefKind, Res};
9use rustc_hir::intravisit;
10use rustc_hir::{GenericParamKind, ImplItemKind};
11use rustc_hir::{intravisit, GenericParamKind, ImplItemKind};
1112use rustc_infer::infer::outlives::env::OutlivesEnvironment;
1213use rustc_infer::infer::{self, InferCtxt, TyCtxtInferExt};
1314use rustc_infer::traits::util;
1415use rustc_middle::ty::error::{ExpectedFound, TypeError};
1516use rustc_middle::ty::fold::BottomUpFolder;
1617use rustc_middle::ty::util::ExplicitSelf;
17use rustc_middle::ty::Upcast;
1818use rustc_middle::ty::{
19 self, GenericArgs, Ty, TypeFoldable, TypeFolder, TypeSuperFoldable, TypeVisitableExt,
19 self, GenericArgs, GenericParamDefKind, Ty, TyCtxt, TypeFoldable, TypeFolder,
20 TypeSuperFoldable, TypeVisitableExt, Upcast,
2021};
21use rustc_middle::ty::{GenericParamDefKind, TyCtxt};
2222use rustc_middle::{bug, span_bug};
2323use rustc_span::Span;
2424use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
......@@ -28,8 +28,9 @@ use rustc_trait_selection::traits::outlives_bounds::InferCtxtExt as _;
2828use rustc_trait_selection::traits::{
2929 self, FulfillmentError, ObligationCause, ObligationCauseCode, ObligationCtxt, Reveal,
3030};
31use std::borrow::Cow;
32use std::iter;
31
32use super::potentially_plural_count;
33use crate::errors::{LifetimesOrBoundsMismatchOnTrait, MethodShouldReturnFuture};
3334
3435mod refine;
3536
compiler/rustc_hir_analysis/src/check/compare_impl_item/refine.rs+4-4
......@@ -1,7 +1,8 @@
11use rustc_data_structures::fx::FxIndexSet;
22use rustc_hir as hir;
33use rustc_hir::def_id::DefId;
4use rustc_infer::infer::{outlives::env::OutlivesEnvironment, TyCtxtInferExt};
4use rustc_infer::infer::outlives::env::OutlivesEnvironment;
5use rustc_infer::infer::TyCtxtInferExt;
56use rustc_lint_defs::builtin::{REFINING_IMPL_TRAIT_INTERNAL, REFINING_IMPL_TRAIT_REACHABLE};
67use rustc_middle::span_bug;
78use rustc_middle::traits::{ObligationCause, Reveal};
......@@ -10,9 +11,8 @@ use rustc_middle::ty::{
1011};
1112use rustc_span::Span;
1213use rustc_trait_selection::regions::InferCtxtRegionExt;
13use rustc_trait_selection::traits::{
14 elaborate, normalize_param_env_or_error, outlives_bounds::InferCtxtExt, ObligationCtxt,
15};
14use rustc_trait_selection::traits::outlives_bounds::InferCtxtExt;
15use rustc_trait_selection::traits::{elaborate, normalize_param_env_or_error, ObligationCtxt};
1616
1717/// Check that an implementation does not refine an RPITIT from a trait method signature.
1818pub(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 @@
33// We don't do any drop checking during hir typeck.
44
55use rustc_data_structures::fx::FxHashSet;
6use rustc_errors::{codes::*, struct_span_code_err, ErrorGuaranteed};
6use rustc_errors::codes::*;
7use rustc_errors::{struct_span_code_err, ErrorGuaranteed};
78use rustc_infer::infer::outlives::env::OutlivesEnvironment;
89use rustc_infer::infer::{RegionResolutionError, TyCtxtInferExt};
910use rustc_infer::traits::{ObligationCause, ObligationCauseCode};
1011use rustc_middle::ty::util::CheckRegions;
11use rustc_middle::ty::{self, TyCtxt};
12use rustc_middle::ty::{GenericArgsRef, Ty};
12use rustc_middle::ty::{self, GenericArgsRef, Ty, TyCtxt};
1313use rustc_trait_selection::regions::InferCtxtRegionExt;
1414use rustc_trait_selection::traits::{self, ObligationCtxt};
1515
compiler/rustc_hir_analysis/src/check/entry.rs+4-3
......@@ -1,3 +1,5 @@
1use std::ops::Not;
2
13use rustc_hir as hir;
24use rustc_hir::Node;
35use rustc_infer::infer::TyCtxtInferExt;
......@@ -5,13 +7,12 @@ use rustc_middle::span_bug;
57use rustc_middle::ty::{self, Ty, TyCtxt};
68use rustc_session::config::EntryFnType;
79use rustc_span::def_id::{DefId, LocalDefId, CRATE_DEF_ID};
8use rustc_span::{symbol::sym, Span};
10use rustc_span::symbol::sym;
11use rustc_span::Span;
912use rustc_target::spec::abi::Abi;
1013use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
1114use rustc_trait_selection::traits::{self, ObligationCause, ObligationCauseCode};
1215
13use std::ops::Not;
14
1516use super::check_function_signature;
1617use crate::errors;
1718
compiler/rustc_hir_analysis/src/check/intrinsic.rs+8-7
......@@ -1,13 +1,8 @@
11//! Type-checking for the rust-intrinsic and platform-intrinsic
22//! intrinsics that the compiler exposes.
33
4use crate::check::check_function_signature;
5use crate::errors::{
6 UnrecognizedAtomicOperation, UnrecognizedIntrinsicFunction,
7 WrongNumberOfGenericArgumentsToIntrinsic,
8};
9
10use rustc_errors::{codes::*, struct_span_code_err, DiagMessage};
4use rustc_errors::codes::*;
5use rustc_errors::{struct_span_code_err, DiagMessage};
116use rustc_hir as hir;
127use rustc_middle::bug;
138use rustc_middle::traits::{ObligationCause, ObligationCauseCode};
......@@ -17,6 +12,12 @@ use rustc_span::symbol::sym;
1712use rustc_span::{Span, Symbol};
1813use rustc_target::spec::abi::Abi;
1914
15use crate::check::check_function_signature;
16use crate::errors::{
17 UnrecognizedAtomicOperation, UnrecognizedIntrinsicFunction,
18 WrongNumberOfGenericArgumentsToIntrinsic,
19};
20
2021fn equate_intrinsic_type<'tcx>(
2122 tcx: TyCtxt<'tcx>,
2223 span: Span,
compiler/rustc_hir_analysis/src/check/mod.rs+6-10
......@@ -72,13 +72,11 @@ pub mod intrinsicck;
7272mod region;
7373pub mod wfcheck;
7474
75pub use check::check_abi;
76
7775use std::num::NonZero;
7876
77pub use check::check_abi;
7978use rustc_data_structures::fx::{FxHashSet, FxIndexMap};
80use rustc_errors::ErrorGuaranteed;
81use rustc_errors::{pluralize, struct_span_code_err, Diag};
79use rustc_errors::{pluralize, struct_span_code_err, Diag, ErrorGuaranteed};
8280use rustc_hir::def_id::{DefId, LocalDefId};
8381use rustc_hir::intravisit::Visitor;
8482use rustc_index::bit_set::BitSet;
......@@ -87,12 +85,12 @@ use rustc_infer::infer::{self, TyCtxtInferExt as _};
8785use rustc_infer::traits::ObligationCause;
8886use rustc_middle::query::Providers;
8987use rustc_middle::ty::error::{ExpectedFound, TypeError};
90use rustc_middle::ty::{self, Ty, TyCtxt};
91use rustc_middle::ty::{GenericArgs, GenericArgsRef};
88use rustc_middle::ty::{self, GenericArgs, GenericArgsRef, Ty, TyCtxt};
9289use rustc_middle::{bug, span_bug};
9390use rustc_session::parse::feature_err;
91use rustc_span::def_id::CRATE_DEF_ID;
9492use rustc_span::symbol::{kw, sym, Ident};
95use rustc_span::{def_id::CRATE_DEF_ID, BytePos, Span, Symbol, DUMMY_SP};
93use rustc_span::{BytePos, Span, Symbol, DUMMY_SP};
9694use rustc_target::abi::VariantIdx;
9795use rustc_target::spec::abi::Abi;
9896use rustc_trait_selection::error_reporting::infer::ObligationCauseExt as _;
......@@ -100,11 +98,9 @@ use rustc_trait_selection::error_reporting::traits::suggestions::ReturnsVisitor;
10098use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
10199use rustc_trait_selection::traits::ObligationCtxt;
102100
103use crate::errors;
104use crate::require_c_abi_if_c_variadic;
105
106101use self::compare_impl_item::collect_return_position_impl_trait_in_trait_tys;
107102use self::region::region_scope_tree;
103use crate::{errors, require_c_abi_if_c_variadic};
108104
109105pub fn provide(providers: &mut Providers) {
110106 wfcheck::provide(providers);
compiler/rustc_hir_analysis/src/check/region.rs+2-2
......@@ -6,6 +6,8 @@
66//!
77//! [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/borrow_check.html
88
9use std::mem;
10
911use rustc_data_structures::fx::FxHashSet;
1012use rustc_hir as hir;
1113use rustc_hir::def_id::DefId;
......@@ -19,8 +21,6 @@ use rustc_span::source_map;
1921
2022use super::errs::{maybe_expr_static_mut, maybe_stmt_static_mut};
2123
22use std::mem;
23
2424#[derive(Debug, Copy, Clone)]
2525pub struct Context {
2626 /// 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 @@
1use crate::autoderef::Autoderef;
2use crate::collect::CollectItemTypesVisitor;
3use crate::constrained_generic_params::{identify_constrained_generic_params, Parameter};
4use crate::errors;
5use crate::fluent_generated as fluent;
1use std::cell::LazyCell;
2use std::ops::{ControlFlow, Deref};
63
74use hir::intravisit::{self, Visitor};
8use rustc_ast as ast;
95use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexSet};
10use rustc_errors::{codes::*, pluralize, struct_span_code_err, Applicability, ErrorGuaranteed};
11use rustc_hir as hir;
6use rustc_errors::codes::*;
7use rustc_errors::{pluralize, struct_span_code_err, Applicability, ErrorGuaranteed};
128use rustc_hir::def::{DefKind, Res};
139use rustc_hir::def_id::{DefId, LocalDefId, LocalModDefId};
1410use rustc_hir::lang_items::LangItem;
......@@ -20,10 +16,9 @@ use rustc_middle::query::Providers;
2016use rustc_middle::ty::print::with_no_trimmed_paths;
2117use rustc_middle::ty::trait_def::TraitSpecializationKind;
2218use 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,
2521};
26use rustc_middle::ty::{GenericArgKind, GenericArgs};
2722use rustc_middle::{bug, span_bug};
2823use rustc_session::parse::feature_err;
2924use rustc_span::symbol::{sym, Ident};
......@@ -41,9 +36,12 @@ use rustc_trait_selection::traits::{
4136};
4237use rustc_type_ir::solve::NoSolution;
4338use rustc_type_ir::TypeFlags;
39use {rustc_ast as ast, rustc_hir as hir};
4440
45use std::cell::LazyCell;
46use std::ops::{ControlFlow, Deref};
41use crate::autoderef::Autoderef;
42use crate::collect::CollectItemTypesVisitor;
43use crate::constrained_generic_params::{identify_constrained_generic_params, Parameter};
44use crate::{errors, fluent_generated as fluent};
4745
4846pub(super) struct WfCheckingCtxt<'a, 'tcx> {
4947 pub(super) ocx: ObligationCtxt<'a, 'tcx, FulfillmentError<'tcx>>,
compiler/rustc_hir_analysis/src/coherence/builtin.rs+5-6
......@@ -1,7 +1,7 @@
11//! Check properties that are required by built-in traits and set
22//! up data structures required by type-checking/codegen.
33
4use crate::errors;
4use std::collections::BTreeMap;
55
66use rustc_data_structures::fx::FxHashSet;
77use rustc_errors::{ErrorGuaranteed, MultiSpan};
......@@ -10,8 +10,7 @@ use rustc_hir::def_id::{DefId, LocalDefId};
1010use rustc_hir::lang_items::LangItem;
1111use rustc_hir::ItemKind;
1212use rustc_infer::infer::outlives::env::OutlivesEnvironment;
13use rustc_infer::infer::TyCtxtInferExt;
14use rustc_infer::infer::{self, RegionResolutionError};
13use rustc_infer::infer::{self, RegionResolutionError, TyCtxtInferExt};
1514use rustc_infer::traits::Obligation;
1615use rustc_middle::ty::adjustment::CoerceUnsizedInfo;
1716use rustc_middle::ty::print::PrintTraitRefExt as _;
......@@ -22,9 +21,9 @@ use rustc_trait_selection::traits::misc::{
2221 type_allowed_to_implement_const_param_ty, type_allowed_to_implement_copy,
2322 ConstParamTyImplementationError, CopyImplementationError, InfringingFieldsReason,
2423};
25use rustc_trait_selection::traits::ObligationCtxt;
26use rustc_trait_selection::traits::{self, ObligationCause};
27use std::collections::BTreeMap;
24use rustc_trait_selection::traits::{self, ObligationCause, ObligationCtxt};
25
26use crate::errors;
2827
2928pub(super) fn check_trait<'tcx>(
3029 tcx: TyCtxt<'tcx>,
compiler/rustc_hir_analysis/src/coherence/inherent_impls_overlap.rs+3-3
......@@ -1,6 +1,6 @@
1use rustc_data_structures::fx::IndexEntry;
2use rustc_data_structures::fx::{FxHashSet, FxIndexMap};
3use rustc_errors::{codes::*, struct_span_code_err};
1use rustc_data_structures::fx::{FxHashSet, FxIndexMap, IndexEntry};
2use rustc_errors::codes::*;
3use rustc_errors::struct_span_code_err;
44use rustc_hir as hir;
55use rustc_hir::def::DefKind;
66use rustc_hir::def_id::DefId;
compiler/rustc_hir_analysis/src/coherence/mod.rs+4-2
......@@ -5,8 +5,8 @@
55// done by the orphan and overlap modules. Then we build up various
66// mappings. That mapping code resides here.
77
8use crate::errors;
9use rustc_errors::{codes::*, struct_span_code_err};
8use rustc_errors::codes::*;
9use rustc_errors::struct_span_code_err;
1010use rustc_hir::def_id::{DefId, LocalDefId};
1111use rustc_hir::LangItem;
1212use rustc_middle::query::Providers;
......@@ -14,6 +14,8 @@ use rustc_middle::ty::{self, TyCtxt, TypeVisitableExt};
1414use rustc_session::parse::feature_err;
1515use rustc_span::{sym, ErrorGuaranteed};
1616
17use crate::errors;
18
1719mod builtin;
1820mod inherent_impls;
1921mod inherent_impls_overlap;
compiler/rustc_hir_analysis/src/coherence/orphan.rs+9-7
......@@ -1,19 +1,21 @@
11//! Orphan checker: every impl either implements a trait defined in this
22//! crate or pertains to a type defined in this crate.
33
4use crate::errors;
5
64use rustc_data_structures::fx::FxIndexSet;
75use rustc_errors::ErrorGuaranteed;
86use rustc_infer::infer::{InferCtxt, TyCtxtInferExt};
97use rustc_lint_defs::builtin::UNCOVERED_PARAM_IN_PROJECTION;
10use rustc_middle::ty::{self, Ty, TyCtxt};
11use rustc_middle::ty::{TypeFoldable, TypeFolder, TypeSuperFoldable};
12use rustc_middle::ty::{TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor};
8use rustc_middle::ty::{
9 self, Ty, TyCtxt, TypeFoldable, TypeFolder, TypeSuperFoldable, TypeSuperVisitable,
10 TypeVisitable, TypeVisitableExt, TypeVisitor,
11};
1312use rustc_middle::{bug, span_bug};
1413use rustc_span::def_id::{DefId, LocalDefId};
15use rustc_trait_selection::traits::{self, IsFirstInputType, UncoveredTyParams};
16use rustc_trait_selection::traits::{OrphanCheckErr, OrphanCheckMode};
14use rustc_trait_selection::traits::{
15 self, IsFirstInputType, OrphanCheckErr, OrphanCheckMode, UncoveredTyParams,
16};
17
18use crate::errors;
1719
1820#[instrument(level = "debug", skip(tcx))]
1921pub(crate) fn orphan_check_impl(
compiler/rustc_hir_analysis/src/coherence/unsafety.rs+4-2
......@@ -1,10 +1,12 @@
11//! Unsafety checker: every impl either implements a trait defined in this
22//! crate or pertains to a type defined in this crate.
33
4use rustc_errors::{codes::*, struct_span_code_err};
4use rustc_errors::codes::*;
5use rustc_errors::struct_span_code_err;
56use rustc_hir::Safety;
67use rustc_middle::ty::print::PrintTraitRefExt as _;
7use rustc_middle::ty::{ImplPolarity::*, ImplTraitHeader, TraitDef, TyCtxt};
8use rustc_middle::ty::ImplPolarity::*;
9use rustc_middle::ty::{ImplTraitHeader, TraitDef, TyCtxt};
810use rustc_span::def_id::LocalDefId;
911use rustc_span::ErrorGuaranteed;
1012
compiler/rustc_hir_analysis/src/collect.rs+5-5
......@@ -14,6 +14,10 @@
1414//! At present, however, we do run collection across all items in the
1515//! crate as a kind of pass. This should eventually be factored away.
1616
17use std::cell::Cell;
18use std::iter;
19use std::ops::Bound;
20
1721use rustc_ast::Recovered;
1822use rustc_data_structures::captures::Captures;
1923use rustc_data_structures::fx::{FxHashSet, FxIndexMap};
......@@ -24,8 +28,7 @@ use rustc_errors::{
2428use rustc_hir::def::DefKind;
2529use rustc_hir::def_id::{DefId, LocalDefId};
2630use rustc_hir::intravisit::{self, walk_generics, Visitor};
27use rustc_hir::{self as hir};
28use rustc_hir::{GenericParamKind, Node};
31use rustc_hir::{self as hir, GenericParamKind, Node};
2932use rustc_infer::infer::{InferCtxt, TyCtxtInferExt};
3033use rustc_infer::traits::ObligationCause;
3134use rustc_middle::hir::nested_filter;
......@@ -39,9 +42,6 @@ use rustc_target::spec::abi;
3942use rustc_trait_selection::error_reporting::traits::suggestions::NextTypeParamName;
4043use rustc_trait_selection::infer::InferCtxtExt;
4144use rustc_trait_selection::traits::ObligationCtxt;
42use std::cell::Cell;
43use std::iter;
44use std::ops::Bound;
4545
4646use crate::check::intrinsic::intrinsic_operation_unsafety;
4747use crate::errors;
compiler/rustc_hir_analysis/src/collect/generics_of.rs+4-5
......@@ -1,10 +1,7 @@
11use std::ops::ControlFlow;
22
3use crate::middle::resolve_bound_vars as rbv;
4use hir::{
5 intravisit::{self, Visitor},
6 GenericParamKind, HirId, Node,
7};
3use hir::intravisit::{self, Visitor};
4use hir::{GenericParamKind, HirId, Node};
85use rustc_hir as hir;
96use rustc_hir::def::DefKind;
107use rustc_hir::def_id::LocalDefId;
......@@ -13,6 +10,8 @@ use rustc_session::lint;
1310use rustc_span::symbol::{kw, Symbol};
1411use rustc_span::Span;
1512
13use crate::middle::resolve_bound_vars as rbv;
14
1615#[instrument(level = "debug", skip(tcx), ret)]
1716pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Generics {
1817 use rustc_hir::*;
compiler/rustc_hir_analysis/src/collect/item_bounds.rs+6-4
......@@ -1,15 +1,17 @@
1use super::ItemCtxt;
2use crate::hir_ty_lowering::{HirTyLowerer, PredicateFilter};
31use rustc_data_structures::fx::FxIndexSet;
42use rustc_hir as hir;
53use rustc_infer::traits::util;
6use rustc_middle::ty::GenericArgs;
7use rustc_middle::ty::{self, Ty, TyCtxt, TypeFoldable, TypeFolder, TypeSuperFoldable};
4use rustc_middle::ty::{
5 self, GenericArgs, Ty, TyCtxt, TypeFoldable, TypeFolder, TypeSuperFoldable,
6};
87use rustc_middle::{bug, span_bug};
98use rustc_span::def_id::{DefId, LocalDefId};
109use rustc_span::Span;
1110use rustc_type_ir::Upcast;
1211
12use super::ItemCtxt;
13use crate::hir_ty_lowering::{HirTyLowerer, PredicateFilter};
14
1315/// For associated types we include both bounds written on the type
1416/// (`type X: Trait`) and predicates from the trait: `where Self::X: Trait`.
1517///
compiler/rustc_hir_analysis/src/collect/predicates_of.rs+6-6
......@@ -1,19 +1,19 @@
1use crate::bounds::Bounds;
2use crate::collect::ItemCtxt;
3use crate::constrained_generic_params as cgp;
4use crate::hir_ty_lowering::{HirTyLowerer, OnlySelfBounds, PredicateFilter, RegionInferReason};
51use hir::{HirId, Node};
62use rustc_data_structures::fx::FxIndexSet;
73use rustc_hir as hir;
84use rustc_hir::def::DefKind;
95use rustc_hir::def_id::{DefId, LocalDefId};
106use rustc_hir::intravisit::{self, Visitor};
11use rustc_middle::ty::{self, Ty, TyCtxt};
12use rustc_middle::ty::{GenericPredicates, ImplTraitInTraitData, Upcast};
7use rustc_middle::ty::{self, GenericPredicates, ImplTraitInTraitData, Ty, TyCtxt, Upcast};
138use rustc_middle::{bug, span_bug};
149use rustc_span::symbol::Ident;
1510use rustc_span::{Span, DUMMY_SP};
1611
12use crate::bounds::Bounds;
13use crate::collect::ItemCtxt;
14use crate::constrained_generic_params as cgp;
15use crate::hir_ty_lowering::{HirTyLowerer, OnlySelfBounds, PredicateFilter, RegionInferReason};
16
1717/// Returns a list of all type predicates (explicit and implicit) for the definition with
1818/// ID `def_id`. This includes all predicates returned by `predicates_defined_on`, plus
1919/// `Self: Trait` predicates for traits.
compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs+2-1
......@@ -7,6 +7,8 @@
77//! is also responsible for assigning their semantics to implicit lifetimes in trait objects.
88
99use core::ops::ControlFlow;
10use std::fmt;
11
1012use rustc_ast::visit::walk_list;
1113use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet};
1214use rustc_hir as hir;
......@@ -23,7 +25,6 @@ use rustc_middle::{bug, span_bug};
2325use rustc_span::def_id::DefId;
2426use rustc_span::symbol::{sym, Ident};
2527use rustc_span::Span;
26use std::fmt;
2728
2829use crate::errors;
2930
compiler/rustc_hir_analysis/src/collect/type_of.rs+2-3
......@@ -1,4 +1,5 @@
11use core::ops::ControlFlow;
2
23use rustc_errors::{Applicability, StashKey};
34use rustc_hir as hir;
45use rustc_hir::def_id::{DefId, LocalDefId};
......@@ -11,12 +12,10 @@ use rustc_middle::{bug, span_bug};
1112use rustc_span::symbol::Ident;
1213use rustc_span::{Span, DUMMY_SP};
1314
15use super::{bad_placeholder, ItemCtxt};
1416use crate::errors::TypeofReservedKeywordUsed;
1517use crate::hir_ty_lowering::HirTyLowerer;
1618
17use super::bad_placeholder;
18use super::ItemCtxt;
19
2019mod opaque;
2120
2221fn 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 @@
11//! Errors emitted by `rustc_hir_analysis`.
22
3use crate::fluent_generated as fluent;
3use rustc_errors::codes::*;
44use rustc_errors::{
5 codes::*, Applicability, Diag, DiagCtxtHandle, Diagnostic, EmissionGuarantee, Level, MultiSpan,
5 Applicability, Diag, DiagCtxtHandle, Diagnostic, EmissionGuarantee, Level, MultiSpan,
66};
77use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
88use rustc_middle::ty::Ty;
9use rustc_span::{symbol::Ident, Span, Symbol};
9use rustc_span::symbol::Ident;
10use rustc_span::{Span, Symbol};
11
12use crate::fluent_generated as fluent;
1013mod pattern_types;
1114pub use pattern_types::*;
1215pub mod wrong_number_of_generic_args;
compiler/rustc_hir_analysis/src/errors/wrong_number_of_generic_args.rs+4-5
......@@ -1,11 +1,10 @@
1use rustc_errors::{
2 codes::*, pluralize, Applicability, Diag, Diagnostic, EmissionGuarantee, MultiSpan,
3};
1use std::iter;
2
3use rustc_errors::codes::*;
4use rustc_errors::{pluralize, Applicability, Diag, Diagnostic, EmissionGuarantee, MultiSpan};
45use rustc_hir as hir;
56use rustc_middle::ty::{self as ty, AssocItems, AssocKind, TyCtxt};
67use rustc_span::def_id::DefId;
7use std::iter;
8
98use GenericArgsInfo::*;
109
1110/// 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 @@
11use std::ops::ControlFlow;
22
33use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
4use rustc_errors::{codes::*, struct_span_code_err};
4use rustc_errors::codes::*;
5use rustc_errors::struct_span_code_err;
56use rustc_hir as hir;
67use rustc_hir::def::{DefKind, Res};
78use rustc_hir::def_id::{DefId, LocalDefId};
......@@ -15,8 +16,9 @@ use smallvec::SmallVec;
1516
1617use crate::bounds::Bounds;
1718use crate::errors;
18use crate::hir_ty_lowering::HirTyLowerer;
19use crate::hir_ty_lowering::{AssocItemQSelf, OnlySelfBounds, PredicateFilter, RegionInferReason};
19use crate::hir_ty_lowering::{
20 AssocItemQSelf, HirTyLowerer, OnlySelfBounds, PredicateFilter, RegionInferReason,
21};
2022
2123impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
2224 /// 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 @@
1use crate::errors::{
2 self, AssocItemConstraintsNotAllowedHere, ManualImplementation, MissingTypeParams,
3 ParenthesizedFnTraitExpansion, TraitObjectDeclaredWithNoTraits,
4};
5use crate::fluent_generated as fluent;
6use crate::hir_ty_lowering::{AssocItemQSelf, HirTyLowerer};
71use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
82use rustc_data_structures::sorted_map::SortedMap;
93use rustc_data_structures::unord::UnordMap;
10use rustc_errors::MultiSpan;
4use rustc_errors::codes::*;
115use rustc_errors::{
12 codes::*, pluralize, struct_span_code_err, Applicability, Diag, ErrorGuaranteed,
6 pluralize, struct_span_code_err, Applicability, Diag, ErrorGuaranteed, MultiSpan,
137};
148use rustc_hir as hir;
159use rustc_hir::def::{DefKind, Res};
......@@ -17,21 +11,26 @@ use rustc_hir::def_id::DefId;
1711use rustc_middle::bug;
1812use rustc_middle::query::Key;
1913use rustc_middle::ty::print::{PrintPolyTraitRefExt as _, PrintTraitRefExt as _};
20use rustc_middle::ty::GenericParamDefKind;
21use rustc_middle::ty::{self, suggest_constraining_type_param};
22use rustc_middle::ty::{AdtDef, Ty, TyCtxt, TypeVisitableExt};
23use rustc_middle::ty::{Binder, TraitRef};
14use rustc_middle::ty::{
15 self, suggest_constraining_type_param, AdtDef, Binder, GenericParamDefKind, TraitRef, Ty,
16 TyCtxt, TypeVisitableExt,
17};
2418use rustc_session::parse::feature_err;
2519use rustc_span::edit_distance::find_best_match_for_name;
2620use rustc_span::symbol::{kw, sym, Ident};
27use rustc_span::BytePos;
28use rustc_span::{Span, Symbol, DUMMY_SP};
21use rustc_span::{BytePos, Span, Symbol, DUMMY_SP};
2922use rustc_trait_selection::error_reporting::traits::report_object_safety_error;
30use rustc_trait_selection::traits::FulfillmentError;
3123use rustc_trait_selection::traits::{
32 object_safety_violations_for_assoc_item, TraitAliasExpansionInfo,
24 object_safety_violations_for_assoc_item, FulfillmentError, TraitAliasExpansionInfo,
3325};
3426
27use crate::errors::{
28 self, AssocItemConstraintsNotAllowedHere, ManualImplementation, MissingTypeParams,
29 ParenthesizedFnTraitExpansion, TraitObjectDeclaredWithNoTraits,
30};
31use crate::fluent_generated as fluent;
32use crate::hir_ty_lowering::{AssocItemQSelf, HirTyLowerer};
33
3534impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
3635 /// On missing type parameters, emit an E0393 error and provide a structured suggestion using
3736 /// the type parameter's name as a placeholder.
compiler/rustc_hir_analysis/src/hir_ty_lowering/generics.rs+10-9
......@@ -1,13 +1,6 @@
1use super::{HirTyLowerer, IsMethodCall};
2use crate::errors::wrong_number_of_generic_args::{GenericArgsInfo, WrongNumberOfGenericArgs};
3use crate::hir_ty_lowering::{
4 errors::prohibit_assoc_item_constraint, ExplicitLateBound, GenericArgCountMismatch,
5 GenericArgCountResult, GenericArgPosition, GenericArgsLowerer,
6};
71use rustc_ast::ast::ParamKindOrd;
8use rustc_errors::{
9 codes::*, struct_span_code_err, Applicability, Diag, ErrorGuaranteed, MultiSpan,
10};
2use rustc_errors::codes::*;
3use rustc_errors::{struct_span_code_err, Applicability, Diag, ErrorGuaranteed, MultiSpan};
114use rustc_hir as hir;
125use rustc_hir::def::{DefKind, Res};
136use rustc_hir::def_id::DefId;
......@@ -19,6 +12,14 @@ use rustc_session::lint::builtin::LATE_BOUND_LIFETIME_ARGUMENTS;
1912use rustc_span::symbol::{kw, sym};
2013use smallvec::SmallVec;
2114
15use super::{HirTyLowerer, IsMethodCall};
16use crate::errors::wrong_number_of_generic_args::{GenericArgsInfo, WrongNumberOfGenericArgs};
17use crate::hir_ty_lowering::errors::prohibit_assoc_item_constraint;
18use crate::hir_ty_lowering::{
19 ExplicitLateBound, GenericArgCountMismatch, GenericArgCountResult, GenericArgPosition,
20 GenericArgsLowerer,
21};
22
2223/// Report an error that a generic argument did not match the generic parameter that was
2324/// expected.
2425fn generic_arg_mismatch_err(
compiler/rustc_hir_analysis/src/hir_ty_lowering/lint.rs+4-2
......@@ -1,8 +1,10 @@
11use rustc_ast::TraitObjectSyntax;
2use rustc_errors::{codes::*, Diag, EmissionGuarantee, StashKey};
2use rustc_errors::codes::*;
3use rustc_errors::{Diag, EmissionGuarantee, StashKey};
34use rustc_hir as hir;
45use rustc_hir::def::{DefKind, Res};
5use rustc_lint_defs::{builtin::BARE_TRAIT_OBJECTS, Applicability};
6use rustc_lint_defs::builtin::BARE_TRAIT_OBJECTS;
7use rustc_lint_defs::Applicability;
68use rustc_span::Span;
79use rustc_trait_selection::error_reporting::traits::suggestions::NextTypeParamName;
810
compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs+10-9
......@@ -20,17 +20,13 @@ pub mod generics;
2020mod lint;
2121mod object_safety;
2222
23use crate::bounds::Bounds;
24use crate::errors::{AmbiguousLifetimeBound, WildPatTy};
25use crate::hir_ty_lowering::errors::{prohibit_assoc_item_constraint, GenericsArgsErrExtend};
26use crate::hir_ty_lowering::generics::{check_generic_arg_count, lower_generic_args};
27use crate::middle::resolve_bound_vars as rbv;
28use crate::require_c_abi_if_c_variadic;
23use std::slice;
24
2925use rustc_ast::TraitObjectSyntax;
3026use rustc_data_structures::fx::{FxHashSet, FxIndexMap};
27use rustc_errors::codes::*;
3128use rustc_errors::{
32 codes::*, struct_span_code_err, Applicability, Diag, DiagCtxtHandle, ErrorGuaranteed,
33 FatalError,
29 struct_span_code_err, Applicability, Diag, DiagCtxtHandle, ErrorGuaranteed, FatalError,
3430};
3531use rustc_hir as hir;
3632use rustc_hir::def::{CtorOf, DefKind, Namespace, Res};
......@@ -55,7 +51,12 @@ use rustc_trait_selection::infer::InferCtxtExt;
5551use rustc_trait_selection::traits::wf::object_region_bounds;
5652use rustc_trait_selection::traits::{self, ObligationCtxt};
5753
58use std::slice;
54use crate::bounds::Bounds;
55use crate::errors::{AmbiguousLifetimeBound, WildPatTy};
56use crate::hir_ty_lowering::errors::{prohibit_assoc_item_constraint, GenericsArgsErrExtend};
57use crate::hir_ty_lowering::generics::{check_generic_arg_count, lower_generic_args};
58use crate::middle::resolve_bound_vars as rbv;
59use crate::require_c_abi_if_c_variadic;
5960
6061/// A path segment that is semantically allowed to have generic arguments.
6162#[derive(Debug)]
compiler/rustc_hir_analysis/src/hir_ty_lowering/object_safety.rs+9-8
......@@ -1,24 +1,25 @@
1use crate::bounds::Bounds;
2use crate::hir_ty_lowering::{
3 GenericArgCountMismatch, GenericArgCountResult, OnlySelfBounds, RegionInferReason,
4};
51use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet};
6use rustc_errors::{codes::*, struct_span_code_err};
2use rustc_errors::codes::*;
3use rustc_errors::struct_span_code_err;
74use rustc_hir as hir;
85use rustc_hir::def::{DefKind, Res};
96use rustc_hir::def_id::DefId;
107use rustc_lint_defs::builtin::UNUSED_ASSOCIATED_TYPE_BOUNDS;
118use rustc_middle::span_bug;
129use rustc_middle::ty::fold::BottomUpFolder;
13use rustc_middle::ty::{self, ExistentialPredicateStableCmpExt as _, Ty, TyCtxt, TypeFoldable};
14use rustc_middle::ty::{DynKind, Upcast};
10use rustc_middle::ty::{
11 self, DynKind, ExistentialPredicateStableCmpExt as _, Ty, TyCtxt, TypeFoldable, Upcast,
12};
1513use rustc_span::{ErrorGuaranteed, Span};
1614use rustc_trait_selection::error_reporting::traits::report_object_safety_error;
1715use rustc_trait_selection::traits::{self, hir_ty_lowering_object_safety_violations};
18
1916use smallvec::{smallvec, SmallVec};
2017
2118use super::HirTyLowerer;
19use crate::bounds::Bounds;
20use crate::hir_ty_lowering::{
21 GenericArgCountMismatch, GenericArgCountResult, OnlySelfBounds, RegionInferReason,
22};
2223
2324impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
2425 /// 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 @@
1use crate::collect::ItemCtxt;
21use rustc_hir as hir;
32use rustc_hir::intravisit::{self, Visitor};
43use rustc_hir::{ForeignItem, ForeignItemKind};
......@@ -10,6 +9,8 @@ use rustc_middle::ty::{self, TyCtxt};
109use rustc_span::def_id::LocalDefId;
1110use rustc_trait_selection::traits::{self, ObligationCtxt};
1211
12use crate::collect::ItemCtxt;
13
1314pub fn provide(providers: &mut Providers) {
1415 *providers = Providers { diagnostic_hir_wf_check, ..*providers };
1516}
compiler/rustc_hir_analysis/src/impl_wf_check.rs+3-2
......@@ -8,9 +8,7 @@
88//! specialization errors. These things can (and probably should) be
99//! fixed, but for the moment it's easier to do these checks early.
1010
11use crate::{constrained_generic_params as cgp, errors::UnconstrainedGenericParameter};
1211use min_specialization::check_min_specialization;
13
1412use rustc_data_structures::fx::FxHashSet;
1513use rustc_errors::codes::*;
1614use rustc_hir::def::DefKind;
......@@ -18,6 +16,9 @@ use rustc_hir::def_id::LocalDefId;
1816use rustc_middle::ty::{self, TyCtxt, TypeVisitableExt};
1917use rustc_span::ErrorGuaranteed;
2018
19use crate::constrained_generic_params as cgp;
20use crate::errors::UnconstrainedGenericParameter;
21
2122mod min_specialization;
2223
2324/// 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 @@
6565//! cause use after frees with purely safe code in the same way as specializing
6666//! on traits with methods can.
6767
68use crate::errors::GenericArgsOnOverriddenImpl;
69use crate::{constrained_generic_params as cgp, errors};
70
7168use rustc_data_structures::fx::FxHashSet;
7269use rustc_hir as hir;
7370use rustc_hir::def_id::{DefId, LocalDefId};
......@@ -75,13 +72,15 @@ use rustc_infer::infer::outlives::env::OutlivesEnvironment;
7572use rustc_infer::infer::TyCtxtInferExt;
7673use rustc_infer::traits::specialization_graph::Node;
7774use rustc_middle::ty::trait_def::TraitSpecializationKind;
78use rustc_middle::ty::{self, TyCtxt, TypeVisitableExt};
79use rustc_middle::ty::{GenericArg, GenericArgs, GenericArgsRef};
75use rustc_middle::ty::{self, GenericArg, GenericArgs, GenericArgsRef, TyCtxt, TypeVisitableExt};
8076use rustc_span::{ErrorGuaranteed, Span};
8177use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
8278use rustc_trait_selection::traits::outlives_bounds::InferCtxtExt as _;
8379use rustc_trait_selection::traits::{self, translate_args_with_cause, wf, ObligationCtxt};
8480
81use crate::errors::GenericArgsOnOverriddenImpl;
82use crate::{constrained_generic_params as cgp, errors};
83
8584pub(super) fn check_min_specialization(
8685 tcx: TyCtxt<'_>,
8786 impl_def_id: LocalDefId,
compiler/rustc_hir_analysis/src/lib.rs+2-1
......@@ -100,7 +100,8 @@ use rustc_middle::mir::interpret::GlobalId;
100100use rustc_middle::query::Providers;
101101use rustc_middle::ty::{self, Ty, TyCtxt};
102102use rustc_session::parse::feature_err;
103use rustc_span::{symbol::sym, Span};
103use rustc_span::symbol::sym;
104use rustc_span::Span;
104105use rustc_target::spec::abi::Abi;
105106use rustc_trait_selection::traits;
106107
compiler/rustc_hir_analysis/src/outlives/implicit_infer.rs+1-2
......@@ -1,8 +1,7 @@
11use rustc_data_structures::fx::FxIndexMap;
22use rustc_hir::def::DefKind;
33use rustc_hir::def_id::DefId;
4use rustc_middle::ty::{self, Ty, TyCtxt};
5use rustc_middle::ty::{GenericArg, GenericArgKind};
4use rustc_middle::ty::{self, GenericArg, GenericArgKind, Ty, TyCtxt};
65use rustc_span::Span;
76
87use super::explicit::ExplicitPredicatesMap;
compiler/rustc_hir_analysis/src/outlives/mod.rs+1-2
......@@ -1,8 +1,7 @@
11use rustc_hir::def::DefKind;
22use rustc_hir::def_id::LocalDefId;
33use rustc_middle::query::Providers;
4use rustc_middle::ty::GenericArgKind;
5use rustc_middle::ty::{self, CratePredicatesMap, TyCtxt, Upcast};
4use rustc_middle::ty::{self, CratePredicatesMap, GenericArgKind, TyCtxt, Upcast};
65use rustc_span::Span;
76
87pub(crate) mod dump;
compiler/rustc_hir_analysis/src/outlives/utils.rs+1-2
......@@ -1,6 +1,5 @@
11use rustc_data_structures::fx::FxIndexMap;
2use rustc_middle::ty::{self, Region, Ty, TyCtxt};
3use rustc_middle::ty::{GenericArg, GenericArgKind};
2use rustc_middle::ty::{self, GenericArg, GenericArgKind, Region, Ty, TyCtxt};
43use rustc_middle::{bug, span_bug};
54use rustc_span::Span;
65use rustc_type_ir::outlives::{push_outlives_components, Component};
compiler/rustc_hir_analysis/src/variance/constraints.rs+1-2
......@@ -6,8 +6,7 @@
66use hir::def_id::{DefId, LocalDefId};
77use rustc_hir as hir;
88use rustc_hir::def::DefKind;
9use rustc_middle::ty::{self, Ty, TyCtxt};
10use rustc_middle::ty::{GenericArgKind, GenericArgsRef};
9use rustc_middle::ty::{self, GenericArgKind, GenericArgsRef, Ty, TyCtxt};
1110use rustc_middle::{bug, span_bug};
1211
1312use super::terms::VarianceTerm::*;
compiler/rustc_hir_analysis/src/variance/mod.rs+3-2
......@@ -9,8 +9,9 @@ use rustc_hir::def::DefKind;
99use rustc_hir::def_id::{DefId, LocalDefId};
1010use rustc_middle::query::Providers;
1111use rustc_middle::span_bug;
12use rustc_middle::ty::{self, CrateVariancesMap, GenericArgsRef, Ty, TyCtxt};
13use rustc_middle::ty::{TypeSuperVisitable, TypeVisitable};
12use rustc_middle::ty::{
13 self, CrateVariancesMap, GenericArgsRef, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable,
14};
1415
1516/// Defines the `TermsContext` basically houses an arena where we can
1617/// allocate terms.
compiler/rustc_hir_analysis/src/variance/terms.rs+2-1
......@@ -9,11 +9,12 @@
99// `InferredIndex` is a newtype'd int representing the index of such
1010// a variable.
1111
12use std::fmt;
13
1214use rustc_arena::DroplessArena;
1315use rustc_hir::def::DefKind;
1416use rustc_hir::def_id::{LocalDefId, LocalDefIdMap};
1517use rustc_middle::ty::{self, TyCtxt};
16use std::fmt;
1718
1819use self::VarianceTerm::*;
1920
compiler/rustc_hir_pretty/src/lib.rs+4-5
......@@ -5,12 +5,13 @@
55#![recursion_limit = "256"]
66// tidy-alphabetical-end
77
8use rustc_ast as ast;
8use std::cell::Cell;
9use std::vec;
10
911use rustc_ast::util::parser::{self, AssocOp, Fixity};
1012use rustc_ast_pretty::pp::Breaks::{Consistent, Inconsistent};
1113use rustc_ast_pretty::pp::{self, Breaks};
1214use rustc_ast_pretty::pprust::{Comments, PrintState};
13use rustc_hir as hir;
1415use rustc_hir::{
1516 BindingMode, ByRef, ConstArgKind, GenericArg, GenericBound, GenericParam, GenericParamKind,
1617 HirId, LifetimeParamKind, Node, PatKind, PreciseCapturingArg, RangeEnd, Term,
......@@ -20,9 +21,7 @@ use rustc_span::source_map::SourceMap;
2021use rustc_span::symbol::{kw, Ident, Symbol};
2122use rustc_span::FileName;
2223use rustc_target::spec::abi::Abi;
23
24use std::cell::Cell;
25use std::vec;
24use {rustc_ast as ast, rustc_hir as hir};
2625
2726pub fn id_to_string(map: &dyn rustc_hir::intravisit::Map<'_>, hir_id: HirId) -> String {
2827 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 @@
1use crate::coercion::{AsCoercionSite, CoerceMany};
2use crate::{Diverges, Expectation, FnCtxt, Needs};
31use rustc_errors::{Applicability, Diag};
42use rustc_hir::def::{CtorOf, DefKind, Res};
53use rustc_hir::def_id::LocalDefId;
......@@ -11,6 +9,9 @@ use rustc_trait_selection::traits::{
119 IfExpressionCause, MatchExpressionArmCause, ObligationCause, ObligationCauseCode,
1210};
1311
12use crate::coercion::{AsCoercionSite, CoerceMany};
13use crate::{Diverges, Expectation, FnCtxt, Needs};
14
1415impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1516 #[instrument(skip(self), level = "debug", ret)]
1617 pub fn check_match(
compiler/rustc_hir_typeck/src/autoderef.rs+3-3
......@@ -1,7 +1,6 @@
11//! Some helper functions for `AutoDeref`.
22
3use super::method::MethodCallee;
4use super::{FnCtxt, PlaceOp};
3use std::iter;
54
65use itertools::Itertools;
76use rustc_hir_analysis::autoderef::{Autoderef, AutoderefKind};
......@@ -10,7 +9,8 @@ use rustc_middle::ty::adjustment::{Adjust, Adjustment, OverloadedDeref};
109use rustc_middle::ty::{self, Ty};
1110use rustc_span::Span;
1211
13use std::iter;
12use super::method::MethodCallee;
13use super::{FnCtxt, PlaceOp};
1414
1515impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1616 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 @@
1use super::method::probe::ProbeScope;
2use super::method::MethodCallee;
3use super::{Expectation, FnCtxt, TupleArgumentsFlag};
1use std::{iter, slice};
42
5use crate::errors;
63use rustc_ast::util::parser::PREC_UNAMBIGUOUS;
74use rustc_errors::{Applicability, Diag, ErrorGuaranteed, StashKey};
85use rustc_hir::def::{self, CtorKind, Namespace, Res};
96use rustc_hir::def_id::DefId;
107use rustc_hir::{self as hir, LangItem};
118use rustc_hir_analysis::autoderef::Autoderef;
12use rustc_infer::traits::ObligationCauseCode;
13use rustc_infer::{
14 infer,
15 traits::{self, Obligation, ObligationCause},
16};
9use rustc_infer::infer;
10use rustc_infer::traits::{self, Obligation, ObligationCause, ObligationCauseCode};
1711use rustc_middle::ty::adjustment::{
1812 Adjust, Adjustment, AllowTwoPhase, AutoBorrow, AutoBorrowMutability,
1913};
20use rustc_middle::ty::GenericArgsRef;
21use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitableExt};
14use rustc_middle::ty::{self, GenericArgsRef, Ty, TyCtxt, TypeVisitableExt};
2215use rustc_middle::{bug, span_bug};
2316use rustc_span::def_id::LocalDefId;
2417use rustc_span::symbol::{sym, Ident};
......@@ -28,7 +21,10 @@ use rustc_trait_selection::error_reporting::traits::DefIdOrName;
2821use rustc_trait_selection::infer::InferCtxtExt as _;
2922use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt as _;
3023
31use std::{iter, slice};
24use super::method::probe::ProbeScope;
25use super::method::MethodCallee;
26use super::{Expectation, FnCtxt, TupleArgumentsFlag};
27use crate::errors;
3228
3329/// Checks that it is legal to call methods of the trait corresponding
3430/// 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 @@
2828//! expression, `e as U2` is not necessarily so (in fact it will only be valid if
2929//! `U1` coerces to `U2`).
3030
31use super::FnCtxt;
32
33use crate::errors;
34use crate::type_error_struct;
3531use rustc_data_structures::fx::FxHashSet;
36use rustc_errors::{codes::*, Applicability, Diag, ErrorGuaranteed};
32use rustc_errors::codes::*;
33use rustc_errors::{Applicability, Diag, ErrorGuaranteed};
3734use rustc_hir::{self as hir, ExprKind};
3835use rustc_macros::{TypeFoldable, TypeVisitable};
3936use rustc_middle::bug;
......@@ -41,15 +38,16 @@ use rustc_middle::mir::Mutability;
4138use rustc_middle::ty::adjustment::AllowTwoPhase;
4239use rustc_middle::ty::cast::{CastKind, CastTy};
4340use rustc_middle::ty::error::TypeError;
44use rustc_middle::ty::TyCtxt;
45use rustc_middle::ty::{self, Ty, TypeAndMut, TypeVisitableExt, VariantDef};
41use rustc_middle::ty::{self, Ty, TyCtxt, TypeAndMut, TypeVisitableExt, VariantDef};
4642use rustc_session::lint;
4743use rustc_span::def_id::LOCAL_CRATE;
4844use rustc_span::symbol::sym;
49use rustc_span::Span;
50use rustc_span::DUMMY_SP;
45use rustc_span::{Span, DUMMY_SP};
5146use rustc_trait_selection::infer::InferCtxtExt;
5247
48use super::FnCtxt;
49use crate::{errors, type_error_struct};
50
5351/// Reifies a cast check to be checked once we have full type information for
5452/// a function context.
5553#[derive(Debug)]
compiler/rustc_hir_typeck/src/check.rs+4-3
......@@ -1,8 +1,5 @@
11use std::cell::RefCell;
22
3use crate::coercion::CoerceMany;
4use crate::gather_locals::GatherLocalsVisitor;
5use crate::{CoroutineTypes, Diverges, FnCtxt};
63use rustc_hir as hir;
74use rustc_hir::def::DefKind;
85use rustc_hir::intravisit::Visitor;
......@@ -16,6 +13,10 @@ use rustc_span::symbol::sym;
1613use rustc_target::spec::abi::Abi;
1714use rustc_trait_selection::traits::{ObligationCause, ObligationCauseCode};
1815
16use crate::coercion::CoerceMany;
17use crate::gather_locals::GatherLocalsVisitor;
18use crate::{CoroutineTypes, Diverges, FnCtxt};
19
1920/// Helper used for fns and closures. Does the grungy work of checking a function
2021/// body and returns the function context used for that purpose, since in the case of a fn item
2122/// there is still a bit more to do.
compiler/rustc_hir_typeck/src/closure.rs+6-7
......@@ -1,27 +1,26 @@
11//! Code for type-checking closure expressions.
22
3use super::{check_fn, CoroutineTypes, Expectation, FnCtxt};
3use std::iter;
4use std::ops::ControlFlow;
45
56use rustc_errors::ErrorGuaranteed;
67use rustc_hir as hir;
78use rustc_hir::lang_items::LangItem;
89use rustc_hir_analysis::hir_ty_lowering::HirTyLowerer;
9use rustc_infer::infer::{BoundRegionConversionTime, DefineOpaqueTypes};
10use rustc_infer::infer::{InferOk, InferResult};
10use rustc_infer::infer::{BoundRegionConversionTime, DefineOpaqueTypes, InferOk, InferResult};
1111use rustc_infer::traits::ObligationCauseCode;
1212use rustc_macros::{TypeFoldable, TypeVisitable};
1313use rustc_middle::span_bug;
1414use rustc_middle::ty::visit::{TypeVisitable, TypeVisitableExt};
15use rustc_middle::ty::GenericArgs;
16use rustc_middle::ty::{self, Ty, TyCtxt, TypeSuperVisitable, TypeVisitor};
15use rustc_middle::ty::{self, GenericArgs, Ty, TyCtxt, TypeSuperVisitable, TypeVisitor};
1716use rustc_span::def_id::LocalDefId;
1817use rustc_span::Span;
1918use rustc_target::spec::abi::Abi;
2019use rustc_trait_selection::error_reporting::traits::ArgKind;
2120use rustc_trait_selection::traits;
2221use rustc_type_ir::ClosureKind;
23use std::iter;
24use std::ops::ControlFlow;
22
23use super::{check_fn, CoroutineTypes, Expectation, FnCtxt};
2524
2625/// What signature do we *expect* the closure to have from context?
2726#[derive(Debug, Clone, TypeFoldable, TypeVisitable)]
compiler/rustc_hir_typeck/src/coercion.rs+10-7
......@@ -35,16 +35,18 @@
3535//! // and are then unable to coerce `&7i32` to `&mut i32`.
3636//! ```
3737
38use crate::errors::SuggestBoxingForReturnImplTrait;
39use crate::FnCtxt;
40use rustc_errors::{codes::*, struct_span_code_err, Applicability, Diag};
38use std::ops::Deref;
39
40use rustc_errors::codes::*;
41use rustc_errors::{struct_span_code_err, Applicability, Diag};
4142use rustc_hir as hir;
4243use rustc_hir::def_id::{DefId, LocalDefId};
4344use rustc_hir_analysis::hir_ty_lowering::HirTyLowerer;
4445use rustc_infer::infer::relate::RelateResult;
4546use rustc_infer::infer::{Coercion, DefineOpaqueTypes, InferOk, InferResult};
46use rustc_infer::traits::{IfExpressionCause, MatchExpressionArmCause};
47use rustc_infer::traits::{Obligation, PredicateObligation};
47use rustc_infer::traits::{
48 IfExpressionCause, MatchExpressionArmCause, Obligation, PredicateObligation,
49};
4850use rustc_middle::lint::in_external_macro;
4951use rustc_middle::span_bug;
5052use rustc_middle::traits::BuiltinImplSource;
......@@ -63,9 +65,10 @@ use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt;
6365use rustc_trait_selection::traits::{
6466 self, NormalizeExt, ObligationCause, ObligationCauseCode, ObligationCtxt,
6567};
66
6768use smallvec::{smallvec, SmallVec};
68use std::ops::Deref;
69
70use crate::errors::SuggestBoxingForReturnImplTrait;
71use crate::FnCtxt;
6972
7073struct Coerce<'a, 'tcx> {
7174 fcx: &'a FnCtxt<'a, 'tcx>,
compiler/rustc_hir_typeck/src/demand.rs+2-3
......@@ -1,6 +1,4 @@
1use crate::FnCtxt;
2use rustc_errors::MultiSpan;
3use rustc_errors::{Applicability, Diag};
1use rustc_errors::{Applicability, Diag, MultiSpan};
42use rustc_hir as hir;
53use rustc_hir::def::Res;
64use rustc_hir::intravisit::Visitor;
......@@ -17,6 +15,7 @@ use rustc_trait_selection::infer::InferCtxtExt;
1715use rustc_trait_selection::traits::ObligationCause;
1816
1917use super::method::probe;
18use crate::FnCtxt;
2019
2120impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
2221 pub fn emit_type_mismatch_suggestions(
compiler/rustc_hir_typeck/src/diverges.rs+2-1
......@@ -1,6 +1,7 @@
1use rustc_span::{Span, DUMMY_SP};
21use std::{cmp, ops};
32
3use rustc_span::{Span, DUMMY_SP};
4
45/// Tracks whether executing a node may exit normally (versus
56/// return/break/panic, which "diverge", leaving dead code in their
67/// wake). Tracked semi-automatically (through type variables marked
compiler/rustc_hir_typeck/src/errors.rs+8-8
......@@ -2,18 +2,18 @@
22
33use std::borrow::Cow;
44
5use crate::fluent_generated as fluent;
5use rustc_errors::codes::*;
66use 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,
99};
1010use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
1111use rustc_middle::ty::{self, Ty};
12use rustc_span::{
13 edition::{Edition, LATEST_STABLE_EDITION},
14 symbol::Ident,
15 Span, Symbol,
16};
12use rustc_span::edition::{Edition, LATEST_STABLE_EDITION};
13use rustc_span::symbol::Ident;
14use rustc_span::{Span, Symbol};
15
16use crate::fluent_generated as fluent;
1717
1818#[derive(Diagnostic)]
1919#[diag(hir_typeck_field_multiply_specified_in_initializer, code = E0062)]
compiler/rustc_hir_typeck/src/expr.rs+20-29
......@@ -2,33 +2,13 @@
22//!
33//! See [`rustc_hir_analysis::check`] for more context on type checking in general.
44
5use crate::cast;
6use crate::coercion::CoerceMany;
7use crate::coercion::DynamicCoerceMany;
8use crate::errors::ReturnLikeStatementKind;
9use crate::errors::TypeMismatchFruTypo;
10use crate::errors::{AddressOfTemporaryTaken, ReturnStmtOutsideOfFnBody, StructExprNonExhaustive};
11use crate::errors::{
12 FieldMultiplySpecifiedInInitializer, FunctionalRecordUpdateOnNonStruct, HelpUseLatestEdition,
13 YieldExprOutsideOfCoroutine,
14};
15use crate::fatally_break_rust;
16use crate::type_error_struct;
17use crate::CoroutineTypes;
18use crate::Expectation::{self, ExpectCastableToType, ExpectHasType, NoExpectation};
19use crate::{
20 report_unexpected_variant_res, BreakableCtxt, Diverges, FnCtxt, Needs,
21 TupleArgumentsFlag::DontTupleArguments,
22};
23use rustc_ast as ast;
245use rustc_data_structures::fx::{FxHashMap, FxHashSet};
256use rustc_data_structures::stack::ensure_sufficient_stack;
267use rustc_data_structures::unord::UnordMap;
8use rustc_errors::codes::*;
279use 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,
3011};
31use rustc_hir as hir;
3212use rustc_hir::def::{CtorKind, DefKind, Res};
3313use rustc_hir::def_id::DefId;
3414use rustc_hir::intravisit::Visitor;
......@@ -36,14 +16,12 @@ use rustc_hir::lang_items::LangItem;
3616use rustc_hir::{ExprKind, HirId, QPath};
3717use rustc_hir_analysis::hir_ty_lowering::HirTyLowerer as _;
3818use rustc_infer::infer;
39use rustc_infer::infer::DefineOpaqueTypes;
40use rustc_infer::infer::InferOk;
19use rustc_infer::infer::{DefineOpaqueTypes, InferOk};
4120use rustc_infer::traits::query::NoSolution;
4221use rustc_infer::traits::ObligationCause;
4322use rustc_middle::ty::adjustment::{Adjust, Adjustment, AllowTwoPhase};
4423use rustc_middle::ty::error::{ExpectedFound, TypeError};
45use rustc_middle::ty::GenericArgsRef;
46use rustc_middle::ty::{self, AdtKind, Ty, TypeVisitableExt};
24use rustc_middle::ty::{self, AdtKind, GenericArgsRef, Ty, TypeVisitableExt};
4725use rustc_middle::{bug, span_bug};
4826use rustc_session::errors::ExprParenthesesNeeded;
4927use rustc_session::parse::feature_err;
......@@ -54,10 +32,23 @@ use rustc_span::symbol::{kw, sym, Ident, Symbol};
5432use rustc_span::Span;
5533use rustc_target::abi::{FieldIdx, FIRST_VARIANT};
5634use rustc_trait_selection::infer::InferCtxtExt;
57use rustc_trait_selection::traits::ObligationCtxt;
58use rustc_trait_selection::traits::{self, ObligationCauseCode};
59
35use rustc_trait_selection::traits::{self, ObligationCauseCode, ObligationCtxt};
6036use smallvec::SmallVec;
37use {rustc_ast as ast, rustc_hir as hir};
38
39use crate::coercion::{CoerceMany, DynamicCoerceMany};
40use crate::errors::{
41 AddressOfTemporaryTaken, FieldMultiplySpecifiedInInitializer,
42 FunctionalRecordUpdateOnNonStruct, HelpUseLatestEdition, ReturnLikeStatementKind,
43 ReturnStmtOutsideOfFnBody, StructExprNonExhaustive, TypeMismatchFruTypo,
44 YieldExprOutsideOfCoroutine,
45};
46use crate::Expectation::{self, ExpectCastableToType, ExpectHasType, NoExpectation};
47use crate::TupleArgumentsFlag::DontTupleArguments;
48use crate::{
49 cast, fatally_break_rust, report_unexpected_variant_res, type_error_struct, BreakableCtxt,
50 CoroutineTypes, Diverges, FnCtxt, Needs,
51};
6152
6253impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
6354 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;
99use hir::def::DefKind;
1010use hir::pat_util::EnumerateAndAdjustIterator as _;
1111use hir::Expr;
12use rustc_lint::LateContext;
13// Export these here so that Clippy can use them.
14pub use rustc_middle::hir::place::{Place, PlaceBase, PlaceWithHirId, Projection};
15
1612use rustc_data_structures::fx::FxIndexMap;
1713use rustc_hir as hir;
1814use rustc_hir::def::{CtorOf, Res};
1915use rustc_hir::def_id::LocalDefId;
2016use rustc_hir::{HirId, PatKind};
17use rustc_lint::LateContext;
2118use rustc_middle::hir::place::ProjectionKind;
19// Export these here so that Clippy can use them.
20pub use rustc_middle::hir::place::{Place, PlaceBase, PlaceWithHirId, Projection};
2221use rustc_middle::mir::FakeReadCause;
2322use rustc_middle::ty::{
2423 self, adjustment, AdtKind, Ty, TyCtxt, TypeFoldable, TypeVisitableExt as _,
compiler/rustc_hir_typeck/src/fallback.rs+8-7
......@@ -1,10 +1,9 @@
11use std::cell::OnceCell;
22
3use crate::{errors, FnCtxt, TypeckRootCtxt};
4use rustc_data_structures::{
5 graph::{self, iterate::DepthFirstSearch, vec_graph::VecGraph},
6 unord::{UnordBag, UnordMap, UnordSet},
7};
3use rustc_data_structures::graph::iterate::DepthFirstSearch;
4use rustc_data_structures::graph::vec_graph::VecGraph;
5use rustc_data_structures::graph::{self};
6use rustc_data_structures::unord::{UnordBag, UnordMap, UnordSet};
87use rustc_hir as hir;
98use rustc_hir::intravisit::Visitor;
109use rustc_hir::HirId;
......@@ -12,10 +11,12 @@ use rustc_infer::infer::{DefineOpaqueTypes, InferOk};
1211use rustc_middle::bug;
1312use rustc_middle::ty::{self, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable};
1413use rustc_session::lint;
15use rustc_span::DUMMY_SP;
16use rustc_span::{def_id::LocalDefId, Span};
14use rustc_span::def_id::LocalDefId;
15use rustc_span::{Span, DUMMY_SP};
1716use rustc_trait_selection::traits::{ObligationCause, ObligationCtxt};
1817
18use crate::{errors, FnCtxt, TypeckRootCtxt};
19
1920#[derive(Copy, Clone)]
2021pub enum DivergingFallbackBehavior {
2122 /// Always fallback to `()` (aka "always spontaneous decay")
compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs+9-9
......@@ -1,8 +1,6 @@
1use crate::callee::{self, DeferredCallResolution};
2use crate::errors::{self, CtorIsPrivate};
3use crate::method::{self, MethodCallee};
4use crate::rvalue_scopes;
5use crate::{BreakableCtxt, Diverges, Expectation, FnCtxt, LoweredTy};
1use std::collections::hash_map::Entry;
2use std::slice;
3
64use rustc_data_structures::fx::FxHashSet;
75use rustc_errors::{Applicability, Diag, ErrorGuaranteed, MultiSpan, StashKey};
86use rustc_hir as hir;
......@@ -26,9 +24,9 @@ use rustc_middle::ty::error::TypeError;
2624use rustc_middle::ty::fold::TypeFoldable;
2725use rustc_middle::ty::visit::{TypeVisitable, TypeVisitableExt};
2826use 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,
3029};
31use rustc_middle::ty::{GenericArgKind, GenericArgsRef, UserArgs, UserSelfTy};
3230use rustc_middle::{bug, span_bug};
3331use rustc_session::lint;
3432use rustc_span::def_id::LocalDefId;
......@@ -41,8 +39,10 @@ use rustc_trait_selection::traits::{
4139 self, NormalizeExt, ObligationCauseCode, ObligationCtxt, StructurallyNormalizeExt,
4240};
4341
44use std::collections::hash_map::Entry;
45use std::slice;
42use crate::callee::{self, DeferredCallResolution};
43use crate::errors::{self, CtorIsPrivate};
44use crate::method::{self, MethodCallee};
45use crate::{rvalue_scopes, BreakableCtxt, Diverges, Expectation, FnCtxt, LoweredTy};
4646
4747impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
4848 /// 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 @@
1use crate::FnCtxt;
1use std::ops::ControlFlow;
2
23use rustc_hir as hir;
34use rustc_hir::def::{DefKind, Res};
45use rustc_hir::def_id::DefId;
56use rustc_infer::traits::ObligationCauseCode;
67use rustc_middle::ty::{self, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitor};
7use rustc_span::{symbol::kw, Span};
8use rustc_span::symbol::kw;
9use rustc_span::Span;
810use rustc_trait_selection::traits;
911
10use std::ops::ControlFlow;
12use crate::FnCtxt;
1113
1214impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1315 pub fn adjust_fulfillment_error_for_expr_obligation(
compiler/rustc_hir_typeck/src/fn_ctxt/arg_matrix.rs+2-1
......@@ -1,7 +1,8 @@
11use core::cmp::Ordering;
2use std::cmp;
3
24use rustc_index::IndexVec;
35use rustc_middle::ty::error::TypeError;
4use std::cmp;
56
67rustc_index::newtype_index! {
78 #[orderable]
compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs+22-23
......@@ -1,26 +1,12 @@
1use crate::coercion::CoerceMany;
2use crate::errors::SuggestPtrNullMut;
3use crate::fn_ctxt::arg_matrix::{ArgMatrix, Compatibility, Error, ExpectedIdx, ProvidedIdx};
4use crate::fn_ctxt::infer::FnCall;
5use crate::gather_locals::Declaration;
6use crate::method::probe::IsSuggestion;
7use crate::method::probe::Mode::MethodCall;
8use crate::method::probe::ProbeScope::TraitsInScope;
9use crate::method::MethodCallee;
10use crate::TupleArgumentsFlag::*;
11use crate::{errors, Expectation::*};
12use crate::{
13 struct_span_code_err, BreakableCtxt, Diverges, Expectation, FnCtxt, LoweredTy, Needs,
14 TupleArgumentsFlag,
15};
1use std::{iter, mem};
2
163use itertools::Itertools;
17use rustc_ast as ast;
184use rustc_data_structures::fx::FxIndexSet;
5use rustc_errors::codes::*;
196use 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,
229};
23use rustc_hir as hir;
2410use rustc_hir::def::{CtorOf, DefKind, Res};
2511use rustc_hir::def_id::DefId;
2612use rustc_hir::intravisit::Visitor;
......@@ -29,8 +15,7 @@ use rustc_hir_analysis::check::intrinsicck::InlineAsmCtxt;
2915use rustc_hir_analysis::check::potentially_plural_count;
3016use rustc_hir_analysis::hir_ty_lowering::HirTyLowerer;
3117use rustc_index::IndexVec;
32use rustc_infer::infer::TypeTrace;
33use rustc_infer::infer::{DefineOpaqueTypes, InferOk};
18use rustc_infer::infer::{DefineOpaqueTypes, InferOk, TypeTrace};
3419use rustc_middle::ty::adjustment::AllowTwoPhase;
3520use rustc_middle::ty::visit::TypeVisitableExt;
3621use rustc_middle::ty::{self, IsSuggestable, Ty, TyCtxt};
......@@ -41,9 +26,23 @@ use rustc_span::{sym, BytePos, Span, DUMMY_SP};
4126use rustc_trait_selection::error_reporting::infer::{FailureCode, ObligationCauseExt};
4227use rustc_trait_selection::infer::InferCtxtExt;
4328use rustc_trait_selection::traits::{self, ObligationCauseCode, SelectionContext};
29use {rustc_ast as ast, rustc_hir as hir};
4430
45use std::iter;
46use std::mem;
31use crate::coercion::CoerceMany;
32use crate::errors::SuggestPtrNullMut;
33use crate::fn_ctxt::arg_matrix::{ArgMatrix, Compatibility, Error, ExpectedIdx, ProvidedIdx};
34use crate::fn_ctxt::infer::FnCall;
35use crate::gather_locals::Declaration;
36use crate::method::probe::IsSuggestion;
37use crate::method::probe::Mode::MethodCall;
38use crate::method::probe::ProbeScope::TraitsInScope;
39use crate::method::MethodCallee;
40use crate::Expectation::*;
41use crate::TupleArgumentsFlag::*;
42use crate::{
43 errors, struct_span_code_err, BreakableCtxt, Diverges, Expectation, FnCtxt, LoweredTy, Needs,
44 TupleArgumentsFlag,
45};
4746
4847#[derive(Clone, Copy, Default)]
4948pub enum DivergingBlockBehavior {
compiler/rustc_hir_typeck/src/fn_ctxt/inspect_obligations.rs+5-3
......@@ -1,12 +1,14 @@
11//! A utility module to inspect currently ambiguous obligations in the current context.
22
3use crate::FnCtxt;
43use rustc_infer::traits::{self, ObligationCause};
54use rustc_middle::traits::solve::Goal;
65use rustc_middle::ty::{self, Ty, TypeVisitableExt};
76use rustc_span::Span;
8use rustc_trait_selection::solve::inspect::ProofTreeInferCtxtExt;
9use rustc_trait_selection::solve::inspect::{InspectConfig, InspectGoal, ProofTreeVisitor};
7use rustc_trait_selection::solve::inspect::{
8 InspectConfig, InspectGoal, ProofTreeInferCtxtExt, ProofTreeVisitor,
9};
10
11use crate::FnCtxt;
1012
1113impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1214 /// 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;
55mod inspect_obligations;
66mod suggestions;
77
8use rustc_errors::DiagCtxtHandle;
8use std::cell::{Cell, RefCell};
9use std::ops::Deref;
910
10use crate::coercion::DynamicCoerceMany;
11use crate::fallback::DivergingFallbackBehavior;
12use crate::fn_ctxt::checks::DivergingBlockBehavior;
13use crate::{CoroutineTypes, Diverges, EnclosingBreakables, TypeckRootCtxt};
1411use hir::def_id::CRATE_DEF_ID;
12use rustc_errors::DiagCtxtHandle;
1513use rustc_hir as hir;
1614use rustc_hir::def_id::{DefId, LocalDefId};
1715use rustc_hir_analysis::hir_ty_lowering::{HirTyLowerer, RegionInferReason};
......@@ -24,8 +22,10 @@ use rustc_trait_selection::error_reporting::infer::sub_relations::SubRelations;
2422use rustc_trait_selection::error_reporting::TypeErrCtxt;
2523use rustc_trait_selection::traits::{ObligationCause, ObligationCauseCode, ObligationCtxt};
2624
27use std::cell::{Cell, RefCell};
28use std::ops::Deref;
25use crate::coercion::DynamicCoerceMany;
26use crate::fallback::DivergingFallbackBehavior;
27use crate::fn_ctxt::checks::DivergingBlockBehavior;
28use crate::{CoroutineTypes, Diverges, EnclosingBreakables, TypeckRootCtxt};
2929
3030/// The `FnCtxt` stores type-checking context needed to type-check bodies of
3131/// functions, closures, and `const`s, including performing type inference
compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs+13-12
......@@ -1,20 +1,12 @@
1use super::FnCtxt;
2
3use crate::errors;
4use crate::fluent_generated as fluent;
5use crate::fn_ctxt::rustc_span::BytePos;
6use crate::hir::is_range_literal;
7use crate::method::probe;
8use crate::method::probe::{IsSuggestion, Mode, ProbeScope};
91use core::cmp::min;
102use core::iter;
3
114use hir::def_id::LocalDefId;
125use rustc_ast::util::parser::{ExprPrecedence, PREC_UNAMBIGUOUS};
136use rustc_data_structures::packed::Pu128;
147use rustc_errors::{Applicability, Diag, MultiSpan};
158use rustc_hir as hir;
16use rustc_hir::def::Res;
17use rustc_hir::def::{CtorKind, CtorOf, DefKind};
9use rustc_hir::def::{CtorKind, CtorOf, DefKind, Res};
1810use rustc_hir::lang_items::LangItem;
1911use rustc_hir::{
2012 Arm, CoroutineDesugaring, CoroutineKind, CoroutineSource, Expr, ExprKind, GenericBound, HirId,
......@@ -26,8 +18,10 @@ use rustc_middle::lint::in_external_macro;
2618use rustc_middle::middle::stability::EvalResult;
2719use rustc_middle::span_bug;
2820use rustc_middle::ty::print::with_no_trimmed_paths;
29use rustc_middle::ty::{self, suggest_constraining_type_params, Article, Binder};
30use rustc_middle::ty::{IsSuggestable, Ty, TyCtxt, TypeVisitableExt, Upcast};
21use rustc_middle::ty::{
22 self, suggest_constraining_type_params, Article, Binder, IsSuggestable, Ty, TyCtxt,
23 TypeVisitableExt, Upcast,
24};
3125use rustc_session::errors::ExprParenthesesNeeded;
3226use rustc_span::source_map::Spanned;
3327use rustc_span::symbol::{sym, Ident};
......@@ -38,6 +32,13 @@ use rustc_trait_selection::infer::InferCtxtExt;
3832use rustc_trait_selection::traits;
3933use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt as _;
4034
35use super::FnCtxt;
36use crate::fn_ctxt::rustc_span::BytePos;
37use crate::hir::is_range_literal;
38use crate::method::probe;
39use crate::method::probe::{IsSuggestion, Mode, ProbeScope};
40use crate::{errors, fluent_generated as fluent};
41
4142impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
4243 pub(crate) fn body_fn_sig(&self) -> Option<ty::FnSig<'tcx>> {
4344 self.typeck_results
compiler/rustc_hir_typeck/src/gather_locals.rs+3-3
......@@ -1,13 +1,13 @@
1use crate::FnCtxt;
21use rustc_hir as hir;
32use rustc_hir::intravisit::{self, Visitor};
43use rustc_hir::{HirId, PatKind};
54use rustc_infer::traits::ObligationCauseCode;
6use rustc_middle::ty::Ty;
7use rustc_middle::ty::UserType;
5use rustc_middle::ty::{Ty, UserType};
86use rustc_span::def_id::LocalDefId;
97use rustc_span::Span;
108
9use crate::FnCtxt;
10
1111/// Provides context for checking patterns in declarations. More specifically this
1212/// allows us to infer array types if the pattern is irrefutable and allows us to infer
1313/// the size of the array. See issue #76342.
compiler/rustc_hir_typeck/src/intrinsicck.rs+2-1
......@@ -1,5 +1,6 @@
11use hir::HirId;
2use rustc_errors::{codes::*, struct_span_code_err};
2use rustc_errors::codes::*;
3use rustc_errors::struct_span_code_err;
34use rustc_hir as hir;
45use rustc_index::Idx;
56use rustc_middle::bug;
compiler/rustc_hir_typeck/src/lib.rs+10-9
......@@ -44,16 +44,9 @@ mod writeback;
4444
4545pub use coercion::can_coerce;
4646use fn_ctxt::FnCtxt;
47use typeck_root_ctxt::TypeckRootCtxt;
48
49use crate::check::check_fn;
50use crate::coercion::DynamicCoerceMany;
51use crate::diverges::Diverges;
52use crate::expectation::Expectation;
53use crate::fn_ctxt::LoweredTy;
54use crate::gather_locals::GatherLocalsVisitor;
5547use rustc_data_structures::unord::UnordSet;
56use rustc_errors::{codes::*, struct_span_code_err, Applicability, ErrorGuaranteed};
48use rustc_errors::codes::*;
49use rustc_errors::{struct_span_code_err, Applicability, ErrorGuaranteed};
5750use rustc_hir as hir;
5851use rustc_hir::def::{DefKind, Res};
5952use rustc_hir::intravisit::Visitor;
......@@ -67,6 +60,14 @@ use rustc_middle::{bug, span_bug};
6760use rustc_session::config;
6861use rustc_span::def_id::LocalDefId;
6962use rustc_span::Span;
63use typeck_root_ctxt::TypeckRootCtxt;
64
65use crate::check::check_fn;
66use crate::coercion::DynamicCoerceMany;
67use crate::diverges::Diverges;
68use crate::expectation::Expectation;
69use crate::fn_ctxt::LoweredTy;
70use crate::gather_locals::GatherLocalsVisitor;
7071
7172rustc_fluent_macro::fluent_messages! { "../messages.ftl" }
7273
compiler/rustc_hir_typeck/src/method/confirm.rs+6-5
......@@ -1,6 +1,5 @@
1use super::{probe, MethodCallee};
1use std::ops::Deref;
22
3use crate::{callee, FnCtxt};
43use rustc_hir as hir;
54use rustc_hir::def_id::DefId;
65use rustc_hir::GenericArg;
......@@ -12,8 +11,9 @@ use rustc_hir_analysis::hir_ty_lowering::{
1211};
1312use rustc_infer::infer::{self, DefineOpaqueTypes, InferOk};
1413use rustc_middle::traits::{ObligationCauseCode, UnifyReceiverContext};
15use rustc_middle::ty::adjustment::{Adjust, Adjustment, PointerCoercion};
16use rustc_middle::ty::adjustment::{AllowTwoPhase, AutoBorrow, AutoBorrowMutability};
14use rustc_middle::ty::adjustment::{
15 Adjust, Adjustment, AllowTwoPhase, AutoBorrow, AutoBorrowMutability, PointerCoercion,
16};
1717use rustc_middle::ty::fold::TypeFoldable;
1818use rustc_middle::ty::{
1919 self, GenericArgs, GenericArgsRef, GenericParamDefKind, Ty, TyCtxt, UserArgs, UserType,
......@@ -22,7 +22,8 @@ use rustc_middle::{bug, span_bug};
2222use rustc_span::{Span, DUMMY_SP};
2323use rustc_trait_selection::traits;
2424
25use std::ops::Deref;
25use super::{probe, MethodCallee};
26use crate::{callee, FnCtxt};
2627
2728struct ConfirmContext<'a, 'tcx> {
2829 fcx: &'a FnCtxt<'a, 'tcx>,
compiler/rustc_hir_typeck/src/method/mod.rs+5-5
......@@ -7,9 +7,6 @@ mod prelude_edition_lints;
77pub mod probe;
88mod suggest;
99
10pub use self::MethodError::*;
11
12use crate::FnCtxt;
1310use rustc_errors::{Applicability, Diag, SubdiagMessage};
1411use rustc_hir as hir;
1512use rustc_hir::def::{CtorOf, DefKind, Namespace};
......@@ -17,8 +14,9 @@ use rustc_hir::def_id::DefId;
1714use rustc_infer::infer::{self, InferOk};
1815use rustc_middle::query::Providers;
1916use rustc_middle::traits::ObligationCause;
20use rustc_middle::ty::{self, GenericParamDefKind, Ty, TypeVisitableExt};
21use rustc_middle::ty::{GenericArgs, GenericArgsRef};
17use rustc_middle::ty::{
18 self, GenericArgs, GenericArgsRef, GenericParamDefKind, Ty, TypeVisitableExt,
19};
2220use rustc_middle::{bug, span_bug};
2321use rustc_span::symbol::Ident;
2422use rustc_span::Span;
......@@ -26,6 +24,8 @@ use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt;
2624use rustc_trait_selection::traits::{self, NormalizeExt};
2725
2826use self::probe::{IsSuggestion, ProbeScope};
27pub use self::MethodError::*;
28use crate::FnCtxt;
2929
3030pub fn provide(providers: &mut Providers) {
3131 probe::provide(providers);
compiler/rustc_hir_typeck/src/method/prelude_edition_lints.rs+5-5
......@@ -1,9 +1,7 @@
1use crate::method::probe::{self, Pick};
2use crate::FnCtxt;
1use std::fmt::Write;
32
43use hir::def_id::DefId;
5use hir::HirId;
6use hir::ItemKind;
4use hir::{HirId, ItemKind};
75use rustc_errors::Applicability;
86use rustc_hir as hir;
97use rustc_lint::{ARRAY_INTO_ITER, BOXED_SLICE_INTO_ITER};
......@@ -14,7 +12,9 @@ use rustc_span::symbol::kw::{Empty, Underscore};
1412use rustc_span::symbol::{sym, Ident};
1513use rustc_span::Span;
1614use rustc_trait_selection::infer::InferCtxtExt;
17use std::fmt::Write;
15
16use crate::method::probe::{self, Pick};
17use crate::FnCtxt;
1818
1919impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
2020 pub(super) fn lint_edition_dependent_dot_call(
compiler/rustc_hir_typeck/src/method/probe.rs+17-29
......@@ -1,58 +1,46 @@
1use super::suggest;
2use super::CandidateSource;
3use super::MethodError;
4use super::NoMatchData;
1use std::cell::{Cell, RefCell};
2use std::cmp::max;
3use std::iter;
4use std::ops::Deref;
55
6use crate::FnCtxt;
76use rustc_data_structures::fx::FxHashSet;
87use rustc_errors::Applicability;
98use rustc_hir as hir;
109use rustc_hir::def::DefKind;
1110use rustc_hir::HirId;
1211use rustc_hir_analysis::autoderef::{self, Autoderef};
13use rustc_infer::infer::canonical::OriginalQueryValues;
14use rustc_infer::infer::canonical::{Canonical, QueryResponse};
15use rustc_infer::infer::DefineOpaqueTypes;
16use rustc_infer::infer::{self, InferOk, TyCtxtInferExt};
12use rustc_infer::infer::canonical::{Canonical, OriginalQueryValues, QueryResponse};
13use rustc_infer::infer::{self, DefineOpaqueTypes, InferOk, TyCtxtInferExt};
1714use rustc_infer::traits::ObligationCauseCode;
1815use rustc_middle::middle::stability;
1916use rustc_middle::query::Providers;
2017use rustc_middle::ty::fast_reject::{simplify_type, TreatParams};
21use rustc_middle::ty::AssocItem;
22use rustc_middle::ty::AssocItemContainer;
23use rustc_middle::ty::GenericParamDefKind;
24use rustc_middle::ty::Upcast;
25use rustc_middle::ty::{self, ParamEnvAnd, Ty, TyCtxt, TypeVisitableExt};
26use rustc_middle::ty::{GenericArgs, GenericArgsRef};
18use rustc_middle::ty::{
19 self, AssocItem, AssocItemContainer, GenericArgs, GenericArgsRef, GenericParamDefKind,
20 ParamEnvAnd, Ty, TyCtxt, TypeVisitableExt, Upcast,
21};
2722use rustc_middle::{bug, span_bug};
2823use rustc_session::lint;
29use rustc_span::def_id::DefId;
30use rustc_span::def_id::LocalDefId;
24use rustc_span::def_id::{DefId, LocalDefId};
3125use rustc_span::edit_distance::{
3226 edit_distance_with_substrings, find_best_match_for_name_with_substrings,
3327};
34use rustc_span::symbol::sym;
35use rustc_span::{symbol::Ident, Span, Symbol, DUMMY_SP};
28use rustc_span::symbol::{sym, Ident};
29use rustc_span::{Span, Symbol, DUMMY_SP};
3630use rustc_trait_selection::error_reporting::infer::need_type_info::TypeAnnotationNeeded;
3731use rustc_trait_selection::infer::InferCtxtExt as _;
3832use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt;
39use rustc_trait_selection::traits::query::method_autoderef::MethodAutoderefBadTy;
4033use rustc_trait_selection::traits::query::method_autoderef::{
41 CandidateStep, MethodAutoderefStepsResult,
34 CandidateStep, MethodAutoderefBadTy, MethodAutoderefStepsResult,
4235};
4336use rustc_trait_selection::traits::query::CanonicalTyGoal;
44use rustc_trait_selection::traits::ObligationCtxt;
45use rustc_trait_selection::traits::{self, ObligationCause};
46use std::cell::Cell;
47use std::cell::RefCell;
48use std::cmp::max;
49use std::iter;
50use std::ops::Deref;
51
37use rustc_trait_selection::traits::{self, ObligationCause, ObligationCtxt};
5238use smallvec::{smallvec, SmallVec};
5339
5440use self::CandidateKind::*;
5541pub use self::PickKind::*;
42use super::{suggest, CandidateSource, MethodError, NoMatchData};
43use crate::FnCtxt;
5644
5745/// Boolean flag used to indicate if this search is for a suggestion
5846/// 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 @@
33
44// ignore-tidy-filelength
55
6use crate::errors::{self, CandidateTraitNote, NoAssociatedItem};
7use crate::Expectation;
8use crate::FnCtxt;
96use core::ops::ControlFlow;
7use std::borrow::Cow;
8
109use hir::Expr;
1110use rustc_ast::ast::Mutability;
1211use rustc_attr::parse_confusables;
1312use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
1413use rustc_data_structures::sorted_map::SortedMap;
1514use rustc_data_structures::unord::UnordSet;
16use rustc_errors::{
17 codes::*, pluralize, struct_span_code_err, Applicability, Diag, MultiSpan, StashKey,
18};
15use rustc_errors::codes::*;
16use rustc_errors::{pluralize, struct_span_code_err, Applicability, Diag, MultiSpan, StashKey};
1917use rustc_hir::def::DefKind;
2018use rustc_hir::def_id::DefId;
19use rustc_hir::intravisit::{self, Visitor};
2120use rustc_hir::lang_items::LangItem;
22use rustc_hir::PathSegment;
23use rustc_hir::{self as hir, HirId};
24use rustc_hir::{ExprKind, Node, QPath};
21use rustc_hir::{self as hir, ExprKind, HirId, Node, PathSegment, QPath};
2522use rustc_infer::infer::{self, RegionVariableOrigin};
2623use rustc_middle::bug;
27use rustc_middle::ty::fast_reject::DeepRejectCtxt;
28use rustc_middle::ty::fast_reject::{simplify_type, TreatParams};
24use rustc_middle::ty::fast_reject::{simplify_type, DeepRejectCtxt, TreatParams};
2925use rustc_middle::ty::print::{
3026 with_crate_prefix, with_forced_trimmed_paths, PrintTraitRefExt as _,
3127};
32use rustc_middle::ty::IsSuggestable;
33use rustc_middle::ty::{self, GenericArgKind, Ty, TyCtxt, TypeVisitableExt};
28use rustc_middle::ty::{self, GenericArgKind, IsSuggestable, Ty, TyCtxt, TypeVisitableExt};
3429use rustc_span::def_id::DefIdSet;
3530use rustc_span::symbol::{kw, sym, Ident};
36use rustc_span::{edit_distance, ErrorGuaranteed, ExpnKind, FileName, MacroKind, Span};
37use rustc_span::{Symbol, DUMMY_SP};
31use rustc_span::{
32 edit_distance, ErrorGuaranteed, ExpnKind, FileName, MacroKind, Span, Symbol, DUMMY_SP,
33};
3834use rustc_trait_selection::error_reporting::traits::on_unimplemented::OnUnimplementedNote;
3935use rustc_trait_selection::infer::InferCtxtExt;
4036use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt as _;
4137use rustc_trait_selection::traits::{
4238 supertraits, FulfillmentError, Obligation, ObligationCause, ObligationCauseCode,
4339};
44use std::borrow::Cow;
4540
4641use super::probe::{AutorefOrPtrAdjustment, IsSuggestion, Mode, ProbeScope};
4742use super::{CandidateSource, MethodError, NoMatchData};
48use rustc_hir::intravisit::{self, Visitor};
43use crate::errors::{self, CandidateTraitNote, NoAssociatedItem};
44use crate::{Expectation, FnCtxt};
4945
5046impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
5147 fn is_fn_ty(&self, ty: Ty<'tcx>, span: Span) -> bool {
compiler/rustc_hir_typeck/src/op.rs+7-6
......@@ -1,12 +1,8 @@
11//! Code related to processing overloaded binary and unary operators.
22
3use super::method::MethodCallee;
4use super::FnCtxt;
5use crate::Expectation;
6use rustc_ast as ast;
73use rustc_data_structures::packed::Pu128;
8use rustc_errors::{codes::*, struct_span_code_err, Applicability, Diag};
9use rustc_hir as hir;
4use rustc_errors::codes::*;
5use rustc_errors::{struct_span_code_err, Applicability, Diag};
106use rustc_infer::traits::ObligationCauseCode;
117use rustc_middle::ty::adjustment::{
128 Adjust, Adjustment, AllowTwoPhase, AutoBorrow, AutoBorrowMutability,
......@@ -21,6 +17,11 @@ use rustc_span::Span;
2117use rustc_trait_selection::infer::InferCtxtExt;
2218use rustc_trait_selection::traits::{FulfillmentError, ObligationCtxt};
2319use rustc_type_ir::TyKind::*;
20use {rustc_ast as ast, rustc_hir as hir};
21
22use super::method::MethodCallee;
23use super::FnCtxt;
24use crate::Expectation;
2425
2526impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
2627 /// Checks a `a <op>= b`
compiler/rustc_hir_typeck/src/pat.rs+9-7
......@@ -1,9 +1,11 @@
1use crate::gather_locals::DeclOrigin;
2use crate::{errors, FnCtxt, LoweredTy};
1use std::cmp;
2use std::collections::hash_map::Entry::{Occupied, Vacant};
3
34use rustc_ast as ast;
45use rustc_data_structures::fx::FxHashMap;
6use rustc_errors::codes::*;
57use rustc_errors::{
6 codes::*, pluralize, struct_span_code_err, Applicability, Diag, ErrorGuaranteed, MultiSpan,
8 pluralize, struct_span_code_err, Applicability, Diag, ErrorGuaranteed, MultiSpan,
79};
810use rustc_hir::def::{CtorKind, DefKind, Res};
911use rustc_hir::pat_util::EnumerateAndAdjustIterator;
......@@ -12,7 +14,8 @@ use rustc_infer::infer;
1214use rustc_middle::mir::interpret::ErrorHandled;
1315use rustc_middle::ty::{self, Ty, TypeVisitableExt};
1416use rustc_middle::{bug, span_bug};
15use rustc_session::{lint::builtin::NON_EXHAUSTIVE_OMITTED_PATTERNS, parse::feature_err};
17use rustc_session::lint::builtin::NON_EXHAUSTIVE_OMITTED_PATTERNS;
18use rustc_session::parse::feature_err;
1619use rustc_span::edit_distance::find_best_match_for_name;
1720use rustc_span::hygiene::DesugaringKind;
1821use rustc_span::source_map::Spanned;
......@@ -23,10 +26,9 @@ use rustc_trait_selection::infer::InferCtxtExt;
2326use rustc_trait_selection::traits::{ObligationCause, ObligationCauseCode};
2427use ty::VariantDef;
2528
26use std::cmp;
27use std::collections::hash_map::Entry::{Occupied, Vacant};
28
2929use super::report_unexpected_variant_res;
30use crate::gather_locals::DeclOrigin;
31use crate::{errors, FnCtxt, LoweredTy};
3032
3133const CANNOT_IMPLICITLY_DEREF_POINTER_TRAIT_OBJ: &str = "\
3234This 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 @@
1use crate::method::MethodCallee;
2use crate::{FnCtxt, PlaceOp};
3use rustc_ast as ast;
41use rustc_errors::Applicability;
5use rustc_hir as hir;
62use rustc_hir_analysis::autoderef::Autoderef;
73use rustc_infer::infer::InferOk;
84use rustc_middle::span_bug;
9use rustc_middle::ty::adjustment::{Adjust, Adjustment, OverloadedDeref, PointerCoercion};
10use rustc_middle::ty::adjustment::{AllowTwoPhase, AutoBorrow, AutoBorrowMutability};
5use rustc_middle::ty::adjustment::{
6 Adjust, Adjustment, AllowTwoPhase, AutoBorrow, AutoBorrowMutability, OverloadedDeref,
7 PointerCoercion,
8};
119use rustc_middle::ty::{self, Ty};
1210use rustc_span::symbol::{sym, Ident};
1311use rustc_span::Span;
12use {rustc_ast as ast, rustc_hir as hir};
13
14use crate::method::MethodCallee;
15use crate::{FnCtxt, PlaceOp};
1416
1517impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1618 /// Type-check `*oprnd_expr` with `oprnd_expr` type-checked already.
compiler/rustc_hir_typeck/src/rvalue_scopes.rs+2-1
......@@ -1,4 +1,3 @@
1use super::FnCtxt;
21use hir::def_id::DefId;
32use hir::Node;
43use rustc_hir as hir;
......@@ -6,6 +5,8 @@ use rustc_middle::bug;
65use rustc_middle::middle::region::{RvalueCandidateType, Scope, ScopeTree};
76use rustc_middle::ty::RvalueScopes;
87
8use super::FnCtxt;
9
910/// Applied to an expression `expr` if `expr` -- or something owned or partially owned by
1011/// `expr` -- is going to be indirectly referenced by a variable in a let statement. In that
1112/// 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 @@
1use super::callee::DeferredCallResolution;
1use std::cell::RefCell;
2use std::ops::Deref;
23
34use rustc_data_structures::unord::{UnordMap, UnordSet};
45use rustc_hir as hir;
......@@ -15,8 +16,7 @@ use rustc_trait_selection::traits::{
1516 self, FulfillmentError, PredicateObligation, TraitEngine, TraitEngineExt as _,
1617};
1718
18use std::cell::RefCell;
19use std::ops::Deref;
19use super::callee::DeferredCallResolution;
2020
2121/// Data shared between a "typeck root" and its nested bodies,
2222/// e.g. closures defined within the function. For example:
compiler/rustc_hir_typeck/src/upvar.rs+6-8
......@@ -30,9 +30,9 @@
3030//! then mean that all later passes would have to check for these figments
3131//! and report an error, and it just seems like more mess in the end.)
3232
33use super::FnCtxt;
33use std::iter;
3434
35use crate::expr_use_visitor as euv;
35use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
3636use rustc_data_structures::unord::{ExtendUnord, UnordSet};
3737use rustc_errors::{Applicability, MultiSpan};
3838use rustc_hir as hir;
......@@ -49,14 +49,12 @@ use rustc_middle::ty::{
4949};
5050use rustc_middle::{bug, span_bug};
5151use rustc_session::lint;
52use rustc_span::sym;
53use rustc_span::{BytePos, Pos, Span, Symbol};
54use rustc_trait_selection::infer::InferCtxtExt;
55
56use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
52use rustc_span::{sym, BytePos, Pos, Span, Symbol};
5753use rustc_target::abi::FIRST_VARIANT;
54use rustc_trait_selection::infer::InferCtxtExt;
5855
59use std::iter;
56use super::FnCtxt;
57use crate::expr_use_visitor as euv;
6058
6159/// Describe the relationship between the paths of two places
6260/// eg:
compiler/rustc_hir_typeck/src/writeback.rs+4-4
......@@ -2,7 +2,8 @@
22// unresolved type variables and replaces "ty_var" types with their
33// generic parameters.
44
5use crate::FnCtxt;
5use std::mem;
6
67use rustc_data_structures::unord::ExtendUnord;
78use rustc_errors::{ErrorGuaranteed, StashKey};
89use rustc_hir as hir;
......@@ -13,14 +14,13 @@ use rustc_middle::traits::ObligationCause;
1314use rustc_middle::ty::adjustment::{Adjust, Adjustment, PointerCoercion};
1415use rustc_middle::ty::fold::{TypeFoldable, TypeFolder};
1516use rustc_middle::ty::visit::TypeVisitableExt;
16use rustc_middle::ty::TypeSuperFoldable;
17use rustc_middle::ty::{self, Ty, TyCtxt};
17use rustc_middle::ty::{self, Ty, TyCtxt, TypeSuperFoldable};
1818use rustc_span::symbol::sym;
1919use rustc_span::Span;
2020use rustc_trait_selection::error_reporting::infer::need_type_info::TypeAnnotationNeeded;
2121use rustc_trait_selection::solve;
2222
23use std::mem;
23use crate::FnCtxt;
2424
2525///////////////////////////////////////////////////////////////////////////
2626// Entry point
compiler/rustc_incremental/src/assert_dep_graph.rs+7-7
......@@ -33,12 +33,12 @@
3333//! fn baz() { foo(); }
3434//! ```
3535
36use crate::errors;
37use rustc_ast as ast;
36use std::env;
37use std::fs::{self, File};
38use std::io::{BufWriter, Write};
39
3840use rustc_data_structures::fx::FxIndexSet;
3941use rustc_data_structures::graph::implementation::{Direction, NodeIndex, INCOMING, OUTGOING};
40use rustc_graphviz as dot;
41use rustc_hir as hir;
4242use rustc_hir::def_id::{DefId, LocalDefId, CRATE_DEF_ID};
4343use rustc_hir::intravisit::{self, Visitor};
4444use rustc_middle::dep_graph::{
......@@ -49,10 +49,10 @@ use rustc_middle::ty::TyCtxt;
4949use rustc_middle::{bug, span_bug};
5050use rustc_span::symbol::{sym, Symbol};
5151use rustc_span::Span;
52use std::env;
53use std::fs::{self, File};
54use std::io::{BufWriter, Write};
5552use tracing::debug;
53use {rustc_ast as ast, rustc_graphviz as dot, rustc_hir as hir};
54
55use crate::errors;
5656
5757#[allow(missing_docs)]
5858pub fn assert_dep_graph(tcx: TyCtxt<'_>) {
compiler/rustc_incremental/src/errors.rs+4-2
......@@ -1,7 +1,9 @@
1use rustc_macros::Diagnostic;
2use rustc_span::{symbol::Ident, Span, Symbol};
31use std::path::{Path, PathBuf};
42
3use rustc_macros::Diagnostic;
4use rustc_span::symbol::Ident;
5use rustc_span::{Span, Symbol};
6
57#[derive(Diagnostic)]
68#[diag(incremental_unrecognized_depnode)]
79pub struct UnrecognizedDepNode {
compiler/rustc_incremental/src/lib.rs+5-9
......@@ -12,14 +12,10 @@ mod assert_dep_graph;
1212mod errors;
1313mod persist;
1414
15pub use persist::copy_cgu_workproduct_to_incr_comp_cache_dir;
16pub use persist::finalize_session_directory;
17pub use persist::in_incr_comp_dir;
18pub use persist::in_incr_comp_dir_sess;
19pub use persist::load_query_result_cache;
20pub use persist::save_dep_graph;
21pub use persist::save_work_product_index;
22pub use persist::setup_dep_graph;
23pub use persist::LoadResult;
15pub 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};
2420
2521rustc_fluent_macro::fluent_messages! { "../messages.ftl" }
compiler/rustc_incremental/src/persist/dirty_clean.rs+3-4
......@@ -19,14 +19,11 @@
1919//! Errors are reported if we are in the suitable configuration but
2020//! the required condition is not met.
2121
22use crate::errors;
2322use rustc_ast::{self as ast, Attribute, NestedMetaItem};
2423use rustc_data_structures::fx::FxHashSet;
2524use rustc_data_structures::unord::UnordSet;
2625use rustc_hir::def_id::LocalDefId;
27use rustc_hir::intravisit;
28use rustc_hir::Node as HirNode;
29use rustc_hir::{ImplItemKind, ItemKind as HirItem, TraitItemKind};
26use rustc_hir::{intravisit, ImplItemKind, ItemKind as HirItem, Node as HirNode, TraitItemKind};
3027use rustc_middle::dep_graph::{label_strs, DepNode, DepNodeExt};
3128use rustc_middle::hir::nested_filter;
3229use rustc_middle::ty::TyCtxt;
......@@ -35,6 +32,8 @@ use rustc_span::Span;
3532use thin_vec::ThinVec;
3633use tracing::debug;
3734
35use crate::errors;
36
3837const LOADED_FROM_DISK: Symbol = sym::loaded_from_disk;
3938const EXCEPT: Symbol = sym::except;
4039const CFG: Symbol = sym::cfg;
compiler/rustc_incremental/src/persist/file_format.rs+7-6
......@@ -9,18 +9,19 @@
99//! compiler versions don't change frequently for the typical user, being
1010//! conservative here practically has no downside.
1111
12use crate::errors;
12use std::borrow::Cow;
13use std::io::{self, Read};
14use std::path::{Path, PathBuf};
15use std::{env, fs};
16
1317use rustc_data_structures::memmap::Mmap;
1418use rustc_serialize::opaque::{FileEncodeResult, FileEncoder};
1519use rustc_serialize::Encoder;
1620use rustc_session::Session;
17use std::borrow::Cow;
18use std::env;
19use std::fs;
20use std::io::{self, Read};
21use std::path::{Path, PathBuf};
2221use tracing::debug;
2322
23use crate::errors;
24
2425/// The first few bytes of files generated by incremental compilation.
2526const FILE_MAGIC: &[u8] = b"RSIC";
2627
compiler/rustc_incremental/src/persist/fs.rs+10-13
......@@ -103,30 +103,27 @@
103103//! unsupported file system and emit a warning in that case. This is not yet
104104//! implemented.
105105
106use crate::errors;
107use rustc_data_structures::base_n;
108use rustc_data_structures::base_n::BaseNString;
109use rustc_data_structures::base_n::ToBaseN;
110use rustc_data_structures::base_n::CASE_INSENSITIVE;
111use rustc_data_structures::flock;
106use std::fs as std_fs;
107use std::io::{self, ErrorKind};
108use std::path::{Path, PathBuf};
109use std::time::{Duration, SystemTime, UNIX_EPOCH};
110
111use rand::{thread_rng, RngCore};
112use rustc_data_structures::base_n::{BaseNString, ToBaseN, CASE_INSENSITIVE};
112113use rustc_data_structures::fx::{FxHashSet, FxIndexSet};
113114use rustc_data_structures::svh::Svh;
114115use rustc_data_structures::unord::{UnordMap, UnordSet};
116use rustc_data_structures::{base_n, flock};
115117use rustc_errors::ErrorGuaranteed;
116118use rustc_fs_util::{link_or_copy, try_canonicalize, LinkOrCopy};
117119use rustc_middle::bug;
118120use rustc_session::config::CrateType;
119121use rustc_session::output::{collect_crate_types, find_crate_name};
120122use rustc_session::{Session, StableCrateId};
121
122use std::fs as std_fs;
123use std::io::{self, ErrorKind};
124use std::path::{Path, PathBuf};
125use std::time::{Duration, SystemTime, UNIX_EPOCH};
126
127use rand::{thread_rng, RngCore};
128123use tracing::debug;
129124
125use crate::errors;
126
130127#[cfg(test)]
131128mod tests;
132129
compiler/rustc_incremental/src/persist/load.rs+5-5
......@@ -1,6 +1,8 @@
11//! Code to load the dep-graph from files.
22
3use crate::errors;
3use std::path::{Path, PathBuf};
4use std::sync::Arc;
5
46use rustc_data_structures::memmap::Mmap;
57use rustc_data_structures::unord::UnordMap;
68use rustc_middle::dep_graph::{DepGraph, DepsType, SerializedDepGraph, WorkProductMap};
......@@ -10,15 +12,13 @@ use rustc_serialize::Decodable;
1012use rustc_session::config::IncrementalStateAssertion;
1113use rustc_session::Session;
1214use rustc_span::ErrorGuaranteed;
13use std::path::{Path, PathBuf};
14use std::sync::Arc;
1515use tracing::{debug, warn};
1616
1717use super::data::*;
18use super::file_format;
1918use super::fs::*;
2019use super::save::build_dep_graph;
21use super::work_product;
20use super::{file_format, work_product};
21use crate::errors;
2222
2323#[derive(Debug)]
2424/// 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;
1010mod save;
1111mod work_product;
1212
13pub use fs::finalize_session_directory;
14pub use fs::in_incr_comp_dir;
15pub use fs::in_incr_comp_dir_sess;
16pub use load::load_query_result_cache;
17pub use load::setup_dep_graph;
18pub use load::LoadResult;
19pub use save::save_dep_graph;
20pub use save::save_work_product_index;
13pub use fs::{finalize_session_directory, in_incr_comp_dir, in_incr_comp_dir_sess};
14pub use load::{load_query_result_cache, setup_dep_graph, LoadResult};
15pub use save::{save_dep_graph, save_work_product_index};
2116pub use work_product::copy_cgu_workproduct_to_incr_comp_cache_dir;
compiler/rustc_incremental/src/persist/save.rs+6-7
......@@ -1,5 +1,6 @@
1use crate::assert_dep_graph::assert_dep_graph;
2use crate::errors;
1use std::fs;
2use std::sync::Arc;
3
34use rustc_data_structures::fx::FxIndexMap;
45use rustc_data_structures::sync::join;
56use rustc_middle::dep_graph::{
......@@ -9,15 +10,13 @@ use rustc_middle::ty::TyCtxt;
910use rustc_serialize::opaque::{FileEncodeResult, FileEncoder};
1011use rustc_serialize::Encodable as RustcEncodable;
1112use rustc_session::Session;
12use std::fs;
13use std::sync::Arc;
1413use tracing::debug;
1514
1615use super::data::*;
17use super::dirty_clean;
18use super::file_format;
1916use super::fs::*;
20use super::work_product;
17use super::{dirty_clean, file_format, work_product};
18use crate::assert_dep_graph::assert_dep_graph;
19use crate::errors;
2120
2221/// Saves and writes the [`DepGraph`] to the file system.
2322///
compiler/rustc_incremental/src/persist/work_product.rs+6-4
......@@ -2,16 +2,18 @@
22//!
33//! [work products]: WorkProduct
44
5use crate::errors;
6use crate::persist::fs::*;
5use std::fs as std_fs;
6use std::path::Path;
7
78use rustc_data_structures::unord::UnordMap;
89use rustc_fs_util::link_or_copy;
910use rustc_middle::dep_graph::{WorkProduct, WorkProductId};
1011use rustc_session::Session;
11use std::fs as std_fs;
12use std::path::Path;
1312use tracing::debug;
1413
14use crate::errors;
15use crate::persist::fs::*;
16
1517/// Copies a CGU work product to the incremental compilation directory, so next compilation can
1618/// find and reuse it.
1719pub fn copy_cgu_workproduct_to_incr_comp_cache_dir(
compiler/rustc_index/src/bit_set.rs+3-8
......@@ -1,21 +1,16 @@
1use std::fmt;
2use std::iter;
31use std::marker::PhantomData;
4use std::mem;
52use std::ops::{BitAnd, BitAndAssign, BitOrAssign, Bound, Not, Range, RangeBounds, Shl};
63use std::rc::Rc;
7use std::slice;
4use std::{fmt, iter, mem, slice};
85
96use arrayvec::ArrayVec;
10use smallvec::{smallvec, SmallVec};
11
127#[cfg(feature = "nightly")]
138use rustc_macros::{Decodable_Generic, Encodable_Generic};
9use smallvec::{smallvec, SmallVec};
10use Chunk::*;
1411
1512use crate::{Idx, IndexVec};
1613
17use Chunk::*;
18
1914#[cfg(test)]
2015mod tests;
2116
compiler/rustc_index/src/bit_set/tests.rs+1
......@@ -2,6 +2,7 @@ use super::*;
22
33extern crate test;
44use std::hint::black_box;
5
56use test::Bencher;
67
78#[test]
compiler/rustc_index/src/interval.rs+1-2
......@@ -1,7 +1,6 @@
11use std::iter::Step;
22use std::marker::PhantomData;
3use std::ops::RangeBounds;
4use std::ops::{Bound, Range};
3use std::ops::{Bound, Range, RangeBounds};
54
65use smallvec::SmallVec;
76
compiler/rustc_index/src/lib.rs+3-2
......@@ -12,9 +12,10 @@ mod idx;
1212mod slice;
1313mod vec;
1414
15pub use {idx::Idx, slice::IndexSlice, vec::IndexVec};
16
15pub use idx::Idx;
1716pub use rustc_index_macros::newtype_index;
17pub use slice::IndexSlice;
18pub use vec::IndexVec;
1819
1920/// Type size assertion. The first argument is a type and the second argument is its expected size.
2021///
compiler/rustc_index/src/slice.rs+3-6
......@@ -1,9 +1,6 @@
1use std::{
2 fmt,
3 marker::PhantomData,
4 ops::{Index, IndexMut},
5 slice,
6};
1use std::marker::PhantomData;
2use std::ops::{Index, IndexMut};
3use std::{fmt, slice};
74
85use crate::{Idx, IndexVec};
96
compiler/rustc_index/src/vec.rs+4-6
......@@ -1,13 +1,11 @@
1#[cfg(feature = "nightly")]
2use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
3
41use std::borrow::{Borrow, BorrowMut};
5use std::fmt;
62use std::hash::Hash;
73use std::marker::PhantomData;
84use std::ops::{Deref, DerefMut, RangeBounds};
9use std::slice;
10use std::vec;
5use std::{fmt, slice, vec};
6
7#[cfg(feature = "nightly")]
8use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
119
1210use crate::{Idx, IndexSlice};
1311
compiler/rustc_infer/src/infer/at.rs+2-3
......@@ -25,12 +25,11 @@
2525//! sometimes useful when the types of `c` and `d` are not traceable
2626//! things. (That system should probably be refactored.)
2727
28use super::*;
29
30use crate::infer::relate::{Relate, StructurallyRelateAliases, TypeRelation};
3128use rustc_middle::bug;
3229use rustc_middle::ty::{Const, ImplSubject};
3330
31use super::*;
32use crate::infer::relate::{Relate, StructurallyRelateAliases, TypeRelation};
3433use crate::traits::Obligation;
3534
3635/// 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 @@
55//!
66//! [c]: https://rust-lang.github.io/chalk/book/canonical_queries/canonicalization.html
77
8use rustc_data_structures::fx::FxHashMap;
9use rustc_index::Idx;
10use rustc_middle::bug;
11use rustc_middle::ty::fold::{TypeFoldable, TypeFolder, TypeSuperFoldable};
12use rustc_middle::ty::{
13 self, BoundVar, GenericArg, InferConst, List, Ty, TyCtxt, TypeFlags, TypeVisitableExt,
14};
15use smallvec::SmallVec;
16
817use crate::infer::canonical::{
918 Canonical, CanonicalTyVarKind, CanonicalVarInfo, CanonicalVarKind, OriginalQueryValues,
1019};
1120use crate::infer::InferCtxt;
12use rustc_middle::bug;
13use rustc_middle::ty::fold::{TypeFoldable, TypeFolder, TypeSuperFoldable};
14use rustc_middle::ty::GenericArg;
15use rustc_middle::ty::{self, BoundVar, InferConst, List, Ty, TyCtxt, TypeFlags, TypeVisitableExt};
16
17use rustc_data_structures::fx::FxHashMap;
18use rustc_index::Idx;
19use smallvec::SmallVec;
2021
2122impl<'tcx> InferCtxt<'tcx> {
2223 /// Canonicalizes a query value `V`. When we canonicalize a query,
compiler/rustc_infer/src/infer/canonical/instantiate.rs+3-3
......@@ -6,12 +6,12 @@
66//!
77//! [c]: https://rust-lang.github.io/chalk/book/canonical_queries/canonicalization.html
88
9use crate::infer::canonical::{Canonical, CanonicalVarValues};
109use rustc_macros::extension;
1110use rustc_middle::bug;
1211use rustc_middle::ty::fold::{FnMutDelegate, TypeFoldable};
13use rustc_middle::ty::GenericArgKind;
14use rustc_middle::ty::{self, TyCtxt};
12use rustc_middle::ty::{self, GenericArgKind, TyCtxt};
13
14use crate::infer::canonical::{Canonical, CanonicalVarValues};
1515
1616/// FIXME(-Znext-solver): This or public because it is shared with the
1717/// new trait solver implementation. We should deduplicate canonicalization.
compiler/rustc_infer/src/infer/canonical/mod.rs+4-5
......@@ -21,16 +21,15 @@
2121//!
2222//! [c]: https://rust-lang.github.io/chalk/book/canonical_queries/canonicalization.html
2323
24use crate::infer::{InferCtxt, RegionVariableOrigin};
24pub use instantiate::CanonicalExt;
2525use rustc_index::IndexVec;
26pub use rustc_middle::infer::canonical::*;
2627use rustc_middle::infer::unify_key::EffectVarValue;
2728use rustc_middle::ty::fold::TypeFoldable;
28use rustc_middle::ty::GenericArg;
29use rustc_middle::ty::{self, List, Ty, TyCtxt};
29use rustc_middle::ty::{self, GenericArg, List, Ty, TyCtxt};
3030use rustc_span::Span;
3131
32pub use instantiate::CanonicalExt;
33pub use rustc_middle::infer::canonical::*;
32use crate::infer::{InferCtxt, RegionVariableOrigin};
3433
3534mod canonicalizer;
3635mod instantiate;
compiler/rustc_infer/src/infer/canonical/query_response.rs+14-13
......@@ -7,6 +7,17 @@
77//!
88//! [c]: https://rust-lang.github.io/chalk/book/canonical_queries/canonicalization.html
99
10use std::fmt::Debug;
11use std::iter;
12
13use rustc_data_structures::captures::Captures;
14use rustc_index::{Idx, IndexVec};
15use rustc_middle::arena::ArenaAllocatable;
16use rustc_middle::mir::ConstraintCategory;
17use rustc_middle::ty::fold::TypeFoldable;
18use rustc_middle::ty::{self, BoundVar, GenericArg, GenericArgKind, Ty, TyCtxt};
19use rustc_middle::{bug, span_bug};
20
1021use crate::infer::canonical::instantiate::{instantiate_value, CanonicalExt};
1122use crate::infer::canonical::{
1223 Canonical, CanonicalQueryResponse, CanonicalVarValues, Certainty, OriginalQueryValues,
......@@ -15,19 +26,9 @@ use crate::infer::canonical::{
1526use crate::infer::region_constraints::{Constraint, RegionConstraintData};
1627use crate::infer::{DefineOpaqueTypes, InferCtxt, InferOk, InferResult};
1728use crate::traits::query::NoSolution;
18use crate::traits::{Obligation, ObligationCause, PredicateObligation};
19use crate::traits::{ScrubbedTraitError, TraitEngine};
20use rustc_data_structures::captures::Captures;
21use rustc_index::Idx;
22use rustc_index::IndexVec;
23use rustc_middle::arena::ArenaAllocatable;
24use rustc_middle::mir::ConstraintCategory;
25use rustc_middle::ty::fold::TypeFoldable;
26use rustc_middle::ty::{self, BoundVar, Ty, TyCtxt};
27use rustc_middle::ty::{GenericArg, GenericArgKind};
28use rustc_middle::{bug, span_bug};
29use std::fmt::Debug;
30use std::iter;
29use crate::traits::{
30 Obligation, ObligationCause, PredicateObligation, ScrubbedTraitError, TraitEngine,
31};
3132
3233impl<'tcx> InferCtxt<'tcx> {
3334 /// 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 @@
3131//! variable only once, and it does so as soon as it can, so it is reasonable to ask what the type
3232//! inferencer knows "so far".
3333
34use super::InferCtxt;
34use std::collections::hash_map::Entry;
35
3536use rustc_data_structures::fx::FxHashMap;
3637use rustc_middle::bug;
3738use rustc_middle::ty::fold::TypeFolder;
3839use rustc_middle::ty::{self, Ty, TyCtxt, TypeFoldable, TypeSuperFoldable, TypeVisitableExt};
39use std::collections::hash_map::Entry;
40
41use super::InferCtxt;
4042
4143pub struct TypeFreshener<'a, 'tcx> {
4244 infcx: &'a InferCtxt<'tcx>,
compiler/rustc_infer/src/infer/lexical_region_resolve/mod.rs+10-13
......@@ -1,13 +1,7 @@
11//! Lexical region resolution.
22
3use crate::infer::region_constraints::Constraint;
4use crate::infer::region_constraints::GenericKind;
5use crate::infer::region_constraints::RegionConstraintData;
6use crate::infer::region_constraints::VarInfos;
7use crate::infer::region_constraints::VerifyBound;
8use crate::infer::RegionRelations;
9use crate::infer::RegionVariableOrigin;
10use crate::infer::SubregionOrigin;
3use std::fmt;
4
115use rustc_data_structures::fx::FxHashSet;
126use rustc_data_structures::graph::implementation::{
137 Direction, Graph, NodeIndex, INCOMING, OUTGOING,
......@@ -16,15 +10,18 @@ use rustc_data_structures::intern::Interned;
1610use rustc_data_structures::unord::UnordSet;
1711use rustc_index::{IndexSlice, IndexVec};
1812use rustc_middle::ty::fold::TypeFoldable;
19use rustc_middle::ty::{self, Ty, TyCtxt};
20use rustc_middle::ty::{ReBound, RePlaceholder, ReVar};
21use rustc_middle::ty::{ReEarlyParam, ReErased, ReError, ReLateParam, ReStatic};
22use rustc_middle::ty::{Region, RegionVid};
13use rustc_middle::ty::{
14 self, ReBound, ReEarlyParam, ReErased, ReError, ReLateParam, RePlaceholder, ReStatic, ReVar,
15 Region, RegionVid, Ty, TyCtxt,
16};
2317use rustc_middle::{bug, span_bug};
2418use rustc_span::Span;
25use std::fmt;
2619
2720use super::outlives::test_type_match;
21use crate::infer::region_constraints::{
22 Constraint, GenericKind, RegionConstraintData, VarInfos, VerifyBound,
23};
24use crate::infer::{RegionRelations, RegionVariableOrigin, SubregionOrigin};
2825
2926/// This function performs lexical region resolution given a complete
3027/// set of constraints and variable origins. It performs a fixed-point
compiler/rustc_infer/src/infer/mod.rs+29-28
......@@ -1,55 +1,56 @@
1pub use at::DefineOpaqueTypes;
2pub use freshen::TypeFreshener;
3pub use lexical_region_resolve::RegionResolutionError;
4pub use relate::combine::CombineFields;
5pub use relate::combine::PredicateEmittingRelation;
6pub use relate::StructurallyRelateAliases;
7use rustc_errors::DiagCtxtHandle;
8pub use rustc_macros::{TypeFoldable, TypeVisitable};
9pub use rustc_middle::ty::IntVarValue;
10pub use BoundRegionConversionTime::*;
11pub use RegionVariableOrigin::*;
12pub use SubregionOrigin::*;
1use std::cell::{Cell, RefCell};
2use std::fmt;
133
14use crate::infer::relate::RelateResult;
15use crate::traits::{self, ObligationCause, ObligationInspector, PredicateObligation, TraitEngine};
4pub use at::DefineOpaqueTypes;
165use free_regions::RegionRelations;
6pub use freshen::TypeFreshener;
177use lexical_region_resolve::LexicalRegionResolutions;
8pub use lexical_region_resolve::RegionResolutionError;
189use opaque_types::OpaqueTypeStorage;
19use region_constraints::{GenericKind, VarInfos, VerifyBound};
20use region_constraints::{RegionConstraintCollector, RegionConstraintStorage};
10use region_constraints::{
11 GenericKind, RegionConstraintCollector, RegionConstraintStorage, VarInfos, VerifyBound,
12};
13pub use relate::combine::{CombineFields, PredicateEmittingRelation};
14pub use relate::StructurallyRelateAliases;
2115use rustc_data_structures::captures::Captures;
2216use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap};
2317use rustc_data_structures::sync::Lrc;
2418use rustc_data_structures::undo_log::Rollback;
2519use rustc_data_structures::unify as ut;
26use rustc_errors::ErrorGuaranteed;
20use rustc_errors::{DiagCtxtHandle, ErrorGuaranteed};
2721use rustc_hir as hir;
2822use rustc_hir::def_id::{DefId, LocalDefId};
2923use rustc_macros::extension;
24pub use rustc_macros::{TypeFoldable, TypeVisitable};
3025use rustc_middle::infer::canonical::{Canonical, CanonicalVarValues};
31use rustc_middle::infer::unify_key::ConstVariableOrigin;
32use rustc_middle::infer::unify_key::ConstVariableValue;
33use rustc_middle::infer::unify_key::EffectVarValue;
34use rustc_middle::infer::unify_key::{ConstVidKey, EffectVidKey};
26use rustc_middle::infer::unify_key::{
27 ConstVariableOrigin, ConstVariableValue, ConstVidKey, EffectVarValue, EffectVidKey,
28};
3529use rustc_middle::mir::interpret::{ErrorHandled, EvalToValTreeResult};
3630use rustc_middle::mir::ConstraintCategory;
3731use rustc_middle::traits::select;
3832use rustc_middle::traits::solve::{Goal, NoSolution};
3933use rustc_middle::ty::error::{ExpectedFound, TypeError};
40use rustc_middle::ty::fold::BoundVarReplacerDelegate;
41use rustc_middle::ty::fold::{TypeFoldable, TypeFolder, TypeSuperFoldable};
34use rustc_middle::ty::fold::{
35 BoundVarReplacerDelegate, TypeFoldable, TypeFolder, TypeSuperFoldable,
36};
4237use rustc_middle::ty::visit::TypeVisitableExt;
43use rustc_middle::ty::{self, GenericParamDefKind, InferConst, Ty, TyCtxt};
44use rustc_middle::ty::{ConstVid, EffectVid, FloatVid, IntVid, TyVid};
45use rustc_middle::ty::{GenericArg, GenericArgKind, GenericArgs, GenericArgsRef};
38pub use rustc_middle::ty::IntVarValue;
39use rustc_middle::ty::{
40 self, ConstVid, EffectVid, FloatVid, GenericArg, GenericArgKind, GenericArgs, GenericArgsRef,
41 GenericParamDefKind, InferConst, IntVid, Ty, TyCtxt, TyVid,
42};
4643use rustc_middle::{bug, span_bug};
4744use rustc_span::symbol::Symbol;
4845use rustc_span::Span;
4946use snapshot::undo_log::InferCtxtUndoLogs;
50use std::cell::{Cell, RefCell};
51use std::fmt;
5247use type_variable::TypeVariableOrigin;
48pub use BoundRegionConversionTime::*;
49pub use RegionVariableOrigin::*;
50pub use SubregionOrigin::*;
51
52use crate::infer::relate::RelateResult;
53use crate::traits::{self, ObligationCause, ObligationInspector, PredicateObligation, TraitEngine};
5354
5455pub mod at;
5556pub mod canonical;
compiler/rustc_infer/src/infer/opaque_types/mod.rs+6-6
......@@ -1,6 +1,3 @@
1use crate::errors::OpaqueHiddenTypeDiag;
2use crate::infer::{InferCtxt, InferOk};
3use crate::traits::{self, Obligation};
41use hir::def_id::{DefId, LocalDefId};
52use rustc_data_structures::fx::FxIndexMap;
63use rustc_data_structures::sync::Lrc;
......@@ -9,13 +6,16 @@ use rustc_middle::traits::solve::Goal;
96use rustc_middle::traits::ObligationCause;
107use rustc_middle::ty::error::{ExpectedFound, TypeError};
118use rustc_middle::ty::fold::BottomUpFolder;
12use rustc_middle::ty::GenericArgKind;
139use 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,
1612};
1713use rustc_span::Span;
1814
15use crate::errors::OpaqueHiddenTypeDiag;
16use crate::infer::{InferCtxt, InferOk};
17use crate::traits::{self, Obligation};
18
1919mod table;
2020
2121pub 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;
22use rustc_middle::bug;
33use rustc_middle::ty::{self, OpaqueHiddenType, OpaqueTypeKey, Ty};
44
5use crate::infer::snapshot::undo_log::{InferCtxtUndoLogs, UndoLog};
6
75use super::{OpaqueTypeDecl, OpaqueTypeMap};
6use crate::infer::snapshot::undo_log::{InferCtxtUndoLogs, UndoLog};
87
98#[derive(Default, Debug, Clone)]
109pub struct OpaqueTypeStorage<'tcx> {
compiler/rustc_infer/src/infer/outlives/env.rs+3-3
......@@ -1,12 +1,12 @@
1use crate::infer::free_regions::FreeRegionMap;
2use crate::infer::GenericKind;
3use crate::traits::query::OutlivesBound;
41use rustc_data_structures::fx::FxIndexSet;
52use rustc_data_structures::transitive_relation::TransitiveRelationBuilder;
63use rustc_middle::bug;
74use rustc_middle::ty::{self, Region};
85
96use super::explicit_outlives_bounds;
7use crate::infer::free_regions::FreeRegionMap;
8use crate::infer::GenericKind;
9use crate::traits::query::OutlivesBound;
1010
1111/// The `OutlivesEnvironment` collects information about what outlives
1212/// 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 @@
11//! Various code related to computing outlives relations.
22
3use rustc_middle::traits::query::{NoSolution, OutlivesBound};
4use rustc_middle::ty;
5
36use self::env::OutlivesEnvironment;
47use super::region_constraints::RegionConstraintData;
58use super::{InferCtxt, RegionResolutionError, SubregionOrigin};
69use crate::infer::free_regions::RegionRelations;
710use crate::infer::lexical_region_resolve;
8use rustc_middle::traits::query::{NoSolution, OutlivesBound};
9use rustc_middle::ty;
1011
1112pub mod env;
1213pub mod for_liveness;
compiler/rustc_infer/src/infer/outlives/obligations.rs+8-8
......@@ -59,25 +59,25 @@
5959//! might later infer `?U` to something like `&'b u32`, which would
6060//! imply that `'b: 'a`.
6161
62use crate::infer::outlives::env::RegionBoundPairs;
63use crate::infer::outlives::verify::VerifyBoundCx;
64use crate::infer::resolve::OpportunisticRegionResolver;
65use crate::infer::snapshot::undo_log::UndoLog;
66use crate::infer::{self, GenericKind, InferCtxt, RegionObligation, SubregionOrigin, VerifyBound};
67use crate::traits::{ObligationCause, ObligationCauseCode};
6862use rustc_data_structures::undo_log::UndoLogs;
6963use rustc_middle::bug;
7064use rustc_middle::mir::ConstraintCategory;
7165use rustc_middle::traits::query::NoSolution;
7266use rustc_middle::ty::{
73 self, GenericArgsRef, Region, Ty, TyCtxt, TypeFoldable as _, TypeVisitableExt,
67 self, GenericArgKind, GenericArgsRef, PolyTypeOutlivesPredicate, Region, Ty, TyCtxt,
68 TypeFoldable as _, TypeVisitableExt,
7469};
75use rustc_middle::ty::{GenericArgKind, PolyTypeOutlivesPredicate};
7670use rustc_span::DUMMY_SP;
7771use rustc_type_ir::outlives::{push_outlives_components, Component};
7872use smallvec::smallvec;
7973
8074use super::env::OutlivesEnvironment;
75use crate::infer::outlives::env::RegionBoundPairs;
76use crate::infer::outlives::verify::VerifyBoundCx;
77use crate::infer::resolve::OpportunisticRegionResolver;
78use crate::infer::snapshot::undo_log::UndoLog;
79use crate::infer::{self, GenericKind, InferCtxt, RegionObligation, SubregionOrigin, VerifyBound};
80use crate::traits::{ObligationCause, ObligationCauseCode};
8181
8282impl<'tcx> InferCtxt<'tcx> {
8383 /// 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;
22
33use rustc_data_structures::fx::FxHashMap;
44use rustc_middle::ty::error::TypeError;
5use rustc_middle::ty::TypeVisitableExt;
6use rustc_middle::ty::{self, Ty, TyCtxt};
5use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitableExt};
76
87use crate::infer::region_constraints::VerifyIfEq;
98use crate::infer::relate::{self as relate, Relate, RelateResult, TypeRelation};
compiler/rustc_infer/src/infer/outlives/verify.rs+4-4
......@@ -1,11 +1,11 @@
1use crate::infer::outlives::env::RegionBoundPairs;
2use crate::infer::region_constraints::VerifyIfEq;
3use crate::infer::{GenericKind, VerifyBound};
41use rustc_middle::ty::{self, OutlivesPredicate, Ty, TyCtxt};
52use rustc_type_ir::outlives::{compute_alias_components_recursive, Component};
6
73use smallvec::smallvec;
84
5use crate::infer::outlives::env::RegionBoundPairs;
6use crate::infer::region_constraints::VerifyIfEq;
7use crate::infer::{GenericKind, VerifyBound};
8
99/// The `TypeOutlives` struct has the job of "lowering" a `T: 'a`
1010/// obligation into a series of `'a: 'b` constraints and "verifys", as
1111/// described on the module comment. The final constraints are emitted
compiler/rustc_infer/src/infer/projection.rs+1-2
......@@ -1,9 +1,8 @@
11use rustc_middle::traits::ObligationCause;
22use rustc_middle::ty::{self, Ty};
33
4use crate::traits::{Obligation, PredicateObligation};
5
64use super::InferCtxt;
5use crate::traits::{Obligation, PredicateObligation};
76
87impl<'tcx> InferCtxt<'tcx> {
98 /// Instead of normalizing an associated type projection,
compiler/rustc_infer/src/infer/region_constraints/leak_check.rs+6-4
......@@ -1,12 +1,14 @@
1use super::*;
2use crate::infer::relate::RelateResult;
3use crate::infer::snapshot::CombinedSnapshot;
41use rustc_data_structures::fx::FxIndexMap;
5use rustc_data_structures::graph::{scc::Sccs, vec_graph::VecGraph};
2use rustc_data_structures::graph::scc::Sccs;
3use rustc_data_structures::graph::vec_graph::VecGraph;
64use rustc_index::Idx;
75use rustc_middle::span_bug;
86use rustc_middle::ty::error::TypeError;
97
8use super::*;
9use crate::infer::relate::RelateResult;
10use crate::infer::snapshot::CombinedSnapshot;
11
1012impl<'tcx> RegionConstraintCollector<'_, 'tcx> {
1113 /// Searches new universes created during `snapshot`, looking for
1214 /// 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 @@
11//! See `README.md`.
22
3use self::CombineMapType::*;
4use self::UndoLog::*;
5
6use super::{MiscVariable, RegionVariableOrigin, Rollback, SubregionOrigin};
7use crate::infer::snapshot::undo_log::{InferCtxtUndoLogs, Snapshot};
3use std::ops::Range;
4use std::{cmp, fmt, mem};
85
96use rustc_data_structures::fx::FxHashMap;
107use rustc_data_structures::sync::Lrc;
......@@ -13,15 +10,14 @@ use rustc_data_structures::unify as ut;
1310use rustc_index::IndexVec;
1411use rustc_macros::{TypeFoldable, TypeVisitable};
1512use rustc_middle::infer::unify_key::{RegionVariableValue, RegionVidKey};
16use rustc_middle::ty::ReStatic;
17use rustc_middle::ty::{self, Ty, TyCtxt};
18use rustc_middle::ty::{ReBound, ReVar};
19use rustc_middle::ty::{Region, RegionVid};
13use rustc_middle::ty::{self, ReBound, ReStatic, ReVar, Region, RegionVid, Ty, TyCtxt};
2014use rustc_middle::{bug, span_bug};
2115use rustc_span::Span;
2216
23use std::ops::Range;
24use std::{cmp, fmt, mem};
17use self::CombineMapType::*;
18use self::UndoLog::*;
19use super::{MiscVariable, RegionVariableOrigin, Rollback, SubregionOrigin};
20use crate::infer::snapshot::undo_log::{InferCtxtUndoLogs, Snapshot};
2521
2622mod leak_check;
2723
compiler/rustc_infer/src/infer/relate/combine.rs+7-10
......@@ -18,22 +18,19 @@
1818//! On success, the LUB/GLB operations return the appropriate bound. The
1919//! return value of `Equate` or `Sub` shouldn't really be used.
2020
21use rustc_middle::bug;
22use rustc_middle::infer::unify_key::EffectVarValue;
23use rustc_middle::traits::solve::Goal;
24use rustc_middle::ty::error::{ExpectedFound, TypeError};
25use rustc_middle::ty::{self, InferConst, IntType, Ty, TyCtxt, TypeVisitableExt, UintType, Upcast};
2126pub use rustc_next_trait_solver::relate::combine::*;
2227
2328use super::glb::Glb;
2429use super::lub::Lub;
2530use super::type_relating::TypeRelating;
26use super::RelateResult;
27use super::StructurallyRelateAliases;
28use crate::infer::relate;
29use crate::infer::{DefineOpaqueTypes, InferCtxt, TypeTrace};
31use super::{RelateResult, StructurallyRelateAliases};
32use crate::infer::{relate, DefineOpaqueTypes, InferCtxt, TypeTrace};
3033use crate::traits::{Obligation, PredicateObligation};
31use rustc_middle::bug;
32use rustc_middle::infer::unify_key::EffectVarValue;
33use rustc_middle::traits::solve::Goal;
34use rustc_middle::ty::error::{ExpectedFound, TypeError};
35use rustc_middle::ty::{self, InferConst, Ty, TyCtxt, TypeVisitableExt, Upcast};
36use rustc_middle::ty::{IntType, UintType};
3734
3835#[derive(Clone)]
3936pub struct CombineFields<'infcx, 'tcx> {
compiler/rustc_infer/src/infer/relate/generalize.rs+9-7
......@@ -1,10 +1,5 @@
11use std::mem;
22
3use super::StructurallyRelateAliases;
4use super::{PredicateEmittingRelation, Relate, RelateResult, TypeRelation};
5use crate::infer::relate;
6use crate::infer::type_variable::TypeVariableValue;
7use crate::infer::{InferCtxt, RegionVariableOrigin};
83use rustc_data_structures::sso::SsoHashMap;
94use rustc_data_structures::stack::ensure_sufficient_stack;
105use rustc_hir::def_id::DefId;
......@@ -12,10 +7,17 @@ use rustc_middle::bug;
127use rustc_middle::infer::unify_key::ConstVariableValue;
138use rustc_middle::ty::error::TypeError;
149use rustc_middle::ty::visit::MaxUniverse;
15use rustc_middle::ty::{self, Ty, TyCtxt};
16use rustc_middle::ty::{AliasRelationDirection, InferConst, Term, TypeVisitable, TypeVisitableExt};
10use rustc_middle::ty::{
11 self, AliasRelationDirection, InferConst, Term, Ty, TyCtxt, TypeVisitable, TypeVisitableExt,
12};
1713use rustc_span::Span;
1814
15use super::{
16 PredicateEmittingRelation, Relate, RelateResult, StructurallyRelateAliases, TypeRelation,
17};
18use crate::infer::type_variable::TypeVariableValue;
19use crate::infer::{relate, InferCtxt, RegionVariableOrigin};
20
1921impl<'tcx> InferCtxt<'tcx> {
2022 /// The idea is that we should ensure that the type variable `target_vid`
2123 /// 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 @@
11//! Helper routines for higher-ranked things. See the `doc` module at
22//! the end of the file for details.
33
4use rustc_middle::ty::fold::FnMutDelegate;
5use rustc_middle::ty::{self, Ty, TyCtxt, TypeFoldable};
6
47use super::RelateResult;
58use crate::infer::snapshot::CombinedSnapshot;
69use crate::infer::InferCtxt;
7use rustc_middle::ty::fold::FnMutDelegate;
8use rustc_middle::ty::{self, Ty, TyCtxt, TypeFoldable};
910
1011impl<'tcx> InferCtxt<'tcx> {
1112 /// Replaces all bound variables (lifetimes, types, and constants) bound by
compiler/rustc_infer/src/infer/relate/lattice.rs+3-4
......@@ -17,14 +17,13 @@
1717//!
1818//! [lattices]: https://en.wikipedia.org/wiki/Lattice_(order)
1919
20use rustc_middle::ty::relate::RelateResult;
21use rustc_middle::ty::{self, Ty, TyVar};
22
2023use super::combine::PredicateEmittingRelation;
2124use crate::infer::{DefineOpaqueTypes, InferCtxt};
2225use crate::traits::ObligationCause;
2326
24use rustc_middle::ty::relate::RelateResult;
25use rustc_middle::ty::TyVar;
26use rustc_middle::ty::{self, Ty};
27
2827/// Trait for returning data about a lattice, and for abstracting
2928/// over the "direction" of the lattice operation (LUB/GLB).
3029///
compiler/rustc_infer/src/infer/relate/lub.rs+5-5
......@@ -1,16 +1,16 @@
11//! Least upper bound. See [`lattice`].
22
3use rustc_middle::traits::solve::Goal;
4use rustc_middle::ty::relate::{Relate, RelateResult, TypeRelation};
5use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitableExt};
6use rustc_span::Span;
7
38use super::combine::{CombineFields, PredicateEmittingRelation};
49use super::lattice::{self, LatticeDir};
510use super::StructurallyRelateAliases;
611use crate::infer::{DefineOpaqueTypes, InferCtxt, SubregionOrigin};
712use crate::traits::ObligationCause;
813
9use rustc_middle::traits::solve::Goal;
10use rustc_middle::ty::relate::{Relate, RelateResult, TypeRelation};
11use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitableExt};
12use rustc_span::Span;
13
1414/// "Least upper bound" (common supertype)
1515pub struct Lub<'combine, 'infcx, 'tcx> {
1616 fields: &'combine mut CombineFields<'infcx, 'tcx>,
compiler/rustc_infer/src/infer/relate/mod.rs+1-2
......@@ -5,8 +5,7 @@
55pub use rustc_middle::ty::relate::RelateResult;
66pub use rustc_next_trait_solver::relate::*;
77
8pub use self::combine::CombineFields;
9pub use self::combine::PredicateEmittingRelation;
8pub use self::combine::{CombineFields, PredicateEmittingRelation};
109
1110#[allow(hidden_glob_reexports)]
1211pub(super) mod combine;
compiler/rustc_infer/src/infer/relate/type_relating.rs+6-6
......@@ -1,15 +1,15 @@
1use super::combine::CombineFields;
2use crate::infer::relate::{PredicateEmittingRelation, StructurallyRelateAliases};
3use crate::infer::BoundRegionConversionTime::HigherRankedType;
4use crate::infer::{DefineOpaqueTypes, InferCtxt, SubregionOrigin};
51use rustc_middle::traits::solve::Goal;
62use rustc_middle::ty::relate::{
73 relate_args_invariantly, relate_args_with_variances, Relate, RelateResult, TypeRelation,
84};
9use rustc_middle::ty::TyVar;
10use rustc_middle::ty::{self, Ty, TyCtxt};
5use rustc_middle::ty::{self, Ty, TyCtxt, TyVar};
116use rustc_span::Span;
127
8use super::combine::CombineFields;
9use crate::infer::relate::{PredicateEmittingRelation, StructurallyRelateAliases};
10use crate::infer::BoundRegionConversionTime::HigherRankedType;
11use crate::infer::{DefineOpaqueTypes, InferCtxt, SubregionOrigin};
12
1313/// Enforce that `a` is equal to or a subtype of `b`.
1414pub struct TypeRelating<'combine, 'a, 'tcx> {
1515 fields: &'combine mut CombineFields<'a, 'tcx>,
compiler/rustc_infer/src/infer/resolve.rs+2-1
......@@ -1,9 +1,10 @@
1use super::{FixupError, FixupResult, InferCtxt};
21use rustc_middle::bug;
32use rustc_middle::ty::fold::{FallibleTypeFolder, TypeFolder, TypeSuperFoldable};
43use rustc_middle::ty::visit::TypeVisitableExt;
54use rustc_middle::ty::{self, Const, InferConst, Ty, TyCtxt, TypeFoldable};
65
6use super::{FixupError, FixupResult, InferCtxt};
7
78///////////////////////////////////////////////////////////////////////////
89// OPPORTUNISTIC VAR RESOLVER
910
compiler/rustc_infer/src/infer/snapshot/fudge.rs+5-8
......@@ -1,16 +1,13 @@
1use std::ops::Range;
2
3use rustc_data_structures::{snapshot_vec as sv, unify as ut};
14use rustc_middle::infer::unify_key::{ConstVariableValue, ConstVidKey};
25use rustc_middle::ty::fold::{TypeFoldable, TypeFolder, TypeSuperFoldable};
36use rustc_middle::ty::{self, ConstVid, FloatVid, IntVid, RegionVid, Ty, TyCtxt, TyVid};
4
5use crate::infer::type_variable::TypeVariableOrigin;
6use crate::infer::InferCtxt;
7use crate::infer::{ConstVariableOrigin, RegionVariableOrigin, UnificationTable};
8
9use rustc_data_structures::snapshot_vec as sv;
10use rustc_data_structures::unify as ut;
117use ut::UnifyKey;
128
13use std::ops::Range;
9use crate::infer::type_variable::TypeVariableOrigin;
10use crate::infer::{ConstVariableOrigin, InferCtxt, RegionVariableOrigin, UnificationTable};
1411
1512fn vars_since_snapshot<'tcx, T>(
1613 table: &UnificationTable<'_, 'tcx, T>,
compiler/rustc_infer/src/infer/snapshot/mod.rs+3-2
......@@ -1,8 +1,9 @@
1use super::region_constraints::RegionSnapshot;
2use super::InferCtxt;
31use rustc_data_structures::undo_log::UndoLogs;
42use rustc_middle::ty;
53
4use super::region_constraints::RegionSnapshot;
5use super::InferCtxt;
6
67mod fudge;
78pub(crate) mod undo_log;
89
compiler/rustc_infer/src/infer/snapshot/undo_log.rs+3-6
......@@ -1,15 +1,12 @@
11use std::marker::PhantomData;
22
3use rustc_data_structures::snapshot_vec as sv;
43use rustc_data_structures::undo_log::{Rollback, UndoLogs};
5use rustc_data_structures::unify as ut;
4use rustc_data_structures::{snapshot_vec as sv, unify as ut};
65use rustc_middle::infer::unify_key::{ConstVidKey, EffectVidKey, RegionVidKey};
76use rustc_middle::ty::{self, OpaqueHiddenType, OpaqueTypeKey};
87
9use crate::{
10 infer::{region_constraints, type_variable, InferCtxtInner},
11 traits,
12};
8use crate::infer::{region_constraints, type_variable, InferCtxtInner};
9use crate::traits;
1310
1411pub struct Snapshot<'tcx> {
1512 pub(crate) undo_len: usize,
compiler/rustc_infer/src/infer/type_variable.rs+5-6
......@@ -1,4 +1,9 @@
1use std::cmp;
2use std::marker::PhantomData;
3use std::ops::Range;
4
15use rustc_data_structures::undo_log::Rollback;
6use rustc_data_structures::{snapshot_vec as sv, unify as ut};
27use rustc_hir::def_id::DefId;
38use rustc_index::IndexVec;
49use rustc_middle::bug;
......@@ -7,12 +12,6 @@ use rustc_span::Span;
712
813use crate::infer::InferCtxtUndoLogs;
914
10use rustc_data_structures::snapshot_vec as sv;
11use rustc_data_structures::unify as ut;
12use std::cmp;
13use std::marker::PhantomData;
14use std::ops::Range;
15
1615impl<'tcx> Rollback<sv::UndoLog<ut::Delegate<TyVidEqKey<'tcx>>>> for TypeVariableStorage<'tcx> {
1716 fn reverse(&mut self, undo: sv::UndoLog<ut::Delegate<TyVidEqKey<'tcx>>>) {
1817 self.eq_relations.reverse(undo)
compiler/rustc_infer/src/traits/engine.rs+2-2
......@@ -1,11 +1,11 @@
11use std::fmt::Debug;
22
3use crate::infer::InferCtxt;
4use crate::traits::Obligation;
53use rustc_hir::def_id::DefId;
64use rustc_middle::ty::{self, Ty, Upcast};
75
86use super::{ObligationCause, PredicateObligation};
7use crate::infer::InferCtxt;
8use crate::traits::Obligation;
99
1010/// A trait error with most of its information removed. This is the error
1111/// 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;
1414use rustc_hir as hir;
1515use rustc_middle::traits::query::NoSolution;
1616use rustc_middle::traits::solve::Certainty;
17pub use rustc_middle::traits::*;
1718use rustc_middle::ty::{self, Ty, TyCtxt, Upcast};
1819use rustc_span::Span;
1920
20pub use self::ImplSource::*;
21pub use self::SelectionError::*;
22use crate::infer::InferCtxt;
23
2421pub use self::engine::{FromSolverError, ScrubbedTraitError, TraitEngine};
25pub use self::project::MismatchedProjectionTypes;
2622pub(crate) use self::project::UndoLog;
2723pub use self::project::{
28 Normalized, NormalizedTerm, ProjectionCache, ProjectionCacheEntry, ProjectionCacheKey,
29 ProjectionCacheStorage, Reveal,
24 MismatchedProjectionTypes, Normalized, NormalizedTerm, ProjectionCache, ProjectionCacheEntry,
25 ProjectionCacheKey, ProjectionCacheStorage, Reveal,
3026};
31pub use rustc_middle::traits::*;
27pub use self::ImplSource::*;
28pub use self::SelectionError::*;
29use crate::infer::InferCtxt;
3230
3331/// An `Obligation` represents some trait reference (e.g., `i32: Eq`) for
3432/// 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 @@
11//! Code for projecting associated types out of trait references.
22
3use super::PredicateObligation;
4
5use crate::infer::snapshot::undo_log::InferCtxtUndoLogs;
6
7use rustc_data_structures::{
8 snapshot_map::{self, SnapshotMapRef, SnapshotMapStorage},
9 undo_log::Rollback,
10};
3use rustc_data_structures::snapshot_map::{self, SnapshotMapRef, SnapshotMapStorage};
4use rustc_data_structures::undo_log::Rollback;
5pub use rustc_middle::traits::{EvaluationResult, Reveal};
116use rustc_middle::ty;
127
13pub use rustc_middle::traits::{EvaluationResult, Reveal};
8use super::PredicateObligation;
9use crate::infer::snapshot::undo_log::InferCtxtUndoLogs;
1410
1511pub(crate) type UndoLog<'tcx> =
1612 snapshot_map::UndoLog<ProjectionCacheKey<'tcx>, ProjectionCacheEntry<'tcx>>;
compiler/rustc_infer/src/traits/structural_impls.rs+4-3
......@@ -1,11 +1,12 @@
1use crate::traits;
2use crate::traits::project::Normalized;
1use std::fmt;
2
33use rustc_ast_ir::try_visit;
44use rustc_middle::ty::fold::{FallibleTypeFolder, TypeFoldable};
55use rustc_middle::ty::visit::{TypeVisitable, TypeVisitor};
66use rustc_middle::ty::{self, TyCtxt};
77
8use std::fmt;
8use crate::traits;
9use crate::traits::project::Normalized;
910
1011// Structural impls for the structs in `traits`.
1112
compiler/rustc_infer/src/traits/util.rs+3-3
......@@ -1,11 +1,11 @@
1use crate::traits::{self, Obligation, ObligationCauseCode, PredicateObligation};
21use rustc_data_structures::fx::FxHashSet;
3use rustc_middle::ty::ToPolyTraitRef;
4use rustc_middle::ty::{self, TyCtxt};
2use rustc_middle::ty::{self, ToPolyTraitRef, TyCtxt};
53use rustc_span::symbol::Ident;
64use rustc_span::Span;
75pub use rustc_type_ir::elaborate::*;
86
7use crate::traits::{self, Obligation, ObligationCauseCode, PredicateObligation};
8
99pub fn anonymize_predicate<'tcx>(
1010 tcx: TyCtxt<'tcx>,
1111 pred: ty::Predicate<'tcx>,
compiler/rustc_interface/src/callbacks.rs+2-1
......@@ -9,12 +9,13 @@
99//! The functions in this file should fall back to the default set in their
1010//! origin crate when the `TyCtxt` is not present in TLS.
1111
12use std::fmt;
13
1214use rustc_errors::{DiagInner, TRACK_DIAGNOSTIC};
1315use rustc_middle::dep_graph::{DepNodeExt, TaskDepsRef};
1416use rustc_middle::ty::tls;
1517use rustc_query_system::dep_graph::dep_node::default_dep_kind_debug;
1618use rustc_query_system::dep_graph::{DepContext, DepKind, DepNode};
17use std::fmt;
1819
1920fn track_span_parent(def_id: rustc_span::def_id::LocalDefId) {
2021 tls::with_opt(|tcx| {
compiler/rustc_interface/src/errors.rs+3-3
......@@ -1,9 +1,9 @@
1use rustc_macros::Diagnostic;
2use rustc_span::{Span, Symbol};
3
41use std::io;
52use std::path::Path;
63
4use rustc_macros::Diagnostic;
5use rustc_span::{Span, Symbol};
6
77#[derive(Diagnostic)]
88#[diag(interface_ferris_identifier)]
99pub struct FerrisIdentifier {
compiler/rustc_interface/src/interface.rs+7-8
......@@ -1,13 +1,13 @@
1use crate::util;
1use std::path::PathBuf;
2use std::result;
3use std::sync::Arc;
24
3use rustc_ast::token;
4use rustc_ast::{LitKind, MetaItemKind};
5use rustc_ast::{token, LitKind, MetaItemKind};
56use rustc_codegen_ssa::traits::CodegenBackend;
6use rustc_data_structures::defer;
77use rustc_data_structures::fx::{FxHashMap, FxHashSet};
8use rustc_data_structures::jobserver;
98use rustc_data_structures::stable_hasher::StableHasher;
109use rustc_data_structures::sync::Lrc;
10use rustc_data_structures::{defer, jobserver};
1111use rustc_errors::registry::Registry;
1212use rustc_errors::{DiagCtxtHandle, ErrorGuaranteed};
1313use rustc_lint::LintStore;
......@@ -24,11 +24,10 @@ use rustc_session::{lint, CompilerIO, EarlyDiagCtxt, Session};
2424use rustc_span::source_map::{FileLoader, RealFileLoader, SourceMapInputs};
2525use rustc_span::symbol::sym;
2626use rustc_span::FileName;
27use std::path::PathBuf;
28use std::result;
29use std::sync::Arc;
3027use tracing::trace;
3128
29use crate::util;
30
3231pub type Result<T> = result::Result<T, ErrorGuaranteed>;
3332
3433/// Represents a compiler session. Note that every `Compiler` contains a
compiler/rustc_interface/src/passes.rs+10-13
......@@ -1,7 +1,9 @@
1use crate::errors;
2use crate::interface::{Compiler, Result};
3use crate::proc_macro_decls;
4use crate::util;
1use std::any::Any;
2use std::ffi::OsString;
3use std::io::{self, BufWriter, Write};
4use std::path::{Path, PathBuf};
5use std::sync::{Arc, LazyLock};
6use std::{env, fs, iter};
57
68use rustc_ast::{self as ast, visit};
79use rustc_codegen_ssa::traits::CodegenBackend;
......@@ -27,23 +29,18 @@ use rustc_resolve::Resolver;
2729use rustc_session::code_stats::VTableSizeInfo;
2830use rustc_session::config::{CrateType, Input, OutFileName, OutputFilenames, OutputType};
2931use rustc_session::cstore::Untracked;
30use rustc_session::output::filename_for_input;
31use rustc_session::output::{collect_crate_types, find_crate_name};
32use rustc_session::output::{collect_crate_types, filename_for_input, find_crate_name};
3233use rustc_session::search_paths::PathKind;
3334use rustc_session::{Limit, Session};
3435use rustc_span::symbol::{sym, Symbol};
3536use rustc_span::FileName;
3637use rustc_target::spec::PanicStrategy;
3738use rustc_trait_selection::traits;
38
39use std::any::Any;
40use std::ffi::OsString;
41use std::io::{self, BufWriter, Write};
42use std::path::{Path, PathBuf};
43use std::sync::{Arc, LazyLock};
44use std::{env, fs, iter};
4539use tracing::{info, instrument};
4640
41use crate::interface::{Compiler, Result};
42use crate::{errors, proc_macro_decls, util};
43
4744pub(crate) fn parse<'a>(sess: &'a Session) -> Result<ast::Crate> {
4845 let krate = sess
4946 .time("parse_crate", || {
compiler/rustc_interface/src/queries.rs+7-6
......@@ -1,6 +1,6 @@
1use crate::errors::FailedWritingFile;
2use crate::interface::{Compiler, Result};
3use crate::{errors, passes};
1use std::any::Any;
2use std::cell::{RefCell, RefMut};
3use std::sync::Arc;
44
55use rustc_ast as ast;
66use rustc_codegen_ssa::traits::CodegenBackend;
......@@ -15,9 +15,10 @@ use rustc_middle::ty::{GlobalCtxt, TyCtxt};
1515use rustc_serialize::opaque::FileEncodeResult;
1616use rustc_session::config::{self, OutputFilenames, OutputType};
1717use rustc_session::Session;
18use std::any::Any;
19use std::cell::{RefCell, RefMut};
20use std::sync::Arc;
18
19use crate::errors::FailedWritingFile;
20use crate::interface::{Compiler, Result};
21use crate::{errors, passes};
2122
2223/// Represent the result of a query.
2324///
compiler/rustc_interface/src/tests.rs+16-21
......@@ -1,23 +1,20 @@
11#![allow(rustc::bad_opt_access)]
2use crate::interface::{initialize_checked_jobserver, parse_cfg};
2use std::collections::{BTreeMap, BTreeSet};
3use std::num::NonZero;
4use std::path::{Path, PathBuf};
5use std::sync::Arc;
6
37use rustc_data_structures::profiling::TimePassesFormat;
4use rustc_errors::{emitter::HumanReadableErrorType, registry, ColorConfig};
5use rustc_session::config::{build_configuration, build_session_options, rustc_optgroups};
6use rustc_session::config::{
7 BranchProtection, CFGuard, Cfg, CollapseMacroDebuginfo, CoverageLevel, CoverageOptions,
8 DebugInfo, DumpMonoStatsFormat, ErrorOutputType,
9};
10use rustc_session::config::{
11 ExternEntry, ExternLocation, Externs, FunctionReturn, InliningThreshold, Input,
12 InstrumentCoverage, InstrumentXRay, LinkSelfContained, LinkerPluginLto,
13};
14use rustc_session::config::{
15 LocationDetail, LtoCli, NextSolverConfig, OomStrategy, Options, OutFileName, OutputType,
16 OutputTypes, PAuthKey, PacRet, Passes, PatchableFunctionEntry,
17};
8use rustc_errors::emitter::HumanReadableErrorType;
9use rustc_errors::{registry, ColorConfig};
1810use 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,
2118};
2219use rustc_session::lint::Level;
2320use rustc_session::search_paths::SearchPath;
......@@ -31,10 +28,8 @@ use rustc_target::spec::{
3128 CodeModel, FramePointer, LinkerFlavorCli, MergeFunctions, OnBrokenPipe, PanicStrategy,
3229 RelocModel, RelroLevel, SanitizerSet, SplitDebuginfo, StackProtector, TlsModel, WasmCAbi,
3330};
34use std::collections::{BTreeMap, BTreeSet};
35use std::num::NonZero;
36use std::path::{Path, PathBuf};
37use std::sync::Arc;
31
32use crate::interface::{initialize_checked_jobserver, parse_cfg};
3833
3934fn sess_and_cfg<F>(args: &[&'static str], f: F)
4035where
compiler/rustc_interface/src/util.rs+12-9
......@@ -1,4 +1,9 @@
1use crate::errors;
1use std::env::consts::{DLL_PREFIX, DLL_SUFFIX};
2use std::path::{Path, PathBuf};
3use std::sync::atomic::{AtomicBool, Ordering};
4use std::sync::OnceLock;
5use std::{env, iter, thread};
6
27use rustc_ast as ast;
38use rustc_codegen_ssa::traits::CodegenBackend;
49#[cfg(parallel_compiler)]
......@@ -16,14 +21,10 @@ use rustc_span::edition::Edition;
1621use rustc_span::source_map::SourceMapInputs;
1722use rustc_span::symbol::sym;
1823use rustc_target::spec::Target;
19use std::env::consts::{DLL_PREFIX, DLL_SUFFIX};
20use std::path::{Path, PathBuf};
21use std::sync::atomic::{AtomicBool, Ordering};
22use std::sync::OnceLock;
23use std::thread;
24use std::{env, iter};
2524use tracing::info;
2625
26use crate::errors;
27
2728/// Function pointer type that constructs a new CodegenBackend.
2829pub type MakeBackendFn = fn() -> Box<dyn CodegenBackend>;
2930
......@@ -136,11 +137,13 @@ pub(crate) fn run_in_thread_pool_with_globals<F: FnOnce(CurrentGcx) -> R + Send,
136137 sm_inputs: SourceMapInputs,
137138 f: F,
138139) -> 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};
140144 use rustc_middle::ty::tls;
141145 use rustc_query_impl::QueryCtxt;
142146 use rustc_query_system::query::{break_query_cycles, QueryContext};
143 use std::process;
144147
145148 let thread_stack_size = init_stack_size(thread_builder_diag);
146149
compiler/rustc_lexer/src/lib.rs+2-2
......@@ -31,12 +31,12 @@ pub mod unescape;
3131#[cfg(test)]
3232mod tests;
3333
34pub use crate::cursor::Cursor;
34use unicode_properties::UnicodeEmoji;
3535
3636use self::LiteralKind::*;
3737use self::TokenKind::*;
38pub use crate::cursor::Cursor;
3839use crate::cursor::EOF_CHAR;
39use unicode_properties::UnicodeEmoji;
4040
4141/// Parsed token.
4242/// It doesn't contain information about data that has been parsed,
compiler/rustc_lexer/src/tests.rs+2-2
......@@ -1,7 +1,7 @@
1use super::*;
2
31use expect_test::{expect, Expect};
42
3use super::*;
4
55fn check_raw_str(s: &str, expected: Result<u8, RawStrError>) {
66 let s = &format!("r{}", s);
77 let mut cursor = Cursor::new(s);
compiler/rustc_lint/src/async_fn_in_trait.rs+3-3
......@@ -1,10 +1,10 @@
1use crate::lints::AsyncFnInTraitDiag;
2use crate::LateContext;
3use crate::LateLintPass;
41use rustc_hir as hir;
52use rustc_session::{declare_lint, declare_lint_pass};
63use rustc_trait_selection::error_reporting::traits::suggestions::suggest_desugaring_async_fn_to_impl_future_in_trait;
74
5use crate::lints::AsyncFnInTraitDiag;
6use crate::{LateContext, LateLintPass};
7
88declare_lint! {
99 /// The `async_fn_in_trait` lint detects use of `async fn` in the
1010 /// definition of a publicly-reachable trait.
compiler/rustc_lint/src/builtin.rs+28-30
......@@ -20,25 +20,8 @@
2020//! If you define a new `LateLintPass`, you will also need to add it to the
2121//! `late_lint_methods!` invocation in `lib.rs`.
2222
23use crate::fluent_generated as fluent;
24use 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};
23use std::fmt::Write;
24
4225use ast::token::TokenKind;
4326use rustc_ast::tokenstream::{TokenStream, TokenTree};
4427use rustc_ast::visit::{FnCtxt, FnKind};
......@@ -55,9 +38,9 @@ use rustc_middle::bug;
5538use rustc_middle::lint::in_external_macro;
5639use rustc_middle::ty::layout::LayoutOf;
5740use rustc_middle::ty::print::with_no_trimmed_paths;
58use rustc_middle::ty::TypeVisitableExt;
59use rustc_middle::ty::Upcast;
60use rustc_middle::ty::{self, Ty, TyCtxt, VariantDef};
41use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitableExt, Upcast, VariantDef};
42// hardwired lints from rustc_lint_defs
43pub use rustc_session::lint::builtin::*;
6144use rustc_session::lint::FutureIncompatibilityReason;
6245use rustc_session::{declare_lint, declare_lint_pass, impl_lint_pass};
6346use rustc_span::edition::Edition;
......@@ -67,15 +50,29 @@ use rustc_span::{BytePos, InnerSpan, Span};
6750use rustc_target::abi::Abi;
6851use rustc_target::asm::InlineAsmArch;
6952use rustc_trait_selection::infer::{InferCtxtExt, TyCtxtInferExt};
53use rustc_trait_selection::traits::misc::type_allowed_to_implement_copy;
7054use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt as _;
71use rustc_trait_selection::traits::{self, misc::type_allowed_to_implement_copy};
72
55use rustc_trait_selection::traits::{self};
56
57use crate::errors::BuiltinEllipsisInclusiveRangePatterns;
58use 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};
7371use crate::nonstandard_style::{method_context, MethodLateContext};
74
75use std::fmt::Write;
76
77// hardwired lints from rustc_lint_defs
78pub use rustc_session::lint::builtin::*;
72use crate::{
73 fluent_generated as fluent, EarlyContext, EarlyLintPass, LateContext, LateLintPass, Level,
74 LintContext,
75};
7976
8077declare_lint! {
8178 /// The `while_true` lint detects `while true { }`.
......@@ -1672,7 +1669,8 @@ impl EarlyLintPass for EllipsisInclusiveRangePatterns {
16721669 return;
16731670 }
16741671
1675 use self::ast::{PatKind, RangeSyntax::DotDotDot};
1672 use self::ast::PatKind;
1673 use self::ast::RangeSyntax::DotDotDot;
16761674
16771675 /// If `pat` is a `...` pattern, return the start and end of the range, as well as the span
16781676 /// corresponding to the ellipsis.
compiler/rustc_lint/src/context.rs+11-10
......@@ -14,10 +14,9 @@
1414//! upon. As the ast is traversed, this keeps track of the current lint level
1515//! for all lint attributes.
1616
17use self::TargetLint::*;
17use std::cell::Cell;
18use std::{iter, slice};
1819
19use crate::levels::LintLevelsBuilder;
20use crate::passes::{EarlyLintPassObject, LateLintPassObject};
2120use rustc_data_structures::fx::FxIndexMap;
2221use rustc_data_structures::sync;
2322use rustc_data_structures::unord::UnordMap;
......@@ -30,20 +29,22 @@ use rustc_hir::definitions::{DefPathData, DisambiguatedDefPathData};
3029use rustc_middle::bug;
3130use rustc_middle::middle::privacy::EffectiveVisibilities;
3231use rustc_middle::ty::layout::{LayoutError, LayoutOfHelpers, TyAndLayout};
33use rustc_middle::ty::print::{with_no_trimmed_paths, PrintError, PrintTraitRefExt as _};
34use rustc_middle::ty::{self, print::Printer, GenericArg, RegisteredTools, Ty, TyCtxt};
35use rustc_session::lint::{BuiltinLintDiag, LintExpectationId};
36use rustc_session::lint::{FutureIncompatibleInfo, Level, Lint, LintBuffer, LintId};
32use rustc_middle::ty::print::{with_no_trimmed_paths, PrintError, PrintTraitRefExt as _, Printer};
33use rustc_middle::ty::{self, GenericArg, RegisteredTools, Ty, TyCtxt};
34use rustc_session::lint::{
35 BuiltinLintDiag, FutureIncompatibleInfo, Level, Lint, LintBuffer, LintExpectationId, LintId,
36};
3737use rustc_session::{LintStoreMarker, Session};
3838use rustc_span::edit_distance::find_best_match_for_names;
3939use rustc_span::symbol::{sym, Ident, Symbol};
4040use rustc_span::Span;
4141use rustc_target::abi;
42use std::cell::Cell;
43use std::iter;
44use std::slice;
4542use tracing::debug;
4643
44use self::TargetLint::*;
45use crate::levels::LintLevelsBuilder;
46use crate::passes::{EarlyLintPassObject, LateLintPassObject};
47
4748mod diagnostics;
4849
4950type EarlyLintPassFactory = dyn Fn() -> EarlyLintPassObject + sync::DynSend + sync::DynSync;
compiler/rustc_lint/src/context/diagnostics.rs+3-2
......@@ -4,8 +4,9 @@
44use std::borrow::Cow;
55
66use rustc_ast::util::unicode::TEXT_FLOW_CONTROL_CHARS;
7use rustc_errors::elided_lifetime_in_path_suggestion;
8use rustc_errors::{Applicability, Diag, DiagArgValue, LintDiagnostic};
7use rustc_errors::{
8 elided_lifetime_in_path_suggestion, Applicability, Diag, DiagArgValue, LintDiagnostic,
9};
910use rustc_middle::middle::stability;
1011use rustc_session::lint::BuiltinLintDiag;
1112use rustc_session::Session;
compiler/rustc_lint/src/context/diagnostics/check_cfg.rs+2-1
......@@ -1,5 +1,6 @@
11use rustc_middle::bug;
2use rustc_session::{config::ExpectedValues, Session};
2use rustc_session::config::ExpectedValues;
3use rustc_session::Session;
34use rustc_span::edit_distance::find_best_match_for_name;
45use rustc_span::{sym, Span, Symbol};
56
compiler/rustc_lint/src/deref_into_dyn_supertrait.rs+3-5
......@@ -1,8 +1,3 @@
1use crate::{
2 lints::{SupertraitAsDerefTarget, SupertraitAsDerefTargetLabel},
3 LateContext, LateLintPass, LintContext,
4};
5
61use rustc_hir::{self as hir, LangItem};
72use rustc_middle::ty;
83use rustc_session::lint::FutureIncompatibilityReason;
......@@ -10,6 +5,9 @@ use rustc_session::{declare_lint, declare_lint_pass};
105use rustc_span::sym;
116use rustc_trait_selection::traits::supertraits;
127
8use crate::lints::{SupertraitAsDerefTarget, SupertraitAsDerefTargetLabel};
9use crate::{LateContext, LateLintPass, LintContext};
10
1311declare_lint! {
1412 /// The `deref_into_dyn_supertrait` lint is output whenever there is a use of the
1513 /// `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;
33use rustc_session::{declare_lint, declare_lint_pass};
44use rustc_span::sym;
55
6use crate::{
7 lints::{
8 DropCopyDiag, DropRefDiag, ForgetCopyDiag, ForgetRefDiag, UndroppedManuallyDropsDiag,
9 UndroppedManuallyDropsSuggestion, UseLetUnderscoreIgnoreSuggestion,
10 },
11 LateContext, LateLintPass, LintContext,
6use crate::lints::{
7 DropCopyDiag, DropRefDiag, ForgetCopyDiag, ForgetRefDiag, UndroppedManuallyDropsDiag,
8 UndroppedManuallyDropsSuggestion, UseLetUnderscoreIgnoreSuggestion,
129};
10use crate::{LateContext, LateLintPass, LintContext};
1311
1412declare_lint! {
1513 /// 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 @@
1414//! upon. As the ast is traversed, this keeps track of the current lint level
1515//! for all lint attributes.
1616
17use crate::context::{EarlyContext, LintStore};
18use crate::passes::{EarlyLintPass, EarlyLintPassObject};
1917use rustc_ast::ptr::P;
2018use rustc_ast::visit::{self as ast_visit, walk_list, Visitor};
2119use rustc_ast::{self as ast, HasAttrs};
......@@ -28,6 +26,9 @@ use rustc_span::symbol::Ident;
2826use rustc_span::Span;
2927use tracing::debug;
3028
29use crate::context::{EarlyContext, LintStore};
30use crate::passes::{EarlyLintPass, EarlyLintPassObject};
31
3132macro_rules! lint_callback { ($cx:expr, $f:ident, $($args:expr),*) => ({
3233 $cx.pass.$f(&$cx.context, $($args),*);
3334}) }
compiler/rustc_lint/src/enum_intrinsics_non_enums.rs+8-7
......@@ -1,12 +1,13 @@
1use crate::{
2 context::LintContext,
3 lints::{EnumIntrinsicsMemDiscriminate, EnumIntrinsicsMemVariant},
4 LateContext, LateLintPass,
5};
61use rustc_hir as hir;
7use rustc_middle::ty::{visit::TypeVisitableExt, Ty};
2use rustc_middle::ty::visit::TypeVisitableExt;
3use rustc_middle::ty::Ty;
84use rustc_session::{declare_lint, declare_lint_pass};
9use rustc_span::{symbol::sym, Span};
5use rustc_span::symbol::sym;
6use rustc_span::Span;
7
8use crate::context::LintContext;
9use crate::lints::{EnumIntrinsicsMemDiscriminate, EnumIntrinsicsMemVariant};
10use crate::{LateContext, LateLintPass};
1011
1112declare_lint! {
1213 /// The `enum_intrinsics_non_enums` lint detects calls to
compiler/rustc_lint/src/errors.rs+4-2
......@@ -1,9 +1,11 @@
1use crate::fluent_generated as fluent;
2use rustc_errors::{codes::*, Diag, EmissionGuarantee, SubdiagMessageOp, Subdiagnostic};
1use rustc_errors::codes::*;
2use rustc_errors::{Diag, EmissionGuarantee, SubdiagMessageOp, Subdiagnostic};
33use rustc_macros::{Diagnostic, Subdiagnostic};
44use rustc_session::lint::Level;
55use rustc_span::{Span, Symbol};
66
7use crate::fluent_generated as fluent;
8
79#[derive(Diagnostic)]
810#[diag(lint_overruled_attribute, code = E0453)]
911pub struct OverruledAttribute<'a> {
compiler/rustc_lint/src/expect.rs+2-1
......@@ -1,10 +1,11 @@
1use crate::lints::{Expectation, ExpectationNote};
21use rustc_middle::query::Providers;
32use rustc_middle::ty::TyCtxt;
43use rustc_session::lint::builtin::UNFULFILLED_LINT_EXPECTATIONS;
54use rustc_session::lint::LintExpectationId;
65use rustc_span::Symbol;
76
7use crate::lints::{Expectation, ExpectationNote};
8
89pub(crate) fn provide(providers: &mut Providers) {
910 *providers = Providers { check_expectations, ..*providers };
1011}
compiler/rustc_lint/src/for_loops_over_fallibles.rs+8-9
......@@ -1,19 +1,18 @@
1use crate::{
2 lints::{
3 ForLoopsOverFalliblesDiag, ForLoopsOverFalliblesLoopSub, ForLoopsOverFalliblesQuestionMark,
4 ForLoopsOverFalliblesSuggestion,
5 },
6 LateContext, LateLintPass, LintContext,
7};
8
91use hir::{Expr, Pat};
102use rustc_hir as hir;
11use rustc_infer::{infer::TyCtxtInferExt, traits::ObligationCause};
3use rustc_infer::infer::TyCtxtInferExt;
4use rustc_infer::traits::ObligationCause;
125use rustc_middle::ty;
136use rustc_session::{declare_lint, declare_lint_pass};
147use rustc_span::{sym, Span};
158use rustc_trait_selection::traits::ObligationCtxt;
169
10use crate::lints::{
11 ForLoopsOverFalliblesDiag, ForLoopsOverFalliblesLoopSub, ForLoopsOverFalliblesQuestionMark,
12 ForLoopsOverFalliblesSuggestion,
13};
14use crate::{LateContext, LateLintPass, LintContext};
15
1716declare_lint! {
1817 /// The `for_loops_over_fallibles` lint checks for `for` loops over `Option` or `Result` values.
1918 ///
compiler/rustc_lint/src/hidden_unicode_codepoints.rs+5-7
......@@ -1,15 +1,13 @@
1use crate::{
2 lints::{
3 HiddenUnicodeCodepointsDiag, HiddenUnicodeCodepointsDiagLabels,
4 HiddenUnicodeCodepointsDiagSub,
5 },
6 EarlyContext, EarlyLintPass, LintContext,
7};
81use ast::util::unicode::{contains_text_flow_control_chars, TEXT_FLOW_CONTROL_CHARS};
92use rustc_ast as ast;
103use rustc_session::{declare_lint, declare_lint_pass};
114use rustc_span::{BytePos, Span, Symbol};
125
6use crate::lints::{
7 HiddenUnicodeCodepointsDiag, HiddenUnicodeCodepointsDiagLabels, HiddenUnicodeCodepointsDiagSub,
8};
9use crate::{EarlyContext, EarlyLintPass, LintContext};
10
1311declare_lint! {
1412 /// The `text_direction_codepoint_in_literal` lint detects Unicode codepoints that change the
1513 /// 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::{
1313use rustc_session::{declare_lint, declare_lint_pass};
1414use rustc_span::Span;
1515
16use crate::fluent_generated as fluent;
17use crate::{LateContext, LateLintPass};
16use crate::{fluent_generated as fluent, LateContext, LateLintPass};
1817
1918declare_lint! {
2019 /// The `impl_trait_overcaptures` lint warns against cases where lifetime
compiler/rustc_lint/src/internal.rs+12-8
......@@ -1,16 +1,13 @@
11//! Some lints that are only useful in the compiler or crates that use compiler internals, such as
22//! Clippy.
33
4use crate::lints::{
5 BadOptAccessDiag, DefaultHashTypesDiag, DiagOutOfImpl, LintPassByHand, NonExistentDocKeyword,
6 NonGlobImportTypeIrInherent, QueryInstability, SpanUseEqCtxtDiag, TyQualified, TykindDiag,
7 TykindKind, UntranslatableDiag,
8};
9use crate::{EarlyContext, EarlyLintPass, LateContext, LateLintPass, LintContext};
104use rustc_ast as ast;
115use rustc_hir::def::Res;
12use rustc_hir::{def_id::DefId, Expr, ExprKind, GenericArg, PatKind, Path, PathSegment, QPath};
13use rustc_hir::{BinOp, BinOpKind, HirId, Impl, Item, ItemKind, Node, Pat, Ty, TyKind};
6use rustc_hir::def_id::DefId;
7use rustc_hir::{
8 BinOp, BinOpKind, Expr, ExprKind, GenericArg, HirId, Impl, Item, ItemKind, Node, Pat, PatKind,
9 Path, PathSegment, QPath, Ty, TyKind,
10};
1411use rustc_middle::ty::{self, Ty as MiddleTy};
1512use rustc_session::{declare_lint_pass, declare_tool_lint};
1613use rustc_span::hygiene::{ExpnKind, MacroKind};
......@@ -18,6 +15,13 @@ use rustc_span::symbol::{kw, sym, Symbol};
1815use rustc_span::Span;
1916use tracing::debug;
2017
18use crate::lints::{
19 BadOptAccessDiag, DefaultHashTypesDiag, DiagOutOfImpl, LintPassByHand, NonExistentDocKeyword,
20 NonGlobImportTypeIrInherent, QueryInstability, SpanUseEqCtxtDiag, TyQualified, TykindDiag,
21 TykindKind, UntranslatableDiag,
22};
23use crate::{EarlyContext, EarlyLintPass, LateContext, LateLintPass, LintContext};
24
2125declare_tool_lint! {
2226 /// The `default_hash_type` lint detects use of [`std::collections::HashMap`] and
2327 /// [`std::collections::HashSet`], suggesting the use of `FxHashMap`/`FxHashSet`.
compiler/rustc_lint/src/late.rs+7-5
......@@ -14,22 +14,24 @@
1414//! upon. As the ast is traversed, this keeps track of the current lint level
1515//! for all lint attributes.
1616
17use crate::{passes::LateLintPassObject, LateContext, LateLintPass, LintStore};
17use std::any::Any;
18use std::cell::Cell;
19
1820use rustc_data_structures::stack::ensure_sufficient_stack;
1921use rustc_data_structures::sync::{join, Lrc};
2022use rustc_hir as hir;
2123use rustc_hir::def_id::{LocalDefId, LocalModDefId};
22use rustc_hir::intravisit as hir_visit;
23use rustc_hir::HirId;
24use rustc_hir::{intravisit as hir_visit, HirId};
2425use rustc_middle::hir::nested_filter;
2526use rustc_middle::ty::{self, TyCtxt};
2627use rustc_session::lint::LintPass;
2728use rustc_session::Session;
2829use rustc_span::Span;
29use std::any::Any;
30use std::cell::Cell;
3130use tracing::debug;
3231
32use crate::passes::LateLintPassObject;
33use crate::{LateContext, LateLintPass, LintStore};
34
3335/// Extract the [`LintStore`] from [`Session`].
3436///
3537/// This function exists because [`Session::lint_store`] is type-erased.
compiler/rustc_lint/src/let_underscore.rs+3-4
......@@ -1,13 +1,12 @@
1use crate::{
2 lints::{NonBindingLet, NonBindingLetSub},
3 LateContext, LateLintPass, LintContext,
4};
51use rustc_errors::MultiSpan;
62use rustc_hir as hir;
73use rustc_middle::ty;
84use rustc_session::{declare_lint, declare_lint_pass};
95use rustc_span::{sym, Symbol};
106
7use crate::lints::{NonBindingLet, NonBindingLetSub};
8use crate::{LateContext, LateLintPass, LintContext};
9
1110declare_lint! {
1211 /// The `let_underscore_drop` lint checks for statements which don't bind
1312 /// an expression which has a non-trivial Drop implementation to anything,
compiler/rustc_lint/src/levels.rs+17-25
......@@ -1,24 +1,7 @@
1use crate::errors::{CheckNameUnknownTool, RequestedLevel, UnsupportedGroup};
2use crate::lints::{
3 DeprecatedLintNameFromCommandLine, RemovedLintFromCommandLine, RenamedLintFromCommandLine,
4 UnknownLintFromCommandLine,
5};
6use 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};
16use rustc_ast as ast;
171use rustc_ast_pretty::pprust;
182use rustc_data_structures::fx::FxIndexMap;
193use rustc_errors::{Diag, LintDiagnostic, MultiSpan};
204use rustc_feature::{Features, GateIssue};
21use rustc_hir as hir;
225use rustc_hir::intravisit::{self, Visitor};
236use rustc_hir::HirId;
247use rustc_index::IndexVec;
......@@ -30,21 +13,30 @@ use rustc_middle::lint::{
3013};
3114use rustc_middle::query::Providers;
3215use rustc_middle::ty::{RegisteredTools, TyCtxt};
33use 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,
16use rustc_session::lint::builtin::{
17 self, FORBIDDEN_LINT_GROUPS, RENAMED_AND_REMOVED_LINTS, SINGLE_USE_LIFETIMES,
18 UNFULFILLED_LINT_EXPECTATIONS, UNKNOWN_LINTS, UNUSED_ATTRIBUTES,
3919};
20use rustc_session::lint::{Level, Lint, LintExpectationId, LintId};
4021use rustc_session::Session;
4122use rustc_span::symbol::{sym, Symbol};
4223use rustc_span::{Span, DUMMY_SP};
4324use tracing::{debug, instrument};
25use {rustc_ast as ast, rustc_hir as hir};
4426
27use crate::builtin::MISSING_DOCS;
28use crate::context::{CheckLintNameResult, LintStore};
4529use crate::errors::{
46 MalformedAttribute, MalformedAttributeSub, OverruledAttribute, OverruledAttributeSub,
47 UnknownToolInScopedLint,
30 CheckNameUnknownTool, MalformedAttribute, MalformedAttributeSub, OverruledAttribute,
31 OverruledAttributeSub, RequestedLevel, UnknownToolInScopedLint, UnsupportedGroup,
32};
33use crate::fluent_generated as fluent;
34use crate::late::unerased_lint_store;
35use crate::lints::{
36 DeprecatedLintName, DeprecatedLintNameFromCommandLine, IgnoredUnlessCrateSpecified,
37 OverruledAttributeLint, RemovedLint, RemovedLintFromCommandLine, RenamedLint,
38 RenamedLintFromCommandLine, RenamedLintSuggestion, UnknownLint, UnknownLintFromCommandLine,
39 UnknownLintSuggestion,
4840};
4941
5042/// Collection of lint levels for the whole crate.
compiler/rustc_lint/src/lib.rs+10-10
......@@ -83,12 +83,6 @@ mod types;
8383mod unit_bindings;
8484mod unused;
8585
86pub use shadowed_into_iter::{ARRAY_INTO_ITER, BOXED_SLICE_INTO_ITER};
87
88use rustc_hir::def_id::LocalModDefId;
89use rustc_middle::query::Providers;
90use rustc_middle::ty::TyCtxt;
91
9286use async_closures::AsyncClosureUsage;
9387use async_fn_in_trait::AsyncFnInTrait;
9488use builtin::*;
......@@ -116,7 +110,11 @@ use precedence::*;
116110use ptr_nulls::*;
117111use redundant_semicolon::*;
118112use reference_casting::*;
113use rustc_hir::def_id::LocalModDefId;
114use rustc_middle::query::Providers;
115use rustc_middle::ty::TyCtxt;
119116use shadowed_into_iter::ShadowedIntoIter;
117pub use shadowed_into_iter::{ARRAY_INTO_ITER, BOXED_SLICE_INTO_ITER};
120118use traits::*;
121119use types::*;
122120use unit_bindings::*;
......@@ -124,14 +122,16 @@ use unused::*;
124122
125123#[rustfmt::skip]
126124pub use builtin::{MissingDoc, SoftLints};
127pub use context::{CheckLintNameResult, FindLintError, LintStore};
128pub use context::{EarlyContext, LateContext, LintContext};
125pub use context::{
126 CheckLintNameResult, EarlyContext, FindLintError, LateContext, LintContext, LintStore,
127};
129128pub use early::{check_ast_node, EarlyCheckNode};
130129pub use late::{check_crate, late_lint_mod, unerased_lint_store};
131130pub use passes::{EarlyLintPass, LateLintPass};
132131pub use rustc_session::lint::Level::{self, *};
133pub use rustc_session::lint::{BufferedEarlyLint, FutureIncompatibleInfo, Lint, LintId};
134pub use rustc_session::lint::{LintPass, LintVec};
132pub use rustc_session::lint::{
133 BufferedEarlyLint, FutureIncompatibleInfo, Lint, LintId, LintPass, LintVec,
134};
135135
136136rustc_fluent_macro::fluent_messages! { "../messages.ftl" }
137137
compiler/rustc_lint/src/lints.rs+17-18
......@@ -2,27 +2,26 @@
22#![allow(rustc::untranslatable_diagnostic)]
33use std::num::NonZero;
44
5use crate::builtin::{InitError, ShorthandAssocTyCollector, TypeAliasBounds};
6use crate::errors::{OverruledAttributeSub, RequestedLevel};
7use crate::fluent_generated as fluent;
8use crate::LateContext;
5use rustc_errors::codes::*;
96use 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,
139};
14use rustc_hir::{self as hir, def::Namespace, def_id::DefId};
10use rustc_hir::def::Namespace;
11use rustc_hir::def_id::DefId;
12use rustc_hir::{self as hir};
1513use rustc_macros::{LintDiagnostic, Subdiagnostic};
16use rustc_middle::ty::{
17 inhabitedness::InhabitedPredicate, Clause, PolyExistentialTraitRef, Ty, TyCtxt,
18};
19use rustc_session::{lint::AmbiguityErrorDiag, Session};
20use rustc_span::{
21 edition::Edition,
22 sym,
23 symbol::{Ident, MacroRulesNormalizedIdent},
24 Span, Symbol,
25};
14use rustc_middle::ty::inhabitedness::InhabitedPredicate;
15use rustc_middle::ty::{Clause, PolyExistentialTraitRef, Ty, TyCtxt};
16use rustc_session::lint::AmbiguityErrorDiag;
17use rustc_session::Session;
18use rustc_span::edition::Edition;
19use rustc_span::symbol::{Ident, MacroRulesNormalizedIdent};
20use rustc_span::{sym, Span, Symbol};
21
22use crate::builtin::{InitError, ShorthandAssocTyCollector, TypeAliasBounds};
23use crate::errors::{OverruledAttributeSub, RequestedLevel};
24use crate::{fluent_generated as fluent, LateContext};
2625
2726// array_into_iter.rs
2827#[derive(LintDiagnostic)]
compiler/rustc_lint/src/macro_expr_fragment_specifier_2024_migration.rs+4-8
......@@ -1,16 +1,12 @@
11//! Migration code for the `expr_fragment_specifier_2024`
22//! rule.
3use tracing::debug;
4
5use rustc_ast::token::Token;
6use rustc_ast::token::TokenKind;
7use rustc_ast::tokenstream::TokenStream;
8use rustc_ast::tokenstream::TokenTree;
9use rustc_session::declare_lint;
10use rustc_session::declare_lint_pass;
3use rustc_ast::token::{Token, TokenKind};
4use rustc_ast::tokenstream::{TokenStream, TokenTree};
115use rustc_session::lint::FutureIncompatibilityReason;
6use rustc_session::{declare_lint, declare_lint_pass};
127use rustc_span::edition::Edition;
138use rustc_span::sym;
9use tracing::debug;
1410
1511use crate::lints::MacroExprFragment2024;
1612use crate::EarlyLintPass;
compiler/rustc_lint/src/map_unit_fn.rs+5-7
......@@ -1,13 +1,11 @@
1use crate::lints::MappingToUnit;
2use crate::{LateContext, LateLintPass, LintContext};
3
41use rustc_hir::{Expr, ExprKind, HirId, Stmt, StmtKind};
5use rustc_middle::{
6 query::Key,
7 ty::{self, Ty},
8};
2use rustc_middle::query::Key;
3use rustc_middle::ty::{self, Ty};
94use rustc_session::{declare_lint, declare_lint_pass};
105
6use crate::lints::MappingToUnit;
7use crate::{LateContext, LateLintPass, LintContext};
8
119declare_lint! {
1210 /// The `map_unit_fn` lint checks for `Iterator::map` receive
1311 /// a callable that returns `()`.
compiler/rustc_lint/src/methods.rs+5-5
......@@ -1,11 +1,11 @@
1use crate::lints::CStringPtr;
2use crate::LateContext;
3use crate::LateLintPass;
4use crate::LintContext;
51use rustc_hir::{Expr, ExprKind};
62use rustc_middle::ty;
73use rustc_session::{declare_lint, declare_lint_pass};
8use rustc_span::{symbol::sym, Span};
4use rustc_span::symbol::sym;
5use rustc_span::Span;
6
7use crate::lints::CStringPtr;
8use crate::{LateContext, LateLintPass, LintContext};
99
1010declare_lint! {
1111 /// 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 @@
1use crate::{LateContext, LateLintPass, LintContext};
2
31use rustc_hir as hir;
42use rustc_session::{declare_lint, declare_lint_pass};
53
4use crate::{LateContext, LateLintPass, LintContext};
5
66declare_lint! {
77 /// The `multiple_supertrait_upcastable` lint detects when an object-safe trait has multiple
88 /// supertraits.
compiler/rustc_lint/src/non_ascii_idents.rs+8-6
......@@ -1,8 +1,3 @@
1use crate::lints::{
2 ConfusableIdentifierPair, IdentifierNonAsciiChar, IdentifierUncommonCodepoints,
3 MixedScriptConfusables,
4};
5use crate::{EarlyContext, EarlyLintPass, LintContext};
61use rustc_ast as ast;
72use rustc_data_structures::fx::FxIndexMap;
83use rustc_data_structures::unord::UnordMap;
......@@ -10,6 +5,12 @@ use rustc_session::{declare_lint, declare_lint_pass};
105use rustc_span::symbol::Symbol;
116use unicode_security::general_security_profile::IdentifierType;
127
8use crate::lints::{
9 ConfusableIdentifierPair, IdentifierNonAsciiChar, IdentifierUncommonCodepoints,
10 MixedScriptConfusables,
11};
12use crate::{EarlyContext, EarlyLintPass, LintContext};
13
1314declare_lint! {
1415 /// The `non_ascii_idents` lint detects non-ASCII identifiers.
1516 ///
......@@ -152,9 +153,10 @@ declare_lint_pass!(NonAsciiIdents => [NON_ASCII_IDENTS, UNCOMMON_CODEPOINTS, CON
152153
153154impl EarlyLintPass for NonAsciiIdents {
154155 fn check_crate(&mut self, cx: &EarlyContext<'_>, _: &ast::Crate) {
156 use std::collections::BTreeMap;
157
155158 use rustc_session::lint::Level;
156159 use rustc_span::Span;
157 use std::collections::BTreeMap;
158160 use unicode_security::GeneralSecurityProfile;
159161
160162 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 @@
1use crate::lints::{NonFmtPanicBraces, NonFmtPanicUnused};
2use crate::{fluent_generated as fluent, LateContext, LateLintPass, LintContext};
31use rustc_ast as ast;
42use rustc_errors::Applicability;
53use rustc_hir::{self as hir, LangItem};
64use rustc_infer::infer::TyCtxtInferExt;
7use rustc_middle::bug;
85use rustc_middle::lint::in_external_macro;
9use rustc_middle::ty;
6use rustc_middle::{bug, ty};
107use rustc_parse_format::{ParseMode, Parser, Piece};
118use rustc_session::lint::FutureIncompatibilityReason;
129use rustc_session::{declare_lint, declare_lint_pass};
1310use rustc_span::edition::Edition;
14use rustc_span::{hygiene, sym, symbol::kw, InnerSpan, Span, Symbol};
11use rustc_span::symbol::kw;
12use rustc_span::{hygiene, sym, InnerSpan, Span, Symbol};
1513use rustc_trait_selection::infer::InferCtxtExt;
1614
15use crate::lints::{NonFmtPanicBraces, NonFmtPanicUnused};
16use crate::{fluent_generated as fluent, LateContext, LateLintPass, LintContext};
17
1718declare_lint! {
1819 /// The `non_fmt_panics` lint detects `panic!(..)` invocations where the first
1920 /// argument is not a formatting string.
compiler/rustc_lint/src/non_local_def.rs+8-9
......@@ -1,24 +1,23 @@
11use rustc_errors::MultiSpan;
2use rustc_hir::def::DefKind;
23use rustc_hir::intravisit::{self, Visitor};
3use rustc_hir::HirId;
4use rustc_hir::{def::DefKind, Body, Item, ItemKind, Node, TyKind};
5use rustc_hir::{Path, QPath};
4use rustc_hir::{Body, HirId, Item, ItemKind, Node, Path, QPath, TyKind};
65use rustc_infer::infer::InferCtxt;
76use rustc_infer::traits::{Obligation, ObligationCause};
8use rustc_middle::ty::{self, Binder, Ty, TyCtxt, TypeFoldable, TypeFolder};
9use rustc_middle::ty::{EarlyBinder, TraitRef, TypeSuperFoldable};
7use rustc_middle::ty::{
8 self, Binder, EarlyBinder, TraitRef, Ty, TyCtxt, TypeFoldable, TypeFolder, TypeSuperFoldable,
9};
1010use rustc_session::{declare_lint, impl_lint_pass};
1111use rustc_span::def_id::{DefId, LOCAL_CRATE};
12use rustc_span::Span;
13use rustc_span::{sym, symbol::kw, ExpnKind, MacroKind, Symbol};
12use rustc_span::symbol::kw;
13use rustc_span::{sym, ExpnKind, MacroKind, Span, Symbol};
1414use rustc_trait_selection::error_reporting::traits::ambiguity::{
1515 compute_applicable_impls_for_diagnostics, CandidateSource,
1616};
1717use rustc_trait_selection::infer::TyCtxtInferExt;
1818
19use crate::fluent_generated as fluent;
2019use crate::lints::{NonLocalDefinitionsCargoUpdateNote, NonLocalDefinitionsDiag};
21use crate::{LateContext, LateLintPass, LintContext};
20use crate::{fluent_generated as fluent, LateContext, LateLintPass, LintContext};
2221
2322declare_lint! {
2423 /// 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 @@
1use crate::lints::{
2 NonCamelCaseType, NonCamelCaseTypeSub, NonSnakeCaseDiag, NonSnakeCaseDiagSub,
3 NonUpperCaseGlobal, NonUpperCaseGlobalSub,
4};
5use crate::{EarlyContext, EarlyLintPass, LateContext, LateLintPass, LintContext};
6use rustc_ast as ast;
7use rustc_attr as attr;
8use rustc_hir as hir;
91use rustc_hir::def::{DefKind, Res};
102use rustc_hir::intravisit::FnKind;
113use rustc_hir::{GenericParamKind, PatKind};
......@@ -16,6 +8,13 @@ use rustc_span::def_id::LocalDefId;
168use rustc_span::symbol::{sym, Ident};
179use rustc_span::{BytePos, Span};
1810use rustc_target::spec::abi::Abi;
11use {rustc_ast as ast, rustc_attr as attr, rustc_hir as hir};
12
13use crate::lints::{
14 NonCamelCaseType, NonCamelCaseTypeSub, NonSnakeCaseDiag, NonSnakeCaseDiagSub,
15 NonUpperCaseGlobal, NonUpperCaseGlobalSub,
16};
17use crate::{EarlyContext, EarlyLintPass, LateContext, LateLintPass, LintContext};
1918
2019#[derive(PartialEq)]
2120pub enum MethodLateContext {
compiler/rustc_lint/src/noop_method_call.rs+6-6
......@@ -1,9 +1,3 @@
1use crate::context::LintContext;
2use crate::lints::{
3 NoopMethodCallDiag, SuspiciousDoubleRefCloneDiag, SuspiciousDoubleRefDerefDiag,
4};
5use crate::LateContext;
6use crate::LateLintPass;
71use rustc_hir::def::DefKind;
82use rustc_hir::{Expr, ExprKind};
93use rustc_middle::ty;
......@@ -11,6 +5,12 @@ use rustc_middle::ty::adjustment::Adjust;
115use rustc_session::{declare_lint, declare_lint_pass};
126use rustc_span::symbol::sym;
137
8use crate::context::LintContext;
9use crate::lints::{
10 NoopMethodCallDiag, SuspiciousDoubleRefCloneDiag, SuspiciousDoubleRefDerefDiag,
11};
12use crate::{LateContext, LateLintPass};
13
1414declare_lint! {
1515 /// The `noop_method_call` lint detects specific calls to noop methods
1616 /// 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 @@
11use rustc_hir as hir;
22use rustc_infer::infer::TyCtxtInferExt;
33use rustc_macros::{LintDiagnostic, Subdiagnostic};
4use rustc_middle::ty::fold::BottomUpFolder;
45use rustc_middle::ty::print::{PrintTraitPredicateExt as _, TraitPredPrintModifiersAndPath};
5use rustc_middle::ty::{self, fold::BottomUpFolder, Ty, TypeFoldable};
6use rustc_middle::ty::{self, Ty, TypeFoldable};
67use rustc_session::{declare_lint, declare_lint_pass};
7use rustc_span::{symbol::kw, Span};
8use rustc_span::symbol::kw;
9use rustc_span::Span;
810use rustc_trait_selection::traits::{self, ObligationCtxt};
911
1012use crate::{LateContext, LateLintPass, LintContext};
compiler/rustc_lint/src/pass_by_value.rs+3-2
......@@ -1,5 +1,3 @@
1use crate::lints::PassByValueDiag;
2use crate::{LateContext, LateLintPass, LintContext};
31use rustc_hir as hir;
42use rustc_hir::def::Res;
53use rustc_hir::{GenericArg, PathSegment, QPath, TyKind};
......@@ -7,6 +5,9 @@ use rustc_middle::ty;
75use rustc_session::{declare_lint_pass, declare_tool_lint};
86use rustc_span::symbol::sym;
97
8use crate::lints::PassByValueDiag;
9use crate::{LateContext, LateLintPass, LintContext};
10
1011declare_tool_lint! {
1112 /// The `rustc_pass_by_value` lint marks a type with `#[rustc_pass_by_value]` requiring it to
1213 /// 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 @@
1use crate::context::{EarlyContext, LateContext};
2
31use rustc_session::lint::builtin::HardwiredLints;
42use rustc_session::lint::LintPass;
53
4use crate::context::{EarlyContext, LateContext};
5
66#[macro_export]
77macro_rules! late_lint_methods {
88 ($macro:path, $args:tt) => (
compiler/rustc_lint/src/ptr_nulls.rs+3-1
......@@ -1,9 +1,11 @@
1use crate::{lints::PtrNullChecksDiag, LateContext, LateLintPass, LintContext};
21use rustc_ast::LitKind;
32use rustc_hir::{BinOpKind, Expr, ExprKind, TyKind};
43use rustc_session::{declare_lint, declare_lint_pass};
54use rustc_span::sym;
65
6use crate::lints::PtrNullChecksDiag;
7use crate::{LateContext, LateLintPass, LintContext};
8
79declare_lint! {
810 /// The `useless_ptr_null_checks` lint checks for useless null checks against pointers
911 /// obtained from non-null types.
compiler/rustc_lint/src/redundant_semicolon.rs+3-1
......@@ -1,8 +1,10 @@
1use crate::{lints::RedundantSemicolonsDiag, EarlyContext, EarlyLintPass, LintContext};
21use rustc_ast::{Block, StmtKind};
32use rustc_session::{declare_lint, declare_lint_pass};
43use rustc_span::Span;
54
5use crate::lints::RedundantSemicolonsDiag;
6use crate::{EarlyContext, EarlyLintPass, LintContext};
7
68declare_lint! {
79 /// The `redundant_semicolons` lint detects unnecessary trailing
810 /// semicolons.
compiler/rustc_lint/src/reference_casting.rs+4-3
......@@ -1,11 +1,12 @@
11use rustc_ast::Mutability;
22use rustc_hir::{Expr, ExprKind, UnOp};
3use rustc_middle::ty::layout::LayoutOf as _;
4use rustc_middle::ty::{self, layout::TyAndLayout};
3use rustc_middle::ty::layout::{LayoutOf as _, TyAndLayout};
4use rustc_middle::ty::{self};
55use rustc_session::{declare_lint, declare_lint_pass};
66use rustc_span::sym;
77
8use crate::{lints::InvalidReferenceCastingDiag, LateContext, LateLintPass, LintContext};
8use crate::lints::InvalidReferenceCastingDiag;
9use crate::{LateContext, LateLintPass, LintContext};
910
1011declare_lint! {
1112 /// 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 @@
1use crate::lints::{ShadowedIntoIterDiag, ShadowedIntoIterDiagSub};
2use crate::{LateContext, LateLintPass, LintContext};
31use rustc_hir as hir;
42use rustc_middle::ty::{self, Ty};
53use rustc_session::lint::FutureIncompatibilityReason;
64use rustc_session::{declare_lint, impl_lint_pass};
75use rustc_span::edition::Edition;
86
7use crate::lints::{ShadowedIntoIterDiag, ShadowedIntoIterDiagSub};
8use crate::{LateContext, LateLintPass, LintContext};
9
910declare_lint! {
1011 /// The `array_into_iter` lint detects calling `into_iter` on arrays.
1112 ///
compiler/rustc_lint/src/tests.rs+2-1
......@@ -1,6 +1,7 @@
1use crate::levels::parse_lint_and_tool_name;
21use rustc_span::{create_default_session_globals_then, Symbol};
32
3use crate::levels::parse_lint_and_tool_name;
4
45#[test]
56fn parse_lint_no_tool() {
67 create_default_session_globals_then(|| {
compiler/rustc_lint/src/traits.rs+3-4
......@@ -1,11 +1,10 @@
1use crate::lints::{DropGlue, DropTraitConstraintsDiag};
2use crate::LateContext;
3use crate::LateLintPass;
4use crate::LintContext;
51use rustc_hir::{self as hir, LangItem};
62use rustc_session::{declare_lint, declare_lint_pass};
73use rustc_span::symbol::sym;
84
5use crate::lints::{DropGlue, DropTraitConstraintsDiag};
6use crate::{LateContext, LateLintPass, LintContext};
7
98declare_lint! {
109 /// The `drop_bounds` lint checks for generics with `std::ops::Drop` as
1110 /// bounds.
compiler/rustc_lint/src/types.rs+18-24
......@@ -1,39 +1,33 @@
1use 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};
13use crate::{LateContext, LateLintPass, LintContext};
14use rustc_ast as ast;
15use rustc_attr as attr;
1use std::iter;
2use std::ops::ControlFlow;
3
164use rustc_data_structures::fx::FxHashSet;
175use rustc_errors::DiagMessage;
18use rustc_hir as hir;
196use rustc_hir::{is_range_literal, Expr, ExprKind, Node};
207use rustc_middle::bug;
218use rustc_middle::ty::layout::{IntegerExt, LayoutOf, SizeSkeleton};
22use rustc_middle::ty::GenericArgsRef;
239use rustc_middle::ty::{
24 self, AdtKind, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitableExt,
10 self, AdtKind, GenericArgsRef, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitableExt,
2511};
2612use rustc_session::{declare_lint, declare_lint_pass, impl_lint_pass};
2713use rustc_span::def_id::LocalDefId;
28use rustc_span::source_map;
2914use rustc_span::symbol::sym;
30use rustc_span::{Span, Symbol};
31use rustc_target::abi::{Abi, Size, WrappingRange};
32use rustc_target::abi::{Integer, TagEncoding, Variants};
15use rustc_span::{source_map, Span, Symbol};
16use rustc_target::abi::{Abi, Integer, Size, TagEncoding, Variants, WrappingRange};
3317use rustc_target::spec::abi::Abi as SpecAbi;
34use std::iter;
35use std::ops::ControlFlow;
3618use tracing::debug;
19use {rustc_ast as ast, rustc_attr as attr, rustc_hir as hir};
20
21use 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};
30use crate::{fluent_generated as fluent, LateContext, LateLintPass, LintContext};
3731
3832declare_lint! {
3933 /// The `unused_comparisons` lint detects comparisons made useless by
compiler/rustc_lint/src/unit_bindings.rs+3-2
......@@ -1,8 +1,9 @@
1use crate::lints::UnitBindingsDiag;
2use crate::{LateLintPass, LintContext};
31use rustc_hir as hir;
42use rustc_session::{declare_lint, declare_lint_pass};
53
4use crate::lints::UnitBindingsDiag;
5use crate::{LateLintPass, LintContext};
6
67declare_lint! {
78 /// The `unit_bindings` lint detects cases where bindings are useless because they have
89 /// 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 @@
1use crate::lints::{
2 PathStatementDrop, PathStatementDropSub, PathStatementNoEffect, UnusedAllocationDiag,
3 UnusedAllocationMutDiag, UnusedClosure, UnusedCoroutine, UnusedDef, UnusedDefSuggestion,
4 UnusedDelim, UnusedDelimSuggestion, UnusedImportBracesDiag, UnusedOp, UnusedOpSuggestion,
5 UnusedResult,
6};
7use crate::Lint;
8use crate::{EarlyContext, EarlyLintPass, LateContext, LateLintPass, LintContext};
1use std::iter;
2use std::ops::ControlFlow;
3
94use rustc_ast as ast;
105use rustc_ast::util::{classify, parser};
116use rustc_ast::{ExprKind, StmtKind};
......@@ -14,16 +9,20 @@ use rustc_hir::def::{DefKind, Res};
149use rustc_hir::def_id::DefId;
1510use rustc_hir::{self as hir, LangItem};
1611use rustc_infer::traits::util::elaborate;
17use rustc_middle::ty::adjustment;
18use rustc_middle::ty::{self, Ty};
12use rustc_middle::ty::{self, adjustment, Ty};
1913use rustc_session::{declare_lint, declare_lint_pass, impl_lint_pass};
20use rustc_span::symbol::Symbol;
21use rustc_span::symbol::{kw, sym};
14use rustc_span::symbol::{kw, sym, Symbol};
2215use rustc_span::{BytePos, Span};
23use std::iter;
24use std::ops::ControlFlow;
2516use tracing::instrument;
2617
18use crate::lints::{
19 PathStatementDrop, PathStatementDropSub, PathStatementNoEffect, UnusedAllocationDiag,
20 UnusedAllocationMutDiag, UnusedClosure, UnusedCoroutine, UnusedDef, UnusedDefSuggestion,
21 UnusedDelim, UnusedDelimSuggestion, UnusedImportBracesDiag, UnusedOp, UnusedOpSuggestion,
22 UnusedResult,
23};
24use crate::{EarlyContext, EarlyLintPass, LateContext, LateLintPass, Lint, LintContext};
25
2726declare_lint! {
2827 /// The `unused_must_use` lint detects unused result of a type flagged as
2928 /// `#[must_use]`.
......@@ -1205,7 +1204,8 @@ impl EarlyLintPass for UnusedParens {
12051204 }
12061205
12071206 fn check_pat(&mut self, cx: &EarlyContext<'_>, p: &ast::Pat) {
1208 use ast::{Mutability, PatKind::*};
1207 use ast::Mutability;
1208 use ast::PatKind::*;
12091209 let keep_space = (false, false);
12101210 match &p.kind {
12111211 // 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 @@
77//! When removing a lint, make sure to also add a call to `register_removed` in
88//! compiler/rustc_lint/src/lib.rs.
99
10use crate::{declare_lint, declare_lint_pass, FutureIncompatibilityReason};
1110use rustc_span::edition::Edition;
1211
12use crate::{declare_lint, declare_lint_pass, FutureIncompatibilityReason};
13
1314declare_lint_pass! {
1415 /// Does nothing as a lint pass, but registers some `Lint`s
1516 /// that are used by other parts of the compiler.
compiler/rustc_lint_defs/src/lib.rs+5-6
......@@ -1,4 +1,3 @@
1pub use self::Level::*;
21use rustc_ast::node_id::NodeId;
32use rustc_ast::{AttrId, Attribute};
43use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
......@@ -7,16 +6,16 @@ use rustc_data_structures::stable_hasher::{
76};
87use rustc_error_messages::{DiagMessage, MultiSpan};
98use rustc_hir::def::Namespace;
10use rustc_hir::HashStableContext;
11use rustc_hir::HirId;
9use rustc_hir::{HashStableContext, HirId};
1210use rustc_macros::{Decodable, Encodable, HashStable_Generic};
1311use rustc_span::edition::Edition;
14use rustc_span::symbol::MacroRulesNormalizedIdent;
15use rustc_span::{sym, symbol::Ident, Span, Symbol};
12use rustc_span::symbol::{Ident, MacroRulesNormalizedIdent};
13use rustc_span::{sym, Span, Symbol};
1614use rustc_target::spec::abi::Abi;
17
1815use serde::{Deserialize, Serialize};
1916
17pub use self::Level::*;
18
2019pub mod builtin;
2120
2221#[macro_export]
compiler/rustc_llvm/src/lib.rs+2-1
......@@ -7,10 +7,11 @@
77
88// NOTE: This crate only exists to allow linking on mingw targets.
99
10use libc::{c_char, size_t};
1110use std::cell::RefCell;
1211use std::slice;
1312
13use libc::{c_char, size_t};
14
1415#[repr(C)]
1516pub struct RustString {
1617 pub bytes: RefCell<Vec<u8>>,
compiler/rustc_log/src/lib.rs+3-4
......@@ -41,12 +41,11 @@
4141use std::env::{self, VarError};
4242use std::fmt::{self, Display};
4343use std::io::{self, IsTerminal};
44
4445use tracing_core::{Event, Subscriber};
4546use tracing_subscriber::filter::{Directive, EnvFilter, LevelFilter};
46use tracing_subscriber::fmt::{
47 format::{self, FormatEvent, FormatFields},
48 FmtContext,
49};
47use tracing_subscriber::fmt::format::{self, FormatEvent, FormatFields};
48use tracing_subscriber::fmt::FmtContext;
5049use tracing_subscriber::layer::SubscriberExt;
5150
5251/// 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 @@
22
33use std::cell::RefCell;
44
5use crate::diagnostics::diagnostic_builder::DiagnosticDeriveKind;
6use crate::diagnostics::error::{span_err, DiagnosticDeriveError};
7use crate::diagnostics::utils::SetOnce;
85use proc_macro2::TokenStream;
96use quote::quote;
107use syn::spanned::Spanned;
118use synstructure::Structure;
129
10use crate::diagnostics::diagnostic_builder::DiagnosticDeriveKind;
11use crate::diagnostics::error::{span_err, DiagnosticDeriveError};
12use crate::diagnostics::utils::SetOnce;
13
1314/// The central struct for constructing the `into_diag` method from an annotated struct.
1415pub(crate) struct DiagnosticDerive<'a> {
1516 structure: Structure<'a>,
compiler/rustc_macros/src/diagnostics/diagnostic_builder.rs+7-7
......@@ -1,5 +1,12 @@
11#![deny(unused_must_use)]
22
3use proc_macro2::{Ident, Span, TokenStream};
4use quote::{format_ident, quote, quote_spanned};
5use syn::spanned::Spanned;
6use syn::{parse_quote, Attribute, Meta, Path, Token, Type};
7use synstructure::{BindingInfo, Structure, VariantInfo};
8
9use super::utils::SubdiagnosticVariant;
310use crate::diagnostics::error::{
411 span_err, throw_invalid_attr, throw_span_err, DiagnosticDeriveError,
512};
......@@ -8,13 +15,6 @@ use crate::diagnostics::utils::{
815 should_generate_arg, type_is_bool, type_is_unit, type_matches_path, FieldInfo, FieldInnerTy,
916 FieldMap, HasFieldMap, SetOnce, SpannedOption, SubdiagnosticKind,
1017};
11use proc_macro2::{Ident, Span, TokenStream};
12use quote::{format_ident, quote, quote_spanned};
13use syn::Token;
14use syn::{parse_quote, spanned::Spanned, Attribute, Meta, Path, Type};
15use synstructure::{BindingInfo, Structure, VariantInfo};
16
17use super::utils::SubdiagnosticVariant;
1818
1919/// What kind of diagnostic is being derived - a fatal/error/warning or a lint?
2020#[derive(Clone, Copy, PartialEq, Eq)]
compiler/rustc_macros/src/diagnostics/error.rs+2-1
......@@ -1,7 +1,8 @@
11use proc_macro::{Diagnostic, Level, MultiSpan};
22use proc_macro2::TokenStream;
33use quote::quote;
4use syn::{spanned::Spanned, Attribute, Error as SynError, Meta};
4use syn::spanned::Spanned;
5use syn::{Attribute, Error as SynError, Meta};
56
67#[derive(Debug)]
78pub(crate) enum DiagnosticDeriveError {
compiler/rustc_macros/src/diagnostics/subdiagnostic.rs+7-6
......@@ -1,5 +1,12 @@
11#![deny(unused_must_use)]
22
3use proc_macro2::TokenStream;
4use quote::{format_ident, quote};
5use syn::spanned::Spanned;
6use syn::{Attribute, Meta, MetaList, Path};
7use synstructure::{BindingInfo, Structure, VariantInfo};
8
9use super::utils::SubdiagnosticVariant;
310use crate::diagnostics::error::{
411 invalid_attr, span_err, throw_invalid_attr, throw_span_err, DiagnosticDeriveError,
512};
......@@ -9,12 +16,6 @@ use crate::diagnostics::utils::{
916 should_generate_arg, AllowMultipleAlternatives, FieldInfo, FieldInnerTy, FieldMap, HasFieldMap,
1017 SetOnce, SpannedOption, SubdiagnosticKind,
1118};
12use proc_macro2::TokenStream;
13use quote::{format_ident, quote};
14use syn::{spanned::Spanned, Attribute, Meta, MetaList, Path};
15use synstructure::{BindingInfo, Structure, VariantInfo};
16
17use super::utils::SubdiagnosticVariant;
1819
1920/// The central struct for constructing the `add_to_diag` method from an annotated struct.
2021pub(crate) struct SubdiagnosticDerive {
compiler/rustc_macros/src/diagnostics/utils.rs+9-8
......@@ -1,20 +1,21 @@
1use crate::diagnostics::error::{
2 span_err, throw_invalid_attr, throw_span_err, DiagnosticDeriveError,
3};
4use proc_macro::Span;
5use proc_macro2::{Ident, TokenStream};
6use quote::{format_ident, quote, ToTokens};
71use std::cell::RefCell;
82use std::collections::{BTreeSet, HashMap};
93use std::fmt;
104use std::str::FromStr;
5
6use proc_macro::Span;
7use proc_macro2::{Ident, TokenStream};
8use quote::{format_ident, quote, ToTokens};
119use syn::meta::ParseNestedMeta;
1210use syn::punctuated::Punctuated;
13use syn::{parenthesized, LitStr, Path, Token};
14use syn::{spanned::Spanned, Attribute, Field, Meta, Type, TypeTuple};
11use syn::spanned::Spanned;
12use syn::{parenthesized, Attribute, Field, LitStr, Meta, Path, Token, Type, TypeTuple};
1513use synstructure::{BindingInfo, VariantInfo};
1614
1715use super::error::invalid_attr;
16use crate::diagnostics::error::{
17 span_err, throw_invalid_attr, throw_span_err, DiagnosticDeriveError,
18};
1819
1920thread_local! {
2021 pub(crate) static CODE_IDENT_COUNT: RefCell<u32> = RefCell::new(0);
compiler/rustc_macros/src/lib.rs+1-2
......@@ -10,9 +10,8 @@
1010#![feature(proc_macro_tracked_env)]
1111// tidy-alphabetical-end
1212
13use synstructure::decl_derive;
14
1513use proc_macro::TokenStream;
14use synstructure::decl_derive;
1615
1716mod current_version;
1817mod diagnostics;
compiler/rustc_macros/src/symbols.rs+4-2
......@@ -24,11 +24,13 @@
2424//! CFG_RELEASE="0.0.0" cargo +nightly expand > /tmp/rustc_span.rs
2525//! ```
2626
27use std::collections::HashMap;
28
2729use proc_macro2::{Span, TokenStream};
2830use quote::quote;
29use std::collections::HashMap;
3031use syn::parse::{Parse, ParseStream, Result};
31use syn::{braced, punctuated::Punctuated, Expr, Ident, Lit, LitStr, Macro, Token};
32use syn::punctuated::Punctuated;
33use syn::{braced, Expr, Ident, Lit, LitStr, Macro, Token};
3234
3335#[cfg(test)]
3436mod tests;
compiler/rustc_metadata/src/creader.rs+10-10
......@@ -1,9 +1,13 @@
11//! Validates all used crates and extern libraries and loads their metadata
22
3use crate::errors;
4use crate::locator::{CrateError, CrateLocator, CratePaths};
5use crate::rmeta::{CrateDep, CrateMetadata, CrateNumMap, CrateRoot, MetadataBlob};
3use std::error::Error;
4use std::ops::Fn;
5use std::path::Path;
6use std::str::FromStr;
7use std::time::Duration;
8use std::{cmp, env, iter};
69
10use proc_macro::bridge::client::ProcMacro;
711use rustc_ast::expand::allocator::{alloc_error_handler_name, global_fn_name, AllocatorKind};
812use rustc_ast::{self as ast, *};
913use rustc_data_structures::fx::FxHashSet;
......@@ -29,13 +33,9 @@ use rustc_span::{Span, DUMMY_SP};
2933use rustc_target::spec::{PanicStrategy, Target, TargetTriple};
3034use tracing::{debug, info, trace};
3135
32use proc_macro::bridge::client::ProcMacro;
33use std::error::Error;
34use std::ops::Fn;
35use std::path::Path;
36use std::str::FromStr;
37use std::time::Duration;
38use std::{cmp, env, iter};
36use crate::errors;
37use crate::locator::{CrateError, CrateLocator, CratePaths};
38use crate::rmeta::{CrateDep, CrateMetadata, CrateNumMap, CrateRoot, MetadataBlob};
3939
4040/// The backend's way to give the crate store access to the metadata in a library.
4141/// 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 @@
5151//! Additionally, the algorithm is geared towards finding *any* solution rather
5252//! than finding a number of solutions (there are normally quite a few).
5353
54use crate::creader::CStore;
55use crate::errors::{
56 BadPanicStrategy, CrateDepMultiple, IncompatiblePanicInDropStrategy, LibRequired,
57 NonStaticCrateDep, RequiredPanicStrategy, RlibRequired, RustcLibRequired, TwoPanicRuntimes,
58};
59
6054use rustc_data_structures::fx::FxHashMap;
6155use rustc_hir::def_id::CrateNum;
6256use rustc_middle::bug;
......@@ -67,6 +61,12 @@ use rustc_session::cstore::CrateDepKind;
6761use rustc_session::cstore::LinkagePreference::{self, RequireDynamic, RequireStatic};
6862use tracing::info;
6963
64use crate::creader::CStore;
65use crate::errors::{
66 BadPanicStrategy, CrateDepMultiple, IncompatiblePanicInDropStrategy, LibRequired,
67 NonStaticCrateDep, RequiredPanicStrategy, RlibRequired, RustcLibRequired, TwoPanicRuntimes,
68};
69
7070pub(crate) fn calculate(tcx: TyCtxt<'_>) -> Dependencies {
7171 tcx.crate_types()
7272 .iter()
compiler/rustc_metadata/src/errors.rs+4-5
......@@ -1,9 +1,8 @@
1use std::{
2 io::Error,
3 path::{Path, PathBuf},
4};
1use std::io::Error;
2use std::path::{Path, PathBuf};
53
6use rustc_errors::{codes::*, Diag, DiagCtxtHandle, Diagnostic, EmissionGuarantee, Level};
4use rustc_errors::codes::*;
5use rustc_errors::{Diag, DiagCtxtHandle, Diagnostic, EmissionGuarantee, Level};
76use rustc_macros::{Diagnostic, Subdiagnostic};
87use rustc_span::{sym, Span, Symbol};
98use rustc_target::spec::{PanicStrategy, TargetTriple};
compiler/rustc_metadata/src/fs.rs+7-7
......@@ -1,8 +1,5 @@
1use crate::errors::{
2 BinaryOutputToTty, FailedCopyToStdout, FailedCreateEncodedMetadata, FailedCreateFile,
3 FailedCreateTempdir, FailedWriteError,
4};
5use crate::{encode_metadata, EncodedMetadata};
1use std::path::{Path, PathBuf};
2use std::{fs, io};
63
74use rustc_data_structures::temp_dir::MaybeTempDir;
85use rustc_middle::ty::TyCtxt;
......@@ -11,8 +8,11 @@ use rustc_session::output::filename_for_metadata;
118use rustc_session::{MetadataKind, Session};
129use tempfile::Builder as TempFileBuilder;
1310
14use std::path::{Path, PathBuf};
15use std::{fs, io};
11use crate::errors::{
12 BinaryOutputToTty, FailedCopyToStdout, FailedCreateEncodedMetadata, FailedCreateFile,
13 FailedCreateTempdir, FailedWriteError,
14};
15use crate::{encode_metadata, EncodedMetadata};
1616
1717// FIXME(eddyb) maybe include the crate name in this?
1818pub const METADATA_FILENAME: &str = "lib.rmeta";
compiler/rustc_metadata/src/locator.rs+9-9
......@@ -212,9 +212,11 @@
212212//! no means all of the necessary details. Take a look at the rest of
213213//! metadata::locator or metadata::creader for all the juicy details!
214214
215use crate::creader::{Library, MetadataLoader};
216use crate::errors;
217use crate::rmeta::{rustc_version, MetadataBlob, METADATA_HEADER};
215use std::borrow::Cow;
216use std::io::{Read, Result as IoResult, Write};
217use std::ops::Deref;
218use std::path::{Path, PathBuf};
219use std::{cmp, fmt};
218220
219221use rustc_data_structures::fx::{FxHashMap, FxHashSet};
220222use rustc_data_structures::memmap::Mmap;
......@@ -230,14 +232,12 @@ use rustc_session::Session;
230232use rustc_span::symbol::Symbol;
231233use rustc_span::Span;
232234use rustc_target::spec::{Target, TargetTriple};
235use snap::read::FrameDecoder;
233236use tracing::{debug, info};
234237
235use snap::read::FrameDecoder;
236use std::borrow::Cow;
237use std::io::{Read, Result as IoResult, Write};
238use std::ops::Deref;
239use std::path::{Path, PathBuf};
240use std::{cmp, fmt};
238use crate::creader::{Library, MetadataLoader};
239use crate::errors;
240use crate::rmeta::{rustc_version, MetadataBlob, METADATA_HEADER};
241241
242242#[derive(Clone)]
243243pub(crate) struct CrateLocator<'a> {
compiler/rustc_metadata/src/native_libs.rs+2-2
......@@ -1,3 +1,5 @@
1use std::path::PathBuf;
2
13use rustc_ast::{NestedMetaItem, CRATE_NODE_ID};
24use rustc_attr as attr;
35use rustc_data_structures::fx::FxHashSet;
......@@ -17,8 +19,6 @@ use rustc_target::spec::abi::Abi;
1719
1820use crate::errors;
1921
20use std::path::PathBuf;
21
2222pub fn find_native_static_library(name: &str, verbatim: bool, sess: &Session) -> PathBuf {
2323 let formats = if verbatim {
2424 vec![("".into(), "".into())]
compiler/rustc_metadata/src/rmeta/decoder.rs+9-10
......@@ -1,9 +1,11 @@
11// Decoding metadata from a single crate's metadata
22
3use crate::creader::CStore;
4use crate::rmeta::table::IsDefault;
5use crate::rmeta::*;
3use std::iter::TrustedLen;
4use std::path::Path;
5use std::{io, iter, mem};
66
7pub(super) use cstore_impl::provide;
8use proc_macro::bridge::client::ProcMacro;
79use rustc_ast as ast;
810use rustc_data_structures::captures::Captures;
911use rustc_data_structures::fingerprint::Fingerprint;
......@@ -27,17 +29,14 @@ use rustc_serialize::opaque::MemDecoder;
2729use rustc_serialize::{Decodable, Decoder};
2830use rustc_session::cstore::{CrateSource, ExternCrate};
2931use rustc_session::Session;
32use rustc_span::hygiene::HygieneDecodeContext;
3033use rustc_span::symbol::kw;
3134use rustc_span::{BytePos, Pos, SpanData, SpanDecoder, SyntaxContext, DUMMY_SP};
3235use tracing::debug;
3336
34use proc_macro::bridge::client::ProcMacro;
35use std::iter::TrustedLen;
36use std::path::Path;
37use std::{io, iter, mem};
38
39pub(super) use cstore_impl::provide;
40use rustc_span::hygiene::HygieneDecodeContext;
37use crate::creader::CStore;
38use crate::rmeta::table::IsDefault;
39use crate::rmeta::*;
4140
4241mod cstore_impl;
4342
compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs+7-10
......@@ -1,8 +1,5 @@
1use crate::creader::{CStore, LoadedMacro};
2use crate::foreign_modules;
3use crate::native_libs;
4use crate::rmeta::table::IsDefault;
5use crate::rmeta::AttrFlags;
1use std::any::Any;
2use std::mem;
63
74use rustc_ast as ast;
85use rustc_attr::Deprecation;
......@@ -15,8 +12,7 @@ use rustc_middle::bug;
1512use rustc_middle::metadata::ModChild;
1613use rustc_middle::middle::exported_symbols::ExportedSymbol;
1714use rustc_middle::middle::stability::DeprecationEntry;
18use rustc_middle::query::ExternProviders;
19use rustc_middle::query::LocalCrate;
15use rustc_middle::query::{ExternProviders, LocalCrate};
2016use rustc_middle::ty::fast_reject::SimplifiedType;
2117use rustc_middle::ty::{self, TyCtxt};
2218use rustc_middle::util::Providers;
......@@ -26,10 +22,11 @@ use rustc_span::hygiene::ExpnId;
2622use rustc_span::symbol::{kw, Symbol};
2723use rustc_span::Span;
2824
29use std::any::Any;
30use std::mem;
31
3225use super::{Decodable, DecodeContext, DecodeIterator};
26use crate::creader::{CStore, LoadedMacro};
27use crate::rmeta::table::IsDefault;
28use crate::rmeta::AttrFlags;
29use crate::{foreign_modules, native_libs};
3330
3431trait ProcessQueryValue<'tcx, T> {
3532 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 @@
1use crate::rmeta::DecodeContext;
2use crate::rmeta::EncodeContext;
31use rustc_data_structures::owned_slice::OwnedSlice;
42use rustc_hir::def_path_hash_map::{Config as HashMapConfig, DefPathHashMap};
53use rustc_middle::parameterized_over_tcx;
64use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
75use rustc_span::def_id::{DefIndex, DefPathHash};
86
7use crate::rmeta::{DecodeContext, EncodeContext};
8
99pub(crate) enum DefPathHashMapRef<'tcx> {
1010 OwnedFromMetadata(odht::HashTable<HashMapConfig, OwnedSlice>),
1111 BorrowedFromTcx(&'tcx DefPathHashMap),
compiler/rustc_metadata/src/rmeta/encoder.rs+8-7
......@@ -1,5 +1,8 @@
1use crate::errors::{FailCreateFileEncoder, FailWriteFile};
2use crate::rmeta::*;
1use std::borrow::Borrow;
2use std::collections::hash_map::Entry;
3use std::fs::File;
4use std::io::{Read, Seek, Write};
5use std::path::{Path, PathBuf};
36
47use rustc_ast::Attribute;
58use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
......@@ -27,13 +30,11 @@ use rustc_span::symbol::sym;
2730use rustc_span::{
2831 ExternalSource, FileName, SourceFile, SpanData, SpanEncoder, StableSourceFileId, SyntaxContext,
2932};
30use std::borrow::Borrow;
31use std::collections::hash_map::Entry;
32use std::fs::File;
33use std::io::{Read, Seek, Write};
34use std::path::{Path, PathBuf};
3533use tracing::{debug, instrument, trace};
3634
35use crate::errors::{FailCreateFileEncoder, FailWriteFile};
36use crate::rmeta::*;
37
3738pub(super) struct EncodeContext<'a, 'tcx> {
3839 opaque: opaque::FileEncoder,
3940 tcx: TyCtxt<'tcx>,
compiler/rustc_metadata/src/rmeta/mod.rs+13-12
......@@ -1,35 +1,35 @@
1use crate::creader::CrateMetadataRef;
1use std::marker::PhantomData;
2use std::num::NonZero;
3
24pub(crate) use decoder::{CrateMetadata, CrateNumMap, MetadataBlob};
35use decoder::{DecodeContext, Metadata};
46use def_path_hash_map::DefPathHashMapRef;
57use encoder::EncodeContext;
68pub use encoder::{encode_metadata, rendered_const, EncodedMetadata};
7use rustc_ast as ast;
89use rustc_ast::expand::StrippedCfgItem;
9use rustc_attr as attr;
1010use rustc_data_structures::fx::FxHashMap;
1111use rustc_data_structures::svh::Svh;
12use rustc_hir as hir;
1312use rustc_hir::def::{CtorKind, DefKind, DocLinkResMap};
1413use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, DefIndex, DefPathHash, StableCrateId};
1514use rustc_hir::definitions::DefKey;
1615use rustc_hir::lang_items::LangItem;
1716use rustc_index::bit_set::BitSet;
1817use rustc_index::IndexVec;
19use rustc_macros::{Decodable, Encodable, TyDecodable, TyEncodable};
20use rustc_macros::{MetadataDecodable, MetadataEncodable};
18use rustc_macros::{
19 Decodable, Encodable, MetadataDecodable, MetadataEncodable, TyDecodable, TyEncodable,
20};
2121use rustc_middle::metadata::ModChild;
2222use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrs;
2323use rustc_middle::middle::debugger_visualizer::DebuggerVisualizerFile;
2424use rustc_middle::middle::exported_symbols::{ExportedSymbol, SymbolExportInfo};
2525use rustc_middle::middle::lib_features::FeatureStability;
2626use rustc_middle::middle::resolve_bound_vars::ObjectLifetimeDefault;
27use rustc_middle::mir;
28use rustc_middle::trivially_parameterized_over_tcx;
2927use rustc_middle::ty::fast_reject::SimplifiedType;
30use rustc_middle::ty::{self, ReprOptions, Ty, UnusedGenericParams};
31use rustc_middle::ty::{DeducedParamAttrs, ParameterizedOverTcx, TyCtxt};
28use rustc_middle::ty::{
29 self, DeducedParamAttrs, ParameterizedOverTcx, ReprOptions, Ty, TyCtxt, UnusedGenericParams,
30};
3231use rustc_middle::util::Providers;
32use rustc_middle::{mir, trivially_parameterized_over_tcx};
3333use rustc_serialize::opaque::FileEncoder;
3434use rustc_session::config::SymbolManglingVersion;
3535use rustc_session::cstore::{CrateDepKind, ForeignModule, LinkagePreference, NativeLib};
......@@ -39,9 +39,10 @@ use rustc_span::symbol::{Ident, Symbol};
3939use rustc_span::{self, ExpnData, ExpnHash, ExpnId, Span};
4040use rustc_target::abi::{FieldIdx, VariantIdx};
4141use rustc_target::spec::{PanicStrategy, TargetTriple};
42use std::marker::PhantomData;
43use std::num::NonZero;
4442use table::TableBuilder;
43use {rustc_ast as ast, rustc_attr as attr, rustc_hir as hir};
44
45use crate::creader::CrateMetadataRef;
4546
4647mod decoder;
4748mod def_path_hash_map;
compiler/rustc_metadata/src/rmeta/table.rs+2-2
......@@ -1,9 +1,9 @@
1use crate::rmeta::*;
2
31use rustc_hir::def::CtorOf;
42use rustc_index::Idx;
53use tracing::trace;
64
5use crate::rmeta::*;
6
77pub(super) trait IsDefault: Default {
88 fn is_default(&self) -> bool;
99}
compiler/rustc_middle/src/dep_graph/dep_node.rs+4-5
......@@ -56,18 +56,17 @@
5656//!
5757//! [dependency graph]: https://rustc-dev-guide.rust-lang.org/query.html
5858
59use crate::mir::mono::MonoItem;
60use crate::ty::TyCtxt;
61
6259use rustc_data_structures::fingerprint::Fingerprint;
6360use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, LocalModDefId, ModDefId, LOCAL_CRATE};
6461use rustc_hir::definitions::DefPathHash;
6562use rustc_hir::{HirId, ItemLocalId, OwnerId};
63pub use rustc_query_system::dep_graph::dep_node::DepKind;
6664use rustc_query_system::dep_graph::FingerprintStyle;
65pub use rustc_query_system::dep_graph::{DepContext, DepNode, DepNodeParams};
6766use rustc_span::symbol::Symbol;
6867
69pub use rustc_query_system::dep_graph::dep_node::DepKind;
70pub use rustc_query_system::dep_graph::{DepContext, DepNode, DepNodeParams};
68use crate::mir::mono::MonoItem;
69use crate::ty::TyCtxt;
7170
7271macro_rules! define_dep_nodes {
7372 (
compiler/rustc_middle/src/dep_graph/mod.rs+7-8
......@@ -1,20 +1,19 @@
1use crate::ty::{self, TyCtxt};
21use rustc_data_structures::profiling::SelfProfilerRef;
32use rustc_query_system::ich::StableHashingContext;
43use rustc_session::Session;
54
5use crate::ty::{self, TyCtxt};
6
67#[macro_use]
78mod dep_node;
89
9pub use rustc_query_system::dep_graph::debug::EdgeFilter;
10pub 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
1610pub use dep_node::{dep_kinds, label_strs, DepKind, DepNode, DepNodeExt};
1711pub(crate) use dep_node::{make_compile_codegen_unit, make_compile_mono_item};
12pub use rustc_query_system::dep_graph::debug::{DepNodeFilter, EdgeFilter};
13pub use rustc_query_system::dep_graph::{
14 hash_result, DepContext, DepGraphQuery, DepNodeIndex, Deps, SerializedDepGraph,
15 SerializedDepNodeIndex, TaskDepsRef, WorkProduct, WorkProductId, WorkProductMap,
16};
1817
1918pub type DepGraph = rustc_query_system::dep_graph::DepGraph<DepsType>;
2019
compiler/rustc_middle/src/error.rs+2-1
......@@ -1,7 +1,8 @@
11use std::fmt;
22use std::path::PathBuf;
33
4use rustc_errors::{codes::*, DiagArgName, DiagArgValue, DiagMessage};
4use rustc_errors::codes::*;
5use rustc_errors::{DiagArgName, DiagArgValue, DiagMessage};
56use rustc_macros::{Diagnostic, Subdiagnostic};
67use rustc_span::{Span, Symbol};
78
compiler/rustc_middle/src/hir/map/mod.rs+6-6
......@@ -1,8 +1,3 @@
1use crate::hir::ModuleItems;
2use crate::middle::debugger_visualizer::DebuggerVisualizerFile;
3use crate::query::LocalCrate;
4use crate::ty::TyCtxt;
5use rustc_ast as ast;
61use rustc_ast::visit::{walk_list, VisitorResult};
72use rustc_data_structures::fingerprint::Fingerprint;
83use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
......@@ -13,12 +8,17 @@ use rustc_hir::def_id::{DefId, LocalDefId, LocalModDefId, LOCAL_CRATE};
138use rustc_hir::definitions::{DefKey, DefPath, DefPathHash};
149use rustc_hir::intravisit::Visitor;
1510use rustc_hir::*;
16use rustc_hir_pretty as pprust_hir;
1711use rustc_middle::hir::nested_filter;
1812use rustc_span::def_id::StableCrateId;
1913use rustc_span::symbol::{kw, sym, Ident, Symbol};
2014use rustc_span::{ErrorGuaranteed, Span};
2115use rustc_target::spec::abi::Abi;
16use {rustc_ast as ast, rustc_hir_pretty as pprust_hir};
17
18use crate::hir::ModuleItems;
19use crate::middle::debugger_visualizer::DebuggerVisualizerFile;
20use crate::query::LocalCrate;
21use crate::ty::TyCtxt;
2222
2323// FIXME: the structure was necessary in the past but now it
2424// 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;
66pub mod nested_filter;
77pub mod place;
88
9use crate::query::Providers;
10use crate::ty::{EarlyBinder, ImplSubject, TyCtxt};
119use rustc_data_structures::fingerprint::Fingerprint;
1210use rustc_data_structures::sorted_map::SortedMap;
1311use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
......@@ -18,6 +16,9 @@ use rustc_hir::*;
1816use rustc_macros::{Decodable, Encodable, HashStable};
1917use rustc_span::{ErrorGuaranteed, ExpnId};
2018
19use crate::query::Providers;
20use crate::ty::{EarlyBinder, ImplSubject, TyCtxt};
21
2122/// Gather the LocalDefId for each item-like within a module, including items contained within
2223/// bodies. The Ids are in visitor order. This is used to partition a pass between modules.
2324#[derive(Debug, HashStable, Encodable, Decodable)]
compiler/rustc_middle/src/hir/place.rs+3-3
......@@ -1,10 +1,10 @@
1use crate::ty;
2use crate::ty::Ty;
3
41use rustc_hir::HirId;
52use rustc_macros::{HashStable, TyDecodable, TyEncodable, TypeFoldable, TypeVisitable};
63use rustc_target::abi::{FieldIdx, VariantIdx};
74
5use crate::ty;
6use crate::ty::Ty;
7
88#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, TyEncodable, TyDecodable, HashStable)]
99#[derive(TypeFoldable, TypeVisitable)]
1010pub enum PlaceBase {
compiler/rustc_middle/src/hooks/mod.rs+4-3
......@@ -3,15 +3,16 @@
33//! queries come with a lot of machinery for caching and incremental compilation, whereas hooks are
44//! just plain function pointers without any of the query magic.
55
6use crate::mir;
7use crate::query::TyCtxtAt;
8use crate::ty::{Ty, TyCtxt};
96use rustc_hir::def_id::{DefId, DefPathHash};
107use rustc_session::StableCrateId;
118use rustc_span::def_id::{CrateNum, LocalDefId};
129use rustc_span::{ExpnHash, ExpnId, DUMMY_SP};
1310use tracing::instrument;
1411
12use crate::mir;
13use crate::query::TyCtxtAt;
14use crate::ty::{Ty, TyCtxt};
15
1516macro_rules! declare_hooks {
1617 ($($(#[$attr:meta])*hook $name:ident($($arg:ident: $K:ty),*) -> $V:ty;)*) => {
1718
compiler/rustc_middle/src/infer/canonical.rs+3-3
......@@ -21,18 +21,18 @@
2121//!
2222//! [c]: https://rust-lang.github.io/chalk/book/canonical_queries/canonicalization.html
2323
24use std::collections::hash_map::Entry;
25
2426use rustc_data_structures::fx::FxHashMap;
2527use rustc_data_structures::sync::Lock;
2628use rustc_macros::{HashStable, TypeFoldable, TypeVisitable};
2729pub use rustc_type_ir as ir;
2830pub use rustc_type_ir::{CanonicalTyVarKind, CanonicalVarKind};
2931use smallvec::SmallVec;
30use std::collections::hash_map::Entry;
3132
3233use crate::infer::MemberConstraint;
3334use crate::mir::ConstraintCategory;
34use crate::ty::GenericArg;
35use crate::ty::{self, List, Ty, TyCtxt, TypeFlags, TypeVisitableExt};
35use crate::ty::{self, GenericArg, List, Ty, TyCtxt, TypeFlags, TypeVisitableExt};
3636
3737pub type Canonical<'tcx, V> = ir::Canonical<TyCtxt<'tcx>, V>;
3838pub type CanonicalVarInfo<'tcx> = ir::CanonicalVarInfo<TyCtxt<'tcx>>;
compiler/rustc_middle/src/infer/mod.rs+2-2
......@@ -1,12 +1,12 @@
11pub mod canonical;
22pub mod unify_key;
33
4use crate::ty::Region;
5use crate::ty::{OpaqueTypeKey, Ty};
64use rustc_data_structures::sync::Lrc;
75use rustc_macros::{HashStable, TypeFoldable, TypeVisitable};
86use rustc_span::Span;
97
8use crate::ty::{OpaqueTypeKey, Region, Ty};
9
1010/// Requires that `region` must be equal to one of the regions in `choice_regions`.
1111/// We often denote this using the syntax:
1212///
compiler/rustc_middle/src/infer/unify_key.rs+5-3
......@@ -1,9 +1,11 @@
1use crate::ty::{self, Ty, TyCtxt};
1use std::cmp;
2use std::marker::PhantomData;
3
24use rustc_data_structures::unify::{NoError, UnifyKey, UnifyValue};
35use rustc_span::def_id::DefId;
46use rustc_span::Span;
5use std::cmp;
6use std::marker::PhantomData;
7
8use crate::ty::{self, Ty, TyCtxt};
79
810pub trait ToType {
911 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;
55use rustc_errors::{Diag, MultiSpan};
66use rustc_hir::{HirId, ItemLocalId};
77use rustc_macros::HashStable;
8use rustc_session::lint::{
9 builtin::{self, FORBIDDEN_LINT_GROUPS},
10 FutureIncompatibilityReason, Level, Lint, LintId,
11};
8use rustc_session::lint::builtin::{self, FORBIDDEN_LINT_GROUPS};
9use rustc_session::lint::{FutureIncompatibilityReason, Level, Lint, LintId};
1210use rustc_session::Session;
1311use rustc_span::hygiene::{ExpnKind, MacroKind};
1412use rustc_span::{symbol, DesugaringKind, Span, Symbol, DUMMY_SP};
compiler/rustc_middle/src/metadata.rs+2-2
......@@ -1,11 +1,11 @@
1use crate::ty;
2
31use rustc_hir::def::Res;
42use rustc_macros::{HashStable, TyDecodable, TyEncodable};
53use rustc_span::def_id::DefId;
64use rustc_span::symbol::Ident;
75use smallvec::SmallVec;
86
7use crate::ty;
8
99/// A simplified version of `ImportKind` from resolve.
1010/// `DefId`s here correspond to `use` and `extern crate` items themselves, not their targets.
1111#[derive(Clone, Copy, Debug, TyEncodable, TyDecodable, HashStable)]
compiler/rustc_middle/src/middle/codegen_fn_attrs.rs+2-1
......@@ -1,10 +1,11 @@
1use crate::mir::mono::Linkage;
21use rustc_attr::{InlineAttr, InstructionSetAttr, OptimizeAttr};
32use rustc_macros::{HashStable, TyDecodable, TyEncodable};
43use rustc_span::symbol::Symbol;
54use rustc_target::abi::Align;
65use rustc_target::spec::SanitizerSet;
76
7use crate::mir::mono::Linkage;
8
89#[derive(Clone, TyEncodable, TyDecodable, HashStable, Debug)]
910pub struct CodegenFnAttrs {
1011 pub flags: CodegenFnAttrFlags,
compiler/rustc_middle/src/middle/debugger_visualizer.rs+2-1
......@@ -1,6 +1,7 @@
1use std::path::PathBuf;
2
13use rustc_data_structures::sync::Lrc;
24use rustc_macros::{Decodable, Encodable, HashStable};
3use std::path::PathBuf;
45
56#[derive(HashStable)]
67#[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 @@
1use crate::ty::GenericArgsRef;
2use crate::ty::{self, Ty, TyCtxt};
31use rustc_hir::def_id::{DefId, LOCAL_CRATE};
42use rustc_macros::{Decodable, Encodable, HashStable, TyDecodable, TyEncodable};
53
4use crate::ty::{self, GenericArgsRef, Ty, TyCtxt};
5
66/// The SymbolExportLevel of a symbols specifies from which kinds of crates
77/// the symbol will be exported. `C` symbols will be exported from any
88/// kind of crate, including cdylibs which export very few things.
compiler/rustc_middle/src/middle/lang_items.rs+2-2
......@@ -7,13 +7,13 @@
77//! * Traits that represent operators; e.g., `Add`, `Sub`, `Index`.
88//! * Functions called by the compiler itself.
99
10use crate::ty::{self, TyCtxt};
11
1210use rustc_hir::def_id::DefId;
1311use rustc_hir::LangItem;
1412use rustc_span::Span;
1513use rustc_target::spec::PanicStrategy;
1614
15use crate::ty::{self, TyCtxt};
16
1717impl<'tcx> TyCtxt<'tcx> {
1818 /// Returns the `DefId` for a given `LangItem`.
1919 /// If not found, fatally aborts compilation.
compiler/rustc_middle/src/middle/limits.rs+5-5
......@@ -8,14 +8,14 @@
88//! this via an attribute on the crate like `#![recursion_limit="22"]`. This pass
99//! just peeks and looks for that attribute.
1010
11use crate::error::LimitInvalid;
12use crate::query::Providers;
11use std::num::IntErrorKind;
12
1313use rustc_ast::Attribute;
14use rustc_session::Session;
15use rustc_session::{Limit, Limits};
14use rustc_session::{Limit, Limits, Session};
1615use rustc_span::symbol::{sym, Symbol};
1716
18use std::num::IntErrorKind;
17use crate::error::LimitInvalid;
18use crate::query::Providers;
1919
2020pub fn provide(providers: &mut Providers) {
2121 providers.limits = |tcx, ()| Limits {
compiler/rustc_middle/src/middle/mod.rs+2-1
......@@ -6,7 +6,8 @@ pub mod lang_items;
66pub mod lib_features {
77 use rustc_data_structures::unord::UnordMap;
88 use rustc_macros::{HashStable, TyDecodable, TyEncodable};
9 use rustc_span::{symbol::Symbol, Span};
9 use rustc_span::symbol::Symbol;
10 use rustc_span::Span;
1011
1112 #[derive(Copy, Clone, Debug, PartialEq, Eq)]
1213 #[derive(HashStable, TyEncodable, TyDecodable)]
compiler/rustc_middle/src/middle/privacy.rs+4-2
......@@ -2,14 +2,16 @@
22//! outside their scopes. This pass will also generate a set of exported items
33//! which are available for use externally when compiled as a library.
44
5use crate::ty::{TyCtxt, Visibility};
5use std::hash::Hash;
6
67use rustc_data_structures::fx::{FxIndexMap, IndexEntry};
78use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
89use rustc_hir::def::DefKind;
910use rustc_macros::HashStable;
1011use rustc_query_system::ich::StableHashingContext;
1112use rustc_span::def_id::{LocalDefId, CRATE_DEF_ID};
12use std::hash::Hash;
13
14use crate::ty::{TyCtxt, Visibility};
1315
1416/// Represents the levels of effective visibility an item can have.
1517///
compiler/rustc_middle/src/middle/region.rs+4-3
......@@ -6,7 +6,9 @@
66//!
77//! [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/borrow_check.html
88
9use crate::ty::TyCtxt;
9use std::fmt;
10use std::ops::Deref;
11
1012use rustc_data_structures::fx::FxIndexMap;
1113use rustc_data_structures::unord::UnordMap;
1214use rustc_hir as hir;
......@@ -15,8 +17,7 @@ use rustc_macros::{HashStable, TyDecodable, TyEncodable};
1517use rustc_span::{Span, DUMMY_SP};
1618use tracing::debug;
1719
18use std::fmt;
19use std::ops::Deref;
20use crate::ty::TyCtxt;
2021
2122/// Represents a statically-describable scope that can be used to
2223/// bound the lifetime/region for values.
compiler/rustc_middle/src/middle/resolve_bound_vars.rs+2-2
......@@ -1,13 +1,13 @@
11//! Name resolution for lifetimes and late-bound type and const variables: type declarations.
22
3use crate::ty;
4
53use rustc_data_structures::fx::FxIndexMap;
64use rustc_errors::ErrorGuaranteed;
75use rustc_hir::def_id::DefId;
86use rustc_hir::{ItemLocalId, OwnerId};
97use rustc_macros::{Decodable, Encodable, HashStable, TyDecodable, TyEncodable};
108
9use crate::ty;
10
1111#[derive(Clone, Copy, PartialEq, Eq, Hash, TyEncodable, TyDecodable, Debug, HashStable)]
1212pub enum ResolvedArg {
1313 StaticLifetime,
compiler/rustc_middle/src/middle/stability.rs+4-3
......@@ -1,9 +1,8 @@
11//! A pass that annotates every item and method with its stability level,
22//! propagating default levels lexically from parent to children ast nodes.
33
4pub use self::StabilityLevel::*;
4use std::num::NonZero;
55
6use crate::ty::{self, TyCtxt};
76use rustc_ast::NodeId;
87use rustc_attr::{
98 self as attr, ConstStability, DefaultBodyStability, DeprecatedSince, Deprecation, Stability,
......@@ -22,9 +21,11 @@ use rustc_session::parse::feature_err_issue;
2221use rustc_session::Session;
2322use rustc_span::symbol::{sym, Symbol};
2423use rustc_span::Span;
25use std::num::NonZero;
2624use tracing::debug;
2725
26pub use self::StabilityLevel::*;
27use crate::ty::{self, TyCtxt};
28
2829#[derive(PartialEq, Clone, Copy, Debug)]
2930pub enum StabilityLevel {
3031 Unstable,
compiler/rustc_middle/src/mir/basic_blocks.rs+3-3
......@@ -1,6 +1,3 @@
1use crate::mir::traversal::Postorder;
2use crate::mir::{BasicBlock, BasicBlockData, Terminator, TerminatorKind, START_BLOCK};
3
41use rustc_data_structures::fx::FxHashMap;
52use rustc_data_structures::graph;
63use rustc_data_structures::graph::dominators::{dominators, Dominators};
......@@ -11,6 +8,9 @@ use rustc_macros::{HashStable, TyDecodable, TyEncodable, TypeFoldable, TypeVisit
118use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
129use smallvec::SmallVec;
1310
11use crate::mir::traversal::Postorder;
12use crate::mir::{BasicBlock, BasicBlockData, Terminator, TerminatorKind, START_BLOCK};
13
1414#[derive(Clone, TyEncodable, TyDecodable, Debug, HashStable, TypeFoldable, TypeVisitable)]
1515pub struct BasicBlocks<'tcx> {
1616 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};
22
33use rustc_hir::def_id::DefId;
44use rustc_macros::{HashStable, Lift, TyDecodable, TyEncodable, TypeFoldable, TypeVisitable};
5use rustc_session::{config::RemapPathScopeComponents, RemapFileNameExt};
5use rustc_session::config::RemapPathScopeComponents;
6use rustc_session::RemapFileNameExt;
67use rustc_span::{Span, DUMMY_SP};
78use rustc_target::abi::{HasDataLayout, Size};
89
910use crate::mir::interpret::{alloc_range, AllocId, ConstAllocation, ErrorHandled, Scalar};
1011use crate::mir::{pretty_print_const_value, Promoted};
11use crate::ty::print::with_no_trimmed_paths;
12use crate::ty::GenericArgsRef;
13use crate::ty::ScalarInt;
14use crate::ty::{self, print::pretty_print_const, Ty, TyCtxt};
12use crate::ty::print::{pretty_print_const, with_no_trimmed_paths};
13use crate::ty::{self, GenericArgsRef, ScalarInt, Ty, TyCtxt};
1514
1615///////////////////////////////////////////////////////////////////////////
1716/// Evaluated Constants
compiler/rustc_middle/src/mir/coverage.rs+2-2
......@@ -1,11 +1,11 @@
11//! Metadata from source code coverage analysis and instrumentation.
22
3use std::fmt::{self, Debug, Formatter};
4
35use rustc_index::IndexVec;
46use rustc_macros::{HashStable, TyDecodable, TyEncodable, TypeFoldable, TypeVisitable};
57use rustc_span::{Span, Symbol};
68
7use std::fmt::{self, Debug, Formatter};
8
99rustc_index::newtype_index! {
1010 /// Used by [`CoverageKind::BlockMarker`] to mark blocks during THIR-to-MIR
1111 /// lowering, so that those blocks can be identified later.
compiler/rustc_middle/src/mir/generic_graphviz.rs+2-1
......@@ -1,7 +1,8 @@
1use std::io::{self, Write};
2
13use rustc_data_structures::graph::{self, iterate};
24use rustc_graphviz as dot;
35use rustc_middle::ty::TyCtxt;
4use std::io::{self, Write};
56
67pub struct GraphvizWriter<
78 'a,
compiler/rustc_middle/src/mir/graphviz.rs+2-1
......@@ -1,7 +1,8 @@
1use std::io::{self, Write};
2
13use gsgdt::GraphvizSettings;
24use rustc_graphviz as dot;
35use rustc_middle::mir::*;
4use std::io::{self, Write};
56
67use super::generic_graph::mir_fn_to_generic_graph;
78use super::pretty::dump_mir_def_ids;
compiler/rustc_middle/src/mir/interpret/allocation.rs+4-8
......@@ -4,14 +4,14 @@ mod init_mask;
44mod provenance_map;
55
66use std::borrow::Cow;
7use std::fmt;
8use std::hash;
97use std::hash::Hash;
108use std::ops::{Deref, DerefMut, Range};
11use std::ptr;
9use std::{fmt, hash, ptr};
1210
1311use either::{Left, Right};
14
12use init_mask::*;
13pub use init_mask::{InitChunk, InitChunkIter};
14use provenance_map::*;
1515use rustc_ast::Mutability;
1616use rustc_data_structures::intern::Interned;
1717use rustc_macros::{HashStable, TyDecodable, TyEncodable};
......@@ -23,10 +23,6 @@ use super::{
2323 ScalarSizeMismatch, UndefinedBehaviorInfo, UnsupportedOpInfo,
2424};
2525use crate::ty;
26use init_mask::*;
27use provenance_map::*;
28
29pub use init_mask::{InitChunk, InitChunkIter};
3026
3127/// Functionality required for the bytes of an `Allocation`.
3228pub 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 @@
11#[cfg(test)]
22mod tests;
33
4use std::hash;
5use std::iter;
64use std::ops::Range;
5use std::{hash, iter};
76
87use rustc_macros::{HashStable, TyDecodable, TyEncodable};
98use rustc_serialize::{Decodable, Encodable};
compiler/rustc_middle/src/mir/interpret/allocation/provenance_map.rs+2-1
......@@ -3,13 +3,14 @@
33
44use std::cmp;
55
6use super::{alloc_range, AllocError, AllocRange, AllocResult, CtfeProvenance, Provenance};
76use rustc_data_structures::sorted_map::SortedMap;
87use rustc_macros::HashStable;
98use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
109use rustc_target::abi::{HasDataLayout, Size};
1110use tracing::trace;
1211
12use super::{alloc_range, AllocError, AllocRange, AllocResult, CtfeProvenance, Provenance};
13
1314/// Stores the provenance information of pointers stored in memory.
1415#[derive(Clone, PartialEq, Eq, Hash, Debug)]
1516#[derive(HashStable)]
compiler/rustc_middle/src/mir/interpret/error.rs+5-5
......@@ -1,19 +1,19 @@
1use std::any::Any;
2use std::backtrace::Backtrace;
13use std::borrow::Cow;
2use std::{any::Any, backtrace::Backtrace, fmt};
4use std::fmt;
35
46use either::Either;
5
67use rustc_ast_ir::Mutability;
78use rustc_data_structures::sync::Lock;
89use rustc_errors::{DiagArgName, DiagArgValue, DiagMessage, ErrorGuaranteed, IntoDiagArg};
910use rustc_macros::{HashStable, TyDecodable, TyEncodable};
1011use rustc_session::CtfeBacktrace;
11use rustc_span::Symbol;
12use rustc_span::{def_id::DefId, Span, DUMMY_SP};
12use rustc_span::def_id::DefId;
13use rustc_span::{Span, Symbol, DUMMY_SP};
1314use rustc_target::abi::{call, Align, Size, VariantIdx, WrappingRange};
1415
1516use super::{AllocId, AllocRange, ConstAllocation, Pointer, Scalar};
16
1717use crate::error;
1818use crate::mir::{ConstAlloc, ConstValue};
1919use crate::ty::{self, layout, tls, Ty, TyCtxt, ValTree};
compiler/rustc_middle/src/mir/interpret/mod.rs+14-21
......@@ -8,12 +8,9 @@ mod pointer;
88mod queries;
99mod value;
1010
11use std::fmt;
12use std::io;
1311use std::io::{Read, Write};
1412use std::num::NonZero;
15
16use tracing::{debug, trace};
13use std::{fmt, io};
1714
1815use rustc_ast::LitKind;
1916use rustc_attr::InlineAttr;
......@@ -25,20 +22,7 @@ use rustc_macros::{HashStable, TyDecodable, TyEncodable, TypeFoldable, TypeVisit
2522use rustc_middle::ty::print::with_no_trimmed_paths;
2623use rustc_serialize::{Decodable, Encodable};
2724use rustc_target::abi::{AddressSpace, Endian, HasDataLayout};
28
29use crate::mir;
30use crate::ty::codec::{TyDecoder, TyEncoder};
31use crate::ty::GenericArgKind;
32use crate::ty::{self, Instance, Ty, TyCtxt};
33
34pub 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};
25use tracing::{debug, trace};
4226// Also make the error macros available from this module.
4327pub use {
4428 err_exhaust, err_inval, err_machine_stop, err_ub, err_ub_custom, err_ub_format, err_unsup,
......@@ -46,14 +30,23 @@ pub use {
4630 throw_ub_format, throw_unsup, throw_unsup_format,
4731};
4832
49pub use self::value::Scalar;
50
5133pub use self::allocation::{
5234 alloc_range, AllocBytes, AllocError, AllocRange, AllocResult, Allocation, ConstAllocation,
5335 InitChunk, InitChunkIter,
5436};
55
37pub 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};
5645pub use self::pointer::{CtfeProvenance, Pointer, PointerArithmetic, Provenance};
46pub use self::value::Scalar;
47use crate::mir;
48use crate::ty::codec::{TyDecoder, TyEncoder};
49use crate::ty::{self, GenericArgKind, Instance, Ty, TyCtxt};
5750
5851/// Uniquely identifies one of the following:
5952/// - A constant
compiler/rustc_middle/src/mir/interpret/pointer.rs+3-2
......@@ -1,10 +1,11 @@
1use super::{AllocId, InterpResult};
1use std::fmt;
2use std::num::NonZero;
23
34use rustc_data_structures::static_assert_size;
45use rustc_macros::{HashStable, TyDecodable, TyEncodable};
56use rustc_target::abi::{HasDataLayout, Size};
67
7use std::{fmt, num::NonZero};
8use super::{AllocId, InterpResult};
89
910////////////////////////////////////////////////////////////////////////////////
1011// Pointer arithmetic
compiler/rustc_middle/src/mir/interpret/queries.rs+7-8
......@@ -1,17 +1,16 @@
1use rustc_hir::def::DefKind;
2use rustc_hir::def_id::DefId;
3use rustc_session::lint;
4use rustc_span::{Span, DUMMY_SP};
5use tracing::{debug, instrument};
6
17use super::{
28 ErrorHandled, EvalToAllocationRawResult, EvalToConstValueResult, EvalToValTreeResult, GlobalId,
39};
4
510use crate::mir;
611use crate::query::TyCtxtEnsure;
712use crate::ty::visit::TypeVisitableExt;
8use crate::ty::GenericArgs;
9use crate::ty::{self, TyCtxt};
10use rustc_hir::def::DefKind;
11use rustc_hir::def_id::DefId;
12use rustc_session::lint;
13use rustc_span::{Span, DUMMY_SP};
14use tracing::{debug, instrument};
13use crate::ty::{self, GenericArgs, TyCtxt};
1514
1615impl<'tcx> TyCtxt<'tcx> {
1716 /// 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 @@
11use std::fmt;
22
33use either::{Either, Left, Right};
4
5use rustc_apfloat::{
6 ieee::{Double, Half, Quad, Single},
7 Float,
8};
4use rustc_apfloat::ieee::{Double, Half, Quad, Single};
5use rustc_apfloat::Float;
96use rustc_macros::{HashStable, TyDecodable, TyEncodable};
107use rustc_target::abi::{HasDataLayout, Size};
118
12use crate::ty::ScalarInt;
13
149use super::{
1510 AllocId, CtfeProvenance, InterpResult, Pointer, PointerArithmetic, Provenance,
1611 ScalarSizeMismatch,
1712};
13use crate::ty::ScalarInt;
1814
1915/// A `Scalar` represents an immediate, primitive value existing outside of a
2016/// `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 @@
22//!
33//! [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/mir/index.html
44
5use crate::mir::interpret::{AllocRange, Scalar};
6use crate::mir::visit::MirVisitable;
7use crate::ty::codec::{TyDecoder, TyEncoder};
8use crate::ty::fold::{FallibleTypeFolder, TypeFoldable};
9use crate::ty::print::{pretty_print_const, with_no_trimmed_paths};
10use crate::ty::print::{FmtPrinter, Printer};
11use crate::ty::visit::TypeVisitableExt;
12use crate::ty::{self, List, Ty, TyCtxt};
13use crate::ty::{AdtDef, Instance, InstanceKind, UserTypeAnnotationIndex};
14use crate::ty::{GenericArg, GenericArgsRef};
5use std::borrow::Cow;
6use std::cell::RefCell;
7use std::collections::hash_map::Entry;
8use std::fmt::{self, Debug, Formatter};
9use std::ops::{Index, IndexMut};
10use std::{iter, mem};
1511
12pub use basic_blocks::BasicBlocks;
13use either::Either;
14use polonius_engine::Atom;
15pub use rustc_ast::Mutability;
1616use rustc_data_structures::captures::Captures;
17use rustc_data_structures::fx::{FxHashMap, FxHashSet};
18use rustc_data_structures::graph::dominators::Dominators;
1719use rustc_errors::{DiagArgName, DiagArgValue, DiagMessage, ErrorGuaranteed, IntoDiagArg};
1820use rustc_hir::def::{CtorKind, Namespace};
1921use rustc_hir::def_id::{DefId, CRATE_DEF_ID};
2022use rustc_hir::{
2123 self as hir, BindingMode, ByRef, CoroutineDesugaring, CoroutineKind, HirId, ImplicitSelfKind,
2224};
23use rustc_macros::{HashStable, TyDecodable, TyEncodable, TypeFoldable, TypeVisitable};
24use rustc_session::Session;
25use rustc_span::source_map::Spanned;
26use rustc_target::abi::{FieldIdx, VariantIdx};
27
28use polonius_engine::Atom;
29pub use rustc_ast::Mutability;
30use rustc_data_structures::fx::FxHashMap;
31use rustc_data_structures::fx::FxHashSet;
32use rustc_data_structures::graph::dominators::Dominators;
3325use rustc_index::bit_set::BitSet;
3426use rustc_index::{Idx, IndexSlice, IndexVec};
27use rustc_macros::{HashStable, TyDecodable, TyEncodable, TypeFoldable, TypeVisitable};
3528use rustc_serialize::{Decodable, Encodable};
29use rustc_session::Session;
30use rustc_span::source_map::Spanned;
3631use rustc_span::symbol::Symbol;
3732use rustc_span::{Span, DUMMY_SP};
38
39use either::Either;
33use rustc_target::abi::{FieldIdx, VariantIdx};
4034use tracing::trace;
4135
42use std::borrow::Cow;
43use std::cell::RefCell;
44use std::collections::hash_map::Entry;
45use std::fmt::{self, Debug, Formatter};
46use std::ops::{Index, IndexMut};
47use std::{iter, mem};
48
4936pub use self::query::*;
5037use self::visit::TyContext;
51pub use basic_blocks::BasicBlocks;
38use crate::mir::interpret::{AllocRange, Scalar};
39use crate::mir::visit::MirVisitable;
40use crate::ty::codec::{TyDecoder, TyEncoder};
41use crate::ty::fold::{FallibleTypeFolder, TypeFoldable};
42use crate::ty::print::{pretty_print_const, with_no_trimmed_paths, FmtPrinter, Printer};
43use crate::ty::visit::TypeVisitableExt;
44use crate::ty::{
45 self, AdtDef, GenericArg, GenericArgsRef, Instance, InstanceKind, List, Ty, TyCtxt,
46 UserTypeAnnotationIndex,
47};
5248
5349mod basic_blocks;
5450mod consts;
......@@ -70,17 +66,18 @@ pub mod traversal;
7066mod type_foldable;
7167pub mod visit;
7268
73pub use self::generic_graph::graphviz_safe_def_name;
74pub use self::graphviz::write_mir_graphviz;
75pub use self::pretty::{
76 create_dump_file, display_allocation, dump_enabled, dump_mir, write_mir_pretty, PassWhere,
77};
7869pub use consts::*;
7970use pretty::pretty_print_const_value;
8071pub use statement::*;
8172pub use syntax::*;
8273pub use terminator::*;
8374
75pub use self::generic_graph::graphviz_safe_def_name;
76pub use self::graphviz::write_mir_graphviz;
77pub use self::pretty::{
78 create_dump_file, display_allocation, dump_enabled, dump_mir, write_mir_pretty, PassWhere,
79};
80
8481/// Types for locals
8582pub type LocalDecls<'tcx> = IndexSlice<Local, LocalDecl<'tcx>>;
8683
......@@ -1815,8 +1812,9 @@ impl DefLocation {
18151812// Some nodes are used a lot. Make sure they don't unintentionally get bigger.
18161813#[cfg(target_pointer_width = "64")]
18171814mod size_asserts {
1818 use super::*;
18191815 use rustc_data_structures::static_assert_size;
1816
1817 use super::*;
18201818 // tidy-alphabetical-start
18211819 static_assert_size!(BasicBlockData<'_>, 128);
18221820 static_assert_size!(LocalDecl<'_>, 40);
compiler/rustc_middle/src/mir/mono.rs+7-7
......@@ -1,9 +1,8 @@
1use crate::dep_graph::{DepNode, WorkProduct, WorkProductId};
2use crate::ty::{GenericArgs, Instance, InstanceKind, SymbolName, TyCtxt};
1use std::fmt;
2use std::hash::Hash;
3
34use rustc_attr::InlineAttr;
4use rustc_data_structures::base_n::BaseNString;
5use rustc_data_structures::base_n::ToBaseN;
6use rustc_data_structures::base_n::CASE_INSENSITIVE;
5use rustc_data_structures::base_n::{BaseNString, ToBaseN, CASE_INSENSITIVE};
76use rustc_data_structures::fingerprint::Fingerprint;
87use rustc_data_structures::fx::FxIndexMap;
98use rustc_data_structures::stable_hasher::{Hash128, HashStable, StableHasher, ToStableHashKey};
......@@ -16,10 +15,11 @@ use rustc_query_system::ich::StableHashingContext;
1615use rustc_session::config::OptLevel;
1716use rustc_span::symbol::Symbol;
1817use rustc_span::Span;
19use std::fmt;
20use std::hash::Hash;
2118use tracing::debug;
2219
20use crate::dep_graph::{DepNode, WorkProduct, WorkProductId};
21use crate::ty::{GenericArgs, Instance, InstanceKind, SymbolName, TyCtxt};
22
2323/// Describes how a monomorphization will be instantiated in object files.
2424#[derive(PartialEq)]
2525pub enum InstantiationMode {
compiler/rustc_middle/src/mir/pretty.rs+3-3
......@@ -4,9 +4,6 @@ use std::fs;
44use std::io::{self, Write as _};
55use std::path::{Path, PathBuf};
66
7use crate::mir::interpret::ConstAllocation;
8
9use super::graphviz::write_mir_fn_graphviz;
107use rustc_ast::{InlineAsmOptions, InlineAsmTemplatePiece};
118use rustc_middle::mir::interpret::{
129 alloc_range, read_target_uint, AllocBytes, AllocId, Allocation, GlobalAlloc, Pointer,
......@@ -17,6 +14,9 @@ use rustc_middle::mir::*;
1714use rustc_target::abi::Size;
1815use tracing::trace;
1916
17use super::graphviz::write_mir_fn_graphviz;
18use crate::mir::interpret::ConstAllocation;
19
2020const INDENT: &str = " ";
2121/// Alignment for lining up comments following MIR statements
2222pub(crate) const ALIGN: usize = 40;
compiler/rustc_middle/src/mir/query.rs+5-4
......@@ -1,7 +1,8 @@
11//! Values computed by queries that use MIR.
22
3use crate::mir;
4use crate::ty::{self, CoroutineArgsExt, OpaqueHiddenType, Ty, TyCtxt};
3use std::cell::Cell;
4use std::fmt::{self, Debug};
5
56use derive_where::derive_where;
67use rustc_data_structures::fx::FxIndexMap;
78use rustc_errors::ErrorGuaranteed;
......@@ -13,10 +14,10 @@ use rustc_span::symbol::Symbol;
1314use rustc_span::Span;
1415use rustc_target::abi::{FieldIdx, VariantIdx};
1516use smallvec::SmallVec;
16use std::cell::Cell;
17use std::fmt::{self, Debug};
1817
1918use super::{ConstValue, SourceInfo};
19use crate::mir;
20use crate::ty::{self, CoroutineArgsExt, OpaqueHiddenType, Ty, TyCtxt};
2021
2122rustc_index::newtype_index! {
2223 #[derive(HashStable)]
compiler/rustc_middle/src/mir/statement.rs+2-1
......@@ -1,6 +1,7 @@
11//! Functionality for statements, operands, places, and things that appear in them.
22
3use super::{interpret::GlobalAlloc, *};
3use super::interpret::GlobalAlloc;
4use super::*;
45
56///////////////////////////////////////////////////////////////////////////
67// Statements
compiler/rustc_middle/src/mir/syntax.rs+11-15
......@@ -3,31 +3,26 @@
33//! This is in a dedicated file so that changes to this file can be reviewed more carefully.
44//! The intention is that this file only contains datatype declarations, no code.
55
6use super::{BasicBlock, Const, Local, UserTypeProjection};
7
8use crate::mir::coverage::CoverageKind;
9use crate::traits::Reveal;
10use crate::ty::adjustment::PointerCoercion;
11use crate::ty::GenericArgsRef;
12use crate::ty::{self, List, Ty};
13use crate::ty::{Region, UserTypeAnnotationIndex};
14
15use rustc_ast::{InlineAsmOptions, InlineAsmTemplatePiece};
6use rustc_ast::{InlineAsmOptions, InlineAsmTemplatePiece, Mutability};
167use rustc_data_structures::packed::Pu128;
178use rustc_hir::def_id::DefId;
189use rustc_hir::CoroutineKind;
1910use rustc_index::IndexVec;
2011use rustc_macros::{HashStable, TyDecodable, TyEncodable, TypeFoldable, TypeVisitable};
21use rustc_span::source_map::Spanned;
22use rustc_target::abi::{FieldIdx, VariantIdx};
23
24use rustc_ast::Mutability;
2512use rustc_span::def_id::LocalDefId;
13use rustc_span::source_map::Spanned;
2614use rustc_span::symbol::Symbol;
2715use rustc_span::Span;
16use rustc_target::abi::{FieldIdx, VariantIdx};
2817use rustc_target::asm::InlineAsmRegOrRegClass;
2918use smallvec::SmallVec;
3019
20use super::{BasicBlock, Const, Local, UserTypeProjection};
21use crate::mir::coverage::CoverageKind;
22use crate::traits::Reveal;
23use crate::ty::adjustment::PointerCoercion;
24use crate::ty::{self, GenericArgsRef, List, Region, Ty, UserTypeAnnotationIndex};
25
3126/// Represents the "flavors" of MIR.
3227///
3328/// All flavors of MIR use the same data structure, but there are some important differences. These
......@@ -1583,8 +1578,9 @@ pub enum BinOp {
15831578// Some nodes are used a lot. Make sure they don't unintentionally get bigger.
15841579#[cfg(target_pointer_width = "64")]
15851580mod size_asserts {
1586 use super::*;
15871581 use rustc_data_structures::static_assert_size;
1582
1583 use super::*;
15881584 // tidy-alphabetical-start
15891585 static_assert_size!(AggregateKind<'_>, 32);
15901586 static_assert_size!(Operand<'_>, 24);
compiler/rustc_middle/src/mir/tcx.rs+2-1
......@@ -3,10 +3,11 @@
33 * building is complete.
44 */
55
6use crate::mir::*;
76use rustc_hir as hir;
87use tracing::{debug, instrument};
98
9use crate::mir::*;
10
1011#[derive(Copy, Clone, Debug, TypeFoldable, TypeVisitable)]
1112pub struct PlaceTy<'tcx> {
1213 pub ty: Ty<'tcx>,
compiler/rustc_middle/src/mir/terminator.rs+6-6
......@@ -1,14 +1,13 @@
11//! Functionality for terminators and helper types that appear in terminators.
22
3use rustc_hir::LangItem;
4use smallvec::{smallvec, SmallVec};
3use std::slice;
54
6use super::TerminatorKind;
75use rustc_data_structures::packed::Pu128;
6use rustc_hir::LangItem;
87use rustc_macros::{HashStable, TyDecodable, TyEncodable, TypeFoldable, TypeVisitable};
9use std::slice;
8use smallvec::{smallvec, SmallVec};
109
11use super::*;
10use super::{TerminatorKind, *};
1211
1312impl SwitchTargets {
1413 /// Creates switch targets from an iterator of values and target blocks.
......@@ -295,9 +294,10 @@ impl<O> AssertKind<O> {
295294 /// Note that we deliberately show more details here than we do at runtime, such as the actual
296295 /// numbers that overflowed -- it is much easier to do so here than at runtime.
297296 pub fn diagnostic_message(&self) -> DiagMessage {
298 use crate::fluent_generated::*;
299297 use AssertKind::*;
300298
299 use crate::fluent_generated::*;
300
301301 match self {
302302 BoundsCheck { .. } => middle_bounds_check,
303303 Overflow(BinOp::Shl, _, _) => middle_assert_shl_overflow,
compiler/rustc_middle/src/query/erase.rs+4-4
......@@ -1,10 +1,10 @@
1use crate::mir;
1use std::intrinsics::transmute_unchecked;
2use std::mem::MaybeUninit;
3
24use crate::query::CyclePlaceholder;
3use crate::traits;
45use crate::ty::adjustment::CoerceUnsizedInfo;
56use crate::ty::{self, Ty};
6use std::intrinsics::transmute_unchecked;
7use std::mem::MaybeUninit;
7use crate::{mir, traits};
88
99#[derive(Copy, Clone)]
1010pub struct Erased<T: Copy> {
compiler/rustc_middle/src/query/keys.rs+6-7
......@@ -1,12 +1,5 @@
11//! Defines the set of legal keys that can be used in queries.
22
3use crate::infer::canonical::Canonical;
4use crate::mir;
5use crate::traits;
6use crate::ty::fast_reject::SimplifiedType;
7use crate::ty::layout::{TyAndLayout, ValidityRequirement};
8use crate::ty::{self, Ty, TyCtxt};
9use crate::ty::{GenericArg, GenericArgsRef};
103use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, LocalModDefId, ModDefId, LOCAL_CRATE};
114use rustc_hir::hir_id::{HirId, OwnerId};
125use rustc_query_system::query::{DefIdCache, DefaultCache, SingleCache, VecCache};
......@@ -14,6 +7,12 @@ use rustc_span::symbol::{Ident, Symbol};
147use rustc_span::{Span, DUMMY_SP};
158use rustc_target::abi;
169
10use crate::infer::canonical::Canonical;
11use crate::ty::fast_reject::SimplifiedType;
12use crate::ty::layout::{TyAndLayout, ValidityRequirement};
13use crate::ty::{self, GenericArg, GenericArgsRef, Ty, TyCtxt};
14use crate::{mir, traits};
15
1716/// Placeholder for `CrateNum`'s "local" counterpart
1817#[derive(Copy, Clone, Debug)]
1918pub struct LocalCrate;
compiler/rustc_middle/src/query/mod.rs+46-53
......@@ -6,7 +6,44 @@
66
77#![allow(unused_parens)]
88
9use crate::dep_graph;
9use std::mem;
10use std::ops::Deref;
11use std::path::PathBuf;
12use std::sync::Arc;
13
14use rustc_arena::TypedArena;
15use rustc_ast::expand::allocator::AllocatorKind;
16use rustc_ast::expand::StrippedCfgItem;
17use rustc_data_structures::fingerprint::Fingerprint;
18use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
19use rustc_data_structures::steal::Steal;
20use rustc_data_structures::svh::Svh;
21use rustc_data_structures::sync::Lrc;
22use rustc_data_structures::unord::{UnordMap, UnordSet};
23use rustc_errors::ErrorGuaranteed;
24use rustc_hir::def::{DefKind, DocLinkResMap};
25use rustc_hir::def_id::{
26 CrateNum, DefId, DefIdMap, DefIdSet, LocalDefId, LocalDefIdMap, LocalDefIdSet, LocalModDefId,
27};
28use rustc_hir::lang_items::{LangItem, LanguageItems};
29use rustc_hir::{Crate, ItemLocalId, ItemLocalMap, TraitCandidate};
30use rustc_index::IndexVec;
31use rustc_macros::rustc_queries;
32use rustc_query_system::ich::StableHashingContext;
33use rustc_query_system::query::{try_get_cached, QueryCache, QueryMode, QueryState};
34use rustc_session::config::{EntryFnType, OptLevel, OutputFilenames, SymbolManglingVersion};
35use rustc_session::cstore::{
36 CrateDepKind, CrateSource, ExternCrate, ForeignModule, LinkagePreference, NativeLib,
37};
38use rustc_session::lint::LintExpectationId;
39use rustc_session::Limits;
40use rustc_span::def_id::LOCAL_CRATE;
41use rustc_span::symbol::Symbol;
42use rustc_span::{Span, DUMMY_SP};
43use rustc_target::abi;
44use rustc_target::spec::PanicStrategy;
45use {rustc_ast as ast, rustc_attr as attr, rustc_hir as hir};
46
1047use crate::infer::canonical::{self, Canonical};
1148use crate::lint::LintExpectation;
1249use crate::metadata::ModChild;
......@@ -17,79 +54,35 @@ use crate::middle::lib_features::LibFeatures;
1754use crate::middle::privacy::EffectiveVisibilities;
1855use crate::middle::resolve_bound_vars::{ObjectLifetimeDefault, ResolveBoundVars, ResolvedArg};
1956use crate::middle::stability::{self, DeprecationEntry};
20use crate::mir;
21use crate::mir::interpret::GlobalId;
2257use crate::mir::interpret::{
2358 EvalStaticInitializerRawResult, EvalToAllocationRawResult, EvalToConstValueResult,
24 EvalToValTreeResult,
59 EvalToValTreeResult, GlobalId, LitToConstError, LitToConstInput,
2560};
26use crate::mir::interpret::{LitToConstError, LitToConstInput};
2761use crate::mir::mono::CodegenUnit;
2862use crate::query::erase::{erase, restore, Erase};
2963use crate::query::plumbing::{
3064 query_ensure, query_ensure_error_guaranteed, query_get_at, CyclePlaceholder, DynamicQuery,
3165};
32use crate::thir;
3366use crate::traits::query::{
3467 CanonicalAliasGoal, CanonicalPredicateGoal, CanonicalTyGoal,
3568 CanonicalTypeOpAscribeUserTypeGoal, CanonicalTypeOpEqGoal, CanonicalTypeOpNormalizeGoal,
36 CanonicalTypeOpProvePredicateGoal, CanonicalTypeOpSubtypeGoal, NoSolution,
37};
38use crate::traits::query::{
39 DropckConstraint, DropckOutlivesResult, MethodAutoderefStepsResult, NormalizationResult,
69 CanonicalTypeOpProvePredicateGoal, CanonicalTypeOpSubtypeGoal, DropckConstraint,
70 DropckOutlivesResult, MethodAutoderefStepsResult, NoSolution, NormalizationResult,
4071 OutlivesBound,
4172};
42use crate::traits::specialization_graph;
4373use crate::traits::{
44 CodegenObligationError, EvaluationResult, ImplSource, ObjectSafetyViolation, ObligationCause,
45 OverflowError, WellFormedLoc,
74 specialization_graph, CodegenObligationError, EvaluationResult, ImplSource,
75 ObjectSafetyViolation, ObligationCause, OverflowError, WellFormedLoc,
4676};
4777use crate::ty::fast_reject::SimplifiedType;
4878use crate::ty::layout::ValidityRequirement;
49use crate::ty::print::PrintTraitRefExt;
79use crate::ty::print::{describe_as_module, PrintTraitRefExt};
5080use crate::ty::util::AlwaysRequiresDrop;
51use crate::ty::TyCtxtFeed;
5281use crate::ty::{
53 self, print::describe_as_module, CrateInherentImpls, ParamEnvAnd, Ty, TyCtxt,
82 self, CrateInherentImpls, GenericArg, GenericArgsRef, ParamEnvAnd, Ty, TyCtxt, TyCtxtFeed,
5483 UnusedGenericParams,
5584};
56use crate::ty::{GenericArg, GenericArgsRef};
57use rustc_arena::TypedArena;
58use rustc_ast as ast;
59use rustc_ast::expand::{allocator::AllocatorKind, StrippedCfgItem};
60use rustc_attr as attr;
61use rustc_data_structures::fingerprint::Fingerprint;
62use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
63use rustc_data_structures::steal::Steal;
64use rustc_data_structures::svh::Svh;
65use rustc_data_structures::sync::Lrc;
66use rustc_data_structures::unord::{UnordMap, UnordSet};
67use rustc_errors::ErrorGuaranteed;
68use rustc_hir as hir;
69use rustc_hir::def::{DefKind, DocLinkResMap};
70use rustc_hir::def_id::{
71 CrateNum, DefId, DefIdMap, DefIdSet, LocalDefId, LocalDefIdMap, LocalDefIdSet, LocalModDefId,
72};
73use rustc_hir::lang_items::{LangItem, LanguageItems};
74use rustc_hir::{Crate, ItemLocalId, ItemLocalMap, TraitCandidate};
75use rustc_index::IndexVec;
76use rustc_macros::rustc_queries;
77use rustc_query_system::ich::StableHashingContext;
78use rustc_query_system::query::{try_get_cached, QueryCache, QueryMode, QueryState};
79use rustc_session::config::{EntryFnType, OptLevel, OutputFilenames, SymbolManglingVersion};
80use rustc_session::cstore::{CrateDepKind, CrateSource};
81use rustc_session::cstore::{ExternCrate, ForeignModule, LinkagePreference, NativeLib};
82use rustc_session::lint::LintExpectationId;
83use rustc_session::Limits;
84use rustc_span::def_id::LOCAL_CRATE;
85use rustc_span::symbol::Symbol;
86use rustc_span::{Span, DUMMY_SP};
87use rustc_target::abi;
88use rustc_target::spec::PanicStrategy;
89use std::mem;
90use std::ops::Deref;
91use std::path::PathBuf;
92use std::sync::Arc;
85use crate::{dep_graph, mir, thir};
9386
9487pub mod erase;
9588mod keys;
compiler/rustc_middle/src/query/on_disk_cache.rs+7-9
......@@ -1,3 +1,6 @@
1use std::collections::hash_map::Entry;
2use std::mem;
3
14use rustc_data_structures::fx::{FxHashMap, FxIndexSet};
25use rustc_data_structures::memmap::Mmap;
36use rustc_data_structures::sync::{HashMapExt, Lock, Lrc, RwLock};
......@@ -13,22 +16,17 @@ use rustc_middle::mir::{self, interpret};
1316use rustc_middle::ty::codec::{RefDecodable, TyDecoder, TyEncoder};
1417use rustc_middle::ty::{self, Ty, TyCtxt};
1518use rustc_query_system::query::QuerySideEffects;
16use rustc_serialize::{
17 opaque::{FileEncodeResult, FileEncoder, IntEncodedWithFixedSize, MemDecoder},
18 Decodable, Decoder, Encodable, Encoder,
19};
19use rustc_serialize::opaque::{FileEncodeResult, FileEncoder, IntEncodedWithFixedSize, MemDecoder};
20use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
2021use rustc_session::Session;
2122use rustc_span::hygiene::{
2223 ExpnId, HygieneDecodeContext, HygieneEncodeContext, SyntaxContext, SyntaxContextData,
2324};
2425use rustc_span::source_map::SourceMap;
2526use 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,
2829};
29use rustc_span::{CachingSourceMapView, Symbol};
30use std::collections::hash_map::Entry;
31use std::mem;
3230
3331const TAG_FILE_FOOTER: u128 = 0xC0FFEE_C0FFEE_C0FFEE_C0FFEE_C0FFEE;
3432
compiler/rustc_middle/src/query/plumbing.rs+14-15
......@@ -1,25 +1,23 @@
1use crate::dep_graph;
2use crate::dep_graph::DepKind;
3use crate::query::on_disk_cache::CacheEncoder;
4use crate::query::on_disk_cache::EncodedDepNodeIndex;
5use crate::query::on_disk_cache::OnDiskCache;
6use crate::query::{
7 DynamicQueries, ExternProviders, Providers, QueryArenas, QueryCaches, QueryEngine, QueryStates,
8};
9use crate::ty::TyCtxt;
1use std::ops::Deref;
2
103use field_offset::FieldOffset;
11use rustc_data_structures::sync::AtomicU64;
12use rustc_data_structures::sync::WorkerLocal;
4use rustc_data_structures::sync::{AtomicU64, WorkerLocal};
135use rustc_hir::def_id::{DefId, LocalDefId};
146use rustc_hir::hir_id::OwnerId;
157use rustc_macros::HashStable;
16use rustc_query_system::dep_graph::DepNodeIndex;
17use rustc_query_system::dep_graph::SerializedDepNodeIndex;
8use rustc_query_system::dep_graph::{DepNodeIndex, SerializedDepNodeIndex};
189pub(crate) use rustc_query_system::query::QueryJobId;
1910use rustc_query_system::query::*;
2011use rustc_query_system::HandleCycleError;
2112use rustc_span::{ErrorGuaranteed, Span, DUMMY_SP};
22use std::ops::Deref;
13
14use crate::dep_graph;
15use crate::dep_graph::DepKind;
16use crate::query::on_disk_cache::{CacheEncoder, EncodedDepNodeIndex, OnDiskCache};
17use crate::query::{
18 DynamicQueries, ExternProviders, Providers, QueryArenas, QueryCaches, QueryEngine, QueryStates,
19};
20use crate::ty::TyCtxt;
2321
2422pub struct DynamicQuery<'tcx, C: QueryCache> {
2523 pub name: &'static str,
......@@ -574,9 +572,10 @@ macro_rules! define_feedable {
574572// as they will raise an fatal error on query cycles instead.
575573
576574mod sealed {
577 use super::{DefId, LocalDefId, OwnerId};
578575 use rustc_hir::def_id::{LocalModDefId, ModDefId};
579576
577 use super::{DefId, LocalDefId, OwnerId};
578
580579 /// An analogue of the `Into` trait that's intended only for query parameters.
581580 ///
582581 /// 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 @@
88//!
99//! [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/thir.html
1010
11use std::cmp::Ordering;
12use std::fmt;
13use std::ops::Index;
14
1115use rustc_ast::{InlineAsmOptions, InlineAsmTemplatePiece};
1216use rustc_errors::{DiagArgValue, IntoDiagArg};
1317use rustc_hir as hir;
1418use rustc_hir::def_id::DefId;
1519use rustc_hir::{BindingMode, ByRef, HirId, MatchSource, RangeEnd};
16use rustc_index::newtype_index;
17use rustc_index::IndexVec;
20use rustc_index::{newtype_index, IndexVec};
1821use rustc_macros::{HashStable, TyDecodable, TyEncodable, TypeVisitable};
1922use rustc_middle::middle::region;
2023use rustc_middle::mir::interpret::AllocId;
......@@ -29,9 +32,6 @@ use rustc_span::def_id::LocalDefId;
2932use rustc_span::{sym, ErrorGuaranteed, Span, Symbol, DUMMY_SP};
3033use rustc_target::abi::{FieldIdx, Integer, Size, VariantIdx};
3134use rustc_target::asm::InlineAsmRegOrRegClass;
32use std::cmp::Ordering;
33use std::fmt;
34use std::ops::Index;
3535use tracing::instrument;
3636
3737pub mod visit;
......@@ -1236,8 +1236,9 @@ impl<'tcx> fmt::Display for Pat<'tcx> {
12361236// Some nodes are used a lot. Make sure they don't unintentionally get bigger.
12371237#[cfg(target_pointer_width = "64")]
12381238mod size_asserts {
1239 use super::*;
12401239 use rustc_data_structures::static_assert_size;
1240
1241 use super::*;
12411242 // tidy-alphabetical-start
12421243 static_assert_size!(Block, 48);
12431244 static_assert_size!(Expr<'_>, 64);
compiler/rustc_middle/src/traits/mod.rs+7-9
......@@ -8,10 +8,8 @@ pub mod solve;
88pub mod specialization_graph;
99mod structural_impls;
1010
11use crate::mir::ConstraintCategory;
12use crate::ty::abstract_const::NotConstEvaluatable;
13use crate::ty::GenericArgsRef;
14use crate::ty::{self, AdtKind, Ty};
11use std::borrow::Cow;
12use std::hash::{Hash, Hasher};
1513
1614use rustc_data_structures::sync::Lrc;
1715use rustc_errors::{Applicability, Diag, EmissionGuarantee};
......@@ -24,14 +22,14 @@ use rustc_macros::{
2422use rustc_span::def_id::{LocalDefId, CRATE_DEF_ID};
2523use rustc_span::symbol::Symbol;
2624use rustc_span::{Span, DUMMY_SP};
25// FIXME: Remove this import and import via `solve::`
26pub use rustc_type_ir::solve::{BuiltinImplSource, Reveal};
2727use smallvec::{smallvec, SmallVec};
2828
29use std::borrow::Cow;
30use std::hash::{Hash, Hasher};
31
3229pub use self::select::{EvaluationCache, EvaluationResult, OverflowError, SelectionCache};
33// FIXME: Remove this import and import via `solve::`
34pub use rustc_type_ir::solve::{BuiltinImplSource, Reveal};
30use crate::mir::ConstraintCategory;
31use crate::ty::abstract_const::NotConstEvaluatable;
32use crate::ty::{self, AdtKind, GenericArgsRef, Ty};
3533
3634/// The reason why we incurred this obligation; used for error reporting.
3735///
compiler/rustc_middle/src/traits/query.rs+8-6
......@@ -5,20 +5,22 @@
55//! The providers for the queries defined here can be found in
66//! `rustc_traits`.
77
8use crate::error::DropCheckOverflow;
9use crate::infer::canonical::{Canonical, QueryResponse};
10use crate::ty::GenericArg;
11use crate::ty::{self, Ty, TyCtxt};
128use rustc_macros::{HashStable, TypeFoldable, TypeVisitable};
139use rustc_span::Span;
1410// FIXME: Remove this import and import via `traits::solve`.
1511pub use rustc_type_ir::solve::NoSolution;
1612
13use crate::error::DropCheckOverflow;
14use crate::infer::canonical::{Canonical, QueryResponse};
15use crate::ty::{self, GenericArg, Ty, TyCtxt};
16
1717pub mod type_op {
18 use std::fmt;
19
20 use rustc_macros::{HashStable, TypeFoldable, TypeVisitable};
21
1822 use crate::ty::fold::TypeFoldable;
1923 use crate::ty::{Predicate, Ty, TyCtxt, UserType};
20 use rustc_macros::{HashStable, TypeFoldable, TypeVisitable};
21 use std::fmt;
2224
2325 #[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, HashStable, TypeFoldable, TypeVisitable)]
2426 pub struct AscribeUserType<'tcx> {
compiler/rustc_middle/src/traits/select.rs+4-6
......@@ -2,17 +2,15 @@
22//!
33//! [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/traits/resolution.html#selection
44
5use self::EvaluationResult::*;
6
7use super::{SelectionError, SelectionResult};
85use rustc_errors::ErrorGuaranteed;
9
10use crate::ty;
11
126use rustc_hir::def_id::DefId;
137use rustc_macros::{HashStable, TypeVisitable};
148use rustc_query_system::cache::Cache;
159
10use self::EvaluationResult::*;
11use super::{SelectionError, SelectionResult};
12use crate::ty;
13
1614pub type SelectionCache<'tcx> = Cache<
1715 // This cache does not use `ParamEnvAnd` in its keys because `ParamEnv::and` can replace
1816 // 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 @@
1use crate::error::StrictCoherenceNeedsNegativeCoherence;
2use crate::ty::fast_reject::SimplifiedType;
3use crate::ty::visit::TypeVisitableExt;
4use crate::ty::{self, TyCtxt};
51use rustc_data_structures::fx::FxIndexMap;
62use rustc_errors::ErrorGuaranteed;
73use rustc_hir::def_id::{DefId, DefIdMap};
84use rustc_macros::{HashStable, TyDecodable, TyEncodable};
95use rustc_span::symbol::sym;
106
7use crate::error::StrictCoherenceNeedsNegativeCoherence;
8use crate::ty::fast_reject::SimplifiedType;
9use crate::ty::visit::TypeVisitableExt;
10use crate::ty::{self, TyCtxt};
11
1112/// A per-trait graph of impls in specialization order. At the moment, this
1213/// graph forms a tree rooted with the trait itself, with all other nodes
1314/// representing impls, and parent-child relationships representing
compiler/rustc_middle/src/traits/structural_impls.rs+2-2
......@@ -1,7 +1,7 @@
1use crate::traits;
2
31use std::fmt;
42
3use crate::traits;
4
55// Structural impls for the structs in `traits`.
66
77impl<'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 @@
11//! A subset of a mir body used for const evaluability checking.
22
3use rustc_errors::ErrorGuaranteed;
4use rustc_macros::{HashStable, TyDecodable, TyEncodable, TypeVisitable};
5
36use crate::ty::{
47 self, Const, EarlyBinder, Ty, TyCtxt, TypeFoldable, TypeFolder, TypeSuperFoldable,
58 TypeVisitableExt,
69};
7use rustc_errors::ErrorGuaranteed;
8use rustc_macros::{HashStable, TyDecodable, TyEncodable, TypeVisitable};
910
1011#[derive(Hash, Debug, Clone, Copy, Ord, PartialOrd, PartialEq, Eq)]
1112#[derive(TyDecodable, TyEncodable, HashStable, TypeVisitable, TypeFoldable)]
compiler/rustc_middle/src/ty/adjustment.rs+2-1
......@@ -1,10 +1,11 @@
1use crate::ty::{self, Ty, TyCtxt};
21use rustc_hir as hir;
32use rustc_hir::lang_items::LangItem;
43use rustc_macros::{HashStable, TyDecodable, TyEncodable, TypeFoldable, TypeVisitable};
54use rustc_span::Span;
65use rustc_target::abi::FieldIdx;
76
7use crate::ty::{self, Ty, TyCtxt};
8
89#[derive(Clone, Copy, Debug, PartialEq, Eq, TyEncodable, TyDecodable, Hash, HashStable)]
910pub enum PointerCoercion {
1011 /// Go from a fn-item type to a fn-pointer type.
compiler/rustc_middle/src/ty/adt.rs+9-10
......@@ -1,12 +1,13 @@
1use crate::mir::interpret::ErrorHandled;
2use crate::ty;
3use crate::ty::util::{Discr, IntTypeExt};
1use std::cell::RefCell;
2use std::hash::{Hash, Hasher};
3use std::ops::Range;
4use std::str;
5
46use rustc_data_structures::captures::Captures;
57use rustc_data_structures::fingerprint::Fingerprint;
68use rustc_data_structures::fx::FxHashMap;
79use rustc_data_structures::intern::Interned;
8use rustc_data_structures::stable_hasher::HashingControls;
9use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
10use rustc_data_structures::stable_hasher::{HashStable, HashingControls, StableHasher};
1011use rustc_errors::ErrorGuaranteed;
1112use rustc_hir::def::{CtorKind, DefKind, Res};
1213use rustc_hir::def_id::DefId;
......@@ -19,14 +20,12 @@ use rustc_span::symbol::sym;
1920use rustc_target::abi::{ReprOptions, VariantIdx, FIRST_VARIANT};
2021use tracing::{debug, info, trace};
2122
22use std::cell::RefCell;
23use std::hash::{Hash, Hasher};
24use std::ops::Range;
25use std::str;
26
2723use super::{
2824 AsyncDestructor, Destructor, FieldDef, GenericPredicates, Ty, TyCtxt, VariantDef, VariantDiscr,
2925};
26use crate::mir::interpret::ErrorHandled;
27use crate::ty;
28use crate::ty::util::{Discr, IntTypeExt};
3029
3130#[derive(Clone, Copy, PartialEq, Eq, Hash, HashStable, TyEncodable, TyDecodable)]
3231pub struct AdtFlags(u16);
compiler/rustc_middle/src/ty/assoc.rs+1-1
......@@ -1,4 +1,3 @@
1use crate::ty;
21use rustc_data_structures::sorted_map::SortedIndexMultiMap;
32use rustc_hir as hir;
43use rustc_hir::def::{DefKind, Namespace};
......@@ -7,6 +6,7 @@ use rustc_macros::{Decodable, Encodable, HashStable};
76use rustc_span::symbol::{Ident, Symbol};
87
98use super::{TyCtxt, Visibility};
9use crate::ty;
1010
1111#[derive(Clone, Copy, PartialEq, Eq, Debug, HashStable, Hash, Encodable, Decodable)]
1212pub enum AssocItemContainer {
compiler/rustc_middle/src/ty/cast.rs+2-2
......@@ -1,10 +1,10 @@
11// Helpers for handling cast expressions, used in both
22// typeck and codegen.
33
4use crate::ty::{self, Ty};
4use rustc_macros::{HashStable, TyDecodable, TyEncodable};
55use rustc_middle::mir;
66
7use rustc_macros::{HashStable, TyDecodable, TyEncodable};
7use crate::ty::{self, Ty};
88
99/// Types that are represented as ints.
1010#[derive(Copy, Clone, Debug, PartialEq, Eq)]
compiler/rustc_middle/src/ty/closure.rs+6-8
......@@ -1,11 +1,5 @@
1use crate::hir::place::{
2 Place as HirPlace, PlaceBase as HirPlaceBase, ProjectionKind as HirProjectionKind,
3};
4use crate::{mir, ty};
5
61use std::fmt::Write;
72
8use crate::query::Providers;
93use rustc_data_structures::captures::Captures;
104use rustc_data_structures::fx::FxIndexMap;
115use rustc_hir as hir;
......@@ -16,9 +10,13 @@ use rustc_span::def_id::LocalDefIdMap;
1610use rustc_span::symbol::Ident;
1711use rustc_span::{Span, Symbol};
1812
19use super::TyCtxt;
20
2113use self::BorrowKind::*;
14use super::TyCtxt;
15use crate::hir::place::{
16 Place as HirPlace, PlaceBase as HirPlaceBase, ProjectionKind as HirProjectionKind,
17};
18use crate::query::Providers;
19use crate::{mir, ty};
2220
2321/// Captures are represented using fields inside a structure.
2422/// This represents accessing self in the closure structure
compiler/rustc_middle/src/ty/codec.rs+11-13
......@@ -6,16 +6,10 @@
66//! The functionality in here is shared between persisting to crate metadata and
77//! persisting to incr. comp. caches.
88
9use crate::arena::ArenaAllocatable;
10use crate::infer::canonical::{CanonicalVarInfo, CanonicalVarInfos};
11use crate::mir::interpret::CtfeProvenance;
12use crate::mir::{
13 self,
14 interpret::{AllocId, ConstAllocation},
15};
16use crate::traits;
17use crate::ty::GenericArgsRef;
18use crate::ty::{self, AdtDef, Ty};
9use std::hash::Hash;
10use std::intrinsics;
11use std::marker::DiscriminantKind;
12
1913use rustc_data_structures::fx::FxHashMap;
2014use rustc_hir::def_id::LocalDefId;
2115use rustc_middle::ty::TyCtxt;
......@@ -23,9 +17,13 @@ use rustc_serialize::{Decodable, Encodable};
2317use rustc_span::Span;
2418use rustc_target::abi::{FieldIdx, VariantIdx};
2519pub use rustc_type_ir::{TyDecoder, TyEncoder};
26use std::hash::Hash;
27use std::intrinsics;
28use std::marker::DiscriminantKind;
20
21use crate::arena::ArenaAllocatable;
22use crate::infer::canonical::{CanonicalVarInfo, CanonicalVarInfos};
23use crate::mir::interpret::{AllocId, ConstAllocation, CtfeProvenance};
24use crate::mir::{self};
25use crate::traits;
26use crate::ty::{self, AdtDef, GenericArgsRef, Ty};
2927
3028/// The shorthand encoding uses an enum's variant index `usize`
3129/// 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 @@
1use crate::middle::resolve_bound_vars as rbv;
2use crate::mir::interpret::{ErrorHandled, LitToConstInput, Scalar};
3use crate::ty::{self, GenericArgs, ParamEnv, ParamEnvAnd, Ty, TyCtxt, TypeVisitableExt};
41use either::Either;
52use rustc_data_structures::intern::Interned;
63use rustc_error_messages::MultiSpan;
......@@ -11,14 +8,17 @@ use rustc_macros::HashStable;
118use rustc_type_ir::{self as ir, TypeFlags, WithCachedTypeInfo};
129use tracing::{debug, instrument};
1310
11use crate::middle::resolve_bound_vars as rbv;
12use crate::mir::interpret::{ErrorHandled, LitToConstInput, Scalar};
13use crate::ty::{self, GenericArgs, ParamEnv, ParamEnvAnd, Ty, TyCtxt, TypeVisitableExt};
14
1415mod int;
1516mod kind;
1617mod valtree;
1718
1819pub use int::*;
1920pub use kind::*;
20use rustc_span::DUMMY_SP;
21use rustc_span::{ErrorGuaranteed, Span};
21use rustc_span::{ErrorGuaranteed, Span, DUMMY_SP};
2222pub use valtree::*;
2323
2424pub type ConstKind<'tcx> = ir::ConstKind<TyCtxt<'tcx>>;
compiler/rustc_middle/src/ty/consts/int.rs+3-2
......@@ -1,10 +1,11 @@
1use std::fmt;
2use std::num::NonZero;
3
14use rustc_apfloat::ieee::{Double, Half, Quad, Single};
25use rustc_apfloat::Float;
36use rustc_errors::{DiagArgValue, IntoDiagArg};
47use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
58use rustc_target::abi::Size;
6use std::fmt;
7use std::num::NonZero;
89
910use crate::ty::TyCtxt;
1011
compiler/rustc_middle/src/ty/consts/kind.rs+4-2
......@@ -1,8 +1,10 @@
1use rustc_macros::{extension, HashStable, TyDecodable, TyEncodable, TypeFoldable, TypeVisitable};
2
13use super::Const;
24use crate::mir;
35use crate::ty::abstract_const::CastKind;
4use crate::ty::{self, visit::TypeVisitableExt as _, Ty, TyCtxt};
5use rustc_macros::{extension, HashStable, TyDecodable, TyEncodable, TypeFoldable, TypeVisitable};
6use crate::ty::visit::TypeVisitableExt as _;
7use crate::ty::{self, Ty, TyCtxt};
68
79#[extension(pub(crate) trait UnevaluatedConstEvalExt<'tcx>)]
810impl<'tcx> ty::UnevaluatedConst<'tcx> {
compiler/rustc_middle/src/ty/consts/valtree.rs+2-1
......@@ -1,7 +1,8 @@
1use rustc_macros::{HashStable, TyDecodable, TyEncodable};
2
13use super::ScalarInt;
24use crate::mir::interpret::Scalar;
35use crate::ty::{self, Ty, TyCtxt};
4use rustc_macros::{HashStable, TyDecodable, TyEncodable};
56
67#[derive(Copy, Clone, Debug, Hash, TyEncodable, TyDecodable, Eq, PartialEq)]
78#[derive(HashStable)]
compiler/rustc_middle/src/ty/context.rs+33-38
......@@ -4,36 +4,14 @@
44
55pub mod tls;
66
7pub use rustc_type_ir::lift::Lift;
7use std::assert_matches::assert_matches;
8use std::borrow::Borrow;
9use std::cmp::Ordering;
10use std::hash::{Hash, Hasher};
11use std::marker::PhantomData;
12use std::ops::{Bound, Deref};
13use std::{fmt, iter, mem};
814
9use crate::arena::Arena;
10use crate::dep_graph::{DepGraph, DepKindStruct};
11use crate::infer::canonical::{CanonicalParamEnvCache, CanonicalVarInfo, CanonicalVarInfos};
12use crate::lint::lint_level;
13use crate::metadata::ModChild;
14use crate::middle::codegen_fn_attrs::CodegenFnAttrs;
15use crate::middle::resolve_bound_vars;
16use crate::middle::stability;
17use crate::mir::interpret::{self, Allocation, ConstAllocation};
18use crate::mir::{Body, Local, Place, PlaceElem, ProjectionKind, Promoted};
19use crate::query::plumbing::QuerySystem;
20use crate::query::LocalCrate;
21use crate::query::Providers;
22use crate::query::{IntoQueryParam, TyCtxtAt};
23use crate::thir::Thir;
24use crate::traits;
25use crate::traits::solve;
26use crate::traits::solve::{
27 ExternalConstraints, ExternalConstraintsData, PredefinedOpaques, PredefinedOpaquesData,
28};
29use crate::ty::predicate::ExistentialPredicateStableCmpExt as _;
30use 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};
36use crate::ty::{GenericArg, GenericArgs, GenericArgsRef};
3715use rustc_ast::{self as ast, attr};
3816use rustc_data_structures::defer;
3917use rustc_data_structures::fingerprint::Fingerprint;
......@@ -74,20 +52,37 @@ use rustc_target::abi::{FieldIdx, Layout, LayoutS, TargetDataLayout, VariantIdx}
7452use rustc_target::spec::abi;
7553use rustc_type_ir::fold::TypeFoldable;
7654use rustc_type_ir::lang_items::TraitSolverLangItem;
55pub use rustc_type_ir::lift::Lift;
7756use rustc_type_ir::solve::SolverMode;
7857use rustc_type_ir::TyKind::*;
7958use rustc_type_ir::{search_graph, CollectAndApply, Interner, TypeFlags, WithCachedTypeInfo};
8059use tracing::{debug, instrument};
8160
82use std::assert_matches::assert_matches;
83use std::borrow::Borrow;
84use std::cmp::Ordering;
85use std::fmt;
86use std::hash::{Hash, Hasher};
87use std::iter;
88use std::marker::PhantomData;
89use std::mem;
90use std::ops::{Bound, Deref};
61use crate::arena::Arena;
62use crate::dep_graph::{DepGraph, DepKindStruct};
63use crate::infer::canonical::{CanonicalParamEnvCache, CanonicalVarInfo, CanonicalVarInfos};
64use crate::lint::lint_level;
65use crate::metadata::ModChild;
66use crate::middle::codegen_fn_attrs::CodegenFnAttrs;
67use crate::middle::{resolve_bound_vars, stability};
68use crate::mir::interpret::{self, Allocation, ConstAllocation};
69use crate::mir::{Body, Local, Place, PlaceElem, ProjectionKind, Promoted};
70use crate::query::plumbing::QuerySystem;
71use crate::query::{IntoQueryParam, LocalCrate, Providers, TyCtxtAt};
72use crate::thir::Thir;
73use crate::traits;
74use crate::traits::solve;
75use crate::traits::solve::{
76 ExternalConstraints, ExternalConstraintsData, PredefinedOpaques, PredefinedOpaquesData,
77};
78use crate::ty::predicate::ExistentialPredicateStableCmpExt as _;
79use 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};
9186
9287#[allow(rustc::usage_of_ty_tykind)]
9388impl<'tcx> Interner for TyCtxt<'tcx> {
compiler/rustc_middle/src/ty/context/tls.rs+7-7
......@@ -1,15 +1,15 @@
1use super::{GlobalCtxt, TyCtxt};
1#[cfg(not(parallel_compiler))]
2use std::cell::Cell;
3use std::{mem, ptr};
24
3use crate::dep_graph::TaskDepsRef;
4use crate::query::plumbing::QueryJobId;
55use rustc_data_structures::sync::{self, Lock};
66use rustc_errors::DiagInner;
7#[cfg(not(parallel_compiler))]
8use std::cell::Cell;
9use std::mem;
10use std::ptr;
117use thin_vec::ThinVec;
128
9use super::{GlobalCtxt, TyCtxt};
10use crate::dep_graph::TaskDepsRef;
11use crate::query::plumbing::QueryJobId;
12
1313/// This is the implicit state of rustc. It contains the current
1414/// `TyCtxt` and query. It is updated when creating a local interner or
1515/// 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;
44use std::fmt::Write;
55use std::ops::ControlFlow;
66
7use crate::ty::{
8 self, AliasTy, Const, ConstKind, FallibleTypeFolder, InferConst, InferTy, Opaque,
9 PolyTraitPredicate, Projection, Ty, TyCtxt, TypeFoldable, TypeSuperFoldable,
10 TypeSuperVisitable, TypeVisitable, TypeVisitor,
11};
12
137use rustc_data_structures::fx::FxHashMap;
148use rustc_errors::{into_diag_arg_using_display, Applicability, Diag, DiagArgValue, IntoDiagArg};
159use rustc_hir as hir;
......@@ -19,6 +13,12 @@ use rustc_hir::{PredicateOrigin, WherePredicate};
1913use rustc_span::{BytePos, Span};
2014use rustc_type_ir::TyKind::*;
2115
16use crate::ty::{
17 self, AliasTy, Const, ConstKind, FallibleTypeFolder, InferConst, InferTy, Opaque,
18 PolyTraitPredicate, Projection, Ty, TyCtxt, TypeFoldable, TypeSuperFoldable,
19 TypeSuperVisitable, TypeVisitable, TypeVisitor,
20};
21
2222into_diag_arg_using_display! {
2323 Ty<'_>,
2424 ty::Region<'_>,
compiler/rustc_middle/src/ty/erase_regions.rs+2-1
......@@ -1,7 +1,8 @@
1use tracing::debug;
2
13use crate::query::Providers;
24use crate::ty::fold::{TypeFoldable, TypeFolder, TypeSuperFoldable};
35use crate::ty::{self, Ty, TyCtxt, TypeFlags, TypeVisitableExt};
4use tracing::debug;
56
67pub(super) fn provide(providers: &mut Providers) {
78 *providers = Providers { erase_regions_ty, ..*providers };
compiler/rustc_middle/src/ty/error.rs+5-5
......@@ -1,5 +1,6 @@
1use crate::ty::print::{with_forced_trimmed_paths, FmtPrinter, PrettyPrinter};
2use crate::ty::{self, Ty, TyCtxt};
1use std::borrow::Cow;
2use std::hash::{DefaultHasher, Hash, Hasher};
3use std::path::PathBuf;
34
45use rustc_errors::pluralize;
56use rustc_hir as hir;
......@@ -7,9 +8,8 @@ use rustc_hir::def::{CtorOf, DefKind};
78use rustc_macros::extension;
89pub use rustc_type_ir::error::ExpectedFound;
910
10use std::borrow::Cow;
11use std::hash::{DefaultHasher, Hash, Hasher};
12use std::path::PathBuf;
11use crate::ty::print::{with_forced_trimmed_paths, FmtPrinter, PrettyPrinter};
12use crate::ty::{self, Ty, TyCtxt};
1313
1414pub type TypeError<'tcx> = rustc_type_ir::error::TypeError<TyCtxt<'tcx>>;
1515
compiler/rustc_middle/src/ty/fast_reject.rs+1-2
......@@ -1,9 +1,8 @@
11use rustc_hir::def_id::DefId;
2pub use rustc_type_ir::fast_reject::*;
23
34use super::TyCtxt;
45
5pub use rustc_type_ir::fast_reject::*;
6
76pub type DeepRejectCtxt<'tcx> = rustc_type_ir::fast_reject::DeepRejectCtxt<TyCtxt<'tcx>>;
87
98pub type SimplifiedType = rustc_type_ir::fast_reject::SimplifiedType<DefId>;
compiler/rustc_middle/src/ty/flags.rs+2-2
......@@ -1,7 +1,7 @@
1use crate::ty::{self, InferConst, Ty, TypeFlags};
2use crate::ty::{GenericArg, GenericArgKind};
31use std::slice;
42
3use crate::ty::{self, GenericArg, GenericArgKind, InferConst, Ty, TypeFlags};
4
55#[derive(Debug)]
66pub struct FlagComputation {
77 pub flags: TypeFlags,
compiler/rustc_middle/src/ty/fold.rs+3-3
......@@ -1,11 +1,11 @@
1use crate::ty::{self, Binder, BoundTy, Ty, TyCtxt, TypeVisitableExt};
21use rustc_data_structures::fx::FxIndexMap;
32use rustc_hir::def_id::DefId;
4use tracing::{debug, instrument};
5
63pub use rustc_type_ir::fold::{
74 shift_region, shift_vars, FallibleTypeFolder, TypeFoldable, TypeFolder, TypeSuperFoldable,
85};
6use tracing::{debug, instrument};
7
8use crate::ty::{self, Binder, BoundTy, Ty, TyCtxt, TypeVisitableExt};
99
1010///////////////////////////////////////////////////////////////////////////
1111// Some sample folders
compiler/rustc_middle/src/ty/generic_args.rs+12-13
......@@ -1,28 +1,27 @@
11// Generic arguments.
22
3use crate::ty::codec::{TyDecoder, TyEncoder};
4use crate::ty::fold::{FallibleTypeFolder, TypeFoldable};
5use crate::ty::visit::{TypeVisitable, TypeVisitor};
6use crate::ty::{
7 self, ClosureArgs, CoroutineArgs, CoroutineClosureArgs, InlineConstArgs, Lift, List, Ty, TyCtxt,
8};
3use core::intrinsics;
4use std::marker::PhantomData;
5use std::mem;
6use std::num::NonZero;
7use std::ptr::NonNull;
98
109use rustc_ast_ir::visit::VisitorResult;
1110use rustc_ast_ir::walk_visitable_list;
1211use rustc_data_structures::intern::Interned;
1312use rustc_errors::{DiagArgValue, IntoDiagArg};
1413use rustc_hir::def_id::DefId;
15use rustc_macros::extension;
16use rustc_macros::{HashStable, TyDecodable, TyEncodable, TypeFoldable, TypeVisitable};
14use rustc_macros::{extension, HashStable, TyDecodable, TyEncodable, TypeFoldable, TypeVisitable};
1715use rustc_serialize::{Decodable, Encodable};
1816use rustc_type_ir::WithCachedTypeInfo;
1917use smallvec::SmallVec;
2018
21use core::intrinsics;
22use std::marker::PhantomData;
23use std::mem;
24use std::num::NonZero;
25use std::ptr::NonNull;
19use crate::ty::codec::{TyDecoder, TyEncoder};
20use crate::ty::fold::{FallibleTypeFolder, TypeFoldable};
21use crate::ty::visit::{TypeVisitable, TypeVisitor};
22use crate::ty::{
23 self, ClosureArgs, CoroutineArgs, CoroutineClosureArgs, InlineConstArgs, Lift, List, Ty, TyCtxt,
24};
2625
2726pub type GenericArgKind<'tcx> = rustc_type_ir::GenericArgKind<TyCtxt<'tcx>>;
2827pub type TermKind<'tcx> = rustc_type_ir::TermKind<TyCtxt<'tcx>>;
compiler/rustc_middle/src/ty/generics.rs+2-2
......@@ -1,5 +1,3 @@
1use crate::ty;
2use crate::ty::{EarlyBinder, GenericArgsRef};
31use rustc_ast as ast;
42use rustc_data_structures::fx::FxHashMap;
53use rustc_hir::def_id::DefId;
......@@ -9,6 +7,8 @@ use rustc_span::Span;
97use tracing::instrument;
108
119use super::{Clause, InstantiatedPredicates, ParamConst, ParamTy, Ty, TyCtxt};
10use crate::ty;
11use crate::ty::{EarlyBinder, GenericArgsRef};
1212
1313#[derive(Clone, Debug, TyEncodable, TyDecodable, HashStable)]
1414pub enum GenericParamDefKind {
compiler/rustc_middle/src/ty/impls_ty.rs+9-7
......@@ -1,18 +1,20 @@
11//! This module contains `HashStable` implementations for various data types
22//! from `rustc_middle::ty` in no particular order.
33
4use crate::middle::region;
5use crate::mir;
6use crate::ty;
4use std::cell::RefCell;
5use std::ptr;
6
77use rustc_data_structures::fingerprint::Fingerprint;
88use rustc_data_structures::fx::FxHashMap;
9use rustc_data_structures::stable_hasher::HashingControls;
10use rustc_data_structures::stable_hasher::{HashStable, StableHasher, ToStableHashKey};
9use rustc_data_structures::stable_hasher::{
10 HashStable, HashingControls, StableHasher, ToStableHashKey,
11};
1112use rustc_query_system::ich::StableHashingContext;
12use std::cell::RefCell;
13use std::ptr;
1413use tracing::trace;
1514
15use crate::middle::region;
16use crate::{mir, ty};
17
1618impl<'a, 'tcx, H, T> HashStable<StableHashingContext<'a>> for &'tcx ty::list::RawList<H, T>
1719where
1820 T: HashStable<StableHashingContext<'a>>,
compiler/rustc_middle/src/ty/inhabitedness/mod.rs+3-3
......@@ -43,13 +43,13 @@
4343//! This code should only compile in modules where the uninhabitedness of `Foo`
4444//! is visible.
4545
46use rustc_type_ir::TyKind::*;
47use tracing::instrument;
48
4649use crate::query::Providers;
4750use crate::ty::context::TyCtxt;
4851use crate::ty::{self, DefId, Ty, TypeVisitableExt, VariantDef, Visibility};
4952
50use rustc_type_ir::TyKind::*;
51use tracing::instrument;
52
5353pub mod inhabited_predicate;
5454
5555pub use inhabited_predicate::InhabitedPredicate;
compiler/rustc_middle/src/ty/instance.rs+11-10
......@@ -1,10 +1,7 @@
1use crate::error;
2use crate::middle::codegen_fn_attrs::CodegenFnAttrFlags;
3use crate::ty::print::{shrunk_instance_name, FmtPrinter, Printer};
4use crate::ty::{
5 self, EarlyBinder, GenericArgs, GenericArgsRef, Ty, TyCtxt, TypeFoldable, TypeSuperFoldable,
6 TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor,
7};
1use std::assert_matches::assert_matches;
2use std::fmt;
3use std::path::PathBuf;
4
85use rustc_data_structures::fx::FxHashMap;
96use rustc_errors::ErrorGuaranteed;
107use rustc_hir as hir;
......@@ -18,9 +15,13 @@ use rustc_span::def_id::LOCAL_CRATE;
1815use rustc_span::{Span, Symbol, DUMMY_SP};
1916use tracing::{debug, instrument};
2017
21use std::assert_matches::assert_matches;
22use std::fmt;
23use std::path::PathBuf;
18use crate::error;
19use crate::middle::codegen_fn_attrs::CodegenFnAttrFlags;
20use crate::ty::print::{shrunk_instance_name, FmtPrinter, Printer};
21use crate::ty::{
22 self, EarlyBinder, GenericArgs, GenericArgsRef, Ty, TyCtxt, TypeFoldable, TypeSuperFoldable,
23 TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor,
24};
2425
2526/// An `InstanceKind` along with the args that are needed to substitute the instance.
2627///
compiler/rustc_middle/src/ty/intrinsic.rs+2-1
......@@ -1,5 +1,6 @@
11use rustc_macros::{Decodable, Encodable, HashStable};
2use rustc_span::{def_id::DefId, Symbol};
2use rustc_span::def_id::DefId;
3use rustc_span::Symbol;
34
45use super::TyCtxt;
56
compiler/rustc_middle/src/ty/layout.rs+16-15
......@@ -1,8 +1,8 @@
1use crate::error::UnsupportedFnAbi;
2use crate::middle::codegen_fn_attrs::CodegenFnAttrFlags;
3use crate::query::TyCtxtAt;
4use crate::ty::normalize_erasing_regions::NormalizationError;
5use crate::ty::{self, CoroutineArgsExt, Ty, TyCtxt, TypeVisitableExt};
1use std::borrow::Cow;
2use std::num::NonZero;
3use std::ops::Bound;
4use std::{cmp, fmt};
5
66use rustc_error_messages::DiagMessage;
77use rustc_errors::{
88 Diag, DiagArgValue, DiagCtxtHandle, Diagnostic, EmissionGuarantee, IntoDiagArg, Level,
......@@ -17,16 +17,15 @@ use rustc_span::symbol::{sym, Symbol};
1717use rustc_span::{ErrorGuaranteed, Span, DUMMY_SP};
1818use rustc_target::abi::call::FnAbi;
1919use rustc_target::abi::*;
20use rustc_target::spec::{
21 abi::Abi as SpecAbi, HasTargetSpec, HasWasmCAbiOpt, PanicStrategy, Target, WasmCAbi,
22};
20use rustc_target::spec::abi::Abi as SpecAbi;
21use rustc_target::spec::{HasTargetSpec, HasWasmCAbiOpt, PanicStrategy, Target, WasmCAbi};
2322use tracing::debug;
2423
25use std::borrow::Cow;
26use std::cmp;
27use std::fmt;
28use std::num::NonZero;
29use std::ops::Bound;
24use crate::error::UnsupportedFnAbi;
25use crate::middle::codegen_fn_attrs::CodegenFnAttrFlags;
26use crate::query::TyCtxtAt;
27use crate::ty::normalize_erasing_regions::NormalizationError;
28use crate::ty::{self, CoroutineArgsExt, Ty, TyCtxt, TypeVisitableExt};
3029
3130#[extension(pub trait IntegerExt)]
3231impl Integer {
......@@ -231,8 +230,9 @@ pub enum LayoutError<'tcx> {
231230
232231impl<'tcx> LayoutError<'tcx> {
233232 pub fn diagnostic_message(&self) -> DiagMessage {
234 use crate::fluent_generated::*;
235233 use LayoutError::*;
234
235 use crate::fluent_generated::*;
236236 match self {
237237 Unknown(_) => middle_unknown_layout,
238238 SizeOverflow(_) => middle_values_too_big,
......@@ -243,8 +243,9 @@ impl<'tcx> LayoutError<'tcx> {
243243 }
244244
245245 pub fn into_diagnostic(self) -> crate::error::LayoutError<'tcx> {
246 use crate::error::LayoutError as E;
247246 use LayoutError::*;
247
248 use crate::error::LayoutError as E;
248249 match self {
249250 Unknown(ty) => E::Unknown { ty },
250251 SizeOverflow(ty) => E::Overflow { ty },
compiler/rustc_middle/src/ty/list.rs+7-10
......@@ -1,20 +1,17 @@
1use super::flags::FlagComputation;
2use super::{DebruijnIndex, TypeFlags};
3use crate::arena::Arena;
4use rustc_data_structures::aligned::{align_of, Aligned};
5use rustc_serialize::{Encodable, Encoder};
61use std::alloc::Layout;
72use std::cmp::Ordering;
8use std::fmt;
93use std::hash::{Hash, Hasher};
10use std::iter;
11use std::mem;
124use std::ops::Deref;
13use std::ptr;
14use std::slice;
5use std::{fmt, iter, mem, ptr, slice};
156
7use rustc_data_structures::aligned::{align_of, Aligned};
168#[cfg(parallel_compiler)]
179use rustc_data_structures::sync::DynSync;
10use rustc_serialize::{Encodable, Encoder};
11
12use super::flags::FlagComputation;
13use super::{DebruijnIndex, TypeFlags};
14use crate::arena::Arena;
1815
1916/// `List<T>` is a bit like `&[T]`, but with some critical differences.
2017/// - IMPORTANT: Every `List<T>` is *required* to have unique contents. The
compiler/rustc_middle/src/ty/mod.rs+30-33
......@@ -11,37 +11,28 @@
1111
1212#![allow(rustc::usage_of_ty_tykind)]
1313
14pub use self::fold::{FallibleTypeFolder, TypeFoldable, TypeFolder, TypeSuperFoldable};
15pub use self::visit::{TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor};
16pub use self::AssocItemContainer::*;
17pub use self::BorrowKind::*;
18pub use self::IntVarValue::*;
19use crate::error::{OpaqueHiddenTypeMismatch, TypeMismatchReason};
20use crate::metadata::ModChild;
21use crate::middle::privacy::EffectiveVisibilities;
22use crate::mir::{Body, CoroutineLayout};
23use crate::query::Providers;
24use crate::traits::{self, Reveal};
25use crate::ty;
26use crate::ty::fast_reject::SimplifiedType;
27use crate::ty::util::Discr;
14use std::assert_matches::assert_matches;
15use std::fmt::Debug;
16use std::hash::{Hash, Hasher};
17use std::marker::PhantomData;
18use std::num::NonZero;
19use std::ptr::NonNull;
20use std::{fmt, mem, str};
21
2822pub use adt::*;
2923pub use assoc::*;
3024pub use generic_args::{GenericArgKind, TermKind, *};
3125pub use generics::*;
3226pub use intrinsic::IntrinsicDef;
33use rustc_ast as ast;
3427use rustc_ast::expand::StrippedCfgItem;
3528use rustc_ast::node_id::NodeMap;
3629pub use rustc_ast_ir::{try_visit, Movability, Mutability};
37use rustc_attr as attr;
3830use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap, FxIndexSet};
3931use rustc_data_structures::intern::Interned;
4032use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
4133use rustc_data_structures::steal::Steal;
4234use rustc_data_structures::tagged_ptr::CopyTaggedPtr;
4335use rustc_errors::{Diag, ErrorGuaranteed, StashKey};
44use rustc_hir as hir;
4536use rustc_hir::def::{CtorKind, CtorOf, DefKind, DocLinkResMap, LifetimeRes, Res};
4637use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, LocalDefId, LocalDefIdMap};
4738use rustc_index::IndexVec;
......@@ -59,24 +50,14 @@ use rustc_span::{ExpnId, ExpnKind, Span};
5950use rustc_target::abi::{Align, FieldIdx, Integer, IntegerType, VariantIdx};
6051pub use rustc_target::abi::{ReprFlags, ReprOptions};
6152pub use rustc_type_ir::relate::VarianceDiagInfo;
62use tracing::{debug, instrument};
63pub use vtable::*;
64
65use std::assert_matches::assert_matches;
66use std::fmt::Debug;
67use std::hash::{Hash, Hasher};
68use std::marker::PhantomData;
69use std::mem;
70use std::num::NonZero;
71use std::ptr::NonNull;
72use std::{fmt, str};
73
74pub use crate::ty::diagnostics::*;
7553pub use rustc_type_ir::ConstKind::{
7654 Bound as BoundCt, Error as ErrorCt, Expr as ExprCt, Infer as InferCt, Param as ParamCt,
7755 Placeholder as PlaceholderCt, Unevaluated, Value,
7856};
7957pub use rustc_type_ir::*;
58use tracing::{debug, instrument};
59pub use vtable::*;
60use {rustc_ast as ast, rustc_attr as attr, rustc_hir as hir};
8061
8162pub use self::closure::{
8263 analyze_coroutine_closure_captures, is_ancestor_or_same_capture, place_to_string_for_capture,
......@@ -91,6 +72,7 @@ pub use self::context::{
9172 tls, CtxtInterners, CurrentGcx, DeducedParamAttrs, Feed, FreeRegionInfo, GlobalCtxt, Lift,
9273 TyCtxt, TyCtxtFeed,
9374};
75pub use self::fold::{FallibleTypeFolder, TypeFoldable, TypeFolder, TypeSuperFoldable};
9476pub use self::instance::{Instance, InstanceKind, ReifyReason, ShortInstance, UnusedGenericParams};
9577pub use self::list::{List, ListWithCachedTypeInfo};
9678pub use self::opaque_types::OpaqueTypeKey;
......@@ -105,9 +87,9 @@ pub use self::predicate::{
10587 PredicateKind, ProjectionPredicate, RegionOutlivesPredicate, SubtypePredicate, ToPolyTraitRef,
10688 TraitPredicate, TraitRef, TypeOutlivesPredicate,
10789};
90pub use self::region::BoundRegionKind::*;
10891pub use self::region::{
109 BoundRegion, BoundRegionKind, BoundRegionKind::*, EarlyParamRegion, LateParamRegion, Region,
110 RegionKind, RegionVid,
92 BoundRegion, BoundRegionKind, EarlyParamRegion, LateParamRegion, Region, RegionKind, RegionVid,
11193};
11294pub use self::rvalue_scopes::RvalueScopes;
11395pub use self::sty::{
......@@ -120,6 +102,20 @@ pub use self::typeck_results::{
120102 CanonicalUserType, CanonicalUserTypeAnnotation, CanonicalUserTypeAnnotations, IsIdentity,
121103 TypeckResults, UserType, UserTypeAnnotationIndex,
122104};
105pub use self::visit::{TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor};
106pub use self::AssocItemContainer::*;
107pub use self::BorrowKind::*;
108pub use self::IntVarValue::*;
109use crate::error::{OpaqueHiddenTypeMismatch, TypeMismatchReason};
110use crate::metadata::ModChild;
111use crate::middle::privacy::EffectiveVisibilities;
112use crate::mir::{Body, CoroutineLayout};
113use crate::query::Providers;
114use crate::traits::{self, Reveal};
115use crate::ty;
116pub use crate::ty::diagnostics::*;
117use crate::ty::fast_reject::SimplifiedType;
118use crate::ty::util::Discr;
123119
124120pub mod abstract_const;
125121pub mod adjustment;
......@@ -2148,8 +2144,9 @@ pub struct DestructuredConst<'tcx> {
21482144// Some types are used a lot. Make sure they don't unintentionally get bigger.
21492145#[cfg(target_pointer_width = "64")]
21502146mod size_asserts {
2151 use super::*;
21522147 use rustc_data_structures::static_assert_size;
2148
2149 use super::*;
21532150 // tidy-alphabetical-start
21542151 static_assert_size!(PredicateKind<'_>, 32);
21552152 static_assert_size!(WithCachedTypeInfo<TyKind<'_>>, 56);
compiler/rustc_middle/src/ty/normalize_erasing_regions.rs+3-2
......@@ -7,11 +7,12 @@
77//! `normalize_generic_arg_after_erasing_regions` query for each type
88//! or constant found within. (This underlying query is what is cached.)
99
10use rustc_macros::{HashStable, TyDecodable, TyEncodable};
11use tracing::{debug, instrument};
12
1013use crate::traits::query::NoSolution;
1114use crate::ty::fold::{FallibleTypeFolder, TypeFoldable, TypeFolder};
1215use crate::ty::{self, EarlyBinder, GenericArgsRef, Ty, TyCtxt, TypeVisitableExt};
13use rustc_macros::{HashStable, TyDecodable, TyEncodable};
14use tracing::{debug, instrument};
1516
1617#[derive(Debug, Copy, Clone, HashStable, TyEncodable, TyDecodable)]
1718pub enum NormalizationError<'tcx> {
compiler/rustc_middle/src/ty/opaque_types.rs+4-4
......@@ -1,12 +1,12 @@
1use crate::error::ConstNotUsedTraitAlias;
2use crate::ty::fold::{TypeFolder, TypeSuperFoldable};
3use crate::ty::{self, Ty, TyCtxt, TypeFoldable};
4use crate::ty::{GenericArg, GenericArgKind};
51use rustc_data_structures::fx::FxHashMap;
62use rustc_span::def_id::DefId;
73use rustc_span::Span;
84use tracing::{debug, instrument, trace};
95
6use crate::error::ConstNotUsedTraitAlias;
7use crate::ty::fold::{TypeFolder, TypeSuperFoldable};
8use crate::ty::{self, GenericArg, GenericArgKind, Ty, TyCtxt, TypeFoldable};
9
1010pub type OpaqueTypeKey<'tcx> = rustc_type_ir::OpaqueTypeKey<TyCtxt<'tcx>>;
1111
1212/// Converts generic params of a TypeFoldable from one
compiler/rustc_middle/src/ty/parameterized.rs+2-1
......@@ -1,7 +1,8 @@
1use std::hash::Hash;
2
13use rustc_data_structures::unord::UnordMap;
24use rustc_hir::def_id::DefIndex;
35use rustc_index::{Idx, IndexVec};
4use std::hash::Hash;
56
67use crate::ty;
78
compiler/rustc_middle/src/ty/pattern.rs+2-1
......@@ -1,9 +1,10 @@
11use std::fmt;
22
3use crate::ty;
43use rustc_data_structures::intern::Interned;
54use rustc_macros::{HashStable, TyDecodable, TyEncodable, TypeFoldable, TypeVisitable};
65
6use crate::ty;
7
78#[derive(Copy, Clone, PartialEq, Eq, Hash, HashStable)]
89#[rustc_pass_by_value]
910pub struct Pattern<'tcx>(pub Interned<'tcx, PatternKind<'tcx>>);
compiler/rustc_middle/src/ty/predicate.rs+2-1
......@@ -1,9 +1,10 @@
1use std::cmp::Ordering;
2
13use rustc_data_structures::captures::Captures;
24use rustc_data_structures::intern::Interned;
35use rustc_hir::def_id::DefId;
46use rustc_macros::{extension, HashStable};
57use rustc_type_ir as ir;
6use std::cmp::Ordering;
78use tracing::instrument;
89
910use crate::ty::{
compiler/rustc_middle/src/ty/print/mod.rs+2-4
......@@ -1,8 +1,5 @@
11use std::path::PathBuf;
22
3use crate::ty::GenericArg;
4use crate::ty::{self, ShortInstance, Ty, TyCtxt};
5
63use hir::def::Namespace;
74use rustc_data_structures::fx::FxHashSet;
85use rustc_data_structures::sso::SsoHashSet;
......@@ -11,10 +8,11 @@ use rustc_hir::def_id::{CrateNum, DefId, LocalDefId};
118use rustc_hir::definitions::{DefPathData, DisambiguatedDefPathData};
129use tracing::{debug, instrument, trace};
1310
11use crate::ty::{self, GenericArg, ShortInstance, Ty, TyCtxt};
12
1413// `pretty` is a separate module only for organization.
1514mod pretty;
1615pub use self::pretty::*;
17
1816use super::Lift;
1917
2018pub type PrintError = std::fmt::Error;
compiler/rustc_middle/src/ty/print/pretty.rs+11-13
......@@ -1,11 +1,8 @@
1use crate::mir::interpret::{AllocRange, GlobalAlloc, Pointer, Provenance, Scalar};
2use crate::query::IntoQueryParam;
3use crate::query::Providers;
4use crate::ty::GenericArgKind;
5use crate::ty::{
6 ConstInt, Expr, ParamConst, ScalarInt, Term, TermKind, TypeFoldable, TypeSuperFoldable,
7 TypeSuperVisitable, TypeVisitable, TypeVisitableExt,
8};
1use std::cell::Cell;
2use std::fmt::{self, Write as _};
3use std::iter;
4use std::ops::{Deref, DerefMut};
5
96use rustc_apfloat::ieee::{Double, Half, Quad, Single};
107use rustc_apfloat::Float;
118use rustc_data_structures::fx::{FxHashMap, FxIndexMap};
......@@ -25,13 +22,14 @@ use rustc_target::spec::abi::Abi;
2522use rustc_type_ir::{elaborate, Upcast as _};
2623use smallvec::SmallVec;
2724
28use std::cell::Cell;
29use std::fmt::{self, Write as _};
30use std::iter;
31use std::ops::{Deref, DerefMut};
32
3325// `pretty` is a separate module only for organization.
3426use super::*;
27use crate::mir::interpret::{AllocRange, GlobalAlloc, Pointer, Provenance, Scalar};
28use crate::query::{IntoQueryParam, Providers};
29use crate::ty::{
30 ConstInt, Expr, GenericArgKind, ParamConst, ScalarInt, Term, TermKind, TypeFoldable,
31 TypeSuperFoldable, TypeSuperVisitable, TypeVisitable, TypeVisitableExt,
32};
3533
3634macro_rules! p {
3735 (@$lit:literal) => {
compiler/rustc_middle/src/ty/region.rs+3-3
......@@ -1,13 +1,13 @@
1use std::ops::Deref;
2
13use rustc_data_structures::intern::Interned;
24use rustc_errors::MultiSpan;
35use rustc_hir::def_id::DefId;
46use rustc_macros::{HashStable, TyDecodable, TyEncodable};
5use rustc_span::symbol::sym;
6use rustc_span::symbol::{kw, Symbol};
7use rustc_span::symbol::{kw, sym, Symbol};
78use rustc_span::{ErrorGuaranteed, DUMMY_SP};
89use rustc_type_ir::RegionKind as IrRegionKind;
910pub use rustc_type_ir::RegionVid;
10use std::ops::Deref;
1111use tracing::debug;
1212
1313use crate::ty::{self, BoundVar, TyCtxt, TypeFlags};
compiler/rustc_middle/src/ty/rvalue_scopes.rs+2-1
......@@ -1,9 +1,10 @@
1use crate::middle::region::{Scope, ScopeData, ScopeTree};
21use rustc_hir as hir;
32use rustc_hir::ItemLocalMap;
43use rustc_macros::{HashStable, TyDecodable, TyEncodable};
54use tracing::debug;
65
6use crate::middle::region::{Scope, ScopeData, ScopeTree};
7
78/// `RvalueScopes` is a mapping from sub-expressions to _extended_ lifetime as determined by
89/// rules laid out in `rustc_hir_analysis::check::rvalue_scopes`.
910#[derive(TyEncodable, TyDecodable, Clone, Debug, Default, Eq, PartialEq, HashStable)]
compiler/rustc_middle/src/ty/structural_impls.rs+8-10
......@@ -3,11 +3,8 @@
33//! written by hand, though we've recently added some macros and proc-macros
44//! to help with the tedium.
55
6use crate::mir::interpret;
7use crate::ty::fold::{FallibleTypeFolder, TypeFoldable, TypeSuperFoldable};
8use crate::ty::print::{with_no_trimmed_paths, FmtPrinter, Printer};
9use crate::ty::visit::{TypeSuperVisitable, TypeVisitable, TypeVisitor};
10use crate::ty::{self, InferConst, Lift, Term, TermKind, Ty, TyCtxt};
6use std::fmt::{self, Debug};
7
118use rustc_ast_ir::try_visit;
129use rustc_ast_ir::visit::VisitorResult;
1310use rustc_hir::def::Namespace;
......@@ -15,12 +12,13 @@ use rustc_span::source_map::Spanned;
1512use rustc_target::abi::TyAndLayout;
1613use rustc_type_ir::ConstKind;
1714
18use std::fmt::{self, Debug};
19
2015use super::print::PrettyPrinter;
21use super::{GenericArg, GenericArgKind, Region};
22
23use super::Pattern;
16use super::{GenericArg, GenericArgKind, Pattern, Region};
17use crate::mir::interpret;
18use crate::ty::fold::{FallibleTypeFolder, TypeFoldable, TypeSuperFoldable};
19use crate::ty::print::{with_no_trimmed_paths, FmtPrinter, Printer};
20use crate::ty::visit::{TypeSuperVisitable, TypeVisitable, TypeVisitor};
21use crate::ty::{self, InferConst, Lift, Term, TermKind, Ty, TyCtxt};
2422
2523impl fmt::Debug for ty::TraitDef {
2624 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
compiler/rustc_middle/src/ty/sty.rs+14-15
......@@ -2,14 +2,11 @@
22
33#![allow(rustc::usage_of_ty_tykind)]
44
5use crate::infer::canonical::Canonical;
6use crate::ty::InferTy::*;
7use crate::ty::{
8 self, AdtDef, BoundRegionKind, Discr, Region, Ty, TyCtxt, TypeFlags, TypeSuperVisitable,
9 TypeVisitable, TypeVisitor,
10};
11use crate::ty::{GenericArg, GenericArgs, GenericArgsRef};
12use crate::ty::{List, ParamEnv};
5use std::assert_matches::debug_assert_matches;
6use std::borrow::Cow;
7use std::iter;
8use std::ops::{ControlFlow, Range};
9
1310use hir::def::{CtorKind, DefKind};
1411use rustc_data_structures::captures::Captures;
1512use rustc_errors::{ErrorGuaranteed, MultiSpan};
......@@ -22,16 +19,17 @@ use rustc_span::{Span, DUMMY_SP};
2219use rustc_target::abi::{FieldIdx, VariantIdx, FIRST_VARIANT};
2320use rustc_target::spec::abi;
2421use rustc_type_ir::visit::TypeVisitableExt;
25use std::assert_matches::debug_assert_matches;
26use std::borrow::Cow;
27use std::iter;
28use std::ops::{ControlFlow, Range};
29use ty::util::{AsyncDropGlueMorphology, IntTypeExt};
30
3122use rustc_type_ir::TyKind::*;
3223use rustc_type_ir::{self as ir, BoundVar, CollectAndApply, DynKind};
24use ty::util::{AsyncDropGlueMorphology, IntTypeExt};
3325
3426use super::GenericParamDefKind;
27use crate::infer::canonical::Canonical;
28use crate::ty::InferTy::*;
29use crate::ty::{
30 self, AdtDef, BoundRegionKind, Discr, GenericArg, GenericArgs, GenericArgsRef, List, ParamEnv,
31 Region, Ty, TyCtxt, TypeFlags, TypeSuperVisitable, TypeVisitable, TypeVisitor,
32};
3533
3634// Re-export and re-parameterize some `I = TyCtxt<'tcx>` types here
3735#[rustc_diagnostic_item = "TyKind"]
......@@ -1966,8 +1964,9 @@ impl<'tcx> rustc_type_ir::inherent::Tys<TyCtxt<'tcx>> for &'tcx ty::List<Ty<'tcx
19661964// Some types are used a lot. Make sure they don't unintentionally get bigger.
19671965#[cfg(target_pointer_width = "64")]
19681966mod size_asserts {
1969 use super::*;
19701967 use rustc_data_structures::static_assert_size;
1968
1969 use super::*;
19711970 // tidy-alphabetical-start
19721971 static_assert_size!(ty::RegionKind<'_>, 24);
19731972 static_assert_size!(ty::TyKind<'_>, 32);
compiler/rustc_middle/src/ty/trait_def.rs+2-3
......@@ -1,13 +1,12 @@
11use std::iter;
2use tracing::debug;
32
43use rustc_data_structures::fx::FxIndexMap;
54use rustc_errors::ErrorGuaranteed;
65use rustc_hir as hir;
76use rustc_hir::def::DefKind;
8use rustc_hir::def_id::DefId;
9use rustc_hir::def_id::LOCAL_CRATE;
7use rustc_hir::def_id::{DefId, LOCAL_CRATE};
108use rustc_macros::{Decodable, Encodable, HashStable};
9use tracing::debug;
1110
1211use crate::query::LocalCrate;
1312use crate::traits::specialization_graph;
compiler/rustc_middle/src/ty/typeck_results.rs+15-15
......@@ -1,21 +1,15 @@
1use 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};
1use std::collections::hash_map::Entry;
2use std::hash::Hash;
3use std::iter;
4
105use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
116use rustc_data_structures::unord::{ExtendUnord, UnordItems, UnordSet};
127use rustc_errors::ErrorGuaranteed;
8use rustc_hir::def::{DefKind, Res};
9use rustc_hir::def_id::{DefId, LocalDefId, LocalDefIdMap};
10use rustc_hir::hir_id::OwnerId;
1311use 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,
1913};
2014use rustc_index::IndexVec;
2115use rustc_macros::{HashStable, TyDecodable, TyEncodable, TypeFoldable, TypeVisitable};
......@@ -23,9 +17,15 @@ use rustc_middle::mir::FakeReadCause;
2317use rustc_session::Session;
2418use rustc_span::Span;
2519use rustc_target::abi::{FieldIdx, VariantIdx};
26use std::{collections::hash_map::Entry, hash::Hash, iter};
2720
2821use super::RvalueScopes;
22use crate::hir::place::Place as HirPlace;
23use crate::infer::canonical::Canonical;
24use crate::traits::ObligationCause;
25use crate::ty::{
26 self, tls, BoundVar, CanonicalPolyFnSig, ClosureSizeProfileData, GenericArgKind, GenericArgs,
27 GenericArgsRef, Ty, UserArgs,
28};
2929
3030#[derive(TyEncodable, TyDecodable, Debug, HashStable)]
3131pub struct TypeckResults<'tcx> {
compiler/rustc_middle/src/ty/util.rs+10-9
......@@ -1,13 +1,7 @@
11//! Miscellaneous type-system utilities that are too small to deserve their own modules.
22
3use crate::middle::codegen_fn_attrs::CodegenFnAttrFlags;
4use crate::query::{IntoQueryParam, Providers};
5use crate::ty::layout::{FloatExt, IntegerExt};
6use crate::ty::{
7 self, Asyncness, FallibleTypeFolder, Ty, TyCtxt, TypeFoldable, TypeFolder, TypeSuperFoldable,
8 TypeVisitableExt, Upcast,
9};
10use crate::ty::{GenericArgKind, GenericArgsRef};
3use std::{fmt, iter};
4
115use rustc_apfloat::Float as _;
126use rustc_data_structures::fx::{FxHashMap, FxHashSet};
137use rustc_data_structures::stable_hasher::{Hash128, HashStable, StableHasher};
......@@ -23,9 +17,16 @@ use rustc_span::sym;
2317use rustc_target::abi::{Float, Integer, IntegerType, Size};
2418use rustc_target::spec::abi::Abi;
2519use smallvec::{smallvec, SmallVec};
26use std::{fmt, iter};
2720use tracing::{debug, instrument, trace};
2821
22use crate::middle::codegen_fn_attrs::CodegenFnAttrFlags;
23use crate::query::{IntoQueryParam, Providers};
24use crate::ty::layout::{FloatExt, IntegerExt};
25use crate::ty::{
26 self, Asyncness, FallibleTypeFolder, GenericArgKind, GenericArgsRef, Ty, TyCtxt, TypeFoldable,
27 TypeFolder, TypeSuperFoldable, TypeVisitableExt, Upcast,
28};
29
2930#[derive(Copy, Clone, Debug)]
3031pub struct Discr<'tcx> {
3132 /// Bit representation of the discriminant (e.g., `-128i8` is `0xFF_u128`).
compiler/rustc_middle/src/ty/visit.rs+3-3
......@@ -1,11 +1,11 @@
1use crate::ty::{self, Binder, Ty, TyCtxt, TypeFlags};
1use std::ops::ControlFlow;
22
33use rustc_data_structures::fx::FxHashSet;
44use rustc_type_ir::fold::TypeFoldable;
5use std::ops::ControlFlow;
6
75pub use rustc_type_ir::visit::{TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor};
86
7use crate::ty::{self, Binder, Ty, TyCtxt, TypeFlags};
8
99///////////////////////////////////////////////////////////////////////////
1010// Region folder
1111
compiler/rustc_middle/src/ty/vtable.rs+3-2
......@@ -1,10 +1,11 @@
11use std::fmt;
22
3use crate::mir::interpret::{alloc_range, AllocId, Allocation, Pointer, Scalar};
4use crate::ty::{self, Instance, PolyTraitRef, Ty, TyCtxt};
53use rustc_ast::Mutability;
64use rustc_macros::HashStable;
75
6use crate::mir::interpret::{alloc_range, AllocId, Allocation, Pointer, Scalar};
7use crate::ty::{self, Instance, PolyTraitRef, Ty, TyCtxt};
8
89#[derive(Clone, Copy, PartialEq, HashStable)]
910pub enum VtblEntry<'tcx> {
1011 /// destructor of this type (used in vtable header)
compiler/rustc_middle/src/ty/walk.rs+2-2
......@@ -1,12 +1,12 @@
11//! An iterator over the type substructure.
22//! WARNING: this does not keep track of the region depth.
33
4use crate::ty::{self, Ty};
5use crate::ty::{GenericArg, GenericArgKind};
64use rustc_data_structures::sso::SsoHashSet;
75use smallvec::{smallvec, SmallVec};
86use tracing::debug;
97
8use crate::ty::{self, GenericArg, GenericArgKind, Ty};
9
1010// The TypeWalker's stack is hot enough that it's worth going to some effort to
1111// avoid heap allocations.
1212type TypeWalkerStack<'tcx> = SmallVec<[GenericArg<'tcx>; 8]>;
compiler/rustc_middle/src/util/bug.rs+5-3
......@@ -1,11 +1,13 @@
11// These functions are used by macro expansion for bug! and span_bug!
22
3use crate::ty::{tls, TyCtxt};
4use rustc_errors::MultiSpan;
5use rustc_span::Span;
63use std::fmt;
74use std::panic::{panic_any, Location};
85
6use rustc_errors::MultiSpan;
7use rustc_span::Span;
8
9use crate::ty::{tls, TyCtxt};
10
911#[cold]
1012#[inline(never)]
1113#[track_caller]
compiler/rustc_middle/src/util/call_kind.rs+2-2
......@@ -2,14 +2,14 @@
22//! as well as errors when attempting to call a non-const function in a const
33//! context.
44
5use crate::ty::GenericArgsRef;
6use crate::ty::{AssocItemContainer, Instance, ParamEnv, Ty, TyCtxt};
75use rustc_hir::def_id::DefId;
86use rustc_hir::{lang_items, LangItem};
97use rustc_span::symbol::Ident;
108use rustc_span::{sym, DesugaringKind, Span};
119use tracing::debug;
1210
11use crate::ty::{AssocItemContainer, GenericArgsRef, Instance, ParamEnv, Ty, TyCtxt};
12
1313#[derive(Clone, Copy, PartialEq, Eq, Debug)]
1414pub enum CallDesugaringKind {
1515 /// for _ in x {} calls x.into_iter()
compiler/rustc_middle/src/util/find_self_call.rs+3-3
......@@ -1,10 +1,10 @@
1use crate::mir::*;
2use crate::ty::GenericArgsRef;
3use crate::ty::{self, TyCtxt};
41use rustc_span::def_id::DefId;
52use rustc_span::source_map::Spanned;
63use tracing::debug;
74
5use crate::mir::*;
6use crate::ty::{self, GenericArgsRef, TyCtxt};
7
88/// Checks if the specified `local` is used as the `self` parameter of a method call
99/// in the provided `BasicBlock`. If it is, then the `DefId` of the called method is
1010/// returned.
compiler/rustc_middle/src/values.rs+9-8
......@@ -1,19 +1,20 @@
1use crate::dep_graph::dep_kinds;
2use crate::query::plumbing::CyclePlaceholder;
1use std::collections::VecDeque;
2use std::fmt::Write;
3use std::ops::ControlFlow;
4
35use rustc_data_structures::fx::FxHashSet;
4use rustc_errors::{codes::*, pluralize, struct_span_code_err, Applicability, MultiSpan};
6use rustc_errors::codes::*;
7use rustc_errors::{pluralize, struct_span_code_err, Applicability, MultiSpan};
58use rustc_hir as hir;
69use rustc_hir::def::{DefKind, Res};
7use rustc_middle::ty::Representability;
8use rustc_middle::ty::{self, Ty, TyCtxt};
10use rustc_middle::ty::{self, Representability, Ty, TyCtxt};
911use rustc_query_system::query::{report_cycle, CycleError};
1012use rustc_query_system::Value;
1113use rustc_span::def_id::LocalDefId;
1214use rustc_span::{ErrorGuaranteed, Span};
1315
14use std::collections::VecDeque;
15use std::fmt::Write;
16use std::ops::ControlFlow;
16use crate::dep_graph::dep_kinds;
17use crate::query::plumbing::CyclePlaceholder;
1718
1819impl<'tcx> Value<TyCtxt<'tcx>> for Ty<'_> {
1920 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 @@
1use crate::build::matches::{DeclareLetBindings, EmitStorageLive, ScheduleDrops};
2use crate::build::ForGuard::OutsideGuard;
3use crate::build::{BlockAnd, BlockAndExtension, BlockFrame, Builder};
41use rustc_middle::middle::region::Scope;
5use rustc_middle::span_bug;
2use rustc_middle::mir::*;
63use rustc_middle::thir::*;
7use rustc_middle::{mir::*, ty};
4use rustc_middle::{span_bug, ty};
85use rustc_span::Span;
96use tracing::debug;
107
8use crate::build::matches::{DeclareLetBindings, EmitStorageLive, ScheduleDrops};
9use crate::build::ForGuard::OutsideGuard;
10use crate::build::{BlockAnd, BlockAndExtension, BlockFrame, Builder};
11
1112impl<'a, 'tcx> Builder<'a, 'tcx> {
1213 pub(crate) fn ast_block(
1314 &mut self,
compiler/rustc_mir_build/src/build/cfg.rs+2-1
......@@ -1,10 +1,11 @@
11//! Routines for manipulating the control-flow graph.
22
3use crate::build::CFG;
43use rustc_middle::mir::*;
54use rustc_middle::ty::TyCtxt;
65use tracing::debug;
76
7use crate::build::CFG;
8
89impl<'tcx> CFG<'tcx> {
910 pub(crate) fn block_data(&self, blk: BasicBlock) -> &BasicBlockData<'tcx> {
1011 &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;
2222use rustc_hir::def_id::DefId;
2323use rustc_hir::HirId;
2424use rustc_index::{IndexSlice, IndexVec};
25use rustc_middle::{
26 mir::*,
27 span_bug,
28 thir::*,
29 ty::{ParamEnv, Ty, TyCtxt},
30};
25use rustc_middle::mir::*;
26use rustc_middle::span_bug;
27use rustc_middle::thir::*;
28use rustc_middle::ty::{ParamEnv, Ty, TyCtxt};
3129use rustc_span::Span;
3230
3331mod parse;
compiler/rustc_mir_build/src/build/custom/parse.rs+2-1
......@@ -1,6 +1,7 @@
11use rustc_index::IndexSlice;
2use rustc_middle::mir::*;
3use rustc_middle::thir::*;
24use rustc_middle::ty::{self, Ty};
3use rustc_middle::{mir::*, thir::*};
45use rustc_span::Span;
56
67use super::{PResult, ParseCtxt, ParseError};
compiler/rustc_mir_build/src/build/custom/parse/instruction.rs+4-3
......@@ -1,16 +1,17 @@
11use rustc_middle::mir::interpret::Scalar;
22use rustc_middle::mir::tcx::PlaceTy;
3use rustc_middle::mir::*;
4use rustc_middle::thir::*;
5use rustc_middle::ty;
36use rustc_middle::ty::cast::mir_cast_kind;
4use rustc_middle::{mir::*, thir::*, ty};
57use rustc_span::source_map::Spanned;
68use rustc_span::Span;
79use rustc_target::abi::{FieldIdx, VariantIdx};
810
11use super::{parse_by_kind, PResult, ParseCtxt};
912use crate::build::custom::ParseError;
1013use crate::build::expr::as_constant::as_constant_inner;
1114
12use super::{parse_by_kind, PResult, ParseCtxt};
13
1415impl<'tcx, 'body> ParseCtxt<'tcx, 'body> {
1516 pub(crate) fn parse_statement(&self, expr_id: ExprId) -> PResult<StatementKind<'tcx>> {
1617 parse_by_kind!(self, expr_id, _, "statement",
compiler/rustc_mir_build/src/build/expr/as_constant.rs+3-3
......@@ -1,19 +1,19 @@
11//! See docs in build/expr/mod.rs
22
3use crate::build::{parse_float_into_constval, Builder};
43use rustc_ast as ast;
54use rustc_hir::LangItem;
6use rustc_middle::mir;
75use rustc_middle::mir::interpret::{Allocation, LitToConstError, LitToConstInput, Scalar};
86use rustc_middle::mir::*;
97use rustc_middle::thir::*;
108use rustc_middle::ty::{
119 self, CanonicalUserType, CanonicalUserTypeAnnotation, Ty, TyCtxt, UserTypeAnnotationIndex,
1210};
13use rustc_middle::{bug, span_bug};
11use rustc_middle::{bug, mir, span_bug};
1412use rustc_target::abi::Size;
1513use tracing::{instrument, trace};
1614
15use crate::build::{parse_float_into_constval, Builder};
16
1717impl<'a, 'tcx> Builder<'a, 'tcx> {
1818 /// Compile `expr`, yielding a compile-time constant. Assumes that
1919 /// `expr` is a valid compile-time constant!
compiler/rustc_mir_build/src/build/expr/as_operand.rs+3-2
......@@ -1,12 +1,13 @@
11//! See docs in build/expr/mod.rs
22
3use crate::build::expr::category::Category;
4use crate::build::{BlockAnd, BlockAndExtension, Builder, NeedsTemporary};
53use rustc_middle::middle::region;
64use rustc_middle::mir::*;
75use rustc_middle::thir::*;
86use tracing::{debug, instrument};
97
8use crate::build::expr::category::Category;
9use crate::build::{BlockAnd, BlockAndExtension, Builder, NeedsTemporary};
10
1011impl<'a, 'tcx> Builder<'a, 'tcx> {
1112 /// Returns an operand suitable for use until the end of the current
1213 /// scope expression.
compiler/rustc_mir_build/src/build/expr/as_place.rs+8-9
......@@ -1,24 +1,23 @@
11//! See docs in build/expr/mod.rs
22
3use crate::build::expr::category::Category;
4use crate::build::ForGuard::{OutsideGuard, RefWithinGuard};
5use crate::build::{BlockAnd, BlockAndExtension, Builder, Capture, CaptureMap};
3use std::assert_matches::assert_matches;
4use std::iter;
5
66use rustc_hir::def_id::LocalDefId;
7use rustc_middle::hir::place::Projection as HirProjection;
8use rustc_middle::hir::place::ProjectionKind as HirProjectionKind;
7use rustc_middle::hir::place::{Projection as HirProjection, ProjectionKind as HirProjectionKind};
98use rustc_middle::middle::region;
109use rustc_middle::mir::AssertKind::BoundsCheck;
1110use rustc_middle::mir::*;
1211use rustc_middle::thir::*;
13use rustc_middle::ty::AdtDef;
14use rustc_middle::ty::{self, CanonicalUserTypeAnnotation, Ty, Variance};
12use rustc_middle::ty::{self, AdtDef, CanonicalUserTypeAnnotation, Ty, Variance};
1513use rustc_middle::{bug, span_bug};
1614use rustc_span::Span;
1715use rustc_target::abi::{FieldIdx, VariantIdx, FIRST_VARIANT};
1816use tracing::{debug, instrument, trace};
1917
20use std::assert_matches::assert_matches;
21use std::iter;
18use crate::build::expr::category::Category;
19use crate::build::ForGuard::{OutsideGuard, RefWithinGuard};
20use crate::build::{BlockAnd, BlockAndExtension, Builder, Capture, CaptureMap};
2221
2322/// The "outermost" place that holds this value.
2423#[derive(Copy, Clone, Debug, PartialEq)]
compiler/rustc_mir_build/src/build/expr/as_rvalue.rs+8-8
......@@ -1,14 +1,7 @@
11//! See docs in `build/expr/mod.rs`.
22
3use rustc_index::{Idx, IndexVec};
4use rustc_middle::ty::util::IntTypeExt;
5use rustc_span::source_map::Spanned;
6use rustc_target::abi::{Abi, FieldIdx, Primitive};
7
8use crate::build::expr::as_place::PlaceBase;
9use crate::build::expr::category::{Category, RvalueFunc};
10use crate::build::{BlockAnd, BlockAndExtension, Builder, NeedsTemporary};
113use rustc_hir::lang_items::LangItem;
4use rustc_index::{Idx, IndexVec};
125use rustc_middle::bug;
136use rustc_middle::middle::region;
147use rustc_middle::mir::interpret::Scalar;
......@@ -16,10 +9,17 @@ use rustc_middle::mir::*;
169use rustc_middle::thir::*;
1710use rustc_middle::ty::cast::{mir_cast_kind, CastTy};
1811use rustc_middle::ty::layout::IntegerExt;
12use rustc_middle::ty::util::IntTypeExt;
1913use rustc_middle::ty::{self, Ty, UpvarArgs};
14use rustc_span::source_map::Spanned;
2015use rustc_span::{Span, DUMMY_SP};
16use rustc_target::abi::{Abi, FieldIdx, Primitive};
2117use tracing::debug;
2218
19use crate::build::expr::as_place::PlaceBase;
20use crate::build::expr::category::{Category, RvalueFunc};
21use crate::build::{BlockAnd, BlockAndExtension, Builder, NeedsTemporary};
22
2323impl<'a, 'tcx> Builder<'a, 'tcx> {
2424 /// Returns an rvalue suitable for use until the end of the current
2525 /// scope expression.
compiler/rustc_mir_build/src/build/expr/as_temp.rs+3-2
......@@ -1,13 +1,14 @@
11//! See docs in build/expr/mod.rs
22
3use crate::build::scope::DropKind;
4use crate::build::{BlockAnd, BlockAndExtension, Builder};
53use rustc_data_structures::stack::ensure_sufficient_stack;
64use rustc_middle::middle::region;
75use rustc_middle::mir::*;
86use rustc_middle::thir::*;
97use tracing::{debug, instrument};
108
9use crate::build::scope::DropKind;
10use crate::build::{BlockAnd, BlockAndExtension, Builder};
11
1112impl<'a, 'tcx> Builder<'a, 'tcx> {
1213 /// Compile `expr` into a fresh temporary. This is used when building
1314 /// 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 @@
11//! See docs in build/expr/mod.rs
22
3use crate::build::expr::category::{Category, RvalueFunc};
4use crate::build::matches::DeclareLetBindings;
5use crate::build::{BlockAnd, BlockAndExtension, BlockFrame, Builder, NeedsTemporary};
3use std::iter;
4
65use rustc_ast::InlineAsmOptions;
76use rustc_data_structures::fx::FxHashMap;
87use rustc_data_structures::stack::ensure_sufficient_stack;
......@@ -12,9 +11,12 @@ use rustc_middle::span_bug;
1211use rustc_middle::thir::*;
1312use rustc_middle::ty::CanonicalUserTypeAnnotation;
1413use rustc_span::source_map::Spanned;
15use std::iter;
1614use tracing::{debug, instrument};
1715
16use crate::build::expr::category::{Category, RvalueFunc};
17use crate::build::matches::DeclareLetBindings;
18use crate::build::{BlockAnd, BlockAndExtension, BlockFrame, Builder, NeedsTemporary};
19
1820impl<'a, 'tcx> Builder<'a, 'tcx> {
1921 /// Compile `expr`, storing the result into `destination`, which
2022 /// is assumed to be uninitialized.
compiler/rustc_mir_build/src/build/expr/stmt.rs+3-2
......@@ -1,5 +1,3 @@
1use crate::build::scope::BreakableTarget;
2use crate::build::{BlockAnd, BlockAndExtension, BlockFrame, Builder};
31use rustc_middle::middle::region;
42use rustc_middle::mir::*;
53use rustc_middle::span_bug;
......@@ -7,6 +5,9 @@ use rustc_middle::thir::*;
75use rustc_span::source_map::Spanned;
86use tracing::debug;
97
8use crate::build::scope::BreakableTarget;
9use crate::build::{BlockAnd, BlockAndExtension, BlockFrame, Builder};
10
1011impl<'a, 'tcx> Builder<'a, 'tcx> {
1112 /// Builds a block of MIR statements to evaluate the THIR `expr`.
1213 ///
compiler/rustc_mir_build/src/build/matches/mod.rs+9-6
......@@ -5,12 +5,8 @@
55//! This also includes code for pattern bindings in `let` statements and
66//! function parameters.
77
8use crate::build::expr::as_place::PlaceBuilder;
9use crate::build::scope::DropKind;
10use crate::build::ForGuard::{self, OutsideGuard, RefWithinGuard};
11use crate::build::{BlockAnd, BlockAndExtension, Builder};
12use crate::build::{GuardFrame, GuardFrameLocal, LocalsForNode};
13use rustc_data_structures::{fx::FxIndexMap, stack::ensure_sufficient_stack};
8use rustc_data_structures::fx::FxIndexMap;
9use rustc_data_structures::stack::ensure_sufficient_stack;
1410use rustc_hir::{BindingMode, ByRef};
1511use rustc_middle::bug;
1612use rustc_middle::middle::region;
......@@ -23,6 +19,13 @@ use rustc_target::abi::VariantIdx;
2319use tracing::{debug, instrument};
2420use util::visit_bindings;
2521
22use crate::build::expr::as_place::PlaceBuilder;
23use crate::build::scope::DropKind;
24use crate::build::ForGuard::{self, OutsideGuard, RefWithinGuard};
25use crate::build::{
26 BlockAnd, BlockAndExtension, Builder, GuardFrame, GuardFrameLocal, LocalsForNode,
27};
28
2629// helper functions, broken out by category:
2730mod match_pair;
2831mod simplify;
compiler/rustc_mir_build/src/build/matches/simplify.rs+4-3
......@@ -12,11 +12,12 @@
1212//! sort of test: for example, testing which variant an enum is, or
1313//! testing a value against a constant.
1414
15use crate::build::matches::{MatchPairTree, PatternExtraData, TestCase};
16use crate::build::Builder;
15use std::mem;
16
1717use tracing::{debug, instrument};
1818
19use std::mem;
19use crate::build::matches::{MatchPairTree, PatternExtraData, TestCase};
20use crate::build::Builder;
2021
2122impl<'a, 'tcx> Builder<'a, 'tcx> {
2223 /// 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 @@
55// identify what tests are needed, perform the tests, and then filter
66// the candidates based on the result.
77
8use crate::build::matches::{Candidate, MatchPairTree, Test, TestBranch, TestCase, TestKind};
9use crate::build::Builder;
8use std::cmp::Ordering;
9
1010use rustc_data_structures::fx::FxIndexMap;
1111use rustc_hir::{LangItem, RangeEnd};
1212use rustc_middle::mir::*;
13use rustc_middle::ty::adjustment::PointerCoercion;
1314use rustc_middle::ty::util::IntTypeExt;
14use rustc_middle::ty::GenericArg;
15use rustc_middle::ty::{self, adjustment::PointerCoercion, Ty, TyCtxt};
15use rustc_middle::ty::{self, GenericArg, Ty, TyCtxt};
1616use rustc_middle::{bug, span_bug};
1717use rustc_span::def_id::DefId;
1818use rustc_span::source_map::Spanned;
......@@ -20,7 +20,8 @@ use rustc_span::symbol::{sym, Symbol};
2020use rustc_span::{Span, DUMMY_SP};
2121use tracing::{debug, instrument};
2222
23use std::cmp::Ordering;
23use crate::build::matches::{Candidate, MatchPairTree, Test, TestBranch, TestCase, TestKind};
24use crate::build::Builder;
2425
2526impl<'a, 'tcx> Builder<'a, 'tcx> {
2627 /// 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 @@
11use std::marker::PhantomData;
22
3use crate::build::expr::as_place::PlaceBase;
4use crate::build::matches::{Binding, Candidate, FlatPat, MatchPairTree, TestCase};
5use crate::build::Builder;
63use rustc_data_structures::fx::FxIndexMap;
74use rustc_middle::mir::*;
85use rustc_middle::ty::Ty;
96use rustc_span::Span;
107use tracing::debug;
118
9use crate::build::expr::as_place::PlaceBase;
10use crate::build::matches::{Binding, Candidate, FlatPat, MatchPairTree, TestCase};
11use crate::build::Builder;
12
1213impl<'a, 'tcx> Builder<'a, 'tcx> {
1314 /// Creates a false edge to `imaginary_target` and a real edge to
1415 /// 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 @@
11//! Miscellaneous builder routines that are not specific to building any particular
22//! kind of thing.
33
4use crate::build::Builder;
5
64use rustc_middle::mir::*;
75use rustc_middle::ty::{self, Ty};
86use rustc_span::Span;
97use rustc_trait_selection::infer::InferCtxtExt;
108use tracing::debug;
119
10use crate::build::Builder;
11
1212impl<'a, 'tcx> Builder<'a, 'tcx> {
1313 /// Adds a new temporary value of type `ty` storing the result of
1414 /// evaluating `expr`.
compiler/rustc_mir_build/src/build/mod.rs+3-4
......@@ -1,5 +1,3 @@
1use crate::build::expr::as_place::PlaceBuilder;
2use crate::build::scope::DropKind;
31use itertools::Itertools;
42use rustc_apfloat::ieee::{Double, Half, Quad, Single};
53use rustc_apfloat::Float;
......@@ -21,12 +19,13 @@ use rustc_middle::thir::{self, ExprId, LintLevel, LocalVarId, Param, ParamId, Pa
2119use rustc_middle::ty::{self, ScalarInt, Ty, TyCtxt, TypeVisitableExt};
2220use rustc_middle::{bug, span_bug};
2321use rustc_span::symbol::sym;
24use rustc_span::Span;
25use rustc_span::Symbol;
22use rustc_span::{Span, Symbol};
2623use rustc_target::abi::FieldIdx;
2724use rustc_target::spec::abi::Abi;
2825
2926use super::lints;
27use crate::build::expr::as_place::PlaceBuilder;
28use crate::build::scope::DropKind;
3029
3130pub(crate) fn closure_saved_names_of_captured_variables<'tcx>(
3231 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`,
8383
8484use std::mem;
8585
86use crate::build::{BlockAnd, BlockAndExtension, BlockFrame, Builder, CFG};
8786use rustc_data_structures::fx::FxHashMap;
8887use rustc_hir::HirId;
8988use rustc_index::{IndexSlice, IndexVec};
......@@ -96,6 +95,8 @@ use rustc_span::source_map::Spanned;
9695use rustc_span::{Span, DUMMY_SP};
9796use tracing::{debug, instrument};
9897
98use crate::build::{BlockAnd, BlockAndExtension, BlockFrame, Builder, CFG};
99
99100#[derive(Debug)]
100101pub(crate) struct Scopes<'tcx> {
101102 scopes: Vec<Scope>,
compiler/rustc_mir_build/src/check_unsafety.rs+5-5
......@@ -1,5 +1,6 @@
1use crate::build::ExprCategory;
2use crate::errors::*;
1use std::borrow::Cow;
2use std::mem;
3use std::ops::Bound;
34
45use rustc_errors::DiagArgValue;
56use rustc_hir::def::DefKind;
......@@ -16,9 +17,8 @@ use rustc_span::def_id::{DefId, LocalDefId};
1617use rustc_span::symbol::Symbol;
1718use rustc_span::{sym, Span};
1819
19use std::borrow::Cow;
20use std::mem;
21use std::ops::Bound;
20use crate::build::ExprCategory;
21use crate::errors::*;
2222
2323struct UnsafetyVisitor<'a, 'tcx> {
2424 tcx: TyCtxt<'tcx>,
compiler/rustc_mir_build/src/errors.rs+7-5
......@@ -1,15 +1,17 @@
1use crate::fluent_generated as fluent;
1use rustc_errors::codes::*;
22use 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,
55};
6use rustc_errors::{DiagArgValue, DiagCtxtHandle};
76use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
87use rustc_middle::ty::{self, Ty};
9use rustc_pattern_analysis::{errors::Uncovered, rustc::RustcPatCtxt};
8use rustc_pattern_analysis::errors::Uncovered;
9use rustc_pattern_analysis::rustc::RustcPatCtxt;
1010use rustc_span::symbol::Symbol;
1111use rustc_span::Span;
1212
13use crate::fluent_generated as fluent;
14
1315#[derive(LintDiagnostic)]
1416#[diag(mir_build_unconditional_recursion)]
1517#[help]
compiler/rustc_mir_build/src/lints.rs+5-4
......@@ -1,14 +1,15 @@
1use crate::errors::UnconditionalRecursion;
1use std::ops::ControlFlow;
2
23use rustc_data_structures::graph::iterate::{
34 NodeStatus, TriColorDepthFirstSearch, TriColorVisitor,
45};
56use rustc_hir::def::DefKind;
67use rustc_middle::mir::{self, BasicBlock, BasicBlocks, Body, Terminator, TerminatorKind};
7use rustc_middle::ty::{self, Instance, Ty, TyCtxt};
8use rustc_middle::ty::{GenericArg, GenericArgs};
8use rustc_middle::ty::{self, GenericArg, GenericArgs, Instance, Ty, TyCtxt};
99use rustc_session::lint::builtin::UNCONDITIONAL_RECURSION;
1010use rustc_span::Span;
11use std::ops::ControlFlow;
11
12use crate::errors::UnconditionalRecursion;
1213
1314pub(crate) fn check<'tcx>(tcx: TyCtxt<'tcx>, body: &Body<'tcx>) {
1415 check_call_recursion(tcx, body);
compiler/rustc_mir_build/src/thir/cx/block.rs+2-2
......@@ -1,5 +1,3 @@
1use crate::thir::cx::Cx;
2
31use rustc_hir as hir;
42use rustc_index::Idx;
53use rustc_middle::middle::region;
......@@ -8,6 +6,8 @@ use rustc_middle::ty;
86use rustc_middle::ty::CanonicalUserTypeAnnotation;
97use tracing::debug;
108
9use crate::thir::cx::Cx;
10
1111impl<'tcx> Cx<'tcx> {
1212 pub(crate) fn mirror_block(&mut self, block: &'tcx hir::Block<'tcx>) -> BlockId {
1313 // 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 @@
1use crate::errors;
2use crate::thir::cx::region::Scope;
3use crate::thir::cx::Cx;
4use crate::thir::util::UserAnnotatedTyHelpers;
51use itertools::Itertools;
62use rustc_data_structures::stack::ensure_sufficient_stack;
73use rustc_hir as hir;
84use rustc_hir::def::{CtorKind, CtorOf, DefKind, Res};
95use rustc_index::Idx;
10use rustc_middle::hir::place::Place as HirPlace;
11use rustc_middle::hir::place::PlaceBase as HirPlaceBase;
12use rustc_middle::hir::place::ProjectionKind as HirProjectionKind;
6use rustc_middle::hir::place::{
7 Place as HirPlace, PlaceBase as HirPlaceBase, ProjectionKind as HirProjectionKind,
8};
139use rustc_middle::middle::region;
1410use rustc_middle::mir::{self, BinOp, BorrowKind, UnOp};
1511use rustc_middle::thir::*;
1612use rustc_middle::ty::adjustment::{
1713 Adjust, Adjustment, AutoBorrow, AutoBorrowMutability, PointerCoercion,
1814};
19use rustc_middle::ty::GenericArgs;
2015use rustc_middle::ty::{
21 self, AdtKind, InlineConstArgs, InlineConstArgsParts, ScalarInt, Ty, UpvarArgs, UserType,
16 self, AdtKind, GenericArgs, InlineConstArgs, InlineConstArgsParts, ScalarInt, Ty, UpvarArgs,
17 UserType,
2218};
2319use rustc_middle::{bug, span_bug};
2420use rustc_span::{sym, Span};
2521use rustc_target::abi::{FieldIdx, FIRST_VARIANT};
2622use tracing::{debug, info, instrument, trace};
2723
24use crate::errors;
25use crate::thir::cx::region::Scope;
26use crate::thir::cx::Cx;
27use crate::thir::util::UserAnnotatedTyHelpers;
28
2829impl<'tcx> Cx<'tcx> {
2930 pub(crate) fn mirror_expr(&mut self, expr: &'tcx hir::Expr<'tcx>) -> ExprId {
3031 // `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 @@
22//! structures into the THIR. The `builder` is generally ignorant of the tcx,
33//! etc., and instead goes through the `Cx` for most of its work.
44
5use crate::thir::pattern::pat_from_hir;
6use crate::thir::util::UserAnnotatedTyHelpers;
7
85use rustc_data_structures::steal::Steal;
96use rustc_errors::ErrorGuaranteed;
107use rustc_hir as hir;
118use rustc_hir::def::DefKind;
129use rustc_hir::def_id::{DefId, LocalDefId};
1310use rustc_hir::lang_items::LangItem;
14use rustc_hir::HirId;
15use rustc_hir::Node;
11use rustc_hir::{HirId, Node};
1612use rustc_middle::bug;
1713use rustc_middle::middle::region;
1814use rustc_middle::thir::*;
1915use rustc_middle::ty::{self, RvalueScopes, TyCtxt};
2016use tracing::instrument;
2117
18use crate::thir::pattern::pat_from_hir;
19use crate::thir::util::UserAnnotatedTyHelpers;
20
2221pub(crate) fn thir_body(
2322 tcx: TyCtxt<'_>,
2423 owner_def: LocalDefId,
compiler/rustc_mir_build/src/thir/pattern/check_match.rs+5-4
......@@ -1,11 +1,9 @@
1use crate::errors::*;
2use crate::fluent_generated as fluent;
3
41use rustc_arena::{DroplessArena, TypedArena};
52use rustc_ast::Mutability;
63use rustc_data_structures::fx::FxIndexSet;
74use rustc_data_structures::stack::ensure_sufficient_stack;
8use rustc_errors::{codes::*, struct_span_code_err, Applicability, ErrorGuaranteed, MultiSpan};
5use rustc_errors::codes::*;
6use rustc_errors::{struct_span_code_err, Applicability, ErrorGuaranteed, MultiSpan};
97use rustc_hir::def::*;
108use rustc_hir::def_id::LocalDefId;
119use rustc_hir::{self as hir, BindingMode, ByRef, HirId};
......@@ -27,6 +25,9 @@ use rustc_span::hygiene::DesugaringKind;
2725use rustc_span::{sym, Span};
2826use tracing::instrument;
2927
28use crate::errors::*;
29use crate::fluent_generated as fluent;
30
3031pub(crate) fn check_match(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(), ErrorGuaranteed> {
3132 let typeck_results = tcx.typeck(def_id);
3233 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;
77use rustc_middle::mir;
88use rustc_middle::mir::interpret::ErrorHandled;
99use rustc_middle::thir::{FieldPat, Pat, PatKind};
10use rustc_middle::ty::TypeVisitableExt;
11use rustc_middle::ty::{self, Ty, TyCtxt, ValTree};
10use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitableExt, ValTree};
1211use rustc_span::Span;
1312use rustc_target::abi::{FieldIdx, VariantIdx};
1413use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt;
compiler/rustc_mir_build/src/thir/pattern/mod.rs+4-5
......@@ -3,10 +3,7 @@
33mod check_match;
44mod const_to_pat;
55
6pub(crate) use self::check_match::check_match;
7
8use crate::errors::*;
9use crate::thir::util::UserAnnotatedTyHelpers;
6use std::cmp::Ordering;
107
118use rustc_errors::codes::*;
129use rustc_hir::def::{CtorOf, DefKind, Res};
......@@ -26,7 +23,9 @@ use rustc_span::{ErrorGuaranteed, Span};
2623use rustc_target::abi::{FieldIdx, Integer};
2724use tracing::{debug, instrument};
2825
29use std::cmp::Ordering;
26pub(crate) use self::check_match::check_match;
27use crate::errors::*;
28use crate::thir::util::UserAnnotatedTyHelpers;
3029
3130struct PatCtxt<'a, 'tcx> {
3231 tcx: TyCtxt<'tcx>,
compiler/rustc_mir_build/src/thir/print.rs+2-1
......@@ -1,8 +1,9 @@
1use std::fmt::{self, Write};
2
13use rustc_middle::query::TyCtxtAt;
24use rustc_middle::thir::*;
35use rustc_middle::ty;
46use rustc_span::def_id::LocalDefId;
5use std::fmt::{self, Write};
67
78pub(crate) fn thir_tree(tcx: TyCtxtAt<'_>, owner_def: LocalDefId) -> String {
89 match super::cx::thir_body(*tcx, owner_def) {
compiler/rustc_mir_dataflow/src/drop_flag_effects.rs+1-1
......@@ -1,10 +1,10 @@
1use crate::elaborate_drops::DropFlagState;
21use rustc_middle::mir::{self, Body, Location, Terminator, TerminatorKind};
32use rustc_target::abi::VariantIdx;
43use tracing::debug;
54
65use super::move_paths::{InitKind, LookupResult, MoveData, MovePathIndex};
76use super::MoveDataParamEnv;
7use crate::elaborate_drops::DropFlagState;
88
99pub fn move_path_children_matching<'tcx, F>(
1010 move_data: &MoveData<'tcx>,
compiler/rustc_mir_dataflow/src/elaborate_drops.rs+3-3
......@@ -1,3 +1,5 @@
1use std::{fmt, iter};
2
13use rustc_hir::lang_items::LangItem;
24use rustc_index::Idx;
35use rustc_middle::mir::patch::MirPatch;
......@@ -5,12 +7,10 @@ use rustc_middle::mir::*;
57use rustc_middle::span_bug;
68use rustc_middle::traits::Reveal;
79use rustc_middle::ty::util::IntTypeExt;
8use rustc_middle::ty::GenericArgsRef;
9use rustc_middle::ty::{self, Ty, TyCtxt};
10use rustc_middle::ty::{self, GenericArgsRef, Ty, TyCtxt};
1011use rustc_span::source_map::Spanned;
1112use rustc_span::DUMMY_SP;
1213use rustc_target::abi::{FieldIdx, VariantIdx, FIRST_VARIANT};
13use std::{fmt, iter};
1414use tracing::{debug, instrument};
1515
1616/// The value of an inserted drop flag.
compiler/rustc_mir_dataflow/src/framework/cursor.rs+1-2
......@@ -1,7 +1,5 @@
11//! Random access inspection of the results of a dataflow analysis.
22
3use crate::framework::BitSetExt;
4
53use std::cmp::Ordering;
64
75#[cfg(debug_assertions)]
......@@ -9,6 +7,7 @@ use rustc_index::bit_set::BitSet;
97use rustc_middle::mir::{self, BasicBlock, Location};
108
119use super::{Analysis, Direction, Effect, EffectIndex, Results};
10use crate::framework::BitSetExt;
1211
1312/// Allows random access inspection of the results of a dataflow analysis.
1413///
compiler/rustc_mir_dataflow/src/framework/direction.rs+2-1
......@@ -1,7 +1,8 @@
1use std::ops::RangeInclusive;
2
13use rustc_middle::mir::{
24 self, BasicBlock, CallReturnPlaces, Location, SwitchTargets, TerminatorEdges,
35};
4use std::ops::RangeInclusive;
56
67use super::visitor::{ResultsVisitable, ResultsVisitor};
78use super::{Analysis, Effect, EffectIndex, GenKillAnalysis, GenKillSet, SwitchIntTarget};
compiler/rustc_mir_dataflow/src/framework/engine.rs+8-12
......@@ -1,32 +1,28 @@
11//! A solver for dataflow problems.
22
3use crate::errors::{
4 DuplicateValuesFor, PathMustEndInFilename, RequiresAnArgument, UnknownFormatter,
5};
6use crate::framework::BitSetExt;
7
83use std::ffi::OsString;
94use std::path::PathBuf;
105
11use rustc_ast as ast;
126use rustc_data_structures::work_queue::WorkQueue;
13use rustc_graphviz as dot;
147use rustc_hir::def_id::DefId;
158use rustc_index::{Idx, IndexVec};
169use rustc_middle::bug;
17use rustc_middle::mir::{self, traversal, BasicBlock};
18use rustc_middle::mir::{create_dump_file, dump_enabled};
10use rustc_middle::mir::{self, create_dump_file, dump_enabled, traversal, BasicBlock};
1911use rustc_middle::ty::print::with_no_trimmed_paths;
2012use rustc_middle::ty::TyCtxt;
2113use rustc_span::symbol::{sym, Symbol};
2214use tracing::{debug, error};
15use {rustc_ast as ast, rustc_graphviz as dot};
2316
2417use super::fmt::DebugWithContext;
25use super::graphviz;
2618use 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,
2921};
22use crate::errors::{
23 DuplicateValuesFor, PathMustEndInFilename, RequiresAnArgument, UnknownFormatter,
24};
25use crate::framework::BitSetExt;
3026
3127pub type EntrySets<'tcx, A> = IndexVec<BasicBlock, <A as AnalysisDomain<'tcx>>::Domain>;
3228
compiler/rustc_mir_dataflow/src/framework/fmt.rs+4-2
......@@ -1,10 +1,12 @@
11//! Custom formatting traits used when outputting Graphviz diagrams with the results of a dataflow
22//! analysis.
33
4use super::lattice::MaybeReachable;
4use std::fmt;
5
56use rustc_index::bit_set::{BitSet, ChunkedBitSet, HybridBitSet};
67use rustc_index::Idx;
7use std::fmt;
8
9use super::lattice::MaybeReachable;
810
911/// An extension to `fmt::Debug` for data that can be better printed with some auxiliary data `C`.
1012pub 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};
88use regex::Regex;
99use rustc_graphviz as dot;
1010use rustc_index::bit_set::BitSet;
11use rustc_middle::mir::graphviz_safe_def_name;
12use rustc_middle::mir::{self, BasicBlock, Body, Location};
11use rustc_middle::mir::{self, graphviz_safe_def_name, BasicBlock, Body, Location};
1312
1413use super::fmt::{DebugDiffWithAdapter, DebugWithAdapter, DebugWithContext};
1514use super::{Analysis, CallReturnPlaces, Direction, Results, ResultsCursor, ResultsVisitor};
compiler/rustc_mir_dataflow/src/framework/lattice.rs+4-2
......@@ -38,10 +38,12 @@
3838//! [Hasse diagram]: https://en.wikipedia.org/wiki/Hasse_diagram
3939//! [poset]: https://en.wikipedia.org/wiki/Partially_ordered_set
4040
41use crate::framework::BitSetExt;
41use std::iter;
42
4243use rustc_index::bit_set::{BitSet, ChunkedBitSet, HybridBitSet};
4344use rustc_index::{Idx, IndexVec};
44use std::iter;
45
46use crate::framework::BitSetExt;
4547
4648/// A [partially ordered set][poset] that has a [least upper bound][lub] for any pair of elements
4749/// 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}
55use rustc_middle::ty::{self, TyCtxt};
66use tracing::{debug, instrument};
77
8use crate::drop_flag_effects_for_function_entry;
9use crate::drop_flag_effects_for_location;
108use crate::elaborate_drops::DropFlagState;
119use crate::framework::SwitchIntEdgeEffects;
1210use crate::move_paths::{HasMoveData, InitIndex, InitKind, LookupResult, MoveData, MovePathIndex};
13use crate::on_lookup_result_bits;
14use crate::MoveDataParamEnv;
15use crate::{drop_flag_effects, on_all_children_bits};
16use crate::{lattice, AnalysisDomain, GenKill, GenKillAnalysis, MaybeReachable};
11use 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};
1716
1817/// `MaybeInitializedPlaces` tracks all places that might be
1918/// 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;
77mod liveness;
88mod storage_liveness;
99
10pub use self::borrowed_locals::borrowed_locals;
11pub use self::borrowed_locals::MaybeBorrowedLocals;
10pub use self::borrowed_locals::{borrowed_locals, MaybeBorrowedLocals};
1211pub use self::initialized::{
1312 DefinitelyInitializedPlaces, EverInitializedPlaces, MaybeInitializedPlaces,
1413 MaybeUninitializedPlaces,
1514};
16pub use self::liveness::MaybeLiveLocals;
17pub use self::liveness::MaybeTransitiveLiveLocals;
18pub use self::liveness::TransferFunction as LivenessTransferFunction;
15pub use self::liveness::{
16 MaybeLiveLocals, MaybeTransitiveLiveLocals, TransferFunction as LivenessTransferFunction,
17};
1918pub use self::storage_liveness::{MaybeRequiresStorage, MaybeStorageDead, MaybeStorageLive};
compiler/rustc_mir_dataflow/src/impls/storage_liveness.rs+2-2
......@@ -1,9 +1,9 @@
1use std::borrow::Cow;
2
13use rustc_index::bit_set::BitSet;
24use rustc_middle::mir::visit::{NonMutatingUseContext, PlaceContext, Visitor};
35use rustc_middle::mir::*;
46
5use std::borrow::Cow;
6
77use super::MaybeBorrowedLocals;
88use crate::{GenKill, ResultsCursor};
99
compiler/rustc_mir_dataflow/src/move_paths/builder.rs+4-4
......@@ -1,3 +1,5 @@
1use std::mem;
2
13use rustc_index::IndexVec;
24use rustc_middle::mir::tcx::{PlaceTy, RvalueInitializationState};
35use rustc_middle::mir::*;
......@@ -6,12 +8,10 @@ use rustc_middle::{bug, span_bug};
68use smallvec::{smallvec, SmallVec};
79use tracing::debug;
810
9use std::mem;
10
1111use super::abs_domain::Lift;
12use super::{Init, InitIndex, InitKind, InitLocation, LookupResult};
1312use super::{
14 LocationMap, MoveData, MoveOut, MoveOutIndex, MovePath, MovePathIndex, MovePathLookup,
13 Init, InitIndex, InitKind, InitLocation, LocationMap, LookupResult, MoveData, MoveOut,
14 MoveOutIndex, MovePath, MovePathIndex, MovePathLookup,
1515};
1616
1717struct MoveDataBuilder<'a, 'tcx, F> {
compiler/rustc_mir_dataflow/src/move_paths/mod.rs+4-4
......@@ -1,4 +1,6 @@
1use crate::un_derefer::UnDerefer;
1use std::fmt;
2use std::ops::{Index, IndexMut};
3
24use rustc_data_structures::fx::FxHashMap;
35use rustc_index::{IndexSlice, IndexVec};
46use rustc_middle::mir::*;
......@@ -6,10 +8,8 @@ use rustc_middle::ty::{ParamEnv, Ty, TyCtxt};
68use rustc_span::Span;
79use smallvec::SmallVec;
810
9use std::fmt;
10use std::ops::{Index, IndexMut};
11
1211use self::abs_domain::{AbstractElem, Lift};
12use crate::un_derefer::UnDerefer;
1313
1414mod abs_domain;
1515
compiler/rustc_mir_dataflow/src/points.rs+3-3
......@@ -1,10 +1,10 @@
1use crate::framework::{visit_results, ResultsVisitable, ResultsVisitor};
21use rustc_index::bit_set::BitSet;
32use rustc_index::interval::SparseIntervalMatrix;
4use rustc_index::Idx;
5use rustc_index::IndexVec;
3use rustc_index::{Idx, IndexVec};
64use rustc_middle::mir::{self, BasicBlock, Body, Location};
75
6use crate::framework::{visit_results, ResultsVisitable, ResultsVisitor};
7
88/// Maps between a `Location` and a `PointIndex` (and vice versa).
99pub struct DenseLocationMap {
1010 /// For each basic block, how many points are contained within?
compiler/rustc_mir_dataflow/src/rustc_peek.rs+11-13
......@@ -1,3 +1,12 @@
1use rustc_ast::MetaItem;
2use rustc_hir::def_id::DefId;
3use rustc_index::bit_set::BitSet;
4use rustc_middle::mir::{self, Body, Local, Location, MirPass};
5use rustc_middle::ty::{self, Ty, TyCtxt};
6use rustc_span::symbol::{sym, Symbol};
7use rustc_span::Span;
8use tracing::{debug, info};
9
110use crate::errors::{
211 PeekArgumentNotALocal, PeekArgumentUntracked, PeekBitNotSet, PeekMustBeNotTemporary,
312 PeekMustBePlaceOrRefPlace, StopAfterDataFlowEndedCompilation,
......@@ -6,19 +15,8 @@ use crate::framework::BitSetExt;
615use crate::impls::{
716 DefinitelyInitializedPlaces, MaybeInitializedPlaces, MaybeLiveLocals, MaybeUninitializedPlaces,
817};
9use crate::move_paths::{HasMoveData, MoveData};
10use crate::move_paths::{LookupResult, MovePathIndex};
11use crate::MoveDataParamEnv;
12use crate::{Analysis, JoinSemiLattice, ResultsCursor};
13use rustc_ast::MetaItem;
14use rustc_hir::def_id::DefId;
15use rustc_index::bit_set::BitSet;
16use rustc_middle::mir::MirPass;
17use rustc_middle::mir::{self, Body, Local, Location};
18use rustc_middle::ty::{self, Ty, TyCtxt};
19use rustc_span::symbol::{sym, Symbol};
20use rustc_span::Span;
21use tracing::{debug, info};
18use crate::move_paths::{HasMoveData, LookupResult, MoveData, MovePathIndex};
19use crate::{Analysis, JoinSemiLattice, MoveDataParamEnv, ResultsCursor};
2220
2321pub struct SanityCheck;
2422
compiler/rustc_mir_dataflow/src/value_analysis.rs+2-3
......@@ -48,10 +48,9 @@ use rustc_middle::ty::{self, Ty, TyCtxt};
4848use rustc_target::abi::{FieldIdx, VariantIdx};
4949use tracing::debug;
5050
51use crate::fmt::DebugWithContext;
5152use crate::lattice::{HasBottom, HasTop};
52use crate::{
53 fmt::DebugWithContext, Analysis, AnalysisDomain, JoinSemiLattice, SwitchIntEdgeEffects,
54};
53use crate::{Analysis, AnalysisDomain, JoinSemiLattice, SwitchIntEdgeEffects};
5554
5655pub trait ValueAnalysis<'tcx> {
5756 /// 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 @@
11use rustc_ast::InlineAsmOptions;
22use rustc_middle::mir::*;
33use rustc_middle::span_bug;
4use rustc_middle::ty::layout;
5use rustc_middle::ty::{self, TyCtxt};
4use rustc_middle::ty::{self, layout, TyCtxt};
65use rustc_target::spec::abi::Abi;
76use rustc_target::spec::PanicStrategy;
87
compiler/rustc_mir_transform/src/add_moves_for_packed_drops.rs+1-1
......@@ -1,8 +1,8 @@
1use rustc_middle::mir::patch::MirPatch;
12use rustc_middle::mir::*;
23use rustc_middle::ty::TyCtxt;
34
45use crate::util;
5use rustc_middle::mir::patch::MirPatch;
66
77/// This pass moves values being dropped that are within a packed
88/// 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 @@
11use rustc_hir::lang_items::LangItem;
22use rustc_index::IndexVec;
3use rustc_middle::mir::interpret::Scalar;
4use rustc_middle::mir::visit::{MutatingUseContext, NonMutatingUseContext, PlaceContext, Visitor};
35use rustc_middle::mir::*;
4use rustc_middle::mir::{
5 interpret::Scalar,
6 visit::{MutatingUseContext, NonMutatingUseContext, PlaceContext, Visitor},
7};
86use rustc_middle::ty::{self, ParamEnv, Ty, TyCtxt};
97use rustc_session::Session;
108
compiler/rustc_mir_transform/src/check_packed_ref.rs+1-2
......@@ -3,8 +3,7 @@ use rustc_middle::mir::*;
33use rustc_middle::span_bug;
44use rustc_middle::ty::{self, TyCtxt};
55
6use crate::MirLint;
7use crate::{errors, util};
6use crate::{errors, util, MirLint};
87
98pub struct CheckPackedRef;
109
compiler/rustc_mir_transform/src/cleanup_post_borrowck.rs+2-1
......@@ -16,12 +16,13 @@
1616//! [`BlockMarker`]: rustc_middle::mir::coverage::CoverageKind::BlockMarker
1717//! [`SpanMarker`]: rustc_middle::mir::coverage::CoverageKind::SpanMarker
1818
19use crate::MirPass;
2019use rustc_middle::mir::coverage::CoverageKind;
2120use rustc_middle::mir::{Body, BorrowKind, CastKind, Rvalue, StatementKind, TerminatorKind};
2221use rustc_middle::ty::adjustment::PointerCoercion;
2322use rustc_middle::ty::TyCtxt;
2423
24use crate::MirPass;
25
2526pub struct CleanupPostBorrowck;
2627
2728impl<'tcx> MirPass<'tcx> for CleanupPostBorrowck {
compiler/rustc_mir_transform/src/coroutine.rs+9-13
......@@ -51,13 +51,9 @@
5151//! Otherwise it drops all the values in scope at the last suspension point.
5252
5353mod by_move_body;
54pub use by_move_body::ByMoveBody;
54use std::{iter, ops};
5555
56use crate::abort_unwinding_calls;
57use crate::deref_separator::deref_finder;
58use crate::errors;
59use crate::pass_manager as pm;
60use crate::simplify;
56pub use by_move_body::ByMoveBody;
6157use rustc_data_structures::fx::FxHashSet;
6258use rustc_errors::pluralize;
6359use rustc_hir as hir;
......@@ -67,9 +63,7 @@ use rustc_index::bit_set::{BitMatrix, BitSet, GrowableBitSet};
6763use rustc_index::{Idx, IndexVec};
6864use rustc_middle::mir::visit::{MutVisitor, PlaceContext, Visitor};
6965use rustc_middle::mir::*;
70use rustc_middle::ty::CoroutineArgs;
71use rustc_middle::ty::InstanceKind;
72use rustc_middle::ty::{self, CoroutineArgsExt, Ty, TyCtxt};
66use rustc_middle::ty::{self, CoroutineArgs, CoroutineArgsExt, InstanceKind, Ty, TyCtxt};
7367use rustc_middle::{bug, span_bug};
7468use rustc_mir_dataflow::impls::{
7569 MaybeBorrowedLocals, MaybeLiveLocals, MaybeRequiresStorage, MaybeStorageLive,
......@@ -83,9 +77,10 @@ use rustc_target::abi::{FieldIdx, VariantIdx};
8377use rustc_target::spec::PanicStrategy;
8478use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
8579use rustc_trait_selection::infer::TyCtxtInferExt as _;
86use rustc_trait_selection::traits::ObligationCtxt;
87use rustc_trait_selection::traits::{ObligationCause, ObligationCauseCode};
88use std::{iter, ops};
80use rustc_trait_selection::traits::{ObligationCause, ObligationCauseCode, ObligationCtxt};
81
82use crate::deref_separator::deref_finder;
83use crate::{abort_unwinding_calls, errors, pass_manager as pm, simplify};
8984
9085pub struct StateTransform;
9186
......@@ -1167,10 +1162,11 @@ fn insert_switch<'tcx>(
11671162}
11681163
11691164fn elaborate_coroutine_drops<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
1170 use crate::shim::DropShimElaborator;
11711165 use rustc_middle::mir::patch::MirPatch;
11721166 use rustc_mir_dataflow::elaborate_drops::{elaborate_drop, Unwind};
11731167
1168 use crate::shim::DropShimElaborator;
1169
11741170 // Note that `elaborate_drops` only drops the upvars of a coroutine, and
11751171 // this is ok because `open_drop` can only be reached within that own
11761172 // coroutine's resume function.
compiler/rustc_mir_transform/src/coverage/graph.rs+4-4
......@@ -1,3 +1,7 @@
1use std::cmp::Ordering;
2use std::collections::VecDeque;
3use std::ops::{Index, IndexMut};
4
15use rustc_data_structures::captures::Captures;
26use rustc_data_structures::fx::FxHashSet;
37use rustc_data_structures::graph::dominators::{self, Dominators};
......@@ -7,10 +11,6 @@ use rustc_index::IndexVec;
711use rustc_middle::bug;
812use rustc_middle::mir::{self, BasicBlock, Terminator, TerminatorKind};
913
10use std::cmp::Ordering;
11use std::collections::VecDeque;
12use std::ops::{Index, IndexMut};
13
1414/// A coverage-specific simplification of the MIR control flow graph (CFG). The `CoverageGraph`s
1515/// nodes are `BasicCoverageBlock`s, which encompass one or more MIR `BasicBlock`s.
1616#[derive(Debug)]
compiler/rustc_mir_transform/src/coverage/mod.rs+2-1
......@@ -147,7 +147,8 @@ fn create_mappings<'tcx>(
147147
148148 let source_file = source_map.lookup_source_file(body_span.lo());
149149
150 use rustc_session::{config::RemapPathScopeComponents, RemapFileNameExt};
150 use rustc_session::config::RemapPathScopeComponents;
151 use rustc_session::RemapFileNameExt;
151152 let file_name = Symbol::intern(
152153 &source_file.name.for_scope(tcx.sess, RemapPathScopeComponents::MACRO).to_string_lossy(),
153154 );
compiler/rustc_mir_transform/src/coverage/spans.rs+1-2
......@@ -6,11 +6,10 @@ use rustc_middle::mir;
66use rustc_span::Span;
77
88use crate::coverage::graph::{BasicCoverageBlock, CoverageGraph};
9use crate::coverage::mappings;
109use crate::coverage::spans::from_mir::{
1110 extract_covspans_from_mir, ExtractedCovspans, Hole, SpanFromMir,
1211};
13use crate::coverage::ExtractedHirInfo;
12use crate::coverage::{mappings, ExtractedHirInfo};
1413
1514mod from_mir;
1615
compiler/rustc_mir_transform/src/coverage/tests.rs+3-4
......@@ -24,16 +24,15 @@
2424//! globals is comparatively simpler. The easiest way is to wrap the test in a closure argument
2525//! to: `rustc_span::create_default_session_globals_then(|| { test_here(); })`.
2626
27use super::graph::{self, BasicCoverageBlock};
28
2927use itertools::Itertools;
3028use rustc_data_structures::graph::{DirectedGraph, Successors};
3129use rustc_index::{Idx, IndexVec};
32use rustc_middle::bug;
3330use rustc_middle::mir::*;
34use rustc_middle::ty;
31use rustc_middle::{bug, ty};
3532use rustc_span::{BytePos, Pos, Span, DUMMY_SP};
3633
34use super::graph::{self, BasicCoverageBlock};
35
3736fn bcb(index: u32) -> BasicCoverageBlock {
3837 BasicCoverageBlock::from_u32(index)
3938}
compiler/rustc_mir_transform/src/cross_crate_inline.rs+3-4
......@@ -1,5 +1,3 @@
1use crate::inline;
2use crate::pass_manager as pm;
31use rustc_attr::InlineAttr;
42use rustc_hir::def::DefKind;
53use rustc_hir::def_id::LocalDefId;
......@@ -7,10 +5,11 @@ use rustc_middle::mir::visit::Visitor;
75use rustc_middle::mir::*;
86use rustc_middle::query::Providers;
97use rustc_middle::ty::TyCtxt;
10use rustc_session::config::InliningThreshold;
11use rustc_session::config::OptLevel;
8use rustc_session::config::{InliningThreshold, OptLevel};
129use rustc_span::sym;
1310
11use crate::{inline, pass_manager as pm};
12
1413pub fn provide(providers: &mut Providers) {
1514 providers.cross_crate_inlinable = cross_crate_inlinable;
1615}
compiler/rustc_mir_transform/src/ctfe_limit.rs+2-2
......@@ -1,14 +1,14 @@
11//! A pass that inserts the `ConstEvalCounter` instruction into any blocks that have a back edge
22//! (thus indicating there is a loop in the CFG), or whose terminator is a function call.
33
4use crate::MirPass;
5
64use rustc_data_structures::graph::dominators::Dominators;
75use rustc_middle::mir::{
86 BasicBlock, BasicBlockData, Body, Statement, StatementKind, TerminatorKind,
97};
108use rustc_middle::ty::TyCtxt;
119
10use crate::MirPass;
11
1212pub struct CtfeLimit;
1313
1414impl<'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};
1212use rustc_middle::mir::*;
1313use rustc_middle::ty::layout::{HasParamEnv, LayoutOf};
1414use rustc_middle::ty::{self, Ty, TyCtxt};
15use rustc_mir_dataflow::lattice::FlatSet;
1516use rustc_mir_dataflow::value_analysis::{
1617 Map, PlaceIndex, State, TrackElem, ValueAnalysis, ValueAnalysisWrapper, ValueOrPlace,
1718};
18use rustc_mir_dataflow::{lattice::FlatSet, Analysis, Results, ResultsVisitor};
19use rustc_mir_dataflow::{Analysis, Results, ResultsVisitor};
1920use rustc_span::DUMMY_SP;
2021use rustc_target::abi::{Abi, FieldIdx, Size, VariantIdx, FIRST_VARIANT};
2122
compiler/rustc_mir_transform/src/dead_store_elimination.rs+2-1
......@@ -12,7 +12,6 @@
1212//! will still not cause any further changes.
1313//!
1414
15use crate::util::is_within_packed;
1615use rustc_middle::bug;
1716use rustc_middle::mir::visit::Visitor;
1817use rustc_middle::mir::*;
......@@ -23,6 +22,8 @@ use rustc_mir_dataflow::impls::{
2322};
2423use rustc_mir_dataflow::Analysis;
2524
25use crate::util::is_within_packed;
26
2627/// Performs the optimization on the body
2728///
2829/// 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 @@
11//! This pass finds basic blocks that are completely equal,
22//! and replaces all uses with just one of them.
33
4use std::{collections::hash_map::Entry, hash::Hash, hash::Hasher, iter};
4use std::collections::hash_map::Entry;
5use std::hash::{Hash, Hasher};
6use std::iter;
57
68use rustc_data_structures::fx::FxHashMap;
79use rustc_middle::mir::visit::MutVisitor;
compiler/rustc_mir_transform/src/dest_prop.rs+4-5
......@@ -131,23 +131,22 @@
131131//! [attempt 2]: https://github.com/rust-lang/rust/pull/71003
132132//! [attempt 3]: https://github.com/rust-lang/rust/pull/72632
133133
134use crate::MirPass;
135134use rustc_data_structures::fx::{FxIndexMap, IndexEntry, IndexOccupiedEntry};
136135use rustc_index::bit_set::BitSet;
137136use rustc_index::interval::SparseIntervalMatrix;
138137use rustc_middle::bug;
139138use rustc_middle::mir::visit::{MutVisitor, PlaceContext, Visitor};
140use rustc_middle::mir::HasLocalDecls;
141use rustc_middle::mir::{dump_mir, PassWhere};
142139use 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,
145142};
146143use rustc_middle::ty::TyCtxt;
147144use rustc_mir_dataflow::impls::MaybeLiveLocals;
148145use rustc_mir_dataflow::points::{save_as_intervals, DenseLocationMap, PointIndex};
149146use rustc_mir_dataflow::Analysis;
150147
148use crate::MirPass;
149
151150pub struct DestinationPropagation;
152151
153152impl<'tcx> MirPass<'tcx> for DestinationPropagation {
compiler/rustc_mir_transform/src/dump_mir.rs+3-3
......@@ -3,12 +3,12 @@
33use std::fs::File;
44use std::io;
55
6use crate::MirPass;
7use rustc_middle::mir::write_mir_pretty;
8use rustc_middle::mir::Body;
6use rustc_middle::mir::{write_mir_pretty, Body};
97use rustc_middle::ty::TyCtxt;
108use rustc_session::config::{OutFileName, OutputType};
119
10use crate::MirPass;
11
1212pub struct Marker(pub &'static str);
1313
1414impl<'tcx> MirPass<'tcx> for Marker {
compiler/rustc_mir_transform/src/early_otherwise_branch.rs+2-1
......@@ -1,7 +1,8 @@
1use std::fmt::Debug;
2
13use rustc_middle::mir::patch::MirPatch;
24use rustc_middle::mir::*;
35use rustc_middle::ty::{Ty, TyCtxt};
4use std::fmt::Debug;
56
67use super::simplify::simplify_cfg;
78
compiler/rustc_mir_transform/src/elaborate_drops.rs+10-8
......@@ -1,20 +1,22 @@
1use crate::deref_separator::deref_finder;
1use std::fmt;
2
23use rustc_index::bit_set::BitSet;
34use rustc_index::IndexVec;
45use rustc_middle::mir::patch::MirPatch;
56use rustc_middle::mir::*;
67use rustc_middle::ty::{self, TyCtxt};
7use rustc_mir_dataflow::elaborate_drops::{elaborate_drop, DropFlagState, Unwind};
8use rustc_mir_dataflow::elaborate_drops::{DropElaborator, DropFlagMode, DropStyle};
8use rustc_mir_dataflow::elaborate_drops::{
9 elaborate_drop, DropElaborator, DropFlagMode, DropFlagState, DropStyle, Unwind,
10};
911use rustc_mir_dataflow::impls::{MaybeInitializedPlaces, MaybeUninitializedPlaces};
1012use rustc_mir_dataflow::move_paths::{LookupResult, MoveData, MovePathIndex};
11use rustc_mir_dataflow::on_all_children_bits;
12use rustc_mir_dataflow::on_lookup_result_bits;
13use rustc_mir_dataflow::MoveDataParamEnv;
14use rustc_mir_dataflow::{Analysis, ResultsCursor};
13use rustc_mir_dataflow::{
14 on_all_children_bits, on_lookup_result_bits, Analysis, MoveDataParamEnv, ResultsCursor,
15};
1516use rustc_span::Span;
1617use rustc_target::abi::{FieldIdx, VariantIdx};
17use std::fmt;
18
19use crate::deref_separator::deref_finder;
1820
1921/// During MIR building, Drop terminators are inserted in every place where a drop may occur.
2022/// 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 @@
1use rustc_errors::{codes::*, Diag, LintDiagnostic};
1use rustc_errors::codes::*;
2use rustc_errors::{Diag, LintDiagnostic};
23use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
34use rustc_middle::mir::AssertKind;
45use rustc_middle::ty::TyCtxt;
compiler/rustc_mir_transform/src/ffi_unwind_calls.rs+2-4
......@@ -1,9 +1,7 @@
11use rustc_hir::def_id::{LocalDefId, LOCAL_CRATE};
22use rustc_middle::mir::*;
3use rustc_middle::query::LocalCrate;
4use rustc_middle::query::Providers;
5use rustc_middle::ty::layout;
6use rustc_middle::ty::{self, TyCtxt};
3use rustc_middle::query::{LocalCrate, Providers};
4use rustc_middle::ty::{self, layout, TyCtxt};
75use rustc_middle::{bug, span_bug};
86use rustc_session::lint::builtin::FFI_UNWIND_CALLS;
97use rustc_target::spec::abi::Abi;
compiler/rustc_mir_transform/src/function_item_references.rs+2-1
......@@ -5,7 +5,8 @@ use rustc_middle::mir::*;
55use rustc_middle::ty::{self, EarlyBinder, GenericArgsRef, Ty, TyCtxt};
66use rustc_session::lint::builtin::FUNCTION_ITEM_REFERENCES;
77use rustc_span::source_map::Spanned;
8use rustc_span::{symbol::sym, Span};
8use rustc_span::symbol::sym;
9use rustc_span::Span;
910use rustc_target::spec::abi::Abi;
1011
1112use crate::{errors, MirLint};
compiler/rustc_mir_transform/src/gvn.rs+8-6
......@@ -82,15 +82,19 @@
8282//! Second, when writing constants in MIR, we do not write `Const::Slice` or `Const`
8383//! that contain `AllocId`s.
8484
85use std::borrow::Cow;
86
87use either::Either;
8588use rustc_const_eval::const_eval::DummyMachine;
86use rustc_const_eval::interpret::{intern_const_alloc_for_constprop, MemPlaceMeta, MemoryKind};
87use rustc_const_eval::interpret::{ImmTy, Immediate, InterpCx, OpTy, Projectable, Scalar};
89use rustc_const_eval::interpret::{
90 intern_const_alloc_for_constprop, ImmTy, Immediate, InterpCx, MemPlaceMeta, MemoryKind, OpTy,
91 Projectable, Scalar,
92};
8893use rustc_data_structures::fx::FxIndexSet;
8994use rustc_data_structures::graph::dominators::Dominators;
9095use rustc_hir::def::DefKind;
9196use rustc_index::bit_set::BitSet;
92use rustc_index::newtype_index;
93use rustc_index::IndexVec;
97use rustc_index::{newtype_index, IndexVec};
9498use rustc_middle::bug;
9599use rustc_middle::mir::interpret::GlobalAlloc;
96100use rustc_middle::mir::visit::*;
......@@ -101,10 +105,8 @@ use rustc_span::def_id::DefId;
101105use rustc_span::DUMMY_SP;
102106use rustc_target::abi::{self, Abi, FieldIdx, Size, VariantIdx, FIRST_VARIANT};
103107use smallvec::SmallVec;
104use std::borrow::Cow;
105108
106109use crate::ssa::{AssignedValue, SsaLocals};
107use either::Either;
108110
109111pub struct GVN;
110112
compiler/rustc_mir_transform/src/inline.rs+7-5
......@@ -1,6 +1,8 @@
11//! Inlining pass for MIR functions.
22
3use crate::deref_separator::deref_finder;
3use std::iter;
4use std::ops::{Range, RangeFrom};
5
46use rustc_attr::InlineAttr;
57use rustc_hir::def::DefKind;
68use rustc_hir::def_id::DefId;
......@@ -10,8 +12,9 @@ use rustc_middle::bug;
1012use rustc_middle::middle::codegen_fn_attrs::{CodegenFnAttrFlags, CodegenFnAttrs};
1113use rustc_middle::mir::visit::*;
1214use rustc_middle::mir::*;
13use rustc_middle::ty::TypeVisitableExt;
14use rustc_middle::ty::{self, Instance, InstanceKind, ParamEnv, Ty, TyCtxt, TypeFlags};
15use rustc_middle::ty::{
16 self, Instance, InstanceKind, ParamEnv, Ty, TyCtxt, TypeFlags, TypeVisitableExt,
17};
1518use rustc_session::config::{DebugInfo, OptLevel};
1619use rustc_span::source_map::Spanned;
1720use rustc_span::sym;
......@@ -19,11 +22,10 @@ use rustc_target::abi::FieldIdx;
1922use rustc_target::spec::abi::Abi;
2023
2124use crate::cost_checker::CostChecker;
25use crate::deref_separator::deref_finder;
2226use crate::simplify::simplify_cfg;
2327use crate::util;
2428use crate::validate::validate_types;
25use std::iter;
26use std::ops::{Range, RangeFrom};
2729
2830pub(crate) mod cycle;
2931
compiler/rustc_mir_transform/src/inline/cycle.rs+1-2
......@@ -2,8 +2,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexSet};
22use rustc_data_structures::stack::ensure_sufficient_stack;
33use rustc_hir::def_id::{DefId, LocalDefId};
44use rustc_middle::mir::TerminatorKind;
5use rustc_middle::ty::TypeVisitableExt;
6use rustc_middle::ty::{self, GenericArgsRef, InstanceKind, TyCtxt};
5use rustc_middle::ty::{self, GenericArgsRef, InstanceKind, TyCtxt, TypeVisitableExt};
76use rustc_session::Limit;
87use rustc_span::sym;
98
compiler/rustc_mir_transform/src/instsimplify.rs+4-4
......@@ -1,18 +1,18 @@
11//! Performs various peephole optimizations.
22
3use crate::simplify::simplify_duplicate_switch_targets;
4use crate::take_array;
53use rustc_ast::attr;
64use rustc_hir::LangItem;
75use rustc_middle::bug;
86use rustc_middle::mir::*;
9use rustc_middle::ty::layout;
107use rustc_middle::ty::layout::ValidityRequirement;
11use rustc_middle::ty::{self, GenericArgsRef, ParamEnv, Ty, TyCtxt};
8use rustc_middle::ty::{self, layout, GenericArgsRef, ParamEnv, Ty, TyCtxt};
129use rustc_span::sym;
1310use rustc_span::symbol::Symbol;
1411use rustc_target::spec::abi::Abi;
1512
13use crate::simplify::simplify_duplicate_switch_targets;
14use crate::take_array;
15
1616pub struct InstSimplify;
1717
1818impl<'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::{
1313use rustc_data_structures::fx::FxHashSet;
1414use rustc_hir::def::DefKind;
1515use rustc_hir::HirId;
16use rustc_index::{bit_set::BitSet, IndexVec};
16use rustc_index::bit_set::BitSet;
17use rustc_index::IndexVec;
1718use rustc_middle::bug;
1819use rustc_middle::mir::visit::{MutatingUseContext, NonMutatingUseContext, PlaceContext, Visitor};
1920use rustc_middle::mir::*;
compiler/rustc_mir_transform/src/lib.rs+3-3
......@@ -34,11 +34,11 @@ use rustc_middle::mir::{
3434 LocalDecl, MirPass, MirPhase, Operand, Place, ProjectionElem, Promoted, RuntimePhase, Rvalue,
3535 SourceInfo, Statement, StatementKind, TerminatorKind, START_BLOCK,
3636};
37use rustc_middle::query;
3837use rustc_middle::ty::{self, TyCtxt, TypeVisitableExt};
3938use rustc_middle::util::Providers;
40use rustc_middle::{bug, span_bug};
41use rustc_span::{source_map::Spanned, sym, DUMMY_SP};
39use rustc_middle::{bug, query, span_bug};
40use rustc_span::source_map::Spanned;
41use rustc_span::{sym, DUMMY_SP};
4242use rustc_trait_selection::traits;
4343
4444#[macro_use]
compiler/rustc_mir_transform/src/lint.rs+2-1
......@@ -2,6 +2,8 @@
22//! It can be used to locate problems in MIR building or optimizations. It assumes that all code
33//! can be executed, so it has false positives.
44
5use std::borrow::Cow;
6
57use rustc_data_structures::fx::FxHashSet;
68use rustc_index::bit_set::BitSet;
79use rustc_middle::mir::visit::{PlaceContext, Visitor};
......@@ -10,7 +12,6 @@ use rustc_middle::ty::TyCtxt;
1012use rustc_mir_dataflow::impls::{MaybeStorageDead, MaybeStorageLive};
1113use rustc_mir_dataflow::storage::always_storage_live_locals;
1214use rustc_mir_dataflow::{Analysis, ResultsCursor};
13use std::borrow::Cow;
1415
1516pub fn lint_body<'tcx>(tcx: TyCtxt<'tcx>, body: &Body<'tcx>, when: String) {
1617 let always_live_locals = &always_storage_live_locals(body);
compiler/rustc_mir_transform/src/lower_intrinsics.rs+2-1
......@@ -1,11 +1,12 @@
11//! Lowers intrinsic calls
22
3use crate::take_array;
43use rustc_middle::mir::*;
54use rustc_middle::ty::{self, TyCtxt};
65use rustc_middle::{bug, span_bug};
76use rustc_span::symbol::sym;
87
8use crate::take_array;
9
910pub struct LowerIntrinsics;
1011
1112impl<'tcx> MirPass<'tcx> for LowerIntrinsics {
compiler/rustc_mir_transform/src/match_branches.rs+2-1
......@@ -1,9 +1,10 @@
1use std::iter;
2
13use rustc_index::IndexSlice;
24use rustc_middle::mir::patch::MirPatch;
35use rustc_middle::mir::*;
46use rustc_middle::ty::{ParamEnv, ScalarInt, Ty, TyCtxt};
57use rustc_target::abi::Size;
6use std::iter;
78
89use super::simplify::simplify_cfg;
910
compiler/rustc_mir_transform/src/mentioned_items.rs+2-1
......@@ -1,6 +1,7 @@
11use rustc_middle::mir::visit::Visitor;
22use rustc_middle::mir::{self, Location, MentionedItem, MirPass};
3use rustc_middle::ty::{self, adjustment::PointerCoercion, TyCtxt};
3use rustc_middle::ty::adjustment::PointerCoercion;
4use rustc_middle::ty::{self, TyCtxt};
45use rustc_session::Session;
56use rustc_span::source_map::Spanned;
67
compiler/rustc_mir_transform/src/multiple_return_terminators.rs+2-1
......@@ -1,11 +1,12 @@
11//! This pass removes jumps to basic blocks containing only a return, and replaces them with a
22//! return instead.
33
4use crate::simplify;
54use rustc_index::bit_set::BitSet;
65use rustc_middle::mir::*;
76use rustc_middle::ty::TyCtxt;
87
8use crate::simplify;
9
910pub struct MultipleReturnTerminators;
1011
1112impl<'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};
22use rustc_middle::ty::TyCtxt;
33use rustc_session::Session;
44
5use crate::{lint::lint_body, validate, MirPass};
5use crate::lint::lint_body;
6use crate::{validate, MirPass};
67
78/// Just like `MirPass`, except it cannot mutate `Body`.
89pub trait MirLint<'tcx> {
compiler/rustc_mir_transform/src/prettify.rs+2-1
......@@ -4,7 +4,8 @@
44//! (`-Zmir-enable-passes=+ReorderBasicBlocks,+ReorderLocals`)
55//! to make the MIR easier to read for humans.
66
7use rustc_index::{bit_set::BitSet, IndexSlice, IndexVec};
7use rustc_index::bit_set::BitSet;
8use rustc_index::{IndexSlice, IndexVec};
89use rustc_middle::mir::visit::{MutVisitor, PlaceContext, Visitor};
910use rustc_middle::mir::*;
1011use rustc_middle::ty::TyCtxt;
compiler/rustc_mir_transform/src/promote_consts.rs+9-13
......@@ -12,25 +12,21 @@
1212//! initialization and can otherwise silence errors, if
1313//! move analysis runs after promotion on broken MIR.
1414
15use std::assert_matches::assert_matches;
16use std::cell::Cell;
17use std::{cmp, iter, mem};
18
1519use either::{Left, Right};
20use rustc_const_eval::check_consts::{qualifs, ConstCx};
1621use rustc_data_structures::fx::FxHashSet;
1722use rustc_hir as hir;
18use rustc_middle::mir;
23use rustc_index::{Idx, IndexSlice, IndexVec};
1924use rustc_middle::mir::visit::{MutVisitor, MutatingUseContext, PlaceContext, Visitor};
2025use rustc_middle::mir::*;
21use rustc_middle::ty::GenericArgs;
22use rustc_middle::ty::{self, List, Ty, TyCtxt, TypeVisitableExt};
23use rustc_middle::{bug, span_bug};
24use rustc_span::Span;
25
26use rustc_index::{Idx, IndexSlice, IndexVec};
26use rustc_middle::ty::{self, GenericArgs, List, Ty, TyCtxt, TypeVisitableExt};
27use rustc_middle::{bug, mir, span_bug};
2728use rustc_span::source_map::Spanned;
28
29use std::assert_matches::assert_matches;
30use std::cell::Cell;
31use std::{cmp, iter, mem};
32
33use rustc_const_eval::check_consts::{qualifs, ConstCx};
29use rustc_span::Span;
3430
3531/// A `MirPass` for promotion.
3632///
compiler/rustc_mir_transform/src/ref_prop.rs+2-1
......@@ -1,3 +1,5 @@
1use std::borrow::Cow;
2
13use rustc_data_structures::fx::FxHashSet;
24use rustc_index::bit_set::BitSet;
35use rustc_index::IndexVec;
......@@ -8,7 +10,6 @@ use rustc_middle::ty::TyCtxt;
810use rustc_mir_dataflow::impls::MaybeStorageDead;
911use rustc_mir_dataflow::storage::always_storage_live_locals;
1012use rustc_mir_dataflow::Analysis;
11use std::borrow::Cow;
1213
1314use crate::ssa::{SsaLocals, StorageLiveLocals};
1415
compiler/rustc_mir_transform/src/remove_uninit_drops.rs+1-2
......@@ -1,7 +1,6 @@
11use rustc_index::bit_set::ChunkedBitSet;
22use rustc_middle::mir::{Body, TerminatorKind};
3use rustc_middle::ty::GenericArgsRef;
4use rustc_middle::ty::{self, ParamEnv, Ty, TyCtxt, VariantDef};
3use rustc_middle::ty::{self, GenericArgsRef, ParamEnv, Ty, TyCtxt, VariantDef};
54use rustc_mir_dataflow::impls::MaybeInitializedPlaces;
65use rustc_mir_dataflow::move_paths::{LookupResult, MoveData, MovePathIndex};
76use rustc_mir_dataflow::{move_path_children_matching, Analysis, MaybeReachable, MoveDataParamEnv};
compiler/rustc_mir_transform/src/shim.rs+10-9
......@@ -1,26 +1,27 @@
1use std::assert_matches::assert_matches;
2use std::{fmt, iter};
3
14use rustc_hir as hir;
25use rustc_hir::def_id::DefId;
36use rustc_hir::lang_items::LangItem;
47use rustc_index::{Idx, IndexVec};
8use rustc_middle::mir::patch::MirPatch;
59use rustc_middle::mir::*;
610use rustc_middle::query::Providers;
7use rustc_middle::ty::GenericArgs;
8use rustc_middle::ty::{self, CoroutineArgs, CoroutineArgsExt, EarlyBinder, Ty, TyCtxt};
11use rustc_middle::ty::{
12 self, CoroutineArgs, CoroutineArgsExt, EarlyBinder, GenericArgs, Ty, TyCtxt,
13};
914use rustc_middle::{bug, span_bug};
10use rustc_span::{source_map::Spanned, Span, DUMMY_SP};
15use rustc_mir_dataflow::elaborate_drops::{self, DropElaborator, DropFlagMode, DropStyle};
16use rustc_span::source_map::Spanned;
17use rustc_span::{Span, DUMMY_SP};
1118use rustc_target::abi::{FieldIdx, VariantIdx, FIRST_VARIANT};
1219use rustc_target::spec::abi::Abi;
1320
14use std::assert_matches::assert_matches;
15use std::fmt;
16use std::iter;
17
1821use crate::{
1922 abort_unwinding_calls, add_call_guards, add_moves_for_packed_drops, deref_separator,
2023 instsimplify, mentioned_items, pass_manager as pm, remove_noop_landing_pads, simplify,
2124};
22use rustc_middle::mir::patch::MirPatch;
23use rustc_mir_dataflow::elaborate_drops::{self, DropElaborator, DropFlagMode, DropStyle};
2425
2526mod async_destructor_ctor;
2627
compiler/rustc_mir_transform/src/simplify_comparison_integral.rs+8-8
......@@ -1,14 +1,14 @@
11use std::iter;
22
3use super::MirPass;
4use 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},
3use rustc_middle::bug;
4use rustc_middle::mir::interpret::Scalar;
5use rustc_middle::mir::{
6 BasicBlock, BinOp, Body, Operand, Place, Rvalue, Statement, StatementKind, SwitchTargets,
7 TerminatorKind,
118};
9use rustc_middle::ty::{Ty, TyCtxt};
10
11use super::MirPass;
1212
1313/// Pass to convert `if` conditions on integrals into switches on the integral.
1414/// For an example, it turns something like
compiler/rustc_mir_transform/src/single_use_consts.rs+2-1
......@@ -1,4 +1,5 @@
1use rustc_index::{bit_set::BitSet, IndexVec};
1use rustc_index::bit_set::BitSet;
2use rustc_index::IndexVec;
23use rustc_middle::bug;
34use rustc_middle::mir::visit::{MutVisitor, PlaceContext, Visitor};
45use rustc_middle::mir::*;
compiler/rustc_mir_transform/src/unreachable_enum_branching.rs+2-1
......@@ -1,6 +1,5 @@
11//! A pass that eliminates branches on uninhabited or unreachable enum variants.
22
3use crate::MirPass;
43use rustc_data_structures::fx::FxHashSet;
54use rustc_middle::bug;
65use rustc_middle::mir::patch::MirPatch;
......@@ -12,6 +11,8 @@ use rustc_middle::ty::layout::TyAndLayout;
1211use rustc_middle::ty::{Ty, TyCtxt};
1312use rustc_target::abi::{Abi, Variants};
1413
14use crate::MirPass;
15
1516pub struct UnreachableEnumBranching;
1617
1718fn 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};
1717use rustc_target::abi::{Size, FIRST_VARIANT};
1818use rustc_target::spec::abi::Abi;
1919
20use crate::util::is_within_packed;
21
22use crate::util::relate_types;
20use crate::util::{is_within_packed, relate_types};
2321
2422#[derive(Copy, Clone, Debug, PartialEq, Eq)]
2523enum EdgeKind {
compiler/rustc_monomorphize/src/collector.rs+6-7
......@@ -207,6 +207,9 @@
207207
208208mod move_check;
209209
210use std::path::PathBuf;
211
212use move_check::MoveCheckState;
210213use rustc_data_structures::sync::{par_for_each_in, LRef, MTLock};
211214use rustc_data_structures::unord::{UnordMap, UnordSet};
212215use rustc_hir as hir;
......@@ -216,17 +219,15 @@ use rustc_hir::lang_items::LangItem;
216219use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
217220use rustc_middle::mir::interpret::{AllocId, ErrorHandled, GlobalAlloc, Scalar};
218221use rustc_middle::mir::mono::{InstantiationMode, MonoItem};
219use rustc_middle::mir::traversal;
220222use rustc_middle::mir::visit::Visitor as MirVisitor;
221use rustc_middle::mir::{self, Location, MentionedItem};
223use rustc_middle::mir::{self, traversal, Location, MentionedItem};
222224use rustc_middle::query::TyCtxtAt;
223225use rustc_middle::ty::adjustment::{CustomCoerceUnsized, PointerCoercion};
224226use rustc_middle::ty::layout::ValidityRequirement;
225227use rustc_middle::ty::print::{shrunk_instance_name, with_no_trimmed_paths};
226use rustc_middle::ty::GenericArgs;
227228use 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,
230231};
231232use rustc_middle::util::Providers;
232233use rustc_middle::{bug, span_bug};
......@@ -236,11 +237,9 @@ use rustc_span::source_map::{dummy_spanned, respan, Spanned};
236237use rustc_span::symbol::{sym, Ident};
237238use rustc_span::{Span, DUMMY_SP};
238239use rustc_target::abi::Size;
239use std::path::PathBuf;
240240use tracing::{debug, instrument, trace};
241241
242242use crate::errors::{self, EncounteredErrorWhileInstantiating, NoOptimizedMir, RecursionLimit};
243use move_check::MoveCheckState;
244243
245244#[derive(PartialEq)]
246245pub enum MonoItemCollectionStrategy {
compiler/rustc_monomorphize/src/errors.rs+2-1
......@@ -1,10 +1,11 @@
11use std::path::PathBuf;
22
3use crate::fluent_generated as fluent;
43use rustc_errors::{Diag, DiagCtxtHandle, Diagnostic, EmissionGuarantee, Level};
54use rustc_macros::{Diagnostic, LintDiagnostic};
65use rustc_span::{Span, Symbol};
76
7use crate::fluent_generated as fluent;
8
89#[derive(Diagnostic)]
910#[diag(monomorphize_recursion_limit)]
1011pub struct RecursionLimit {
compiler/rustc_monomorphize/src/lib.rs+1-2
......@@ -3,12 +3,11 @@
33// tidy-alphabetical-end
44
55use rustc_hir::lang_items::LangItem;
6use rustc_middle::bug;
76use rustc_middle::query::TyCtxtAt;
8use rustc_middle::traits;
97use rustc_middle::ty::adjustment::CustomCoerceUnsized;
108use rustc_middle::ty::{self, Ty};
119use rustc_middle::util::Providers;
10use rustc_middle::{bug, traits};
1211use rustc_span::ErrorGuaranteed;
1312
1413mod collector;
compiler/rustc_monomorphize/src/partitioning.rs+3-3
......@@ -113,15 +113,15 @@ use rustc_middle::mir::mono::{
113113 Visibility,
114114};
115115use rustc_middle::ty::print::{characteristic_def_id_of_type, with_no_trimmed_paths};
116use rustc_middle::ty::{self, visit::TypeVisitableExt, InstanceKind, TyCtxt};
116use rustc_middle::ty::visit::TypeVisitableExt;
117use rustc_middle::ty::{self, InstanceKind, TyCtxt};
117118use rustc_middle::util::Providers;
118119use rustc_session::config::{DumpMonoStatsFormat, SwitchWithOptPath};
119120use rustc_session::CodegenUnits;
120121use rustc_span::symbol::Symbol;
121122use tracing::debug;
122123
123use crate::collector::UsageMap;
124use crate::collector::{self, MonoItemCollectionStrategy};
124use crate::collector::{self, MonoItemCollectionStrategy, UsageMap};
125125use crate::errors::{CouldntDumpMonoStats, SymbolAlreadyDefined, UnknownCguCollectionMode};
126126
127127struct PartitioningCx<'a, 'tcx> {
compiler/rustc_monomorphize/src/polymorphize.rs+7-11
......@@ -5,18 +5,14 @@
55//! generic parameters are unused (and eventually, in what ways generic parameters are used - only
66//! for their size, offset of a field, etc.).
77
8use rustc_hir::{def::DefKind, def_id::DefId, ConstContext};
9use rustc_middle::mir::{
10 self,
11 visit::{TyContext, Visitor},
12 Local, LocalDecl, Location,
13};
8use rustc_hir::def::DefKind;
9use rustc_hir::def_id::DefId;
10use rustc_hir::ConstContext;
11use rustc_middle::mir::visit::{TyContext, Visitor};
12use rustc_middle::mir::{self, Local, LocalDecl, Location};
1413use rustc_middle::query::Providers;
15use rustc_middle::ty::{
16 self,
17 visit::{TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor},
18 GenericArgsRef, Ty, TyCtxt, UnusedGenericParams,
19};
14use rustc_middle::ty::visit::{TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor};
15use rustc_middle::ty::{self, GenericArgsRef, Ty, TyCtxt, UnusedGenericParams};
2016use rustc_span::symbol::sym;
2117use tracing::{debug, instrument};
2218
compiler/rustc_monomorphize/src/util.rs+2-1
......@@ -1,7 +1,8 @@
1use rustc_middle::ty::{self, ClosureSizeProfileData, Instance, TyCtxt};
21use std::fs::OpenOptions;
32use std::io::prelude::*;
43
4use rustc_middle::ty::{self, ClosureSizeProfileData, Instance, TyCtxt};
5
56/// For a given closure, writes out the data for the profiling the impact of RFC 2229 on
67/// closure size into a CSV.
78///
compiler/rustc_next_trait_solver/src/resolve.rs+2-1
......@@ -1,9 +1,10 @@
1use crate::delegate::SolverDelegate;
21use rustc_type_ir::fold::{TypeFoldable, TypeFolder, TypeSuperFoldable};
32use rustc_type_ir::inherent::*;
43use rustc_type_ir::visit::TypeVisitableExt;
54use rustc_type_ir::{self as ty, InferCtxtLike, Interner};
65
6use crate::delegate::SolverDelegate;
7
78///////////////////////////////////////////////////////////////////////////
89// EAGER RESOLUTION
910
compiler/rustc_next_trait_solver/src/solve/assembly/mod.rs+1-2
......@@ -3,12 +3,11 @@
33pub(super) mod structural_traits;
44
55use derive_where::derive_where;
6use rustc_type_ir::elaborate;
76use rustc_type_ir::fold::TypeFoldable;
87use rustc_type_ir::inherent::*;
98use rustc_type_ir::lang_items::TraitSolverLangItem;
109use rustc_type_ir::visit::TypeVisitableExt as _;
11use rustc_type_ir::{self as ty, Interner, Upcast as _};
10use rustc_type_ir::{self as ty, elaborate, Interner, Upcast as _};
1211use tracing::{debug, instrument};
1312
1413use 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};
2121use crate::delegate::SolverDelegate;
2222use crate::resolve::EagerResolver;
2323use crate::solve::eval_ctxt::NestedGoals;
24use crate::solve::inspect;
2524use crate::solve::{
26 response_no_constraints_raw, CanonicalInput, CanonicalResponse, Certainty, EvalCtxt,
25 inspect, response_no_constraints_raw, CanonicalInput, CanonicalResponse, Certainty, EvalCtxt,
2726 ExternalConstraintsData, Goal, MaybeCause, NestedNormalizationGoals, NoSolution,
2827 PredefinedOpaquesData, QueryInput, QueryResult, Response,
2928};
compiler/rustc_next_trait_solver/src/solve/eval_ctxt/probe.rs+3-2
......@@ -5,8 +5,9 @@ use tracing::instrument;
55
66use crate::delegate::SolverDelegate;
77use crate::solve::assembly::Candidate;
8use crate::solve::inspect;
9use crate::solve::{BuiltinImplSource, CandidateSource, EvalCtxt, NoSolution, QueryResult};
8use crate::solve::{
9 inspect, BuiltinImplSource, CandidateSource, EvalCtxt, NoSolution, QueryResult,
10};
1011
1112pub(in crate::solve) struct ProbeCtxt<'me, 'a, D, I, F, T>
1213where
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};
1313
1414use crate::delegate::SolverDelegate;
1515use crate::solve::eval_ctxt::canonical;
16use crate::solve::inspect;
1716use crate::solve::{
18 CanonicalInput, Certainty, GenerateProofTree, Goal, GoalEvaluationKind, GoalSource, QueryInput,
19 QueryResult,
17 inspect, CanonicalInput, Certainty, GenerateProofTree, Goal, GoalEvaluationKind, GoalSource,
18 QueryInput, QueryResult,
2019};
2120
2221/// 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;
66use rustc_type_ir::fast_reject::{DeepRejectCtxt, TreatParams};
77use rustc_type_ir::inherent::*;
88use rustc_type_ir::lang_items::TraitSolverLangItem;
9use rustc_type_ir::Upcast as _;
10use rustc_type_ir::{self as ty, Interner, NormalizesTo};
9use rustc_type_ir::{self as ty, Interner, NormalizesTo, Upcast as _};
1110use tracing::instrument;
1211
1312use crate::delegate::SolverDelegate;
compiler/rustc_parse/src/errors.rs+3-2
......@@ -2,9 +2,10 @@ use std::borrow::Cow;
22
33use rustc_ast::token::Token;
44use rustc_ast::{Path, Visibility};
5use rustc_errors::codes::*;
56use rustc_errors::{
6 codes::*, Applicability, Diag, DiagCtxtHandle, Diagnostic, EmissionGuarantee, Level,
7 SubdiagMessageOp, Subdiagnostic,
7 Applicability, Diag, DiagCtxtHandle, Diagnostic, EmissionGuarantee, Level, SubdiagMessageOp,
8 Subdiagnostic,
89};
910use rustc_macros::{Diagnostic, Subdiagnostic};
1011use rustc_session::errors::ExprParenthesesNeeded;
compiler/rustc_parse/src/lexer/diagnostics.rs+2-1
......@@ -1,9 +1,10 @@
1use super::UnmatchedDelim;
21use rustc_ast::token::Delimiter;
32use rustc_errors::Diag;
43use rustc_span::source_map::SourceMap;
54use rustc_span::Span;
65
6use super::UnmatchedDelim;
7
78#[derive(Default)]
89pub(super) struct TokenTreeDiagInfo {
910 /// Stack of open delimiters and their spans. Used for error message.
compiler/rustc_parse/src/lexer/mod.rs+8-7
......@@ -1,25 +1,26 @@
11use std::ops::Range;
22
3use crate::errors;
4use crate::lexer::unicode_chars::UNICODE_ARRAY;
5use crate::make_unclosed_delims_error;
63use rustc_ast::ast::{self, AttrStyle};
74use rustc_ast::token::{self, CommentKind, Delimiter, IdentIsRaw, Token, TokenKind};
85use rustc_ast::tokenstream::TokenStream;
96use rustc_ast::util::unicode::contains_text_flow_control_chars;
10use rustc_errors::{codes::*, Applicability, Diag, DiagCtxtHandle, StashKey};
7use rustc_errors::codes::*;
8use rustc_errors::{Applicability, Diag, DiagCtxtHandle, StashKey};
119use rustc_lexer::unescape::{self, EscapeError, Mode};
12use rustc_lexer::{Base, DocStyle, RawStrError};
13use rustc_lexer::{Cursor, LiteralKind};
10use rustc_lexer::{Base, Cursor, DocStyle, LiteralKind, RawStrError};
1411use rustc_session::lint::builtin::{
1512 RUST_2021_PREFIXES_INCOMPATIBLE_SYNTAX, TEXT_DIRECTION_CODEPOINT_IN_COMMENT,
1613};
1714use rustc_session::lint::BuiltinLintDiag;
1815use rustc_session::parse::ParseSess;
16use rustc_span::edition::Edition;
1917use rustc_span::symbol::Symbol;
20use rustc_span::{edition::Edition, BytePos, Pos, Span};
18use rustc_span::{BytePos, Pos, Span};
2119use tracing::debug;
2220
21use crate::lexer::unicode_chars::UNICODE_ARRAY;
22use crate::{errors, make_unclosed_delims_error};
23
2324mod diagnostics;
2425mod tokentrees;
2526mod unescape_error_reporting;
compiler/rustc_parse/src/lexer/tokentrees.rs+6-5
......@@ -1,14 +1,15 @@
1use super::diagnostics::report_suspicious_mismatch_block;
2use super::diagnostics::same_indentation_level;
3use super::diagnostics::TokenTreeDiagInfo;
4use super::{StringReader, UnmatchedDelim};
5use crate::Parser;
61use rustc_ast::token::{self, Delimiter, Token};
72use rustc_ast::tokenstream::{DelimSpacing, DelimSpan, Spacing, TokenStream, TokenTree};
83use rustc_ast_pretty::pprust::token_to_string;
94use rustc_errors::{Applicability, PErr};
105use rustc_span::symbol::kw;
116
7use super::diagnostics::{
8 report_suspicious_mismatch_block, same_indentation_level, TokenTreeDiagInfo,
9};
10use super::{StringReader, UnmatchedDelim};
11use crate::Parser;
12
1213pub(super) struct TokenTreesReader<'psess, 'src> {
1314 string_reader: StringReader<'psess, 'src>,
1415 /// 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(
4040 dcx.emit_err(UnescapeError::InvalidUnicodeEscape { span: err_span, surrogate: false })
4141 }
4242 EscapeError::MoreThanOneChar => {
43 use unicode_normalization::{char::is_combining_mark, UnicodeNormalization};
43 use unicode_normalization::char::is_combining_mark;
44 use unicode_normalization::UnicodeNormalization;
4445 let mut sugg = None;
4546 let mut note = None;
4647
compiler/rustc_parse/src/lexer/unicode_chars.rs+5-5
......@@ -1,12 +1,12 @@
11//! Characters and their corresponding confusables were collected from
22//! <https://www.unicode.org/Public/security/10.0.0/confusables.txt>
33
4use rustc_span::symbol::kw;
5use rustc_span::{BytePos, Pos, Span};
6
47use super::StringReader;
5use crate::{
6 errors::TokenSubstitution,
7 token::{self, Delimiter},
8};
9use rustc_span::{symbol::kw, BytePos, Pos, Span};
8use crate::errors::TokenSubstitution;
9use crate::token::{self, Delimiter};
1010
1111#[rustfmt::skip] // for line breaks
1212pub(super) const UNICODE_ARRAY: &[(char, &str, &str)] = &[
compiler/rustc_parse/src/lib.rs+3-4
......@@ -12,18 +12,17 @@
1212#![feature(let_chains)]
1313// tidy-alphabetical-end
1414
15use std::path::Path;
16
1517use rustc_ast as ast;
16use rustc_ast::token;
1718use rustc_ast::tokenstream::TokenStream;
18use rustc_ast::{AttrItem, Attribute, MetaItem};
19use rustc_ast::{token, AttrItem, Attribute, MetaItem};
1920use rustc_ast_pretty::pprust;
2021use rustc_data_structures::sync::Lrc;
2122use rustc_errors::{Diag, FatalError, PResult};
2223use rustc_session::parse::ParseSess;
2324use rustc_span::{FileName, SourceFile, Span};
2425
25use std::path::Path;
26
2726pub const MACRO_ARGUMENTS: Option<&str> = Some("macro arguments");
2827
2928#[macro_use]
compiler/rustc_parse/src/parser/attr.rs+7-7
......@@ -1,16 +1,16 @@
1use crate::errors;
2use crate::fluent_generated as fluent;
3use crate::maybe_whole;
4
5use super::{AttrWrapper, Capturing, FnParseMode, ForceCollect, Parser, PathStyle};
61use rustc_ast as ast;
72use rustc_ast::attr;
83use rustc_ast::token::{self, Delimiter};
9use rustc_errors::{codes::*, Diag, PResult};
10use rustc_span::{sym, symbol::kw, BytePos, Span};
4use rustc_errors::codes::*;
5use rustc_errors::{Diag, PResult};
6use rustc_span::symbol::kw;
7use rustc_span::{sym, BytePos, Span};
118use thin_vec::ThinVec;
129use tracing::debug;
1310
11use super::{AttrWrapper, Capturing, FnParseMode, ForceCollect, Parser, PathStyle};
12use crate::{errors, fluent_generated as fluent, maybe_whole};
13
1414// Public for rustfmt usage
1515#[derive(Debug)]
1616pub enum InnerAttrPolicy {
compiler/rustc_parse/src/parser/attr_wrapper.rs+10-7
......@@ -1,14 +1,16 @@
1use super::{Capturing, FlatToken, ForceCollect, Parser, ReplaceRange, TokenCursor};
1use std::{iter, mem};
2
23use rustc_ast::token::{Delimiter, Token, TokenKind};
3use rustc_ast::tokenstream::{AttrTokenStream, AttrTokenTree, AttrsTarget, DelimSpacing};
4use rustc_ast::tokenstream::{DelimSpan, LazyAttrTokenStream, Spacing, ToAttrTokenStream};
5use rustc_ast::{self as ast};
6use rustc_ast::{AttrVec, Attribute, HasAttrs, HasTokens};
4use rustc_ast::tokenstream::{
5 AttrTokenStream, AttrTokenTree, AttrsTarget, DelimSpacing, DelimSpan, LazyAttrTokenStream,
6 Spacing, ToAttrTokenStream,
7};
8use rustc_ast::{self as ast, AttrVec, Attribute, HasAttrs, HasTokens};
79use rustc_errors::PResult;
810use rustc_session::parse::ParseSess;
911use rustc_span::{sym, Span, DUMMY_SP};
1012
11use std::{iter, mem};
13use super::{Capturing, FlatToken, ForceCollect, Parser, ReplaceRange, TokenCursor};
1214
1315/// A wrapper type to ensure that the parser handles outer attributes correctly.
1416/// When we parse outer attributes, we need to ensure that we capture tokens
......@@ -469,8 +471,9 @@ fn needs_tokens(attrs: &[ast::Attribute]) -> bool {
469471// Some types are used a lot. Make sure they don't unintentionally get bigger.
470472#[cfg(target_pointer_width = "64")]
471473mod size_asserts {
472 use super::*;
473474 use rustc_data_structures::static_assert_size;
475
476 use super::*;
474477 // tidy-alphabetical-start
475478 static_assert_size!(AttrWrapper, 16);
476479 static_assert_size!(LazyAttrTokenStreamImpl, 96);
compiler/rustc_parse/src/parser/diagnostics.rs+25-24
......@@ -1,25 +1,6 @@
1use super::pat::Expected;
2use super::{
3 BlockMode, CommaRecoveryMode, Parser, PathStyle, Restrictions, SemiColonMode, SeqSep, TokenType,
4};
5use 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};
20use crate::fluent_generated as fluent;
21use crate::parser;
22use crate::parser::attr::InnerAttrPolicy;
1use std::mem::take;
2use std::ops::{Deref, DerefMut};
3
234use ast::token::IdentIsRaw;
245use rustc_ast as ast;
256use rustc_ast::ptr::P;
......@@ -41,11 +22,31 @@ use rustc_session::errors::ExprParenthesesNeeded;
4122use rustc_span::source_map::Spanned;
4223use rustc_span::symbol::{kw, sym, Ident};
4324use rustc_span::{BytePos, Span, SpanSnippetError, Symbol, DUMMY_SP};
44use std::mem::take;
45use std::ops::{Deref, DerefMut};
4625use thin_vec::{thin_vec, ThinVec};
4726use tracing::{debug, trace};
4827
28use super::pat::Expected;
29use super::{
30 BlockMode, CommaRecoveryMode, Parser, PathStyle, Restrictions, SemiColonMode, SeqSep, TokenType,
31};
32use 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};
47use crate::parser::attr::InnerAttrPolicy;
48use crate::{fluent_generated as fluent, parser};
49
4950/// Creates a placeholder argument.
5051pub(super) fn dummy_arg(ident: Ident, guar: ErrorGuaranteed) -> Param {
5152 let pat = P(Pat {
compiler/rustc_parse/src/parser/expr.rs+16-15
......@@ -1,30 +1,22 @@
11// ignore-tidy-filelength
22
3use super::diagnostics::SnapshotParser;
4use super::pat::{CommaRecoveryMode, Expected, RecoverColon, RecoverComma};
5use super::ty::{AllowPlus, RecoverQPath, RecoverReturnSign};
6use super::{
7 AttrWrapper, BlockMode, ClosureSpans, ForceCollect, Parser, PathStyle, Restrictions,
8 SemiColonMode, SeqSep, TokenType, Trailing,
9};
3use core::mem;
4use core::ops::ControlFlow;
105
11use crate::errors;
12use crate::maybe_recover_from_interpolated_ty_qpath;
136use ast::mut_visit::{self, MutVisitor};
147use ast::token::IdentIsRaw;
158use ast::{CoroutineKind, ForLoopKind, GenBlockKind, MatchKind, Pat, Path, PathSegment, Recovered};
16use core::mem;
17use core::ops::ControlFlow;
189use rustc_ast::ptr::P;
1910use rustc_ast::token::{self, Delimiter, Token, TokenKind};
2011use rustc_ast::util::case::Case;
2112use rustc_ast::util::classify;
2213use rustc_ast::util::parser::{prec_let_scrutinee_needs_par, AssocOp, Fixity};
2314use rustc_ast::visit::{walk_expr, Visitor};
24use rustc_ast::{self as ast, AttrStyle, AttrVec, CaptureBy, ExprField, UnOp, DUMMY_NODE_ID};
25use rustc_ast::{AnonConst, BinOp, BinOpKind, FnDecl, FnRetTy, MacCall, Param, Ty, TyKind};
26use rustc_ast::{Arm, BlockCheckMode, Expr, ExprKind, Label, Movability, RangeLimits};
27use rustc_ast::{ClosureBinder, MetaItemLit, StmtKind};
15use 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};
2820use rustc_ast_pretty::pprust;
2921use rustc_data_structures::stack::ensure_sufficient_stack;
3022use rustc_errors::{Applicability, Diag, PResult, StashKey, Subdiagnostic};
......@@ -39,6 +31,15 @@ use rustc_span::{BytePos, ErrorGuaranteed, Pos, Span};
3931use thin_vec::{thin_vec, ThinVec};
4032use tracing::instrument;
4133
34use super::diagnostics::SnapshotParser;
35use super::pat::{CommaRecoveryMode, Expected, RecoverColon, RecoverComma};
36use super::ty::{AllowPlus, RecoverQPath, RecoverReturnSign};
37use super::{
38 AttrWrapper, BlockMode, ClosureSpans, ForceCollect, Parser, PathStyle, Restrictions,
39 SemiColonMode, SeqSep, TokenType, Trailing,
40};
41use crate::{errors, maybe_recover_from_interpolated_ty_qpath};
42
4243#[derive(Debug)]
4344pub(super) enum LhsExpr {
4445 // Already parsed just the outer attributes.
compiler/rustc_parse/src/parser/generics.rs+8-10
......@@ -1,21 +1,19 @@
1use crate::errors::{
2 self, MultipleWhereClauses, UnexpectedDefaultValueForLifetimeInGenericParameters,
3 UnexpectedSelfInGenericParameters, WhereClauseBeforeTupleStructBody,
4 WhereClauseBeforeTupleStructBodySugg,
5};
6
7use super::{ForceCollect, Parser};
8
91use ast::token::Delimiter;
10use rustc_ast::token;
112use rustc_ast::{
12 self as ast, AttrVec, GenericBounds, GenericParam, GenericParamKind, TyKind, WhereClause,
3 self as ast, token, AttrVec, GenericBounds, GenericParam, GenericParamKind, TyKind, WhereClause,
134};
145use rustc_errors::{Applicability, PResult};
156use rustc_span::symbol::{kw, Ident};
167use rustc_span::Span;
178use thin_vec::ThinVec;
189
10use super::{ForceCollect, Parser};
11use crate::errors::{
12 self, MultipleWhereClauses, UnexpectedDefaultValueForLifetimeInGenericParameters,
13 UnexpectedSelfInGenericParameters, WhereClauseBeforeTupleStructBody,
14 WhereClauseBeforeTupleStructBodySugg,
15};
16
1917enum PredicateOrStructBody {
2018 Predicate(ast::WherePredicate),
2119 StructBody(ThinVec<ast::FieldDef>),
compiler/rustc_parse/src/parser/item.rs+12-12
......@@ -1,9 +1,6 @@
1use super::diagnostics::{dummy_arg, ConsumeClosingDelim};
2use super::ty::{AllowPlus, RecoverQPath, RecoverReturnSign};
3use super::{AttrWrapper, FollowedByType, ForceCollect, Parser, PathStyle, Trailing};
4use crate::errors::{self, MacroExpandsToAdtField};
5use crate::fluent_generated as fluent;
6use crate::maybe_whole;
1use std::fmt::Write;
2use std::mem;
3
74use ast::token::IdentIsRaw;
85use rustc_ast::ast::*;
96use rustc_ast::ptr::P;
......@@ -12,18 +9,21 @@ use rustc_ast::tokenstream::{DelimSpan, TokenStream, TokenTree};
129use rustc_ast::util::case::Case;
1310use rustc_ast::{self as ast};
1411use rustc_ast_pretty::pprust;
15use rustc_errors::{codes::*, struct_span_code_err, Applicability, PResult, StashKey};
12use rustc_errors::codes::*;
13use rustc_errors::{struct_span_code_err, Applicability, PResult, StashKey};
1614use rustc_span::edit_distance::edit_distance;
1715use rustc_span::edition::Edition;
18use rustc_span::source_map;
1916use rustc_span::symbol::{kw, sym, Ident, Symbol};
20use rustc_span::ErrorGuaranteed;
21use rustc_span::{Span, DUMMY_SP};
22use std::fmt::Write;
23use std::mem;
17use rustc_span::{source_map, ErrorGuaranteed, Span, DUMMY_SP};
2418use thin_vec::{thin_vec, ThinVec};
2519use tracing::debug;
2620
21use super::diagnostics::{dummy_arg, ConsumeClosingDelim};
22use super::ty::{AllowPlus, RecoverQPath, RecoverReturnSign};
23use super::{AttrWrapper, FollowedByType, ForceCollect, Parser, PathStyle, Trailing};
24use crate::errors::{self, MacroExpandsToAdtField};
25use crate::{fluent_generated as fluent, maybe_whole};
26
2727impl<'a> Parser<'a> {
2828 /// Parses a source module as a crate. This is the main entry point for the parser.
2929 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;
1010mod stmt;
1111mod ty;
1212
13use crate::lexer::UnmatchedDelim;
13use std::ops::Range;
14use std::{fmt, mem, slice};
15
1416use attr_wrapper::AttrWrapper;
1517pub use diagnostics::AttemptLocalParseRecovery;
1618pub(crate) use expr::ForbiddenLetReason;
1719pub(crate) use item::FnParseMode;
1820pub use pat::{CommaRecoveryMode, RecoverColon, RecoverComma};
1921use path::PathStyle;
20
2122use rustc_ast::ptr::P;
2223use rustc_ast::token::{self, Delimiter, IdentIsRaw, Nonterminal, Token, TokenKind};
23use rustc_ast::tokenstream::{AttrsTarget, DelimSpacing, DelimSpan, Spacing};
24use rustc_ast::tokenstream::{TokenStream, TokenTree, TokenTreeCursor};
24use rustc_ast::tokenstream::{
25 AttrsTarget, DelimSpacing, DelimSpan, Spacing, TokenStream, TokenTree, TokenTreeCursor,
26};
2527use rustc_ast::util::case::Case;
2628use rustc_ast::{
2729 self as ast, AnonConst, AttrArgs, AttrArgsEq, AttrId, ByRef, Const, CoroutineKind, DelimArgs,
......@@ -35,14 +37,13 @@ use rustc_errors::{Applicability, Diag, FatalError, MultiSpan, PResult};
3537use rustc_session::parse::ParseSess;
3638use rustc_span::symbol::{kw, sym, Ident, Symbol};
3739use rustc_span::{Span, DUMMY_SP};
38use std::ops::Range;
39use std::{fmt, mem, slice};
4040use thin_vec::ThinVec;
4141use tracing::debug;
4242
4343use crate::errors::{
4444 self, IncorrectVisibilityRestriction, MismatchedClosingDelimiter, NonStringAbiLiteral,
4545};
46use crate::lexer::UnmatchedDelim;
4647
4748#[cfg(test)]
4849mod tests;
compiler/rustc_parse/src/parser/mut_visit/tests.rs+2-1
......@@ -1,10 +1,11 @@
1use crate::parser::tests::{matches_codepattern, string_to_crate};
21use rustc_ast as ast;
32use rustc_ast::mut_visit::MutVisitor;
43use rustc_ast_pretty::pprust;
54use rustc_span::create_default_session_globals_then;
65use rustc_span::symbol::Ident;
76
7use crate::parser::tests::{matches_codepattern, string_to_crate};
8
89// This version doesn't care about getting comments or doc-strings in.
910fn print_crate_items(krate: &ast::Crate) -> String {
1011 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 @@
11use rustc_ast::ptr::P;
2use rustc_ast::token::{
3 self, Delimiter, Nonterminal::*, NonterminalKind, NtExprKind::*, NtPatKind::*, Token,
4};
2use rustc_ast::token::Nonterminal::*;
3use rustc_ast::token::NtExprKind::*;
4use rustc_ast::token::NtPatKind::*;
5use rustc_ast::token::{self, Delimiter, NonterminalKind, Token};
56use rustc_ast::HasTokens;
67use rustc_ast_pretty::pprust;
78use rustc_data_structures::sync::Lrc;
compiler/rustc_parse/src/parser/pat.rs+15-14
......@@ -1,17 +1,3 @@
1use super::{ForceCollect, Parser, PathStyle, Restrictions, Trailing};
2use 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};
13use crate::parser::expr::{could_be_unclosed_char_literal, LhsExpr};
14use crate::{maybe_recover_from_interpolated_ty_qpath, maybe_whole};
151use rustc_ast::mut_visit::{walk_pat, MutVisitor};
162use rustc_ast::ptr::P;
173use rustc_ast::token::{self, BinOpToken, Delimiter, Token};
......@@ -27,6 +13,21 @@ use rustc_span::symbol::{kw, sym, Ident};
2713use rustc_span::{BytePos, ErrorGuaranteed, Span};
2814use thin_vec::{thin_vec, ThinVec};
2915
16use super::{ForceCollect, Parser, PathStyle, Restrictions, Trailing};
17use 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};
28use crate::parser::expr::{could_be_unclosed_char_literal, LhsExpr};
29use crate::{maybe_recover_from_interpolated_ty_qpath, maybe_whole};
30
3031#[derive(PartialEq, Copy, Clone)]
3132pub enum Expected {
3233 ParameterName,
compiler/rustc_parse/src/parser/path.rs+8-6
......@@ -1,8 +1,5 @@
1use super::ty::{AllowPlus, RecoverQPath, RecoverReturnSign};
2use super::{Parser, Restrictions, TokenType};
3use crate::errors::PathSingleColon;
4use crate::parser::{CommaRecoveryMode, RecoverColon, RecoverComma};
5use crate::{errors, maybe_whole};
1use std::mem;
2
63use ast::token::IdentIsRaw;
74use rustc_ast::ptr::P;
85use rustc_ast::token::{self, Delimiter, Token, TokenKind};
......@@ -14,10 +11,15 @@ use rustc_ast::{
1411use rustc_errors::{Applicability, Diag, PResult};
1512use rustc_span::symbol::{kw, sym, Ident};
1613use rustc_span::{BytePos, Span};
17use std::mem;
1814use thin_vec::ThinVec;
1915use tracing::debug;
2016
17use super::ty::{AllowPlus, RecoverQPath, RecoverReturnSign};
18use super::{Parser, Restrictions, TokenType};
19use crate::errors::PathSingleColon;
20use crate::parser::{CommaRecoveryMode, RecoverColon, RecoverComma};
21use crate::{errors, maybe_whole};
22
2123/// Specifies how to parse a path.
2224#[derive(Copy, Clone, PartialEq)]
2325pub(super) enum PathStyle {
compiler/rustc_parse/src/parser/stmt.rs+17-17
......@@ -1,31 +1,31 @@
1use super::attr::InnerAttrForbiddenReason;
2use super::diagnostics::AttemptLocalParseRecovery;
3use super::expr::LhsExpr;
4use super::pat::{PatternLocation, RecoverComma};
5use super::path::PathStyle;
6use super::{
7 AttrWrapper, BlockMode, FnParseMode, ForceCollect, Parser, Restrictions, SemiColonMode,
8};
9use crate::errors;
10use crate::maybe_whole;
1use std::borrow::Cow;
2use std::mem;
113
12use crate::errors::MalformedLoopLabel;
134use ast::Label;
145use rustc_ast as ast;
156use rustc_ast::ptr::P;
167use rustc_ast::token::{self, Delimiter, TokenKind};
178use rustc_ast::util::classify::{self, TrailingBrace};
18use rustc_ast::{AttrStyle, AttrVec, LocalKind, MacCall, MacCallStmt, MacStmtStyle};
19use rustc_ast::{Block, BlockCheckMode, Expr, ExprKind, HasAttrs, Local, Recovered, Stmt};
20use rustc_ast::{StmtKind, DUMMY_NODE_ID};
9use rustc_ast::{
10 AttrStyle, AttrVec, Block, BlockCheckMode, Expr, ExprKind, HasAttrs, Local, LocalKind, MacCall,
11 MacCallStmt, MacStmtStyle, Recovered, Stmt, StmtKind, DUMMY_NODE_ID,
12};
2113use rustc_errors::{Applicability, Diag, PResult};
2214use rustc_span::symbol::{kw, sym, Ident};
2315use rustc_span::{BytePos, ErrorGuaranteed, Span};
24
25use std::borrow::Cow;
26use std::mem;
2716use thin_vec::{thin_vec, ThinVec};
2817
18use super::attr::InnerAttrForbiddenReason;
19use super::diagnostics::AttemptLocalParseRecovery;
20use super::expr::LhsExpr;
21use super::pat::{PatternLocation, RecoverComma};
22use super::path::PathStyle;
23use super::{
24 AttrWrapper, BlockMode, FnParseMode, ForceCollect, Parser, Restrictions, SemiColonMode,
25};
26use crate::errors::MalformedLoopLabel;
27use crate::{errors, maybe_whole};
28
2929impl<'a> Parser<'a> {
3030 /// Parses a statement. This stops just before trailing semicolons on everything but items.
3131 /// 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 @@
1use crate::parser::ForceCollect;
2use crate::{
3 new_parser_from_source_str, parser::Parser, source_str_to_stream, unwrap_or_emit_fatal,
4};
1use std::io::prelude::*;
2use std::iter::Peekable;
3use std::path::{Path, PathBuf};
4use std::sync::{Arc, Mutex};
5use std::{io, str};
6
57use ast::token::IdentIsRaw;
68use rustc_ast::ptr::P;
79use rustc_ast::token::{self, Delimiter, Token};
810use rustc_ast::tokenstream::{DelimSpacing, DelimSpan, Spacing, TokenStream, TokenTree};
9use rustc_ast::visit;
10use rustc_ast::{self as ast, PatKind};
11use rustc_ast::{self as ast, visit, PatKind};
1112use rustc_ast_pretty::pprust::item_to_string;
1213use rustc_data_structures::sync::Lrc;
1314use rustc_errors::emitter::HumanEmitter;
1415use rustc_errors::{DiagCtxt, MultiSpan, PResult};
1516use rustc_session::parse::ParseSess;
16use rustc_span::create_default_session_globals_then;
1717use rustc_span::source_map::{FilePathMapping, SourceMap};
1818use rustc_span::symbol::{kw, sym, Symbol};
19use rustc_span::{BytePos, FileName, Pos, Span};
20use std::io;
21use std::io::prelude::*;
22use std::iter::Peekable;
23use std::path::{Path, PathBuf};
24use std::str;
25use std::sync::{Arc, Mutex};
19use rustc_span::{create_default_session_globals_then, BytePos, FileName, Pos, Span};
2620use termcolor::WriteColor;
2721
22use crate::parser::{ForceCollect, Parser};
23use crate::{new_parser_from_source_str, source_str_to_stream, unwrap_or_emit_fatal};
24
2825fn psess() -> ParseSess {
2926 ParseSess::new(vec![crate::DEFAULT_LOCALE_RESOURCE, crate::DEFAULT_LOCALE_RESOURCE])
3027}
compiler/rustc_parse/src/parser/tokenstream/tests.rs+3-3
......@@ -1,8 +1,8 @@
1use crate::parser::tests::string_to_stream;
21use rustc_ast::token::{self, IdentIsRaw};
32use rustc_ast::tokenstream::{TokenStream, TokenTree};
4use rustc_span::create_default_session_globals_then;
5use rustc_span::{BytePos, Span, Symbol};
3use rustc_span::{create_default_session_globals_then, BytePos, Span, Symbol};
4
5use crate::parser::tests::string_to_stream;
66
77fn string_to_ts(string: &str) -> TokenStream {
88 string_to_stream(string.to_owned())
compiler/rustc_parse/src/parser/ty.rs+9-10
......@@ -1,13 +1,3 @@
1use super::{Parser, PathStyle, SeqSep, TokenType, Trailing};
2
3use crate::errors::{
4 self, DynAfterMut, ExpectedFnPathFoundFnKeyword, ExpectedMutOrConstInRawPointerType,
5 FnPointerCannotBeAsync, FnPointerCannotBeConst, FnPtrWithGenerics, FnPtrWithGenericsSugg,
6 HelpUseLatestEdition, InvalidDynKeyword, LifetimeAfterMut, NeedPlusAfterTraitObjectLifetime,
7 NestedCVariadicType, ReturnTypesUseThinArrow,
8};
9use crate::{maybe_recover_from_interpolated_ty_qpath, maybe_whole};
10
111use rustc_ast::ptr::P;
122use rustc_ast::token::{self, BinOpToken, Delimiter, Token, TokenKind};
133use rustc_ast::util::case::Case;
......@@ -21,6 +11,15 @@ use rustc_span::symbol::{kw, sym, Ident};
2111use rustc_span::{ErrorGuaranteed, Span, Symbol};
2212use thin_vec::{thin_vec, ThinVec};
2313
14use super::{Parser, PathStyle, SeqSep, TokenType, Trailing};
15use crate::errors::{
16 self, DynAfterMut, ExpectedFnPathFoundFnKeyword, ExpectedMutOrConstInRawPointerType,
17 FnPointerCannotBeAsync, FnPointerCannotBeConst, FnPtrWithGenerics, FnPtrWithGenericsSugg,
18 HelpUseLatestEdition, InvalidDynKeyword, LifetimeAfterMut, NeedPlusAfterTraitObjectLifetime,
19 NestedCVariadicType, ReturnTypesUseThinArrow,
20};
21use crate::{maybe_recover_from_interpolated_ty_qpath, maybe_whole};
22
2423/// Signals whether parsing a type should allow `+`.
2524///
2625/// For example, let T be the type `impl Default + 'static`
compiler/rustc_parse/src/validate_attr.rs+2-2
......@@ -1,7 +1,5 @@
11//! Meta-syntax validation logic of attributes for post-expansion.
22
3use crate::{errors, parse_in};
4
53use rustc_ast::token::Delimiter;
64use rustc_ast::tokenstream::DelimSpan;
75use rustc_ast::{
......@@ -18,6 +16,8 @@ use rustc_session::lint::BuiltinLintDiag;
1816use rustc_session::parse::ParseSess;
1917use rustc_span::{sym, BytePos, Span, Symbol};
2018
19use crate::{errors, parse_in};
20
2121pub fn check_attr(features: &Features, psess: &ParseSess, attr: &Attribute) {
2222 if attr.is_doc_comment() {
2323 return;
compiler/rustc_parse_format/src/lib.rs+2-4
......@@ -15,16 +15,14 @@
1515)]
1616// tidy-alphabetical-end
1717
18use std::{iter, str, string};
19
1820use rustc_lexer::unescape;
1921pub use Alignment::*;
2022pub use Count::*;
2123pub use Piece::*;
2224pub use Position::*;
2325
24use std::iter;
25use std::str;
26use std::string;
27
2826// Note: copied from rustc_span
2927/// Range inside of a `Span` used for diagnostics when we only have access to relative positions.
3028#[derive(Copy, Clone, PartialEq, Eq, Debug)]
compiler/rustc_passes/src/check_attr.rs+11-10
......@@ -4,20 +4,21 @@
44//! conflicts between multiple such attributes attached to the same
55//! item.
66
7use crate::{errors, fluent_generated as fluent};
8use rustc_ast::{ast, AttrKind, AttrStyle, Attribute, LitKind};
9use rustc_ast::{MetaItemKind, MetaItemLit, NestedMetaItem};
7use std::cell::Cell;
8use std::collections::hash_map::Entry;
9
10use rustc_ast::{
11 ast, AttrKind, AttrStyle, Attribute, LitKind, MetaItemKind, MetaItemLit, NestedMetaItem,
12};
1013use rustc_data_structures::fx::FxHashMap;
11use rustc_errors::{Applicability, IntoDiagArg, MultiSpan};
12use rustc_errors::{DiagCtxtHandle, StashKey};
14use rustc_errors::{Applicability, DiagCtxtHandle, IntoDiagArg, MultiSpan, StashKey};
1315use rustc_feature::{AttributeDuplicates, AttributeType, BuiltinAttribute, BUILTIN_ATTRIBUTE_MAP};
1416use rustc_hir::def_id::LocalModDefId;
1517use rustc_hir::intravisit::{self, Visitor};
16use rustc_hir::{self as hir};
1718use 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,
1921};
20use rustc_hir::{MethodKind, Safety, Target};
2122use rustc_macros::LintDiagnostic;
2223use rustc_middle::bug;
2324use rustc_middle::hir::nested_filter;
......@@ -37,10 +38,10 @@ use rustc_target::spec::abi::Abi;
3738use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
3839use rustc_trait_selection::infer::{TyCtxtInferExt, ValuePairs};
3940use rustc_trait_selection::traits::ObligationCtxt;
40use std::cell::Cell;
41use std::collections::hash_map::Entry;
4241use tracing::debug;
4342
43use crate::{errors, fluent_generated as fluent};
44
4445#[derive(LintDiagnostic)]
4546#[diag(passes_diagnostic_diagnostic_on_unimplemented_only_for_traits)]
4647struct DiagnosticOnUnimplementedOnlyForTraits;
compiler/rustc_passes/src/check_const.rs+1-2
......@@ -7,8 +7,6 @@
77//! errors. We still look for those primitives in the MIR const-checker to ensure nothing slips
88//! through, but errors for structured control flow in a `const` should be emitted here.
99
10use rustc_attr as attr;
11use rustc_hir as hir;
1210use rustc_hir::def_id::{LocalDefId, LocalModDefId};
1311use rustc_hir::intravisit::{self, Visitor};
1412use rustc_middle::hir::nested_filter;
......@@ -17,6 +15,7 @@ use rustc_middle::span_bug;
1715use rustc_middle::ty::TyCtxt;
1816use rustc_session::parse::feature_err;
1917use rustc_span::{sym, Span, Symbol};
18use {rustc_attr as attr, rustc_hir as hir};
2019
2120use crate::errors::SkippingConstChecks;
2221
compiler/rustc_passes/src/dead.rs+2-1
......@@ -3,6 +3,8 @@
33// expectations such as `#[expect(unused)]` and `#[expect(dead_code)]` is live, and everything else
44// is dead.
55
6use std::mem;
7
68use hir::def_id::{LocalDefIdMap, LocalDefIdSet};
79use hir::ItemKind;
810use rustc_data_structures::unord::UnordSet;
......@@ -21,7 +23,6 @@ use rustc_session::lint;
2123use rustc_session::lint::builtin::DEAD_CODE;
2224use rustc_span::symbol::{sym, Symbol};
2325use rustc_target::abi::FieldIdx;
24use std::mem;
2526
2627use crate::errors::{
2728 ChangeFields, IgnoredDerivedImpls, MultipleDeadCodes, ParentInfo, UselessAssignment,
compiler/rustc_passes/src/debugger_visualizer.rs+3-5
......@@ -3,11 +3,9 @@
33use rustc_ast::Attribute;
44use rustc_data_structures::sync::Lrc;
55use rustc_expand::base::resolve_path;
6use rustc_middle::{
7 middle::debugger_visualizer::{DebuggerVisualizerFile, DebuggerVisualizerType},
8 query::{LocalCrate, Providers},
9 ty::TyCtxt,
10};
6use rustc_middle::middle::debugger_visualizer::{DebuggerVisualizerFile, DebuggerVisualizerType};
7use rustc_middle::query::{LocalCrate, Providers};
8use rustc_middle::ty::TyCtxt;
119use rustc_session::Session;
1210use rustc_span::sym;
1311
compiler/rustc_passes/src/diagnostic_items.rs+1-2
......@@ -12,8 +12,7 @@
1212use rustc_ast as ast;
1313use rustc_hir::diagnostic_items::DiagnosticItems;
1414use rustc_hir::OwnerId;
15use rustc_middle::query::LocalCrate;
16use rustc_middle::query::Providers;
15use rustc_middle::query::{LocalCrate, Providers};
1716use rustc_middle::ty::TyCtxt;
1817use rustc_span::def_id::{DefId, LOCAL_CRATE};
1918use 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};
66use rustc_hir::{ItemId, Node, CRATE_HIR_ID};
77use rustc_middle::query::Providers;
88use rustc_middle::ty::TyCtxt;
9use rustc_session::config::{sigpipe, CrateType, EntryFnType};
10use rustc_session::{config::RemapPathScopeComponents, RemapFileNameExt};
9use rustc_session::config::{sigpipe, CrateType, EntryFnType, RemapPathScopeComponents};
10use rustc_session::RemapFileNameExt;
1111use rustc_span::symbol::sym;
1212use rustc_span::{Span, Symbol};
1313
compiler/rustc_passes/src/errors.rs+6-7
......@@ -1,13 +1,11 @@
1use std::{
2 io::Error,
3 path::{Path, PathBuf},
4};
1use std::io::Error;
2use std::path::{Path, PathBuf};
53
6use crate::fluent_generated as fluent;
74use rustc_ast::Label;
5use rustc_errors::codes::*;
86use 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,
119};
1210use rustc_hir::{self as hir, ExprKind, Target};
1311use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
......@@ -15,6 +13,7 @@ use rustc_middle::ty::{MainDefinition, Ty};
1513use rustc_span::{Span, Symbol, DUMMY_SP};
1614
1715use crate::check_attr::ProcMacroKind;
16use crate::fluent_generated as fluent;
1817use crate::lang_items::Duplicate;
1918
2019#[derive(LintDiagnostic)]
compiler/rustc_passes/src/hir_stats.rs+2-4
......@@ -2,13 +2,11 @@
22// pieces of AST and HIR. The resulting numbers are good approximations but not
33// completely accurate (some things might be counted twice, others missed).
44
5use rustc_ast::visit as ast_visit;
65use rustc_ast::visit::BoundKind;
7use rustc_ast::{self as ast, AttrId, NodeId};
6use rustc_ast::{self as ast, visit as ast_visit, AttrId, NodeId};
87use rustc_data_structures::fx::{FxHashMap, FxHashSet};
98use rustc_hir as hir;
10use rustc_hir::intravisit as hir_visit;
11use rustc_hir::HirId;
9use rustc_hir::{intravisit as hir_visit, HirId};
1210use rustc_middle::hir::map::Map;
1311use rustc_middle::ty::TyCtxt;
1412use rustc_middle::util::common::to_readable_str;
compiler/rustc_passes/src/lang_items.rs+5-6
......@@ -7,23 +7,22 @@
77//! * Traits that represent operators; e.g., `Add`, `Sub`, `Index`.
88//! * Functions called by the compiler itself.
99
10use crate::errors::{
11 DuplicateLangItem, IncorrectTarget, LangItemOnIncorrectTarget, UnknownLangItem,
12};
13use crate::weak_lang_items;
14
1510use rustc_ast as ast;
1611use rustc_ast::visit;
1712use rustc_data_structures::fx::FxHashMap;
1813use rustc_hir::def_id::{DefId, LocalDefId};
1914use rustc_hir::lang_items::{extract, GenericRequirement};
2015use rustc_hir::{LangItem, LanguageItems, MethodKind, Target};
16use rustc_middle::query::Providers;
2117use rustc_middle::ty::{ResolverAstLowering, TyCtxt};
2218use rustc_session::cstore::ExternCrate;
2319use rustc_span::symbol::kw::Empty;
2420use rustc_span::Span;
2521
26use rustc_middle::query::Providers;
22use crate::errors::{
23 DuplicateLangItem, IncorrectTarget, LangItemOnIncorrectTarget, UnknownLangItem,
24};
25use crate::weak_lang_items;
2726
2827pub(crate) enum Duplicate {
2928 Plain,
compiler/rustc_passes/src/layout_test.rs+2-1
......@@ -9,7 +9,8 @@ use rustc_span::symbol::sym;
99use rustc_span::Span;
1010use rustc_target::abi::{HasDataLayout, TargetDataLayout};
1111use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
12use rustc_trait_selection::{infer::TyCtxtInferExt, traits};
12use rustc_trait_selection::infer::TyCtxtInferExt;
13use rustc_trait_selection::traits;
1314
1415use crate::errors::{
1516 LayoutAbi, LayoutAlign, LayoutHomogeneousAggregate, LayoutInvalidAttribute, LayoutOf,
compiler/rustc_passes/src/liveness.rs+7-7
......@@ -81,10 +81,9 @@
8181//! We generate various special nodes for various, well, special purposes.
8282//! These are described in the `Liveness` struct.
8383
84use crate::errors;
85
86use self::LiveNodeKind::*;
87use self::VarKind::*;
84use std::io;
85use std::io::prelude::*;
86use std::rc::Rc;
8887
8988use rustc_data_structures::fx::FxIndexMap;
9089use rustc_hir as hir;
......@@ -99,11 +98,12 @@ use rustc_middle::ty::{self, RootVariableMinCaptureList, Ty, TyCtxt};
9998use rustc_session::lint;
10099use rustc_span::symbol::{kw, sym, Symbol};
101100use rustc_span::{BytePos, Span};
102use std::io;
103use std::io::prelude::*;
104use std::rc::Rc;
105101use tracing::{debug, instrument};
106102
103use self::LiveNodeKind::*;
104use self::VarKind::*;
105use crate::errors;
106
107107mod rwu_table;
108108
109109rustc_index::newtype_index! {
compiler/rustc_passes/src/liveness/rwu_table.rs+2-1
......@@ -1,6 +1,7 @@
1use crate::liveness::{LiveNode, Variable};
21use std::iter;
32
3use crate::liveness::{LiveNode, Variable};
4
45#[derive(Clone, Copy)]
56pub(super) struct RWU {
67 pub(super) reader: bool,
compiler/rustc_passes/src/loops.rs+1-1
......@@ -1,6 +1,5 @@
11use std::collections::BTreeMap;
22use std::fmt;
3use Context::*;
43
54use rustc_hir as hir;
65use rustc_hir::def_id::{LocalDefId, LocalModDefId};
......@@ -13,6 +12,7 @@ use rustc_middle::ty::TyCtxt;
1312use rustc_session::Session;
1413use rustc_span::hygiene::DesugaringKind;
1514use rustc_span::{BytePos, Span};
15use Context::*;
1616
1717use crate::errors::{
1818 BreakInsideClosure, BreakInsideCoroutine, BreakNonLoop, ContinueLabeledBlock, OutsideLoop,
compiler/rustc_passes/src/stability.rs+5-3
......@@ -1,7 +1,9 @@
11//! A pass that annotates every item and method with its stability level,
22//! propagating default levels lexically from parent to children ast nodes.
33
4use crate::errors;
4use std::mem::replace;
5use std::num::NonZero;
6
57use rustc_attr::{
68 self as attr, ConstStability, DeprecatedSince, Stability, StabilityLevel, StableSince,
79 Unstable, UnstableReason, VERSION_PLACEHOLDER,
......@@ -25,10 +27,10 @@ use rustc_session::lint::builtin::{INEFFECTIVE_UNSTABLE_TRAIT_IMPL, USELESS_DEPR
2527use rustc_span::symbol::{sym, Symbol};
2628use rustc_span::Span;
2729use rustc_target::spec::abi::Abi;
28use std::mem::replace;
29use std::num::NonZero;
3030use tracing::{debug, info};
3131
32use crate::errors;
33
3234#[derive(PartialEq)]
3335enum AnnotationKind {
3436 /// 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};
180180use std::fmt;
181181use std::iter::once;
182182
183use smallvec::SmallVec;
184
185183use rustc_apfloat::ieee::{DoubleS, HalfS, IeeeFloat, QuadS, SingleS};
186184use rustc_index::bit_set::{BitSet, GrowableBitSet};
187185use rustc_index::IndexVec;
186use smallvec::SmallVec;
188187
189188use self::Constructor::*;
190189use self::MaybeInfiniteInt::*;
191190use self::SliceKind::*;
192
193191use crate::PatCx;
194192
195193/// Whether we have seen a constructor in the column or not.
compiler/rustc_pattern_analysis/src/lints.rs+4-3
......@@ -1,11 +1,12 @@
1use rustc_session::lint::builtin::NON_EXHAUSTIVE_OMITTED_PATTERNS;
2use rustc_span::ErrorGuaranteed;
3use tracing::instrument;
4
15use crate::constructor::Constructor;
26use crate::errors::{NonExhaustiveOmittedPattern, NonExhaustiveOmittedPatternLintOnArm, Uncovered};
37use crate::pat_column::PatternColumn;
48use crate::rustc::{RevealedTy, RustcPatCtxt, WitnessPat};
59use crate::MatchArm;
6use rustc_session::lint::builtin::NON_EXHAUSTIVE_OMITTED_PATTERNS;
7use rustc_span::ErrorGuaranteed;
8use tracing::instrument;
910
1011/// Traverse the patterns to collect any variants of a non_exhaustive enum that fail to be mentioned
1112/// in a given column.
compiler/rustc_pattern_analysis/src/pat.rs+1-2
......@@ -5,11 +5,10 @@ use std::fmt;
55
66use smallvec::{smallvec, SmallVec};
77
8use self::Constructor::*;
89use crate::constructor::{Constructor, Slice, SliceKind};
910use crate::{PatCx, PrivateUninhabitedField};
1011
11use self::Constructor::*;
12
1312/// A globally unique id to distinguish patterns.
1413#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
1514pub(crate) struct PatId(u32);
compiler/rustc_pattern_analysis/src/rustc.rs+1-2
......@@ -17,6 +17,7 @@ use rustc_session::lint;
1717use rustc_span::{ErrorGuaranteed, Span, DUMMY_SP};
1818use rustc_target::abi::{FieldIdx, Integer, VariantIdx, FIRST_VARIANT};
1919
20use crate::constructor::Constructor::*;
2021use crate::constructor::{
2122 IntRange, MaybeInfiniteInt, OpaqueId, RangeEnd, Slice, SliceKind, VariantVisibility,
2223};
......@@ -25,8 +26,6 @@ use crate::pat_column::PatternColumn;
2526use crate::usefulness::{compute_match_usefulness, PlaceValidity};
2627use crate::{errors, Captures, PatCx, PrivateUninhabitedField};
2728
28use crate::constructor::Constructor::*;
29
3029// Re-export rustc-specific versions of all these types.
3130pub type Constructor<'p, 'tcx> = crate::constructor::Constructor<RustcPatCtxt<'p, 'tcx>>;
3231pub type ConstructorSet<'p, 'tcx> = crate::constructor::ConstructorSet<RustcPatCtxt<'p, 'tcx>>;
compiler/rustc_pattern_analysis/src/usefulness.rs+8-7
......@@ -709,18 +709,19 @@
709709//! I (Nadrieril) prefer to put new tests in `ui/pattern/usefulness` unless there's a specific
710710//! reason not to, for example if they crucially depend on a particular feature like `or_patterns`.
711711
712use self::PlaceValidity::*;
713use crate::constructor::{Constructor, ConstructorSet, IntRange};
714use crate::pat::{DeconstructedPat, PatId, PatOrWild, WitnessPat};
715use crate::{Captures, MatchArm, PatCx, PrivateUninhabitedField};
712use std::fmt;
713
714#[cfg(feature = "rustc")]
715use rustc_data_structures::stack::ensure_sufficient_stack;
716716use rustc_hash::{FxHashMap, FxHashSet};
717717use rustc_index::bit_set::BitSet;
718718use smallvec::{smallvec, SmallVec};
719use std::fmt;
720719use tracing::{debug, instrument};
721720
722#[cfg(feature = "rustc")]
723use rustc_data_structures::stack::ensure_sufficient_stack;
721use self::PlaceValidity::*;
722use crate::constructor::{Constructor, ConstructorSet, IntRange};
723use crate::pat::{DeconstructedPat, PatId, PatOrWild, WitnessPat};
724use crate::{Captures, MatchArm, PatCx, PrivateUninhabitedField};
724725#[cfg(not(feature = "rustc"))]
725726pub fn ensure_sufficient_stack<R>(f: impl FnOnce() -> R) -> R {
726727 f()
compiler/rustc_pattern_analysis/tests/common/mod.rs+4-6
......@@ -1,10 +1,8 @@
1use rustc_pattern_analysis::{
2 constructor::{
3 Constructor, ConstructorSet, IntRange, MaybeInfiniteInt, RangeEnd, VariantVisibility,
4 },
5 usefulness::{PlaceValidity, UsefulnessReport},
6 Captures, MatchArm, PatCx, PrivateUninhabitedField,
1use rustc_pattern_analysis::constructor::{
2 Constructor, ConstructorSet, IntRange, MaybeInfiniteInt, RangeEnd, VariantVisibility,
73};
4use rustc_pattern_analysis::usefulness::{PlaceValidity, UsefulnessReport};
5use rustc_pattern_analysis::{Captures, MatchArm, PatCx, PrivateUninhabitedField};
86
97/// Sets up `tracing` for easier debugging. Tries to look like the `rustc` setup.
108pub fn init_tracing() {
compiler/rustc_pattern_analysis/tests/complexity.rs+3-1
......@@ -1,7 +1,9 @@
11//! Test the pattern complexity limit.
22
33use common::*;
4use rustc_pattern_analysis::{pat::DeconstructedPat, usefulness::PlaceValidity, MatchArm};
4use rustc_pattern_analysis::pat::DeconstructedPat;
5use rustc_pattern_analysis::usefulness::PlaceValidity;
6use rustc_pattern_analysis::MatchArm;
57
68#[macro_use]
79mod common;
compiler/rustc_pattern_analysis/tests/exhaustiveness.rs+3-5
......@@ -1,11 +1,9 @@
11//! Test exhaustiveness checking.
22
33use common::*;
4use rustc_pattern_analysis::{
5 pat::{DeconstructedPat, WitnessPat},
6 usefulness::PlaceValidity,
7 MatchArm,
8};
4use rustc_pattern_analysis::pat::{DeconstructedPat, WitnessPat};
5use rustc_pattern_analysis::usefulness::PlaceValidity;
6use rustc_pattern_analysis::MatchArm;
97
108#[macro_use]
119mod common;
compiler/rustc_pattern_analysis/tests/intersection.rs+3-1
......@@ -1,7 +1,9 @@
11//! Test the computation of arm intersections.
22
33use common::*;
4use rustc_pattern_analysis::{pat::DeconstructedPat, usefulness::PlaceValidity, MatchArm};
4use rustc_pattern_analysis::pat::DeconstructedPat;
5use rustc_pattern_analysis::usefulness::PlaceValidity;
6use rustc_pattern_analysis::MatchArm;
57
68#[macro_use]
79mod common;
compiler/rustc_privacy/src/errors.rs+2-1
......@@ -1,4 +1,5 @@
1use rustc_errors::{codes::*, DiagArgFromDisplay};
1use rustc_errors::codes::*;
2use rustc_errors::DiagArgFromDisplay;
23use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
34use rustc_span::{Span, Symbol};
45
compiler/rustc_privacy/src/lib.rs+14-15
......@@ -10,12 +10,19 @@
1010
1111mod errors;
1212
13use std::fmt;
14use std::marker::PhantomData;
15use std::ops::ControlFlow;
16
17use errors::{
18 FieldIsPrivate, FieldIsPrivateLabel, FromPrivateDependencyInPublicInterface, InPublicInterface,
19 ItemIsPrivate, PrivateInterfacesOrBoundsLint, ReportEffectiveVisibility, UnnameableTypesLint,
20 UnnamedItemIsPrivate,
21};
1322use rustc_ast::visit::{try_visit, VisitorResult};
1423use rustc_ast::MacroDef;
15use rustc_attr as attr;
1624use rustc_data_structures::fx::FxHashSet;
1725use rustc_data_structures::intern::Interned;
18use rustc_hir as hir;
1926use rustc_hir::def::{DefKind, Res};
2027use rustc_hir::def_id::{DefId, LocalDefId, LocalModDefId, CRATE_DEF_ID};
2128use rustc_hir::intravisit::{self, Visitor};
......@@ -23,25 +30,17 @@ use rustc_hir::{AssocItemKind, ForeignItemKind, ItemId, ItemKind, PatKind};
2330use rustc_middle::middle::privacy::{EffectiveVisibilities, EffectiveVisibility, Level};
2431use rustc_middle::query::Providers;
2532use rustc_middle::ty::print::PrintTraitRefExt as _;
26use rustc_middle::ty::GenericArgs;
27use rustc_middle::ty::{self, Const, GenericParamDefKind};
28use rustc_middle::ty::{TraitRef, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitor};
33use rustc_middle::ty::{
34 self, Const, GenericArgs, GenericParamDefKind, TraitRef, Ty, TyCtxt, TypeSuperVisitable,
35 TypeVisitable, TypeVisitor,
36};
2937use rustc_middle::{bug, span_bug};
3038use rustc_session::lint;
3139use rustc_span::hygiene::Transparency;
3240use rustc_span::symbol::{kw, sym, Ident};
3341use rustc_span::Span;
3442use tracing::debug;
35
36use std::fmt;
37use std::marker::PhantomData;
38use std::ops::ControlFlow;
39
40use errors::{
41 FieldIsPrivate, FieldIsPrivateLabel, FromPrivateDependencyInPublicInterface, InPublicInterface,
42 ItemIsPrivate, PrivateInterfacesOrBoundsLint, ReportEffectiveVisibility, UnnameableTypesLint,
43 UnnamedItemIsPrivate,
44};
43use {rustc_attr as attr, rustc_hir as hir};
4544
4645rustc_fluent_macro::fluent_messages! { "../messages.ftl" }
4746
compiler/rustc_query_impl/src/lib.rs+7-8
......@@ -10,20 +10,17 @@
1010#![feature(rustdoc_internals)]
1111// tidy-alphabetical-end
1212
13use crate::plumbing::{__rust_begin_short_backtrace, encode_all_query_results, try_mark_green};
14use crate::profiling_support::QueryKeyStringCache;
1513use field_offset::offset_of;
1614use rustc_data_structures::stable_hasher::HashStable;
1715use rustc_data_structures::sync::AtomicU64;
1816use rustc_middle::arena::Arena;
19use rustc_middle::dep_graph::DepNodeIndex;
20use rustc_middle::dep_graph::{self, DepKind, DepKindStruct};
17use rustc_middle::dep_graph::{self, DepKind, DepKindStruct, DepNodeIndex};
2118use rustc_middle::query::erase::{erase, restore, Erase};
2219use rustc_middle::query::on_disk_cache::{CacheEncoder, EncodedDepNodeIndex, OnDiskCache};
2320use rustc_middle::query::plumbing::{DynamicQuery, QuerySystem, QuerySystemFns};
24use rustc_middle::query::AsLocalKey;
2521use rustc_middle::query::{
26 queries, DynamicQueries, ExternProviders, Providers, QueryCaches, QueryEngine, QueryStates,
22 queries, AsLocalKey, DynamicQueries, ExternProviders, Providers, QueryCaches, QueryEngine,
23 QueryStates,
2724};
2825use rustc_middle::ty::TyCtxt;
2926use rustc_query_system::dep_graph::SerializedDepNodeIndex;
......@@ -32,10 +29,12 @@ use rustc_query_system::query::{
3229 get_query_incr, get_query_non_incr, CycleError, HashResult, QueryCache, QueryConfig, QueryMap,
3330 QueryMode, QueryState,
3431};
35use rustc_query_system::HandleCycleError;
36use rustc_query_system::Value;
32use rustc_query_system::{HandleCycleError, Value};
3733use rustc_span::{ErrorGuaranteed, Span};
3834
35use crate::plumbing::{__rust_begin_short_backtrace, encode_all_query_results, try_mark_green};
36use crate::profiling_support::QueryKeyStringCache;
37
3938#[macro_use]
4039mod plumbing;
4140pub use crate::plumbing::{query_key_hash_verify_all, QueryCtxt};
compiler/rustc_query_impl/src/plumbing.rs+10-8
......@@ -2,19 +2,21 @@
22//! generate the actual methods on tcx which find and execute the provider,
33//! manage the caches, and so forth.
44
5use crate::QueryConfigRestored;
5use std::num::NonZero;
6
67use rustc_data_structures::stable_hasher::{Hash64, HashStable, StableHasher};
78use rustc_data_structures::sync::Lock;
89use rustc_data_structures::unord::UnordMap;
910use rustc_errors::DiagInner;
1011use rustc_index::Idx;
1112use rustc_middle::bug;
12use rustc_middle::dep_graph::dep_kinds;
1313use rustc_middle::dep_graph::{
14 self, DepContext, DepKind, DepKindStruct, DepNode, DepNodeIndex, SerializedDepNodeIndex,
14 self, dep_kinds, DepContext, DepKind, DepKindStruct, DepNode, DepNodeIndex,
15 SerializedDepNodeIndex,
16};
17use rustc_middle::query::on_disk_cache::{
18 AbsoluteBytePos, CacheDecoder, CacheEncoder, EncodedDepNodeIndex,
1519};
16use rustc_middle::query::on_disk_cache::AbsoluteBytePos;
17use rustc_middle::query::on_disk_cache::{CacheDecoder, CacheEncoder, EncodedDepNodeIndex};
1820use rustc_middle::query::Key;
1921use rustc_middle::ty::print::with_reduced_queries;
2022use rustc_middle::ty::tls::{self, ImplicitCtxt};
......@@ -26,13 +28,13 @@ use rustc_query_system::query::{
2628 QueryStackFrame,
2729};
2830use rustc_query_system::{LayoutOfDepth, QueryOverflow};
29use rustc_serialize::Decodable;
30use rustc_serialize::Encodable;
31use rustc_serialize::{Decodable, Encodable};
3132use rustc_session::Limit;
3233use rustc_span::def_id::LOCAL_CRATE;
33use std::num::NonZero;
3434use thin_vec::ThinVec;
3535
36use crate::QueryConfigRestored;
37
3638#[derive(Copy, Clone)]
3739pub struct QueryCtxt<'tcx> {
3840 pub tcx: TyCtxt<'tcx>,
compiler/rustc_query_impl/src/profiling_support.rs+3-2
......@@ -1,3 +1,6 @@
1use std::fmt::Debug;
2use std::io::Write;
3
14use measureme::{StringComponent, StringId};
25use rustc_data_structures::fx::FxHashMap;
36use rustc_data_structures::profiling::SelfProfiler;
......@@ -5,8 +8,6 @@ use rustc_hir::def_id::{CrateNum, DefId, DefIndex, LocalDefId, LOCAL_CRATE};
58use rustc_hir::definitions::DefPathData;
69use rustc_middle::ty::TyCtxt;
710use rustc_query_system::query::QueryCache;
8use std::fmt::Debug;
9use std::io::Write;
1011
1112pub(crate) struct QueryKeyStringCache {
1213 def_id_cache: FxHashMap<DefId, StringId>,
compiler/rustc_query_system/src/cache.rs+2-2
......@@ -1,11 +1,11 @@
11//! Cache for candidate selection.
22
3use crate::dep_graph::{DepContext, DepNodeIndex};
3use std::hash::Hash;
44
55use rustc_data_structures::fx::FxHashMap;
66use rustc_data_structures::sync::Lock;
77
8use std::hash::Hash;
8use crate::dep_graph::{DepContext, DepNodeIndex};
99
1010pub struct Cache<Key, Value> {
1111 hashmap: Lock<FxHashMap<Key, WithDepNode<Value>>>,
compiler/rustc_query_system/src/dep_graph/debug.rs+4-2
......@@ -1,9 +1,11 @@
11//! Code for debugging the dep-graph.
22
3use super::{DepNode, DepNodeIndex};
3use std::error::Error;
4
45use rustc_data_structures::fx::FxHashMap;
56use rustc_data_structures::sync::Lock;
6use std::error::Error;
7
8use super::{DepNode, DepNodeIndex};
79
810/// A dep-node filter goes from a user-defined string to a query over
911/// nodes. Right now the format is like this:
compiler/rustc_query_system/src/dep_graph/dep_node.rs+7-5
......@@ -42,16 +42,17 @@
4242//! `DefId` it was computed from. In other cases, too much information gets
4343//! lost during fingerprint computation.
4444
45use super::{DepContext, FingerprintStyle};
46use crate::ich::StableHashingContext;
45use std::fmt;
46use std::hash::Hash;
4747
4848use rustc_data_structures::fingerprint::{Fingerprint, PackedFingerprint};
4949use rustc_data_structures::stable_hasher::{HashStable, StableHasher, StableOrd, ToStableHashKey};
5050use rustc_data_structures::AtomicRef;
5151use rustc_hir::definitions::DefPathHash;
5252use rustc_macros::{Decodable, Encodable};
53use std::fmt;
54use std::hash::Hash;
53
54use super::{DepContext, FingerprintStyle};
55use crate::ich::StableHashingContext;
5556
5657/// This serves as an index into arrays built by `make_dep_kind_array`.
5758#[derive(Clone, Copy, PartialEq, Eq, Hash)]
......@@ -312,8 +313,9 @@ impl StableOrd for WorkProductId {
312313// Some types are used a lot. Make sure they don't unintentionally get bigger.
313314#[cfg(target_pointer_width = "64")]
314315mod size_asserts {
315 use super::*;
316316 use rustc_data_structures::static_assert_size;
317
318 use super::*;
317319 // tidy-alphabetical-start
318320 static_assert_size!(DepKind, 2);
319321 #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
compiler/rustc_query_system/src/dep_graph/edges.rs+4-2
......@@ -1,8 +1,10 @@
1use crate::dep_graph::DepNodeIndex;
2use smallvec::SmallVec;
31use std::hash::{Hash, Hasher};
42use std::ops::Deref;
53
4use smallvec::SmallVec;
5
6use crate::dep_graph::DepNodeIndex;
7
68#[derive(Default, Debug)]
79pub(crate) struct EdgesVec {
810 max: u32,
compiler/rustc_query_system/src/dep_graph/graph.rs+10-10
......@@ -1,3 +1,11 @@
1use std::assert_matches::assert_matches;
2use std::collections::hash_map::Entry;
3use std::fmt::Debug;
4use std::hash::Hash;
5use std::marker::PhantomData;
6use std::sync::atomic::Ordering;
7use std::sync::Arc;
8
19use rustc_data_structures::fingerprint::Fingerprint;
210use rustc_data_structures::fx::{FxHashMap, FxHashSet};
311use rustc_data_structures::profiling::{QueryInvocationId, SelfProfilerRef};
......@@ -8,14 +16,9 @@ use rustc_data_structures::unord::UnordMap;
816use rustc_index::IndexVec;
917use rustc_macros::{Decodable, Encodable};
1018use rustc_serialize::opaque::{FileEncodeResult, FileEncoder};
11use std::assert_matches::assert_matches;
12use std::collections::hash_map::Entry;
13use std::fmt::Debug;
14use std::hash::Hash;
15use std::marker::PhantomData;
16use std::sync::atomic::Ordering;
17use std::sync::Arc;
1819use tracing::{debug, instrument};
20#[cfg(debug_assertions)]
21use {super::debug::EdgeFilter, std::env};
1922
2023use super::query::DepGraphQuery;
2124use super::serialized::{GraphEncoder, SerializedDepGraph, SerializedDepNodeIndex};
......@@ -24,9 +27,6 @@ use crate::dep_graph::edges::EdgesVec;
2427use crate::ich::StableHashingContext;
2528use crate::query::{QueryContext, QuerySideEffects};
2629
27#[cfg(debug_assertions)]
28use {super::debug::EdgeFilter, std::env};
29
3030#[derive(Clone)]
3131pub struct DepGraph<D: Deps> {
3232 data: Option<Lrc<DepGraphData<D>>>,
compiler/rustc_query_system/src/dep_graph/mod.rs+5-4
......@@ -5,18 +5,19 @@ mod graph;
55mod query;
66mod serialized;
77
8use std::panic;
9
810pub use dep_node::{DepKind, DepKindStruct, DepNode, DepNodeParams, WorkProductId};
911pub(crate) use graph::DepGraphData;
1012pub use graph::{hash_result, DepGraph, DepNodeIndex, TaskDepsRef, WorkProduct, WorkProductMap};
1113pub use query::DepGraphQuery;
14use rustc_data_structures::profiling::SelfProfilerRef;
15use rustc_session::Session;
1216pub use serialized::{SerializedDepGraph, SerializedDepNodeIndex};
17use tracing::instrument;
1318
1419use self::graph::{print_markframe_trace, MarkFrame};
1520use crate::ich::StableHashingContext;
16use rustc_data_structures::profiling::SelfProfilerRef;
17use rustc_session::Session;
18use std::panic;
19use tracing::instrument;
2021
2122pub trait DepContext: Copy {
2223 type Deps: Deps;
compiler/rustc_query_system/src/dep_graph/serialized.rs+9-8
......@@ -35,11 +35,11 @@
3535//! If the number of edges in this node does not fit in the bits available in the header, we
3636//! store it directly after the header with leb128.
3737
38use super::query::DepGraphQuery;
39use super::{DepKind, DepNode, DepNodeIndex, Deps};
40use crate::dep_graph::edges::EdgesVec;
41use rustc_data_structures::fingerprint::Fingerprint;
42use rustc_data_structures::fingerprint::PackedFingerprint;
38use std::iter;
39use std::marker::PhantomData;
40use std::sync::Arc;
41
42use rustc_data_structures::fingerprint::{Fingerprint, PackedFingerprint};
4343use rustc_data_structures::fx::FxHashMap;
4444use rustc_data_structures::outline;
4545use rustc_data_structures::profiling::SelfProfilerRef;
......@@ -48,11 +48,12 @@ use rustc_data_structures::unhash::UnhashMap;
4848use rustc_index::{Idx, IndexVec};
4949use rustc_serialize::opaque::{FileEncodeResult, FileEncoder, IntEncodedWithFixedSize, MemDecoder};
5050use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
51use std::iter;
52use std::marker::PhantomData;
53use std::sync::Arc;
5451use tracing::{debug, instrument};
5552
53use super::query::DepGraphQuery;
54use super::{DepKind, DepNode, DepNodeIndex, Deps};
55use crate::dep_graph::edges::EdgesVec;
56
5657// The maximum value of `SerializedDepNodeIndex` leaves the upper two bits
5758// unused so that we can store multiple index types in `CompressedHybridIndex`,
5859// 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 @@
1use crate::ich;
2
31use rustc_ast as ast;
42use rustc_data_structures::stable_hasher::{HashStable, HashingControls, StableHasher};
53use rustc_data_structures::sync::Lrc;
......@@ -11,6 +9,8 @@ use rustc_span::source_map::SourceMap;
119use rustc_span::symbol::Symbol;
1210use rustc_span::{BytePos, CachingSourceMapView, SourceFile, Span, SpanData, DUMMY_SP};
1311
12use crate::ich;
13
1414/// This is the context state available during incr. comp. hashing. It contains
1515/// enough information to transform `DefId`s and `HirId`s into stable `DefPath`s (i.e.,
1616/// 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 @@
11//! This module contains `HashStable` implementations for various data types
22//! from `rustc_ast` in no particular order.
33
4use crate::ich::StableHashingContext;
4use std::assert_matches::assert_matches;
55
66use rustc_ast as ast;
77use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
88use rustc_span::SourceFile;
9use std::assert_matches::assert_matches;
10
119use smallvec::SmallVec;
1210
11use crate::ich::StableHashingContext;
12
1313impl<'ctx> rustc_target::HashStableContext for StableHashingContext<'ctx> {}
1414
1515impl<'a> HashStable<StableHashingContext<'a>> for [ast::Attribute] {
compiler/rustc_query_system/src/ich/mod.rs+2-1
......@@ -1,8 +1,9 @@
11//! ICH - Incremental Compilation Hash
22
3pub use self::hcx::StableHashingContext;
43use rustc_span::symbol::{sym, Symbol};
54
5pub use self::hcx::StableHashingContext;
6
67mod hcx;
78mod impls_syntax;
89
compiler/rustc_query_system/src/lib.rs+1-3
......@@ -14,9 +14,7 @@ pub mod ich;
1414pub mod query;
1515mod values;
1616
17pub use error::HandleCycleError;
18pub use error::LayoutOfDepth;
19pub use error::QueryOverflow;
17pub use error::{HandleCycleError, LayoutOfDepth, QueryOverflow};
2018pub use values::Value;
2119
2220rustc_fluent_macro::fluent_messages! { "../messages.ftl" }
compiler/rustc_query_system/src/query/caches.rs+5-5
......@@ -1,14 +1,14 @@
1use crate::dep_graph::DepNodeIndex;
1use std::fmt::Debug;
2use std::hash::Hash;
23
34use rustc_data_structures::fx::FxHashMap;
45use rustc_data_structures::sharded::{self, Sharded};
56use rustc_data_structures::sync::{Lock, OnceLock};
67use rustc_hir::def_id::LOCAL_CRATE;
78use rustc_index::{Idx, IndexVec};
8use rustc_span::def_id::DefId;
9use rustc_span::def_id::DefIndex;
10use std::fmt::Debug;
11use std::hash::Hash;
9use rustc_span::def_id::{DefId, DefIndex};
10
11use crate::dep_graph::DepNodeIndex;
1212
1313pub trait QueryCache: Sized {
1414 type Key: Hash + Eq + Copy + Debug;
compiler/rustc_query_system/src/query/config.rs+7-7
......@@ -1,16 +1,16 @@
11//! Query configuration and description traits.
22
3use std::fmt::Debug;
4use std::hash::Hash;
5
6use rustc_data_structures::fingerprint::Fingerprint;
7use rustc_span::ErrorGuaranteed;
8
39use crate::dep_graph::{DepKind, DepNode, DepNodeParams, SerializedDepNodeIndex};
410use crate::error::HandleCycleError;
511use crate::ich::StableHashingContext;
612use crate::query::caches::QueryCache;
7use crate::query::DepNodeIndex;
8use crate::query::{CycleError, QueryContext, QueryState};
9
10use rustc_data_structures::fingerprint::Fingerprint;
11use rustc_span::ErrorGuaranteed;
12use std::fmt::Debug;
13use std::hash::Hash;
13use crate::query::{CycleError, DepNodeIndex, QueryContext, QueryState};
1414
1515pub type HashResult<V> = Option<fn(&mut StableHashingContext<'_>, &V) -> Fingerprint>;
1616
compiler/rustc_query_system/src/query/job.rs+9-10
......@@ -1,18 +1,12 @@
1use crate::dep_graph::DepContext;
2use crate::error::CycleStack;
3use crate::query::plumbing::CycleError;
4use crate::query::DepKind;
5use crate::query::{QueryContext, QueryStackFrame};
1use std::hash::Hash;
2use std::io::Write;
3use std::num::NonZero;
4
65use rustc_data_structures::fx::FxHashMap;
76use rustc_errors::{Diag, DiagCtxtHandle};
87use rustc_hir::def::DefKind;
98use rustc_session::Session;
109use rustc_span::Span;
11
12use std::hash::Hash;
13use std::io::Write;
14use std::num::NonZero;
15
1610#[cfg(parallel_compiler)]
1711use {
1812 parking_lot::{Condvar, Mutex},
......@@ -23,6 +17,11 @@ use {
2317 std::sync::Arc,
2418};
2519
20use crate::dep_graph::DepContext;
21use crate::error::CycleStack;
22use crate::query::plumbing::CycleError;
23use crate::query::{DepKind, QueryContext, QueryStackFrame};
24
2625/// Represents a span and a query key.
2726#[derive(Clone, Debug)]
2827pub struct QueryInfo {
compiler/rustc_query_system/src/query/mod.rs+3-4
......@@ -12,10 +12,6 @@ mod caches;
1212pub use self::caches::{DefIdCache, DefaultCache, QueryCache, SingleCache, VecCache};
1313
1414mod config;
15pub use self::config::{HashResult, QueryConfig};
16
17use crate::dep_graph::DepKind;
18use crate::dep_graph::{DepNodeIndex, HasDepContext, SerializedDepNodeIndex};
1915use rustc_data_structures::stable_hasher::Hash64;
2016use rustc_data_structures::sync::Lock;
2117use rustc_errors::DiagInner;
......@@ -25,6 +21,9 @@ use rustc_span::def_id::DefId;
2521use rustc_span::Span;
2622use thin_vec::ThinVec;
2723
24pub use self::config::{HashResult, QueryConfig};
25use crate::dep_graph::{DepKind, DepNodeIndex, HasDepContext, SerializedDepNodeIndex};
26
2827/// Description of a frame in the query stack.
2928///
3029/// 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 @@
22//! generate the actual methods on tcx which find and execute the provider,
33//! manage the caches, and so forth.
44
5use crate::dep_graph::DepGraphData;
6use crate::dep_graph::{DepContext, DepNode, DepNodeIndex, DepNodeParams};
7use crate::ich::StableHashingContext;
8use crate::query::caches::QueryCache;
9#[cfg(parallel_compiler)]
10use crate::query::job::QueryLatch;
11use crate::query::job::{report_cycle, QueryInfo, QueryJob, QueryJobId, QueryJobInfo};
12use crate::query::SerializedDepNodeIndex;
13use crate::query::{QueryContext, QueryMap, QuerySideEffects, QueryStackFrame};
14use crate::HandleCycleError;
5use std::cell::Cell;
6use std::collections::hash_map::Entry;
7use std::fmt::Debug;
8use std::hash::Hash;
9use std::mem;
10
1511use rustc_data_structures::fingerprint::Fingerprint;
1612use rustc_data_structures::fx::FxHashMap;
1713use rustc_data_structures::sharded::Sharded;
......@@ -21,15 +17,20 @@ use rustc_data_structures::sync::Lock;
2117use rustc_data_structures::{outline, sync};
2218use rustc_errors::{Diag, FatalError, StashKey};
2319use rustc_span::{Span, DUMMY_SP};
24use std::cell::Cell;
25use std::collections::hash_map::Entry;
26use std::fmt::Debug;
27use std::hash::Hash;
28use std::mem;
2920use thin_vec::ThinVec;
3021use tracing::instrument;
3122
3223use super::QueryConfig;
24use crate::dep_graph::{DepContext, DepGraphData, DepNode, DepNodeIndex, DepNodeParams};
25use crate::ich::StableHashingContext;
26use crate::query::caches::QueryCache;
27#[cfg(parallel_compiler)]
28use crate::query::job::QueryLatch;
29use crate::query::job::{report_cycle, QueryInfo, QueryJob, QueryJobId, QueryJobInfo};
30use crate::query::{
31 QueryContext, QueryMap, QuerySideEffects, QueryStackFrame, SerializedDepNodeIndex,
32};
33use crate::HandleCycleError;
3334
3435pub struct QueryState<K> {
3536 active: Sharded<FxHashMap<K, QueryResult>>,
compiler/rustc_resolve/src/build_reduced_graph.rs+15-13
......@@ -5,18 +5,13 @@
55//! unexpanded macros in the fragment are visited and registered.
66//! Imports are also considered items and placed into modules here, but not resolved yet.
77
8use crate::def_collector::collect_definitions;
9use crate::imports::{ImportData, ImportKind};
10use crate::macros::{MacroRulesBinding, MacroRulesScope, MacroRulesScopeRef};
11use crate::Namespace::{MacroNS, TypeNS, ValueNS};
12use crate::{errors, BindingKey, MacroData, NameBindingData};
13use crate::{Determinacy, ExternPreludeEntry, Finalize, Module, ModuleKind, ModuleOrUniformRoot};
14use crate::{NameBinding, NameBindingKind, ParentScope, PathResult, ResolutionError};
15use crate::{Resolver, ResolverArenas, Segment, ToNameBinding, Used, VisResolutionError};
8use std::cell::Cell;
169
1710use rustc_ast::visit::{self, AssocCtxt, Visitor, WalkItemKind};
18use rustc_ast::{self as ast, AssocItem, AssocItemKind, MetaItemKind, StmtKind};
19use rustc_ast::{Block, ForeignItem, ForeignItemKind, Impl, Item, ItemKind, NodeId};
11use rustc_ast::{
12 self as ast, AssocItem, AssocItemKind, Block, ForeignItem, ForeignItemKind, Impl, Item,
13 ItemKind, MetaItemKind, NodeId, StmtKind,
14};
2015use rustc_attr as attr;
2116use rustc_data_structures::sync::Lrc;
2217use rustc_expand::base::ResolverExpand;
......@@ -30,11 +25,18 @@ use rustc_middle::{bug, ty};
3025use rustc_span::hygiene::{ExpnId, LocalExpnId, MacroKind};
3126use rustc_span::symbol::{kw, sym, Ident, Symbol};
3227use rustc_span::Span;
33
34use std::cell::Cell;
35
3628use tracing::debug;
3729
30use crate::def_collector::collect_definitions;
31use crate::imports::{ImportData, ImportKind};
32use crate::macros::{MacroRulesBinding, MacroRulesScope, MacroRulesScopeRef};
33use crate::Namespace::{MacroNS, TypeNS, ValueNS};
34use 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
3840type Res = def::Res<NodeId>;
3941
4042impl<'a, Id: Into<DefId>> ToNameBinding<'a>
compiler/rustc_resolve/src/check_unused.rs+6-7
......@@ -23,23 +23,22 @@
2323// - `check_unused` finally emits the diagnostics based on the data generated
2424// in the last step
2525
26use crate::imports::{Import, ImportKind};
27use crate::module_to_string;
28use crate::Resolver;
29
30use crate::{LexicalScopeBinding, NameBindingKind};
3126use rustc_ast as ast;
3227use rustc_ast::visit::{self, Visitor};
3328use rustc_data_structures::fx::{FxHashMap, FxIndexMap, FxIndexSet};
3429use rustc_data_structures::unord::UnordSet;
3530use rustc_errors::MultiSpan;
3631use rustc_hir::def::{DefKind, Res};
37use rustc_session::lint::builtin::{MACRO_USE_EXTERN_CRATE, UNUSED_EXTERN_CRATES};
38use rustc_session::lint::builtin::{UNUSED_IMPORTS, UNUSED_QUALIFICATIONS};
32use rustc_session::lint::builtin::{
33 MACRO_USE_EXTERN_CRATE, UNUSED_EXTERN_CRATES, UNUSED_IMPORTS, UNUSED_QUALIFICATIONS,
34};
3935use rustc_session::lint::BuiltinLintDiag;
4036use rustc_span::symbol::{kw, Ident};
4137use rustc_span::{Span, DUMMY_SP};
4238
39use crate::imports::{Import, ImportKind};
40use crate::{module_to_string, LexicalScopeBinding, NameBindingKind, Resolver};
41
4342struct UnusedImport {
4443 use_tree: ast::UseTree,
4544 use_tree_id: ast::NodeId,
compiler/rustc_resolve/src/def_collector.rs+4-2
......@@ -1,4 +1,5 @@
1use crate::{ImplTraitContext, Resolver};
1use std::mem;
2
23use rustc_ast::visit::FnKind;
34use rustc_ast::*;
45use rustc_expand::expand::AstFragment;
......@@ -8,9 +9,10 @@ use rustc_hir::def_id::LocalDefId;
89use rustc_span::hygiene::LocalExpnId;
910use rustc_span::symbol::{kw, sym, Symbol};
1011use rustc_span::Span;
11use std::mem;
1212use tracing::debug;
1313
14use crate::{ImplTraitContext, Resolver};
15
1416pub(crate) fn collect_definitions(
1517 resolver: &mut Resolver<'_, '_>,
1618 fragment: &AstFragment,
compiler/rustc_resolve/src/diagnostics.rs+17-13
......@@ -1,12 +1,15 @@
11use rustc_ast::expand::StrippedCfgItem;
22use rustc_ast::ptr::P;
33use rustc_ast::visit::{self, Visitor};
4use rustc_ast::{self as ast, Crate, ItemKind, ModKind, NodeId, Path, CRATE_NODE_ID};
5use rustc_ast::{MetaItemKind, NestedMetaItem};
4use rustc_ast::{
5 self as ast, Crate, ItemKind, MetaItemKind, ModKind, NestedMetaItem, NodeId, Path,
6 CRATE_NODE_ID,
7};
68use rustc_ast_pretty::pprust;
79use rustc_data_structures::fx::FxHashSet;
10use rustc_errors::codes::*;
811use 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,
1013 ErrorGuaranteed, MultiSpan, SuggestionStyle,
1114};
1215use rustc_feature::BUILTIN_ATTRIBUTES;
......@@ -16,9 +19,10 @@ use rustc_hir::def_id::{DefId, CRATE_DEF_ID};
1619use rustc_hir::PrimTy;
1720use rustc_middle::bug;
1821use rustc_middle::ty::TyCtxt;
19use rustc_session::lint::builtin::ABSOLUTE_PATHS_NOT_STARTING_WITH_CRATE;
20use rustc_session::lint::builtin::AMBIGUOUS_GLOB_IMPORTS;
21use rustc_session::lint::builtin::MACRO_EXPANDED_MACRO_EXPORTS_ACCESSED_BY_ABSOLUTE_PATHS;
22use rustc_session::lint::builtin::{
23 ABSOLUTE_PATHS_NOT_STARTING_WITH_CRATE, AMBIGUOUS_GLOB_IMPORTS,
24 MACRO_EXPANDED_MACRO_EXPORTS_ACCESSED_BY_ABSOLUTE_PATHS,
25};
2226use rustc_session::lint::{AmbiguityErrorDiag, BuiltinLintDiag};
2327use rustc_session::Session;
2428use rustc_span::edit_distance::find_best_match_for_name;
......@@ -36,13 +40,13 @@ use crate::errors::{
3640};
3741use crate::imports::{Import, ImportKind};
3842use crate::late::{PatternSource, Rib};
39use crate::{errors as errs, BindingKey};
40use crate::{path_names_to_string, Used};
41use crate::{AmbiguityError, AmbiguityErrorMisc, AmbiguityKind, BindingError, Finalize};
42use crate::{HasGenericParams, MacroRulesScope, Module, ModuleKind, ModuleOrUniformRoot};
43use crate::{LexicalScopeBinding, NameBinding, NameBindingKind, PrivacyError, VisResolutionError};
44use crate::{ParentScope, PathResult, ResolutionError, Resolver, Scope, ScopeSet};
45use crate::{Segment, UseError};
43use 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};
4650
4751type Res = def::Res<ast::NodeId>;
4852
compiler/rustc_resolve/src/effective_visibilities.rs+7-10
......@@ -1,18 +1,15 @@
1use crate::{NameBinding, NameBindingKind, Resolver};
2use rustc_ast::ast;
3use rustc_ast::visit;
1use std::mem;
2
43use rustc_ast::visit::Visitor;
5use rustc_ast::Crate;
6use rustc_ast::EnumDef;
4use rustc_ast::{ast, visit, Crate, EnumDef};
75use rustc_data_structures::fx::FxHashSet;
8use rustc_hir::def_id::LocalDefId;
9use rustc_hir::def_id::CRATE_DEF_ID;
10use rustc_middle::middle::privacy::Level;
11use rustc_middle::middle::privacy::{EffectiveVisibilities, EffectiveVisibility};
6use rustc_hir::def_id::{LocalDefId, CRATE_DEF_ID};
7use rustc_middle::middle::privacy::{EffectiveVisibilities, EffectiveVisibility, Level};
128use rustc_middle::ty::Visibility;
13use std::mem;
149use tracing::info;
1510
11use crate::{NameBinding, NameBindingKind, Resolver};
12
1613#[derive(Clone, Copy)]
1714enum ParentId<'a> {
1815 Def(LocalDefId),
compiler/rustc_resolve/src/errors.rs+6-6
......@@ -1,11 +1,11 @@
1use rustc_errors::{codes::*, Applicability, ElidedLifetimeInPathSubdiag, MultiSpan};
1use rustc_errors::codes::*;
2use rustc_errors::{Applicability, ElidedLifetimeInPathSubdiag, MultiSpan};
23use rustc_macros::{Diagnostic, Subdiagnostic};
3use rustc_span::{
4 symbol::{Ident, Symbol},
5 Span,
6};
4use rustc_span::symbol::{Ident, Symbol};
5use rustc_span::Span;
76
8use crate::{late::PatternSource, Res};
7use crate::late::PatternSource;
8use crate::Res;
99
1010#[derive(Diagnostic)]
1111#[diag(resolve_generic_params_from_outer_item, code = E0401)]
compiler/rustc_resolve/src/ident.rs+10-12
......@@ -1,29 +1,27 @@
11use rustc_ast::{self as ast, NodeId};
22use rustc_errors::ErrorGuaranteed;
33use rustc_hir::def::{DefKind, Namespace, NonMacroAttrKind, PartialRes, PerNS};
4use rustc_middle::bug;
5use rustc_middle::ty;
4use rustc_middle::{bug, ty};
65use rustc_session::lint::builtin::PROC_MACRO_DERIVE_RESOLUTION_FALLBACK;
76use rustc_session::lint::BuiltinLintDiag;
87use rustc_session::parse::feature_err;
98use rustc_span::def_id::LocalDefId;
109use rustc_span::hygiene::{ExpnId, ExpnKind, LocalExpnId, MacroKind, SyntaxContext};
11use rustc_span::sym;
1210use rustc_span::symbol::{kw, Ident};
13use rustc_span::Span;
11use rustc_span::{sym, Span};
1412use tracing::{debug, instrument};
13use Determinacy::*;
14use Namespace::*;
1515
1616use crate::errors::{ParamKindInEnumDiscriminant, ParamKindInNonTrivialAnonConst};
1717use crate::late::{ConstantHasGenerics, NoConstantGenericsReason, PathSource, Rib, RibKind};
1818use crate::macros::{sub_namespace_match, MacroRulesScope};
19use crate::{errors, AmbiguityError, AmbiguityErrorMisc, AmbiguityKind, Determinacy, Finalize};
20use crate::{BindingKey, Used};
21use crate::{ImportKind, LexicalScopeBinding, Module, ModuleKind, ModuleOrUniformRoot};
22use crate::{NameBinding, NameBindingKind, ParentScope, PathResult, PrivacyError, Res};
23use crate::{ResolutionError, Resolver, Scope, ScopeSet, Segment, ToNameBinding, Weak};
24
25use Determinacy::*;
26use Namespace::*;
19use 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};
2725
2826type Visibility = ty::Visibility<LocalDefId>;
2927
compiler/rustc_resolve/src/imports.rs+20-20
......@@ -1,29 +1,17 @@
11//! A bunch of methods and structures more or less related to resolving imports.
22
3use crate::diagnostics::{import_candidates, DiagMode, Suggestion};
4use crate::errors::{
5 CannotBeReexportedCratePublic, CannotBeReexportedCratePublicNS, CannotBeReexportedPrivate,
6 CannotBeReexportedPrivateNS, CannotDetermineImportResolution, CannotGlobImportAllCrates,
7 ConsiderAddingMacroExport, ConsiderMarkingAsPub, IsNotDirectlyImportable,
8 ItemsInTraitsAreNotImportable,
9};
10use crate::Determinacy::{self, *};
11use crate::{module_to_string, names_to_string, ImportSuggestion};
12use crate::{AmbiguityError, Namespace::*};
13use crate::{AmbiguityKind, BindingKey, ResolutionError, Resolver, Segment};
14use crate::{Finalize, Module, ModuleOrUniformRoot, ParentScope, PerNS, ScopeSet};
15use crate::{NameBinding, NameBindingData, NameBindingKind, PathResult, Used};
3use std::cell::Cell;
4use std::mem;
165
176use rustc_ast::NodeId;
187use rustc_data_structures::fx::FxHashSet;
198use rustc_data_structures::intern::Interned;
20use rustc_errors::{codes::*, pluralize, struct_span_code_err, Applicability, MultiSpan};
9use rustc_errors::codes::*;
10use rustc_errors::{pluralize, struct_span_code_err, Applicability, MultiSpan};
2111use rustc_hir::def::{self, DefKind, PartialRes};
2212use rustc_hir::def_id::DefId;
23use rustc_middle::metadata::ModChild;
24use rustc_middle::metadata::Reexport;
25use rustc_middle::span_bug;
26use rustc_middle::ty;
13use rustc_middle::metadata::{ModChild, Reexport};
14use rustc_middle::{span_bug, ty};
2715use rustc_session::lint::builtin::{
2816 AMBIGUOUS_GLOB_REEXPORTS, HIDDEN_GLOB_REEXPORTS, PUB_USE_OF_PRIVATE_EXTERN_CRATE,
2917 UNUSED_IMPORTS,
......@@ -36,8 +24,20 @@ use rustc_span::Span;
3624use smallvec::SmallVec;
3725use tracing::debug;
3826
39use std::cell::Cell;
40use std::mem;
27use crate::diagnostics::{import_candidates, DiagMode, Suggestion};
28use crate::errors::{
29 CannotBeReexportedCratePublic, CannotBeReexportedCratePublicNS, CannotBeReexportedPrivate,
30 CannotBeReexportedPrivateNS, CannotDetermineImportResolution, CannotGlobImportAllCrates,
31 ConsiderAddingMacroExport, ConsiderMarkingAsPub, IsNotDirectlyImportable,
32 ItemsInTraitsAreNotImportable,
33};
34use crate::Determinacy::{self, *};
35use crate::Namespace::*;
36use 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};
4141
4242type Res = def::Res<NodeId>;
4343
compiler/rustc_resolve/src/late.rs+12-9
......@@ -6,16 +6,18 @@
66//! If you wonder why there's no `early.rs`, that's because it's split into three files -
77//! `build_reduced_graph.rs`, `macros.rs` and `imports.rs`.
88
9use crate::{errors, path_names_to_string, rustdoc, BindingError, Finalize, LexicalScopeBinding};
10use crate::{BindingKey, Used};
11use crate::{Module, ModuleOrUniformRoot, NameBinding, ParentScope, PathResult};
12use crate::{ResolutionError, Resolver, Segment, TyCtxt, UseError};
9use std::assert_matches::debug_assert_matches;
10use std::borrow::Cow;
11use std::collections::hash_map::Entry;
12use std::collections::BTreeSet;
13use std::mem::{replace, swap, take};
1314
1415use rustc_ast::ptr::P;
1516use rustc_ast::visit::{visit_opt, walk_list, AssocCtxt, BoundKind, FnCtxt, FnKind, Visitor};
1617use rustc_ast::*;
1718use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap};
18use rustc_errors::{codes::*, Applicability, DiagArgValue, IntoDiagArg, StashKey};
19use rustc_errors::codes::*;
20use rustc_errors::{Applicability, DiagArgValue, IntoDiagArg, StashKey};
1921use rustc_hir::def::Namespace::{self, *};
2022use rustc_hir::def::{self, CtorKind, DefKind, LifetimeRes, NonMacroAttrKind, PartialRes, PerNS};
2123use rustc_hir::def_id::{DefId, LocalDefId, CRATE_DEF_ID, LOCAL_CRATE};
......@@ -32,10 +34,11 @@ use rustc_span::{BytePos, Span, SyntaxContext};
3234use smallvec::{smallvec, SmallVec};
3335use tracing::{debug, instrument, trace};
3436
35use std::assert_matches::debug_assert_matches;
36use std::borrow::Cow;
37use std::collections::{hash_map::Entry, BTreeSet};
38use std::mem::{replace, swap, take};
37use 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};
3942
4043mod diagnostics;
4144
compiler/rustc_resolve/src/late/diagnostics.rs+19-20
......@@ -1,13 +1,8 @@
11// ignore-tidy-filelength
22
3use crate::diagnostics::{ImportSuggestion, LabelSuggestion, TypoSuggestion};
4use crate::late::{AliasPossibility, LateResolutionVisitor, RibKind};
5use crate::late::{LifetimeBinderKind, LifetimeRes, LifetimeRibKind, LifetimeUseSet};
6use crate::ty::fast_reject::SimplifiedType;
7use crate::{errors, path_names_to_string};
8use crate::{Module, ModuleKind, ModuleOrUniformRoot};
9use crate::{PathResult, PathSource, Segment};
10use rustc_hir::def::Namespace::{self, *};
3use std::borrow::Cow;
4use std::iter;
5use std::ops::Deref;
116
127use rustc_ast::ptr::P;
138use rustc_ast::visit::{walk_ty, FnCtxt, FnKind, LifetimeCtxt, Visitor};
......@@ -16,34 +11,38 @@ use rustc_ast::{
1611 MethodCall, NodeId, Path, Ty, TyKind, DUMMY_NODE_ID,
1712};
1813use rustc_ast_pretty::pprust::where_bound_predicate_to_string;
19use rustc_data_structures::fx::FxHashSet;
20use rustc_data_structures::fx::FxIndexSet;
14use rustc_data_structures::fx::{FxHashSet, FxIndexSet};
15use rustc_errors::codes::*;
2116use rustc_errors::{
22 codes::*, pluralize, struct_span_code_err, Applicability, Diag, ErrorGuaranteed, MultiSpan,
17 pluralize, struct_span_code_err, Applicability, Diag, ErrorGuaranteed, MultiSpan,
2318 SuggestionStyle,
2419};
2520use rustc_hir as hir;
21use rustc_hir::def::Namespace::{self, *};
2622use rustc_hir::def::{self, CtorKind, CtorOf, DefKind};
2723use rustc_hir::def_id::{DefId, CRATE_DEF_ID};
2824use rustc_hir::{MissingLifetimeKind, PrimTy};
29use rustc_session::lint;
30use rustc_session::Session;
25use rustc_middle::ty;
26use rustc_session::{lint, Session};
3127use rustc_span::edit_distance::find_best_match_for_name;
3228use rustc_span::edition::Edition;
3329use rustc_span::hygiene::MacroKind;
3430use rustc_span::symbol::{kw, sym, Ident, Symbol};
3531use rustc_span::{Span, DUMMY_SP};
36
37use rustc_middle::ty;
38
39use std::borrow::Cow;
40use std::iter;
41use std::ops::Deref;
42
4332use thin_vec::ThinVec;
4433use tracing::debug;
4534
4635use super::NoConstantGenericsReason;
36use crate::diagnostics::{ImportSuggestion, LabelSuggestion, TypoSuggestion};
37use crate::late::{
38 AliasPossibility, LateResolutionVisitor, LifetimeBinderKind, LifetimeRes, LifetimeRibKind,
39 LifetimeUseSet, RibKind,
40};
41use crate::ty::fast_reject::SimplifiedType;
42use crate::{
43 errors, path_names_to_string, Module, ModuleKind, ModuleOrUniformRoot, PathResult, PathSource,
44 Segment,
45};
4746
4847type Res = def::Res<ast::NodeId>;
4948
compiler/rustc_resolve/src/lib.rs+24-20
......@@ -23,11 +23,25 @@
2323#![feature(rustdoc_internals)]
2424// tidy-alphabetical-end
2525
26use std::cell::{Cell, RefCell};
27use std::collections::BTreeSet;
28use std::fmt;
29
30use diagnostics::{ImportSuggestion, LabelSuggestion, Suggestion};
31use effective_visibilities::EffectiveVisibilitiesVisitor;
32use errors::{
33 ParamKindInEnumDiscriminant, ParamKindInNonTrivialAnonConst, ParamKindInTyOfConstParam,
34};
35use imports::{Import, ImportData, ImportKind, NameResolution};
36use late::{HasGenericParams, PathSource, PatternSource, UnnecessaryQualification};
37use macros::{MacroRulesBinding, MacroRulesScope, MacroRulesScopeRef};
2638use rustc_arena::{DroplessArena, TypedArena};
2739use rustc_ast::expand::StrippedCfgItem;
2840use rustc_ast::node_id::NodeMap;
29use rustc_ast::{self as ast, attr, NodeId, CRATE_NODE_ID};
30use rustc_ast::{AngleBracketedArg, Crate, Expr, ExprKind, GenericArg, GenericArgs, LitKind, Path};
41use rustc_ast::{
42 self as ast, attr, AngleBracketedArg, Crate, Expr, ExprKind, GenericArg, GenericArgs, LitKind,
43 NodeId, Path, CRATE_NODE_ID,
44};
3145use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap, FxIndexSet};
3246use rustc_data_structures::intern::Interned;
3347use rustc_data_structures::steal::Steal;
......@@ -36,10 +50,10 @@ use rustc_errors::{Applicability, Diag, ErrCode, ErrorGuaranteed};
3650use rustc_expand::base::{DeriveResolution, SyntaxExtension, SyntaxExtensionKind};
3751use rustc_feature::BUILTIN_ATTRIBUTES;
3852use rustc_hir::def::Namespace::{self, *};
39use rustc_hir::def::NonMacroAttrKind;
40use rustc_hir::def::{self, CtorOf, DefKind, DocLinkResMap, LifetimeRes, PartialRes, PerNS};
41use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, LocalDefIdMap};
42use rustc_hir::def_id::{CRATE_DEF_ID, LOCAL_CRATE};
53use rustc_hir::def::{
54 self, CtorOf, DefKind, DocLinkResMap, LifetimeRes, NonMacroAttrKind, PartialRes, PerNS,
55};
56use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, LocalDefIdMap, CRATE_DEF_ID, LOCAL_CRATE};
4357use rustc_hir::{PrimTy, TraitCandidate};
4458use rustc_index::IndexVec;
4559use rustc_metadata::creader::{CStore, CrateLoader};
......@@ -47,8 +61,10 @@ use rustc_middle::metadata::ModChild;
4761use rustc_middle::middle::privacy::EffectiveVisibilities;
4862use rustc_middle::query::Providers;
4963use rustc_middle::span_bug;
50use rustc_middle::ty::{self, DelegationFnSig, Feed, MainDefinition, RegisteredTools};
51use rustc_middle::ty::{ResolverGlobalCtxt, ResolverOutputs, TyCtxt, TyCtxtFeed};
64use rustc_middle::ty::{
65 self, DelegationFnSig, Feed, MainDefinition, RegisteredTools, ResolverGlobalCtxt,
66 ResolverOutputs, TyCtxt, TyCtxtFeed,
67};
5268use rustc_query_system::ich::StableHashingContext;
5369use rustc_session::lint::builtin::PRIVATE_MACRO_USE;
5470use rustc_session::lint::{BuiltinLintDiag, LintBuffer};
......@@ -56,20 +72,8 @@ use rustc_span::hygiene::{ExpnId, LocalExpnId, MacroKind, SyntaxContext, Transpa
5672use rustc_span::symbol::{kw, sym, Ident, Symbol};
5773use rustc_span::{Span, DUMMY_SP};
5874use smallvec::{smallvec, SmallVec};
59use std::cell::{Cell, RefCell};
60use std::collections::BTreeSet;
61use std::fmt;
6275use tracing::debug;
6376
64use diagnostics::{ImportSuggestion, LabelSuggestion, Suggestion};
65use effective_visibilities::EffectiveVisibilitiesVisitor;
66use errors::{
67 ParamKindInEnumDiscriminant, ParamKindInNonTrivialAnonConst, ParamKindInTyOfConstParam,
68};
69use imports::{Import, ImportData, ImportKind, NameResolution};
70use late::{HasGenericParams, PathSource, PatternSource, UnnecessaryQualification};
71use macros::{MacroRulesBinding, MacroRulesScope, MacroRulesScopeRef};
72
7377type Res = def::Res<NodeId>;
7478
7579mod build_reduced_graph;
compiler/rustc_resolve/src/macros.rs+20-15
......@@ -1,13 +1,9 @@
11//! A bunch of methods and structures more or less related to resolving macros and
22//! interface provided by `Resolver` to macro expander.
33
4use crate::errors::CannotDetermineMacroResolution;
5use crate::errors::{self, AddAsNonDerive, CannotFindIdentInThisScope};
6use crate::errors::{MacroExpectedFound, RemoveSurroundingDerive};
7use crate::Namespace::*;
8use crate::{BindingKey, BuiltinMacroState, Determinacy, MacroData, NameBindingKind, Used};
9use crate::{DeriveData, Finalize, ParentScope, ResolutionError, Resolver, ScopeSet};
10use crate::{ModuleKind, ModuleOrUniformRoot, NameBinding, PathResult, Segment, ToNameBinding};
4use std::cell::Cell;
5use std::mem;
6
117use rustc_ast::expand::StrippedCfgItem;
128use rustc_ast::{self as ast, attr, Crate, Inline, ItemKind, ModKind, NodeId};
139use rustc_ast_pretty::pprust;
......@@ -15,8 +11,10 @@ use rustc_attr::StabilityLevel;
1511use rustc_data_structures::intern::Interned;
1612use rustc_data_structures::sync::Lrc;
1713use rustc_errors::{Applicability, StashKey};
18use rustc_expand::base::{Annotatable, DeriveResolution, Indeterminate, ResolverExpand};
19use rustc_expand::base::{SyntaxExtension, SyntaxExtensionKind};
14use rustc_expand::base::{
15 Annotatable, DeriveResolution, Indeterminate, ResolverExpand, SyntaxExtension,
16 SyntaxExtensionKind,
17};
2018use rustc_expand::compile_declarative_macro;
2119use rustc_expand::expand::{
2220 AstFragment, AstFragmentKind, Invocation, InvocationKind, SupportsMacroExpansion,
......@@ -24,8 +22,7 @@ use rustc_expand::expand::{
2422use rustc_hir::def::{self, DefKind, Namespace, NonMacroAttrKind};
2523use rustc_hir::def_id::{CrateNum, DefId, LocalDefId};
2624use rustc_middle::middle::stability;
27use rustc_middle::ty::RegisteredTools;
28use rustc_middle::ty::{TyCtxt, Visibility};
25use rustc_middle::ty::{RegisteredTools, TyCtxt, Visibility};
2926use rustc_session::lint::builtin::{
3027 LEGACY_DERIVE_HELPERS, OUT_OF_SCOPE_MACRO_CALLS, SOFT_UNSTABLE,
3128 UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES, UNUSED_MACROS, UNUSED_MACRO_RULES,
......@@ -34,12 +31,20 @@ use rustc_session::lint::BuiltinLintDiag;
3431use rustc_session::parse::feature_err;
3532use rustc_span::edit_distance::edit_distance;
3633use rustc_span::edition::Edition;
37use rustc_span::hygiene::{self, ExpnData, ExpnKind, LocalExpnId};
38use rustc_span::hygiene::{AstPass, MacroKind};
34use rustc_span::hygiene::{self, AstPass, ExpnData, ExpnKind, LocalExpnId, MacroKind};
3935use rustc_span::symbol::{kw, sym, Ident, Symbol};
4036use rustc_span::{Span, DUMMY_SP};
41use std::cell::Cell;
42use std::mem;
37
38use crate::errors::{
39 self, AddAsNonDerive, CannotDetermineMacroResolution, CannotFindIdentInThisScope,
40 MacroExpectedFound, RemoveSurroundingDerive,
41};
42use crate::Namespace::*;
43use crate::{
44 BindingKey, BuiltinMacroState, DeriveData, Determinacy, Finalize, MacroData, ModuleKind,
45 ModuleOrUniformRoot, NameBinding, NameBindingKind, ParentScope, PathResult, ResolutionError,
46 Resolver, ScopeSet, Segment, ToNameBinding, Used,
47};
4348
4449type Res = def::Res<NodeId>;
4550
compiler/rustc_resolve/src/rustdoc.rs+3-2
......@@ -1,3 +1,6 @@
1use std::mem;
2use std::ops::Range;
3
14use pulldown_cmark::{
25 BrokenLink, BrokenLinkCallback, CowStr, Event, LinkType, Options, Parser, Tag,
36};
......@@ -8,8 +11,6 @@ use rustc_middle::ty::TyCtxt;
811use rustc_span::def_id::DefId;
912use rustc_span::symbol::{kw, sym, Symbol};
1013use rustc_span::{InnerSpan, Span, DUMMY_SP};
11use std::mem;
12use std::ops::Range;
1314use tracing::{debug, trace};
1415
1516#[derive(Clone, Copy, PartialEq, Eq, Debug)]
compiler/rustc_sanitizers/src/cfi/typeid/itanium_cxx_abi/encode.rs+3-4
......@@ -5,9 +5,9 @@
55//! For more information about LLVM CFI and cross-language LLVM CFI support for the Rust compiler,
66//! see design document in the tracking issue #89653.
77
8use rustc_data_structures::base_n::ToBaseN;
9use rustc_data_structures::base_n::ALPHANUMERIC_ONLY;
10use rustc_data_structures::base_n::CASE_INSENSITIVE;
8use std::fmt::Write as _;
9
10use rustc_data_structures::base_n::{ToBaseN, ALPHANUMERIC_ONLY, CASE_INSENSITIVE};
1111use rustc_data_structures::fx::FxHashMap;
1212use rustc_hir as hir;
1313use rustc_middle::bug;
......@@ -20,7 +20,6 @@ use rustc_span::def_id::DefId;
2020use rustc_span::sym;
2121use rustc_target::abi::Integer;
2222use rustc_target::spec::abi::Abi;
23use std::fmt::Write as _;
2423use tracing::instrument;
2524
2625use 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 @@
44//! For more information about LLVM CFI and cross-language LLVM CFI support for the Rust compiler,
55//! see design document in the tracking issue #89653.
66
7use std::iter;
8
79use rustc_hir as hir;
810use rustc_hir::LangItem;
911use rustc_middle::bug;
......@@ -12,9 +14,9 @@ use rustc_middle::ty::{
1214 self, ExistentialPredicateStableCmpExt as _, Instance, InstanceKind, IntTy, List, TraitRef, Ty,
1315 TyCtxt, TypeFoldable, TypeVisitableExt, UintTy,
1416};
15use rustc_span::{def_id::DefId, sym};
17use rustc_span::def_id::DefId;
18use rustc_span::sym;
1619use rustc_trait_selection::traits;
17use std::iter;
1820use tracing::{debug, instrument};
1921
2022use crate::cfi::typeid::itanium_cxx_abi::encode::EncodeTyOptions;
compiler/rustc_sanitizers/src/kcfi/typeid/mod.rs+2-1
......@@ -4,9 +4,10 @@
44//! For more information about LLVM KCFI and cross-language LLVM KCFI support for the Rust compiler,
55//! see the tracking issue #123479.
66
7use std::hash::Hasher;
8
79use rustc_middle::ty::{Instance, InstanceKind, ReifyReason, Ty, TyCtxt};
810use rustc_target::abi::call::FnAbi;
9use std::hash::Hasher;
1011use twox_hash::XxHash64;
1112
1213pub use crate::cfi::typeid::{itanium_cxx_abi, TypeIdOptions};
compiler/rustc_serialize/src/leb128.rs+2-3
......@@ -1,9 +1,8 @@
1use crate::opaque::MemDecoder;
2use crate::serialize::Decoder;
3
41// This code is very hot and uses lots of arithmetic, avoid overflow checks for performance.
52// See https://github.com/rust-lang/rust/pull/119440#issuecomment-1874255727
63use crate::int_overflow::DebugStrictAdd;
4use crate::opaque::MemDecoder;
5use crate::serialize::Decoder;
76
87/// Returns the length of the longest LEB128 encoding for `T`, assuming `T` is an integer type
98pub const fn max_leb128_len<T>() -> usize {
compiler/rustc_serialize/src/opaque.rs+3-4
......@@ -1,15 +1,14 @@
1use crate::leb128;
2use crate::serialize::{Decodable, Decoder, Encodable, Encoder};
31use std::fs::File;
42use std::io::{self, Write};
53use std::marker::PhantomData;
64use std::ops::Range;
7use std::path::Path;
8use std::path::PathBuf;
5use std::path::{Path, PathBuf};
96
107// This code is very hot and uses lots of arithmetic, avoid overflow checks for performance.
118// See https://github.com/rust-lang/rust/pull/119440#issuecomment-1874255727
129use crate::int_overflow::DebugStrictAdd;
10use crate::leb128;
11use crate::serialize::{Decodable, Decoder, Encodable, Encoder};
1312
1413// -----------------------------------------------------------------------------
1514// Encoder
compiler/rustc_serialize/src/serialize.rs+2-1
......@@ -1,6 +1,5 @@
11//! Support code for encoding and decoding types.
22
3use smallvec::{Array, SmallVec};
43use std::borrow::Cow;
54use std::cell::{Cell, RefCell};
65use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet, VecDeque};
......@@ -10,6 +9,8 @@ use std::num::NonZero;
109use std::path;
1110use std::rc::Rc;
1211use std::sync::Arc;
12
13use smallvec::{Array, SmallVec};
1314use thin_vec::ThinVec;
1415
1516/// 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 @@
11use rustc_serialize::leb128::*;
2use rustc_serialize::opaque::MemDecoder;
3use rustc_serialize::opaque::MAGIC_END_BYTES;
2use rustc_serialize::opaque::{MemDecoder, MAGIC_END_BYTES};
43use rustc_serialize::Decoder;
54
65macro_rules! impl_test_unsigned_leb128 {
compiler/rustc_serialize/tests/opaque.rs+3-2
......@@ -1,10 +1,11 @@
11#![allow(rustc::internal)]
22
3use std::fmt::Debug;
4use std::fs;
5
36use rustc_macros::{Decodable_Generic, Encodable_Generic};
47use rustc_serialize::opaque::{FileEncoder, MemDecoder};
58use rustc_serialize::{Decodable, Encodable};
6use std::fmt::Debug;
7use std::fs;
89
910#[derive(PartialEq, Clone, Debug, Encodable_Generic, Decodable_Generic)]
1011struct Struct {
compiler/rustc_session/src/code_stats.rs+2-1
......@@ -1,9 +1,10 @@
1use std::cmp;
2
13use rustc_data_structures::fx::{FxHashMap, FxHashSet};
24use rustc_data_structures::sync::Lock;
35use rustc_span::def_id::DefId;
46use rustc_span::Symbol;
57use rustc_target::abi::{Align, Size};
6use std::cmp;
78
89#[derive(Clone, PartialEq, Eq, Hash, Debug)]
910pub struct VariantInfo {
compiler/rustc_session/src/config.rs+36-34
......@@ -3,13 +3,17 @@
33
44#![allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
55
6pub use crate::options::*;
6use std::collections::btree_map::{
7 Iter as BTreeMapIter, Keys as BTreeMapKeysIter, Values as BTreeMapValuesIter,
8};
9use std::collections::{BTreeMap, BTreeSet};
10use std::ffi::OsStr;
11use std::hash::Hash;
12use std::path::{Path, PathBuf};
13use std::str::{self, FromStr};
14use std::sync::LazyLock;
15use std::{fmt, fs, iter};
716
8use crate::errors::FileWriteFail;
9use crate::search_paths::SearchPath;
10use crate::utils::{CanonicalizedPath, NativeLib, NativeLibKind};
11use crate::{filesearch, lint, HashStableContext};
12use crate::{EarlyDiagCtxt, Session};
1317use rustc_data_structures::fx::{FxHashSet, FxIndexMap};
1418use rustc_data_structures::stable_hasher::{StableOrd, ToStableHashKey};
1519use rustc_errors::emitter::HumanReadableErrorType;
......@@ -19,22 +23,17 @@ use rustc_macros::{Decodable, Encodable, HashStable_Generic};
1923use rustc_span::edition::{Edition, DEFAULT_EDITION, EDITION_NAME_LIST, LATEST_STABLE_EDITION};
2024use rustc_span::source_map::FilePathMapping;
2125use rustc_span::{FileName, FileNameDisplayPreference, RealFileName, SourceFileHashAlgorithm};
22use rustc_target::spec::{FramePointer, LinkSelfContainedComponents, LinkerFeatures};
23use rustc_target::spec::{SplitDebuginfo, Target, TargetTriple};
24use std::collections::btree_map::{
25 Iter as BTreeMapIter, Keys as BTreeMapKeysIter, Values as BTreeMapValuesIter,
26use rustc_target::spec::{
27 FramePointer, LinkSelfContainedComponents, LinkerFeatures, SplitDebuginfo, Target, TargetTriple,
2628};
27use std::collections::{BTreeMap, BTreeSet};
28use std::ffi::OsStr;
29use std::fmt;
30use std::fs;
31use std::hash::Hash;
32use std::iter;
33use std::path::{Path, PathBuf};
34use std::str::{self, FromStr};
35use std::sync::LazyLock;
3629use tracing::debug;
3730
31use crate::errors::FileWriteFail;
32pub use crate::options::*;
33use crate::search_paths::SearchPath;
34use crate::utils::{CanonicalizedPath, NativeLib, NativeLibKind};
35use crate::{filesearch, lint, EarlyDiagCtxt, HashStableContext, Session};
36
3837mod cfg;
3938pub mod sigpipe;
4039
......@@ -2765,9 +2764,10 @@ pub fn parse_crate_types_from_list(list_list: Vec<String>) -> Result<Vec<CrateTy
27652764}
27662765
27672766pub mod nightly_options {
2767 use rustc_feature::UnstableFeatures;
2768
27682769 use super::{OptionStability, RustcOptGroup};
27692770 use crate::EarlyDiagCtxt;
2770 use rustc_feature::UnstableFeatures;
27712771
27722772 pub fn is_unstable_enabled(matches: &getopts::Matches) -> bool {
27732773 match_is_nightly_build(matches)
......@@ -2960,6 +2960,22 @@ pub enum WasiExecModel {
29602960/// we have an opt-in scheme here, so one is hopefully forced to think about
29612961/// how the hash should be calculated when adding a new command-line argument.
29622962pub(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
29632979 use super::{
29642980 BranchProtection, CFGuard, CFProtection, CollapseMacroDebuginfo, CoverageOptions,
29652981 CrateType, DebugInfo, DebugInfoCompression, ErrorOutputType, FunctionReturn,
......@@ -2971,20 +2987,6 @@ pub(crate) mod dep_tracking {
29712987 };
29722988 use crate::lint;
29732989 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;
29882990
29892991 pub(crate) trait DepTrackingHash {
29902992 fn hash(
compiler/rustc_session/src/config/cfg.rs+4-5
......@@ -19,18 +19,17 @@
1919//! so that the compiler can know the cfg is expected
2020//! - Add the feature gating in `compiler/rustc_feature/src/builtin_attrs.rs`
2121
22use std::hash::Hash;
23use std::iter;
24
2225use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexSet};
2326use rustc_span::symbol::{sym, Symbol};
2427use rustc_target::abi::Align;
25use rustc_target::spec::{PanicStrategy, RelocModel, SanitizerSet};
26use rustc_target::spec::{Target, TargetTriple, TARGETS};
28use rustc_target::spec::{PanicStrategy, RelocModel, SanitizerSet, Target, TargetTriple, TARGETS};
2729
2830use crate::config::CrateType;
2931use crate::Session;
3032
31use std::hash::Hash;
32use std::iter;
33
3433/// The parsed `--cfg` options that define the compilation environment of the
3534/// crate, used to drive conditional compilation.
3635///
compiler/rustc_session/src/cstore.rs+5-4
......@@ -2,8 +2,9 @@
22//! are *mostly* used as a part of that interface, but these should
33//! probably get a better home if someone can find one.
44
5use crate::search_paths::PathKind;
6use crate::utils::NativeLibKind;
5use std::any::Any;
6use std::path::PathBuf;
7
78use rustc_ast as ast;
89use rustc_data_structures::sync::{self, AppendOnlyIndexVec, FreezeLock};
910use rustc_hir::def_id::{
......@@ -15,8 +16,8 @@ use rustc_span::symbol::Symbol;
1516use rustc_span::Span;
1617use rustc_target::spec::abi::Abi;
1718
18use std::any::Any;
19use std::path::PathBuf;
19use crate::search_paths::PathKind;
20use crate::utils::NativeLibKind;
2021
2122// lonely orphan structs and enums looking for a better home
2223
compiler/rustc_session/src/errors.rs+5-3
......@@ -2,15 +2,17 @@ use std::num::NonZero;
22
33use rustc_ast::token;
44use rustc_ast::util::literal::LitError;
5use rustc_errors::codes::*;
56use rustc_errors::{
6 codes::*, Diag, DiagCtxtHandle, DiagMessage, Diagnostic, EmissionGuarantee, ErrorGuaranteed,
7 Level, MultiSpan,
7 Diag, DiagCtxtHandle, DiagMessage, Diagnostic, EmissionGuarantee, ErrorGuaranteed, Level,
8 MultiSpan,
89};
910use rustc_macros::{Diagnostic, Subdiagnostic};
1011use rustc_span::{Span, Symbol};
1112use rustc_target::spec::{SplitDebuginfo, StackProtector, TargetTriple};
1213
13use crate::{config::CrateType, parse::ParseSess};
14use crate::config::CrateType;
15use crate::parse::ParseSess;
1416
1517pub(crate) struct FeatureGateError {
1618 pub(crate) span: MultiSpan,
compiler/rustc_session/src/filesearch.rs+9-10
......@@ -1,13 +1,14 @@
11//! A module for searching for libraries
22
3use crate::search_paths::{PathKind, SearchPath};
3use std::path::{Path, PathBuf};
4use std::{env, fs};
5
46use rustc_fs_util::{fix_windows_verbatim_for_gcc, try_canonicalize};
57use smallvec::{smallvec, SmallVec};
6use std::env;
7use std::fs;
8use std::path::{Path, PathBuf};
98use tracing::debug;
109
10use crate::search_paths::{PathKind, SearchPath};
11
1112#[derive(Clone)]
1213pub struct FileSearch<'a> {
1314 sysroot: &'a Path,
......@@ -129,12 +130,10 @@ fn current_dll_path() -> Result<PathBuf, String> {
129130 use std::io;
130131 use std::os::windows::prelude::*;
131132
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,
138137 };
139138
140139 let mut module = HMODULE::default();
compiler/rustc_session/src/options.rs+15-14
......@@ -1,26 +1,26 @@
1use crate::config::*;
2use crate::search_paths::SearchPath;
3use crate::utils::NativeLib;
4use crate::{lint, EarlyDiagCtxt};
1use std::collections::BTreeMap;
2use std::hash::{DefaultHasher, Hasher};
3use std::num::{IntErrorKind, NonZero};
4use std::path::PathBuf;
5use std::str;
6
57use rustc_data_structures::fx::FxIndexMap;
68use rustc_data_structures::profiling::TimePassesFormat;
79use rustc_data_structures::stable_hasher::Hash64;
8use rustc_errors::ColorConfig;
9use rustc_errors::{LanguageIdentifier, TerminalUrl};
10use rustc_errors::{ColorConfig, LanguageIdentifier, TerminalUrl};
1011use rustc_feature::UnstableFeatures;
1112use rustc_span::edition::Edition;
12use rustc_span::RealFileName;
13use rustc_span::SourceFileHashAlgorithm;
13use rustc_span::{RealFileName, SourceFileHashAlgorithm};
1414use rustc_target::spec::{
1515 CodeModel, FramePointer, LinkerFlavorCli, MergeFunctions, OnBrokenPipe, PanicStrategy,
1616 RelocModel, RelroLevel, SanitizerSet, SplitDebuginfo, StackProtector, TargetTriple, TlsModel,
1717 WasmCAbi,
1818};
19use std::collections::BTreeMap;
20use std::hash::{DefaultHasher, Hasher};
21use std::num::{IntErrorKind, NonZero};
22use std::path::PathBuf;
23use std::str;
19
20use crate::config::*;
21use crate::search_paths::SearchPath;
22use crate::utils::NativeLib;
23use crate::{lint, EarlyDiagCtxt};
2424
2525macro_rules! insert {
2626 ($opt_name:ident, $opt_expr:expr, $sub_hashes:expr) => {
......@@ -447,9 +447,10 @@ mod desc {
447447}
448448
449449mod parse {
450 pub(crate) use super::*;
451450 use std::str::FromStr;
452451
452 pub(crate) use super::*;
453
453454 /// This is for boolean options that don't take a value and start with
454455 /// `no-`. This style of option is deprecated.
455456 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 @@
11//! Related to out filenames of compilation (e.g. binaries).
22
3use std::path::Path;
4
5use rustc_ast::{self as ast, attr};
6use rustc_errors::FatalError;
7use rustc_span::symbol::sym;
8use rustc_span::{Span, Symbol};
9
310use crate::config::{self, CrateType, Input, OutFileName, OutputFilenames, OutputType};
411use crate::errors::{
512 self, CrateNameDoesNotMatch, CrateNameEmpty, CrateNameInvalid, FileIsNotWriteable,
613 InvalidCharacterInCrateName, InvalidCrateNameHelp,
714};
815use crate::Session;
9use rustc_ast::{self as ast, attr};
10use rustc_errors::FatalError;
11use rustc_span::symbol::sym;
12use rustc_span::{Span, Symbol};
13use std::path::Path;
1416
1517pub fn out_filename(
1618 sess: &Session,
compiler/rustc_session/src/parse.rs+11-11
......@@ -1,15 +1,9 @@
11//! Contains `ParseSess` which holds state living beyond what one `Parser` might.
22//! It also serves as an input to the parser itself.
33
4use crate::config::{Cfg, CheckCfg};
5use crate::errors::{
6 CliFeatureDiagnosticHelp, FeatureDiagnosticForIssue, FeatureDiagnosticHelp,
7 FeatureDiagnosticSuggestion, FeatureGateError, SuggestUpgradeCompiler,
8};
9use crate::lint::{
10 builtin::UNSTABLE_SYNTAX_PRE_EXPANSION, BufferedEarlyLint, BuiltinLintDiag, Lint, LintId,
11};
12use crate::Session;
4use std::str;
5
6use rustc_ast::attr::AttrIdGenerator;
137use rustc_ast::node_id::NodeId;
148use rustc_data_structures::fx::{FxHashMap, FxIndexMap, FxIndexSet};
159use rustc_data_structures::sync::{AppendOnlyVec, Lock, Lrc};
......@@ -24,8 +18,14 @@ use rustc_span::hygiene::ExpnId;
2418use rustc_span::source_map::{FilePathMapping, SourceMap};
2519use rustc_span::{Span, Symbol};
2620
27use rustc_ast::attr::AttrIdGenerator;
28use std::str;
21use crate::config::{Cfg, CheckCfg};
22use crate::errors::{
23 CliFeatureDiagnosticHelp, FeatureDiagnosticForIssue, FeatureDiagnosticHelp,
24 FeatureDiagnosticSuggestion, FeatureGateError, SuggestUpgradeCompiler,
25};
26use crate::lint::builtin::UNSTABLE_SYNTAX_PRE_EXPANSION;
27use crate::lint::{BufferedEarlyLint, BuiltinLintDiag, Lint, LintId};
28use crate::Session;
2929
3030/// Collected spans during parsing for places where a certain feature was
3131/// used and should be feature gated accordingly in `check_crate`.
compiler/rustc_session/src/search_paths.rs+5-3
......@@ -1,8 +1,10 @@
1use crate::filesearch::make_target_lib_path;
2use crate::EarlyDiagCtxt;
1use std::path::{Path, PathBuf};
2
33use rustc_macros::{Decodable, Encodable, HashStable_Generic};
44use rustc_target::spec::TargetTriple;
5use std::path::{Path, PathBuf};
5
6use crate::filesearch::make_target_lib_path;
7use crate::EarlyDiagCtxt;
68
79#[derive(Clone, Debug)]
810pub struct SearchPath {
compiler/rustc_session/src/session.rs+22-24
......@@ -1,14 +1,11 @@
1use crate::code_stats::CodeStats;
2pub use crate::code_stats::{DataTypeKind, FieldInfo, FieldKind, SizeKind, VariantInfo};
3use crate::config::{
4 self, CoverageLevel, CrateType, FunctionReturn, InstrumentCoverage, OptLevel, OutFileName,
5 OutputType, RemapPathScopeComponents, SwitchWithOptPath,
6};
7use crate::config::{ErrorOutputType, Input};
8use crate::errors;
9use crate::parse::{add_feature_diagnostics, ParseSess};
10use crate::search_paths::{PathKind, SearchPath};
11use crate::{filesearch, lint};
1use std::any::Any;
2use std::ops::{Div, Mul};
3use std::path::{Path, PathBuf};
4use std::str::FromStr;
5use std::sync::atomic::AtomicBool;
6use std::sync::atomic::Ordering::SeqCst;
7use std::sync::Arc;
8use std::{env, fmt, io};
129
1310use rustc_data_structures::flock;
1411use rustc_data_structures::fx::{FxHashMap, FxIndexSet};
......@@ -18,33 +15,34 @@ use rustc_data_structures::sync::{
1815 AtomicU64, DynSend, DynSync, Lock, Lrc, MappedReadGuard, ReadGuard, RwLock,
1916};
2017use rustc_errors::annotate_snippet_emitter_writer::AnnotateSnippetEmitter;
18use rustc_errors::codes::*;
2119use rustc_errors::emitter::{stderr_destination, DynEmitter, HumanEmitter, HumanReadableErrorType};
2220use rustc_errors::json::JsonEmitter;
2321use rustc_errors::registry::Registry;
2422use rustc_errors::{
25 codes::*, fallback_fluent_bundle, Diag, DiagCtxt, DiagCtxtHandle, DiagMessage, Diagnostic,
23 fallback_fluent_bundle, Diag, DiagCtxt, DiagCtxtHandle, DiagMessage, Diagnostic,
2624 ErrorGuaranteed, FatalAbort, FluentBundle, LazyFallbackBundle, TerminalUrl,
2725};
2826use rustc_macros::HashStable_Generic;
2927pub use rustc_span::def_id::StableCrateId;
3028use rustc_span::edition::Edition;
3129use rustc_span::source_map::{FilePathMapping, SourceMap};
32use rustc_span::{FileNameDisplayPreference, RealFileName};
33use rustc_span::{Span, Symbol};
30use rustc_span::{FileNameDisplayPreference, RealFileName, Span, Symbol};
3431use rustc_target::asm::InlineAsmArch;
35use rustc_target::spec::{CodeModel, PanicStrategy, RelocModel, RelroLevel};
3632use rustc_target::spec::{
37 DebuginfoKind, SanitizerSet, SplitDebuginfo, StackProtector, Target, TargetTriple, TlsModel,
33 CodeModel, DebuginfoKind, PanicStrategy, RelocModel, RelroLevel, SanitizerSet, SplitDebuginfo,
34 StackProtector, Target, TargetTriple, TlsModel,
3835};
3936
40use std::any::Any;
41use std::env;
42use std::fmt;
43use std::io;
44use std::ops::{Div, Mul};
45use std::path::{Path, PathBuf};
46use std::str::FromStr;
47use std::sync::{atomic::AtomicBool, atomic::Ordering::SeqCst, Arc};
37use crate::code_stats::CodeStats;
38pub use crate::code_stats::{DataTypeKind, FieldInfo, FieldKind, SizeKind, VariantInfo};
39use crate::config::{
40 self, CoverageLevel, CrateType, ErrorOutputType, FunctionReturn, Input, InstrumentCoverage,
41 OptLevel, OutFileName, OutputType, RemapPathScopeComponents, SwitchWithOptPath,
42};
43use crate::parse::{add_feature_diagnostics, ParseSess};
44use crate::search_paths::{PathKind, SearchPath};
45use crate::{errors, filesearch, lint};
4846
4947struct OptimizationFuel {
5048 /// If `-zfuel=crate=n` is specified, initially set to `n`, otherwise `0`.
compiler/rustc_session/src/utils.rs+5-5
......@@ -1,11 +1,11 @@
1use crate::session::Session;
1use std::path::{Path, PathBuf};
2use std::sync::OnceLock;
3
24use rustc_data_structures::profiling::VerboseTimingGuard;
35use rustc_fs_util::try_canonicalize;
46use rustc_macros::{Decodable, Encodable, HashStable_Generic};
5use std::{
6 path::{Path, PathBuf},
7 sync::OnceLock,
8};
7
8use crate::session::Session;
99
1010impl Session {
1111 pub fn timer(&self, what: &'static str) -> VerboseTimingGuard<'_> {
compiler/rustc_session/src/version.rs+3-5
......@@ -1,10 +1,8 @@
1use rustc_macros::{current_rustc_version, Decodable, Encodable, HashStable_Generic};
2use std::{
3 borrow::Cow,
4 fmt::{self, Display},
5};
1use std::borrow::Cow;
2use std::fmt::{self, Display};
63
74use rustc_errors::IntoDiagArg;
5use rustc_macros::{current_rustc_version, Decodable, Encodable, HashStable_Generic};
86
97#[derive(Encodable, Decodable, Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
108#[derive(HashStable_Generic)]
compiler/rustc_smir/src/rustc_internal/internal.rs+1-1
......@@ -5,7 +5,6 @@
55
66// Prefer importing stable_mir over internal rustc constructs to make this file more readable.
77
8use crate::rustc_smir::Tables;
98use rustc_middle::ty::{self as rustc_ty, Const as InternalConst, Ty as InternalTy, TyCtxt};
109use rustc_span::Symbol;
1110use stable_mir::abi::Layout;
......@@ -21,6 +20,7 @@ use stable_mir::ty::{
2120use stable_mir::{CrateItem, CrateNum, DefId};
2221
2322use super::RustcInternal;
23use crate::rustc_smir::Tables;
2424
2525impl RustcInternal for CrateItem {
2626 type T<'tcx> = rustc_span::def_id::DefId;
compiler/rustc_smir/src/rustc_internal/mod.rs+8-6
......@@ -3,7 +3,11 @@
33//! For that, we define APIs that will temporarily be public to 3P that exposes rustc internal APIs
44//! until stable MIR is complete.
55
6use crate::rustc_smir::{context::TablesWrapper, Stable, Tables};
6use std::cell::{Cell, RefCell};
7use std::fmt::Debug;
8use std::hash::Hash;
9use std::ops::Index;
10
711use rustc_data_structures::fx;
812use rustc_data_structures::fx::FxIndexMap;
913use rustc_middle::mir::interpret::AllocId;
......@@ -15,11 +19,9 @@ use scoped_tls::scoped_thread_local;
1519use stable_mir::abi::Layout;
1620use stable_mir::ty::IndexedVal;
1721use stable_mir::Error;
18use std::cell::Cell;
19use std::cell::RefCell;
20use std::fmt::Debug;
21use std::hash::Hash;
22use std::ops::Index;
22
23use crate::rustc_smir::context::TablesWrapper;
24use crate::rustc_smir::{Stable, Tables};
2325
2426mod internal;
2527pub mod pretty;
compiler/rustc_smir/src/rustc_internal/pretty.rs+2-1
......@@ -1,8 +1,9 @@
11use std::io;
22
3use super::run;
43use rustc_middle::ty::TyCtxt;
54
5use super::run;
6
67pub fn write_smir_pretty<'tcx, W: io::Write>(tcx: TyCtxt<'tcx>, w: &mut W) -> io::Result<()> {
78 writeln!(
89 w,
compiler/rustc_smir/src/rustc_smir/alloc.rs+4-6
......@@ -1,12 +1,10 @@
1use rustc_middle::mir::{
2 interpret::{alloc_range, AllocRange, Pointer},
3 ConstValue,
4};
1use rustc_middle::mir::interpret::{alloc_range, AllocRange, Pointer};
2use rustc_middle::mir::ConstValue;
3use stable_mir::mir::Mutability;
4use stable_mir::ty::{Allocation, ProvenanceMap};
55use stable_mir::Error;
66
77use crate::rustc_smir::{Stable, Tables};
8use stable_mir::mir::Mutability;
9use stable_mir::ty::{Allocation, ProvenanceMap};
108
119/// Creates new empty `Allocation` from given `Align`.
1210fn new_empty_allocation(align: rustc_target::abi::Align) -> Allocation {
compiler/rustc_smir/src/rustc_smir/builder.rs+2-1
......@@ -4,12 +4,13 @@
44//! monomorphic body using internal representation.
55//! After that, we convert the internal representation into a stable one.
66
7use crate::rustc_smir::{Stable, Tables};
87use rustc_hir::def::DefKind;
98use rustc_middle::mir;
109use rustc_middle::mir::visit::MutVisitor;
1110use rustc_middle::ty::{self, TyCtxt};
1211
12use crate::rustc_smir::{Stable, Tables};
13
1314/// Builds a monomorphic body for a given instance.
1415pub struct BodyBuilder<'tcx> {
1516 tcx: TyCtxt<'tcx>,
compiler/rustc_smir/src/rustc_smir/context.rs+3-2
......@@ -5,6 +5,9 @@
55
66#![allow(rustc::usage_of_qualified_ty)]
77
8use std::cell::RefCell;
9use std::iter;
10
811use rustc_abi::HasDataLayout;
912use rustc_hir::LangItem;
1013use rustc_middle::ty::layout::{
......@@ -28,8 +31,6 @@ use stable_mir::ty::{
2831 TyConst, TyKind, UintTy, VariantDef,
2932};
3033use stable_mir::{Crate, CrateDef, CrateItem, CrateNum, DefId, Error, Filename, ItemKind, Symbol};
31use std::cell::RefCell;
32use std::iter;
3334
3435use crate::rustc_internal::RustcInternal;
3536use crate::rustc_smir::builder::BodyBuilder;
compiler/rustc_smir/src/rustc_smir/convert/abi.rs+2-1
......@@ -2,7 +2,6 @@
22
33#![allow(rustc::usage_of_qualified_ty)]
44
5use crate::rustc_smir::{Stable, Tables};
65use rustc_middle::ty;
76use rustc_target::abi::call::Conv;
87use stable_mir::abi::{
......@@ -14,6 +13,8 @@ use stable_mir::opaque;
1413use stable_mir::target::MachineSize as Size;
1514use stable_mir::ty::{Align, IndexedVal, VariantIdx};
1615
16use crate::rustc_smir::{Stable, Tables};
17
1718impl<'tcx> Stable<'tcx> for rustc_target::abi::VariantIdx {
1819 type T = VariantIdx;
1920 fn stable(&self, _: &mut Tables<'_>) -> Self::T {
compiler/rustc_smir/src/rustc_smir/convert/error.rs+2-1
......@@ -2,10 +2,11 @@
22//!
33//! Currently we encode everything as [stable_mir::Error], which is represented as a string.
44
5use crate::rustc_smir::{Stable, Tables};
65use rustc_middle::mir::interpret::AllocError;
76use rustc_middle::ty::layout::LayoutError;
87
8use crate::rustc_smir::{Stable, Tables};
9
910impl<'tcx> Stable<'tcx> for LayoutError<'tcx> {
1011 type T = stable_mir::Error;
1112
compiler/rustc_smir/src/rustc_smir/convert/mir.rs+1-2
......@@ -1,9 +1,8 @@
11//! Conversion of internal Rust compiler `mir` items to stable ones.
22
3use rustc_middle::bug;
4use rustc_middle::mir;
53use rustc_middle::mir::interpret::alloc_range;
64use rustc_middle::mir::mono::MonoItem;
5use rustc_middle::{bug, mir};
76use stable_mir::mir::alloc::GlobalAlloc;
87use stable_mir::mir::{ConstOperand, Statement, UserTypeProjection, VarDebugInfoFragment};
98use stable_mir::ty::{Allocation, ConstantKind, MirConst};
compiler/rustc_smir/src/rustc_smir/mod.rs+2-1
......@@ -7,6 +7,8 @@
77//!
88//! For now, we are developing everything inside `rustc`, thus, we keep this module private.
99
10use std::ops::RangeInclusive;
11
1012use rustc_hir::def::DefKind;
1113use rustc_middle::mir;
1214use rustc_middle::mir::interpret::AllocId;
......@@ -16,7 +18,6 @@ use stable_mir::abi::Layout;
1618use stable_mir::mir::mono::InstanceDef;
1719use stable_mir::ty::{MirConstId, Span, TyConstId};
1820use stable_mir::{CtorKind, ItemKind};
19use std::ops::RangeInclusive;
2021use tracing::debug;
2122
2223use crate::rustc_internal::IndexMap;
compiler/rustc_span/src/caching_source_map_view.rs+4-2
......@@ -1,7 +1,9 @@
1use std::ops::Range;
2
3use rustc_data_structures::sync::Lrc;
4
15use crate::source_map::SourceMap;
26use crate::{BytePos, Pos, RelativeBytePos, SourceFile, SpanData};
3use rustc_data_structures::sync::Lrc;
4use std::ops::Range;
57
68#[derive(Clone)]
79struct CacheEntry {
compiler/rustc_span/src/def_id.rs+5-3
......@@ -1,4 +1,6 @@
1use crate::{HashStableContext, SpanDecoder, SpanEncoder, Symbol};
1use std::fmt;
2use std::hash::{BuildHasherDefault, Hash, Hasher};
3
24use rustc_data_structures::fingerprint::Fingerprint;
35use rustc_data_structures::stable_hasher::{
46 Hash64, HashStable, StableHasher, StableOrd, ToStableHashKey,
......@@ -8,8 +10,8 @@ use rustc_data_structures::AtomicRef;
810use rustc_index::Idx;
911use rustc_macros::{Decodable, Encodable, HashStable_Generic};
1012use rustc_serialize::{Decodable, Encodable};
11use std::fmt;
12use std::hash::{BuildHasherDefault, Hash, Hasher};
13
14use crate::{HashStableContext, SpanDecoder, SpanEncoder, Symbol};
1315
1416pub type StableCrateIdMap =
1517 indexmap::IndexMap<StableCrateId, CrateNum, BuildHasherDefault<Unhasher>>;
compiler/rustc_span/src/edit_distance.rs+2-1
......@@ -9,9 +9,10 @@
99// algorithm should not matter to the caller of the methods, which is why it is not noted in the
1010// documentation.
1111
12use crate::symbol::Symbol;
1312use std::{cmp, mem};
1413
14use crate::symbol::Symbol;
15
1516#[cfg(test)]
1617mod tests;
1718
compiler/rustc_span/src/hygiene.rs+10-8
......@@ -24,10 +24,11 @@
2424// because getting it wrong can lead to nested `HygieneData::with` calls that
2525// trigger runtime aborts. (Fortunately these are obvious and easy to fix.)
2626
27use crate::def_id::{CrateNum, DefId, StableCrateId, CRATE_DEF_ID, LOCAL_CRATE};
28use crate::edition::Edition;
29use crate::symbol::{kw, sym, Symbol};
30use crate::{with_session_globals, HashStableContext, Span, SpanDecoder, SpanEncoder, DUMMY_SP};
27use std::cell::RefCell;
28use std::collections::hash_map::Entry;
29use std::fmt;
30use std::hash::Hash;
31
3132use rustc_data_structures::fingerprint::Fingerprint;
3233use rustc_data_structures::fx::{FxHashMap, FxHashSet};
3334use rustc_data_structures::stable_hasher::{Hash64, HashStable, HashingControls, StableHasher};
......@@ -36,12 +37,13 @@ use rustc_data_structures::unhash::UnhashMap;
3637use rustc_index::IndexVec;
3738use rustc_macros::{Decodable, Encodable, HashStable_Generic};
3839use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
39use std::cell::RefCell;
40use std::collections::hash_map::Entry;
41use std::fmt;
42use std::hash::Hash;
4340use tracing::{debug, trace};
4441
42use crate::def_id::{CrateNum, DefId, StableCrateId, CRATE_DEF_ID, LOCAL_CRATE};
43use crate::edition::Edition;
44use crate::symbol::{kw, sym, Symbol};
45use crate::{with_session_globals, HashStableContext, Span, SpanDecoder, SpanEncoder, DUMMY_SP};
46
4547/// A `SyntaxContext` represents a chain of pairs `(ExpnId, Transparency)` named "marks".
4648#[derive(Clone, Copy, PartialEq, Eq, Hash)]
4749pub struct SyntaxContext(u32);
compiler/rustc_span/src/lib.rs+9-9
......@@ -47,15 +47,17 @@ use tracing::debug;
4747
4848mod caching_source_map_view;
4949pub mod source_map;
50pub use self::caching_source_map_view::CachingSourceMapView;
5150use source_map::{SourceMap, SourceMapInputs};
5251
52pub use self::caching_source_map_view::CachingSourceMapView;
53
5354pub mod edition;
5455use edition::Edition;
5556pub mod hygiene;
5657use hygiene::Transparency;
57pub use hygiene::{DesugaringKind, ExpnKind, MacroKind};
58pub use hygiene::{ExpnData, ExpnHash, ExpnId, LocalExpnId, SyntaxContext};
58pub use hygiene::{
59 DesugaringKind, ExpnData, ExpnHash, ExpnId, ExpnKind, LocalExpnId, MacroKind, SyntaxContext,
60};
5961use rustc_data_structures::stable_hasher::HashingControls;
6062pub mod def_id;
6163use def_id::{CrateNum, DefId, DefIndex, DefPathHash, LocalDefId, StableCrateId, LOCAL_CRATE};
......@@ -71,10 +73,6 @@ pub mod fatal_error;
7173
7274pub mod profiling;
7375
74use rustc_data_structures::fx::FxHashMap;
75use rustc_data_structures::stable_hasher::{Hash128, Hash64, HashStable, StableHasher};
76use rustc_data_structures::sync::{FreezeLock, FreezeWriteGuard, Lock, Lrc};
77
7876use std::borrow::Cow;
7977use std::cmp::{self, Ordering};
8078use std::hash::Hash;
......@@ -83,8 +81,10 @@ use std::path::{Path, PathBuf};
8381use std::str::FromStr;
8482use std::{fmt, iter};
8583
86use md5::Digest;
87use md5::Md5;
84use md5::{Digest, Md5};
85use rustc_data_structures::fx::FxHashMap;
86use rustc_data_structures::stable_hasher::{Hash128, Hash64, HashStable, StableHasher};
87use rustc_data_structures::sync::{FreezeLock, FreezeWriteGuard, Lock, Lrc};
8888use sha1::Sha1;
8989use sha2::Sha256;
9090
compiler/rustc_span/src/profiling.rs+2-2
......@@ -1,9 +1,9 @@
1use crate::source_map::SourceMap;
2
31use std::borrow::Borrow;
42
53use rustc_data_structures::profiling::EventArgRecorder;
64
5use crate::source_map::SourceMap;
6
77/// Extension trait for self-profiling purposes: allows to record spans within a generic activity's
88/// event arguments.
99pub trait SpannedEventArgRecorder {
compiler/rustc_span/src/source_map.rs+5-4
......@@ -9,15 +9,16 @@
99//! within the `SourceMap`, which upon request can be converted to line and column
1010//! information, source code snippets, etc.
1111
12use crate::*;
12use std::io::{self, BorrowedBuf, Read};
13use std::{fs, path};
14
1315use rustc_data_structures::sync::{IntoDynSyncSend, MappedReadGuard, ReadGuard, RwLock};
1416use rustc_data_structures::unhash::UnhashMap;
1517use rustc_macros::{Decodable, Encodable};
16use std::fs;
17use std::io::{self, BorrowedBuf, Read};
18use std::path;
1918use tracing::{debug, instrument, trace};
2019
20use crate::*;
21
2122#[cfg(test)]
2223mod tests;
2324
compiler/rustc_span/src/span_encoding.rs+4-6
......@@ -1,14 +1,12 @@
1use crate::def_id::{DefIndex, LocalDefId};
2use crate::hygiene::SyntaxContext;
3use crate::SPAN_TRACK;
4use crate::{BytePos, SpanData};
5
61use rustc_data_structures::fx::FxIndexSet;
7
82// This code is very hot and uses lots of arithmetic, avoid overflow checks for performance.
93// See https://github.com/rust-lang/rust/pull/119440#issuecomment-1874255727
104use rustc_serialize::int_overflow::DebugStrictAdd;
115
6use crate::def_id::{DefIndex, LocalDefId};
7use crate::hygiene::SyntaxContext;
8use crate::{BytePos, SpanData, SPAN_TRACK};
9
1210/// A compressed span.
1311///
1412/// [`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 @@
22//! allows bidirectional lookup; i.e., given a value, one can easily find the
33//! type, and vice versa.
44
5use std::hash::{Hash, Hasher};
6use std::{fmt, str};
7
58use rustc_arena::DroplessArena;
69use rustc_data_structures::fx::FxIndexSet;
710use rustc_data_structures::stable_hasher::{
......@@ -10,10 +13,6 @@ use rustc_data_structures::stable_hasher::{
1013use rustc_data_structures::sync::Lock;
1114use rustc_macros::{symbols, Decodable, Encodable, HashStable_Generic};
1215
13use std::fmt;
14use std::hash::{Hash, Hasher};
15use std::str;
16
1716use crate::{with_session_globals, Edition, Span, DUMMY_SP};
1817
1918#[cfg(test)]
......@@ -2446,13 +2445,11 @@ pub mod kw {
24462445/// Given that `sym` is imported, use them like `sym::symbol_name`.
24472446/// For example `sym::rustfmt` or `sym::u8`.
24482447pub mod sym {
2449 use super::Symbol;
2450
2451 #[doc(inline)]
2452 pub use super::sym_generated::*;
2453
24542448 // Used from a macro in `librustc_feature/accepted.rs`
24552449 pub use super::kw::MacroRules as macro_rules;
2450 #[doc(inline)]
2451 pub use super::sym_generated::*;
2452 use super::Symbol;
24562453
24572454 /// Get the symbol for an integer.
24582455 ///
compiler/rustc_span/src/symbol/tests.rs-1
......@@ -1,5 +1,4 @@
11use super::*;
2
32use crate::create_default_session_globals_then;
43
54#[test]
compiler/rustc_symbol_mangling/src/errors.rs+2-1
......@@ -1,8 +1,9 @@
11//! Errors emitted by symbol_mangling.
22
3use std::fmt;
4
35use rustc_errors::{Diag, DiagCtxtHandle, Diagnostic, EmissionGuarantee, Level};
46use rustc_span::Span;
5use std::fmt;
67
78pub struct TestOutput {
89 pub span: Span,
compiler/rustc_symbol_mangling/src/hashed.rs+3-2
......@@ -1,9 +1,10 @@
1use crate::v0;
1use std::fmt::Write;
2
23use rustc_data_structures::stable_hasher::{Hash64, HashStable, StableHasher};
34use rustc_hir::def_id::CrateNum;
45use rustc_middle::ty::{Instance, TyCtxt};
56
6use std::fmt::Write;
7use crate::v0;
78
89pub(super) fn mangle<'tcx>(
910 tcx: TyCtxt<'tcx>,
compiler/rustc_symbol_mangling/src/legacy.rs+6-4
......@@ -1,12 +1,14 @@
1use std::fmt::{self, Write};
2use std::mem::{self, discriminant};
3
14use rustc_data_structures::stable_hasher::{Hash64, HashStable, StableHasher};
25use rustc_hir::def_id::CrateNum;
36use rustc_hir::definitions::{DefPathData, DisambiguatedDefPathData};
47use rustc_middle::bug;
58use rustc_middle::ty::print::{PrettyPrinter, Print, PrintError, Printer};
6use rustc_middle::ty::{self, Instance, ReifyReason, Ty, TyCtxt, TypeVisitableExt};
7use rustc_middle::ty::{GenericArg, GenericArgKind};
8use std::fmt::{self, Write};
9use std::mem::{self, discriminant};
9use rustc_middle::ty::{
10 self, GenericArg, GenericArgKind, Instance, ReifyReason, Ty, TyCtxt, TypeVisitableExt,
11};
1012use tracing::debug;
1113
1214pub(super) fn mangle<'tcx>(
compiler/rustc_symbol_mangling/src/lib.rs+1-2
......@@ -97,8 +97,7 @@
9797
9898use rustc_hir::def::DefKind;
9999use rustc_hir::def_id::{CrateNum, LOCAL_CRATE};
100use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
101use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrs;
100use rustc_middle::middle::codegen_fn_attrs::{CodegenFnAttrFlags, CodegenFnAttrs};
102101use rustc_middle::mir::mono::{InstantiationMode, MonoItem};
103102use rustc_middle::query::Providers;
104103use rustc_middle::ty::{self, Instance, TyCtxt};
compiler/rustc_symbol_mangling/src/test.rs+2-1
......@@ -4,12 +4,13 @@
44//! def-path. This is used for unit testing the code that generates
55//! paths etc in all kinds of annoying scenarios.
66
7use crate::errors::{Kind, TestOutput};
87use rustc_hir::def_id::LocalDefId;
98use rustc_middle::ty::print::with_no_trimmed_paths;
109use rustc_middle::ty::{GenericArgs, Instance, TyCtxt};
1110use rustc_span::symbol::{sym, Symbol};
1211
12use crate::errors::{Kind, TestOutput};
13
1314const SYMBOL_NAME: Symbol = sym::rustc_symbol_name;
1415const DEF_PATH: Symbol = sym::rustc_def_path;
1516
compiler/rustc_symbol_mangling/src/v0.rs+6-7
......@@ -1,3 +1,7 @@
1use std::fmt::Write;
2use std::iter;
3use std::ops::Range;
4
15use rustc_data_structures::base_n::ToBaseN;
26use rustc_data_structures::fx::FxHashMap;
37use rustc_data_structures::intern::Interned;
......@@ -9,18 +13,13 @@ use rustc_middle::bug;
913use rustc_middle::ty::layout::IntegerExt;
1014use rustc_middle::ty::print::{Print, PrintError, Printer};
1115use 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,
1418};
15use rustc_middle::ty::{GenericArg, GenericArgKind};
1619use rustc_span::symbol::kw;
1720use rustc_target::abi::Integer;
1821use rustc_target::spec::abi::Abi;
1922
20use std::fmt::Write;
21use std::iter;
22use std::ops::Range;
23
2423pub(super) fn mangle<'tcx>(
2524 tcx: TyCtxt<'tcx>,
2625 instance: Instance<'tcx>,
compiler/rustc_target/src/abi/call/mod.rs+8-6
......@@ -1,11 +1,12 @@
1use crate::abi::{self, Abi, Align, FieldsShape, Size};
2use crate::abi::{HasDataLayout, TyAbiInterface, TyAndLayout};
3use crate::spec::{self, HasTargetSpec, HasWasmCAbiOpt, WasmCAbi};
4use rustc_macros::HashStable_Generic;
5use rustc_span::Symbol;
61use std::fmt;
72use std::str::FromStr;
83
4use rustc_macros::HashStable_Generic;
5use rustc_span::Symbol;
6
7use crate::abi::{self, Abi, Align, FieldsShape, HasDataLayout, Size, TyAbiInterface, TyAndLayout};
8use crate::spec::{self, HasTargetSpec, HasWasmCAbiOpt, WasmCAbi};
9
910mod aarch64;
1011mod amdgpu;
1112mod arm;
......@@ -967,8 +968,9 @@ impl FromStr for Conv {
967968// Some types are used a lot. Make sure they don't unintentionally get bigger.
968969#[cfg(target_pointer_width = "64")]
969970mod size_asserts {
970 use super::*;
971971 use rustc_data_structures::static_assert_size;
972
973 use super::*;
972974 // tidy-alphabetical-start
973975 static_assert_size!(ArgAbi<'_, usize>, 56);
974976 static_assert_size!(FnAbi<'_, usize>, 80);
compiler/rustc_target/src/abi/call/nvptx64.rs+1-2
......@@ -1,8 +1,7 @@
1use super::{ArgAttribute, ArgAttributes, ArgExtension, CastTarget};
12use crate::abi::call::{ArgAbi, FnAbi, PassMode, Reg, Size, Uniform};
23use crate::abi::{HasDataLayout, TyAbiInterface};
34
4use super::{ArgAttribute, ArgAttributes, ArgExtension, CastTarget};
5
65fn classify_ret<Ty>(ret: &mut ArgAbi<'_, Ty>) {
76 if ret.layout.is_aggregate() && ret.layout.is_sized() {
87 classify_aggregate(ret)
compiler/rustc_target/src/abi/mod.rs+4-5
......@@ -1,15 +1,14 @@
1use std::fmt;
2use std::ops::Deref;
3
14use rustc_data_structures::intern::Interned;
5use rustc_macros::HashStable_Generic;
26pub use Float::*;
37pub use Integer::*;
48pub use Primitive::*;
59
610use crate::json::{Json, ToJson};
711
8use std::fmt;
9use std::ops::Deref;
10
11use rustc_macros::HashStable_Generic;
12
1312pub mod call;
1413
1514// Explicitly import `Float` to avoid ambiguity with `Primitive::Float`.
compiler/rustc_target/src/asm/aarch64.rs+5-3
......@@ -1,8 +1,10 @@
1use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
2use crate::spec::{RelocModel, Target};
1use std::fmt;
2
33use rustc_data_structures::fx::FxIndexSet;
44use rustc_span::Symbol;
5use std::fmt;
5
6use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
7use crate::spec::{RelocModel, Target};
68
79def_reg_class! {
810 AArch64 AArch64InlineAsmRegClass {
compiler/rustc_target/src/asm/arm.rs+5-3
......@@ -1,8 +1,10 @@
1use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
2use crate::spec::{RelocModel, Target};
1use std::fmt;
2
33use rustc_data_structures::fx::FxIndexSet;
44use rustc_span::{sym, Symbol};
5use std::fmt;
5
6use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
7use crate::spec::{RelocModel, Target};
68
79def_reg_class! {
810 Arm ArmInlineAsmRegClass {
compiler/rustc_target/src/asm/avr.rs+4-2
......@@ -1,7 +1,9 @@
1use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
2use rustc_span::Symbol;
31use std::fmt;
42
3use rustc_span::Symbol;
4
5use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
6
57def_reg_class! {
68 Avr AvrInlineAsmRegClass {
79 reg,
compiler/rustc_target/src/asm/bpf.rs+4-2
......@@ -1,7 +1,9 @@
1use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
2use rustc_span::Symbol;
31use std::fmt;
42
3use rustc_span::Symbol;
4
5use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
6
57def_reg_class! {
68 Bpf BpfInlineAsmRegClass {
79 reg,
compiler/rustc_target/src/asm/csky.rs+4-2
......@@ -1,7 +1,9 @@
1use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
2use rustc_span::Symbol;
31use std::fmt;
42
3use rustc_span::Symbol;
4
5use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
6
57def_reg_class! {
68 CSKY CSKYInlineAsmRegClass {
79 reg,
compiler/rustc_target/src/asm/hexagon.rs+4-2
......@@ -1,7 +1,9 @@
1use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
2use rustc_span::Symbol;
31use std::fmt;
42
3use rustc_span::Symbol;
4
5use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
6
57def_reg_class! {
68 Hexagon HexagonInlineAsmRegClass {
79 reg,
compiler/rustc_target/src/asm/loongarch.rs+4-2
......@@ -1,7 +1,9 @@
1use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
2use rustc_span::Symbol;
31use std::fmt;
42
3use rustc_span::Symbol;
4
5use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
6
57def_reg_class! {
68 LoongArch LoongArchInlineAsmRegClass {
79 reg,
compiler/rustc_target/src/asm/m68k.rs+4-2
......@@ -1,7 +1,9 @@
1use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
2use rustc_span::Symbol;
31use std::fmt;
42
3use rustc_span::Symbol;
4
5use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
6
57def_reg_class! {
68 M68k M68kInlineAsmRegClass {
79 reg,
compiler/rustc_target/src/asm/mips.rs+4-2
......@@ -1,7 +1,9 @@
1use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
2use rustc_span::Symbol;
31use std::fmt;
42
3use rustc_span::Symbol;
4
5use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
6
57def_reg_class! {
68 Mips MipsInlineAsmRegClass {
79 reg,
compiler/rustc_target/src/asm/mod.rs+6-4
......@@ -1,10 +1,12 @@
1use crate::spec::Target;
2use crate::{abi::Size, spec::RelocModel};
1use std::fmt;
2use std::str::FromStr;
3
34use rustc_data_structures::fx::{FxHashMap, FxIndexSet};
45use rustc_macros::{Decodable, Encodable, HashStable_Generic};
56use rustc_span::Symbol;
6use std::fmt;
7use std::str::FromStr;
7
8use crate::abi::Size;
9use crate::spec::{RelocModel, Target};
810
911pub struct ModifierInfo {
1012 pub modifier: char,
compiler/rustc_target/src/asm/msp430.rs+4-2
......@@ -1,7 +1,9 @@
1use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
2use rustc_span::Symbol;
31use std::fmt;
42
3use rustc_span::Symbol;
4
5use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
6
57def_reg_class! {
68 Msp430 Msp430InlineAsmRegClass {
79 reg,
compiler/rustc_target/src/asm/nvptx.rs+2-1
......@@ -1,6 +1,7 @@
1use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
21use rustc_span::Symbol;
32
3use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
4
45def_reg_class! {
56 Nvptx NvptxInlineAsmRegClass {
67 reg16,
compiler/rustc_target/src/asm/powerpc.rs+4-2
......@@ -1,7 +1,9 @@
1use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
2use rustc_span::Symbol;
31use std::fmt;
42
3use rustc_span::Symbol;
4
5use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
6
57def_reg_class! {
68 PowerPC PowerPCInlineAsmRegClass {
79 reg,
compiler/rustc_target/src/asm/riscv.rs+5-3
......@@ -1,8 +1,10 @@
1use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
2use crate::spec::{RelocModel, Target};
1use std::fmt;
2
33use rustc_data_structures::fx::FxIndexSet;
44use rustc_span::{sym, Symbol};
5use std::fmt;
5
6use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
7use crate::spec::{RelocModel, Target};
68
79def_reg_class! {
810 RiscV RiscVInlineAsmRegClass {
compiler/rustc_target/src/asm/s390x.rs+4-2
......@@ -1,7 +1,9 @@
1use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
2use rustc_span::Symbol;
31use std::fmt;
42
3use rustc_span::Symbol;
4
5use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
6
57def_reg_class! {
68 S390x S390xInlineAsmRegClass {
79 reg,
compiler/rustc_target/src/asm/spirv.rs+2-1
......@@ -1,6 +1,7 @@
1use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
21use rustc_span::Symbol;
32
3use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
4
45def_reg_class! {
56 SpirV SpirVInlineAsmRegClass {
67 reg,
compiler/rustc_target/src/asm/wasm.rs+2-1
......@@ -1,6 +1,7 @@
1use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
21use rustc_span::Symbol;
32
3use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
4
45def_reg_class! {
56 Wasm WasmInlineAsmRegClass {
67 local,
compiler/rustc_target/src/asm/x86.rs+5-3
......@@ -1,8 +1,10 @@
1use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
2use crate::spec::{RelocModel, Target};
1use std::fmt;
2
33use rustc_data_structures::fx::FxIndexSet;
44use rustc_span::Symbol;
5use std::fmt;
5
6use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
7use crate::spec::{RelocModel, Target};
68
79def_reg_class! {
810 X86 X86InlineAsmRegClass {
compiler/rustc_target/src/spec/base/apple/mod.rs+6-4
......@@ -1,8 +1,10 @@
1use std::{borrow::Cow, env};
1use std::borrow::Cow;
2use std::env;
23
3use crate::spec::{add_link_args, add_link_args_iter};
4use crate::spec::{cvs, Cc, DebuginfoKind, FramePointer, LinkArgs, LinkerFlavor, Lld};
5use crate::spec::{SplitDebuginfo, StackProbeType, StaticCow, Target, TargetOptions};
4use crate::spec::{
5 add_link_args, add_link_args_iter, cvs, Cc, DebuginfoKind, FramePointer, LinkArgs,
6 LinkerFlavor, Lld, SplitDebuginfo, StackProbeType, StaticCow, Target, TargetOptions,
7};
68
79#[cfg(test)]
810mod tests;
compiler/rustc_target/src/spec/base/avr_gnu.rs+2-1
......@@ -1,6 +1,7 @@
1use crate::spec::{Cc, LinkerFlavor, Lld, RelocModel, Target, TargetOptions};
21use object::elf;
32
3use crate::spec::{Cc, LinkerFlavor, Lld, RelocModel, Target, TargetOptions};
4
45/// A base target for AVR devices using the GNU toolchain.
56///
67/// 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 @@
1use crate::spec::{cvs, RelroLevel, SplitDebuginfo, TargetOptions};
21use std::borrow::Cow;
32
3use crate::spec::{cvs, RelroLevel, SplitDebuginfo, TargetOptions};
4
45pub fn opts() -> TargetOptions {
56 TargetOptions {
67 os: "linux".into(),
compiler/rustc_target/src/spec/base/linux_musl.rs+1-2
......@@ -1,5 +1,4 @@
1use crate::spec::crt_objects;
2use crate::spec::{base, LinkSelfContainedDefault, TargetOptions};
1use crate::spec::{base, crt_objects, LinkSelfContainedDefault, TargetOptions};
32
43pub fn opts() -> TargetOptions {
54 let mut base = base::linux::opts();
compiler/rustc_target/src/spec/base/msvc.rs+2-1
......@@ -1,6 +1,7 @@
1use crate::spec::{DebuginfoKind, LinkerFlavor, Lld, SplitDebuginfo, TargetOptions};
21use std::borrow::Cow;
32
3use crate::spec::{DebuginfoKind, LinkerFlavor, Lld, SplitDebuginfo, TargetOptions};
4
45pub fn opts() -> TargetOptions {
56 // Suppress the verbose logo and authorship debugging output, which would needlessly
67 // clog any log files.
compiler/rustc_target/src/spec/base/windows_gnu.rs+5-3
......@@ -1,8 +1,10 @@
1use crate::spec::LinkSelfContainedDefault;
2use crate::spec::{add_link_args, crt_objects};
3use crate::spec::{cvs, Cc, DebuginfoKind, LinkerFlavor, Lld, SplitDebuginfo, TargetOptions};
41use std::borrow::Cow;
52
3use crate::spec::{
4 add_link_args, crt_objects, cvs, Cc, DebuginfoKind, LinkSelfContainedDefault, LinkerFlavor,
5 Lld, SplitDebuginfo, TargetOptions,
6};
7
68pub fn opts() -> TargetOptions {
79 let mut pre_link_args = TargetOptions::link_args(
810 LinkerFlavor::Gnu(Cc::No, Lld::No),
compiler/rustc_target/src/spec/base/windows_gnullvm.rs+2-1
......@@ -1,6 +1,7 @@
1use crate::spec::{cvs, Cc, DebuginfoKind, LinkerFlavor, Lld, SplitDebuginfo, TargetOptions};
21use std::borrow::Cow;
32
3use crate::spec::{cvs, Cc, DebuginfoKind, LinkerFlavor, Lld, SplitDebuginfo, TargetOptions};
4
45pub fn opts() -> TargetOptions {
56 // We cannot use `-nodefaultlibs` because compiler-rt has to be passed
67 // 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 @@
4040//! but not gcc's. As a result rustc cannot link with C++ static libraries (#36710)
4141//! when linking in self-contained mode.
4242
43use crate::spec::LinkOutputKind;
4443use std::borrow::Cow;
4544use std::collections::BTreeMap;
4645
46use crate::spec::LinkOutputKind;
47
4748pub type CrtObjects = BTreeMap<LinkOutputKind, Vec<Cow<'static, str>>>;
4849
4950pub(super) fn new(obj_table: &[(LinkOutputKind, &[&'static str])]) -> CrtObjects {
compiler/rustc_target/src/spec/mod.rs+17-15
......@@ -34,16 +34,6 @@
3434//! the target's settings, though `target-feature` and `link-args` will *add*
3535//! to the list specified by the target, rather than replace.
3636
37use crate::abi::call::Conv;
38use crate::abi::{Endian, Integer, Size, TargetDataLayout, TargetDataLayoutErrors};
39use crate::json::{Json, ToJson};
40use crate::spec::abi::Abi;
41use crate::spec::crt_objects::CrtObjects;
42use rustc_fs_util::try_canonicalize;
43use rustc_macros::{Decodable, Encodable, HashStable_Generic};
44use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
45use rustc_span::symbol::{kw, sym, Symbol};
46use serde_json::Value;
4737use std::borrow::Cow;
4838use std::collections::BTreeMap;
4939use std::hash::{Hash, Hasher};
......@@ -51,15 +41,28 @@ use std::ops::{Deref, DerefMut};
5141use std::path::{Path, PathBuf};
5242use std::str::FromStr;
5343use std::{fmt, io};
44
45use rustc_fs_util::try_canonicalize;
46use rustc_macros::{Decodable, Encodable, HashStable_Generic};
47use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
48use rustc_span::symbol::{kw, sym, Symbol};
49use serde_json::Value;
5450use tracing::debug;
5551
52use crate::abi::call::Conv;
53use crate::abi::{Endian, Integer, Size, TargetDataLayout, TargetDataLayoutErrors};
54use crate::json::{Json, ToJson};
55use crate::spec::abi::Abi;
56use crate::spec::crt_objects::CrtObjects;
57
5658pub mod abi;
5759pub mod crt_objects;
5860
5961mod base;
60pub use base::apple::deployment_target as current_apple_deployment_target;
61pub use base::apple::platform as current_apple_platform;
62pub use base::apple::sdk_version as current_apple_sdk_version;
62pub 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};
6366pub use base::avr_gnu::ef_avr_arch;
6467
6568/// Linker is called through a C/C++ compiler.
......@@ -3353,8 +3356,7 @@ impl Target {
33533356 target_triple: &TargetTriple,
33543357 sysroot: &Path,
33553358 ) -> Result<(Target, TargetWarnings), String> {
3356 use std::env;
3357 use std::fs;
3359 use std::{env, fs};
33583360
33593361 fn load_file(path: &Path) -> Result<(Target, TargetWarnings), String> {
33603362 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 @@
1use crate::spec::SanitizerSet;
2use crate::spec::{base, StackProbeType, Target, TargetOptions};
1use crate::spec::{base, SanitizerSet, StackProbeType, Target, TargetOptions};
32
43pub fn target() -> Target {
54 let mut base = base::linux_ohos::opts();
compiler/rustc_target/src/spec/targets/bpfeb_unknown_none.rs+2-2
......@@ -1,5 +1,5 @@
1use crate::spec::Target;
2use crate::{abi::Endian, spec::base};
1use crate::abi::Endian;
2use crate::spec::{base, Target};
33
44pub fn target() -> Target {
55 Target {
compiler/rustc_target/src/spec/targets/bpfel_unknown_none.rs+2-2
......@@ -1,5 +1,5 @@
1use crate::spec::Target;
2use crate::{abi::Endian, spec::base};
1use crate::abi::Endian;
2use crate::spec::{base, Target};
33
44pub fn target() -> Target {
55 Target {
compiler/rustc_target/src/spec/targets/loongarch64_unknown_none.rs+3-2
......@@ -1,5 +1,6 @@
1use crate::spec::{Cc, CodeModel, LinkerFlavor, Lld, PanicStrategy, RelocModel};
2use crate::spec::{Target, TargetOptions};
1use crate::spec::{
2 Cc, CodeModel, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions,
3};
34
45pub fn target() -> Target {
56 Target {
compiler/rustc_target/src/spec/targets/loongarch64_unknown_none_softfloat.rs+3-2
......@@ -1,5 +1,6 @@
1use crate::spec::{Cc, CodeModel, LinkerFlavor, Lld, PanicStrategy, RelocModel};
2use crate::spec::{Target, TargetOptions};
1use crate::spec::{
2 Cc, CodeModel, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions,
3};
34
45pub fn target() -> Target {
56 Target {
compiler/rustc_target/src/spec/targets/nvptx64_nvidia_cuda.rs+3-2
......@@ -1,5 +1,6 @@
1use crate::spec::LinkSelfContainedDefault;
2use crate::spec::{LinkerFlavor, MergeFunctions, PanicStrategy, Target, TargetOptions};
1use crate::spec::{
2 LinkSelfContainedDefault, LinkerFlavor, MergeFunctions, PanicStrategy, Target, TargetOptions,
3};
34
45pub fn target() -> Target {
56 Target {
compiler/rustc_target/src/spec/targets/riscv32im_risc0_zkvm_elf.rs+1-2
......@@ -1,5 +1,4 @@
1use crate::spec::{Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel};
2use crate::spec::{Target, TargetOptions};
1use crate::spec::{Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions};
32
43pub fn target() -> Target {
54 Target {
compiler/rustc_target/src/spec/targets/riscv64gc_unknown_none_elf.rs+4-3
......@@ -1,6 +1,7 @@
1use crate::spec::SanitizerSet;
2use crate::spec::{Cc, CodeModel, LinkerFlavor, Lld, PanicStrategy};
3use crate::spec::{RelocModel, Target, TargetOptions};
1use crate::spec::{
2 Cc, CodeModel, LinkerFlavor, Lld, PanicStrategy, RelocModel, SanitizerSet, Target,
3 TargetOptions,
4};
45
56pub fn target() -> Target {
67 Target {
compiler/rustc_target/src/spec/targets/riscv64gc_unknown_nuttx_elf.rs+4-3
......@@ -1,6 +1,7 @@
1use crate::spec::SanitizerSet;
2use crate::spec::{cvs, Cc, CodeModel, LinkerFlavor, Lld, PanicStrategy};
3use crate::spec::{RelocModel, Target, TargetOptions};
1use crate::spec::{
2 cvs, Cc, CodeModel, LinkerFlavor, Lld, PanicStrategy, RelocModel, SanitizerSet, Target,
3 TargetOptions,
4};
45
56pub fn target() -> Target {
67 Target {
compiler/rustc_target/src/spec/targets/riscv64imac_unknown_none_elf.rs+4-2
......@@ -1,5 +1,7 @@
1use crate::spec::{Cc, CodeModel, LinkerFlavor, Lld, PanicStrategy};
2use crate::spec::{RelocModel, SanitizerSet, Target, TargetOptions};
1use crate::spec::{
2 Cc, CodeModel, LinkerFlavor, Lld, PanicStrategy, RelocModel, SanitizerSet, Target,
3 TargetOptions,
4};
35
46pub fn target() -> Target {
57 Target {
compiler/rustc_target/src/spec/targets/riscv64imac_unknown_nuttx_elf.rs+4-3
......@@ -1,6 +1,7 @@
1use crate::spec::SanitizerSet;
2use crate::spec::{cvs, Cc, CodeModel, LinkerFlavor, Lld, PanicStrategy};
3use crate::spec::{RelocModel, Target, TargetOptions};
1use crate::spec::{
2 cvs, Cc, CodeModel, LinkerFlavor, Lld, PanicStrategy, RelocModel, SanitizerSet, Target,
3 TargetOptions,
4};
45
56pub fn target() -> Target {
67 Target {
compiler/rustc_target/src/spec/targets/thumbv4t_none_eabi.rs+1-2
......@@ -9,8 +9,7 @@
99//! The default link script is very likely wrong, so you should use
1010//! `-Clink-arg=-Tmy_script.ld` to override that with a correct linker script.
1111
12use crate::spec::{base, PanicStrategy, RelocModel, Target, TargetOptions};
13use crate::spec::{cvs, FramePointer};
12use crate::spec::{base, cvs, FramePointer, PanicStrategy, RelocModel, Target, TargetOptions};
1413
1514pub fn target() -> Target {
1615 Target {
compiler/rustc_target/src/spec/targets/wasm32_wasip1.rs+1-3
......@@ -10,9 +10,7 @@
1010//! was since renamed to `wasm32-wasip1` after the preview2 target was
1111//! introduced.
1212
13use crate::spec::crt_objects;
14use crate::spec::LinkSelfContainedDefault;
15use crate::spec::{base, Cc, LinkerFlavor, Target};
13use crate::spec::{base, crt_objects, Cc, LinkSelfContainedDefault, LinkerFlavor, Target};
1614
1715pub fn target() -> Target {
1816 let mut options = base::wasm::options();
compiler/rustc_target/src/spec/targets/wasm32_wasip2.rs+1-3
......@@ -16,9 +16,7 @@
1616//! You can see more about wasi at <https://wasi.dev> and the component model at
1717//! <https://github.com/WebAssembly/component-model>.
1818
19use crate::spec::crt_objects;
20use crate::spec::LinkSelfContainedDefault;
21use crate::spec::{base, RelocModel, Target};
19use crate::spec::{base, crt_objects, LinkSelfContainedDefault, RelocModel, Target};
2220
2321pub fn target() -> Target {
2422 let mut options = base::wasm::options();
compiler/rustc_target/src/spec/targets/x86_64_apple_darwin.rs+1-2
......@@ -1,6 +1,5 @@
11use crate::spec::base::apple::{macos_llvm_target, opts, Arch, TargetAbi};
2use crate::spec::{Cc, FramePointer, LinkerFlavor, Lld, SanitizerSet};
3use crate::spec::{Target, TargetOptions};
2use crate::spec::{Cc, FramePointer, LinkerFlavor, Lld, SanitizerSet, Target, TargetOptions};
43
54pub fn target() -> Target {
65 let arch = Arch::X86_64;
compiler/rustc_target/src/spec/targets/x86_64_unknown_none.rs+4-2
......@@ -4,8 +4,10 @@
44// `target-cpu` compiler flags to opt-in more hardware-specific
55// features.
66
7use crate::spec::{Cc, CodeModel, LinkerFlavor, Lld, PanicStrategy};
8use crate::spec::{RelroLevel, SanitizerSet, StackProbeType, Target, TargetOptions};
7use crate::spec::{
8 Cc, CodeModel, LinkerFlavor, Lld, PanicStrategy, RelroLevel, SanitizerSet, StackProbeType,
9 Target, TargetOptions,
10};
911
1012pub fn target() -> Target {
1113 let opts = TargetOptions {
compiler/rustc_target/src/spec/targets/x86_64_unknown_uefi.rs+2-4
......@@ -5,10 +5,8 @@
55// The win64 ABI is used. It differs from the sysv64 ABI, so we must use a windows target with
66// LLVM. "x86_64-unknown-windows" is used to get the minimal subset of windows-specific features.
77
8use crate::{
9 abi::call::Conv,
10 spec::{base, Target},
11};
8use crate::abi::call::Conv;
9use crate::spec::{base, Target};
1210
1311pub fn target() -> Target {
1412 let mut base = base::uefi_msvc::opts();
compiler/rustc_target/src/spec/targets/x86_64h_apple_darwin.rs+1-2
......@@ -1,6 +1,5 @@
11use crate::spec::base::apple::{macos_llvm_target, opts, Arch, TargetAbi};
2use crate::spec::{Cc, FramePointer, LinkerFlavor, Lld, SanitizerSet};
3use crate::spec::{Target, TargetOptions};
2use crate::spec::{Cc, FramePointer, LinkerFlavor, Lld, SanitizerSet, Target, TargetOptions};
43
54pub fn target() -> Target {
65 let arch = Arch::X86_64h;
compiler/rustc_target/src/spec/targets/xtensa_esp32_espidf.rs+2-1
......@@ -1,5 +1,6 @@
11use crate::abi::Endian;
2use crate::spec::{base::xtensa, cvs, Target, TargetOptions};
2use crate::spec::base::xtensa;
3use crate::spec::{cvs, Target, TargetOptions};
34
45pub fn target() -> Target {
56 Target {
compiler/rustc_target/src/spec/targets/xtensa_esp32_none_elf.rs+2-1
......@@ -1,4 +1,5 @@
1use crate::spec::{base::xtensa, Target, TargetOptions};
1use crate::spec::base::xtensa;
2use crate::spec::{Target, TargetOptions};
23
34pub fn target() -> Target {
45 Target {
compiler/rustc_target/src/spec/targets/xtensa_esp32s2_espidf.rs+2-1
......@@ -1,5 +1,6 @@
11use crate::abi::Endian;
2use crate::spec::{base::xtensa, cvs, Target, TargetOptions};
2use crate::spec::base::xtensa;
3use crate::spec::{cvs, Target, TargetOptions};
34
45pub fn target() -> Target {
56 Target {
compiler/rustc_target/src/spec/targets/xtensa_esp32s2_none_elf.rs+2-1
......@@ -1,4 +1,5 @@
1use crate::spec::{base::xtensa, Target, TargetOptions};
1use crate::spec::base::xtensa;
2use crate::spec::{Target, TargetOptions};
23
34pub fn target() -> Target {
45 Target {
compiler/rustc_target/src/spec/targets/xtensa_esp32s3_espidf.rs+2-1
......@@ -1,5 +1,6 @@
11use crate::abi::Endian;
2use crate::spec::{base::xtensa, cvs, Target, TargetOptions};
2use crate::spec::base::xtensa;
3use crate::spec::{cvs, Target, TargetOptions};
34
45pub fn target() -> Target {
56 Target {
compiler/rustc_target/src/spec/targets/xtensa_esp32s3_none_elf.rs+2-1
......@@ -1,4 +1,5 @@
1use crate::spec::{base::xtensa, Target, TargetOptions};
1use crate::spec::base::xtensa;
2use crate::spec::{Target, TargetOptions};
23
34pub fn target() -> Target {
45 Target {
compiler/rustc_target/src/spec/tests/tests_impl.rs+2-1
......@@ -1,6 +1,7 @@
1use super::super::*;
21use std::assert_matches::assert_matches;
32
3use super::super::*;
4
45// Test target self-consistency and JSON encoding/decoding roundtrip.
56pub(super) fn test_target(mut target: Target) {
67 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 @@
1use rustc_span::symbol::sym;
2use rustc_span::symbol::Symbol;
1use rustc_span::symbol::{sym, Symbol};
32
43/// Features that control behaviour of rustc, rather than the codegen.
54pub 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};
6060use rustc_macros::extension;
6161use rustc_middle::bug;
6262use rustc_middle::dep_graph::DepContext;
63use rustc_middle::ty::error::ExpectedFound;
64use rustc_middle::ty::error::TypeErrorToStringExt;
63use rustc_middle::ty::error::{ExpectedFound, TypeError, TypeErrorToStringExt};
6564use rustc_middle::ty::print::{with_forced_trimmed_paths, PrintError, PrintTraitRefExt as _};
6665use 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,
6968};
7069use rustc_span::{sym, BytePos, DesugaringKind, Pos, Span};
7170use rustc_target::spec::abi;
compiler/rustc_trait_selection/src/error_reporting/infer/need_type_info.rs+14-12
......@@ -1,13 +1,11 @@
1use crate::error_reporting::TypeErrCtxt;
2use crate::errors::{
3 AmbiguousImpl, AmbiguousReturn, AnnotationRequired, InferenceBadError,
4 SourceKindMultiSuggestion, SourceKindSubdiag,
5};
6use crate::infer::InferCtxt;
7use rustc_errors::{codes::*, Diag, IntoDiagArg};
1use std::borrow::Cow;
2use std::iter;
3use std::path::PathBuf;
4
5use rustc_errors::codes::*;
6use rustc_errors::{Diag, IntoDiagArg};
87use rustc_hir as hir;
9use rustc_hir::def::Res;
10use rustc_hir::def::{CtorOf, DefKind, Namespace};
8use rustc_hir::def::{CtorOf, DefKind, Namespace, Res};
119use rustc_hir::def_id::{DefId, LocalDefId};
1210use rustc_hir::intravisit::{self, Visitor};
1311use rustc_hir::{Body, Closure, Expr, ExprKind, FnRetTy, HirId, LetStmt, LocalSource};
......@@ -21,9 +19,13 @@ use rustc_middle::ty::{
2119};
2220use rustc_span::symbol::{sym, Ident};
2321use rustc_span::{BytePos, Span, DUMMY_SP};
24use std::borrow::Cow;
25use std::iter;
26use std::path::PathBuf;
22
23use crate::error_reporting::TypeErrCtxt;
24use crate::errors::{
25 AmbiguousImpl, AmbiguousReturn, AnnotationRequired, InferenceBadError,
26 SourceKindMultiSuggestion, SourceKindSubdiag,
27};
28use crate::infer::InferCtxt;
2729
2830pub enum TypeAnnotationNeeded {
2931 /// ```compile_fail,E0282
compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/different_lifetimes.rs+7-11
......@@ -1,21 +1,17 @@
11//! Error Reporting for Anonymous Region Lifetime Errors
22//! where both the regions are anonymous.
33
4use crate::error_reporting::infer::nice_region_error::find_anon_type::find_anon_type;
5use crate::error_reporting::infer::nice_region_error::util::AnonymousParamInfo;
6use crate::error_reporting::infer::nice_region_error::NiceRegionError;
7use crate::errors::AddLifetimeParamsSuggestion;
8use crate::errors::LifetimeMismatch;
9use crate::errors::LifetimeMismatchLabels;
10use crate::infer::RegionResolutionError;
11use crate::infer::SubregionOrigin;
12
13use rustc_errors::Subdiagnostic;
14use rustc_errors::{Diag, ErrorGuaranteed};
4use rustc_errors::{Diag, ErrorGuaranteed, Subdiagnostic};
155use rustc_hir::def_id::LocalDefId;
166use rustc_hir::Ty;
177use rustc_middle::ty::{Region, TyCtxt};
188
9use crate::error_reporting::infer::nice_region_error::find_anon_type::find_anon_type;
10use crate::error_reporting::infer::nice_region_error::util::AnonymousParamInfo;
11use crate::error_reporting::infer::nice_region_error::NiceRegionError;
12use crate::errors::{AddLifetimeParamsSuggestion, LifetimeMismatch, LifetimeMismatchLabels};
13use crate::infer::{RegionResolutionError, SubregionOrigin};
14
1915impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
2016 /// Print the error message for lifetime errors when both the concerned regions are anonymous.
2117 ///
compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/find_anon_type.rs+1
......@@ -1,4 +1,5 @@
11use core::ops::ControlFlow;
2
23use rustc_hir as hir;
34use rustc_hir::def_id::LocalDefId;
45use 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 @@
11//! Error Reporting for when the lifetime for a type doesn't match the `impl` selected for a predicate
22//! to hold.
33
4use crate::error_reporting::infer::nice_region_error::NiceRegionError;
5use crate::errors::{note_and_explain, IntroducesStaticBecauseUnmetLifetimeReq};
6use crate::errors::{
7 DoesNotOutliveStaticFromImpl, ImplicitStaticLifetimeSubdiag, MismatchedStaticLifetime,
8};
9use crate::infer::RegionResolutionError;
10use crate::infer::{SubregionOrigin, TypeTrace};
11use crate::traits::ObligationCauseCode;
124use rustc_data_structures::fx::FxIndexSet;
135use rustc_errors::{ErrorGuaranteed, MultiSpan};
146use rustc_hir as hir;
......@@ -16,6 +8,14 @@ use rustc_hir::intravisit::Visitor;
168use rustc_middle::bug;
179use rustc_middle::ty::TypeVisitor;
1810
11use crate::error_reporting::infer::nice_region_error::NiceRegionError;
12use crate::errors::{
13 note_and_explain, DoesNotOutliveStaticFromImpl, ImplicitStaticLifetimeSubdiag,
14 IntroducesStaticBecauseUnmetLifetimeReq, MismatchedStaticLifetime,
15};
16use crate::infer::{RegionResolutionError, SubregionOrigin, TypeTrace};
17use crate::traits::ObligationCauseCode;
18
1919impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
2020 pub(super) fn try_report_mismatched_static_lifetime(&self) -> Option<ErrorGuaranteed> {
2121 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 @@
1use crate::error_reporting::TypeErrCtxt;
2use crate::infer::RegionResolutionError;
3use crate::infer::RegionResolutionError::*;
41use rustc_errors::{Diag, ErrorGuaranteed};
52use rustc_hir::def_id::LocalDefId;
63use rustc_middle::ty::{self, TyCtxt};
74use rustc_span::Span;
85
6use crate::error_reporting::TypeErrCtxt;
7use crate::infer::RegionResolutionError;
8use crate::infer::RegionResolutionError::*;
9
910mod different_lifetimes;
1011pub mod find_anon_type;
1112mod mismatched_static_lifetime;
compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/named_anon_conflict.rs+4-3
......@@ -1,13 +1,14 @@
11//! Error Reporting for Anonymous Region Lifetime Errors
22//! where one region is named and the other is anonymous.
33
4use crate::error_reporting::infer::nice_region_error::find_anon_type::find_anon_type;
5use crate::error_reporting::infer::nice_region_error::NiceRegionError;
6use crate::errors::ExplicitLifetimeRequired;
74use rustc_errors::Diag;
85use rustc_middle::ty;
96use rustc_span::symbol::kw;
107
8use crate::error_reporting::infer::nice_region_error::find_anon_type::find_anon_type;
9use crate::error_reporting::infer::nice_region_error::NiceRegionError;
10use crate::errors::ExplicitLifetimeRequired;
11
1112impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
1213 /// When given a `ConcreteFailure` for a function with parameters containing a named region and
1314 /// 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 @@
1use crate::error_reporting::infer::nice_region_error::NiceRegionError;
2use crate::errors::{
3 ActualImplExpectedKind, ActualImplExpectedLifetimeKind, ActualImplExplNotes,
4 TraitPlaceholderMismatch, TyOrSig,
5};
6use crate::infer::RegionResolutionError;
7use crate::infer::ValuePairs;
8use crate::infer::{SubregionOrigin, TypeTrace};
9use crate::traits::{ObligationCause, ObligationCauseCode};
1use std::fmt;
2
103use rustc_data_structures::intern::Interned;
114use rustc_errors::{Diag, IntoDiagArg};
125use rustc_hir::def::Namespace;
......@@ -14,10 +7,15 @@ use rustc_hir::def_id::{DefId, CRATE_DEF_ID};
147use rustc_middle::bug;
158use rustc_middle::ty::error::ExpectedFound;
169use rustc_middle::ty::print::{FmtPrinter, Print, PrintTraitRefExt as _, RegionHighlightMode};
17use rustc_middle::ty::GenericArgsRef;
18use rustc_middle::ty::{self, RePlaceholder, Region, TyCtxt};
10use rustc_middle::ty::{self, GenericArgsRef, RePlaceholder, Region, TyCtxt};
1911
20use std::fmt;
12use crate::error_reporting::infer::nice_region_error::NiceRegionError;
13use crate::errors::{
14 ActualImplExpectedKind, ActualImplExpectedLifetimeKind, ActualImplExplNotes,
15 TraitPlaceholderMismatch, TyOrSig,
16};
17use crate::infer::{RegionResolutionError, SubregionOrigin, TypeTrace, ValuePairs};
18use crate::traits::{ObligationCause, ObligationCauseCode};
2119
2220// HACK(eddyb) maybe move this in a more central location.
2321#[derive(Copy, Clone)]
compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/placeholder_relation.rs+4-3
......@@ -1,10 +1,11 @@
1use crate::error_reporting::infer::nice_region_error::NiceRegionError;
2use crate::errors::PlaceholderRelationLfNotSatisfied;
3use crate::infer::{RegionResolutionError, SubregionOrigin};
41use rustc_data_structures::intern::Interned;
52use rustc_errors::Diag;
63use rustc_middle::ty::{self, RePlaceholder, Region};
74
5use crate::error_reporting::infer::nice_region_error::NiceRegionError;
6use crate::errors::PlaceholderRelationLfNotSatisfied;
7use crate::infer::{RegionResolutionError, SubregionOrigin};
8
89impl<'tcx> NiceRegionError<'_, 'tcx> {
910 /// Emitted wwhen given a `ConcreteFailure` when relating two placeholders.
1011 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 @@
11//! Error Reporting for static impl Traits.
22
3use crate::error_reporting::infer::nice_region_error::NiceRegionError;
4use crate::errors::{
5 ButCallingIntroduces, ButNeedsToSatisfy, DynTraitConstraintSuggestion, MoreTargeted,
6 ReqIntroducedLocations,
7};
8use crate::infer::RegionResolutionError;
9use crate::infer::{SubregionOrigin, TypeTrace};
10use crate::traits::{ObligationCauseCode, UnifyReceiverContext};
113use rustc_data_structures::fx::FxIndexSet;
124use rustc_errors::{Applicability, Diag, ErrorGuaranteed, MultiSpan, Subdiagnostic};
135use rustc_hir::def_id::DefId;
......@@ -19,10 +11,17 @@ use rustc_hir::{
1911use rustc_middle::ty::{
2012 self, AssocItemContainer, StaticLifetimeVisitor, Ty, TyCtxt, TypeSuperVisitable, TypeVisitor,
2113};
14use rustc_span::def_id::LocalDefId;
2215use rustc_span::symbol::Ident;
2316use rustc_span::Span;
2417
25use rustc_span::def_id::LocalDefId;
18use crate::error_reporting::infer::nice_region_error::NiceRegionError;
19use crate::errors::{
20 ButCallingIntroduces, ButNeedsToSatisfy, DynTraitConstraintSuggestion, MoreTargeted,
21 ReqIntroducedLocations,
22};
23use crate::infer::{RegionResolutionError, SubregionOrigin, TypeTrace};
24use crate::traits::{ObligationCauseCode, UnifyReceiverContext};
2625
2726impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
2827 /// 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 @@
11//! Error Reporting for `impl` items that do not match the obligations from their `trait`.
22
3use crate::error_reporting::infer::nice_region_error::NiceRegionError;
4use crate::errors::{ConsiderBorrowingParamHelp, RelationshipHelp, TraitImplDiff};
5use crate::infer::RegionResolutionError;
6use crate::infer::{Subtype, ValuePairs};
73use rustc_errors::ErrorGuaranteed;
84use rustc_hir as hir;
95use rustc_hir::def::Res;
......@@ -16,6 +12,10 @@ use rustc_middle::ty::print::RegionHighlightMode;
1612use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitor};
1713use rustc_span::Span;
1814
15use crate::error_reporting::infer::nice_region_error::NiceRegionError;
16use crate::errors::{ConsiderBorrowingParamHelp, RelationshipHelp, TraitImplDiff};
17use crate::infer::{RegionResolutionError, Subtype, ValuePairs};
18
1919impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
2020 /// Print the error message for lifetime errors when the `impl` doesn't conform to the `trait`.
2121 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 @@
1use crate::error_reporting::infer::{note_and_explain_region, TypeErrCtxt};
2use crate::errors::{
3 note_and_explain, FulfillReqLifetime, LfBoundNotSatisfied, OutlivesBound, OutlivesContent,
4 RefLongerThanData, RegionOriginNote, WhereClauseSuggestions,
5};
6use crate::fluent_generated as fluent;
7use crate::infer::{self, SubregionOrigin};
81use rustc_errors::{Diag, Subdiagnostic};
92use rustc_hir::def_id::{DefId, LocalDefId};
103use rustc_middle::traits::ObligationCauseCode;
......@@ -13,6 +6,13 @@ use rustc_middle::ty::{self, IsSuggestable, Region, Ty};
136use rustc_span::symbol::kw;
147
158use super::ObligationCauseAsDiagArg;
9use crate::error_reporting::infer::{note_and_explain_region, TypeErrCtxt};
10use crate::errors::{
11 note_and_explain, FulfillReqLifetime, LfBoundNotSatisfied, OutlivesBound, OutlivesContent,
12 RefLongerThanData, RegionOriginNote, WhereClauseSuggestions,
13};
14use crate::fluent_generated as fluent;
15use crate::infer::{self, SubregionOrigin};
1616
1717impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
1818 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};
22use rustc_errors::{pluralize, Diag, MultiSpan};
33use rustc_hir as hir;
44use rustc_hir::def::DefKind;
5use rustc_middle::traits::ObligationCauseCode;
6use rustc_middle::ty::error::ExpectedFound;
7use rustc_middle::ty::print::Printer;
8use rustc_middle::{
9 traits::ObligationCause,
10 ty::{self, error::TypeError, print::FmtPrinter, suggest_constraining_type_param, Ty},
11};
12use rustc_span::{def_id::DefId, sym, BytePos, Span, Symbol};
5use rustc_middle::traits::{ObligationCause, ObligationCauseCode};
6use rustc_middle::ty::error::{ExpectedFound, TypeError};
7use rustc_middle::ty::print::{FmtPrinter, Printer};
8use rustc_middle::ty::{self, suggest_constraining_type_param, Ty};
9use rustc_span::def_id::DefId;
10use rustc_span::{sym, BytePos, Span, Symbol};
1311
1412use crate::error_reporting::TypeErrCtxt;
1513use crate::infer::InferCtxtExt;
compiler/rustc_trait_selection/src/error_reporting/infer/suggest.rs+3-3
......@@ -1,5 +1,5 @@
1use crate::error_reporting::infer::hir::Path;
21use core::ops::ControlFlow;
2
33use hir::def::CtorKind;
44use hir::intravisit::{walk_expr, walk_stmt, Visitor};
55use hir::{LetStmt, QPath};
......@@ -7,8 +7,7 @@ use rustc_data_structures::fx::FxIndexSet;
77use rustc_errors::{Applicability, Diag};
88use rustc_hir as hir;
99use rustc_hir::def::Res;
10use rustc_hir::MatchSource;
11use rustc_hir::Node;
10use rustc_hir::{MatchSource, Node};
1211use rustc_middle::traits::{
1312 IfExpressionCause, MatchExpressionArmCause, ObligationCause, ObligationCauseCode,
1413 StatementAsExpression,
......@@ -17,6 +16,7 @@ use rustc_middle::ty::print::with_no_trimmed_paths;
1716use rustc_middle::ty::{self as ty, GenericArgKind, IsSuggestable, Ty, TypeVisitableExt};
1817use rustc_span::{sym, Span};
1918
19use crate::error_reporting::infer::hir::Path;
2020use crate::error_reporting::TypeErrCtxt;
2121use crate::errors::{
2222 ConsiderAddingAwait, FnConsiderCasting, FnItemsAreDistinct, FnUniqTypes,
compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs+21-22
......@@ -1,31 +1,16 @@
1use super::on_unimplemented::{AppendConstMessage, OnUnimplementedNote};
2use super::suggestions::get_explanation_based_on_obligation;
3use crate::error_reporting::infer::TyCategory;
4use crate::error_reporting::traits::report_object_safety_error;
5use crate::error_reporting::TypeErrCtxt;
6use crate::errors::{
7 AsyncClosureNotFn, ClosureFnMutLabel, ClosureFnOnceLabel, ClosureKindMismatch,
8};
9use crate::infer::InferCtxtExt as _;
10use crate::infer::{self, InferCtxt};
11use crate::traits::query::evaluate_obligation::InferCtxtExt as _;
12use crate::traits::NormalizeExt;
13use crate::traits::{
14 elaborate, MismatchedProjectionTypes, Obligation, ObligationCause, ObligationCauseCode,
15 ObligationCtxt, Overflow, PredicateObligation, SelectionError, SignatureMismatch,
16 TraitNotObjectSafe,
17};
181use core::ops::ControlFlow;
2use std::borrow::Cow;
3
194use rustc_data_structures::fx::FxHashMap;
205use rustc_data_structures::unord::UnordSet;
216use rustc_errors::codes::*;
22use rustc_errors::{pluralize, struct_span_code_err, Applicability, StringPart};
23use rustc_errors::{Diag, ErrorGuaranteed, StashKey};
7use rustc_errors::{
8 pluralize, struct_span_code_err, Applicability, Diag, ErrorGuaranteed, StashKey, StringPart,
9};
2410use rustc_hir::def::Namespace;
2511use rustc_hir::def_id::{DefId, LocalDefId};
2612use rustc_hir::intravisit::Visitor;
27use rustc_hir::Node;
28use rustc_hir::{self as hir, LangItem};
13use rustc_hir::{self as hir, LangItem, Node};
2914use rustc_infer::infer::{InferOk, TypeTrace};
3015use rustc_middle::traits::select::OverflowError;
3116use rustc_middle::traits::SignatureMismatchData;
......@@ -42,11 +27,25 @@ use rustc_middle::ty::{
4227use rustc_middle::{bug, span_bug};
4328use rustc_span::symbol::sym;
4429use rustc_span::{BytePos, Span, Symbol, DUMMY_SP};
45use std::borrow::Cow;
4630
31use super::on_unimplemented::{AppendConstMessage, OnUnimplementedNote};
32use super::suggestions::get_explanation_based_on_obligation;
4733use super::{
4834 ArgKind, CandidateSimilarity, GetSafeTransmuteErrorAndReason, ImplCandidate, UnsatisfiedConst,
4935};
36use crate::error_reporting::infer::TyCategory;
37use crate::error_reporting::traits::report_object_safety_error;
38use crate::error_reporting::TypeErrCtxt;
39use crate::errors::{
40 AsyncClosureNotFn, ClosureFnMutLabel, ClosureFnOnceLabel, ClosureKindMismatch,
41};
42use crate::infer::{self, InferCtxt, InferCtxtExt as _};
43use crate::traits::query::evaluate_obligation::InferCtxtExt as _;
44use crate::traits::{
45 elaborate, MismatchedProjectionTypes, NormalizeExt, Obligation, ObligationCause,
46 ObligationCauseCode, ObligationCtxt, Overflow, PredicateObligation, SelectionError,
47 SignatureMismatch, TraitNotObjectSafe,
48};
5049
5150impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
5251 /// 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 _};
1919use rustc_middle::ty::{self, Ty, TyCtxt};
2020use rustc_span::{ErrorGuaranteed, ExpnKind, Span};
2121
22pub use self::overflow::*;
2223use crate::error_reporting::TypeErrCtxt;
2324use crate::traits::{FulfillmentError, FulfillmentErrorCode};
2425
25pub use self::overflow::*;
26
2726// When outputting impl candidates, prefer showing those that are more similar.
2827//
2928// 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 @@
1use super::{ObligationCauseCode, PredicateObligation};
2use crate::error_reporting::TypeErrCtxt;
3use crate::errors::{
4 EmptyOnClauseInOnUnimplemented, InvalidOnClauseInOnUnimplemented, NoValueInOnUnimplemented,
5};
6use crate::infer::InferCtxtExt;
7use rustc_ast::AttrArgs;
8use rustc_ast::AttrArgsEq;
9use rustc_ast::AttrKind;
10use rustc_ast::{Attribute, MetaItem, NestedMetaItem};
11use rustc_attr as attr;
1use std::iter;
2use std::path::PathBuf;
3
4use rustc_ast::{AttrArgs, AttrArgsEq, AttrKind, Attribute, MetaItem, NestedMetaItem};
125use rustc_data_structures::fx::FxHashMap;
13use rustc_errors::{codes::*, struct_span_code_err, ErrorGuaranteed};
14use rustc_hir as hir;
6use rustc_errors::codes::*;
7use rustc_errors::{struct_span_code_err, ErrorGuaranteed};
158use rustc_hir::def_id::{DefId, LocalDefId};
169use rustc_macros::LintDiagnostic;
1710use rustc_middle::bug;
1811use rustc_middle::ty::print::PrintTraitRefExt as _;
19use rustc_middle::ty::GenericArgsRef;
20use rustc_middle::ty::{self, GenericParamDefKind, TyCtxt};
12use rustc_middle::ty::{self, GenericArgsRef, GenericParamDefKind, TyCtxt};
2113use rustc_parse_format::{ParseMode, Parser, Piece, Position};
2214use rustc_session::lint::builtin::UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES;
2315use rustc_span::symbol::{kw, sym, Symbol};
2416use rustc_span::Span;
25use std::iter;
26use std::path::PathBuf;
17use {rustc_attr as attr, rustc_hir as hir};
18
19use super::{ObligationCauseCode, PredicateObligation};
20use crate::error_reporting::TypeErrCtxt;
21use crate::errors::{
22 EmptyOnClauseInOnUnimplemented, InvalidOnClauseInOnUnimplemented, NoValueInOnUnimplemented,
23};
24use crate::infer::InferCtxtExt;
2725
2826/// The symbols which are always allowed in a format string
2927static ALLOWED_FORMAT_SYMBOLS: &[Symbol] = &[
compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs+23-27
......@@ -1,34 +1,33 @@
11// ignore-tidy-filelength
22
3use super::{
4 DefIdOrName, FindExprBySpan, ImplCandidate, Obligation, ObligationCause, ObligationCauseCode,
5 PredicateObligation,
6};
7
8use crate::error_reporting::TypeErrCtxt;
9use crate::errors;
10use crate::traits::{ImplDerivedCause, NormalizeExt, ObligationCtxt};
3use std::assert_matches::debug_assert_matches;
4use std::borrow::Cow;
5use std::iter;
116
7use itertools::{EitherOrBoth, Itertools};
128use rustc_data_structures::fx::FxHashSet;
139use rustc_data_structures::stack::ensure_sufficient_stack;
10use rustc_errors::codes::*;
1411use 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,
1714};
1815use rustc_hir as hir;
19use rustc_hir::def::CtorOf;
20use rustc_hir::def::{DefKind, Res};
16use rustc_hir::def::{CtorOf, DefKind, Res};
2117use rustc_hir::def_id::DefId;
2218use rustc_hir::intravisit::Visitor;
23use rustc_hir::is_range_literal;
2419use rustc_hir::lang_items::LangItem;
25use rustc_hir::{CoroutineDesugaring, CoroutineKind, CoroutineSource, Expr, HirId, Node};
26use rustc_infer::infer::InferCtxt;
27use rustc_infer::infer::{BoundRegionConversionTime, DefineOpaqueTypes, InferOk};
20use rustc_hir::{
21 is_range_literal, CoroutineDesugaring, CoroutineKind, CoroutineSource, Expr, HirId, Node,
22};
23use rustc_infer::infer::{BoundRegionConversionTime, DefineOpaqueTypes, InferCtxt, InferOk};
2824use rustc_middle::hir::map;
2925use rustc_middle::traits::IsConstable;
3026use rustc_middle::ty::error::TypeError;
31use rustc_middle::ty::print::PrintPolyTraitRefExt;
27use rustc_middle::ty::print::{
28 with_forced_trimmed_paths, with_no_trimmed_paths, PrintPolyTraitPredicateExt as _,
29 PrintPolyTraitRefExt, PrintTraitPredicateExt as _,
30};
3231use rustc_middle::ty::{
3332 self, suggest_arbitrary_trait_bound, suggest_constraining_type_param, AdtKind, GenericArgs,
3433 InferTy, IsSuggestable, ToPolyTraitRef, Ty, TyCtxt, TypeFoldable, TypeFolder,
......@@ -39,19 +38,16 @@ use rustc_span::def_id::LocalDefId;
3938use rustc_span::symbol::{kw, sym, Ident, Symbol};
4039use rustc_span::{BytePos, DesugaringKind, ExpnKind, MacroKind, Span, DUMMY_SP};
4140use rustc_target::spec::abi;
42use std::assert_matches::debug_assert_matches;
43use std::borrow::Cow;
44use std::iter;
4541
42use super::{
43 DefIdOrName, FindExprBySpan, ImplCandidate, Obligation, ObligationCause, ObligationCauseCode,
44 PredicateObligation,
45};
46use crate::error_reporting::TypeErrCtxt;
47use crate::errors;
4648use crate::infer::InferCtxtExt as _;
4749use crate::traits::query::evaluate_obligation::InferCtxtExt as _;
48use rustc_middle::ty::print::{
49 with_forced_trimmed_paths, with_no_trimmed_paths, PrintPolyTraitPredicateExt as _,
50 PrintTraitPredicateExt as _,
51};
52
53use itertools::EitherOrBoth;
54use itertools::Itertools;
50use crate::traits::{ImplDerivedCause, NormalizeExt, ObligationCtxt};
5551
5652#[derive(Debug)]
5753pub enum CoroutineInteriorOrUpvar {
compiler/rustc_trait_selection/src/errors.rs+7-10
......@@ -1,19 +1,18 @@
1use std::path::PathBuf;
2
13use rustc_data_structures::fx::FxHashSet;
4use rustc_errors::codes::*;
25use rustc_errors::{
3 codes::*, Applicability, Diag, DiagCtxtHandle, DiagMessage, DiagStyledString, Diagnostic,
6 Applicability, Diag, DiagCtxtHandle, DiagMessage, DiagStyledString, Diagnostic,
47 EmissionGuarantee, IntoDiagArg, Level, MultiSpan, SubdiagMessageOp, Subdiagnostic,
58};
69use rustc_hir as hir;
710use rustc_hir::def_id::LocalDefId;
811use rustc_hir::intravisit::{walk_ty, Visitor};
9use rustc_hir::FnRetTy;
10use rustc_hir::GenericParamKind;
12use rustc_hir::{FnRetTy, GenericParamKind};
1113use rustc_macros::{Diagnostic, Subdiagnostic};
12use rustc_middle::ty::print::TraitRefPrintOnlyTraitPath;
13use rustc_middle::ty::{
14 self, print::PrintTraitRefExt as _, Binder, ClosureKind, FnSig, PolyTraitRef, Region, Ty,
15 TyCtxt,
16};
14use rustc_middle::ty::print::{PrintTraitRefExt as _, TraitRefPrintOnlyTraitPath};
15use rustc_middle::ty::{self, Binder, ClosureKind, FnSig, PolyTraitRef, Region, Ty, TyCtxt};
1716use rustc_span::symbol::{kw, Ident, Symbol};
1817use rustc_span::{BytePos, Span};
1918
......@@ -22,8 +21,6 @@ use crate::error_reporting::infer::nice_region_error::placeholder_error::Highlig
2221use crate::error_reporting::infer::ObligationCauseAsDiagArg;
2322use crate::fluent_generated as fluent;
2423
25use std::path::PathBuf;
26
2724pub mod note_and_explain;
2825
2926#[derive(Diagnostic)]
compiler/rustc_trait_selection/src/errors/note_and_explain.rs+5-3
......@@ -1,10 +1,12 @@
1use crate::error_reporting::infer::nice_region_error::find_anon_type;
2use crate::fluent_generated as fluent;
31use rustc_errors::{Diag, EmissionGuarantee, IntoDiagArg, SubdiagMessageOp, Subdiagnostic};
42use rustc_hir::def_id::LocalDefId;
53use rustc_middle::bug;
64use rustc_middle::ty::{self, TyCtxt};
7use rustc_span::{symbol::kw, Span};
5use rustc_span::symbol::kw;
6use rustc_span::Span;
7
8use crate::error_reporting::infer::nice_region_error::find_anon_type;
9use crate::fluent_generated as fluent;
810
911struct DescriptionCtx<'a> {
1012 span: Option<Span>,
compiler/rustc_trait_selection/src/infer.rs+6-8
......@@ -1,20 +1,18 @@
1use crate::infer::at::ToTrace;
2use crate::traits::query::evaluate_obligation::InferCtxtExt as _;
3use crate::traits::{self, Obligation, ObligationCause, ObligationCtxt, SelectionContext};
1use std::fmt::Debug;
42
53use rustc_hir::def_id::DefId;
64use rustc_hir::lang_items::LangItem;
5pub use rustc_infer::infer::*;
76use rustc_macros::extension;
87use rustc_middle::arena::ArenaAllocatable;
98use rustc_middle::infer::canonical::{Canonical, CanonicalQueryResponse, QueryResponse};
109use rustc_middle::traits::query::NoSolution;
11use rustc_middle::ty::{self, Ty, TyCtxt, TypeFoldable, TypeVisitableExt};
12use rustc_middle::ty::{GenericArg, Upcast};
10use rustc_middle::ty::{self, GenericArg, Ty, TyCtxt, TypeFoldable, TypeVisitableExt, Upcast};
1311use rustc_span::DUMMY_SP;
1412
15use std::fmt::Debug;
16
17pub use rustc_infer::infer::*;
13use crate::infer::at::ToTrace;
14use crate::traits::query::evaluate_obligation::InferCtxtExt as _;
15use crate::traits::{self, Obligation, ObligationCause, ObligationCtxt, SelectionContext};
1816
1917#[extension(pub trait InferCtxtExt<'tcx>)]
2018impl<'tcx> InferCtxt<'tcx> {
compiler/rustc_trait_selection/src/regions.rs+2-1
......@@ -1,10 +1,11 @@
1use crate::traits::ScrubbedTraitError;
21use rustc_infer::infer::outlives::env::OutlivesEnvironment;
32use rustc_infer::infer::{InferCtxt, RegionResolutionError};
43use rustc_macros::extension;
54use rustc_middle::traits::query::NoSolution;
65use rustc_middle::traits::ObligationCause;
76
7use crate::traits::ScrubbedTraitError;
8
89#[extension(pub trait InferCtxtRegionExt<'tcx>)]
910impl<'tcx> InferCtxt<'tcx> {
1011 /// 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};
1515use rustc_next_trait_solver::solve::{GenerateProofTree, SolverDelegateEvalExt as _};
1616use rustc_span::symbol::sym;
1717
18use crate::traits::{FulfillmentError, FulfillmentErrorCode, ScrubbedTraitError};
19
2018use super::delegate::SolverDelegate;
2119use super::inspect::{self, ProofTreeInferCtxtExt, ProofTreeVisitor};
2220use super::Certainty;
21use crate::traits::{FulfillmentError, FulfillmentErrorCode, ScrubbedTraitError};
2322
2423/// A trait engine using the new trait solver.
2524///
compiler/rustc_trait_selection/src/solve/normalize.rs+8-7
......@@ -1,20 +1,21 @@
11use std::fmt::Debug;
22use std::marker::PhantomData;
33
4use crate::error_reporting::traits::OverflowCause;
5use crate::error_reporting::InferCtxtErrorExt;
6use crate::traits::query::evaluate_obligation::InferCtxtExt;
7use crate::traits::{BoundVarReplacer, PlaceholderReplacer, ScrubbedTraitError};
84use rustc_data_structures::stack::ensure_sufficient_stack;
95use rustc_infer::infer::at::At;
106use rustc_infer::infer::InferCtxt;
117use rustc_infer::traits::{FromSolverError, Obligation, TraitEngine};
128use rustc_middle::traits::ObligationCause;
13use rustc_middle::ty::{self, Ty, TyCtxt, UniverseIndex};
14use rustc_middle::ty::{FallibleTypeFolder, TypeFolder, TypeSuperFoldable};
15use rustc_middle::ty::{TypeFoldable, TypeVisitableExt};
9use rustc_middle::ty::{
10 self, FallibleTypeFolder, Ty, TyCtxt, TypeFoldable, TypeFolder, TypeSuperFoldable,
11 TypeVisitableExt, UniverseIndex,
12};
1613
1714use super::{FulfillmentCtxt, NextSolverError};
15use crate::error_reporting::traits::OverflowCause;
16use crate::error_reporting::InferCtxtErrorExt;
17use crate::traits::query::evaluate_obligation::InferCtxtExt;
18use crate::traits::{BoundVarReplacer, PlaceholderReplacer, ScrubbedTraitError};
1819
1920/// Deeply normalize all aliases in `value`. This does not handle inference and expects
2021/// its input to be already fully resolved.
compiler/rustc_trait_selection/src/traits/auto_trait.rs+6-7
......@@ -1,11 +1,8 @@
11//! Support code for rustdoc and external tools.
22//! You really don't want to be using this unless you need to.
33
4use super::*;
5
6use crate::errors::UnableToConstructConstantValue;
7use crate::infer::region_constraints::{Constraint, RegionConstraintData};
8use crate::traits::project::ProjectAndUnifyResult;
4use std::collections::VecDeque;
5use std::iter;
96
107use rustc_data_structures::fx::{FxIndexMap, FxIndexSet, IndexEntry};
118use rustc_data_structures::unord::UnordSet;
......@@ -13,8 +10,10 @@ use rustc_infer::infer::DefineOpaqueTypes;
1310use rustc_middle::mir::interpret::ErrorHandled;
1411use rustc_middle::ty::{Region, RegionVid};
1512
16use std::collections::VecDeque;
17use std::iter;
13use super::*;
14use crate::errors::UnableToConstructConstantValue;
15use crate::infer::region_constraints::{Constraint, RegionConstraintData};
16use crate::traits::project::ProjectAndUnifyResult;
1817
1918// FIXME(twk): this is obviously not nice to duplicate like that
2019#[derive(Eq, PartialEq, Hash, Copy, Clone, Debug)]
compiler/rustc_trait_selection/src/traits/coherence.rs+11-10
......@@ -4,15 +4,8 @@
44//! [trait-resolution]: https://rustc-dev-guide.rust-lang.org/traits/resolution.html
55//! [trait-specialization]: https://rustc-dev-guide.rust-lang.org/traits/specialization.html
66
7use crate::infer::outlives::env::OutlivesEnvironment;
8use crate::infer::InferOk;
9use crate::solve::inspect::{InspectGoal, ProofTreeInferCtxtExt, ProofTreeVisitor};
10use crate::solve::{deeply_normalize_for_diagnostics, inspect};
11use crate::traits::select::IntercrateAmbiguityCause;
12use crate::traits::NormalizeExt;
13use crate::traits::SkipLeakCheck;
14use crate::traits::{util, FulfillmentErrorCode};
15use crate::traits::{Obligation, ObligationCause, PredicateObligation, SelectionContext};
7use std::fmt::Debug;
8
169use rustc_data_structures::fx::FxIndexSet;
1710use rustc_errors::{Diag, EmissionGuarantee};
1811use rustc_hir::def::DefKind;
......@@ -28,10 +21,18 @@ use rustc_middle::ty::{self, Ty, TyCtxt};
2821pub use rustc_next_trait_solver::coherence::*;
2922use rustc_span::symbol::sym;
3023use rustc_span::{Span, DUMMY_SP};
31use std::fmt::Debug;
3224
3325use super::ObligationCtxt;
3426use crate::error_reporting::traits::suggest_new_overflow_limit;
27use crate::infer::outlives::env::OutlivesEnvironment;
28use crate::infer::InferOk;
29use crate::solve::inspect::{InspectGoal, ProofTreeInferCtxtExt, ProofTreeVisitor};
30use crate::solve::{deeply_normalize_for_diagnostics, inspect};
31use crate::traits::select::IntercrateAmbiguityCause;
32use crate::traits::{
33 util, FulfillmentErrorCode, NormalizeExt, Obligation, ObligationCause, PredicateObligation,
34 SelectionContext, SkipLeakCheck,
35};
3536
3637pub struct OverlapResult<'tcx> {
3738 pub impl_header: ty::ImplHeader<'tcx>,
compiler/rustc_trait_selection/src/traits/engine.rs+12-16
......@@ -1,16 +1,6 @@
11use std::cell::RefCell;
22use std::fmt::Debug;
33
4use super::{FromSolverError, TraitEngine};
5use super::{FulfillmentContext, ScrubbedTraitError};
6use crate::error_reporting::InferCtxtErrorExt;
7use crate::regions::InferCtxtRegionExt;
8use crate::solve::FulfillmentCtxt as NextFulfillmentCtxt;
9use crate::solve::NextSolverError;
10use crate::traits::fulfill::OldSolverError;
11use crate::traits::NormalizeExt;
12use crate::traits::StructurallyNormalizeExt;
13use crate::traits::{FulfillmentError, Obligation, ObligationCause, PredicateObligation};
144use rustc_data_structures::fx::FxIndexSet;
155use rustc_errors::ErrorGuaranteed;
166use rustc_hir::def_id::{DefId, LocalDefId};
......@@ -19,16 +9,22 @@ use rustc_infer::infer::canonical::{
199 Canonical, CanonicalQueryResponse, CanonicalVarValues, QueryResponse,
2010};
2111use rustc_infer::infer::outlives::env::OutlivesEnvironment;
22use rustc_infer::infer::RegionResolutionError;
23use rustc_infer::infer::{DefineOpaqueTypes, InferCtxt, InferOk};
12use rustc_infer::infer::{DefineOpaqueTypes, InferCtxt, InferOk, RegionResolutionError};
2413use rustc_macros::extension;
2514use rustc_middle::arena::ArenaAllocatable;
2615use rustc_middle::traits::query::NoSolution;
2716use rustc_middle::ty::error::TypeError;
28use rustc_middle::ty::TypeFoldable;
29use rustc_middle::ty::Upcast;
30use rustc_middle::ty::Variance;
31use rustc_middle::ty::{self, Ty, TyCtxt};
17use rustc_middle::ty::{self, Ty, TyCtxt, TypeFoldable, Upcast, Variance};
18
19use super::{FromSolverError, FulfillmentContext, ScrubbedTraitError, TraitEngine};
20use crate::error_reporting::InferCtxtErrorExt;
21use crate::regions::InferCtxtRegionExt;
22use crate::solve::{FulfillmentCtxt as NextFulfillmentCtxt, NextSolverError};
23use crate::traits::fulfill::OldSolverError;
24use crate::traits::{
25 FulfillmentError, NormalizeExt, Obligation, ObligationCause, PredicateObligation,
26 StructurallyNormalizeExt,
27};
3228
3329#[extension(pub trait TraitEngineExt<'tcx, E>)]
3430impl<'tcx, E> dyn TraitEngine<'tcx, E>
compiler/rustc_trait_selection/src/traits/fulfill.rs+16-19
......@@ -1,32 +1,29 @@
1use crate::infer::{InferCtxt, TyOrConstInferVar};
2use crate::traits::normalize::normalize_with_depth_to;
1use std::marker::PhantomData;
2
33use rustc_data_structures::captures::Captures;
4use rustc_data_structures::obligation_forest::ProcessResult;
5use rustc_data_structures::obligation_forest::{Error, ForestObligation, Outcome};
6use rustc_data_structures::obligation_forest::{ObligationForest, ObligationProcessor};
4use rustc_data_structures::obligation_forest::{
5 Error, ForestObligation, ObligationForest, ObligationProcessor, Outcome, ProcessResult,
6};
77use rustc_infer::infer::DefineOpaqueTypes;
8use rustc_infer::traits::{FromSolverError, ProjectionCacheKey};
9use rustc_infer::traits::{PolyTraitObligation, SelectionError, TraitEngine};
8use rustc_infer::traits::{
9 FromSolverError, PolyTraitObligation, ProjectionCacheKey, SelectionError, TraitEngine,
10};
1011use rustc_middle::bug;
1112use rustc_middle::mir::interpret::ErrorHandled;
1213use rustc_middle::ty::abstract_const::NotConstEvaluatable;
1314use rustc_middle::ty::error::{ExpectedFound, TypeError};
14use rustc_middle::ty::GenericArgsRef;
15use rustc_middle::ty::{self, Binder, Const, TypeVisitableExt};
16use std::marker::PhantomData;
15use rustc_middle::ty::{self, Binder, Const, GenericArgsRef, TypeVisitableExt};
1716
1817use super::project::{self, ProjectAndUnifyResult};
1918use super::select::SelectionContext;
20use super::wf;
21use super::EvaluationResult;
22use super::PredicateObligation;
23use super::Unimplemented;
24use super::{const_evaluatable, ScrubbedTraitError};
25use super::{FulfillmentError, FulfillmentErrorCode};
26
19use super::{
20 const_evaluatable, wf, EvaluationResult, FulfillmentError, FulfillmentErrorCode,
21 PredicateObligation, ScrubbedTraitError, Unimplemented,
22};
2723use crate::error_reporting::InferCtxtErrorExt;
28use crate::traits::project::PolyProjectionObligation;
29use crate::traits::project::ProjectionCacheKeyExt as _;
24use crate::infer::{InferCtxt, TyOrConstInferVar};
25use crate::traits::normalize::normalize_with_depth_to;
26use crate::traits::project::{PolyProjectionObligation, ProjectionCacheKeyExt as _};
3027use crate::traits::query::evaluate_obligation::InferCtxtExt;
3128
3229impl<'tcx> ForestObligation for PendingPredicateObligation<'tcx> {
compiler/rustc_trait_selection/src/traits/misc.rs+2-3
......@@ -1,8 +1,5 @@
11//! Miscellaneous type-system utilities that are too small to deserve their own modules.
22
3use crate::regions::InferCtxtRegionExt;
4use crate::traits::{self, FulfillmentError, ObligationCause};
5
63use hir::LangItem;
74use rustc_ast::Mutability;
85use rustc_data_structures::fx::FxIndexSet;
......@@ -12,6 +9,8 @@ use rustc_infer::infer::{RegionResolutionError, TyCtxtInferExt};
129use rustc_middle::ty::{self, AdtDef, Ty, TyCtxt, TypeVisitableExt};
1310
1411use super::outlives_bounds::InferCtxtExt;
12use crate::regions::InferCtxtRegionExt;
13use crate::traits::{self, FulfillmentError, ObligationCause};
1514
1615pub enum CopyImplementationError<'tcx> {
1716 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;
2222pub mod vtable;
2323pub mod wf;
2424
25use crate::error_reporting::InferCtxtErrorExt;
26use crate::infer::outlives::env::OutlivesEnvironment;
27use crate::infer::{InferCtxt, TyCtxtInferExt};
28use crate::regions::InferCtxtRegionExt;
29use crate::traits::query::evaluate_obligation::InferCtxtExt as _;
25use std::fmt::Debug;
26use std::ops::ControlFlow;
27
3028use rustc_errors::ErrorGuaranteed;
29pub use rustc_infer::traits::*;
3130use rustc_middle::query::Providers;
3231use rustc_middle::span_bug;
3332use rustc_middle::ty::error::{ExpectedFound, TypeError};
3433use rustc_middle::ty::fold::TypeFoldable;
3534use rustc_middle::ty::visit::{TypeVisitable, TypeVisitableExt};
36use rustc_middle::ty::{self, Ty, TyCtxt, TypeFolder, TypeSuperVisitable, Upcast};
37use rustc_middle::ty::{GenericArgs, GenericArgsRef};
35use rustc_middle::ty::{
36 self, GenericArgs, GenericArgsRef, Ty, TyCtxt, TypeFolder, TypeSuperVisitable, Upcast,
37};
3838use rustc_span::def_id::DefId;
3939use rustc_span::Span;
4040
41use std::fmt::Debug;
42use std::ops::ControlFlow;
43
44pub use self::coherence::{add_placeholder_note, orphan_check_trait_ref, overlapping_impls};
45pub use self::coherence::{InCrate, IsFirstInputType, UncoveredTyParams};
46pub use self::coherence::{OrphanCheckErr, OrphanCheckMode, OverlapResult};
41pub use self::coherence::{
42 add_placeholder_note, orphan_check_trait_ref, overlapping_impls, InCrate, IsFirstInputType,
43 OrphanCheckErr, OrphanCheckMode, OverlapResult, UncoveredTyParams,
44};
4745pub use self::engine::{ObligationCtxt, TraitEngineExt};
4846pub use self::fulfill::{FulfillmentContext, OldSolverError, PendingPredicateObligation};
4947pub use self::normalize::NormalizeExt;
50pub use self::object_safety::hir_ty_lowering_object_safety_violations;
51pub use self::object_safety::is_vtable_safe_method;
52pub use self::object_safety::object_safety_violations_for_assoc_item;
53pub use self::object_safety::ObjectSafetyViolation;
48pub use self::object_safety::{
49 hir_ty_lowering_object_safety_violations, is_vtable_safe_method,
50 object_safety_violations_for_assoc_item, ObjectSafetyViolation,
51};
5452pub use self::project::{normalize_inherent_projection, normalize_projection_ty};
55pub use self::select::{EvaluationCache, SelectionCache, SelectionContext};
56pub use self::select::{EvaluationResult, IntercrateAmbiguityCause, OverflowError};
57pub use self::specialize::specialization_graph::FutureCompatOverlapError;
58pub use self::specialize::specialization_graph::FutureCompatOverlapErrorKind;
53pub use self::select::{
54 EvaluationCache, EvaluationResult, IntercrateAmbiguityCause, OverflowError, SelectionCache,
55 SelectionContext,
56};
57pub use self::specialize::specialization_graph::{
58 FutureCompatOverlapError, FutureCompatOverlapErrorKind,
59};
5960pub use self::specialize::{
6061 specialization_graph, translate_args, translate_args_with_cause, OverlapError,
6162};
6263pub use self::structural_normalize::StructurallyNormalizeExt;
63pub use self::util::elaborate;
64pub use self::util::{expand_trait_aliases, TraitAliasExpander, TraitAliasExpansionInfo};
65pub use self::util::{impl_item_is_final, upcast_choices};
66pub use self::util::{supertraits, transitive_bounds, transitive_bounds_that_define_assoc_item};
67pub use self::util::{with_replaced_escaping_bound_vars, BoundVarReplacer, PlaceholderReplacer};
68
69pub use rustc_infer::traits::*;
64pub 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};
69use crate::error_reporting::InferCtxtErrorExt;
70use crate::infer::outlives::env::OutlivesEnvironment;
71use crate::infer::{InferCtxt, TyCtxtInferExt};
72use crate::regions::InferCtxtRegionExt;
73use crate::traits::query::evaluate_obligation::InferCtxtExt as _;
7074
7175pub struct FulfillmentError<'tcx> {
7276 pub obligation: PredicateObligation<'tcx>,
compiler/rustc_trait_selection/src/traits/normalize.rs+14-10
......@@ -1,20 +1,24 @@
11//! Deeply normalize types using the old trait solver.
22
3use super::SelectionContext;
4use super::{project, with_replaced_escaping_bound_vars, BoundVarReplacer, PlaceholderReplacer};
5use crate::error_reporting::traits::OverflowCause;
6use crate::error_reporting::InferCtxtErrorExt;
7use crate::solve::NextSolverError;
83use rustc_data_structures::stack::ensure_sufficient_stack;
94use rustc_infer::infer::at::At;
105use rustc_infer::infer::InferOk;
11use rustc_infer::traits::FromSolverError;
12use rustc_infer::traits::PredicateObligation;
13use rustc_infer::traits::{Normalized, Obligation, TraitEngine};
6use rustc_infer::traits::{
7 FromSolverError, Normalized, Obligation, PredicateObligation, TraitEngine,
8};
149use rustc_macros::extension;
1510use rustc_middle::traits::{ObligationCause, ObligationCauseCode, Reveal};
16use rustc_middle::ty::{self, Ty, TyCtxt, TypeFolder};
17use rustc_middle::ty::{TypeFoldable, TypeSuperFoldable, TypeVisitable, TypeVisitableExt};
11use rustc_middle::ty::{
12 self, Ty, TyCtxt, TypeFoldable, TypeFolder, TypeSuperFoldable, TypeVisitable, TypeVisitableExt,
13};
14
15use super::{
16 project, with_replaced_escaping_bound_vars, BoundVarReplacer, PlaceholderReplacer,
17 SelectionContext,
18};
19use crate::error_reporting::traits::OverflowCause;
20use crate::error_reporting::InferCtxtErrorExt;
21use crate::solve::NextSolverError;
1822
1923#[extension(pub trait NormalizeExt<'tcx>)]
2024impl<'tcx> At<'_, 'tcx> {
compiler/rustc_trait_selection/src/traits/object_safety.rs+6-7
......@@ -8,11 +8,9 @@
88//! - not reference the erased type `Self` except for in this receiver;
99//! - not have generic type parameters.
1010
11use super::elaborate;
11use std::iter;
12use std::ops::ControlFlow;
1213
13use crate::infer::TyCtxtInferExt;
14use crate::traits::query::evaluate_obligation::InferCtxtExt;
15use crate::traits::{util, Obligation, ObligationCause};
1614use rustc_errors::FatalError;
1715use rustc_hir as hir;
1816use rustc_hir::def_id::DefId;
......@@ -27,9 +25,10 @@ use rustc_span::Span;
2725use rustc_target::abi::Abi;
2826use smallvec::SmallVec;
2927
30use std::iter;
31use std::ops::ControlFlow;
32
28use super::elaborate;
29use crate::infer::TyCtxtInferExt;
30use crate::traits::query::evaluate_obligation::InferCtxtExt;
31use crate::traits::{util, Obligation, ObligationCause};
3332pub use crate::traits::{MethodViolationCode, ObjectSafetyViolation};
3433
3534/// 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 @@
1use crate::infer::InferCtxt;
2use crate::traits::{ObligationCause, ObligationCtxt};
31use rustc_data_structures::fx::FxIndexSet;
42use rustc_infer::infer::resolve::OpportunisticRegionResolver;
53use rustc_infer::infer::InferOk;
64use rustc_macros::extension;
75use rustc_middle::infer::canonical::{OriginalQueryValues, QueryRegionConstraints};
86use rustc_middle::span_bug;
7pub use rustc_middle::traits::query::OutlivesBound;
98use rustc_middle::ty::{self, ParamEnv, Ty, TypeFolder, TypeVisitableExt};
109use rustc_span::def_id::LocalDefId;
1110
12pub use rustc_middle::traits::query::OutlivesBound;
11use crate::infer::InferCtxt;
12use crate::traits::{ObligationCause, ObligationCtxt};
1313
1414pub type BoundsCompat<'a, 'tcx: 'a> = impl Iterator<Item = OutlivesBound<'tcx>> + 'a;
1515pub 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 @@
22
33use std::ops::ControlFlow;
44
5use super::specialization_graph;
6use super::translate_args;
7use super::util;
8use super::MismatchedProjectionTypes;
9use super::Obligation;
10use super::ObligationCause;
11use super::PredicateObligation;
12use super::Selection;
13use super::SelectionContext;
14use super::SelectionError;
15use super::{Normalized, NormalizedTerm, ProjectionCacheEntry, ProjectionCacheKey};
16use rustc_infer::traits::ObligationCauseCode;
17use rustc_middle::traits::BuiltinImplSource;
18use rustc_middle::traits::ImplSource;
19use rustc_middle::traits::ImplSourceUserDefinedData;
20use rustc_middle::{bug, span_bug};
21
22use crate::errors::InherentProjectionNormalizationOverflow;
23use crate::infer::{BoundRegionConversionTime, InferOk};
24use crate::traits::normalize::normalize_with_depth;
25use crate::traits::normalize::normalize_with_depth_to;
26use crate::traits::query::evaluate_obligation::InferCtxtExt as _;
27use crate::traits::select::ProjectionMatchesProjection;
285use rustc_data_structures::sso::SsoHashSet;
296use rustc_data_structures::stack::ensure_sufficient_stack;
307use rustc_errors::ErrorGuaranteed;
......@@ -32,13 +9,26 @@ use rustc_hir::def::DefKind;
329use rustc_hir::lang_items::LangItem;
3310use rustc_infer::infer::resolve::OpportunisticRegionResolver;
3411use rustc_infer::infer::DefineOpaqueTypes;
12use rustc_infer::traits::ObligationCauseCode;
3513use rustc_middle::traits::select::OverflowError;
14pub use rustc_middle::traits::Reveal;
15use rustc_middle::traits::{BuiltinImplSource, ImplSource, ImplSourceUserDefinedData};
3616use rustc_middle::ty::fold::TypeFoldable;
3717use rustc_middle::ty::visit::{MaxUniverse, TypeVisitable, TypeVisitableExt};
3818use rustc_middle::ty::{self, Term, Ty, TyCtxt, Upcast};
19use rustc_middle::{bug, span_bug};
3920use rustc_span::symbol::sym;
4021
41pub use rustc_middle::traits::Reveal;
22use super::{
23 specialization_graph, translate_args, util, MismatchedProjectionTypes, Normalized,
24 NormalizedTerm, Obligation, ObligationCause, PredicateObligation, ProjectionCacheEntry,
25 ProjectionCacheKey, Selection, SelectionContext, SelectionError,
26};
27use crate::errors::InherentProjectionNormalizationOverflow;
28use crate::infer::{BoundRegionConversionTime, InferOk};
29use crate::traits::normalize::{normalize_with_depth, normalize_with_depth_to};
30use crate::traits::query::evaluate_obligation::InferCtxtExt as _;
31use crate::traits::select::ProjectionMatchesProjection;
4232
4333pub type PolyProjectionObligation<'tcx> = Obligation<'tcx, ty::PolyProjectionPredicate<'tcx>>;
4434
compiler/rustc_trait_selection/src/traits/query/dropck_outlives.rs+4-4
......@@ -1,12 +1,12 @@
1use crate::traits::query::normalize::QueryNormalizeExt;
2use crate::traits::query::NoSolution;
3use crate::traits::{Normalized, ObligationCause, ObligationCtxt};
4
51use rustc_data_structures::fx::FxHashSet;
62use rustc_middle::traits::query::{DropckConstraint, DropckOutlivesResult};
73use rustc_middle::ty::{self, EarlyBinder, ParamEnvAnd, Ty, TyCtxt};
84use rustc_span::{Span, DUMMY_SP};
95
6use crate::traits::query::normalize::QueryNormalizeExt;
7use crate::traits::query::NoSolution;
8use crate::traits::{Normalized, ObligationCause, ObligationCtxt};
9
1010/// This returns true if the type `ty` is "trivial" for
1111/// dropck-outlives -- that is, if it doesn't require any types to
1212/// 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 @@
22//! which folds deeply, invoking the underlying
33//! `normalize_canonicalized_projection_ty` query when it encounters projections.
44
5use crate::error_reporting::traits::OverflowCause;
6use crate::error_reporting::InferCtxtErrorExt;
7use crate::infer::at::At;
8use crate::infer::canonical::OriginalQueryValues;
9use crate::infer::{InferCtxt, InferOk};
10use crate::traits::normalize::needs_normalization;
11use crate::traits::Normalized;
12use crate::traits::{BoundVarReplacer, PlaceholderReplacer, ScrubbedTraitError};
13use crate::traits::{ObligationCause, PredicateObligation, Reveal};
145use rustc_data_structures::sso::SsoHashMap;
156use rustc_data_structures::stack::ensure_sufficient_stack;
167use rustc_macros::extension;
8pub use rustc_middle::traits::query::NormalizationResult;
179use rustc_middle::ty::fold::{FallibleTypeFolder, TypeFoldable, TypeSuperFoldable};
1810use rustc_middle::ty::visit::{TypeSuperVisitable, TypeVisitable, TypeVisitableExt};
1911use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitor};
2012use rustc_span::DUMMY_SP;
2113
2214use super::NoSolution;
23
24pub use rustc_middle::traits::query::NormalizationResult;
15use crate::error_reporting::traits::OverflowCause;
16use crate::error_reporting::InferCtxtErrorExt;
17use crate::infer::at::At;
18use crate::infer::canonical::OriginalQueryValues;
19use crate::infer::{InferCtxt, InferOk};
20use crate::traits::normalize::needs_normalization;
21use crate::traits::{
22 BoundVarReplacer, Normalized, ObligationCause, PlaceholderReplacer, PredicateObligation,
23 Reveal, ScrubbedTraitError,
24};
2525
2626#[extension(pub trait QueryNormalizeExt<'tcx>)]
2727impl<'cx, 'tcx> At<'cx, 'tcx> {
compiler/rustc_trait_selection/src/traits/query/type_op/ascribe_user_type.rs+4-4
......@@ -1,14 +1,14 @@
1use crate::infer::canonical::{Canonical, CanonicalQueryResponse};
2use crate::traits::ObligationCtxt;
31use rustc_hir::def_id::{DefId, CRATE_DEF_ID};
42use rustc_infer::traits::Obligation;
3pub use rustc_middle::traits::query::type_op::AscribeUserType;
54use rustc_middle::traits::query::NoSolution;
65use rustc_middle::traits::{ObligationCause, ObligationCauseCode};
76use rustc_middle::ty::{self, ParamEnvAnd, Ty, TyCtxt, UserArgs, UserSelfTy, UserType};
8
9pub use rustc_middle::traits::query::type_op::AscribeUserType;
107use rustc_span::{Span, DUMMY_SP};
118
9use crate::infer::canonical::{Canonical, CanonicalQueryResponse};
10use crate::traits::ObligationCtxt;
11
1212impl<'tcx> super::QueryTypeOp<'tcx> for AscribeUserType<'tcx> {
1313 type QueryResponse = ();
1414
compiler/rustc_trait_selection/src/traits/query/type_op/custom.rs+6-5
......@@ -1,14 +1,15 @@
1use crate::infer::canonical::query_response;
2use crate::infer::InferCtxt;
3use crate::traits::query::type_op::TypeOpOutput;
4use crate::traits::ObligationCtxt;
1use std::fmt;
2
53use rustc_errors::ErrorGuaranteed;
64use rustc_infer::infer::region_constraints::RegionConstraintData;
75use rustc_middle::traits::query::NoSolution;
86use rustc_middle::ty::{TyCtxt, TypeFoldable};
97use rustc_span::Span;
108
11use std::fmt;
9use crate::infer::canonical::query_response;
10use crate::infer::InferCtxt;
11use crate::traits::query::type_op::TypeOpOutput;
12use crate::traits::ObligationCtxt;
1213
1314pub struct CustomTypeOp<F> {
1415 closure: F,
compiler/rustc_trait_selection/src/traits/query/type_op/eq.rs+3-3
......@@ -1,10 +1,10 @@
1use crate::infer::canonical::{Canonical, CanonicalQueryResponse};
2use crate::traits::ObligationCtxt;
1pub use rustc_middle::traits::query::type_op::Eq;
32use rustc_middle::traits::query::NoSolution;
43use rustc_middle::traits::ObligationCause;
54use rustc_middle::ty::{ParamEnvAnd, TyCtxt};
65
7pub use rustc_middle::traits::query::type_op::Eq;
6use crate::infer::canonical::{Canonical, CanonicalQueryResponse};
7use crate::traits::ObligationCtxt;
88
99impl<'tcx> super::QueryTypeOp<'tcx> for Eq<'tcx> {
1010 type QueryResponse = ();
compiler/rustc_trait_selection/src/traits/query/type_op/implied_outlives_bounds.rs+3-4
......@@ -1,7 +1,3 @@
1use crate::traits::query::NoSolution;
2use crate::traits::wf;
3use crate::traits::ObligationCtxt;
4
51use rustc_infer::infer::canonical::Canonical;
62use rustc_infer::infer::resolve::OpportunisticRegionResolver;
73use rustc_infer::traits::query::OutlivesBound;
......@@ -14,6 +10,9 @@ use rustc_span::DUMMY_SP;
1410use rustc_type_ir::outlives::{push_outlives_components, Component};
1511use smallvec::{smallvec, SmallVec};
1612
13use crate::traits::query::NoSolution;
14use crate::traits::{wf, ObligationCtxt};
15
1716#[derive(Copy, Clone, Debug, HashStable, TypeFoldable, TypeVisitable)]
1817pub struct ImpliedOutlivesBounds<'tcx> {
1918 pub ty: Ty<'tcx>,
compiler/rustc_trait_selection/src/traits/query/type_op/mod.rs+8-6
......@@ -1,8 +1,5 @@
1use crate::infer::canonical::{
2 Canonical, CanonicalQueryResponse, OriginalQueryValues, QueryRegionConstraints,
3};
4use crate::infer::{InferCtxt, InferOk};
5use crate::traits::{ObligationCause, ObligationCtxt};
1use std::fmt;
2
63use rustc_errors::ErrorGuaranteed;
74use rustc_infer::infer::canonical::Certainty;
85use rustc_infer::traits::PredicateObligation;
......@@ -10,7 +7,12 @@ use rustc_middle::traits::query::NoSolution;
107use rustc_middle::ty::fold::TypeFoldable;
118use rustc_middle::ty::{ParamEnvAnd, TyCtxt};
129use rustc_span::Span;
13use std::fmt;
10
11use crate::infer::canonical::{
12 Canonical, CanonicalQueryResponse, OriginalQueryValues, QueryRegionConstraints,
13};
14use crate::infer::{InferCtxt, InferOk};
15use crate::traits::{ObligationCause, ObligationCtxt};
1416
1517pub mod ascribe_user_type;
1618pub mod custom;
compiler/rustc_trait_selection/src/traits/query/type_op/normalize.rs+5-4
......@@ -1,12 +1,13 @@
1use crate::infer::canonical::{Canonical, CanonicalQueryResponse};
2use crate::traits::ObligationCtxt;
1use std::fmt;
2
3pub use rustc_middle::traits::query::type_op::Normalize;
34use rustc_middle::traits::query::NoSolution;
45use rustc_middle::traits::ObligationCause;
56use rustc_middle::ty::fold::TypeFoldable;
67use rustc_middle::ty::{self, Lift, ParamEnvAnd, Ty, TyCtxt, TypeVisitableExt};
7use std::fmt;
88
9pub use rustc_middle::traits::query::type_op::Normalize;
9use crate::infer::canonical::{Canonical, CanonicalQueryResponse};
10use crate::traits::ObligationCtxt;
1011
1112impl<'tcx, T> super::QueryTypeOp<'tcx> for Normalize<T>
1213where
compiler/rustc_trait_selection/src/traits/query/type_op/outlives.rs+4-3
......@@ -1,11 +1,12 @@
1use rustc_macros::{HashStable, TypeFoldable, TypeVisitable};
2use rustc_middle::traits::query::{DropckOutlivesResult, NoSolution};
3use rustc_middle::ty::{ParamEnvAnd, Ty, TyCtxt};
4
15use crate::infer::canonical::{Canonical, CanonicalQueryResponse};
26use crate::traits::query::dropck_outlives::{
37 compute_dropck_outlives_inner, trivial_dropck_outlives,
48};
59use crate::traits::ObligationCtxt;
6use rustc_macros::{HashStable, TypeFoldable, TypeVisitable};
7use rustc_middle::traits::query::{DropckOutlivesResult, NoSolution};
8use rustc_middle::ty::{ParamEnvAnd, Ty, TyCtxt};
910
1011#[derive(Copy, Clone, Debug, HashStable, TypeFoldable, TypeVisitable)]
1112pub struct DropckOutlives<'tcx> {
compiler/rustc_trait_selection/src/traits/query/type_op/prove_predicate.rs+3-3
......@@ -1,11 +1,11 @@
1use crate::infer::canonical::{Canonical, CanonicalQueryResponse};
2use crate::traits::ObligationCtxt;
31use rustc_infer::traits::Obligation;
2pub use rustc_middle::traits::query::type_op::ProvePredicate;
43use rustc_middle::traits::query::NoSolution;
54use rustc_middle::traits::ObligationCause;
65use rustc_middle::ty::{self, ParamEnvAnd, TyCtxt};
76
8pub use rustc_middle::traits::query::type_op::ProvePredicate;
7use crate::infer::canonical::{Canonical, CanonicalQueryResponse};
8use crate::traits::ObligationCtxt;
99
1010impl<'tcx> super::QueryTypeOp<'tcx> for ProvePredicate<'tcx> {
1111 type QueryResponse = ();
compiler/rustc_trait_selection/src/traits/query/type_op/subtype.rs+3-3
......@@ -1,10 +1,10 @@
1use crate::infer::canonical::{Canonical, CanonicalQueryResponse};
2use crate::traits::ObligationCtxt;
1pub use rustc_middle::traits::query::type_op::Subtype;
32use rustc_middle::traits::query::NoSolution;
43use rustc_middle::traits::ObligationCause;
54use rustc_middle::ty::{ParamEnvAnd, TyCtxt};
65
7pub use rustc_middle::traits::query::type_op::Subtype;
6use crate::infer::canonical::{Canonical, CanonicalQueryResponse};
7use crate::traits::ObligationCtxt;
88
99impl<'tcx> super::QueryTypeOp<'tcx> for Subtype<'tcx> {
1010 type QueryResponse = ();
compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs+3-6
......@@ -12,20 +12,17 @@ use hir::def_id::DefId;
1212use hir::LangItem;
1313use rustc_data_structures::fx::{FxHashSet, FxIndexSet};
1414use rustc_hir as hir;
15use rustc_infer::traits::ObligationCause;
16use rustc_infer::traits::{Obligation, PolyTraitObligation, SelectionError};
15use rustc_infer::traits::{Obligation, ObligationCause, PolyTraitObligation, SelectionError};
1716use rustc_middle::ty::fast_reject::{DeepRejectCtxt, TreatParams};
1817use rustc_middle::ty::{self, ToPolyTraitRef, Ty, TypeVisitableExt};
1918use rustc_middle::{bug, span_bug};
2019
20use super::SelectionCandidate::*;
21use super::{BuiltinImplConditions, SelectionCandidateSet, SelectionContext, TraitObligationStack};
2122use crate::traits;
2223use crate::traits::query::evaluate_obligation::InferCtxtExt;
2324use crate::traits::util;
2425
25use super::BuiltinImplConditions;
26use super::SelectionCandidate::*;
27use super::{SelectionCandidateSet, SelectionContext, TraitObligationStack};
28
2926impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
3027 #[instrument(skip(self, stack), level = "debug")]
3128 pub(super) fn assemble_candidates<'o>(
compiler/rustc_trait_selection/src/traits/select/confirmation.rs+6-9
......@@ -7,11 +7,13 @@
77//! [rustc dev guide]:
88//! https://rustc-dev-guide.rust-lang.org/traits/resolution.html#confirmation
99
10use std::iter;
11use std::ops::ControlFlow;
12
1013use rustc_ast::Mutability;
1114use rustc_data_structures::stack::ensure_sufficient_stack;
1215use rustc_hir::lang_items::LangItem;
13use rustc_infer::infer::HigherRankedType;
14use rustc_infer::infer::{DefineOpaqueTypes, InferOk};
16use rustc_infer::infer::{DefineOpaqueTypes, HigherRankedType, InferOk};
1517use rustc_infer::traits::ObligationCauseCode;
1618use rustc_middle::traits::{BuiltinImplSource, SignatureMismatchData};
1719use rustc_middle::ty::{
......@@ -21,6 +23,8 @@ use rustc_middle::ty::{
2123use rustc_middle::{bug, span_bug};
2224use rustc_span::def_id::DefId;
2325
26use super::SelectionCandidate::{self, *};
27use super::{BuiltinImplConditions, SelectionContext};
2428use crate::traits::normalize::{normalize_with_depth, normalize_with_depth_to};
2529use crate::traits::util::{self, closure_trait_ref_and_return_type};
2630use crate::traits::{
......@@ -29,13 +33,6 @@ use crate::traits::{
2933 SignatureMismatch, TraitNotObjectSafe, TraitObligation, Unimplemented,
3034};
3135
32use super::BuiltinImplConditions;
33use super::SelectionCandidate::{self, *};
34use super::SelectionContext;
35
36use std::iter;
37use std::ops::ControlFlow;
38
3936impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
4037 #[instrument(level = "debug", skip(self))]
4138 pub(super) fn confirm_candidate(
compiler/rustc_trait_selection/src/traits/select/mod.rs+28-40
......@@ -2,31 +2,11 @@
22//!
33//! [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/traits/resolution.html#selection
44
5use self::EvaluationResult::*;
6use self::SelectionCandidate::*;
7
8use super::coherence::{self, Conflict};
9use super::const_evaluatable;
10use super::project;
11use super::project::ProjectionTermObligation;
12use super::util;
13use super::util::closure_trait_ref_and_return_type;
14use super::wf;
15use super::{
16 ImplDerivedCause, Normalized, Obligation, ObligationCause, ObligationCauseCode, Overflow,
17 PolyTraitObligation, PredicateObligation, Selection, SelectionError, SelectionResult,
18 TraitQueryMode,
19};
5use std::cell::{Cell, RefCell};
6use std::fmt::{self, Display};
7use std::ops::ControlFlow;
8use std::{cmp, iter};
209
21use crate::error_reporting::InferCtxtErrorExt;
22use crate::infer::{InferCtxt, InferCtxtExt, InferOk, TypeFreshener};
23use crate::solve::InferCtxtSelectExt as _;
24use crate::traits::normalize::normalize_with_depth;
25use crate::traits::normalize::normalize_with_depth_to;
26use crate::traits::project::ProjectAndUnifyResult;
27use crate::traits::project::ProjectionCacheKeyExt;
28use crate::traits::ProjectionCacheKey;
29use crate::traits::Unimplemented;
3010use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet};
3111use rustc_data_structures::stack::ensure_sufficient_stack;
3212use rustc_errors::{Diag, EmissionGuarantee};
......@@ -34,31 +14,39 @@ use rustc_hir as hir;
3414use rustc_hir::def_id::DefId;
3515use rustc_hir::LangItem;
3616use rustc_infer::infer::relate::TypeRelation;
37use rustc_infer::infer::BoundRegionConversionTime;
3817use rustc_infer::infer::BoundRegionConversionTime::HigherRankedType;
39use rustc_infer::infer::DefineOpaqueTypes;
18use rustc_infer::infer::{BoundRegionConversionTime, DefineOpaqueTypes};
4019use rustc_infer::traits::TraitObligation;
4120use rustc_middle::bug;
42use rustc_middle::dep_graph::dep_kinds;
43use rustc_middle::dep_graph::DepNodeIndex;
21use rustc_middle::dep_graph::{dep_kinds, DepNodeIndex};
4422use rustc_middle::mir::interpret::ErrorHandled;
23pub use rustc_middle::traits::select::*;
4524use rustc_middle::ty::abstract_const::NotConstEvaluatable;
4625use rustc_middle::ty::error::TypeErrorToStringExt;
47use rustc_middle::ty::print::PrintTraitRefExt as _;
48use rustc_middle::ty::GenericArgsRef;
49use rustc_middle::ty::{self, PolyProjectionPredicate, Upcast};
50use rustc_middle::ty::{Ty, TyCtxt, TypeFoldable, TypeVisitableExt};
26use rustc_middle::ty::print::{with_no_trimmed_paths, PrintTraitRefExt as _};
27use rustc_middle::ty::{
28 self, GenericArgsRef, PolyProjectionPredicate, Ty, TyCtxt, TypeFoldable, TypeVisitableExt,
29 Upcast,
30};
5131use rustc_span::symbol::sym;
5232use rustc_span::Symbol;
5333
54use std::cell::{Cell, RefCell};
55use std::cmp;
56use std::fmt::{self, Display};
57use std::iter;
58use std::ops::ControlFlow;
59
60pub use rustc_middle::traits::select::*;
61use rustc_middle::ty::print::with_no_trimmed_paths;
34use self::EvaluationResult::*;
35use self::SelectionCandidate::*;
36use super::coherence::{self, Conflict};
37use super::project::ProjectionTermObligation;
38use super::util::closure_trait_ref_and_return_type;
39use super::{
40 const_evaluatable, project, util, wf, ImplDerivedCause, Normalized, Obligation,
41 ObligationCause, ObligationCauseCode, Overflow, PolyTraitObligation, PredicateObligation,
42 Selection, SelectionError, SelectionResult, TraitQueryMode,
43};
44use crate::error_reporting::InferCtxtErrorExt;
45use crate::infer::{InferCtxt, InferCtxtExt, InferOk, TypeFreshener};
46use crate::solve::InferCtxtSelectExt as _;
47use crate::traits::normalize::{normalize_with_depth, normalize_with_depth_to};
48use crate::traits::project::{ProjectAndUnifyResult, ProjectionCacheKeyExt};
49use crate::traits::{ProjectionCacheKey, Unimplemented};
6250
6351mod _match;
6452mod candidate_assembly;
compiler/rustc_trait_selection/src/traits/specialize/mod.rs+10-13
......@@ -10,28 +10,25 @@
1010//! [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/traits/specialization.html
1111
1212pub mod specialization_graph;
13use rustc_data_structures::fx::FxIndexSet;
14use rustc_errors::codes::*;
15use rustc_errors::{Diag, EmissionGuarantee};
16use rustc_hir::def_id::{DefId, LocalDefId};
1317use rustc_infer::infer::DefineOpaqueTypes;
18use rustc_middle::bug;
19use rustc_middle::query::LocalCrate;
1420use rustc_middle::ty::print::PrintTraitRefExt as _;
21use rustc_middle::ty::{self, GenericArgsRef, ImplSubject, Ty, TyCtxt, TypeVisitableExt};
22use rustc_session::lint::builtin::{COHERENCE_LEAK_CHECK, ORDER_DEPENDENT_TRAIT_OBJECTS};
23use rustc_span::{sym, ErrorGuaranteed, Span, DUMMY_SP};
1524use specialization_graph::GraphExt;
1625
26use super::{util, SelectionContext};
1727use crate::error_reporting::traits::to_pretty_impl_header;
1828use crate::errors::NegativePositiveConflict;
1929use crate::infer::{InferCtxt, InferOk, TyCtxtInferExt};
2030use crate::traits::select::IntercrateAmbiguityCause;
2131use crate::traits::{coherence, FutureCompatOverlapErrorKind, ObligationCause, ObligationCtxt};
22use rustc_data_structures::fx::FxIndexSet;
23use rustc_errors::{codes::*, Diag, EmissionGuarantee};
24use rustc_hir::def_id::{DefId, LocalDefId};
25use rustc_middle::bug;
26use rustc_middle::query::LocalCrate;
27use rustc_middle::ty::GenericArgsRef;
28use rustc_middle::ty::{self, ImplSubject, Ty, TyCtxt, TypeVisitableExt};
29use rustc_session::lint::builtin::COHERENCE_LEAK_CHECK;
30use rustc_session::lint::builtin::ORDER_DEPENDENT_TRAIT_OBJECTS;
31use rustc_span::{sym, ErrorGuaranteed, Span, DUMMY_SP};
32
33use super::util;
34use super::SelectionContext;
3532
3633/// Information pertinent to an overlapping impl error.
3734#[derive(Debug)]
compiler/rustc_trait_selection/src/traits/specialize/specialization_graph.rs+3-4
......@@ -1,14 +1,13 @@
1use super::OverlapError;
2
3use crate::traits;
41use rustc_errors::ErrorGuaranteed;
52use rustc_hir::def_id::DefId;
63use rustc_macros::extension;
74use rustc_middle::bug;
5pub use rustc_middle::traits::specialization_graph::*;
86use rustc_middle::ty::fast_reject::{self, SimplifiedType, TreatParams};
97use rustc_middle::ty::{self, TyCtxt, TypeVisitableExt};
108
11pub use rustc_middle::traits::specialization_graph::*;
9use super::OverlapError;
10use crate::traits;
1211
1312#[derive(Copy, Clone, Debug)]
1413pub enum FutureCompatOverlapErrorKind {
compiler/rustc_trait_selection/src/traits/util.rs+6-6
......@@ -1,19 +1,19 @@
11use std::collections::BTreeMap;
22
3use super::NormalizeExt;
4use super::{ObligationCause, PredicateObligation, SelectionContext};
53use rustc_data_structures::fx::FxIndexMap;
64use rustc_errors::Diag;
75use rustc_hir::def_id::DefId;
86use rustc_infer::infer::{InferCtxt, InferOk};
7pub use rustc_infer::traits::util::*;
98use rustc_middle::bug;
10use rustc_middle::ty::GenericArgsRef;
11use rustc_middle::ty::{self, ImplSubject, Ty, TyCtxt, TypeVisitableExt, Upcast};
12use rustc_middle::ty::{TypeFoldable, TypeFolder, TypeSuperFoldable};
9use rustc_middle::ty::{
10 self, GenericArgsRef, ImplSubject, Ty, TyCtxt, TypeFoldable, TypeFolder, TypeSuperFoldable,
11 TypeVisitableExt, Upcast,
12};
1313use rustc_span::Span;
1414use smallvec::{smallvec, SmallVec};
1515
16pub use rustc_infer::traits::util::*;
16use super::{NormalizeExt, ObligationCause, PredicateObligation, SelectionContext};
1717
1818///////////////////////////////////////////////////////////////////////////
1919// `TraitAliasExpander` iterator
compiler/rustc_trait_selection/src/traits/vtable.rs+8-6
......@@ -1,16 +1,18 @@
1use crate::errors::DumpVTableEntries;
2use crate::traits::{impossible_predicates, is_vtable_safe_method};
1use std::fmt::Debug;
2use std::ops::ControlFlow;
3
34use rustc_hir::def_id::DefId;
45use rustc_infer::traits::util::PredicateSet;
56use rustc_middle::bug;
67use rustc_middle::query::Providers;
7use rustc_middle::ty::{self, GenericParamDefKind, Ty, TyCtxt, Upcast, VtblEntry};
8use rustc_middle::ty::{GenericArgs, TypeVisitableExt};
8use rustc_middle::ty::{
9 self, GenericArgs, GenericParamDefKind, Ty, TyCtxt, TypeVisitableExt, Upcast, VtblEntry,
10};
911use rustc_span::{sym, Span, DUMMY_SP};
1012use smallvec::{smallvec, SmallVec};
1113
12use std::fmt::Debug;
13use std::ops::ControlFlow;
14use crate::errors::DumpVTableEntries;
15use crate::traits::{impossible_predicates, is_vtable_safe_method};
1416
1517#[derive(Clone, Debug)]
1618pub enum VtblSegment<'tcx> {
compiler/rustc_trait_selection/src/traits/wf.rs+6-5
......@@ -1,17 +1,18 @@
1use crate::infer::InferCtxt;
2use crate::traits;
1use std::iter;
2
33use rustc_hir as hir;
44use rustc_hir::lang_items::LangItem;
55use rustc_infer::traits::ObligationCauseCode;
66use rustc_middle::bug;
77use rustc_middle::ty::{
8 self, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor,
8 self, GenericArg, GenericArgKind, GenericArgsRef, Ty, TyCtxt, TypeSuperVisitable,
9 TypeVisitable, TypeVisitableExt, TypeVisitor,
910};
10use rustc_middle::ty::{GenericArg, GenericArgKind, GenericArgsRef};
1111use rustc_span::def_id::{DefId, LocalDefId, CRATE_DEF_ID};
1212use rustc_span::{Span, DUMMY_SP};
1313
14use std::iter;
14use crate::infer::InferCtxt;
15use crate::traits;
1516/// Returns the set of obligations needed to make `arg` well-formed.
1617/// If `arg` contains unresolved inference variables, this may include
1718/// 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;
55use rustc_middle::bug;
66use rustc_middle::query::Providers;
77use rustc_middle::traits::query::{DropckConstraint, DropckOutlivesResult};
8use rustc_middle::ty::GenericArgs;
9use rustc_middle::ty::TyCtxt;
8use rustc_middle::ty::{GenericArgs, TyCtxt};
109use rustc_trait_selection::infer::InferCtxtBuilderExt;
1110use rustc_trait_selection::traits::query::dropck_outlives::{
1211 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;
1212mod normalize_projection_ty;
1313mod type_op;
1414
15use rustc_middle::query::Providers;
1516pub use rustc_trait_selection::traits::query::type_op::ascribe_user_type::type_op_ascribe_user_type_with_span;
1617pub use type_op::type_op_prove_predicate_with_cause;
1718
18use rustc_middle::query::Providers;
19
2019pub fn provide(p: &mut Providers) {
2120 dropck_outlives::provide(p);
2221 evaluate_obligation::provide(p);
compiler/rustc_traits/src/normalize_projection_ty.rs+2-3
......@@ -4,9 +4,8 @@ use rustc_middle::query::Providers;
44use rustc_middle::ty::{ParamEnvAnd, TyCtxt};
55use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
66use rustc_trait_selection::infer::InferCtxtBuilderExt;
7use rustc_trait_selection::traits::query::{
8 normalize::NormalizationResult, CanonicalAliasGoal, NoSolution,
9};
7use rustc_trait_selection::traits::query::normalize::NormalizationResult;
8use rustc_trait_selection::traits::query::{CanonicalAliasGoal, NoSolution};
109use rustc_trait_selection::traits::{self, ObligationCause, ScrubbedTraitError, SelectionContext};
1110use tracing::debug;
1211
compiler/rustc_traits/src/type_op.rs+3-3
......@@ -1,9 +1,10 @@
1use std::fmt;
2
13use rustc_infer::infer::canonical::{Canonical, QueryResponse};
24use rustc_infer::infer::TyCtxtInferExt;
35use rustc_middle::query::Providers;
46use rustc_middle::traits::query::NoSolution;
5use rustc_middle::ty::{Clause, ParamEnvAnd};
6use rustc_middle::ty::{FnSig, PolyFnSig, Ty, TyCtxt, TypeFoldable};
7use rustc_middle::ty::{Clause, FnSig, ParamEnvAnd, PolyFnSig, Ty, TyCtxt, TypeFoldable};
78use rustc_trait_selection::infer::InferCtxtBuilderExt;
89use rustc_trait_selection::traits::query::normalize::QueryNormalizeExt;
910use rustc_trait_selection::traits::query::type_op::ascribe_user_type::{
......@@ -14,7 +15,6 @@ use rustc_trait_selection::traits::query::type_op::normalize::Normalize;
1415use rustc_trait_selection::traits::query::type_op::prove_predicate::ProvePredicate;
1516use rustc_trait_selection::traits::query::type_op::subtype::Subtype;
1617use rustc_trait_selection::traits::{Normalized, Obligation, ObligationCause, ObligationCtxt};
17use std::fmt;
1818
1919pub(crate) fn provide(p: &mut Providers) {
2020 *p = Providers {
compiler/rustc_transmute/src/layout/dfa.rs+4-2
......@@ -1,9 +1,11 @@
1use super::{nfa, Byte, Nfa, Ref};
2use crate::Map;
31use std::fmt;
42use std::sync::atomic::{AtomicU32, Ordering};
3
54use tracing::instrument;
65
6use super::{nfa, Byte, Nfa, Ref};
7use crate::Map;
8
79#[derive(PartialEq, Clone, Debug)]
810pub(crate) struct Dfa<R>
911where
compiler/rustc_transmute/src/layout/mod.rs+2-1
......@@ -60,9 +60,10 @@ impl Ref for ! {
6060
6161#[cfg(feature = "rustc")]
6262pub mod rustc {
63 use std::fmt::{self, Write};
64
6365 use rustc_middle::mir::Mutability;
6466 use rustc_middle::ty::{self, Ty};
65 use std::fmt::{self, Write};
6667
6768 /// A reference in the layout.
6869 #[derive(Debug, Hash, Eq, PartialEq, Clone, Copy)]
compiler/rustc_transmute/src/layout/nfa.rs+3-2
......@@ -1,8 +1,9 @@
1use super::{Byte, Ref, Tree, Uninhabited};
2use crate::{Map, Set};
31use std::fmt;
42use std::sync::atomic::{AtomicU32, Ordering};
53
4use super::{Byte, Ref, Tree, Uninhabited};
5use crate::{Map, Set};
6
67/// A non-deterministic finite automaton (NFA) that represents the layout of a type.
78/// The transmutability of two given types is computed by comparing their `Nfa`s.
89#[derive(PartialEq, Debug)]
compiler/rustc_transmute/src/layout/tree.rs+7-16
......@@ -1,6 +1,7 @@
1use super::{Byte, Def, Ref};
21use std::ops::ControlFlow;
32
3use super::{Byte, Def, Ref};
4
45#[cfg(test)]
56mod tests;
67
......@@ -170,24 +171,14 @@ where
170171
171172#[cfg(feature = "rustc")]
172173pub(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
173179 use super::Tree;
174180 use crate::layout::rustc::{Def, Ref};
175181
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
191182 #[derive(Debug, Copy, Clone)]
192183 pub(crate) enum Err {
193184 /// 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> {
7979
8080#[cfg(feature = "rustc")]
8181mod rustc {
82 use super::*;
83
8482 use rustc_hir::lang_items::LangItem;
8583 use rustc_infer::infer::InferCtxt;
8684 use rustc_macros::TypeVisitable;
8785 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};
9387 use rustc_span::DUMMY_SP;
9488
89 use super::*;
90
9591 /// The source and destination types of a transmutation.
9692 #[derive(TypeVisitable, Debug, Clone, Copy)]
9793 pub struct Types<'tcx> {
compiler/rustc_transmute/src/maybe_transmutable/mod.rs+6-11
......@@ -4,11 +4,9 @@ pub(crate) mod query_context;
44#[cfg(test)]
55mod tests;
66
7use crate::{
8 layout::{self, dfa, Byte, Def, Dfa, Nfa, Ref, Tree, Uninhabited},
9 maybe_transmutable::query_context::QueryContext,
10 Answer, Condition, Map, Reason,
11};
7use crate::layout::{self, dfa, Byte, Def, Dfa, Nfa, Ref, Tree, Uninhabited};
8use crate::maybe_transmutable::query_context::QueryContext;
9use crate::{Answer, Condition, Map, Reason};
1210
1311pub(crate) struct MaybeTransmutableQuery<L, C>
1412where
......@@ -32,15 +30,12 @@ where
3230// FIXME: Nix this cfg, so we can write unit tests independently of rustc
3331#[cfg(feature = "rustc")]
3432mod rustc {
33 use rustc_middle::ty::layout::{LayoutCx, LayoutOf};
34 use rustc_middle::ty::{ParamEnv, Ty, TyCtxt};
35
3536 use super::*;
3637 use crate::layout::tree::rustc::Err;
3738
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
4439 impl<'tcx> MaybeTransmutableQuery<Ty<'tcx>, TyCtxt<'tcx>> {
4540 /// This method begins by converting `src` and `dst` from `Ty`s to `Tree`s,
4641 /// 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 {
3434
3535#[cfg(feature = "rustc")]
3636mod rustc {
37 use super::*;
3837 use rustc_middle::ty::{Ty, TyCtxt};
3938
39 use super::*;
40
4041 impl<'tcx> super::QueryContext for TyCtxt<'tcx> {
4142 type Def = layout::rustc::Def<'tcx>;
4243 type Ref = layout::rustc::Ref<'tcx>;
compiler/rustc_transmute/src/maybe_transmutable/tests.rs+4-5
......@@ -1,12 +1,12 @@
1use itertools::Itertools;
2
13use super::query_context::test::{Def, UltraMinimal};
24use crate::maybe_transmutable::MaybeTransmutableQuery;
35use crate::{layout, Reason};
4use itertools::Itertools;
56
67mod safety {
7 use crate::Answer;
8
98 use super::*;
9 use crate::Answer;
1010
1111 type Tree = layout::Tree<Def, !>;
1212
......@@ -63,9 +63,8 @@ mod safety {
6363}
6464
6565mod bool {
66 use crate::Answer;
67
6866 use super::*;
67 use crate::Answer;
6968
7069 #[test]
7170 fn should_permit_identity_transmutation_tree() {
compiler/rustc_ty_utils/src/abi.rs+2-2
......@@ -1,3 +1,5 @@
1use std::iter;
2
13use rustc_hir as hir;
24use rustc_hir::lang_items::LangItem;
35use rustc_middle::bug;
......@@ -16,8 +18,6 @@ use rustc_target::abi::*;
1618use rustc_target::spec::abi::Abi as SpecAbi;
1719use tracing::debug;
1820
19use std::iter;
20
2121pub(crate) fn provide(providers: &mut Providers) {
2222 *providers = Providers { fn_abi_of_fn_ptr, fn_abi_of_instance, ..*providers };
2323}
compiler/rustc_ty_utils/src/consts.rs+3-4
......@@ -1,20 +1,19 @@
1use std::iter;
2
13use rustc_errors::ErrorGuaranteed;
24use rustc_hir::def::DefKind;
35use rustc_hir::def_id::LocalDefId;
4use rustc_middle::bug;
56use rustc_middle::mir::interpret::{LitToConstError, LitToConstInput};
67use rustc_middle::query::Providers;
78use rustc_middle::thir::visit;
89use rustc_middle::thir::visit::Visitor;
910use rustc_middle::ty::abstract_const::CastKind;
1011use rustc_middle::ty::{self, Expr, TyCtxt, TypeVisitableExt};
11use rustc_middle::{mir, thir};
12use rustc_middle::{bug, mir, thir};
1213use rustc_span::Span;
1314use rustc_target::abi::{VariantIdx, FIRST_VARIANT};
1415use tracing::{debug, instrument};
1516
16use std::iter;
17
1817use crate::errors::{GenericConstantTooComplex, GenericConstantTooComplexSub};
1918
2019/// Destructures array, ADT or tuple constants into the constants
compiler/rustc_ty_utils/src/implied_bounds.rs+2-1
......@@ -1,3 +1,5 @@
1use std::iter;
2
13use rustc_data_structures::fx::FxHashMap;
24use rustc_hir as hir;
35use rustc_hir::def::DefKind;
......@@ -6,7 +8,6 @@ use rustc_middle::bug;
68use rustc_middle::query::Providers;
79use rustc_middle::ty::{self, Ty, TyCtxt};
810use rustc_span::Span;
9use std::iter;
1011
1112pub(crate) fn provide(providers: &mut Providers) {
1213 *providers = Providers {
compiler/rustc_ty_utils/src/instance.rs+1-2
......@@ -6,8 +6,7 @@ use rustc_middle::bug;
66use rustc_middle::query::Providers;
77use rustc_middle::traits::{BuiltinImplSource, CodegenObligationError};
88use rustc_middle::ty::util::AsyncDropGlueMorphology;
9use rustc_middle::ty::GenericArgsRef;
10use rustc_middle::ty::{self, Instance, TyCtxt, TypeVisitableExt};
9use rustc_middle::ty::{self, GenericArgsRef, Instance, TyCtxt, TypeVisitableExt};
1110use rustc_span::sym;
1211use rustc_trait_selection::traits;
1312use rustc_type_ir::ClosureKind;
compiler/rustc_ty_utils/src/layout.rs+3-3
......@@ -1,3 +1,6 @@
1use std::fmt::Debug;
2use std::iter;
3
14use hir::def_id::DefId;
25use rustc_hir as hir;
36use rustc_index::bit_set::BitSet;
......@@ -19,9 +22,6 @@ use rustc_span::symbol::Symbol;
1922use rustc_target::abi::*;
2023use tracing::{debug, instrument, trace};
2124
22use std::fmt::Debug;
23use std::iter;
24
2525use crate::errors::{
2626 MultipleArrayFieldsSimdType, NonPrimitiveSimdType, OversizedSimdType, ZeroLengthSimdType,
2727};
compiler/rustc_ty_utils/src/layout_sanity_check.rs+4-6
......@@ -1,12 +1,10 @@
1use std::assert_matches::assert_matches;
2
13use rustc_middle::bug;
2use rustc_middle::ty::{
3 layout::{LayoutCx, TyAndLayout},
4 TyCtxt,
5};
4use rustc_middle::ty::layout::{LayoutCx, TyAndLayout};
5use rustc_middle::ty::TyCtxt;
66use rustc_target::abi::*;
77
8use std::assert_matches::assert_matches;
9
108/// Enforce some basic invariants on layouts.
119pub(super) fn sanity_check_layout<'tcx>(
1210 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;
55use rustc_middle::bug;
66use rustc_middle::query::Providers;
77use rustc_middle::ty::util::{needs_drop_components, AlwaysRequiresDrop};
8use rustc_middle::ty::GenericArgsRef;
9use rustc_middle::ty::{self, EarlyBinder, Ty, TyCtxt};
8use rustc_middle::ty::{self, EarlyBinder, GenericArgsRef, Ty, TyCtxt};
109use rustc_session::Limit;
1110use rustc_span::sym;
1211use tracing::debug;
compiler/rustc_ty_utils/src/opaque_types.rs+3-3
......@@ -1,12 +1,12 @@
11use rustc_data_structures::fx::FxHashSet;
2use rustc_hir::def::DefKind;
3use rustc_hir::def_id::LocalDefId;
24use rustc_hir::intravisit::Visitor;
3use rustc_hir::{def::DefKind, def_id::LocalDefId};
45use rustc_hir::{intravisit, CRATE_HIR_ID};
56use rustc_middle::bug;
67use rustc_middle::query::Providers;
78use rustc_middle::ty::util::{CheckRegions, NotUniqueParam};
8use rustc_middle::ty::{self, Ty, TyCtxt};
9use rustc_middle::ty::{TypeSuperVisitable, TypeVisitable, TypeVisitor};
9use rustc_middle::ty::{self, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitor};
1010use rustc_span::Span;
1111use tracing::{instrument, trace};
1212
compiler/rustc_ty_utils/src/sig_types.rs+2-1
......@@ -3,7 +3,8 @@
33
44use rustc_ast_ir::try_visit;
55use rustc_ast_ir::visit::VisitorResult;
6use rustc_hir::{def::DefKind, def_id::LocalDefId};
6use rustc_hir::def::DefKind;
7use rustc_hir::def_id::LocalDefId;
78use rustc_middle::span_bug;
89use rustc_middle::ty::{self, TyCtxt};
910use rustc_span::Span;
compiler/rustc_ty_utils/src/structural_match.rs+1-2
......@@ -1,8 +1,7 @@
11use rustc_hir::lang_items::LangItem;
2use rustc_infer::infer::TyCtxtInferExt;
23use rustc_middle::query::Providers;
34use rustc_middle::ty::{self, Ty, TyCtxt};
4
5use rustc_infer::infer::TyCtxtInferExt;
65use rustc_trait_selection::traits::{ObligationCause, ObligationCtxt};
76
87/// 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;
55use rustc_index::bit_set::BitSet;
66use rustc_middle::bug;
77use rustc_middle::query::Providers;
8use rustc_middle::ty::{self, EarlyBinder, Ty, TyCtxt, TypeVisitableExt, TypeVisitor};
9use rustc_middle::ty::{TypeSuperVisitable, TypeVisitable, Upcast};
8use rustc_middle::ty::{
9 self, EarlyBinder, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitableExt,
10 TypeVisitor, Upcast,
11};
1012use rustc_span::def_id::{DefId, LocalDefId, CRATE_DEF_ID};
1113use rustc_span::DUMMY_SP;
1214use rustc_trait_selection::traits;
compiler/rustc_type_ir/src/canonical.rs+4-3
......@@ -1,10 +1,11 @@
1use std::fmt;
2use std::hash::Hash;
3use std::ops::Index;
4
15use derive_where::derive_where;
26#[cfg(feature = "nightly")]
37use rustc_macros::{HashStable_NoContext, TyDecodable, TyEncodable};
48use rustc_type_ir_macros::{Lift_Generic, TypeFoldable_Generic, TypeVisitable_Generic};
5use std::fmt;
6use std::hash::Hash;
7use std::ops::Index;
89
910use crate::inherent::*;
1011use crate::{self as ty, Interner, UniverseIndex};
compiler/rustc_type_ir/src/codec.rs+2-2
......@@ -1,8 +1,8 @@
1use crate::{Interner, PredicateKind};
2
31use rustc_data_structures::fx::FxHashMap;
42use rustc_span::{SpanDecoder, SpanEncoder};
53
4use crate::{Interner, PredicateKind};
5
66/// The shorthand encoding uses an enum's variant index `usize`
77/// and is offset by this value so it never matches a real variant.
88/// 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 @@
1use std::fmt;
2
13use derive_where::derive_where;
24#[cfg(feature = "nightly")]
35use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
46#[cfg(feature = "nightly")]
57use rustc_macros::{HashStable_NoContext, TyDecodable, TyEncodable};
68use rustc_type_ir_macros::{Lift_Generic, TypeFoldable_Generic, TypeVisitable_Generic};
7use std::fmt;
89
910use crate::{self as ty, DebruijnIndex, Interner};
1011
compiler/rustc_type_ir/src/data_structures.rs+7-12
......@@ -1,25 +1,20 @@
11#[cfg(feature = "nightly")]
22mod 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};
97 pub use rustc_data_structures::stack::ensure_sufficient_stack;
108 pub use rustc_data_structures::sync::Lrc;
119}
1210
1311#[cfg(not(feature = "nightly"))]
1412mod 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};
2114 pub use std::sync::Arc as Lrc;
2215
16 pub use indexmap::{IndexMap, IndexSet};
17
2318 #[inline]
2419 pub fn ensure_sufficient_stack<R>(f: impl FnOnce() -> R) -> R {
2520 f()
compiler/rustc_type_ir/src/elaborate.rs+2-2
......@@ -3,9 +3,9 @@ use std::marker::PhantomData;
33use smallvec::smallvec;
44
55use crate::data_structures::HashSet;
6use crate::inherent::*;
67use crate::outlives::{push_outlives_components, Component};
7use crate::{self as ty, Interner};
8use crate::{inherent::*, Upcast as _};
8use crate::{self as ty, Interner, Upcast as _};
99
1010/// "Elaboration" is the process of identifying all the predicates that
1111/// are implied by a source predicate. Currently, this basically means
compiler/rustc_type_ir/src/fold.rs+2-1
......@@ -45,8 +45,9 @@
4545//! - u.fold_with(folder)
4646//! ```
4747
48use rustc_index::{Idx, IndexVec};
4948use std::mem;
49
50use rustc_index::{Idx, IndexVec};
5051use tracing::debug;
5152
5253use crate::data_structures::Lrc;
compiler/rustc_type_ir/src/interner.rs+7-5
......@@ -1,22 +1,24 @@
1use rustc_ast_ir::Movability;
2use rustc_index::bit_set::BitSet;
3use smallvec::SmallVec;
41use std::fmt::Debug;
52use std::hash::Hash;
63use std::ops::Deref;
74
5use rustc_ast_ir::Movability;
6use rustc_index::bit_set::BitSet;
7use smallvec::SmallVec;
8
89use crate::fold::TypeFoldable;
910use crate::inherent::*;
1011use crate::ir_print::IrPrint;
1112use crate::lang_items::TraitSolverLangItem;
1213use crate::relate::Relate;
13use crate::search_graph;
1414use crate::solve::inspect::CanonicalGoalEvaluationStep;
1515use crate::solve::{
1616 CanonicalInput, ExternalConstraintsData, PredefinedOpaquesData, QueryResult, SolverMode,
1717};
1818use crate::visit::{Flags, TypeSuperVisitable, TypeVisitable};
19use crate::{self as ty};
19use crate::{
20 search_graph, {self as ty},
21};
2022
2123pub trait Interner:
2224 Sized
compiler/rustc_type_ir/src/lib.rs+3-2
......@@ -9,11 +9,12 @@
99
1010extern crate self as rustc_type_ir;
1111
12#[cfg(feature = "nightly")]
13use rustc_macros::{Decodable, Encodable, HashStable_NoContext};
1412use std::fmt;
1513use std::hash::Hash;
1614
15#[cfg(feature = "nightly")]
16use rustc_macros::{Decodable, Encodable, HashStable_NoContext};
17
1718// These modules are `pub` since they are not glob-imported.
1819#[macro_use]
1920pub mod visit;
compiler/rustc_type_ir/src/predicate_kind.rs+2-1
......@@ -1,8 +1,9 @@
1use std::fmt;
2
13use derive_where::derive_where;
24#[cfg(feature = "nightly")]
35use rustc_macros::{Decodable, Encodable, HashStable_NoContext, TyDecodable, TyEncodable};
46use rustc_type_ir_macros::{TypeFoldable_Generic, TypeVisitable_Generic};
5use std::fmt;
67
78use crate::{self as ty, Interner};
89
compiler/rustc_type_ir/src/region_kind.rs+3-3
......@@ -1,13 +1,13 @@
1use std::fmt;
2
13use derive_where::derive_where;
24#[cfg(feature = "nightly")]
35use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
46#[cfg(feature = "nightly")]
57use rustc_macros::{HashStable_NoContext, TyDecodable, TyEncodable};
6use std::fmt;
7
8use crate::{DebruijnIndex, Interner};
98
109use self::RegionKind::*;
10use crate::{DebruijnIndex, Interner};
1111
1212rustc_index::newtype_index! {
1313 /// A **region** **v**ariable **ID**.
compiler/rustc_type_ir/src/solve/inspect.rs+6-4
......@@ -17,14 +17,16 @@
1717//!
1818//! [canonicalized]: https://rustc-dev-guide.rust-lang.org/solve/canonicalization.html
1919
20use std::fmt::Debug;
21use std::hash::Hash;
22
23use derive_where::derive_where;
24use rustc_type_ir_macros::{TypeFoldable_Generic, TypeVisitable_Generic};
25
2026use crate::solve::{
2127 CandidateSource, CanonicalInput, Certainty, Goal, GoalSource, QueryInput, QueryResult,
2228};
2329use crate::{Canonical, CanonicalVarValues, Interner};
24use derive_where::derive_where;
25use rustc_type_ir_macros::{TypeFoldable_Generic, TypeVisitable_Generic};
26use std::fmt::Debug;
27use std::hash::Hash;
2830
2931/// Some `data` together with information about how they relate to the input
3032/// of the canonical query.
compiler/rustc_type_ir/src/ty_info.rs+4-3
......@@ -1,10 +1,11 @@
1use std::cmp::Ordering;
2use std::hash::{Hash, Hasher};
3use std::ops::Deref;
4
15#[cfg(feature = "nightly")]
26use rustc_data_structures::fingerprint::Fingerprint;
37#[cfg(feature = "nightly")]
48use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
5use std::cmp::Ordering;
6use std::hash::{Hash, Hasher};
7use std::ops::Deref;
89
910use crate::{DebruijnIndex, TypeFlags};
1011
compiler/rustc_type_ir/src/ty_kind.rs+3-4
......@@ -1,5 +1,7 @@
1use derive_where::derive_where;
1use std::fmt;
22
3use derive_where::derive_where;
4use rustc_ast_ir::Mutability;
35#[cfg(feature = "nightly")]
46use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
57#[cfg(feature = "nightly")]
......@@ -7,15 +9,12 @@ use rustc_data_structures::unify::{NoError, UnifyKey, UnifyValue};
79#[cfg(feature = "nightly")]
810use rustc_macros::{Decodable, Encodable, HashStable_NoContext, TyDecodable, TyEncodable};
911use rustc_type_ir_macros::{Lift_Generic, TypeFoldable_Generic, TypeVisitable_Generic};
10use std::fmt;
1112
1213pub use self::closure::*;
1314use self::TyKind::*;
1415use crate::inherent::*;
1516use crate::{self as ty, DebruijnIndex, Interner};
1617
17use rustc_ast_ir::Mutability;
18
1918mod closure;
2019
2120/// Specifies how a trait object is represented.
compiler/rustc_type_ir/src/visit.rs+3-2
......@@ -41,11 +41,12 @@
4141//! - u.visit_with(visitor)
4242//! ```
4343
44use std::fmt;
45use std::ops::ControlFlow;
46
4447use rustc_ast_ir::visit::VisitorResult;
4548use rustc_ast_ir::{try_visit, walk_visitable_list};
4649use rustc_index::{Idx, IndexVec};
47use std::fmt;
48use std::ops::ControlFlow;
4950
5051use crate::data_structures::Lrc;
5152use crate::inherent::*;
compiler/rustc_type_ir_macros/src/lib.rs+2-1
......@@ -1,5 +1,6 @@
11use quote::quote;
2use syn::{parse_quote, visit_mut::VisitMut};
2use syn::parse_quote;
3use syn::visit_mut::VisitMut;
34use synstructure::decl_derive;
45
56decl_derive!(
compiler/stable_mir/src/abi.rs+7-7
......@@ -1,14 +1,14 @@
1use std::fmt::{self, Debug};
2use std::num::NonZero;
3use std::ops::RangeInclusive;
4
5use serde::Serialize;
6
17use crate::compiler_interface::with;
2use crate::error;
38use crate::mir::FieldIdx;
49use crate::target::{MachineInfo, MachineSize as Size};
510use crate::ty::{Align, IndexedVal, Ty, VariantIdx};
6use crate::Error;
7use crate::Opaque;
8use serde::Serialize;
9use std::fmt::{self, Debug};
10use std::num::NonZero;
11use std::ops::RangeInclusive;
11use crate::{error, Error, Opaque};
1212
1313/// A function ABI definition.
1414#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize)]
compiler/stable_mir/src/crate_def.rs+2-1
......@@ -1,9 +1,10 @@
11//! Module that define a common trait for things that represent a crate definition,
22//! such as, a function, a trait, an enum, and any other definitions.
33
4use serde::Serialize;
5
46use crate::ty::{GenericArgs, Span, Ty};
57use crate::{with, Crate, Symbol};
6use serde::Serialize;
78
89/// A unique identification number for each item accessible for the current compilation unit.
910#[derive(Clone, Copy, PartialEq, Eq, Hash, Serialize)]
compiler/stable_mir/src/lib.rs+4-5
......@@ -17,17 +17,16 @@
1717//! The goal is to eventually be published on
1818//! [crates.io](https://crates.io).
1919
20use std::fmt;
2120use std::fmt::Debug;
22use std::io;
21use std::{fmt, io};
22
23use serde::Serialize;
2324
2425use crate::compiler_interface::with;
2526pub use crate::crate_def::{CrateDef, CrateDefType, DefId};
2627pub use crate::error::*;
27use crate::mir::Body;
28use crate::mir::Mutability;
28use crate::mir::{Body, Mutability};
2929use crate::ty::{ForeignModuleDef, ImplDef, IndexedVal, Span, TraitDef, Ty};
30use serde::Serialize;
3130
3231pub mod abi;
3332#[macro_use]
compiler/stable_mir/src/mir/alloc.rs+4-2
......@@ -1,11 +1,13 @@
11//! This module provides methods to retrieve allocation information, such as static variables.
22
3use std::io::Read;
4
5use serde::Serialize;
6
37use crate::mir::mono::{Instance, StaticDef};
48use crate::target::{Endian, MachineInfo};
59use crate::ty::{Allocation, Binder, ExistentialTraitRef, IndexedVal, Ty};
610use crate::{with, Error};
7use serde::Serialize;
8use std::io::Read;
911
1012/// An allocation in the SMIR global memory can be either a function pointer,
1113/// a static, or a "real" allocation with some data in it.
compiler/stable_mir/src/mir/body.rs+4-2
......@@ -1,3 +1,7 @@
1use std::io;
2
3use serde::Serialize;
4
15use crate::compiler_interface::with;
26use crate::mir::pretty::function_body;
37use crate::ty::{
......@@ -5,8 +9,6 @@ use crate::ty::{
59 TyConst, TyKind, VariantIdx,
610};
711use crate::{Error, Opaque, Span, Symbol};
8use serde::Serialize;
9use std::io;
1012
1113/// The SMIR representation of a single function.
1214#[derive(Clone, Debug, Serialize)]
compiler/stable_mir/src/mir/mono.rs+5-3
......@@ -1,11 +1,13 @@
1use std::fmt::{Debug, Formatter};
2use std::io;
3
4use serde::Serialize;
5
16use crate::abi::FnAbi;
27use crate::crate_def::CrateDef;
38use crate::mir::Body;
49use crate::ty::{Allocation, ClosureDef, ClosureKind, FnDef, GenericArgs, IndexedVal, Ty};
510use crate::{with, CrateItem, DefId, Error, ItemKind, Opaque, Symbol};
6use serde::Serialize;
7use std::fmt::{Debug, Formatter};
8use std::io;
911
1012#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize)]
1113pub enum MonoItem {
compiler/stable_mir/src/mir/pretty.rs+5-6
......@@ -1,14 +1,13 @@
1use crate::mir::{Operand, Place, Rvalue, StatementKind, UnwindAction, VarDebugInfoContents};
2use crate::ty::{IndexedVal, MirConst, Ty, TyConst};
3use crate::{with, Body, Mutability};
4use fmt::{Display, Formatter};
51use std::fmt::Debug;
62use std::io::Write;
73use std::{fmt, io, iter};
84
9use super::{AssertMessage, BinOp, TerminatorKind};
5use fmt::{Display, Formatter};
106
11use super::{BorrowKind, FakeBorrowKind};
7use super::{AssertMessage, BinOp, BorrowKind, FakeBorrowKind, TerminatorKind};
8use crate::mir::{Operand, Place, Rvalue, StatementKind, UnwindAction, VarDebugInfoContents};
9use crate::ty::{IndexedVal, MirConst, Ty, TyConst};
10use crate::{with, Body, Mutability};
1211
1312impl Display for Ty {
1413 fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
compiler/stable_mir/src/target.rs+2-1
......@@ -1,8 +1,9 @@
11//! Provide information about the machine that this is being compiled into.
22
3use crate::compiler_interface::with;
43use serde::Serialize;
54
5use crate::compiler_interface::with;
6
67/// The properties of the target machine being compiled into.
78#[derive(Clone, PartialEq, Eq, Serialize)]
89pub struct MachineInfo {
compiler/stable_mir/src/ty.rs+7-7
......@@ -1,16 +1,16 @@
1use super::{
2 mir::{Body, Mutability, Safety},
3 with, DefId, Error, Symbol,
4};
1use std::fmt::{self, Debug, Display, Formatter};
2use std::ops::Range;
3
4use serde::Serialize;
5
6use super::mir::{Body, Mutability, Safety};
7use super::{with, DefId, Error, Symbol};
58use crate::abi::{FnAbi, Layout};
69use crate::crate_def::{CrateDef, CrateDefType};
710use crate::mir::alloc::{read_target_int, read_target_uint, AllocId};
811use crate::mir::mono::StaticDef;
912use crate::target::MachineInfo;
1013use crate::{Filename, Opaque};
11use serde::Serialize;
12use std::fmt::{self, Debug, Display, Formatter};
13use std::ops::Range;
1414
1515#[derive(Copy, Clone, Eq, PartialEq, Hash, Serialize)]
1616pub struct Ty(usize);
compiler/stable_mir/src/visitor.rs+2-2
......@@ -1,11 +1,11 @@
11use std::ops::ControlFlow;
22
3use crate::{ty::TyConst, Opaque};
4
53use super::ty::{
64 Allocation, Binder, ConstDef, ExistentialPredicate, FnSig, GenericArgKind, GenericArgs,
75 MirConst, Promoted, Region, RigidTy, TermKind, Ty, UnevaluatedConst,
86};
7use crate::ty::TyConst;
8use crate::Opaque;
99
1010pub trait Visitor: Sized {
1111 type Break;
library/alloc/benches/btree/map.rs+2-1
......@@ -1,7 +1,8 @@
11use std::collections::BTreeMap;
22use std::ops::RangeBounds;
33
4use rand::{seq::SliceRandom, Rng};
4use rand::seq::SliceRandom;
5use rand::Rng;
56use test::{black_box, Bencher};
67
78macro_rules! map_insert_rand_bench {
library/alloc/benches/linked_list.rs+1
......@@ -1,4 +1,5 @@
11use std::collections::LinkedList;
2
23use test::Bencher;
34
45#[bench]
library/alloc/benches/string.rs+1
......@@ -1,4 +1,5 @@
11use std::iter::repeat;
2
23use test::{black_box, Bencher};
34
45#[bench]
library/alloc/benches/vec.rs+2-1
......@@ -1,5 +1,6 @@
1use rand::RngCore;
21use std::iter::repeat;
2
3use rand::RngCore;
34use test::{black_box, Bencher};
45
56#[bench]
library/alloc/benches/vec_deque.rs+3-4
......@@ -1,7 +1,6 @@
1use std::{
2 collections::{vec_deque, VecDeque},
3 mem,
4};
1use std::collections::{vec_deque, VecDeque};
2use std::mem;
3
54use test::{black_box, Bencher};
65
76#[bench]
library/alloc/benches/vec_deque_append.rs+2-1
......@@ -1,4 +1,5 @@
1use std::{collections::VecDeque, time::Instant};
1use std::collections::VecDeque;
2use std::time::Instant;
23
34const VECDEQUE_LEN: i32 = 100000;
45const WARMUP_N: usize = 100;
library/alloc/src/alloc.rs+3-5
......@@ -2,16 +2,14 @@
22
33#![stable(feature = "alloc_module", since = "1.28.0")]
44
5#[stable(feature = "alloc_module", since = "1.28.0")]
6#[doc(inline)]
7pub use core::alloc::*;
58#[cfg(not(test))]
69use core::hint;
7
810#[cfg(not(test))]
911use core::ptr::{self, NonNull};
1012
11#[stable(feature = "alloc_module", since = "1.28.0")]
12#[doc(inline)]
13pub use core::alloc::*;
14
1513#[cfg(test)]
1614mod tests;
1715
library/alloc/src/alloc/tests.rs+2-1
......@@ -1,9 +1,10 @@
11use super::*;
22
33extern crate test;
4use crate::boxed::Box;
54use test::Bencher;
65
6use crate::boxed::Box;
7
78#[test]
89fn allocate_zeroed() {
910 unsafe {
library/alloc/src/borrow.rs+3-4
......@@ -2,21 +2,20 @@
22
33#![stable(feature = "rust1", since = "1.0.0")]
44
5#[stable(feature = "rust1", since = "1.0.0")]
6pub use core::borrow::{Borrow, BorrowMut};
57use core::cmp::Ordering;
68use core::hash::{Hash, Hasher};
79#[cfg(not(no_global_oom_handling))]
810use core::ops::{Add, AddAssign};
911use core::ops::{Deref, DerefPure};
1012
11#[stable(feature = "rust1", since = "1.0.0")]
12pub use core::borrow::{Borrow, BorrowMut};
13use Cow::*;
1314
1415use crate::fmt;
1516#[cfg(not(no_global_oom_handling))]
1617use crate::string::String;
1718
18use Cow::*;
19
2019#[stable(feature = "rust1", since = "1.0.0")]
2120impl<'a, B: ?Sized> Borrow<B> for Cow<'a, B>
2221where
library/alloc/src/boxed.rs+7-10
......@@ -187,26 +187,26 @@
187187
188188use core::any::Any;
189189use core::async_iter::AsyncIterator;
190use core::borrow;
191190#[cfg(not(no_global_oom_handling))]
192191use core::clone::CloneToUninit;
193192use core::cmp::Ordering;
194193use core::error::Error;
195use core::fmt;
196194use core::future::Future;
197195use core::hash::{Hash, Hasher};
198196use core::iter::FusedIterator;
199use core::marker::Tuple;
200use core::marker::Unsize;
197use core::marker::{Tuple, Unsize};
201198use core::mem::{self, SizedTypeProperties};
202use core::ops::{AsyncFn, AsyncFnMut, AsyncFnOnce};
203199use core::ops::{
204 CoerceUnsized, Coroutine, CoroutineState, Deref, DerefMut, DerefPure, DispatchFromDyn, Receiver,
200 AsyncFn, AsyncFnMut, AsyncFnOnce, CoerceUnsized, Coroutine, CoroutineState, Deref, DerefMut,
201 DerefPure, DispatchFromDyn, Receiver,
205202};
206203use core::pin::Pin;
207204use core::ptr::{self, addr_of_mut, NonNull, Unique};
208use core::slice;
209205use core::task::{Context, Poll};
206use core::{borrow, fmt, slice};
207
208#[unstable(feature = "thin_box", issue = "92791")]
209pub use thin::ThinBox;
210210
211211#[cfg(not(no_global_oom_handling))]
212212use crate::alloc::handle_alloc_error;
......@@ -222,9 +222,6 @@ use crate::vec;
222222#[cfg(not(no_global_oom_handling))]
223223use crate::vec::Vec;
224224
225#[unstable(feature = "thin_box", issue = "92791")]
226pub use thin::ThinBox;
227
228225mod thin;
229226
230227/// A pointer type that uniquely owns a heap allocation of type `T`.
library/alloc/src/boxed/thin.rs+3-3
......@@ -2,7 +2,6 @@
22//! <https://github.com/matthieu-m/rfc2580/blob/b58d1d3cba0d4b5e859d3617ea2d0943aaa31329/examples/thin.rs>
33//! by matthieu-m
44
5use crate::alloc::{self, Layout, LayoutError};
65use core::error::Error;
76use core::fmt::{self, Debug, Display, Formatter};
87#[cfg(not(no_global_oom_handling))]
......@@ -14,8 +13,9 @@ use core::mem;
1413#[cfg(not(no_global_oom_handling))]
1514use core::mem::SizedTypeProperties;
1615use core::ops::{Deref, DerefMut};
17use core::ptr::Pointee;
18use core::ptr::{self, NonNull};
16use core::ptr::{self, NonNull, Pointee};
17
18use crate::alloc::{self, Layout, LayoutError};
1919
2020/// ThinBox.
2121///
library/alloc/src/collections/binary_heap/mod.rs+1-2
......@@ -144,12 +144,11 @@
144144#![stable(feature = "rust1", since = "1.0.0")]
145145
146146use core::alloc::Allocator;
147use core::fmt;
148147use core::iter::{FusedIterator, InPlaceIterable, SourceIter, TrustedFused, TrustedLen};
149148use core::mem::{self, swap, ManuallyDrop};
150149use core::num::NonZero;
151150use core::ops::{Deref, DerefMut};
152use core::ptr;
151use core::{fmt, ptr};
153152
154153use crate::alloc::Global;
155154use crate::collections::TryReserveError;
library/alloc/src/collections/binary_heap/tests.rs+4-2
......@@ -1,7 +1,8 @@
1use std::panic::{catch_unwind, AssertUnwindSafe};
2
13use super::*;
24use crate::boxed::Box;
35use crate::testing::crash_test::{CrashTestDummy, Panic};
4use std::panic::{catch_unwind, AssertUnwindSafe};
56
67#[test]
78fn test_iterator() {
......@@ -504,11 +505,12 @@ fn test_retain_catch_unwind() {
504505#[cfg(not(target_os = "emscripten"))]
505506#[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")]
506507fn panic_safe() {
507 use rand::seq::SliceRandom;
508508 use std::cmp;
509509 use std::panic::{self, AssertUnwindSafe};
510510 use std::sync::atomic::{AtomicUsize, Ordering};
511511
512 use rand::seq::SliceRandom;
513
512514 static DROP_COUNTER: AtomicUsize = AtomicUsize::new(0);
513515
514516 #[derive(Eq, PartialEq, Ord, Clone, Debug)]
library/alloc/src/collections/btree/append.rs+3-2
......@@ -1,8 +1,9 @@
1use super::merge_iter::MergeIterInner;
2use super::node::{self, Root};
31use core::alloc::Allocator;
42use core::iter::FusedIterator;
53
4use super::merge_iter::MergeIterInner;
5use super::node::{self, Root};
6
67impl<K, V> Root<K, V> {
78 /// Appends all key-value pairs from the union of two ascending iterators,
89 /// incrementing a `length` variable along the way. The latter makes it
library/alloc/src/collections/btree/fix.rs+5-2
......@@ -1,7 +1,10 @@
1use super::map::MIN_LEN;
2use super::node::{marker, ForceResult::*, Handle, LeftOrRight::*, NodeRef, Root};
31use core::alloc::Allocator;
42
3use super::map::MIN_LEN;
4use super::node::ForceResult::*;
5use super::node::LeftOrRight::*;
6use super::node::{marker, Handle, NodeRef, Root};
7
58impl<'a, K: 'a, V: 'a> NodeRef<marker::Mut<'a>, K, V, marker::LeafOrInternal> {
69 /// Stocks up a possibly underfull node by merging with or stealing from a
710 /// 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 @@
1use crate::vec::Vec;
21use core::borrow::Borrow;
32use core::cmp::Ordering;
43use core::error::Error;
......@@ -10,20 +9,21 @@ use core::mem::{self, ManuallyDrop};
109use core::ops::{Bound, Index, RangeBounds};
1110use core::ptr;
1211
13use crate::alloc::{Allocator, Global};
14
1512use super::borrow::DormantMutRef;
1613use super::dedup_sorted_iter::DedupSortedIter;
1714use super::navigate::{LazyLeafRange, LeafRange};
18use super::node::{self, marker, ForceResult::*, Handle, NodeRef, Root};
19use super::search::{SearchBound, SearchResult::*};
15use super::node::ForceResult::*;
16use super::node::{self, marker, Handle, NodeRef, Root};
17use super::search::SearchBound;
18use super::search::SearchResult::*;
2019use super::set_val::SetValZST;
20use crate::alloc::{Allocator, Global};
21use crate::vec::Vec;
2122
2223mod entry;
2324
2425#[stable(feature = "rust1", since = "1.0.0")]
2526pub use entry::{Entry, OccupiedEntry, OccupiedError, VacantEntry};
26
2727use Entry::*;
2828
2929/// 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};
22use core::marker::PhantomData;
33use core::mem;
44
5use crate::alloc::{Allocator, Global};
5use Entry::*;
66
77use super::super::borrow::DormantMutRef;
88use super::super::node::{marker, Handle, NodeRef};
99use super::BTreeMap;
10
11use Entry::*;
10use crate::alloc::{Allocator, Global};
1211
1312/// A view into a single entry in a map, which may either be vacant or occupied.
1413///
library/alloc/src/collections/btree/map/tests.rs+7-5
......@@ -1,3 +1,10 @@
1use core::assert_matches::assert_matches;
2use std::iter;
3use std::ops::Bound::{Excluded, Included, Unbounded};
4use std::panic::{catch_unwind, AssertUnwindSafe};
5use std::sync::atomic::AtomicUsize;
6use std::sync::atomic::Ordering::SeqCst;
7
18use super::*;
29use crate::boxed::Box;
310use crate::fmt::Debug;
......@@ -6,11 +13,6 @@ use crate::string::{String, ToString};
613use crate::testing::crash_test::{CrashTestDummy, Panic};
714use crate::testing::ord_chaos::{Cyclic3, Governed, Governor};
815use crate::testing::rng::DeterministicRng;
9use core::assert_matches::assert_matches;
10use std::iter;
11use std::ops::Bound::{Excluded, Included, Unbounded};
12use std::panic::{catch_unwind, AssertUnwindSafe};
13use std::sync::atomic::{AtomicUsize, Ordering::SeqCst};
1416
1517// Minimum number of elements to insert, to guarantee a tree with 2 levels,
1618// 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 @@
1use core::intrinsics;
2use core::mem;
3use core::ptr;
1use core::{intrinsics, mem, ptr};
42
53/// This replaces the value behind the `v` unique reference by calling the
64/// relevant function.
library/alloc/src/collections/btree/navigate.rs+3-4
......@@ -1,11 +1,10 @@
11use core::borrow::Borrow;
2use core::hint;
32use core::ops::RangeBounds;
4use core::ptr;
3use core::{hint, ptr};
54
6use super::node::{marker, ForceResult::*, Handle, NodeRef};
5use super::node::ForceResult::*;
6use super::node::{marker, Handle, NodeRef};
77use super::search::SearchBound;
8
98use crate::alloc::Allocator;
109// `front` and `back` are always both `None` or both `Some`.
1110pub struct LeafRange<BorrowType, K, V> {
library/alloc/src/collections/btree/remove.rs+5-2
......@@ -1,7 +1,10 @@
1use super::map::MIN_LEN;
2use super::node::{marker, ForceResult::*, Handle, LeftOrRight::*, NodeRef};
31use core::alloc::Allocator;
42
3use super::map::MIN_LEN;
4use super::node::ForceResult::*;
5use super::node::LeftOrRight::*;
6use super::node::{marker, Handle, NodeRef};
7
58impl<'a, K: 'a, V: 'a> Handle<NodeRef<marker::Mut<'a>, K, V, marker::LeafOrInternal>, marker::KV> {
69 /// Removes a key-value pair from the tree, and returns that pair, as well as
710 /// 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;
22use core::cmp::Ordering;
33use core::ops::{Bound, RangeBounds};
44
5use super::node::{marker, ForceResult::*, Handle, NodeRef};
6
75use SearchBound::*;
86use SearchResult::*;
97
8use super::node::ForceResult::*;
9use super::node::{marker, Handle, NodeRef};
10
1011pub enum SearchBound<T> {
1112 /// An inclusive bound to look for, just like `Bound::Included(T)`.
1213 Included(T),
library/alloc/src/collections/btree/set.rs+1-2
......@@ -1,4 +1,3 @@
1use crate::vec::Vec;
21use core::borrow::Borrow;
32use core::cmp::Ordering::{self, Equal, Greater, Less};
43use core::cmp::{max, min};
......@@ -12,8 +11,8 @@ use super::map::{BTreeMap, Keys};
1211use super::merge_iter::MergeIterInner;
1312use super::set_val::SetValZST;
1413use super::Recover;
15
1614use crate::alloc::{Allocator, Global};
15use crate::vec::Vec;
1716
1817/// An ordered set based on a B-Tree.
1918///
library/alloc/src/collections/btree/set/tests.rs+3-2
......@@ -1,8 +1,9 @@
1use std::ops::Bound::{Excluded, Included};
2use std::panic::{catch_unwind, AssertUnwindSafe};
3
14use super::*;
25use crate::testing::crash_test::{CrashTestDummy, Panic};
36use crate::testing::rng::DeterministicRng;
4use std::ops::Bound::{Excluded, Included};
5use std::panic::{catch_unwind, AssertUnwindSafe};
67
78#[test]
89fn test_clone_eq() {
library/alloc/src/collections/btree/split.rs+4-2
......@@ -1,8 +1,10 @@
1use super::node::{ForceResult::*, Root};
2use super::search::SearchResult::*;
31use core::alloc::Allocator;
42use core::borrow::Borrow;
53
4use super::node::ForceResult::*;
5use super::node::Root;
6use super::search::SearchResult::*;
7
68impl<K, V> Root<K, V> {
79 /// Calculates the length of both trees that result from splitting up
810 /// a given number of distinct key-value pairs.
library/alloc/src/collections/linked_list.rs+1-2
......@@ -13,12 +13,11 @@
1313#![stable(feature = "rust1", since = "1.0.0")]
1414
1515use core::cmp::Ordering;
16use core::fmt;
1716use core::hash::{Hash, Hasher};
1817use core::iter::FusedIterator;
1918use core::marker::PhantomData;
20use core::mem;
2119use core::ptr::NonNull;
20use core::{fmt, mem};
2221
2322use super::SpecExtend;
2423use crate::alloc::{Allocator, Global};
library/alloc/src/collections/linked_list/tests.rs+5-7
......@@ -1,12 +1,12 @@
1use super::*;
2use crate::testing::crash_test::{CrashTestDummy, Panic};
3use crate::vec::Vec;
4
51use std::panic::{catch_unwind, AssertUnwindSafe};
62use std::thread;
73
84use rand::RngCore;
95
6use super::*;
7use crate::testing::crash_test::{CrashTestDummy, Panic};
8use crate::vec::Vec;
9
1010#[test]
1111fn test_basic() {
1212 let mut m = LinkedList::<Box<_>>::new();
......@@ -1167,9 +1167,7 @@ fn test_drop_panic() {
11671167
11681168#[test]
11691169fn test_allocator() {
1170 use core::alloc::AllocError;
1171 use core::alloc::Allocator;
1172 use core::alloc::Layout;
1170 use core::alloc::{AllocError, Allocator, Layout};
11731171 use core::cell::Cell;
11741172
11751173 struct A {
library/alloc/src/collections/mod.rs+2-5
......@@ -27,33 +27,30 @@ pub mod btree_set {
2727 pub use super::btree::set::*;
2828}
2929
30use core::fmt::Display;
31
3032#[cfg(not(no_global_oom_handling))]
3133#[stable(feature = "rust1", since = "1.0.0")]
3234#[doc(no_inline)]
3335pub use binary_heap::BinaryHeap;
34
3536#[cfg(not(no_global_oom_handling))]
3637#[stable(feature = "rust1", since = "1.0.0")]
3738#[doc(no_inline)]
3839pub use btree_map::BTreeMap;
39
4040#[cfg(not(no_global_oom_handling))]
4141#[stable(feature = "rust1", since = "1.0.0")]
4242#[doc(no_inline)]
4343pub use btree_set::BTreeSet;
44
4544#[cfg(not(no_global_oom_handling))]
4645#[stable(feature = "rust1", since = "1.0.0")]
4746#[doc(no_inline)]
4847pub use linked_list::LinkedList;
49
5048#[cfg(not(no_global_oom_handling))]
5149#[stable(feature = "rust1", since = "1.0.0")]
5250#[doc(no_inline)]
5351pub use vec_deque::VecDeque;
5452
5553use crate::alloc::{Layout, LayoutError};
56use core::fmt::Display;
5754
5855/// The error type for `try_reserve` methods.
5956#[derive(Clone, PartialEq, Eq, Debug)]
library/alloc/src/collections/vec_deque/drain.rs+1-2
......@@ -4,9 +4,8 @@ use core::mem::{self, SizedTypeProperties};
44use core::ptr::NonNull;
55use core::{fmt, ptr};
66
7use crate::alloc::{Allocator, Global};
8
97use super::VecDeque;
8use crate::alloc::{Allocator, Global};
109
1110/// A draining iterator over the elements of a `VecDeque`.
1211///
library/alloc/src/collections/vec_deque/into_iter.rs+4-3
......@@ -1,10 +1,11 @@
11use core::iter::{FusedIterator, TrustedLen};
2use core::mem::MaybeUninit;
23use core::num::NonZero;
3use core::{array, fmt, mem::MaybeUninit, ops::Try, ptr};
4
5use crate::alloc::{Allocator, Global};
4use core::ops::Try;
5use core::{array, fmt, ptr};
66
77use super::VecDeque;
8use crate::alloc::{Allocator, Global};
89
910/// An owning iterator over the elements of a `VecDeque`.
1011///
library/alloc/src/collections/vec_deque/mod.rs+4-8
......@@ -8,23 +8,19 @@
88#![stable(feature = "rust1", since = "1.0.0")]
99
1010use core::cmp::{self, Ordering};
11use core::fmt;
1211use core::hash::{Hash, Hasher};
1312use core::iter::{repeat_n, repeat_with, ByRefSized};
14use core::mem::{ManuallyDrop, SizedTypeProperties};
15use core::ops::{Index, IndexMut, Range, RangeBounds};
16use core::ptr;
17use core::slice;
18
1913// This is used in a bunch of intra-doc links.
2014// FIXME: For some reason, `#[cfg(doc)]` wasn't sufficient, resulting in
2115// failures in linkchecker even though rustdoc built the docs just fine.
2216#[allow(unused_imports)]
2317use core::mem;
18use core::mem::{ManuallyDrop, SizedTypeProperties};
19use core::ops::{Index, IndexMut, Range, RangeBounds};
20use core::{fmt, ptr, slice};
2421
2522use crate::alloc::{Allocator, Global};
26use crate::collections::TryReserveError;
27use crate::collections::TryReserveErrorKind;
23use crate::collections::{TryReserveError, TryReserveErrorKind};
2824use crate::raw_vec::RawVec;
2925use crate::vec::Vec;
3026
library/alloc/src/collections/vec_deque/spec_extend.rs+2-2
......@@ -1,9 +1,9 @@
1use crate::alloc::Allocator;
2use crate::vec;
31use core::iter::TrustedLen;
42use core::slice;
53
64use super::VecDeque;
5use crate::alloc::Allocator;
6use crate::vec;
77
88// Specialization trait used for VecDeque::extend
99pub(super) trait SpecExtend<T, I> {
library/alloc/src/ffi/c_str.rs+7-11
......@@ -3,25 +3,21 @@
33#[cfg(test)]
44mod tests;
55
6use crate::borrow::{Cow, ToOwned};
7use crate::boxed::Box;
8use crate::rc::Rc;
9use crate::slice::hack::into_vec;
10use crate::string::String;
11use crate::vec::Vec;
126use core::borrow::Borrow;
137use core::ffi::{c_char, CStr};
14use core::fmt;
15use core::mem;
168use core::num::NonZero;
17use core::ops;
18use core::ptr;
19use core::slice;
209use core::slice::memchr;
2110use core::str::{self, Utf8Error};
11use core::{fmt, mem, ops, ptr, slice};
2212
13use crate::borrow::{Cow, ToOwned};
14use crate::boxed::Box;
15use crate::rc::Rc;
16use crate::slice::hack::into_vec;
17use crate::string::String;
2318#[cfg(target_has_atomic = "ptr")]
2419use crate::sync::Arc;
20use crate::vec::Vec;
2521
2622/// A type representing an owned, C-compatible, nul-terminated string with no nul bytes in the
2723/// middle.
library/alloc/src/ffi/c_str/tests.rs+3-3
......@@ -1,10 +1,10 @@
1use super::*;
21use core::assert_matches::assert_matches;
32use core::ffi::FromBytesUntilNulError;
4use core::hash::{Hash, Hasher};
5
63#[allow(deprecated)]
74use core::hash::SipHasher13 as DefaultHasher;
5use core::hash::{Hash, Hasher};
6
7use super::*;
88
99#[test]
1010fn c_to_rust() {
library/alloc/src/ffi/mod.rs+3-4
......@@ -80,13 +80,12 @@
8080
8181#![stable(feature = "alloc_ffi", since = "1.64.0")]
8282
83#[doc(no_inline)]
84#[stable(feature = "alloc_c_string", since = "1.64.0")]
85pub use self::c_str::{FromVecWithNulError, IntoStringError, NulError};
86
8783#[doc(inline)]
8884#[stable(feature = "alloc_c_string", since = "1.64.0")]
8985pub use self::c_str::CString;
86#[doc(no_inline)]
87#[stable(feature = "alloc_c_string", since = "1.64.0")]
88pub use self::c_str::{FromVecWithNulError, IntoStringError, NulError};
9089
9190#[unstable(feature = "c_str_module", issue = "112134")]
9291pub mod c_str;
library/alloc/src/raw_vec.rs+1-2
......@@ -1,10 +1,9 @@
11#![unstable(feature = "raw_vec_internals", reason = "unstable const warnings", issue = "none")]
22
33use core::alloc::LayoutError;
4use core::cmp;
5use core::hint;
64use core::mem::{self, ManuallyDrop, MaybeUninit, SizedTypeProperties};
75use core::ptr::{self, NonNull, Unique};
6use core::{cmp, hint};
87
98#[cfg(not(no_global_oom_handling))]
109use crate::alloc::handle_alloc_error;
library/alloc/src/raw_vec/tests.rs+2-1
......@@ -1,7 +1,8 @@
1use super::*;
21use core::mem::size_of;
32use std::cell::Cell;
43
4use super::*;
5
56#[test]
67fn allocator_param() {
78 use crate::alloc::AllocError;
library/alloc/src/rc.rs+5-8
......@@ -241,20 +241,12 @@
241241
242242#![stable(feature = "rust1", since = "1.0.0")]
243243
244#[cfg(not(test))]
245use crate::boxed::Box;
246#[cfg(test)]
247use std::boxed::Box;
248
249244use core::any::Any;
250use core::borrow;
251245use core::cell::Cell;
252246#[cfg(not(no_global_oom_handling))]
253247use core::clone::CloneToUninit;
254248use core::cmp::Ordering;
255use core::fmt;
256249use core::hash::{Hash, Hasher};
257use core::hint;
258250use core::intrinsics::abort;
259251#[cfg(not(no_global_oom_handling))]
260252use core::iter;
......@@ -267,11 +259,16 @@ use core::pin::Pin;
267259use core::ptr::{self, drop_in_place, NonNull};
268260#[cfg(not(no_global_oom_handling))]
269261use core::slice::from_raw_parts_mut;
262use core::{borrow, fmt, hint};
263#[cfg(test)]
264use std::boxed::Box;
270265
271266#[cfg(not(no_global_oom_handling))]
272267use crate::alloc::handle_alloc_error;
273268use crate::alloc::{AllocError, Allocator, Global, Layout};
274269use crate::borrow::{Cow, ToOwned};
270#[cfg(not(test))]
271use crate::boxed::Box;
275272#[cfg(not(no_global_oom_handling))]
276273use crate::string::String;
277274#[cfg(not(no_global_oom_handling))]
library/alloc/src/rc/tests.rs+2-2
......@@ -1,8 +1,8 @@
1use super::*;
2
31use std::cell::RefCell;
42use std::clone::Clone;
53
4use super::*;
5
66#[test]
77fn test_clone() {
88 let x = Rc::new(RefCell::new(5));
library/alloc/src/slice.rs-1
......@@ -78,7 +78,6 @@ pub use core::slice::{SplitInclusive, SplitInclusiveMut};
7878// N.B., see the `hack` module in this file for more details.
7979#[cfg(test)]
8080pub use hack::into_vec;
81
8281// HACK(japaric) needed for the implementation of `Vec::clone` during testing
8382// N.B., see the `hack` module in this file for more details.
8483#[cfg(test)]
library/alloc/src/slice/tests.rs+12-9
......@@ -1,18 +1,21 @@
1use core::cell::Cell;
2use core::cmp::Ordering::{self, Equal, Greater, Less};
3use core::convert::identity;
4use core::sync::atomic::AtomicUsize;
5use core::sync::atomic::Ordering::Relaxed;
6use core::{fmt, mem};
7use std::panic;
8
9use rand::distributions::Standard;
10use rand::prelude::*;
11use rand::{Rng, RngCore};
12
113use crate::borrow::ToOwned;
214use crate::rc::Rc;
315use crate::string::ToString;
416use crate::test_helpers::test_rng;
517use crate::vec::Vec;
618
7use core::cell::Cell;
8use core::cmp::Ordering::{self, Equal, Greater, Less};
9use core::convert::identity;
10use core::fmt;
11use core::mem;
12use core::sync::atomic::{AtomicUsize, Ordering::Relaxed};
13use rand::{distributions::Standard, prelude::*, Rng, RngCore};
14use std::panic;
15
1619macro_rules! do_test {
1720 ($input:ident, $func:ident) => {
1821 let len = $input.len();
library/alloc/src/str.rs+9-11
......@@ -9,19 +9,9 @@
99
1010use core::borrow::{Borrow, BorrowMut};
1111use core::iter::FusedIterator;
12use core::mem;
13use core::ptr;
14use core::str::pattern::{DoubleEndedSearcher, Pattern, ReverseSearcher, Searcher};
15use core::unicode::conversions;
16
17use crate::borrow::ToOwned;
18use crate::boxed::Box;
19use crate::slice::{Concat, Join, SliceIndex};
20use crate::string::String;
21use crate::vec::Vec;
22
2312#[stable(feature = "rust1", since = "1.0.0")]
2413pub use core::str::pattern;
14use core::str::pattern::{DoubleEndedSearcher, Pattern, ReverseSearcher, Searcher};
2515#[stable(feature = "encode_utf16", since = "1.8.0")]
2616pub use core::str::EncodeUtf16;
2717#[stable(feature = "split_ascii_whitespace", since = "1.34.0")]
......@@ -55,6 +45,14 @@ pub use core::str::{RSplitN, SplitN};
5545pub use core::str::{RSplitTerminator, SplitTerminator};
5646#[stable(feature = "utf8_chunks", since = "1.79.0")]
5747pub use core::str::{Utf8Chunk, Utf8Chunks};
48use core::unicode::conversions;
49use core::{mem, ptr};
50
51use crate::borrow::ToOwned;
52use crate::boxed::Box;
53use crate::slice::{Concat, Join, SliceIndex};
54use crate::string::String;
55use crate::vec::Vec;
5856
5957/// Note: `str` in `Concat<str>` is not meaningful here.
6058/// This type parameter of the trait only exists to enable another impl.
library/alloc/src/string.rs+1-4
......@@ -43,8 +43,6 @@
4343#![stable(feature = "rust1", since = "1.0.0")]
4444
4545use core::error::Error;
46use core::fmt;
47use core::hash;
4846#[cfg(not(no_global_oom_handling))]
4947use core::iter::from_fn;
5048use core::iter::FusedIterator;
......@@ -55,9 +53,8 @@ use core::ops::AddAssign;
5553#[cfg(not(no_global_oom_handling))]
5654use core::ops::Bound::{Excluded, Included, Unbounded};
5755use core::ops::{self, Range, RangeBounds};
58use core::ptr;
59use core::slice;
6056use core::str::pattern::Pattern;
57use core::{fmt, hash, ptr, slice};
6158
6259#[cfg(not(no_global_oom_handling))]
6360use crate::alloc::Allocator;
library/alloc/src/sync.rs+1-3
......@@ -9,13 +9,10 @@
99//! `#[cfg(target_has_atomic = "ptr")]`.
1010
1111use core::any::Any;
12use core::borrow;
1312#[cfg(not(no_global_oom_handling))]
1413use core::clone::CloneToUninit;
1514use core::cmp::Ordering;
16use core::fmt;
1715use core::hash::{Hash, Hasher};
18use core::hint;
1916use core::intrinsics::abort;
2017#[cfg(not(no_global_oom_handling))]
2118use core::iter;
......@@ -29,6 +26,7 @@ use core::ptr::{self, NonNull};
2926use core::slice::from_raw_parts_mut;
3027use core::sync::atomic;
3128use core::sync::atomic::Ordering::{Acquire, Relaxed, Release};
29use core::{borrow, fmt, hint};
3230
3331#[cfg(not(no_global_oom_handling))]
3432use crate::alloc::handle_alloc_error;
library/alloc/src/sync/tests.rs+2-2
......@@ -1,5 +1,3 @@
1use super::*;
2
31use std::clone::Clone;
42use std::mem::MaybeUninit;
53use std::option::Option::None;
......@@ -9,6 +7,8 @@ use std::sync::mpsc::channel;
97use std::sync::Mutex;
108use std::thread;
119
10use super::*;
11
1212struct Canary(*mut AtomicUsize);
1313
1414impl Drop for Canary {
library/alloc/src/task.rs+3-3
......@@ -7,14 +7,14 @@
77//! This may be detected at compile time using
88//! `#[cfg(target_has_atomic = "ptr")]`.
99
10use crate::rc::Rc;
1110use core::mem::ManuallyDrop;
11#[cfg(target_has_atomic = "ptr")]
12use core::task::Waker;
1213use core::task::{LocalWaker, RawWaker, RawWakerVTable};
1314
15use crate::rc::Rc;
1416#[cfg(target_has_atomic = "ptr")]
1517use crate::sync::Arc;
16#[cfg(target_has_atomic = "ptr")]
17use core::task::Waker;
1818
1919/// The implementation of waking a task on an executor.
2020///
library/alloc/src/testing/crash_test.rs+4-2
......@@ -1,6 +1,8 @@
1use crate::fmt::Debug; // the `Debug` trait is the only thing we use from `crate::fmt`
21use std::cmp::Ordering;
3use std::sync::atomic::{AtomicUsize, Ordering::SeqCst};
2use std::sync::atomic::AtomicUsize;
3use std::sync::atomic::Ordering::SeqCst;
4
5use crate::fmt::Debug; // the `Debug` trait is the only thing we use from `crate::fmt`
46
57/// A blueprint for crash test dummy instances that monitor particular events.
68/// Some instances may be configured to panic at some point.
library/alloc/src/tests.rs-1
......@@ -2,7 +2,6 @@
22
33use core::any::Any;
44use core::ops::Deref;
5
65use std::boxed::Box;
76
87#[test]
library/alloc/src/vec/cow.rs+1-2
......@@ -1,6 +1,5 @@
1use crate::borrow::Cow;
2
31use super::Vec;
2use crate::borrow::Cow;
43
54#[stable(feature = "cow_from_vec", since = "1.8.0")]
65impl<'a, T: Clone> From<&'a [T]> for Cow<'a, [T]> {
library/alloc/src/vec/drain.rs+1-1
......@@ -1,4 +1,3 @@
1use crate::alloc::{Allocator, Global};
21use core::fmt;
32use core::iter::{FusedIterator, TrustedLen};
43use core::mem::{self, ManuallyDrop, SizedTypeProperties};
......@@ -6,6 +5,7 @@ use core::ptr::{self, NonNull};
65use core::slice::{self};
76
87use super::Vec;
8use crate::alloc::{Allocator, Global};
99
1010/// A draining iterator for `Vec<T>`.
1111///
library/alloc/src/vec/extract_if.rs+2-3
......@@ -1,8 +1,7 @@
1use crate::alloc::{Allocator, Global};
2use core::ptr;
3use core::slice;
1use core::{ptr, slice};
42
53use super::Vec;
4use crate::alloc::{Allocator, Global};
65
76/// An iterator which uses a closure to determine if an element should be removed.
87///
library/alloc/src/vec/in_place_collect.rs+2-3
......@@ -155,9 +155,7 @@
155155//! vec.truncate(write_idx);
156156//! ```
157157
158use crate::alloc::{handle_alloc_error, Global};
159use core::alloc::Allocator;
160use core::alloc::Layout;
158use core::alloc::{Allocator, Layout};
161159use core::iter::{InPlaceIterable, SourceIter, TrustedRandomAccessNoCoerce};
162160use core::marker::PhantomData;
163161use core::mem::{self, ManuallyDrop, SizedTypeProperties};
......@@ -165,6 +163,7 @@ use core::num::NonZero;
165163use core::ptr;
166164
167165use super::{InPlaceDrop, InPlaceDstDataSrcBufDrop, SpecFromIter, SpecFromIterNested, Vec};
166use crate::alloc::{handle_alloc_error, Global};
168167
169168const fn in_place_collectible<DEST, SRC>(
170169 step_merge: Option<NonZero<usize>>,
library/alloc/src/vec/in_place_drop.rs+1-2
......@@ -1,6 +1,5 @@
11use core::marker::PhantomData;
2use core::ptr::NonNull;
3use core::ptr::{self, drop_in_place};
2use core::ptr::{self, drop_in_place, NonNull};
43use core::slice::{self};
54
65use crate::alloc::Global;
library/alloc/src/vec/into_iter.rs+8-8
......@@ -1,11 +1,3 @@
1#[cfg(not(no_global_oom_handling))]
2use super::AsVecIntoIter;
3use crate::alloc::{Allocator, Global};
4#[cfg(not(no_global_oom_handling))]
5use crate::collections::VecDeque;
6use crate::raw_vec::RawVec;
7use core::array;
8use core::fmt;
91use core::iter::{
102 FusedIterator, InPlaceIterable, SourceIter, TrustedFused, TrustedLen,
113 TrustedRandomAccessNoCoerce,
......@@ -17,6 +9,14 @@ use core::num::NonZero;
179use core::ops::Deref;
1810use core::ptr::{self, NonNull};
1911use core::slice::{self};
12use core::{array, fmt};
13
14#[cfg(not(no_global_oom_handling))]
15use super::AsVecIntoIter;
16use crate::alloc::{Allocator, Global};
17#[cfg(not(no_global_oom_handling))]
18use crate::collections::VecDeque;
19use crate::raw_vec::RawVec;
2020
2121macro non_null {
2222 (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};
6666use core::ptr::{self, NonNull};
6767use core::slice::{self, SliceIndex};
6868
69#[unstable(feature = "extract_if", reason = "recently added", issue = "43244")]
70pub use self::extract_if::ExtractIf;
6971use crate::alloc::{Allocator, Global};
7072use crate::borrow::{Cow, ToOwned};
7173use crate::boxed::Box;
7274use crate::collections::TryReserveError;
7375use crate::raw_vec::RawVec;
7476
75#[unstable(feature = "extract_if", reason = "recently added", issue = "43244")]
76pub use self::extract_if::ExtractIf;
77
7877mod extract_if;
7978
8079#[cfg(not(no_global_oom_handling))]
library/alloc/src/vec/partial_eq.rs+1-2
......@@ -1,9 +1,8 @@
1use super::Vec;
12use crate::alloc::Allocator;
23#[cfg(not(no_global_oom_handling))]
34use crate::borrow::Cow;
45
5use super::Vec;
6
76macro_rules! __impl_slice_eq1 {
87 ([$($vars:tt)*] $lhs:ty, $rhs:ty $(where $ty:ty: $bound:ident)?, #[$stability:meta]) => {
98 #[$stability]
library/alloc/src/vec/spec_extend.rs+1-1
......@@ -1,8 +1,8 @@
1use crate::alloc::Allocator;
21use core::iter::TrustedLen;
32use core::slice::{self};
43
54use super::{IntoIter, Vec};
5use crate::alloc::Allocator;
66
77// Specialization trait used for Vec::extend
88pub(super) trait SpecExtend<T, I> {
library/alloc/src/vec/spec_from_elem.rs+1-2
......@@ -1,10 +1,9 @@
11use core::ptr;
22
3use super::{IsZero, Vec};
34use crate::alloc::Allocator;
45use crate::raw_vec::RawVec;
56
6use super::{IsZero, Vec};
7
87// Specialization trait used for Vec::from_elem
98pub(super) trait SpecFromElem: Sized {
109 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 @@
1use core::cmp;
21use core::iter::TrustedLen;
3use core::ptr;
4
5use crate::raw_vec::RawVec;
2use core::{cmp, ptr};
63
74use super::{SpecExtend, Vec};
5use crate::raw_vec::RawVec;
86
97/// Another specialization trait for Vec::from_iter
108/// necessary to manually prioritize overlapping specializations
library/alloc/src/vec/splice.rs+1-1
......@@ -1,8 +1,8 @@
1use crate::alloc::{Allocator, Global};
21use core::ptr::{self};
32use core::slice::{self};
43
54use super::{Drain, Vec};
5use crate::alloc::{Allocator, Global};
66
77/// A splicing iterator for `Vec`.
88///
library/alloc/tests/btree_set_hash.rs+2-1
......@@ -1,6 +1,7 @@
1use crate::hash;
21use std::collections::BTreeSet;
32
3use crate::hash;
4
45#[test]
56fn test_hash() {
67 let mut x = BTreeSet::new();
library/alloc/tests/slice.rs+2-5
......@@ -1,9 +1,7 @@
11use std::cmp::Ordering::{Equal, Greater, Less};
22use std::convert::identity;
3use std::fmt;
4use std::mem;
5use std::panic;
63use std::rc::Rc;
4use std::{fmt, mem, panic};
75
86fn square(n: usize) -> usize {
97 n * n
......@@ -911,8 +909,7 @@ fn test_split_iterators_size_hint() {
911909 // become maximally long, so the size_hint upper bounds are tight
912910 ((|_| true) as fn(&_) -> _, Bounds::Upper),
913911 ] {
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};
916913
917914 a(v.split(p), b, "split");
918915 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() {
165165
166166#[test]
167167fn test_join_issue_80335() {
168 use core::{borrow::Borrow, cell::Cell};
168 use core::borrow::Borrow;
169 use core::cell::Cell;
169170
170171 struct WeirdBorrow {
171172 state: Cell<bool>,
library/alloc/tests/string.rs+2-4
......@@ -2,11 +2,9 @@ use std::assert_matches::assert_matches;
22use std::borrow::Cow;
33use std::cell::Cell;
44use std::collections::TryReserveErrorKind::*;
5use std::ops::Bound;
65use std::ops::Bound::*;
7use std::ops::RangeBounds;
8use std::panic;
9use std::str;
6use std::ops::{Bound, RangeBounds};
7use std::{panic, str};
108
119pub trait IntoCow<'a, B: ?Sized>
1210where
library/alloc/tests/vec.rs+3-3
......@@ -8,15 +8,14 @@ use std::borrow::Cow;
88use std::cell::Cell;
99use std::collections::TryReserveErrorKind::*;
1010use std::fmt::Debug;
11use std::hint;
1211use std::iter::InPlaceIterable;
13use std::mem;
1412use std::mem::{size_of, swap};
1513use std::ops::Bound::*;
1614use std::panic::{catch_unwind, AssertUnwindSafe};
1715use std::rc::Rc;
1816use std::sync::atomic::{AtomicU32, Ordering};
1917use std::vec::{Drain, IntoIter};
18use std::{hint, mem};
2019
2120struct DropCounter<'a> {
2221 count: &'a mut u32,
......@@ -2572,7 +2571,8 @@ fn test_into_flattened_size_overflow() {
25722571
25732572#[test]
25742573fn test_box_zero_allocator() {
2575 use core::{alloc::AllocError, cell::RefCell};
2574 use core::alloc::AllocError;
2575 use core::cell::RefCell;
25762576 use std::collections::HashSet;
25772577
25782578 // Track ZST allocations and ensure that they all have a matching free.
library/alloc/tests/vec_deque.rs+4-3
......@@ -1,16 +1,17 @@
11use core::num::NonZero;
22use std::assert_matches::assert_matches;
3use std::collections::vec_deque::Drain;
34use std::collections::TryReserveErrorKind::*;
4use std::collections::{vec_deque::Drain, VecDeque};
5use std::collections::VecDeque;
56use std::fmt::Debug;
67use std::ops::Bound::*;
78use std::panic::{catch_unwind, AssertUnwindSafe};
89
9use crate::hash;
10
1110use Taggy::*;
1211use Taggypar::*;
1312
13use crate::hash;
14
1415#[test]
1516fn test_simple() {
1617 let mut d = VecDeque::new();
library/alloc/tests/vec_deque_alloc_error.rs+4-6
......@@ -1,11 +1,9 @@
11#![feature(alloc_error_hook, allocator_api)]
22
3use std::{
4 alloc::{set_alloc_error_hook, AllocError, Allocator, Layout, System},
5 collections::VecDeque,
6 panic::{catch_unwind, AssertUnwindSafe},
7 ptr::NonNull,
8};
3use std::alloc::{set_alloc_error_hook, AllocError, Allocator, Layout, System};
4use std::collections::VecDeque;
5use std::panic::{catch_unwind, AssertUnwindSafe};
6use std::ptr::NonNull;
97
108#[test]
119#[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")]
library/core/benches/any.rs+1
......@@ -1,4 +1,5 @@
11use core::any::*;
2
23use test::{black_box, Bencher};
34
45#[bench]
library/core/benches/array.rs+1-2
......@@ -1,5 +1,4 @@
1use test::black_box;
2use test::Bencher;
1use test::{black_box, Bencher};
32
43macro_rules! map_array {
54 ($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 {
6464}
6565
6666use std::fmt::Write;
67use test::black_box;
68use test::Bencher;
67
68use test::{black_box, Bencher};
6969
7070const ASCII_CASE_MASK: u8 = 0b0010_0000;
7171
library/core/benches/ascii/is_ascii.rs+2-2
......@@ -1,6 +1,6 @@
1use test::{black_box, Bencher};
2
13use super::{LONG, MEDIUM, SHORT};
2use test::black_box;
3use test::Bencher;
44
55macro_rules! benches {
66 ($( fn $name: ident($arg: ident: &[u8]) $body: block )+) => {
library/core/benches/fmt.rs+1
......@@ -1,5 +1,6 @@
11use std::fmt::{self, Write as FmtWrite};
22use std::io::{self, Write as IoWrite};
3
34use test::{black_box, Bencher};
45
56#[bench]
library/core/benches/hash/sip.rs+1
......@@ -1,6 +1,7 @@
11#![allow(deprecated)]
22
33use core::hash::*;
4
45use test::{black_box, Bencher};
56
67fn hash_bytes<H: Hasher>(mut s: H, x: &[u8]) -> u64 {
library/core/benches/iter.rs+1
......@@ -3,6 +3,7 @@ use core::iter::*;
33use core::mem;
44use core::num::Wrapping;
55use core::ops::Range;
6
67use test::{black_box, Bencher};
78
89#[bench]
library/core/benches/num/flt2dec/mod.rs+2-2
......@@ -3,9 +3,9 @@ mod strategy {
33 mod grisu;
44}
55
6use core::num::flt2dec::MAX_SIG_DIGITS;
7use core::num::flt2dec::{decode, DecodableFloat, Decoded, FullDecoded};
6use core::num::flt2dec::{decode, DecodableFloat, Decoded, FullDecoded, MAX_SIG_DIGITS};
87use std::io::Write;
8
99use test::{black_box, Bencher};
1010
1111pub fn decode_finite<T: DecodableFloat>(v: T) -> Decoded {
library/core/benches/num/flt2dec/strategy/dragon.rs+2-1
......@@ -1,7 +1,8 @@
1use super::super::*;
21use core::num::flt2dec::strategy::dragon::*;
32use std::mem::MaybeUninit;
43
4use super::super::*;
5
56#[bench]
67fn bench_small_shortest(b: &mut Bencher) {
78 let decoded = decode_finite(3.141592f64);
library/core/benches/num/flt2dec/strategy/grisu.rs+2-1
......@@ -1,7 +1,8 @@
1use super::super::*;
21use core::num::flt2dec::strategy::grisu::*;
32use std::mem::MaybeUninit;
43
4use super::super::*;
5
56pub fn decode_finite<T: DecodableFloat>(v: T) -> Decoded {
67 match decode(v).1 {
78 FullDecoded::Finite(decoded) => decoded,
library/core/benches/num/mod.rs+1
......@@ -4,6 +4,7 @@ mod int_log;
44mod int_pow;
55
66use std::str::FromStr;
7
78use test::{black_box, Bencher};
89
910const ASCII_NUMBERS: [&str; 19] = [
library/core/benches/ops.rs+1
......@@ -1,4 +1,5 @@
11use core::ops::*;
2
23use test::Bencher;
34
45// Overhead of dtors
library/core/benches/pattern.rs+1-2
......@@ -1,5 +1,4 @@
1use test::black_box;
2use test::Bencher;
1use test::{black_box, Bencher};
32
43#[bench]
54fn starts_with_char(b: &mut Bencher) {
library/core/benches/slice.rs+2-2
......@@ -1,6 +1,6 @@
11use core::ptr::NonNull;
2use test::black_box;
3use test::Bencher;
2
3use test::{black_box, Bencher};
44
55enum Cache {
66 L1,
library/core/benches/str.rs+1
......@@ -1,4 +1,5 @@
11use std::str;
2
23use test::{black_box, Bencher};
34
45mod char_count;
library/core/benches/str/char_count.rs+2-1
......@@ -1,6 +1,7 @@
1use super::corpora::*;
21use test::{black_box, Bencher};
32
3use super::corpora::*;
4
45macro_rules! define_benches {
56 ($( fn $name: ident($arg: ident: &str) $body: block )+) => {
67 define_benches!(mod en_tiny, en::TINY, $($name $arg $body)+);
library/core/benches/str/debug.rs+1
......@@ -4,6 +4,7 @@
44//! we should still try to minimize those calls over time rather than regress them.
55
66use std::fmt::{self, Write};
7
78use test::{black_box, Bencher};
89
910#[derive(Default)]
library/core/benches/str/iter.rs+2-1
......@@ -1,6 +1,7 @@
1use super::corpora;
21use test::{black_box, Bencher};
32
3use super::corpora;
4
45#[bench]
56fn chars_advance_by_1000(b: &mut Bencher) {
67 b.iter(|| black_box(corpora::ru::LARGE).chars().advance_by(1000));
library/core/src/alloc/global.rs+1-2
......@@ -1,6 +1,5 @@
11use crate::alloc::Layout;
2use crate::cmp;
3use crate::ptr;
2use crate::{cmp, ptr};
43
54/// A memory allocator that can be registered as the standard library’s default
65/// through the `#[global_allocator]` attribute.
library/core/src/alloc/layout.rs+1-3
......@@ -4,11 +4,9 @@
44// collections, resulting in having to optimize down excess IR multiple times.
55// Your performance intuition is useless. Run perf.
66
7use crate::cmp;
87use crate::error::Error;
9use crate::fmt;
10use crate::mem;
118use crate::ptr::{Alignment, NonNull};
9use crate::{cmp, fmt, mem};
1210
1311// While this function is used in one place and its implementation
1412// 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;
1717)]
1818#[allow(deprecated, deprecated_in_future)]
1919pub use self::layout::LayoutErr;
20
2120#[stable(feature = "alloc_layout_error", since = "1.50.0")]
2221pub use self::layout::LayoutError;
23
2422use crate::error::Error;
2523use crate::fmt;
2624use crate::ptr::{self, NonNull};
library/core/src/any.rs+1-3
......@@ -86,9 +86,7 @@
8686
8787#![stable(feature = "rust1", since = "1.0.0")]
8888
89use crate::fmt;
90use crate::hash;
91use crate::intrinsics;
89use crate::{fmt, hash, intrinsics};
9290
9391///////////////////////////////////////////////////////////////////////////////
9492// Any trait
library/core/src/array/iter.rs+5-8
......@@ -1,14 +1,11 @@
11//! Defines the `IntoIter` owned iterator for arrays.
22
3use crate::intrinsics::transmute_unchecked;
4use crate::iter::{self, FusedIterator, TrustedLen, TrustedRandomAccessNoCoerce};
5use crate::mem::MaybeUninit;
36use crate::num::NonZero;
4use crate::{
5 fmt,
6 intrinsics::transmute_unchecked,
7 iter::{self, FusedIterator, TrustedLen, TrustedRandomAccessNoCoerce},
8 mem::MaybeUninit,
9 ops::{IndexRange, Range},
10 ptr,
11};
7use crate::ops::{IndexRange, Range};
8use crate::{fmt, ptr};
129
1310/// A by-value [array] iterator.
1411#[stable(feature = "array_value_iter", since = "1.51.0")]
library/core/src/array/mod.rs-1
......@@ -23,7 +23,6 @@ mod equality;
2323mod iter;
2424
2525pub(crate) use drain::drain_array_with;
26
2726#[stable(feature = "array_value_iter", since = "1.51.0")]
2827pub use iter::IntoIter;
2928
library/core/src/ascii.rs+1-2
......@@ -9,10 +9,9 @@
99
1010#![stable(feature = "core_ascii", since = "1.26.0")]
1111
12use crate::escape;
13use crate::fmt;
1412use crate::iter::FusedIterator;
1513use crate::num::NonZero;
14use crate::{escape, fmt};
1615
1716mod ascii_char;
1817#[unstable(feature = "ascii_char", issue = "110998")]
library/core/src/asserting.rs+2-4
......@@ -9,10 +9,8 @@
99#![doc(hidden)]
1010#![unstable(feature = "generic_assert_internals", issue = "44838")]
1111
12use crate::{
13 fmt::{Debug, Formatter},
14 marker::PhantomData,
15};
12use crate::fmt::{Debug, Formatter};
13use crate::marker::PhantomData;
1614
1715// ***** TryCapture - Generic *****
1816
library/core/src/async_iter/from_iter.rs+1-2
......@@ -1,6 +1,5 @@
1use crate::pin::Pin;
2
31use crate::async_iter::AsyncIterator;
2use crate::pin::Pin;
43use crate::task::{Context, Poll};
54
65/// An async iterator that was created from iterator.
library/core/src/cell/lazy.rs+1-2
......@@ -1,8 +1,7 @@
1use super::UnsafeCell;
12use crate::ops::Deref;
23use crate::{fmt, mem};
34
4use super::UnsafeCell;
5
65enum State<T, F> {
76 Uninit(F),
87 Init(T),
library/core/src/cell/once.rs+1-2
......@@ -1,6 +1,5 @@
11use crate::cell::UnsafeCell;
2use crate::fmt;
3use crate::mem;
2use crate::{fmt, mem};
43
54/// A cell which can nominally be written to only once.
65///
library/core/src/char/methods.rs+1-2
......@@ -1,12 +1,11 @@
11//! impl char {}
22
3use super::*;
34use crate::slice;
45use crate::str::from_utf8_unchecked_mut;
56use crate::unicode::printable::is_printable;
67use crate::unicode::{self, conversions};
78
8use super::*;
9
109impl char {
1110 /// The lowest valid code point a `char` can have, `'\0'`.
1211 ///
library/core/src/char/mod.rs+1-2
......@@ -42,14 +42,13 @@ pub use self::methods::encode_utf8_raw; // perma-unstable
4242
4343#[rustfmt::skip]
4444use crate::ascii;
45pub(crate) use self::methods::EscapeDebugExtArgs;
4546use crate::error::Error;
4647use crate::escape;
4748use crate::fmt::{self, Write};
4849use crate::iter::{FusedIterator, TrustedLen, TrustedRandomAccess, TrustedRandomAccessNoCoerce};
4950use crate::num::NonZero;
5051
51pub(crate) use self::methods::EscapeDebugExtArgs;
52
5352// UTF-8 ranges and tags for encoding characters
5453const TAG_CONT: u8 = 0b1000_0000;
5554const TAG_TWO_B: u8 = 0b1100_0000;
library/core/src/ffi/c_str.rs+2-7
......@@ -3,16 +3,11 @@
33use crate::cmp::Ordering;
44use crate::error::Error;
55use crate::ffi::c_char;
6use crate::fmt;
7use crate::intrinsics;
86use crate::iter::FusedIterator;
97use crate::marker::PhantomData;
10use crate::ops;
11use crate::ptr::addr_of;
12use crate::ptr::NonNull;
13use crate::slice;
8use crate::ptr::{addr_of, NonNull};
149use crate::slice::memchr;
15use crate::str;
10use crate::{fmt, intrinsics, ops, slice, str};
1611
1712// FIXME: because this is doc(inline)d, we *have* to use intra-doc links because the actual link
1813// 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 @@
99#![stable(feature = "core_ffi", since = "1.30.0")]
1010#![allow(non_camel_case_types)]
1111
12use crate::fmt;
13
14#[doc(no_inline)]
12#[doc(inline)]
1513#[stable(feature = "core_c_str", since = "1.64.0")]
16pub use self::c_str::FromBytesWithNulError;
17
14pub use self::c_str::CStr;
1815#[doc(no_inline)]
1916#[stable(feature = "cstr_from_bytes_until_nul", since = "1.69.0")]
2017pub use self::c_str::FromBytesUntilNulError;
21
22#[doc(inline)]
18#[doc(no_inline)]
2319#[stable(feature = "core_c_str", since = "1.64.0")]
24pub use self::c_str::CStr;
20pub use self::c_str::FromBytesWithNulError;
21use crate::fmt;
2522
2623#[unstable(feature = "c_str_module", issue = "112134")]
2724pub mod c_str;
library/core/src/ffi/va_list.rs-1
......@@ -3,7 +3,6 @@
33//! Better known as "varargs".
44
55use crate::ffi::c_void;
6
76#[allow(unused_imports)]
87use crate::fmt;
98use crate::marker::PhantomData;
library/core/src/fmt/float.rs+1-2
......@@ -1,7 +1,6 @@
11use crate::fmt::{Debug, Display, Formatter, LowerExp, Result, UpperExp};
22use crate::mem::MaybeUninit;
3use crate::num::flt2dec;
4use crate::num::fmt as numfmt;
3use crate::num::{flt2dec, fmt as numfmt};
54
65#[doc(hidden)]
76trait GeneralFormat: PartialOrd {
library/core/src/fmt/mod.rs+3-7
......@@ -4,13 +4,10 @@
44
55use crate::cell::{Cell, Ref, RefCell, RefMut, SyncUnsafeCell, UnsafeCell};
66use crate::char::EscapeDebugExtArgs;
7use crate::iter;
87use crate::marker::PhantomData;
9use crate::mem;
108use crate::num::fmt as numfmt;
119use crate::ops::Deref;
12use crate::result;
13use crate::str;
10use crate::{iter, mem, result, str};
1411
1512mod builders;
1613#[cfg(not(no_fp_fmt_parse))]
......@@ -36,11 +33,10 @@ pub enum Alignment {
3633 Center,
3734}
3835
39#[stable(feature = "debug_builders", since = "1.2.0")]
40pub use self::builders::{DebugList, DebugMap, DebugSet, DebugStruct, DebugTuple};
41
4236#[unstable(feature = "debug_closure_helpers", issue = "117729")]
4337pub use self::builders::FormatterFn;
38#[stable(feature = "debug_builders", since = "1.2.0")]
39pub use self::builders::{DebugList, DebugMap, DebugSet, DebugStruct, DebugTuple};
4440
4541/// The type returned by formatter methods.
4642///
library/core/src/fmt/num.rs+1-4
......@@ -1,12 +1,9 @@
11//! Integer and floating-point number formatting
22
3use crate::fmt;
43use crate::mem::MaybeUninit;
54use crate::num::fmt as numfmt;
65use crate::ops::{Div, Rem, Sub};
7use crate::ptr;
8use crate::slice;
9use crate::str;
6use crate::{fmt, ptr, slice, str};
107
118#[doc(hidden)]
129trait DisplayInt:
library/core/src/future/mod.rs+8-12
......@@ -20,25 +20,21 @@ mod pending;
2020mod poll_fn;
2121mod ready;
2222
23#[stable(feature = "futures_api", since = "1.36.0")]
24pub use self::future::Future;
25
26#[unstable(feature = "future_join", issue = "91642")]
27pub use self::join::join;
28
23#[unstable(feature = "async_drop", issue = "126482")]
24pub use async_drop::{async_drop, async_drop_in_place, AsyncDrop, AsyncDropInPlace};
2925#[stable(feature = "into_future", since = "1.64.0")]
3026pub use into_future::IntoFuture;
31
3227#[stable(feature = "future_readiness_fns", since = "1.48.0")]
3328pub use pending::{pending, Pending};
34#[stable(feature = "future_readiness_fns", since = "1.48.0")]
35pub use ready::{ready, Ready};
36
3729#[stable(feature = "future_poll_fn", since = "1.64.0")]
3830pub use poll_fn::{poll_fn, PollFn};
31#[stable(feature = "future_readiness_fns", since = "1.48.0")]
32pub use ready::{ready, Ready};
3933
40#[unstable(feature = "async_drop", issue = "126482")]
41pub use async_drop::{async_drop, async_drop_in_place, AsyncDrop, AsyncDropInPlace};
34#[stable(feature = "futures_api", since = "1.36.0")]
35pub use self::future::Future;
36#[unstable(feature = "future_join", issue = "91642")]
37pub use self::join::join;
4238
4339/// This type is needed because:
4440///
library/core/src/hash/mod.rs+2-7
......@@ -83,17 +83,14 @@
8383
8484#![stable(feature = "rust1", since = "1.0.0")]
8585
86use crate::fmt;
87use crate::marker;
88
8986#[stable(feature = "rust1", since = "1.0.0")]
9087#[allow(deprecated)]
9188pub use self::sip::SipHasher;
92
9389#[unstable(feature = "hashmap_internals", issue = "none")]
9490#[allow(deprecated)]
9591#[doc(hidden)]
9692pub use self::sip::SipHasher13;
93use crate::{fmt, marker};
9794
9895mod sip;
9996
......@@ -806,10 +803,8 @@ impl<H> PartialEq for BuildHasherDefault<H> {
806803impl<H> Eq for BuildHasherDefault<H> {}
807804
808805mod impls {
809 use crate::mem;
810 use crate::slice;
811
812806 use super::*;
807 use crate::{mem, slice};
813808
814809 macro_rules! impl_write {
815810 ($(($ty:ident, $meth:ident),)*) => {$(
library/core/src/hash/sip.rs+1-3
......@@ -2,10 +2,8 @@
22
33#![allow(deprecated)] // the types in this module are deprecated
44
5use crate::cmp;
65use crate::marker::PhantomData;
7use crate::mem;
8use crate::ptr;
6use crate::{cmp, mem, ptr};
97
108/// An implementation of SipHash 1-3.
119///
library/core/src/hint.rs+1-2
......@@ -3,8 +3,7 @@
33//! Hints to compiler that affects how code should be emitted or optimized.
44//! Hints may be compile time or runtime.
55
6use crate::intrinsics;
7use crate::ub_checks;
6use crate::{intrinsics, ub_checks};
87
98/// Informs the compiler that the site which is calling this function is not
109/// reachable, possibly enabling further optimizations.
library/core/src/intrinsics.rs+2-4
......@@ -63,10 +63,8 @@
6363)]
6464#![allow(missing_docs)]
6565
66use crate::marker::DiscriminantKind;
67use crate::marker::Tuple;
68use crate::ptr;
69use crate::ub_checks;
66use crate::marker::{DiscriminantKind, Tuple};
67use crate::{ptr, ub_checks};
7068
7169pub mod mir;
7270pub mod simd;
library/core/src/intrinsics/mir.rs+1-2
......@@ -276,8 +276,7 @@ pub enum UnwindTerminateReason {
276276 InCleanup,
277277}
278278
279pub use UnwindTerminateReason::Abi as ReasonAbi;
280pub use UnwindTerminateReason::InCleanup as ReasonInCleanup;
279pub use UnwindTerminateReason::{Abi as ReasonAbi, InCleanup as ReasonInCleanup};
281280
282281macro_rules! define {
283282 ($name:literal, $( #[ $meta:meta ] )* fn $($sig:tt)*) => {
library/core/src/iter/adapters/cloned.rs+4-4
......@@ -1,9 +1,9 @@
1use crate::iter::adapters::{
2 zip::try_get_unchecked, SourceIter, TrustedRandomAccess, TrustedRandomAccessNoCoerce,
3};
1use core::num::NonZero;
2
3use crate::iter::adapters::zip::try_get_unchecked;
4use crate::iter::adapters::{SourceIter, TrustedRandomAccess, TrustedRandomAccessNoCoerce};
45use crate::iter::{FusedIterator, InPlaceIterable, TrustedLen, UncheckedIterator};
56use crate::ops::Try;
6use core::num::NonZero;
77
88/// An iterator that clones the elements of an underlying iterator.
99///
library/core/src/iter/adapters/copied.rs+3-5
......@@ -1,9 +1,7 @@
1use crate::iter::adapters::{
2 zip::try_get_unchecked, SourceIter, TrustedRandomAccess, TrustedRandomAccessNoCoerce,
3};
1use crate::iter::adapters::zip::try_get_unchecked;
2use crate::iter::adapters::{SourceIter, TrustedRandomAccess, TrustedRandomAccessNoCoerce};
43use crate::iter::{FusedIterator, InPlaceIterable, TrustedLen};
5use crate::mem::MaybeUninit;
6use crate::mem::SizedTypeProperties;
4use crate::mem::{MaybeUninit, SizedTypeProperties};
75use crate::num::NonZero;
86use crate::ops::Try;
97use crate::{array, ptr};
library/core/src/iter/adapters/cycle.rs+2-1
......@@ -1,5 +1,6 @@
1use crate::iter::FusedIterator;
12use crate::num::NonZero;
2use crate::{iter::FusedIterator, ops::Try};
3use crate::ops::Try;
34
45/// An iterator that repeats endlessly.
56///
library/core/src/iter/adapters/enumerate.rs+2-3
......@@ -1,6 +1,5 @@
1use crate::iter::adapters::{
2 zip::try_get_unchecked, SourceIter, TrustedRandomAccess, TrustedRandomAccessNoCoerce,
3};
1use crate::iter::adapters::zip::try_get_unchecked;
2use crate::iter::adapters::{SourceIter, TrustedRandomAccess, TrustedRandomAccessNoCoerce};
43use crate::iter::{FusedIterator, InPlaceIterable, TrustedFused, TrustedLen};
54use crate::num::NonZero;
65use crate::ops::Try;
library/core/src/iter/adapters/filter.rs+6-4
......@@ -1,11 +1,13 @@
1use crate::fmt;
2use crate::iter::{adapters::SourceIter, FusedIterator, InPlaceIterable, TrustedFused};
3use crate::num::NonZero;
4use crate::ops::Try;
51use core::array;
62use core::mem::MaybeUninit;
73use core::ops::ControlFlow;
84
5use crate::fmt;
6use crate::iter::adapters::SourceIter;
7use crate::iter::{FusedIterator, InPlaceIterable, TrustedFused};
8use crate::num::NonZero;
9use crate::ops::Try;
10
911/// An iterator that filters the elements of `iter` with `predicate`.
1012///
1113/// 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 @@
1use crate::iter::{adapters::SourceIter, FusedIterator, InPlaceIterable, TrustedFused};
1use crate::iter::adapters::SourceIter;
2use crate::iter::{FusedIterator, InPlaceIterable, TrustedFused};
23use crate::mem::{ManuallyDrop, MaybeUninit};
34use crate::num::NonZero;
45use crate::ops::{ControlFlow, Try};
library/core/src/iter/adapters/flatten.rs+3-5
......@@ -1,13 +1,11 @@
11use crate::iter::adapters::SourceIter;
22use 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,
55};
6use crate::iter::{Empty, Once, OnceWith};
76use crate::num::NonZero;
87use crate::ops::{ControlFlow, Try};
9use crate::result;
10use crate::{array, fmt, option};
8use crate::{array, fmt, option, result};
119
1210/// An iterator that maps each element to an iterator, and yields the elements
1311/// of the produced iterators.
library/core/src/iter/adapters/inspect.rs+2-1
......@@ -1,5 +1,6 @@
11use crate::fmt;
2use crate::iter::{adapters::SourceIter, FusedIterator, InPlaceIterable, TrustedFused};
2use crate::iter::adapters::SourceIter;
3use crate::iter::{FusedIterator, InPlaceIterable, TrustedFused};
34use crate::num::NonZero;
45use crate::ops::Try;
56
library/core/src/iter/adapters/map.rs+2-3
......@@ -1,7 +1,6 @@
11use crate::fmt;
2use crate::iter::adapters::{
3 zip::try_get_unchecked, SourceIter, TrustedRandomAccess, TrustedRandomAccessNoCoerce,
4};
2use crate::iter::adapters::zip::try_get_unchecked;
3use crate::iter::adapters::{SourceIter, TrustedRandomAccess, TrustedRandomAccessNoCoerce};
54use crate::iter::{FusedIterator, InPlaceIterable, TrustedFused, TrustedLen, UncheckedIterator};
65use crate::num::NonZero;
76use crate::ops::Try;
library/core/src/iter/adapters/map_while.rs+2-1
......@@ -1,5 +1,6 @@
11use crate::fmt;
2use crate::iter::{adapters::SourceIter, InPlaceIterable};
2use crate::iter::adapters::SourceIter;
3use crate::iter::InPlaceIterable;
34use crate::num::NonZero;
45use crate::ops::{ControlFlow, Try};
56
library/core/src/iter/adapters/map_windows.rs+3-6
......@@ -1,9 +1,6 @@
1use crate::{
2 fmt,
3 iter::FusedIterator,
4 mem::{self, MaybeUninit},
5 ptr,
6};
1use crate::iter::FusedIterator;
2use crate::mem::{self, MaybeUninit};
3use crate::{fmt, ptr};
74
85/// An iterator over the mapped windows of another iterator.
96///
library/core/src/iter/adapters/mod.rs+12-25
......@@ -28,51 +28,38 @@ mod take;
2828mod take_while;
2929mod zip;
3030
31#[stable(feature = "rust1", since = "1.0.0")]
32pub 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
3831#[unstable(feature = "iter_array_chunks", reason = "recently added", issue = "100450")]
3932pub use self::array_chunks::ArrayChunks;
40
4133#[unstable(feature = "std_internals", issue = "none")]
4234pub use self::by_ref_sized::ByRefSized;
43
4435#[unstable(feature = "iter_chain", reason = "recently added", issue = "125964")]
4536pub use self::chain::chain;
46
4737#[stable(feature = "iter_cloned", since = "1.1.0")]
4838pub use self::cloned::Cloned;
49
50#[stable(feature = "iterator_step_by", since = "1.28.0")]
51pub use self::step_by::StepBy;
52
53#[stable(feature = "iterator_flatten", since = "1.29.0")]
54pub use self::flatten::Flatten;
55
5639#[stable(feature = "iter_copied", since = "1.36.0")]
5740pub use self::copied::Copied;
58
41#[stable(feature = "iterator_flatten", since = "1.29.0")]
42pub use self::flatten::Flatten;
5943#[unstable(feature = "iter_intersperse", reason = "recently added", issue = "79524")]
6044pub use self::intersperse::{Intersperse, IntersperseWith};
61
6245#[stable(feature = "iter_map_while", since = "1.57.0")]
6346pub use self::map_while::MapWhile;
64
6547#[unstable(feature = "iter_map_windows", reason = "recently added", issue = "87155")]
6648pub use self::map_windows::MapWindows;
67
49#[stable(feature = "iterator_step_by", since = "1.28.0")]
50pub use self::step_by::StepBy;
51#[stable(feature = "iter_zip", since = "1.59.0")]
52pub use self::zip::zip;
6853#[unstable(feature = "trusted_random_access", issue = "none")]
6954pub use self::zip::TrustedRandomAccess;
70
7155#[unstable(feature = "trusted_random_access", issue = "none")]
7256pub use self::zip::TrustedRandomAccessNoCoerce;
73
74#[stable(feature = "iter_zip", since = "1.59.0")]
75pub use self::zip::zip;
57#[stable(feature = "rust1", since = "1.0.0")]
58pub 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};
7663
7764/// This trait provides transitive access to source-stage in an iterator-adapter pipeline
7865/// under the conditions that
library/core/src/iter/adapters/peekable.rs+2-1
......@@ -1,4 +1,5 @@
1use crate::iter::{adapters::SourceIter, FusedIterator, TrustedLen};
1use crate::iter::adapters::SourceIter;
2use crate::iter::{FusedIterator, TrustedLen};
23use crate::ops::{ControlFlow, Try};
34
45/// 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 @@
11use crate::fmt;
2use crate::iter::{adapters::SourceIter, InPlaceIterable};
2use crate::iter::adapters::SourceIter;
3use crate::iter::InPlaceIterable;
34use crate::num::NonZero;
45use crate::ops::{ControlFlow, Try};
56
library/core/src/iter/adapters/skip.rs+2-2
......@@ -1,8 +1,8 @@
11use crate::intrinsics::unlikely;
22use crate::iter::adapters::zip::try_get_unchecked;
3use crate::iter::TrustedFused;
3use crate::iter::adapters::SourceIter;
44use crate::iter::{
5 adapters::SourceIter, FusedIterator, InPlaceIterable, TrustedLen, TrustedRandomAccess,
5 FusedIterator, InPlaceIterable, TrustedFused, TrustedLen, TrustedRandomAccess,
66 TrustedRandomAccessNoCoerce,
77};
88use crate::num::NonZero;
library/core/src/iter/adapters/skip_while.rs+2-1
......@@ -1,5 +1,6 @@
11use crate::fmt;
2use crate::iter::{adapters::SourceIter, FusedIterator, InPlaceIterable, TrustedFused};
2use crate::iter::adapters::SourceIter;
3use crate::iter::{FusedIterator, InPlaceIterable, TrustedFused};
34use crate::num::NonZero;
45use crate::ops::Try;
56
library/core/src/iter/adapters/step_by.rs+4-6
......@@ -1,9 +1,7 @@
1use crate::{
2 intrinsics,
3 iter::{from_fn, TrustedLen, TrustedRandomAccess},
4 num::NonZero,
5 ops::{Range, Try},
6};
1use crate::intrinsics;
2use crate::iter::{from_fn, TrustedLen, TrustedRandomAccess};
3use crate::num::NonZero;
4use crate::ops::{Range, Try};
75
86/// An iterator for stepping iterators by a custom amount.
97///
library/core/src/iter/adapters/take.rs+2-4
......@@ -1,8 +1,6 @@
11use crate::cmp;
2use crate::iter::{
3 adapters::SourceIter, FusedIterator, InPlaceIterable, TrustedFused, TrustedLen,
4 TrustedRandomAccess,
5};
2use crate::iter::adapters::SourceIter;
3use crate::iter::{FusedIterator, InPlaceIterable, TrustedFused, TrustedLen, TrustedRandomAccess};
64use crate::num::NonZero;
75use crate::ops::{ControlFlow, Try};
86
library/core/src/iter/adapters/take_while.rs+2-1
......@@ -1,5 +1,6 @@
11use crate::fmt;
2use crate::iter::{adapters::SourceIter, FusedIterator, InPlaceIterable, TrustedFused};
2use crate::iter::adapters::SourceIter;
3use crate::iter::{FusedIterator, InPlaceIterable, TrustedFused};
34use crate::num::NonZero;
45use crate::ops::{ControlFlow, Try};
56
library/core/src/iter/adapters/zip.rs+3-2
......@@ -1,7 +1,8 @@
11use crate::cmp;
22use crate::fmt::{self, Debug};
3use crate::iter::{FusedIterator, TrustedFused};
4use crate::iter::{InPlaceIterable, SourceIter, TrustedLen, UncheckedIterator};
3use crate::iter::{
4 FusedIterator, InPlaceIterable, SourceIter, TrustedFused, TrustedLen, UncheckedIterator,
5};
56use crate::num::NonZero;
67
78/// 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 {
380380 };
381381}
382382
383#[unstable(feature = "iter_chain", reason = "recently added", issue = "125964")]
384pub use self::adapters::chain;
385pub(crate) use self::adapters::try_process;
386#[stable(feature = "iter_zip", since = "1.59.0")]
387pub use self::adapters::zip;
388#[unstable(feature = "iter_array_chunks", reason = "recently added", issue = "100450")]
389pub use self::adapters::ArrayChunks;
390#[unstable(feature = "std_internals", issue = "none")]
391pub use self::adapters::ByRefSized;
392#[stable(feature = "iter_cloned", since = "1.1.0")]
393pub use self::adapters::Cloned;
394#[stable(feature = "iter_copied", since = "1.36.0")]
395pub use self::adapters::Copied;
396#[stable(feature = "iterator_flatten", since = "1.29.0")]
397pub use self::adapters::Flatten;
398#[stable(feature = "iter_map_while", since = "1.57.0")]
399pub use self::adapters::MapWhile;
400#[unstable(feature = "iter_map_windows", reason = "recently added", issue = "87155")]
401pub use self::adapters::MapWindows;
402#[unstable(feature = "inplace_iteration", issue = "none")]
403pub use self::adapters::SourceIter;
404#[stable(feature = "iterator_step_by", since = "1.28.0")]
405pub use self::adapters::StepBy;
406#[unstable(feature = "trusted_random_access", issue = "none")]
407pub use self::adapters::TrustedRandomAccess;
408#[unstable(feature = "trusted_random_access", issue = "none")]
409pub use self::adapters::TrustedRandomAccessNoCoerce;
383410#[stable(feature = "rust1", since = "1.0.0")]
384pub use self::traits::Iterator;
385
411pub 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")]
416pub use self::adapters::{Intersperse, IntersperseWith};
386417#[unstable(
387418 feature = "step_trait",
388419 reason = "likely to be replaced by finer-grained traits",
389420 issue = "42168"
390421)]
391422pub use self::range::Step;
392
393423#[unstable(
394424 feature = "iter_from_coroutine",
395425 issue = "43122",
......@@ -412,59 +442,24 @@ pub use self::sources::{repeat_n, RepeatN};
412442pub use self::sources::{repeat_with, RepeatWith};
413443#[stable(feature = "iter_successors", since = "1.34.0")]
414444pub use self::sources::{successors, Successors};
415
416445#[stable(feature = "fused", since = "1.26.0")]
417446pub use self::traits::FusedIterator;
418447#[unstable(issue = "none", feature = "inplace_iteration")]
419448pub use self::traits::InPlaceIterable;
449#[stable(feature = "rust1", since = "1.0.0")]
450pub use self::traits::Iterator;
420451#[unstable(issue = "none", feature = "trusted_fused")]
421452pub use self::traits::TrustedFused;
422453#[unstable(feature = "trusted_len", issue = "37572")]
423454pub use self::traits::TrustedLen;
424455#[unstable(feature = "trusted_step", issue = "85731")]
425456pub use self::traits::TrustedStep;
457pub(crate) use self::traits::UncheckedIterator;
426458#[stable(feature = "rust1", since = "1.0.0")]
427459pub use self::traits::{
428460 DoubleEndedIterator, ExactSizeIterator, Extend, FromIterator, IntoIterator, Product, Sum,
429461};
430462
431#[unstable(feature = "iter_chain", reason = "recently added", issue = "125964")]
432pub use self::adapters::chain;
433#[stable(feature = "iter_zip", since = "1.59.0")]
434pub use self::adapters::zip;
435#[unstable(feature = "iter_array_chunks", reason = "recently added", issue = "100450")]
436pub use self::adapters::ArrayChunks;
437#[unstable(feature = "std_internals", issue = "none")]
438pub use self::adapters::ByRefSized;
439#[stable(feature = "iter_cloned", since = "1.1.0")]
440pub use self::adapters::Cloned;
441#[stable(feature = "iter_copied", since = "1.36.0")]
442pub use self::adapters::Copied;
443#[stable(feature = "iterator_flatten", since = "1.29.0")]
444pub use self::adapters::Flatten;
445#[stable(feature = "iter_map_while", since = "1.57.0")]
446pub use self::adapters::MapWhile;
447#[unstable(feature = "iter_map_windows", reason = "recently added", issue = "87155")]
448pub use self::adapters::MapWindows;
449#[unstable(feature = "inplace_iteration", issue = "none")]
450pub use self::adapters::SourceIter;
451#[stable(feature = "iterator_step_by", since = "1.28.0")]
452pub use self::adapters::StepBy;
453#[unstable(feature = "trusted_random_access", issue = "none")]
454pub use self::adapters::TrustedRandomAccess;
455#[unstable(feature = "trusted_random_access", issue = "none")]
456pub use self::adapters::TrustedRandomAccessNoCoerce;
457#[stable(feature = "rust1", since = "1.0.0")]
458pub 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")]
463pub use self::adapters::{Intersperse, IntersperseWith};
464
465pub(crate) use self::adapters::try_process;
466pub(crate) use self::traits::UncheckedIterator;
467
468463mod adapters;
469464mod range;
470465mod sources;
library/core/src/iter/range.rs+3-4
......@@ -1,13 +1,12 @@
1use super::{
2 FusedIterator, TrustedLen, TrustedRandomAccess, TrustedRandomAccessNoCoerce, TrustedStep,
3};
14use crate::ascii::Char as AsciiChar;
25use crate::mem;
36use crate::net::{Ipv4Addr, Ipv6Addr};
47use crate::num::NonZero;
58use crate::ops::{self, Try};
69
7use super::{
8 FusedIterator, TrustedLen, TrustedRandomAccess, TrustedRandomAccessNoCoerce, TrustedStep,
9};
10
1110// Safety: All invariants are upheld.
1211macro_rules! unsafe_impl_trusted_step {
1312 ($($type:ty)*) => {$(
library/core/src/iter/sources.rs+12-20
......@@ -8,33 +8,25 @@ mod repeat_n;
88mod repeat_with;
99mod successors;
1010
11#[stable(feature = "rust1", since = "1.0.0")]
12pub use self::repeat::{repeat, Repeat};
13
1411#[stable(feature = "iter_empty", since = "1.2.0")]
1512pub use self::empty::{empty, Empty};
16
17#[stable(feature = "iter_once", since = "1.2.0")]
18pub use self::once::{once, Once};
19
20#[unstable(feature = "iter_repeat_n", issue = "104434")]
21pub use self::repeat_n::{repeat_n, RepeatN};
22
23#[stable(feature = "iterator_repeat_with", since = "1.28.0")]
24pub use self::repeat_with::{repeat_with, RepeatWith};
25
26#[stable(feature = "iter_from_fn", since = "1.34.0")]
27pub use self::from_fn::{from_fn, FromFn};
28
2913#[unstable(
3014 feature = "iter_from_coroutine",
3115 issue = "43122",
3216 reason = "coroutines are unstable"
3317)]
3418pub use self::from_coroutine::from_coroutine;
35
36#[stable(feature = "iter_successors", since = "1.34.0")]
37pub use self::successors::{successors, Successors};
38
19#[stable(feature = "iter_from_fn", since = "1.34.0")]
20pub use self::from_fn::{from_fn, FromFn};
21#[stable(feature = "iter_once", since = "1.2.0")]
22pub use self::once::{once, Once};
3923#[stable(feature = "iter_once_with", since = "1.43.0")]
4024pub use self::once_with::{once_with, OnceWith};
25#[stable(feature = "rust1", since = "1.0.0")]
26pub use self::repeat::{repeat, Repeat};
27#[unstable(feature = "iter_repeat_n", issue = "104434")]
28pub use self::repeat_n::{repeat_n, RepeatN};
29#[stable(feature = "iterator_repeat_with", since = "1.28.0")]
30pub use self::repeat_with::{repeat_with, RepeatWith};
31#[stable(feature = "iter_successors", since = "1.34.0")]
32pub use self::successors::{successors, Successors};
library/core/src/iter/sources/empty.rs+1-2
......@@ -1,6 +1,5 @@
1use crate::fmt;
21use crate::iter::{FusedIterator, TrustedLen};
3use crate::marker;
2use crate::{fmt, marker};
43
54/// Creates an iterator that yields nothing.
65///
library/core/src/iter/sources/successors.rs+2-1
......@@ -1,4 +1,5 @@
1use crate::{fmt, iter::FusedIterator};
1use crate::fmt;
2use crate::iter::FusedIterator;
23
34/// Creates a new iterator where each successive item is computed based on the preceding one.
45///
library/core/src/iter/traits/iterator.rs+6-11
......@@ -1,19 +1,14 @@
1use 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};
17use crate::array;
28use crate::cmp::{self, Ordering};
39use crate::num::NonZero;
410use crate::ops::{ChangeOutputType, ControlFlow, FromResidual, Residual, Try};
511
6use super::super::try_process;
7use super::super::ByRefSized;
8use super::super::TrustedRandomAccessNoCoerce;
9use super::super::{ArrayChunks, Chain, Cloned, Copied, Cycle, Enumerate, Filter, FilterMap, Fuse};
10use super::super::{FlatMap, Flatten};
11use super::super::{
12 Inspect, Map, MapWhile, MapWindows, Peekable, Rev, Scan, Skip, SkipWhile, StepBy, Take,
13 TakeWhile,
14};
15use super::super::{Intersperse, IntersperseWith, Product, Sum, Zip};
16
1712fn _assert_is_object_safe(_: &dyn Iterator<Item = ()>) {}
1813
1914/// A trait for dealing with iterators.
library/core/src/iter/traits/mod.rs+7-9
......@@ -6,6 +6,13 @@ mod iterator;
66mod marker;
77mod unchecked_iterator;
88
9#[unstable(issue = "none", feature = "inplace_iteration")]
10pub use self::marker::InPlaceIterable;
11#[unstable(issue = "none", feature = "trusted_fused")]
12pub use self::marker::TrustedFused;
13#[unstable(feature = "trusted_step", issue = "85731")]
14pub use self::marker::TrustedStep;
15pub(crate) use self::unchecked_iterator::UncheckedIterator;
916#[stable(feature = "rust1", since = "1.0.0")]
1017pub use self::{
1118 accum::{Product, Sum},
......@@ -15,12 +22,3 @@ pub use self::{
1522 iterator::Iterator,
1623 marker::{FusedIterator, TrustedLen},
1724};
18
19#[unstable(issue = "none", feature = "inplace_iteration")]
20pub use self::marker::InPlaceIterable;
21#[unstable(issue = "none", feature = "trusted_fused")]
22pub use self::marker::TrustedFused;
23#[unstable(feature = "trusted_step", issue = "85731")]
24pub use self::marker::TrustedStep;
25
26pub(crate) use self::unchecked_iterator::UncheckedIterator;
library/core/src/marker.rs+1-2
......@@ -9,8 +9,7 @@
99use crate::cell::UnsafeCell;
1010use crate::cmp;
1111use crate::fmt::Debug;
12use crate::hash::Hash;
13use crate::hash::Hasher;
12use crate::hash::{Hash, Hasher};
1413
1514/// Implements a given marker trait for multiple types at the same time.
1615///
library/core/src/mem/maybe_uninit.rs+1-4
......@@ -1,9 +1,6 @@
11use crate::any::type_name;
2use crate::fmt;
3use crate::intrinsics;
42use crate::mem::{self, ManuallyDrop};
5use crate::ptr;
6use crate::slice;
3use crate::{fmt, intrinsics, ptr, slice};
74
85/// A wrapper type to construct uninitialized instances of `T`.
96///
library/core/src/mem/mod.rs+1-6
......@@ -5,13 +5,8 @@
55
66#![stable(feature = "rust1", since = "1.0.0")]
77
8use crate::clone;
9use crate::cmp;
10use crate::fmt;
11use crate::hash;
12use crate::intrinsics;
138use crate::marker::DiscriminantKind;
14use crate::ptr;
9use crate::{clone, cmp, fmt, hash, intrinsics, ptr};
1510
1611mod manually_drop;
1712#[stable(feature = "manually_drop", since = "1.20.0")]
library/core/src/net/display_buffer.rs+1-2
......@@ -1,6 +1,5 @@
1use crate::fmt;
21use crate::mem::MaybeUninit;
3use crate::str;
2use crate::{fmt, str};
43
54/// Used for slow path in `Display` implementations when alignment is required.
65pub struct DisplayBuffer<const SIZE: usize> {
library/core/src/net/ip_addr.rs+1-2
......@@ -1,11 +1,10 @@
1use super::display_buffer::DisplayBuffer;
12use crate::cmp::Ordering;
23use crate::fmt::{self, Write};
34use crate::iter;
45use crate::mem::transmute;
56use crate::ops::{BitAnd, BitAndAssign, BitOr, BitOrAssign, Not};
67
7use super::display_buffer::DisplayBuffer;
8
98/// An IP address, either IPv4 or IPv6.
109///
1110/// 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 @@
1use super::display_buffer::DisplayBuffer;
12use crate::fmt::{self, Write};
23use crate::net::{IpAddr, Ipv4Addr, Ipv6Addr};
34
4use super::display_buffer::DisplayBuffer;
5
65/// An internet socket address, either IPv4 or IPv6.
76///
87/// 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 {
145145
146146 /// Adds `other` to itself and returns its own mutable reference.
147147 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};
150149
151150 let mut sz = cmp::max(self.size, other.size);
152151 let mut carry = false;
......@@ -181,8 +180,7 @@ macro_rules! define_bignum {
181180
182181 /// Subtracts `other` from itself and returns its own mutable reference.
183182 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};
186184
187185 let sz = cmp::max(self.size, other.size);
188186 let mut noborrow = true;
library/core/src/num/dec2flt/mod.rs+3-4
......@@ -75,15 +75,14 @@
7575 issue = "none"
7676)]
7777
78use crate::error::Error;
79use crate::fmt;
80use crate::str::FromStr;
81
8278use self::common::BiasedFp;
8379use self::float::RawFloat;
8480use self::lemire::compute_float;
8581use self::parse::{parse_inf_nan, parse_number};
8682use self::slow::parse_long_mantissa;
83use crate::error::Error;
84use crate::fmt;
85use crate::str::FromStr;
8786
8887mod common;
8988mod decimal;
library/core/src/num/flt2dec/mod.rs-1
......@@ -123,7 +123,6 @@ functions.
123123)]
124124
125125pub use self::decoder::{decode, DecodableFloat, Decoded, FullDecoded};
126
127126use super::fmt::{Formatted, Part};
128127use crate::mem::MaybeUninit;
129128
library/core/src/num/flt2dec/strategy/dragon.rs+1-3
......@@ -6,9 +6,7 @@
66
77use crate::cmp::Ordering;
88use crate::mem::MaybeUninit;
9
10use crate::num::bignum::Big32x40 as Big;
11use crate::num::bignum::Digit32 as Digit;
9use crate::num::bignum::{Big32x40 as Big, Digit32 as Digit};
1210use crate::num::flt2dec::estimator::estimate_scaling_factor;
1311use crate::num::flt2dec::{round_up, Decoded, MAX_SIG_DIGITS};
1412
library/core/src/num/mod.rs+11-21
......@@ -2,11 +2,9 @@
22
33#![stable(feature = "rust1", since = "1.0.0")]
44
5use crate::ascii;
6use crate::intrinsics;
7use crate::mem;
85use crate::str::FromStr;
96use crate::ub_checks::assert_unsafe_precondition;
7use crate::{ascii, intrinsics, mem};
108
119// Used because the `?` operator is not allowed in a const context.
1210macro_rules! try_opt {
......@@ -48,39 +46,31 @@ mod overflow_panic;
4846mod saturating;
4947mod wrapping;
5048
51#[stable(feature = "saturating_int_impl", since = "1.74.0")]
52pub use saturating::Saturating;
53#[stable(feature = "rust1", since = "1.0.0")]
54pub use wrapping::Wrapping;
55
5649#[stable(feature = "rust1", since = "1.0.0")]
5750#[cfg(not(no_fp_fmt_parse))]
5851pub use dec2flt::ParseFloatError;
59
52#[stable(feature = "int_error_matching", since = "1.55.0")]
53pub use error::IntErrorKind;
6054#[stable(feature = "rust1", since = "1.0.0")]
6155pub use error::ParseIntError;
62
56#[stable(feature = "try_from", since = "1.34.0")]
57pub use error::TryFromIntError;
58#[stable(feature = "generic_nonzero", since = "1.79.0")]
59pub use nonzero::NonZero;
6360#[unstable(
6461 feature = "nonzero_internals",
6562 reason = "implementation detail which may disappear or be replaced at any time",
6663 issue = "none"
6764)]
6865pub use nonzero::ZeroablePrimitive;
69
70#[stable(feature = "generic_nonzero", since = "1.79.0")]
71pub use nonzero::NonZero;
72
7366#[stable(feature = "signed_nonzero", since = "1.34.0")]
7467pub use nonzero::{NonZeroI128, NonZeroI16, NonZeroI32, NonZeroI64, NonZeroI8, NonZeroIsize};
75
7668#[stable(feature = "nonzero", since = "1.28.0")]
7769pub use nonzero::{NonZeroU128, NonZeroU16, NonZeroU32, NonZeroU64, NonZeroU8, NonZeroUsize};
78
79#[stable(feature = "try_from", since = "1.34.0")]
80pub use error::TryFromIntError;
81
82#[stable(feature = "int_error_matching", since = "1.55.0")]
83pub use error::IntErrorKind;
70#[stable(feature = "saturating_int_impl", since = "1.74.0")]
71pub use saturating::Saturating;
72#[stable(feature = "rust1", since = "1.0.0")]
73pub use wrapping::Wrapping;
8474
8575macro_rules! usize_isize_to_xe_bytes_doc {
8676 () => {
library/core/src/num/nonzero.rs+2-7
......@@ -1,18 +1,13 @@
11//! Definitions of integer that is known not to equal zero.
22
3use super::{IntErrorKind, ParseIntError};
34use crate::cmp::Ordering;
4use crate::fmt;
55use crate::hash::{Hash, Hasher};
6use crate::hint;
7use crate::intrinsics;
86use crate::marker::{Freeze, StructuralPartialEq};
97use crate::ops::{BitOr, BitOrAssign, Div, DivAssign, Neg, Rem, RemAssign};
108use crate::panic::{RefUnwindSafe, UnwindSafe};
11use crate::ptr;
129use crate::str::FromStr;
13use crate::ub_checks;
14
15use super::{IntErrorKind, ParseIntError};
10use crate::{fmt, hint, intrinsics, ptr, ub_checks};
1611
1712/// A marker trait for primitive types which can be zero.
1813///
library/core/src/num/saturating.rs+4-4
......@@ -1,10 +1,10 @@
11//! Definitions of `Saturating<T>`.
22
33use crate::fmt;
4use crate::ops::{Add, AddAssign, BitAnd, BitAndAssign, BitOr, BitOrAssign};
5use crate::ops::{BitXor, BitXorAssign, Div, DivAssign};
6use crate::ops::{Mul, MulAssign, Neg, Not, Rem, RemAssign};
7use crate::ops::{Sub, SubAssign};
4use crate::ops::{
5 Add, AddAssign, BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign, Div, DivAssign,
6 Mul, MulAssign, Neg, Not, Rem, RemAssign, Sub, SubAssign,
7};
88
99/// Provides intentionally-saturating arithmetic on `T`.
1010///
library/core/src/num/wrapping.rs+4-4
......@@ -1,10 +1,10 @@
11//! Definitions of `Wrapping<T>`.
22
33use crate::fmt;
4use crate::ops::{Add, AddAssign, BitAnd, BitAndAssign, BitOr, BitOrAssign};
5use crate::ops::{BitXor, BitXorAssign, Div, DivAssign};
6use crate::ops::{Mul, MulAssign, Neg, Not, Rem, RemAssign};
7use crate::ops::{Shl, ShlAssign, Shr, ShrAssign, Sub, SubAssign};
4use 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};
88
99/// Provides intentionally-wrapped arithmetic on `T`.
1010///
library/core/src/ops/mod.rs+17-38
......@@ -156,65 +156,44 @@ mod unsize;
156156pub use self::arith::{Add, Div, Mul, Neg, Rem, Sub};
157157#[stable(feature = "op_assign_traits", since = "1.8.0")]
158158pub use self::arith::{AddAssign, DivAssign, MulAssign, RemAssign, SubAssign};
159
159#[unstable(feature = "async_fn_traits", issue = "none")]
160pub use self::async_function::{AsyncFn, AsyncFnMut, AsyncFnOnce};
160161#[stable(feature = "rust1", since = "1.0.0")]
161162pub use self::bit::{BitAnd, BitOr, BitXor, Not, Shl, Shr};
162163#[stable(feature = "op_assign_traits", since = "1.8.0")]
163164pub use self::bit::{BitAndAssign, BitOrAssign, BitXorAssign, ShlAssign, ShrAssign};
164
165#[stable(feature = "rust1", since = "1.0.0")]
166pub use self::deref::{Deref, DerefMut};
167
165#[unstable(feature = "control_flow_enum", reason = "new API", issue = "75744")]
166pub use self::control_flow::ControlFlow;
167#[unstable(feature = "coroutine_trait", issue = "43122")]
168pub use self::coroutine::{Coroutine, CoroutineState};
168169#[unstable(feature = "deref_pure_trait", issue = "87121")]
169170pub use self::deref::DerefPure;
170
171171#[unstable(feature = "receiver_trait", issue = "none")]
172172pub use self::deref::Receiver;
173
174173#[stable(feature = "rust1", since = "1.0.0")]
175pub use self::drop::Drop;
176
174pub use self::deref::{Deref, DerefMut};
177175pub(crate) use self::drop::fallback_surface_drop;
178
176#[stable(feature = "rust1", since = "1.0.0")]
177pub use self::drop::Drop;
179178#[stable(feature = "rust1", since = "1.0.0")]
180179pub use self::function::{Fn, FnMut, FnOnce};
181
182#[unstable(feature = "async_fn_traits", issue = "none")]
183pub use self::async_function::{AsyncFn, AsyncFnMut, AsyncFnOnce};
184
185180#[stable(feature = "rust1", since = "1.0.0")]
186181pub use self::index::{Index, IndexMut};
187
188#[stable(feature = "rust1", since = "1.0.0")]
189pub use self::range::{Range, RangeFrom, RangeFull, RangeTo};
190
191182pub(crate) use self::index_range::IndexRange;
192
193#[stable(feature = "inclusive_range", since = "1.26.0")]
194pub use self::range::{Bound, RangeBounds, RangeInclusive, RangeToInclusive};
195
196183#[unstable(feature = "one_sided_range", issue = "69780")]
197184pub use self::range::OneSidedRange;
198
199#[unstable(feature = "try_trait_v2", issue = "84277")]
200pub use self::try_trait::{FromResidual, Try};
201
202#[unstable(feature = "try_trait_v2_yeet", issue = "96374")]
203pub use self::try_trait::Yeet;
204
185#[stable(feature = "inclusive_range", since = "1.26.0")]
186pub use self::range::{Bound, RangeBounds, RangeInclusive, RangeToInclusive};
187#[stable(feature = "rust1", since = "1.0.0")]
188pub use self::range::{Range, RangeFrom, RangeFull, RangeTo};
205189#[unstable(feature = "try_trait_v2_residual", issue = "91285")]
206190pub use self::try_trait::Residual;
207
191#[unstable(feature = "try_trait_v2_yeet", issue = "96374")]
192pub use self::try_trait::Yeet;
208193pub(crate) use self::try_trait::{ChangeOutputType, NeverShortCircuit};
209
210#[unstable(feature = "coroutine_trait", issue = "43122")]
211pub use self::coroutine::{Coroutine, CoroutineState};
212
194#[unstable(feature = "try_trait_v2", issue = "84277")]
195pub use self::try_trait::{FromResidual, Try};
213196#[unstable(feature = "coerce_unsized", issue = "18598")]
214197pub use self::unsize::CoerceUnsized;
215
216198#[unstable(feature = "dispatch_from_dyn", issue = "none")]
217199pub use self::unsize::DispatchFromDyn;
218
219#[unstable(feature = "control_flow_enum", reason = "new API", issue = "75744")]
220pub use self::control_flow::ControlFlow;
library/core/src/option.rs+2-5
......@@ -557,13 +557,10 @@
557557#![stable(feature = "rust1", since = "1.0.0")]
558558
559559use crate::iter::{self, FusedIterator, TrustedLen};
560use crate::ops::{self, ControlFlow, Deref, DerefMut};
560561use crate::panicking::{panic, panic_display};
561562use crate::pin::Pin;
562use crate::{
563 cmp, convert, hint, mem,
564 ops::{self, ControlFlow, Deref, DerefMut},
565 slice,
566};
563use crate::{cmp, convert, hint, mem, slice};
567564
568565/// The `Option` type. See [the module level documentation](self) for more.
569566#[derive(Copy, Eq, Debug, Hash)]
library/core/src/panic.rs+1-2
......@@ -6,8 +6,6 @@ mod location;
66mod panic_info;
77mod unwind_safe;
88
9use crate::any::Any;
10
119#[stable(feature = "panic_hooks", since = "1.10.0")]
1210pub use self::location::Location;
1311#[stable(feature = "panic_hooks", since = "1.10.0")]
......@@ -16,6 +14,7 @@ pub use self::panic_info::PanicInfo;
1614pub use self::panic_info::PanicMessage;
1715#[stable(feature = "catch_unwind", since = "1.9.0")]
1816pub use self::unwind_safe::{AssertUnwindSafe, RefUnwindSafe, UnwindSafe};
17use crate::any::Any;
1918
2019#[doc(hidden)]
2120#[unstable(feature = "edition_panic", issue = "none", reason = "use panic!() instead")]
library/core/src/pin.rs+1-3
......@@ -920,11 +920,8 @@
920920
921921#![stable(feature = "pin", since = "1.33.0")]
922922
923use crate::cmp;
924use crate::fmt;
925923use crate::hash::{Hash, Hasher};
926924use crate::ops::{CoerceUnsized, Deref, DerefMut, DerefPure, DispatchFromDyn, Receiver};
927
928925#[allow(unused_imports)]
929926use crate::{
930927 cell::{RefCell, UnsafeCell},
......@@ -932,6 +929,7 @@ use crate::{
932929 marker::PhantomPinned,
933930 mem, ptr,
934931};
932use crate::{cmp, fmt};
935933
936934/// A pointer which pins its pointee in place.
937935///
library/core/src/ptr/metadata.rs+1-2
......@@ -2,8 +2,7 @@
22
33use crate::fmt;
44use crate::hash::{Hash, Hasher};
5use crate::intrinsics::aggregate_raw_ptr;
6use crate::intrinsics::ptr_metadata;
5use crate::intrinsics::{aggregate_raw_ptr, ptr_metadata};
76use crate::marker::Freeze;
87use crate::ptr::NonNull;
98
library/core/src/ptr/mod.rs+3-9
......@@ -409,13 +409,9 @@
409409#![allow(clippy::not_unsafe_ptr_arg_deref)]
410410
411411use crate::cmp::Ordering;
412use crate::fmt;
413use crate::hash;
414use crate::intrinsics;
415412use crate::marker::FnPtr;
416use crate::ub_checks;
417
418413use crate::mem::{self, MaybeUninit};
414use crate::{fmt, hash, intrinsics, ub_checks};
419415
420416mod alignment;
421417#[unstable(feature = "ptr_alignment_type", issue = "102070")]
......@@ -423,12 +419,10 @@ pub use alignment::Alignment;
423419
424420#[stable(feature = "rust1", since = "1.0.0")]
425421#[doc(inline)]
426pub use crate::intrinsics::copy_nonoverlapping;
427
422pub use crate::intrinsics::copy;
428423#[stable(feature = "rust1", since = "1.0.0")]
429424#[doc(inline)]
430pub use crate::intrinsics::copy;
431
425pub use crate::intrinsics::copy_nonoverlapping;
432426#[stable(feature = "rust1", since = "1.0.0")]
433427#[doc(inline)]
434428pub use crate::intrinsics::write_bytes;
library/core/src/ptr/non_null.rs+1-4
......@@ -1,15 +1,12 @@
11use crate::cmp::Ordering;
2use crate::fmt;
3use crate::hash;
4use crate::intrinsics;
52use crate::marker::Unsize;
63use crate::mem::{MaybeUninit, SizedTypeProperties};
74use crate::num::NonZero;
85use crate::ops::{CoerceUnsized, DispatchFromDyn};
9use crate::ptr;
106use crate::ptr::Unique;
117use crate::slice::{self, SliceIndex};
128use crate::ub_checks::assert_unsafe_precondition;
9use crate::{fmt, hash, intrinsics, ptr};
1310
1411/// `*mut T` but non-zero and [covariant].
1512///
library/core/src/range.rs+2-4
......@@ -25,15 +25,13 @@ mod iter;
2525pub mod legacy;
2626
2727#[doc(inline)]
28pub use crate::ops::{Bound, OneSidedRange, RangeBounds, RangeFull, RangeTo, RangeToInclusive};
29
28pub use iter::{IterRange, IterRangeFrom, IterRangeInclusive};
3029use Bound::{Excluded, Included, Unbounded};
3130
3231#[doc(inline)]
3332pub use crate::iter::Step;
34
3533#[doc(inline)]
36pub use iter::{IterRange, IterRangeFrom, IterRangeInclusive};
34pub use crate::ops::{Bound, OneSidedRange, RangeBounds, RangeFull, RangeTo, RangeToInclusive};
3735
3836/// A (half-open) range bounded inclusively below and exclusively above
3937/// (`start..end` in a future edition).
library/core/src/range/iter.rs+2-3
......@@ -1,9 +1,8 @@
1use crate::num::NonZero;
2use crate::range::{legacy, Range, RangeFrom, RangeInclusive};
3
41use crate::iter::{
52 FusedIterator, Step, TrustedLen, TrustedRandomAccess, TrustedRandomAccessNoCoerce, TrustedStep,
63};
4use crate::num::NonZero;
5use crate::range::{legacy, Range, RangeFrom, RangeInclusive};
76
87/// By-value [`Range`] iterator.
98#[unstable(feature = "new_range_api", issue = "125687")]
library/core/src/slice/ascii.rs+3-5
......@@ -1,12 +1,10 @@
11//! Operations on ASCII `[u8]`.
22
3use crate::ascii;
4use crate::fmt::{self, Write};
5use crate::iter;
6use crate::mem;
7use crate::ops;
83use core::ascii::EscapeDefault;
94
5use crate::fmt::{self, Write};
6use crate::{ascii, iter, mem, ops};
7
108#[cfg(not(test))]
119impl [u8] {
1210 /// Checks if all bytes in this slice are within the ASCII range.
library/core/src/slice/cmp.rs+1-3
......@@ -1,12 +1,10 @@
11//! Comparison traits for `[T]`.
22
3use super::{from_raw_parts, memchr};
34use crate::cmp::{self, BytewiseEq, Ordering};
45use crate::intrinsics::compare_bytes;
56use crate::mem;
67
7use super::from_raw_parts;
8use super::memchr;
9
108#[stable(feature = "rust1", since = "1.0.0")]
119impl<T, U> PartialEq<[U]> for [T]
1210where
library/core/src/slice/index.rs+1-2
......@@ -1,9 +1,8 @@
11//! Indexing implementations for `[T]`.
22
33use crate::intrinsics::const_eval_select;
4use crate::ops;
5use crate::range;
64use crate::ub_checks::assert_unsafe_precondition;
5use crate::{ops, range};
76
87#[stable(feature = "rust1", since = "1.0.0")]
98impl<T, I> ops::Index<I> for [T]
library/core/src/slice/iter.rs+2-4
......@@ -3,8 +3,7 @@
33#[macro_use] // import iterator! and forward_iterator!
44mod macros;
55
6use crate::cmp;
7use crate::fmt;
6use super::{from_raw_parts, from_raw_parts_mut};
87use crate::hint::assert_unchecked;
98use crate::iter::{
109 FusedIterator, TrustedLen, TrustedRandomAccess, TrustedRandomAccessNoCoerce, UncheckedIterator,
......@@ -13,8 +12,7 @@ use crate::marker::PhantomData;
1312use crate::mem::{self, SizedTypeProperties};
1413use crate::num::NonZero;
1514use crate::ptr::{self, without_provenance, without_provenance_mut, NonNull};
16
17use super::{from_raw_parts, from_raw_parts_mut};
15use crate::{cmp, fmt};
1816
1917#[stable(feature = "boxed_slice_into_iter", since = "1.80.0")]
2018impl<T> !Iterator for [T] {}
library/core/src/slice/mod.rs+21-38
......@@ -7,16 +7,13 @@
77#![stable(feature = "rust1", since = "1.0.0")]
88
99use crate::cmp::Ordering::{self, Equal, Greater, Less};
10use crate::fmt;
11use crate::hint;
1210use crate::intrinsics::{exact_div, unchecked_sub};
1311use crate::mem::{self, SizedTypeProperties};
1412use crate::num::NonZero;
1513use crate::ops::{Bound, OneSidedRange, Range, RangeBounds};
16use crate::ptr;
1714use crate::simd::{self, Simd};
18use crate::slice;
1915use crate::ub_checks::assert_unsafe_precondition;
16use crate::{fmt, hint, ptr, slice};
2017
2118#[unstable(
2219 feature = "slice_internals",
......@@ -44,52 +41,38 @@ mod specialize;
4441#[unstable(feature = "str_internals", issue = "none")]
4542#[doc(hidden)]
4643pub use ascii::is_ascii_simple;
47
44#[stable(feature = "inherent_ascii_escape", since = "1.60.0")]
45pub use ascii::EscapeAscii;
46#[stable(feature = "slice_get_slice", since = "1.28.0")]
47pub use index::SliceIndex;
48#[unstable(feature = "slice_range", issue = "76393")]
49pub use index::{range, try_range};
50#[unstable(feature = "array_windows", issue = "75027")]
51pub use iter::ArrayWindows;
52#[unstable(feature = "array_chunks", issue = "74985")]
53pub use iter::{ArrayChunks, ArrayChunksMut};
54#[stable(feature = "slice_group_by", since = "1.77.0")]
55pub use iter::{ChunkBy, ChunkByMut};
4856#[stable(feature = "rust1", since = "1.0.0")]
4957pub use iter::{Chunks, ChunksMut, Windows};
50#[stable(feature = "rust1", since = "1.0.0")]
51pub use iter::{Iter, IterMut};
52#[stable(feature = "rust1", since = "1.0.0")]
53pub use iter::{RSplitN, RSplitNMut, Split, SplitMut, SplitN, SplitNMut};
54
55#[stable(feature = "slice_rsplit", since = "1.27.0")]
56pub use iter::{RSplit, RSplitMut};
57
5858#[stable(feature = "chunks_exact", since = "1.31.0")]
5959pub use iter::{ChunksExact, ChunksExactMut};
60
60#[stable(feature = "rust1", since = "1.0.0")]
61pub use iter::{Iter, IterMut};
6162#[stable(feature = "rchunks", since = "1.31.0")]
6263pub use iter::{RChunks, RChunksExact, RChunksExactMut, RChunksMut};
63
64#[unstable(feature = "array_chunks", issue = "74985")]
65pub use iter::{ArrayChunks, ArrayChunksMut};
66
67#[unstable(feature = "array_windows", issue = "75027")]
68pub use iter::ArrayWindows;
69
70#[stable(feature = "slice_group_by", since = "1.77.0")]
71pub use iter::{ChunkBy, ChunkByMut};
72
64#[stable(feature = "slice_rsplit", since = "1.27.0")]
65pub use iter::{RSplit, RSplitMut};
66#[stable(feature = "rust1", since = "1.0.0")]
67pub use iter::{RSplitN, RSplitNMut, Split, SplitMut, SplitN, SplitNMut};
7368#[stable(feature = "split_inclusive", since = "1.51.0")]
7469pub use iter::{SplitInclusive, SplitInclusiveMut};
75
76#[stable(feature = "rust1", since = "1.0.0")]
77pub use raw::{from_raw_parts, from_raw_parts_mut};
78
7970#[stable(feature = "from_ref", since = "1.28.0")]
8071pub use raw::{from_mut, from_ref};
81
8272#[unstable(feature = "slice_from_ptr_range", issue = "89792")]
8373pub use raw::{from_mut_ptr_range, from_ptr_range};
84
85#[stable(feature = "slice_get_slice", since = "1.28.0")]
86pub use index::SliceIndex;
87
88#[unstable(feature = "slice_range", issue = "76393")]
89pub use index::{range, try_range};
90
91#[stable(feature = "inherent_ascii_escape", since = "1.60.0")]
92pub use ascii::EscapeAscii;
74#[stable(feature = "rust1", since = "1.0.0")]
75pub use raw::{from_raw_parts, from_raw_parts_mut};
9376
9477/// Calculates the direction and split point of a one-sided range.
9578///
library/core/src/slice/raw.rs+1-3
......@@ -1,9 +1,7 @@
11//! Free functions to create `&[T]` and `&mut [T]`.
22
3use crate::array;
43use crate::ops::Range;
5use crate::ptr;
6use crate::ub_checks;
4use crate::{array, ptr, ub_checks};
75
86/// Forms a slice from a pointer and a length.
97///
library/core/src/slice/rotate.rs+1-2
......@@ -1,6 +1,5 @@
1use crate::cmp;
21use crate::mem::{self, MaybeUninit, SizedTypeProperties};
3use crate::ptr;
2use crate::{cmp, ptr};
43
54/// Rotates the range `[mid-left, mid+right)` such that the element at `mid` becomes the first
65/// 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 @@
77//! better performance than one would get using heapsort as fallback.
88
99use crate::mem::{self, SizedTypeProperties};
10
1110use crate::slice::sort::shared::pivot::choose_pivot;
1211use crate::slice::sort::shared::smallsort::insertion_sort_shift_left;
1312use crate::slice::sort::unstable::quicksort::partition;
library/core/src/slice/sort/shared/smallsort.rs+1-4
......@@ -1,11 +1,8 @@
11//! This module contains a variety of sort implementations that are optimized for small lengths.
22
3use crate::intrinsics;
43use crate::mem::{self, ManuallyDrop, MaybeUninit};
5use crate::ptr;
6use crate::slice;
7
84use crate::slice::sort::shared::FreezeMarker;
5use crate::{intrinsics, ptr, slice};
96
107// It's important to differentiate between SMALL_SORT_THRESHOLD performance for
118// 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 @@
11//! This module contains the hybrid top-level loop combining bottom-up Mergesort with top-down
22//! Quicksort.
33
4use crate::cmp;
5use crate::intrinsics;
64use crate::mem::MaybeUninit;
7
85use crate::slice::sort::shared::find_existing_run;
96use crate::slice::sort::shared::smallsort::StableSmallSortTypeImpl;
107use crate::slice::sort::stable::merge::merge;
118use crate::slice::sort::stable::quicksort::quicksort;
9use crate::{cmp, intrinsics};
1210
1311/// Sorts `v` based on comparison function `is_less`. If `eager_sort` is true,
1412/// 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 @@
11//! This module contains logic for performing a merge of two sorted sub-slices.
22
3use crate::cmp;
43use crate::mem::MaybeUninit;
5use crate::ptr;
4use crate::{cmp, ptr};
65
76/// Merges non-decreasing runs `v[..mid]` and `v[mid..]` using `scratch` as
87/// temporary storage, and stores the result into `v[..]`.
library/core/src/slice/sort/stable/mod.rs+1-3
......@@ -1,12 +1,10 @@
11//! This module contains the entry points for `slice::sort`.
22
3use crate::cmp;
4use crate::intrinsics;
53use crate::mem::{self, MaybeUninit, SizedTypeProperties};
6
74use crate::slice::sort::shared::smallsort::{
85 insertion_sort_shift_left, StableSmallSortTypeImpl, SMALL_SORT_GENERAL_SCRATCH_LEN,
96};
7use crate::{cmp, intrinsics};
108
119pub(crate) mod drift;
1210pub(crate) mod merge;
library/core/src/slice/sort/stable/quicksort.rs+1-3
......@@ -1,12 +1,10 @@
11//! This module contains a stable quicksort and partition implementation.
22
3use crate::intrinsics;
43use crate::mem::{self, ManuallyDrop, MaybeUninit};
5use crate::ptr;
6
74use crate::slice::sort::shared::pivot::choose_pivot;
85use crate::slice::sort::shared::smallsort::StableSmallSortTypeImpl;
96use crate::slice::sort::shared::FreezeMarker;
7use crate::{intrinsics, ptr};
108
119/// Sorts `v` recursively using quicksort.
1210///
library/core/src/slice/sort/unstable/heapsort.rs+1-2
......@@ -1,7 +1,6 @@
11//! This module contains a branchless heapsort as fallback for unstable quicksort.
22
3use crate::intrinsics;
4use crate::ptr;
3use crate::{intrinsics, ptr};
54
65/// Sorts `v` using heapsort, which guarantees *O*(*n* \* log(*n*)) worst-case.
76///
library/core/src/slice/sort/unstable/mod.rs-1
......@@ -2,7 +2,6 @@
22
33use crate::intrinsics;
44use crate::mem::SizedTypeProperties;
5
65use crate::slice::sort::shared::find_existing_run;
76use crate::slice::sort::shared::smallsort::insertion_sort_shift_left;
87
library/core/src/slice/sort/unstable/quicksort.rs+1-3
......@@ -1,11 +1,9 @@
11//! This module contains an unstable quicksort and two partition implementations.
22
3use crate::intrinsics;
43use crate::mem::{self, ManuallyDrop};
5use crate::ptr;
6
74use crate::slice::sort::shared::pivot::choose_pivot;
85use crate::slice::sort::shared::smallsort::UnstableSmallSortTypeImpl;
6use crate::{intrinsics, ptr};
97
108/// Sorts `v` recursively.
119///
library/core/src/str/converts.rs+1-2
......@@ -1,9 +1,8 @@
11//! Ways to create a `str` from bytes slice.
22
3use crate::{mem, ptr};
4
53use super::validations::run_utf8_validation;
64use super::Utf8Error;
5use crate::{mem, ptr};
76
87/// Converts a slice of bytes to a string slice.
98///
library/core/src/str/iter.rs+11-14
......@@ -1,23 +1,20 @@
11//! Iterators for `str` methods.
22
3use crate::char as char_mod;
3use super::pattern::{DoubleEndedSearcher, Pattern, ReverseSearcher, Searcher};
4use super::validations::{next_code_point, next_code_point_reverse};
5use super::{
6 from_utf8_unchecked, BytesIsNotEmpty, CharEscapeDebugContinue, CharEscapeDefault,
7 CharEscapeUnicode, IsAsciiWhitespace, IsNotEmpty, IsWhitespace, LinesMap, UnsafeBytesToStr,
8};
49use crate::fmt::{self, Write};
5use crate::iter::{Chain, FlatMap, Flatten};
6use crate::iter::{Copied, Filter, FusedIterator, Map, TrustedLen};
7use crate::iter::{TrustedRandomAccess, TrustedRandomAccessNoCoerce};
10use crate::iter::{
11 Chain, Copied, Filter, FlatMap, Flatten, FusedIterator, Map, TrustedLen, TrustedRandomAccess,
12 TrustedRandomAccessNoCoerce,
13};
814use crate::num::NonZero;
915use crate::ops::Try;
10use crate::option;
1116use crate::slice::{self, Split as SliceSplit};
12
13use super::from_utf8_unchecked;
14use super::pattern::Pattern;
15use super::pattern::{DoubleEndedSearcher, ReverseSearcher, Searcher};
16use super::validations::{next_code_point, next_code_point_reverse};
17use super::LinesMap;
18use super::{BytesIsNotEmpty, UnsafeBytesToStr};
19use super::{CharEscapeDebugContinue, CharEscapeDefault, CharEscapeUnicode};
20use super::{IsAsciiWhitespace, IsNotEmpty, IsWhitespace};
17use crate::{char as char_mod, option};
2118
2219/// An iterator over the [`char`]s of a string slice.
2320///
library/core/src/str/lossy.rs+3-5
......@@ -1,10 +1,8 @@
1use crate::fmt;
2use crate::fmt::Formatter;
3use crate::fmt::Write;
4use crate::iter::FusedIterator;
5
61use super::from_utf8_unchecked;
72use super::validations::utf8_char_width;
3use crate::fmt;
4use crate::fmt::{Formatter, Write};
5use crate::iter::FusedIterator;
86
97impl [u8] {
108 /// 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;
1313mod traits;
1414mod validations;
1515
16use self::pattern::Pattern;
17use self::pattern::{DoubleEndedSearcher, ReverseSearcher, Searcher};
18
19use crate::ascii;
16use self::pattern::{DoubleEndedSearcher, Pattern, ReverseSearcher, Searcher};
2017use crate::char::{self, EscapeDebugExtArgs};
21use crate::mem;
2218use crate::ops::Range;
2319use crate::slice::{self, SliceIndex};
20use crate::{ascii, mem};
2421
2522pub mod pattern;
2623
2724mod lossy;
28#[stable(feature = "utf8_chunks", since = "1.79.0")]
29pub use lossy::{Utf8Chunk, Utf8Chunks};
30
25#[unstable(feature = "str_from_raw_parts", issue = "119206")]
26pub use converts::{from_raw_parts, from_raw_parts_mut};
3127#[stable(feature = "rust1", since = "1.0.0")]
3228pub use converts::{from_utf8, from_utf8_unchecked};
33
3429#[stable(feature = "str_mut_extras", since = "1.20.0")]
3530pub use converts::{from_utf8_mut, from_utf8_unchecked_mut};
36
37#[unstable(feature = "str_from_raw_parts", issue = "119206")]
38pub use converts::{from_raw_parts, from_raw_parts_mut};
39
4031#[stable(feature = "rust1", since = "1.0.0")]
4132pub use error::{ParseBoolError, Utf8Error};
42
43#[stable(feature = "rust1", since = "1.0.0")]
44pub use traits::FromStr;
45
46#[stable(feature = "rust1", since = "1.0.0")]
47pub use iter::{Bytes, CharIndices, Chars, Lines, SplitWhitespace};
48
33#[stable(feature = "encode_utf16", since = "1.8.0")]
34pub use iter::EncodeUtf16;
4935#[stable(feature = "rust1", since = "1.0.0")]
5036#[allow(deprecated)]
5137pub use iter::LinesAny;
52
53#[stable(feature = "rust1", since = "1.0.0")]
54pub use iter::{RSplit, RSplitTerminator, Split, SplitTerminator};
55
56#[stable(feature = "rust1", since = "1.0.0")]
57pub use iter::{RSplitN, SplitN};
58
59#[stable(feature = "str_matches", since = "1.2.0")]
60pub use iter::{Matches, RMatches};
61
62#[stable(feature = "str_match_indices", since = "1.5.0")]
63pub use iter::{MatchIndices, RMatchIndices};
64
65#[stable(feature = "encode_utf16", since = "1.8.0")]
66pub use iter::EncodeUtf16;
67
68#[stable(feature = "str_escape", since = "1.34.0")]
69pub use iter::{EscapeDebug, EscapeDefault, EscapeUnicode};
70
7138#[stable(feature = "split_ascii_whitespace", since = "1.34.0")]
7239pub use iter::SplitAsciiWhitespace;
73
7440#[stable(feature = "split_inclusive", since = "1.51.0")]
7541pub use iter::SplitInclusive;
76
42#[stable(feature = "rust1", since = "1.0.0")]
43pub use iter::{Bytes, CharIndices, Chars, Lines, SplitWhitespace};
44#[stable(feature = "str_escape", since = "1.34.0")]
45pub use iter::{EscapeDebug, EscapeDefault, EscapeUnicode};
46#[stable(feature = "str_match_indices", since = "1.5.0")]
47pub use iter::{MatchIndices, RMatchIndices};
48use iter::{MatchIndicesInternal, MatchesInternal, SplitInternal, SplitNInternal};
49#[stable(feature = "str_matches", since = "1.2.0")]
50pub use iter::{Matches, RMatches};
51#[stable(feature = "rust1", since = "1.0.0")]
52pub use iter::{RSplit, RSplitTerminator, Split, SplitTerminator};
53#[stable(feature = "rust1", since = "1.0.0")]
54pub use iter::{RSplitN, SplitN};
55#[stable(feature = "utf8_chunks", since = "1.79.0")]
56pub use lossy::{Utf8Chunk, Utf8Chunks};
57#[stable(feature = "rust1", since = "1.0.0")]
58pub use traits::FromStr;
7759#[unstable(feature = "str_internals", issue = "none")]
7860pub use validations::{next_code_point, utf8_char_width};
7961
80use iter::MatchIndicesInternal;
81use iter::SplitInternal;
82use iter::{MatchesInternal, SplitNInternal};
83
8462#[inline(never)]
8563#[cold]
8664#[track_caller]
library/core/src/str/pattern.rs+2-4
......@@ -38,11 +38,10 @@
3838 issue = "27721"
3939)]
4040
41use crate::cmp;
4241use crate::cmp::Ordering;
4342use crate::convert::TryInto as _;
44use crate::fmt;
4543use crate::slice::memchr;
44use crate::{cmp, fmt};
4645
4746// Pattern
4847
......@@ -1759,8 +1758,7 @@ fn simd_contains(needle: &str, haystack: &str) -> Option<bool> {
17591758
17601759 use crate::ops::BitAnd;
17611760 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};
17641762
17651763 let first_probe = needle[0];
17661764 let last_byte_offset = needle.len() - 1;
library/core/src/str/traits.rs+2-5
......@@ -1,14 +1,11 @@
11//! Trait implementations for `str`.
22
3use super::ParseBoolError;
34use crate::cmp::Ordering;
45use crate::intrinsics::unchecked_sub;
5use crate::ops;
6use crate::ptr;
7use crate::range;
86use crate::slice::SliceIndex;
97use crate::ub_checks::assert_unsafe_precondition;
10
11use super::ParseBoolError;
8use crate::{ops, ptr, range};
129
1310/// Implements ordering of strings.
1411///
library/core/src/str/validations.rs+1-2
......@@ -1,8 +1,7 @@
11//! Operations related to UTF-8 validation.
22
3use crate::mem;
4
53use super::Utf8Error;
4use crate::mem;
65
76/// Returns the initial codepoint accumulator for the first byte.
87/// 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 @@
223223#![allow(clippy::not_unsafe_ptr_arg_deref)]
224224
225225use self::Ordering::*;
226
227226use crate::cell::UnsafeCell;
228use crate::fmt;
229use crate::intrinsics;
230
231227use crate::hint::spin_loop;
228use crate::{fmt, intrinsics};
232229
233230// Some architectures don't have byte-sized atomics, which results in LLVM
234231// 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 @@
11#![stable(feature = "futures_api", since = "1.36.0")]
22
33use crate::any::Any;
4use crate::fmt;
54use crate::marker::PhantomData;
65use crate::mem::{transmute, ManuallyDrop};
76use crate::panic::AssertUnwindSafe;
8use crate::ptr;
7use crate::{fmt, ptr};
98
109/// A `RawWaker` allows the implementor of a task executor to create a [`Waker`]
1110/// or a [`LocalWaker`] which provides customized wakeup behavior.
library/core/src/tuple.rs+1-3
......@@ -1,9 +1,7 @@
11// See core/src/primitive_docs.rs for documentation.
22
33use crate::cmp::Ordering::{self, *};
4use crate::marker::ConstParamTy_;
5use crate::marker::StructuralPartialEq;
6use crate::marker::UnsizedConstParamTy;
4use crate::marker::{ConstParamTy_, StructuralPartialEq, UnsizedConstParamTy};
75
86// Recursive macro for implementing n-ary tuple functions and operations
97//
library/core/src/ub_checks.rs-1
......@@ -81,7 +81,6 @@ macro_rules! assert_unsafe_precondition {
8181}
8282#[unstable(feature = "ub_checks", issue = "none")]
8383pub use assert_unsafe_precondition;
84
8584/// Checking library UB is always enabled when UB-checking is done
8685/// (and we use a reexport so that there is no unnecessary wrapper function).
8786#[unstable(feature = "ub_checks", issue = "none")]
library/core/tests/array.rs+2-1
......@@ -259,7 +259,8 @@ fn iterator_drops() {
259259#[test]
260260#[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")]
261261fn 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;
263264 static COUNTER: AtomicUsize = AtomicUsize::new(0);
264265 #[derive(Debug)]
265266 struct Bomb(#[allow(dead_code)] usize);
library/core/tests/clone.rs+2-1
......@@ -36,7 +36,8 @@ fn test_clone_to_uninit_slice_success() {
3636#[test]
3737#[cfg(panic = "unwind")]
3838fn 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;
4041
4142 /// A static counter is OK to use as long as _this one test_ isn't run several times in
4243 /// multiple threads.
library/core/tests/cmp.rs+2-4
......@@ -1,7 +1,5 @@
1use core::cmp::{
2 self,
3 Ordering::{self, *},
4};
1use core::cmp::Ordering::{self, *};
2use core::cmp::{self};
53
64#[test]
75fn test_int_totalord() {
library/core/tests/hash/sip.rs+1-2
......@@ -1,7 +1,6 @@
11#![allow(deprecated)]
22
3use core::hash::{Hash, Hasher};
4use core::hash::{SipHasher, SipHasher13};
3use core::hash::{Hash, Hasher, SipHasher, SipHasher13};
54use core::{mem, slice};
65
76// Hash just the bytes of the slice, without length prefix
library/core/tests/iter/adapters/chain.rs+2-1
......@@ -1,7 +1,8 @@
1use super::*;
21use core::iter::*;
32use core::num::NonZero;
43
4use super::*;
5
56#[test]
67fn test_chain() {
78 let xs = [0, 1, 2, 3, 4, 5];
library/core/tests/iter/adapters/flatten.rs+2-1
......@@ -1,8 +1,9 @@
1use super::*;
21use core::assert_eq;
32use core::iter::*;
43use core::num::NonZero;
54
5use super::*;
6
67#[test]
78fn test_iterator_flatten() {
89 let xs = [0, 3, 6];
library/core/tests/iter/adapters/map_windows.rs+4-2
......@@ -1,10 +1,12 @@
1use std::sync::atomic::{AtomicUsize, Ordering::SeqCst};
1use std::sync::atomic::AtomicUsize;
2use std::sync::atomic::Ordering::SeqCst;
23
34#[cfg(not(panic = "abort"))]
45mod drop_checks {
56 //! These tests mainly make sure the elements are correctly dropped.
67
7 use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering::SeqCst};
8 use std::sync::atomic::Ordering::SeqCst;
9 use std::sync::atomic::{AtomicBool, AtomicUsize};
810
911 #[derive(Debug)]
1012 struct DropInfo {
library/core/tests/iter/adapters/peekable.rs+2-1
......@@ -1,6 +1,7 @@
1use super::*;
21use core::iter::*;
32
3use super::*;
4
45#[test]
56fn test_iterator_peekable() {
67 let xs = vec![0, 1, 2, 3, 4, 5];
library/core/tests/iter/adapters/zip.rs+3-3
......@@ -1,6 +1,7 @@
1use super::*;
21use core::iter::*;
32
3use super::*;
4
45#[test]
56fn test_zip_nth() {
67 let xs = [0, 1, 2, 4, 5];
......@@ -239,8 +240,7 @@ fn test_zip_trusted_random_access_composition() {
239240#[test]
240241#[cfg(panic = "unwind")]
241242fn 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};
244244
245245 let mut counter = 0;
246246
library/core/tests/iter/range.rs+2-1
......@@ -1,7 +1,8 @@
1use super::*;
21use core::ascii::Char as AsciiChar;
32use core::num::NonZero;
43
4use super::*;
5
56#[test]
67fn test_range() {
78 assert_eq!((0..5).collect::<Vec<_>>(), [0, 1, 2, 3, 4]);
library/core/tests/iter/sources.rs+2-1
......@@ -1,6 +1,7 @@
1use super::*;
21use core::iter::*;
32
3use super::*;
4
45#[test]
56fn test_repeat() {
67 let mut it = repeat(42);
library/core/tests/lazy.rs+3-4
......@@ -1,7 +1,6 @@
1use core::{
2 cell::{Cell, LazyCell, OnceCell},
3 sync::atomic::{AtomicUsize, Ordering::SeqCst},
4};
1use core::cell::{Cell, LazyCell, OnceCell};
2use core::sync::atomic::AtomicUsize;
3use core::sync::atomic::Ordering::SeqCst;
54
65#[test]
76fn once_cell() {
library/core/tests/mem.rs-1
......@@ -1,6 +1,5 @@
11use core::mem::*;
22use core::ptr;
3
43#[cfg(panic = "unwind")]
54use std::rc::Rc;
65
library/core/tests/net/ip_addr.rs+2-1
......@@ -1,9 +1,10 @@
1use super::{sa4, sa6};
21use core::net::{
32 IpAddr, Ipv4Addr, Ipv6Addr, Ipv6MulticastScope, SocketAddr, SocketAddrV4, SocketAddrV6,
43};
54use core::str::FromStr;
65
6use super::{sa4, sa6};
7
78#[test]
89fn test_from_str_ipv4() {
910 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 @@
1use std::mem::MaybeUninit;
2use std::{fmt, str};
3
4use core::num::flt2dec::{decode, DecodableFloat, Decoded, FullDecoded};
5use core::num::flt2dec::{round_up, Sign, MAX_SIG_DIGITS};
61use 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,
84};
95use core::num::fmt::{Formatted, Part};
6use std::mem::MaybeUninit;
7use std::{fmt, str};
108
119mod estimator;
1210mod strategy {
library/core/tests/num/flt2dec/random.rs+2-5
......@@ -1,13 +1,10 @@
11#![cfg(not(target_arch = "wasm32"))]
22
3use core::num::flt2dec::strategy::grisu::{format_exact_opt, format_shortest_opt};
4use core::num::flt2dec::{decode, DecodableFloat, Decoded, FullDecoded, MAX_SIG_DIGITS};
35use std::mem::MaybeUninit;
46use std::str;
57
6use core::num::flt2dec::strategy::grisu::format_exact_opt;
7use core::num::flt2dec::strategy::grisu::format_shortest_opt;
8use core::num::flt2dec::MAX_SIG_DIGITS;
9use core::num::flt2dec::{decode, DecodableFloat, Decoded, FullDecoded};
10
118use rand::distributions::{Distribution, Uniform};
129
1310pub fn decode_finite<T: DecodableFloat>(v: T) -> Decoded {
library/core/tests/num/flt2dec/strategy/dragon.rs+2-1
......@@ -1,7 +1,8 @@
1use super::super::*;
21use core::num::bignum::Big32x40 as Big;
32use core::num::flt2dec::strategy::dragon::*;
43
4use super::super::*;
5
56#[test]
67fn test_mul_pow10() {
78 let mut prevpow10 = Big::from_small(1);
library/core/tests/num/flt2dec/strategy/grisu.rs+2-1
......@@ -1,6 +1,7 @@
1use super::super::*;
21use core::num::flt2dec::strategy::grisu::*;
32
3use super::super::*;
4
45#[test]
56#[cfg_attr(miri, ignore)] // Miri is too slow
67fn test_cached_power() {
library/core/tests/ops.rs+3-2
......@@ -1,7 +1,8 @@
11mod control_flow;
22
3use core::ops::{Bound, Range, RangeFrom, RangeFull, RangeInclusive, RangeTo, RangeToInclusive};
4use core::ops::{Deref, DerefMut};
3use core::ops::{
4 Bound, Deref, DerefMut, Range, RangeFrom, RangeFull, RangeInclusive, RangeTo, RangeToInclusive,
5};
56
67// Test the Range structs and syntax.
78
library/core/tests/pin_macro.rs+3-5
......@@ -1,10 +1,8 @@
11// edition:2021
22
3use core::{
4 marker::PhantomPinned,
5 mem::{drop as stuff, transmute},
6 pin::{pin, Pin},
7};
3use core::marker::PhantomPinned;
4use core::mem::{drop as stuff, transmute};
5use core::pin::{pin, Pin};
86
97#[test]
108fn basic() {
library/core/tests/result.rs+2-1
......@@ -410,7 +410,8 @@ fn result_opt_conversions() {
410410#[test]
411411fn result_try_trait_v2_branch() {
412412 use core::num::NonZero;
413 use core::ops::{ControlFlow::*, Try};
413 use core::ops::ControlFlow::*;
414 use core::ops::Try;
414415
415416 assert_eq!(Ok::<i32, i32>(4).branch(), Continue(4));
416417 assert_eq!(Err::<i32, i32>(4).branch(), Break(Err(4)));
library/core/tests/slice.rs+1
......@@ -1856,6 +1856,7 @@ fn sort_unstable() {
18561856#[cfg_attr(miri, ignore)] // Miri is too slow
18571857fn select_nth_unstable() {
18581858 use core::cmp::Ordering::{Equal, Greater, Less};
1859
18591860 use rand::seq::SliceRandom;
18601861 use rand::Rng;
18611862
library/core/tests/waker.rs+3-5
......@@ -23,11 +23,9 @@ static WAKER_VTABLE: RawWakerVTable = RawWakerVTable::new(
2323
2424// https://github.com/rust-lang/rust/issues/102012#issuecomment-1915282956
2525mod 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};
3129
3230 const NOP_RAWWAKER: RawWaker = {
3331 fn nop(_: *const ()) {}
library/panic_unwind/src/emcc.rs+2-3
......@@ -8,10 +8,9 @@
88
99use alloc::boxed::Box;
1010use core::any::Any;
11use core::intrinsics;
12use core::mem;
13use core::ptr;
1411use core::sync::atomic::{AtomicBool, Ordering};
12use core::{intrinsics, mem, ptr};
13
1514use unwind as uw;
1615
1716// This matches the layout of std::type_info in C++
library/proc_macro/src/bridge/arena.rs+1-4
......@@ -5,12 +5,9 @@
55//! being built at the same time as `std`.
66
77use std::cell::{Cell, RefCell};
8use std::cmp;
98use std::mem::MaybeUninit;
109use std::ops::Range;
11use std::ptr;
12use std::slice;
13use std::str;
10use std::{cmp, ptr, slice, str};
1411
1512// The arenas start with PAGE-sized chunks, and then each new chunk is twice as
1613// 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 @@
11//! Client-side types.
22
3use super::*;
4
53use std::cell::RefCell;
64use std::marker::PhantomData;
75use std::sync::atomic::AtomicU32;
86
7use super::*;
8
99macro_rules! define_client_handles {
1010 (
1111 'owned: $($oty:ident,)*
......@@ -190,10 +190,11 @@ impl<'a> !Sync for Bridge<'a> {}
190190
191191#[allow(unsafe_code)]
192192mod state {
193 use super::Bridge;
194193 use std::cell::{Cell, RefCell};
195194 use std::ptr;
196195
196 use super::Bridge;
197
197198 thread_local! {
198199 static BRIDGE_STATE: Cell<*const ()> = const { Cell::new(ptr::null()) };
199200 }
library/proc_macro/src/bridge/fxhash.rs+1-2
......@@ -5,8 +5,7 @@
55//! on the `rustc_hash` crate.
66
77use std::collections::HashMap;
8use std::hash::BuildHasherDefault;
9use std::hash::Hasher;
8use std::hash::{BuildHasherDefault, Hasher};
109use std::ops::BitXor;
1110
1211/// Type alias for a hashmap using the `fx` hash algorithm.
library/proc_macro/src/bridge/mod.rs+4-8
......@@ -8,16 +8,12 @@
88
99#![deny(unsafe_code)]
1010
11use crate::{Delimiter, Level, Spacing};
12use std::fmt;
1311use std::hash::Hash;
14use std::marker;
15use std::mem;
16use std::ops::Bound;
17use std::ops::Range;
18use std::panic;
12use std::ops::{Bound, Range};
1913use std::sync::Once;
20use std::thread;
14use std::{fmt, marker, mem, panic, thread};
15
16use crate::{Delimiter, Level, Spacing};
2117
2218/// Higher-order macro describing the server RPC API, allowing automatic
2319/// 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 @@
11//! Server-side traits.
22
3use super::*;
4
53use std::cell::Cell;
64use std::marker::PhantomData;
75
6use super::*;
7
88macro_rules! define_server_handles {
99 (
1010 'owned: $($oty:ident,)*
library/proc_macro/src/lib.rs+5-4
......@@ -45,16 +45,17 @@ pub mod bridge;
4545mod diagnostic;
4646mod escape;
4747
48#[unstable(feature = "proc_macro_diagnostic", issue = "54140")]
49pub use diagnostic::{Diagnostic, Level, MultiSpan};
50
51use crate::escape::{escape_bytes, EscapeOptions};
5248use std::ffi::CStr;
5349use std::ops::{Range, RangeBounds};
5450use std::path::PathBuf;
5551use std::str::FromStr;
5652use std::{error, fmt};
5753
54#[unstable(feature = "proc_macro_diagnostic", issue = "54140")]
55pub use diagnostic::{Diagnostic, Level, MultiSpan};
56
57use crate::escape::{escape_bytes, EscapeOptions};
58
5859/// Determines whether proc_macro has been made accessible to the currently
5960/// running program.
6061///
library/std/benches/hash/map.rs+1
......@@ -1,6 +1,7 @@
11#![cfg(test)]
22
33use std::collections::HashMap;
4
45use test::Bencher;
56
67#[bench]
library/std/benches/hash/set_ops.rs+1
......@@ -1,4 +1,5 @@
11use std::collections::HashSet;
2
23use test::Bencher;
34
45#[bench]
library/std/src/alloc.rs+1-2
......@@ -56,10 +56,9 @@
5656#![deny(unsafe_op_in_unsafe_fn)]
5757#![stable(feature = "alloc_module", since = "1.28.0")]
5858
59use core::hint;
6059use core::ptr::NonNull;
6160use core::sync::atomic::{AtomicPtr, Ordering};
62use core::{mem, ptr};
61use core::{hint, mem, ptr};
6362
6463#[stable(feature = "alloc_module", since = "1.28.0")]
6564#[doc(inline)]
library/std/src/ascii.rs+2-3
......@@ -13,11 +13,10 @@
1313
1414#![stable(feature = "rust1", since = "1.0.0")]
1515
16#[stable(feature = "rust1", since = "1.0.0")]
17pub use core::ascii::{escape_default, EscapeDefault};
18
1916#[unstable(feature = "ascii_char", issue = "110998")]
2017pub use core::ascii::Char;
18#[stable(feature = "rust1", since = "1.0.0")]
19pub use core::ascii::{escape_default, EscapeDefault};
2120
2221/// Extension methods for ASCII-subset only operations.
2322///
library/std/src/backtrace.rs+3-3
......@@ -89,13 +89,13 @@ mod tests;
8989// a backtrace or actually symbolizing it.
9090
9191use crate::backtrace_rs::{self, BytesOrWideString};
92use crate::env;
9392use crate::ffi::c_void;
94use crate::fmt;
9593use crate::panic::UnwindSafe;
96use crate::sync::atomic::{AtomicU8, Ordering::Relaxed};
94use crate::sync::atomic::AtomicU8;
95use crate::sync::atomic::Ordering::Relaxed;
9796use crate::sync::LazyLock;
9897use crate::sys::backtrace::{lock, output_filename, set_image_base};
98use crate::{env, fmt};
9999
100100/// A captured OS thread stack backtrace.
101101///
library/std/src/collections/hash/map.rs+2-4
......@@ -1,13 +1,11 @@
11#[cfg(test)]
22mod tests;
33
4use self::Entry::*;
5
64use hashbrown::hash_map as base;
75
6use self::Entry::*;
87use crate::borrow::Borrow;
9use crate::collections::TryReserveError;
10use crate::collections::TryReserveErrorKind;
8use crate::collections::{TryReserveError, TryReserveErrorKind};
119use crate::error::Error;
1210use crate::fmt::{self, Debug};
1311use crate::hash::{BuildHasher, Hash, RandomState};
library/std/src/collections/hash/map/tests.rs+3-3
......@@ -1,11 +1,12 @@
1use rand::Rng;
2use realstd::collections::TryReserveErrorKind::*;
3
14use super::Entry::{Occupied, Vacant};
25use super::HashMap;
36use crate::assert_matches::assert_matches;
47use crate::cell::RefCell;
58use crate::hash::RandomState;
69use crate::test_helpers::test_rng;
7use rand::Rng;
8use realstd::collections::TryReserveErrorKind::*;
910
1011// https://github.com/rust-lang/rust/issues/62301
1112fn _assert_hashmap_is_unwind_safe() {
......@@ -946,7 +947,6 @@ fn test_raw_entry() {
946947
947948mod test_extract_if {
948949 use super::*;
949
950950 use crate::panic::{catch_unwind, AssertUnwindSafe};
951951 use crate::sync::atomic::{AtomicUsize, Ordering};
952952
library/std/src/collections/hash/set.rs+1-2
......@@ -3,6 +3,7 @@ mod tests;
33
44use hashbrown::hash_set as base;
55
6use super::map::map_try_reserve_error;
67use crate::borrow::Borrow;
78use crate::collections::TryReserveError;
89use crate::fmt;
......@@ -10,8 +11,6 @@ use crate::hash::{BuildHasher, Hash, RandomState};
1011use crate::iter::{Chain, FusedIterator};
1112use crate::ops::{BitAnd, BitOr, BitXor, Sub};
1213
13use super::map::map_try_reserve_error;
14
1514/// A [hash set] implemented as a `HashMap` where the value is `()`.
1615///
1716/// As with the [`HashMap`] type, a `HashSet` requires that the elements
library/std/src/collections/hash/set/tests.rs-1
......@@ -1,5 +1,4 @@
11use super::HashSet;
2
32use crate::hash::RandomState;
43use crate::panic::{catch_unwind, AssertUnwindSafe};
54use crate::sync::atomic::{AtomicU32, Ordering};
library/std/src/collections/mod.rs+13-16
......@@ -401,12 +401,14 @@
401401
402402#![stable(feature = "rust1", since = "1.0.0")]
403403
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)]
408pub use crate::ops::Bound;
409
404#[stable(feature = "try_reserve", since = "1.57.0")]
405pub 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)]
411pub use alloc_crate::collections::TryReserveErrorKind;
410412#[stable(feature = "rust1", since = "1.0.0")]
411413pub use alloc_crate::collections::{binary_heap, btree_map, btree_set};
412414#[stable(feature = "rust1", since = "1.0.0")]
......@@ -422,15 +424,11 @@ pub use self::hash_map::HashMap;
422424#[stable(feature = "rust1", since = "1.0.0")]
423425#[doc(inline)]
424426pub use self::hash_set::HashSet;
425
426#[stable(feature = "try_reserve", since = "1.57.0")]
427pub 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)]
433pub 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)]
431pub use crate::ops::Bound;
434432
435433mod hash;
436434
......@@ -439,7 +437,6 @@ pub mod hash_map {
439437 //! A hash map implemented with quadratic probing and SIMD lookup.
440438 #[stable(feature = "rust1", since = "1.0.0")]
441439 pub use super::hash::map::*;
442
443440 #[stable(feature = "hashmap_build_hasher", since = "1.7.0")]
444441 pub use crate::hash::random::DefaultHasher;
445442 #[stable(feature = "hashmap_build_hasher", since = "1.7.0")]
library/std/src/env.rs+1-3
......@@ -15,11 +15,9 @@ mod tests;
1515
1616use crate::error::Error;
1717use crate::ffi::{OsStr, OsString};
18use crate::fmt;
19use crate::io;
2018use crate::path::{Path, PathBuf};
21use crate::sys;
2219use crate::sys::os as os_imp;
20use crate::{fmt, io, sys};
2321
2422/// Returns the current working directory as a [`PathBuf`].
2523///
library/std/src/error.rs+3-3
......@@ -4,14 +4,14 @@
44#[cfg(test)]
55mod tests;
66
7use crate::backtrace::Backtrace;
8use crate::fmt::{self, Write};
9
107#[stable(feature = "rust1", since = "1.0.0")]
118pub use core::error::Error;
129#[unstable(feature = "error_generic_member_access", issue = "99301")]
1310pub use core::error::{request_ref, request_value, Request};
1411
12use crate::backtrace::Backtrace;
13use crate::fmt::{self, Write};
14
1515/// An error reporter that prints an error and its sources.
1616///
1717/// 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 @@
1use core::error::Request;
2
13use super::Error;
24use crate::fmt;
3use core::error::Request;
45
56#[derive(Debug, PartialEq)]
67struct A;
library/std/src/f128.rs+3-3
......@@ -7,12 +7,12 @@
77#[cfg(test)]
88mod tests;
99
10#[cfg(not(test))]
11use crate::intrinsics;
12
1310#[unstable(feature = "f128", issue = "116909")]
1411pub use core::f128::consts;
1512
13#[cfg(not(test))]
14use crate::intrinsics;
15
1616#[cfg(not(test))]
1717impl f128 {
1818 /// Raises a number to an integer power.
library/std/src/f128/tests.rs+1-2
......@@ -3,8 +3,7 @@
33#![cfg(reliable_f128)]
44
55use crate::f128::consts;
6use crate::num::FpCategory as Fp;
7use crate::num::*;
6use crate::num::{FpCategory as Fp, *};
87
98/// Smallest number
109const TINY_BITS: u128 = 0x1;
library/std/src/f16.rs+3-3
......@@ -7,12 +7,12 @@
77#[cfg(test)]
88mod tests;
99
10#[cfg(not(test))]
11use crate::intrinsics;
12
1310#[unstable(feature = "f16", issue = "116909")]
1411pub use core::f16::consts;
1512
13#[cfg(not(test))]
14use crate::intrinsics;
15
1616#[cfg(not(test))]
1717impl f16 {
1818 /// Raises a number to an integer power.
library/std/src/f16/tests.rs+1-2
......@@ -3,8 +3,7 @@
33#![cfg(reliable_f16)]
44
55use crate::f16::consts;
6use crate::num::FpCategory as Fp;
7use crate::num::*;
6use crate::num::{FpCategory as Fp, *};
87
98// We run out of precision pretty quickly with f16
109// const F16_APPROX_L1: f16 = 0.001;
library/std/src/f32.rs+5-5
......@@ -15,11 +15,6 @@
1515#[cfg(test)]
1616mod tests;
1717
18#[cfg(not(test))]
19use crate::intrinsics;
20#[cfg(not(test))]
21use crate::sys::cmath;
22
2318#[stable(feature = "rust1", since = "1.0.0")]
2419#[allow(deprecated, deprecated_in_future)]
2520pub use core::f32::{
......@@ -27,6 +22,11 @@ pub use core::f32::{
2722 MIN_EXP, MIN_POSITIVE, NAN, NEG_INFINITY, RADIX,
2823};
2924
25#[cfg(not(test))]
26use crate::intrinsics;
27#[cfg(not(test))]
28use crate::sys::cmath;
29
3030#[cfg(not(test))]
3131impl f32 {
3232 /// Returns the largest integer less than or equal to `self`.
library/std/src/f32/tests.rs+1-2
......@@ -1,6 +1,5 @@
11use crate::f32::consts;
2use crate::num::FpCategory as Fp;
3use crate::num::*;
2use crate::num::{FpCategory as Fp, *};
43
54/// Smallest number
65#[allow(dead_code)] // unused on x86
library/std/src/f64.rs+5-5
......@@ -15,11 +15,6 @@
1515#[cfg(test)]
1616mod tests;
1717
18#[cfg(not(test))]
19use crate::intrinsics;
20#[cfg(not(test))]
21use crate::sys::cmath;
22
2318#[stable(feature = "rust1", since = "1.0.0")]
2419#[allow(deprecated, deprecated_in_future)]
2520pub use core::f64::{
......@@ -27,6 +22,11 @@ pub use core::f64::{
2722 MIN_EXP, MIN_POSITIVE, NAN, NEG_INFINITY, RADIX,
2823};
2924
25#[cfg(not(test))]
26use crate::intrinsics;
27#[cfg(not(test))]
28use crate::sys::cmath;
29
3030#[cfg(not(test))]
3131impl f64 {
3232 /// Returns the largest integer less than or equal to `self`.
library/std/src/f64/tests.rs+1-2
......@@ -1,6 +1,5 @@
11use crate::f64::consts;
2use crate::num::FpCategory as Fp;
3use crate::num::*;
2use crate::num::{FpCategory as Fp, *};
43
54/// Smallest number
65#[allow(dead_code)] // unused on x86
library/std/src/ffi/c_str.rs+8-13
......@@ -1,19 +1,14 @@
11//! [`CStr`], [`CString`], and related types.
22
3#[stable(feature = "rust1", since = "1.0.0")]
4pub use core::ffi::c_str::CStr;
5
6#[stable(feature = "cstr_from_bytes", since = "1.10.0")]
7pub use core::ffi::c_str::FromBytesWithNulError;
8
9#[stable(feature = "cstr_from_bytes_until_nul", since = "1.69.0")]
10pub use core::ffi::c_str::FromBytesUntilNulError;
11
12#[stable(feature = "rust1", since = "1.0.0")]
13pub use alloc::ffi::c_str::{CString, NulError};
14
153#[stable(feature = "cstring_from_vec_with_nul", since = "1.58.0")]
164pub use alloc::ffi::c_str::FromVecWithNulError;
17
185#[stable(feature = "cstring_into", since = "1.7.0")]
196pub use alloc::ffi::c_str::IntoStringError;
7#[stable(feature = "rust1", since = "1.0.0")]
8pub use alloc::ffi::c_str::{CString, NulError};
9#[stable(feature = "rust1", since = "1.0.0")]
10pub use core::ffi::c_str::CStr;
11#[stable(feature = "cstr_from_bytes_until_nul", since = "1.69.0")]
12pub use core::ffi::c_str::FromBytesUntilNulError;
13#[stable(feature = "cstr_from_bytes", since = "1.10.0")]
14pub use core::ffi::c_str::FromBytesWithNulError;
library/std/src/ffi/mod.rs+22-30
......@@ -164,50 +164,42 @@
164164#[unstable(feature = "c_str_module", issue = "112134")]
165165pub mod c_str;
166166
167#[doc(inline)]
168#[stable(feature = "rust1", since = "1.0.0")]
169pub use self::c_str::{CStr, CString};
170
171#[doc(no_inline)]
172#[stable(feature = "cstr_from_bytes", since = "1.10.0")]
173pub use self::c_str::FromBytesWithNulError;
167#[stable(feature = "core_c_void", since = "1.30.0")]
168pub use core::ffi::c_void;
169#[stable(feature = "core_ffi_c", since = "1.64.0")]
170pub 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)]
180pub use core::ffi::{VaList, VaListImpl};
174181
175182#[doc(no_inline)]
176183#[stable(feature = "cstr_from_bytes_until_nul", since = "1.69.0")]
177184pub use self::c_str::FromBytesUntilNulError;
178
179185#[doc(no_inline)]
180#[stable(feature = "rust1", since = "1.0.0")]
181pub use self::c_str::NulError;
182
186#[stable(feature = "cstr_from_bytes", since = "1.10.0")]
187pub use self::c_str::FromBytesWithNulError;
183188#[doc(no_inline)]
184189#[stable(feature = "cstring_from_vec_with_nul", since = "1.58.0")]
185190pub use self::c_str::FromVecWithNulError;
186
187191#[doc(no_inline)]
188192#[stable(feature = "cstring_into", since = "1.7.0")]
189193pub use self::c_str::IntoStringError;
190
194#[doc(no_inline)]
195#[stable(feature = "rust1", since = "1.0.0")]
196pub use self::c_str::NulError;
197#[doc(inline)]
198#[stable(feature = "rust1", since = "1.0.0")]
199pub use self::c_str::{CStr, CString};
191200#[stable(feature = "rust1", since = "1.0.0")]
192201#[doc(inline)]
193202pub use self::os_str::{OsStr, OsString};
194203
195#[stable(feature = "core_ffi_c", since = "1.64.0")]
196pub 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")]
202pub 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)]
210pub use core::ffi::{VaList, VaListImpl};
211
212204#[unstable(feature = "os_str_display", issue = "120048")]
213205pub mod os_str;
library/std/src/ffi/os_str.rs+1-4
......@@ -4,18 +4,15 @@
44mod tests;
55
66use crate::borrow::{Borrow, Cow};
7use crate::cmp;
87use crate::collections::TryReserveError;
9use crate::fmt;
108use crate::hash::{Hash, Hasher};
119use crate::ops::{self, Range};
1210use crate::rc::Rc;
13use crate::slice;
1411use crate::str::FromStr;
1512use crate::sync::Arc;
16
1713use crate::sys::os_str::{Buf, Slice};
1814use crate::sys_common::{AsInner, FromInner, IntoInner};
15use crate::{cmp, fmt, slice};
1916
2017/// A type that can represent owned, mutable platform-native strings, but is
2118/// cheaply inter-convertible with Rust strings.
library/std/src/fs/tests.rs+12-14
......@@ -1,20 +1,11 @@
1use crate::io::prelude::*;
2
3use crate::env;
4use crate::fs::{self, File, FileTimes, OpenOptions};
5use crate::io::{BorrowedBuf, ErrorKind, SeekFrom};
6use crate::mem::MaybeUninit;
7use crate::path::Path;
8use crate::str;
9use crate::sync::Arc;
10use crate::sys_common::io::test::{tmpdir, TempDir};
11use crate::thread;
12use crate::time::{Duration, Instant, SystemTime};
13
141use rand::RngCore;
152
163#[cfg(target_os = "macos")]
174use crate::ffi::{c_char, c_int};
5use crate::fs::{self, File, FileTimes, OpenOptions};
6use crate::io::prelude::*;
7use crate::io::{BorrowedBuf, ErrorKind, SeekFrom};
8use crate::mem::MaybeUninit;
189#[cfg(unix)]
1910use crate::os::unix::fs::symlink as symlink_dir;
2011#[cfg(unix)]
......@@ -23,8 +14,13 @@ use crate::os::unix::fs::symlink as symlink_file;
2314use crate::os::unix::fs::symlink as junction_point;
2415#[cfg(windows)]
2516use crate::os::windows::fs::{junction_point, symlink_dir, symlink_file, OpenOptionsExt};
17use crate::path::Path;
18use crate::sync::Arc;
2619#[cfg(target_os = "macos")]
2720use crate::sys::weak::weak;
21use crate::sys_common::io::test::{tmpdir, TempDir};
22use crate::time::{Duration, Instant, SystemTime};
23use crate::{env, str, thread};
2824
2925macro_rules! check {
3026 ($e:expr) => {
......@@ -1514,7 +1510,9 @@ fn symlink_hard_link() {
15141510#[test]
15151511#[cfg(windows)]
15161512fn 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;
15181516 const PATH_LEN: usize = 247;
15191517
15201518 let tmpdir = tmpdir();
library/std/src/hash/random.rs+1-2
......@@ -10,8 +10,7 @@
1010#[allow(deprecated)]
1111use super::{BuildHasher, Hasher, SipHasher13};
1212use crate::cell::Cell;
13use crate::fmt;
14use crate::sys;
13use crate::{fmt, sys};
1514
1615/// `RandomState` is the default state for [`HashMap`] types.
1716///
library/std/src/io/buffered/bufreader.rs+2-1
......@@ -1,11 +1,12 @@
11mod buffer;
22
3use buffer::Buffer;
4
35use crate::fmt;
46use crate::io::{
57 self, uninlined_slow_read_byte, BorrowedCursor, BufRead, IoSliceMut, Read, Seek, SeekFrom,
68 SizeHint, SpecReadByte, DEFAULT_BUF_SIZE,
79};
8use buffer::Buffer;
910
1011/// The `BufReader<R>` struct adds buffering to any reader.
1112///
library/std/src/io/buffered/bufwriter.rs+1-3
......@@ -1,10 +1,8 @@
1use crate::error;
2use crate::fmt;
31use crate::io::{
42 self, ErrorKind, IntoInnerError, IoSlice, Seek, SeekFrom, Write, DEFAULT_BUF_SIZE,
53};
64use crate::mem::{self, ManuallyDrop};
7use crate::ptr;
5use crate::{error, fmt, ptr};
86
97/// Wraps a writer and buffers its output.
108///
library/std/src/io/buffered/linewriter.rs+2-1
......@@ -1,5 +1,6 @@
11use crate::fmt;
2use crate::io::{self, buffered::LineWriterShim, BufWriter, IntoInnerError, IoSlice, Write};
2use crate::io::buffered::LineWriterShim;
3use crate::io::{self, BufWriter, IntoInnerError, IoSlice, Write};
34
45/// Wraps a writer and buffers output to it, flushing whenever a newline
56/// (`0x0a`, `'\n'`) is detected.
library/std/src/io/buffered/linewritershim.rs+2-1
......@@ -1,6 +1,7 @@
1use crate::io::{self, BufWriter, IoSlice, Write};
21use core::slice::memchr;
32
3use crate::io::{self, BufWriter, IoSlice, Write};
4
45/// Private helper struct for implementing the line-buffered writing logic.
56///
67/// 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;
88#[cfg(test)]
99mod tests;
1010
11use crate::error;
12use crate::fmt;
13use crate::io::Error;
11#[stable(feature = "bufwriter_into_parts", since = "1.56.0")]
12pub use bufwriter::WriterPanicked;
13use linewritershim::LineWriterShim;
1414
1515#[stable(feature = "rust1", since = "1.0.0")]
1616pub use self::{bufreader::BufReader, bufwriter::BufWriter, linewriter::LineWriter};
17use linewritershim::LineWriterShim;
18
19#[stable(feature = "bufwriter_into_parts", since = "1.56.0")]
20pub use bufwriter::WriterPanicked;
17use crate::io::Error;
18use crate::{error, fmt};
2119
2220/// An error returned by [`BufWriter::into_inner`] which combines an error that
2321/// 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::{
33 self, BorrowedBuf, BufReader, BufWriter, ErrorKind, IoSlice, LineWriter, SeekFrom,
44};
55use crate::mem::MaybeUninit;
6use crate::panic;
76use crate::sync::atomic::{AtomicUsize, Ordering};
8use crate::thread;
7use crate::{panic, thread};
98
109/// A dummy reader intended at testing short-reads propagation.
1110pub struct ShortReader {
library/std/src/io/copy/tests.rs+3-4
......@@ -119,13 +119,12 @@ fn copy_specializes_from_slice() {
119119
120120#[cfg(unix)]
121121mod io_benches {
122 use crate::fs::File;
123 use crate::fs::OpenOptions;
122 use test::Bencher;
123
124 use crate::fs::{File, OpenOptions};
124125 use crate::io::prelude::*;
125126 use crate::io::BufReader;
126127
127 use test::Bencher;
128
129128 #[bench]
130129 fn bench_copy_buf_reader(b: &mut Bencher) {
131130 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 @@
11#[cfg(test)]
22mod tests;
33
4use crate::io::prelude::*;
5
64use crate::alloc::Allocator;
75use crate::cmp;
6use crate::io::prelude::*;
87use crate::io::{self, BorrowedCursor, ErrorKind, IoSlice, IoSliceMut, SeekFrom};
98
109/// 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;
1111#[cfg(any(not(target_pointer_width = "64"), target_os = "uefi"))]
1212use repr_unpacked::Repr;
1313
14use crate::error;
15use crate::fmt;
16use crate::result;
17use crate::sys;
14use crate::{error, fmt, result, sys};
1815
1916/// A specialized [`Result`] type for I/O operations.
2017///
library/std/src/io/error/repr_bitpacked.rs+2-1
......@@ -102,10 +102,11 @@
102102//! to use a pointer type to store something that may hold an integer, some of
103103//! the time.
104104
105use super::{Custom, ErrorData, ErrorKind, RawOsError, SimpleMessage};
106105use core::marker::PhantomData;
107106use core::ptr::{self, NonNull};
108107
108use super::{Custom, ErrorData, ErrorKind, RawOsError, SimpleMessage};
109
109110// The 2 least-significant bits are used as tag.
110111const TAG_MASK: usize = 0b11;
111112const TAG_SIMPLE_MESSAGE: usize = 0b00;
library/std/src/io/error/tests.rs+3-3
......@@ -1,10 +1,9 @@
11use super::{const_io_error, Custom, Error, ErrorData, ErrorKind, Repr, SimpleMessage};
22use crate::assert_matches::assert_matches;
3use crate::error;
4use crate::fmt;
53use crate::mem::size_of;
64use crate::sys::decode_error_kind;
75use crate::sys::os::error_string;
6use crate::{error, fmt};
87
98#[test]
109fn test_size() {
......@@ -95,7 +94,8 @@ fn test_errorkind_packing() {
9594
9695#[test]
9796fn test_simple_message_packing() {
98 use super::{ErrorKind::*, SimpleMessage};
97 use super::ErrorKind::*;
98 use super::SimpleMessage;
9999 macro_rules! check_simple_msg {
100100 ($err:expr, $kind:ident, $msg:literal) => {{
101101 let e = &$err;
library/std/src/io/impls.rs+1-4
......@@ -2,12 +2,9 @@
22mod tests;
33
44use crate::alloc::Allocator;
5use crate::cmp;
65use crate::collections::VecDeque;
7use crate::fmt;
86use crate::io::{self, BorrowedCursor, BufRead, IoSlice, IoSliceMut, Read, Seek, SeekFrom, Write};
9use crate::mem;
10use crate::str;
7use crate::{cmp, fmt, mem, str};
118
129// =============================================================================
1310// Forwarding implementations
library/std/src/io/mod.rs+7-11
......@@ -297,15 +297,12 @@
297297#[cfg(test)]
298298mod tests;
299299
300use crate::cmp;
301use crate::fmt;
302use crate::mem::take;
303use crate::ops::{Deref, DerefMut};
304use crate::slice;
305use crate::str;
306use crate::sys;
300#[unstable(feature = "read_buf", issue = "78485")]
301pub use core::io::{BorrowedBuf, BorrowedCursor};
307302use core::slice::memchr;
308303
304pub(crate) use error::const_io_error;
305
309306#[stable(feature = "bufwriter_into_parts", since = "1.56.0")]
310307pub use self::buffered::WriterPanicked;
311308#[unstable(feature = "raw_os_error_ty", issue = "107792")]
......@@ -328,10 +325,9 @@ pub use self::{
328325 stdio::{stderr, stdin, stdout, Stderr, StderrLock, Stdin, StdinLock, Stdout, StdoutLock},
329326 util::{empty, repeat, sink, Empty, Repeat, Sink},
330327};
331
332#[unstable(feature = "read_buf", issue = "78485")]
333pub use core::io::{BorrowedBuf, BorrowedCursor};
334pub(crate) use error::const_io_error;
328use crate::mem::take;
329use crate::ops::{Deref, DerefMut};
330use crate::{cmp, fmt, slice, str, sys};
335331
336332mod buffered;
337333pub(crate) mod copy;
library/std/src/io/stdio.rs+1-2
......@@ -3,11 +3,10 @@
33#[cfg(test)]
44mod tests;
55
6use crate::io::prelude::*;
7
86use crate::cell::{Cell, RefCell};
97use crate::fmt;
108use crate::fs::File;
9use crate::io::prelude::*;
1110use crate::io::{
1211 self, BorrowedCursor, BufReader, IoSlice, IoSliceMut, LineWriter, Lines, SpecReadByte,
1312};
library/std/src/io/tests.rs+3-2
......@@ -1,7 +1,8 @@
11use super::{repeat, BorrowedBuf, Cursor, SeekFrom};
22use crate::cmp::{self, min};
3use crate::io::{self, IoSlice, IoSliceMut, DEFAULT_BUF_SIZE};
4use crate::io::{BufRead, BufReader, Read, Seek, Write};
3use crate::io::{
4 self, BufRead, BufReader, IoSlice, IoSliceMut, Read, Seek, Write, DEFAULT_BUF_SIZE,
5};
56use crate::mem::MaybeUninit;
67use crate::ops::Deref;
78
library/std/src/io/util/tests.rs-1
......@@ -1,6 +1,5 @@
11use crate::io::prelude::*;
22use crate::io::{empty, repeat, sink, BorrowedBuf, Empty, Repeat, SeekFrom, Sink};
3
43use crate::mem::MaybeUninit;
54
65#[test]
library/std/src/lib.rs+41-44
......@@ -470,24 +470,6 @@ pub mod rt;
470470// The Rust prelude
471471pub mod prelude;
472472
473#[stable(feature = "rust1", since = "1.0.0")]
474pub use alloc_crate::borrow;
475#[stable(feature = "rust1", since = "1.0.0")]
476pub use alloc_crate::boxed;
477#[stable(feature = "rust1", since = "1.0.0")]
478pub use alloc_crate::fmt;
479#[stable(feature = "rust1", since = "1.0.0")]
480pub use alloc_crate::format;
481#[stable(feature = "rust1", since = "1.0.0")]
482pub use alloc_crate::rc;
483#[stable(feature = "rust1", since = "1.0.0")]
484pub use alloc_crate::slice;
485#[stable(feature = "rust1", since = "1.0.0")]
486pub use alloc_crate::str;
487#[stable(feature = "rust1", since = "1.0.0")]
488pub use alloc_crate::string;
489#[stable(feature = "rust1", since = "1.0.0")]
490pub use alloc_crate::vec;
491473#[stable(feature = "rust1", since = "1.0.0")]
492474pub use core::any;
493475#[stable(feature = "core_array", since = "1.36.0")]
......@@ -565,6 +547,25 @@ pub use core::u8;
565547#[allow(deprecated, deprecated_in_future)]
566548pub use core::usize;
567549
550#[stable(feature = "rust1", since = "1.0.0")]
551pub use alloc_crate::borrow;
552#[stable(feature = "rust1", since = "1.0.0")]
553pub use alloc_crate::boxed;
554#[stable(feature = "rust1", since = "1.0.0")]
555pub use alloc_crate::fmt;
556#[stable(feature = "rust1", since = "1.0.0")]
557pub use alloc_crate::format;
558#[stable(feature = "rust1", since = "1.0.0")]
559pub use alloc_crate::rc;
560#[stable(feature = "rust1", since = "1.0.0")]
561pub use alloc_crate::slice;
562#[stable(feature = "rust1", since = "1.0.0")]
563pub use alloc_crate::str;
564#[stable(feature = "rust1", since = "1.0.0")]
565pub use alloc_crate::string;
566#[stable(feature = "rust1", since = "1.0.0")]
567pub use alloc_crate::vec;
568
568569#[unstable(feature = "f128", issue = "116909")]
569570pub mod f128;
570571#[unstable(feature = "f16", issue = "116909")]
......@@ -608,23 +609,23 @@ mod std_float;
608609pub mod simd {
609610 #![doc = include_str!("../../portable-simd/crates/core_simd/src/core_simd_docs.md")]
610611
611 #[doc(inline)]
612 pub use crate::std_float::StdFloat;
613612 #[doc(inline)]
614613 pub use core::simd::*;
614
615 #[doc(inline)]
616 pub use crate::std_float::StdFloat;
615617}
616618
617619#[stable(feature = "futures_api", since = "1.36.0")]
618620pub mod task {
619621 //! Types and Traits for working with asynchronous tasks.
620622
621 #[doc(inline)]
622 #[stable(feature = "futures_api", since = "1.36.0")]
623 pub use core::task::*;
624
625623 #[doc(inline)]
626624 #[stable(feature = "wake_trait", since = "1.51.0")]
627625 pub use alloc::task::*;
626 #[doc(inline)]
627 #[stable(feature = "futures_api", since = "1.36.0")]
628 pub use core::task::*;
628629}
629630
630631#[doc = include_str!("../../stdarch/crates/core_arch/src/core_arch_docs.md")]
......@@ -670,34 +671,30 @@ mod panicking;
670671mod backtrace_rs;
671672
672673// Re-export macros defined in core.
673#[stable(feature = "rust1", since = "1.0.0")]
674#[allow(deprecated, deprecated_in_future)]
675pub 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)]
683pub 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")]
675pub use core::cfg_match;
689676#[unstable(
690677 feature = "concat_bytes",
691678 issue = "87555",
692679 reason = "`concat_bytes` is not stable enough for use and is subject to change"
693680)]
694681pub use core::concat_bytes;
695
696#[unstable(feature = "cfg_match", issue = "115585")]
697pub use core::cfg_match;
698
699682#[stable(feature = "core_primitive", since = "1.43.0")]
700683pub 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)]
687pub 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)]
694pub 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};
701698
702699// Include a number of private modules that exist solely to provide
703700// the rustdoc documentation for primitive types. Using `include!`
library/std/src/net/ip_addr.rs+4-6
......@@ -2,17 +2,15 @@
22#[cfg(all(test, not(target_os = "emscripten")))]
33mod tests;
44
5use crate::sys::net::netc as c;
6use crate::sys_common::{FromInner, IntoInner};
7
85#[stable(feature = "ip_addr", since = "1.7.0")]
96pub use core::net::IpAddr;
10
7#[unstable(feature = "ip", issue = "27709")]
8pub use core::net::Ipv6MulticastScope;
119#[stable(feature = "rust1", since = "1.0.0")]
1210pub use core::net::{Ipv4Addr, Ipv6Addr};
1311
14#[unstable(feature = "ip", issue = "27709")]
15pub use core::net::Ipv6MulticastScope;
12use crate::sys::net::netc as c;
13use crate::sys_common::{FromInner, IntoInner};
1614
1715impl IntoInner<c::in_addr> for Ipv4Addr {
1816 #[inline]
library/std/src/net/mod.rs+3-3
......@@ -21,7 +21,8 @@
2121
2222#![stable(feature = "rust1", since = "1.0.0")]
2323
24use crate::io::{self, ErrorKind};
24#[stable(feature = "rust1", since = "1.0.0")]
25pub use core::net::AddrParseError;
2526
2627#[stable(feature = "rust1", since = "1.0.0")]
2728pub use self::ip_addr::{IpAddr, Ipv4Addr, Ipv6Addr, Ipv6MulticastScope};
......@@ -33,8 +34,7 @@ pub use self::tcp::IntoIncoming;
3334pub use self::tcp::{Incoming, TcpListener, TcpStream};
3435#[stable(feature = "rust1", since = "1.0.0")]
3536pub use self::udp::UdpSocket;
36#[stable(feature = "rust1", since = "1.0.0")]
37pub use core::net::AddrParseError;
37use crate::io::{self, ErrorKind};
3838
3939mod ip_addr;
4040mod socket_addr;
library/std/src/net/socket_addr.rs+4-9
......@@ -2,19 +2,14 @@
22#[cfg(all(test, not(target_os = "emscripten")))]
33mod tests;
44
5use crate::io;
6use crate::iter;
7use crate::mem;
5#[stable(feature = "rust1", since = "1.0.0")]
6pub use core::net::{SocketAddr, SocketAddrV4, SocketAddrV6};
7
88use crate::net::{IpAddr, Ipv4Addr, Ipv6Addr};
9use crate::option;
10use crate::slice;
119use crate::sys::net::netc as c;
1210use crate::sys_common::net::LookupHost;
1311use crate::sys_common::{FromInner, IntoInner};
14use crate::vec;
15
16#[stable(feature = "rust1", since = "1.0.0")]
17pub use core::net::{SocketAddr, SocketAddrV4, SocketAddrV6};
12use crate::{io, iter, mem, option, slice, vec};
1813
1914impl FromInner<c::sockaddr_in> for SocketAddrV4 {
2015 fn from_inner(addr: c::sockaddr_in) -> SocketAddrV4 {
library/std/src/net/tcp.rs+2-4
......@@ -3,14 +3,12 @@
33#[cfg(all(test, not(any(target_os = "emscripten", target_os = "xous"))))]
44mod tests;
55
6use crate::io::prelude::*;
7
86use crate::fmt;
7use crate::io::prelude::*;
98use crate::io::{self, BorrowedCursor, IoSlice, IoSliceMut};
109use crate::iter::FusedIterator;
1110use crate::net::{Shutdown, SocketAddr, ToSocketAddrs};
12use crate::sys_common::net as net_imp;
13use crate::sys_common::{AsInner, FromInner, IntoInner};
11use crate::sys_common::{net as net_imp, AsInner, FromInner, IntoInner};
1412use crate::time::Duration;
1513
1614/// A TCP stream between a local and a remote socket.
library/std/src/net/tcp/tests.rs+1-2
......@@ -1,12 +1,11 @@
1use crate::fmt;
21use crate::io::prelude::*;
32use crate::io::{BorrowedBuf, IoSlice, IoSliceMut};
43use crate::mem::MaybeUninit;
54use crate::net::test::{next_test_ip4, next_test_ip6};
65use crate::net::*;
76use crate::sync::mpsc::channel;
8use crate::thread;
97use crate::time::{Duration, Instant};
8use crate::{fmt, thread};
109
1110fn each_ip(f: &mut dyn FnMut(SocketAddr)) {
1211 f(next_test_ip4());
library/std/src/net/udp.rs+1-2
......@@ -4,8 +4,7 @@ mod tests;
44use crate::fmt;
55use crate::io::{self, ErrorKind};
66use crate::net::{Ipv4Addr, Ipv6Addr, SocketAddr, ToSocketAddrs};
7use crate::sys_common::net as net_imp;
8use crate::sys_common::{AsInner, FromInner, IntoInner};
7use crate::sys_common::{net as net_imp, AsInner, FromInner, IntoInner};
98use crate::time::Duration;
109
1110/// A UDP socket.
library/std/src/num.rs+6-11
......@@ -9,32 +9,27 @@
99#[cfg(test)]
1010mod tests;
1111
12#[stable(feature = "int_error_matching", since = "1.55.0")]
13pub use core::num::IntErrorKind;
14#[stable(feature = "generic_nonzero", since = "1.79.0")]
15pub use core::num::NonZero;
1216#[stable(feature = "saturating_int_impl", since = "1.74.0")]
1317pub use core::num::Saturating;
1418#[stable(feature = "rust1", since = "1.0.0")]
1519pub use core::num::Wrapping;
16#[stable(feature = "rust1", since = "1.0.0")]
17pub use core::num::{FpCategory, ParseFloatError, ParseIntError, TryFromIntError};
18
1920#[unstable(
2021 feature = "nonzero_internals",
2122 reason = "implementation detail which may disappear or be replaced at any time",
2223 issue = "none"
2324)]
2425pub use core::num::ZeroablePrimitive;
25
26#[stable(feature = "generic_nonzero", since = "1.79.0")]
27pub use core::num::NonZero;
28
26#[stable(feature = "rust1", since = "1.0.0")]
27pub use core::num::{FpCategory, ParseFloatError, ParseIntError, TryFromIntError};
2928#[stable(feature = "signed_nonzero", since = "1.34.0")]
3029pub use core::num::{NonZeroI128, NonZeroI16, NonZeroI32, NonZeroI64, NonZeroI8, NonZeroIsize};
31
3230#[stable(feature = "nonzero", since = "1.28.0")]
3331pub use core::num::{NonZeroU128, NonZeroU16, NonZeroU32, NonZeroU64, NonZeroU8, NonZeroUsize};
3432
35#[stable(feature = "int_error_matching", since = "1.55.0")]
36pub use core::num::IntErrorKind;
37
3833#[cfg(test)]
3934use crate::fmt;
4035#[cfg(test)]
library/std/src/os/aix/raw.rs-1
......@@ -4,6 +4,5 @@
44
55#[stable(feature = "pthread_t", since = "1.8.0")]
66pub use libc::pthread_t;
7
87#[stable(feature = "raw_ext", since = "1.1.0")]
98pub 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 @@
11#![stable(feature = "metadata_ext", since = "1.1.0")]
22
33use crate::fs::Metadata;
4use crate::sys_common::AsInner;
5
64#[allow(deprecated)]
75use crate::os::android::raw;
6use crate::sys_common::AsInner;
87
98/// OS-specific extensions to [`fs::Metadata`].
109///
library/std/src/os/android/net.rs-2
......@@ -4,9 +4,7 @@
44
55#[stable(feature = "unix_socket_abstract", since = "1.70.0")]
66pub use crate::os::net::linux_ext::addr::SocketAddrExt;
7
87#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
98pub use crate::os::net::linux_ext::socket::UnixSocketExt;
10
119#[unstable(feature = "tcp_quickack", issue = "96256")]
1210pub use crate::os::net::linux_ext::tcp::TcpStreamExt;
library/std/src/os/darwin/fs.rs+2-3
......@@ -1,13 +1,12 @@
11#![allow(dead_code)]
22
3#[allow(deprecated)]
4use super::raw;
35use crate::fs::{self, Metadata};
46use crate::sealed::Sealed;
57use crate::sys_common::{AsInner, AsInnerMut, IntoInner};
68use crate::time::SystemTime;
79
8#[allow(deprecated)]
9use super::raw;
10
1110/// OS-specific extensions to [`fs::Metadata`].
1211///
1312/// [`fs::Metadata`]: crate::fs::Metadata
library/std/src/os/dragonfly/fs.rs+1-2
......@@ -1,10 +1,9 @@
11#![stable(feature = "metadata_ext", since = "1.1.0")]
22
33use crate::fs::Metadata;
4use crate::sys_common::AsInner;
5
64#[allow(deprecated)]
75use crate::os::dragonfly::raw;
6use crate::sys_common::AsInner;
87
98/// OS-specific extensions to [`fs::Metadata`].
109///
library/std/src/os/emscripten/fs.rs+1-2
......@@ -1,10 +1,9 @@
11#![stable(feature = "metadata_ext", since = "1.1.0")]
22
33use crate::fs::Metadata;
4use crate::sys_common::AsInner;
5
64#[allow(deprecated)]
75use crate::os::emscripten::raw;
6use crate::sys_common::AsInner;
87
98/// OS-specific extensions to [`fs::Metadata`].
109///
library/std/src/os/espidf/fs.rs+1-2
......@@ -1,10 +1,9 @@
11#![stable(feature = "metadata_ext", since = "1.1.0")]
22
33use crate::fs::Metadata;
4use crate::sys_common::AsInner;
5
64#[allow(deprecated)]
75use crate::os::espidf::raw;
6use crate::sys_common::AsInner;
87
98/// OS-specific extensions to [`fs::Metadata`].
109///
library/std/src/os/fd/owned.rs+1-3
......@@ -4,14 +4,12 @@
44#![deny(unsafe_op_in_unsafe_fn)]
55
66use super::raw::{AsRawFd, FromRawFd, IntoRawFd, RawFd};
7use crate::fmt;
8use crate::fs;
9use crate::io;
107use crate::marker::PhantomData;
118use crate::mem::ManuallyDrop;
129#[cfg(not(any(target_arch = "wasm32", target_env = "sgx", target_os = "hermit")))]
1310use crate::sys::cvt;
1411use crate::sys_common::{AsInner, FromInner, IntoInner};
12use crate::{fmt, fs, io};
1513
1614/// A borrowed file descriptor.
1715///
library/std/src/os/fd/raw.rs+4-4
......@@ -2,8 +2,9 @@
22
33#![stable(feature = "rust1", since = "1.0.0")]
44
5use crate::fs;
6use crate::io;
5#[cfg(target_os = "hermit")]
6use hermit_abi as libc;
7
78#[cfg(target_os = "hermit")]
89use crate::os::hermit::io::OwnedFd;
910#[cfg(not(target_os = "hermit"))]
......@@ -15,8 +16,7 @@ use crate::os::unix::io::OwnedFd;
1516#[cfg(target_os = "wasi")]
1617use crate::os::wasi::io::OwnedFd;
1718use crate::sys_common::{AsInner, IntoInner};
18#[cfg(target_os = "hermit")]
19use hermit_abi as libc;
19use crate::{fs, io};
2020
2121/// Raw file descriptors.
2222#[rustc_allowed_through_unstable_modules]
library/std/src/os/fortanix_sgx/arch.rs+2-1
......@@ -4,9 +4,10 @@
44//! Software Developer's Manual, Volume 3, Chapter 40.
55#![unstable(feature = "sgx_platform", issue = "56975")]
66
7use crate::mem::MaybeUninit;
87use core::arch::asm;
98
9use crate::mem::MaybeUninit;
10
1011/// Wrapper struct to force 16-byte alignment.
1112#[repr(align(16))]
1213#[unstable(feature = "sgx_platform", issue = "56975")]
library/std/src/os/fortanix_sgx/mod.rs+6-14
......@@ -22,20 +22,12 @@ pub mod usercalls {
2222 /// Lowest-level interfaces to usercalls and usercall ABI type definitions.
2323 pub mod raw {
2424 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,
3931 };
4032 }
4133}
library/std/src/os/freebsd/fs.rs+1-2
......@@ -1,10 +1,9 @@
11#![stable(feature = "metadata_ext", since = "1.1.0")]
22
33use crate::fs::Metadata;
4use crate::sys_common::AsInner;
5
64#[allow(deprecated)]
75use crate::os::freebsd::raw;
6use crate::sys_common::AsInner;
87
98/// OS-specific extensions to [`fs::Metadata`].
109///
library/std/src/os/haiku/fs.rs+1-2
......@@ -1,10 +1,9 @@
11#![stable(feature = "metadata_ext", since = "1.1.0")]
22
33use crate::fs::Metadata;
4use crate::sys_common::AsInner;
5
64#[allow(deprecated)]
75use crate::os::haiku::raw;
6use crate::sys_common::AsInner;
87
98/// OS-specific extensions to [`fs::Metadata`].
109///
library/std/src/os/hermit/io/net.rs+1-2
......@@ -1,5 +1,4 @@
1use crate::os::hermit::io::OwnedFd;
2use crate::os::hermit::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd};
1use crate::os::hermit::io::{AsRawFd, FromRawFd, IntoRawFd, OwnedFd, RawFd};
32use crate::sys_common::{self, AsInner, FromInner, IntoInner};
43use crate::{net, sys};
54
library/std/src/os/illumos/fs.rs+1-2
......@@ -1,10 +1,9 @@
11#![stable(feature = "metadata_ext", since = "1.1.0")]
22
33use crate::fs::Metadata;
4use crate::sys_common::AsInner;
5
64#[allow(deprecated)]
75use crate::os::illumos::raw;
6use crate::sys_common::AsInner;
87
98/// OS-specific extensions to [`fs::Metadata`].
109///
library/std/src/os/ios/mod.rs-1
......@@ -7,7 +7,6 @@ pub mod fs {
77 #[doc(inline)]
88 #[stable(feature = "file_set_times", since = "1.75.0")]
99 pub use crate::os::darwin::fs::FileTimesExt;
10
1110 #[doc(inline)]
1211 #[stable(feature = "metadata_ext", since = "1.1.0")]
1312 pub use crate::os::darwin::fs::MetadataExt;
library/std/src/os/l4re/fs.rs+1-2
......@@ -5,10 +5,9 @@
55#![stable(feature = "metadata_ext", since = "1.1.0")]
66
77use crate::fs::Metadata;
8use crate::sys_common::AsInner;
9
108#[allow(deprecated)]
119use crate::os::l4re::raw;
10use crate::sys_common::AsInner;
1211
1312/// OS-specific extensions to [`fs::Metadata`].
1413///
library/std/src/os/linux/fs.rs+1-2
......@@ -5,10 +5,9 @@
55#![stable(feature = "metadata_ext", since = "1.1.0")]
66
77use crate::fs::Metadata;
8use crate::sys_common::AsInner;
9
108#[allow(deprecated)]
119use crate::os::linux::raw;
10use crate::sys_common::AsInner;
1211
1312/// OS-specific extensions to [`fs::Metadata`].
1413///
library/std/src/os/linux/net.rs-2
......@@ -4,9 +4,7 @@
44
55#[stable(feature = "unix_socket_abstract", since = "1.70.0")]
66pub use crate::os::net::linux_ext::addr::SocketAddrExt;
7
87#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
98pub use crate::os::net::linux_ext::socket::UnixSocketExt;
10
119#[unstable(feature = "tcp_quickack", issue = "96256")]
1210pub use crate::os::net::linux_ext::tcp::TcpStreamExt;
library/std/src/os/macos/mod.rs-1
......@@ -7,7 +7,6 @@ pub mod fs {
77 #[doc(inline)]
88 #[stable(feature = "file_set_times", since = "1.75.0")]
99 pub use crate::os::darwin::fs::FileTimesExt;
10
1110 #[doc(inline)]
1211 #[stable(feature = "metadata_ext", since = "1.1.0")]
1312 pub use crate::os::darwin::fs::MetadataExt;
library/std/src/os/net/linux_ext/tcp.rs+1-2
......@@ -2,10 +2,9 @@
22//!
33//! [`std::net`]: crate::net
44
5use crate::io;
6use crate::net;
75use crate::sealed::Sealed;
86use crate::sys_common::AsInner;
7use crate::{io, net};
98
109/// Os-specific extensions for [`TcpStream`]
1110///
library/std/src/os/net/linux_ext/tests.rs+6-8
......@@ -1,9 +1,8 @@
11#[test]
22fn 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;
76
87 macro_rules! t {
98 ($e:expr) => {
......@@ -30,10 +29,9 @@ fn quickack() {
3029#[test]
3130#[cfg(target_os = "linux")]
3231fn 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;
3735
3836 macro_rules! t {
3937 ($e:expr) => {
library/std/src/os/netbsd/fs.rs+1-2
......@@ -1,10 +1,9 @@
11#![stable(feature = "metadata_ext", since = "1.1.0")]
22
33use crate::fs::Metadata;
4use crate::sys_common::AsInner;
5
64#[allow(deprecated)]
75use crate::os::netbsd::raw;
6use crate::sys_common::AsInner;
87
98/// OS-specific extensions to [`fs::Metadata`].
109///
library/std/src/os/openbsd/fs.rs+1-2
......@@ -1,10 +1,9 @@
11#![stable(feature = "metadata_ext", since = "1.1.0")]
22
33use crate::fs::Metadata;
4use crate::sys_common::AsInner;
5
64#[allow(deprecated)]
75use crate::os::openbsd::raw;
6use crate::sys_common::AsInner;
87
98/// OS-specific extensions to [`fs::Metadata`].
109///
library/std/src/os/redox/fs.rs+1-2
......@@ -1,10 +1,9 @@
11#![stable(feature = "metadata_ext", since = "1.1.0")]
22
33use crate::fs::Metadata;
4use crate::sys_common::AsInner;
5
64#[allow(deprecated)]
75use crate::os::redox::raw;
6use crate::sys_common::AsInner;
87
98/// OS-specific extensions to [`fs::Metadata`].
109///
library/std/src/os/solaris/fs.rs+1-2
......@@ -1,10 +1,9 @@
11#![stable(feature = "metadata_ext", since = "1.1.0")]
22
33use crate::fs::Metadata;
4use crate::sys_common::AsInner;
5
64#[allow(deprecated)]
75use crate::os::solaris::raw;
6use crate::sys_common::AsInner;
87
98/// OS-specific extensions to [`fs::Metadata`].
109///
library/std/src/os/solid/io.rs+1-3
......@@ -46,12 +46,10 @@
4646
4747#![unstable(feature = "solid_ext", issue = "none")]
4848
49use crate::fmt;
5049use crate::marker::PhantomData;
5150use crate::mem::ManuallyDrop;
52use crate::net;
53use crate::sys;
5451use crate::sys_common::{self, AsInner, FromInner, IntoInner};
52use crate::{fmt, net, sys};
5553
5654/// Raw file descriptors.
5755pub type RawFd = i32;
library/std/src/os/uefi/env.rs+2-1
......@@ -2,8 +2,9 @@
22
33#![unstable(feature = "uefi_std", issue = "100499")]
44
5use crate::ffi::c_void;
6use crate::ptr::NonNull;
57use crate::sync::atomic::{AtomicBool, AtomicPtr, Ordering};
6use crate::{ffi::c_void, ptr::NonNull};
78
89static SYSTEM_TABLE: AtomicPtr<c_void> = AtomicPtr::new(crate::ptr::null_mut());
910static IMAGE_HANDLE: AtomicPtr<c_void> = AtomicPtr::new(crate::ptr::null_mut());
library/std/src/os/unix/fs.rs+7-7
......@@ -4,18 +4,18 @@
44
55#![stable(feature = "rust1", since = "1.0.0")]
66
7#[allow(unused_imports)]
8use io::{Read, Write};
9
710use super::platform::fs::MetadataExt as _;
11// Used for `File::read` on intra-doc links
12use crate::ffi::OsStr;
813use crate::fs::{self, OpenOptions, Permissions};
9use crate::io;
1014use crate::os::unix::io::{AsFd, AsRawFd};
1115use crate::path::Path;
12use crate::sys;
13use crate::sys_common::{AsInner, AsInnerMut, FromInner};
14// Used for `File::read` on intra-doc links
15use crate::ffi::OsStr;
1616use crate::sealed::Sealed;
17#[allow(unused_imports)]
18use io::{Read, Write};
17use crate::sys_common::{AsInner, AsInnerMut, FromInner};
18use crate::{io, sys};
1919
2020// Tests for this module
2121#[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))]
13use libc::MSG_NOSIGNAL;
14
115#[cfg(any(doc, target_os = "android", target_os = "linux"))]
216use super::{recv_vectored_with_ancillary_from, send_vectored_with_ancillary_to, SocketAncillary};
317use super::{sockaddr_un, SocketAddr};
......@@ -12,20 +26,6 @@ use crate::sys::net::Socket;
1226use crate::sys_common::{AsInner, FromInner, IntoInner};
1327use crate::time::Duration;
1428use 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))]
28use libc::MSG_NOSIGNAL;
2929#[cfg(not(any(
3030 target_os = "linux",
3131 target_os = "android",
library/std/src/os/unix/net/tests.rs+4-6
......@@ -1,18 +1,16 @@
11use super::*;
22use crate::io::prelude::*;
33use crate::io::{self, ErrorKind, IoSlice, IoSliceMut};
4#[cfg(target_os = "android")]
5use crate::os::android::net::{SocketAddrExt, UnixSocketExt};
6#[cfg(target_os = "linux")]
7use crate::os::linux::net::{SocketAddrExt, UnixSocketExt};
48#[cfg(any(target_os = "android", target_os = "linux"))]
59use crate::os::unix::io::AsRawFd;
610use crate::sys_common::io::test::tmpdir;
711use crate::thread;
812use crate::time::Duration;
913
10#[cfg(target_os = "android")]
11use crate::os::android::net::{SocketAddrExt, UnixSocketExt};
12
13#[cfg(target_os = "linux")]
14use crate::os::linux::net::{SocketAddrExt, UnixSocketExt};
15
1614macro_rules! or_panic {
1715 ($e:expr) => {
1816 match $e {
library/std/src/os/unix/net/ucred.rs+8-8
......@@ -23,9 +23,8 @@ pub struct UCred {
2323 pub pid: Option<pid_t>,
2424}
2525
26#[cfg(any(target_os = "android", target_os = "linux"))]
27pub(super) use self::impl_linux::peer_cred;
28
26#[cfg(target_vendor = "apple")]
27pub(super) use self::impl_apple::peer_cred;
2928#[cfg(any(
3029 target_os = "dragonfly",
3130 target_os = "freebsd",
......@@ -34,17 +33,17 @@ pub(super) use self::impl_linux::peer_cred;
3433 target_os = "nto"
3534))]
3635pub(super) use self::impl_bsd::peer_cred;
37
38#[cfg(target_vendor = "apple")]
39pub(super) use self::impl_apple::peer_cred;
36#[cfg(any(target_os = "android", target_os = "linux"))]
37pub(super) use self::impl_linux::peer_cred;
4038
4139#[cfg(any(target_os = "linux", target_os = "android"))]
4240mod impl_linux {
41 use libc::{c_void, getsockopt, socklen_t, ucred, SOL_SOCKET, SO_PEERCRED};
42
4343 use super::UCred;
4444 use crate::os::unix::io::AsRawFd;
4545 use crate::os::unix::net::UnixStream;
4646 use crate::{io, mem};
47 use libc::{c_void, getsockopt, socklen_t, ucred, SOL_SOCKET, SO_PEERCRED};
4847
4948 pub fn peer_cred(socket: &UnixStream) -> io::Result<UCred> {
5049 let ucred_size = mem::size_of::<ucred>();
......@@ -99,11 +98,12 @@ mod impl_bsd {
9998
10099#[cfg(target_vendor = "apple")]
101100mod impl_apple {
101 use libc::{c_void, getpeereid, getsockopt, pid_t, socklen_t, LOCAL_PEERPID, SOL_LOCAL};
102
102103 use super::UCred;
103104 use crate::os::unix::io::AsRawFd;
104105 use crate::os::unix::net::UnixStream;
105106 use crate::{io, mem};
106 use libc::{c_void, getpeereid, getsockopt, pid_t, socklen_t, LOCAL_PEERPID, SOL_LOCAL};
107107
108108 pub fn peer_cred(socket: &UnixStream) -> io::Result<UCred> {
109109 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 @@
1use crate::os::unix::net::UnixStream;
21use libc::{getegid, geteuid, getpid};
32
3use crate::os::unix::net::UnixStream;
4
45#[test]
56#[cfg(any(
67 target_os = "android",
library/std/src/os/unix/process.rs+3-5
......@@ -4,15 +4,13 @@
44
55#![stable(feature = "rust1", since = "1.0.0")]
66
7use cfg_if::cfg_if;
8
79use crate::ffi::OsStr;
8use crate::io;
910use crate::os::unix::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, OwnedFd, RawFd};
10use crate::process;
1111use crate::sealed::Sealed;
12use crate::sys;
1312use crate::sys_common::{AsInner, AsInnerMut, FromInner, IntoInner};
14
15use cfg_if::cfg_if;
13use crate::{io, process, sys};
1614
1715cfg_if! {
1816 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 @@
55#![deny(unsafe_op_in_unsafe_fn)]
66#![unstable(feature = "wasi_ext", issue = "71213")]
77
8// Used for `File::read` on intra-doc links
9#[allow(unused_imports)]
10use io::{Read, Write};
11
812use crate::ffi::OsStr;
913use crate::fs::{self, File, Metadata, OpenOptions};
1014use crate::io::{self, IoSlice, IoSliceMut};
1115use crate::path::{Path, PathBuf};
1216use crate::sys_common::{AsInner, AsInnerMut, FromInner};
13// Used for `File::read` on intra-doc links
14#[allow(unused_imports)]
15use io::{Read, Write};
1617
1718/// WASI-specific extensions to [`File`].
1819pub trait FileExt {
library/std/src/os/wasi/net/mod.rs+1-2
......@@ -2,9 +2,8 @@
22
33#![unstable(feature = "wasi_ext", issue = "71213")]
44
5use crate::io;
6use crate::net;
75use crate::sys_common::AsInner;
6use crate::{io, net};
87
98/// WASI-specific extensions to [`std::net::TcpListener`].
109///
library/std/src/os/windows/ffi.rs+2-3
......@@ -56,11 +56,10 @@
5656use crate::ffi::{OsStr, OsString};
5757use crate::sealed::Sealed;
5858use crate::sys::os_str::Buf;
59use crate::sys_common::wtf8::Wtf8Buf;
60use crate::sys_common::{AsInner, FromInner};
61
6259#[stable(feature = "rust1", since = "1.0.0")]
6360pub use crate::sys_common::wtf8::EncodeWide;
61use crate::sys_common::wtf8::Wtf8Buf;
62use crate::sys_common::{AsInner, FromInner};
6463
6564/// Windows-specific extensions to [`OsString`].
6665///
library/std/src/os/windows/fs.rs+1-2
......@@ -5,12 +5,11 @@
55#![stable(feature = "rust1", since = "1.0.0")]
66
77use crate::fs::{self, Metadata, OpenOptions};
8use crate::io;
98use crate::path::Path;
109use crate::sealed::Sealed;
11use crate::sys;
1210use crate::sys_common::{AsInner, AsInnerMut, IntoInner};
1311use crate::time::SystemTime;
12use crate::{io, sys};
1413
1514/// Windows-specific extensions to [`fs::File`].
1615#[stable(feature = "file_offset", since = "1.15.0")]
library/std/src/os/windows/io/handle.rs+1-5
......@@ -3,15 +3,11 @@
33#![stable(feature = "io_safety", since = "1.63.0")]
44
55use super::raw::{AsRawHandle, FromRawHandle, IntoRawHandle, RawHandle};
6use crate::fmt;
7use crate::fs;
8use crate::io;
96use crate::marker::PhantomData;
107use crate::mem::ManuallyDrop;
11use crate::ptr;
12use crate::sys;
138use crate::sys::cvt;
149use crate::sys_common::{AsInner, FromInner, IntoInner};
10use crate::{fmt, fs, io, ptr, sys};
1511
1612/// A borrowed handle.
1713///
library/std/src/os/windows/io/raw.rs+1-5
......@@ -2,16 +2,12 @@
22
33#![stable(feature = "rust1", since = "1.0.0")]
44
5use crate::fs;
6use crate::io;
7use crate::net;
85#[cfg(doc)]
96use crate::os::windows::io::{AsHandle, AsSocket};
107use crate::os::windows::io::{OwnedHandle, OwnedSocket};
118use crate::os::windows::raw;
12use crate::ptr;
13use crate::sys;
149use crate::sys_common::{self, AsInner, FromInner, IntoInner};
10use crate::{fs, io, net, ptr, sys};
1511
1612/// Raw HANDLEs.
1713#[stable(feature = "rust1", since = "1.0.0")]
library/std/src/os/windows/io/socket.rs+1-3
......@@ -3,13 +3,11 @@
33#![stable(feature = "io_safety", since = "1.63.0")]
44
55use super::raw::{AsRawSocket, FromRawSocket, IntoRawSocket, RawSocket};
6use crate::fmt;
7use crate::io;
86use crate::marker::PhantomData;
97use crate::mem::{self, ManuallyDrop};
10use crate::sys;
118#[cfg(not(target_vendor = "uwp"))]
129use crate::sys::cvt;
10use crate::{fmt, io, sys};
1311
1412/// A borrowed socket.
1513///
library/std/src/os/windows/process.rs+1-2
......@@ -8,10 +8,9 @@ use crate::ffi::OsStr;
88use crate::os::windows::io::{
99 AsHandle, AsRawHandle, BorrowedHandle, FromRawHandle, IntoRawHandle, OwnedHandle, RawHandle,
1010};
11use crate::process;
1211use crate::sealed::Sealed;
13use crate::sys;
1412use crate::sys_common::{AsInner, AsInnerMut, FromInner, IntoInner};
13use crate::{process, sys};
1514
1615#[stable(feature = "process_extensions", since = "1.2.0")]
1716impl FromRawHandle for process::Stdio {
library/std/src/os/xous/services.rs+2-1
......@@ -1,6 +1,7 @@
1use crate::os::xous::ffi::Connection;
21use core::sync::atomic::{AtomicU32, Ordering};
32
3use crate::os::xous::ffi::Connection;
4
45mod dns;
56pub(crate) use dns::*;
67
library/std/src/os/xous/services/dns.rs+2-1
......@@ -1,6 +1,7 @@
1use core::sync::atomic::{AtomicU32, Ordering};
2
13use crate::os::xous::ffi::Connection;
24use crate::os::xous::services::connect;
3use core::sync::atomic::{AtomicU32, Ordering};
45
56#[repr(usize)]
67pub(crate) enum DnsLendMut {
library/std/src/os/xous/services/log.rs+2-1
......@@ -1,6 +1,7 @@
1use crate::os::xous::ffi::Connection;
21use core::sync::atomic::{AtomicU32, Ordering};
32
3use crate::os::xous::ffi::Connection;
4
45/// Group a `usize` worth of bytes into a `usize` and return it, beginning from
56/// `offset` * sizeof(usize) bytes from the start. For example,
67/// `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 @@
1use core::sync::atomic::{AtomicU32, Ordering};
2
13use crate::os::xous::ffi::Connection;
24use crate::os::xous::services::connect;
3use core::sync::atomic::{AtomicU32, Ordering};
45
56pub(crate) enum NetBlockingScalar {
67 StdGetTtlUdp(u16 /* fd */), /* 36 */
library/std/src/os/xous/services/systime.rs+2-1
......@@ -1,6 +1,7 @@
1use crate::os::xous::ffi::{connect, Connection};
21use core::sync::atomic::{AtomicU32, Ordering};
32
3use crate::os::xous::ffi::{connect, Connection};
4
45pub(crate) enum SystimeScalar {
56 GetUtcTimeMs,
67}
library/std/src/os/xous/services/ticktimer.rs+2-1
......@@ -1,6 +1,7 @@
1use crate::os::xous::ffi::Connection;
21use core::sync::atomic::{AtomicU32, Ordering};
32
3use crate::os::xous::ffi::Connection;
4
45pub(crate) enum TicktimerScalar {
56 ElapsedMs,
67 SleepMs(usize),
library/std/src/panic.rs+5-10
......@@ -3,12 +3,10 @@
33#![stable(feature = "std_panic", since = "1.9.0")]
44
55use crate::any::Any;
6use crate::collections;
7use crate::fmt;
8use crate::panicking;
96use crate::sync::atomic::{AtomicU8, Ordering};
107use crate::sync::{Condvar, Mutex, RwLock};
118use crate::thread::Result;
9use crate::{collections, fmt, panicking};
1210
1311#[stable(feature = "panic_hooks", since = "1.10.0")]
1412#[deprecated(
......@@ -236,18 +234,15 @@ pub macro panic_2015 {
236234#[doc(hidden)]
237235#[unstable(feature = "edition_panic", issue = "none", reason = "use panic!() instead")]
238236pub use core::panic::panic_2021;
239
240237#[stable(feature = "panic_hooks", since = "1.10.0")]
241pub use crate::panicking::{set_hook, take_hook};
238pub use core::panic::Location;
239#[stable(feature = "catch_unwind", since = "1.9.0")]
240pub use core::panic::{AssertUnwindSafe, RefUnwindSafe, UnwindSafe};
242241
243242#[unstable(feature = "panic_update_hook", issue = "92649")]
244243pub use crate::panicking::update_hook;
245
246244#[stable(feature = "panic_hooks", since = "1.10.0")]
247pub use core::panic::Location;
248
249#[stable(feature = "catch_unwind", since = "1.9.0")]
250pub use core::panic::{AssertUnwindSafe, RefUnwindSafe, UnwindSafe};
245pub use crate::panicking::{set_hook, take_hook};
251246
252247/// Panics the current thread with the given message as the panic payload.
253248///
library/std/src/panicking.rs+9-12
......@@ -9,26 +9,23 @@
99
1010#![deny(unsafe_op_in_unsafe_fn)]
1111
12use crate::panic::{BacktraceStyle, PanicHookInfo};
1312use core::panic::{Location, PanicPayload};
1413
14// make sure to use the stderr output configured
15// by libtest in the real copy of std
16#[cfg(test)]
17use realstd::io::try_set_output_capture;
18
1519use crate::any::Any;
16use crate::fmt;
17use crate::intrinsics;
20#[cfg(not(test))]
21use crate::io::try_set_output_capture;
1822use crate::mem::{self, ManuallyDrop};
19use crate::process;
23use crate::panic::{BacktraceStyle, PanicHookInfo};
2024use crate::sync::atomic::{AtomicBool, Ordering};
2125use crate::sync::{PoisonError, RwLock};
2226use crate::sys::backtrace;
2327use crate::sys::stdio::panic_output;
24use crate::thread;
25
26#[cfg(not(test))]
27use 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)]
31use realstd::io::try_set_output_capture;
28use crate::{fmt, intrinsics, process, thread};
3229
3330// Binary interface to the panic runtime that the standard library depends on.
3431//
library/std/src/path.rs+2-7
......@@ -71,22 +71,17 @@
7171mod tests;
7272
7373use crate::borrow::{Borrow, Cow};
74use crate::cmp;
7574use crate::collections::TryReserveError;
7675use crate::error::Error;
77use crate::fmt;
78use crate::fs;
76use crate::ffi::{os_str, OsStr, OsString};
7977use crate::hash::{Hash, Hasher};
80use crate::io;
8178use crate::iter::FusedIterator;
8279use crate::ops::{self, Deref};
8380use crate::rc::Rc;
8481use crate::str::FromStr;
8582use crate::sync::Arc;
86
87use crate::ffi::{os_str, OsStr, OsString};
88use crate::sys;
8983use crate::sys::path::{is_sep_byte, is_verbatim_sep, parse_prefix, MAIN_SEP_STR};
84use crate::{cmp, fmt, fs, io, sys};
9085
9186////////////////////////////////////////////////////////////////////////////////
9287// GENERAL NOTES
library/std/src/path/tests.rs+2-2
......@@ -1,8 +1,8 @@
1use super::*;
1use core::hint::black_box;
22
3use super::*;
34use crate::collections::{BTreeSet, HashSet};
45use crate::hash::DefaultHasher;
5use core::hint::black_box;
66
77#[allow(unknown_lints, unused_macro_rules)]
88macro_rules! t (
library/std/src/pipe.rs+2-4
......@@ -11,10 +11,8 @@
1111//! # }
1212//! ```
1313
14use crate::{
15 io,
16 sys::anonymous_pipe::{pipe as pipe_inner, AnonPipe},
17};
14use crate::io;
15use crate::sys::anonymous_pipe::{pipe as pipe_inner, AnonPipe};
1816
1917/// Create anonymous pipe that is close-on-exec and blocking.
2018#[unstable(feature = "anonymous_pipe", issue = "127154")]
library/std/src/process.rs+2-5
......@@ -151,21 +151,18 @@
151151#[cfg(all(test, not(any(target_os = "emscripten", target_env = "sgx", target_os = "xous"))))]
152152mod tests;
153153
154use crate::io::prelude::*;
155
156154use crate::convert::Infallible;
157155use crate::ffi::OsStr;
158use crate::fmt;
159use crate::fs;
156use crate::io::prelude::*;
160157use crate::io::{self, BorrowedCursor, IoSlice, IoSliceMut};
161158use crate::num::NonZero;
162159use crate::path::Path;
163use crate::str;
164160use crate::sys::pipe::{read2, AnonPipe};
165161use crate::sys::process as imp;
166162#[stable(feature = "command_access", since = "1.57.0")]
167163pub use crate::sys_common::process::CommandEnvs;
168164use crate::sys_common::{AsInner, AsInnerMut, FromInner, IntoInner};
165use crate::{fmt, fs, str};
169166
170167/// Representation of a running or exited child process.
171168///
library/std/src/process/tests.rs+1-2
......@@ -1,6 +1,5 @@
1use crate::io::prelude::*;
2
31use super::{Command, Output, Stdio};
2use crate::io::prelude::*;
43use crate::io::{BorrowedBuf, ErrorKind};
54use crate::mem::MaybeUninit;
65use crate::str;
library/std/src/sync/lazy_lock.rs+1-2
......@@ -1,3 +1,4 @@
1use super::once::ExclusiveState;
12use crate::cell::UnsafeCell;
23use crate::mem::ManuallyDrop;
34use crate::ops::Deref;
......@@ -5,8 +6,6 @@ use crate::panic::{RefUnwindSafe, UnwindSafe};
56use crate::sync::Once;
67use crate::{fmt, ptr};
78
8use super::once::ExclusiveState;
9
109// We use the state of a Once as discriminant value. Upon creation, the state is
1110// "incomplete" and `f` contains the initialization closure. In the first call to
1211// `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 @@
1use crate::{
2 cell::LazyCell,
3 panic,
4 sync::{
5 atomic::{AtomicUsize, Ordering::SeqCst},
6 Mutex,
7 },
8 sync::{LazyLock, OnceLock},
9 thread,
10};
1use crate::cell::LazyCell;
2use crate::sync::atomic::AtomicUsize;
3use crate::sync::atomic::Ordering::SeqCst;
4use crate::sync::{LazyLock, Mutex, OnceLock};
5use crate::{panic, thread};
116
127fn spawn_and_wait<R: Send + 'static>(f: impl FnOnce() -> R + Send + 'static) -> R {
138 thread::spawn(f).join().unwrap()
library/std/src/sync/mod.rs+9-10
......@@ -158,17 +158,20 @@
158158
159159#![stable(feature = "rust1", since = "1.0.0")]
160160
161#[stable(feature = "rust1", since = "1.0.0")]
162pub use alloc_crate::sync::{Arc, Weak};
163161#[stable(feature = "rust1", since = "1.0.0")]
164162pub use core::sync::atomic;
165163#[unstable(feature = "exclusive_wrapper", issue = "98407")]
166164pub use core::sync::Exclusive;
167165
166#[stable(feature = "rust1", since = "1.0.0")]
167pub use alloc_crate::sync::{Arc, Weak};
168
168169#[stable(feature = "rust1", since = "1.0.0")]
169170pub use self::barrier::{Barrier, BarrierWaitResult};
170171#[stable(feature = "rust1", since = "1.0.0")]
171172pub use self::condvar::{Condvar, WaitTimeoutResult};
173#[stable(feature = "lazy_cell", since = "1.80.0")]
174pub use self::lazy_lock::LazyLock;
172175#[unstable(feature = "mapped_lock_guards", issue = "117108")]
173176pub use self::mutex::MappedMutexGuard;
174177#[stable(feature = "rust1", since = "1.0.0")]
......@@ -176,21 +179,17 @@ pub use self::mutex::{Mutex, MutexGuard};
176179#[stable(feature = "rust1", since = "1.0.0")]
177180#[allow(deprecated)]
178181pub use self::once::{Once, OnceState, ONCE_INIT};
182#[stable(feature = "once_cell", since = "1.70.0")]
183pub use self::once_lock::OnceLock;
179184#[stable(feature = "rust1", since = "1.0.0")]
180185pub use self::poison::{LockResult, PoisonError, TryLockError, TryLockResult};
186#[unstable(feature = "reentrant_lock", issue = "121440")]
187pub use self::reentrant_lock::{ReentrantLock, ReentrantLockGuard};
181188#[unstable(feature = "mapped_lock_guards", issue = "117108")]
182189pub use self::rwlock::{MappedRwLockReadGuard, MappedRwLockWriteGuard};
183190#[stable(feature = "rust1", since = "1.0.0")]
184191pub use self::rwlock::{RwLock, RwLockReadGuard, RwLockWriteGuard};
185192
186#[stable(feature = "lazy_cell", since = "1.80.0")]
187pub use self::lazy_lock::LazyLock;
188#[stable(feature = "once_cell", since = "1.70.0")]
189pub use self::once_lock::OnceLock;
190
191#[unstable(feature = "reentrant_lock", issue = "121440")]
192pub use self::reentrant_lock::{ReentrantLock, ReentrantLockGuard};
193
194193pub mod mpsc;
195194
196195mod barrier;
library/std/src/sync/mpmc/array.rs-1
......@@ -13,7 +13,6 @@ use super::error::*;
1313use super::select::{Operation, Selected, Token};
1414use super::utils::{Backoff, CachePadded};
1515use super::waker::SyncWaker;
16
1716use crate::cell::UnsafeCell;
1817use crate::mem::MaybeUninit;
1918use crate::ptr;
library/std/src/sync/mpmc/context.rs-1
......@@ -2,7 +2,6 @@
22
33use super::select::Selected;
44use super::waker::current_thread_id;
5
65use crate::cell::Cell;
76use crate::ptr;
87use crate::sync::atomic::{AtomicPtr, AtomicUsize, Ordering};
library/std/src/sync/mpmc/counter.rs+1-2
......@@ -1,6 +1,5 @@
1use crate::ops;
2use crate::process;
31use crate::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
2use crate::{ops, process};
43
54/// Reference counter internals.
65struct Counter<C> {
library/std/src/sync/mpmc/error.rs+1-3
......@@ -1,7 +1,5 @@
1use crate::error;
2use crate::fmt;
3
41pub use crate::sync::mpsc::{RecvError, RecvTimeoutError, SendError, TryRecvError, TrySendError};
2use crate::{error, fmt};
53
64/// An error returned from the [`send_timeout`] method.
75///
library/std/src/sync/mpmc/list.rs-1
......@@ -5,7 +5,6 @@ use super::error::*;
55use super::select::{Operation, Selected, Token};
66use super::utils::{Backoff, CachePadded};
77use super::waker::SyncWaker;
8
98use crate::cell::UnsafeCell;
109use crate::marker::PhantomData;
1110use crate::mem::MaybeUninit;
library/std/src/sync/mpmc/mod.rs+2-1
......@@ -40,10 +40,11 @@ mod utils;
4040mod waker;
4141mod zero;
4242
43pub use error::*;
44
4345use crate::fmt;
4446use crate::panic::{RefUnwindSafe, UnwindSafe};
4547use crate::time::{Duration, Instant};
46pub use error::*;
4748
4849/// Creates a channel of unbounded capacity.
4950///
library/std/src/sync/mpmc/waker.rs-1
......@@ -2,7 +2,6 @@
22
33use super::context::Context;
44use super::select::{Operation, Selected};
5
65use crate::ptr;
76use crate::sync::atomic::{AtomicBool, Ordering};
87use crate::sync::Mutex;
library/std/src/sync/mpmc/zero.rs-1
......@@ -7,7 +7,6 @@ use super::error::*;
77use super::select::{Operation, Selected, Token};
88use super::utils::Backoff;
99use super::waker::Waker;
10
1110use crate::cell::UnsafeCell;
1211use crate::marker::PhantomData;
1312use crate::sync::atomic::{AtomicBool, Ordering};
library/std/src/sync/mpsc/mod.rs+1-2
......@@ -148,10 +148,9 @@ mod sync_tests;
148148// not exposed publicly, but if you are curious about the implementation,
149149// that's where everything is.
150150
151use crate::error;
152use crate::fmt;
153151use crate::sync::mpmc;
154152use crate::time::{Duration, Instant};
153use crate::{error, fmt};
155154
156155/// The receiving half of Rust's [`channel`] (or [`sync_channel`]) type.
157156/// This half can only be owned by one thread.
library/std/src/sync/mpsc/sync_tests.rs+1-2
......@@ -1,8 +1,7 @@
11use super::*;
2use crate::env;
32use crate::rc::Rc;
43use crate::sync::mpmc::SendTimeoutError;
5use crate::thread;
4use crate::{env, thread};
65
76pub fn stress_factor() -> usize {
87 match env::var("RUST_TEST_STRESS") {
library/std/src/sync/mpsc/tests.rs+1-2
......@@ -1,6 +1,5 @@
11use super::*;
2use crate::env;
3use crate::thread;
2use crate::{env, thread};
43
54pub fn stress_factor() -> usize {
65 match env::var("RUST_TEST_STRESS") {
library/std/src/sync/once/tests.rs+1-2
......@@ -1,7 +1,6 @@
11use super::Once;
2use crate::panic;
32use crate::sync::mpsc::channel;
4use crate::thread;
3use crate::{panic, thread};
54
65#[test]
76fn smoke_once() {
library/std/src/sync/once_lock/tests.rs+5-9
......@@ -1,12 +1,8 @@
1use crate::{
2 panic,
3 sync::OnceLock,
4 sync::{
5 atomic::{AtomicUsize, Ordering::SeqCst},
6 mpsc::channel,
7 },
8 thread,
9};
1use crate::sync::atomic::AtomicUsize;
2use crate::sync::atomic::Ordering::SeqCst;
3use crate::sync::mpsc::channel;
4use crate::sync::OnceLock;
5use crate::{panic, thread};
106
117fn spawn_and_wait<R: Send + 'static>(f: impl FnOnce() -> R + Send + 'static) -> R {
128 thread::spawn(f).join().unwrap()
library/std/src/sync/poison.rs-1
......@@ -1,6 +1,5 @@
11use crate::error::Error;
22use crate::fmt;
3
43#[cfg(panic = "unwind")]
54use crate::sync::atomic::{AtomicBool, Ordering};
65#[cfg(panic = "unwind")]
library/std/src/sync/rwlock/tests.rs+2-1
......@@ -1,3 +1,5 @@
1use rand::Rng;
2
13use crate::sync::atomic::{AtomicUsize, Ordering};
24use crate::sync::mpsc::channel;
35use crate::sync::{
......@@ -5,7 +7,6 @@ use crate::sync::{
57 TryLockError,
68};
79use crate::thread;
8use rand::Rng;
910
1011#[derive(Eq, PartialEq, Debug)]
1112struct NonCopy(i32);
library/std/src/sys/anonymous_pipe/tests.rs+2-4
......@@ -1,7 +1,5 @@
1use crate::{
2 io::{Read, Write},
3 pipe::pipe,
4};
1use crate::io::{Read, Write};
2use crate::pipe::pipe;
53
64#[test]
75fn pipe_creation_clone_and_rw() {
library/std/src/sys/anonymous_pipe/unix.rs+7-8
......@@ -1,11 +1,10 @@
1use 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};
1use crate::io;
2use crate::os::fd::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, OwnedFd, RawFd};
3use crate::pipe::{PipeReader, PipeWriter};
4use crate::process::Stdio;
5use crate::sys::fd::FileDesc;
6use crate::sys::pipe::anon_pipe;
7use crate::sys_common::{FromInner, IntoInner};
98
109pub(crate) type AnonPipe = FileDesc;
1110
library/std/src/sys/anonymous_pipe/unsupported.rs+3-6
......@@ -1,9 +1,6 @@
1use crate::{
2 io,
3 pipe::{PipeReader, PipeWriter},
4 process::Stdio,
5};
6
1use crate::io;
2use crate::pipe::{PipeReader, PipeWriter};
3use crate::process::Stdio;
74pub(crate) use crate::sys::pipe::AnonPipe;
85
96#[inline]
library/std/src/sys/anonymous_pipe/windows.rs+8-9
......@@ -1,13 +1,12 @@
1use 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},
1use crate::io;
2use crate::os::windows::io::{
3 AsHandle, AsRawHandle, BorrowedHandle, FromRawHandle, IntoRawHandle, OwnedHandle, RawHandle,
104};
5use crate::pipe::{PipeReader, PipeWriter};
6use crate::process::Stdio;
7use crate::sys::handle::Handle;
8use crate::sys::pipe::unnamed_anon_pipe;
9use crate::sys_common::{FromInner, IntoInner};
1110
1211pub(crate) type AnonPipe = Handle;
1312
library/std/src/sys/backtrace.rs+1-3
......@@ -3,12 +3,10 @@
33
44use crate::backtrace_rs::{self, BacktraceFmt, BytesOrWideString, PrintFmt};
55use crate::borrow::Cow;
6use crate::env;
7use crate::fmt;
8use crate::io;
96use crate::io::prelude::*;
107use crate::path::{self, Path, PathBuf};
118use crate::sync::{Mutex, MutexGuard, PoisonError};
9use crate::{env, fmt, io};
1210
1311/// Max number of frames to print.
1412const MAX_NB_FRAMES: usize = 100;
library/std/src/sys/os_str/bytes.rs+1-3
......@@ -3,13 +3,11 @@
33
44use crate::borrow::Cow;
55use crate::collections::TryReserveError;
6use crate::fmt;
76use crate::fmt::Write;
8use crate::mem;
97use crate::rc::Rc;
10use crate::str;
118use crate::sync::Arc;
129use crate::sys_common::{AsInner, IntoInner};
10use crate::{fmt, mem, str};
1311
1412#[cfg(test)]
1513mod tests;
library/std/src/sys/os_str/wtf8.rs+1-2
......@@ -2,12 +2,11 @@
22//! wrapper around the "WTF-8" encoding; see the `wtf8` module for more.
33use crate::borrow::Cow;
44use crate::collections::TryReserveError;
5use crate::fmt;
6use crate::mem;
75use crate::rc::Rc;
86use crate::sync::Arc;
97use crate::sys_common::wtf8::{check_utf8_boundary, Wtf8, Wtf8Buf};
108use crate::sys_common::{AsInner, FromInner, IntoInner};
9use crate::{fmt, mem};
1110
1211#[derive(Clone, Hash)]
1312pub struct Buf {
library/std/src/sys/pal/common/alloc.rs+1-2
......@@ -1,7 +1,6 @@
11#![forbid(unsafe_op_in_unsafe_fn)]
22use crate::alloc::{GlobalAlloc, Layout, System};
3use crate::cmp;
4use crate::ptr;
3use crate::{cmp, ptr};
54
65// The minimum alignment guaranteed by the architecture. This value is used to
76// add fast paths for low alignment values.
library/std/src/sys/pal/common/small_c_string.rs+1-2
......@@ -1,8 +1,7 @@
11use crate::ffi::{CStr, CString};
22use crate::mem::MaybeUninit;
33use crate::path::Path;
4use crate::slice;
5use crate::{io, ptr};
4use crate::{io, ptr, slice};
65
76// Make sure to stay under 4096 so the compiler doesn't insert a probe frame:
87// 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 @@
1use core::iter::repeat;
2
13use crate::ffi::CString;
24use crate::hint::black_box;
35use crate::path::Path;
46use crate::sys::common::small_c_string::run_path_with_cstr;
5use core::iter::repeat;
67
78#[test]
89fn stack_allocation_works() {
library/std/src/sys/pal/hermit/args.rs+3-7
......@@ -1,12 +1,8 @@
11use crate::ffi::{c_char, CStr, OsString};
2use crate::fmt;
32use crate::os::hermit::ffi::OsStringExt;
4use crate::ptr;
5use crate::sync::atomic::{
6 AtomicIsize, AtomicPtr,
7 Ordering::{Acquire, Relaxed, Release},
8};
9use crate::vec;
3use crate::sync::atomic::Ordering::{Acquire, Relaxed, Release};
4use crate::sync::atomic::{AtomicIsize, AtomicPtr};
5use crate::{fmt, ptr, vec};
106
117static ARGC: AtomicIsize = AtomicIsize::new(0);
128static ARGV: AtomicPtr<*const u8> = AtomicPtr::new(ptr::null_mut());
library/std/src/sys/pal/hermit/fd.rs+2-5
......@@ -3,13 +3,10 @@
33use super::hermit_abi;
44use crate::cmp;
55use crate::io::{self, IoSlice, IoSliceMut, Read};
6use crate::os::hermit::io::{FromRawFd, OwnedFd, RawFd};
7use crate::sys::cvt;
8use crate::sys::unsupported;
6use crate::os::hermit::io::{FromRawFd, OwnedFd, RawFd, *};
7use crate::sys::{cvt, unsupported};
98use crate::sys_common::{AsInner, FromInner, IntoInner};
109
11use crate::os::hermit::io::*;
12
1310const fn max_iov() -> usize {
1411 hermit_abi::IOV_MAX
1512}
library/std/src/sys/pal/hermit/fs.rs+4-8
......@@ -4,21 +4,17 @@ use super::hermit_abi::{
44 O_DIRECTORY, O_EXCL, O_RDONLY, O_RDWR, O_TRUNC, O_WRONLY, S_IFDIR, S_IFLNK, S_IFMT, S_IFREG,
55};
66use crate::ffi::{CStr, OsStr, OsString};
7use crate::fmt;
8use crate::io::{self, Error, ErrorKind};
9use crate::io::{BorrowedCursor, IoSlice, IoSliceMut, SeekFrom};
10use crate::mem;
7use crate::io::{self, BorrowedCursor, Error, ErrorKind, IoSlice, IoSliceMut, SeekFrom};
118use crate::os::hermit::ffi::OsStringExt;
129use crate::os::hermit::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, RawFd};
1310use crate::path::{Path, PathBuf};
1411use crate::sync::Arc;
1512use crate::sys::common::small_c_string::run_path_with_cstr;
16use crate::sys::cvt;
1713use crate::sys::time::SystemTime;
18use crate::sys::unsupported;
19use crate::sys_common::{AsInner, AsInnerMut, FromInner, IntoInner};
20
14use crate::sys::{cvt, unsupported};
2115pub use crate::sys_common::fs::{copy, exists};
16use crate::sys_common::{AsInner, AsInnerMut, FromInner, IntoInner};
17use crate::{fmt, mem};
2218
2319#[derive(Debug)]
2420pub struct File(FileDesc);
library/std/src/sys/pal/hermit/io.rs+2-2
......@@ -1,9 +1,9 @@
1use hermit_abi::{c_void, iovec};
2
13use crate::marker::PhantomData;
24use crate::os::hermit::io::{AsFd, AsRawFd};
35use crate::slice;
46
5use hermit_abi::{c_void, iovec};
6
77#[derive(Copy, Clone)]
88#[repr(transparent)]
99pub struct IoSlice<'a> {
library/std/src/sys/pal/hermit/net.rs+3-4
......@@ -1,17 +1,16 @@
11#![allow(dead_code)]
22
3use core::ffi::c_int;
4
35use super::fd::FileDesc;
4use crate::cmp;
56use crate::io::{self, BorrowedBuf, BorrowedCursor, IoSlice, IoSliceMut};
6use crate::mem;
77use crate::net::{Shutdown, SocketAddr};
88use crate::os::hermit::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, RawFd};
99use crate::sys::time::Instant;
1010use crate::sys_common::net::{getsockopt, setsockopt, sockaddr_to_addr};
1111use crate::sys_common::{AsInner, FromInner, IntoInner};
1212use crate::time::Duration;
13
14use core::ffi::c_int;
13use crate::{cmp, mem};
1514
1615#[allow(unused_extern_crates)]
1716pub extern crate hermit_abi as netc;
library/std/src/sys/pal/hermit/os.rs+3-5
......@@ -1,17 +1,15 @@
1use core::slice::memchr;
2
13use super::hermit_abi;
24use crate::collections::HashMap;
35use crate::error::Error as StdError;
46use crate::ffi::{CStr, OsStr, OsString};
5use crate::fmt;
6use crate::io;
77use crate::marker::PhantomData;
88use crate::os::hermit::ffi::OsStringExt;
99use crate::path::{self, PathBuf};
10use crate::str;
1110use crate::sync::Mutex;
1211use crate::sys::unsupported;
13use crate::vec;
14use core::slice::memchr;
12use crate::{fmt, io, str, vec};
1513
1614pub fn errno() -> i32 {
1715 unsafe { hermit_abi::get_errno() }
library/std/src/sys/pal/hermit/thread.rs+1-2
......@@ -2,11 +2,10 @@
22
33use super::hermit_abi;
44use crate::ffi::CStr;
5use crate::io;
65use crate::mem::ManuallyDrop;
76use crate::num::NonZero;
8use crate::ptr;
97use crate::time::Duration;
8use crate::{io, ptr};
109
1110pub type Tid = hermit_abi::Tid;
1211
library/std/src/sys/pal/hermit/time.rs+2-1
......@@ -1,10 +1,11 @@
11#![allow(dead_code)]
22
3use core::hash::{Hash, Hasher};
4
35use super::hermit_abi::{self, timespec, CLOCK_MONOTONIC, CLOCK_REALTIME};
46use crate::cmp::Ordering;
57use crate::ops::{Add, AddAssign, Sub, SubAssign};
68use crate::time::Duration;
7use core::hash::{Hash, Hasher};
89
910const NSEC_PER_SEC: i32 = 1_000_000_000;
1011
library/std/src/sys/pal/itron/error.rs+2-2
......@@ -1,6 +1,6 @@
1use crate::{fmt, io::ErrorKind};
2
31use super::abi;
2use crate::fmt;
3use crate::io::ErrorKind;
44
55/// Wraps a μITRON error code.
66#[derive(Debug, Copy, Clone)]
library/std/src/sys/pal/itron/spin.rs+3-5
......@@ -1,9 +1,7 @@
11use super::abi;
2use crate::{
3 cell::UnsafeCell,
4 mem::MaybeUninit,
5 sync::atomic::{AtomicBool, AtomicUsize, Ordering},
6};
2use crate::cell::UnsafeCell;
3use crate::mem::MaybeUninit;
4use crate::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
75
86/// A mutex implemented by `dis_dsp` (for intra-core synchronization) and a
97/// spinlock (for inter-core synchronization).
library/std/src/sys/pal/itron/task.rs+2-5
......@@ -1,8 +1,5 @@
1use super::{
2 abi,
3 error::{fail, fail_aborting, ItronError},
4};
5
1use super::abi;
2use super::error::{fail, fail_aborting, ItronError};
63use crate::mem::MaybeUninit;
74
85/// 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 @@
11//! Thread implementation backed by μITRON tasks. Assumes `acre_tsk` and
22//! `exd_tsk` are available.
33
4use super::{
5 abi,
6 error::{expect_success, expect_success_aborting, ItronError},
7 task,
8 time::dur2reltims,
9};
10use 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};
4use super::error::{expect_success, expect_success_aborting, ItronError};
5use super::time::dur2reltims;
6use super::{abi, task};
7use crate::cell::UnsafeCell;
8use crate::ffi::CStr;
9use crate::mem::ManuallyDrop;
10use crate::num::NonZero;
11use crate::ptr::NonNull;
12use crate::sync::atomic::{AtomicUsize, Ordering};
13use crate::time::Duration;
14use crate::{hint, io};
2015
2116pub struct Thread {
2217 p_inner: NonNull<ThreadInner>,
library/std/src/sys/pal/itron/time.rs+4-2
......@@ -1,5 +1,7 @@
1use super::{abi, error::expect_success};
2use crate::{mem::MaybeUninit, time::Duration};
1use super::abi;
2use super::error::expect_success;
3use crate::mem::MaybeUninit;
4use crate::time::Duration;
35
46#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
57pub struct Instant(abi::SYSTIM);
library/std/src/sys/pal/sgx/abi/mod.rs+2-1
......@@ -1,9 +1,10 @@
11#![cfg_attr(test, allow(unused))] // RT initialization logic is not compiled for test
22
3use crate::io::Write;
43use core::arch::global_asm;
54use core::sync::atomic::{AtomicUsize, Ordering};
65
6use crate::io::Write;
7
78// runtime features
89pub(super) mod panic;
910mod reloc;
library/std/src/sys/pal/sgx/abi/panic.rs+1-2
......@@ -1,7 +1,6 @@
11use super::usercalls::alloc::UserRef;
2use crate::cmp;
32use crate::io::{self, Write};
4use crate::mem;
3use crate::{cmp, mem};
54
65extern "C" {
76 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;
22
33use self::sync_bitset::*;
44use crate::cell::Cell;
5use crate::mem;
65use crate::num::NonZero;
7use crate::ptr;
86use crate::sync::atomic::{AtomicUsize, Ordering};
7use crate::{mem, ptr};
98
109#[cfg(target_pointer_width = "64")]
1110const USIZE_BITS: usize = 64;
library/std/src/sys/pal/sgx/abi/usercalls/alloc.rs+4-6
......@@ -1,18 +1,16 @@
11#![allow(unused)]
22
3use fortanix_sgx_abi::*;
4
5use super::super::mem::{is_enclave_range, is_user_range};
36use crate::arch::asm;
47use crate::cell::UnsafeCell;
5use crate::cmp;
68use crate::convert::TryInto;
7use crate::intrinsics;
89use crate::mem::{self, ManuallyDrop};
910use crate::ops::{CoerceUnsized, Deref, DerefMut, Index, IndexMut};
1011use crate::ptr::{self, NonNull};
11use crate::slice;
1212use crate::slice::SliceIndex;
13
14use super::super::mem::{is_enclave_range, is_user_range};
15use fortanix_sgx_abi::*;
13use crate::{cmp, intrinsics, slice};
1614
1715/// A type that can be safely read from or written to userspace.
1816///
library/std/src/sys/pal/sgx/abi/usercalls/tests.rs+1-2
......@@ -1,5 +1,4 @@
1use super::alloc::User;
2use super::alloc::{copy_from_userspace, copy_to_userspace};
1use super::alloc::{copy_from_userspace, copy_to_userspace, User};
32
43#[test]
54fn test_copy_to_userspace_function() {
library/std/src/sys/pal/sgx/alloc.rs+2-2
......@@ -1,9 +1,9 @@
1use crate::alloc::{GlobalAlloc, Layout, System};
2use crate::ptr;
31use core::sync::atomic::{AtomicBool, Ordering};
42
53use super::abi::mem as sgx_mem;
64use super::waitqueue::SpinMutex;
5use crate::alloc::{GlobalAlloc, Layout, System};
6use crate::ptr;
77
88// Using a SpinMutex because we never want to exit the enclave waiting for the
99// allocator.
library/std/src/sys/pal/sgx/args.rs+3-3
......@@ -1,10 +1,10 @@
1use super::abi::usercalls::{alloc, raw::ByteBuffer};
1use super::abi::usercalls::alloc;
2use super::abi::usercalls::raw::ByteBuffer;
23use crate::ffi::OsString;
3use crate::fmt;
4use crate::slice;
54use crate::sync::atomic::{AtomicUsize, Ordering};
65use crate::sys::os_str::Buf;
76use crate::sys_common::FromInner;
7use crate::{fmt, slice};
88
99#[cfg_attr(test, linkage = "available_externally")]
1010#[export_name = "_ZN16__rust_internals3std3sys3sgx4args4ARGSE"]
library/std/src/sys/pal/sgx/net.rs+2-4
......@@ -1,13 +1,11 @@
1use crate::error;
2use crate::fmt;
1use super::abi::usercalls;
32use crate::io::{self, BorrowedCursor, IoSlice, IoSliceMut};
43use crate::net::{Ipv4Addr, Ipv6Addr, Shutdown, SocketAddr, ToSocketAddrs};
54use crate::sync::Arc;
65use crate::sys::fd::FileDesc;
76use crate::sys::{sgx_ineffective, unsupported, AsInner, FromInner, IntoInner, TryIntoInner};
87use crate::time::Duration;
9
10use super::abi::usercalls;
8use crate::{error, fmt};
119
1210const DEFAULT_FAKE_TTL: u32 = 64;
1311
library/std/src/sys/pal/sgx/os.rs+2-6
......@@ -3,16 +3,12 @@ use fortanix_sgx_abi::{Error, RESULT_SUCCESS};
33use crate::collections::HashMap;
44use crate::error::Error as StdError;
55use crate::ffi::{OsStr, OsString};
6use crate::fmt;
7use crate::io;
86use crate::marker::PhantomData;
97use crate::path::{self, PathBuf};
10use crate::str;
118use crate::sync::atomic::{AtomicUsize, Ordering};
12use crate::sync::Mutex;
13use crate::sync::Once;
9use crate::sync::{Mutex, Once};
1410use crate::sys::{decode_error_kind, sgx_ineffective, unsupported};
15use crate::vec;
11use crate::{fmt, io, str, vec};
1612
1713pub fn errno() -> i32 {
1814 RESULT_SUCCESS
library/std/src/sys/pal/sgx/thread.rs+1-2
......@@ -1,12 +1,11 @@
11#![cfg_attr(test, allow(dead_code))] // why is this necessary?
2use super::abi::usercalls;
23use super::unsupported;
34use crate::ffi::CStr;
45use crate::io;
56use crate::num::NonZero;
67use crate::time::Duration;
78
8use super::abi::usercalls;
9
109pub struct Thread(task_queue::JoinHandle);
1110
1211pub const DEFAULT_MIN_STACK_SIZE: usize = 4096;
library/std/src/sys/pal/sgx/thread_parking.rs+2-1
......@@ -1,7 +1,8 @@
1use fortanix_sgx_abi::{EV_UNPARK, WAIT_INDEFINITE};
2
13use super::abi::usercalls;
24use crate::io::ErrorKind;
35use crate::time::Duration;
4use fortanix_sgx_abi::{EV_UNPARK, WAIT_INDEFINITE};
56
67pub type ThreadId = fortanix_sgx_abi::Tcs;
78
library/std/src/sys/pal/sgx/waitqueue/mod.rs+5-7
......@@ -16,17 +16,15 @@ mod tests;
1616mod spin_mutex;
1717mod unsafe_list;
1818
19use crate::num::NonZero;
20use crate::ops::{Deref, DerefMut};
21use crate::panic::{self, AssertUnwindSafe};
22use crate::time::Duration;
23
24use super::abi::thread;
25use super::abi::usercalls;
2619use fortanix_sgx_abi::{Tcs, EV_UNPARK, WAIT_INDEFINITE};
2720
2821pub use self::spin_mutex::{try_lock_or_false, SpinMutex, SpinMutexGuard};
2922use self::unsafe_list::{UnsafeList, UnsafeListEntry};
23use super::abi::{thread, usercalls};
24use crate::num::NonZero;
25use crate::ops::{Deref, DerefMut};
26use crate::panic::{self, AssertUnwindSafe};
27use crate::time::Duration;
3028
3129/// An queue entry in a `WaitQueue`.
3230struct WaitEntry {
library/std/src/sys/pal/solid/abi/fs.rs+2-1
......@@ -1,11 +1,12 @@
11//! `solid_fs.h`
22
3use crate::os::raw::{c_char, c_int, c_uchar};
43pub use libc::{
54 ino_t, off_t, stat, time_t, O_APPEND, O_CREAT, O_EXCL, O_RDONLY, O_RDWR, O_TRUNC, O_WRONLY,
65 SEEK_CUR, SEEK_END, SEEK_SET, S_IFBLK, S_IFCHR, S_IFDIR, S_IFIFO, S_IFMT, S_IFREG, S_IWRITE,
76};
87
8use crate::os::raw::{c_char, c_int, c_uchar};
9
910pub const O_ACCMODE: c_int = 0x3;
1011
1112pub 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;
33mod fs;
44pub mod sockets;
55pub use self::fs::*;
6
76// `solid_types.h`
87pub use super::itron::abi::{ER, ER_ID, E_TMOUT, ID};
98
library/std/src/sys/pal/solid/abi/sockets.rs+2-1
......@@ -1,6 +1,7 @@
1use crate::os::raw::{c_char, c_uint, c_void};
21pub use libc::{c_int, c_long, size_t, ssize_t, timeval};
32
3use crate::os::raw::{c_char, c_uint, c_void};
4
45pub const SOLID_NET_ERR_BASE: c_int = -2000;
56pub const EINPROGRESS: c_int = SOLID_NET_ERR_BASE - libc::EINPROGRESS;
67
library/std/src/sys/pal/solid/alloc.rs+2-4
......@@ -1,7 +1,5 @@
1use crate::{
2 alloc::{GlobalAlloc, Layout, System},
3 sys::common::alloc::{realloc_fallback, MIN_ALIGN},
4};
1use crate::alloc::{GlobalAlloc, Layout, System};
2use crate::sys::common::alloc::{realloc_fallback, MIN_ALIGN};
53
64#[stable(feature = "alloc_system_type", since = "1.28.0")]
75unsafe impl GlobalAlloc for System {
library/std/src/sys/pal/solid/error.rs+1-2
......@@ -1,8 +1,7 @@
1pub use self::itron::error::{expect_success, ItronError as SolidError};
12use super::{abi, itron, net};
23use crate::io::ErrorKind;
34
4pub use self::itron::error::{expect_success, ItronError as SolidError};
5
65/// Describe the specified SOLID error code. Returns `None` if it's an
76/// undefined error code.
87///
library/std/src/sys/pal/solid/fs.rs+10-13
......@@ -1,17 +1,14 @@
11use super::{abi, error};
2use 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
2use crate::ffi::{CStr, CString, OsStr, OsString};
3use crate::fmt;
4use crate::io::{self, BorrowedCursor, IoSlice, IoSliceMut, SeekFrom};
5use crate::mem::MaybeUninit;
6use crate::os::raw::{c_int, c_short};
7use crate::os::solid::ffi::OsStrExt;
8use crate::path::{Path, PathBuf};
9use crate::sync::Arc;
10use crate::sys::time::SystemTime;
11use crate::sys::unsupported;
1512pub use crate::sys_common::fs::exists;
1613
1714/// A file descriptor.
library/std/src/sys/pal/solid/io.rs+3-3
......@@ -1,8 +1,8 @@
1use crate::marker::PhantomData;
2use crate::slice;
1use libc::c_void;
32
43use super::abi::sockets::iovec;
5use libc::c_void;
4use crate::marker::PhantomData;
5use crate::slice;
66
77#[derive(Copy, Clone)]
88#[repr(transparent)]
library/std/src/sys/pal/solid/mod.rs+1-2
......@@ -32,8 +32,7 @@ pub mod pipe;
3232#[path = "../unsupported/process.rs"]
3333pub mod process;
3434pub mod stdio;
35pub use self::itron::thread;
36pub use self::itron::thread_parking;
35pub use self::itron::{thread, thread_parking};
3736pub mod time;
3837
3938// SAFETY: must be called only once during runtime initialization.
library/std/src/sys/pal/solid/net.rs+10-14
......@@ -1,19 +1,15 @@
1use super::abi;
2use 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};
1use libc::{c_int, c_void, size_t};
142
153use self::netc::{sockaddr, socklen_t, MSG_PEEK};
16use libc::{c_int, c_void, size_t};
4use super::abi;
5use crate::ffi::CStr;
6use crate::io::{self, BorrowedBuf, BorrowedCursor, ErrorKind, IoSlice, IoSliceMut};
7use crate::net::{Shutdown, SocketAddr};
8use crate::os::solid::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, OwnedFd};
9use crate::sys_common::net::{getsockopt, setsockopt, sockaddr_to_addr};
10use crate::sys_common::{FromInner, IntoInner};
11use crate::time::Duration;
12use crate::{cmp, mem, ptr, str};
1713
1814pub mod netc {
1915 pub use super::super::abi::sockets::*;
library/std/src/sys/pal/solid/os.rs+6-12
......@@ -1,20 +1,14 @@
1use super::unsupported;
1use core::slice::memchr;
2
3use super::{error, itron, unsupported};
24use crate::error::Error as StdError;
35use crate::ffi::{CStr, OsStr, OsString};
4use crate::fmt;
5use crate::io;
6use crate::os::{
7 raw::{c_char, c_int},
8 solid::ffi::{OsStrExt, OsStringExt},
9};
6use crate::os::raw::{c_char, c_int};
7use crate::os::solid::ffi::{OsStrExt, OsStringExt};
108use crate::path::{self, PathBuf};
119use crate::sync::{PoisonError, RwLock};
1210use crate::sys::common::small_c_string::run_with_cstr;
13use crate::vec;
14
15use super::{error, itron};
16
17use core::slice::memchr;
11use crate::{fmt, io, vec};
1812
1913// `solid` directly maps `errno`s to μITRON error codes.
2014impl itron::error::ItronError {
library/std/src/sys/pal/solid/time.rs+4-3
......@@ -1,7 +1,8 @@
1use super::{abi, error::expect_success};
2use crate::{mem::MaybeUninit, time::Duration};
3
1use super::abi;
2use super::error::expect_success;
43pub use super::itron::time::Instant;
4use crate::mem::MaybeUninit;
5use crate::time::Duration;
56
67#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
78pub struct SystemTime(abi::time_t);
library/std/src/sys/pal/teeos/os.rs+2-5
......@@ -2,14 +2,11 @@
22
33use core::marker::PhantomData;
44
5use super::unsupported;
56use crate::error::Error as StdError;
67use crate::ffi::{OsStr, OsString};
7use crate::fmt;
8use crate::io;
9use crate::path;
108use crate::path::PathBuf;
11
12use super::unsupported;
9use crate::{fmt, io, path};
1310
1411pub fn errno() -> i32 {
1512 unsafe { (*libc::__errno_location()) as i32 }
library/std/src/sys/pal/teeos/stdio.rs+2-1
......@@ -1,8 +1,9 @@
11#![deny(unsafe_op_in_unsafe_fn)]
22
3use crate::io;
43use core::arch::asm;
54
5use crate::io;
6
67pub struct Stdin;
78pub struct Stdout;
89pub struct Stderr;
library/std/src/sys/pal/teeos/thread.rs+1-3
......@@ -1,11 +1,9 @@
1use crate::cmp;
21use crate::ffi::CStr;
3use crate::io;
42use crate::mem::{self, ManuallyDrop};
53use crate::num::NonZero;
6use crate::ptr;
74use crate::sys::os;
85use crate::time::Duration;
6use crate::{cmp, io, ptr};
97
108pub const DEFAULT_MIN_STACK_SIZE: usize = 8 * 1024;
119
library/std/src/sys/pal/uefi/args.rs+1-2
......@@ -3,10 +3,9 @@ use r_efi::protocols::loaded_image;
33use super::helpers;
44use crate::env::current_exe;
55use crate::ffi::OsString;
6use crate::fmt;
76use crate::iter::Iterator;
87use crate::mem::size_of;
9use crate::vec;
8use crate::{fmt, vec};
109
1110pub struct Args {
1211 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};
1515use crate::ffi::{OsStr, OsString};
1616use crate::io::{self, const_io_error};
1717use crate::mem::{size_of, MaybeUninit};
18use crate::os::uefi::{self, env::boot_services, ffi::OsStrExt, ffi::OsStringExt};
18use crate::os::uefi::env::boot_services;
19use crate::os::uefi::ffi::{OsStrExt, OsStringExt};
20use crate::os::uefi::{self};
1921use crate::ptr::NonNull;
2022use crate::slice;
2123use 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 {
101101}
102102
103103pub fn decode_error_kind(code: RawOsError) -> crate::io::ErrorKind {
104 use crate::io::ErrorKind;
105104 use r_efi::efi::Status;
106105
106 use crate::io::ErrorKind;
107
107108 match r_efi::efi::Status::from_usize(code) {
108109 Status::ALREADY_STARTED
109110 | Status::COMPROMISED_DATA
library/std/src/sys/pal/uefi/os.rs+4-4
......@@ -1,14 +1,14 @@
1use r_efi::efi::protocols::{device_path, loaded_image_device_path};
2use r_efi::efi::Status;
3
14use super::{helpers, unsupported, RawOsError};
25use crate::error::Error as StdError;
36use crate::ffi::{OsStr, OsString};
4use crate::fmt;
5use crate::io;
67use crate::marker::PhantomData;
78use crate::os::uefi;
89use crate::path::{self, PathBuf};
910use crate::ptr::NonNull;
10use r_efi::efi::protocols::{device_path, loaded_image_device_path};
11use r_efi::efi::Status;
11use crate::{fmt, io};
1212
1313pub fn errno() -> RawOsError {
1414 0
library/std/src/sys/pal/uefi/process.rs+5-10
......@@ -1,20 +1,15 @@
11use r_efi::protocols::simple_text_output;
22
3use crate::ffi::OsStr;
4use crate::ffi::OsString;
5use crate::fmt;
6use crate::io;
7use crate::num::NonZero;
8use crate::num::NonZeroI32;
3use super::helpers;
4pub use crate::ffi::OsString as EnvKey;
5use crate::ffi::{OsStr, OsString};
6use crate::num::{NonZero, NonZeroI32};
97use crate::path::Path;
108use crate::sys::fs::File;
119use crate::sys::pipe::AnonPipe;
1210use crate::sys::unsupported;
1311use crate::sys_common::process::{CommandEnv, CommandEnvs};
14
15pub use crate::ffi::OsString as EnvKey;
16
17use super::helpers;
12use crate::{fmt, io};
1813
1914////////////////////////////////////////////////////////////////////////////////
2015// Command
library/std/src/sys/pal/uefi/time.rs+4-2
......@@ -59,11 +59,12 @@ impl SystemTime {
5959}
6060
6161pub(crate) mod system_time_internal {
62 use r_efi::efi::{RuntimeServices, Time};
63
6264 use super::super::helpers;
6365 use super::*;
6466 use crate::mem::MaybeUninit;
6567 use crate::ptr::NonNull;
66 use r_efi::efi::{RuntimeServices, Time};
6768
6869 pub fn now() -> Option<SystemTime> {
6970 let runtime_services: NonNull<RuntimeServices> = helpers::runtime_services()?;
......@@ -114,13 +115,14 @@ pub(crate) mod system_time_internal {
114115}
115116
116117pub(crate) mod instant_internal {
118 use r_efi::protocols::timestamp;
119
117120 use super::super::helpers;
118121 use super::*;
119122 use crate::mem::MaybeUninit;
120123 use crate::ptr::NonNull;
121124 use crate::sync::atomic::{AtomicPtr, Ordering};
122125 use crate::sys_common::mul_div_u64;
123 use r_efi::protocols::timestamp;
124126
125127 const NS_PER_SEC: u64 = 1_000_000_000;
126128
library/std/src/sys/pal/unix/args.rs+1-2
......@@ -6,9 +6,8 @@
66#![allow(dead_code)] // runtime init functions not used during testing
77
88use crate::ffi::{CStr, OsString};
9use crate::fmt;
109use crate::os::unix::ffi::OsStringExt;
11use crate::vec;
10use crate::{fmt, vec};
1211
1312/// One-time global initialization.
1413pub unsafe fn init(argc: isize, argv: *const *const u8) {
library/std/src/sys/pal/unix/fd.rs+6-6
......@@ -3,12 +3,6 @@
33#[cfg(test)]
44mod tests;
55
6use crate::cmp;
7use crate::io::{self, BorrowedCursor, IoSlice, IoSliceMut, Read};
8use crate::os::unix::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, OwnedFd, RawFd};
9use crate::sys::cvt;
10use crate::sys_common::{AsInner, FromInner, IntoInner};
11
126#[cfg(any(
137 target_os = "android",
148 target_os = "linux",
......@@ -26,6 +20,12 @@ use libc::off64_t;
2620)))]
2721use libc::off_t as off64_t;
2822
23use crate::cmp;
24use crate::io::{self, BorrowedCursor, IoSlice, IoSliceMut, Read};
25use crate::os::unix::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, OwnedFd, RawFd};
26use crate::sys::cvt;
27use crate::sys_common::{AsInner, FromInner, IntoInner};
28
2929#[derive(Debug)]
3030pub struct FileDesc(OwnedFd);
3131
library/std/src/sys/pal/unix/fd/tests.rs+2-1
......@@ -1,6 +1,7 @@
1use core::mem::ManuallyDrop;
2
13use super::{FileDesc, IoSlice};
24use crate::os::unix::io::FromRawFd;
3use core::mem::ManuallyDrop;
45
56#[test]
67fn limit_vector_count() {
library/std/src/sys/pal/unix/fs.rs+23-28
......@@ -4,29 +4,6 @@
44#[cfg(test)]
55mod tests;
66
7use crate::os::unix::prelude::*;
8
9use crate::ffi::{CStr, OsStr, OsString};
10use crate::fmt::{self, Write as _};
11use crate::io::{self, BorrowedCursor, Error, IoSlice, IoSliceMut, SeekFrom};
12use crate::mem;
13use crate::os::unix::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd};
14use crate::path::{Path, PathBuf};
15use crate::ptr;
16use crate::sync::Arc;
17use crate::sys::common::small_c_string::run_path_with_cstr;
18use crate::sys::fd::FileDesc;
19use crate::sys::time::SystemTime;
20use crate::sys::{cvt, cvt_r};
21use crate::sys_common::{AsInner, AsInnerMut, FromInner, IntoInner};
22
23#[cfg(all(target_os = "linux", target_env = "gnu"))]
24use crate::sys::weak::syscall;
25#[cfg(target_os = "android")]
26use crate::sys::weak::weak;
27
28use libc::{c_int, mode_t};
29
307#[cfg(all(target_os = "linux", target_env = "gnu"))]
318use libc::c_char;
329#[cfg(any(
......@@ -73,6 +50,7 @@ use libc::readdir64_r;
7350 target_os = "hurd",
7451)))]
7552use libc::readdir_r as readdir64_r;
53use libc::{c_int, mode_t};
7654#[cfg(target_os = "android")]
7755use libc::{
7856 dirent as dirent64, fstat as fstat64, fstatat as fstatat64, ftruncate64, lseek64,
......@@ -97,7 +75,24 @@ use libc::{
9775))]
9876use libc::{dirent64, fstat64, ftruncate64, lseek64, lstat64, off64_t, open64, stat64};
9977
78use crate::ffi::{CStr, OsStr, OsString};
79use crate::fmt::{self, Write as _};
80use crate::io::{self, BorrowedCursor, Error, IoSlice, IoSliceMut, SeekFrom};
81use crate::os::unix::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd};
82use crate::os::unix::prelude::*;
83use crate::path::{Path, PathBuf};
84use crate::sync::Arc;
85use crate::sys::common::small_c_string::run_path_with_cstr;
86use crate::sys::fd::FileDesc;
87use crate::sys::time::SystemTime;
88#[cfg(all(target_os = "linux", target_env = "gnu"))]
89use crate::sys::weak::syscall;
90#[cfg(target_os = "android")]
91use crate::sys::weak::weak;
92use crate::sys::{cvt, cvt_r};
10093pub use crate::sys_common::fs::exists;
94use crate::sys_common::{AsInner, AsInnerMut, FromInner, IntoInner};
95use crate::{mem, ptr};
10196
10297pub struct File(FileDesc);
10398
......@@ -2021,6 +2016,11 @@ mod remove_dir_impl {
20212016 miri
20222017)))]
20232018mod 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
20242024 use super::{lstat, Dir, DirEntry, InnerReadDir, ReadDir};
20252025 use crate::ffi::CStr;
20262026 use crate::io;
......@@ -2030,11 +2030,6 @@ mod remove_dir_impl {
20302030 use crate::sys::common::small_c_string::run_path_with_cstr;
20312031 use crate::sys::{cvt, cvt_r};
20322032
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
20382033 pub fn openat_nofollow_dironly(parent_fd: Option<RawFd>, p: &CStr) -> io::Result<OwnedFd> {
20392034 let fd = cvt_r(|| unsafe {
20402035 openat(
library/std/src/sys/pal/unix/io.rs+2-2
......@@ -1,9 +1,9 @@
1use libc::{c_void, iovec};
2
13use crate::marker::PhantomData;
24use crate::os::fd::{AsFd, AsRawFd};
35use crate::slice;
46
5use libc::{c_void, iovec};
6
77#[derive(Copy, Clone)]
88#[repr(transparent)]
99pub struct IoSlice<'a> {
library/std/src/sys/pal/unix/kernel_copy.rs+6-5
......@@ -42,6 +42,12 @@
4242//! progress, they can hit a performance cliff.
4343//! * complexity
4444
45#[cfg(not(any(all(target_os = "linux", target_env = "gnu"), target_os = "hurd")))]
46use libc::sendfile as sendfile64;
47#[cfg(any(all(target_os = "linux", target_env = "gnu"), target_os = "hurd"))]
48use libc::sendfile64;
49use libc::{EBADF, EINVAL, ENOSYS, EOPNOTSUPP, EOVERFLOW, EPERM, EXDEV};
50
4551use crate::cmp::min;
4652use crate::fs::{File, Metadata};
4753use crate::io::copy::generic_copy;
......@@ -59,11 +65,6 @@ use crate::ptr;
5965use crate::sync::atomic::{AtomicBool, AtomicU8, Ordering};
6066use crate::sys::cvt;
6167use crate::sys::weak::syscall;
62#[cfg(not(any(all(target_os = "linux", target_env = "gnu"), target_os = "hurd")))]
63use libc::sendfile as sendfile64;
64#[cfg(any(all(target_os = "linux", target_env = "gnu"), target_os = "hurd"))]
65use libc::sendfile64;
66use libc::{EBADF, EINVAL, ENOSYS, EOPNOTSUPP, EOVERFLOW, EPERM, EXDEV};
6768
6869#[cfg(test)]
6970mod tests;
library/std/src/sys/pal/unix/kernel_copy/tests.rs+1-3
......@@ -1,8 +1,6 @@
11use crate::fs::OpenOptions;
22use crate::io;
3use crate::io::Result;
4use crate::io::SeekFrom;
5use crate::io::{BufRead, Read, Seek, Write};
3use crate::io::{BufRead, Read, Result, Seek, SeekFrom, Write};
64use crate::os::unix::io::AsRawFd;
75use crate::sys_common::io::test::tmpdir;
86
library/std/src/sys/pal/unix/mod.rs+8-6
......@@ -1,8 +1,7 @@
11#![allow(missing_docs, nonstandard_style)]
22
3use crate::io::ErrorKind;
4
53pub use self::rand::hashmap_random_keys;
4use crate::io::ErrorKind;
65
76#[cfg(not(target_os = "espidf"))]
87#[macro_use]
......@@ -86,11 +85,12 @@ pub unsafe fn init(argc: isize, argv: *const *const u8, sigpipe: u8) {
8685 target_vendor = "apple",
8786 )))]
8887 'poll: {
89 use crate::sys::os::errno;
9088 #[cfg(not(all(target_os = "linux", target_env = "gnu")))]
9189 use libc::open as open64;
9290 #[cfg(all(target_os = "linux", target_env = "gnu"))]
9391 use libc::open64;
92
93 use crate::sys::os::errno;
9494 let pfds: &mut [_] = &mut [
9595 libc::pollfd { fd: 0, events: 0, revents: 0 },
9696 libc::pollfd { fd: 1, events: 0, revents: 0 },
......@@ -140,11 +140,12 @@ pub unsafe fn init(argc: isize, argv: *const *const u8, sigpipe: u8) {
140140 target_os = "vita",
141141 )))]
142142 {
143 use crate::sys::os::errno;
144143 #[cfg(not(all(target_os = "linux", target_env = "gnu")))]
145144 use libc::open as open64;
146145 #[cfg(all(target_os = "linux", target_env = "gnu"))]
147146 use libc::open64;
147
148 use crate::sys::os::errno;
148149 for fd in 0..3 {
149150 if libc::fcntl(fd, libc::F_GETFD) == -1 && errno() == libc::EBADF {
150151 if open64(c"/dev/null".as_ptr().cast(), libc::O_RDWR, 0) == -1 {
......@@ -232,12 +233,13 @@ pub unsafe fn cleanup() {
232233 stack_overflow::cleanup();
233234}
234235
235#[cfg(target_os = "android")]
236pub use crate::sys::android::signal;
237236#[allow(unused_imports)]
238237#[cfg(not(target_os = "android"))]
239238pub use libc::signal;
240239
240#[cfg(target_os = "android")]
241pub use crate::sys::android::signal;
242
241243#[inline]
242244pub(crate) fn is_interrupted(errno: i32) -> bool {
243245 errno == libc::EINTR
library/std/src/sys/pal/unix/net.rs+3-4
......@@ -1,7 +1,7 @@
1use crate::cmp;
1use libc::{c_int, c_void, size_t, sockaddr, socklen_t, MSG_PEEK};
2
23use crate::ffi::CStr;
34use crate::io::{self, BorrowedBuf, BorrowedCursor, IoSlice, IoSliceMut};
4use crate::mem;
55use crate::net::{Shutdown, SocketAddr};
66use crate::os::unix::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, RawFd};
77use crate::sys::fd::FileDesc;
......@@ -9,8 +9,7 @@ use crate::sys::pal::unix::IsMinusOne;
99use crate::sys_common::net::{getsockopt, setsockopt, sockaddr_to_addr};
1010use crate::sys_common::{AsInner, FromInner, IntoInner};
1111use crate::time::{Duration, Instant};
12
13use libc::{c_int, c_void, size_t, sockaddr, socklen_t, MSG_PEEK};
12use crate::{cmp, mem};
1413
1514cfg_if::cfg_if! {
1615 if #[cfg(target_vendor = "apple")] {
library/std/src/sys/pal/unix/os.rs+8-19
......@@ -5,29 +5,20 @@
55#[cfg(test)]
66mod tests;
77
8use crate::os::unix::prelude::*;
8use core::slice::memchr;
9
10use libc::{c_char, c_int, c_void};
911
1012use crate::error::Error as StdError;
1113use crate::ffi::{CStr, CString, OsStr, OsString};
12use crate::fmt;
13use crate::io;
14use crate::iter;
15use crate::mem;
14use crate::os::unix::prelude::*;
1615use crate::path::{self, PathBuf};
17use crate::ptr;
18use crate::slice;
19use crate::str;
2016use crate::sync::{PoisonError, RwLock};
2117use crate::sys::common::small_c_string::{run_path_with_cstr, run_with_cstr};
22use crate::sys::cvt;
23use crate::sys::fd;
24use crate::vec;
25use core::slice::memchr;
26
2718#[cfg(all(target_env = "gnu", not(target_os = "vxworks")))]
2819use crate::sys::weak::weak;
29
30use libc::{c_char, c_int, c_void};
20use crate::sys::{cvt, fd};
21use crate::{fmt, io, iter, mem, ptr, slice, str, vec};
3122
3223const TMPBUF_SZ: usize = 128;
3324
......@@ -248,13 +239,12 @@ impl StdError for JoinPathsError {
248239
249240#[cfg(target_os = "aix")]
250241pub fn current_exe() -> io::Result<PathBuf> {
251 use crate::io::ErrorKind;
252
253242 #[cfg(test)]
254243 use realstd::env;
255244
256245 #[cfg(not(test))]
257246 use crate::env;
247 use crate::io::ErrorKind;
258248
259249 let exe_path = env::args().next().ok_or(io::const_io_error!(
260250 ErrorKind::NotFound,
......@@ -513,13 +503,12 @@ pub fn current_exe() -> io::Result<PathBuf> {
513503
514504#[cfg(target_os = "fuchsia")]
515505pub fn current_exe() -> io::Result<PathBuf> {
516 use crate::io::ErrorKind;
517
518506 #[cfg(test)]
519507 use realstd::env;
520508
521509 #[cfg(not(test))]
522510 use crate::env;
511 use crate::io::ErrorKind;
523512
524513 let exe_path = env::args().next().ok_or(io::const_io_error!(
525514 ErrorKind::Uncategorized,
library/std/src/sys/pal/unix/process/process_common.rs+5-9
......@@ -1,24 +1,20 @@
11#[cfg(all(test, not(target_os = "emscripten")))]
22mod tests;
33
4use crate::os::unix::prelude::*;
4use libc::{c_char, c_int, gid_t, pid_t, uid_t, EXIT_FAILURE, EXIT_SUCCESS};
55
66use crate::collections::BTreeMap;
77use crate::ffi::{CStr, CString, OsStr, OsString};
8use crate::fmt;
9use crate::io;
8use crate::os::unix::prelude::*;
109use crate::path::Path;
11use crate::ptr;
1210use crate::sys::fd::FileDesc;
1311use crate::sys::fs::File;
12#[cfg(not(target_os = "fuchsia"))]
13use crate::sys::fs::OpenOptions;
1414use crate::sys::pipe::{self, AnonPipe};
1515use crate::sys_common::process::{CommandEnv, CommandEnvs};
1616use crate::sys_common::{FromInner, IntoInner};
17
18#[cfg(not(target_os = "fuchsia"))]
19use crate::sys::fs::OpenOptions;
20
21use libc::{c_char, c_int, gid_t, pid_t, uid_t, EXIT_FAILURE, EXIT_SUCCESS};
17use crate::{fmt, io, ptr};
2218
2319cfg_if::cfg_if! {
2420 if #[cfg(target_os = "fuchsia")] {
library/std/src/sys/pal/unix/process/process_common/tests.rs+1-3
......@@ -1,9 +1,7 @@
11use super::*;
2
32use crate::ffi::OsStr;
4use crate::mem;
5use crate::ptr;
63use crate::sys::{cvt, cvt_nz};
4use crate::{mem, ptr};
75
86macro_rules! t {
97 ($e:expr) => {
library/std/src/sys/pal/unix/process/process_fuchsia.rs+3-7
......@@ -1,13 +1,9 @@
1use crate::fmt;
2use crate::io;
3use crate::mem;
4use crate::num::NonZero;
5use crate::ptr;
1use libc::{c_int, size_t};
62
3use crate::num::NonZero;
74use crate::sys::process::process_common::*;
85use crate::sys::process::zircon::{zx_handle_t, Handle};
9
10use libc::{c_int, size_t};
6use crate::{fmt, io, mem, ptr};
117
128////////////////////////////////////////////////////////////////////////////////
139// Command
library/std/src/sys/pal/unix/process/process_unix.rs+16-20
......@@ -1,20 +1,7 @@
1use crate::fmt;
2use crate::io::{self, Error, ErrorKind};
3use crate::mem;
4use crate::num::NonZero;
5use crate::sys;
6use crate::sys::cvt;
7use crate::sys::process::process_common::*;
8
9#[cfg(target_os = "linux")]
10use crate::sys::pal::unix::linux::pidfd::PidFd;
11
121#[cfg(target_os = "vxworks")]
132use libc::RTP_ID as pid_t;
14
153#[cfg(not(target_os = "vxworks"))]
164use libc::{c_int, pid_t};
17
185#[cfg(not(any(
196 target_os = "vxworks",
207 target_os = "l4re",
......@@ -23,6 +10,14 @@ use libc::{c_int, pid_t};
2310)))]
2411use libc::{gid_t, uid_t};
2512
13use crate::io::{self, Error, ErrorKind};
14use crate::num::NonZero;
15use crate::sys::cvt;
16#[cfg(target_os = "linux")]
17use crate::sys::pal::unix::linux::pidfd::PidFd;
18use crate::sys::process::process_common::*;
19use crate::{fmt, mem, sys};
20
2621cfg_if::cfg_if! {
2722 if #[cfg(all(target_os = "nto", target_env = "nto71"))] {
2823 use crate::thread;
......@@ -446,11 +441,12 @@ impl Command {
446441 stdio: &ChildPipes,
447442 envp: Option<&CStringArray>,
448443 ) -> io::Result<Option<Process>> {
444 #[cfg(target_os = "linux")]
445 use core::sync::atomic::{AtomicU8, Ordering};
446
449447 use crate::mem::MaybeUninit;
450448 use crate::sys::weak::weak;
451449 use crate::sys::{self, cvt_nz, on_broken_pipe_flag_used};
452 #[cfg(target_os = "linux")]
453 use core::sync::atomic::{AtomicU8, Ordering};
454450
455451 if self.get_gid().is_some()
456452 || self.get_uid().is_some()
......@@ -762,10 +758,11 @@ impl Command {
762758
763759 #[cfg(target_os = "linux")]
764760 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
765763 use crate::io::IoSlice;
766764 use crate::os::fd::RawFd;
767765 use crate::sys::cvt_r;
768 use libc::{CMSG_DATA, CMSG_FIRSTHDR, CMSG_LEN, CMSG_SPACE, SCM_RIGHTS, SOL_SOCKET};
769766
770767 unsafe {
771768 let child_pid = libc::getpid();
......@@ -819,11 +816,11 @@ impl Command {
819816
820817 #[cfg(target_os = "linux")]
821818 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
822821 use crate::io::IoSliceMut;
823822 use crate::sys::cvt_r;
824823
825 use libc::{CMSG_DATA, CMSG_FIRSTHDR, CMSG_LEN, CMSG_SPACE, SCM_RIGHTS, SOL_SOCKET};
826
827824 unsafe {
828825 const SCM_MSG_LEN: usize = mem::size_of::<[c_int; 1]>();
829826
......@@ -1189,12 +1186,11 @@ impl ExitStatusError {
11891186#[cfg(target_os = "linux")]
11901187mod linux_child_ext {
11911188
1192 use crate::io;
1193 use crate::mem;
11941189 use crate::os::linux::process as os;
11951190 use crate::sys::pal::unix::linux::pidfd as imp;
11961191 use crate::sys::pal::unix::ErrorKind;
11971192 use crate::sys_common::FromInner;
1193 use crate::{io, mem};
11981194
11991195 #[unstable(feature = "linux_pidfd", issue = "82971")]
12001196 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 @@
1use libc::{c_int, pid_t};
2
13use crate::io;
24use crate::num::NonZero;
35use crate::sys::pal::unix::unsupported::*;
46use crate::sys::process::process_common::*;
57
6use libc::{c_int, pid_t};
7
88////////////////////////////////////////////////////////////////////////////////
99// Command
1010////////////////////////////////////////////////////////////////////////////////
library/std/src/sys/pal/unix/process/process_unsupported/wait_status.rs+1-2
......@@ -2,12 +2,11 @@
22//!
33//! Separate module to facilitate testing against a real Unix implementation.
44
5use super::ExitStatusError;
56use crate::ffi::c_int;
67use crate::fmt;
78use crate::num::NonZero;
89
9use super::ExitStatusError;
10
1110/// Emulated wait status for use by `process_unsupported.rs`
1211///
1312/// 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 @@
1use crate::fmt;
1use libc::{self, c_char, c_int, RTP_ID};
2
23use crate::io::{self, ErrorKind};
34use crate::num::NonZero;
4use crate::sys;
55use crate::sys::cvt;
66use crate::sys::pal::unix::thread;
77use crate::sys::process::process_common::*;
8use libc::RTP_ID;
9use libc::{self, c_char, c_int};
8use crate::{fmt, sys};
109
1110////////////////////////////////////////////////////////////////////////////////
1211// Command
library/std/src/sys/pal/unix/process/zircon.rs+2-2
......@@ -1,11 +1,11 @@
11#![allow(non_camel_case_types, unused)]
22
3use libc::{c_int, c_void, size_t};
4
35use crate::io;
46use crate::mem::MaybeUninit;
57use crate::os::raw::c_char;
68
7use libc::{c_int, c_void, size_t};
8
99pub type zx_handle_t = u32;
1010pub type zx_vaddr_t = usize;
1111pub 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) {
2424mod imp {
2525 use crate::fs::File;
2626 use crate::io::Read;
27
2827 #[cfg(any(target_os = "linux", target_os = "android"))]
2928 use crate::sys::weak::syscall;
3029
......@@ -178,9 +177,10 @@ mod imp {
178177
179178#[cfg(target_vendor = "apple")]
180179mod imp {
181 use crate::io;
182180 use libc::{c_int, c_void, size_t};
183181
182 use crate::io;
183
184184 #[inline(always)]
185185 fn random_failure() -> ! {
186186 panic!("unexpected random generation error: {}", io::Error::last_os_error());
......@@ -311,8 +311,10 @@ mod imp {
311311
312312#[cfg(target_os = "vxworks")]
313313mod imp {
314 use core::sync::atomic::AtomicBool;
315 use core::sync::atomic::Ordering::Relaxed;
316
314317 use crate::io;
315 use core::sync::atomic::{AtomicBool, Ordering::Relaxed};
316318
317319 pub fn fill_bytes(v: &mut [u8]) {
318320 static RNG_INIT: AtomicBool = AtomicBool::new(false);
library/std/src/sys/pal/unix/stack_overflow.rs+12-15
......@@ -1,10 +1,8 @@
11#![cfg_attr(test, allow(dead_code))]
22
3pub use self::imp::{cleanup, init};
34use self::imp::{drop_handler, make_handler};
45
5pub use self::imp::cleanup;
6pub use self::imp::init;
7
86pub struct Handler {
97 data: *mut libc::c_void,
108}
......@@ -37,24 +35,23 @@ impl Drop for Handler {
3735 target_os = "solaris"
3836))]
3937mod 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
4048 use super::Handler;
4149 use crate::cell::Cell;
42 use crate::io;
43 use crate::mem;
4450 use crate::ops::Range;
45 use crate::ptr;
4651 use crate::sync::atomic::{AtomicBool, AtomicPtr, AtomicUsize, Ordering};
4752 use crate::sync::OnceLock;
4853 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};
5855
5956 // We use a TLS variable to store the address of the guard page. While TLS
6057 // 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 @@
1use crate::cmp;
21use crate::ffi::CStr;
3use crate::io;
42use crate::mem::{self, ManuallyDrop};
53use crate::num::NonZero;
6use crate::ptr;
7use crate::sys::{os, stack_overflow};
8use crate::time::Duration;
9
104#[cfg(all(target_os = "linux", target_env = "gnu"))]
115use crate::sys::weak::dlsym;
126#[cfg(any(target_os = "solaris", target_os = "illumos", target_os = "nto"))]
137use crate::sys::weak::weak;
8use crate::sys::{os, stack_overflow};
9use crate::time::Duration;
10use crate::{cmp, io, ptr};
1411#[cfg(not(any(target_os = "l4re", target_os = "vxworks", target_os = "espidf")))]
1512pub const DEFAULT_MIN_STACK_SIZE: usize = 2 * 1024 * 1024;
1613#[cfg(target_os = "l4re")]
......@@ -475,11 +472,9 @@ mod cgroups {
475472 use crate::borrow::Cow;
476473 use crate::ffi::OsString;
477474 use crate::fs::{exists, File};
478 use crate::io::Read;
479 use crate::io::{BufRead, BufReader};
475 use crate::io::{BufRead, BufReader, Read};
480476 use crate::os::unix::ffi::OsStringExt;
481 use crate::path::Path;
482 use crate::path::PathBuf;
477 use crate::path::{Path, PathBuf};
483478 use crate::str::from_utf8;
484479
485480 #[derive(PartialEq)]
library/std/src/sys/pal/unix/thread_parking.rs+2-1
......@@ -2,10 +2,11 @@
22// separate modules for each platform.
33#![cfg(target_os = "netbsd")]
44
5use libc::{_lwp_self, c_long, clockid_t, lwpid_t, time_t, timespec, CLOCK_MONOTONIC};
6
57use crate::ffi::{c_int, c_void};
68use crate::ptr;
79use crate::time::Duration;
8use libc::{_lwp_self, c_long, clockid_t, lwpid_t, time_t, timespec, CLOCK_MONOTONIC};
910
1011extern "C" {
1112 fn ___lwp_park60(
library/std/src/sys/pal/unix/weak.rs+1-2
......@@ -23,9 +23,8 @@
2323
2424use crate::ffi::CStr;
2525use crate::marker::PhantomData;
26use crate::mem;
27use crate::ptr;
2826use crate::sync::atomic::{self, AtomicPtr, Ordering};
27use crate::{mem, ptr};
2928
3029// We can use true weak linkage on ELF targets.
3130#[cfg(all(unix, not(target_vendor = "apple")))]
library/std/src/sys/pal/unsupported/os.rs+1-2
......@@ -1,10 +1,9 @@
11use super::unsupported;
22use crate::error::Error as StdError;
33use crate::ffi::{OsStr, OsString};
4use crate::fmt;
5use crate::io;
64use crate::marker::PhantomData;
75use crate::path::{self, PathBuf};
6use crate::{fmt, io};
87
98pub fn errno() -> i32 {
109 0
library/std/src/sys/pal/unsupported/pipe.rs+2-4
......@@ -1,7 +1,5 @@
1use crate::{
2 fmt,
3 io::{self, BorrowedCursor, IoSlice, IoSliceMut},
4};
1use crate::fmt;
2use crate::io::{self, BorrowedCursor, IoSlice, IoSliceMut};
53
64pub struct AnonPipe(!);
75
library/std/src/sys/pal/unsupported/process.rs+2-4
......@@ -1,14 +1,12 @@
1pub use crate::ffi::OsString as EnvKey;
12use crate::ffi::{OsStr, OsString};
2use crate::fmt;
3use crate::io;
43use crate::num::NonZero;
54use crate::path::Path;
65use crate::sys::fs::File;
76use crate::sys::pipe::AnonPipe;
87use crate::sys::unsupported;
98use crate::sys_common::process::{CommandEnv, CommandEnvs};
10
11pub use crate::ffi::OsString as EnvKey;
9use crate::{fmt, io};
1210
1311////////////////////////////////////////////////////////////////////////////////
1412// Command
library/std/src/sys/pal/wasi/args.rs+1-2
......@@ -1,9 +1,8 @@
11#![deny(unsafe_op_in_unsafe_fn)]
22
33use crate::ffi::{CStr, OsStr, OsString};
4use crate::fmt;
54use crate::os::wasi::ffi::OsStrExt;
6use crate::vec;
5use crate::{fmt, vec};
76
87pub struct Args {
98 iter: vec::IntoIter<OsString>,
library/std/src/sys/pal/wasi/fs.rs+2-5
......@@ -2,22 +2,19 @@
22
33use super::fd::WasiFd;
44use crate::ffi::{CStr, OsStr, OsString};
5use crate::fmt;
65use crate::io::{self, BorrowedCursor, IoSlice, IoSliceMut, SeekFrom};
7use crate::iter;
86use crate::mem::{self, ManuallyDrop};
97use crate::os::raw::c_int;
108use crate::os::wasi::ffi::{OsStrExt, OsStringExt};
119use crate::os::wasi::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, RawFd};
1210use crate::path::{Path, PathBuf};
13use crate::ptr;
1411use crate::sync::Arc;
1512use crate::sys::common::small_c_string::run_path_with_cstr;
1613use crate::sys::time::SystemTime;
1714use crate::sys::unsupported;
18use crate::sys_common::{AsInner, FromInner, IntoInner};
19
2015pub use crate::sys_common::fs::exists;
16use crate::sys_common::{AsInner, FromInner, IntoInner};
17use crate::{fmt, iter, ptr};
2118
2219pub struct File {
2320 fd: WasiFd,
library/std/src/sys/pal/wasi/helpers.rs+1-2
......@@ -1,5 +1,4 @@
1use crate::io as std_io;
2use crate::mem;
1use crate::{io as std_io, mem};
32
43#[inline]
54pub fn is_interrupted(errno: i32) -> bool {
library/std/src/sys/pal/wasi/mod.rs+1-4
......@@ -48,8 +48,5 @@ mod helpers;
4848// import conflict rules. If we glob export `helpers` and `common` together,
4949// then the compiler complains about conflicts.
5050
51pub use helpers::abort_internal;
52pub use helpers::decode_error_kind;
5351use helpers::err2io;
54pub use helpers::hashmap_random_keys;
55pub use helpers::is_interrupted;
52pub 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 @@
11#![deny(unsafe_op_in_unsafe_fn)]
22
3use core::slice::memchr;
4
35use crate::error::Error as StdError;
46use crate::ffi::{CStr, OsStr, OsString};
5use crate::fmt;
6use crate::io;
77use crate::marker::PhantomData;
88use crate::ops::Drop;
99use crate::os::wasi::prelude::*;
1010use crate::path::{self, PathBuf};
11use crate::str;
1211use crate::sys::common::small_c_string::{run_path_with_cstr, run_with_cstr};
1312use crate::sys::unsupported;
14use crate::vec;
15use core::slice::memchr;
13use crate::{fmt, io, str, vec};
1614
1715// Add a few symbols not in upstream `libc` just yet.
1816mod libc {
library/std/src/sys/pal/wasi/thread.rs+1-2
......@@ -1,9 +1,8 @@
11use crate::ffi::CStr;
2use crate::io;
3use crate::mem;
42use crate::num::NonZero;
53use crate::sys::unsupported;
64use crate::time::Duration;
5use crate::{io, mem};
76
87cfg_if::cfg_if! {
98 if #[cfg(target_feature = "atomics")] {
library/std/src/sys/pal/wasip2/mod.rs+1-4
......@@ -51,10 +51,7 @@ mod helpers;
5151// import conflict rules. If we glob export `helpers` and `common` together,
5252// then the compiler complains about conflicts.
5353
54pub use helpers::abort_internal;
55pub use helpers::decode_error_kind;
5654use helpers::err2io;
57pub use helpers::hashmap_random_keys;
58pub use helpers::is_interrupted;
55pub use helpers::{abort_internal, decode_error_kind, hashmap_random_keys, is_interrupted};
5956
6057mod cabi_realloc;
library/std/src/sys/pal/wasm/alloc.rs+2-4
......@@ -57,10 +57,8 @@ unsafe impl GlobalAlloc for System {
5757
5858#[cfg(target_feature = "atomics")]
5959mod 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};
6462
6563 static LOCKED: AtomicI32 = AtomicI32::new(0);
6664
library/std/src/sys/pal/windows/alloc.rs+2-1
......@@ -1,10 +1,11 @@
1use core::mem::MaybeUninit;
2
13use crate::alloc::{GlobalAlloc, Layout, System};
24use crate::ffi::c_void;
35use crate::ptr;
46use crate::sync::atomic::{AtomicPtr, Ordering};
57use crate::sys::c::{self, windows_targets};
68use crate::sys::common::alloc::{realloc_fallback, MIN_ALIGN};
7use core::mem::MaybeUninit;
89
910#[cfg(test)]
1011mod tests;
library/std/src/sys/pal/windows/args.rs+1-5
......@@ -8,8 +8,6 @@ mod tests;
88
99use super::os::current_exe;
1010use crate::ffi::{OsStr, OsString};
11use crate::fmt;
12use crate::io;
1311use crate::num::NonZero;
1412use crate::os::windows::prelude::*;
1513use crate::path::{Path, PathBuf};
......@@ -18,9 +16,7 @@ use crate::sys::process::ensure_no_nuls;
1816use crate::sys::{c, to_u16s};
1917use crate::sys_common::wstr::WStrUnits;
2018use crate::sys_common::AsInner;
21use crate::vec;
22
23use crate::iter;
19use crate::{fmt, io, iter, vec};
2420
2521/// This is the const equivalent to `NonZero::new(n).unwrap()`
2622///
library/std/src/sys/pal/windows/c.rs+1-2
......@@ -6,8 +6,7 @@
66#![allow(clippy::style)]
77
88use core::ffi::{c_uint, c_ulong, c_ushort, c_void, CStr};
9use core::mem;
10use core::ptr;
9use core::{mem, ptr};
1110
1211pub(super) mod windows_targets;
1312
library/std/src/sys/pal/windows/fs.rs+5-10
......@@ -1,26 +1,21 @@
11use core::ptr::addr_of;
22
3use crate::os::windows::prelude::*;
4
3use super::api::{self, WinError};
4use super::{to_u16s, IoResult};
55use crate::borrow::Cow;
66use crate::ffi::{c_void, OsStr, OsString};
7use crate::fmt;
87use crate::io::{self, BorrowedCursor, Error, IoSlice, IoSliceMut, SeekFrom};
98use crate::mem::{self, MaybeUninit};
109use crate::os::windows::io::{AsHandle, BorrowedHandle};
10use crate::os::windows::prelude::*;
1111use crate::path::{Path, PathBuf};
12use crate::ptr;
13use crate::slice;
1412use crate::sync::Arc;
1513use crate::sys::handle::Handle;
14use crate::sys::path::maybe_verbatim;
1615use crate::sys::time::SystemTime;
1716use crate::sys::{c, cvt, Align8};
1817use crate::sys_common::{AsInner, FromInner, IntoInner};
19use crate::thread;
20
21use super::api::{self, WinError};
22use super::{to_u16s, IoResult};
23use crate::sys::path::maybe_verbatim;
18use crate::{fmt, ptr, slice, thread};
2419
2520pub struct File {
2621 handle: Handle,
library/std/src/sys/pal/windows/futex.rs+4-5
......@@ -1,14 +1,13 @@
1use super::api::{self, WinError};
2use crate::sys::c;
3use crate::sys::dur2timeout;
41use core::ffi::c_void;
5use core::mem;
6use core::ptr;
72use core::sync::atomic::{
83 AtomicBool, AtomicI16, AtomicI32, AtomicI64, AtomicI8, AtomicIsize, AtomicPtr, AtomicU16,
94 AtomicU32, AtomicU64, AtomicU8, AtomicUsize,
105};
116use core::time::Duration;
7use core::{mem, ptr};
8
9use super::api::{self, WinError};
10use crate::sys::{c, dur2timeout};
1211
1312/// An atomic for use as a futex that is at least 8-bits but may be larger.
1413pub type SmallAtomic = AtomicU8;
library/std/src/sys/pal/windows/handle.rs+4-6
......@@ -3,17 +3,15 @@
33#[cfg(test)]
44mod tests;
55
6use core::ffi::c_void;
7use core::{cmp, mem, ptr};
8
69use crate::io::{self, BorrowedCursor, ErrorKind, IoSlice, IoSliceMut, Read};
710use crate::os::windows::io::{
811 AsHandle, AsRawHandle, BorrowedHandle, FromRawHandle, IntoRawHandle, OwnedHandle, RawHandle,
912};
10use crate::sys::c;
11use crate::sys::cvt;
13use crate::sys::{c, cvt};
1214use crate::sys_common::{AsInner, FromInner, IntoInner};
13use core::cmp;
14use core::ffi::c_void;
15use core::mem;
16use core::ptr;
1715
1816/// An owned container for `HANDLE` object, closing them on Drop.
1917///
library/std/src/sys/pal/windows/io.rs+2-1
......@@ -1,9 +1,10 @@
1use core::ffi::c_void;
2
13use crate::marker::PhantomData;
24use crate::mem::size_of;
35use crate::os::windows::io::{AsHandle, AsRawHandle, BorrowedHandle};
46use crate::slice;
57use crate::sys::c;
6use core::ffi::c_void;
78
89#[derive(Copy, Clone)]
910#[repr(transparent)]
library/std/src/sys/pal/windows/mod.rs+1-2
......@@ -1,6 +1,7 @@
11#![allow(missing_docs, nonstandard_style)]
22#![forbid(unsafe_op_in_unsafe_fn)]
33
4pub use self::rand::hashmap_random_keys;
45use crate::ffi::{OsStr, OsString};
56use crate::io::ErrorKind;
67use crate::mem::MaybeUninit;
......@@ -9,8 +10,6 @@ use crate::path::PathBuf;
910use crate::sys::pal::windows::api::wide_str;
1011use crate::time::Duration;
1112
12pub use self::rand::hashmap_random_keys;
13
1413#[macro_use]
1514pub mod compat;
1615
library/std/src/sys/pal/windows/net.rs+5-9
......@@ -1,21 +1,17 @@
11#![unstable(issue = "none", feature = "windows_net")]
22
3use crate::cmp;
3use core::ffi::{c_int, c_long, c_ulong, c_ushort};
4
45use crate::io::{self, BorrowedBuf, BorrowedCursor, IoSlice, IoSliceMut, Read};
5use crate::mem;
66use crate::net::{Shutdown, SocketAddr};
77use crate::os::windows::io::{
88 AsRawSocket, AsSocket, BorrowedSocket, FromRawSocket, IntoRawSocket, OwnedSocket, RawSocket,
99};
10use crate::ptr;
1110use crate::sync::OnceLock;
12use crate::sys;
1311use crate::sys::c;
14use crate::sys_common::net;
15use crate::sys_common::{AsInner, FromInner, IntoInner};
12use crate::sys_common::{net, AsInner, FromInner, IntoInner};
1613use crate::time::Duration;
17
18use core::ffi::{c_int, c_long, c_ulong, c_ushort};
14use crate::{cmp, mem, ptr, sys};
1915
2016#[allow(non_camel_case_types)]
2117pub type wrlen_t = i32;
......@@ -25,9 +21,9 @@ pub mod netc {
2521 //!
2622 //! Some Windows API types are not quite what's expected by our cross-platform
2723 //! net code. E.g. naming differences or different pointer types.
28 use crate::sys::c::{self, ADDRESS_FAMILY, ADDRINFOA, SOCKADDR, SOCKET};
2924 use core::ffi::{c_char, c_int, c_uint, c_ulong, c_ushort, c_void};
3025
26 use crate::sys::c::{self, ADDRESS_FAMILY, ADDRINFOA, SOCKADDR, SOCKET};
3127 // re-exports from Windows API bindings.
3228 pub use crate::sys::c::{
3329 bind, connect, freeaddrinfo, getpeername, getsockname, getsockopt, listen, setsockopt,
library/std/src/sys/pal/windows/os.rs+4-9
......@@ -5,20 +5,15 @@
55#[cfg(test)]
66mod tests;
77
8use crate::os::windows::prelude::*;
9
8use super::api::{self, WinError};
9use super::to_u16s;
1010use crate::error::Error as StdError;
1111use crate::ffi::{OsStr, OsString};
12use crate::fmt;
13use crate::io;
1412use crate::os::windows::ffi::EncodeWide;
13use crate::os::windows::prelude::*;
1514use crate::path::{self, PathBuf};
16use crate::ptr;
17use crate::slice;
1815use crate::sys::{c, cvt};
19
20use super::api::{self, WinError};
21use super::to_u16s;
16use crate::{fmt, io, ptr, slice};
2217
2318pub fn errno() -> i32 {
2419 api::get_last_error().code as i32
library/std/src/sys/pal/windows/pipe.rs+3-6
......@@ -1,18 +1,15 @@
1use crate::os::windows::prelude::*;
2
31use crate::ffi::OsStr;
42use crate::io::{self, BorrowedCursor, IoSlice, IoSliceMut};
5use crate::mem;
3use crate::os::windows::prelude::*;
64use crate::path::Path;
7use crate::ptr;
85use crate::sync::atomic::AtomicUsize;
96use crate::sync::atomic::Ordering::Relaxed;
10use crate::sys::c;
117use crate::sys::fs::{File, OpenOptions};
128use crate::sys::handle::Handle;
13use crate::sys::hashmap_random_keys;
149use crate::sys::pal::windows::api::{self, WinError};
10use crate::sys::{c, hashmap_random_keys};
1511use crate::sys_common::{FromInner, IntoInner};
12use crate::{mem, ptr};
1613
1714////////////////////////////////////////////////////////////////////////////////
1815// Anonymous pipes
library/std/src/sys/pal/windows/process.rs+5-12
......@@ -3,35 +3,28 @@
33#[cfg(test)]
44mod tests;
55
6use crate::cmp;
6use core::ffi::c_void;
7
8use super::api::{self, WinError};
79use crate::collections::BTreeMap;
8use crate::env;
910use crate::env::consts::{EXE_EXTENSION, EXE_SUFFIX};
1011use crate::ffi::{OsStr, OsString};
11use crate::fmt;
1212use crate::io::{self, Error, ErrorKind};
13use crate::mem;
1413use crate::mem::MaybeUninit;
1514use crate::num::NonZero;
1615use crate::os::windows::ffi::{OsStrExt, OsStringExt};
1716use crate::os::windows::io::{AsHandle, AsRawHandle, BorrowedHandle, FromRawHandle, IntoRawHandle};
1817use crate::path::{Path, PathBuf};
19use crate::ptr;
2018use crate::sync::Mutex;
2119use crate::sys::args::{self, Arg};
2220use crate::sys::c::{self, EXIT_FAILURE, EXIT_SUCCESS};
23use crate::sys::cvt;
2421use crate::sys::fs::{File, OpenOptions};
2522use crate::sys::handle::Handle;
26use crate::sys::path;
2723use crate::sys::pipe::{self, AnonPipe};
28use crate::sys::stdio;
24use crate::sys::{cvt, path, stdio};
2925use crate::sys_common::process::{CommandEnv, CommandEnvs};
3026use crate::sys_common::IntoInner;
31
32use core::ffi::c_void;
33
34use super::api::{self, WinError};
27use crate::{cmp, env, fmt, mem, ptr};
3528
3629////////////////////////////////////////////////////////////////////////////////
3730// Command
library/std/src/sys/pal/windows/process/tests.rs+1-2
......@@ -1,5 +1,4 @@
1use super::make_command_line;
2use super::Arg;
1use super::{make_command_line, Arg};
32use crate::env;
43use crate::ffi::{OsStr, OsString};
54use crate::process::Command;
library/std/src/sys/pal/windows/stdio.rs+4-7
......@@ -1,16 +1,13 @@
11#![unstable(issue = "none", feature = "windows_stdio")]
22
3use core::str::utf8_char_width;
4
35use super::api::{self, WinError};
4use crate::cmp;
5use crate::io;
66use crate::mem::MaybeUninit;
77use crate::os::windows::io::{FromRawHandle, IntoRawHandle};
8use crate::ptr;
9use crate::str;
10use crate::sys::c;
11use crate::sys::cvt;
128use crate::sys::handle::Handle;
13use core::str::utf8_char_width;
9use crate::sys::{c, cvt};
10use crate::{cmp, io, ptr, str};
1411
1512#[cfg(test)]
1613mod tests;
library/std/src/sys/pal/windows/thread.rs+7-10
......@@ -1,18 +1,15 @@
1use core::ffi::c_void;
2
3use super::time::WaitableTimer;
4use super::to_u16s;
15use crate::ffi::CStr;
2use crate::io;
36use crate::num::NonZero;
4use crate::os::windows::io::AsRawHandle;
5use crate::os::windows::io::HandleOrNull;
6use crate::ptr;
7use crate::sys::c;
7use crate::os::windows::io::{AsRawHandle, HandleOrNull};
88use crate::sys::handle::Handle;
9use crate::sys::stack_overflow;
9use crate::sys::{c, stack_overflow};
1010use crate::sys_common::FromInner;
1111use crate::time::Duration;
12use core::ffi::c_void;
13
14use super::time::WaitableTimer;
15use super::to_u16s;
12use crate::{io, ptr};
1613
1714pub const DEFAULT_MIN_STACK_SIZE: usize = 2 * 1024 * 1024;
1815
library/std/src/sys/pal/windows/time.rs+5-7
......@@ -1,13 +1,12 @@
1use core::hash::{Hash, Hasher};
2use core::ops::Neg;
3
14use crate::cmp::Ordering;
2use crate::fmt;
3use crate::mem;
45use crate::ptr::null;
56use crate::sys::c;
67use crate::sys_common::IntoInner;
78use crate::time::Duration;
8
9use core::hash::{Hash, Hasher};
10use core::ops::Neg;
9use crate::{fmt, mem};
1110
1211const NANOS_PER_SEC: u64 = 1_000_000_000;
1312const INTERVALS_PER_SEC: u64 = NANOS_PER_SEC / 100;
......@@ -166,8 +165,7 @@ fn intervals2dur(intervals: u64) -> Duration {
166165mod perf_counter {
167166 use super::NANOS_PER_SEC;
168167 use crate::sync::atomic::{AtomicU64, Ordering};
169 use crate::sys::c;
170 use crate::sys::cvt;
168 use crate::sys::{c, cvt};
171169 use crate::sys_common::mul_div_u64;
172170 use crate::time::Duration;
173171
library/std/src/sys/pal/xous/alloc.rs+2-4
......@@ -46,10 +46,8 @@ unsafe impl GlobalAlloc for System {
4646}
4747
4848mod 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};
5351
5452 static LOCKED: AtomicI32 = AtomicI32::new(0);
5553
library/std/src/sys/pal/xous/net/dns.rs+2-1
......@@ -1,8 +1,9 @@
1use core::convert::{TryFrom, TryInto};
2
13use crate::io;
24use crate::net::{Ipv4Addr, SocketAddr, SocketAddrV4, SocketAddrV6};
35use crate::os::xous::ffi::lend_mut;
46use crate::os::xous::services::{dns_server, DnsLendMut};
5use core::convert::{TryFrom, TryInto};
67
78pub struct DnsError {
89 pub code: u8,
library/std/src/sys/pal/xous/net/tcplistener.rs+4-4
......@@ -1,11 +1,11 @@
1use core::convert::TryInto;
2use core::sync::atomic::{AtomicBool, AtomicU16, AtomicUsize, Ordering};
3
14use super::*;
2use crate::fmt;
3use crate::io;
45use crate::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr};
56use crate::os::xous::services;
67use crate::sync::Arc;
7use core::convert::TryInto;
8use core::sync::atomic::{AtomicBool, AtomicU16, AtomicUsize, Ordering};
8use crate::{fmt, io};
99
1010macro_rules! unimpl {
1111 () => {
library/std/src/sys/pal/xous/net/tcpstream.rs+2-1
......@@ -1,3 +1,5 @@
1use core::sync::atomic::{AtomicBool, AtomicU32, AtomicUsize, Ordering};
2
13use super::*;
24use crate::fmt;
35use crate::io::{self, BorrowedCursor, IoSlice, IoSliceMut};
......@@ -5,7 +7,6 @@ use crate::net::{IpAddr, Ipv4Addr, Shutdown, SocketAddr, SocketAddrV4, SocketAdd
57use crate::os::xous::services;
68use crate::sync::Arc;
79use crate::time::Duration;
8use core::sync::atomic::{AtomicBool, AtomicU32, AtomicUsize, Ordering};
910
1011macro_rules! unimpl {
1112 () => {
library/std/src/sys/pal/xous/net/udp.rs+4-4
......@@ -1,13 +1,13 @@
1use core::convert::TryInto;
2use core::sync::atomic::{AtomicUsize, Ordering};
3
14use super::*;
25use crate::cell::Cell;
3use crate::fmt;
4use crate::io;
56use crate::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr};
67use crate::os::xous::services;
78use crate::sync::Arc;
89use crate::time::Duration;
9use core::convert::TryInto;
10use core::sync::atomic::{AtomicUsize, Ordering};
10use crate::{fmt, io};
1111
1212macro_rules! unimpl {
1313 () => {
library/std/src/sys/pal/xous/os.rs+1-2
......@@ -1,11 +1,10 @@
11use super::unsupported;
22use crate::error::Error as StdError;
33use crate::ffi::{OsStr, OsString};
4use crate::fmt;
5use crate::io;
64use crate::marker::PhantomData;
75use crate::os::xous::ffi::Error as XousError;
86use crate::path::{self, PathBuf};
7use crate::{fmt, io};
98
109#[cfg(not(test))]
1110#[cfg(feature = "panic_unwind")]
library/std/src/sys/pal/xous/thread.rs+2-1
......@@ -1,3 +1,5 @@
1use core::arch::asm;
2
13use crate::ffi::CStr;
24use crate::io;
35use crate::num::NonZero;
......@@ -7,7 +9,6 @@ use crate::os::xous::ffi::{
79};
810use crate::os::xous::services::{ticktimer_server, TicktimerScalar};
911use crate::time::Duration;
10use core::arch::asm;
1112
1213pub struct Thread {
1314 tid: ThreadId,
library/std/src/sys/pal/xous/time.rs+3-3
......@@ -1,7 +1,7 @@
11use crate::os::xous::ffi::blocking_scalar;
2use crate::os::xous::services::{
3 systime_server, ticktimer_server, SystimeScalar::GetUtcTimeMs, TicktimerScalar::ElapsedMs,
4};
2use crate::os::xous::services::SystimeScalar::GetUtcTimeMs;
3use crate::os::xous::services::TicktimerScalar::ElapsedMs;
4use crate::os::xous::services::{systime_server, ticktimer_server};
55use crate::time::Duration;
66
77#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
library/std/src/sys/pal/zkvm/os.rs+1-2
......@@ -1,12 +1,11 @@
11use super::{abi, unsupported, WORD_SIZE};
22use crate::error::Error as StdError;
33use crate::ffi::{OsStr, OsString};
4use crate::fmt;
5use crate::io;
64use crate::marker::PhantomData;
75use crate::path::{self, PathBuf};
86use crate::sys::os_str;
97use crate::sys_common::FromInner;
8use crate::{fmt, io};
109
1110pub fn errno() -> i32 {
1211 0
library/std/src/sys/pal/zkvm/stdio.rs+2-1
......@@ -1,4 +1,5 @@
1use super::{abi, abi::fileno};
1use super::abi;
2use super::abi::fileno;
23use crate::io;
34
45pub struct Stdin;
library/std/src/sys/path/unix.rs+1-2
......@@ -1,7 +1,6 @@
1use crate::env;
21use crate::ffi::OsStr;
3use crate::io;
42use crate::path::{Path, PathBuf, Prefix};
3use crate::{env, io};
54
65#[inline]
76pub fn is_sep_byte(b: u8) -> bool {
library/std/src/sys/path/windows.rs+1-2
......@@ -1,8 +1,7 @@
11use crate::ffi::{OsStr, OsString};
2use crate::io;
32use crate::path::{Path, PathBuf, Prefix};
4use crate::ptr;
53use crate::sys::pal::{c, fill_utf16_buf, os2path, to_u16s};
4use crate::{io, ptr};
65
76#[cfg(test)]
87mod tests;
library/std/src/sys/personality/dwarf/eh.rs+2-2
......@@ -12,9 +12,9 @@
1212#![allow(non_upper_case_globals)]
1313#![allow(unused)]
1414
15use core::{mem, ptr};
16
1517use super::DwarfReader;
16use core::mem;
17use core::ptr;
1818
1919pub const DW_EH_PE_omit: u8 = 0xFF;
2020pub const DW_EH_PE_absptr: u8 = 0x00;
library/std/src/sys/personality/emcc.rs+2-1
......@@ -1,9 +1,10 @@
11//! On Emscripten Rust panics are wrapped in C++ exceptions, so we just forward
22//! to `__gxx_personality_v0` which is provided by Emscripten.
33
4use crate::ffi::c_int;
54use unwind as uw;
65
6use crate::ffi::c_int;
7
78// This is required by the compiler to exist (e.g., it's a lang item), but it's
89// never actually called by the compiler. Emscripten EH doesn't use a
910// personality function at all, it instead uses __cxa_find_matching_catch.
library/std/src/sys/personality/gcc.rs+2-1
......@@ -37,9 +37,10 @@
3737//! and the last personality routine transfers control to the catch block.
3838#![forbid(unsafe_op_in_unsafe_fn)]
3939
40use unwind as uw;
41
4042use super::dwarf::eh::{self, EHAction, EHContext};
4143use crate::ffi::c_int;
42use unwind as uw;
4344
4445// Register ids were lifted from LLVM's TargetLowering::getExceptionPointerRegister()
4546// and TargetLowering::getExceptionSelectorRegister() for each architecture,
library/std/src/sys/sync/condvar/futex.rs+2-1
......@@ -1,4 +1,5 @@
1use crate::sync::atomic::{AtomicU32, Ordering::Relaxed};
1use crate::sync::atomic::AtomicU32;
2use crate::sync::atomic::Ordering::Relaxed;
23use crate::sys::futex::{futex_wait, futex_wake, futex_wake_all};
34use crate::sys::sync::Mutex;
45use crate::time::Duration;
library/std/src/sys/sync/condvar/itron.rs+8-4
......@@ -1,9 +1,13 @@
11//! POSIX conditional variable implementation based on user-space wait queues.
22
3use crate::sys::pal::itron::{
4 abi, error::expect_success_aborting, spin::SpinMutex, task, time::with_tmos_strong,
5};
6use crate::{mem::replace, ptr::NonNull, sys::sync::Mutex, time::Duration};
3use crate::mem::replace;
4use crate::ptr::NonNull;
5use crate::sys::pal::itron::error::expect_success_aborting;
6use crate::sys::pal::itron::spin::SpinMutex;
7use crate::sys::pal::itron::time::with_tmos_strong;
8use crate::sys::pal::itron::{abi, task};
9use crate::sys::sync::Mutex;
10use crate::time::Duration;
711
812// The implementation is inspired by the queue-based implementation shown in
913// Andrew D. Birrell's paper "Implementing Condition Variables with Semaphores"
library/std/src/sys/sync/condvar/pthread.rs+2-1
......@@ -1,6 +1,7 @@
11use crate::cell::UnsafeCell;
22use crate::ptr;
3use crate::sync::atomic::{AtomicPtr, Ordering::Relaxed};
3use crate::sync::atomic::AtomicPtr;
4use crate::sync::atomic::Ordering::Relaxed;
45use crate::sys::sync::{mutex, Mutex};
56#[cfg(not(target_os = "nto"))]
67use crate::sys::time::TIMESPEC_MAX;
library/std/src/sys/sync/condvar/teeos.rs+2-1
......@@ -1,6 +1,7 @@
11use crate::cell::UnsafeCell;
22use crate::ptr;
3use crate::sync::atomic::{AtomicPtr, Ordering::Relaxed};
3use crate::sync::atomic::AtomicPtr;
4use crate::sync::atomic::Ordering::Relaxed;
45use crate::sys::sync::mutex::{self, Mutex};
56use crate::sys::time::TIMESPEC_MAX;
67use crate::sys_common::lazy_box::{LazyBox, LazyInit};
library/std/src/sys/sync/condvar/windows7.rs+1-2
......@@ -1,7 +1,6 @@
11use crate::cell::UnsafeCell;
2use crate::sys::c;
3use crate::sys::os;
42use crate::sys::sync::{mutex, Mutex};
3use crate::sys::{c, os};
54use crate::time::Duration;
65
76pub struct Condvar {
library/std/src/sys/sync/condvar/xous.rs+2-1
......@@ -1,8 +1,9 @@
1use core::sync::atomic::{AtomicUsize, Ordering};
2
13use crate::os::xous::ffi::{blocking_scalar, scalar};
24use crate::os::xous::services::{ticktimer_server, TicktimerScalar};
35use crate::sys::sync::Mutex;
46use crate::time::Duration;
5use core::sync::atomic::{AtomicUsize, Ordering};
67
78// The implementation is inspired by Andrew D. Birrell's paper
89// "Implementing Condition Variables with Semaphores"
library/std/src/sys/sync/mutex/fuchsia.rs+2-4
......@@ -37,10 +37,8 @@
3737//!
3838//! [mutex in Fuchsia's libsync]: https://cs.opensource.google/fuchsia/fuchsia/+/main:zircon/system/ulib/sync/mutex.c
3939
40use crate::sync::atomic::{
41 AtomicU32,
42 Ordering::{Acquire, Relaxed, Release},
43};
40use crate::sync::atomic::AtomicU32;
41use crate::sync::atomic::Ordering::{Acquire, Relaxed, Release};
4442use crate::sys::futex::zircon::{
4543 zx_futex_wait, zx_futex_wake_single_owner, zx_handle_t, zx_thread_self, ZX_ERR_BAD_HANDLE,
4644 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 @@
22//! `TA_INHERIT` are available.
33#![forbid(unsafe_op_in_unsafe_fn)]
44
5use crate::sys::pal::itron::{
6 abi,
7 error::{expect_success, expect_success_aborting, fail, ItronError},
8 spin::SpinIdOnceCell,
9};
5use crate::sys::pal::itron::abi;
6use crate::sys::pal::itron::error::{expect_success, expect_success_aborting, fail, ItronError};
7use crate::sys::pal::itron::spin::SpinIdOnceCell;
108
119pub struct Mutex {
1210 /// The ID of the underlying mutex object
library/std/src/sys/sync/mutex/xous.rs+2-4
......@@ -1,9 +1,7 @@
11use crate::os::xous::ffi::{blocking_scalar, do_yield};
22use crate::os::xous::services::{ticktimer_server, TicktimerScalar};
3use crate::sync::atomic::{
4 AtomicBool, AtomicUsize,
5 Ordering::{Acquire, Relaxed, Release},
6};
3use crate::sync::atomic::Ordering::{Acquire, Relaxed, Release};
4use crate::sync::atomic::{AtomicBool, AtomicUsize};
75
86pub struct Mutex {
97 /// 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 @@
11use crate::cell::Cell;
22use crate::sync as public;
3use crate::sync::atomic::{
4 AtomicU32,
5 Ordering::{Acquire, Relaxed, Release},
6};
3use crate::sync::atomic::AtomicU32;
4use crate::sync::atomic::Ordering::{Acquire, Relaxed, Release};
75use crate::sync::once::ExclusiveState;
86use crate::sys::futex::{futex_wait, futex_wake_all};
97
library/std/src/sys/sync/once/queue.rs+1-3
......@@ -56,12 +56,10 @@
5656// allowed, so no need for `SeqCst`.
5757
5858use crate::cell::Cell;
59use crate::fmt;
60use crate::ptr;
61use crate::sync as public;
6259use crate::sync::atomic::{AtomicBool, AtomicPtr, Ordering};
6360use crate::sync::once::ExclusiveState;
6461use crate::thread::{self, Thread};
62use crate::{fmt, ptr, sync as public};
6563
6664type Masked = ();
6765
library/std/src/sys/sync/rwlock/futex.rs+2-4
......@@ -1,7 +1,5 @@
1use crate::sync::atomic::{
2 AtomicU32,
3 Ordering::{Acquire, Relaxed, Release},
4};
1use crate::sync::atomic::AtomicU32;
2use crate::sync::atomic::Ordering::{Acquire, Relaxed, Release};
53use crate::sys::futex::{futex_wait, futex_wake, futex_wake_all};
64
75pub struct RwLock {
library/std/src/sys/sync/rwlock/queue.rs+2-4
......@@ -111,10 +111,8 @@ use crate::cell::OnceCell;
111111use crate::hint::spin_loop;
112112use crate::mem;
113113use crate::ptr::{self, null_mut, without_provenance_mut, NonNull};
114use crate::sync::atomic::{
115 AtomicBool, AtomicPtr,
116 Ordering::{AcqRel, Acquire, Relaxed, Release},
117};
114use crate::sync::atomic::Ordering::{AcqRel, Acquire, Relaxed, Release};
115use crate::sync::atomic::{AtomicBool, AtomicPtr};
118116use crate::thread::{self, Thread};
119117
120118// 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 @@
11//! A readers-writer lock implementation backed by the SOLID kernel extension.
22#![forbid(unsafe_op_in_unsafe_fn)]
33
4use crate::sys::pal::{
5 abi,
6 itron::{
7 error::{expect_success, expect_success_aborting, fail, ItronError},
8 spin::SpinIdOnceCell,
9 },
10};
4use crate::sys::pal::abi;
5use crate::sys::pal::itron::error::{expect_success, expect_success_aborting, fail, ItronError};
6use crate::sys::pal::itron::spin::SpinIdOnceCell;
117
128pub struct RwLock {
139 /// The ID of the underlying mutex object
library/std/src/sys/sync/thread_parking/darwin.rs+2-4
......@@ -13,10 +13,8 @@
1313#![allow(non_camel_case_types)]
1414
1515use crate::pin::Pin;
16use crate::sync::atomic::{
17 AtomicI8,
18 Ordering::{Acquire, Release},
19};
16use crate::sync::atomic::AtomicI8;
17use crate::sync::atomic::Ordering::{Acquire, Release};
2018use crate::time::Duration;
2119
2220type dispatch_semaphore_t = *mut crate::ffi::c_void;
library/std/src/sys/sync/thread_parking/id.rs+2-4
......@@ -9,10 +9,8 @@
99
1010use crate::cell::UnsafeCell;
1111use crate::pin::Pin;
12use crate::sync::atomic::{
13 fence, AtomicI8,
14 Ordering::{Acquire, Relaxed, Release},
15};
12use crate::sync::atomic::Ordering::{Acquire, Relaxed, Release};
13use crate::sync::atomic::{fence, AtomicI8};
1614use crate::sys::thread_parking::{current, park, park_timeout, unpark, ThreadId};
1715use crate::time::Duration;
1816
library/std/src/sys/sync/thread_parking/windows7.rs+9-11
......@@ -57,14 +57,13 @@
5757// [3]: https://docs.microsoft.com/en-us/archive/msdn-magazine/2012/november/windows-with-c-the-evolution-of-synchronization-in-windows-and-c
5858// [4]: Windows Internals, Part 1, ISBN 9780735671300
5959
60use core::ffi::c_void;
61
6062use crate::pin::Pin;
61use crate::sync::atomic::{
62 AtomicI8,
63 Ordering::{Acquire, Release},
64};
63use crate::sync::atomic::AtomicI8;
64use crate::sync::atomic::Ordering::{Acquire, Release};
6565use crate::sys::{c, dur2timeout};
6666use crate::time::Duration;
67use core::ffi::c_void;
6867
6968pub struct Parker {
7069 state: AtomicI8,
......@@ -185,16 +184,15 @@ impl Parker {
185184
186185#[cfg(target_vendor = "win7")]
187186mod keyed_events {
188 use super::{Parker, EMPTY, NOTIFIED};
189 use crate::sys::c;
190187 use core::pin::Pin;
191188 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};
196191 use core::time::Duration;
197192
193 use super::{Parker, EMPTY, NOTIFIED};
194 use crate::sys::c;
195
198196 pub unsafe fn park(parker: Pin<&Parker>) {
199197 // Wait for unpark() to produce this event.
200198 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};
22use crate::os::xous::services::{ticktimer_server, TicktimerScalar};
33use crate::pin::Pin;
44use crate::ptr;
5use crate::sync::atomic::{
6 AtomicI8,
7 Ordering::{Acquire, Release},
8};
5use crate::sync::atomic::AtomicI8;
6use crate::sync::atomic::Ordering::{Acquire, Release};
97use crate::time::Duration;
108
119const NOTIFIED: i8 = 1;
library/std/src/sys/thread_local/guard/solid.rs+2-1
......@@ -3,7 +3,8 @@
33//! destructors for terminated tasks, we still keep our own list.
44
55use crate::cell::Cell;
6use crate::sys::pal::{abi, itron::task};
6use crate::sys::pal::abi;
7use crate::sys::pal::itron::task;
78use crate::sys::thread_local::destructors;
89
910pub fn enable() {
library/std/src/sys/thread_local/guard/windows.rs+2-1
......@@ -63,9 +63,10 @@
6363//! [1]: https://www.codeproject.com/Articles/8113/Thread-Local-Storage-The-C-Way
6464//! [2]: https://github.com/ChromiumWebApps/chromium/blob/master/base/threading/thread_local_storage_win.cc#L42
6565
66use core::ffi::c_void;
67
6668use crate::ptr;
6769use crate::sys::c;
68use core::ffi::c_void;
6970
7071pub fn enable() {
7172 // 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 @@
2626
2727use crate::cell::UnsafeCell;
2828use crate::ptr;
29use crate::sync::atomic::{
30 AtomicPtr, AtomicU32,
31 Ordering::{AcqRel, Acquire, Relaxed, Release},
32};
29use crate::sync::atomic::Ordering::{AcqRel, Acquire, Relaxed, Release};
30use crate::sync::atomic::{AtomicPtr, AtomicU32};
3331use crate::sys::c;
3432use crate::sys::thread_local::guard;
3533
library/std/src/sys/thread_local/key/xous.rs+4-5
......@@ -36,14 +36,13 @@
3636
3737// FIXME(joboet): implement support for native TLS instead.
3838
39use crate::mem::ManuallyDrop;
40use crate::ptr;
41use crate::sync::atomic::AtomicPtr;
42use crate::sync::atomic::AtomicUsize;
43use crate::sync::atomic::Ordering::{Acquire, Relaxed, Release};
4439use core::arch::asm;
4540
41use crate::mem::ManuallyDrop;
4642use crate::os::xous::ffi::{map_memory, unmap_memory, MemoryFlags};
43use crate::ptr;
44use crate::sync::atomic::Ordering::{Acquire, Relaxed, Release};
45use crate::sync::atomic::{AtomicPtr, AtomicUsize};
4746
4847pub type Key = usize;
4948pub type Dtor = unsafe extern "C" fn(*mut u8);
library/std/src/sys/thread_local/native/eager.rs+1-2
......@@ -1,7 +1,6 @@
11use crate::cell::{Cell, UnsafeCell};
22use crate::ptr::{self, drop_in_place};
3use crate::sys::thread_local::abort_on_dtor_unwind;
4use crate::sys::thread_local::destructors;
3use crate::sys::thread_local::{abort_on_dtor_unwind, destructors};
54
65#[derive(Clone, Copy)]
76enum State {
library/std/src/sys/thread_local/native/lazy.rs+1-2
......@@ -1,8 +1,7 @@
11use crate::cell::UnsafeCell;
22use crate::hint::unreachable_unchecked;
33use crate::ptr;
4use crate::sys::thread_local::abort_on_dtor_unwind;
5use crate::sys::thread_local::destructors;
4use crate::sys::thread_local::{abort_on_dtor_unwind, destructors};
65
76pub unsafe trait DestroyedState: Sized {
87 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 {
55#[cfg(test)]
66#[allow(dead_code)] // not used on emscripten
77pub mod test {
8 use crate::env;
9 use crate::fs;
10 use crate::path::{Path, PathBuf};
11 use crate::thread;
128 use rand::RngCore;
139
10 use crate::path::{Path, PathBuf};
11 use crate::{env, fs, thread};
12
1413 pub struct TempDir(PathBuf);
1514
1615 impl TempDir {
library/std/src/sys_common/lazy_box.rs+2-4
......@@ -5,10 +5,8 @@
55use crate::marker::PhantomData;
66use crate::ops::{Deref, DerefMut};
77use crate::ptr::null_mut;
8use crate::sync::atomic::{
9 AtomicPtr,
10 Ordering::{AcqRel, Acquire},
11};
8use crate::sync::atomic::AtomicPtr;
9use crate::sync::atomic::Ordering::{AcqRel, Acquire};
1210
1311pub(crate) struct LazyBox<T: LazyInit> {
1412 ptr: AtomicPtr<T>,
library/std/src/sys_common/net.rs+3-8
......@@ -1,19 +1,14 @@
11#[cfg(test)]
22mod tests;
33
4use crate::cmp;
5use crate::fmt;
4use crate::ffi::{c_int, c_void};
65use crate::io::{self, BorrowedCursor, ErrorKind, IoSlice, IoSliceMut};
7use crate::mem;
86use crate::net::{Ipv4Addr, Ipv6Addr, Shutdown, SocketAddr};
9use crate::ptr;
107use crate::sys::common::small_c_string::run_with_cstr;
11use crate::sys::net::netc as c;
12use crate::sys::net::{cvt, cvt_gai, cvt_r, init, wrlen_t, Socket};
8use crate::sys::net::{cvt, cvt_gai, cvt_r, init, netc as c, wrlen_t, Socket};
139use crate::sys_common::{AsInner, FromInner, IntoInner};
1410use crate::time::Duration;
15
16use crate::ffi::{c_int, c_void};
11use crate::{cmp, fmt, mem, ptr};
1712
1813cfg_if::cfg_if! {
1914 if #[cfg(any(
library/std/src/sys_common/process.rs+1-3
......@@ -2,12 +2,10 @@
22#![unstable(feature = "process_internals", issue = "none")]
33
44use crate::collections::BTreeMap;
5use crate::env;
65use crate::ffi::{OsStr, OsString};
7use crate::fmt;
8use crate::io;
96use crate::sys::pipe::read2;
107use crate::sys::process::{EnvKey, ExitStatus, Process, StdioPipes};
8use crate::{env, fmt, io};
119
1210// Stores a set of changes to an environment
1311#[derive(Clone)]
library/std/src/sys_common/wtf8.rs+1-5
......@@ -23,16 +23,12 @@ use core::str::next_code_point;
2323
2424use crate::borrow::Cow;
2525use crate::collections::TryReserveError;
26use crate::fmt;
2726use crate::hash::{Hash, Hasher};
2827use crate::iter::FusedIterator;
29use crate::mem;
30use crate::ops;
3128use crate::rc::Rc;
32use crate::slice;
33use crate::str;
3429use crate::sync::Arc;
3530use crate::sys_common::AsInner;
31use crate::{fmt, mem, ops, slice, str};
3632
3733const UTF8_REPLACEMENT_CHARACTER: &str = "\u{FFFD}";
3834
library/std/src/thread/mod.rs+3-7
......@@ -160,24 +160,19 @@ mod tests;
160160
161161use crate::any::Any;
162162use crate::cell::{Cell, OnceCell, UnsafeCell};
163use crate::env;
164163use crate::ffi::CStr;
165use crate::fmt;
166use crate::io;
167164use crate::marker::PhantomData;
168165use crate::mem::{self, forget, ManuallyDrop};
169166use crate::num::NonZero;
170use crate::panic;
171use crate::panicking;
172167use crate::pin::Pin;
173168use crate::ptr::addr_of_mut;
174use crate::str;
175169use crate::sync::atomic::{AtomicUsize, Ordering};
176170use crate::sync::Arc;
177171use crate::sys::sync::Parker;
178172use crate::sys::thread as imp;
179173use crate::sys_common::{AsInner, IntoInner};
180174use crate::time::{Duration, Instant};
175use crate::{env, fmt, io, panic, panicking, str};
181176
182177#[stable(feature = "scoped_threads", since = "1.63.0")]
183178mod scoped;
......@@ -1292,9 +1287,10 @@ enum ThreadName {
12921287
12931288// This module ensures private fields are kept private, which is necessary to enforce the safety requirements.
12941289mod thread_name_string {
1290 use core::str;
1291
12951292 use super::ThreadName;
12961293 use crate::ffi::{CStr, CString};
1297 use core::str;
12981294
12991295 /// Like a `String` it's guaranteed UTF-8 and like a `CString` it's null terminated.
13001296 pub(crate) struct ThreadNameString {
library/std/src/thread/scoped.rs+1-2
......@@ -1,10 +1,9 @@
11use super::{current, park, Builder, JoinInner, Result, Thread};
2use crate::fmt;
3use crate::io;
42use crate::marker::PhantomData;
53use crate::panic::{catch_unwind, resume_unwind, AssertUnwindSafe};
64use crate::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
75use crate::sync::Arc;
6use crate::{fmt, io};
87
98/// A scope to spawn scoped threads in.
109///
library/std/src/thread/tests.rs+5-9
......@@ -1,16 +1,12 @@
11use super::Builder;
22use crate::any::Any;
3use crate::mem;
43use crate::panic::panic_any;
5use crate::result;
6use crate::sync::{
7 atomic::{AtomicBool, Ordering},
8 mpsc::{channel, Sender},
9 Arc, Barrier,
10};
4use crate::sync::atomic::{AtomicBool, Ordering};
5use crate::sync::mpsc::{channel, Sender};
6use crate::sync::{Arc, Barrier};
117use crate::thread::{self, Scope, ThreadId};
12use crate::time::Duration;
13use crate::time::Instant;
8use crate::time::{Duration, Instant};
9use crate::{mem, result};
1410
1511// !!! These tests are dangerous. If something is buggy, they will hang, !!!
1612// !!! instead of exiting cleanly. This might wedge the buildbots. !!!
library/std/src/time.rs+5-6
......@@ -34,18 +34,17 @@
3434#[cfg(test)]
3535mod tests;
3636
37#[stable(feature = "time", since = "1.3.0")]
38pub use core::time::Duration;
39#[stable(feature = "duration_checked_float", since = "1.66.0")]
40pub use core::time::TryFromFloatSecsError;
41
3742use crate::error::Error;
3843use crate::fmt;
3944use crate::ops::{Add, AddAssign, Sub, SubAssign};
4045use crate::sys::time;
4146use crate::sys_common::{FromInner, IntoInner};
4247
43#[stable(feature = "time", since = "1.3.0")]
44pub use core::time::Duration;
45
46#[stable(feature = "duration_checked_float", since = "1.66.0")]
47pub use core::time::TryFromFloatSecsError;
48
4948/// A measurement of a monotonically nondecreasing clock.
5049/// Opaque and useful only with [`Duration`].
5150///
library/std/src/time/tests.rs+3-1
......@@ -1,8 +1,10 @@
1use super::{Duration, Instant, SystemTime, UNIX_EPOCH};
21use core::fmt::Debug;
2
33#[cfg(not(target_arch = "wasm32"))]
44use test::{black_box, Bencher};
55
6use super::{Duration, Instant, SystemTime, UNIX_EPOCH};
7
68macro_rules! assert_almost_eq {
79 ($a:expr, $b:expr) => {{
810 let (a, b) = ($a, $b);
library/std/tests/common/mod.rs+3-4
......@@ -1,10 +1,9 @@
11#![allow(unused)]
22
3use rand::RngCore;
4use std::env;
5use std::fs;
63use std::path::{Path, PathBuf};
7use std::thread;
4use std::{env, fs, thread};
5
6use rand::RngCore;
87
98/// Copied from `std::test_helpers::test_rng`, since these tests rely on the
109/// seed not being the same for every RNG invocation too.
library/std/tests/create_dir_all_bare.rs+1-2
......@@ -3,9 +3,8 @@
33//! Note that this test changes the current directory so
44//! should not be in the same process as other tests.
55
6use std::env;
7use std::fs;
86use std::path::{Path, PathBuf};
7use std::{env, fs};
98
109mod common;
1110
library/std/tests/env.rs+2-1
......@@ -4,9 +4,10 @@ use std::ffi::{OsStr, OsString};
44use rand::distributions::{Alphanumeric, DistString};
55
66mod common;
7use common::test_rng;
87use std::thread;
98
9use common::test_rng;
10
1011#[track_caller]
1112fn make_rand_name() -> OsString {
1213 let n = format!("TEST{}", Alphanumeric.sample_string(&mut test_rng(), 10));
library/std/tests/pipe_subprocess.rs+3-1
......@@ -3,7 +3,9 @@
33fn main() {
44 #[cfg(all(not(miri), any(unix, windows)))]
55 {
6 use std::{env, io::Read, pipe::pipe, process};
6 use std::io::Read;
7 use std::pipe::pipe;
8 use std::{env, process};
79
810 if env::var("I_AM_THE_CHILD").is_ok() {
911 child();
library/std/tests/process_spawning.rs+1-4
......@@ -1,9 +1,6 @@
11#![cfg(not(target_env = "sgx"))]
22
3use std::env;
4use std::fs;
5use std::process;
6use std::str;
3use std::{env, fs, process, str};
74
85mod common;
96
library/std/tests/switch-stdout.rs+2-3
......@@ -5,11 +5,10 @@ use std::io::{Read, Write};
55
66mod common;
77
8#[cfg(windows)]
9use std::os::windows::io::OwnedHandle;
10
118#[cfg(unix)]
129use std::os::fd::OwnedFd;
10#[cfg(windows)]
11use std::os::windows::io::OwnedHandle;
1312
1413#[cfg(unix)]
1514fn switch_stdout_to(file: OwnedFd) -> OwnedFd {
library/std/tests/windows.rs+3-1
......@@ -1,7 +1,9 @@
11#![cfg(windows)]
22//! An external tests
33
4use std::{ffi::OsString, os::windows::ffi::OsStringExt, path::PathBuf};
4use std::ffi::OsString;
5use std::os::windows::ffi::OsStringExt;
6use std::path::PathBuf;
57
68#[test]
79#[should_panic]
library/test/src/bench.rs+8-11
......@@ -1,19 +1,16 @@
11//! Benchmarking module.
22
3use super::{
4 event::CompletedTest,
5 options::BenchMode,
6 test_result::TestResult,
7 types::{TestDesc, TestId},
8 Sender,
9};
10
11use crate::stats;
12use std::cmp;
13use std::io;
143use std::panic::{catch_unwind, AssertUnwindSafe};
154use std::sync::{Arc, Mutex};
165use std::time::{Duration, Instant};
6use std::{cmp, io};
7
8use super::event::CompletedTest;
9use super::options::BenchMode;
10use super::test_result::TestResult;
11use super::types::{TestDesc, TestId};
12use super::Sender;
13use crate::stats;
1714
1815/// An identity function that *__hints__* to the compiler to be maximally pessimistic about what
1916/// `black_box` could do.
library/test/src/cli.rs+1-1
......@@ -1,11 +1,11 @@
11//! Module converting command-line arguments into test configuration.
22
33use std::env;
4use std::io::{self, IsTerminal};
45use std::path::PathBuf;
56
67use super::options::{ColorConfig, Options, OutputFormat, RunIgnored};
78use super::time::TestTimeOptions;
8use std::io::{self, IsTerminal};
99
1010#[derive(Debug)]
1111pub struct TestOpts {
library/test/src/console.rs+12-12
......@@ -5,19 +5,19 @@ use std::io;
55use std::io::prelude::Write;
66use std::time::Instant;
77
8use 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},
8use super::bench::fmt_bench_samples;
9use super::cli::TestOpts;
10use super::event::{CompletedTest, TestEvent};
11use super::formatters::{
12 JsonFormatter, JunitFormatter, OutputFormatter, PrettyFormatter, TerseFormatter,
2013};
14use super::helpers::concurrency::get_concurrency;
15use super::helpers::metrics::MetricMap;
16use super::options::{Options, OutputFormat};
17use super::test_result::TestResult;
18use super::time::{TestExecTime, TestSuiteExecTime};
19use super::types::{NamePadding, TestDesc, TestDescAndFn};
20use super::{filter_tests, run_tests, term};
2121
2222/// Generic wrapper over stdout.
2323pub enum OutputLocation<T> {
library/test/src/formatters/json.rs+7-7
......@@ -1,12 +1,12 @@
1use std::{borrow::Cow, io, io::prelude::Write};
1use std::borrow::Cow;
2use std::io;
3use std::io::prelude::Write;
24
35use super::OutputFormatter;
4use crate::{
5 console::{ConsoleTestDiscoveryState, ConsoleTestState, OutputLocation},
6 test_result::TestResult,
7 time,
8 types::TestDesc,
9};
6use crate::console::{ConsoleTestDiscoveryState, ConsoleTestState, OutputLocation};
7use crate::test_result::TestResult;
8use crate::time;
9use crate::types::TestDesc;
1010
1111pub(crate) struct JsonFormatter<T> {
1212 out: OutputLocation<T>,
library/test/src/formatters/junit.rs+6-7
......@@ -1,13 +1,12 @@
1use std::io::{self, prelude::Write};
1use std::io::prelude::Write;
2use std::io::{self};
23use std::time::Duration;
34
45use super::OutputFormatter;
5use crate::{
6 console::{ConsoleTestDiscoveryState, ConsoleTestState, OutputLocation},
7 test_result::TestResult,
8 time,
9 types::{TestDesc, TestType},
10};
6use crate::console::{ConsoleTestDiscoveryState, ConsoleTestState, OutputLocation};
7use crate::test_result::TestResult;
8use crate::time;
9use crate::types::{TestDesc, TestType};
1110
1211pub struct JunitFormatter<T> {
1312 out: OutputLocation<T>,
library/test/src/formatters/mod.rs+6-7
......@@ -1,11 +1,10 @@
1use std::{io, io::prelude::Write};
1use std::io;
2use std::io::prelude::Write;
23
3use crate::{
4 console::{ConsoleTestDiscoveryState, ConsoleTestState},
5 test_result::TestResult,
6 time,
7 types::{TestDesc, TestName},
8};
4use crate::console::{ConsoleTestDiscoveryState, ConsoleTestState};
5use crate::test_result::TestResult;
6use crate::time;
7use crate::types::{TestDesc, TestName};
98
109mod json;
1110mod junit;
library/test/src/formatters/pretty.rs+7-9
......@@ -1,14 +1,12 @@
1use std::{io, io::prelude::Write};
1use std::io;
2use std::io::prelude::Write;
23
34use super::OutputFormatter;
4use crate::{
5 bench::fmt_bench_samples,
6 console::{ConsoleTestDiscoveryState, ConsoleTestState, OutputLocation},
7 term,
8 test_result::TestResult,
9 time,
10 types::TestDesc,
11};
5use crate::bench::fmt_bench_samples;
6use crate::console::{ConsoleTestDiscoveryState, ConsoleTestState, OutputLocation};
7use crate::test_result::TestResult;
8use crate::types::TestDesc;
9use crate::{term, time};
1210
1311pub(crate) struct PrettyFormatter<T> {
1412 out: OutputLocation<T>,
library/test/src/formatters/terse.rs+7-10
......@@ -1,15 +1,12 @@
1use std::{io, io::prelude::Write};
1use std::io;
2use std::io::prelude::Write;
23
34use super::OutputFormatter;
4use 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};
5use crate::bench::fmt_bench_samples;
6use crate::console::{ConsoleTestDiscoveryState, ConsoleTestState, OutputLocation};
7use crate::test_result::TestResult;
8use crate::types::{NamePadding, TestDesc};
9use crate::{term, time};
1310
1411// We insert a '\n' when the output hits 100 columns in quiet mode. 88 test
1512// result chars leaves 12 chars for a progress count like " 11704/12853".
library/test/src/helpers/concurrency.rs+2-1
......@@ -1,7 +1,8 @@
11//! Helper module which helps to determine amount of threads to be used
22//! during tests execution.
33
4use std::{env, num::NonZero, thread};
4use std::num::NonZero;
5use std::{env, thread};
56
67pub fn get_concurrency() -> usize {
78 if let Ok(value) = env::var("RUST_TEST_THREADS") {
library/test/src/helpers/shuffle.rs+3-2
......@@ -1,8 +1,9 @@
1use crate::cli::TestOpts;
2use crate::types::{TestDescAndFn, TestId, TestName};
31use std::hash::{DefaultHasher, Hasher};
42use std::time::{SystemTime, UNIX_EPOCH};
53
4use crate::cli::TestOpts;
5use crate::types::{TestDescAndFn, TestId, TestName};
6
67pub fn get_shuffle_seed(opts: &TestOpts) -> Option<u64> {
78 opts.shuffle_seed.or_else(|| {
89 if opts.shuffle {
library/test/src/lib.rs+22-27
......@@ -25,45 +25,39 @@
2525#![feature(test)]
2626#![allow(internal_features)]
2727
28pub use cli::TestOpts;
29
2830pub use self::bench::{black_box, Bencher};
2931pub use self::console::run_tests_console;
3032pub use self::options::{ColorConfig, Options, OutputFormat, RunIgnored, ShouldPanic};
3133pub use self::types::TestName::*;
3234pub use self::types::*;
3335pub use self::ColorConfig::*;
34pub use cli::TestOpts;
3536
3637// Module to be used by rustc to compile tests in libtest
3738pub 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,
5248 };
49 pub use crate::{assert_test_result, filter_tests, run_test, test_main, test_main_static};
5350}
5451
55use 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};
52use std::collections::VecDeque;
53use std::io::prelude::Write;
54use std::mem::ManuallyDrop;
55use std::panic::{self, catch_unwind, AssertUnwindSafe, PanicHookInfo};
56use std::process::{self, Command, Termination};
57use std::sync::mpsc::{channel, Sender};
58use std::sync::{Arc, Mutex};
59use std::time::{Duration, Instant};
60use std::{env, io, thread};
6761
6862pub mod bench;
6963mod cli;
......@@ -82,6 +76,7 @@ mod types;
8276mod tests;
8377
8478use core::any::Any;
79
8580use event::{CompletedTest, TestEvent};
8681use helpers::concurrency::get_concurrency;
8782use helpers::shuffle::{get_shuffle_seed, shuffle_tests};
library/test/src/stats/tests.rs+2-1
......@@ -1,10 +1,11 @@
11use super::*;
22
33extern crate test;
4use self::test::test::Bencher;
54use std::io;
65use std::io::prelude::*;
76
7use self::test::test::Bencher;
8
89// Test vectors generated from R, using the script src/etc/stat-test-vectors.r.
910
1011macro_rules! assert_approx_eq {
library/test/src/term.rs+2-1
......@@ -12,7 +12,8 @@
1212
1313#![deny(missing_docs)]
1414
15use std::io::{self, prelude::*};
15use std::io::prelude::*;
16use std::io::{self};
1617
1718pub(crate) use terminfo::TerminfoTerminal;
1819#[cfg(windows)]
library/test/src/term/terminfo/mod.rs+5-7
......@@ -1,20 +1,18 @@
11//! Terminfo database interface.
22
33use std::collections::HashMap;
4use std::env;
5use std::error;
6use std::fmt;
74use std::fs::File;
8use std::io::{self, prelude::*, BufReader};
5use std::io::prelude::*;
6use std::io::{self, BufReader};
97use std::path::Path;
10
11use super::color;
12use super::Terminal;
8use std::{env, error, fmt};
139
1410use parm::{expand, Param, Variables};
1511use parser::compiled::{msys_terminfo, parse};
1612use searcher::get_dbpath_for_term;
1713
14use super::{color, Terminal};
15
1816/// A parsed terminfo database entry.
1917#[allow(unused)]
2018#[derive(Debug)]
library/test/src/term/terminfo/parm.rs+2-2
......@@ -1,10 +1,10 @@
11//! Parameterized string expansion
22
3use std::iter::repeat;
4
35use self::Param::*;
46use self::States::*;
57
6use std::iter::repeat;
7
88#[cfg(test)]
99mod tests;
1010
library/test/src/term/terminfo/parser/compiled.rs+2-1
......@@ -2,11 +2,12 @@
22
33//! ncurses-compatible compiled terminfo format parsing (term(5))
44
5use super::super::TermInfo;
65use std::collections::HashMap;
76use std::io;
87use std::io::prelude::*;
98
9use super::super::TermInfo;
10
1011#[cfg(test)]
1112mod tests;
1213
library/test/src/term/terminfo/searcher.rs+1-2
......@@ -2,9 +2,8 @@
22//!
33//! Does not support hashed database, only filesystem!
44
5use std::env;
6use std::fs;
75use std::path::PathBuf;
6use std::{env, fs};
87
98#[cfg(test)]
109mod tests;
library/test/src/term/win.rs+1-2
......@@ -5,8 +5,7 @@
55use std::io;
66use std::io::prelude::*;
77
8use super::color;
9use super::Terminal;
8use super::{color, Terminal};
109
1110/// A Terminal implementation that uses the Win32 Console API.
1211pub(crate) struct WinConsole<T> {
library/test/src/test_result.rs+2-4
......@@ -1,16 +1,14 @@
11use std::any::Any;
2use std::process::ExitStatus;
3
42#[cfg(unix)]
53use std::os::unix::process::ExitStatusExt;
4use std::process::ExitStatus;
65
6pub use self::TestResult::*;
77use super::bench::BenchSamples;
88use super::options::ShouldPanic;
99use super::time;
1010use super::types::TestDesc;
1111
12pub use self::TestResult::*;
13
1412// Return code for secondary process.
1513// Start somewhere other than 0 so we know the return code means what we think
1614// it means.
library/test/src/tests.rs+2-2
......@@ -1,5 +1,4 @@
11use super::*;
2
32use crate::{
43 console::OutputLocation,
54 formatters::PrettyFormatter,
......@@ -237,8 +236,9 @@ fn test_should_panic_bad_message() {
237236#[cfg(not(target_os = "emscripten"))]
238237#[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")]
239238fn test_should_panic_non_string_message_type() {
240 use crate::tests::TrFailedMsg;
241239 use std::any::TypeId;
240
241 use crate::tests::TrFailedMsg;
242242 fn f() -> Result<(), String> {
243243 std::panic::panic_any(1i32);
244244 }
library/test/src/time.rs+3-3
......@@ -5,10 +5,9 @@
55//! - Provide helpers for `report-time` and `measure-time` options.
66//! - Provide newtypes for executions times.
77
8use std::env;
9use std::fmt;
108use std::str::FromStr;
119use std::time::{Duration, Instant};
10use std::{env, fmt};
1211
1312use super::types::{TestDesc, TestType};
1413
......@@ -24,9 +23,10 @@ pub const TEST_WARN_TIMEOUT_S: u64 = 60;
2423/// Example of the expected format is `RUST_TEST_TIME_xxx=100,200`, where 100 means
2524/// warn time, and 200 means critical time.
2625pub mod time_constants {
27 use super::TEST_WARN_TIMEOUT_S;
2826 use std::time::Duration;
2927
28 use super::TEST_WARN_TIMEOUT_S;
29
3030 /// Environment variable for overriding default threshold for unit-tests.
3131 pub const UNIT_ENV_NAME: &str = "RUST_TEST_TIME_UNIT";
3232
library/test/src/types.rs+4-5
......@@ -4,15 +4,14 @@ use std::borrow::Cow;
44use std::fmt;
55use std::sync::mpsc::Sender;
66
7use super::__rust_begin_short_backtrace;
8use super::bench::Bencher;
9use super::event::CompletedTest;
10use super::options;
11
127pub use NamePadding::*;
138pub use TestFn::*;
149pub use TestName::*;
1510
11use super::bench::Bencher;
12use super::event::CompletedTest;
13use super::{__rust_begin_short_backtrace, options};
14
1615/// Type of the test according to the [Rust book](https://doc.rust-lang.org/cargo/guide/tests.html)
1716/// conventions.
1817#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
library/unwind/src/unwinding.rs+1-3
......@@ -28,9 +28,7 @@ pub enum _Unwind_Reason_Code {
2828 _URC_FAILURE = 9, // used only by ARM EHABI
2929}
3030pub use _Unwind_Reason_Code::*;
31
32pub use unwinding::abi::UnwindContext;
33pub use unwinding::abi::UnwindException;
31pub use unwinding::abi::{UnwindContext, UnwindException};
3432pub enum _Unwind_Context {}
3533
3634pub use unwinding::custom_eh_frame_finder::{
rustfmt.toml+2
......@@ -2,6 +2,8 @@
22version = "Two"
33use_small_heuristics = "Max"
44merge_derives = false
5group_imports = "StdExternalCrate"
6imports_granularity = "Module"
57
68# Files to ignore. Each entry uses gitignore syntax, but `!` prefixes aren't allowed.
79ignore = [
src/bootstrap/src/bin/main.rs+3-7
......@@ -5,14 +5,10 @@
55//! parent directory, and otherwise documentation can be found throughout the `build`
66//! directory in each respective module.
77
8use std::io::Write;
9use std::process;
8use std::fs::{self, OpenOptions};
9use std::io::{self, BufRead, BufReader, IsTerminal, Write};
1010use std::str::FromStr;
11use std::{
12 env,
13 fs::{self, OpenOptions},
14 io::{self, BufRead, BufReader, IsTerminal},
15};
11use std::{env, process};
1612
1713use bootstrap::{
1814 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> {
315315fn format_rusage_data(child: Child) -> Option<String> {
316316 use std::os::windows::io::AsRawHandle;
317317
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;
324322
325323 let handle = HANDLE(child.as_raw_handle() as isize);
326324
src/bootstrap/src/core/build_steps/check.rs+2-1
......@@ -1,5 +1,7 @@
11//! Implementation of compiling the compiler and standard library, in "check"-based modes.
22
3use std::path::PathBuf;
4
35use crate::core::build_steps::compile::{
46 add_to_sysroot, run_cargo, rustc_cargo, rustc_cargo_env, std_cargo,
57};
......@@ -9,7 +11,6 @@ use crate::core::builder::{
911};
1012use crate::core::config::TargetSelection;
1113use crate::{Compiler, Mode, Subcommand};
12use std::path::PathBuf;
1314
1415pub fn cargo_subcommand(kind: Kind) -> &'static str {
1516 match kind {
src/bootstrap/src/core/build_steps/clippy.rs+6-20
......@@ -1,26 +1,12 @@
11//! Implementation of running clippy on the compiler, standard library and various tools.
22
3use crate::builder::Builder;
4use crate::builder::ShouldRun;
3use super::compile::{librustc_stamp, libstd_stamp, run_cargo, rustc_cargo, std_cargo};
4use super::tool::{prepare_tool_cargo, SourceType};
5use super::{check, compile};
6use crate::builder::{Builder, ShouldRun};
57use crate::core::builder;
6use crate::core::builder::crate_description;
7use crate::core::builder::Alias;
8use crate::core::builder::Kind;
9use crate::core::builder::RunConfig;
10use crate::core::builder::Step;
11use crate::Mode;
12use crate::Subcommand;
13use crate::TargetSelection;
14
15use super::check;
16use super::compile;
17use super::compile::librustc_stamp;
18use super::compile::libstd_stamp;
19use super::compile::run_cargo;
20use super::compile::rustc_cargo;
21use super::compile::std_cargo;
22use super::tool::prepare_tool_cargo;
23use super::tool::SourceType;
8use crate::core::builder::{crate_description, Alias, Kind, RunConfig, Step};
9use crate::{Mode, Subcommand, TargetSelection};
2410
2511/// Disable the most spammy clippy lints
2612const IGNORED_RULES_FOR_STD_AND_RUSTC: &[&str] = &[
src/bootstrap/src/core/build_steps/compile.rs+6-10
......@@ -8,31 +8,27 @@
88
99use std::borrow::Cow;
1010use std::collections::HashSet;
11use std::env;
1211use std::ffi::OsStr;
13use std::fs;
1412use std::io::prelude::*;
1513use std::io::BufReader;
1614use std::path::{Path, PathBuf};
1715use std::process::Stdio;
18use std::str;
16use std::{env, fs, str};
1917
2018use serde_derive::Deserialize;
2119
22use crate::core::build_steps::dist;
23use crate::core::build_steps::llvm;
2420use crate::core::build_steps::tool::SourceType;
21use crate::core::build_steps::{dist, llvm};
2522use crate::core::builder;
26use crate::core::builder::crate_description;
27use crate::core::builder::Cargo;
28use crate::core::builder::{Builder, Kind, PathSet, RunConfig, ShouldRun, Step, TaskPath};
23use crate::core::builder::{
24 crate_description, Builder, Cargo, Kind, PathSet, RunConfig, ShouldRun, Step, TaskPath,
25};
2926use crate::core::config::{DebuginfoLevel, LlvmLibunwind, RustcLto, TargetSelection};
3027use crate::utils::exec::command;
3128use crate::utils::helpers::{
3229 exe, get_clang_cl_resource_dir, is_debug_info, is_dylib, symlink_dir, t, up_to_date,
3330};
34use crate::LLVM_TOOLS;
35use crate::{CLang, Compiler, DependencyType, GitRepo, Mode};
31use crate::{CLang, Compiler, DependencyType, GitRepo, Mode, LLVM_TOOLS};
3632
3733#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
3834pub struct Std {
src/bootstrap/src/core/build_steps/dist.rs+2-4
......@@ -9,19 +9,17 @@
99//! pieces of `rustup.rs`!
1010
1111use std::collections::HashSet;
12use std::env;
1312use std::ffi::OsStr;
14use std::fs;
1513use std::io::Write;
1614use std::path::{Path, PathBuf};
15use std::{env, fs};
1716
1817use object::read::archive::ArchiveFile;
1918use object::BinaryFormat;
2019
21use crate::core::build_steps::compile;
2220use crate::core::build_steps::doc::DocumentationFormat;
23use crate::core::build_steps::llvm;
2421use crate::core::build_steps::tool::{self, Tool};
22use crate::core::build_steps::{compile, llvm};
2523use crate::core::builder::{Builder, Kind, RunConfig, ShouldRun, Step};
2624use crate::core::config::TargetSelection;
2725use crate::utils::channel::{self, Info};
src/bootstrap/src/core/build_steps/doc.rs+3-2
......@@ -13,8 +13,9 @@ use std::{env, fs, mem};
1313
1414use crate::core::build_steps::compile;
1515use crate::core::build_steps::tool::{self, prepare_tool_cargo, SourceType, Tool};
16use crate::core::builder::{self, crate_description};
17use crate::core::builder::{Alias, Builder, Compiler, Kind, RunConfig, ShouldRun, Step};
16use crate::core::builder::{
17 self, crate_description, Alias, Builder, Compiler, Kind, RunConfig, ShouldRun, Step,
18};
1819use crate::core::config::{Config, TargetSelection};
1920use crate::utils::helpers::{symlink_dir, t, up_to_date};
2021use crate::Mode;
src/bootstrap/src/core/build_steps/format.rs+8-6
......@@ -1,17 +1,19 @@
11//! Runs rustfmt on the repository.
22
3use crate::core::builder::Builder;
4use crate::utils::exec::command;
5use crate::utils::helpers::{self, program_out_of_date, t};
6use build_helper::ci::CiEnv;
7use build_helper::git::get_git_modified_files;
8use ignore::WalkBuilder;
93use std::collections::VecDeque;
104use std::path::{Path, PathBuf};
115use std::process::Command;
126use std::sync::mpsc::SyncSender;
137use std::sync::Mutex;
148
9use build_helper::ci::CiEnv;
10use build_helper::git::get_git_modified_files;
11use ignore::WalkBuilder;
12
13use crate::core::builder::Builder;
14use crate::utils::exec::command;
15use crate::utils::helpers::{self, program_out_of_date, t};
16
1517fn rustfmt(src: &Path, rustfmt: &Path, paths: &[PathBuf], check: bool) -> impl FnMut(bool) -> bool {
1618 let mut cmd = Command::new(rustfmt);
1719 // 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 @@
33//! This module is responsible for installing the standard library,
44//! compiler, and documentation.
55
6use std::env;
7use std::fs;
86use std::path::{Component, Path, PathBuf};
7use std::{env, fs};
98
109use crate::core::build_steps::dist;
1110use crate::core::builder::{Builder, RunConfig, ShouldRun, Step};
src/bootstrap/src/core/build_steps/llvm.rs+4-5
......@@ -8,25 +8,24 @@
88//! LLVM and compiler-rt are essentially just wired up to everything else to
99//! ensure that they're always in place if needed.
1010
11use std::env;
1211use std::env::consts::EXE_EXTENSION;
1312use std::ffi::{OsStr, OsString};
1413use std::fs::{self, File};
15use std::io;
1614use std::path::{Path, PathBuf};
1715use std::sync::OnceLock;
16use std::{env, io};
17
18use build_helper::ci::CiEnv;
1819
1920use crate::core::builder::{Builder, RunConfig, ShouldRun, Step};
2021use crate::core::config::{Config, TargetSelection};
2122use crate::utils::channel;
23use crate::utils::exec::command;
2224use crate::utils::helpers::{
2325 self, exe, get_clang_cl_resource_dir, output, t, unhashed_basename, up_to_date,
2426};
2527use crate::{generate_smart_stamp_hash, CLang, GitRepo, Kind};
2628
27use crate::utils::exec::command;
28use build_helper::ci::CiEnv;
29
3029#[derive(Clone)]
3130pub struct LlvmResult {
3231 /// Path to llvm-config binary.
src/bootstrap/src/core/build_steps/setup.rs+8-7
......@@ -5,13 +5,6 @@
55//! allows setting up things that cannot be simply captured inside the config.toml, in addition to
66//! leading people away from manually editing most of the config.toml values.
77
8use crate::core::builder::{Builder, RunConfig, ShouldRun, Step};
9use crate::t;
10use crate::utils::change_tracker::CONFIG_CHANGE_HISTORY;
11use crate::utils::exec::command;
12use crate::utils::helpers::{self, hex_encode};
13use crate::Config;
14use sha2::Digest;
158use std::env::consts::EXE_SUFFIX;
169use std::fmt::Write as _;
1710use std::fs::File;
......@@ -20,6 +13,14 @@ use std::path::{Path, PathBuf, MAIN_SEPARATOR_STR};
2013use std::str::FromStr;
2114use std::{fmt, fs, io};
2215
16use sha2::Digest;
17
18use crate::core::builder::{Builder, RunConfig, ShouldRun, Step};
19use crate::utils::change_tracker::CONFIG_CHANGE_HISTORY;
20use crate::utils::exec::command;
21use crate::utils::helpers::{self, hex_encode};
22use crate::{t, Config};
23
2324#[cfg(test)]
2425mod tests;
2526
src/bootstrap/src/core/build_steps/setup/tests.rs+2-1
......@@ -1,6 +1,7 @@
1use sha2::Digest;
2
13use super::{RUST_ANALYZER_SETTINGS, SETTINGS_HASHES};
24use crate::utils::helpers::hex_encode;
3use sha2::Digest;
45
56#[test]
67fn check_matching_settings_hash() {
src/bootstrap/src/core/build_steps/suggest.rs+2-1
......@@ -2,10 +2,11 @@
22
33#![cfg_attr(feature = "build-metrics", allow(unused))]
44
5use clap::Parser;
65use std::path::PathBuf;
76use std::str::FromStr;
87
8use clap::Parser;
9
910use crate::core::build_steps::tool::Tool;
1011use crate::core::builder::Builder;
1112
src/bootstrap/src/core/build_steps/test.rs+7-12
......@@ -3,27 +3,22 @@
33//! `./x.py test` (aka [`Kind::Test`]) is currently allowed to reach build steps in other modules.
44//! However, this contains ~all test parts we expect people to be able to build and run locally.
55
6use std::env;
7use std::ffi::OsStr;
8use std::ffi::OsString;
9use std::fs;
10use std::iter;
6use std::ffi::{OsStr, OsString};
117use std::path::{Path, PathBuf};
8use std::{env, fs, iter};
129
1310use clap_complete::shells;
1411
15use crate::core::build_steps::compile;
16use crate::core::build_steps::dist;
1712use crate::core::build_steps::doc::DocumentationFormat;
18use crate::core::build_steps::llvm;
1913use crate::core::build_steps::synthetic_targets::MirOptPanicAbortSyntheticTarget;
2014use crate::core::build_steps::tool::{self, SourceType, Tool};
2115use crate::core::build_steps::toolstate::ToolState;
16use crate::core::build_steps::{compile, dist, llvm};
2217use crate::core::builder;
23use crate::core::builder::crate_description;
24use crate::core::builder::{Builder, Compiler, Kind, RunConfig, ShouldRun, Step};
25use crate::core::config::flags::get_completion;
26use crate::core::config::flags::Subcommand;
18use crate::core::builder::{
19 crate_description, Builder, Compiler, Kind, RunConfig, ShouldRun, Step,
20};
21use crate::core::config::flags::{get_completion, Subcommand};
2722use crate::core::config::TargetSelection;
2823use crate::utils::exec::{command, BootstrapCommand};
2924use crate::utils::helpers::{
src/bootstrap/src/core/build_steps/tool.rs+2-5
......@@ -1,6 +1,5 @@
1use std::env;
2use std::fs;
31use std::path::PathBuf;
2use std::{env, fs};
43
54use crate::core::build_steps::compile;
65use crate::core::build_steps::toolstate::ToolState;
......@@ -10,9 +9,7 @@ use crate::core::config::TargetSelection;
109use crate::utils::channel::GitInfo;
1110use crate::utils::exec::{command, BootstrapCommand};
1211use crate::utils::helpers::{add_dylib_path, exe, get_closest_merge_base_commit, git, t};
13use crate::Compiler;
14use crate::Mode;
15use crate::{gha, Kind};
12use crate::{gha, Compiler, Kind, Mode};
1613
1714#[derive(Debug, Clone, Hash, PartialEq, Eq)]
1815pub enum SourceType {
src/bootstrap/src/core/build_steps/toolstate.rs+6-7
......@@ -4,16 +4,15 @@
44//!
55//! [Toolstate]: https://forge.rust-lang.org/infra/toolstate.html
66
7use crate::core::builder::{Builder, RunConfig, ShouldRun, Step};
8use crate::utils::helpers::{self, t};
9use serde_derive::{Deserialize, Serialize};
107use std::collections::HashMap;
11use std::env;
12use std::fmt;
13use std::fs;
148use std::io::{Seek, SeekFrom};
159use std::path::{Path, PathBuf};
16use std::time;
10use std::{env, fmt, fs, time};
11
12use serde_derive::{Deserialize, Serialize};
13
14use crate::core::builder::{Builder, RunConfig, ShouldRun, Step};
15use crate::utils::helpers::{self, t};
1716
1817// Each cycle is 42 days long (6 weeks); the last week is 35..=42 then.
1918const BETA_WEEK_START: u64 = 35;
src/bootstrap/src/core/build_steps/vendor.rs+2-1
......@@ -1,7 +1,8 @@
1use std::path::PathBuf;
2
13use crate::core::build_steps::tool::SUBMODULES_FOR_RUSTBOOK;
24use crate::core::builder::{Builder, RunConfig, ShouldRun, Step};
35use crate::utils::exec::command;
4use std::path::PathBuf;
56
67#[derive(Debug, Clone, Hash, PartialEq, Eq)]
78pub(crate) struct Vendor {
src/bootstrap/src/core/builder.rs+10-10
......@@ -1,15 +1,16 @@
11use std::any::{type_name, Any};
22use std::cell::{Cell, RefCell};
33use std::collections::BTreeSet;
4use std::env;
54use std::ffi::{OsStr, OsString};
65use std::fmt::{Debug, Write};
7use std::fs;
86use std::hash::Hash;
97use std::ops::Deref;
108use std::path::{Path, PathBuf};
119use std::sync::LazyLock;
1210use std::time::{Duration, Instant};
11use std::{env, fs};
12
13use clap::ValueEnum;
1314
1415use crate::core::build_steps::tool::{self, SourceType};
1516use crate::core::build_steps::{
......@@ -17,17 +18,16 @@ use crate::core::build_steps::{
1718};
1819use crate::core::config::flags::{Color, Subcommand};
1920use crate::core::config::{DryRun, SplitDebuginfo, TargetSelection};
20use crate::prepare_behaviour_dump_dir;
2121use crate::utils::cache::Cache;
22use crate::utils::helpers::{self, add_dylib_path, add_link_lib_path, exe, linker_args};
23use crate::utils::helpers::{check_cfg_arg, libdir, linker_flags, t, LldThreads};
24use crate::EXTRA_CHECK_CFGS;
25use crate::{Build, CLang, Crate, DocTests, GitRepo, Mode};
26
2722use crate::utils::exec::{command, BootstrapCommand};
23use 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};
2827pub use crate::Compiler;
29
30use clap::ValueEnum;
28use crate::{
29 prepare_behaviour_dump_dir, Build, CLang, Crate, DocTests, GitRepo, Mode, EXTRA_CHECK_CFGS,
30};
3131
3232#[cfg(test)]
3333mod tests;
src/bootstrap/src/core/builder/tests.rs+6-3
......@@ -1,7 +1,8 @@
1use std::thread;
2
13use super::*;
24use crate::core::build_steps::doc::DocumentationFormat;
35use crate::core::config::Config;
4use std::thread;
56
67fn configure(cmd: &str, host: &[&str], target: &[&str]) -> Config {
78 configure_with_args(&[cmd.to_owned()], host, target)
......@@ -215,10 +216,11 @@ fn alias_and_path_for_library() {
215216}
216217
217218mod defaults {
219 use pretty_assertions::assert_eq;
220
218221 use super::{configure, first, run_build};
219222 use crate::core::builder::*;
220223 use crate::Config;
221 use pretty_assertions::assert_eq;
222224
223225 #[test]
224226 fn build_default() {
......@@ -326,9 +328,10 @@ mod defaults {
326328}
327329
328330mod dist {
331 use pretty_assertions::assert_eq;
332
329333 use super::{first, run_build, Config};
330334 use crate::core::builder::*;
331 use pretty_assertions::assert_eq;
332335
333336 fn configure(host: &[&str], target: &[&str]) -> Config {
334337 Config { stage: 2, ..super::configure("dist", host, target) }
src/bootstrap/src/core/config/config.rs+7-9
......@@ -4,29 +4,27 @@
44//! how the build runs.
55
66use std::cell::{Cell, RefCell};
7use std::cmp;
87use std::collections::{HashMap, HashSet};
9use std::env;
108use std::fmt::{self, Display};
11use std::fs;
129use std::io::IsTerminal;
1310use std::path::{absolute, Path, PathBuf};
1411use std::process::Command;
1512use std::str::FromStr;
1613use std::sync::OnceLock;
14use std::{cmp, env, fs};
15
16use build_helper::exit;
17use build_helper::git::GitConfig;
18use serde::{Deserialize, Deserializer};
19use serde_derive::Deserialize;
1720
1821use crate::core::build_steps::compile::CODEGEN_BACKEND_PREFIX;
1922use crate::core::build_steps::llvm;
23pub use crate::core::config::flags::Subcommand;
2024use crate::core::config::flags::{Color, Flags, Warnings};
2125use crate::utils::cache::{Interned, INTERNER};
2226use crate::utils::channel::{self, GitInfo};
2327use crate::utils::helpers::{self, exe, get_closest_merge_base_commit, output, t};
24use build_helper::exit;
25use serde::{Deserialize, Deserializer};
26use serde_derive::Deserialize;
27
28pub use crate::core::config::flags::Subcommand;
29use build_helper::git::GitConfig;
3028
3129macro_rules! check_ci_llvm {
3230 ($name:expr) => {
src/bootstrap/src/core/config/tests.rs+9-11
......@@ -1,17 +1,15 @@
1use super::{flags::Flags, ChangeIdWrapper, Config};
2use crate::core::build_steps::clippy::get_clippy_rules_in_order;
3use crate::core::config::Target;
4use crate::core::config::TargetSelection;
5use crate::core::config::{LldMode, TomlConfig};
1use std::env;
2use std::fs::{remove_file, File};
3use std::io::Write;
4use std::path::Path;
65
76use clap::CommandFactory;
87use serde::Deserialize;
9use std::{
10 env,
11 fs::{remove_file, File},
12 io::Write,
13 path::Path,
14};
8
9use super::flags::Flags;
10use super::{ChangeIdWrapper, Config};
11use crate::core::build_steps::clippy::get_clippy_rules_in_order;
12use crate::core::config::{LldMode, Target, TargetSelection, TomlConfig};
1513
1614fn parse(config: &str) -> Config {
1715 Config::parse_inner(&["check".to_string(), "--config=/does/not/exist".to_string()], |&_| {
src/bootstrap/src/core/download.rs+8-11
......@@ -1,19 +1,16 @@
1use 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};
1use std::env;
2use std::ffi::OsString;
3use std::fs::{self, File};
4use std::io::{BufRead, BufReader, BufWriter, ErrorKind, Write};
5use std::path::{Path, PathBuf};
6use std::process::{Command, Stdio};
7use std::sync::OnceLock;
108
119use build_helper::ci::CiEnv;
1210use xz2::bufread::XzDecoder;
1311
1412use crate::utils::exec::{command, BootstrapCommand};
15use crate::utils::helpers::hex_encode;
16use crate::utils::helpers::{check_run, exe, move_file, program_out_of_date};
13use crate::utils::helpers::{check_run, exe, hex_encode, move_file, program_out_of_date};
1714use crate::{t, Config};
1815
1916static SHOULD_FIX_BINS_AND_DYLIBS: OnceLock<bool> = OnceLock::new();
src/bootstrap/src/core/sanity.rs+4-6
......@@ -9,19 +9,17 @@
99//! practice that's likely not true!
1010
1111use std::collections::HashMap;
12use std::env;
12#[cfg(not(feature = "bootstrap-self-test"))]
13use std::collections::HashSet;
1314use std::ffi::{OsStr, OsString};
14use std::fs;
1515use std::path::PathBuf;
16use std::{env, fs};
1617
1718#[cfg(not(feature = "bootstrap-self-test"))]
1819use crate::builder::Builder;
20use crate::builder::Kind;
1921#[cfg(not(feature = "bootstrap-self-test"))]
2022use crate::core::build_steps::tool;
21#[cfg(not(feature = "bootstrap-self-test"))]
22use std::collections::HashSet;
23
24use crate::builder::Kind;
2523use crate::core::config::Target;
2624use crate::utils::exec::command;
2725use crate::Build;
src/bootstrap/src/lib.rs+3-6
......@@ -18,15 +18,13 @@
1818
1919use std::cell::{Cell, RefCell};
2020use std::collections::{HashMap, HashSet};
21use std::env;
2221use std::fmt::Display;
2322use std::fs::{self, File};
24use std::io;
2523use std::path::{Path, PathBuf};
2624use std::process::Command;
27use std::str;
2825use std::sync::OnceLock;
2926use std::time::SystemTime;
27use std::{env, io, str};
3028
3129use build_helper::ci::{gha, CiEnv};
3230use build_helper::exit;
......@@ -37,9 +35,7 @@ use utils::helpers::hex_encode;
3735
3836use crate::core::builder;
3937use crate::core::builder::{Builder, Kind};
40use crate::core::config::{flags, LldMode};
41use crate::core::config::{DryRun, Target};
42use crate::core::config::{LlvmLibunwind, TargetSelection};
38use crate::core::config::{flags, DryRun, LldMode, LlvmLibunwind, Target, TargetSelection};
4339use crate::utils::exec::{command, BehaviorOnFailure, BootstrapCommand, CommandOutput, OutputMode};
4440use crate::utils::helpers::{self, dir_is_empty, exe, libdir, mtime, output, symlink_dir};
4541
......@@ -49,6 +45,7 @@ mod utils;
4945pub use core::builder::PathSet;
5046pub use core::config::flags::Subcommand;
5147pub use core::config::Config;
48
5249pub use utils::change_tracker::{
5350 find_recent_config_change_ids, human_readable_changes, CONFIG_CHANGE_HISTORY,
5451};
src/bootstrap/src/utils/cache.rs+1-2
......@@ -3,13 +3,12 @@ use std::borrow::Borrow;
33use std::cell::RefCell;
44use std::cmp::Ordering;
55use std::collections::HashMap;
6use std::fmt;
76use std::hash::{Hash, Hasher};
87use std::marker::PhantomData;
9use std::mem;
108use std::ops::Deref;
119use std::path::PathBuf;
1210use std::sync::{LazyLock, Mutex};
11use std::{fmt, mem};
1312
1413use crate::core::builder::Step;
1514
src/bootstrap/src/utils/channel.rs+1-2
......@@ -8,11 +8,10 @@
88use std::fs;
99use std::path::Path;
1010
11use super::helpers;
1112use crate::utils::helpers::{output, t};
1213use crate::Build;
1314
14use super::helpers;
15
1615#[derive(Clone, Default)]
1716pub enum GitInfo {
1817 /// This is not a git repository.
src/bootstrap/src/utils/exec.rs+5-3
......@@ -1,11 +1,13 @@
1use crate::Build;
2use build_helper::ci::CiEnv;
3use build_helper::drop_bomb::DropBomb;
41use std::ffi::OsStr;
52use std::fmt::{Debug, Formatter};
63use std::path::Path;
74use std::process::{Command, CommandArgs, CommandEnvs, ExitStatus, Output, Stdio};
85
6use build_helper::ci::CiEnv;
7use build_helper::drop_bomb::DropBomb;
8
9use crate::Build;
10
911/// What should be done when the command fails.
1012#[derive(Debug, Copy, Clone)]
1113pub enum BehaviorOnFailure {
src/bootstrap/src/utils/helpers.rs+7-9
......@@ -3,23 +3,20 @@
33//! Simple things like testing the various filesystem operations here and there,
44//! not a lot of interesting happenings here unfortunately.
55
6use build_helper::git::{get_git_merge_base, output_result, GitConfig};
7use build_helper::util::fail;
8use std::env;
96use std::ffi::OsStr;
10use std::fs;
11use std::io;
127use std::path::{Path, PathBuf};
138use std::process::{Command, Stdio};
14use std::str;
159use std::sync::OnceLock;
1610use std::time::{Instant, SystemTime, UNIX_EPOCH};
11use std::{env, fs, io, str};
12
13use build_helper::git::{get_git_merge_base, output_result, GitConfig};
14use build_helper::util::fail;
1715
1816use crate::core::builder::Builder;
1917use crate::core::config::{Config, TargetSelection};
20use crate::LldMode;
21
2218pub use crate::utils::shared_helpers::{dylib_path, dylib_path_var};
19use crate::LldMode;
2320
2421#[cfg(test)]
2522mod tests;
......@@ -48,9 +45,10 @@ macro_rules! t {
4845 }
4946 };
5047}
51use crate::utils::exec::{command, BootstrapCommand};
5248pub use t;
5349
50use crate::utils::exec::{command, BootstrapCommand};
51
5452pub fn exe(name: &str, target: TargetSelection) -> String {
5553 crate::utils::shared_helpers::exe(name, &target.triple)
5654}
src/bootstrap/src/utils/helpers/tests.rs+7-10
......@@ -1,14 +1,11 @@
1use crate::{
2 utils::helpers::{
3 check_cfg_arg, extract_beta_rev, hex_encode, make, program_out_of_date, symlink_dir,
4 },
5 Config,
6};
7use std::{
8 fs::{self, remove_file, File},
9 io::Write,
10 path::PathBuf,
1use std::fs::{self, remove_file, File};
2use std::io::Write;
3use std::path::PathBuf;
4
5use crate::utils::helpers::{
6 check_cfg_arg, extract_beta_rev, hex_encode, make, program_out_of_date, symlink_dir,
117};
8use crate::Config;
129
1310#[test]
1411fn test_make() {
src/bootstrap/src/utils/job.rs+15-18
......@@ -40,28 +40,25 @@ pub unsafe fn setup(build: &mut crate::Build) {
4040/// Note that this is a Windows specific module as none of this logic is required on Unix.
4141#[cfg(windows)]
4242mod for_windows {
43 use crate::Build;
44 use std::env;
4543 use std::ffi::c_void;
46 use std::io;
47 use std::mem;
44 use std::{env, io, mem};
4845
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,
6358 };
6459
60 use crate::Build;
61
6562 pub unsafe fn setup(build: &mut Build) {
6663 // Enable the Windows Error Reporting dialog which msys disables,
6764 // so we can JIT debug rustc
src/bootstrap/src/utils/metrics.rs+9-7
......@@ -4,19 +4,21 @@
44//! As this module requires additional dependencies not present during local builds, it's cfg'd
55//! away whenever the `build.metrics` config option is not set to `true`.
66
7use crate::core::builder::{Builder, Step};
8use crate::utils::helpers::t;
9use crate::Build;
10use build_helper::metrics::{
11 JsonInvocation, JsonInvocationSystemStats, JsonNode, JsonRoot, JsonStepSystemStats, Test,
12 TestOutcome, TestSuite, TestSuiteMetadata,
13};
147use std::cell::RefCell;
158use std::fs::File;
169use std::io::BufWriter;
1710use std::time::{Duration, Instant, SystemTime};
11
12use build_helper::metrics::{
13 JsonInvocation, JsonInvocationSystemStats, JsonNode, JsonRoot, JsonStepSystemStats, Test,
14 TestOutcome, TestSuite, TestSuiteMetadata,
15};
1816use sysinfo::System;
1917
18use crate::core::builder::{Builder, Step};
19use crate::utils::helpers::t;
20use crate::Build;
21
2022// Update this number whenever a breaking change is made to the build metrics.
2123//
2224// The output format is versioned for two reasons:
src/bootstrap/src/utils/render_tests.rs+4-2
......@@ -6,13 +6,15 @@
66//! and rustc) libtest doesn't include the rendered human-readable output as a JSON field. We had
77//! to reimplement all the rendering logic in this module because of that.
88
9use crate::core::builder::Builder;
10use crate::utils::exec::BootstrapCommand;
119use std::io::{BufRead, BufReader, Read, Write};
1210use std::process::{ChildStdout, Stdio};
1311use std::time::Duration;
12
1413use termcolor::{Color, ColorSpec, WriteColor};
1514
15use crate::core::builder::Builder;
16use crate::utils::exec::BootstrapCommand;
17
1618const TERSE_TESTS_PER_LINE: usize = 88;
1719
1820pub(crate) fn add_flags_and_try_run_tests(
src/bootstrap/src/utils/tarball.rs+2-2
......@@ -7,8 +7,8 @@
77
88use std::path::{Path, PathBuf};
99
10use crate::core::builder::Builder;
11use crate::core::{build_steps::dist::distdir, builder::Kind};
10use crate::core::build_steps::dist::distdir;
11use crate::core::builder::{Builder, Kind};
1212use crate::utils::exec::BootstrapCommand;
1313use crate::utils::helpers::{move_file, t};
1414use crate::utils::{channel, helpers};
src/ci/docker/host-x86_64/test-various/uefi_qemu_test/src/main.rs+1
......@@ -5,6 +5,7 @@
55#![no_std]
66
77use core::{panic, ptr};
8
89use r_efi::efi::{Char16, Handle, Status, SystemTable, RESET_SHUTDOWN};
910
1011#[panic_handler]
src/librustdoc/clean/auto_trait.rs+2-4
......@@ -6,13 +6,11 @@ use rustc_middle::ty::{self, Region, Ty};
66use rustc_span::def_id::DefId;
77use rustc_span::symbol::{kw, Symbol};
88use rustc_trait_selection::traits::auto_trait::{self, RegionTarget};
9
109use thin_vec::ThinVec;
1110
12use crate::clean::{self, simplify, Lifetime};
1311use 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,
1614};
1715use crate::core::DocContext;
1816
src/librustdoc/clean/blanket_impl.rs-1
......@@ -5,7 +5,6 @@ use rustc_middle::ty::{self, Upcast};
55use rustc_span::def_id::DefId;
66use rustc_span::DUMMY_SP;
77use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt;
8
98use thin_vec::ThinVec;
109
1110use crate::clean;
src/librustdoc/clean/cfg.rs+1-3
......@@ -4,15 +4,13 @@
44// switch to use those structures instead.
55
66use std::fmt::{self, Write};
7use std::mem;
8use std::ops;
7use std::{mem, ops};
98
109use rustc_ast::{LitKind, MetaItem, MetaItemKind, NestedMetaItem};
1110use rustc_data_structures::fx::FxHashSet;
1211use rustc_feature::Features;
1312use rustc_session::parse::ParseSess;
1413use rustc_span::symbol::{sym, Symbol};
15
1614use rustc_span::Span;
1715
1816use crate::html::escape::Escape;
src/librustdoc/clean/cfg/tests.rs+3-4
......@@ -1,11 +1,10 @@
1use super::*;
2
31use rustc_ast::{MetaItemLit, Path, Safety, StrStyle};
4use rustc_span::create_default_session_globals_then;
52use rustc_span::symbol::{kw, Ident};
6use rustc_span::DUMMY_SP;
3use rustc_span::{create_default_session_globals_then, DUMMY_SP};
74use thin_vec::thin_vec;
85
6use super::*;
7
98fn word_cfg(s: &str) -> Cfg {
109 Cfg::Cfg(Symbol::intern(s), None)
1110}
src/librustdoc/clean/inline.rs+3-6
......@@ -3,11 +3,7 @@
33use std::iter::once;
44use std::sync::Arc;
55
6use thin_vec::{thin_vec, ThinVec};
7
8use rustc_ast as ast;
96use rustc_data_structures::fx::FxHashSet;
10use rustc_hir as hir;
117use rustc_hir::def::{DefKind, Res};
128use rustc_hir::def_id::{DefId, DefIdSet, LocalModDefId};
139use rustc_hir::Mutability;
......@@ -17,7 +13,10 @@ use rustc_middle::ty::{self, TyCtxt};
1713use rustc_span::def_id::LOCAL_CRATE;
1814use rustc_span::hygiene::MacroKind;
1915use rustc_span::symbol::{kw, sym, Symbol};
16use thin_vec::{thin_vec, ThinVec};
17use {rustc_ast as ast, rustc_hir as hir};
2018
19use super::Item;
2120use crate::clean::{
2221 self, clean_bound_vars, clean_generics, clean_impl_item, clean_middle_assoc_item,
2322 clean_middle_field, clean_middle_ty, clean_poly_fn_sig, clean_trait_ref_with_constraints,
......@@ -27,8 +26,6 @@ use crate::clean::{
2726use crate::core::DocContext;
2827use crate::formats::item_type::ItemType;
2928
30use super::Item;
31
3229/// Attempt to inline a definition into this AST.
3330///
3431/// This function will fetch the definition specified, and if it is
src/librustdoc/clean/mod.rs+11-16
......@@ -30,41 +30,36 @@ mod simplify;
3030pub(crate) mod types;
3131pub(crate) mod utils;
3232
33use rustc_ast as ast;
33use std::borrow::Cow;
34use std::collections::BTreeMap;
35use std::mem;
36
3437use rustc_ast::token::{Token, TokenKind};
3538use rustc_ast::tokenstream::{TokenStream, TokenTree};
36use rustc_attr as attr;
3739use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap, FxIndexSet, IndexEntry};
38use rustc_errors::{codes::*, struct_span_code_err, FatalError};
39use rustc_hir as hir;
40use rustc_errors::codes::*;
41use rustc_errors::{struct_span_code_err, FatalError};
4042use rustc_hir::def::{CtorKind, DefKind, Res};
4143use rustc_hir::def_id::{DefId, DefIdMap, DefIdSet, LocalDefId, LOCAL_CRATE};
4244use rustc_hir::PredicateOrigin;
4345use rustc_hir_analysis::lower_ty;
4446use rustc_middle::metadata::Reexport;
4547use rustc_middle::middle::resolve_bound_vars as rbv;
46use rustc_middle::ty::GenericArgsRef;
47use rustc_middle::ty::TypeVisitableExt;
48use rustc_middle::ty::{self, AdtKind, Ty, TyCtxt};
48use rustc_middle::ty::{self, AdtKind, GenericArgsRef, Ty, TyCtxt, TypeVisitableExt};
4949use rustc_middle::{bug, span_bug};
5050use rustc_span::hygiene::{AstPass, MacroKind};
5151use rustc_span::symbol::{kw, sym, Ident, Symbol};
5252use rustc_span::ExpnKind;
5353use rustc_trait_selection::traits::wf::object_region_bounds;
54
55use std::borrow::Cow;
56use std::collections::BTreeMap;
57use std::mem;
5854use thin_vec::ThinVec;
59
60use crate::core::DocContext;
61use crate::formats::item_type::ItemType;
62use crate::visit_ast::Module as DocModule;
63
6455use utils::*;
56use {rustc_ast as ast, rustc_attr as attr, rustc_hir as hir};
6557
6658pub(crate) use self::types::*;
6759pub(crate) use self::utils::{krate, register_res, synthesize_auto_trait_and_blanket_impls};
60use crate::core::DocContext;
61use crate::formats::item_type::ItemType;
62use crate::visit_ast::Module as DocModule;
6863
6964pub(crate) fn clean_doc_module<'tcx>(doc: &DocModule<'tcx>, cx: &mut DocContext<'tcx>) -> Item {
7065 let mut items: Vec<Item> = vec![];
src/librustdoc/clean/simplify.rs+1-2
......@@ -18,8 +18,7 @@ use rustc_middle::ty;
1818use thin_vec::ThinVec;
1919
2020use crate::clean;
21use crate::clean::GenericArgs as PP;
22use crate::clean::WherePredicate as WP;
21use crate::clean::{GenericArgs as PP, WherePredicate as WP};
2322use crate::core::DocContext;
2423
2524pub(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;
33use std::hash::Hash;
44use std::path::PathBuf;
55use std::rc::Rc;
6use std::sync::Arc;
7use std::sync::OnceLock as OnceCell;
6use std::sync::{Arc, OnceLock as OnceCell};
87use std::{fmt, iter};
98
109use arrayvec::ArrayVec;
11use thin_vec::ThinVec;
12
13use rustc_ast as ast;
1410use rustc_ast_pretty::pprust;
1511use rustc_attr::{ConstStability, Deprecation, Stability, StabilityLevel, StableSince};
1612use rustc_const_eval::const_eval::is_unstable_const_fn;
1713use rustc_data_structures::fx::{FxHashMap, FxHashSet};
18use rustc_hir as hir;
1914use rustc_hir::def::{CtorKind, DefKind, Res};
2015use rustc_hir::def_id::{CrateNum, DefId, LOCAL_CRATE};
2116use rustc_hir::lang_items::LangItem;
......@@ -35,7 +30,15 @@ use rustc_span::symbol::{kw, sym, Ident, Symbol};
3530use rustc_span::{FileName, Loc, DUMMY_SP};
3631use rustc_target::abi::VariantIdx;
3732use rustc_target::spec::abi::Abi;
33use thin_vec::ThinVec;
34use {rustc_ast as ast, rustc_hir as hir};
3835
36pub(crate) use self::ItemKind::*;
37pub(crate) use self::SelfTy::*;
38pub(crate) use self::Type::{
39 Array, BareFunction, BorrowedRef, DynTrait, Generic, ImplTrait, Infer, Primitive, QPath,
40 RawPointer, Slice, Tuple,
41};
3942use crate::clean::cfg::Cfg;
4043use crate::clean::clean_middle_path;
4144use crate::clean::inline::{self, print_inlined_const};
......@@ -46,13 +49,6 @@ use crate::formats::item_type::ItemType;
4649use crate::html::render::Context;
4750use crate::passes::collect_intra_doc_links::UrlFragment;
4851
49pub(crate) use self::ItemKind::*;
50pub(crate) use self::SelfTy::*;
51pub(crate) use self::Type::{
52 Array, BareFunction, BorrowedRef, DynTrait, Generic, ImplTrait, Infer, Primitive, QPath,
53 RawPointer, Slice, Tuple,
54};
55
5652#[cfg(test)]
5753mod tests;
5854
......@@ -2586,8 +2582,9 @@ pub(crate) enum AssocItemConstraintKind {
25862582// Some nodes are used a lot. Make sure they don't unintentionally get bigger.
25872583#[cfg(target_pointer_width = "64")]
25882584mod size_asserts {
2589 use super::*;
25902585 use rustc_data_structures::static_assert_size;
2586
2587 use super::*;
25912588 // tidy-alphabetical-start
25922589 static_assert_size!(Crate, 64); // frequently moved by-value
25932590 static_assert_size!(DocFragment, 32);
src/librustdoc/clean/types/tests.rs+2-2
......@@ -1,8 +1,8 @@
1use super::*;
2
31use rustc_resolve::rustdoc::{unindent_doc_fragments, DocFragmentKind};
42use rustc_span::create_default_session_globals_then;
53
4use super::*;
5
66fn create_doc_fragment(s: &str) -> Vec<DocFragment> {
77 vec![DocFragment {
88 span: DUMMY_SP,
src/librustdoc/clean/utils.rs+15-16
......@@ -1,3 +1,18 @@
1use std::assert_matches::debug_assert_matches;
2use std::fmt::Write as _;
3use std::mem;
4use std::sync::LazyLock as Lazy;
5
6use rustc_ast::tokenstream::TokenTree;
7use rustc_hir::def::{DefKind, Res};
8use rustc_hir::def_id::{DefId, LocalDefId, LOCAL_CRATE};
9use rustc_metadata::rendered_const;
10use rustc_middle::mir;
11use rustc_middle::ty::{self, GenericArgKind, GenericArgsRef, TyCtxt, TypeVisitableExt};
12use rustc_span::symbol::{kw, sym, Symbol};
13use thin_vec::{thin_vec, ThinVec};
14use {rustc_ast as ast, rustc_hir as hir};
15
116use crate::clean::auto_trait::synthesize_auto_trait_impls;
217use crate::clean::blanket_impl::synthesize_blanket_impls;
318use crate::clean::render_macro_matchers::render_macro_matcher;
......@@ -10,22 +25,6 @@ use crate::clean::{
1025use crate::core::DocContext;
1126use crate::html::format::visibility_to_src_with_space;
1227
13use rustc_ast as ast;
14use rustc_ast::tokenstream::TokenTree;
15use rustc_hir as hir;
16use rustc_hir::def::{DefKind, Res};
17use rustc_hir::def_id::{DefId, LocalDefId, LOCAL_CRATE};
18use rustc_metadata::rendered_const;
19use rustc_middle::mir;
20use rustc_middle::ty::TypeVisitableExt;
21use rustc_middle::ty::{self, GenericArgKind, GenericArgsRef, TyCtxt};
22use rustc_span::symbol::{kw, sym, Symbol};
23use std::assert_matches::debug_assert_matches;
24use std::fmt::Write as _;
25use std::mem;
26use std::sync::LazyLock as Lazy;
27use thin_vec::{thin_vec, ThinVec};
28
2928#[cfg(test)]
3029mod tests;
3130
src/librustdoc/config.rs+7-13
......@@ -1,38 +1,32 @@
11use std::collections::BTreeMap;
22use std::ffi::OsStr;
3use std::fmt;
4use std::io;
53use std::io::Read;
6use std::path::Path;
7use std::path::PathBuf;
4use std::path::{Path, PathBuf};
85use std::str::FromStr;
6use std::{fmt, io};
97
108use rustc_data_structures::fx::FxHashMap;
119use rustc_errors::DiagCtxtHandle;
1210use 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,
1414};
15use rustc_session::config::{get_cmd_lint_options, nightly_options};
16use rustc_session::config::{CodegenOptions, ErrorOutputType, Externs, Input};
17use rustc_session::config::{JsonUnusedExterns, UnstableOptions};
18use rustc_session::getopts;
1915use rustc_session::lint::Level;
2016use rustc_session::search_paths::SearchPath;
21use rustc_session::EarlyDiagCtxt;
17use rustc_session::{getopts, EarlyDiagCtxt};
2218use rustc_span::edition::Edition;
2319use rustc_span::FileName;
2420use rustc_target::spec::TargetTriple;
2521
2622use crate::core::new_dcx;
2723use crate::externalfiles::ExternalHtml;
28use crate::html;
2924use crate::html::markdown::IdMap;
3025use crate::html::render::StylePath;
3126use crate::html::static_files;
32use crate::opts;
3327use crate::passes::{self, Condition};
3428use crate::scrape_examples::{AllCallLocations, ScrapeExamplesOptions};
35use crate::theme;
29use crate::{html, opts, theme};
3630
3731#[derive(Clone, Copy, PartialEq, Eq, Debug, Default)]
3832pub(crate) enum OutputFormat {
src/librustdoc/core.rs+12-13
......@@ -1,9 +1,16 @@
1use std::cell::RefCell;
2use std::rc::Rc;
3use std::sync::atomic::AtomicBool;
4use std::sync::{Arc, LazyLock};
5use std::{io, mem};
6
17use rustc_data_structures::fx::{FxHashMap, FxHashSet};
28use rustc_data_structures::sync::Lrc;
39use rustc_data_structures::unord::UnordSet;
10use rustc_errors::codes::*;
411use rustc_errors::emitter::{stderr_destination, DynEmitter, HumanEmitter};
512use rustc_errors::json::JsonEmitter;
6use rustc_errors::{codes::*, DiagCtxtHandle, ErrorGuaranteed, TerminalUrl};
13use rustc_errors::{DiagCtxtHandle, ErrorGuaranteed, TerminalUrl};
714use rustc_feature::UnstableFeatures;
815use rustc_hir::def::Res;
916use rustc_hir::def_id::{DefId, DefIdMap, DefIdSet, LocalDefId};
......@@ -14,25 +21,17 @@ use rustc_lint::{late_lint_mod, MissingDoc};
1421use rustc_middle::hir::nested_filter;
1522use rustc_middle::ty::{ParamEnv, Ty, TyCtxt};
1623use rustc_session::config::{self, CrateType, ErrorOutputType, ResolveDocLinks};
17use rustc_session::lint;
18use rustc_session::Session;
24pub(crate) use rustc_session::config::{Options, UnstableOptions};
25use rustc_session::{lint, Session};
1926use rustc_span::symbol::sym;
2027use rustc_span::{source_map, Span};
2128
22use std::cell::RefCell;
23use std::io;
24use std::mem;
25use std::rc::Rc;
26use std::sync::LazyLock;
27use std::sync::{atomic::AtomicBool, Arc};
28
2929use crate::clean::inline::build_external_trait;
3030use crate::clean::{self, ItemId};
3131use crate::config::{Options as RustdocOptions, OutputFormat, RenderOptions};
3232use crate::formats::cache::Cache;
33use crate::passes::{self, Condition::*};
34
35pub(crate) use rustc_session::config::{Options, UnstableOptions};
33use crate::passes::Condition::*;
34use crate::passes::{self};
3635
3736pub(crate) struct DocContext<'tcx> {
3837 pub(crate) tcx: TyCtxt<'tcx>,
src/librustdoc/docfs.rs+2-2
......@@ -9,11 +9,11 @@
99//! abstraction.
1010
1111use std::cmp::max;
12use std::fs;
13use std::io;
1412use std::path::{Path, PathBuf};
1513use std::sync::mpsc::Sender;
1614use std::thread::available_parallelism;
15use std::{fs, io};
16
1717use threadpool::ThreadPool;
1818
1919pub(crate) trait PathError {
src/librustdoc/doctest.rs+9-13
......@@ -2,9 +2,16 @@ mod make;
22mod markdown;
33mod rust;
44
5use std::fs::File;
6use std::io::{self, Write};
7use std::path::{Path, PathBuf};
8use std::process::{self, Command, Stdio};
9use std::sync::atomic::{AtomicUsize, Ordering};
10use std::sync::{Arc, Mutex};
11use std::{panic, str};
12
513pub(crate) use make::make_test;
614pub(crate) use markdown::test as test_markdown;
7
815use rustc_ast as ast;
916use rustc_data_structures::fx::{FxHashMap, FxHashSet};
1017use rustc_errors::{ColorConfig, DiagCtxtHandle, ErrorGuaranteed, FatalError};
......@@ -17,24 +24,13 @@ use rustc_span::edition::Edition;
1724use rustc_span::symbol::sym;
1825use rustc_span::FileName;
1926use rustc_target::spec::{Target, TargetTriple};
20
21use std::fs::File;
22use std::io::{self, Write};
23use std::panic;
24use std::path::{Path, PathBuf};
25use std::process::{self, Command, Stdio};
26use std::str;
27use std::sync::atomic::{AtomicUsize, Ordering};
28use std::sync::{Arc, Mutex};
29
3027use tempfile::{Builder as TempFileBuilder, TempDir};
3128
29use self::rust::HirCollector;
3230use crate::config::Options as RustdocOptions;
3331use crate::html::markdown::{ErrorCodes, Ignore, LangString, MdRelLine};
3432use crate::lint::init_lints;
3533
36use self::rust::HirCollector;
37
3834/// Options that apply to all doctests in a crate or Markdown file (for `rustdoc foo.md`).
3935#[derive(Clone)]
4036pub(crate) struct GlobalTestOptions {
src/librustdoc/doctest/rust.rs+4-2
......@@ -2,7 +2,8 @@
22
33use std::env;
44
5use rustc_data_structures::{fx::FxHashSet, sync::Lrc};
5use rustc_data_structures::fx::FxHashSet;
6use rustc_data_structures::sync::Lrc;
67use rustc_hir::def_id::{LocalDefId, CRATE_DEF_ID};
78use rustc_hir::{self as hir, intravisit, CRATE_HIR_ID};
89use rustc_middle::hir::map::Map;
......@@ -14,7 +15,8 @@ use rustc_span::source_map::SourceMap;
1415use rustc_span::{BytePos, FileName, Pos, Span, DUMMY_SP};
1516
1617use super::{DoctestVisitor, ScrapedDoctest};
17use crate::clean::{types::AttributesExt, Attributes};
18use crate::clean::types::AttributesExt;
19use crate::clean::Attributes;
1820use crate::html::markdown::{self, ErrorCodes, LangString, MdRelLine};
1921
2022struct RustCollector {
src/librustdoc/doctest/tests.rs+2-1
......@@ -1,8 +1,9 @@
11use std::path::PathBuf;
22
3use super::{make_test, GlobalTestOptions};
43use rustc_span::edition::DEFAULT_EDITION;
54
5use super::{make_test, GlobalTestOptions};
6
67/// Default [`GlobalTestOptions`] for these unit tests.
78fn default_global_opts(crate_name: impl Into<String>) -> GlobalTestOptions {
89 GlobalTestOptions {
src/librustdoc/externalfiles.rs+5-5
......@@ -1,12 +1,12 @@
1use crate::html::markdown::{ErrorCodes, HeadingOffset, IdMap, Markdown, Playground};
2use rustc_errors::DiagCtxtHandle;
3use rustc_span::edition::Edition;
4use std::fs;
51use std::path::Path;
6use std::str;
2use std::{fs, str};
73
4use rustc_errors::DiagCtxtHandle;
5use rustc_span::edition::Edition;
86use serde::Serialize;
97
8use crate::html::markdown::{ErrorCodes, HeadingOffset, IdMap, Markdown, Playground};
9
1010#[derive(Clone, Debug, Serialize)]
1111pub(crate) struct ExternalHtml {
1212 /// 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};
55use rustc_middle::ty::{self, TyCtxt};
66use rustc_span::Symbol;
77
8use crate::clean::{self, types::ExternalLocation, ExternalCrate, ItemId, PrimitiveType};
8use crate::clean::types::ExternalLocation;
9use crate::clean::{self, ExternalCrate, ItemId, PrimitiveType};
910use crate::core::DocContext;
1011use crate::fold::DocFolder;
1112use crate::formats::item_type::ItemType;
src/librustdoc/formats/item_type.rs+1-2
......@@ -2,10 +2,9 @@
22
33use std::fmt;
44
5use serde::{Serialize, Serializer};
6
75use rustc_hir::def::{CtorOf, DefKind};
86use rustc_span::hygiene::MacroKind;
7use serde::{Serialize, Serializer};
98
109use crate::clean;
1110
src/librustdoc/formats/mod.rs+1-2
......@@ -2,9 +2,8 @@ pub(crate) mod cache;
22pub(crate) mod item_type;
33pub(crate) mod renderer;
44
5use rustc_hir::def_id::DefId;
6
75pub(crate) use renderer::{run_format, FormatRenderer};
6use rustc_hir::def_id::DefId;
87
98use crate::clean::{self, ItemId};
109use crate::html::render::Context;
src/librustdoc/html/format.rs+6-10
......@@ -12,11 +12,10 @@ use std::cell::Cell;
1212use std::fmt::{self, Display, Write};
1313use std::iter::{self, once};
1414
15use rustc_ast as ast;
15use itertools::Itertools;
1616use rustc_attr::{ConstStability, StabilityLevel, StableSince};
1717use rustc_data_structures::captures::Captures;
1818use rustc_data_structures::fx::FxHashSet;
19use rustc_hir as hir;
2019use rustc_hir::def::DefKind;
2120use rustc_hir::def_id::{DefId, LOCAL_CRATE};
2221use rustc_metadata::creader::{CStore, LoadedMacro};
......@@ -25,21 +24,18 @@ use rustc_middle::ty::TyCtxt;
2524use rustc_span::symbol::kw;
2625use rustc_span::{sym, Symbol};
2726use rustc_target::spec::abi::Abi;
27use {rustc_ast as ast, rustc_hir as hir};
2828
29use itertools::Itertools;
30
31use crate::clean::{
32 self, types::ExternalLocation, utils::find_nearest_parent_module, ExternalCrate, PrimitiveType,
33};
29use super::url_parts_builder::{estimate_item_path_byte_length, UrlPartsBuilder};
30use crate::clean::types::ExternalLocation;
31use crate::clean::utils::find_nearest_parent_module;
32use crate::clean::{self, ExternalCrate, PrimitiveType};
3433use crate::formats::cache::Cache;
3534use crate::formats::item_type::ItemType;
3635use crate::html::escape::Escape;
3736use crate::html::render::Context;
3837use crate::passes::collect_intra_doc_links::UrlFragment;
3938
40use super::url_parts_builder::estimate_item_path_byte_length;
41use super::url_parts_builder::UrlPartsBuilder;
42
4339pub(crate) trait Print {
4440 fn print(self, buffer: &mut Buffer);
4541}
src/librustdoc/html/highlight.rs+3-4
......@@ -5,10 +5,6 @@
55//!
66//! Use the `render_with_highlighting` to highlight some rust code.
77
8use crate::clean::PrimitiveType;
9use crate::html::escape::EscapeBodyText;
10use crate::html::render::{Context, LinkFromSrc};
11
128use std::collections::VecDeque;
139use std::fmt::{Display, Write};
1410
......@@ -19,6 +15,9 @@ use rustc_span::symbol::Symbol;
1915use rustc_span::{BytePos, Span, DUMMY_SP};
2016
2117use super::format::{self, Buffer};
18use crate::clean::PrimitiveType;
19use crate::html::escape::EscapeBodyText;
20use crate::html::render::{Context, LinkFromSrc};
2221
2322/// This type is needed in case we want to render links on items to allow to go to their definition.
2423pub(crate) struct HrefContext<'a, 'tcx> {
src/librustdoc/html/highlight/tests.rs+3-2
......@@ -1,9 +1,10 @@
1use super::{write_code, DecorationInfo};
2use crate::html::format::Buffer;
31use expect_test::expect_file;
42use rustc_data_structures::fx::FxHashMap;
53use rustc_span::create_default_session_globals_then;
64
5use super::{write_code, DecorationInfo};
6use crate::html::format::Buffer;
7
78const STYLE: &str = r#"
89<style>
910.kw { color: #8959A8; }
src/librustdoc/html/layout.rs+2-4
......@@ -1,15 +1,13 @@
11use std::path::PathBuf;
22
3use rinja::Template;
34use rustc_data_structures::fx::FxHashMap;
45
6use super::static_files::{StaticFiles, STATIC_FILES};
57use crate::externalfiles::ExternalHtml;
68use crate::html::format::{Buffer, Print};
79use crate::html::render::{ensure_trailing_slash, StylePath};
810
9use rinja::Template;
10
11use super::static_files::{StaticFiles, STATIC_FILES};
12
1311#[derive(Clone)]
1412pub(crate) struct Layout {
1513 pub(crate) logo: String,
src/librustdoc/html/markdown.rs+13-14
......@@ -25,15 +25,6 @@
2525//! // ... something using html
2626//! ```
2727
28use rustc_data_structures::fx::FxHashMap;
29use rustc_errors::{Diag, DiagMessage};
30use rustc_hir::def_id::DefId;
31use rustc_middle::ty::TyCtxt;
32pub(crate) use rustc_resolve::rustdoc::main_body_opts;
33use rustc_resolve::rustdoc::may_be_doc_link;
34use rustc_span::edition::Edition;
35use rustc_span::{Span, Symbol};
36
3728use std::borrow::Cow;
3829use std::collections::VecDeque;
3930use std::fmt::Write;
......@@ -43,6 +34,19 @@ use std::path::PathBuf;
4334use std::str::{self, CharIndices};
4435use std::sync::OnceLock;
4536
37use pulldown_cmark::{
38 html, BrokenLink, BrokenLinkCallback, CodeBlockKind, CowStr, Event, LinkType, OffsetIter,
39 Options, Parser, Tag, TagEnd,
40};
41use rustc_data_structures::fx::FxHashMap;
42use rustc_errors::{Diag, DiagMessage};
43use rustc_hir::def_id::DefId;
44use rustc_middle::ty::TyCtxt;
45pub(crate) use rustc_resolve::rustdoc::main_body_opts;
46use rustc_resolve::rustdoc::may_be_doc_link;
47use rustc_span::edition::Edition;
48use rustc_span::{Span, Symbol};
49
4650use crate::clean::RenderedLink;
4751use crate::doctest;
4852use crate::doctest::GlobalTestOptions;
......@@ -53,11 +57,6 @@ use crate::html::length_limit::HtmlWithLimit;
5357use crate::html::render::small_url_encode;
5458use crate::html::toc::TocBuilder;
5559
56use pulldown_cmark::{
57 html, BrokenLink, BrokenLinkCallback, CodeBlockKind, CowStr, Event, LinkType, OffsetIter,
58 Options, Parser, Tag, TagEnd,
59};
60
6160#[cfg(test)]
6261mod tests;
6362
src/librustdoc/html/markdown/tests.rs+4-4
......@@ -1,9 +1,9 @@
1use super::{find_testable_code, plain_text_summary, short_markdown_summary};
1use rustc_span::edition::{Edition, DEFAULT_EDITION};
2
23use 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,
56};
6use rustc_span::edition::{Edition, DEFAULT_EDITION};
77
88#[test]
99fn test_unique_id() {
src/librustdoc/html/render/context.rs+5-8
......@@ -5,6 +5,7 @@ use std::path::{Path, PathBuf};
55use std::rc::Rc;
66use std::sync::mpsc::{channel, Receiver};
77
8use rinja::Template;
89use rustc_data_structures::fx::{FxHashMap, FxHashSet};
910use rustc_hir::def_id::{DefIdMap, LOCAL_CRATE};
1011use rustc_middle::ty::TyCtxt;
......@@ -14,15 +15,12 @@ use rustc_span::{sym, FileName, Symbol};
1415
1516use super::print_item::{full_path, item_path, print_item};
1617use super::search_index::build_index;
18use super::sidebar::{print_sidebar, sidebar_module_like, Sidebar};
1719use super::write_shared::write_shared;
18use super::{
19 collect_spans_and_sources, scrape_examples_help,
20 sidebar::print_sidebar,
21 sidebar::{sidebar_module_like, Sidebar},
22 AllTypes, LinkFromSrc, StylePath,
23};
20use super::{collect_spans_and_sources, scrape_examples_help, AllTypes, LinkFromSrc, StylePath};
21use crate::clean::types::ExternalLocation;
2422use crate::clean::utils::has_doc_flag;
25use crate::clean::{self, types::ExternalLocation, ExternalCrate};
23use crate::clean::{self, ExternalCrate};
2624use crate::config::{ModuleSorting, RenderOptions};
2725use crate::docfs::{DocFS, PathError};
2826use crate::error::Error;
......@@ -36,7 +34,6 @@ use crate::html::url_parts_builder::UrlPartsBuilder;
3634use crate::html::{layout, sources, static_files};
3735use crate::scrape_examples::AllCallLocations;
3836use crate::try_err;
39use rinja::Template;
4037
4138/// Major driving force in all rustdoc rendering. This contains information
4239/// 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;
3535mod type_layout;
3636mod write_shared;
3737
38pub(crate) use self::context::*;
39pub(crate) use self::span_map::{collect_spans_and_sources, LinkFromSrc};
40
4138use std::collections::VecDeque;
4239use std::fmt::{self, Write};
43use std::fs;
4440use std::iter::Peekable;
4541use std::path::PathBuf;
4642use std::rc::Rc;
47use std::str;
43use std::{fs, str};
4844
4945use rinja::Template;
5046use rustc_attr::{ConstStability, DeprecatedSince, Deprecation, StabilityLevel, StableSince};
......@@ -55,13 +51,13 @@ use rustc_hir::Mutability;
5551use rustc_middle::ty::print::PrintTraitRefExt;
5652use rustc_middle::ty::{self, TyCtxt};
5753use rustc_session::RustcVersion;
58use rustc_span::{
59 symbol::{sym, Symbol},
60 BytePos, FileName, RealFileName, DUMMY_SP,
61};
54use rustc_span::symbol::{sym, Symbol};
55use rustc_span::{BytePos, FileName, RealFileName, DUMMY_SP};
6256use serde::ser::SerializeMap;
6357use serde::{Serialize, Serializer};
6458
59pub(crate) use self::context::*;
60pub(crate) use self::span_map::{collect_spans_and_sources, LinkFromSrc};
6561use crate::clean::{self, ItemId, RenderedLink, SelfTy};
6662use crate::error::Error;
6763use crate::formats::cache::Cache;
......@@ -73,15 +69,13 @@ use crate::html::format::{
7369 print_default_space, print_generic_bounds, print_where_clause, visibility_print_with_space,
7470 Buffer, Ending, HrefError, PrintWithSpace,
7571};
76use crate::html::highlight;
7772use crate::html::markdown::{
7873 HeadingOffset, IdMap, Markdown, MarkdownItemInfo, MarkdownSummaryLine,
7974};
80use crate::html::sources;
8175use crate::html::static_files::SCRAPE_EXAMPLES_HELP_MD;
76use crate::html::{highlight, sources};
8277use crate::scrape_examples::{CallData, CallLocation};
83use crate::try_none;
84use crate::DOC_RUST_LANG_ORG_CHANNEL;
78use crate::{try_none, DOC_RUST_LANG_ORG_CHANNEL};
8579
8680pub(crate) fn ensure_trailing_slash(v: &str) -> impl fmt::Display + '_ {
8781 crate::html::format::display_fn(move |f| {
src/librustdoc/html/render/print_item.rs+7-7
......@@ -1,3 +1,10 @@
1use std::cell::{RefCell, RefMut};
2use std::cmp::Ordering;
3use std::fmt;
4use std::rc::Rc;
5
6use itertools::Itertools;
7use rinja::Template;
18use rustc_data_structures::captures::Captures;
29use rustc_data_structures::fx::{FxHashMap, FxHashSet};
310use rustc_hir as hir;
......@@ -8,10 +15,6 @@ use rustc_middle::ty::{self, TyCtxt};
815use rustc_span::hygiene::MacroKind;
916use rustc_span::symbol::{kw, sym, Symbol};
1017use rustc_target::abi::VariantIdx;
11use std::cell::{RefCell, RefMut};
12use std::cmp::Ordering;
13use std::fmt;
14use std::rc::Rc;
1518
1619use super::type_layout::document_type_layout;
1720use super::{
......@@ -36,9 +39,6 @@ use crate::html::markdown::{HeadingOffset, MarkdownSummaryLine};
3639use crate::html::render::{document_full, document_item_info};
3740use crate::html::url_parts_builder::UrlPartsBuilder;
3841
39use itertools::Itertools;
40use rinja::Template;
41
4242/// Generates a Rinja template struct for rendering items with common methods.
4343///
4444/// Usage:
src/librustdoc/html/render/search_index.rs+1-2
......@@ -3,6 +3,7 @@ pub(crate) mod encode;
33use std::collections::hash_map::Entry;
44use std::collections::{BTreeMap, VecDeque};
55
6use encode::{bitmap_to_string, write_vlqhex_to_string};
67use rustc_data_structures::fx::{FxHashMap, FxIndexMap};
78use rustc_middle::ty::TyCtxt;
89use rustc_span::def_id::DefId;
......@@ -19,8 +20,6 @@ use crate::html::format::join_with_double_colon;
1920use crate::html::markdown::short_markdown_summary;
2021use crate::html::render::{self, IndexItem, IndexItemFunctionType, RenderType, RenderTypeId};
2122
22use encode::{bitmap_to_string, write_vlqhex_to_string};
23
2423/// The serialized search description sharded version
2524///
2625/// The `index` is a JSON-encoded list of names and other information.
src/librustdoc/html/render/sidebar.rs+9-8
......@@ -1,17 +1,18 @@
1use std::{borrow::Cow, rc::Rc};
1use std::borrow::Cow;
2use std::rc::Rc;
23
34use rinja::Template;
45use rustc_data_structures::fx::FxHashSet;
5use rustc_hir::{def::CtorKind, def_id::DefIdSet};
6use rustc_hir::def::CtorKind;
7use rustc_hir::def_id::DefIdSet;
68use rustc_middle::ty::{self, TyCtxt};
79
8use crate::{
9 clean,
10 formats::{item_type::ItemType, Impl},
11 html::{format::Buffer, markdown::IdMap},
12};
13
1410use super::{item_ty_to_section, Context, ItemSection};
11use crate::clean;
12use crate::formats::item_type::ItemType;
13use crate::formats::Impl;
14use crate::html::format::Buffer;
15use crate::html::markdown::IdMap;
1516
1617#[derive(Template)]
1718#[template(path = "sidebar.html")]
src/librustdoc/html/render/span_map.rs+3-3
......@@ -1,5 +1,4 @@
1use crate::clean::{self, rustc_span, PrimitiveType};
2use crate::html::sources;
1use std::path::{Path, PathBuf};
32
43use rustc_data_structures::fx::FxHashMap;
54use rustc_hir::def::{DefKind, Res};
......@@ -11,7 +10,8 @@ use rustc_middle::ty::TyCtxt;
1110use rustc_span::hygiene::MacroKind;
1211use rustc_span::{BytePos, ExpnKind, Span};
1312
14use std::path::{Path, PathBuf};
13use crate::clean::{self, rustc_span, PrimitiveType};
14use crate::html::sources;
1515
1616/// This enum allows us to store two different kinds of information:
1717///
src/librustdoc/html/render/type_layout.rs+4-4
......@@ -1,14 +1,14 @@
1use rinja::Template;
1use std::fmt;
22
3use rinja::Template;
34use rustc_data_structures::captures::Captures;
45use rustc_hir::def_id::DefId;
56use rustc_middle::span_bug;
6use rustc_middle::ty::{self, layout::LayoutError};
7use rustc_middle::ty::layout::LayoutError;
8use rustc_middle::ty::{self};
79use rustc_span::symbol::Symbol;
810use rustc_target::abi::{Primitive, TagEncoding, Variants};
911
10use std::fmt;
11
1212use crate::html::format::display_fn;
1313use crate::html::render::Context;
1414
src/librustdoc/html/sources.rs+13-16
......@@ -1,12 +1,9 @@
1use crate::clean;
2use crate::clean::utils::has_doc_flag;
3use crate::docfs::PathError;
4use crate::error::Error;
5use crate::html::format;
6use crate::html::highlight;
7use crate::html::layout;
8use crate::html::render::Context;
9use crate::visit::DocVisitor;
1use std::cell::RefCell;
2use std::ffi::OsStr;
3use std::ops::RangeInclusive;
4use std::path::{Component, Path, PathBuf};
5use std::rc::Rc;
6use std::{fmt, fs};
107
118use rinja::Template;
129use rustc_data_structures::fx::{FxHashMap, FxHashSet};
......@@ -15,13 +12,13 @@ use rustc_middle::ty::TyCtxt;
1512use rustc_session::Session;
1613use rustc_span::{sym, FileName};
1714
18use std::cell::RefCell;
19use std::ffi::OsStr;
20use std::fmt;
21use std::fs;
22use std::ops::RangeInclusive;
23use std::path::{Component, Path, PathBuf};
24use std::rc::Rc;
15use crate::clean;
16use crate::clean::utils::has_doc_flag;
17use crate::docfs::PathError;
18use crate::error::Error;
19use crate::html::render::Context;
20use crate::html::{format, highlight, layout};
21use crate::visit::DocVisitor;
2522
2623pub(crate) fn render(cx: &mut Context<'_>, krate: &clean::Crate) -> Result<(), Error> {
2724 info!("emitting source files");
src/librustdoc/html/static_files.rs+2-1
......@@ -3,11 +3,12 @@
33//! All the static files are included here for centralized access in case anything other than the
44//! HTML rendering code (say, the theme checker) needs to access one of these files.
55
6use rustc_data_structures::fx::FxHasher;
76use std::hash::Hasher;
87use std::path::{Path, PathBuf};
98use std::{fmt, str};
109
10use rustc_data_structures::fx::FxHasher;
11
1112pub(crate) struct StaticFile {
1213 pub(crate) filename: PathBuf,
1314 pub(crate) bytes: &'static [u8],
src/librustdoc/html/tests.rs+2-1
......@@ -1,6 +1,7 @@
1use crate::html::format::href_relative_parts;
21use rustc_span::{sym, Symbol};
32
3use crate::html::format::href_relative_parts;
4
45fn assert_relative_path(expected: &[Symbol], relative_to_fqp: &[Symbol], fqp: &[Symbol]) {
56 // No `create_default_session_globals_then` call is needed here because all
67 // 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;
88
99use rustc_ast::ast;
1010use rustc_attr::DeprecatedSince;
11use rustc_hir::{def::CtorKind, def::DefKind, def_id::DefId};
11use rustc_hir::def::{CtorKind, DefKind};
12use rustc_hir::def_id::DefId;
1213use rustc_metadata::rendered_const;
1314use rustc_middle::bug;
1415use rustc_middle::ty::{self, TyCtxt};
1516use rustc_span::symbol::sym;
1617use rustc_span::{Pos, Symbol};
1718use rustc_target::spec::abi::Abi as RustcAbi;
18
1919use rustdoc_json_types::*;
2020
2121use crate::clean::{self, ItemId};
src/librustdoc/json/import_finder.rs+2-4
......@@ -1,9 +1,7 @@
11use rustc_hir::def_id::DefIdSet;
22
3use crate::{
4 clean::{self, Import, ImportSource, Item},
5 fold::DocFolder,
6};
3use crate::clean::{self, Import, ImportSource, Item};
4use crate::fold::DocFolder;
75
86/// Get the id's of all items that are `pub use`d in the crate.
97///
src/librustdoc/json/mod.rs-1
......@@ -18,7 +18,6 @@ use rustc_hir::def_id::{DefId, DefIdSet};
1818use rustc_middle::ty::TyCtxt;
1919use rustc_session::Session;
2020use rustc_span::def_id::LOCAL_CRATE;
21
2221use rustdoc_json_types as types;
2322
2423use crate::clean::types::{ExternalCrate, ExternalLocation};
src/librustdoc/lib.rs+2-1
......@@ -75,7 +75,8 @@ extern crate jemalloc_sys;
7575use std::env::{self, VarError};
7676use std::io::{self, IsTerminal};
7777use std::process;
78use std::sync::{atomic::AtomicBool, Arc};
78use std::sync::atomic::AtomicBool;
79use std::sync::Arc;
7980
8081use rustc_errors::{DiagCtxtHandle, ErrorGuaranteed, FatalError};
8182use rustc_interface::interface;
src/librustdoc/lint.rs+2-2
......@@ -1,10 +1,10 @@
1use std::sync::LazyLock as Lazy;
2
13use rustc_data_structures::fx::FxHashMap;
24use rustc_lint::LintStore;
35use rustc_lint_defs::{declare_tool_lint, Lint, LintId};
46use rustc_session::{lint, Session};
57
6use std::sync::LazyLock as Lazy;
7
88/// This function is used to setup the lint initialization. By default, in rustdoc, everything
99/// is "allowed". Depending if we run in test mode or not, we want some of them to be at their
1010/// 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 @@
11//! Calculates information used for the --show-coverage flag.
22
3use crate::clean;
4use crate::core::DocContext;
5use crate::html::markdown::{find_testable_code, ErrorCodes};
6use crate::passes::check_doc_test_visibility::{should_have_doc_example, Tests};
7use crate::passes::Pass;
8use crate::visit::DocVisitor;
3use std::collections::BTreeMap;
4use std::ops;
5
96use rustc_hir as hir;
107use rustc_lint::builtin::MISSING_DOCS;
118use rustc_middle::lint::LintLevelSource;
......@@ -13,8 +10,12 @@ use rustc_session::lint;
1310use rustc_span::FileName;
1411use serde::Serialize;
1512
16use std::collections::BTreeMap;
17use std::ops;
13use crate::clean;
14use crate::core::DocContext;
15use crate::html::markdown::{find_testable_code, ErrorCodes};
16use crate::passes::check_doc_test_visibility::{should_have_doc_example, Tests};
17use crate::passes::Pass;
18use crate::visit::DocVisitor;
1819
1920pub(crate) const CALCULATE_DOC_COVERAGE: Pass = Pass {
2021 name: "calculate-doc-coverage",
src/librustdoc/passes/check_doc_test_visibility.rs+4-3
......@@ -5,6 +5,10 @@
55//! - MISSING_DOC_CODE_EXAMPLES: this lint is **UNSTABLE** and looks for public items missing doctests.
66//! - PRIVATE_DOC_TESTS: this lint is **STABLE** and looks for private items with doctests.
77
8use rustc_hir as hir;
9use rustc_middle::lint::LintLevelSource;
10use rustc_session::lint;
11
812use super::Pass;
913use crate::clean;
1014use crate::clean::utils::inherits_doc_hidden;
......@@ -12,9 +16,6 @@ use crate::clean::*;
1216use crate::core::DocContext;
1317use crate::html::markdown::{find_testable_code, ErrorCodes, Ignore, LangString, MdRelLine};
1418use crate::visit::DocVisitor;
15use rustc_hir as hir;
16use rustc_middle::lint::LintLevelSource;
17use rustc_session::lint;
1819
1920pub(crate) const CHECK_DOC_TEST_VISIBILITY: Pass = Pass {
2021 name: "check_doc_test_visibility",
src/librustdoc/passes/collect_intra_doc_links.rs+11-13
......@@ -2,12 +2,15 @@
22//!
33//! [RFC 1946]: https://github.com/rust-lang/rfcs/blob/master/text/1946-intra-rustdoc-links.md
44
5use std::borrow::Cow;
6use std::fmt::Display;
7use std::mem;
8use std::ops::Range;
9
510use pulldown_cmark::LinkType;
611use rustc_ast::util::comments::may_have_doc_links;
7use rustc_data_structures::{
8 fx::{FxHashMap, FxHashSet},
9 intern::Interned,
10};
12use rustc_data_structures::fx::{FxHashMap, FxHashSet};
13use rustc_data_structures::intern::Interned;
1114use rustc_errors::{Applicability, Diag, DiagMessage};
1215use rustc_hir::def::Namespace::*;
1316use rustc_hir::def::{DefKind, Namespace, PerNS};
......@@ -15,9 +18,9 @@ use rustc_hir::def_id::{DefId, CRATE_DEF_ID};
1518use rustc_hir::{Mutability, Safety};
1619use rustc_middle::ty::{Ty, TyCtxt};
1720use rustc_middle::{bug, span_bug, ty};
18use rustc_resolve::rustdoc::{has_primitive_or_keyword_docs, prepare_to_doc_link_resolution};
1921use 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,
2124};
2225use rustc_session::lint::Lint;
2326use rustc_span::hygiene::MacroKind;
......@@ -25,13 +28,8 @@ use rustc_span::symbol::{sym, Ident, Symbol};
2528use rustc_span::BytePos;
2629use smallvec::{smallvec, SmallVec};
2730
28use std::borrow::Cow;
29use std::fmt::Display;
30use std::mem;
31use std::ops::Range;
32
33use crate::clean::{self, utils::find_nearest_parent_module};
34use crate::clean::{Crate, Item, ItemLink, PrimitiveType};
31use crate::clean::utils::find_nearest_parent_module;
32use crate::clean::{self, Crate, Item, ItemLink, PrimitiveType};
3533use crate::core::DocContext;
3634use crate::html::markdown::{markdown_links, MarkdownLink, MarkdownLinkRange};
3735use crate::lint::{BROKEN_INTRA_DOC_LINKS, PRIVATE_INTRA_DOC_LINKS};
src/librustdoc/passes/collect_trait_impls.rs+5-5
......@@ -2,17 +2,17 @@
22//! defines a struct that implements a trait, this pass will note that the
33//! struct implements that trait.
44
5use rustc_data_structures::fx::FxHashSet;
6use rustc_hir::def_id::{DefId, DefIdMap, DefIdSet, LOCAL_CRATE};
7use rustc_middle::ty;
8use rustc_span::symbol::sym;
9
510use super::Pass;
611use crate::clean::*;
712use crate::core::DocContext;
813use crate::formats::cache::Cache;
914use crate::visit::DocVisitor;
1015
11use rustc_data_structures::fx::FxHashSet;
12use rustc_hir::def_id::{DefId, DefIdMap, DefIdSet, LOCAL_CRATE};
13use rustc_middle::ty;
14use rustc_span::symbol::sym;
15
1616pub(crate) const COLLECT_TRAIT_IMPLS: Pass = Pass {
1717 name: "collect-trait-impls",
1818 run: collect_trait_impls,
src/librustdoc/passes/lint/bare_urls.rs+7-5
......@@ -1,16 +1,18 @@
11//! Detects links that are not linkified, e.g., in Markdown such as `Go to https://example.com/.`
22//! Suggests wrapping the link with angle brackets: `Go to <https://example.com/>.` to linkify it.
33
4use crate::clean::*;
5use crate::core::DocContext;
6use crate::html::markdown::main_body_opts;
74use core::ops::Range;
5use std::mem;
6use std::sync::LazyLock;
7
88use pulldown_cmark::{Event, Parser, Tag};
99use regex::Regex;
1010use rustc_errors::Applicability;
1111use rustc_resolve::rustdoc::source_span_for_markdown_range;
12use std::mem;
13use std::sync::LazyLock;
12
13use crate::clean::*;
14use crate::core::DocContext;
15use crate::html::markdown::main_body_opts;
1416
1517pub(super) fn visit_item(cx: &DocContext<'_>, item: &Item) {
1618 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 @@
11//! Validates syntax inside Rust code blocks (\`\`\`rust).
22
33use rustc_data_structures::sync::{Lock, Lrc};
4use rustc_errors::{
5 emitter::Emitter,
6 translation::{to_fluent_args, Translate},
7 Applicability, DiagCtxt, DiagInner, LazyFallbackBundle,
8};
4use rustc_errors::emitter::Emitter;
5use rustc_errors::translation::{to_fluent_args, Translate};
6use rustc_errors::{Applicability, DiagCtxt, DiagInner, LazyFallbackBundle};
97use rustc_parse::{source_str_to_stream, unwrap_or_emit_fatal};
108use rustc_resolve::rustdoc::source_span_for_markdown_range;
119use rustc_session::parse::ParseSess;
src/librustdoc/passes/lint/html_tags.rs+6-6
......@@ -1,15 +1,15 @@
11//! Detects invalid HTML (like an unclosed `<span>`) in doc comments.
22
3use crate::clean::*;
4use crate::core::DocContext;
5use crate::html::markdown::main_body_opts;
3use std::iter::Peekable;
4use std::ops::Range;
5use std::str::CharIndices;
66
77use pulldown_cmark::{BrokenLink, Event, LinkType, Parser, Tag, TagEnd};
88use rustc_resolve::rustdoc::source_span_for_markdown_range;
99
10use std::iter::Peekable;
11use std::ops::Range;
12use std::str::CharIndices;
10use crate::clean::*;
11use crate::core::DocContext;
12use crate::html::markdown::main_body_opts;
1313
1414pub(crate) fn visit_item(cx: &DocContext<'_>, item: &Item) {
1515 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
1212use rustc_span::def_id::DefId;
1313use rustc_span::Symbol;
1414
15use crate::clean::utils::find_nearest_parent_module;
16use crate::clean::utils::inherits_doc_hidden;
15use crate::clean::utils::{find_nearest_parent_module, inherits_doc_hidden};
1716use crate::clean::Item;
1817use crate::core::DocContext;
1918use crate::html::markdown::main_body_opts;
src/librustdoc/passes/lint/unescaped_backticks.rs+6-4
......@@ -1,13 +1,15 @@
11//! Detects unescaped backticks (\`) in doc comments.
22
3use crate::clean::Item;
4use crate::core::DocContext;
5use crate::html::markdown::main_body_opts;
3use std::ops::Range;
4
65use pulldown_cmark::{BrokenLink, Event, Parser};
76use rustc_errors::Diag;
87use rustc_lint_defs::Applicability;
98use rustc_resolve::rustdoc::source_span_for_markdown_range;
10use std::ops::Range;
9
10use crate::clean::Item;
11use crate::core::DocContext;
12use crate::html::markdown::main_body_opts;
1113
1214pub(crate) fn visit_item(cx: &DocContext<'_>, item: &Item) {
1315 let tcx = cx.tcx;
src/librustdoc/passes/lint/unportable_markdown.rs+6-5
......@@ -10,13 +10,14 @@
1010//!
1111//! <https://rustc-dev-guide.rust-lang.org/bug-fix-procedure.html#add-the-lint-to-the-list-of-removed-lists>
1212
13use crate::clean::Item;
14use crate::core::DocContext;
15use pulldown_cmark as cmarkn;
16use pulldown_cmark_old as cmarko;
13use std::collections::{BTreeMap, BTreeSet};
14
1715use rustc_lint_defs::Applicability;
1816use rustc_resolve::rustdoc::source_span_for_markdown_range;
19use std::collections::{BTreeMap, BTreeSet};
17use {pulldown_cmark as cmarkn, pulldown_cmark_old as cmarko};
18
19use crate::clean::Item;
20use crate::core::DocContext;
2021
2122pub(crate) fn visit_item(cx: &DocContext<'_>, item: &Item) {
2223 let tcx = cx.tcx;
src/librustdoc/passes/propagate_doc_cfg.rs+2-2
......@@ -2,6 +2,8 @@
22
33use std::sync::Arc;
44
5use rustc_hir::def_id::LocalDefId;
6
57use crate::clean::cfg::Cfg;
68use crate::clean::inline::{load_attrs, merge_attrs};
79use crate::clean::{Crate, Item, ItemKind};
......@@ -9,8 +11,6 @@ use crate::core::DocContext;
911use crate::fold::DocFolder;
1012use crate::passes::Pass;
1113
12use rustc_hir::def_id::LocalDefId;
13
1414pub(crate) const PROPAGATE_DOC_CFG: Pass = Pass {
1515 name: "propagate-doc-cfg",
1616 run: propagate_doc_cfg,
src/librustdoc/passes/strip_aliased_non_local.rs+1-2
......@@ -1,5 +1,4 @@
1use rustc_middle::ty::TyCtxt;
2use rustc_middle::ty::Visibility;
1use rustc_middle::ty::{TyCtxt, Visibility};
32
43use crate::clean;
54use crate::clean::Item;
src/librustdoc/passes/strip_hidden.rs+2-1
......@@ -1,9 +1,10 @@
11//! Strip all doc(hidden) items from the output.
22
3use std::mem;
4
35use rustc_hir::def_id::LocalDefId;
46use rustc_middle::ty::TyCtxt;
57use rustc_span::symbol::sym;
6use std::mem;
78
89use crate::clean;
910use crate::clean::utils::inherits_doc_hidden;
src/librustdoc/passes/stripper.rs+2-1
......@@ -1,8 +1,9 @@
11//! A collection of utility functions for the `strip_*` passes.
22
3use std::mem;
4
35use rustc_hir::def_id::DefId;
46use rustc_middle::ty::{TyCtxt, Visibility};
5use std::mem;
67
78use crate::clean::utils::inherits_doc_hidden;
89use crate::clean::{self, Item, ItemId, ItemIdSet};
src/librustdoc/scrape_examples.rs+12-20
......@@ -1,35 +1,27 @@
11//! This module analyzes crates to find call sites that can serve as examples in the documentation.
22
3use crate::clean;
4use crate::config;
5use crate::formats;
6use crate::formats::renderer::FormatRenderer;
7use crate::html::render::Context;
3use std::fs;
4use std::path::PathBuf;
85
96use rustc_data_structures::fx::FxHashMap;
107use rustc_errors::DiagCtxtHandle;
11use rustc_hir::{
12 self as hir,
13 intravisit::{self, Visitor},
14};
8use rustc_hir::intravisit::{self, Visitor};
9use rustc_hir::{self as hir};
1510use rustc_interface::interface;
1611use rustc_macros::{Decodable, Encodable};
1712use rustc_middle::hir::map::Map;
1813use rustc_middle::hir::nested_filter;
1914use rustc_middle::ty::{self, TyCtxt};
20use rustc_serialize::{
21 opaque::{FileEncoder, MemDecoder},
22 Decodable, Encodable,
23};
15use rustc_serialize::opaque::{FileEncoder, MemDecoder};
16use rustc_serialize::{Decodable, Encodable};
2417use rustc_session::getopts;
25use rustc_span::{
26 def_id::{CrateNum, DefPathHash, LOCAL_CRATE},
27 edition::Edition,
28 BytePos, FileName, SourceFile,
29};
18use rustc_span::def_id::{CrateNum, DefPathHash, LOCAL_CRATE};
19use rustc_span::edition::Edition;
20use rustc_span::{BytePos, FileName, SourceFile};
3021
31use std::fs;
32use std::path::PathBuf;
22use crate::formats::renderer::FormatRenderer;
23use crate::html::render::Context;
24use crate::{clean, config, formats};
3325
3426#[derive(Debug, Clone)]
3527pub(crate) struct ScrapeExamplesOptions {
src/librustdoc/theme.rs+1-1
......@@ -1,10 +1,10 @@
1use rustc_data_structures::fx::FxHashMap;
21use std::collections::hash_map::Entry;
32use std::fs;
43use std::iter::Peekable;
54use std::path::Path;
65use std::str::Chars;
76
7use rustc_data_structures::fx::FxHashMap;
88use rustc_errors::DiagCtxtHandle;
99
1010#[cfg(test)]
src/librustdoc/visit_ast.rs+4-3
......@@ -1,6 +1,8 @@
11//! The Rust AST Visitor. Extracts useful information and massages it into a form
22//! usable for `clean`.
33
4use std::mem;
5
46use rustc_data_structures::fx::{FxHashSet, FxIndexMap};
57use rustc_hir as hir;
68use rustc_hir::def::{DefKind, Res};
......@@ -14,10 +16,9 @@ use rustc_span::hygiene::MacroKind;
1416use rustc_span::symbol::{kw, sym, Symbol};
1517use rustc_span::Span;
1618
17use std::mem;
18
19use crate::clean::cfg::Cfg;
1920use crate::clean::utils::{inherits_doc_hidden, should_ignore_res};
20use crate::clean::{cfg::Cfg, reexport_chain, AttributesExt, NestedAttributesExt};
21use crate::clean::{reexport_chain, AttributesExt, NestedAttributesExt};
2122use crate::core;
2223
2324/// 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 @@
1use crate::core::DocContext;
21use rustc_hir::def::DefKind;
32use rustc_hir::def_id::{DefId, DefIdSet};
43use rustc_middle::ty::TyCtxt;
54
5use crate::core::DocContext;
6
67// FIXME: this may not be exhaustive, but is sufficient for rustdocs current uses
78
89#[derive(Default)]
src/rustdoc-json-types/lib.rs+2-1
......@@ -3,9 +3,10 @@
33//! These types are the public API exposed through the `--output-format json` flag. The [`Crate`]
44//! struct is the root of the JSON blob and all other items are contained within.
55
6use std::path::PathBuf;
7
68use rustc_hash::FxHashMap;
79use serde::{Deserialize, Serialize};
8use std::path::PathBuf;
910
1011/// rustdoc format-version.
1112pub const FORMAT_VERSION: u32 = 32;
src/tools/build-manifest/src/checksum.rs+5-3
......@@ -1,6 +1,3 @@
1use crate::manifest::{FileHash, Manifest};
2use rayon::prelude::*;
3use sha2::{Digest, Sha256};
41use std::collections::{HashMap, HashSet};
52use std::error::Error;
63use std::fs::File;
......@@ -9,6 +6,11 @@ use std::path::{Path, PathBuf};
96use std::sync::Mutex;
107use std::time::Instant;
118
9use rayon::prelude::*;
10use sha2::{Digest, Sha256};
11
12use crate::manifest::{FileHash, Manifest};
13
1214pub(crate) struct Checksums {
1315 cache_path: Option<PathBuf>,
1416 collected: Mutex<HashMap<PathBuf, String>>,
src/tools/build-manifest/src/main.rs+4-4
......@@ -4,13 +4,13 @@ mod checksum;
44mod manifest;
55mod versions;
66
7use std::collections::{BTreeMap, HashSet};
8use std::path::{Path, PathBuf};
9use std::{env, fs};
10
711use crate::checksum::Checksums;
812use crate::manifest::{Component, Manifest, Package, Rename, Target};
913use crate::versions::{PkgType, Versions};
10use std::collections::{BTreeMap, HashSet};
11use std::env;
12use std::fs;
13use std::path::{Path, PathBuf};
1414
1515static HOSTS: &[&str] = &[
1616 "aarch64-apple-darwin",
src/tools/build-manifest/src/manifest.rs+5-3
......@@ -1,9 +1,11 @@
1use crate::versions::PkgType;
2use crate::Builder;
3use serde::{Serialize, Serializer};
41use std::collections::BTreeMap;
52use std::path::{Path, PathBuf};
63
4use serde::{Serialize, Serializer};
5
6use crate::versions::PkgType;
7use crate::Builder;
8
79#[derive(Serialize)]
810#[serde(rename_all = "kebab-case")]
911pub(crate) struct Manifest {
src/tools/build-manifest/src/versions.rs+5-3
......@@ -1,9 +1,10 @@
1use anyhow::Error;
2use flate2::read::GzDecoder;
31use std::collections::HashMap;
42use std::fs::File;
53use std::io::Read;
64use std::path::{Path, PathBuf};
5
6use anyhow::Error;
7use flate2::read::GzDecoder;
78use tar::Archive;
89use xz2::read::XzDecoder;
910
......@@ -100,9 +101,10 @@ impl PkgType {
100101 }
101102
102103 pub(crate) fn targets(&self) -> &[&str] {
103 use crate::{HOSTS, MINGW, TARGETS};
104104 use PkgType::*;
105105
106 use crate::{HOSTS, MINGW, TARGETS};
107
106108 match self {
107109 Rust => HOSTS, // doesn't matter in practice, but return something to avoid panicking
108110 Rustc => HOSTS,
src/tools/build_helper/src/git.rs+2-2
......@@ -1,5 +1,5 @@
1use std::process::Stdio;
2use std::{path::Path, process::Command};
1use std::path::Path;
2use std::process::{Command, Stdio};
33
44pub struct GitConfig<'a> {
55 pub git_repository: &'a str,
src/tools/bump-stage0/src/main.rs+2-1
......@@ -1,10 +1,11 @@
11#![deny(unused_variables)]
22
3use std::collections::HashMap;
4
35use anyhow::{Context, Error};
46use build_helper::stage0_parser::{parse_stage0_file, Stage0Config, VersionMetadata};
57use curl::easy::Easy;
68use indexmap::IndexMap;
7use std::collections::HashMap;
89
910const PATH: &str = "src/stage0";
1011const COMPILER_COMPONENTS: &[&str] = &["rustc", "rust-std", "cargo", "clippy-preview"];
src/tools/cargotest/main.rs+1-2
......@@ -1,7 +1,6 @@
1use std::env;
2use std::fs;
31use std::path::{Path, PathBuf};
42use std::process::Command;
3use std::{env, fs};
54
65struct Test {
76 repo: &'static str,
src/tools/collect-license-metadata/src/main.rs+4-2
......@@ -2,10 +2,12 @@ mod licenses;
22mod path_tree;
33mod reuse;
44
5use crate::licenses::LicensesInterner;
6use anyhow::Error;
75use std::path::PathBuf;
86
7use anyhow::Error;
8
9use crate::licenses::LicensesInterner;
10
911fn main() -> Result<(), Error> {
1012 let reuse_exe: PathBuf = std::env::var_os("REUSE_EXE").expect("Missing REUSE_EXE").into();
1113 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 @@
33//! responsible for that, by turning the list of paths into a tree and executing simplification
44//! passes over the tree to remove redundant information.
55
6use crate::licenses::{License, LicenseId, LicensesInterner};
76use std::collections::BTreeMap;
87use std::path::{Path, PathBuf};
98
9use crate::licenses::{License, LicenseId, LicensesInterner};
10
1011#[derive(serde::Serialize)]
1112#[serde(rename_all = "kebab-case", tag = "type")]
1213pub(crate) enum Node<L> {
src/tools/collect-license-metadata/src/reuse.rs+4-2
......@@ -1,9 +1,11 @@
1use crate::licenses::{License, LicenseId, LicensesInterner};
2use anyhow::Error;
31use std::path::{Path, PathBuf};
42use std::process::{Command, Stdio};
53use std::time::Instant;
64
5use anyhow::Error;
6
7use crate::licenses::{License, LicenseId, LicensesInterner};
8
79pub(crate) fn collect(
810 reuse_exe: &Path,
911 interner: &mut LicensesInterner,
src/tools/compiletest/src/common.rs+5-6
......@@ -1,19 +1,18 @@
1pub use self::Mode::*;
2
1use std::collections::{HashMap, HashSet};
32use std::ffi::OsString;
4use std::fmt;
5use std::iter;
63use std::path::{Path, PathBuf};
74use std::process::Command;
85use std::str::FromStr;
96use std::sync::OnceLock;
7use std::{fmt, iter};
108
11use crate::util::{add_dylib_path, PathBufExt};
129use build_helper::git::GitConfig;
1310use serde::de::{Deserialize, Deserializer, Error as _};
14use std::collections::{HashMap, HashSet};
1511use test::{ColorConfig, OutputFormat};
1612
13pub use self::Mode::*;
14use crate::util::{add_dylib_path, PathBufExt};
15
1716macro_rules! string_enum {
1817 ($(#[$meta:meta])* $vis:vis enum $name:ident { $($variant:ident => $repr:expr,)* }) => {
1918 $(#[$meta])*
src/tools/compiletest/src/errors.rs+2-2
......@@ -1,5 +1,3 @@
1use self::WhichLine::*;
2
31use std::fmt;
42use std::fs::File;
53use std::io::prelude::*;
......@@ -11,6 +9,8 @@ use std::sync::OnceLock;
119use regex::Regex;
1210use tracing::*;
1311
12use self::WhichLine::*;
13
1414#[derive(Copy, Clone, Debug, PartialEq)]
1515pub enum ErrorKind {
1616 Help,
src/tools/compiletest/src/header.rs+1-2
......@@ -11,8 +11,7 @@ use regex::Regex;
1111use tracing::*;
1212
1313use crate::common::{Config, Debugger, FailMode, Mode, PassMode};
14use crate::header::cfg::parse_cfg_name_directive;
15use crate::header::cfg::MatchOutcome;
14use crate::header::cfg::{parse_cfg_name_directive, MatchOutcome};
1615use crate::header::needs::CachedNeedsConditions;
1716use crate::util::static_regex;
1817use crate::{extract_cdb_version, extract_gdb_version};
src/tools/compiletest/src/header/cfg.rs+2-1
......@@ -1,6 +1,7 @@
1use std::collections::HashSet;
2
13use crate::common::{CompareMode, Config, Debugger, Mode};
24use crate::header::IgnoreDecision;
3use std::collections::HashSet;
45
56const EXTRA_ARCHS: &[&str] = &["spirv"];
67
src/tools/compiletest/src/header/tests.rs+1-2
......@@ -2,11 +2,10 @@ use std::io::Read;
22use std::path::Path;
33use std::str::FromStr;
44
5use super::iter_header;
56use crate::common::{Config, Debugger, Mode};
67use crate::header::{parse_normalize_rule, EarlyProps, HeadersCache};
78
8use super::iter_header;
9
109fn make_test_description<R: Read>(
1110 config: &Config,
1211 name: test::TestName,
src/tools/compiletest/src/json.rs+5-3
......@@ -1,12 +1,14 @@
11//! These structs are a subset of the ones found in `rustc_errors::json`.
22//! They are only used for deserialization of JSON output provided by libtest.
33
4use crate::errors::{Error, ErrorKind};
5use crate::runtest::ProcRes;
6use serde::Deserialize;
74use std::path::{Path, PathBuf};
85use std::str::FromStr;
96
7use serde::Deserialize;
8
9use crate::errors::{Error, ErrorKind};
10use crate::runtest::ProcRes;
11
1012#[derive(Deserialize)]
1113struct Diagnostic {
1214 message: String,
src/tools/compiletest/src/lib.rs+9-7
......@@ -18,27 +18,29 @@ mod read2;
1818pub mod runtest;
1919pub mod util;
2020
21use crate::common::{expected_output_path, output_base_dir, output_relative_path, UI_EXTENSIONS};
22use crate::common::{Config, Debugger, Mode, PassMode, TestPaths};
23use crate::util::logv;
24use build_helper::git::{get_git_modified_files, get_git_untracked_files};
2521use core::panic;
26use getopts::Options;
2722use std::collections::HashSet;
2823use std::ffi::{OsStr, OsString};
29use std::fs;
3024use std::io::{self, ErrorKind};
3125use std::path::{Path, PathBuf};
3226use std::process::{Command, Stdio};
3327use std::sync::{Arc, OnceLock};
3428use std::time::SystemTime;
35use std::{env, vec};
29use std::{env, fs, vec};
30
31use build_helper::git::{get_git_modified_files, get_git_untracked_files};
32use getopts::Options;
3633use test::ColorConfig;
3734use tracing::*;
3835use walkdir::WalkDir;
3936
4037use self::header::{make_test_description, EarlyProps};
38use crate::common::{
39 expected_output_path, output_base_dir, output_relative_path, Config, Debugger, Mode, PassMode,
40 TestPaths, UI_EXTENSIONS,
41};
4142use crate::header::HeadersCache;
43use crate::util::logv;
4244
4345pub fn parse_config(args: Vec<String>) -> Config {
4446 let mut opts = Options::new();
src/tools/compiletest/src/main.rs+5-2
......@@ -1,6 +1,9 @@
1use std::{env, io::IsTerminal, sync::Arc};
1use std::env;
2use std::io::IsTerminal;
3use std::sync::Arc;
24
3use compiletest::{common::Mode, log_config, parse_config, run_tests};
5use compiletest::common::Mode;
6use compiletest::{log_config, parse_config, run_tests};
47
58fn main() {
69 tracing_subscriber::fmt::init();
src/tools/compiletest/src/raise_fd_limit.rs+1-2
......@@ -7,10 +7,9 @@
77#[cfg(target_vendor = "apple")]
88#[allow(non_camel_case_types)]
99pub unsafe fn raise_fd_limit() {
10 use std::cmp;
11 use std::io;
1210 use std::mem::size_of_val;
1311 use std::ptr::null_mut;
12 use std::{cmp, io};
1413
1514 static CTL_KERN: libc::c_int = 1;
1615 static KERN_MAXFILESPERPROC: libc::c_int = 29;
src/tools/compiletest/src/read2.rs+4-5
......@@ -4,10 +4,11 @@
44#[cfg(test)]
55mod tests;
66
7pub use self::imp::read2;
87use std::io::{self, Write};
98use std::process::{Child, Output};
109
10pub use self::imp::read2;
11
1112#[derive(Copy, Clone, Debug)]
1213pub enum Truncated {
1314 Yes,
......@@ -154,11 +155,10 @@ mod imp {
154155
155156#[cfg(unix)]
156157mod imp {
157 use std::io;
158158 use std::io::prelude::*;
159 use std::mem;
160159 use std::os::unix::prelude::*;
161160 use std::process::{ChildStderr, ChildStdout};
161 use std::{io, mem};
162162
163163 pub fn read2(
164164 mut out_pipe: ChildStdout,
......@@ -228,10 +228,9 @@ mod imp {
228228
229229#[cfg(windows)]
230230mod imp {
231 use std::io;
232231 use std::os::windows::prelude::*;
233232 use std::process::{ChildStderr, ChildStdout};
234 use std::slice;
233 use std::{io, slice};
235234
236235 use miow::iocp::{CompletionPort, CompletionStatus};
237236 use miow::pipe::NamedPipe;
src/tools/compiletest/src/runtest.rs+18-26
......@@ -1,45 +1,37 @@
11// ignore-tidy-filelength
22
3use crate::common::{
4 expected_output_path, UI_EXTENSIONS, UI_FIXED, UI_STDERR, UI_STDOUT, UI_SVG, UI_WINDOWS_SVG,
5};
6use crate::common::{incremental_dir, output_base_dir, output_base_name, output_testname_unique};
7use crate::common::{Assembly, Crashes, Incremental, JsDocTest, MirOpt, RunMake, RustdocJson, Ui};
8use crate::common::{Codegen, CodegenUnits, DebugInfo, Debugger, Rustdoc};
9use crate::common::{CompareMode, FailMode, PassMode};
10use crate::common::{Config, TestPaths};
11use crate::common::{CoverageMap, CoverageRun, Pretty, RunPassValgrind};
12use crate::common::{UI_RUN_STDERR, UI_RUN_STDOUT};
13use crate::compute_diff::{write_diff, write_filtered_diff};
14use crate::errors::{self, Error, ErrorKind};
15use crate::header::TestProps;
16use crate::json;
17use crate::read2::{read2_abbreviated, Truncated};
18use crate::util::{add_dylib_path, copy_dir_all, dylib_env_var, logv, static_regex, PathBufExt};
19use crate::ColorConfig;
20use colored::Colorize;
21use miropt_test_tools::{files_for_miropt_test, MiroptTest, MiroptTestFile};
22use regex::{Captures, Regex};
23use rustfix::{apply_suggestions, get_suggestions_from_json, Filter};
243use std::collections::{HashMap, HashSet};
25use std::env;
264use std::ffi::{OsStr, OsString};
275use std::fs::{self, create_dir_all, File, OpenOptions};
286use std::hash::{DefaultHasher, Hash, Hasher};
297use std::io::prelude::*;
308use std::io::{self, BufReader};
31use std::iter;
329use std::path::{Path, PathBuf};
3310use std::process::{Child, Command, ExitStatus, Output, Stdio};
34use std::str;
3511use std::sync::Arc;
12use std::{env, iter, str};
3613
3714use anyhow::Context;
15use colored::Colorize;
3816use glob::glob;
17use miropt_test_tools::{files_for_miropt_test, MiroptTest, MiroptTestFile};
18use regex::{Captures, Regex};
19use rustfix::{apply_suggestions, get_suggestions_from_json, Filter};
3920use tracing::*;
4021
41use crate::extract_gdb_version;
42use crate::is_android_gdb_target;
22use 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};
29use crate::compute_diff::{write_diff, write_filtered_diff};
30use crate::errors::{self, Error, ErrorKind};
31use crate::header::TestProps;
32use crate::read2::{read2_abbreviated, Truncated};
33use crate::util::{add_dylib_path, copy_dir_all, dylib_env_var, logv, static_regex, PathBufExt};
34use crate::{extract_gdb_version, is_android_gdb_target, json, ColorConfig};
4335
4436mod coverage;
4537mod debugger;
src/tools/compiletest/src/runtest/debugger.rs+4-4
......@@ -1,12 +1,12 @@
1use crate::common::Config;
2use crate::header::line_directive;
3use crate::runtest::ProcRes;
4
51use std::fmt::Write;
62use std::fs::File;
73use std::io::{BufRead, BufReader};
84use std::path::{Path, PathBuf};
95
6use crate::common::Config;
7use crate::header::line_directive;
8use crate::runtest::ProcRes;
9
1010/// Representation of information to invoke a debugger and check its output
1111pub(super) struct DebuggerCommands {
1212 /// Commands for the debuuger
src/tools/compiletest/src/util.rs+2-1
......@@ -1,4 +1,3 @@
1use crate::common::Config;
21use std::env;
32use std::ffi::OsStr;
43use std::path::{Path, PathBuf};
......@@ -6,6 +5,8 @@ use std::process::Command;
65
76use tracing::*;
87
8use crate::common::Config;
9
910#[cfg(test)]
1011mod tests;
1112
src/tools/coverage-dump/src/covfun.rs+5-3
......@@ -1,10 +1,12 @@
1use crate::parser::{unescape_llvm_string_contents, Parser};
2use anyhow::{anyhow, Context};
3use regex::Regex;
41use std::collections::HashMap;
52use std::fmt::{self, Debug, Write as _};
63use std::sync::OnceLock;
74
5use anyhow::{anyhow, Context};
6use regex::Regex;
7
8use crate::parser::{unescape_llvm_string_contents, Parser};
9
810pub(crate) fn dump_covfun_mappings(
911 llvm_ir: &str,
1012 function_names: &HashMap<u64, String>,
src/tools/coverage-dump/src/parser.rs+2-1
......@@ -1,9 +1,10 @@
11#[cfg(test)]
22mod tests;
33
4use std::sync::OnceLock;
5
46use anyhow::ensure;
57use regex::bytes;
6use std::sync::OnceLock;
78
89/// Given the raw contents of a string literal in LLVM IR assembly, decodes any
910/// 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 @@
1use crate::parser::{unescape_llvm_string_contents, Parser};
2use anyhow::{anyhow, ensure};
3use regex::Regex;
41use std::collections::HashMap;
52use std::sync::OnceLock;
63
4use anyhow::{anyhow, ensure};
5use regex::Regex;
6
7use crate::parser::{unescape_llvm_string_contents, Parser};
8
79/// Scans through the contents of an LLVM IR assembly file to find `__llvm_prf_names`
810/// entries, decodes them, and creates a table that maps name hash values to
911/// (demangled) function names.
src/tools/error_index_generator/main.rs+2-4
......@@ -5,18 +5,16 @@ extern crate rustc_log;
55extern crate rustc_session;
66
77extern crate rustc_errors;
8use rustc_errors::codes::DIAGNOSTICS;
9
108use std::env;
119use std::error::Error;
1210use std::fs::{self, File};
1311use std::io::Write;
14use std::path::Path;
15use std::path::PathBuf;
12use std::path::{Path, PathBuf};
1613use std::str::FromStr;
1714
1815use mdbook::book::{parse_summary, BookItem, Chapter};
1916use mdbook::{Config, MDBook};
17use rustc_errors::codes::DIAGNOSTICS;
2018
2119enum OutputFormat {
2220 HTML,
src/tools/generate-copyright/src/main.rs+2-1
......@@ -1,7 +1,8 @@
1use anyhow::Error;
21use std::io::Write;
32use std::path::PathBuf;
43
4use anyhow::Error;
5
56fn main() -> Result<(), Error> {
67 let dest = env_path("DEST")?;
78 let license_metadata = env_path("LICENSE_METADATA")?;
src/tools/generate-windows-sys/src/main.rs+1-2
......@@ -1,8 +1,7 @@
1use std::env;
21use std::error::Error;
3use std::fs;
42use std::io::{Read, Seek, SeekFrom, Write};
53use std::path::PathBuf;
4use std::{env, fs};
65
76/// 32-bit ARM is not supported by Microsoft so ARM types are not generated.
87/// 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 @@
1use rayon::iter::{ParallelBridge, ParallelIterator};
21use std::env;
32use std::path::Path;
43use std::process::{Command, Output};
54
5use rayon::iter::{ParallelBridge, ParallelIterator};
6
67fn check_html_file(file: &Path) -> usize {
78 let to_mute = &[
89 // "disabled" on <link> or "autocomplete" on <select> emit this warning
src/tools/jsondocck/src/cache.rs+3-2
......@@ -1,9 +1,10 @@
1use crate::config::Config;
2use serde_json::Value;
31use std::collections::HashMap;
42use std::path::Path;
53
64use fs_err as fs;
5use serde_json::Value;
6
7use crate::config::Config;
78
89#[derive(Debug)]
910pub struct Cache {
src/tools/jsondocck/src/error.rs+2-1
......@@ -1,7 +1,8 @@
1use crate::Command;
21use std::error::Error;
32use std::fmt;
43
4use crate::Command;
5
56#[derive(Debug)]
67pub enum CkError {
78 /// 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 @@
1use jsonpath_lib::select;
2use regex::{Regex, RegexBuilder};
3use serde_json::Value;
41use std::borrow::Cow;
52use std::sync::OnceLock;
63use std::{env, fmt, fs};
74
5use jsonpath_lib::select;
6use regex::{Regex, RegexBuilder};
7use serde_json::Value;
8
89mod cache;
910mod config;
1011mod error;
src/tools/jsondoclint/src/validator.rs+2-1
......@@ -9,7 +9,8 @@ use rustdoc_json_types::{
99};
1010use serde_json::Value;
1111
12use crate::{item_kind::Kind, json_find, Error, ErrorKind};
12use crate::item_kind::Kind;
13use crate::{json_find, Error, ErrorKind};
1314
1415// This is a rustc implementation detail that we rely on here
1516const LOCAL_CRATE_ID: u32 = 0;
src/tools/jsondoclint/src/validator/tests.rs+1-2
......@@ -1,9 +1,8 @@
11use rustc_hash::FxHashMap;
22use rustdoc_json_types::{Item, ItemKind, Visibility, FORMAT_VERSION};
33
4use crate::json_find::SelectorPart;
5
64use super::*;
5use crate::json_find::SelectorPart;
76
87#[track_caller]
98fn check(krate: &Crate, errs: &[Error]) {
src/tools/linkchecker/main.rs+6-6
......@@ -14,18 +14,18 @@
1414//! A few exceptions are allowed as there's known bugs in rustdoc, but this
1515//! should catch the majority of "broken link" cases.
1616
17use html5ever::tendril::ByteTendril;
18use html5ever::tokenizer::{
19 BufferQueue, TagToken, Token, TokenSink, TokenSinkResult, Tokenizer, TokenizerOpts,
20};
2117use std::cell::RefCell;
2218use std::collections::{HashMap, HashSet};
23use std::env;
24use std::fs;
2519use std::io::ErrorKind;
2620use std::path::{Component, Path, PathBuf};
2721use std::rc::Rc;
2822use std::time::Instant;
23use std::{env, fs};
24
25use html5ever::tendril::ByteTendril;
26use html5ever::tokenizer::{
27 BufferQueue, TagToken, Token, TokenSink, TokenSinkResult, Tokenizer, TokenizerOpts,
28};
2929
3030// Add linkcheck exceptions here
3131// 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 @@
1use crate::{Lint, LintExtractor};
21use std::collections::{BTreeMap, BTreeSet};
32use std::error::Error;
43use std::fmt::Write;
54use std::fs;
65use std::process::Command;
76
7use crate::{Lint, LintExtractor};
8
89/// Descriptions of rustc lint groups.
910static GROUP_DESCRIPTIONS: &[(&str, &str)] = &[
1011 ("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;
33use std::fs;
44use std::path::{Path, PathBuf};
55use std::process::Command;
6
67use walkdir::WalkDir;
78
89mod groups;
src/tools/lld-wrapper/src/main.rs+2-1
......@@ -11,7 +11,8 @@
1111//! obtained from the wrapper's name as the first two arguments.
1212//! On Windows it spawns a `..\rust-lld.exe` child process.
1313
14use std::env::{self, consts::EXE_SUFFIX};
14use std::env::consts::EXE_SUFFIX;
15use std::env::{self};
1516use std::fmt::Display;
1617use std::path::{Path, PathBuf};
1718use std::process;
src/tools/llvm-bitcode-linker/src/bin/llvm-bitcode-linker.rs-1
......@@ -1,7 +1,6 @@
11use std::path::PathBuf;
22
33use clap::Parser;
4
54use llvm_bitcode_linker::{Optimization, Session, Target};
65
76#[derive(Debug, Parser)]
src/tools/llvm-bitcode-linker/src/linker.rs+1-2
......@@ -2,8 +2,7 @@ use std::path::PathBuf;
22
33use anyhow::Context;
44
5use crate::Optimization;
6use crate::Target;
5use crate::{Optimization, Target};
76
87#[derive(Debug)]
98pub struct Session {
src/tools/llvm-bitcode-linker/src/opt.rs+1-2
......@@ -1,5 +1,4 @@
1use std::fmt::Display;
2use std::fmt::Formatter;
1use std::fmt::{Display, Formatter};
32
43#[derive(Debug, Clone, Copy, Default, Hash, Eq, PartialEq, clap::ValueEnum)]
54pub enum Optimization {
src/tools/opt-dist/src/bolt.rs+1-2
......@@ -1,9 +1,8 @@
11use anyhow::Context;
2use camino::{Utf8Path, Utf8PathBuf};
23
34use crate::exec::cmd;
45use crate::training::BoltProfile;
5use camino::{Utf8Path, Utf8PathBuf};
6
76use crate::utils::io::copy_file;
87
98/// 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 @@
1use std::collections::BTreeMap;
2use std::fs::File;
3use std::process::{Command, Stdio};
4
5use camino::{Utf8Path, Utf8PathBuf};
6
17use crate::environment::Environment;
28use crate::metrics::{load_metrics, record_metrics};
39use crate::timer::TimerSection;
410use crate::training::{BoltProfile, LlvmPGOProfile, RustcPGOProfile};
5use camino::{Utf8Path, Utf8PathBuf};
6use std::collections::BTreeMap;
7use std::fs::File;
8use std::process::{Command, Stdio};
911
1012#[derive(Default)]
1113pub struct CmdBuilder {
src/tools/opt-dist/src/main.rs+1-1
......@@ -1,10 +1,10 @@
1use crate::bolt::{bolt_optimize, with_bolt_instrumented};
21use anyhow::Context;
32use camino::{Utf8Path, Utf8PathBuf};
43use clap::Parser;
54use log::LevelFilter;
65use utils::io;
76
7use crate::bolt::{bolt_optimize, with_bolt_instrumented};
88use crate::environment::{Environment, EnvironmentBuilder};
99use crate::exec::{cmd, Bootstrap};
1010use crate::tests::run_tests;
src/tools/opt-dist/src/metrics.rs+4-2
......@@ -1,7 +1,9 @@
1use crate::timer::TimerSection;
1use std::time::Duration;
2
23use build_helper::metrics::{JsonNode, JsonRoot};
34use camino::Utf8Path;
4use std::time::Duration;
5
6use crate::timer::TimerSection;
57
68#[derive(Clone, Debug)]
79pub struct BuildStep {
src/tools/opt-dist/src/tests.rs+3-2
......@@ -1,8 +1,9 @@
1use anyhow::Context;
2use camino::{Utf8Path, Utf8PathBuf};
3
14use crate::environment::{executable_extension, Environment};
25use crate::exec::cmd;
36use crate::utils::io::{copy_directory, find_file_in_dir, unpack_archive};
4use anyhow::Context;
5use camino::{Utf8Path, Utf8PathBuf};
67
78/// Run tests on optimized dist artifacts.
89pub fn run_tests(env: &Environment) -> anyhow::Result<()> {
src/tools/opt-dist/src/training.rs+5-4
......@@ -1,12 +1,13 @@
1use crate::environment::{executable_extension, Environment};
2use crate::exec::{cmd, CmdBuilder};
3use crate::utils::io::{count_files, delete_directory};
4use crate::utils::with_log_group;
51use anyhow::Context;
62use build_helper::{LLVM_PGO_CRATES, RUSTC_PGO_CRATES};
73use camino::{Utf8Path, Utf8PathBuf};
84use humansize::BINARY;
95
6use crate::environment::{executable_extension, Environment};
7use crate::exec::{cmd, CmdBuilder};
8use crate::utils::io::{count_files, delete_directory};
9use crate::utils::with_log_group;
10
1011fn init_compiler_benchmarks(
1112 env: &Environment,
1213 profiles: &[&str],
src/tools/opt-dist/src/utils/artifact_size.rs+2-2
......@@ -9,10 +9,10 @@ use crate::environment::Environment;
99use crate::utils::io::get_files_from_dir;
1010
1111pub fn print_binary_sizes(env: &Environment) -> anyhow::Result<()> {
12 use humansize::format_size;
13 use humansize::BINARY;
1412 use std::fmt::Write;
1513
14 use humansize::{format_size, BINARY};
15
1616 let root = env.build_artifacts().join("stage2");
1717
1818 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 @@
1use std::fs::File;
2use std::path::Path;
3
14use anyhow::Context;
25use camino::{Utf8Path, Utf8PathBuf};
36use fs_extra::dir::CopyOptions;
4use std::fs::File;
5use std::path::Path;
67
78/// Delete and re-create the directory.
89pub fn reset_directory(path: &Utf8Path) -> anyhow::Result<()> {
src/tools/opt-dist/src/utils/mod.rs+3-2
......@@ -1,10 +1,11 @@
1use std::time::Duration;
2
3use humansize::BINARY;
14use sysinfo::Disks;
25
36use crate::environment::Environment;
47use crate::timer::Timer;
58use crate::utils::io::delete_directory;
6use humansize::BINARY;
7use std::time::Duration;
89
910pub mod artifact_size;
1011pub mod io;
src/tools/remote-test-client/src/main.rs+1-2
......@@ -5,15 +5,14 @@
55//! Here is also where we bake in the support to spawn the QEMU emulator as
66//! well.
77
8use std::env;
98use std::fs::{self, File};
109use std::io::prelude::*;
1110use std::io::{self, BufWriter};
1211use std::net::TcpStream;
1312use std::path::{Path, PathBuf};
1413use std::process::{Command, Stdio};
15use std::thread;
1614use std::time::Duration;
15use std::{env, thread};
1716
1817const REMOTE_ADDR_ENV: &str = "TEST_DEVICE_ADDR";
1918const DEFAULT_ADDR: &str = "127.0.0.1:12345";
src/tools/remote-test-server/src/main.rs+4-9
......@@ -12,22 +12,17 @@
1212
1313#[cfg(not(windows))]
1414use std::fs::Permissions;
15use std::net::SocketAddr;
16#[cfg(not(windows))]
17use std::os::unix::prelude::*;
18
19use std::cmp;
20use std::env;
2115use std::fs::{self, File};
2216use std::io::prelude::*;
2317use std::io::{self, BufReader};
24use std::net::{TcpListener, TcpStream};
18use std::net::{SocketAddr, TcpListener, TcpStream};
19#[cfg(not(windows))]
20use std::os::unix::prelude::*;
2521use std::path::{Path, PathBuf};
2622use std::process::{Command, ExitStatus, Stdio};
27use std::str;
2823use std::sync::atomic::{AtomicUsize, Ordering};
2924use std::sync::{Arc, Mutex};
30use std::thread;
25use std::{cmp, env, str, thread};
3126
3227macro_rules! t {
3328 ($e:expr) => {
src/tools/replace-version-placeholder/src/main.rs+1
......@@ -1,4 +1,5 @@
11use std::path::PathBuf;
2
23use tidy::{t, walk};
34
45pub const VERSION_PLACEHOLDER: &str = "CURRENT_RUSTC_VERSION";
src/tools/rls/src/main.rs+3-3
......@@ -3,10 +3,10 @@
33//! This is a small stub that replaces RLS to alert the user that RLS is no
44//! longer available.
55
6use serde_json::Value;
76use std::error::Error;
8use std::io::BufRead;
9use std::io::Write;
7use std::io::{BufRead, Write};
8
9use serde_json::Value;
1010
1111const ALERT_MSG: &str = "\
1212RLS is no longer available as of Rust 1.65.
src/tools/run-make-support/src/command.rs+3-4
......@@ -1,15 +1,14 @@
1use std::ffi;
21use std::ffi::OsStr;
32use std::io::Write;
4use std::panic;
53use std::path::Path;
64use std::process::{Command as StdCommand, ExitStatus, Output, Stdio};
5use std::{ffi, panic};
6
7use build_helper::drop_bomb::DropBomb;
78
89use crate::util::handle_failed_output;
910use crate::{assert_contains, assert_equals, assert_not_contains};
1011
11use build_helper::drop_bomb::DropBomb;
12
1312/// This is a custom command wrapper that simplifies working with commands and makes it easier to
1413/// ensure that we check the exit status of executed processes.
1514///
src/tools/run-make-support/src/diff/mod.rs+1-2
......@@ -1,10 +1,9 @@
11use std::path::{Path, PathBuf};
22
3use build_helper::drop_bomb::DropBomb;
34use regex::Regex;
45use similar::TextDiff;
56
6use build_helper::drop_bomb::DropBomb;
7
87use crate::fs;
98
109#[cfg(test)]
src/tools/run-make-support/src/external_deps/cc.rs+2-3
......@@ -1,10 +1,9 @@
11use std::path::Path;
22
3use crate::command::Command;
4use crate::{env_var, is_msvc, is_windows, uname};
5
63// FIXME(jieyouxu): can we get rid of the `cygpath` external dependency?
74use super::cygpath::get_windows_path;
5use crate::command::Command;
6use crate::{env_var, is_msvc, is_windows, uname};
87
98/// Construct a new platform-specific C compiler invocation.
109///
src/tools/run-make-support/src/external_deps/htmldocck.rs+1-2
......@@ -1,8 +1,7 @@
1use super::python::python_command;
12use crate::command::Command;
23use crate::source_root;
34
4use super::python::python_command;
5
65/// `htmldocck` is a python script which is used for rustdoc test suites, it is assumed to be
76/// available at `$SOURCE_ROOT/src/etc/htmldocck.py`.
87#[track_caller]
src/tools/run-make-support/src/run.rs+1-2
......@@ -1,7 +1,6 @@
1use std::env;
21use std::ffi::OsStr;
3use std::panic;
42use std::path::{Path, PathBuf};
3use std::{env, panic};
54
65use crate::command::{Command, CompletedProcess};
76use crate::util::{handle_failed_output, set_host_rpath};
src/tools/rust-installer/src/combiner.rs+6-7
......@@ -1,14 +1,13 @@
1use super::Scripter;
2use super::Tarballer;
3use crate::{
4 compression::{CompressionFormat, CompressionFormats, CompressionProfile},
5 util::*,
6};
7use anyhow::{bail, Context, Result};
81use std::io::{Read, Write};
92use std::path::Path;
3
4use anyhow::{bail, Context, Result};
105use tar::Archive;
116
7use super::{Scripter, Tarballer};
8use crate::compression::{CompressionFormat, CompressionFormats, CompressionProfile};
9use crate::util::*;
10
1211actor! {
1312 #[derive(Debug)]
1413 pub struct Combiner {
src/tools/rust-installer/src/compression.rs+9-3
......@@ -1,8 +1,14 @@
1use std::fmt;
2use std::io::{Read, Write};
3use std::path::Path;
4use std::str::FromStr;
5
16use anyhow::{Context, Error};
2use flate2::{read::GzDecoder, write::GzEncoder};
7use flate2::read::GzDecoder;
8use flate2::write::GzEncoder;
39use rayon::prelude::*;
4use std::{fmt, io::Read, io::Write, path::Path, str::FromStr};
5use xz2::{read::XzDecoder, write::XzEncoder};
10use xz2::read::XzDecoder;
11use xz2::write::XzEncoder;
612
713#[derive(Default, Debug, Copy, Clone)]
814pub enum CompressionProfile {
src/tools/rust-installer/src/generator.rs+6-5
......@@ -1,12 +1,13 @@
1use super::Scripter;
2use super::Tarballer;
3use crate::compression::{CompressionFormats, CompressionProfile};
4use crate::util::*;
5use anyhow::{bail, format_err, Context, Result};
61use std::collections::BTreeSet;
72use std::io::Write;
83use std::path::Path;
94
5use anyhow::{bail, format_err, Context, Result};
6
7use super::{Scripter, Tarballer};
8use crate::compression::{CompressionFormats, CompressionProfile};
9use crate::util::*;
10
1011actor! {
1112 #[derive(Debug)]
1213 pub struct Generator {
src/tools/rust-installer/src/scripter.rs+4-2
......@@ -1,7 +1,9 @@
1use crate::util::*;
2use anyhow::{Context, Result};
31use std::io::Write;
42
3use anyhow::{Context, Result};
4
5use crate::util::*;
6
57const TEMPLATE: &str = include_str!("../install-template.sh");
68
79actor! {
src/tools/rust-installer/src/tarballer.rs+4-5
......@@ -1,14 +1,13 @@
1use anyhow::{bail, Context, Result};
21use std::fs::{read_link, symlink_metadata};
32use std::io::{BufWriter, Write};
43use std::path::Path;
4
5use anyhow::{bail, Context, Result};
56use tar::{Builder, Header, HeaderMode};
67use walkdir::WalkDir;
78
8use crate::{
9 compression::{CombinedEncoder, CompressionFormats, CompressionProfile},
10 util::*,
11};
9use crate::compression::{CombinedEncoder, CompressionFormats, CompressionProfile};
10use crate::util::*;
1211
1312actor! {
1413 #[derive(Debug)]
src/tools/rust-installer/src/util.rs+7-8
......@@ -1,17 +1,16 @@
1use anyhow::{format_err, Context, Result};
21use std::fs;
3use std::path::Path;
4use walkdir::WalkDir;
5
6// Needed to set the script mode to executable.
7#[cfg(unix)]
8use std::os::unix::fs::OpenOptionsExt;
92// FIXME: what about Windows? Are default ACLs executable?
10
113#[cfg(unix)]
124use std::os::unix::fs::symlink as symlink_file;
5// Needed to set the script mode to executable.
6#[cfg(unix)]
7use std::os::unix::fs::OpenOptionsExt;
138#[cfg(windows)]
149use std::os::windows::fs::symlink_file;
10use std::path::Path;
11
12use anyhow::{format_err, Context, Result};
13use walkdir::WalkDir;
1514
1615/// Converts a `&Path` to a UTF-8 `&str`.
1716pub fn path_to_str(path: &Path) -> Result<&str> {
src/tools/rustbook/src/main.rs+1-5
......@@ -1,14 +1,10 @@
1use clap::crate_version;
2
31use std::env;
42use std::path::{Path, PathBuf};
53
6use clap::{arg, ArgMatches, Command};
7
4use clap::{arg, crate_version, ArgMatches, Command};
85use mdbook::errors::Result as Result3;
96use mdbook::MDBook;
107use mdbook_i18n_helpers::preprocessors::Gettext;
11
128use mdbook_spec::Spec;
139use mdbook_trpl_listing::TrplListing;
1410use mdbook_trpl_note::TrplNote;
src/tools/rustc-perf-wrapper/src/main.rs+4-2
......@@ -1,8 +1,10 @@
1use crate::config::{Profile, Scenario};
2use clap::Parser;
31use std::path::PathBuf;
42use std::process::Command;
53
4use clap::Parser;
5
6use crate::config::{Profile, Scenario};
7
68mod config;
79
810/// 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 @@
1use std::env;
2use std::path::PathBuf;
3
14use getopts::Options;
2use std::{env, path::PathBuf};
35
46pub(crate) struct Config {
57 pub(crate) nodejs: PathBuf,
src/tools/rustdoc-gui-test/src/main.rs+4-3
......@@ -1,11 +1,12 @@
1use build_helper::util::try_run;
2use compiletest::header::TestProps;
3use config::Config;
41use std::path::{Path, PathBuf};
52use std::process::Command;
63use std::sync::Arc;
74use std::{env, fs};
85
6use build_helper::util::try_run;
7use compiletest::header::TestProps;
8use config::Config;
9
910mod config;
1011
1112fn 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 @@
1use std::{
2 fmt::{self, Display},
3 path::Path,
4};
1use std::fmt::{self, Display};
2use std::path::Path;
53
64use dynamic_suggestions::DYNAMIC_SUGGESTIONS;
75use glob::Pattern;
src/tools/suggest-tests/src/static_suggestions.rs+2-1
......@@ -1,6 +1,7 @@
1use crate::{sug, Suggestion};
21use std::sync::OnceLock;
32
3use crate::{sug, Suggestion};
4
45// FIXME: perhaps this could use `std::lazy` when it is stablizied
56macro_rules! static_suggestions {
67 ($( [ $( $glob:expr ),* $(,)? ] => [ $( $suggestion:expr ),* $(,)? ] ),* $(,)? ) => {
src/tools/tidy/src/alphabetical/tests.rs+2-1
......@@ -1,7 +1,8 @@
1use super::*;
21use std::io::Write;
32use std::str::from_utf8;
43
4use super::*;
5
56fn test(lines: &str, name: &str, expected_msg: &str, expected_bad: bool) {
67 let mut actual_msg = Vec::new();
78 let mut actual_bad = false;
src/tools/tidy/src/bins.rs+2-1
......@@ -21,12 +21,13 @@ mod os_impl {
2121
2222#[cfg(unix)]
2323mod os_impl {
24 use crate::walk::{filter_dirs, walk_no_read};
2524 use std::fs;
2625 use std::os::unix::prelude::*;
2726 use std::path::Path;
2827 use std::process::{Command, Stdio};
2928
29 use crate::walk::{filter_dirs, walk_no_read};
30
3031 enum FilesystemSupport {
3132 Supported,
3233 Unsupported,
src/tools/tidy/src/debug_artifacts.rs+2-1
......@@ -1,8 +1,9 @@
11//! Tidy check to prevent creation of unnecessary debug artifacts while running tests.
22
3use crate::walk::{filter_dirs, filter_not_rust, walk};
43use std::path::Path;
54
5use crate::walk::{filter_dirs, filter_not_rust, walk};
6
67const GRAPHVIZ_POSTFLOW_MSG: &str = "`borrowck_graphviz_postflow` attribute in test";
78
89pub fn check(test_dir: &Path, bad: &mut bool) {
src/tools/tidy/src/deps.rs+3-2
......@@ -1,11 +1,12 @@
11//! Checks the licenses of third-party dependencies.
22
3use build_helper::ci::CiEnv;
4use cargo_metadata::{Metadata, Package, PackageId};
53use std::collections::HashSet;
64use std::fs::read_dir;
75use std::path::Path;
86
7use build_helper::ci::CiEnv;
8use cargo_metadata::{Metadata, Package, PackageId};
9
910/// These are licenses that are allowed for all crates, including the runtime,
1011/// rustc, tools, etc.
1112#[rustfmt::skip]
src/tools/tidy/src/edition.rs+2-1
......@@ -1,8 +1,9 @@
11//! Tidy check to ensure that crate `edition` is '2018' or '2021'.
22
3use crate::walk::{filter_dirs, walk};
43use std::path::Path;
54
5use crate::walk::{filter_dirs, walk};
6
67fn is_edition_2021(mut line: &str) -> bool {
78 line = line.trim();
89 line == "edition = \"2021\""
src/tools/tidy/src/error_codes.rs+3-1
......@@ -16,7 +16,9 @@
1616//! 4. We check that the error code is actually emitted by the compiler.
1717//! - This is done by searching `compiler/` with a regex.
1818
19use std::{ffi::OsStr, fs, path::Path};
19use std::ffi::OsStr;
20use std::fs;
21use std::path::Path;
2022
2123use regex::Regex;
2224
src/tools/tidy/src/ext_tool_checks.rs+1-3
......@@ -18,11 +18,9 @@
1818//! is set, rerun the tool to print a suggestion diff (for e.g. CI)
1919
2020use std::ffi::OsStr;
21use std::fmt;
22use std::fs;
23use std::io;
2421use std::path::{Path, PathBuf};
2522use std::process::Command;
23use std::{fmt, fs, io};
2624
2725const MIN_PY_REV: (u32, u32) = (3, 9);
2826const MIN_PY_REV_STR: &str = "≥3.9";
src/tools/tidy/src/features.rs+3-3
......@@ -9,13 +9,13 @@
99//! * All unstable lang features have tests to ensure they are actually unstable.
1010//! * Language features in a group are sorted by feature name.
1111
12use crate::walk::{filter_dirs, filter_not_rust, walk, walk_many};
1312use std::collections::hash_map::{Entry, HashMap};
1413use std::ffi::OsStr;
15use std::fmt;
16use std::fs;
1714use std::num::NonZeroU32;
1815use std::path::{Path, PathBuf};
16use std::{fmt, fs};
17
18use crate::walk::{filter_dirs, filter_not_rust, walk, walk_many};
1919
2020#[cfg(test)]
2121mod tests;
src/tools/tidy/src/fluent_alphabetical.rs+5-2
......@@ -1,11 +1,14 @@
11//! Checks that all Flunt files have messages in alphabetical order
22
3use crate::walk::{filter_dirs, walk};
43use std::collections::HashMap;
5use std::{fs::OpenOptions, io::Write, path::Path};
4use std::fs::OpenOptions;
5use std::io::Write;
6use std::path::Path;
67
78use regex::Regex;
89
10use crate::walk::{filter_dirs, walk};
11
912fn message() -> &'static Regex {
1013 static_regex!(r#"(?m)^([a-zA-Z0-9_]+)\s*=\s*"#)
1114}
src/tools/tidy/src/fluent_period.rs+2-1
......@@ -1,9 +1,10 @@
11//! Checks that no Fluent messages or attributes end in periods (except ellipses)
22
3use std::path::Path;
4
35use fluent_syntax::ast::{Entry, PatternElement};
46
57use crate::walk::{filter_dirs, walk};
6use std::path::Path;
78
89fn filter_fluent(path: &Path) -> bool {
910 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 @@
11//! Checks that all Fluent messages appear at least twice
22
3use crate::walk::{filter_dirs, walk};
43use std::collections::HashMap;
54use std::path::Path;
65
6use crate::walk::{filter_dirs, walk};
7
78fn filter_used_messages(
89 contents: &str,
910 msgs_not_appeared_yet: &mut HashMap<String, String>,
src/tools/tidy/src/known_bug.rs+2-1
......@@ -1,8 +1,9 @@
11//! Tidy check to ensure that tests inside 'tests/crashes' have a '@known-bug' directive.
22
3use crate::walk::*;
43use std::path::Path;
54
5use crate::walk::*;
6
67pub fn check(filepath: &Path, bad: &mut bool) {
78 walk(filepath, |path, _is_dir| filter_not_rust(path), &mut |entry, contents| {
89 let file = entry.path();
src/tools/tidy/src/lib.rs+1
......@@ -50,6 +50,7 @@ macro_rules! tidy_error_ext {
5050
5151fn tidy_error(args: &str) -> std::io::Result<()> {
5252 use std::io::Write;
53
5354 use termcolor::{Color, ColorChoice, ColorSpec, StandardStream};
5455
5556 let mut stderr = StandardStream::stdout(ColorChoice::Auto);
src/tools/tidy/src/main.rs+3-4
......@@ -4,16 +4,15 @@
44//! etc. This is run by default on `./x.py test` and as part of the auto
55//! builders. The tidy checks can be executed with `./x.py test tidy`.
66
7use tidy::*;
8
97use std::collections::VecDeque;
10use std::env;
118use std::num::NonZeroUsize;
129use std::path::PathBuf;
13use std::process;
1410use std::str::FromStr;
1511use std::sync::atomic::{AtomicBool, Ordering};
1612use std::thread::{self, scope, ScopedJoinHandle};
13use std::{env, process};
14
15use tidy::*;
1716
1817fn main() {
1918 // Running Cargo will read the libstd Cargo.toml
src/tools/tidy/src/mir_opt_tests.rs+2-1
......@@ -1,9 +1,10 @@
11//! Tidy check to ensure that mir opt directories do not have stale files or dashes in file names
22
3use miropt_test_tools::PanicStrategy;
43use std::collections::HashSet;
54use std::path::{Path, PathBuf};
65
6use miropt_test_tools::PanicStrategy;
7
78use crate::walk::walk_no_read;
89
910fn check_unused_files(path: &Path, bless: bool, bad: &mut bool) {
src/tools/tidy/src/pal.rs+2-1
......@@ -30,9 +30,10 @@
3030//! platform-specific cfgs are allowed. Not sure yet how to deal with
3131//! this in the long term.
3232
33use crate::walk::{filter_dirs, walk};
3433use std::path::Path;
3534
35use crate::walk::{filter_dirs, walk};
36
3637// Paths that may contain platform-specific code.
3738const EXCEPTION_PATHS: &[&str] = &[
3839 "library/panic_abort",
src/tools/tidy/src/style.rs+6-2
......@@ -17,10 +17,14 @@
1717//! `// ignore-tidy-CHECK-NAME`.
1818// ignore-tidy-dbg
1919
20use crate::walk::{filter_dirs, walk};
20use std::ffi::OsStr;
21use std::path::Path;
22use std::sync::LazyLock;
23
2124use regex::RegexSetBuilder;
2225use rustc_hash::FxHashMap;
23use std::{ffi::OsStr, path::Path, sync::LazyLock};
26
27use crate::walk::{filter_dirs, walk};
2428
2529#[cfg(test)]
2630mod tests;
src/tools/tidy/src/target_policy.rs+3-1
......@@ -2,8 +2,10 @@
22//!
33//! As of writing, only checks that sanity-check assembly test for targets doesn't miss any targets.
44
5use std::collections::HashSet;
6use std::path::Path;
7
58use crate::walk::{filter_not_rust, walk};
6use std::{collections::HashSet, path::Path};
79
810const TARGET_DEFINITIONS_PATH: &str = "compiler/rustc_target/src/spec/targets/";
911const ASSEMBLY_TEST_PATH: &str = "tests/assembly/targets/";
src/tools/tidy/src/ui_tests.rs+2-1
......@@ -2,13 +2,14 @@
22//! - the number of entries in each directory must be less than `ENTRY_LIMIT`
33//! - there are no stray `.stderr` files
44
5use ignore::Walk;
65use std::collections::{BTreeSet, HashMap};
76use std::ffi::OsStr;
87use std::fs;
98use std::io::Write;
109use std::path::{Path, PathBuf};
1110
11use ignore::Walk;
12
1213// FIXME: GitHub's UI truncates file lists that exceed 1000 entries, so these
1314// should all be 1000 or lower. Limits significantly smaller than 1000 are also
1415// 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 @@
77//! named `tests.rs` or `benches.rs`, or directories named `tests` or `benches` unconfigured
88//! during normal build.
99
10use crate::walk::{filter_dirs, walk};
1110use std::path::Path;
1211
12use crate::walk::{filter_dirs, walk};
13
1314pub fn check(root_path: &Path, bad: &mut bool) {
1415 let core = root_path.join("core");
1516 let core_copy = core.clone();
src/tools/tidy/src/unstable_book.rs+2-1
......@@ -1,8 +1,9 @@
1use crate::features::{CollectedFeatures, Features, Status};
21use std::collections::BTreeSet;
32use std::fs;
43use std::path::{Path, PathBuf};
54
5use crate::features::{CollectedFeatures, Features, Status};
6
67pub const PATH_STR: &str = "doc/unstable-book";
78
89pub const COMPILER_FLAGS_DIR: &str = "src/compiler-flags";
src/tools/tidy/src/walk.rs+5-2
......@@ -1,6 +1,9 @@
1use ignore::DirEntry;
1use std::ffi::OsStr;
2use std::fs::File;
3use std::io::Read;
4use std::path::Path;
25
3use std::{ffi::OsStr, fs::File, io::Read, path::Path};
6use ignore::DirEntry;
47
58/// The default directory filter.
69pub fn filter_dirs(path: &Path) -> bool {
src/tools/tidy/src/x_version.rs+2-1
......@@ -1,7 +1,8 @@
1use semver::Version;
21use std::path::Path;
32use std::process::{Command, Stdio};
43
4use semver::Version;
5
56pub fn check(root: &Path, cargo: &Path, bad: &mut bool) {
67 let cargo_list = Command::new(cargo).args(["install", "--list"]).stdout(Stdio::piped()).spawn();
78
src/tools/unicode-table-generator/src/cascading_map.rs+3-2
......@@ -1,9 +1,10 @@
1use crate::fmt_list;
2use crate::raw_emitter::RawEmitter;
31use std::collections::HashMap;
42use std::fmt::Write as _;
53use std::ops::Range;
64
5use crate::fmt_list;
6use crate::raw_emitter::RawEmitter;
7
78impl RawEmitter {
89 pub fn emit_cascading_map(&mut self, ranges: &[Range<u32>]) -> bool {
910 let mut map: [u8; 256] = [
src/tools/unicode-table-generator/src/case_mapping.rs+4-5
......@@ -1,9 +1,8 @@
1use std::char;
2use std::collections::BTreeMap;
3use std::fmt::{self, Write};
4
15use crate::{fmt_list, UnicodeData};
2use std::{
3 char,
4 collections::BTreeMap,
5 fmt::{self, Write},
6};
76
87const INDEX_MASK: u32 = 1 << 22;
98
src/tools/unicode-table-generator/src/main.rs+1
......@@ -73,6 +73,7 @@
7373
7474use std::collections::{BTreeMap, HashMap};
7575use std::ops::Range;
76
7677use ucd_parse::Codepoints;
7778
7879mod cascading_map;
src/tools/unicode-table-generator/src/raw_emitter.rs+2-1
......@@ -1,8 +1,9 @@
1use crate::fmt_list;
21use std::collections::{BTreeMap, BTreeSet, HashMap};
32use std::fmt::{self, Write};
43use std::ops::Range;
54
5use crate::fmt_list;
6
67#[derive(Clone)]
78pub struct RawEmitter {
89 pub file: String,
src/tools/unicode-table-generator/src/skiplist.rs+3-2
......@@ -1,8 +1,9 @@
1use crate::fmt_list;
2use crate::raw_emitter::RawEmitter;
31use std::fmt::Write as _;
42use std::ops::Range;
53
4use crate::fmt_list;
5use crate::raw_emitter::RawEmitter;
6
67/// This will get packed into a single u32 before inserting into the data set.
78#[derive(Debug, PartialEq)]
89struct ShortOffsetRunHeader {
src/tools/unicode-table-generator/src/unicode_download.rs+2-1
......@@ -1,7 +1,8 @@
1use crate::UNICODE_DIRECTORY;
21use std::path::Path;
32use std::process::{Command, Output};
43
4use crate::UNICODE_DIRECTORY;
5
56static URL_PREFIX: &str = "https://www.unicode.org/Public/UCD/latest/ucd/";
67
78static README: &str = "ReadMe.txt";
src/tools/unstable-book-gen/src/main.rs+1
......@@ -4,6 +4,7 @@ use std::collections::BTreeSet;
44use std::env;
55use std::fs::{self, write};
66use std::path::Path;
7
78use tidy::features::{collect_lang_features, collect_lib_features, Features};
89use tidy::t;
910use tidy::unstable_book::{
src/tools/x/src/main.rs+5-6
......@@ -8,12 +8,11 @@
88//! the ones that call `x.py`. We use `sh -c` on Unix, because it is a standard.
99//! We also don't use `pwsh` on Windows, because it is not installed by default;
1010
11use std::{
12 env::{self, consts::EXE_EXTENSION},
13 io,
14 path::Path,
15 process::{self, Command, ExitStatus},
16};
11use std::env::consts::EXE_EXTENSION;
12use std::env::{self};
13use std::io;
14use std::path::Path;
15use std::process::{self, Command, ExitStatus};
1716
1817const PYTHON: &str = "python";
1918const PYTHON2: &str = "python2";
tests/assembly/asm/aarch64-outline-atomics.rs+2-1
......@@ -7,7 +7,8 @@
77
88#![crate_type = "rlib"]
99
10use std::sync::atomic::{AtomicI32, Ordering::*};
10use std::sync::atomic::AtomicI32;
11use std::sync::atomic::Ordering::*;
1112
1213pub fn compare_exchange(a: &AtomicI32) {
1314 // On AArch64 LLVM should outline atomic operations.
tests/codegen/atomic-operations.rs+2-1
......@@ -2,7 +2,8 @@
22//@ compile-flags: -O
33#![crate_type = "lib"]
44
5use std::sync::atomic::{AtomicI32, Ordering::*};
5use std::sync::atomic::AtomicI32;
6use std::sync::atomic::Ordering::*;
67
78// CHECK-LABEL: @compare_exchange
89#[no_mangle]
tests/codegen/intrinsics/transmute.rs+2-3
......@@ -6,11 +6,10 @@
66#![feature(custom_mir)]
77#![allow(unreachable_code)]
88
9use std::intrinsics::{transmute, transmute_unchecked};
10use std::mem::MaybeUninit;
11
129// Some of these need custom MIR to not get removed by MIR optimizations.
1310use std::intrinsics::mir::*;
11use std::intrinsics::{transmute, transmute_unchecked};
12use std::mem::MaybeUninit;
1413
1514pub enum ZstNever {}
1615
tests/mir-opt/dont_inline_type_id.rs+1-2
......@@ -2,8 +2,7 @@
22//@ test-mir-pass: Inline
33//@ compile-flags: --crate-type=lib -C panic=abort
44
5use std::any::Any;
6use std::any::TypeId;
5use std::any::{Any, TypeId};
76
87struct A<T: ?Sized + 'static> {
98 a: i32,
tests/run-make/branch-protection-check-IBT/_rmake.rs+1-3
......@@ -8,9 +8,7 @@
88//@ ignore-test
99// FIXME(jieyouxu): see the FIXME in the Makefile
1010
11use run_make_support::llvm_readobj;
12use run_make_support::rustc;
13use run_make_support::{cwd, env_var};
11use run_make_support::{cwd, env_var, llvm_readobj, rustc};
1412
1513fn main() {
1614 let llvm_components = env_var("LLVM_COMPONENTS");
tests/run-make/c-link-to-rust-staticlib/rmake.rs+2-1
......@@ -3,9 +3,10 @@
33
44//@ ignore-cross-compile
55
6use std::fs;
7
68use run_make_support::rfs::remove_file;
79use run_make_support::{cc, extra_c_flags, run, rustc, static_lib_name};
8use std::fs;
910
1011fn main() {
1112 rustc().input("foo.rs").run();
tests/run-make/c-link-to-rust-va-list-fn/checkrust.rs+1-3
......@@ -1,9 +1,7 @@
11#![crate_type = "staticlib"]
22#![feature(c_variadic)]
33
4use std::ffi::VaList;
5use std::ffi::{c_char, c_double, c_int, c_long, c_longlong};
6use std::ffi::{CStr, CString};
4use std::ffi::{c_char, c_double, c_int, c_long, c_longlong, CStr, CString, VaList};
75
86macro_rules! continue_if {
97 ($cond:expr) => {
tests/run-make/comment-section/rmake.rs+1-4
......@@ -9,10 +9,7 @@
99
1010use std::path::PathBuf;
1111
12use run_make_support::llvm_readobj;
13use run_make_support::rfs;
14use run_make_support::rustc;
15use run_make_support::{cwd, env_var, run_in_tmpdir};
12use run_make_support::{cwd, env_var, llvm_readobj, rfs, run_in_tmpdir, rustc};
1613
1714fn main() {
1815 let target = env_var("TARGET");
tests/run-make/compiler-builtins/rmake.rs+4-5
......@@ -14,15 +14,14 @@
1414
1515#![deny(warnings)]
1616
17use std::collections::HashSet;
18use std::path::PathBuf;
19
1720use run_make_support::object::read::archive::ArchiveFile;
1821use run_make_support::object::read::Object;
19use run_make_support::object::ObjectSection;
20use run_make_support::object::ObjectSymbol;
21use run_make_support::object::RelocationTarget;
22use run_make_support::object::{ObjectSection, ObjectSymbol, RelocationTarget};
2223use run_make_support::rfs::{read, read_dir};
2324use run_make_support::{cmd, env_var, object};
24use std::collections::HashSet;
25use std::path::PathBuf;
2625
2726fn main() {
2827 let target_dir = PathBuf::from("target");
tests/run-make/crate-hash-rustc-version/rmake.rs+1-2
......@@ -4,8 +4,7 @@
44//@ ignore-cross-compile
55//@ only-unix
66
7use run_make_support::llvm;
8use run_make_support::{diff, dynamic_lib_name, is_darwin, run, run_fail, rustc};
7use run_make_support::{diff, dynamic_lib_name, is_darwin, llvm, run, run_fail, rustc};
98
109fn llvm_readobj() -> llvm::LlvmReadobj {
1110 let mut cmd = llvm::llvm_readobj();
tests/run-make/cross-lang-lto-riscv-abi/rmake.rs+4-6
......@@ -6,13 +6,11 @@
66// FIXME(#126180): This test doesn't actually run anywhere, because the only
77// CI job that sets RUSTBUILD_FORCE_CLANG_BASED_TESTS runs very few tests.
88
9use std::path::PathBuf;
10use std::process::{Command, Output};
11use std::{env, str};
12
913use run_make_support::{bin_name, clang, llvm_readobj, rustc};
10use std::{
11 env,
12 path::PathBuf,
13 process::{Command, Output},
14 str,
15};
1614
1715fn check_target(target: &str, clang_target: &str, carch: &str, is_double_float: bool) {
1816 eprintln!("Checking target {target}");
tests/run-make/doctests-keep-binaries/rmake.rs+2-1
......@@ -1,9 +1,10 @@
11// Check that valid binaries are persisted by running them, regardless of whether the
22// --run or --no-run option is used.
33
4use std::path::Path;
5
46use run_make_support::rfs::{create_dir, remove_dir_all};
57use run_make_support::{run, rustc, rustdoc};
6use std::path::Path;
78
89fn setup_test_env<F: FnOnce(&Path, &Path)>(callback: F) {
910 let out_dir = Path::new("doctests");
tests/run-make/doctests-runtool/rmake.rs+2-1
......@@ -1,8 +1,9 @@
11// Tests behavior of rustdoc `--runtool`.
22
3use std::path::PathBuf;
4
35use run_make_support::rfs::{create_dir, remove_dir_all};
46use run_make_support::{rustc, rustdoc};
5use std::path::PathBuf;
67
78fn mkdir(name: &str) -> PathBuf {
89 let dir = PathBuf::from(name);
tests/run-make/emit-shared-files/rmake.rs+2-1
......@@ -5,9 +5,10 @@
55// `all-shared` should only emit files that can be shared between crates.
66// See https://github.com/rust-lang/rust/pull/83478
77
8use run_make_support::{has_extension, has_prefix, rustdoc, shallow_find_files};
98use std::path::Path;
109
10use run_make_support::{has_extension, has_prefix, rustdoc, shallow_find_files};
11
1112fn main() {
1213 rustdoc()
1314 .arg("-Zunstable-options")
tests/run-make/incr-prev-body-beyond-eof/rmake.rs+1-2
......@@ -13,8 +13,7 @@
1313//@ ignore-nvptx64-nvidia-cuda
1414// FIXME: can't find crate for `std`
1515
16use run_make_support::rfs;
17use run_make_support::rustc;
16use run_make_support::{rfs, rustc};
1817
1918fn main() {
2019 rfs::create_dir("src");
tests/run-make/incremental-debugger-visualizer/rmake.rs+2-1
......@@ -2,9 +2,10 @@
22// (in this case, foo.py and foo.natvis) are picked up when compiling incrementally.
33// See https://github.com/rust-lang/rust/pull/111641
44
5use run_make_support::{invalid_utf8_contains, invalid_utf8_not_contains, rfs, rustc};
65use std::io::Read;
76
7use run_make_support::{invalid_utf8_contains, invalid_utf8_not_contains, rfs, rustc};
8
89fn main() {
910 rfs::create_file("foo.py");
1011 rfs::write("foo.py", "GDB script v1");
tests/run-make/inline-always-many-cgu/rmake.rs+3-4
......@@ -1,9 +1,8 @@
1use run_make_support::regex::Regex;
2use run_make_support::rfs;
3use run_make_support::rustc;
4
51use std::ffi::OsStr;
62
3use run_make_support::regex::Regex;
4use run_make_support::{rfs, rustc};
5
76fn main() {
87 rustc().input("foo.rs").emit("llvm-ir").codegen_units(2).run();
98 let re = Regex::new(r"\bcall\b").unwrap();
tests/run-make/intrinsic-unreachable/exit-unreachable.rs-1
......@@ -1,7 +1,6 @@
11#![feature(core_intrinsics)]
22#![crate_type = "lib"]
33use std::arch::asm;
4
54use std::intrinsics;
65
76#[allow(unreachable_code)]
tests/run-make/invalid-library/rmake.rs+1-2
......@@ -4,8 +4,7 @@
44// one appearing in stderr in this scenario.
55// See https://github.com/rust-lang/rust/pull/12645
66
7use run_make_support::rfs;
8use run_make_support::{llvm_ar, rustc};
7use run_make_support::{llvm_ar, rfs, rustc};
98
109fn main() {
1110 rfs::create_file("lib.rmeta");
tests/run-make/issue-107495-archive-permissions/rmake.rs+2-2
......@@ -3,12 +3,12 @@
33#[cfg(unix)]
44extern crate libc;
55
6use run_make_support::{aux_build, rfs};
7
86#[cfg(unix)]
97use std::os::unix::fs::PermissionsExt;
108use std::path::Path;
119
10use run_make_support::{aux_build, rfs};
11
1212fn main() {
1313 #[cfg(unix)]
1414 unsafe {
tests/run-make/lib-trait-for-trait-no-ice/rmake.rs+2-1
......@@ -5,9 +5,10 @@
55// the lib crate-type flag was actually followed.
66// See https://github.com/rust-lang/rust/issues/18943
77
8use run_make_support::{rust_lib_name, rustc};
98use std::path::Path;
109
10use run_make_support::{rust_lib_name, rustc};
11
1112fn main() {
1213 rustc().input("foo.rs").crate_type("lib").run();
1314 assert!(Path::new(&rust_lib_name("foo")).exists());
tests/run-make/libtest-thread-limit/test.rs+3-5
......@@ -1,8 +1,6 @@
1use std::{
2 io::ErrorKind,
3 sync::OnceLock,
4 thread::{self, Builder, ThreadId},
5};
1use std::io::ErrorKind;
2use std::sync::OnceLock;
3use std::thread::{self, Builder, ThreadId};
64
75static THREAD_ID: OnceLock<ThreadId> = OnceLock::new();
86
tests/run-make/llvm-outputs/rmake.rs+2-1
......@@ -1,8 +1,9 @@
11// test that directories get created when emitting llvm bitcode and IR
22
3use run_make_support::{cwd, run_in_tmpdir, rustc};
43use std::path::PathBuf;
54
5use run_make_support::{cwd, run_in_tmpdir, rustc};
6
67fn main() {
78 let mut path_bc = PathBuf::new();
89 let mut path_ir = PathBuf::new();
tests/run-make/ls-metadata/rmake.rs+1-2
......@@ -6,8 +6,7 @@
66
77//@ ignore-cross-compile
88
9use run_make_support::rfs;
10use run_make_support::rustc;
9use run_make_support::{rfs, rustc};
1110
1211fn main() {
1312 rustc().input("foo.rs").run();
tests/run-make/lto-readonly-lib/rmake.rs+1-2
......@@ -7,8 +7,7 @@
77
88//@ ignore-cross-compile
99
10use run_make_support::rfs;
11use run_make_support::{run, rust_lib_name, rustc, test_while_readonly};
10use run_make_support::{rfs, run, rust_lib_name, rustc, test_while_readonly};
1211
1312fn main() {
1413 rustc().input("lib.rs").run();
tests/run-make/manual-crate-name/rmake.rs+2-1
......@@ -1,6 +1,7 @@
1use run_make_support::rustc;
21use std::path::Path;
32
3use run_make_support::rustc;
4
45fn main() {
56 rustc().input("bar.rs").crate_name("foo").run();
67 assert!(Path::new("libfoo.rlib").is_file());
tests/run-make/no-intermediate-extras/rmake.rs+2-1
......@@ -5,9 +5,10 @@
55
66//@ ignore-cross-compile
77
8use run_make_support::rustc;
98use std::fs;
109
10use run_make_support::rustc;
11
1112fn main() {
1213 rustc().crate_type("rlib").arg("--test").input("foo.rs").run();
1314 assert!(
tests/run-make/non-unicode-env/rmake.rs+1-2
......@@ -1,5 +1,4 @@
1use run_make_support::rfs;
2use run_make_support::rustc;
1use run_make_support::{rfs, rustc};
32
43fn main() {
54 #[cfg(unix)]
tests/run-make/obey-crate-type-flag/rmake.rs+2-1
......@@ -5,10 +5,11 @@
55
66//@ ignore-cross-compile
77
8use std::path::Path;
9
810use run_make_support::{
911 cwd, dynamic_lib_name, has_extension, rfs, rust_lib_name, rustc, shallow_find_files,
1012};
11use std::path::Path;
1213
1314fn main() {
1415 rustc().input("test.rs").run();
tests/run-make/output-type-permutations/rmake.rs+2-1
......@@ -4,11 +4,12 @@
44// files are exactly what is expected, no more, no less.
55// See https://github.com/rust-lang/rust/pull/12020
66
7use std::path::PathBuf;
8
79use run_make_support::{
810 bin_name, dynamic_lib_name, filename_not_in_denylist, rfs, rust_lib_name, rustc,
911 shallow_find_files, static_lib_name,
1012};
11use std::path::PathBuf;
1213
1314// Each test takes 4 arguments:
1415// `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 @@
55// conflicts. This test uses this flag and checks for successful compilation.
66// See https://github.com/rust-lang/rust/pull/83846
77
8use run_make_support::{rfs, rustc};
98use std::sync::{Arc, Barrier};
109use std::thread;
1110
11use run_make_support::{rfs, rustc};
12
1213fn main() {
1314 rfs::create_file("lib.rs");
1415 let barrier = Arc::new(Barrier::new(2));
tests/run-make/pgo-branch-weights/rmake.rs+2-1
......@@ -10,9 +10,10 @@
1010//@ needs-profiler-support
1111//@ ignore-cross-compile
1212
13use run_make_support::{llvm_filecheck, llvm_profdata, rfs, run_with_args, rustc};
1413use std::path::Path;
1514
15use run_make_support::{llvm_filecheck, llvm_profdata, rfs, run_with_args, rustc};
16
1617fn main() {
1718 let path_prof_data_dir = Path::new("prof_data_dir");
1819 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 @@
55// does not get an unexpected dep-info file.
66// See https://github.com/rust-lang/rust/issues/112898
77
8use run_make_support::{invalid_utf8_contains, rfs, rustc};
98use std::path::Path;
109
10use run_make_support::{invalid_utf8_contains, rfs, rustc};
11
1112fn main() {
1213 rustc().emit("dep-info").arg("-Zunpretty=expanded").input("with-dep.rs").run();
1314 invalid_utf8_contains("with-dep.d", "with-dep.rs");
tests/run-make/profile/rmake.rs+2-1
......@@ -8,9 +8,10 @@
88//@ ignore-cross-compile
99//@ needs-profiler-support
1010
11use run_make_support::{run, rustc};
1211use std::path::Path;
1312
13use run_make_support::{run, rustc};
14
1415fn main() {
1516 rustc().arg("-g").arg("-Zprofile").input("test.rs").run();
1617 run("test");
tests/run-make/relro-levels/rmake.rs+1-2
......@@ -2,8 +2,7 @@
22
33//@ only-linux
44
5use run_make_support::llvm_readobj;
6use run_make_support::rustc;
5use run_make_support::{llvm_readobj, rustc};
76
87fn compile(relro_level: &str) {
98 rustc().arg(format!("-Crelro-level={relro_level}")).input("hello.rs").run();
tests/run-make/repr128-dwarf/rmake.rs+4-3
......@@ -1,13 +1,14 @@
11//@ ignore-windows
22// This test should be replaced with one in tests/debuginfo once GDB or LLDB support 128-bit enums.
33
4use gimli::{AttributeValue, EndianRcSlice, Reader, RunTimeEndian};
5use object::{Object, ObjectSection};
6use run_make_support::{gimli, object, rfs, rustc};
74use std::collections::HashMap;
85use std::path::PathBuf;
96use std::rc::Rc;
107
8use gimli::{AttributeValue, EndianRcSlice, Reader, RunTimeEndian};
9use object::{Object, ObjectSection};
10use run_make_support::{gimli, object, rfs, rustc};
11
1112fn main() {
1213 let output = PathBuf::from("repr128");
1314 rustc().input("main.rs").output(&output).arg("-Cdebuginfo=2").run();
tests/run-make/reset-codegen-1/rmake.rs+2-1
......@@ -7,9 +7,10 @@
77
88//@ ignore-cross-compile
99
10use run_make_support::{bin_name, rfs, rustc};
1110use std::path::Path;
1211
12use run_make_support::{bin_name, rfs, rustc};
13
1314fn compile(output_file: &str, emit: Option<&str>) {
1415 let mut rustc = rustc();
1516 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 @@
55// the renamed library.
66// See https://github.com/rust-lang/rust/pull/49253
77
8use run_make_support::rfs;
9use run_make_support::rustc;
8use run_make_support::{rfs, rustc};
109
1110fn main() {
1211 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 @@
44//@ ignore-nightly
55//@ only-x86_64-unknown-linux-gnu
66
7use std::process::Output;
8
79use run_make_support::regex::Regex;
810use run_make_support::rustc;
9use std::process::Output;
1011
1112fn main() {
1213 // 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 @@
66//@ ignore-stable
77//@ only-x86_64-unknown-linux-gnu
88
9use std::process::Output;
10
911use run_make_support::regex::Regex;
1012use run_make_support::rustc;
11use std::process::Output;
1213
1314fn main() {
1415 // 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 @@
88//@ needs-rust-lld
99//@ only-x86_64-unknown-linux-gnu
1010
11use std::process::Output;
12
1113use run_make_support::regex::Regex;
1214use run_make_support::rustc;
13use std::process::Output;
1415
1516fn main() {
1617 // 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 @@
55//@ ignore-msvc
66//@ ignore-s390x lld does not yet support s390x as target
77
8use std::process::Output;
9
810use run_make_support::regex::Regex;
911use run_make_support::rustc;
10use std::process::Output;
1112
1213fn main() {
1314 // 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 @@
11// Assert that the search index is generated deterministically, regardless of the
22// order that crates are documented in.
33
4use run_make_support::{diff, rustdoc};
54use std::path::Path;
65
6use run_make_support::{diff, rustdoc};
7
78fn main() {
89 let foo_first = Path::new("foo_first");
910 rustdoc().input("foo.rs").output(&foo_first).run();
tests/run-make/rustdoc-io-error/rmake.rs+2-1
......@@ -14,9 +14,10 @@
1414// `mkfs.ext4 -d`, as well as mounting a loop device for the rootfs.
1515//@ ignore-windows - the `set_readonly` functions doesn't work on folders.
1616
17use run_make_support::{path, rustdoc};
1817use std::fs;
1918
19use run_make_support::{path, rustdoc};
20
2021fn main() {
2122 let out_dir = path("rustdoc-io-error");
2223 let output = fs::create_dir(&out_dir).unwrap();
tests/run-make/rustdoc-output-path/rmake.rs+2-1
......@@ -1,8 +1,9 @@
11// Checks that if the output folder doesn't exist, rustdoc will create it.
22
3use run_make_support::rustdoc;
43use std::path::Path;
54
5use run_make_support::rustdoc;
6
67fn main() {
78 let out_dir = Path::new("foo/bar/doc");
89 rustdoc().input("foo.rs").output(&out_dir).run();
tests/run-make/rustdoc-scrape-examples-remap/scrape.rs+2-1
......@@ -1,6 +1,7 @@
1use run_make_support::{htmldocck, rfs, rustc, rustdoc, source_root};
21use std::path::Path;
32
3use run_make_support::{htmldocck, rfs, rustc, rustdoc, source_root};
4
45pub fn scrape(extra_args: &[&str]) {
56 let out_dir = Path::new("rustdoc");
67 let crate_name = "foobar";
tests/run-make/rustdoc-test-args/rmake.rs+2-1
......@@ -1,7 +1,8 @@
1use run_make_support::{rfs, rustdoc};
21use std::iter;
32use std::path::Path;
43
4use run_make_support::{rfs, rustdoc};
5
56fn generate_a_lot_of_cfgs(path: &Path) {
67 let content = iter::repeat("--cfg=a\n").take(100_000).collect::<String>();
78 rfs::write(path, content.as_bytes());
tests/run-make/rustdoc-themes/rmake.rs+2-1
......@@ -1,8 +1,9 @@
11// Test that rustdoc will properly load in a theme file and display it in the theme selector.
22
3use run_make_support::{htmldocck, rfs, rustdoc, source_root};
43use std::path::Path;
54
5use run_make_support::{htmldocck, rfs, rustdoc, source_root};
6
67fn main() {
78 let out_dir = Path::new("rustdoc-themes");
89 let test_css = "test.css";
tests/run-make/rustdoc-verify-output-files/rmake.rs+1-2
......@@ -1,7 +1,6 @@
1use run_make_support::rfs;
21use std::path::{Path, PathBuf};
32
4use run_make_support::{assert_dirs_are_equal, rustdoc};
3use run_make_support::{assert_dirs_are_equal, rfs, rustdoc};
54
65#[derive(PartialEq)]
76enum JsonOutput {
tests/run-make/static-pie/rmake.rs+1-3
......@@ -7,10 +7,8 @@
77
88use std::process::Command;
99
10use run_make_support::llvm_readobj;
1110use run_make_support::regex::Regex;
12use run_make_support::rustc;
13use run_make_support::{cmd, run_with_args, target};
11use run_make_support::{cmd, llvm_readobj, run_with_args, rustc, target};
1412
1513// Minimum major versions supporting -static-pie
1614const GCC_VERSION: u32 = 8;
tests/run-make/stdin-rustc/rmake.rs+2-1
......@@ -1,8 +1,9 @@
11//! This test checks rustc `-` (stdin) support
22
3use run_make_support::{is_windows, rustc};
43use std::path::PathBuf;
54
5use run_make_support::{is_windows, rustc};
6
67const HELLO_WORLD: &str = r#"
78fn main() {
89 println!("Hello world!");
tests/run-make/stdin-rustdoc/rmake.rs+2-1
......@@ -1,8 +1,9 @@
11//! This test checks rustdoc `-` (stdin) handling
22
3use run_make_support::rustdoc;
43use std::path::PathBuf;
54
5use run_make_support::rustdoc;
6
67static INPUT: &str = r#"
78//! ```
89//! dbg!(());
tests/run-make/suspicious-library/rmake.rs+2-1
......@@ -3,9 +3,10 @@
33
44//@ ignore-cross-compile
55
6use run_make_support::{dynamic_lib_name, rustc};
76use std::fs::File;
87
8use run_make_support::{dynamic_lib_name, rustc};
9
910fn main() {
1011 rustc().input("foo.rs").arg("-Cprefer-dynamic").run();
1112 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 @@
11#![no_main]
22#![no_std]
33use core::fmt::Write;
4
45use cortex_m::asm;
56use cortex_m_rt::entry;
6use cortex_m_semihosting as semihosting;
7
8use panic_halt as _;
7use {cortex_m_semihosting as semihosting, panic_halt as _};
98
109#[entry]
1110fn main() -> ! {
tests/run-make/volatile-intrinsics/rmake.rs+1-2
......@@ -1,7 +1,6 @@
11//@ ignore-cross-compile
22
3use run_make_support::rfs;
4use run_make_support::{assert_contains, run, rustc};
3use run_make_support::{assert_contains, rfs, run, rustc};
54
65fn main() {
76 // The tests must pass...
tests/run-make/wasm-custom-section/rmake.rs+2-1
......@@ -1,8 +1,9 @@
11//@ only-wasm32-wasip1
22
3use run_make_support::{rfs, rustc, wasmparser};
43use std::collections::HashMap;
54
5use run_make_support::{rfs, rustc, wasmparser};
6
67fn main() {
78 rustc().input("foo.rs").target("wasm32-wasip1").run();
89 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 @@
11//@ only-wasm32-wasip1
22
3use run_make_support::{rfs, rustc, wasmparser};
43use std::collections::HashMap;
54use std::path::Path;
65
6use run_make_support::{rfs, rustc, wasmparser};
7
78fn main() {
89 rustc().input("foo.rs").target("wasm32-wasip1").opt().run();
910
tests/run-make/wasm-export-all-symbols/rmake.rs+2-1
......@@ -1,8 +1,9 @@
11//@ only-wasm32-wasip1
22
3use run_make_support::{rfs, rustc, wasmparser};
43use std::collections::HashMap;
54use std::path::Path;
5
6use run_make_support::{rfs, rustc, wasmparser};
67use wasmparser::ExternalKind::*;
78
89fn main() {
tests/run-make/wasm-import-module/rmake.rs+2-1
......@@ -1,7 +1,8 @@
11//@ only-wasm32-wasip1
22
3use run_make_support::{rfs, rustc, wasmparser};
43use std::collections::HashMap;
4
5use run_make_support::{rfs, rustc, wasmparser};
56use wasmparser::TypeRef::Func;
67
78fn main() {
tests/run-make/wasm-spurious-import/rmake.rs+2-1
......@@ -1,8 +1,9 @@
11//@ only-wasm32-wasip1
22
3use run_make_support::{rfs, rustc, wasmparser};
43use std::collections::HashMap;
54
5use run_make_support::{rfs, rustc, wasmparser};
6
67fn main() {
78 rustc()
89 .input("main.rs")
tests/run-make/wasm-symbols-different-module/rmake.rs+2-1
......@@ -1,9 +1,10 @@
11//@ only-wasm32-wasip1
22
3use run_make_support::{rfs, rustc, wasmparser};
43use std::collections::{HashMap, HashSet};
54use std::path::Path;
65
6use run_make_support::{rfs, rustc, wasmparser};
7
78fn main() {
89 test_file("foo.rs", &[("a", &["foo"]), ("b", &["foo"])]);
910 test_file("bar.rs", &[("m1", &["f", "g"]), ("m2", &["f"])]);
tests/run-make/wasm-symbols-not-exported/rmake.rs+2-1
......@@ -1,8 +1,9 @@
11//@ only-wasm32-wasip1
22
3use run_make_support::{rfs, rustc, wasmparser};
43use std::path::Path;
54
5use run_make_support::{rfs, rustc, wasmparser};
6
67fn main() {
78 rustc().input("foo.rs").target("wasm32-wasip1").run();
89 verify_symbols(Path::new("foo.wasm"));
tests/run-make/wasm-symbols-not-imported/rmake.rs+2-1
......@@ -1,8 +1,9 @@
11//@ only-wasm32-wasip1
22
3use run_make_support::{rfs, rustc, wasmparser};
43use std::path::Path;
54
5use run_make_support::{rfs, rustc, wasmparser};
6
67fn main() {
78 rustc().input("foo.rs").target("wasm32-wasip1").run();
89 verify_symbols(Path::new("foo.wasm"));
tests/run-make/weird-output-filenames/rmake.rs+1-2
......@@ -1,6 +1,5 @@
11use run_make_support::regex::Regex;
2use run_make_support::rfs;
3use run_make_support::{cwd, rustc};
2use run_make_support::{cwd, rfs, rustc};
43
54fn main() {
65 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 @@
22//! a "hello world" application by setting `PATH` to `C:\Windows\System32`.
33//@ only-windows
44
5use run_make_support::{cwd, env_var, rustc};
65use std::path::PathBuf;
76use std::process::Command;
87
8use run_make_support::{cwd, env_var, rustc};
9
910fn main() {
1011 rustc().input("hello.rs").run();
1112
tests/run-make/windows-ws2_32/rmake.rs+2-1
......@@ -2,7 +2,8 @@
22
33// Tests that WS2_32.dll is not unnecessarily linked, see issue #85441
44
5use run_make_support::object::{self, read::Object};
5use run_make_support::object::read::Object;
6use run_make_support::object::{self};
67use run_make_support::{rfs, rustc};
78
89fn main() {
tests/rustdoc-json/primitives/use_primitive.rs-1
......@@ -15,6 +15,5 @@ mod usize {}
1515
1616//@ is "$.index[*].inner.import[?(@.name=='my_i32')].id" null
1717pub use i32 as my_i32;
18
1918//@ is "$.index[*].inner.import[?(@.name=='u32')].id" null
2019pub use u32;