13536 Commits

Author SHA1 Message Date
Mazdak Farrokhzad
060aedd385
Rollup merge of - mathstuf:osstr-doc-typo, r=TimNN
doc: fix typo in OsStrExt and OsStringExt
2019-10-17 13:46:15 +02:00
Mazdak Farrokhzad
55f2ac2483
Rollup merge of - Kampfkarren:patch-1, r=Centril
Don't recommend ONCE_INIT in std::sync::Once

ONCE_INIT is deprecated, and so suggesting it as not only being on par with, but before `Once::new` is a bad idea.
2019-10-17 13:46:09 +02:00
Mazdak Farrokhzad
10b580a1d1
Rollup merge of - oconnor663:noninheritable, r=alexcrichton
make File::try_clone produce non-inheritable handles on Windows

~**NOT READY FOR REVIEW.** This PR is currently mainly to trigger CI so that I can see what happens. (Is there a better way to trigger CI?) I don't know whether this change makes sense yet.~ (Edit: @Mark-Simulacrum clarified that CI doesn't currently run on Windows.)

---

File handles shouldn't be inheritable in general.
`std::process::Command` takes care of making them inheritable when child
processes are spawned, and the `CREATE_PROCESS_LOCK` protects against
races in that section on Windows. But `File::try_clone` has been
creating inheritable file descriptors outside of that lock, which could
be leaking into other child processes unintentionally.

See also https://github.com/rust-lang/rust/pull/31069#discussion_r334117665.
2019-10-17 13:46:04 +02:00
Ben Boeckel
fb6d5e6b1f doc: fix typo in OsStrExt and OsStringExt 2019-10-16 22:22:19 -04:00
Thomas Lively
2bf59bea48 Upgrade Emscripten targets to use upstream LLVM backend
- Compatible with Emscripten 1.38.46-upstream or later upstream.
 - Refactors the Emscripten target spec to share code with other wasm
   targets.
 - Replaces the old incorrect wasm32 C call ABI with the correct one,
   preserving the old one as wasm32_bindgen_compat for wasm-bindgen
   compatibility.
 - Updates the varargs ABI used by Emscripten and deletes the old one.
 - Removes the obsolete wasm32-experimental-emscripten target.
 - Uses EMCC_CFLAGS on CI to avoid the timeout problems with .
2019-10-16 17:06:48 -07:00
boyned//Kampfkarren
247df6e134
Don't recommend ONCE_INIT in std::sync::Once
ONCE_INIT is deprecated, and so suggesting it as not only being on par with, but before `Once::new` is a bad idea.
2019-10-16 00:06:01 -07:00
Mazdak Farrokhzad
8f8954e671
Rollup merge of - faern:source-on-intostringerror, r=bluss
Implement Error::source on IntoStringError + Remove superfluous cause impls

IntoStringError only implemented `Error::cause`, which is deprecated. This implemements `Error::source` instead.
`Error::cause` will still work as before, thanks to the default implementation.

I think this was the only/last `Error` impl in the standard library to have a cause, but not a source.
2019-10-13 19:17:12 +02:00
Mazdak Farrokhzad
d10702b577
Rollup merge of - BO41:typo, r=petrochenkov
Fix typo in task::Waker

fixes  

in `libstd/error.rs` there are a few mentions of `trait@Send` and `trait@Sync`. Are they wrong as well?
2019-10-13 19:17:08 +02:00
Mazdak Farrokhzad
2a9c791076
Rollup merge of - Wind-River:real_master_2, r=kennytm
vxWorks: implement get_path() and get_mode() for File fmt::Debug
2019-10-13 19:17:06 +02:00
Mazdak Farrokhzad
7c20a8ddb8
Rollup merge of - Amanieu:cfg_atomic, r=alexcrichton
Split non-CAS atomic support off into target_has_atomic_load_store

This PR implements my proposed changes in https://github.com/rust-lang/rust/issues/32976#issuecomment-518542029 by removing `target_has_atomic = "cas"` and splitting `target_has_atomic` into two separate `cfg`s:

* `target_has_atomic = 8/16/32/64/128`: This indicates the largest width that the target can atomically CAS (which implies support for all atomic operations).
* ` target_has_atomic_load_store = 8/16/32/64/128`: This indicates the largest width that the target can support loading or storing atomically (but may not support CAS).

cc 

r? @alexcrichton
2019-10-13 19:17:04 +02:00
Linus Färnstrand
b8e7f76181 Remove Error::cause impls equal to deafult impl 2019-10-13 12:30:06 +02:00
BO41
37018e0f9b Fix typos in error.rs 2019-10-13 12:12:46 +02:00
Linus Färnstrand
cd0e4c3263 Implement Error::source on IntoStringError
IntoStringError only implemented Error::cause, which is
deprecated. This implemements Error::source instead.
Error::cause will still work as before, thanks to the default
implementation.
2019-10-13 11:43:26 +02:00
Tyler Mandry
48051e4a79
Rollup merge of - rust-lang:must-use-join, r=dtolnay
Mark Path::join as must_use

I've accidentally did `mut_path_buf.jon(a_path);`, expecting this to be an in-place modification. Seems like we can easily warn in such cases?
2019-10-11 15:09:53 -07:00
Tyler Mandry
ec1d008f65
Rollup merge of - Kixunil:patch-1, r=KodrAus
Added doc about behavior of extend on HashMap

It was unclear what the implementation does when it encounters existing keys. This change makes it clear by documenting the trait impl.
2019-10-11 15:09:44 -07:00
Tyler Mandry
215b09194f
Rollup merge of - rick68:patch-17, r=Dylan-DPC
libstd: Fix typos in doc
2019-10-11 15:09:41 -07:00
Jack O'Connor
93ae6924af make File::try_clone produce non-inheritable handles on Windows
File handles shouldn't be inheritable in general.
`std::process::Command` takes care of making them inheritable when child
processes are spawned, and the `CREATE_PROCESS_LOCK` protects against
races in that section on Windows. But `File::try_clone` has been
creating inheritable file descriptors outside of that lock, which could
be leaking into other child processes unintentionally.

See also https://github.com/rust-lang/rust/pull/31069#discussion_r334117665.
2019-10-11 14:23:25 -04:00
bors
d4f7f974b8 Auto merge of - jonhoo:stabilize-mem-take, r=SimonSapin
Stabilize mem::take (mem_take)

Tracking issue: https://github.com/rust-lang/rust/issues/61129

r? @matklad
2019-10-11 12:45:20 +00:00
BaoshanPang
6afc5091b9 vxWorks: implement get_path() and get_mode() for File fmt::Debug 2019-10-10 08:41:10 -07:00
Aleksey Kladov
19bc0a8c67
Mark Path::join as must_use
I've accidentally did `mut_path_buf.jon(a_path);`, expecting this to be an in-place modification. Seems like we can easily warn in such cases?
2019-10-10 12:42:04 +03:00
bors
20cc752726 Auto merge of - Wind-River:real_master, r=dtolnay
vxworks: add checking (r == 0)
2019-10-09 16:31:49 +00:00
Mazdak Farrokhzad
27240fe77b
Rollup merge of - passcod:map-entry-insert, r=Amanieu
Implement (HashMap) Entry::insert as per 

Implementation of `Entry::insert` as per @SimonSapin's comment on . This requires a patch to hashbrown:

```diff
diff --git a/src/rustc_entry.rs b/src/rustc_entry.rs
index fefa5c3..7de8300 100644
--- a/src/rustc_entry.rs
+++ b/src/rustc_entry.rs
@@ -546,6 +546,32 @@ impl<'a, K, V> RustcVacantEntry<'a, K, V> {
         let bucket = self.table.insert_no_grow(self.hash, (self.key, value));
         unsafe { &mut bucket.as_mut().1 }
     }
+
+    /// Sets the value of the entry with the RustcVacantEntry's key,
+    /// and returns a RustcOccupiedEntry.
+    ///
+    /// # Examples
+    ///
+    /// ```
+    /// use hashbrown::HashMap;
+    /// use hashbrown::hash_map::RustcEntry;
+    ///
+    /// let mut map: HashMap<&str, u32> = HashMap::new();
+    ///
+    /// if let RustcEntry::Vacant(v) = map.rustc_entry("poneyland") {
+    ///     let o = v.insert_and_return(37);
+    ///     assert_eq!(o.get(), &37);
+    /// }
+    /// ```
+     #[inline]
+    pub fn insert_and_return(self, value: V) -> RustcOccupiedEntry<'a, K, V> {
+        let bucket = self.table.insert_no_grow(self.hash, (self.key, value));
+        RustcOccupiedEntry {
+            key: None,
+            elem: bucket,
+            table: self.table
+        }
+    }
 }

 impl<K, V> IterMut<'_, K, V> {
```

This is also only an implementation for HashMap. I tried implementing for BTreeMap, but I don't really understand BTreeMap's internals and require more guidance on implementing the equivalent `VacantEntry::insert_and_return` such that it returns an `OccupiedEntry`. Notably, following the original PR's modifications I end up needing a `Handle<NodeRef<marker::Mut<'_>, _, _, marker::LeafOrInternal>, _>` while I only have a `Handle<NodeRef<marker::Mut<'_>, _, _, marker::Internal>, _>` and don't know how to proceed.

(To be clear, I'm not asking for guidance right now; I'd be happy getting only the HashMap implementation — the subject of this PR — reviewed and ready, and leave the BTreeMap implementation for a latter PR.)
2019-10-09 05:31:33 +02:00
Baoshan Pang
175db95b3d add checking (r == 0) 2019-10-08 18:57:17 -07:00
Jon Gjengset
45aca119a6
Stabilize mem::take (mem_take)
Tracking issue: https://github.com/rust-lang/rust/issues/61129
2019-10-08 18:04:18 -04:00
Félix Saparelli
bdcc21cbc4 Implement (HashMap) Entry::insert as per 2019-10-09 11:00:29 +13:00
Amanieu d'Antras
dfe76a1093 Split non-CAS atomic support off into target_has_atomic_load_store 2019-10-08 20:34:30 +01:00
Mazdak Farrokhzad
bc7df81642
Rollup merge of - Wind-River:master_before_merge, r=rkruppe
use 'invalid argument' for vxWorks

vxWorks is using "invalid argument" instead of "Invalid argument" in reporting invalid options

r? @rkruppe
2019-10-08 05:02:44 +02:00
BaoshanPang
45f7186de3 use 'invalid argument' for vxWorks 2019-10-07 11:52:30 -07:00
Tyler Mandry
69598dc3cf
Rollup merge of - tmandry:revert-emscripten-upgrade, r=tmandry
Revert  - "Upgrade Emscripten targets to use upstream LLVM backend"

This change caused the runtime of the linux-asmjs builder to nearly double from 2+ hours to about 4 hours, which happens to be the bors timeout. (It made it in barely under 4 hours when it was merged.) This is causing timeouts on all new changes.

This reverts commit 7870050796e5904a0fc85ecbe6fa6dde1cfe0c91, reversing
changes made to 2e7244807a7878f6eca3eb7d97ae9b413aa49014.
2019-10-05 21:55:13 -07:00
Tyler Mandry
d54082e5ad
Rollup merge of - BO41:time_typo, r=kennytm
Fix typo on `now()` comments

Fix typo, update words, and remove some redundant word.
Also rustfmt on the rest of the file (hope this is okay :)

revival of 

r? @kennytm
2019-10-05 21:55:10 -07:00
Tyler Mandry
ae2a720e92
Rollup merge of - alexcrichton:less-check-backtrace, r=sfackler
std: Reduce checks for `feature = "backtrace"`

This is a stylistic change to libstd to reduce the number of checks of
`feature = "backtrace"` now that we unconditionally depend on the
`backtrace` crate and rely on it having an empty implementation.
otherwise.
2019-10-05 21:54:51 -07:00
Tyler Mandry
019b5b5f96
Rollup merge of - messense:udp-peer-addr, r=dtolnay
Stabilize UdpSocket::peer_addr

Fixes 
2019-10-05 21:54:49 -07:00
Tyler Mandry
d16b7f705b Revert "Auto merge of - tlively:emscripten-upstream-upgrade, r=alexcrichton"
This reverts commit 7870050796e5904a0fc85ecbe6fa6dde1cfe0c91, reversing
changes made to 2e7244807a7878f6eca3eb7d97ae9b413aa49014.
2019-10-05 21:38:45 -07:00
BO41
318ff305ea Fix typo on now() comments 2019-10-05 12:23:10 +02:00
Thomas Lively
9a55103b98 Upgrade Emscripten targets to use upstream LLVM backend
- Refactors the Emscripten target spec to share code with other wasm
   targets.
 - Replaces the incorrect wasm32 C call ABI with the old asmjs
   version, which is correct for both wasm32 and JS.
 - Updates the varargs ABI used by Emscripten and deletes the old one.
 - Removes the obsolete wasm32-experimental-emscripten target.
 - Temporarily makes Emscripten targets use panic=abort by default
   because supporting unwinding will require an LLVM patch.
2019-10-04 00:47:21 -07:00
Tyler Mandry
f7ee31e3d7
Rollup merge of - stjepang:stabilize-todo, r=withoutboats
Stabilize todo macro

The `todo!` macro is just another name for `unimplemented!`.

Tracking issue: https://github.com/rust-lang/rust/issues/59277

This PR needs a FCP to merge.

r? @withoutboats
2019-10-03 16:25:35 -07:00
Martin Habovštiak
00d9db14f7
Added doc about behavior of extend on HashMap
It was unclear what the implementation does when it encounters existing keys. This change makes it clear by documenting the trait impl.
2019-10-03 10:09:04 +02:00
Ben Boeckel
fb80e6c62e BacktraceStatus: add Eq impl
See discussion on .
2019-10-02 08:17:28 -04:00
Mazdak Farrokhzad
7628cada4f
Rollup merge of - lzutao:unneeded-main-doc, r=jonas-schievink
Remove unneeded `fn main` blocks from docs

## [No whitespace diff](https://github.com/rust-lang/rust/pull/64912/files?w=1)
2019-10-01 23:56:23 +02:00
Lzu Tao
6c1b447f2e Remove unneeded fn main blocks from docs 2019-10-01 11:55:46 +00:00
David Wood
04fa9b1b3f
async/await: improve obligation errors
This commit improves obligation errors for async/await:

```
note: future does not implement `std::marker::Send` because this value is used across an
      await
  --> $DIR/issue-64130-non-send-future-diags.rs:15:5
   |
LL |     let g = x.lock().unwrap();
   |         - has type `std::sync::MutexGuard<'_, u32>`
LL |     baz().await;
   |     ^^^^^^^^^^^ await occurs here, with `g` maybe used later
LL | }
   | - `g` is later dropped here
```

Signed-off-by: David Wood <david@davidtw.co>
2019-09-30 23:41:20 +01:00
Andre Bogus
e77dfa27ca Slice docs: fix typo 2019-09-28 21:02:51 +02:00
Mazdak Farrokhzad
494a8a8525
Rollup merge of - lzutao:stabilize-map_get_key_value, r=SimonSapin
Stabilize map_get_key_value feature

FCP done in https://github.com/rust-lang/rust/issues/49347#issuecomment-521728031
r? @SimonSapin
Closes 
2019-09-28 05:37:54 +02:00
Mazdak Farrokhzad
2d4c101af5
Rollup merge of - Wind-River:master, r=alexcrichton
update rtpSpawn's parameters type(It's prototype has been updated in libc)

r? @alexcrichton
2019-09-28 05:37:51 +02:00
Mazdak Farrokhzad
4c57882cfd
Rollup merge of - llogiq:slices-elems-are-equidistant, r=rkruppe
Docs: slice elements are equidistant

Recently, someone asked why `[char]` and `str` are not interchangeable, and I explained that in a slice, the elements must be laid out equidistantly, whereas the chars in a `str` are stored compactly regardless their size. However I couldn't find this documented anywhere, so here's a small addition of this fact.
2019-09-28 05:37:40 +02:00
Andre Bogus
6ccb7ae643 Docs: slice elements are equidistant 2019-09-27 19:43:56 +02:00
Lzu Tao
c482c84142 Stabilize map_get_key_value feature 2019-09-27 11:21:57 +00:00
Baoshan Pang
dd38a0f6c7 update rtpSpawn's parameters type(It's prototype has been updated in libc) 2019-09-25 20:10:29 -07:00
messense
1de6f74ca4
Update src/libstd/net/udp.rs
Co-Authored-By: Mazdak Farrokhzad <twingoow@gmail.com>
2019-09-26 09:14:45 +08:00
Tyler Mandry
80db06d6da Fix ExitStatus on Fuchsia
Fuchsia exit codes don't follow the convention of libc::WEXITSTATUS et
al, and they are 64 bits instead of 32 bits. This gives Fuchsia its own
representation of ExitStatus.

Additionally, the zircon syscall structs were out of date, causing us to
see bogus return codes.
2019-09-25 15:26:42 -07:00