Skip to content

Commit 72945be

Browse files
committed
Remove special-casing for argument patterns in MIR typeck
1 parent e26ff2f commit 72945be

File tree

3 files changed

+9
-20
lines changed

3 files changed

+9
-20
lines changed

Diff for: compiler/rustc_borrowck/src/type_check/mod.rs

-13
Original file line numberDiff line numberDiff line change
@@ -892,19 +892,6 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
892892
Some(l) if !body.local_decls[l].is_user_variable() => {
893893
ConstraintCategory::Boring
894894
}
895-
Some(_)
896-
if let Some(body_id) = tcx
897-
.hir_node_by_def_id(body.source.def_id().expect_local())
898-
.body_id()
899-
&& let params = tcx.hir().body(body_id).params
900-
&& params
901-
.iter()
902-
.any(|param| param.span.contains(stmt.source_info.span)) =>
903-
{
904-
// Assignments generated from lowering argument patterns shouldn't be called
905-
// "assignments" in diagnostics and aren't interesting to blame for errors.
906-
ConstraintCategory::Boring
907-
}
908895
_ => ConstraintCategory::Assignment,
909896
};
910897
debug!(
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
fn foo(&mut (ref mut v, w): &mut (&u8, &u8), x: &u8) {
2-
*v = x;
32
//~^ ERROR lifetime may not live long enough
3+
*v = x;
44
}
55

66
fn main() { }

Diff for: tests/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-2.stderr

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
error: lifetime may not live long enough
2-
--> $DIR/ex3-both-anon-regions-2.rs:2:5
2+
--> $DIR/ex3-both-anon-regions-2.rs:1:14
33
|
44
LL | fn foo(&mut (ref mut v, w): &mut (&u8, &u8), x: &u8) {
5-
| - - let's call the lifetime of this reference `'1`
6-
| |
7-
| let's call the lifetime of this reference `'2`
8-
LL | *v = x;
9-
| ^^^^^^ assignment requires that `'1` must outlive `'2`
5+
| ^^^^^^^^^ - - let's call the lifetime of this reference `'1`
6+
| | |
7+
| | let's call the lifetime of this reference `'2`
8+
| assignment requires that `'1` must outlive `'2`
109
|
10+
= note: requirement occurs because of a mutable reference to `&u8`
11+
= note: mutable references are invariant over their type parameter
12+
= help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
1113
help: consider introducing a named lifetime parameter
1214
|
1315
LL | fn foo<'a>(&mut (ref mut v, w): &mut (&'a u8, &u8), x: &'a u8) {

0 commit comments

Comments
 (0)