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

Warning: unused borrow must be used #233

Closed
nsabovic opened this issue Sep 6, 2021 · 6 comments · Fixed by #234
Closed

Warning: unused borrow must be used #233

nsabovic opened this issue Sep 6, 2021 · 6 comments · Fixed by #234

Comments

@nsabovic
Copy link

nsabovic commented Sep 6, 2021

As of recently, each time I compile my CLI app that uses Yarte i get a bunch of these:

warning: unused borrow that must be used
 --> src/report/generate_html.rs:5:10
  |
5 | #[derive(Template)]
  |          ^^^^^^^^ the borrow produces a value
  |
  = note: this warning originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info)

Looking into it with cargo expand I see generated code like this:

&(self.surface_type).__renders_it(_fmt)?;

Which, as far as I understand, calls __renders_it(), and grabs the reference of the returned Result instead of grabbing the reference of self.surface_type, hence the warnings.

nsabovic pushed a commit to nsabovic/yarte that referenced this issue Sep 6, 2021
@nsabovic nsabovic mentioned this issue Sep 6, 2021
@Roms1383
Copy link

Hi everybody !
@botika just to mention but I also get the very same warning in current version 0.15.5.

@zzau13 zzau13 reopened this Nov 15, 2021
@zzau13
Copy link
Owner

zzau13 commented Nov 15, 2021

@Roms1383 Can you explain the case to me?

@Roms1383
Copy link

Yes @botika, sure:


platform

dev-machine


context

  • 📦 cargo 1.56.0 (4ed5d137b 2021-10-04)
  • ⚙️ rustc 1.56.1 (59eed8a2a 2021-11-01)
  • 📜 rustup 1.24.3 (ce5817a94 2021-05-31)
  • 💄 rustfmt 1.4.37-stable (59eed8a2 2021-11-01)
  • ✉️ yarte = "0.15.5"

sample of code

#[derive(Template)] // ⚠️ unused borrow that must be used the borrow produces a value
#[template(path = "email-verification")]
pub struct EmailVerification<'a> {
    url: &'a str,
    name: &'a str,
    is_applying: bool,
    code: &'a str,
    expiration: &'a str,
}

sample of template

📁 ./templates/email-verification.hbs

{{#if code == "fr"}}
  {{> fr/email-verification }}
{{else}}
  {{> en/email-verification }}
{{/if}}

📁 ./templates/en/email-verification.hbs

{{name}}

Welcome, we have acknowledged your registration.
Please verify your email address by clicking on the link below.

{{{url}}}

This verification link will expire on {{expiration}}
Once expired, please process with registration from the beginning again.

Thank you.

zzau13 added a commit that referenced this issue Nov 16, 2021
@zzau13
Copy link
Owner

zzau13 commented Nov 17, 2021

@Roms1383 The changes are already in master. Can you confirm that they have solved the problem to get a new version?

@Roms1383
Copy link

@botika I tried quickly from master and indeed the warnings are gone ! 🎉

@zzau13
Copy link
Owner

zzau13 commented Nov 17, 2021

Thank you very much for participating in the development of yarte, I release a new version throughout the morning (CET) (It's that I'm in a meeting now (don't tell my boss) 😺 )

@zzau13 zzau13 closed this as completed Nov 17, 2021
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

Successfully merging a pull request may close this issue.

3 participants