Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #![allow(unreachable_code)]
- fn main() {
- println!("{:?}", {
- fn quote(path: &std::path::Path) -> String { unimplemented!() } let path = std::path::PathBuf::new(); let mut quoted_path = None; let get_quoted_path = || quoted_path.get_or_insert_with(|| quote(&path)); get_quoted_path();
- });
- }
- /* ~~~~=== stderr ===~~~~
- Compiling playground v0.0.1 (/playground)
- error[E0495]: cannot infer an appropriate lifetime for autoref due to conflicting requirements
- --> src/main.rs:6:176
- |
- 6 | fn quote(path: &std::path::Path) -> String { unimplemented!() } let path = std::path::PathBuf::new(); let mut quoted_path = None; let get_quoted_path = || quoted_path.get_or_insert_with(|| quote(&path)); get_quoted_path();
- | ^^^^^^^^^^^^^^^^^^
- |
- note: first, the lifetime cannot outlive the lifetime as defined on the body at 6:161...
- --> src/main.rs:6:161
- |
- 6 | fn quote(path: &std::path::Path) -> String { unimplemented!() } let path = std::path::PathBuf::new(); let mut quoted_path = None; let get_quoted_path = || quoted_path.get_or_insert_with(|| quote(&path)); get_quoted_path();
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- note: ...so that closure can access `quoted_path`
- --> src/main.rs:6:164
- |
- 6 | fn quote(path: &std::path::Path) -> String { unimplemented!() } let path = std::path::PathBuf::new(); let mut quoted_path = None; let get_quoted_path = || quoted_path.get_or_insert_with(|| quote(&path)); get_quoted_path();
- | ^^^^^^^^^^^
- note: but, the lifetime must be valid for the call at 6:213...
- --> src/main.rs:6:213
- |
- 6 | fn quote(path: &std::path::Path) -> String { unimplemented!() } let path = std::path::PathBuf::new(); let mut quoted_path = None; let get_quoted_path = || quoted_path.get_or_insert_with(|| quote(&path)); get_quoted_path();
- | ^^^^^^^^^^^^^^^^^
- note: ...so type `&mut std::string::String` of expression is valid during the expression
- --> src/main.rs:6:213
- |
- 6 | fn quote(path: &std::path::Path) -> String { unimplemented!() } let path = std::path::PathBuf::new(); let mut quoted_path = None; let get_quoted_path = || quoted_path.get_or_insert_with(|| quote(&path)); get_quoted_path();
- | ^^^^^^^^^^^^^^^^^
- error: aborting due to previous error
- For more information about this error, try `rustc --explain E0495`.
- error: Could not compile `playground`.
- To learn more, run the command again with --verbose.
- */
- /* ~~~~=== stdout ===~~~~
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement