Skip to content

Regression in Beta and Nightly in type inference #36352

Closed
@Razican

Description

@Razican

Stable build: https://travis-ci.org/SUPERAndroidAnalyzer/super/jobs/158500096
Beta build: https://travis-ci.org/SUPERAndroidAnalyzer/super/jobs/158500095
Nightly build: https://travis-ci.org/SUPERAndroidAnalyzer/super/jobs/158500094

Beta and nightly fail when trying to get a file name as a String from a PathBuf. The code is the following:

let dir_iter = try!(fs::read_dir("some/random/path"));
for f in dir_iter {
    let path_file = match f.unwrap().path().file_name() {
            Some(n) => String::from(n.to_string_lossy().borrow()),
            None => String::new(),
    };
    println!("{}", path_file);
}

And it also happens when getting the value from an AsRef<str>, in this example code:

pub fn new<S: AsRef<str>>(somedata: S) -> String {
    String::from(somedata.as_ref())
}

In both cases the error is the same:
type annotations required: cannot resolve std::string::String: std::convert::From<&_>

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.regression-from-stable-to-betaPerformance or correctness regression from stable to beta.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions