Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 52f3c71

Browse files
committed
Auto merge of rust-lang#127898 - matthiaskrgr:rollup-lkkpoui, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - rust-lang#127077 (Make language around `ToOwned` for `BorrowedFd` more precise) - rust-lang#127783 (Put the dots back in RTN pretty printing) - rust-lang#127787 (Migrate `atomic-lock-free` to `rmake`) - rust-lang#127810 (Rename `tcx` to `cx` in `rustc_type_ir`) - rust-lang#127878 (Fix associated item removal suggestion) - rust-lang#127886 (Accurate `use` rename suggestion span) - rust-lang#127888 (More accurate span for type parameter suggestion) - rust-lang#127889 (More accurate span for anonymous argument suggestion) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 4bb2f27 + 77e5bbf commit 52f3c71

File tree

80 files changed

+550
-383
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+550
-383
lines changed

compiler/rustc_borrowck/src/type_check/relate_tys.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ impl<'me, 'bccx, 'tcx> NllTypeRelating<'me, 'bccx, 'tcx> {
309309
}
310310

311311
impl<'bccx, 'tcx> TypeRelation<TyCtxt<'tcx>> for NllTypeRelating<'_, 'bccx, 'tcx> {
312-
fn tcx(&self) -> TyCtxt<'tcx> {
312+
fn cx(&self) -> TyCtxt<'tcx> {
313313
self.type_checker.infcx.tcx
314314
}
315315

@@ -370,7 +370,7 @@ impl<'bccx, 'tcx> TypeRelation<TyCtxt<'tcx>> for NllTypeRelating<'_, 'bccx, 'tcx
370370
// shouldn't ever fail. Instead, it unconditionally emits an
371371
// alias-relate goal.
372372
assert!(!self.type_checker.infcx.next_trait_solver());
373-
self.tcx().dcx().span_delayed_bug(
373+
self.cx().dcx().span_delayed_bug(
374374
self.span(),
375375
"failure to relate an opaque to itself should result in an error later on",
376376
);
@@ -540,7 +540,7 @@ impl<'bccx, 'tcx> PredicateEmittingRelation<InferCtxt<'tcx>> for NllTypeRelating
540540
&mut self,
541541
obligations: impl IntoIterator<Item: ty::Upcast<TyCtxt<'tcx>, ty::Predicate<'tcx>>>,
542542
) {
543-
let tcx = self.tcx();
543+
let tcx = self.cx();
544544
let param_env = self.param_env();
545545
self.register_goals(
546546
obligations.into_iter().map(|to_pred| Goal::new(tcx, param_env, to_pred)),
@@ -559,7 +559,7 @@ impl<'bccx, 'tcx> PredicateEmittingRelation<InferCtxt<'tcx>> for NllTypeRelating
559559
.into_iter()
560560
.map(|goal| {
561561
Obligation::new(
562-
self.tcx(),
562+
self.cx(),
563563
ObligationCause::dummy_with_span(self.span()),
564564
goal.param_env,
565565
goal.predicate,

compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1257,14 +1257,12 @@ pub fn prohibit_assoc_item_constraint(
12571257
};
12581258

12591259
// Now emit the suggestion
1260-
if let Ok(suggestion) = tcx.sess.source_map().span_to_snippet(removal_span) {
1261-
e.span_suggestion_verbose(
1262-
removal_span,
1263-
format!("consider removing this associated item {}", constraint.kind.descr()),
1264-
suggestion,
1265-
Applicability::MaybeIncorrect,
1266-
);
1267-
}
1260+
e.span_suggestion_verbose(
1261+
removal_span,
1262+
format!("consider removing this associated item {}", constraint.kind.descr()),
1263+
"",
1264+
Applicability::MaybeIncorrect,
1265+
);
12681266
};
12691267

12701268
// Suggest replacing the associated item binding with a generic argument.
@@ -1340,11 +1338,13 @@ pub fn prohibit_assoc_item_constraint(
13401338
format!("<{lifetimes}{type_with_constraints}>"),
13411339
)
13421340
};
1343-
let suggestions =
1344-
vec![param_decl, (constraint.span, format!("{}", matching_param.name))];
1341+
let suggestions = vec![
1342+
param_decl,
1343+
(constraint.span.with_lo(constraint.ident.span.hi()), String::new()),
1344+
];
13451345

13461346
err.multipart_suggestion_verbose(
1347-
format!("declare the type parameter right after the `impl` keyword"),
1347+
"declare the type parameter right after the `impl` keyword",
13481348
suggestions,
13491349
Applicability::MaybeIncorrect,
13501350
);

compiler/rustc_infer/src/error_reporting/infer/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1930,7 +1930,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
19301930
struct SameTypeModuloInfer<'a, 'tcx>(&'a InferCtxt<'tcx>);
19311931

19321932
impl<'tcx> TypeRelation<TyCtxt<'tcx>> for SameTypeModuloInfer<'_, 'tcx> {
1933-
fn tcx(&self) -> TyCtxt<'tcx> {
1933+
fn cx(&self) -> TyCtxt<'tcx> {
19341934
self.0.tcx
19351935
}
19361936

compiler/rustc_infer/src/infer/outlives/test_type_match.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for MatchAgainstHigherRankedOutlives<'tcx>
137137
"MatchAgainstHigherRankedOutlives"
138138
}
139139

140-
fn tcx(&self) -> TyCtxt<'tcx> {
140+
fn cx(&self) -> TyCtxt<'tcx> {
141141
self.tcx
142142
}
143143

compiler/rustc_infer/src/infer/relate/generalize.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ impl<'tcx> Generalizer<'_, 'tcx> {
372372

373373
let is_nested_alias = mem::replace(&mut self.in_alias, true);
374374
let result = match self.relate(alias, alias) {
375-
Ok(alias) => Ok(alias.to_ty(self.tcx())),
375+
Ok(alias) => Ok(alias.to_ty(self.cx())),
376376
Err(e) => {
377377
if is_nested_alias {
378378
return Err(e);
@@ -397,7 +397,7 @@ impl<'tcx> Generalizer<'_, 'tcx> {
397397
}
398398

399399
impl<'tcx> TypeRelation<TyCtxt<'tcx>> for Generalizer<'_, 'tcx> {
400-
fn tcx(&self) -> TyCtxt<'tcx> {
400+
fn cx(&self) -> TyCtxt<'tcx> {
401401
self.infcx.tcx
402402
}
403403

@@ -417,7 +417,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for Generalizer<'_, 'tcx> {
417417
// (e.g., #41849).
418418
relate::relate_args_invariantly(self, a_arg, b_arg)
419419
} else {
420-
let tcx = self.tcx();
420+
let tcx = self.cx();
421421
let opt_variances = tcx.variances_of(item_def_id);
422422
relate::relate_args_with_variances(
423423
self,
@@ -525,7 +525,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for Generalizer<'_, 'tcx> {
525525
}
526526

527527
debug!("replacing original vid={:?} with new={:?}", vid, new_var_id);
528-
Ok(Ty::new_var(self.tcx(), new_var_id))
528+
Ok(Ty::new_var(self.cx(), new_var_id))
529529
}
530530
}
531531
}
@@ -654,7 +654,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for Generalizer<'_, 'tcx> {
654654
{
655655
variable_table.union(vid, new_var_id);
656656
}
657-
Ok(ty::Const::new_var(self.tcx(), new_var_id))
657+
Ok(ty::Const::new_var(self.cx(), new_var_id))
658658
}
659659
}
660660
}
@@ -672,7 +672,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for Generalizer<'_, 'tcx> {
672672
args,
673673
args,
674674
)?;
675-
Ok(ty::Const::new_unevaluated(self.tcx(), ty::UnevaluatedConst { def, args }))
675+
Ok(ty::Const::new_unevaluated(self.cx(), ty::UnevaluatedConst { def, args }))
676676
}
677677
ty::ConstKind::Placeholder(placeholder) => {
678678
if self.for_universe.can_name(placeholder.universe) {

compiler/rustc_infer/src/infer/relate/glb.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for Glb<'_, '_, 'tcx> {
2727
"Glb"
2828
}
2929

30-
fn tcx(&self) -> TyCtxt<'tcx> {
30+
fn cx(&self) -> TyCtxt<'tcx> {
3131
self.fields.tcx()
3232
}
3333

@@ -61,7 +61,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for Glb<'_, '_, 'tcx> {
6161
let origin = SubregionOrigin::Subtype(Box::new(self.fields.trace.clone()));
6262
// GLB(&'static u8, &'a u8) == &RegionLUB('static, 'a) u8 == &'static u8
6363
Ok(self.fields.infcx.inner.borrow_mut().unwrap_region_constraints().lub_regions(
64-
self.tcx(),
64+
self.cx(),
6565
origin,
6666
a,
6767
b,

compiler/rustc_infer/src/infer/relate/lub.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for Lub<'_, '_, 'tcx> {
2727
"Lub"
2828
}
2929

30-
fn tcx(&self) -> TyCtxt<'tcx> {
30+
fn cx(&self) -> TyCtxt<'tcx> {
3131
self.fields.tcx()
3232
}
3333

@@ -61,7 +61,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for Lub<'_, '_, 'tcx> {
6161
let origin = SubregionOrigin::Subtype(Box::new(self.fields.trace.clone()));
6262
// LUB(&'static u8, &'a u8) == &RegionGLB('static, 'a) u8 == &'a u8
6363
Ok(self.fields.infcx.inner.borrow_mut().unwrap_region_constraints().glb_regions(
64-
self.tcx(),
64+
self.cx(),
6565
origin,
6666
a,
6767
b,

compiler/rustc_infer/src/infer/relate/type_relating.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for TypeRelating<'_, '_, 'tcx> {
3232
"TypeRelating"
3333
}
3434

35-
fn tcx(&self) -> TyCtxt<'tcx> {
35+
fn cx(&self) -> TyCtxt<'tcx> {
3636
self.fields.infcx.tcx
3737
}
3838

@@ -48,7 +48,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for TypeRelating<'_, '_, 'tcx> {
4848
// (e.g., #41849).
4949
relate_args_invariantly(self, a_arg, b_arg)
5050
} else {
51-
let tcx = self.tcx();
51+
let tcx = self.cx();
5252
let opt_variances = tcx.variances_of(item_def_id);
5353
relate_args_with_variances(self, item_def_id, opt_variances, a_arg, b_arg, false)
5454
}
@@ -88,7 +88,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for TypeRelating<'_, '_, 'tcx> {
8888
// can't make progress on `A <: B` if both A and B are
8989
// type variables, so record an obligation.
9090
self.fields.goals.push(Goal::new(
91-
self.tcx(),
91+
self.cx(),
9292
self.fields.param_env,
9393
ty::Binder::dummy(ty::PredicateKind::Subtype(ty::SubtypePredicate {
9494
a_is_expected: true,
@@ -101,7 +101,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for TypeRelating<'_, '_, 'tcx> {
101101
// can't make progress on `B <: A` if both A and B are
102102
// type variables, so record an obligation.
103103
self.fields.goals.push(Goal::new(
104-
self.tcx(),
104+
self.cx(),
105105
self.fields.param_env,
106106
ty::Binder::dummy(ty::PredicateKind::Subtype(ty::SubtypePredicate {
107107
a_is_expected: false,
@@ -134,7 +134,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for TypeRelating<'_, '_, 'tcx> {
134134

135135
(&ty::Error(e), _) | (_, &ty::Error(e)) => {
136136
infcx.set_tainted_by_errors(e);
137-
return Ok(Ty::new_error(self.tcx(), e));
137+
return Ok(Ty::new_error(self.cx(), e));
138138
}
139139

140140
(

compiler/rustc_macros/src/lift.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ pub fn lift_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStre
4545
quote! {
4646
type Lifted = #lifted;
4747

48-
fn lift_to_tcx(self, __tcx: ::rustc_middle::ty::TyCtxt<'__lifted>) -> Option<#lifted> {
48+
fn lift_to_interner(self, __tcx: ::rustc_middle::ty::TyCtxt<'__lifted>) -> Option<#lifted> {
4949
Some(match self { #body })
5050
}
5151
},

compiler/rustc_middle/src/macros.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ macro_rules! TrivialLiftImpls {
5959
$(
6060
impl<'tcx> $crate::ty::Lift<$crate::ty::TyCtxt<'tcx>> for $ty {
6161
type Lifted = Self;
62-
fn lift_to_tcx(self, _: $crate::ty::TyCtxt<'tcx>) -> Option<Self> {
62+
fn lift_to_interner(self, _: $crate::ty::TyCtxt<'tcx>) -> Option<Self> {
6363
Some(self)
6464
}
6565
}

0 commit comments

Comments
 (0)