Skip to content

Commit 987656f

Browse files
committed
Remove a duplicated check that doesn't do anything anymore.
1 parent 023521e commit 987656f

File tree

4 files changed

+18
-42
lines changed

4 files changed

+18
-42
lines changed

compiler/rustc_hir_typeck/src/coercion.rs

-37
Original file line numberDiff line numberDiff line change
@@ -1315,43 +1315,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
13151315
}
13161316
}
13171317

1318-
// Then try to coerce the previous expressions to the type of the new one.
1319-
// This requires ensuring there are no coercions applied to *any* of the
1320-
// previous expressions, other than noop reborrows (ignoring lifetimes).
1321-
for expr in exprs {
1322-
let expr = expr.as_coercion_site();
1323-
let noop = match self.typeck_results.borrow().expr_adjustments(expr) {
1324-
&[
1325-
Adjustment { kind: Adjust::Deref(_), .. },
1326-
Adjustment { kind: Adjust::Borrow(AutoBorrow::Ref(mutbl_adj)), .. },
1327-
] => {
1328-
match *self.node_ty(expr.hir_id).kind() {
1329-
ty::Ref(_, _, mt_orig) => {
1330-
let mutbl_adj: hir::Mutability = mutbl_adj.into();
1331-
// Reborrow that we can safely ignore, because
1332-
// the next adjustment can only be a Deref
1333-
// which will be merged into it.
1334-
mutbl_adj == mt_orig
1335-
}
1336-
_ => false,
1337-
}
1338-
}
1339-
&[Adjustment { kind: Adjust::NeverToAny, .. }] | &[] => true,
1340-
_ => false,
1341-
};
1342-
1343-
if !noop {
1344-
debug!(
1345-
"coercion::try_find_coercion_lub: older expression {:?} had adjustments, requiring LUB",
1346-
expr,
1347-
);
1348-
1349-
return Err(self
1350-
.commit_if_ok(|_| self.at(cause, self.param_env).lub(prev_ty, new_ty))
1351-
.unwrap_err());
1352-
}
1353-
}
1354-
13551318
match self.commit_if_ok(|_| coerce.coerce(prev_ty, new_ty)) {
13561319
Err(_) => {
13571320
// Avoid giving strange errors on failed attempts.

tests/crashes/134005.rs

-5
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//! This test used to hit an assertion instead of erroring and bailing out.
2+
3+
fn main() {
4+
let _ = [std::ops::Add::add, std::ops::Mul::mul, std::ops::Mul::mul as fn(_, &_)];
5+
//~^ ERROR: mismatched types
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/signature-mismatch.rs:4:54
3+
|
4+
LL | let _ = [std::ops::Add::add, std::ops::Mul::mul, std::ops::Mul::mul as fn(_, &_)];
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other
6+
|
7+
= note: expected fn pointer `fn(_, _) -> _`
8+
found fn pointer `for<'a> fn(_, &'a _) -> ()`
9+
10+
error: aborting due to 1 previous error
11+
12+
For more information about this error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)