Remove priv from the language#13547
Merged
bors merged 3 commits intorust-lang:masterfrom Apr 16, 2014
Merged
Conversation
This replaces all uses of private enum variants with a struct that has one private field pointing at a private enum. RFC: 0006-remove-priv
Contributor
There was a problem hiding this comment.
Could this become pub struct c_void { private: u8 }?
Member
Author
There was a problem hiding this comment.
Sadly I don't think so. I think that this was around primarily for free(malloc(size)) to get optimized away.
pub struct c_void { wut: u8 }
extern {
fn malloc(s: uint) -> *mut c_void;
fn free(s: *mut c_void);
}
fn main() {
unsafe {
let a = malloc(4);
free(a);
}
}$ rustc foo.rs --emit=ir -o - -O
; ModuleID = '-.rs'
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
target triple = "x86_64-apple-darwin"
%struct.c_void = type { i8 }
; Function Attrs: nounwind
declare noalias %struct.c_void* @malloc(i64) unnamed_addr #0
; Function Attrs: nounwind
declare void @free(%struct.c_void* nocapture) unnamed_addr #0
; Function Attrs: nounwind uwtable
define internal void @_ZN4main20h1284b3d9a92c1d91yaa4v0.0E() unnamed_addr #1 {
entry-block:
%0 = tail call %struct.c_void* @malloc(i64 4)
tail call void @free(%struct.c_void* %0)
ret void
}
define i64 @main(i64, i8**) unnamed_addr {
top:
%2 = tail call i64 @_ZN10lang_start20he5bbdca974ae42c3eqd9v0.11.preE(i8* bitcast (void ()* @_ZN4main20h1284b3d9a92c1d91yaa4v0.0E to i8*), i64 %0, i8** %1)
ret i64 %2
}
declare i64 @_ZN10lang_start20he5bbdca974ae42c3eqd9v0.11.preE(i8*, i64, i8**) unnamed_addr
attributes #0 = { nounwind }
attributes #1 = { nounwind uwtable }
Contributor
There was a problem hiding this comment.
But the enum works? That seems a little peculiar?
Oh, I guess #[repr(u8)] is making the enum an actual u8, rather than just a struct with a u8 in it?
Member
Author
There was a problem hiding this comment.
Yeah, I think the problem is
%struct.c_void = type { i8 }
which does not happen with enums because the enum is just an LLVM i8 type.
Contributor
|
r=me with the situation with private_variant_1.rs clarified (and its corresponding compile-fail/private_variant_2.rs). |
Contributor
|
Yay, 🍰 |
This removes the `priv` keyword from the language and removes private enum variants as a result. The remaining use cases of private enum variants were all updated to be a struct with one private field that is a private enum. RFC: 0006-remove-priv Closes rust-lang#13535
It is no longer used in rust anywhere. RFC: 0006-remove-priv
bors
added a commit
that referenced
this pull request
Apr 16, 2014
Manishearth
added a commit
to Manishearth/rust
that referenced
this pull request
May 1, 2015
…lexcrichton Hi! While researching stuff for the reference and the grammar, I came across a few mentions of using the `priv` keyword that was removed in 0.11.0 (rust-lang#13547, rust-lang#8122, rust-lang/rfcs#26, [RFC 0026](https://github.com/rust-lang/rfcs/blob/master/text/0026-remove-priv.md)). One occurrence is a mention in the reference, a few are in comments, and a few are marking test functions. I left the test that makes sure you can't name an ident `priv` since it's still a reserved keyword. I did a little grepping around for `priv `, priv in backticks, `Private` etc and I think the remaining instances are fine, but if anyone knows anywhere in particular I should check for any other lingering mentions of `priv`, please let me know and I would be happy to! 🍂 🌊
Manishearth
added a commit
to Manishearth/rust
that referenced
this pull request
May 1, 2015
…lexcrichton Hi! While researching stuff for the reference and the grammar, I came across a few mentions of using the `priv` keyword that was removed in 0.11.0 (rust-lang#13547, rust-lang#8122, rust-lang/rfcs#26, [RFC 0026](https://github.com/rust-lang/rfcs/blob/master/text/0026-remove-priv.md)). One occurrence is a mention in the reference, a few are in comments, and a few are marking test functions. I left the test that makes sure you can't name an ident `priv` since it's still a reserved keyword. I did a little grepping around for `priv `, priv in backticks, `Private` etc and I think the remaining instances are fine, but if anyone knows anywhere in particular I should check for any other lingering mentions of `priv`, please let me know and I would be happy to! 🍂 🌊
matthiaskrgr
pushed a commit
to matthiaskrgr/rust
that referenced
this pull request
Nov 16, 2022
internal: Optimize `apply_document_changes` a bit cc rust-lang/rust-analyzer#13538
flip1995
pushed a commit
to flip1995/rust
that referenced
this pull request
Oct 18, 2024
…ge-category, r=llogiq Change the category of `manual_is_power_of_two` to `pedantic` Fixes rust-lang#13547. The value being checked might be a bit flag, suggesting `is_power_of_two` for it would make the code unreadable. changelog: [`manual_is_power_of_two`]: Change the category to `pedantic`
flip1995
pushed a commit
to flip1995/rust
that referenced
this pull request
Nov 21, 2024
…ge-category, r=llogiq Change the category of `manual_is_power_of_two` to `pedantic` Fixes rust-lang#13547. The value being checked might be a bit flag, suggesting `is_power_of_two` for it would make the code unreadable. changelog: [`manual_is_power_of_two`]: Change the category to `pedantic`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See RFC 6