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

unused arguments vs borrowed pointers #3424

Closed
jesse99 opened this issue Sep 8, 2012 · 6 comments
Closed

unused arguments vs borrowed pointers #3424

jesse99 opened this issue Sep 8, 2012 · 6 comments
Assignees
Labels
A-lifetimes Area: Lifetimes / regions A-type-system Area: Type system
Milestone

Comments

@jesse99
Copy link
Contributor

jesse99 commented Sep 8, 2012

The test case below fails to compile, apparently because the borrow checker doesn't think an unused argument is (not) used safely.


// rustc --test ignores2.rs && ./ignores2
use std;
use path::{Path};

type rsrc_loader = fn~ (path: &Path) -> result::Result<~str, ~str>;

#[test]
fn tester()
{
    let loader: rsrc_loader = |_path| {result::Ok(~"more blah")};

    let path = path::from_str("blah");
    assert loader(&path).is_ok();
}

// ignores2.rs:10:25: 10:82 error: mismatched types: expected `rsrc_loader` but found `fn~(&core::path::Path) -> core::result::Result<~str,~str>` (lifetime re_bound(br_anon(0)) does not necessarily outlive the static lifetime)
// ignores2.rs:10     let loader: rsrc_loader = |_path| {result::Ok(~"unbalanced {{curly}} {{braces}")};
//                                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@jesse99
Copy link
Contributor Author

jesse99 commented Sep 8, 2012

Somewhat related to #3423.

@jesse99
Copy link
Contributor Author

jesse99 commented Sep 8, 2012

Does compile and run if loader is turned into a named function.

@nikomatsakis
Copy link
Contributor

This is probably #2263. The fact that re_bound(re_anon(0)) appears in the error message (which should never happen, under ordinary circumstances) is a clue.

@nikomatsakis
Copy link
Contributor

But I'm not sure, it's odd. I'll have to dig into this.

@jesse99
Copy link
Contributor Author

jesse99 commented Sep 9, 2012

I've also seen this error with anonymous functions that didn't have unused arguments. Worked around it by explicitly typing the anonymous function arguments taking borrowed pointers.

@ghost ghost assigned nikomatsakis Oct 11, 2012
@catamorphism
Copy link
Contributor

This compiles for me, as of d2ad028

flip1995 pushed a commit to flip1995/rust that referenced this issue Apr 22, 2021
Deprecate `filter_map`

Since rust-lang#6591, `filter_map` does not even lint `filter().map()`. The cases that are still linted make no sense IMO. So this just removes/deprecates it.

changelog: Deprecate `filter_map` lint

Closes rust-lang#3424
Fixes rust-lang#7050
bors pushed a commit to rust-lang-ci/rust that referenced this issue May 15, 2021
Support EmitMode::ModifiedLines with stdin input
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lifetimes Area: Lifetimes / regions A-type-system Area: Type system
Projects
None yet
Development

No branches or pull requests

3 participants