Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 7 pull requests #119143

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
ca718ff
track the source of nested goals
lcnr Dec 18, 2023
4a38442
dont discard overflow from normalizes-to goals
lcnr Dec 18, 2023
3f87043
Remove legacy bitcode defaults
arttet Dec 19, 2023
fd0033c
Use LLVM features for arm64e_apple_ios target
arttet Dec 19, 2023
ffdc6c7
effects: fix comment
fmease Dec 19, 2023
e6d6b1d
Do not evaluate in structurally_relate_tys
compiler-errors Dec 18, 2023
009cd9c
Remove unnecessary param-env from lexical region resolution and fully…
compiler-errors Dec 18, 2023
17705ea
add comment
lcnr Dec 19, 2023
a75d002
Remove param env from relation altogether
compiler-errors Dec 19, 2023
d46df80
rustc_codegen_ssa: Don't let `IncorrectCguReuseType` errors get lost
Enselic Dec 12, 2023
7571f6f
resolve: Feed visibilities for unresolved trait impl items
petrochenkov Dec 19, 2023
2c96025
Improve compiler error for c-strings in pre-2021
chfogelman Dec 7, 2023
ea5bfb8
Rollup merge of #118691 - chfogelman:improve-cstr-error, r=fmease
compiler-errors Dec 19, 2023
b25b723
Rollup merge of #118973 - Enselic:fix-IncorrectCguReuseType, r=michae…
compiler-errors Dec 19, 2023
49dc89d
Rollup merge of #119071 - lcnr:overflowo, r=compiler-errors
compiler-errors Dec 19, 2023
505ae86
Rollup merge of #119089 - fmease:dont-ice-on-tilde-const-non-const-tr…
compiler-errors Dec 19, 2023
f5a1261
Rollup merge of #119096 - compiler-errors:yeet-unnecessary-param-envs…
compiler-errors Dec 19, 2023
f06ab92
Rollup merge of #119118 - arttet:feature/fix-arm64e-targets, r=petroc…
compiler-errors Dec 19, 2023
41228d5
Rollup merge of #119134 - petrochenkov:feedvis2, r=compiler-errors
compiler-errors Dec 19, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 6 additions & 23 deletions compiler/rustc_borrowck/src/region_infer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -674,13 +674,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
// eagerly.
let mut outlives_requirements = infcx.tcx.is_typeck_child(mir_def_id).then(Vec::new);

self.check_type_tests(
infcx,
param_env,
body,
outlives_requirements.as_mut(),
&mut errors_buffer,
);
self.check_type_tests(infcx, body, outlives_requirements.as_mut(), &mut errors_buffer);

debug!(?errors_buffer);
debug!(?outlives_requirements);
Expand Down Expand Up @@ -938,7 +932,6 @@ impl<'tcx> RegionInferenceContext<'tcx> {
fn check_type_tests(
&self,
infcx: &InferCtxt<'tcx>,
param_env: ty::ParamEnv<'tcx>,
body: &Body<'tcx>,
mut propagated_outlives_requirements: Option<&mut Vec<ClosureOutlivesRequirement<'tcx>>>,
errors_buffer: &mut RegionErrors<'tcx>,
Expand All @@ -956,7 +949,6 @@ impl<'tcx> RegionInferenceContext<'tcx> {
let generic_ty = type_test.generic_kind.to_ty(tcx);
if self.eval_verify_bound(
infcx,
param_env,
generic_ty,
type_test.lower_bound,
&type_test.verify_bound,
Expand All @@ -967,7 +959,6 @@ impl<'tcx> RegionInferenceContext<'tcx> {
if let Some(propagated_outlives_requirements) = &mut propagated_outlives_requirements {
if self.try_promote_type_test(
infcx,
param_env,
body,
type_test,
propagated_outlives_requirements,
Expand Down Expand Up @@ -1025,7 +1016,6 @@ impl<'tcx> RegionInferenceContext<'tcx> {
fn try_promote_type_test(
&self,
infcx: &InferCtxt<'tcx>,
param_env: ty::ParamEnv<'tcx>,
body: &Body<'tcx>,
type_test: &TypeTest<'tcx>,
propagated_outlives_requirements: &mut Vec<ClosureOutlivesRequirement<'tcx>>,
Expand Down Expand Up @@ -1087,7 +1077,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
// where `ur` is a local bound -- we are sometimes in a
// position to prove things that our caller cannot. See
// #53570 for an example.
if self.eval_verify_bound(infcx, param_env, generic_ty, ur, &type_test.verify_bound) {
if self.eval_verify_bound(infcx, generic_ty, ur, &type_test.verify_bound) {
continue;
}

Expand Down Expand Up @@ -1270,7 +1260,6 @@ impl<'tcx> RegionInferenceContext<'tcx> {
fn eval_verify_bound(
&self,
infcx: &InferCtxt<'tcx>,
param_env: ty::ParamEnv<'tcx>,
generic_ty: Ty<'tcx>,
lower_bound: RegionVid,
verify_bound: &VerifyBound<'tcx>,
Expand All @@ -1279,7 +1268,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {

match verify_bound {
VerifyBound::IfEq(verify_if_eq_b) => {
self.eval_if_eq(infcx, param_env, generic_ty, lower_bound, *verify_if_eq_b)
self.eval_if_eq(infcx, generic_ty, lower_bound, *verify_if_eq_b)
}

VerifyBound::IsEmpty => {
Expand All @@ -1293,31 +1282,25 @@ impl<'tcx> RegionInferenceContext<'tcx> {
}

VerifyBound::AnyBound(verify_bounds) => verify_bounds.iter().any(|verify_bound| {
self.eval_verify_bound(infcx, param_env, generic_ty, lower_bound, verify_bound)
self.eval_verify_bound(infcx, generic_ty, lower_bound, verify_bound)
}),

VerifyBound::AllBounds(verify_bounds) => verify_bounds.iter().all(|verify_bound| {
self.eval_verify_bound(infcx, param_env, generic_ty, lower_bound, verify_bound)
self.eval_verify_bound(infcx, generic_ty, lower_bound, verify_bound)
}),
}
}

fn eval_if_eq(
&self,
infcx: &InferCtxt<'tcx>,
param_env: ty::ParamEnv<'tcx>,
generic_ty: Ty<'tcx>,
lower_bound: RegionVid,
verify_if_eq_b: ty::Binder<'tcx, VerifyIfEq<'tcx>>,
) -> bool {
let generic_ty = self.normalize_to_scc_representatives(infcx.tcx, generic_ty);
let verify_if_eq_b = self.normalize_to_scc_representatives(infcx.tcx, verify_if_eq_b);
match test_type_match::extract_verify_if_eq(
infcx.tcx,
param_env,
&verify_if_eq_b,
generic_ty,
) {
match test_type_match::extract_verify_if_eq(infcx.tcx, &verify_if_eq_b, generic_ty) {
Some(r) => {
let r_vid = self.to_region_vid(r);
self.eval_outlives(r_vid, lower_bound)
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_codegen_ssa/src/assert_module_sources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,13 +278,13 @@ impl CguReuseTracker {

if error {
let at_least = if at_least { 1 } else { 0 };
errors::IncorrectCguReuseType {
sess.emit_err(errors::IncorrectCguReuseType {
span: *error_span,
cgu_user_name,
actual_reuse,
expected_reuse,
at_least,
};
});
}
} else {
sess.emit_fatal(errors::CguNotRecorded { cgu_user_name, cgu_name });
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/src/astconv/generics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ pub fn create_args_for_parent_generic_args<'tcx, 'a>(
// impl const PartialEq for () {}
// ```
//
// Since this is a const impl, we need to insert `<false>` at the end of
// Since this is a const impl, we need to insert a host arg at the end of
// `PartialEq`'s generics, but this errors since `Rhs` isn't specified.
// To work around this, we infer all arguments until we reach the host param.
args.push(ctx.inferred_kind(Some(&args), param, infer_args));
Expand Down
5 changes: 0 additions & 5 deletions compiler/rustc_infer/src/infer/error_reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2653,11 +2653,6 @@ impl<'tcx> TypeRelation<'tcx> for SameTypeModuloInfer<'_, 'tcx> {
self.0.tcx
}

fn param_env(&self) -> ty::ParamEnv<'tcx> {
// Unused, only for consts which we treat as always equal
ty::ParamEnv::empty()
}

fn tag(&self) -> &'static str {
"SameTypeModuloInfer"
}
Expand Down
12 changes: 3 additions & 9 deletions compiler/rustc_infer/src/infer/lexical_region_resolve/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,12 @@ use super::outlives::test_type_match;
/// all the variables as well as a set of errors that must be reported.
#[instrument(level = "debug", skip(region_rels, var_infos, data))]
pub(crate) fn resolve<'tcx>(
param_env: ty::ParamEnv<'tcx>,
region_rels: &RegionRelations<'_, 'tcx>,
var_infos: VarInfos,
data: RegionConstraintData<'tcx>,
) -> (LexicalRegionResolutions<'tcx>, Vec<RegionResolutionError<'tcx>>) {
let mut errors = vec![];
let mut resolver = LexicalResolver { param_env, region_rels, var_infos, data };
let mut resolver = LexicalResolver { region_rels, var_infos, data };
let values = resolver.infer_variable_values(&mut errors);
(values, errors)
}
Expand Down Expand Up @@ -120,7 +119,6 @@ struct RegionAndOrigin<'tcx> {
type RegionGraph<'tcx> = Graph<(), Constraint<'tcx>>;

struct LexicalResolver<'cx, 'tcx> {
param_env: ty::ParamEnv<'tcx>,
region_rels: &'cx RegionRelations<'cx, 'tcx>,
var_infos: VarInfos,
data: RegionConstraintData<'tcx>,
Expand Down Expand Up @@ -914,12 +912,8 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
match bound {
VerifyBound::IfEq(verify_if_eq_b) => {
let verify_if_eq_b = var_values.normalize(self.region_rels.tcx, *verify_if_eq_b);
match test_type_match::extract_verify_if_eq(
self.tcx(),
self.param_env,
&verify_if_eq_b,
generic_ty,
) {
match test_type_match::extract_verify_if_eq(self.tcx(), &verify_if_eq_b, generic_ty)
{
Some(r) => {
self.bound_is_met(&VerifyBound::OutlivedBy(r), var_values, generic_ty, min)
}
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_infer/src/infer/outlives/for_liveness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ where
} else {
test_type_match::extract_verify_if_eq(
tcx,
param_env,
&outlives.map_bound(|ty::OutlivesPredicate(ty, bound)| {
VerifyIfEq { ty, bound }
}),
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_infer/src/infer/outlives/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ impl<'tcx> InferCtxt<'tcx> {
let region_rels = &RegionRelations::new(self.tcx, outlives_env.free_region_map());

let (lexical_region_resolutions, errors) =
lexical_region_resolve::resolve(outlives_env.param_env, region_rels, var_infos, data);
lexical_region_resolve::resolve(region_rels, var_infos, data);

let old_value = self.lexical_region_resolutions.replace(Some(lexical_region_resolutions));
assert!(old_value.is_none());
Expand Down
23 changes: 7 additions & 16 deletions compiler/rustc_infer/src/infer/outlives/test_type_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,14 @@ use crate::infer::region_constraints::VerifyIfEq;
/// like are used. This is a particular challenge since this function is invoked
/// very late in inference and hence cannot make use of the normal inference
/// machinery.
#[instrument(level = "debug", skip(tcx, param_env))]
#[instrument(level = "debug", skip(tcx))]
pub fn extract_verify_if_eq<'tcx>(
tcx: TyCtxt<'tcx>,
param_env: ty::ParamEnv<'tcx>,
verify_if_eq_b: &ty::Binder<'tcx, VerifyIfEq<'tcx>>,
test_ty: Ty<'tcx>,
) -> Option<ty::Region<'tcx>> {
assert!(!verify_if_eq_b.has_escaping_bound_vars());
let mut m = MatchAgainstHigherRankedOutlives::new(tcx, param_env);
let mut m = MatchAgainstHigherRankedOutlives::new(tcx);
let verify_if_eq = verify_if_eq_b.skip_binder();
m.relate(verify_if_eq.ty, test_ty).ok()?;

Expand Down Expand Up @@ -73,10 +72,9 @@ pub fn extract_verify_if_eq<'tcx>(
}

/// True if a (potentially higher-ranked) outlives
#[instrument(level = "debug", skip(tcx, param_env))]
#[instrument(level = "debug", skip(tcx))]
pub(super) fn can_match_erased_ty<'tcx>(
tcx: TyCtxt<'tcx>,
param_env: ty::ParamEnv<'tcx>,
outlives_predicate: ty::Binder<'tcx, ty::TypeOutlivesPredicate<'tcx>>,
erased_ty: Ty<'tcx>,
) -> bool {
Expand All @@ -87,25 +85,20 @@ pub(super) fn can_match_erased_ty<'tcx>(
// pointless micro-optimization
true
} else {
MatchAgainstHigherRankedOutlives::new(tcx, param_env).relate(outlives_ty, erased_ty).is_ok()
MatchAgainstHigherRankedOutlives::new(tcx).relate(outlives_ty, erased_ty).is_ok()
}
}

struct MatchAgainstHigherRankedOutlives<'tcx> {
tcx: TyCtxt<'tcx>,
param_env: ty::ParamEnv<'tcx>,
pattern_depth: ty::DebruijnIndex,
map: FxHashMap<ty::BoundRegion, ty::Region<'tcx>>,
}

impl<'tcx> MatchAgainstHigherRankedOutlives<'tcx> {
fn new(
tcx: TyCtxt<'tcx>,
param_env: ty::ParamEnv<'tcx>,
) -> MatchAgainstHigherRankedOutlives<'tcx> {
fn new(tcx: TyCtxt<'tcx>) -> MatchAgainstHigherRankedOutlives<'tcx> {
MatchAgainstHigherRankedOutlives {
tcx,
param_env,
pattern_depth: ty::INNERMOST,
map: FxHashMap::default(),
}
Expand Down Expand Up @@ -144,15 +137,13 @@ impl<'tcx> MatchAgainstHigherRankedOutlives<'tcx> {

impl<'tcx> TypeRelation<'tcx> for MatchAgainstHigherRankedOutlives<'tcx> {
fn tag(&self) -> &'static str {
"Match"
"MatchAgainstHigherRankedOutlives"
}

fn tcx(&self) -> TyCtxt<'tcx> {
self.tcx
}
fn param_env(&self) -> ty::ParamEnv<'tcx> {
self.param_env
}

fn a_is_expected(&self) -> bool {
true
} // irrelevant
Expand Down
8 changes: 1 addition & 7 deletions compiler/rustc_infer/src/infer/outlives/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,14 +322,8 @@ impl<'cx, 'tcx> VerifyBoundCx<'cx, 'tcx> {
) -> impl Iterator<Item = ty::Binder<'tcx, ty::OutlivesPredicate<Ty<'tcx>, ty::Region<'tcx>>>>
{
let tcx = self.tcx;
let param_env = self.param_env;
clauses.filter_map(|p| p.as_type_outlives_clause()).filter(move |outlives_predicate| {
super::test_type_match::can_match_erased_ty(
tcx,
param_env,
*outlives_predicate,
erased_ty,
)
super::test_type_match::can_match_erased_ty(tcx, *outlives_predicate, erased_ty)
})
}
}
2 changes: 2 additions & 0 deletions compiler/rustc_infer/src/infer/relate/combine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,8 @@ impl<'infcx, 'tcx> CombineFields<'infcx, 'tcx> {
}

pub trait ObligationEmittingRelation<'tcx>: TypeRelation<'tcx> {
fn param_env(&self) -> ty::ParamEnv<'tcx>;

/// Register obligations that must hold in order for this relation to hold
fn register_obligations(&mut self, obligations: PredicateObligations<'tcx>);

Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_infer/src/infer/relate/equate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ impl<'tcx> TypeRelation<'tcx> for Equate<'_, '_, 'tcx> {
self.fields.tcx()
}

fn param_env(&self) -> ty::ParamEnv<'tcx> {
self.fields.param_env
}

fn a_is_expected(&self) -> bool {
self.a_is_expected
}
Expand Down Expand Up @@ -174,6 +170,10 @@ impl<'tcx> TypeRelation<'tcx> for Equate<'_, '_, 'tcx> {
}

impl<'tcx> ObligationEmittingRelation<'tcx> for Equate<'_, '_, 'tcx> {
fn param_env(&self) -> ty::ParamEnv<'tcx> {
self.fields.param_env
}

fn register_predicates(&mut self, obligations: impl IntoIterator<Item: ty::ToPredicate<'tcx>>) {
self.fields.register_predicates(obligations);
}
Expand Down
4 changes: 0 additions & 4 deletions compiler/rustc_infer/src/infer/relate/generalize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,6 @@ where
self.infcx.tcx
}

fn param_env(&self) -> ty::ParamEnv<'tcx> {
self.delegate.param_env()
}

fn tag(&self) -> &'static str {
"Generalizer"
}
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_infer/src/infer/relate/glb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ impl<'tcx> TypeRelation<'tcx> for Glb<'_, '_, 'tcx> {
self.fields.tcx()
}

fn param_env(&self) -> ty::ParamEnv<'tcx> {
self.fields.param_env
}

fn a_is_expected(&self) -> bool {
self.a_is_expected
}
Expand Down Expand Up @@ -138,6 +134,10 @@ impl<'combine, 'infcx, 'tcx> LatticeDir<'infcx, 'tcx> for Glb<'combine, 'infcx,
}

impl<'tcx> ObligationEmittingRelation<'tcx> for Glb<'_, '_, 'tcx> {
fn param_env(&self) -> ty::ParamEnv<'tcx> {
self.fields.param_env
}

fn register_predicates(&mut self, obligations: impl IntoIterator<Item: ty::ToPredicate<'tcx>>) {
self.fields.register_predicates(obligations);
}
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_infer/src/infer/relate/lub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ impl<'tcx> TypeRelation<'tcx> for Lub<'_, '_, 'tcx> {
self.fields.tcx()
}

fn param_env(&self) -> ty::ParamEnv<'tcx> {
self.fields.param_env
}

fn a_is_expected(&self) -> bool {
self.a_is_expected
}
Expand Down Expand Up @@ -138,6 +134,10 @@ impl<'combine, 'infcx, 'tcx> LatticeDir<'infcx, 'tcx> for Lub<'combine, 'infcx,
}

impl<'tcx> ObligationEmittingRelation<'tcx> for Lub<'_, '_, 'tcx> {
fn param_env(&self) -> ty::ParamEnv<'tcx> {
self.fields.param_env
}

fn register_predicates(&mut self, obligations: impl IntoIterator<Item: ty::ToPredicate<'tcx>>) {
self.fields.register_predicates(obligations);
}
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_infer/src/infer/relate/nll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -431,10 +431,6 @@ where
self.infcx.tcx
}

fn param_env(&self) -> ty::ParamEnv<'tcx> {
self.delegate.param_env()
}

fn tag(&self) -> &'static str {
"nll::subtype"
}
Expand Down Expand Up @@ -670,6 +666,10 @@ impl<'tcx, D> ObligationEmittingRelation<'tcx> for TypeRelating<'_, 'tcx, D>
where
D: TypeRelatingDelegate<'tcx>,
{
fn param_env(&self) -> ty::ParamEnv<'tcx> {
self.delegate.param_env()
}

fn register_predicates(&mut self, obligations: impl IntoIterator<Item: ty::ToPredicate<'tcx>>) {
self.delegate.register_obligations(
obligations
Expand Down
Loading
Loading