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 9 pull requests #126514

Merged
merged 37 commits into from
Jun 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
c28e606
Add socketpair shim
tiif Jun 10, 2024
0d66db9
Auto merge of #3609 - tiif:feat/socketpair, r=RalfJung
bors Jun 10, 2024
9048a18
Preparing for merge from rustc
RalfJung Jun 11, 2024
6e06c49
Merge from rustc
RalfJung Jun 11, 2024
654ad52
fmt
RalfJung Jun 11, 2024
c0fe47d
use strict_ instead of checked_ in a few more places
RalfJung Jun 11, 2024
82c34ad
Auto merge of #3667 - RalfJung:rustup, r=RalfJung
bors Jun 11, 2024
54fa4b0
Use Variance glob import everywhere
compiler-errors Jun 12, 2024
2c41b1c
Preparing for merge from rustc
Jun 13, 2024
6771dc4
Merge from rustc
Jun 13, 2024
a49c659
fmt
Jun 13, 2024
c5e9424
Auto merge of #3669 - rust-lang:rustup-2024-06-13, r=RalfJung
bors Jun 13, 2024
fe7d977
Fix socketpair and epoll_create1's throw_unsup_format wording
tiif Jun 13, 2024
ccb5f52
Auto merge of #3671 - tiif:epoll_create1_minor_fix, r=RalfJung
bors Jun 13, 2024
7557177
Implement LLVM x86 SSE4.2 intrinsics
TDecking May 19, 2024
0cd41b9
add some more CRC tests
RalfJung Jun 13, 2024
4345379
cargo miri: add support for '--many-seeds' to run the program / tests…
RalfJung Jun 13, 2024
cfcea21
document --many-seeds; set the default range to 0..64
RalfJung Jun 13, 2024
46c5332
Auto merge of #3622 - TDecking:sse4_2, r=RalfJung
bors Jun 13, 2024
fdd90db
Point out exactly what obligation will fail
compiler-errors Jun 13, 2024
5c8bb67
Use a consistent way to filter out bounds instead of splitting it int…
oli-obk Jun 14, 2024
669a400
MIR Shl/Shr: the offset can be computed with rem_euclid
RalfJung Jun 14, 2024
ad787c1
build `libcxx-version` only when it doesn't exist
onur-ozkan Jun 14, 2024
e2e1afa
update libstdc++ compatibility error log
onur-ozkan Jun 14, 2024
cbc3bdb
delegation: Fix hygiene for `self`
petrochenkov Jun 14, 2024
c006748
make bors ignore comments in PR template
lqd Jun 14, 2024
b8eb6ad
std: suggest OnceLock over Once
workingjubilee Jun 15, 2024
3f2c50c
Auto merge of #3672 - RalfJung:cargo-many-seeds, r=RalfJung
bors Jun 15, 2024
335e320
Rollup merge of #126354 - compiler-errors:variance, r=lcnr
matthiaskrgr Jun 15, 2024
b473ec2
Rollup merge of #126367 - compiler-errors:point-out-failing-never-obl…
matthiaskrgr Jun 15, 2024
f24509a
Rollup merge of #126469 - RalfJung:mir-shifts, r=scottmcm
matthiaskrgr Jun 15, 2024
6f21da3
Rollup merge of #126471 - oli-obk:filter_loop, r=compiler-errors
matthiaskrgr Jun 15, 2024
b5dd3d4
Rollup merge of #126472 - onur-ozkan:improve-libcxx-build, r=Kobzol
matthiaskrgr Jun 15, 2024
4265043
Rollup merge of #126497 - petrochenkov:delehyg, r=compiler-errors
matthiaskrgr Jun 15, 2024
e287a00
Rollup merge of #126501 - lqd:fix-pr-template, r=Mark-Simulacrum
matthiaskrgr Jun 15, 2024
83cbcea
Rollup merge of #126509 - workingjubilee:gently-discourage-doing-thin…
matthiaskrgr Jun 15, 2024
92ad0b1
Rollup merge of #126512 - RalfJung:miri-sync, r=RalfJung
matthiaskrgr Jun 15, 2024
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
4 changes: 3 additions & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<!-- homu-ignore:start -->
<!--
If this PR is related to an unstable feature or an otherwise tracked effort,
please link to the relevant tracking issue here. If you don't know of a related
Expand All @@ -7,4 +8,5 @@ This PR will get automatically assigned to a reviewer. In case you would like
a specific user to review your work, you can assign it to them by using

r​? <reviewer name>
-->
-->
<!-- homu-ignore:end -->
12 changes: 6 additions & 6 deletions compiler/rustc_borrowck/src/type_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
if let Some(annotation_index) = constant.user_ty {
if let Err(terr) = self.cx.relate_type_and_user_type(
constant.const_.ty(),
ty::Variance::Invariant,
ty::Invariant,
&UserTypeProjection { base: annotation_index, projs: vec![] },
locations,
ConstraintCategory::Boring,
Expand Down Expand Up @@ -451,7 +451,7 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {

if let Err(terr) = self.cx.relate_type_and_user_type(
ty,
ty::Variance::Invariant,
ty::Invariant,
user_ty,
Locations::All(*span),
ConstraintCategory::TypeAnnotation,
Expand Down Expand Up @@ -1095,7 +1095,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
) -> Result<(), NoSolution> {
// Use this order of parameters because the sup type is usually the
// "expected" type in diagnostics.
self.relate_types(sup, ty::Variance::Contravariant, sub, locations, category)
self.relate_types(sup, ty::Contravariant, sub, locations, category)
}

#[instrument(skip(self, category), level = "debug")]
Expand All @@ -1106,7 +1106,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
locations: Locations,
category: ConstraintCategory<'tcx>,
) -> Result<(), NoSolution> {
self.relate_types(expected, ty::Variance::Invariant, found, locations, category)
self.relate_types(expected, ty::Invariant, found, locations, category)
}

#[instrument(skip(self), level = "debug")]
Expand Down Expand Up @@ -1146,7 +1146,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
trace!(?curr_projected_ty);

let ty = curr_projected_ty.ty;
self.relate_types(ty, v.xform(ty::Variance::Contravariant), a, locations, category)?;
self.relate_types(ty, v.xform(ty::Contravariant), a, locations, category)?;

Ok(())
}
Expand Down Expand Up @@ -1248,7 +1248,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
if let Some(annotation_index) = self.rvalue_user_ty(rv) {
if let Err(terr) = self.relate_type_and_user_type(
rv_ty,
ty::Variance::Invariant,
ty::Invariant,
&UserTypeProjection { base: annotation_index, projs: vec![] },
location.to_locations(),
ConstraintCategory::Boring,
Expand Down
40 changes: 15 additions & 25 deletions compiler/rustc_borrowck/src/type_check/relate_tys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,8 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
locations: Locations,
category: ConstraintCategory<'tcx>,
) -> Result<(), NoSolution> {
NllTypeRelating::new(
self,
locations,
category,
UniverseInfo::other(),
ty::Variance::Invariant,
)
.relate(a, b)?;
NllTypeRelating::new(self, locations, category, UniverseInfo::other(), ty::Invariant)
.relate(a, b)?;
Ok(())
}
}
Expand Down Expand Up @@ -106,15 +100,15 @@ impl<'me, 'bccx, 'tcx> NllTypeRelating<'me, 'bccx, 'tcx> {

fn ambient_covariance(&self) -> bool {
match self.ambient_variance {
ty::Variance::Covariant | ty::Variance::Invariant => true,
ty::Variance::Contravariant | ty::Variance::Bivariant => false,
ty::Covariant | ty::Invariant => true,
ty::Contravariant | ty::Bivariant => false,
}
}

fn ambient_contravariance(&self) -> bool {
match self.ambient_variance {
ty::Variance::Contravariant | ty::Variance::Invariant => true,
ty::Variance::Covariant | ty::Variance::Bivariant => false,
ty::Contravariant | ty::Invariant => true,
ty::Covariant | ty::Bivariant => false,
}
}

Expand Down Expand Up @@ -336,11 +330,7 @@ impl<'bccx, 'tcx> TypeRelation<TyCtxt<'tcx>> for NllTypeRelating<'_, 'bccx, 'tcx

debug!(?self.ambient_variance);
// In a bivariant context this always succeeds.
let r = if self.ambient_variance == ty::Variance::Bivariant {
Ok(a)
} else {
self.relate(a, b)
};
let r = if self.ambient_variance == ty::Bivariant { Ok(a) } else { self.relate(a, b) };

self.ambient_variance = old_ambient_variance;

Expand Down Expand Up @@ -474,7 +464,7 @@ impl<'bccx, 'tcx> TypeRelation<TyCtxt<'tcx>> for NllTypeRelating<'_, 'bccx, 'tcx
}

match self.ambient_variance {
ty::Variance::Covariant => {
ty::Covariant => {
// Covariance, so we want `for<..> A <: for<..> B` --
// therefore we compare any instantiation of A (i.e., A
// instantiated with existentials) against every
Expand All @@ -489,7 +479,7 @@ impl<'bccx, 'tcx> TypeRelation<TyCtxt<'tcx>> for NllTypeRelating<'_, 'bccx, 'tcx
})?;
}

ty::Variance::Contravariant => {
ty::Contravariant => {
// Contravariance, so we want `for<..> A :> for<..> B` --
// therefore we compare every instantiation of A (i.e., A
// instantiated with universals) against any
Expand All @@ -504,7 +494,7 @@ impl<'bccx, 'tcx> TypeRelation<TyCtxt<'tcx>> for NllTypeRelating<'_, 'bccx, 'tcx
})?;
}

ty::Variance::Invariant => {
ty::Invariant => {
// Invariant, so we want `for<..> A == for<..> B` --
// therefore we want `exists<..> A == for<..> B` and
// `exists<..> B == for<..> A`.
Expand All @@ -525,7 +515,7 @@ impl<'bccx, 'tcx> TypeRelation<TyCtxt<'tcx>> for NllTypeRelating<'_, 'bccx, 'tcx
})?;
}

ty::Variance::Bivariant => {}
ty::Bivariant => {}
}

Ok(a)
Expand Down Expand Up @@ -584,23 +574,23 @@ impl<'bccx, 'tcx> PredicateEmittingRelation<'tcx> for NllTypeRelating<'_, 'bccx,

fn register_alias_relate_predicate(&mut self, a: Ty<'tcx>, b: Ty<'tcx>) {
self.register_predicates([ty::Binder::dummy(match self.ambient_variance {
ty::Variance::Covariant => ty::PredicateKind::AliasRelate(
ty::Covariant => ty::PredicateKind::AliasRelate(
a.into(),
b.into(),
ty::AliasRelationDirection::Subtype,
),
// a :> b is b <: a
ty::Variance::Contravariant => ty::PredicateKind::AliasRelate(
ty::Contravariant => ty::PredicateKind::AliasRelate(
b.into(),
a.into(),
ty::AliasRelationDirection::Subtype,
),
ty::Variance::Invariant => ty::PredicateKind::AliasRelate(
ty::Invariant => ty::PredicateKind::AliasRelate(
a.into(),
b.into(),
ty::AliasRelationDirection::Equate,
),
ty::Variance::Bivariant => {
ty::Bivariant => {
unreachable!("cannot defer an alias-relate goal with Bivariant variance (yet?)")
}
})]);
Expand Down
19 changes: 7 additions & 12 deletions compiler/rustc_const_eval/src/interpret/operator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,25 +112,20 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {

// Shift ops can have an RHS with a different numeric type.
if matches!(bin_op, Shl | ShlUnchecked | Shr | ShrUnchecked) {
let size = left.layout.size.bits();
let l_bits = left.layout.size.bits();
// Compute the equivalent shift modulo `size` that is in the range `0..size`. (This is
// the one MIR operator that does *not* directly map to a single LLVM operation.)
let (shift_amount, overflow) = if right.layout.abi.is_signed() {
let shift_amount = r_signed();
let overflow = shift_amount < 0 || shift_amount >= i128::from(size);
// Deliberately wrapping `as` casts: shift_amount *can* be negative, but the result
// of the `as` will be equal modulo `size` (since it is a power of two).
let masked_amount = (shift_amount as u128) % u128::from(size);
assert_eq!(overflow, shift_amount != i128::try_from(masked_amount).unwrap());
(masked_amount, overflow)
let rem = shift_amount.rem_euclid(l_bits.into());
// `rem` is guaranteed positive, so the `unwrap` cannot fail
(u128::try_from(rem).unwrap(), rem != shift_amount)
} else {
let shift_amount = r_unsigned();
let overflow = shift_amount >= u128::from(size);
let masked_amount = shift_amount % u128::from(size);
assert_eq!(overflow, shift_amount != masked_amount);
(masked_amount, overflow)
let rem = shift_amount.rem_euclid(l_bits.into());
(rem, rem != shift_amount)
};
let shift_amount = u32::try_from(shift_amount).unwrap(); // we masked so this will always fit
let shift_amount = u32::try_from(shift_amount).unwrap(); // we brought this in the range `0..size` so this will always fit
// Compute the shifted result.
let result = if left.layout.abi.is_signed() {
let l = l_signed();
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_hir_typeck/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ hir_typeck_convert_using_method = try using `{$sugg}` to convert `{$found}` to `
hir_typeck_ctor_is_private = tuple struct constructor `{$def}` is private

hir_typeck_dependency_on_unit_never_type_fallback = this function depends on never type fallback being `()`
.note = in edition 2024, the requirement `{$obligation}` will fail
.help = specify the types explicitly

hir_typeck_deref_is_empty = this expression `Deref`s to `{$deref_ty}` which implements `is_empty`
Expand Down
8 changes: 6 additions & 2 deletions compiler/rustc_hir_typeck/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use rustc_errors::{
SubdiagMessageOp, Subdiagnostic,
};
use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
use rustc_middle::ty::Ty;
use rustc_middle::ty::{self, Ty};
use rustc_span::{
edition::{Edition, LATEST_STABLE_EDITION},
symbol::Ident,
Expand Down Expand Up @@ -186,7 +186,11 @@ pub enum NeverTypeFallbackFlowingIntoUnsafe {
#[derive(LintDiagnostic)]
#[help]
#[diag(hir_typeck_dependency_on_unit_never_type_fallback)]
pub struct DependencyOnUnitNeverTypeFallback {}
pub struct DependencyOnUnitNeverTypeFallback<'tcx> {
#[note]
pub obligation_span: Span,
pub obligation: ty::Predicate<'tcx>,
}

#[derive(Subdiagnostic)]
#[multipart_suggestion(
Expand Down
12 changes: 8 additions & 4 deletions compiler/rustc_hir_typeck/src/fallback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ impl<'tcx> FnCtxt<'_, 'tcx> {
let remaining_errors_if_fallback_to = |fallback| {
self.probe(|_| {
let obligations = self.fulfillment_cx.borrow().pending_obligations();
let ocx = ObligationCtxt::new(&self.infcx);
let ocx = ObligationCtxt::new_with_diagnostics(&self.infcx);
ocx.register_obligations(obligations.iter().cloned());

for &diverging_vid in diverging_vids {
Expand All @@ -506,14 +506,18 @@ impl<'tcx> FnCtxt<'_, 'tcx> {
// then this code will be broken by the never type fallback change.qba
let unit_errors = remaining_errors_if_fallback_to(self.tcx.types.unit);
if unit_errors.is_empty()
&& let never_errors = remaining_errors_if_fallback_to(self.tcx.types.never)
&& !never_errors.is_empty()
&& let mut never_errors = remaining_errors_if_fallback_to(self.tcx.types.never)
&& let [ref mut never_error, ..] = never_errors.as_mut_slice()
{
self.adjust_fulfillment_error_for_expr_obligation(never_error);
self.tcx.emit_node_span_lint(
lint::builtin::DEPENDENCY_ON_UNIT_NEVER_TYPE_FALLBACK,
self.tcx.local_def_id_to_hir_id(self.body_id),
self.tcx.def_span(self.body_id),
errors::DependencyOnUnitNeverTypeFallback {},
errors::DependencyOnUnitNeverTypeFallback {
obligation_span: never_error.obligation.cause.span,
obligation: never_error.obligation.predicate,
},
)
}
}
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_infer/src/infer/at.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,16 +212,16 @@ impl<'a, 'tcx> At<'a, 'tcx> {
T: ToTrace<'tcx>,
{
match variance {
ty::Variance::Covariant => self.sub(define_opaque_types, expected, actual),
ty::Variance::Invariant => self.eq(define_opaque_types, expected, actual),
ty::Variance::Contravariant => self.sup(define_opaque_types, expected, actual),
ty::Covariant => self.sub(define_opaque_types, expected, actual),
ty::Invariant => self.eq(define_opaque_types, expected, actual),
ty::Contravariant => self.sup(define_opaque_types, expected, actual),

// We could make this make sense but it's not readily
// exposed and I don't feel like dealing with it. Note
// that bivariance in general does a bit more than just
// *nothing*, it checks that the types are the same
// "modulo variance" basically.
ty::Variance::Bivariant => panic!("Bivariant given to `relate()`"),
ty::Bivariant => panic!("Bivariant given to `relate()`"),
}
}

Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_infer/src/infer/opaque_types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ impl<'tcx> InferCtxt<'tcx> {
.args
.iter()
.enumerate()
.filter(|(i, _)| variances[*i] == ty::Variance::Invariant)
.filter(|(i, _)| variances[*i] == ty::Invariant)
.filter_map(|(_, arg)| match arg.unpack() {
GenericArgKind::Lifetime(r) => Some(r),
GenericArgKind::Type(_) | GenericArgKind::Const(_) => None,
Expand Down Expand Up @@ -441,7 +441,7 @@ where
let variances = self.tcx.variances_of(*def_id);

for (v, s) in std::iter::zip(variances, args.iter()) {
if *v != ty::Variance::Bivariant {
if *v != ty::Bivariant {
s.visit_with(self);
}
}
Expand Down
4 changes: 1 addition & 3 deletions compiler/rustc_infer/src/infer/outlives/for_liveness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,7 @@ where
};

for (idx, s) in args.iter().enumerate() {
if variances.map(|variances| variances[idx])
!= Some(ty::Variance::Bivariant)
{
if variances.map(|variances| variances[idx]) != Some(ty::Bivariant) {
s.visit_with(self);
}
}
Expand Down
18 changes: 9 additions & 9 deletions compiler/rustc_infer/src/infer/relate/generalize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,16 @@ impl<'tcx> InferCtxt<'tcx> {
// mention `?0`.
if self.next_trait_solver() {
let (lhs, rhs, direction) = match instantiation_variance {
ty::Variance::Invariant => {
ty::Invariant => {
(generalized_ty.into(), source_ty.into(), AliasRelationDirection::Equate)
}
ty::Variance::Covariant => {
ty::Covariant => {
(generalized_ty.into(), source_ty.into(), AliasRelationDirection::Subtype)
}
ty::Variance::Contravariant => {
ty::Contravariant => {
(source_ty.into(), generalized_ty.into(), AliasRelationDirection::Subtype)
}
ty::Variance::Bivariant => unreachable!("bivariant generalization"),
ty::Bivariant => unreachable!("bivariant generalization"),
};

relation.register_predicates([ty::PredicateKind::AliasRelate(lhs, rhs, direction)]);
Expand Down Expand Up @@ -192,7 +192,7 @@ impl<'tcx> InferCtxt<'tcx> {
relation.span(),
relation.structurally_relate_aliases(),
target_vid,
ty::Variance::Invariant,
ty::Invariant,
source_ct,
)?;

Expand All @@ -210,14 +210,14 @@ impl<'tcx> InferCtxt<'tcx> {
// generalized const and the source.
if target_is_expected {
relation.relate_with_variance(
ty::Variance::Invariant,
ty::Invariant,
ty::VarianceDiagInfo::default(),
generalized_ct,
source_ct,
)?;
} else {
relation.relate_with_variance(
ty::Variance::Invariant,
ty::Invariant,
ty::VarianceDiagInfo::default(),
source_ct,
generalized_ct,
Expand Down Expand Up @@ -411,7 +411,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for Generalizer<'_, 'tcx> {
a_arg: ty::GenericArgsRef<'tcx>,
b_arg: ty::GenericArgsRef<'tcx>,
) -> RelateResult<'tcx, ty::GenericArgsRef<'tcx>> {
if self.ambient_variance == ty::Variance::Invariant {
if self.ambient_variance == ty::Invariant {
// Avoid fetching the variance if we are in an invariant
// context; no need, and it can induce dependency cycles
// (e.g., #41849).
Expand Down Expand Up @@ -667,7 +667,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for Generalizer<'_, 'tcx> {
// structural.
ty::ConstKind::Unevaluated(ty::UnevaluatedConst { def, args }) => {
let args = self.relate_with_variance(
ty::Variance::Invariant,
ty::Invariant,
ty::VarianceDiagInfo::default(),
args,
args,
Expand Down
Loading
Loading