Skip to content

Commit

Permalink
Auto merge of #126716 - jieyouxu:rollup-yjml58m, r=jieyouxu
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bors committed Jun 20, 2024
2 parents 3d5d7a2 + edfeec0 commit 400a1b1
Show file tree
Hide file tree
Showing 135 changed files with 1,509 additions and 985 deletions.
20 changes: 18 additions & 2 deletions compiler/rustc_ast/src/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -558,9 +558,10 @@ impl Token {
/// Returns `true` if the token can appear at the start of a const param.
pub fn can_begin_const_arg(&self) -> bool {
match self.kind {
OpenDelim(Delimiter::Brace) => true,
OpenDelim(Delimiter::Brace) | Literal(..) | BinOp(Minus) => true,
Ident(name, IdentIsRaw::No) if name.is_bool_lit() => true,
Interpolated(ref nt) => matches!(&**nt, NtExpr(..) | NtBlock(..) | NtLiteral(..)),
_ => self.can_begin_literal_maybe_minus(),
_ => false,
}
}

Expand Down Expand Up @@ -620,6 +621,21 @@ impl Token {
}
}

pub fn can_begin_string_literal(&self) -> bool {
match self.uninterpolate().kind {
Literal(..) => true,
Interpolated(ref nt) => match &**nt {
NtLiteral(_) => true,
NtExpr(e) => match &e.kind {
ast::ExprKind::Lit(_) => true,
_ => false,
},
_ => false,
},
_ => false,
}
}

/// A convenience function for matching on identifiers during parsing.
/// Turns interpolated identifier (`$i: ident`) or lifetime (`$l: lifetime`) token
/// into the regular identifier or lifetime token it refers to,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/region_infer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1110,7 +1110,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
tcx: TyCtxt<'tcx>,
}
impl<'tcx> ty::TypeFolder<TyCtxt<'tcx>> for OpaqueFolder<'tcx> {
fn interner(&self) -> TyCtxt<'tcx> {
fn cx(&self) -> TyCtxt<'tcx> {
self.tcx
}
fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {
Expand Down
16 changes: 8 additions & 8 deletions compiler/rustc_hir_analysis/src/check/compare_impl_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ struct RemapLateBound<'a, 'tcx> {
}

impl<'tcx> TypeFolder<TyCtxt<'tcx>> for RemapLateBound<'_, 'tcx> {
fn interner(&self) -> TyCtxt<'tcx> {
fn cx(&self) -> TyCtxt<'tcx> {
self.tcx
}

Expand Down Expand Up @@ -790,13 +790,13 @@ impl<'tcx, E> TypeFolder<TyCtxt<'tcx>> for ImplTraitInTraitCollector<'_, 'tcx, E
where
E: 'tcx,
{
fn interner(&self) -> TyCtxt<'tcx> {
fn cx(&self) -> TyCtxt<'tcx> {
self.ocx.infcx.tcx
}

fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
if let ty::Alias(ty::Projection, proj) = ty.kind()
&& self.interner().is_impl_trait_in_trait(proj.def_id)
&& self.cx().is_impl_trait_in_trait(proj.def_id)
{
if let Some((ty, _)) = self.types.get(&proj.def_id) {
return *ty;
Expand All @@ -810,9 +810,9 @@ where
self.types.insert(proj.def_id, (infer_ty, proj.args));
// Recurse into bounds
for (pred, pred_span) in self
.interner()
.cx()
.explicit_item_bounds(proj.def_id)
.iter_instantiated_copied(self.interner(), proj.args)
.iter_instantiated_copied(self.cx(), proj.args)
{
let pred = pred.fold_with(self);
let pred = self.ocx.normalize(
Expand All @@ -822,7 +822,7 @@ where
);

self.ocx.register_obligation(traits::Obligation::new(
self.interner(),
self.cx(),
ObligationCause::new(
self.span,
self.body_id,
Expand Down Expand Up @@ -853,7 +853,7 @@ struct RemapHiddenTyRegions<'tcx> {
impl<'tcx> ty::FallibleTypeFolder<TyCtxt<'tcx>> for RemapHiddenTyRegions<'tcx> {
type Error = ErrorGuaranteed;

fn interner(&self) -> TyCtxt<'tcx> {
fn cx(&self) -> TyCtxt<'tcx> {
self.tcx
}

Expand Down Expand Up @@ -2072,7 +2072,7 @@ struct ReplaceTy<'tcx> {
}

impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ReplaceTy<'tcx> {
fn interner(&self) -> TyCtxt<'tcx> {
fn cx(&self) -> TyCtxt<'tcx> {
self.tcx
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ struct Anonymize<'tcx> {
}

impl<'tcx> TypeFolder<TyCtxt<'tcx>> for Anonymize<'tcx> {
fn interner(&self) -> TyCtxt<'tcx> {
fn cx(&self) -> TyCtxt<'tcx> {
self.tcx
}

Expand Down
11 changes: 1 addition & 10 deletions compiler/rustc_hir_analysis/src/check/wfcheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,16 +119,7 @@ where

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

debug!(?assumed_wf_types);
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/src/coherence/orphan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ struct TyVarReplacer<'cx, 'tcx> {
}

impl<'cx, 'tcx> TypeFolder<TyCtxt<'tcx>> for TyVarReplacer<'cx, 'tcx> {
fn interner(&self) -> TyCtxt<'tcx> {
fn cx(&self) -> TyCtxt<'tcx> {
self.infcx.tcx
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/src/collect/item_bounds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ struct AssocTyToOpaque<'tcx> {
}

impl<'tcx> TypeFolder<TyCtxt<'tcx>> for AssocTyToOpaque<'tcx> {
fn interner(&self) -> TyCtxt<'tcx> {
fn cx(&self) -> TyCtxt<'tcx> {
self.tcx
}

Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_hir_typeck/src/writeback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,7 @@ impl<'cx, 'tcx> Resolver<'cx, 'tcx> {
}

fn report_error(&self, p: impl Into<ty::GenericArg<'tcx>>) -> ErrorGuaranteed {
if let Some(guar) = self.fcx.dcx().has_errors() {
if let Some(guar) = self.fcx.tainted_by_errors() {
guar
} else {
self.fcx
Expand Down Expand Up @@ -847,7 +847,7 @@ impl<'cx, 'tcx> Resolver<'cx, 'tcx> {
}

impl<'cx, 'tcx> TypeFolder<TyCtxt<'tcx>> for Resolver<'cx, 'tcx> {
fn interner(&self) -> TyCtxt<'tcx> {
fn cx(&self) -> TyCtxt<'tcx> {
self.fcx.tcx
}

Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_infer/src/infer/canonical/canonicalizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ struct Canonicalizer<'cx, 'tcx> {
}

impl<'cx, 'tcx> TypeFolder<TyCtxt<'tcx>> for Canonicalizer<'cx, 'tcx> {
fn interner(&self) -> TyCtxt<'tcx> {
fn cx(&self) -> TyCtxt<'tcx> {
self.tcx
}

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

/// Given a type variable `ty_var` of the given kind, first check
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ struct ClosureEraser<'tcx> {
}

impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ClosureEraser<'tcx> {
fn interner(&self) -> TyCtxt<'tcx> {
fn cx(&self) -> TyCtxt<'tcx> {
self.tcx
}

Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_infer/src/infer/freshen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ impl<'a, 'tcx> TypeFreshener<'a, 'tcx> {
}

impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for TypeFreshener<'a, 'tcx> {
fn interner(&self) -> TyCtxt<'tcx> {
fn cx(&self) -> TyCtxt<'tcx> {
self.infcx.tcx
}

Expand All @@ -117,7 +117,7 @@ impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for TypeFreshener<'a, 'tcx> {
| ty::RePlaceholder(..)
| ty::ReStatic
| ty::ReError(_)
| ty::ReErased => self.interner().lifetimes.re_erased,
| ty::ReErased => self.cx().lifetimes.re_erased,
}
}

Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_infer/src/infer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1719,7 +1719,7 @@ struct InferenceLiteralEraser<'tcx> {
}

impl<'tcx> TypeFolder<TyCtxt<'tcx>> for InferenceLiteralEraser<'tcx> {
fn interner(&self) -> TyCtxt<'tcx> {
fn cx(&self) -> TyCtxt<'tcx> {
self.tcx
}

Expand Down Expand Up @@ -1859,7 +1859,7 @@ fn replace_param_and_infer_args_with_placeholder<'tcx>(
}

impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ReplaceParamAndInferWithPlaceholder<'tcx> {
fn interner(&self) -> TyCtxt<'tcx> {
fn cx(&self) -> TyCtxt<'tcx> {
self.tcx
}

Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_infer/src/infer/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ impl<'a, 'tcx> OpportunisticVarResolver<'a, 'tcx> {
}

impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for OpportunisticVarResolver<'a, 'tcx> {
fn interner(&self) -> TyCtxt<'tcx> {
fn cx(&self) -> TyCtxt<'tcx> {
self.infcx.tcx
}

Expand Down Expand Up @@ -66,7 +66,7 @@ impl<'a, 'tcx> OpportunisticRegionResolver<'a, 'tcx> {
}

impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for OpportunisticRegionResolver<'a, 'tcx> {
fn interner(&self) -> TyCtxt<'tcx> {
fn cx(&self) -> TyCtxt<'tcx> {
self.infcx.tcx
}

Expand All @@ -85,7 +85,7 @@ impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for OpportunisticRegionResolver<'a, 'tcx
.inner
.borrow_mut()
.unwrap_region_constraints()
.opportunistic_resolve_var(TypeFolder::interner(self), vid),
.opportunistic_resolve_var(TypeFolder::cx(self), vid),
_ => r,
}
}
Expand Down Expand Up @@ -121,7 +121,7 @@ struct FullTypeResolver<'a, 'tcx> {
impl<'a, 'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for FullTypeResolver<'a, 'tcx> {
type Error = FixupError;

fn interner(&self) -> TyCtxt<'tcx> {
fn cx(&self) -> TyCtxt<'tcx> {
self.infcx.tcx
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_infer/src/infer/snapshot/fudge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ pub struct InferenceFudger<'a, 'tcx> {
}

impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for InferenceFudger<'a, 'tcx> {
fn interner(&self) -> TyCtxt<'tcx> {
fn cx(&self) -> TyCtxt<'tcx> {
self.infcx.tcx
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_lint/src/non_local_def.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ struct ReplaceLocalTypesWithInfer<'a, 'tcx, F: FnMut(DefId) -> bool> {
impl<'a, 'tcx, F: FnMut(DefId) -> bool> TypeFolder<TyCtxt<'tcx>>
for ReplaceLocalTypesWithInfer<'a, 'tcx, F>
{
fn interner(&self) -> TyCtxt<'tcx> {
fn cx(&self) -> TyCtxt<'tcx> {
self.infcx.tcx
}

Expand Down
22 changes: 10 additions & 12 deletions compiler/rustc_middle/src/traits/solve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for ExternalConstraints<'tcx> {
self,
folder: &mut F,
) -> Result<Self, F::Error> {
Ok(FallibleTypeFolder::interner(folder).mk_external_constraints(ExternalConstraintsData {
Ok(FallibleTypeFolder::cx(folder).mk_external_constraints(ExternalConstraintsData {
region_constraints: self.region_constraints.clone().try_fold_with(folder)?,
opaque_types: self
.opaque_types
Expand All @@ -68,7 +68,7 @@ impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for ExternalConstraints<'tcx> {
}

fn fold_with<F: TypeFolder<TyCtxt<'tcx>>>(self, folder: &mut F) -> Self {
TypeFolder::interner(folder).mk_external_constraints(ExternalConstraintsData {
TypeFolder::cx(folder).mk_external_constraints(ExternalConstraintsData {
region_constraints: self.region_constraints.clone().fold_with(folder),
opaque_types: self.opaque_types.iter().map(|opaque| opaque.fold_with(folder)).collect(),
normalization_nested_goals: self.normalization_nested_goals.clone().fold_with(folder),
Expand All @@ -94,19 +94,17 @@ impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for PredefinedOpaques<'tcx> {
self,
folder: &mut F,
) -> Result<Self, F::Error> {
Ok(FallibleTypeFolder::interner(folder).mk_predefined_opaques_in_body(
PredefinedOpaquesData {
opaque_types: self
.opaque_types
.iter()
.map(|opaque| opaque.try_fold_with(folder))
.collect::<Result<_, F::Error>>()?,
},
))
Ok(FallibleTypeFolder::cx(folder).mk_predefined_opaques_in_body(PredefinedOpaquesData {
opaque_types: self
.opaque_types
.iter()
.map(|opaque| opaque.try_fold_with(folder))
.collect::<Result<_, F::Error>>()?,
}))
}

fn fold_with<F: TypeFolder<TyCtxt<'tcx>>>(self, folder: &mut F) -> Self {
TypeFolder::interner(folder).mk_predefined_opaques_in_body(PredefinedOpaquesData {
TypeFolder::cx(folder).mk_predefined_opaques_in_body(PredefinedOpaquesData {
opaque_types: self.opaque_types.iter().map(|opaque| opaque.fold_with(folder)).collect(),
})
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/ty/abstract_const.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl<'tcx> TyCtxt<'tcx> {
}

impl<'tcx> TypeFolder<TyCtxt<'tcx>> for Expander<'tcx> {
fn interner(&self) -> TyCtxt<'tcx> {
fn cx(&self) -> TyCtxt<'tcx> {
self.tcx
}
fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/ty/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ pub struct MakeSuggestableFolder<'tcx> {
impl<'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for MakeSuggestableFolder<'tcx> {
type Error = ();

fn interner(&self) -> TyCtxt<'tcx> {
fn cx(&self) -> TyCtxt<'tcx> {
self.tcx
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/ty/erase_regions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ struct RegionEraserVisitor<'tcx> {
}

impl<'tcx> TypeFolder<TyCtxt<'tcx>> for RegionEraserVisitor<'tcx> {
fn interner(&self) -> TyCtxt<'tcx> {
fn cx(&self) -> TyCtxt<'tcx> {
self.tcx
}

Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_middle/src/ty/fold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ where
G: FnMut(ty::Region<'tcx>) -> ty::Region<'tcx>,
H: FnMut(ty::Const<'tcx>) -> ty::Const<'tcx>,
{
fn interner(&self) -> TyCtxt<'tcx> {
fn cx(&self) -> TyCtxt<'tcx> {
self.tcx
}

Expand Down Expand Up @@ -99,7 +99,7 @@ impl<'a, 'tcx> RegionFolder<'a, 'tcx> {
}

impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for RegionFolder<'a, 'tcx> {
fn interner(&self) -> TyCtxt<'tcx> {
fn cx(&self) -> TyCtxt<'tcx> {
self.tcx
}

Expand Down Expand Up @@ -176,7 +176,7 @@ impl<'tcx, D> TypeFolder<TyCtxt<'tcx>> for BoundVarReplacer<'tcx, D>
where
D: BoundVarReplacerDelegate<'tcx>,
{
fn interner(&self) -> TyCtxt<'tcx> {
fn cx(&self) -> TyCtxt<'tcx> {
self.tcx
}

Expand Down
Loading

0 comments on commit 400a1b1

Please sign in to comment.