Commit Graph

100322 Commits

Author SHA1 Message Date
Nicholas Nethercote
18b48bf4b9 Lazify some mac_placeholder() calls.
This avoids some unnecessary creation of empty token streams.
2019-10-14 09:19:40 +11:00
Nicholas Nethercote
1ce0347fd4 Use TokenStream::default() in more places. 2019-10-14 09:19:31 +11:00
Nicholas Nethercote
5c93492da9 Remove the Option in TokenStream.
It means an allocation is required to create an empty `TokenStream`, but
all other operations are simpler and marginally faster due to not having
to check for `None`. Overall it simplifies the code for a negligible
performance effect.

The commit also removes `TokenStream::empty` by implementing `Default`,
which is now possible.
2019-10-14 09:14:39 +11:00
bors
20cc752726 Auto merge of #65228 - Wind-River:real_master, r=dtolnay
vxworks: add checking (r == 0)
2019-10-09 16:31:49 +00:00
bors
321ccbe1db Auto merge of #65208 - michaelwoerister:sp-events-review-2, r=wesleywiser
self-profiling: Add events for everything except trait selection.

This is the followup PR to https://github.com/rust-lang/rust/pull/64840.

Trait selection events are still missing (at least those not covered by regular queries).

r? @wesleywiser (or @Mark-Simulacrum if @wesleywiser is not available at the moment)
2019-10-09 12:51:07 +00:00
Michael Woerister
ceb1a9cfe3 self-profiling: Add events for everything except trait selection. 2019-10-09 13:40:44 +02:00
bors
e59dab52d4 Auto merge of #65198 - nnethercote:fix-65080, r=Mark-Simulacrum
Speed up `TokenStream` concatenation

This PR fixes the quadratic behaviour identified in #65080.

r? @Mark-Simulacrum
2019-10-09 08:57:26 +00:00
bors
275cf4bcac 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)

Failed merges:

r? @ghost
2019-10-09 03:32:21 +00:00
Mazdak Farrokhzad
e27f029836
Rollup merge of #65175 - andjo403:partitioning, r=zackmdavis
add more info in debug traces for gcu merging

to help in investigation of CGU partitioning problems e.g https://github.com/rust-lang/rust/issues/64913
2019-10-09 05:31:38 +02:00
Mazdak Farrokhzad
5bbdcb6734
Rollup merge of #65166 - csmoe:async-move, r=estebank
Suggest to add `move` keyword for generator capture

 Closes #64382
r? @estebank
2019-10-09 05:31:36 +02:00
Mazdak Farrokhzad
ae5bb7e289
Rollup merge of #65037 - anp:track-caller, r=oli-obk
`#[track_caller]` feature gate (RFC 2091 1/N)

RFC text: https://github.com/rust-lang/rfcs/blob/master/text/2091-inline-semantic.md
Tracking issue: https://github.com/rust-lang/rust/issues/47809

I started with @ayosec's commit to add the feature gate with tests and rebased it onto current master. I fixed up some tidy lints and added a test.
2019-10-09 05:31:35 +02:00
Mazdak Farrokhzad
27240fe77b
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.)
2019-10-09 05:31:33 +02:00
Baoshan Pang
175db95b3d add checking (r == 0) 2019-10-08 18:57:17 -07:00
Félix Saparelli
bdcc21cbc4 Implement (HashMap) Entry::insert as per #60142 2019-10-09 11:00:29 +13:00
bors
b5bd31ec6d 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)

Failed merges:

r? @ghost
2019-10-08 21:32:07 +00:00
Mazdak Farrokhzad
ff51611c42
Rollup merge of #65213 - estebank:peel-drop-temps, r=Centril
Ignore `ExprKind::DropTemps` for some ref suggestions

Introduce `Expr::peel_drop_temps()` to ignore `ExprKind::DropTemps` for suggestions that depend on the `ExprKind` for accuracy.
2019-10-08 23:31:28 +02:00
Mazdak Farrokhzad
4a6304fb05
Rollup merge of #65194 - estebank:remove_str, r=petrochenkov
Use structured suggestion for removal of `as_str()` call

Follow up to #64739.
2019-10-08 23:31:27 +02:00
Mazdak Farrokhzad
88d75c36c3
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

r? @Mark-Simulacrum
2019-10-08 23:31:25 +02:00
Mazdak Farrokhzad
ecd6229f72
Rollup merge of #65135 - GuillaumeGomez:add-error-code-check, r=Mark-Simulacrum
Add check for missing tests for error codes

Fixes #64811.

r? @Mark-Simulacrum
2019-10-08 23:31:24 +02:00
Mazdak Farrokhzad
9b989ea298
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).
2019-10-08 23:31:22 +02:00
Mazdak Farrokhzad
3f2ae44ba4
Rollup merge of #65081 - Mark-Simulacrum:remove-profile-queries, r=michaelwoerister
Remove -Zprofile-queries

r? @michaelwoerister

Per [zulip thread](https://zulip-archive.rust-lang.org/131828tcompiler/57361RemoveZprofilequeries.html).
2019-10-08 23:31:20 +02:00
Mazdak Farrokhzad
fc068222d0
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.

r? @petrochenkov

cc https://github.com/rust-lang/rust/issues/35560
2019-10-08 23:31:19 +02:00
David Wood
ccbf2b76a6
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).

Signed-off-by: David Wood <david@davidtw.co>
2019-10-08 18:46:24 +01:00
bors
2748a9fd93 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)

Failed merges:

r? @ghost
2019-10-08 17:31:35 +00:00
Esteban Küber
d0eea6ff6d review comments 2019-10-08 09:56:05 -07:00
Esteban Küber
ac9025c197 Call Expr::peel_drop_temps() from more places for more accurate suggestions 2019-10-08 08:42:26 -07:00
Esteban Küber
d84c4cd718 Ignore ExprKind::DropTemps for some ref suggestions 2019-10-08 08:26:42 -07:00
Mazdak Farrokhzad
3246ab2427
Rollup merge of #65179 - GuillaumeGomez:long-err-explanation-E0567, r=davidtwco
Add long error explanation for E0567

Part of #61137.
2019-10-08 15:45:34 +02:00
Mazdak Farrokhzad
0d17de89ba
Rollup merge of #65176 - nnethercote:rm-query-macros, r=michaelwoerister
Remove query-related macros

The query system has a few macros that only have one or two call sites, and I find they hurt readability. This PR removes them.

r? @michaelwoerister
2019-10-08 15:45:32 +02:00
Mazdak Farrokhzad
f2dc3467f4
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.

r? @Zoxc or @michaelwoerister
2019-10-08 15:45:31 +02:00
Mazdak Farrokhzad
58bfe3b0ec
Rollup merge of #65145 - estebank:turbofish-assoc-fn-call, r=varkor
When suggesting assoc function with type params, include turbofish

Fix https://github.com/rust-lang/rust/issues/61412, fix https://github.com/rust-lang/rust/issues/61411.
2019-10-08 15:45:29 +02:00
Mazdak Farrokhzad
153d3c3ea7
Rollup merge of #65120 - AnthonyMikh:fix_65119, r=estebank
Correctly estimate the required space for string in `StyledBuffer::prepend`

Fix #65119

r? @estebank
2019-10-08 15:45:28 +02:00
Mazdak Farrokhzad
3c5f8a1da0
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.
2019-10-08 15:45:26 +02:00
Mazdak Farrokhzad
7153c9262a
Rollup merge of #64918 - GuillaumeGomez:long-err-explanation-E0551, r=oli-obk
Add long error explanation for E0551

Part of #61137
2019-10-08 15:45:25 +02:00
Mazdak Farrokhzad
6f211f1539
Rollup merge of #64404 - GuillaumeGomez:err-E0495, r=Dylan-DPC
Add long error explanation for E0495

Part of #61137.
2019-10-08 15:45:23 +02:00
bors
3fa9554d77 Auto merge of #65206 - mati865:clippyup, r=oli-obk
Update Clippy

I cannot test it locally but Clippy CI is green so it should work.

Fixes https://github.com/rust-lang/rust/issues/65096
2019-10-08 13:41:12 +00:00
Mateusz Mikuła
6d3e242a2b Update Clippy 2019-10-08 14:14:09 +02:00
Guillaume Gomez
6608e4af1b Update ui tests 2019-10-08 13:57:40 +02:00
Guillaume Gomez
61d92a0952 Add long error explanation for E0567 2019-10-08 13:57:39 +02:00
csmoe
d1d256592b suggest to add move keyword for generator 2019-10-08 11:13:48 +00:00
bors
ec557aa818 Auto merge of #64949 - nnethercote:avoid-SmallVec-collect, r=zackmdavis
Avoid `SmallVec::collect`

We can get sizeable speed-ups by avoiding `SmallVec::collect` when the number of elements is small.
2019-10-08 08:08:21 +00:00
Nicholas Nethercote
75e0078a17 Optimize TokenStreamBuilder::push.
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.
2019-10-08 16:57:29 +11:00
Nicholas Nethercote
3832a634d3 Optimize TokenStream::from_streams.
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.
2019-10-08 16:57:07 +11:00
bors
1e1f25e31b 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)

Failed merges:

 - #65179 (Add long error explanation for E0567)

r? @ghost
2019-10-08 04:35:03 +00:00
Mazdak Farrokhzad
bc7df81642
Rollup merge of #65187 - 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
Mazdak Farrokhzad
f23c9f4565
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.

r? @oli-obk
2019-10-08 05:02:43 +02:00
Mazdak Farrokhzad
ecdb5e98cb
Rollup merge of #65154 - skinny121:const-arg-diagnostic, r=varkor
Fix const generic arguments not displaying in types mismatch diagnostic

Fixes #61395
2019-10-08 05:02:41 +02:00
Mazdak Farrokhzad
5422ed7834
Rollup merge of #65150 - XiangQingW:master, r=estebank
Suggest dereferencing boolean reference when used in 'if' or 'while'

Implements #64557
2019-10-08 05:02:39 +02:00
Mazdak Farrokhzad
73685ec56f
Rollup merge of #65098 - GuillaumeGomez:long-err-explanation-E0561, r=Centril
Add long error explanation for E0561

Part of #61137
2019-10-08 05:02:38 +02:00
Mazdak Farrokhzad
a9777b3061
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`...)
2019-10-08 05:02:36 +02:00