Skip to content

Try & simplify Registry vs Source confusion #5476

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

Merged
merged 8 commits into from
May 4, 2018
Merged

Try & simplify Registry vs Source confusion #5476

merged 8 commits into from
May 4, 2018

Conversation

dwijnand
Copy link
Member

@dwijnand dwijnand commented May 4, 2018

Refs #3006.

I tried to go further and replace references of Registry with PackageRegistry, but I ran into lifetime issue in ops::resolve_with_previous which I think has to do with no longer passing PackageRegistry as a Registry trait object (with a new and distinct lifetime).

dwijnand added 2 commits May 4, 2018 08:19
For now just move `supports_checksums` and `requires_precise` methods
down from `Registry` to `Source`, as they're not as entangled as
`query`.
.. and move query definitions to the struct impls.
@rust-highfive
Copy link

r? @alexcrichton

(rust_highfive has picked a reviewer for you, use r? to override)

@dwijnand
Copy link
Member Author

dwijnand commented May 4, 2018

I just had a thought: is it possible to delegate from one trait to the other, rather than have both traits delegate to the struct?


/// Returns whether or not this registry will return summaries with
/// the `precise` field in the source id listed.
fn requires_precise(&self) -> bool;
}

impl<'a, T: ?Sized + Registry + 'a> Registry for Box<T> {
Copy link
Member

Choose a reason for hiding this comment

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

We can remove this impl altogether.

@@ -46,12 +55,13 @@ impl<'cfg> Debug for DirectorySource<'cfg> {

impl<'cfg> Registry for DirectorySource<'cfg> {
Copy link
Member

Choose a reason for hiding this comment

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

I think we now can remove all impl Registry for XSource blocks.

@matklad
Copy link
Member

matklad commented May 4, 2018

Looks like a good start, but now I believe we can remove a whole bunch of useless impls!

@dwijnand
Copy link
Member Author

dwijnand commented May 4, 2018

You're right, @matklad! I hadn't realised.

That's much better. My first net 🔻 PR! 🎉

@@ -703,13 +673,5 @@ pub mod test {
Ok(())
Copy link
Member Author

Choose a reason for hiding this comment

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

@matklad Shall I trash this impl Registry for RegistryBuilder in cfg(test)?

I thought for a while it might be there to, perhaps, assert at compile-time the interface. But looking again it's got quite the verbose pointless implementation, and looking at the original commit it just looks like dead code.

WDYT?

Copy link
Member

Choose a reason for hiding this comment

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

Wow, this is dead code indeed! Let's remove it!

@alexcrichton
Copy link
Member

👍

@matklad
Copy link
Member

matklad commented May 4, 2018

@bors r+

Thanks!

@bors
Copy link
Contributor

bors commented May 4, 2018

📌 Commit 05e8194 has been approved by matklad

@bors
Copy link
Contributor

bors commented May 4, 2018

⌛ Testing commit 05e8194 with merge 1ca44da...

bors added a commit that referenced this pull request May 4, 2018
Try & simplify Registry vs Source confusion

Refs #3006.

I tried to go further and replace references of `Registry` with `PackageRegistry`, but I ran into lifetime issue in `ops::resolve_with_previous` which I think has to do with no longer passing `PackageRegistry` as a `Registry` trait object (with a new and distinct lifetime).
@bors
Copy link
Contributor

bors commented May 4, 2018

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

@bors bors merged commit 05e8194 into rust-lang:master May 4, 2018
@dwijnand dwijnand deleted the Registry-vs-Source-confusion branch May 4, 2018 15:04
@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.

6 participants