Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

opt(err): show renaming file error source#4414

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
djc merged 1 commit intorust-lang:masterfromBinlogo:opt/rename-error
Jul 16, 2025

Conversation

Binlogo
Copy link
Contributor

Problem you are trying to solve

We occasionally encounter the following error:

error: component download failed for cargo-aarch64-apple-darwin: could not rename downloaded file from '/Users/xxx/.rustup/downloads/344e710d......76ee75be1fff0c7bf3.partial' to '/Users/xxx/.rustup/downloads/344e710d......76ee75be1fff0c7bf3'

This issue is difficult to reproduce, so it's important to add a source for reporting first.

Description

This pull request introduces aRenamingFile error with asource to improve error handling for file renaming operations in theRustupError enum. It updates the codebase to use this new error type, enhancing the clarity and consistency of error reporting.

Copy link
Contributor

@djcdjc left a comment

Choose a reason for hiding this comment

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

Should thestd::error::Error::source() method be implemented to yield thesource error for this?

@Binlogo
Copy link
ContributorAuthor

Should thestd::error::Error::source() method be implemented to provide thesource error for this?

@djc Thanks for asking, but I'm not sure, actually. I noticed thatSettingPermissions is usingio::Error here, so I followed the same pattern. Do you have any suggestions?

@Binlogo
Copy link
ContributorAuthor

Should thestd::error::Error::source() method be implemented to yield thesource error for this?

According to the thiserrordocumentation, it states:

The Error trait’s source() method is implemented to return whichever field has a #[source] attribute or is named source, if any. This is for identifying the underlying lower level error that caused your error.

The #[from] attribute always implies that the same field is #[source], so you don’t ever need to specify both attributes.

Any error type that implements std::error::Error or dereferences to dyn std::error::Error will work as a source.

#[derive(Error, Debug)]pub struct MyError {    msg: String,    #[source]  // optional if field name is `source`    source: anyhow::Error,}

Is it still necessary to implement the std::error::Error::source() method?

@BinlogoBinlogo requested a review fromdjcJuly 15, 2025 13:03
@djc
Copy link
Contributor

djc commentedJul 15, 2025

Sure, but your PR does not add any#[source] attribute, right?

@Binlogo
Copy link
ContributorAuthor

Binlogo commentedJul 15, 2025
edited
Loading

Sure, but your PR doesn't add any#[source] attribute, right?

This PR didn't add#[source] because this macro is optional if the field name issource, as the documentation mentions.

So it should implementedstd::error::Error::source() method bythiserror crate.

@djc
Copy link
Contributor

djc commentedJul 15, 2025

Sure, but your PR doesn't add any#[source] attribute, right?

This PR didn't add#[source] because this macro is optional if the field name issource, as the documentation mentions.

So it should implementedstd::error::Error::source() method bythiserror crate.

Ahh, okay, thanks.

Copy link
Member

@rami3lrami3l left a comment
edited
Loading

Choose a reason for hiding this comment

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

Looks nice to me, thanks!

@djc Do you happen to have remaining concerns or all of them have been addressed already?

@djcdjc added this pull request to themerge queueJul 16, 2025
@djcdjc removed this pull request from themerge queue due to a manual requestJul 16, 2025
@djc
Copy link
Contributor

djc commentedJul 16, 2025

@Binlogo just squash your commits please -- the second commit really belongs with the first one.

chore: fix ci windows build issue
@Binlogo
Copy link
ContributorAuthor

Binlogo commentedJul 16, 2025
edited
Loading

@djc Squashed. Thanks for the review.

@djcdjcenabled auto-mergeJuly 16, 2025 08:55
@djcdjc added this pull request to themerge queueJul 16, 2025
Merged via the queue intorust-lang:master with commit792598cJul 16, 2025
29 checks passed
@BinlogoBinlogo deleted the opt/rename-error branchJuly 16, 2025 13:12
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@djcdjcdjc approved these changes

@rami3lrami3lrami3l approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@Binlogo@djc@rami3l

[8]ページ先頭

©2009-2025 Movatter.jp