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

rustc: Prevent false positives in crate loading #13017

Closed
wants to merge 1 commit into from

Conversation

alexcrichton
Copy link
Member

Previously, any library of the pattern lib<name>-<hash>-<version>.so was

considered a candidate (rightly so) for loading a crate. Sets are generated for
each unique <hash>, and then from these sets a candidate is selected. If a set
contained more than one element, then it immediately generated an error saying
that multiple copies of the same dylib were found.

This is incorrect because each candidate needs to be validated to actually
contain a rust library (valid metadata). This commit alters the logic to filter
each set of candidates for a hash to only libraries which are actually rust
libraries. This means that if multiple false positives are found with the right
name pattern, they're all ignored.

Closes #13010

Previously, any library of the pattern `lib<name>-<hash>-<version>.so` was
>considered a candidate (rightly so) for loading a crate. Sets are generated for
each unique `<hash>`, and then from these sets a candidate is selected. If a set
contained more than one element, then it immediately generated an error saying
that multiple copies of the same dylib were found.

This is incorrect because each candidate needs to be validated to actually
contain a rust library (valid metadata). This commit alters the logic to filter
each set of candidates for a hash to only libraries which are actually rust
libraries. This means that if multiple false positives are found with the right
name pattern, they're all ignored.

Closes rust-lang#13010
error = 1;
ret = None;
}
if error > 0 {
Copy link
Member

Choose a reason for hiding this comment

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

Doesn't this cause the note to be printed twice for candidate 1?

Copy link
Member Author

Choose a reason for hiding this comment

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

A little subtle, but the first errors prints the previously found library (stored in ret), and the second prints prints the current library (stored in lib)

bors added a commit that referenced this pull request Mar 20, 2014
Previously, any library of the pattern `lib<name>-<hash>-<version>.so` was
>considered a candidate (rightly so) for loading a crate. Sets are generated for
each unique `<hash>`, and then from these sets a candidate is selected. If a set
contained more than one element, then it immediately generated an error saying
that multiple copies of the same dylib were found.

This is incorrect because each candidate needs to be validated to actually
contain a rust library (valid metadata). This commit alters the logic to filter
each set of candidates for a hash to only libraries which are actually rust
libraries. This means that if multiple false positives are found with the right
name pattern, they're all ignored.

Closes #13010
@bors bors closed this Mar 20, 2014
@alexcrichton alexcrichton deleted the issue-13010 branch March 20, 2014 18:05
lnicola pushed a commit to lnicola/rust that referenced this pull request Aug 16, 2022
…kril

Pad empty diagnostic messages in relatedInformation as well

Follw up to rust-lang/rust-analyzer#13016
flip1995 pushed a commit to flip1995/rust that referenced this pull request Jul 11, 2024
Image-related valid idents

False positives for idents in markdown

changelog: Add "WebP", "OpenExr", "YcbCr", "sRGB" to `doc-valid-idents` default.
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.

rustc mistakes non-rust crates for candidates
3 participants