Remove special-casing for argument patterns in MIR typeck
This commit is contained in:
parent
e26ff2f908
commit
72945beedd
3 changed files with 9 additions and 20 deletions
|
@ -892,19 +892,6 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
|||
Some(l) if !body.local_decls[l].is_user_variable() => {
|
||||
ConstraintCategory::Boring
|
||||
}
|
||||
Some(_)
|
||||
if let Some(body_id) = tcx
|
||||
.hir_node_by_def_id(body.source.def_id().expect_local())
|
||||
.body_id()
|
||||
&& let params = tcx.hir().body(body_id).params
|
||||
&& params
|
||||
.iter()
|
||||
.any(|param| param.span.contains(stmt.source_info.span)) =>
|
||||
{
|
||||
// Assignments generated from lowering argument patterns shouldn't be called
|
||||
// "assignments" in diagnostics and aren't interesting to blame for errors.
|
||||
ConstraintCategory::Boring
|
||||
}
|
||||
_ => ConstraintCategory::Assignment,
|
||||
};
|
||||
debug!(
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
fn foo(&mut (ref mut v, w): &mut (&u8, &u8), x: &u8) {
|
||||
*v = x;
|
||||
//~^ ERROR lifetime may not live long enough
|
||||
*v = x;
|
||||
}
|
||||
|
||||
fn main() { }
|
||||
|
|
|
@ -1,13 +1,15 @@
|
|||
error: lifetime may not live long enough
|
||||
--> $DIR/ex3-both-anon-regions-2.rs:2:5
|
||||
--> $DIR/ex3-both-anon-regions-2.rs:1:14
|
||||
|
|
||||
LL | fn foo(&mut (ref mut v, w): &mut (&u8, &u8), x: &u8) {
|
||||
| - - let's call the lifetime of this reference `'1`
|
||||
| |
|
||||
| let's call the lifetime of this reference `'2`
|
||||
LL | *v = x;
|
||||
| ^^^^^^ assignment requires that `'1` must outlive `'2`
|
||||
| ^^^^^^^^^ - - let's call the lifetime of this reference `'1`
|
||||
| | |
|
||||
| | let's call the lifetime of this reference `'2`
|
||||
| assignment requires that `'1` must outlive `'2`
|
||||
|
|
||||
= note: requirement occurs because of a mutable reference to `&u8`
|
||||
= note: mutable references are invariant over their type parameter
|
||||
= help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
|
||||
help: consider introducing a named lifetime parameter
|
||||
|
|
||||
LL | fn foo<'a>(&mut (ref mut v, w): &mut (&'a u8, &u8), x: &'a u8) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue