Commit Graph

908 Commits

Author SHA1 Message Date
Simon Sapin 8c30c51686 Remove deprecated heap modules
The heap.rs file was already unused.
2018-06-11 13:47:27 -07:00
bors 1d4dbf488a Auto merge of #51442 - tinaun:more-future-impls, r=cramertj
[futures] add a few blanket impls to std

these were defined in the futures crate, but with the core definitions moving to std these would need to move too.
2018-06-11 20:14:39 +00:00
CrLF0710 02c96d4733
Add #[doc(inline)] in std::task
Add #[doc(inline)] in `std::task` to make the doc seem right.
2018-06-11 03:09:30 +08:00
tinaun 6e5c18e8dc add a few blanket future impls to std 2018-06-08 17:56:59 -04:00
bors 19d0b539aa Auto merge of #51263 - cramertj:futures-in-core, r=aturon
Add Future and task system to the standard library

This adds preliminary versions of the `std::future` and `std::task` modules in order to unblock development of async/await (https://github.com/rust-lang/rust/issues/50547). These shouldn't be considered as final forms of these libraries-- design questions about the libraries should be left on https://github.com/rust-lang/rfcs/pull/2418. Once that RFC (or a successor) is merged, these APIs will be adjusted as necessary.

r? @aturon
2018-06-06 19:42:19 +00:00
Taylor Cramer a6055c8859 Add Future and task system to the standard library 2018-06-06 10:41:52 -07:00
Guillaume Gomez ded5c5a9ee Put doc keyword behind feature flag 2018-06-04 09:52:31 +02:00
Jorge Aparicio e44ad61a2d implement #[panic_implementation] 2018-06-03 13:46:19 +02:00
Mark Simulacrum 9e3432447a Switch to 1.26 bootstrap compiler 2018-05-17 08:47:25 -06:00
Simon Sapin 89d9ca9b50 Stabilize num::NonZeroU*
Tracking issue: https://github.com/rust-lang/rust/issues/49137
2018-05-16 19:11:31 +02:00
kennytm 02f6a0335f
Some final touches to ensure `./x.py test --stage 0 src/lib*` works 2018-05-06 02:34:07 +08:00
Vadim Petrochenkov 730c7222ee Fix an error from "unused" lint + Fix rebase 2018-05-01 17:02:18 +03:00
Vadim Petrochenkov 300b6bb417 Remove `macro_reexport`
It's subsumed by `feature(use_extern_macros)` and `pub use`
2018-05-01 15:58:42 +03:00
kennytm f28f5aa0b2
Rollup merge of #49906 - kennytm:stable-unreachable, r=sfackler
Stabilize `std::hint::unreachable_unchecked`.

Closes #43751.
2018-04-24 11:57:04 +08:00
Steven Fackler e513c1bd31 Replace GlobalAlloc::oom with a lang item 2018-04-22 10:08:17 -07:00
bors bbdd1cf744 Auto merge of #49757 - GuillaumeGomez:never-search, r=QuietMisdreavus
Add specific never search

Fixes #49529.

r? @QuietMisdreavus
2018-04-22 02:18:41 +00:00
bors d5616e1f18 Auto merge of #49896 - SimonSapin:inherent, r=alexcrichton
Add inherent methods in libcore for [T], [u8], str, f32, and f64

# Background

Primitive types are defined by the language, they don’t have a type definition like `pub struct Foo { … }` in any crate. So they don’t “belong” to any crate as far as `impl` coherence is concerned, and on principle no crate would be able to define inherent methods for them, without a trait. Since we want these types to have inherent methods anyway, the standard library (with cooperation from the compiler) bends this rule with code like [`#[lang = "u8"] impl u8 { /*…*/ }`](https://github.com/rust-lang/rust/blob/1.25.0/src/libcore/num/mod.rs#L2244-L2245). The `#[lang]` attribute is permanently-unstable and never intended to be used outside of the standard library.

Each lang item can only be defined once. Before this PR there is one impl-coherence-rule-bending lang item per primitive type (plus one for `[u8]`, which overlaps with `[T]`). And so one `impl` block each. These blocks for `str`, `[T]` and `[u8]` are in liballoc rather than libcore because *some* of the methods (like `<[T]>::to_vec(&self) -> Vec<T> where T: Clone`) need a global memory allocator which we don’t want to make a requirement in libcore. Similarly, `impl f32` and `impl f64` are in libstd because some of the methods are based on FFI calls to C’s `libm` and we want, as much as possible, libcore not to require “runtime support”.

In libcore, the methods of `str` and `[T]` that don’t allocate are made available through two **unstable traits** `StrExt` and `SliceExt` (so the traits can’t be *named* by programs on the Stable release channel) that have **stable methods** and are re-exported in the libcore prelude (so that programs on Stable can *call* these methods anyway). Non-allocating `[u8]` methods are not available in libcore: https://github.com/rust-lang/rust/issues/45803. Some `f32` and `f64` methods are in an unstable `core::num::Float` trait with stable methods, but that one is **not in the libcore prelude**. (So as far as Stable programs are concerns it doesn’t exist, and I don’t know what the point was to mark these methods `#[stable]`.)

https://github.com/rust-lang/rust/issues/32110 is the tracking issue for these unstable traits.

# High-level proposal

Since the standard library is already bending the rules, why not bend them *a little more*? By defining a few additional lang items, the compiler can allow the standard library to have *two* `impl` blocks (in different crates) for some primitive types.

The `StrExt` and `SliceExt` traits still exist for now so that we can bootstrap from a previous-version compiler that doesn’t have these lang items yet, but they can be removed in next release cycle. (`Float` is used internally and needs to be public for libcore unit tests, but was already `#[doc(hidden)]`.) I don’t know if https://github.com/rust-lang/rust/issues/32110 should be closed by this PR, or only when the traits are entirely removed after we make a new bootstrap compiler.

# Float methods

Among the methods of the `core::num::Float` trait, three are based on LLVM intrinsics: `abs`, `signum`, and `powi`. PR https://github.com/rust-lang/rust/pull/27823 “Remove dependencies on libm functions from libcore” moved a bunch of `core::num::Float` methods back to libstd, but left these three behind. However they aren’t specifically discussed in the PR thread. The `compiler_builtins` crate defines `__powisf2` and `__powidf2` functions that look like implementations of `powi`, but I couldn’t find a connection with the `llvm.powi.f32` and `llvm.powi.f32` intrinsics by grepping through LLVM’s code.

In discussion starting at https://github.com/rust-lang/rust/issues/32110#issuecomment-370647922 Alex says that we do not want methods in libcore that require “runtime support”, but it’s not clear whether that applies to these `abs`, `signum`, or `powi`. In doubt, I’ve **removed** them for the trait and moved them to inherent methods in libstd for now. We can move them back later (or in this PR) if we decide that’s appropriate.

# Change details

For users on the Stable release channel:

* I believe this PR does not make any breaking change
* Some methods for `[u8]`, `f32`, and `f64` are newly available to `#![no_std]` users (fixes https://github.com/rust-lang/rust/issues/45803)
* There should be no visible change for `std` users in terms of what programs compile or what their behavior is. (Only in compiler error messages, possibly.)

For Nightly users, additionally:

* The unstable `StrExt` and `SliceExt` traits are gone
* Their methods are now inherent methods of `str` and `[T]` (so only code that explicitly named the traits should be affected, not "normal" method calls)
* The `abs`, `signum` and `powi` methods of the `Float` trait are gone
* The `Float` trait’s unstable feature name changed to `float_internals` with no associated tracking issue, to reflect it being a permanently unstable implementation detail rather than a public API on a path to stabilization.
* Its remaining methods are now inherent methods of `f32` and `f64`.

-----

CC @rust-lang/libs for the API changes, @rust-lang/compiler for the new lang items
2018-04-22 00:01:29 +00:00
Guillaume Gomez 57bcabc108 Generate alias file 2018-04-21 22:02:53 +02:00
Simon Sapin 70fdd1b5c0 Make the unstable StrExt and SliceExt traits private to libcore in not(stage0)
`Float` still needs to be public for libcore unit tests.
2018-04-21 09:47:38 +02:00
Felix S. Klock II d141fdc3bf Revert "Stabilize the TryFrom and TryInto traits"
This reverts commit e53a2a7274.
2018-04-20 18:10:00 +02:00
Felix S. Klock II fadabd6fbb Revert stabilization of `feature(never_type)`.
This commit is just covering the feature gate itself and the tests
that made direct use of `!` and thus need to opt back into the
feature.

A follow on commit brings back the other change that motivates the
revert: Namely, going back to the old rules for falling back to `()`.
2018-04-20 18:09:28 +02:00
bors ac3c2288f9 Auto merge of #50017 - tinaun:stabilize-all-the-things, r=sfackler
stabilize a bunch of minor api additions

besides `ptr::NonNull::cast` (which is 4 days away from end of FCP) all of these have been finished with FCP for a few weeks now with minimal issues raised

* Closes #41020
* Closes #42818
* Closes #44030
* Closes #44400
* Closes #46507
* Closes #47653
* Closes #46344

the following functions will be stabilized in 1.27:
* `[T]::rsplit`
* `[T]::rsplit_mut`
* `[T]::swap_with_slice`
* `ptr::swap_nonoverlapping`
* `NonNull::cast`
* `Duration::from_micros`
* `Duration::from_nanos`
* `Duration::subsec_millis`
* `Duration::subsec_micros`
* `HashMap::remove_entry`
2018-04-18 19:47:56 +00:00
bors 8728c7a726 Auto merge of #49542 - GuillaumeGomez:intra-link-resolution-error, r=GuillaumeGomez
Add warning if a resolution failed

r? @QuietMisdreavus
2018-04-17 09:02:03 +00:00
tinaun b84baf2378 stabilize `nonnull_cast` feature 2018-04-17 01:22:28 -04:00
bors 186db76159 Auto merge of #49664 - alexcrichton:stable-simd, r=BurntSushi
Stabilize x86/x86_64 SIMD

This commit stabilizes the SIMD in Rust for the x86/x86_64 platforms. Notably
this commit is stabilizing:

* The `std::arch::{x86, x86_64}` modules and the intrinsics contained inside.
* The `is_x86_feature_detected!` macro in the standard library
* The `#[target_feature(enable = "...")]` attribute
* The `#[cfg(target_feature = "...")]` matcher

Stabilization of the module and intrinsics were primarily done in
rust-lang-nursery/stdsimd#414 and the two attribute stabilizations are done in
this commit. The standard library is also tweaked a bit with the new way that
stdsimd is integrated.

Note that other architectures like `std::arch::arm` are not stabilized as part
of this commit, they will likely stabilize in the future after they've been
implemented and fleshed out. Similarly the `std::simd` module is also not being
stabilized in this commit, only `std::arch`. Finally, nothing related to `__m64`
is stabilized in this commit either (MMX), only SSE and up types and intrinsics
are stabilized.

Closes #29717
Closes #44839
Closes #48556
2018-04-17 03:57:22 +00:00
Guillaume Gomez b2192ae157 Add rustdoc-ui test suite 2018-04-16 23:37:11 +02:00
Alex Crichton 598d836fff Stabilize x86/x86_64 SIMD
This commit stabilizes the SIMD in Rust for the x86/x86_64 platforms. Notably
this commit is stabilizing:

* The `std::arch::{x86, x86_64}` modules and the intrinsics contained inside.
* The `is_x86_feature_detected!` macro in the standard library
* The `#[target_feature(enable = "...")]` attribute
* The `#[cfg(target_feature = "...")]` matcher

Stabilization of the module and intrinsics were primarily done in
rust-lang-nursery/stdsimd#414 and the two attribute stabilizations are done in
this commit. The standard library is also tweaked a bit with the new way that
stdsimd is integrated.

Note that other architectures like `std::arch::arm` are not stabilized as part
of this commit, they will likely stabilize in the future after they've been
implemented and fleshed out. Similarly the `std::simd` module is also not being
stabilized in this commit, only `std::arch`. Finally, nothing related to `__m64`
is stabilized in this commit either (MMX), only SSE and up types and intrinsics
are stabilized.

Closes #29717
Closes #44839
Closes #48556
2018-04-16 07:25:10 -07:00
kennytm 5fe8c59f12
Stabilize core::hint::unreachable_unchecked.
Closes #43751.
2018-04-16 18:29:40 +08:00
Alex Crichton c3a5d6b130 std: Minimize size of panicking on wasm
This commit applies a few code size optimizations for the wasm target to
the standard library, namely around panics. We notably know that in most
configurations it's impossible for us to print anything in
wasm32-unknown-unknown so we can skip larger portions of panicking that
are otherwise simply informative. This allows us to get quite a nice
size reduction.

Finally we can also tweak where the allocation happens for the
`Box<Any>` that we panic with. By only allocating once unwinding starts
we can reduce the size of a panicking wasm module from 44k to 350 bytes.
2018-04-13 07:03:00 -07:00
Mike Hommey fddf51ee0b Use NonNull<Void> instead of *mut u8 in the Alloc trait
Fixes #49608
2018-04-12 22:53:22 +02:00
Simon Sapin 743c29bdc5 Actually deprecate heap modules. 2018-04-12 22:52:47 +02:00
Simon Sapin 09e8db1e4f Rename `heap` modules in the core, alloc, and std crates to `alloc` 2018-04-12 22:52:47 +02:00
Simon Sapin 1b895d8b88 Import the `alloc` crate as `alloc_crate` in std
… to make the name `alloc` available.
2018-04-12 22:52:47 +02:00
Simon Sapin ef41788cf3 Mark the rest of the `unicode` feature flag as perma-unstable. 2018-04-12 00:13:53 +02:00
Simon Sapin 939692409d Reexport from core::unicode::char in core::char rather than vice versa 2018-04-12 00:13:52 +02:00
Simon Sapin b2027ef17c Deprecate the std_unicode crate 2018-04-12 00:13:51 +02:00
Mark Simulacrum c115cc655c Move deny(warnings) into rustbuild
This permits easier iteration without having to worry about warnings
being denied.

Fixes #49517
2018-04-08 16:59:14 -06:00
bors 8c2d7b2da3 Auto merge of #49661 - alexcrichton:bump-bootstrap, r=nikomatsakis
Bump the bootstrap compiler to 1.26.0 beta

Holy cow that's a lot of `cfg(stage0)` removed and a lot of new stable language
features!
2018-04-07 11:58:38 +00:00
Oliver Schneider 679657b863
Inject the `compiler_builtins` crate whenever the `core` crate is injected 2018-04-07 09:24:35 +02:00
Alex Crichton 71bf15c6e8 Rollup merge of #49686 - memoryleak47:typo, r=alexcrichton
typos
2018-04-05 11:18:17 -07:00
Alex Crichton 8958815916 Bump the bootstrap compiler to 1.26.0 beta
Holy cow that's a lot of `cfg(stage0)` removed and a lot of new stable language
features!
2018-04-05 07:13:45 -07:00
memoryleak47 64ddb390ef typos 2018-04-05 13:04:00 +02:00
Vadim Petrochenkov 1a2a23447e Stabilize attributes on generic parameters 2018-04-05 02:19:56 +03:00
Aidan Hobson Sayers 9b5859aea1 Remove all unstable placement features
Closes #22181, #27779
2018-04-03 11:02:34 +02:00
kennytm 010fb40b44
Rollup merge of #49400 - Diggsey:shrink-to, r=joshtriplett
Implement `shrink_to` method on collections

Fixes #49385
2018-03-28 17:55:09 +02:00
Diggory Blake 04f6692aaf Implement `shrink_to` method on collections 2018-03-27 01:39:11 +01:00
Simon Sapin e53a2a7274 Stabilize the TryFrom and TryInto traits
Tracking issue: https://github.com/rust-lang/rust/issues/33417
2018-03-26 23:36:02 +02:00
Mark Mansi db7d9ea480 Stabilize i128 feature too 2018-03-26 08:37:56 -05:00
Mark Mansi 7ce8191775 Stabilize i128_type 2018-03-26 08:36:50 -05:00
kennytm 8d57071cbb
Rollup merge of #49162 - tmandry:stabilize-termination-trait, r=nikomatsakis
Stabilize termination_trait, split out termination_trait_test

For #48453.

First time contribution, so I'd really appreciate any feedback on how this PR can be better.

Not sure exactly what kind of documentation update is needed. If there is no PR to update the reference, I can try doing that this week as I have time.
2018-03-25 01:26:32 +08:00
Alex Crichton 7cf4cb5a7b
Rollup merge of #48265 - SimonSapin:nonzero, r=KodrAus
Add 12 num::NonZero* types for primitive integers, deprecate core::nonzero

RFC: https://github.com/rust-lang/rfcs/pull/2307
Tracking issue: ~~https://github.com/rust-lang/rust/issues/27730~~ https://github.com/rust-lang/rust/issues/49137
Fixes https://github.com/rust-lang/rust/issues/27730
2018-03-23 09:27:06 -05:00
Tyler Mandry 97b3bf99f6 Stabilize termination_trait
This stabilizes `main` with non-() return types; see #48453.
2018-03-19 01:31:04 -05:00
Simon Sapin f40877feeb Add 12 num::NonZero* types for each primitive integer
RFC: https://github.com/rust-lang/rfcs/pull/2307
2018-03-17 23:07:38 +01:00
Simon Sapin 89ecb0d542 Mark deprecated unstable SipHasher13 as a doc-hidden impl detail of HashMap.
It stays in libcore rather than being private in HashMap’s module
because it shares code with the deprecated *stable* `SipHasher` type.
2018-03-17 13:04:13 +01:00
bors 5f3996c3ec Auto merge of #48813 - sinkuu:build_in_assert_macro, r=alexcrichton
Make `assert` a built-in procedural macro

Makes `assert` macro a built-in one without touching its functionality. This is a prerequisite for RFC 2011 (#44838).
2018-03-16 08:22:11 +00:00
bors 3926453944 Auto merge of #47813 - kennytm:stable-incl-range, r=nrc
Stabilize inclusive range (`..=`)

Stabilize the followings:

* `inclusive_range` — The `std::ops::RangeInclusive` and `std::ops::RangeInclusiveTo` types, except its fields (tracked by #49022 separately).
* `inclusive_range_syntax` — The `a..=b` and `..=b` expression syntax
* `dotdoteq_in_patterns` — Using `a..=b` in a pattern

cc #28237
r? @rust-lang/lang
2018-03-15 16:00:40 +00:00
kennytm b5913f2e76
Stabilize `inclusive_range` library feature.
Stabilize std::ops::RangeInclusive and std::ops::RangeInclusiveTo.
2018-03-15 16:58:01 +08:00
bors a4af6f089b Auto merge of #48648 - snf:fallible_allocation, r=Kimundi
Fallible allocation

Implementing RFC#2116 [Fallible Allocation](https://github.com/rust-lang/rust/issues/48043) .
Work in progress. Initially adding @Gankro's try_reserve for Vec.
2018-03-15 08:18:58 +00:00
snf 92bfcd2b19 implementing fallible allocation API (try_reserve) for Vec, String and HashMap 2018-03-14 03:48:42 -07:00
Andrew Cann a9fc3901b0 stabilise feature(never_type)
Replace feature(never_type) with feature(exhaustive_patterns).
feature(exhaustive_patterns) only covers the pattern-exhaustives checks
that used to be covered by feature(never_type)
2018-03-14 12:44:51 +08:00
Shotaro Yamada 517083fbad Make `assert` macro a built-in procedural macro 2018-03-07 17:22:58 +09:00
kennytm 8e3493d459
Rollup merge of #47463 - bluss:fused-iterator, r=alexcrichton
Stabilize FusedIterator

FusedIterator is a marker trait that promises that the implementing
iterator continues to return `None` from `.next()` once it has returned
`None` once (and/or `.next_back()`, if implemented).

The effects of FusedIterator are already widely available through
`.fuse()`, but with stable `FusedIterator`, stable Rust users can
implement this trait for their iterators when appropriate.

Closes #35602
2018-03-06 20:52:37 +08:00
Ulrik Sverdrup bc651cac8d core: Stabilize FusedIterator
FusedIterator is a marker trait that promises that the implementing
iterator continues to return `None` from `.next()` once it has returned
`None` once (and/or `.next_back()`, if implemented).

The effects of FusedIterator are already widely available through
`.fuse()`, but with stable `FusedIterator`, stable Rust users can
implement this trait for their iterators when appropriate.
2018-03-03 14:14:03 +01:00
Alex Crichton c72537f204 std: Add `arch` and `simd` modules
This commit imports the `stdsimd` crate into the standard library,
creating an `arch` and `simd` module inside of both libcore and libstd.
Both of these modules are **unstable** and will continue to be so until
RFC 2335 is stabilized.

As a brief recap, the modules are organized as so:

* `arch` contains all current architectures with intrinsics, for example
  `std::arch::x86`, `std::arch::x86_64`, `std::arch::arm`, etc. These
  modules contain all of the intrinsics defined for the platform, like
  `_mm_set1_epi8`.
* In the standard library, the `arch` module also exports a
  `is_target_feature_detected` macro which performs runtime detection to
  determine whether a target feature is available at runtime.
* The `simd` module contains experimental versions of strongly-typed
  lane-aware SIMD primitives, to be fully fleshed out in a future RFC.

The main purpose of this commit is to start pulling in all these
intrinsics and such into the standard library on nightly and allow
testing and such. This'll help allow users to easily kick the tires and
see if intrinsics work as well as allow us to test out all the
infrastructure for moving the intrinsics into the standard library.
2018-03-02 14:34:07 -08:00
Manish Goregaokar b52b33a386 Rollup merge of #48143 - nikomatsakis:termination_trait_in_tests, r=eddyb
Termination trait in tests

Support the `Termination` trait in unit tests (cc https://github.com/rust-lang/rust/issues/43301)

Also, a drive-by fix for #47075.

This is joint work with @bkchr.
2018-02-24 12:47:58 -08:00
Niko Matsakis 5f1e78f19a move Termination trait to std::process 2018-02-22 17:57:08 -05:00
Niko Matsakis e446f706a8 put the "unit test" logic into libtest
Also make `std::termination` module public and rename feature.

The lib feature needs a different name from the language feature.
2018-02-22 17:56:24 -05:00
Mark Simulacrum 33f5ceee1f stage0 cfg cleanup 2018-02-20 08:52:33 -07:00
bors 1ad094d81c Auto merge of #47687 - SimonSapin:panic-impl, r=sfackler
RFC 2070 part 1: PanicInfo and Location API changes

This implements part of https://rust-lang.github.io/rfcs/2070-panic-implementation.html
Tracking issue: https://github.com/rust-lang/rust/issues/44489

* Move `std::panic::PanicInfo` and `std::panic::Location` to a new `core::panic` module. The two types and the `std` module were already `#[stable]` and stay that way, the new `core` module is `#[unstable]`.
* Add a new `PanicInfo::message(&self) -> Option<&fmt::Arguments>` method, which is `#[unstable]`.
* Implement `Display` for `PanicInfo` and `Location`
2018-02-18 06:02:35 +00:00
Clar Charr 1a043533f5 Document std::os::raw. 2018-01-29 17:44:12 -05:00
Simon Sapin 2f98f4b12b Move PanicInfo and Location to libcore
Per https://rust-lang.github.io/rfcs/2070-panic-implementation.html
2018-01-23 16:38:26 +01:00
Cameron Hart 651ea8ea44 Stabilized `#[repr(align(x))]` attribute (RFC 1358) 2018-01-23 08:36:13 +11:00
Simon Sapin 55c50cd8ac Stabilize std::ptr::NonNull 2018-01-20 11:09:23 +01:00
Simon Sapin c97c1f7dc3 Mark Unique as perma-unstable, with the feature renamed to ptr_internals. 2018-01-20 11:09:23 +01:00
Simon Sapin f19baf0977 Rename std::ptr::Shared to NonNull
`Shared` is now a deprecated `type` alias.

CC https://github.com/rust-lang/rust/issues/27730#issuecomment-352800629
2018-01-20 10:55:16 +01:00
Carol (Nichols || Goulding) e168aa385b
Reexport -> re-export in prose and documentation comments 2018-01-15 13:36:53 -05:00
bors 6eff103aa1 Auto merge of #46461 - zackmdavis:elemental_method_suggestion_jamboree, 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-13 02:15:19 +00:00
Robin Kruppe 9e4a692e56 Replace empty array hack with repr(align)
As a side effect, this fixes the warning about repr(C, simd) that has been reported during x86_64 windows builds since #47111 (see also: #47103)
2018-01-07 20:25:37 +01:00
Zack M. Davis aba56ddd05 type error method suggestions use whitelisted identity-like conversions
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 preferred (because they're pretty, but
also for RLS and friends).

Also also, we make the E0055 autoderef recursion limit error use the
one-time-diagnostics set, because we can potentially hit the limit a lot
during probing. (Without this,
test/ui/did_you_mean/recursion_limit_deref.rs would report "aborting due to
51 errors").

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-06 17:15:59 -08:00
bors 8c59418962 Auto merge of #46713 - Manishearth:memchr, r=bluss
Use memchr to speed up [u8]::contains 3x

None
2017-12-31 16:38:10 +00:00
Bastian Köcher c7a57d2855 Adds termination_trait feature gate 2017-12-26 12:26:39 +01:00
Bastian Köcher d7918fb2e8 Implements RFC 1937: `?` in `main`
This is the first part of the RFC 1937 that supports new
`Termination` trait in the rust `main` function.
2017-12-26 12:26:39 +01:00
Manish Goregaokar 2bf0df777b Move rust memchr impl to libcore 2017-12-13 01:15:18 -06:00
bors c7b6d8263b Auto merge of #45837 - SimonSapin:file_read_write, r=dtolnay
Add read, read_string, and write functions to std::fs

New APIs in `std::fs`:

```rust
pub fn read<P: AsRef<Path>>(path: P) -> io::Result<Vec<u8>> { … }
pub fn read_string<P: AsRef<Path>>(path: P) -> io::Result<String> { … }
pub fn write<P: AsRef<Path>, C: AsRef<[u8]>>(path: P, contents: C) -> io::Result<()> { ... }
```

(`read_string` is based on `read_to_string` and so returns an error on non-UTF-8 content.)

Before:

```rust
use std::fs::File;
use std::io::Read;

let mut bytes = Vec::new();
File::open(filename)?.read_to_end(&mut bytes)?;
do_something_with(bytes)
```

After:

```rust
use std::fs;

do_something_with(fs::read(filename)?)
```
2017-12-08 21:33:50 +00:00
Simon Sapin 6c5f53e65e Stabilize const-calling existing const-fns in std
Fixes #46038
2017-11-26 23:43:44 +01:00
Alex Crichton 95e9609b9d std: Flag Windows TLS dtor symbol as #[used]
Turns out ThinLTO was internalizing this symbol and eliminating it. Worse yet if
you compiled with LTO turns out no TLS destructors would run on Windows! The
`#[used]` annotation should be a more bulletproof implementation (in the face of
LTO) of preserving this symbol all the way through in LLVM and ensuring it makes
it all the way to the linker which will take care of it.
2017-11-24 14:28:12 -08:00
QuietMisdreavus 831fd78341 add doc_highlight feature flag and tests 2017-11-17 22:50:15 +01:00
Alex Crichton 6bc8f164b0 std: Remove `rand` crate and module
This commit removes the `rand` crate from the standard library facade as
well as the `__rand` module in the standard library. Neither of these
were used in any meaningful way in the standard library itself. The only
need for randomness in libstd is to initialize the thread-local keys of
a `HashMap`, and that unconditionally used `OsRng` defined in the
standard library anyway.

The cruft of the `rand` crate and the extra `rand` support in the
standard library makes libstd slightly more difficult to port to new
platforms, namely WebAssembly which doesn't have any randomness at all
(without interfacing with JS). The purpose of this commit is to clarify
and streamline randomness in libstd, focusing on how it's only required
in one location, hashmap seeds.

Note that the `rand` crate out of tree has almost always been a drop-in
replacement for the `rand` crate in-tree, so any usage (accidental or
purposeful) of the crate in-tree should switch to the `rand` crate on
crates.io. This then also has the further benefit of avoiding
duplication (mostly) between the two crates!
2017-11-08 20:41:17 -08:00
Simon Sapin c670424cbe Move `File::{read,write}_contents` to `fs::{read,write}` free functions. 2017-11-07 18:42:06 +01:00
Simon Sapin fd518ac4b0 Add File::read_contents and File::write_contents convenience functions.
Before:

```rust
use std::fs::File;
use std::io::Read;

let mut bytes = Vec::new();
File::open(filename)?.read_to_end(&mut bytes)?;
do_something_with(bytes)
```

After:

```rust
use std::fs::File;

do_something_with(File::read_contents(filename)?)
```
2017-11-07 17:52:07 +01:00
Lukas Kalbertodt 259c125267 Mark several ascii methods as unstable again
We don't want to stabilize them now already. The goal of this set of
commits is just to add inherent methods to the four types. Stabilizing
all of those methods can be done later.
2017-11-03 21:28:04 +01:00
bors f3b900cc3b Auto merge of #44764 - nvzqz:master, r=alexcrichton
Implement TryFrom<&[T]> for &[T; N]

There are many cases where a buffer with a static compile-time size is preferred over a slice with a dynamic size. This allows for performing a checked conversion from `&[T]` to `&[T; N]`. This may also lead to compile-time optimizations involving `[T; N]` such as loop unrolling.

This is my first PR to Rust, so I'm not sure if discussion of this change should happen here or does it need its own RFC? I figured these changes would be a subset of #33417.
2017-10-31 23:06:37 +00:00
Alex Crichton ca18537197 Bump to 1.23 and update bootstrap
This commit updates the bootstrap compiler, bumps the version to 1.23, updates
Cargo, updates books, and updates crates.io dependencies
2017-10-26 13:59:18 -07:00
Joshua Lockerman 68341a91ee Improve performance of spsc_queue and stream.
This commit makes two main changes.
1. It switches the spsc_queue node caching strategy from keeping a shared
counter of the number of nodes in the cache to keeping a consumer only counter
of the number of node eligible to be cached.
2. It separate the consumer and producers fields of spsc_queue and stream into
a producer cache line and consumer cache line.
2017-10-01 12:15:35 -04:00
Nikolai Vazquez d9d877221f Enable required features for core::array in libstd 2017-09-29 13:30:03 -04:00
bors 9a00f3cc30 Auto merge of #44026 - QuietMisdreavus:trimmed-std, r=steveklabnik
hide internal types/traits from std docs via new #[doc(masked)] attribute

Fixes #43701 (hopefully for good this time)

This PR introduces a new parameter to the `#[doc]` attribute that rustdoc looks for on `extern crate` statements. When it sees `#[doc(masked)]` on such a statement, it hides traits and types from that crate from appearing in either the "Trait Implementations" section of many type pages, or the "Implementors" section of trait pages. This is then applied to the `libc`/`rand`/`compiler_builtins` imports in libstd to prevent those crates from creating broken links in the std docs.

Like in #43348, this also introduces a feature gate, `doc_masked`, that controls the use of this parameter.

To view the std docs generated with this change, head to https://tonberry.quietmisdreavus.net/std-43701/std/index.html.
2017-09-19 04:20:56 +00:00
Oliver Schneider 2787a285bd
Add `<*const T>::align_offset` and use it in `memchr` 2017-09-17 21:30:58 +02:00
Michal Budzynski 04855950b9 stabilized needs_drop (fixes #41890) 2017-09-16 23:41:04 +02:00
Alex Burka 681e5da61e change #![feature(const_fn)] to specific gates 2017-09-16 15:53:02 +00:00
bors 929b878262 Auto merge of #44438 - Xaeroxe:clamp, r=Mark-Simulacrum
Revert clamp

Revert clamp per https://github.com/rust-lang/rust/issues/44095#issuecomment-328218316 while we take time to assess the potential backwards compatibility damage done by it.
2017-09-09 09:13:03 +00:00
Jacob Kiesel 67283fa8e6 Revert "Add panic unit tests"
This reverts commit b762283e57.
2017-09-08 16:07:09 -06:00
Mark Simulacrum 44351edb64 Rollup merge of #44097 - Xaeroxe:clamp, r=burntsushi
Add clamp functions

Implementation of clamp feature:

Tracking issue: https://github.com/rust-lang/rust/issues/44095
RFC: https://github.com/rust-lang/rfcs/pull/1961
2017-09-06 18:27:45 -06:00
QuietMisdreavus bb6de3c9ce add feature gate doc_masked and tests 2017-09-05 13:51:08 -05:00
QuietMisdreavus c491e195c4 new attribute #[doc(masked)] to hide internal crates from std docs 2017-09-05 13:50:37 -05:00
Jacob Kiesel b762283e57 Add panic unit tests 2017-09-04 21:39:46 -06:00
Alex Crichton 9e5a7e9472 Bring back stage0 allocator logic on MSVC
I think there may still be bugs preventing its removal..
2017-08-31 18:20:52 -07:00
Alex Crichton 7a2a8d7d60 Update Cargo to 0.23.0 and our lockfile 2017-08-31 07:02:50 -07:00
Alex Crichton 9b9de27101 Bump to 1.22.0 2017-08-31 06:58:58 -07:00
Tatsuyuki Ishi bf9bdefe8a Whitelist unwind import in std
This is a part of libbacktrace linkage and thus the compiler cannot detect if it's used or not.
2017-08-27 19:02:24 +09:00
Tatsuyuki Ishi 611b111139 Move unused-extern-crate to late pass 2017-08-27 19:02:24 +09:00
Tamir Duberstein b3f50caee0
*: remove crate_{name,type} attributes
Fixes #41701.
2017-08-25 16:18:21 -04:00
Ruud van Asseldonk e63d979e22 Docs: restore link text after renaming anchor
The text does not need the hyphen, but the anchor name does.
2017-08-13 11:20:52 +02:00
Ruud van Asseldonk 01000fb5c6 Replace space in Markdown link label
With the space, the tidy check does not recognize it as
a link label. See also the comment above in line_is_url()
in src/tools/tidy/src/style.rs.
2017-08-13 11:20:52 +02:00
Ruud van Asseldonk f51e64f7e9 Point "deref coercions" links to new book
Currently the link on doc.rust-lang.org is semi-broken; it links to a
page that links to the exact page in the first edition in the book, or
to the index of the second edition of the book. If the second editions
is the recommended one now, we should point the links at that one. It
seems that in the mean time, the links have been updated to point
directly to the first edition of the book, but that hasn't made it onto
the stable channel yet. By the time this commit makes it onto the stable
channel, the second edition of the book should be complete enough. At
least the part about deref coercions is.
2017-08-13 11:20:52 +02:00
bors 0ed03e5490 Auto merge of #43348 - kennytm:fix-24658-doc-every-platform, r=alexcrichton
Expose all OS-specific modules in libstd doc.

1. Uses the special `--cfg dox` configuration passed by rustbuild when running `rustdoc`. Changes the `#[cfg(platform)]` into `#[cfg(any(dox, platform))]` so that platform-specific API are visible to rustdoc.

2. Since platform-specific implementations often won't compile correctly on other platforms, `rustdoc` is changed to apply `everybody_loops` to the functions during documentation and doc-test harness.

3. Since platform-specific code are documented on all platforms now, it could confuse users who found a useful API but is non-portable. Also, their examples will be doc-tested, so must be excluded when not testing on the native platform. An undocumented attribute `#[doc(cfg(...))]` is introduced to serve the above purposed.

Fixes #24658 (Does _not_ fully implement #1998).
2017-08-13 03:00:20 +00:00
Eduard-Mihai Burtescu 92892d3beb Check #[thread_local] statics correctly in the compiler. 2017-08-12 12:58:07 +03:00
Aidan Hobson Sayers 56a07539c0 Fix cross-crate global allocators on windows 2017-08-10 16:22:09 +01:00
kennytm b4114ebe3a
Exposed all platform-specific documentation. 2017-08-10 13:43:59 +08:00
Aidan Hobson Sayers 458ba7aeb5 Make a disable-jemalloc build work
Fixes #43510
2017-08-07 21:44:02 +01:00
bors ddaab61101 Auto merge of #43373 - alexcrichton:stabilize-1.20.0, r=aturon
Stabilize more APIs for the 1.20.0 release

In addition to the few stabilizations that have already landed, this cleans up the remaining APIs that are in `final-comment-period` right now to be stable by the 1.20.0 release
2017-07-26 23:40:48 +00:00
Alex Crichton 16707d4348 std: Stabilize the `str_{mut,box}_extras` feature
Stabilizes

* `<&mut str>::as_bytes_mut`
* `<Box<str>>::into_boxed_bytes`
* `std::str::from_boxed_utf8_unchecked`
* `std::str::from_utf8_mut`
* `std::str::from_utf8_unchecked_mut`

Closes #41119
2017-07-25 07:10:42 -07:00
Alex Crichton 4c9c6e824b std: Stabilize `char_escape_debug`
Stabilizes:

* `<char>::escape_debug`
* `std::char::EscapeDebug`

Closes #35068
2017-07-25 07:09:31 -07:00
Alex Crichton 9010567dcc Bump master to 1.21.0
This commit bumps the master branch's version to 1.21.0 and also updates the
bootstrap compiler from the freshly minted beta release.
2017-07-25 07:03:19 -07:00
bors 56071f6879 Auto merge of #43055 - est31:stabilize_float_bits_conv, r=sfackler
Stabilize float_bits_conv for Rust 1.21

Stabilizes the `float_bits_conv` lib feature for the 1.20 release of Rust. I've initially implemented the feature in #39271 and later made PR #43025 to output quiet NaNs even on platforms with different encodings, which seems to have been the only unresolved issue of the API.

Due to PR #43025 being only applied to master this stabilisation can't happen for Rust 1.19 through the usual "stabilisation on beta" system that is being done for library APIs.

r? @BurntSushi

closes #40470.
2017-07-17 00:19:43 +00:00
Alex Burka 8cce5bc7ab use :vis in thread_local! 2017-07-11 20:27:55 +00:00
Sean McArthur 74b2d69358 remove associated_consts feature gate 2017-07-06 11:52:25 -07:00
est31 010dea13ee Stabilize float_bits_conv 2017-07-06 15:18:06 +02:00
Alex Crichton 695dee063b rustc: Implement the #[global_allocator] attribute
This PR is an implementation of [RFC 1974] which specifies a new method of
defining a global allocator for a program. This obsoletes the old
`#![allocator]` attribute and also removes support for it.

[RFC 1974]: https://github.com/rust-lang/rfcs/pull/197

The new `#[global_allocator]` attribute solves many issues encountered with the
`#![allocator]` attribute such as composition and restrictions on the crate
graph itself. The compiler now has much more control over the ABI of the
allocator and how it's implemented, allowing much more freedom in terms of how
this feature is implemented.

cc #27389
2017-07-05 14:37:01 -07:00
Corey Farwell 4c43bc32b7 Rollup merge of #42271 - tinaun:charfromstr, r=alexcrichton
add `FromStr` Impl for `char`

fixes #24939.

is it possible to use pub(restricted) instead of using a stability attribute for the internal error representation? is it needed at all?
2017-06-20 16:28:25 -04:00
tinaun fd9d7aa2cf added `FromStr` Impl for `char` 2017-06-20 04:38:02 -04:00
bors 1143eb26a2 Auto merge of #42313 - pnkfelix:allocator-integration, r=alexcrichton
Allocator integration

Lets start getting some feedback on `trait Alloc`.

Here is:
 *  the `trait Alloc` itself,
 * the `struct Layout` and `enum AllocErr` that its API relies on
 * a `struct HeapAlloc` that exposes the system allocator as an instance of `Alloc`
 * an integration of `Alloc` with `RawVec`
 * ~~an integration of `Alloc` with `Vec`~~

 TODO
 * [x] split `fn realloc_in_place` into `grow` and `shrink` variants
 * [x] add `# Unsafety` and `# Errors` sections to documentation for all relevant methods
 * [x] remove `Vec` integration with `Allocator`
 * [x] add `allocate_zeroed` impl to `HeapAllocator`
 * [x] remove typedefs e.g. `type Size = usize;`
 * [x] impl `trait Error` for all error types in PR
 * [x] make `Layout::from_size_align` public
 * [x] clarify docs of `fn padding_needed_for`.
 * [x] revise `Layout` constructors to ensure that [size+align combination is valid](https://github.com/rust-lang/rust/pull/42313#issuecomment-306845446)
 * [x] resolve mismatch re requirements of align on dealloc. See [comment](https://github.com/rust-lang/rust/pull/42313#issuecomment-306202489).
2017-06-20 05:02:19 +00:00
est31 c6afde6c46 Introduce tidy lint to check for inconsistent tracking issues
This commit
    * Refactors the collect_lib_features function to work in a
      non-checking mode (no bad pointer needed, and list of
      lang features).
    * Introduces checking whether unstable/stable tags for a
      given feature have inconsistent tracking issues.
    * Fixes such inconsistencies throughout the codebase.
2017-06-16 20:40:40 +02:00
Felix S. Klock II 12d4d12fef implement Error trait for error structs added in allocator API. 2017-06-15 23:48:31 +02:00
Murarth eadda7665e Merge crate `collections` into `alloc` 2017-06-13 23:37:34 -07:00
Alexis Beingessner e847d46bcb migrate everything to using mem::needs_drop 2017-05-20 19:27:30 -04:00
Alex Crichton 5daf557a77 Update stage0 bootstrap compiler
We've got a freshly minted beta compiler, let's update to use that on nightly!
This has a few other changes associated with it as well

* A bump to the rustc version number (to 1.19.0)
* Movement of the `cargo` and `rls` submodules to their "proper" location in
  `src/tools/{cargo,rls}`. Now that Cargo workspaces support the `exclude`
  option this can work.
* Updates of the `cargo` and `rls` submodules to their master branches.
* Tweak to the `src/stage0.txt` format to be more amenable for Cargo version
  numbers. On the beta channel Cargo will bootstrap from a different version
  than rustc (e.g. the version numbers are different), so we need different
  configuration for this.
* Addition of `dev` as a readable key in the `src/stage0.txt` format. If present
  then stage0 compilers are downloaded from `dev-static.rust-lang.org` instead
  of `static.rust-lang.org`. This is added to accomodate our updated release
  process with Travis and AppVeyor.
2017-04-29 12:11:14 -07:00
Josh Stone c1aaa60d8d Remove float_extras
[unstable, deprecated since 1.11.0]
2017-04-20 21:16:31 -07:00
Josh Stone c903ac64e5 Remove num::{Zero,One}
[unstable, deprecated since 1.11.0]
2017-04-20 21:16:31 -07:00
Josh Stone 313aab8fbe Remove RefCell::borrow_state
[unstable, deprecated since 1.15.0]
2017-04-20 21:16:31 -07:00
Scott McMurray 295bcdb715 Override ToOwned::clone_into for Path and OsStr
The only non-overridden one remaining is the CStr impl, which cannot
be optimized as doing so would break CString's second invariant.
2017-04-18 21:02:18 -07:00
est31 32a43da68a Add functions to safely transmute float to int 2017-04-18 02:43:16 +02:00
bors 1dca19ae3f Auto merge of #40765 - pirate:patch-3, r=aturon
Add contribution instructions to stdlib docs

Generally programming language docs have instructions on how to contribute changes.

I couldn't find any in the rust docs, so I figured I'd add an instructions section, let me know if this belongs somewhere else!
2017-04-12 09:16:14 +00:00
Clar Charr a2b28be3f8 Reduce str transmutes, add mut versions of methods. 2017-04-09 19:13:54 -04:00
Nick Sweeting 9765fbc813 fix build errors 2017-04-07 16:42:56 -04:00
Nick Sweeting 9a50874dd4 tweak links 2017-03-30 21:54:10 -04:00
Nick Sweeting 7665991e3e add link to contribution guidelines and IRC room 2017-03-23 13:48:32 -04:00
Nick Sweeting 425c1a3a05 Add contribution instructions to stdlib docs 2017-03-23 13:29:04 -04:00
Corey Farwell 17656ab328 Rollup merge of #40556 - cramertj:stabilize-pub-restricted, r=petrochenkov
Stabilize pub(restricted)

Fix https://github.com/rust-lang/rust/issues/32409
2017-03-20 23:44:59 -04:00
steveklabnik d1d9626e75 Fix up various links
The unstable book, libstd, libcore, and liballoc all needed some
adjustment.
2017-03-20 10:10:16 -04:00
Corey Farwell 4e9033124b Rollup merge of #40566 - clarcharr:never_error, r=sfackler
Implement std::error::Error for !.
2017-03-19 20:51:11 -04:00
Aaron Turon a8f4a1bd98 Stabilize rc_raw feature, closes #37197 2017-03-17 13:28:53 -07:00
Corey Farwell 69717170a4 Rollup merge of #40456 - frewsxcv:frewsxcv-docs-function-parens, r=GuillaumeGomez
Remove function invokation parens from documentation links.

This was never established as a convention we should follow in the 'More
API Documentation Conventions' RFC:

https://github.com/rust-lang/rfcs/blob/master/text/1574-more-api-documentation-conventions.md
2017-03-17 08:48:51 -04:00
Taylor Cramer 28626ca5b1 Stabilize pub(restricted) 2017-03-15 22:39:04 -07:00
Clar Charr a5cf55125c Implement Error for !. 2017-03-15 23:09:29 -04:00
Corey Farwell e7b0f2badf Remove function invokation parens from documentation links.
This was never established as a convention we should follow in the 'More
API Documentation Conventions' RFC:

https://github.com/rust-lang/rfcs/blob/master/text/1574-more-api-documentation-conventions.md
2017-03-13 21:43:18 -04:00
Charlie Fan 584c79888b Implement placement-in protocol for `HashMap` 2017-03-11 21:08:18 +08:00
Steve Klabnik b4cd3d9206 Revert "Fix up links"
This reverts commit 7f1d1c6d9a.

The original commit was created because mdBook and rustdoc had
different generation algorithms for header links; now with
https://github.com/rust-lang/rust/pull/39966 , the algorithms
are the same. So let's undo this change.

... when I came across this problem, I said "eh, this isn't fun,
but it doesn't take that long." I probably should have just actually
taken the time to fix upstream, given that they were amenable. Oh
well!
2017-02-20 09:09:12 -05:00
Steve Klabnik 7f1d1c6d9a Fix up links
mdbook and rustdoc generate links differently, so we need to change all
these links.
2017-02-13 13:41:24 -05:00
whataloadofwhat ca92c51682 Change std::panicking::try::Data into a union
No longer potentially call `mem::uninitialized::<!>()`

Fixes #39432
2017-02-10 19:20:28 +00:00
Corey Farwell 6fb57bf13f Rollup merge of #39431 - alexcrichton:no-more-makefiles, r=brson
Delete the makefile build system

This PR deletes the makefile build system in favor of the rustbuild build system. The beta has now been branched so 1.16 will continue to be buildable from the makefiles, but going forward 1.17 will only be buildable with rustbuild.

Rustbuild has been the default build system [since 1.15.0](https://github.com/rust-lang/rust/pull/37817) and the makefiles were [proposed for deletion](https://internals.rust-lang.org/t/proposal-for-promoting-rustbuild-to-official-status/4368) at this time back in November of last year.

And now with the deletion of these makefiles we can start getting those sweet sweet improvements of using crates.io crates in the compiler!
2017-02-07 22:54:25 -05:00
Alex Crichton 77c3bfa742 std: Remove cfg(cargobuild) annotations
These are all now no longer needed that we've only got rustbuild in tree.
2017-02-06 08:42:54 -08:00
Clar Charr 8b2e334e0e Ipv6Addr <-> u128 2017-02-05 18:55:37 -05:00
Corey Farwell ca202fe181 Rollup merge of #38983 - APTy:udp-peek, r=aturon
Add peek APIs to std::net

Adds "peek" APIs to `std::net` sockets, including:
- `UdpSocket.peek()`
- `UdpSocket.peek_from()`
- `TcpStream.peek()`

These methods enable socket reads without side-effects. That is, repeated calls to `peek()` return identical data. This is accomplished by providing the POSIX flag `MSG_PEEK` to the underlying socket read operations.

This also moves the current implementation of `recv_from` out of the platform-independent `sys_common` and into respective `sys/windows` and `sys/unix` implementations. This allows for more platform-dependent implementations where necessary.

Fixes #38980
2017-02-05 09:14:38 -05:00
Tyler Julian a40be0857c libstd/net: Add `peek` APIs to UdpSocket and TcpStream
These methods enable socket reads without side-effects. That is,
repeated calls to peek() return identical data. This is accomplished
by providing the POSIX flag MSG_PEEK to the underlying socket read
operations.

This also moves the current implementation of recv_from out of the
platform-independent sys_common and into respective sys/windows and
sys/unix implementations. This allows for more platform-dependent
implementations.
2017-02-04 12:00:19 -08:00
Alex Crichton 626e754473 Bump version, upgrade bootstrap
This commit updates the version number to 1.17.0 as we're not on that version of
the nightly compiler, and at the same time this updates src/stage0.txt to
bootstrap from freshly minted beta compiler and beta Cargo.
2017-02-03 13:25:46 -08:00
Aidan Hobson Sayers 70d2372ada Expose a feature to force use of alloc_system, teach rustbuild
This fixes jemalloc-less local rebuilds, where we tell cargo that
we're actually stage1
2017-01-16 03:06:45 +00:00
Seo Sanghyeon d350c9b15f Rollup merge of #38664 - apasel422:may-dangle, r=pnkfelix
Replace uses of `#[unsafe_destructor_blind_to_params]` with `#[may_dangle]`

CC #34761

r? @pnkfelix
2017-01-10 20:27:41 +09:00
bors 7ac9d337dc Auto merge of #38679 - alexcrichton:always-deny-warnings, r=nrc
Remove not(stage0) from deny(warnings)

Historically this was done to accommodate bugs in lints, but there hasn't been a
bug in a lint since this feature was added which the warnings affected. Let's
completely purge warnings from all our stages by denying warnings in all stages.
This will also assist in tracking down `stage0` code to be removed whenever
we're updating the bootstrap compiler.
2017-01-08 08:22:06 +00:00
Simonas Kazlauskas b0e55a83a8 Such large. Very 128. Much bits.
This commit introduces 128-bit integers. Stage 2 builds and produces a working compiler which
understands and supports 128-bit integers throughout.

The general strategy used is to have rustc_i128 module which provides aliases for iu128, equal to
iu64 in stage9 and iu128 later. Since nowhere in rustc we rely on large numbers being supported,
this strategy is good enough to get past the first bootstrap stages to end up with a fully working
128-bit capable compiler.

In order for this strategy to work, number of locations had to be changed to use associated
max_value/min_value instead of MAX/MIN constants as well as the min_value (or was it max_value?)
had to be changed to use xor instead of shift so both 64-bit and 128-bit based consteval works
(former not necessarily producing the right results in stage1).

This commit includes manual merge conflict resolution changes from a rebase by @est31.
2016-12-30 15:15:44 +01:00
Alex Crichton 9b0b5b45db Remove not(stage0) from deny(warnings)
Historically this was done to accommodate bugs in lints, but there hasn't been a
bug in a lint since this feature was added which the warnings affected. Let's
completely purge warnings from all our stages by denying warnings in all stages.
This will also assist in tracking down `stage0` code to be removed whenever
we're updating the bootstrap compiler.
2016-12-29 21:07:20 -08:00
Andrew Paseltiner ca9b07bbc9
Replace uses of `#[unsafe_destructor_blind_to_params]` with `#[may_dangle]`
CC #34761
2016-12-28 17:47:10 -05:00
Corey Farwell 86fc63e62d Implement `fmt::Debug` for all structures in libstd.
Part of https://github.com/rust-lang/rust/issues/31869.

Also turn on the `missing_debug_implementations` lint at the crate
level.
2016-12-18 14:55:14 -08:00
bors b4b1e5ece2 Auto merge of #38049 - frewsxcv:libunicode, r=alexcrichton
Rename 'librustc_unicode' crate to 'libstd_unicode'.

Fixes https://github.com/rust-lang/rust/issues/26554.
2016-12-12 13:19:33 +00:00
Ulrik Sverdrup 7ba762253c std: Forward ExactSizeIterator::is_empty for Args, ArgsOs iterators 2016-12-04 15:46:36 +01:00
Alex Crichton 2186660b51 Update the bootstrap compiler
Now that we've got a beta build, let's use it!
2016-11-30 10:38:08 -08:00
Corey Farwell 274777a158 Rename 'librustc_unicode' crate to 'libstd_unicode'.
Fixes #26554.
2016-11-30 01:24:01 -05:00
Vadim Petrochenkov 74bb594563 Stabilize `..` in tuple (struct) patterns 2016-11-03 01:38:15 +03:00
Brian Anderson 6135cbc9e2 std: Flatten the num directory to reflect the module layout
This makes it dissimilar to how core is structured on disk, but
more predictable on its own.
2016-11-01 17:08:24 +00:00
Brian Anderson c251884575 Clean up and add more comments to libstd/lib.rs 2016-11-01 17:08:24 +00:00
Brian Anderson 8f5bb1f7c0 std: Remove unused test feature 2016-11-01 17:08:24 +00:00
Brian Anderson ca30691813 std: Move sys_common to libstd/sys_common
Make the directory structure reflect the module structure. I've always
found the existing structure confusing.
2016-11-01 17:08:24 +00:00
Brian Anderson 219c018894 std: Move platform-specific code out of libstd/lib.rs 2016-11-01 17:08:24 +00:00
bors 73f5cad6c4 Auto merge of #37178 - apasel422:issue-37136, r=alexcrichton
Implement `RefUnwindSafe` for atomic types

Closes #37136
2016-11-01 00:44:50 -07:00
Ulrik Sverdrup 0a0efcbebf std::collections: Reexport libcollections's range module
This is overdue, even if range and RangeArgument is still unstable.
The stability attributes are the same ones as the other unstable item
(Bound) here, they don't seem to matter.
2016-10-17 21:26:29 +02:00
Andrew Paseltiner f8322035eb
Implement `RefUnwindSafe` for atomic types
Closes #37136
2016-10-16 19:48:59 -04:00
Nick Cameron 14c62f91b7 Deprecate `Reflect`
[tracking issue](https://github.com/rust-lang/rust/issues/27749)
2016-10-12 08:40:22 +13:00
Nick Cameron 9bc6d26092 Stabilise `?`
cc [`?` tracking issue](https://github.com/rust-lang/rust/issues/31436)
2016-10-12 08:40:22 +13:00
Alex Crichton 10c3134da0 std: Stabilize and deprecate APIs for 1.13
This commit is intended to be backported to the 1.13 branch, and works with the
following APIs:

Stabilized

* `i32::checked_abs`
* `i32::wrapping_abs`
* `i32::overflowing_abs`
* `RefCell::try_borrow`
* `RefCell::try_borrow_mut`
* `DefaultHasher`
* `DefaultHasher::new`
* `DefaultHasher::default`

Deprecated

* `BinaryHeap::push_pop`
* `BinaryHeap::replace`
* `SipHash13`
* `SipHash24`
* `SipHasher` - use `DefaultHasher` instead in the `std::collections::hash_map`
  module

Closes #28147
Closes #34767
Closes #35057
Closes #35070
2016-10-03 10:34:34 -07:00
Brian Anderson 3b49c60ab7 Remove stage0 hacks 2016-09-28 23:17:56 +00:00
Ashley Williams 3d8d55787b add assert_ne and debug_assert_ne macros 2016-09-21 14:38:26 +02:00
Alex Crichton 848cfe20a0 Link test to compiler builtins and make unstable
This commit fixes a test which now needs to explicitly link to the
`compiler_builtins` crate as well as makes the `compiler_builtins` crate
unstable.
2016-09-13 12:27:26 -07:00
Jorge Aparicio 3fd5fdd8d3 crate-ify compiler-rt into compiler-builtins
libcompiler-rt.a is dead, long live libcompiler-builtins.rlib

This commit moves the logic that used to build libcompiler-rt.a into a
compiler-builtins crate on top of the core crate and below the std crate.
This new crate still compiles the compiler-rt instrinsics using gcc-rs
but produces an .rlib instead of a static library.

Also, with this commit rustc no longer passes -lcompiler-rt to the
linker. This effectively makes the "no-compiler-rt" field of target
specifications a no-op. Users of `no_std` will have to explicitly add
the compiler-builtins crate to their crate dependency graph *if* they
need the compiler-rt intrinsics. Users of the `std` have to do nothing
extra as the std crate depends on compiler-builtins.

Finally, this a step towards lazy compilation of std with Cargo as the
compiler-rt intrinsics can now be built by Cargo instead of having to
be supplied by the user by some other method.

closes #34400
2016-09-12 21:22:15 -07:00
Vadim Petrochenkov 6f7e51e49b Replace `_, _, _` with `..` 2016-09-04 12:27:01 +03:00
bors eaf71f8d10 Auto merge of #35906 - jseyfried:local_prelude, r=eddyb
Use `#[prelude_import]` in `libcore` and `libstd`

r? @eddyb
2016-08-25 20:45:32 -07:00
Jeffrey Seyfried 9a2c8783d9 Use `#[prelude_import]` in `libstd`. 2016-08-24 22:12:48 +00:00
Eduard Burtescu 119508cdb4 Remove drop flags from structs and enums implementing Drop. 2016-08-24 13:23:37 +03:00
bors 0bd99f9d5c Auto merge of #35656 - Stebalien:fused, r=alexcrichton
Implement 1581 (FusedIterator)

* [ ] Implement on patterns. See https://github.com/rust-lang/rust/issues/27721#issuecomment-239638642.
* [ ] Handle OS Iterators. A bunch of iterators (`Args`, `Env`, etc.) in libstd wrap platform specific iterators. The current ones all appear to be well-behaved but can we assume that future ones will be?
* [ ] Does someone want to audit this? On first glance, all of the iterators on which I implemented `FusedIterator` appear to be well-behaved but there are a *lot* of them so a second pair of eyes would be nice.
* I haven't touched rustc internal iterators (or the internal rand) because rustc doesn't actually call `fuse()`.
* `FusedIterator` can't be implemented on `std::io::{Bytes, Chars}`.

Closes: #35602 (Tracking Issue)
Implements: rust-lang/rfcs#1581
2016-08-23 07:46:52 -07:00
Steven Allen de91872a33 Add a FusedIterator trait.
This trait can be used to avoid the overhead of a fuse wrapper when an iterator
is already well-behaved.

Conforming to: RFC 1581
Closes: #35602
2016-08-18 12:16:29 -04:00
Nick Cameron e6cc4c5d13 Fix links 2016-08-18 15:43:35 +12:00
Nikhil Shagrithaya ea2216cba8 Added an update_panic_count function to handle access to PANIC_COUNT 2016-08-10 22:04:41 +05:30
Andrew Paseltiner a20a1db54a
Implement `RefCell::{try_borrow, try_borrow_mut}` 2016-08-08 23:59:56 -04:00
Tobias Bucher 3d09b4a0d5 Rename `char::escape` to `char::escape_debug` and add tracking issue 2016-07-28 02:20:49 +02:00
Alex Crichton 0c137ab0a6 rustc: Update stage0 to beta-2016-07-06
Hot off the presses, let's update our stage0 compiler!
2016-07-06 09:29:15 -07:00
Sean McArthur db1b1919ba std: use siphash-1-3 for HashMap 2016-06-29 16:08:32 -07:00
Ariel Ben-Yehuda f0174fcbee use the slice_pat hack in libstd too 2016-06-09 00:38:38 +03:00
Alex Crichton fa45670ce4 mk: Prepare for a new stage0 compiler
This commit prepares the source for a new stage0 compiler, the 1.10.0 beta
compiler. These artifacts are hot off the bots and should be ready to go.
2016-05-31 16:11:49 -07:00
Alex Crichton 0ec321f7b5 rustc: Implement custom panic runtimes
This commit is an implementation of [RFC 1513] which allows applications to
alter the behavior of panics at compile time. A new compiler flag, `-C panic`,
is added and accepts the values `unwind` or `panic`, with the default being
`unwind`. This model affects how code is generated for the local crate, skipping
generation of landing pads with `-C panic=abort`.

[RFC 1513]: https://github.com/rust-lang/rfcs/blob/master/text/1513-less-unwinding.md

Panic implementations are then provided by crates tagged with
`#![panic_runtime]` and lazily required by crates with
`#![needs_panic_runtime]`. The panic strategy (`-C panic` value) of the panic
runtime must match the final product, and if the panic strategy is not `abort`
then the entire DAG must have the same panic strategy.

With the `-C panic=abort` strategy, users can expect a stable method to disable
generation of landing pads, improving optimization in niche scenarios,
decreasing compile time, and decreasing output binary size. With the `-C
panic=unwind` strategy users can expect the existing ability to isolate failure
in Rust code from the outside world.

Organizationally, this commit dismantles the `sys_common::unwind` module in
favor of some bits moving part of it to `libpanic_unwind` and the rest into the
`panicking` module in libstd. The custom panic runtime support is pretty similar
to the custom allocator support with the only major difference being how the
panic runtime is injected (takes the `-C panic` flag into account).
2016-05-09 08:22:36 -07:00
Steven Fackler a9779df188 Implement RFC 1542
cc #33417
2016-05-07 08:52:41 -07:00
Alex Crichton 552eda70d3 std: Stabilize APIs for the 1.9 release
This commit applies all stabilizations, renamings, and deprecations that the
library team has decided on for the upcoming 1.9 release. All tracking issues
have gone through a cycle-long "final comment period" and the specific APIs
stabilized/deprecated are:

Stable

* `std::panic`
* `std::panic::catch_unwind` (renamed from `recover`)
* `std::panic::resume_unwind` (renamed from `propagate`)
* `std::panic::AssertUnwindSafe` (renamed from `AssertRecoverSafe`)
* `std::panic::UnwindSafe` (renamed from `RecoverSafe`)
* `str::is_char_boundary`
* `<*const T>::as_ref`
* `<*mut T>::as_ref`
* `<*mut T>::as_mut`
* `AsciiExt::make_ascii_uppercase`
* `AsciiExt::make_ascii_lowercase`
* `char::decode_utf16`
* `char::DecodeUtf16`
* `char::DecodeUtf16Error`
* `char::DecodeUtf16Error::unpaired_surrogate`
* `BTreeSet::take`
* `BTreeSet::replace`
* `BTreeSet::get`
* `HashSet::take`
* `HashSet::replace`
* `HashSet::get`
* `OsString::with_capacity`
* `OsString::clear`
* `OsString::capacity`
* `OsString::reserve`
* `OsString::reserve_exact`
* `OsStr::is_empty`
* `OsStr::len`
* `std::os::unix::thread`
* `RawPthread`
* `JoinHandleExt`
* `JoinHandleExt::as_pthread_t`
* `JoinHandleExt::into_pthread_t`
* `HashSet::hasher`
* `HashMap::hasher`
* `CommandExt::exec`
* `File::try_clone`
* `SocketAddr::set_ip`
* `SocketAddr::set_port`
* `SocketAddrV4::set_ip`
* `SocketAddrV4::set_port`
* `SocketAddrV6::set_ip`
* `SocketAddrV6::set_port`
* `SocketAddrV6::set_flowinfo`
* `SocketAddrV6::set_scope_id`
* `<[T]>::copy_from_slice`
* `ptr::read_volatile`
* `ptr::write_volatile`
* The `#[deprecated]` attribute
* `OpenOptions::create_new`

Deprecated

* `std::raw::Slice` - use raw parts of `slice` module instead
* `std::raw::Repr` - use raw parts of `slice` module instead
* `str::char_range_at` - use slicing plus `chars()` plus `len_utf8`
* `str::char_range_at_reverse` - use slicing plus `chars().rev()` plus `len_utf8`
* `str::char_at` - use slicing plus `chars()`
* `str::char_at_reverse` - use slicing plus `chars().rev()`
* `str::slice_shift_char` - use `chars()` plus `Chars::as_str`
* `CommandExt::session_leader` - use `before_exec` instead.

Closes #27719
cc #27751 (deprecating the `Slice` bits)
Closes #27754
Closes #27780
Closes #27809
Closes #27811
Closes #27830
Closes #28050
Closes #29453
Closes #29791
Closes #29935
Closes #30014
Closes #30752
Closes #31262
cc #31398 (still need to deal with `before_exec`)
Closes #31405
Closes #31572
Closes #31755
Closes #31756
2016-04-11 08:57:53 -07:00
Corey Farwell 5972b22b7c Implement `values_mut` on `HashMap`.
https://github.com/rust-lang/rust/issues/32551
2016-04-01 18:35:54 -04:00
mitaa 6a76872d71 Extend linkchecker with anchor checking
This adds checks to ensure that:
* link anchors refer to existing id's on the target page
* id's are unique within an html document
* page redirects are valid
2016-03-27 00:21:00 +01:00
Jorge Aparicio aa7fe93d4a sprinkle feature gates here and there 2016-03-22 22:02:47 -05:00
Eduard Burtescu 473f804491 Add #[rustc_no_mir] to make tests pass with -Z orbit. 2016-03-17 22:48:07 +02:00
Alex Crichton b53764c73b std: Clean out deprecated APIs
Removes all unstable and deprecated APIs prior to the 1.8 release. All APIs that
are deprecated in the 1.8 release are sticking around for the rest of this
cycle.

Some notable changes are:

* The `dynamic_lib` module was moved into `rustc_back` as the compiler still
  relies on a few bits and pieces.
* The `DebugTuple` formatter now special-cases an empty struct name with only
  one field to append a trailing comma.
2016-03-12 12:31:13 -08:00
bors c6a6053112 Auto merge of #32102 - alexcrichton:assert-safe-closures, r=aturon
std: Add impl of FnOnce to AssertRecoverSafe

This was originally intended, but forgot to land by accident!

cc #27719
2016-03-10 17:52:12 -08:00
Alex Crichton 0d5cfd9117 mk: Distribute fewer TARGET_CRATES
Right now everything in TARGET_CRATES is built by default for all non-fulldeps
tests and is distributed by default for all target standard library packages.
Currenly this includes a number of unstable crates which are rarely used such as
`graphviz` and `rbml`>

This commit trims down the set of `TARGET_CRATES`, moves a number of tests to
`*-fulldeps` as a result, and trims down the dependencies of libtest so we can
distribute fewer crates in the `rust-std` packages.
2016-03-07 13:05:12 -08:00
Alex Crichton ec58f40463 std: Add impl of FnOnce to AssertRecoverSafe
This was originally intended, but forgot to land by accident!

cc #27719
2016-03-07 11:02:43 -08:00
bors 8484831d29 Auto merge of #30884 - durka:inclusive-ranges, r=aturon
This PR implements [RFC 1192](https://github.com/rust-lang/rfcs/blob/master/text/1192-inclusive-ranges.md), which is triple-dot syntax for inclusive range expressions. The new stuff is behind two feature gates (one for the syntax and one for the std::ops types). This replaces the deprecated functionality in std::iter. Along the way I simplified the desugaring for all ranges.

This is my first contribution to rust which changes more than one character outside of a test or comment, so please review carefully! Some of the individual commit messages have more of my notes. Also thanks for putting up with my dumb questions in #rust-internals.

- For implementing `std::ops::RangeInclusive`, I took @Stebalien's suggestion from https://github.com/rust-lang/rfcs/pull/1192#issuecomment-137864421. It seemed to me to make the implementation easier and increase type safety. If that stands, the RFC should be amended to avoid confusion.
- I also kind of like @glaebhoerl's [idea](https://github.com/rust-lang/rfcs/pull/1254#issuecomment-147815299), which is unified inclusive/exclusive range syntax something like `x>..=y`. We can experiment with this while everything is behind a feature gate.
- There are a couple of FIXMEs left (see the last commit). I didn't know what to do about `RangeArgument` and I haven't added `Index` impls yet. Those should be discussed/finished before merging.

cc @Gankro since you [complained](https://www.reddit.com/r/rust/comments/3xkfro/what_happened_to_inclusive_ranges/cy5j0yq)
cc #27777 #30877 rust-lang/rust#1192 rust-lang/rfcs#1254
relevant to #28237 (tracking issue)
2016-03-06 07:16:41 +00:00
Alex Crichton b643782a10 std: Stabilize APIs for the 1.8 release
This commit is the result of the FCPs ending for the 1.8 release cycle for both
the libs and the lang suteams. The full list of changes are:

Stabilized

* `braced_empty_structs`
* `augmented_assignments`
* `str::encode_utf16` - renamed from `utf16_units`
* `str::EncodeUtf16` - renamed from `Utf16Units`
* `Ref::map`
* `RefMut::map`
* `ptr::drop_in_place`
* `time::Instant`
* `time::SystemTime`
* `{Instant,SystemTime}::now`
* `{Instant,SystemTime}::duration_since` - renamed from `duration_from_earlier`
* `{Instant,SystemTime}::elapsed`
* Various `Add`/`Sub` impls for `Time` and `SystemTime`
* `SystemTimeError`
* `SystemTimeError::duration`
* Various impls for `SystemTimeError`
* `UNIX_EPOCH`
* `ops::{Add,Sub,Mul,Div,Rem,BitAnd,BitOr,BitXor,Shl,Shr}Assign`

Deprecated

* Scoped TLS (the `scoped_thread_local!` macro)
* `Ref::filter_map`
* `RefMut::filter_map`
* `RwLockReadGuard::map`
* `RwLockWriteGuard::map`
* `Condvar::wait_timeout_with`

Closes #27714
Closes #27715
Closes #27746
Closes #27748
Closes #27908
Closes #29866
2016-02-29 09:05:33 -08:00
Alex Burka 7eb7c56bd4 add indexing with RangeInclusive in libcore and libcollections 2016-02-27 02:01:41 -05:00
Alex Burka c5d58de665 core: add inclusive ranges to core::ops
Since it removes the old iter::{range_inclusive, RangeInclusive} which
were unstable and deprecated, this is a [breaking-change] on nightly.
2016-02-27 02:01:41 -05:00
Ulrik Sverdrup 2d6496dd84 Use .copy_from_slice() where applicable
.copy_from_slice() does the same job of .clone_from_slice(), but the
former is explicitly for Copy elements and calls `memcpy` directly, and
thus is it efficient without optimization too.
2016-02-26 14:51:38 +01:00
John Kåre Alsaker 8ade080412 Fix liballoc dependencies 2016-02-21 15:32:43 +01:00
bors 4b615854f0 Auto merge of #31120 - alexcrichton:attribute-deny-warnings, r=brson
This commit removes the `-D warnings` flag being passed through the makefiles to
all crates to instead be a crate attribute. We want these attributes always
applied for all our standard builds, and this is more amenable to Cargo-based
builds as well.

Note that all `deny(warnings)` attributes are gated with a `cfg(stage0)`
attribute currently to match the same semantics we have today
2016-01-26 22:10:10 +00:00
Alex Crichton 1fa0be2bc0 std: Stabilize custom hasher support in HashMap
This commit implements the stabilization of the custom hasher support intended
for 1.7 but left out due to some last-minute questions that needed some
decisions. A summary of the actions done in this PR are:

Stable

* `std:#️⃣:BuildHasher`
* `BuildHasher::Hasher`
* `BuildHasher::build_hasher`
* `std:#️⃣:BuildHasherDefault`
* `HashMap::with_hasher`
* `HashMap::with_capacity_and_hasher`
* `HashSet::with_hasher`
* `HashSet::with_capacity_and_hasher`
* `std::collections::hash_map::RandomState`
* `RandomState::new`

Deprecated

* `std::collections::hash_state`
* `std::collections::hash_state::HashState` - this trait was also moved into
  `std::hash` with a reexport here to ensure that we can have a blanket impl to
  prevent immediate breakage on nightly. Note that this is unstable in both
  location.
* `HashMap::with_hash_state` - renamed
* `HashMap::with_capacity_and_hash_state` - renamed
* `HashSet::with_hash_state` - renamed
* `HashSet::with_capacity_and_hash_state` - renamed

Closes #27713
2016-01-26 08:39:07 -08:00
Alex Crichton 2273b52023 mk: Move from `-D warnings` to `#![deny(warnings)]`
This commit removes the `-D warnings` flag being passed through the makefiles to
all crates to instead be a crate attribute. We want these attributes always
applied for all our standard builds, and this is more amenable to Cargo-based
builds as well.

Note that all `deny(warnings)` attributes are gated with a `cfg(stage0)`
attribute currently to match the same semantics we have today
2016-01-24 20:35:55 -08:00
Alex Crichton 9a4f43b9b6 std: Stabilize APIs for the 1.7 release
This commit stabilizes and deprecates the FCP (final comment period) APIs for
the upcoming 1.7 beta release. The specific APIs which changed were:

Stabilized

* `Path::strip_prefix` (renamed from `relative_from`)
* `path::StripPrefixError` (new error type returned from `strip_prefix`)
* `Ipv4Addr::is_loopback`
* `Ipv4Addr::is_private`
* `Ipv4Addr::is_link_local`
* `Ipv4Addr::is_multicast`
* `Ipv4Addr::is_broadcast`
* `Ipv4Addr::is_documentation`
* `Ipv6Addr::is_unspecified`
* `Ipv6Addr::is_loopback`
* `Ipv6Addr::is_unique_local`
* `Ipv6Addr::is_multicast`
* `Vec::as_slice`
* `Vec::as_mut_slice`
* `String::as_str`
* `String::as_mut_str`
* `<[T]>::clone_from_slice` - the `usize` return value is removed
* `<[T]>::sort_by_key`
* `i32::checked_rem` (and other signed types)
* `i32::checked_neg` (and other signed types)
* `i32::checked_shl` (and other signed types)
* `i32::checked_shr` (and other signed types)
* `i32::saturating_mul` (and other signed types)
* `i32::overflowing_add` (and other signed types)
* `i32::overflowing_sub` (and other signed types)
* `i32::overflowing_mul` (and other signed types)
* `i32::overflowing_div` (and other signed types)
* `i32::overflowing_rem` (and other signed types)
* `i32::overflowing_neg` (and other signed types)
* `i32::overflowing_shl` (and other signed types)
* `i32::overflowing_shr` (and other signed types)
* `u32::checked_rem` (and other unsigned types)
* `u32::checked_neg` (and other unsigned types)
* `u32::checked_shl` (and other unsigned types)
* `u32::saturating_mul` (and other unsigned types)
* `u32::overflowing_add` (and other unsigned types)
* `u32::overflowing_sub` (and other unsigned types)
* `u32::overflowing_mul` (and other unsigned types)
* `u32::overflowing_div` (and other unsigned types)
* `u32::overflowing_rem` (and other unsigned types)
* `u32::overflowing_neg` (and other unsigned types)
* `u32::overflowing_shl` (and other unsigned types)
* `u32::overflowing_shr` (and other unsigned types)
* `ffi::IntoStringError`
* `CString::into_string`
* `CString::into_bytes`
* `CString::into_bytes_with_nul`
* `From<CString> for Vec<u8>`
* `From<CString> for Vec<u8>`
* `IntoStringError::into_cstring`
* `IntoStringError::utf8_error`
* `Error for IntoStringError`

Deprecated

* `Path::relative_from` - renamed to `strip_prefix`
* `Path::prefix` - use `components().next()` instead
* `os::unix::fs` constants - moved to the `libc` crate
* `fmt::{radix, Radix, RadixFmt}` - not used enough to stabilize
* `IntoCow` - conflicts with `Into` and may come back later
* `i32::{BITS, BYTES}` (and other integers) - not pulling their weight
* `DebugTuple::formatter` - will be removed
* `sync::Semaphore` - not used enough and confused with system semaphores

Closes #23284
cc #27709 (still lots more methods though)
Closes #27712
Closes #27722
Closes #27728
Closes #27735
Closes #27729
Closes #27755
Closes #27782
Closes #27798
2016-01-16 11:03:10 -08:00
Pyfisch 4057808365 fix trailing whitespace 2016-01-07 20:13:59 +01:00
Pyfisch dce47681e2 f32: inline methods with special variant for msvc 2016-01-07 20:13:59 +01:00
Florian Hartwig 0cf5083b24 Fix link that is currently broken due to bad markup 2015-12-26 00:01:10 +01:00
bors 42c3ef8f9f Auto merge of #30417 - alexcrichton:better-detect-elf-tls, r=alexcrichton
Currently a compiler can be built with the `--disable-elf-tls` option for compatibility with OSX 10.6 which doesn't have ELF TLS. This is unfortunate, however, as a whole new compiler must be generated which can take some time. These commits add a new (feature gated) `cfg(target_thread_local)` annotation set by the compiler which indicates whether `#[thread_local]` is available for use. The compiler now interprets `MACOSX_DEPLOYMENT_TARGET` (a standard environment variable) to set this flag on OSX. With this we may want to start compiling our OSX nightlies with `MACOSX_DEPLOYMENT_TARGET` set to 10.6 which would allow the compiler out-of-the-box to generate 10.6-compatible binaries.

For now the compiler still by default targets OSX 10.7 by allowing ELF TLS by default (e.g. if `MACOSX_DEPLOYMENT_TARGET` isn't set).
2015-12-22 09:15:29 +00:00
Alex Crichton cd74364e5d std: Use cfg(target_thread_local) in thread_local!
This transitions the standard library's `thread_local!` macro to use the
freshly-added and gated `#[cfg(target_thread_local)]` attribute. This greatly
simplifies the `#[cfg]` logic in play here, but requires that the standard
library expose both the OS and ELF TLS implementation modules as unstable
implementation details.

The implementation details were shuffled around a bit but end up generally
compiling to the same thing.

Closes #26581 (this supersedes the need for the option)
Closes #27057 (this also starts ignoring the option)
2015-12-21 22:05:37 -08:00
Alex Crichton cd1848a1a6 Register new snapshots
Lots of cruft to remove!
2015-12-21 09:26:21 -08:00
Florian Hahn ca52c56e34 Add memchr implemenation based on rust-memchr to libstd 2015-12-18 13:32:14 +01:00
Tshepang Lekhonkhobe 6fdde01368 doc: add a missing comma 2015-12-17 20:55:20 +02:00
Brian Bowman 73615f7f8a Fix MIN, MAX links
The `MIN` link was broken. Reverts #29624.
2015-12-11 15:00:54 -06:00
Alex Crichton da50f7c288 std: Remove deprecated functionality from 1.5
This is a standard "clean out libstd" commit which removes all 1.5-and-before
deprecated functionality as it's now all been deprecated for at least one entire
cycle.
2015-12-10 11:47:55 -08:00
Alex Crichton 0a13f1abaf std: Rename thread::catch_panic to panic::recover
This commit is an implementation of [RFC 1236] and [RFC 1323] which
rename the `thread::catch_panic` function to `panic::recover` while also
replacing the `Send + 'static` bounds with a new `PanicSafe` bound.

[RFC 1236]: https://github.com/rust-lang/rfcs/pull/1236
[RFC 1323]: https://github.com/rust-lang/rfcs/pull/1323

cc #27719
2015-12-09 07:19:17 -08:00
Alex Crichton 464cdff102 std: Stabilize APIs for the 1.6 release
This commit is the standard API stabilization commit for the 1.6 release cycle.
The list of issues and APIs below have all been through their cycle-long FCP and
the libs team decisions are listed below

Stabilized APIs

* `Read::read_exact`
* `ErrorKind::UnexpectedEof` (renamed from `UnexpectedEOF`)
* libcore -- this was a bit of a nuanced stabilization, the crate itself is now
  marked as `#[stable]` and the methods appearing via traits for primitives like
  `char` and `str` are now also marked as stable. Note that the extension traits
  themeselves are marked as unstable as they're imported via the prelude. The
  `try!` macro was also moved from the standard library into libcore to have the
  same interface. Otherwise the functions all have copied stability from the
  standard library now.
* The `#![no_std]` attribute
* `fs::DirBuilder`
* `fs::DirBuilder::new`
* `fs::DirBuilder::recursive`
* `fs::DirBuilder::create`
* `os::unix::fs::DirBuilderExt`
* `os::unix::fs::DirBuilderExt::mode`
* `vec::Drain`
* `vec::Vec::drain`
* `string::Drain`
* `string::String::drain`
* `vec_deque::Drain`
* `vec_deque::VecDeque::drain`
* `collections::hash_map::Drain`
* `collections::hash_map::HashMap::drain`
* `collections::hash_set::Drain`
* `collections::hash_set::HashSet::drain`
* `collections::binary_heap::Drain`
* `collections::binary_heap::BinaryHeap::drain`
* `Vec::extend_from_slice` (renamed from `push_all`)
* `Mutex::get_mut`
* `Mutex::into_inner`
* `RwLock::get_mut`
* `RwLock::into_inner`
* `Iterator::min_by_key` (renamed from `min_by`)
* `Iterator::max_by_key` (renamed from `max_by`)

Deprecated APIs

* `ErrorKind::UnexpectedEOF` (renamed to `UnexpectedEof`)
* `OsString::from_bytes`
* `OsStr::to_cstring`
* `OsStr::to_bytes`
* `fs::walk_dir` and `fs::WalkDir`
* `path::Components::peek`
* `slice::bytes::MutableByteVector`
* `slice::bytes::copy_memory`
* `Vec::push_all` (renamed to `extend_from_slice`)
* `Duration::span`
* `IpAddr`
* `SocketAddr::ip`
* `Read::tee`
* `io::Tee`
* `Write::broadcast`
* `io::Broadcast`
* `Iterator::min_by` (renamed to `min_by_key`)
* `Iterator::max_by` (renamed to `max_by_key`)
* `net::lookup_addr`

New APIs (still unstable)

* `<[T]>::sort_by_key` (added to mirror `min_by_key`)

Closes #27585
Closes #27704
Closes #27707
Closes #27710
Closes #27711
Closes #27727
Closes #27740
Closes #27744
Closes #27799
Closes #27801
cc #27801 (doesn't close as `Chars` is still unstable)
Closes #28968
2015-12-05 15:09:44 -08:00
Vadim Petrochenkov be8ace8cac Remove all uses of `#[staged_api]` 2015-11-25 21:55:26 +03:00
Vadim Petrochenkov a613059e3f Rename #[deprecated] to #[rustc_deprecated] 2015-11-20 16:11:20 +03:00
Vadim Petrochenkov 7e2ffc7090 Add missing annotations and some tests 2015-11-18 01:24:21 +03:00
Alex Crichton 3d28b8b98e std: Migrate to the new libc
* Delete `sys::unix::{c, sync}` as these are now all folded into libc itself
* Update all references to use `libc` as a result.
* Update all references to the new flat namespace.
* Moves all windows bindings into sys::c
2015-11-09 22:55:50 -08:00
Rizky Luthfianto edee023297 doc(lib.rs): fix #L79 with inline link syntax 2015-11-06 00:15:32 +07:00
bors fa7a3c210d Auto merge of #29484 - steveklabnik:gh29330, r=brson
These two commits do a few things:

1. reformat to 80 cols
2. use the reference-style links where appropriate for improved in-source readability
3. adds a few links, tweaks a couple of words, `3` -> `three`, stuff like that

While the diff is big due to these edits, there's no significant content change.

r? @brson
2015-10-31 04:04:45 +00:00
Steve Klabnik 744df28758 Some fixes to std index docs
Part of https://github.com/rust-lang/rust/issues/29330

Needed because of https://github.com/rust-lang/rust/issues/29481 and https://github.com/rust-lang/rust/issues/29483
2015-10-30 17:43:05 -04:00
Steve Klabnik e2906dbeac Clean up formatting on std main page
Part of #29330
2015-10-30 17:18:26 -04:00
Alexis Beingessner e351595c61 don't use drop_in_place as an intrinsic 2015-10-30 11:24:54 -04:00
Alex Crichton ff49733274 std: Stabilize library APIs for 1.5
This commit stabilizes and deprecates library APIs whose FCP has closed in the
last cycle, specifically:

Stabilized APIs:

* `fs::canonicalize`
* `Path::{metadata, symlink_metadata, canonicalize, read_link, read_dir, exists,
   is_file, is_dir}` - all moved to inherent methods from the `PathExt` trait.
* `Formatter::fill`
* `Formatter::width`
* `Formatter::precision`
* `Formatter::sign_plus`
* `Formatter::sign_minus`
* `Formatter::alternate`
* `Formatter::sign_aware_zero_pad`
* `string::ParseError`
* `Utf8Error::valid_up_to`
* `Iterator::{cmp, partial_cmp, eq, ne, lt, le, gt, ge}`
* `<[T]>::split_{first,last}{,_mut}`
* `Condvar::wait_timeout` - note that `wait_timeout_ms` is not yet deprecated
  but will be once 1.5 is released.
* `str::{R,}MatchIndices`
* `str::{r,}match_indices`
* `char::from_u32_unchecked`
* `VecDeque::insert`
* `VecDeque::shrink_to_fit`
* `VecDeque::as_slices`
* `VecDeque::as_mut_slices`
* `VecDeque::swap_remove_front` - (renamed from `swap_front_remove`)
* `VecDeque::swap_remove_back` - (renamed from `swap_back_remove`)
* `Vec::resize`
* `str::slice_mut_unchecked`
* `FileTypeExt`
* `FileTypeExt::{is_block_device, is_char_device, is_fifo, is_socket}`
* `BinaryHeap::from` - `from_vec` deprecated in favor of this
* `BinaryHeap::into_vec` - plus a `Into` impl
* `BinaryHeap::into_sorted_vec`

Deprecated APIs

* `slice::ref_slice`
* `slice::mut_ref_slice`
* `iter::{range_inclusive, RangeInclusive}`
* `std::dynamic_lib`

Closes #27706
Closes #27725
cc #27726 (align not stabilized yet)
Closes #27734
Closes #27737
Closes #27742
Closes #27743
Closes #27772
Closes #27774
Closes #27777
Closes #27781
cc #27788 (a few remaining methods though)
Closes #27790
Closes #27793
Closes #27796
Closes #27810
cc #28147 (not all parts stabilized)
2015-10-25 09:36:32 -07:00
Andrew Paseltiner 1162b3752c Correct spelling in docs 2015-10-13 09:44:11 -04:00