about summary refs log tree commit diff
path: root/src/libstd
AgeCommit message (Collapse)AuthorLines
2018-01-26make Command.argv Send on unix platformsCorentin Henry-10/+11
Implementing Send for a specific field rather than the whole struct is safer: if a field is changed/modified and becomes non-Send, we can catch it.
2018-01-26Print inlined functions on WindowsJohn Kåre Alsaker-37/+59
2018-01-25implement Send for process::Command on unixCorentin Henry-0/+5
closes https://github.com/rust-lang/rust/issues/47751
2018-01-25Auto merge of #47006 - bitshifter:stabilize-repr-align, r=eddybbors-1/+1
Stabilized `#[repr(align(x))]` attribute (RFC 1358) Stabilzed `#[repr(align(x))]` with attr_literal syntax as proposed by @eddyb https://github.com/rust-lang/rust/issues/33626#issuecomment-348467804
2018-01-24Add missing micro version number component in stability attributes.Simon Sapin-4/+4
2018-01-24Auto merge of #47300 - remexre:duration-constructors-as-const-fns, ↵bors-13/+16
r=alexcrichton Makes the constructors of Duration const fns. This affects `Duration::new`, `Duration::from_secs`, `Duration::from_millis`, `Duration::from_micros`, and `Duration::from_nanos`.
2018-01-24Auto merge of #47299 - cramertj:unsafe-placer, r=alexcrichtonbors-1/+1
Make core::ops::Place an unsafe trait Consumers of `Place` would reasonably expect that the `pointer` function returns a valid pointer to memory that can actually be written to.
2018-01-24Auto merge of #46931 - clarcharr:float_bits_core, r=alexcrichtonbors-6/+4
Expose float from_bits and to_bits in libcore. These methods have no dependencies on libm and thus should be offered in libcore.
2018-01-23Make PanicInfo::message available for std::panic! with a formatting string.Simon Sapin-6/+7
This enables PanicInfo’s Display impl to show the panic message in those cases.
2018-01-23Add an unstable PanicInfo::message(&self) -> Option<&fmt::Arguments> methodSimon Sapin-0/+1
2018-01-23Move PanicInfo and Location to libcoreSimon Sapin-190/+16
Per https://rust-lang.github.io/rfcs/2070-panic-implementation.html
2018-01-23Stabilized `#[repr(align(x))]` attribute (RFC 1358)Cameron Hart-1/+1
2018-01-21Rollup merge of #47334 - etaoins:only-call-res-init-on-gnu-unix, r=alexcrichtonGuillaume Gomez-32/+16
Only link res_init() on GNU/*nix To workaround a bug in glibc <= 2.26 lookup_host() calls res_init() based on the glibc version detected at runtime. While this avoids calling res_init() on platforms where it's not required we will still end up linking against the symbol. This causes an issue on macOS where res_init() is implemented in a separate library (libresolv.9.dylib) from the main libc. While this is harmless for standalone programs it becomes a problem if Rust code is statically linked against another program. If the linked program doesn't already specify -lresolv it will cause the link to fail. This is captured in issue #46797 Fix this by hooking in to the glibc workaround in `cvt_gai` and only activating it for the "gnu" environment on Unix This should include all glibc platforms while excluding musl, windows-gnu, macOS, FreeBSD, etc. This has the side benefit of removing the #[cfg] in sys_common; only unix.rs has code related to the workaround now. Before this commit: ```shell > cat main.rs use std::net::ToSocketAddrs; #[no_mangle] pub extern "C" fn resolve_test() -> () { let addr_list = ("google.com.au", 0).to_socket_addrs().unwrap(); println!("{:?}", addr_list); } > rustc --crate-type=staticlib main.rs > clang libmain.a test.c -o combined Undefined symbols for architecture x86_64: "_res_9_init", referenced from: std::net::lookup_host::h93c17fe9ad38464a in libmain.a(std-826c8d3b356e180c.std0.rcgu.o) ld: symbol(s) not found for architecture x86_64 clang-5.0: error: linker command failed with exit code 1 (use -v to see invocation) ``` Afterwards: ```shell > rustc --crate-type=staticlib main.rs > clang libmain.a test.c -o combined > ./combined IntoIter([V4(172.217.25.131:0)]) ``` Fixes #46797
2018-01-21NonNull ended up landing in 1.25Simon Sapin-1/+1
2018-01-20Rollup merge of #47578 - arthurprs:btree-doc, r=alexcrichtonGuillaume Gomez-2/+2
Update BTreeMap recommendation Focus on the ordering / range(instead of all) benefit as it's the most important feature.
2018-01-20Rollup merge of #47532 - tbu-:pr_path_oddities, r=TimNNGuillaume Gomez-0/+7
Add some edge cases to the documentation of `Path` Affected methods are `starts_with` and `strip_prefix`.
2018-01-20Rollup merge of #47510 - sfackler:deprecate-dns, r=alexcrichtonGuillaume Gomez-1/+11
Deprecate std::net::lookup_host We intended to do this quite a while ago but it snuck through. r? @alexcrichton
2018-01-20Auto merge of #46980 - ↵bors-2/+2
zackmdavis:and_the_case_of_the_needlessly_parenthesized_arguments, r=petrochenkov in which the unused-parens lint comes to cover function and method args Resolves #46137.
2018-01-20Stabilize std::ptr::NonNullSimon Sapin-2/+1
2018-01-20Mark Unique as perma-unstable, with the feature renamed to ptr_internals.Simon Sapin-2/+2
2018-01-20Rename std::ptr::Shared to NonNullSimon Sapin-7/+7
`Shared` is now a deprecated `type` alias. CC https://github.com/rust-lang/rust/issues/27730#issuecomment-352800629
2018-01-19Update BTreeMap recommendationArthur Silva-2/+2
Focus on the ordering/range benefit.
2018-01-18in which the unused-parens lint comes to cover function and method argsZack M. Davis-2/+2
Resolves #46137.
2018-01-17Deprecate std::net::lookup_hostSteven Fackler-1/+11
We intended to do this quite a while ago but it snuck through.
2018-01-18Add some edge cases to the documentation of `Path`Tobias Bucher-0/+7
Affected methods are `starts_with` and `strip_prefix`.
2018-01-17Rollup merge of #47520 - mbrubeck:fstat, r=Mark-SimulacrumGuillaume Gomez-7/+9
Use File::metadata instead of fs::metadata to choose buffer size This replaces a `stat` syscall with `fstat` or similar, which can be faster. Fixes #47519.
2018-01-17Use File::metadata instead of fs::metadata to choose buffer sizeMatt Brubeck-7/+9
This replaces a `stat` syscall with `fstat` or similar, which can be faster. Fixes #47519.
2018-01-16Only link res_init() on GNU/*nixRyan Cumming-32/+16
To workaround a bug in glibc <= 2.26 lookup_host() calls res_init() based on the glibc version detected at runtime. While this avoids calling res_init() on platforms where it's not required we will still end up linking against the symbol. This causes an issue on macOS where res_init() is implemented in a separate library (libresolv.9.dylib) from the main libc. While this is harmless for standalone programs it becomes a problem if Rust code is statically linked against another program. If the linked program doesn't already specify -lresolv it will cause the link to fail. This is captured in issue #46797 Fix this by hooking in to the glibc workaround in `cvt_gai` and only activating it for the "gnu" environment on Unix This should include all glibc platforms while excluding musl, windows-gnu, macOS, FreeBSD, etc. This has the side benefit of removing the #[cfg] in sys_common; only unix.rs has code related to the workaround now.
2018-01-15Reexport -> re-export in prose and documentation commentsCarol (Nichols || Goulding)-8/+8
2018-01-15Rollup merge of #47443 - FenrirWolf:rand, r=alexcrichtonkennytm-108/+0
Remove leftover Rand stuff The in-tree version of `rand` was removed in 6bc8f164b09b9994e6a2d4c4ca60d7d36c09d3fe, but for some reason this lone file avoided the purge. Figured it's about time to finish the job. :smiling_imp:
2018-01-15Rollup merge of #47330 - bmusin:patch-2, r=shepmasterkennytm-4/+4
fix off-by-one error Fixes https://github.com/rust-lang/rust/issues/47325.
2018-01-15Rollup merge of #47277 - tspiteri:log-correctness, r=frewsxcvkennytm-18/+16
doc: show that `f32::log` and `f64::log` are not correctly rounded Fixes #47273. One thing I'm not sure about is whether the "calculated as `self.ln() / base.ln()`" bit is being too specific, maybe we do not want to make this such a strong commitment. I think it's fine, but we should not make commitments in the API documentation by accident. In case that is removed, the added sentence "`self.log2()` can ... base 10." still makes it amply clear that the `log` methods can be more inaccurate than other methods. If the above clause is removed, this second sentence can be moved to the first paragraph, kind of like the accuracy comment for the [`mul_add`](https://doc.rust-lang.org/std/primitive.f32.html#method.mul_add) method.
2018-01-15Rollup merge of #47120 - clarcharr:io_error_debug, r=dtolnaykennytm-8/+35
Better Debug impl for io::Error. This PR includes the below changes: 1. The former impl wrapped the entire thing in `Error { repr: ... }` which was unhelpful; this has been removed. 2. The `Os` variant of `io::Error` included the code and message, but not the kind; this has been fixed. 3. The `Custom` variant of `io::Error` included a `Custom(Custom { ... })`, which is now just `Custom { ... }`. Example of previous impl: ```rust Error { repr: Custom( Custom { kind: InvalidData, error: Error { repr: Os { code: 2, message: "no such file or directory" } } } ) } ``` Example of new impl: ```rust Custom { kind: InvalidData, error: Os { code: 2, kind: NotFound, message: "no such file or directory" } } ```
2018-01-14Remove leftover Rand stuffFenrir-108/+0
2018-01-14Auto merge of #47268 - EdSchouten:cloudabi-libstd, r=alexcrichtonbors-12/+5055
Implement libstd for CloudABI. Though CloudABI is strongly inspired by POSIX, its absence of features that don't work well with capability-based sandboxing makes it different enough that adding bits to `sys/unix` will make things a mess. This change therefore adds CloudABI specific platform code under `sys/cloudabi`. One of the goals of this implementation is to build as much as possible directly on top of CloudABI's system call layer, as opposed to using the C library. This is preferred, as the system call layer is supposed to be stable, whereas the C library ABI technically is not. An advantage of this approach is that it allows us to implement certain interfaces, such as mutexes and condition variables more optimally. They can be lighter than the ones provided by pthreads. This change disables some modules that cannot realistically be implemented right now. For example, libstd's pathname abstraction is not designed with POSIX `*at()` (e.g., `openat()`) in mind. The `*at()` functions are the only set of file system APIs available on CloudABI. There is no global file system namespace, nor a process working directory. Discussions on how to port these modules over are outside the scope of this change.
2018-01-14Auto merge of #46832 - Diggsey:bufread-cheaper-seek, r=alexcrichtonbors-0/+46
BufRead: Only flush the internal buffer if seeking outside of it. Fixes #31100 r? @dtolnay
2018-01-13Add note to documentationDiggory Blake-0/+4
2018-01-13Implement "seek_relative"Diggory Blake-0/+42
2018-01-13Better Debug impl for io::Error.Clar Charr-8/+35
2018-01-13Adjust tests for removal of `impl Foo for .. {}`leonardo.yvens-2/+2
2018-01-13Remove `impl Foo for ..` in favor of `auto trait Foo`leonardo.yvens-9/+2
No longer parse it. Remove AutoTrait variant from AST and HIR. Remove backwards compatibility lint. Remove coherence checks, they make no sense for the new syntax. Remove from rustdoc.
2018-01-13fix off-by-one errorBulat Musin-4/+4
2018-01-13Auto merge of #46461 - zackmdavis:elemental_method_suggestion_jamboree, ↵bors-1/+2
r=estebank type error method suggestions use whitelisted identity-like conversions ![method_jamboree_summit](https://user-images.githubusercontent.com/1076988/33523646-e5c43184-d7c0-11e7-98e5-1bff426ade86.png) Previously, on a type mismatch (and if this wasn't preëmpted by a higher-priority suggestion), we would look for argumentless methods returning the expected type, and list them in a `help` note. This had two major shortcomings: firstly, a lot of the suggestions didn't really make sense (if you used a &str where a String was expected, `.to_ascii_uppercase()` is probably not the solution you were hoping for). Secondly, we weren't generating suggestions from the most useful traits! We address the first problem with an internal `#[rustc_conversion_suggestion]` attribute meant to mark methods that keep the "same value" in the relevant sense, just converting the type. We address the second problem by making `FnCtxt.probe_for_return_type` pass the `ProbeScope::AllTraits` to `probe_op`: this would seem to be safe because grep reveals no other callers of `probe_for_return_type`. Also, structured suggestions are pretty and good for RLS and friends. Unfortunately, the trait probing is still not all one would hope for: at a minimum, we don't know how to rule out `into()` in cases where it wouldn't actually work, and we don't know how to rule in `.to_owned()` where it would. Issues #46459 and #46460 have been filed and are ref'd in a FIXME. This is hoped to resolve #42929, #44672, and #45777.
2018-01-13Rollup merge of #47375 - overvenus:duration-examples, r=dtolnaykennytm-2/+2
Fix examples of Duration::subsec_millis and Duration::subsec_micros Update examples of `Duration::subsec_millis` and `Duration::subsec_micros`, because they are not for these two methods actually.
2018-01-13Rollup merge of #47357 - whentze:osstr-doc-fix, r=GuillaumeGomezkennytm-2/+5
Fix docs for OsStr At present, there are two small issues with the [docs](https://doc.rust-lang.org/std/ffi/struct.OsStr.html) for std::ffi::OsStr: - The docs say "OsStr is to OsString as String is to &str: the former in each pair are borrowed references; the latter are owned strings.". The latter pair is mixed up: String is the owned variant whereas &str is the borrowed reference. - The doc links to String and &str are broken and render as [String] and [&str]. This PR fixes these issues.
2018-01-13Rollup merge of #47340 - alercah:typo-fix, r=GuillaumeGomezkennytm-1/+1
Fix typo.
2018-01-13Rollup merge of #47324 - mbrubeck:len, r=sfacklerkennytm-2/+10
Pre-allocate in fs::read and fs::read_string This is a simpler alternative to #46340 and #45928, as requested by the libs team.
2018-01-13Rollup merge of #47310 - bmusin:patch-1, r=sfacklerkennytm-1/+1
fix typo rwlock.rs Hi. Fixed typo: contained -> content
2018-01-13Rollup merge of #46985 - Diggsey:path-component-asref, r=alexcrichtonkennytm-0/+7
Implement AsRef<Path> for Component Fixes #41866
2018-01-12Fix Duration::subsec_millis and Duration::subsec_micros examplesNeil Shen-2/+2