Skip to content

dot-dsl tests: error[E0716]: temporary value dropped while borrowed #2011

Closed
@eirnym

Description

@eirnym

rust version rustc 1.84.0 (9fc6b4312 2025-01-07)

error[E0716]: temporary value dropped while borrowed
   --> dot-dsl/tests/dot-dsl.rs:185:10
    |
185 |           &["a", "b", "c"]
    |  __________^
186 | |             .iter()
187 | |             .zip(attributes.iter())
188 | |             .map(|(name, &attr)| Node::new(name).with_attrs(&[attr]))
189 | |             .collect::<Vec<_>>(),
    | |________________________________^ creates a temporary value which is freed while still in use
190 |       );
    |        - temporary value is freed at the end of this statement
191 |
192 |       let a = graph.node("a").expect("node a must be stored");
    |               ----- borrow later used here
    |
help: consider using a `let` binding to create a longer lived value
    |
184 ~     let binding = ["a", "b", "c"]
185 +             .iter()
186 +             .zip(attributes.iter())
187 +             .map(|(name, &attr)| Node::new(name).with_attrs(&[attr]))
188 +             .collect::<Vec<_>>();
189 ~     let graph = Graph::new().with_nodes(
190 ~         &binding,
    |

For more information about this error, try `rustc --explain E0716`.
error: could not compile `dot-dsl` (test "dot-dsl") due to 1 previous error
warning: build failed, waiting for other jobs to finish..

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions