Skip to content

Commit 3bfa28c

Browse files
authored
Rollup merge of rust-lang#67922 - Centril:lowering-cleanup, r=petrochenkov
rustc_ast_lowering: misc cleanup & rustc dep reductions - The first two commits do some code simplification. - The next three do some file splitting (getting `lib.rs` below the 3kloc tidy lint). - The remaining commits reduce the number of `rustc::` imports. This works towards making lowering independent of the `rustc` crate. r? @oli-obk cc @Zoxc
2 parents f396387 + 5dafa6a commit 3bfa28c

File tree

22 files changed

+752
-748
lines changed

22 files changed

+752
-748
lines changed

src/librustc/infer/canonical/query_response.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use crate::traits::{Obligation, ObligationCause, PredicateObligation};
2222
use crate::ty::fold::TypeFoldable;
2323
use crate::ty::subst::{GenericArg, GenericArgKind};
2424
use crate::ty::{self, BoundVar, Ty, TyCtxt};
25-
use crate::util::captures::Captures;
25+
use rustc_data_structures::captures::Captures;
2626
use rustc_index::vec::Idx;
2727
use rustc_index::vec::IndexVec;
2828
use rustc_span::DUMMY_SP;

src/librustc/infer/outlives/verify.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::infer::{GenericKind, VerifyBound};
33
use crate::traits;
44
use crate::ty::subst::{InternalSubsts, Subst};
55
use crate::ty::{self, Ty, TyCtxt};
6-
use crate::util::captures::Captures;
6+
use rustc_data_structures::captures::Captures;
77
use rustc_hir::def_id::DefId;
88

99
/// The `TypeOutlives` struct has the job of "lowering" a `T: 'a`

src/librustc/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ pub mod ty;
100100

101101
pub mod util {
102102
pub mod bug;
103-
pub mod captures;
104103
pub mod common;
105104
}
106105

src/librustc/middle/cstore.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
use crate::hir::map as hir_map;
66
use crate::hir::map::definitions::{DefKey, DefPathTable};
77
use crate::session::search_paths::PathKind;
8-
use crate::session::{CrateDisambiguator, Session};
9-
use crate::ty::{self, TyCtxt};
8+
use crate::session::CrateDisambiguator;
9+
use crate::ty::TyCtxt;
1010

1111
use rustc_data_structures::svh::Svh;
1212
use rustc_data_structures::sync::{self, MetadataRef};
@@ -208,7 +208,6 @@ pub trait CrateStore {
208208
fn crate_is_private_dep_untracked(&self, cnum: CrateNum) -> bool;
209209
fn crate_disambiguator_untracked(&self, cnum: CrateNum) -> CrateDisambiguator;
210210
fn crate_hash_untracked(&self, cnum: CrateNum) -> Svh;
211-
fn item_generics_cloned_untracked(&self, def: DefId, sess: &Session) -> ty::Generics;
212211

213212
// This is basically a 1-based range of ints, which is a little
214213
// silly - I may fix that.

src/librustc/traits/project.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ use crate::infer::{InferCtxt, InferOk, LateBoundRegionConversionTime};
1717
use crate::ty::fold::{TypeFoldable, TypeFolder};
1818
use crate::ty::subst::{InternalSubsts, Subst};
1919
use crate::ty::{self, ToPolyTraitRef, ToPredicate, Ty, TyCtxt};
20-
use crate::util::common::FN_OUTPUT_NAME;
2120
use rustc_data_structures::snapshot_map::{Snapshot, SnapshotMap};
2221
use rustc_hir::def_id::DefId;
2322
use rustc_macros::HashStable;
@@ -1364,7 +1363,7 @@ fn confirm_callable_candidate<'cx, 'tcx>(
13641363
projection_ty: ty::ProjectionTy::from_ref_and_name(
13651364
tcx,
13661365
trait_ref,
1367-
Ident::with_dummy_span(FN_OUTPUT_NAME),
1366+
Ident::with_dummy_span(rustc_hir::FN_OUTPUT_NAME),
13681367
),
13691368
ty: ret_type,
13701369
});

src/librustc/ty/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ use crate::ty::layout::VariantIdx;
2626
use crate::ty::subst::{InternalSubsts, Subst, SubstsRef};
2727
use crate::ty::util::{Discr, IntTypeExt};
2828
use crate::ty::walk::TypeWalker;
29-
use crate::util::captures::Captures;
3029
use arena::SyncDroplessArena;
30+
use rustc_data_structures::captures::Captures;
3131
use rustc_data_structures::fx::FxHashMap;
3232
use rustc_data_structures::fx::FxIndexMap;
3333
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};

src/librustc/ty/sty.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,10 @@ use crate::ty::layout::VariantIdx;
1313
use crate::ty::subst::{GenericArg, GenericArgKind, InternalSubsts, Subst, SubstsRef};
1414
use crate::ty::{self, AdtDef, DefIdTree, Discr, Ty, TyCtxt, TypeFlags, TypeFoldable};
1515
use crate::ty::{List, ParamEnv, ParamEnvAnd, TyS};
16-
use crate::util::captures::Captures;
16+
use polonius_engine::Atom;
17+
use rustc_data_structures::captures::Captures;
1718
use rustc_hir as hir;
1819
use rustc_hir::def_id::DefId;
19-
20-
use polonius_engine::Atom;
2120
use rustc_index::vec::Idx;
2221
use rustc_macros::HashStable;
2322
use rustc_span::symbol::{kw, Symbol};

src/librustc/util/common.rs

-5
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,9 @@ use rustc_data_structures::sync::Lock;
55
use std::fmt::Debug;
66
use std::time::{Duration, Instant};
77

8-
use rustc_span::symbol::{sym, Symbol};
9-
108
#[cfg(test)]
119
mod tests;
1210

13-
// The name of the associated type for `Fn` return types.
14-
pub const FN_OUTPUT_NAME: Symbol = sym::Output;
15-
1611
pub use errors::ErrorReported;
1712

1813
pub fn to_readable_str(mut val: usize) -> String {

src/librustc_ast_lowering/item.rs

+4-7
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,16 @@ pub(super) struct ItemLowerer<'a, 'lowering, 'hir> {
2525
pub(super) lctx: &'a mut LoweringContext<'lowering, 'hir>,
2626
}
2727

28-
impl<'a, 'lowering, 'hir> ItemLowerer<'a, 'lowering, 'hir> {
29-
fn with_trait_impl_ref<F>(&mut self, trait_impl_ref: &Option<TraitRef>, f: F)
30-
where
31-
F: FnOnce(&mut Self),
32-
{
28+
impl ItemLowerer<'_, '_, '_> {
29+
fn with_trait_impl_ref(&mut self, impl_ref: &Option<TraitRef>, f: impl FnOnce(&mut Self)) {
3330
let old = self.lctx.is_in_trait_impl;
34-
self.lctx.is_in_trait_impl = if let &None = trait_impl_ref { false } else { true };
31+
self.lctx.is_in_trait_impl = if let &None = impl_ref { false } else { true };
3532
f(self);
3633
self.lctx.is_in_trait_impl = old;
3734
}
3835
}
3936

40-
impl<'a, 'lowering, 'hir> Visitor<'a> for ItemLowerer<'a, 'lowering, 'hir> {
37+
impl<'a> Visitor<'a> for ItemLowerer<'a, '_, '_> {
4138
fn visit_mod(&mut self, m: &'a Mod, _s: Span, _attrs: &[Attribute], n: NodeId) {
4239
let hir_id = self.lctx.lower_node_id(n);
4340

0 commit comments

Comments
 (0)