diff options
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_error_codes/src/error_codes/E0716.md | 6 | ||||
| -rw-r--r-- | compiler/rustc_mir/src/dataflow/mod.rs | 2 |
2 files changed, 5 insertions, 3 deletions
diff --git a/compiler/rustc_error_codes/src/error_codes/E0716.md b/compiler/rustc_error_codes/src/error_codes/E0716.md index c6d0337ddda..c3546cd744f 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0716.md +++ b/compiler/rustc_error_codes/src/error_codes/E0716.md @@ -14,14 +14,16 @@ Here, the expression `&foo()` is borrowing the expression `foo()`. As `foo()` is a call to a function, and not the name of a variable, this creates a **temporary** -- that temporary stores the return value from `foo()` so that it can be borrowed. You could imagine that `let p = bar(&foo());` is equivalent to -this: +the following, which uses an explicit temporary variable. + +Erroneous code example: ```compile_fail,E0597 # fn foo() -> i32 { 22 } # fn bar(x: &i32) -> &i32 { x } let p = { let tmp = foo(); // the temporary - bar(&tmp) + bar(&tmp) // error: `tmp` does not live long enough }; // <-- tmp is freed as we exit this block let q = p; ``` diff --git a/compiler/rustc_mir/src/dataflow/mod.rs b/compiler/rustc_mir/src/dataflow/mod.rs index 5575a97982f..03531a6b004 100644 --- a/compiler/rustc_mir/src/dataflow/mod.rs +++ b/compiler/rustc_mir/src/dataflow/mod.rs @@ -7,7 +7,7 @@ pub(crate) use self::drop_flag_effects::*; pub use self::framework::{ fmt, lattice, visit_results, Analysis, AnalysisDomain, Backward, BorrowckFlowState, BorrowckResults, Engine, Forward, GenKill, GenKillAnalysis, JoinSemiLattice, Results, - ResultsCursor, ResultsRefCursor, ResultsVisitor, + ResultsCursor, ResultsRefCursor, ResultsVisitor, SwitchIntEdgeEffects, }; use self::move_paths::MoveData; |
