Skip to content

Commit ba7c7a3

Browse files
committed
Auto merge of #117887 - matthiaskrgr:rollup-rgur03f, r=matthiaskrgr
Rollup of 4 pull requests Successful merges: - #114224 (rustc_llvm: Link to libkstat on Solaris/SPARC) - #117695 (Reorder checks to make sure potential missing expect on Option/Result…) - #117870 (`fn args_ref_X` to `fn args_X`) - #117879 (tests: update check for inferred nneg on zext) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 85b8450 + 6d5d509 commit ba7c7a3

File tree

10 files changed

+40
-14
lines changed

10 files changed

+40
-14
lines changed

compiler/rustc_hir_typeck/src/demand.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
3434

3535
// Use `||` to give these suggestions a precedence
3636
let suggested = self.suggest_missing_parentheses(err, expr)
37+
|| self.suggest_missing_unwrap_expect(err, expr, expected, expr_ty)
3738
|| self.suggest_remove_last_method_call(err, expr, expected)
3839
|| self.suggest_associated_const(err, expr, expected)
3940
|| self.suggest_deref_ref_or_into(err, expr, expected, expr_ty, expected_ty_expr)
@@ -49,8 +50,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
4950
|| self.suggest_into(err, expr, expr_ty, expected)
5051
|| self.suggest_floating_point_literal(err, expr, expected)
5152
|| self.suggest_null_ptr_for_literal_zero_given_to_ptr_arg(err, expr, expected)
52-
|| self.suggest_coercing_result_via_try_operator(err, expr, expected, expr_ty)
53-
|| self.suggest_missing_unwrap_expect(err, expr, expected, expr_ty);
53+
|| self.suggest_coercing_result_via_try_operator(err, expr, expected, expr_ty);
5454

5555
if !suggested {
5656
self.note_source_of_type_mismatch_constraint(

compiler/rustc_llvm/build.rs

+6
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,12 @@ fn main() {
242242
cmd.arg("--system-libs");
243243
}
244244

245+
// We need libkstat for getHostCPUName on SPARC builds.
246+
// See also: https://github.com/llvm/llvm-project/issues/64186
247+
if target.starts_with("sparcv9") && target.contains("solaris") {
248+
println!("cargo:rustc-link-lib=kstat");
249+
}
250+
245251
if (target.starts_with("arm") && !target.contains("freebsd"))
246252
|| target.starts_with("mips-")
247253
|| target.starts_with("mipsel-")

compiler/rustc_middle/src/ty/fast_reject.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -189,14 +189,14 @@ pub struct DeepRejectCtxt {
189189
}
190190

191191
impl DeepRejectCtxt {
192-
pub fn args_refs_may_unify<'tcx>(
192+
pub fn args_may_unify<'tcx>(
193193
self,
194194
obligation_args: GenericArgsRef<'tcx>,
195195
impl_args: GenericArgsRef<'tcx>,
196196
) -> bool {
197197
iter::zip(obligation_args, impl_args).all(|(obl, imp)| {
198198
match (obl.unpack(), imp.unpack()) {
199-
// We don't fast reject based on regions for now.
199+
// We don't fast reject based on regions.
200200
(GenericArgKind::Lifetime(_), GenericArgKind::Lifetime(_)) => true,
201201
(GenericArgKind::Type(obl), GenericArgKind::Type(imp)) => {
202202
self.types_may_unify(obl, imp)
@@ -231,7 +231,7 @@ impl DeepRejectCtxt {
231231
| ty::Never
232232
| ty::Tuple(..)
233233
| ty::FnPtr(..)
234-
| ty::Foreign(..) => {}
234+
| ty::Foreign(..) => debug_assert!(impl_ty.is_known_rigid()),
235235
ty::FnDef(..)
236236
| ty::Closure(..)
237237
| ty::Coroutine(..)
@@ -260,7 +260,7 @@ impl DeepRejectCtxt {
260260
},
261261
ty::Adt(obl_def, obl_args) => match k {
262262
&ty::Adt(impl_def, impl_args) => {
263-
obl_def == impl_def && self.args_refs_may_unify(obl_args, impl_args)
263+
obl_def == impl_def && self.args_may_unify(obl_args, impl_args)
264264
}
265265
_ => false,
266266
},

compiler/rustc_trait_selection/src/solve/project_goals/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for ProjectionPredicate<'tcx> {
160160
let goal_trait_ref = goal.predicate.projection_ty.trait_ref(tcx);
161161
let impl_trait_ref = tcx.impl_trait_ref(impl_def_id).unwrap();
162162
let drcx = DeepRejectCtxt { treat_obligation_params: TreatParams::ForLookup };
163-
if !drcx.args_refs_may_unify(goal_trait_ref.args, impl_trait_ref.skip_binder().args) {
163+
if !drcx.args_may_unify(goal_trait_ref.args, impl_trait_ref.skip_binder().args) {
164164
return Err(NoSolution);
165165
}
166166

compiler/rustc_trait_selection/src/solve/trait_goals.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> {
4343

4444
let impl_trait_ref = tcx.impl_trait_ref(impl_def_id).unwrap();
4545
let drcx = DeepRejectCtxt { treat_obligation_params: TreatParams::ForLookup };
46-
if !drcx
47-
.args_refs_may_unify(goal.predicate.trait_ref.args, impl_trait_ref.skip_binder().args)
48-
{
46+
if !drcx.args_may_unify(goal.predicate.trait_ref.args, impl_trait_ref.skip_binder().args) {
4947
return Err(NoSolution);
5048
}
5149

compiler/rustc_trait_selection/src/traits/coherence.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ pub fn overlapping_impls(
100100
let impl1_ref = tcx.impl_trait_ref(impl1_def_id);
101101
let impl2_ref = tcx.impl_trait_ref(impl2_def_id);
102102
let may_overlap = match (impl1_ref, impl2_ref) {
103-
(Some(a), Some(b)) => drcx.args_refs_may_unify(a.skip_binder().args, b.skip_binder().args),
103+
(Some(a), Some(b)) => drcx.args_may_unify(a.skip_binder().args, b.skip_binder().args),
104104
(None, None) => {
105105
let self_ty1 = tcx.type_of(impl1_def_id).skip_binder();
106106
let self_ty2 = tcx.type_of(impl2_def_id).skip_binder();

compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
375375
// consider a "quick reject". This avoids creating more types
376376
// and so forth that we need to.
377377
let impl_trait_ref = self.tcx().impl_trait_ref(impl_def_id).unwrap();
378-
if !drcx.args_refs_may_unify(obligation_args, impl_trait_ref.skip_binder().args) {
378+
if !drcx.args_may_unify(obligation_args, impl_trait_ref.skip_binder().args) {
379379
return;
380380
}
381381
if self.reject_fn_ptr_impls(

tests/codegen/unchecked_shifts.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ pub unsafe fn unchecked_shl_unsigned_smaller(a: u16, b: u32) -> u16 {
3131
#[no_mangle]
3232
pub unsafe fn unchecked_shl_unsigned_bigger(a: u64, b: u32) -> u64 {
3333
// CHECK-NOT: assume
34-
// CHECK: %[[EXT:.+]] = zext i32 %b to i64
34+
// CHECK: %[[EXT:.+]] = zext{{( nneg)?}} i32 %b to i64
3535
// CHECK: shl i64 %a, %[[EXT]]
3636
a.unchecked_shl(b)
3737
}
@@ -63,7 +63,7 @@ pub unsafe fn unchecked_shr_signed_smaller(a: i16, b: u32) -> i16 {
6363
#[no_mangle]
6464
pub unsafe fn unchecked_shr_signed_bigger(a: i64, b: u32) -> i64 {
6565
// CHECK-NOT: assume
66-
// CHECK: %[[EXT:.+]] = zext i32 %b to i64
66+
// CHECK: %[[EXT:.+]] = zext{{( nneg)?}} i32 %b to i64
6767
// CHECK: ashr i64 %a, %[[EXT]]
6868
a.unchecked_shr(b)
6969
}

tests/ui/suggestions/issue-117669.rs

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
fn main() {
2+
let abs: i32 = 3i32.checked_abs();
3+
//~^ ERROR mismatched types
4+
}
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/issue-117669.rs:2:20
3+
|
4+
LL | let abs: i32 = 3i32.checked_abs();
5+
| --- ^^^^^^^^^^^^^^^^^^ expected `i32`, found `Option<i32>`
6+
| |
7+
| expected due to this
8+
|
9+
= note: expected type `i32`
10+
found enum `Option<i32>`
11+
help: consider using `Option::expect` to unwrap the `Option<i32>` value, panicking if the value is an `Option::None`
12+
|
13+
LL | let abs: i32 = 3i32.checked_abs().expect("REASON");
14+
| +++++++++++++++++
15+
16+
error: aborting due to previous error
17+
18+
For more information about this error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)