Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
eirnym opened this issue Feb 8, 2025 · 3 comments
Open

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

eirnym opened this issue Feb 8, 2025 · 3 comments

Comments

@eirnym
Copy link

eirnym commented Feb 8, 2025

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..
Copy link
Contributor

github-actions bot commented Feb 8, 2025

Hello. Thanks for opening an issue on Exercism 🙂

At Exercism we use our Community Forum, not GitHub issues, as the primary place for discussion. That allows maintainers and contributors from across Exercism's ecosystem to discuss your problems/ideas/suggestions without them having to subscribe to hundreds of repositories.

This issue will be automatically closed. Please use this link;%0A%20%20%20%20%7C%20%20%20%20%20%20%20%20-%20temporary%20value%20is%20freed%20at%20the%20end%20of%20this%20statement%0A191%20%7C%0A192%20%7C%20%20%20%20%20%20%20let%20a%20=%20graph.node(%22a%22).expect(%22node%20a%20must%20be%20stored%22);%0A%20%20%20%20%7C%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20-----%20borrow%20later%20used%20here%0A%20%20%20%20%7C%0Ahelp:%20consider%20using%20a%20%60let%60%20binding%20to%20create%20a%20longer%20lived%20value%0A%20%20%20%20%7C%0A184%20~%20%20%20%20%20let%20binding%20=%20%5B%22a%22,%20%22b%22,%20%22c%22%5D%0A185%20+%20%20%20%20%20%20%20%20%20%20%20%20%20.iter()%0A186%20+%20%20%20%20%20%20%20%20%20%20%20%20%20.zip(attributes.iter())%0A187%20+%20%20%20%20%20%20%20%20%20%20%20%20%20.map(%7C(name,%20&attr)%7C%20Node::new(name).with_attrs(&%5Battr%5D))%0A188%20+%20%20%20%20%20%20%20%20%20%20%20%20%20.collect::%3CVec%3C_%3E%3E();%0A189%20~%20%20%20%20%20let%20graph%20=%20Graph::new().with_nodes(%0A190%20~%20%20%20%20%20%20%20%20%20&binding,%0A%20%20%20%20%7C%0A%0AFor%20more%20information%20about%20this%20error,%20try%20%60rustc%20--explain%20E0716%60.%0Aerror:%20could%20not%20compile%20%60dot-dsl%60%20(test%20%22dot-dsl%22)%20due%20to%201%20previous%20error%0Awarning:%20build%20failed,%20waiting%20for%20other%20jobs%20to%20finish..%0A%60%60%60&category=rust ) to copy your GitHub Issue into a new topic on the forum, where we look forward to chatting with you!

If you're interested in learning more about this auto-responder, please read this blog post.

@github-actions github-actions bot closed this as completed Feb 8, 2025
@eirnym
Copy link
Author

eirnym commented Feb 8, 2025

Please, format link properly

@senekor senekor reopened this Feb 8, 2025
@senekor
Copy link
Contributor

senekor commented Feb 8, 2025

We can discuss here. Can you post your solution and explain why you think the code should work? Or what is it you need help with?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants