bors [Thu, 10 Oct 2019 23:43:55 +0000 (23:43 +0000)]
Auto merge of #64823 - cuviper:min-std, r=Mark-Simulacrum
minimize the rust-std component
This changes the `rust-std` dist component to only include the artifacts of compiling the `libstd` step, as listed in `.libstd.stamp`. This does include `test` and `proc-macro` as well. The remaining _unstable_ libraries that are built as part of `rustc` are packaged into a new `rustc-dev` component, intended for use in the development of closely related tools (clippy, miri, rls).
Here are the component sizes from the [try build](https://dev-static.rust-lang.org/dist/2019-10-07/index.html):
bors [Thu, 10 Oct 2019 19:40:48 +0000 (19:40 +0000)]
Auto merge of #65153 - da-x:issue-58017, r=petrochenkov
Improve message when attempting to instantiate tuple structs with private fields
Fixes #58017, fixes #39703.
```
error[E0603]: tuple struct `Error` is private
--> main.rs:22:16
|
2 | pub struct Error(usize, pub usize, usize);
| ----- ----- field is private
| |
| field is private
...
22 | let x = a::Error(3, 1, 2);
| ^^^^^
|
= note: a tuple struct constructor is private if any of its fields is private
```
bors [Thu, 10 Oct 2019 15:40:39 +0000 (15:40 +0000)]
Auto merge of #59546 - sfanxiang:interminable-ub, r=nagisa
Add llvm.sideeffect to potential infinite loops and recursions
LLVM assumes that a thread will eventually cause side effect. This is
not true in Rust if a loop or recursion does nothing in its body,
causing undefined behavior even in common cases like `loop {}`.
Inserting llvm.sideeffect fixes the undefined behavior.
As a micro-optimization, only insert llvm.sideeffect when jumping back
in blocks or calling a function.
A patch for LLVM is expected to allow empty non-terminate code by
default and fix this issue from LLVM side.
https://github.com/rust-lang/rust/issues/28728
**UPDATE:** [Mentoring instructions here](https://github.com/rust-lang/rust/pull/59546#issuecomment-515072429) to unstall this PR
bors [Wed, 9 Oct 2019 03:32:21 +0000 (03:32 +0000)]
Auto merge of #65229 - Centril:rollup-wnr46vg, r=Centril
Rollup of 4 pull requests
Successful merges:
- #64656 (Implement (HashMap) Entry::insert as per #60142)
- #65037 (`#[track_caller]` feature gate (RFC 2091 1/N))
- #65166 (Suggest to add `move` keyword for generator capture)
- #65175 (add more info in debug traces for gcu merging)
Rollup merge of #64656 - passcod:map-entry-insert, r=Amanieu
Implement (HashMap) Entry::insert as per #60142
Implementation of `Entry::insert` as per @SimonSapin's comment on #60142. 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.)
bors [Tue, 8 Oct 2019 21:32:07 +0000 (21:32 +0000)]
Auto merge of #65223 - Centril:rollup-5sdvdni, r=Centril
Rollup of 7 pull requests
Successful merges:
- #64284 (Warn if include macro fails to include entire file)
- #65081 (Remove -Zprofile-queries)
- #65133 (typeck: prohibit foreign statics w/ generics)
- #65135 (Add check for missing tests for error codes)
- #65141 (Replace code of conduct with link)
- #65194 (Use structured suggestion for removal of `as_str()` call)
- #65213 (Ignore `ExprKind::DropTemps` for some ref suggestions)
Rollup merge of #65141 - BO41:code-of-conduct, r=Mark-Simulacrum
Replace code of conduct with link
This will replace the code of conduct and link to a single version at https://www.rust-lang.org/conduct.html
Fixes https://github.com/rust-lang/rust/pull/61531#issuecomment-501473787
Rollup merge of #65133 - davidtwco:issue-65035-static-with-generic-in-foreign-mod, r=petrochenkov
typeck: prohibit foreign statics w/ generics
Fixes #65035 and fixes #65025.
This PR modifies resolve to disallow foreign statics that have
generics.
`improper_ctypes` is not written to support type parameters, as these
are normally disallowed before the lint is run. Thus, type parameters in
foreign statics must be prohibited before the lint.
The only other case where this *could* have occured is in functions,
but typeck prohibits this with a "foreign items may not have type
parameters" error - a similar error did not exist for statics, because
statics cannot have type parameters, but they can use any
type parameters that are in scope (which isn't the case for functions).
Rollup merge of #64284 - Mark-Simulacrum:include-warn, r=petrochenkov
Warn if include macro fails to include entire file
This currently introduces an error, mainly because that was just simpler, and I'm not entirely certain if we can introduce a lint without an RFC and such.
This is primarily to get feedback on the approach and overall aim -- in particular, do we think this is helpful? If so, we probably will need lang-team sign off and decide if it should be an error (as currently introduced by this PR), a lint, or a warning.
David Wood [Sat, 5 Oct 2019 15:55:58 +0000 (16:55 +0100)]
resolve: prohibit foreign statics w/ generics
This commit modifies resolve to disallow foreign statics that use
parent generics.
`improper_ctypes` is not written to support type parameters, as these
are normally disallowed before the lint is run. Thus, type parameters in
foreign statics must be prohibited before the lint.
The only other case where this *could* have occured is in functions,
but typeck prohibits this with a "foreign items may not have type
parameters" error - a similar error did not exist for statics, because
statics cannot have type parameters, but they can use any
type parameters that are in scope (which isn't the case for functions).
bors [Tue, 8 Oct 2019 17:31:35 +0000 (17:31 +0000)]
Auto merge of #65209 - Centril:rollup-tzc0j87, r=Centril
Rollup of 8 pull requests
Successful merges:
- #64404 (Add long error explanation for E0495)
- #64918 (Add long error explanation for E0551)
- #65102 (Disable stack probe when thread sanitizer is enabled)
- #65120 (Correctly estimate the required space for string in `StyledBuffer::prepend`)
- #65145 (When suggesting assoc function with type params, include turbofish)
- #65162 (Remove loaded_from_cache map from DepGraph)
- #65176 (Remove query-related macros)
- #65179 (Add long error explanation for E0567)
Rollup merge of #65162 - Mark-Simulacrum:no-cache-loading-map, r=michaelwoerister
Remove loaded_from_cache map from DepGraph
It's now unused, even with -Zquery-dep-graph
From https://github.com/rust-lang/rust/pull/63756/files#r316039379 -- it'll simplify that PR to get this landed separately so we can just remove some of the code that it touches.
Rollup merge of #65102 - tmiasko:tsan-probe-stack, r=alexcrichton
Disable stack probe when thread sanitizer is enabled
When thread sanitizer instrumentation is enabled during compilation of
stack probe function, the function will be miscompiled and trigger
segmentation fault at runtime. Disable stack probes when tsan is
enabled.
Currently, when two tokens must be glued together, this function duplicates
large chunks of the existing streams. This can cause quadratic behaviour.
This commit changes the function so that it overwrites the last token with a
glued token, which avoids the quadratic behaviour. This removes the need for
`TokenStreamBuilder::push_all_but_{first,last}_tree`.
The commit also restructures `push` somewhat, by removing
`TokenStream::{first_tree_and_joint,last_tree_if_joint}` in favour of more
pattern matching and some comments. This makes the code shorter, and in my
opinion, more readable.
Currently, this function creates a new empty stream, and then appends
the elements from each given stream onto that stream. This can cause
quadratic behaviour.
This commit changes the function so that it modifies the first stream
(which can be long) by extending it with the elements from the
subsequent streams (which are almost always short), which avoids the
quadratic behaviour.
bors [Tue, 8 Oct 2019 04:35:03 +0000 (04:35 +0000)]
Auto merge of #65196 - Centril:rollup-q06lcxm, r=Centril
Rollup of 8 pull requests
Successful merges:
- #64726 (rewrite documentation for unimplemented! to clarify use)
- #65040 (syntax: more cleanups in item and function signature parsing)
- #65046 (Make `Cell::new` method come first in documentation)
- #65098 (Add long error explanation for E0561)
- #65150 (Suggest dereferencing boolean reference when used in 'if' or 'while')
- #65154 (Fix const generic arguments not displaying in types mismatch diagnostic)
- #65181 (fix bug in folding for constants)
- #65187 (use 'invalid argument' for vxWorks)
Rollup merge of #65181 - nikomatsakis:lazy-norm-anon-const-push-1, r=varkor
fix bug in folding for constants
These was a bug in the folding for constants that caused it to overlook bound regions. This branch includes some other little things that I did while trying to track the bug down.
Rollup merge of #65046 - sinkuu:cell_reorder, r=shepmaster
Make `Cell::new` method come first in documentation
Methods to create a thing usually comes first in `std` documentation, and `Cell` has been an exception. Also, `T: Copy` specialized methods should not be on top of the page. (This had led me to miss that most of its methods are not bounded by `Copy`...)
Rollup merge of #64726 - andrewbanchich:unimplemented, r=rkruppe
rewrite documentation for unimplemented! to clarify use
The current docs for `unimplemented!` seem to miss the point of this macro.
> This can be useful if you are prototyping and are just looking to have your code type-check, or if you're implementing a trait that requires multiple methods, and you're only planning on using one of them.
You could also return a `()` if you just want your code to type-check.
I think `unimplemented!` is useful for when you want your program to exit when it reaches an unimplemented area.
I rewrote the explanation and gave examples of both forms of this macro that I think clarify its use a little better.
bors [Tue, 8 Oct 2019 01:05:08 +0000 (01:05 +0000)]
Auto merge of #65186 - mati865:cargoup, r=alexcrichton
Update Cargo
To pull rust-lang/cargo#7482
List of merged PRs:
- Fix wrong directories in PATH on Windows (rust-lang/cargo#7482)
- Update SPDX list to 3.6 (rust-lang/cargo#7481)
- Mark Emscripten's .wasm files auxiliary (rust-lang/cargo#7476)
- Update `curl-sys` dependency requirement (rust-lang/cargo#7464)
- add dependencies for `pkg-config` (rust-lang/cargo#7443)
- Removing hash from output files when using MSVC (rust-lang/cargo#7400)
- Disable preserving mtimes on archives (rust-lang/cargo#7465)
- Removed redundant borrow (rust-lang/cargo#7462)
- Public dependency refactor and re-allow backjumping (rust-lang/cargo#7361)
- unify the quote in Cargo.toml (rust-lang/cargo#7461)