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

expect_fun_call suggests code that does not compile #2937

Closed
RalfJung opened this issue Jul 19, 2018 · 2 comments
Closed

expect_fun_call suggests code that does not compile #2937

RalfJung opened this issue Jul 19, 2018 · 2 comments
Labels
C-bug Category: Clippy is not doing the correct thing L-suggestion Lint: Improving, adding or fixing lint suggestions

Comments

@RalfJung
Copy link
Member

I have this piece of code

            let config_table = rocket.config().get_table(section)
                .expect(format!("[{}] table in Rocket.toml missing or not a table", section).as_str());

which clippy recommends I change to

            let config_table = rocket.config().get_table(section)
                .unwrap_or_else(|_| panic!(format!("[{}] table in Rocket.toml missing or not a table", section).as_str()));

Unfortunately, that does not compile:

error[E0597]: borrowed value does not live long enough
  --> src/config.rs:88:44
   |
88 |                 .unwrap_or_else(|_| panic!(format!("[{}] table in Rocket.toml missing or not a table", section).as_str()));
   |                                     -------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^----------
   |                                     |      |
   |                                     |      temporary value does not live long enough
   |                                     temporary value only lives until here
   |
   = note: borrowed value must be valid for the static lifetime...
   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
@phansch phansch added C-bug Category: Clippy is not doing the correct thing L-suggestion Lint: Improving, adding or fixing lint suggestions labels Jul 19, 2018
@ghost
Copy link

ghost commented Aug 30, 2018

I'm looking at this.

@ghost ghost self-assigned this Aug 30, 2018
@phansch
Copy link
Member

phansch commented Aug 30, 2018

Probably the same as #2928

@ghost ghost mentioned this issue Sep 13, 2018
@ghost ghost closed this as completed in 7499cb5 Oct 11, 2018
@nrc nrc unassigned ghost Nov 21, 2018
flip1995 pushed a commit to flip1995/rust-clippy that referenced this issue May 5, 2020
Changes:

Remove now-useless `allow(unknown_lints)`
Stabilize tool lints
Use `impl Iterator` in arg position in clippy_dev
Fix fn_to_numeric_cast_with_truncation suppression
Limit commutative assign op lint to primitive types
Clarify code
Fix rust-lang#2937
Fix cast_possible_wrap and cast_sign_loss warnings
Fix cast_possible_truncation warnings
Fixes rust-lang#2925 cmp_owned false positive
if_let_redundant_pattern_matching: use Span.to() instead of Span.with_hi() to fix crash.
Improve diagnostics in case of lifetime elision (closes rust-lang#3284)
Fix items_after_statements for `const`s
Fix items_after_statements for sub-functions
Fix items_after_statements for `use` statements
Don't suggest cloned() for map Box deref
Fix excessive_precision false positive
Fix FP in `fn_to_numeric_cast_with_truncation`
new_without_default should not warn about unsafe new
fix command to manually test an example
Add license to README
Adding more detail to filter_map lint documentation.
additional people
Add license header to other files
Add license header to Rust files
Relicense clippy
Document relicensing process
Fix util/export.py to include lints from methods
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing L-suggestion Lint: Improving, adding or fixing lint suggestions
Projects
None yet
Development

No branches or pull requests

2 participants