1
Fork 0

Rollup merge of #137504 - nnethercote:remove-Map-4, r=Zalathar

Move methods from Map to TyCtxt, part 4.

A follow-up to https://github.com/rust-lang/rust/pull/137350.

r? ```@Zalathar```
This commit is contained in:
Manish Goregaokar 2025-03-12 10:19:26 -07:00 committed by GitHub
commit f88f27aff0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
124 changed files with 390 additions and 441 deletions

View file

@ -485,7 +485,7 @@ fn construct_fn<'tcx>(
};
if let Some(custom_mir_attr) =
tcx.hir().attrs(fn_id).iter().find(|attr| attr.name_or_empty() == sym::custom_mir)
tcx.hir_attrs(fn_id).iter().find(|attr| attr.name_or_empty() == sym::custom_mir)
{
return custom::build_custom_mir(
tcx,
@ -741,7 +741,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
coroutine: Option<Box<CoroutineInfo<'tcx>>>,
) -> Builder<'a, 'tcx> {
let tcx = infcx.tcx;
let attrs = tcx.hir().attrs(hir_id);
let attrs = tcx.hir_attrs(hir_id);
// Some functions always have overflow checks enabled,
// however, they may not get codegen'd, depending on
// the settings for the crate they are codegened in.

View file

@ -942,14 +942,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
assert_eq!(orig_id.owner, self.hir_id.owner);
let mut id = orig_id;
let hir = self.tcx.hir();
loop {
if id == self.hir_id {
// This is a moderately common case, mostly hit for previously unseen nodes.
break;
}
if hir.attrs(id).iter().any(|attr| Level::from_attr(attr).is_some()) {
if self.tcx.hir_attrs(id).iter().any(|attr| Level::from_attr(attr).is_some()) {
// This is a rare case. It's for a node path that doesn't reach the root due to an
// intervening lint level attribute. This result doesn't get cached.
return id;

View file

@ -1041,7 +1041,7 @@ impl<'tcx> ThirBuildCx<'tcx> {
"Should have already errored about late bound consts: {def_id:?}"
);
};
let name = self.tcx.hir().name(hir_id);
let name = self.tcx.hir_name(hir_id);
let param = ty::ParamConst::new(index, name);
ExprKind::ConstParam { param, def_id }

View file

@ -73,7 +73,6 @@ struct ThirBuildCx<'tcx> {
impl<'tcx> ThirBuildCx<'tcx> {
fn new(tcx: TyCtxt<'tcx>, def: LocalDefId) -> Self {
let typeck_results = tcx.typeck(def);
let hir = tcx.hir();
let hir_id = tcx.local_def_id_to_hir_id(def);
let body_type = match tcx.hir_body_owner_kind(def) {
@ -111,8 +110,8 @@ impl<'tcx> ThirBuildCx<'tcx> {
typeck_results,
rvalue_scopes: &typeck_results.rvalue_scopes,
body_owner: def.to_def_id(),
apply_adjustments: hir
.attrs(hir_id)
apply_adjustments: tcx
.hir_attrs(hir_id)
.iter()
.all(|attr| attr.name_or_empty() != rustc_span::sym::custom_mir),
}

View file

@ -1043,7 +1043,7 @@ fn find_fallback_pattern_typo<'tcx>(
for item in cx.tcx.hir_crate_items(()).free_items() {
if let DefKind::Use = cx.tcx.def_kind(item.owner_id) {
// Look for consts being re-exported.
let item = cx.tcx.hir().expect_item(item.owner_id.def_id);
let item = cx.tcx.hir_expect_item(item.owner_id.def_id);
let use_name = item.ident.name;
let hir::ItemKind::Use(path, _) = item.kind else {
continue;