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

Drop legacy path support under Rust edition 2018 (or later) #5398

Merged
merged 1 commit into from
Apr 24, 2018
Merged

Drop legacy path support under Rust edition 2018 (or later) #5398

merged 1 commit into from
Apr 24, 2018

Conversation

dwijnand
Copy link
Member

@dwijnand dwijnand commented Apr 21, 2018

builds on #5335

submitted for early feedback: wdyt @matklad? is this what you had in mind? what should change? what should be added? how should we test this? is the current (2015) messaging enough to drop it in 2018?

r? @matklad

rename file to `src/lib.rs` or specify lib.path",
lib.name()
)
return bail();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

having to add the return here concerns me. is it correct?

Copy link
Member

@matklad matklad Apr 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would think that just bail() (without both return and semicolon) should work?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

me too! but looks like it doesn't. I blame macro shenanigans?

error[E0308]: if and else have incompatible types
   --> src/cargo/util/toml/targets.rs:159:13
    |
159 | /             if legacy_path.exists() {
160 | |                 warnings.push(format!(
161 | |                     "path `{}` was erroneously implicitly accepted for library `{}`,\n\
162 | |                      please rename the file to `src/lib.rs` or set lib.path in Cargo.toml",
...   |
168 | |                 bail()
169 | |             }
    | |_____________^ expected struct `std::path::PathBuf`, found enum `std::result::Result`
    |
    = note: expected type `std::path::PathBuf`
               found type `std::result::Result<std::option::Option<core::manifest::Target>, failure::Error>`

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, weird.... Anyway, I hope we can get rid of this closure altogether, as I've mentioned in other comments.

name = name,
target_kind = target_kind
))
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use the bail macro here as well?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sadly looks like no, because bail returns failure::Error and there's a codepath that buffers error strings in a vec

};
if edition >= Edition::Edition2018 {
return err();
}
if let Some(path) = legacy_path(target) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, let's just wrap this if-let into an addition if edition >= 2018, so as to avoid introducing local closures?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

of course.. I find out you can't use && with if let and somehow forgot about just nesting 😆

also I assumed the closure was free. good to know it's not.

};
if edition >= Edition::Edition2018 {
return bail();
}
let legacy_path = package_root.join("src").join(format!("{}.rs", lib.name()));
if legacy_path.exists() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, let's add && edition == 2015 to this condition, instead of introducing the bail closure?

@dwijnand
Copy link
Member Author

thanks for the review @matklad, it's much simpler now :)

@dwijnand
Copy link
Member Author

✅! 😄

@dwijnand
Copy link
Member Author

gentle review bump, please 😄

@matklad
Copy link
Member

matklad commented Apr 24, 2018

Thanks for the bump!

@bors r+

@bors
Copy link
Contributor

bors commented Apr 24, 2018

📌 Commit 46f4408 has been approved by matklad

@bors
Copy link
Contributor

bors commented Apr 24, 2018

⌛ Testing commit 46f4408 with merge ac9d5da...

bors added a commit that referenced this pull request Apr 24, 2018
Drop legacy path support under Rust edition 2018 (or later)

builds on #5335

submitted for early feedback: wdyt @matklad? is this what you had in mind? what should change? what should be added? how should we test this? is the current (2015) messaging enough to drop it in 2018?

r? @matklad

<!--{"baseBranch":"rust-lang:cargo:target-autodiscovery"}-->
@bors
Copy link
Contributor

bors commented Apr 24, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: matklad
Pushing ac9d5da to master...

@bors bors merged commit 46f4408 into rust-lang:master Apr 24, 2018
@dwijnand dwijnand deleted the drop-legacy-paths branch April 24, 2018 10:51
@ehuss ehuss added this to the 1.27.0 milestone Feb 6, 2022
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 this pull request may close these issues.

4 participants