Account for macros when suggesting a new let binding
This commit is contained in:
parent
49a16b64b0
commit
66d23793f0
4 changed files with 17 additions and 4 deletions
|
@ -2133,13 +2133,14 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||||
self.current -= 1;
|
self.current -= 1;
|
||||||
}
|
}
|
||||||
fn visit_expr(&mut self, expr: &hir::Expr<'tcx>) {
|
fn visit_expr(&mut self, expr: &hir::Expr<'tcx>) {
|
||||||
if self.span == expr.span {
|
if self.span == expr.span.source_callsite() {
|
||||||
self.found = self.current;
|
self.found = self.current;
|
||||||
}
|
}
|
||||||
walk_expr(self, expr);
|
walk_expr(self, expr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let source_info = self.body.source_info(location);
|
let source_info = self.body.source_info(location);
|
||||||
|
let proper_span = proper_span.source_callsite();
|
||||||
if let Some(scope) = self.body.source_scopes.get(source_info.scope)
|
if let Some(scope) = self.body.source_scopes.get(source_info.scope)
|
||||||
&& let ClearCrossCrate::Set(scope_data) = &scope.local_data
|
&& let ClearCrossCrate::Set(scope_data) = &scope.local_data
|
||||||
&& let Some(node) = self.infcx.tcx.hir().find(scope_data.lint_root)
|
&& let Some(node) = self.infcx.tcx.hir().find(scope_data.lint_root)
|
||||||
|
|
|
@ -8,8 +8,12 @@ LL | let x = defer(&vec!["Goodbye", "world!"]);
|
||||||
LL | x.x[0];
|
LL | x.x[0];
|
||||||
| ------ borrow later used here
|
| ------ borrow later used here
|
||||||
|
|
|
|
||||||
= note: consider using a `let` binding to create a longer lived value
|
|
||||||
= note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info)
|
= note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
help: consider using a `let` binding to create a longer lived value
|
||||||
|
|
|
||||||
|
LL ~ let binding = vec!["Goodbye", "world!"];
|
||||||
|
LL ~ let x = defer(&binding);
|
||||||
|
|
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -9,8 +9,12 @@ LL |
|
||||||
LL | x.use_mut();
|
LL | x.use_mut();
|
||||||
| - borrow later used here
|
| - borrow later used here
|
||||||
|
|
|
|
||||||
= note: consider using a `let` binding to create a longer lived value
|
|
||||||
= note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info)
|
= note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
help: consider using a `let` binding to create a longer lived value
|
||||||
|
|
|
||||||
|
LL ~ let binding = vec![1];
|
||||||
|
LL ~ let mut x = binding.iter();
|
||||||
|
|
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -9,8 +9,12 @@ LL |
|
||||||
LL | stuff(phantom_pinned)
|
LL | stuff(phantom_pinned)
|
||||||
| -------------- borrow later used here
|
| -------------- borrow later used here
|
||||||
|
|
|
|
||||||
= note: consider using a `let` binding to create a longer lived value
|
|
||||||
= note: this error originates in the macro `pin` (in Nightly builds, run with -Z macro-backtrace for more info)
|
= note: this error originates in the macro `pin` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
help: consider using a `let` binding to create a longer lived value
|
||||||
|
|
|
||||||
|
LL ~ let binding = pin!(PhantomPinned);
|
||||||
|
LL ~ let phantom_pinned = identity(binding);
|
||||||
|
|
|
||||||
|
|
||||||
error[E0716]: temporary value dropped while borrowed
|
error[E0716]: temporary value dropped while borrowed
|
||||||
--> $DIR/lifetime_errors_on_promotion_misusage.rs:18:30
|
--> $DIR/lifetime_errors_on_promotion_misusage.rs:18:30
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue