-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Remove libc from std #12526
Remove libc from std #12526
Conversation
cc @brson/@thestinger
|
c_vec at least has very few dependencies. c_str is much harder. c_str on the other hand has very few dependencies on libc |
Regardless of the ultimate fate of libc bindings this is a good first step. The big question to me is "liblibc or libc?". |
Or "libclib"? |
It would be nice if std somebody does not depend on libc (or maybe just ctypes). |
Ah another thing that I was just reminded of is that it's likely for many crates to depend on C types, but not necessarily on the C functions. Just a thought though. I think that moving |
"liblibc"?? A little weird. Why not just "libc"? I really think |
I don't think c_* moving here is a good idea. This is bindings to the C standard library, not utilities for interfacing with C in general. Those could probably usefully live in a |
I think there's a bug in resolve that types with the same name as primitives aren't resolved correctly, so this would restrict it to always being used as |
Additionally, they're always imported as "c_int" etc, so the name is On Mon, Feb 24, 2014 at 7:19 PM, Huon Wilson notifications@github.comwrote:
|
It would be nice if "someday" std doesn't depend on libc. |
Do we want to name it |
If rt has all the "talk to the OS" stuff, and libc/ffi has all the "talk to |
rt is in std, but there's also a std::os, and std::io uses a lot of libc. at least the types. |
Having two types called extern {
fn foo(x: int); // whoops, meant to be c::int, subtly incorrect on x86-64
} use c::int;
extern {
// ... use `int` a lot ...
}
fn x() -> uint { computation() }
fn y() {
let i = x() as int; // whoops, meant to be built-in `int`, lost precision on x86-64
// ...
} One might say "no-one will ever import Basically, it would make FFI a bigger mine-field than it already is: it's confusing enough that Rust's |
So r? |
@cmr looks like this needs to be rebased. |
updated On Tue, Feb 25, 2014 at 9:13 AM, Flavio Percoco Premoli <
|
Please keep in mind, we do have namespaces,
|
We should keep |
@liigo not when you On Tue, Feb 25, 2014 at 10:51 AM, György Andrasek
|
@Jurily: libstd can depend on |
The basic C types are not defined by libc. We need them to do any sort of FFI including kernel modules and writing |
I'm comfortable moving them out of libstd, until we have On Tue, Feb 25, 2014 at 3:39 PM, György Andrasek
|
It sounds like everyone is in mostly favor of moving I would like to make progress on this extraction. I'd like to take one last look, but other than that r+ with a rebase. |
@liigo, also, I forgot to say, but
isn't true. In anything but the crate root, |
r=me with an update to src/doc/index.md (sorry I forgot that earlier) |
These wrappers are bound to a specific libc, and they don't need to be part of libstd.
libc: remove stray impl in win32
Closing in favor of #13315 |
Rebasing of #12526 with a very obscure bug fixed on windows.
Mention `size_hint()` effect in `flat_map_option` lint documentation. The previous documentation for `flat_map_option` mentioned only readability benefits, but there is also at least one performance benefit: the `size_hint()` upper bound is preserved, whereas `flat_map().size_hint()` is always `(0, None)`. Program demonstrating this difference: ```rust fn main() { let evens = |i| if i % 2 == 0 { Some(i) } else { None }; dbg!( [1, 2, 3].iter().flat_map(evens).size_hint(), [1, 2, 3].iter().filter_map(evens).size_hint(), ); } ``` changelog: [`flat_map_option`]: Mention the benefit to `size_hint()`.
Remove libc from std