Skip to content

Fix warnings in new nightly #1147

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 1 commit into from
Jul 31, 2018
Merged

Conversation

Nemo157
Copy link
Member

@Nemo157 Nemo157 commented Jul 30, 2018

Part of #1143.

@cramertj
Copy link
Member

I don't think we should do this-- as I pointed out in rust-lang/rust#52671, I think it should be fine for an empty type (like []) to be promoted and have mutable references to it shared.

@Nemo157
Copy link
Member Author

Nemo157 commented Jul 30, 2018

Ok, is promotion a guaranteed thing though? It seems odd that you could rely on it working in this case while there's no way to safely write an explicit form like

static mut EMPTY: &mut [u8] = &mut [];
mem::swap(&mut self.buf, &mut EMPTY);

If you want to leave this till it's hashed out on rust-lang/rust#52671 I can drop the ReadExact change and only fix the unnecessary muts in this PR.

@Nemo157
Copy link
Member Author

Nemo157 commented Jul 30, 2018

Dropped the ReadExact change, now this is just removing some unnecessary muts.

@@ -362,7 +362,7 @@ if_std! {
) -> Poll<Result<usize>> {
let position = self.position();
let result = {
let mut out = self.get_mut().as_mut();
let out = self.get_mut().as_mut();
Copy link
Member

Choose a reason for hiding this comment

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

Can you explain why this mut is unused? It looks used to me (there's an &mut out below). Is it just because it's an &mut already and some coercion is firing?

Copy link
Member Author

Choose a reason for hiding this comment

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

It’s not quite an &mut out below, it’s closer to an &mut (out[pos..]). That works fine with an immutable binding to a mutable slice since the indexing is being done via an auto-deref. (At least, I think that’s what’s going on).

Copy link
Member

Choose a reason for hiding this comment

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

Got it, thanks.

@cramertj cramertj merged commit a973f4f into rust-lang:master Jul 31, 2018
@Nemo157 Nemo157 deleted the fix-warnings branch July 31, 2018 22:26
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.

2 participants