Skip to content

unused arguments vs borrowed pointers #3424

Closed
@jesse99

Description

@jesse99

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}")};
//                                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions