Skip to content

Commit 400a1b1

Browse files
committed
Auto merge of #126716 - jieyouxu:rollup-yjml58m, r=jieyouxu
Rollup of 9 pull requests Successful merges: - #126095 (Migrate `link-args-order`, `ls-metadata` and `lto-readonly-lib` `run-make` tests to `rmake`) - #126534 (Migrate `run-make/comment-section` to `rmake.rs`) - #126620 (Actually taint InferCtxt when a fulfillment error is emitted) - #126629 (Migrate `run-make/compressed-debuginfo` to `rmake.rs`) - #126644 (Rewrite `extern-flag-rename-transitive`. `debugger-visualizer-dep-info`, `metadata-flag-frobs-symbols`, `extern-overrides-distribution` and `forced-unwind-terminate-pof` `run-make` tests to rmake) - #126650 (Rename a bunch of things in the new solver and `rustc_type_ir`) - #126698 (Migrate `unknown-mod-stdin`, `issue-68794-textrel-on-minimal-lib`, `raw-dylib-cross-compilation` and `used-cdylib-macos` `run-make` tests to rmake) - #126703 (reword the hint::blackbox non-guarantees) - #126708 (Minimize `can_begin_literal_maybe_minus` usage) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 3d5d7a2 + edfeec0 commit 400a1b1

File tree

135 files changed

+1509
-985
lines changed

Some content is hidden

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

135 files changed

+1509
-985
lines changed

compiler/rustc_ast/src/token.rs

+18-2
Original file line numberDiff line numberDiff line change
@@ -558,9 +558,10 @@ impl Token {
558558
/// Returns `true` if the token can appear at the start of a const param.
559559
pub fn can_begin_const_arg(&self) -> bool {
560560
match self.kind {
561-
OpenDelim(Delimiter::Brace) => true,
561+
OpenDelim(Delimiter::Brace) | Literal(..) | BinOp(Minus) => true,
562+
Ident(name, IdentIsRaw::No) if name.is_bool_lit() => true,
562563
Interpolated(ref nt) => matches!(&**nt, NtExpr(..) | NtBlock(..) | NtLiteral(..)),
563-
_ => self.can_begin_literal_maybe_minus(),
564+
_ => false,
564565
}
565566
}
566567

@@ -620,6 +621,21 @@ impl Token {
620621
}
621622
}
622623

624+
pub fn can_begin_string_literal(&self) -> bool {
625+
match self.uninterpolate().kind {
626+
Literal(..) => true,
627+
Interpolated(ref nt) => match &**nt {
628+
NtLiteral(_) => true,
629+
NtExpr(e) => match &e.kind {
630+
ast::ExprKind::Lit(_) => true,
631+
_ => false,
632+
},
633+
_ => false,
634+
},
635+
_ => false,
636+
}
637+
}
638+
623639
/// A convenience function for matching on identifiers during parsing.
624640
/// Turns interpolated identifier (`$i: ident`) or lifetime (`$l: lifetime`) token
625641
/// into the regular identifier or lifetime token it refers to,

compiler/rustc_borrowck/src/region_infer/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1110,7 +1110,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
11101110
tcx: TyCtxt<'tcx>,
11111111
}
11121112
impl<'tcx> ty::TypeFolder<TyCtxt<'tcx>> for OpaqueFolder<'tcx> {
1113-
fn interner(&self) -> TyCtxt<'tcx> {
1113+
fn cx(&self) -> TyCtxt<'tcx> {
11141114
self.tcx
11151115
}
11161116
fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {

compiler/rustc_hir_analysis/src/check/compare_impl_item.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ struct RemapLateBound<'a, 'tcx> {
397397
}
398398

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

@@ -790,13 +790,13 @@ impl<'tcx, E> TypeFolder<TyCtxt<'tcx>> for ImplTraitInTraitCollector<'_, 'tcx, E
790790
where
791791
E: 'tcx,
792792
{
793-
fn interner(&self) -> TyCtxt<'tcx> {
793+
fn cx(&self) -> TyCtxt<'tcx> {
794794
self.ocx.infcx.tcx
795795
}
796796

797797
fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
798798
if let ty::Alias(ty::Projection, proj) = ty.kind()
799-
&& self.interner().is_impl_trait_in_trait(proj.def_id)
799+
&& self.cx().is_impl_trait_in_trait(proj.def_id)
800800
{
801801
if let Some((ty, _)) = self.types.get(&proj.def_id) {
802802
return *ty;
@@ -810,9 +810,9 @@ where
810810
self.types.insert(proj.def_id, (infer_ty, proj.args));
811811
// Recurse into bounds
812812
for (pred, pred_span) in self
813-
.interner()
813+
.cx()
814814
.explicit_item_bounds(proj.def_id)
815-
.iter_instantiated_copied(self.interner(), proj.args)
815+
.iter_instantiated_copied(self.cx(), proj.args)
816816
{
817817
let pred = pred.fold_with(self);
818818
let pred = self.ocx.normalize(
@@ -822,7 +822,7 @@ where
822822
);
823823

824824
self.ocx.register_obligation(traits::Obligation::new(
825-
self.interner(),
825+
self.cx(),
826826
ObligationCause::new(
827827
self.span,
828828
self.body_id,
@@ -853,7 +853,7 @@ struct RemapHiddenTyRegions<'tcx> {
853853
impl<'tcx> ty::FallibleTypeFolder<TyCtxt<'tcx>> for RemapHiddenTyRegions<'tcx> {
854854
type Error = ErrorGuaranteed;
855855

856-
fn interner(&self) -> TyCtxt<'tcx> {
856+
fn cx(&self) -> TyCtxt<'tcx> {
857857
self.tcx
858858
}
859859

@@ -2072,7 +2072,7 @@ struct ReplaceTy<'tcx> {
20722072
}
20732073

20742074
impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ReplaceTy<'tcx> {
2075-
fn interner(&self) -> TyCtxt<'tcx> {
2075+
fn cx(&self) -> TyCtxt<'tcx> {
20762076
self.tcx
20772077
}
20782078

compiler/rustc_hir_analysis/src/check/compare_impl_item/refine.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ struct Anonymize<'tcx> {
322322
}
323323

324324
impl<'tcx> TypeFolder<TyCtxt<'tcx>> for Anonymize<'tcx> {
325-
fn interner(&self) -> TyCtxt<'tcx> {
325+
fn cx(&self) -> TyCtxt<'tcx> {
326326
self.tcx
327327
}
328328

compiler/rustc_hir_analysis/src/check/wfcheck.rs

+1-10
Original file line numberDiff line numberDiff line change
@@ -119,16 +119,7 @@ where
119119

120120
let errors = wfcx.select_all_or_error();
121121
if !errors.is_empty() {
122-
let err = infcx.err_ctxt().report_fulfillment_errors(errors);
123-
if tcx.dcx().has_errors().is_some() {
124-
return Err(err);
125-
} else {
126-
// HACK(oli-obk): tests/ui/specialization/min_specialization/specialize_on_type_error.rs
127-
// causes an delayed bug during normalization, without reporting an error, so we need
128-
// to act as if no error happened, in order to let our callers continue and report an
129-
// error later in check_impl_items_against_trait.
130-
return Ok(());
131-
}
122+
return Err(infcx.err_ctxt().report_fulfillment_errors(errors));
132123
}
133124

134125
debug!(?assumed_wf_types);

compiler/rustc_hir_analysis/src/coherence/orphan.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ struct TyVarReplacer<'cx, 'tcx> {
539539
}
540540

541541
impl<'cx, 'tcx> TypeFolder<TyCtxt<'tcx>> for TyVarReplacer<'cx, 'tcx> {
542-
fn interner(&self) -> TyCtxt<'tcx> {
542+
fn cx(&self) -> TyCtxt<'tcx> {
543543
self.infcx.tcx
544544
}
545545

compiler/rustc_hir_analysis/src/collect/item_bounds.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ struct AssocTyToOpaque<'tcx> {
203203
}
204204

205205
impl<'tcx> TypeFolder<TyCtxt<'tcx>> for AssocTyToOpaque<'tcx> {
206-
fn interner(&self) -> TyCtxt<'tcx> {
206+
fn cx(&self) -> TyCtxt<'tcx> {
207207
self.tcx
208208
}
209209

compiler/rustc_hir_typeck/src/writeback.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -793,7 +793,7 @@ impl<'cx, 'tcx> Resolver<'cx, 'tcx> {
793793
}
794794

795795
fn report_error(&self, p: impl Into<ty::GenericArg<'tcx>>) -> ErrorGuaranteed {
796-
if let Some(guar) = self.fcx.dcx().has_errors() {
796+
if let Some(guar) = self.fcx.tainted_by_errors() {
797797
guar
798798
} else {
799799
self.fcx
@@ -847,7 +847,7 @@ impl<'cx, 'tcx> Resolver<'cx, 'tcx> {
847847
}
848848

849849
impl<'cx, 'tcx> TypeFolder<TyCtxt<'tcx>> for Resolver<'cx, 'tcx> {
850-
fn interner(&self) -> TyCtxt<'tcx> {
850+
fn cx(&self) -> TyCtxt<'tcx> {
851851
self.fcx.tcx
852852
}
853853

compiler/rustc_infer/src/infer/canonical/canonicalizer.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ struct Canonicalizer<'cx, 'tcx> {
304304
}
305305

306306
impl<'cx, 'tcx> TypeFolder<TyCtxt<'tcx>> for Canonicalizer<'cx, 'tcx> {
307-
fn interner(&self) -> TyCtxt<'tcx> {
307+
fn cx(&self) -> TyCtxt<'tcx> {
308308
self.tcx
309309
}
310310

@@ -773,7 +773,7 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
773773
) -> ty::Region<'tcx> {
774774
let var = self.canonical_var(info, r.into());
775775
let br = ty::BoundRegion { var, kind: ty::BrAnon };
776-
ty::Region::new_bound(self.interner(), self.binder_index, br)
776+
ty::Region::new_bound(self.cx(), self.binder_index, br)
777777
}
778778

779779
/// Given a type variable `ty_var` of the given kind, first check

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ struct ClosureEraser<'tcx> {
158158
}
159159

160160
impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ClosureEraser<'tcx> {
161-
fn interner(&self) -> TyCtxt<'tcx> {
161+
fn cx(&self) -> TyCtxt<'tcx> {
162162
self.tcx
163163
}
164164

compiler/rustc_infer/src/infer/freshen.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ impl<'a, 'tcx> TypeFreshener<'a, 'tcx> {
100100
}
101101

102102
impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for TypeFreshener<'a, 'tcx> {
103-
fn interner(&self) -> TyCtxt<'tcx> {
103+
fn cx(&self) -> TyCtxt<'tcx> {
104104
self.infcx.tcx
105105
}
106106

@@ -117,7 +117,7 @@ impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for TypeFreshener<'a, 'tcx> {
117117
| ty::RePlaceholder(..)
118118
| ty::ReStatic
119119
| ty::ReError(_)
120-
| ty::ReErased => self.interner().lifetimes.re_erased,
120+
| ty::ReErased => self.cx().lifetimes.re_erased,
121121
}
122122
}
123123

compiler/rustc_infer/src/infer/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1719,7 +1719,7 @@ struct InferenceLiteralEraser<'tcx> {
17191719
}
17201720

17211721
impl<'tcx> TypeFolder<TyCtxt<'tcx>> for InferenceLiteralEraser<'tcx> {
1722-
fn interner(&self) -> TyCtxt<'tcx> {
1722+
fn cx(&self) -> TyCtxt<'tcx> {
17231723
self.tcx
17241724
}
17251725

@@ -1859,7 +1859,7 @@ fn replace_param_and_infer_args_with_placeholder<'tcx>(
18591859
}
18601860

18611861
impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ReplaceParamAndInferWithPlaceholder<'tcx> {
1862-
fn interner(&self) -> TyCtxt<'tcx> {
1862+
fn cx(&self) -> TyCtxt<'tcx> {
18631863
self.tcx
18641864
}
18651865

compiler/rustc_infer/src/infer/resolve.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ impl<'a, 'tcx> OpportunisticVarResolver<'a, 'tcx> {
2424
}
2525

2626
impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for OpportunisticVarResolver<'a, 'tcx> {
27-
fn interner(&self) -> TyCtxt<'tcx> {
27+
fn cx(&self) -> TyCtxt<'tcx> {
2828
self.infcx.tcx
2929
}
3030

@@ -66,7 +66,7 @@ impl<'a, 'tcx> OpportunisticRegionResolver<'a, 'tcx> {
6666
}
6767

6868
impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for OpportunisticRegionResolver<'a, 'tcx> {
69-
fn interner(&self) -> TyCtxt<'tcx> {
69+
fn cx(&self) -> TyCtxt<'tcx> {
7070
self.infcx.tcx
7171
}
7272

@@ -85,7 +85,7 @@ impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for OpportunisticRegionResolver<'a, 'tcx
8585
.inner
8686
.borrow_mut()
8787
.unwrap_region_constraints()
88-
.opportunistic_resolve_var(TypeFolder::interner(self), vid),
88+
.opportunistic_resolve_var(TypeFolder::cx(self), vid),
8989
_ => r,
9090
}
9191
}
@@ -121,7 +121,7 @@ struct FullTypeResolver<'a, 'tcx> {
121121
impl<'a, 'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for FullTypeResolver<'a, 'tcx> {
122122
type Error = FixupError;
123123

124-
fn interner(&self) -> TyCtxt<'tcx> {
124+
fn cx(&self) -> TyCtxt<'tcx> {
125125
self.infcx.tcx
126126
}
127127

compiler/rustc_infer/src/infer/snapshot/fudge.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ pub struct InferenceFudger<'a, 'tcx> {
183183
}
184184

185185
impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for InferenceFudger<'a, 'tcx> {
186-
fn interner(&self) -> TyCtxt<'tcx> {
186+
fn cx(&self) -> TyCtxt<'tcx> {
187187
self.infcx.tcx
188188
}
189189

compiler/rustc_lint/src/non_local_def.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ struct ReplaceLocalTypesWithInfer<'a, 'tcx, F: FnMut(DefId) -> bool> {
390390
impl<'a, 'tcx, F: FnMut(DefId) -> bool> TypeFolder<TyCtxt<'tcx>>
391391
for ReplaceLocalTypesWithInfer<'a, 'tcx, F>
392392
{
393-
fn interner(&self) -> TyCtxt<'tcx> {
393+
fn cx(&self) -> TyCtxt<'tcx> {
394394
self.infcx.tcx
395395
}
396396

compiler/rustc_middle/src/traits/solve.rs

+10-12
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for ExternalConstraints<'tcx> {
5353
self,
5454
folder: &mut F,
5555
) -> Result<Self, F::Error> {
56-
Ok(FallibleTypeFolder::interner(folder).mk_external_constraints(ExternalConstraintsData {
56+
Ok(FallibleTypeFolder::cx(folder).mk_external_constraints(ExternalConstraintsData {
5757
region_constraints: self.region_constraints.clone().try_fold_with(folder)?,
5858
opaque_types: self
5959
.opaque_types
@@ -68,7 +68,7 @@ impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for ExternalConstraints<'tcx> {
6868
}
6969

7070
fn fold_with<F: TypeFolder<TyCtxt<'tcx>>>(self, folder: &mut F) -> Self {
71-
TypeFolder::interner(folder).mk_external_constraints(ExternalConstraintsData {
71+
TypeFolder::cx(folder).mk_external_constraints(ExternalConstraintsData {
7272
region_constraints: self.region_constraints.clone().fold_with(folder),
7373
opaque_types: self.opaque_types.iter().map(|opaque| opaque.fold_with(folder)).collect(),
7474
normalization_nested_goals: self.normalization_nested_goals.clone().fold_with(folder),
@@ -94,19 +94,17 @@ impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for PredefinedOpaques<'tcx> {
9494
self,
9595
folder: &mut F,
9696
) -> Result<Self, F::Error> {
97-
Ok(FallibleTypeFolder::interner(folder).mk_predefined_opaques_in_body(
98-
PredefinedOpaquesData {
99-
opaque_types: self
100-
.opaque_types
101-
.iter()
102-
.map(|opaque| opaque.try_fold_with(folder))
103-
.collect::<Result<_, F::Error>>()?,
104-
},
105-
))
97+
Ok(FallibleTypeFolder::cx(folder).mk_predefined_opaques_in_body(PredefinedOpaquesData {
98+
opaque_types: self
99+
.opaque_types
100+
.iter()
101+
.map(|opaque| opaque.try_fold_with(folder))
102+
.collect::<Result<_, F::Error>>()?,
103+
}))
106104
}
107105

108106
fn fold_with<F: TypeFolder<TyCtxt<'tcx>>>(self, folder: &mut F) -> Self {
109-
TypeFolder::interner(folder).mk_predefined_opaques_in_body(PredefinedOpaquesData {
107+
TypeFolder::cx(folder).mk_predefined_opaques_in_body(PredefinedOpaquesData {
110108
opaque_types: self.opaque_types.iter().map(|opaque| opaque.fold_with(folder)).collect(),
111109
})
112110
}

compiler/rustc_middle/src/ty/abstract_const.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ impl<'tcx> TyCtxt<'tcx> {
4040
}
4141

4242
impl<'tcx> TypeFolder<TyCtxt<'tcx>> for Expander<'tcx> {
43-
fn interner(&self) -> TyCtxt<'tcx> {
43+
fn cx(&self) -> TyCtxt<'tcx> {
4444
self.tcx
4545
}
4646
fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {

compiler/rustc_middle/src/ty/diagnostics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ pub struct MakeSuggestableFolder<'tcx> {
579579
impl<'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for MakeSuggestableFolder<'tcx> {
580580
type Error = ();
581581

582-
fn interner(&self) -> TyCtxt<'tcx> {
582+
fn cx(&self) -> TyCtxt<'tcx> {
583583
self.tcx
584584
}
585585

compiler/rustc_middle/src/ty/erase_regions.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ struct RegionEraserVisitor<'tcx> {
3737
}
3838

3939
impl<'tcx> TypeFolder<TyCtxt<'tcx>> for RegionEraserVisitor<'tcx> {
40-
fn interner(&self) -> TyCtxt<'tcx> {
40+
fn cx(&self) -> TyCtxt<'tcx> {
4141
self.tcx
4242
}
4343

compiler/rustc_middle/src/ty/fold.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ where
2828
G: FnMut(ty::Region<'tcx>) -> ty::Region<'tcx>,
2929
H: FnMut(ty::Const<'tcx>) -> ty::Const<'tcx>,
3030
{
31-
fn interner(&self) -> TyCtxt<'tcx> {
31+
fn cx(&self) -> TyCtxt<'tcx> {
3232
self.tcx
3333
}
3434

@@ -99,7 +99,7 @@ impl<'a, 'tcx> RegionFolder<'a, 'tcx> {
9999
}
100100

101101
impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for RegionFolder<'a, 'tcx> {
102-
fn interner(&self) -> TyCtxt<'tcx> {
102+
fn cx(&self) -> TyCtxt<'tcx> {
103103
self.tcx
104104
}
105105

@@ -176,7 +176,7 @@ impl<'tcx, D> TypeFolder<TyCtxt<'tcx>> for BoundVarReplacer<'tcx, D>
176176
where
177177
D: BoundVarReplacerDelegate<'tcx>,
178178
{
179-
fn interner(&self) -> TyCtxt<'tcx> {
179+
fn cx(&self) -> TyCtxt<'tcx> {
180180
self.tcx
181181
}
182182

0 commit comments

Comments
 (0)