]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agoRollup merge of #78224 - lcnr:repeat-expr, r=varkor
Yuki Okushi [Thu, 29 Oct 2020 03:08:40 +0000 (12:08 +0900)]
Rollup merge of #78224 - lcnr:repeat-expr, r=varkor

min_const_generics: allow ty param in repeat expr

implements https://rust-lang.zulipchat.com/#narrow/stream/260443-project-const-generics/topic/repeat.20expressions

Even with `min_const_generics` active, now keeps resulting in future compat warnings instead of hard errors.
Const parameters, for example `[0; N + 1]`, still result in hard errors during resolve.
```rust
#![allow(dead_code)]

fn foo<T>() {
    [0; std::mem::size_of::<*mut T>()];
}

struct Foo<T>(T);

impl<T> Foo<T> {
    const ASSOC: usize = 4;

    fn test() {
        [0; Self::ASSOC];
    }
}
```

r? @varkor cc @petrochenkov

3 years agoRollup merge of #77213 - ijackson:wip-rustdoc-settings, r=jyn514,GuillaumeGomez
Yuki Okushi [Thu, 29 Oct 2020 03:08:38 +0000 (12:08 +0900)]
Rollup merge of #77213 - ijackson:wip-rustdoc-settings, r=jyn514,GuillaumeGomez

rustdoc options to set default theme (and other settings)

Hi.  This is the MR I promised in #77024

It is a little more general than I envisaged there.  Once I had found the settings-handling machinery it seemed foolish to add this feature just for the theme.

Closes #77024

3 years agorustdoc: Use Vec::into_iter() rather than drain()
Ian Jackson [Wed, 28 Oct 2020 21:29:21 +0000 (21:29 +0000)]
rustdoc: Use Vec::into_iter() rather than drain()

This allows removing a `mut` which is nicer.

Suggested-by: @jyn514
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoAdd a comment about non-panicking of splitn().next().unwrap()
Ian Jackson [Wed, 28 Oct 2020 21:25:47 +0000 (21:25 +0000)]
Add a comment about non-panicking of splitn().next().unwrap()

Co-authored-by: Joshua Nelson <joshua@yottadb.com>
3 years agorustdoc: Fix some nits
Ian Jackson [Wed, 28 Oct 2020 20:12:15 +0000 (20:12 +0000)]
rustdoc: Fix some nits

* Remove a needless comma in the Rust code
* Replace double spaces after full stops with single spaces

Requested-by: @GuillaumeGomez
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoAuto merge of #78415 - tgnottingham:expn_id_tag_hash, r=Aaron1011
bors [Wed, 28 Oct 2020 20:03:55 +0000 (20:03 +0000)]
Auto merge of #78415 - tgnottingham:expn_id_tag_hash, r=Aaron1011

rustc_span: avoid hashing ExpnId tag when using cached hash

3 years agorustdoc: Provide a --default-theme THEME option
Ian Jackson [Wed, 28 Oct 2020 17:53:12 +0000 (17:53 +0000)]
rustdoc: Provide a --default-theme THEME option

This is a fairly simple special case of --default-eetting.  We must
set both "theme" and "use-system-theme".

Providing it separately enables us to document a way to set the theme
without expoosing the individual settings keywords, which are quite
complex.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agorustdoc: Provide a general --default-setting SETTING[=VALUE] option
Ian Jackson [Tue, 13 Oct 2020 17:52:43 +0000 (18:52 +0100)]
rustdoc: Provide a general --default-setting SETTING[=VALUE] option

We just plumb through what the user tells us.

This is flagged as unstable, mostly because I don't understand the
compatibility rules that rustdoc obeys for local storage data, and how
error handling of invalid data works.

We collect() the needed HashMap from Vec of Vecs of (key, value)
pairs, so that there is a nice place to add new more-specific options.
It would have been possible to use Extend::extend but doing it this
way ensures that all the used inputs are (and will stay) right next to
each other.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agorustdoc: Provide a way to set the default settings from Rust code
Ian Jackson [Wed, 23 Sep 2020 21:44:54 +0000 (22:44 +0100)]
rustdoc: Provide a way to set the default settings from Rust code

rustdoc has various user-configurable preferences.  These are recorded
in web Local Storage (where available).  But we want to provide a way
to configure the default default, including for when web storage is
not available.

getSettingValue is the function responsible for looking up these
settings.  Here we make it fall back some in-DOM data, which
ultimately comes from RenderOptions.default_settings.

Using HTML data atrtributes is fairly convenient here, dsspite the
need to transform between snake and kebab case to avoid the DOM
converting kebab case to camel case (!)

We cache the element and dataset lookup in a global variable, to
ensure that getSettingValue remains fast.

The DOM representation has to be in an element which precedes the
inclusion of storage.js.  That means it has to be in the <head> and we
should not use an empty <div> as the container (although most browsers
will accept that).  An empty <script> element provides a convenient
and harmless container object.  <meta> would be another possibility
but runs a greater risk of having unwanted behaviours on weird
browsers.

We trust the RenderOptions not to contain unhelpful setting names,
which don't fit nicely into an HTML attribute.  It's awkward to quote
dataset keys.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoAuto merge of #78414 - nox:function-sections, r=nagisa,bjorn3
bors [Wed, 28 Oct 2020 17:47:36 +0000 (17:47 +0000)]
Auto merge of #78414 - nox:function-sections, r=nagisa,bjorn3

Implement -Z function-sections=yes|no

This lets rustc users tweak whether all functions should be put in their own TEXT section, using whatever default value the target defines if the flag is missing.

I'm having fun experimenting with musl libc and trying to implement the start symbol in Rust, that means avoiding code that requires relocations, and AFAIK putting everything in its own section makes the toolchain generate `GOTPCREL` relocations for symbols that could use plain old PC-relative addressing (at least on `x86_64`) if they were all in the same section.

3 years agorustdoc: js: Use getSettingValue for all rustdoc-* values
Ian Jackson [Wed, 23 Sep 2020 21:14:43 +0000 (22:14 +0100)]
rustdoc: js: Use getSettingValue for all rustdoc-* values

Currently, storage.js and main.js have many open-coded calls to
getCurrentValue for "rustdoc-" values, but these are settings and
should be handled by getSettingValue.

So make getSettingValue part of storage.js (where everyone can call
it) and use it everywhere.

No functional change yet.  We are going to make getSettingValue do
something more sophisticated in a moment.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoAuto merge of #78409 - pietroalbini:build-manifest-checksum-cache, r=Mark-Simulacrum
bors [Wed, 28 Oct 2020 14:52:20 +0000 (14:52 +0000)]
Auto merge of #78409 - pietroalbini:build-manifest-checksum-cache, r=Mark-Simulacrum

Add checksums cache to build-manifest

During the release process we're currently calculating the SHA256 of each file three times:

1. In `build-manifest`, to fill the `hash = "f00"` keys of the manifests.
2. In `promote-release`, to generate the `.sha256` files.
3. In `promote-release`, to generate the `.asc` GPG signatures.

Calculations 1. and 2. could be merged into a single one if there was a way for `build-manifest` to pass the checksums it generated over to `promote-release`. Unfortunately calculation 3. can't be merged as GPG requires extra metadata to be hashed.

This PR adds support for merging 1. and 2. by creating the `BUILD_MANIFEST_CHECKSUM_CACHE` environment variable, which points to a JSON file storing a cache of all the calculated checksums. `build-manifest` will load it at startup and avoid generating existing checksums, and it will dump its internal checksums cache into it when it exits successfully.

This PR also allows to run `build-manifest` multiple times without the need to wait for checksums to be calculated in the following invocations. The speedup will allow to work torwards a fix for https://github.com/rust-lang/promote-release/issues/15 without impacting the release process duration nor our storage costs.

This PR can be reviewed commit-by-commit.
r? `@Mark-Simulacrum`

3 years agoAuto merge of #78323 - est31:smaller_list_overlap, r=varkor
bors [Wed, 28 Oct 2020 03:58:32 +0000 (03:58 +0000)]
Auto merge of #78323 - est31:smaller_list_overlap, r=varkor

Iterate over the smaller list

If there are two lists of different sizes,
iterating over the smaller list and then
looking up in the larger list is cheaper
than vice versa, because lookups scale
sublinearly.

3 years agoAuto merge of #78458 - Dylan-DPC:rollup-tan044s, r=Dylan-DPC
bors [Wed, 28 Oct 2020 01:40:06 +0000 (01:40 +0000)]
Auto merge of #78458 - Dylan-DPC:rollup-tan044s, r=Dylan-DPC

Rollup of 10 pull requests

Successful merges:

 - #78152 (Separate unsized locals)
 - #78297 (Suggest calling await on method call and field access)
 - #78351 (Move "mutable thing in const" check from interning to validity)
 - #78365 (check object safety of generic constants)
 - #78379 (Tweak invalid `fn` header and body parsing)
 - #78391 (Add const_fn in generics test)
 - #78401 (resolve: private fields in tuple struct ctor diag)
 - #78408 (Remove tokens from foreign items in `TokenStripper`)
 - #78447 (Fix typo in  comment)
 - #78453 (Fix typo in comments)

Failed merges:

r? `@ghost`

3 years agoRollup merge of #78453 - Storyyeller:patch-1, r=jonas-schievink
Dylan DPC [Wed, 28 Oct 2020 00:21:39 +0000 (01:21 +0100)]
Rollup merge of #78453 - Storyyeller:patch-1, r=jonas-schievink

Fix typo in comments

3 years agoRollup merge of #78447 - bugadani:typo, r=matthewjasper
Dylan DPC [Wed, 28 Oct 2020 00:21:37 +0000 (01:21 +0100)]
Rollup merge of #78447 - bugadani:typo, r=matthewjasper

Fix typo in  comment

I hope I got all the typos in that word. :)

3 years agoRollup merge of #78408 - Aaron1011:fix/remove-foreign-tokens, r=oli-obk
Dylan DPC [Wed, 28 Oct 2020 00:21:34 +0000 (01:21 +0100)]
Rollup merge of #78408 - Aaron1011:fix/remove-foreign-tokens, r=oli-obk

Remove tokens from foreign items in `TokenStripper`

Fixes #78398

I forgot to handle this case in #77255

3 years agoRollup merge of #78401 - davidtwco:issue-75906-tuple-construct-private-field, r=estebank
Dylan DPC [Wed, 28 Oct 2020 00:21:31 +0000 (01:21 +0100)]
Rollup merge of #78401 - davidtwco:issue-75906-tuple-construct-private-field, r=estebank

resolve: private fields in tuple struct ctor diag

Fixes #75906.

This PR improves the diagnostic emitted when a tuple struct is being constructed which has private fields so that private fields are labelled and the message is improved.

r? @estebank

3 years agoRollup merge of #78391 - JulianKnodt:mc_test, r=lcnr
Dylan DPC [Wed, 28 Oct 2020 00:21:27 +0000 (01:21 +0100)]
Rollup merge of #78391 - JulianKnodt:mc_test, r=lcnr

Add const_fn in generics test

Adds a test that constant functions in generic parameters work properly. I was surprised this works, but I also to turbofish the constant in main, otherwise it didn't infer properly:
```
let v: ConstU32<3> = ...
```
Did not work as I expected, which I can highlight in the test if that's the intended behaviour.

r? @lcnr

3 years agoRollup merge of #78379 - estebank:fn-signature-parse, r=varkor
Dylan DPC [Wed, 28 Oct 2020 00:21:24 +0000 (01:21 +0100)]
Rollup merge of #78379 - estebank:fn-signature-parse, r=varkor

Tweak invalid `fn` header and body parsing

* Rely on regular "expected"/"found" parser error for `fn`, fix #77115
* Recover empty `fn` bodies when encountering `}`
* Recover trailing `>` in return types
* Recover from non-type in array type `[<BAD TOKEN>; LEN]`

3 years agoRollup merge of #78365 - lcnr:const-eval-obj-safety, r=oli-obk
Dylan DPC [Wed, 28 Oct 2020 00:21:21 +0000 (01:21 +0100)]
Rollup merge of #78365 - lcnr:const-eval-obj-safety, r=oli-obk

check object safety of generic constants

As `Self` can only be effectively used in constants with `const_evaluatable_checked` this should not matter outside of it.

Implements the first item of #72219

> Object safety interactions with constants

r? @oli-obk for now cc @nikomatsakis

3 years agoRollup merge of #78351 - RalfJung:validity-unsafe-cell, r=oli-obk
Dylan DPC [Wed, 28 Oct 2020 00:21:18 +0000 (01:21 +0100)]
Rollup merge of #78351 - RalfJung:validity-unsafe-cell, r=oli-obk

Move "mutable thing in const" check from interning to validity

This moves the check for mutable things (such as `UnsafeCell` or `&mut`) in a`const` from interning to validity. That means we can give more targeted error messages (pointing out *where* the problem lies), and we can simplify interning a bit.

Also fix the interning mode used for promoteds in statics.

r? @oli-obk

3 years agoRollup merge of #78297 - estebank:match-semicolon-2, r=oli-obk
Dylan DPC [Wed, 28 Oct 2020 00:21:10 +0000 (01:21 +0100)]
Rollup merge of #78297 - estebank:match-semicolon-2, r=oli-obk

Suggest calling await on method call and field access

When encountering a failing method or field resolution on a `Future`,
look at the `Output` and try the same operation on it. If successful,
suggest calling `.await` on the `Future`.

This had already been introduced in #72784, but at some point they
stopped working.

Built on top of #78214, only last commit is relevant.

r? @oli-obk

3 years agoRollup merge of #78152 - spastorino:separate-unsized-locals, r=oli-obk
Dylan DPC [Wed, 28 Oct 2020 00:21:08 +0000 (01:21 +0100)]
Rollup merge of #78152 - spastorino:separate-unsized-locals, r=oli-obk

Separate unsized locals

Closes #71694

Takes over again #72029 and #74971

cc @RalfJung @oli-obk @pnkfelix @eddyb as they've participated in previous reviews of this PR.

3 years agoAuto merge of #75671 - nathanwhit:cstring-temp-lint, r=oli-obk
bors [Tue, 27 Oct 2020 22:59:13 +0000 (22:59 +0000)]
Auto merge of #75671 - nathanwhit:cstring-temp-lint, r=oli-obk

Uplift `temporary-cstring-as-ptr` lint from `clippy` into rustc

The general consensus seems to be that this lint covers a common enough mistake to warrant inclusion in rustc.
The diagnostic message might need some tweaking, as I'm not sure the use of second-person perspective matches the rest of rustc, but I'd like to hear others' thoughts on that.

(cc #53224).

r? `@oli-obk`

3 years agoFix typo in comments
Robert Grosse [Tue, 27 Oct 2020 21:23:58 +0000 (14:23 -0700)]
Fix typo in comments

3 years agoAdd const_fn in generics test
kadmin [Mon, 26 Oct 2020 08:19:05 +0000 (08:19 +0000)]
Add const_fn in generics test

3 years agoMerge unsized locals pat tests
Santiago Pastorino [Wed, 21 Oct 2020 11:23:40 +0000 (08:23 -0300)]
Merge unsized locals pat tests

3 years agoUse unsized_feature_enabled helper function
Santiago Pastorino [Wed, 21 Oct 2020 10:50:15 +0000 (07:50 -0300)]
Use unsized_feature_enabled helper function

3 years agois -> are both
Santiago Pastorino [Wed, 21 Oct 2020 10:36:29 +0000 (07:36 -0300)]
is -> are both

3 years agoBless tests again
Santiago Pastorino [Wed, 21 Oct 2020 10:35:19 +0000 (07:35 -0300)]
Bless tests again

3 years agoHide outermost_fn_param_pat, it's an internal detail
Santiago Pastorino [Wed, 21 Oct 2020 00:56:29 +0000 (21:56 -0300)]
Hide outermost_fn_param_pat, it's an internal detail

3 years agoor -> and
Santiago Pastorino [Wed, 21 Oct 2020 00:53:54 +0000 (21:53 -0300)]
or -> and

3 years agoAdd comment explaining why in these tests unsized locals are not accepted
Santiago Pastorino [Wed, 21 Oct 2020 00:52:49 +0000 (21:52 -0300)]
Add comment explaining why in these tests unsized locals are not accepted

3 years agoparam -> parameter, pat -> pattern
Santiago Pastorino [Tue, 20 Oct 2020 20:45:36 +0000 (17:45 -0300)]
param -> parameter, pat -> pattern

3 years agoRename within_fn_param to outermost_fn_param_pat
Santiago Pastorino [Tue, 20 Oct 2020 16:40:18 +0000 (13:40 -0300)]
Rename within_fn_param to outermost_fn_param_pat

3 years agoDo not use unsized_fn_params in patterns
Santiago Pastorino [Tue, 20 Oct 2020 16:30:47 +0000 (13:30 -0300)]
Do not use unsized_fn_params in patterns

3 years agoProperly restore within_fn_param value to the previous state
Santiago Pastorino [Tue, 20 Oct 2020 16:23:58 +0000 (13:23 -0300)]
Properly restore within_fn_param value to the previous state

3 years agoTest that unsized locals fail when turning unsized_fn_params feature flag on
Santiago Pastorino [Tue, 20 Oct 2020 16:08:40 +0000 (13:08 -0300)]
Test that unsized locals fail when turning unsized_fn_params feature flag on

3 years agoBetter test unsized_fn_params
Santiago Pastorino [Tue, 20 Oct 2020 15:40:02 +0000 (12:40 -0300)]
Better test unsized_fn_params

3 years agoBless issue-53448 test
Santiago Pastorino [Tue, 20 Oct 2020 15:39:32 +0000 (12:39 -0300)]
Bless issue-53448 test

3 years agounsized_locals feature is not needed in this test
Santiago Pastorino [Sat, 17 Oct 2020 02:19:58 +0000 (23:19 -0300)]
unsized_locals feature is not needed in this test

3 years agoDo not depend on except for bootstrap
Santiago Pastorino [Sat, 17 Oct 2020 02:19:26 +0000 (23:19 -0300)]
Do not depend on  except for bootstrap

3 years agoFix unstable-book doc tests
Santiago Pastorino [Sun, 24 May 2020 20:22:41 +0000 (17:22 -0300)]
Fix unstable-book doc tests

3 years agoUsing unsized_local feature is not needed in these tests
Santiago Pastorino [Sat, 23 May 2020 19:26:20 +0000 (16:26 -0300)]
Using unsized_local feature is not needed in these tests

3 years agoMake tidy happy
Santiago Pastorino [Sat, 23 May 2020 12:35:22 +0000 (09:35 -0300)]
Make tidy happy

3 years agoThis flag is not really needed in the test
Santiago Pastorino [Fri, 16 Oct 2020 22:38:46 +0000 (19:38 -0300)]
This flag is not really needed in the test

3 years agoAdd unsized_locals to INCOMPLETE_FEATURES list
Santiago Pastorino [Fri, 16 Oct 2020 22:37:54 +0000 (19:37 -0300)]
Add unsized_locals to INCOMPLETE_FEATURES list

3 years agoAdd unsized_fn_params feature
Santiago Pastorino [Fri, 16 Oct 2020 20:46:59 +0000 (17:46 -0300)]
Add unsized_fn_params feature

3 years agoFix typo in vec_graph
Dániel Buga [Tue, 27 Oct 2020 17:37:43 +0000 (18:37 +0100)]
Fix typo in vec_graph

3 years agoFix typos in arena comments
Dániel Buga [Tue, 27 Oct 2020 17:14:21 +0000 (18:14 +0100)]
Fix typos in arena comments

3 years agoAuto merge of #76269 - ayrtonm:function-reference-lint, r=oli-obk
bors [Tue, 27 Oct 2020 16:32:23 +0000 (16:32 +0000)]
Auto merge of #76269 - ayrtonm:function-reference-lint, r=oli-obk

added a lint against function references

this lint suggests casting function references to `*const ()`
closes #75239
r? `@RalfJung`

3 years agoFix typo in comment
Dániel Buga [Tue, 27 Oct 2020 15:55:20 +0000 (16:55 +0100)]
Fix typo in  comment

3 years agoAdded suggestion to `function_item_references` lint and fixed warning message
Ayrton [Tue, 27 Oct 2020 13:00:19 +0000 (09:00 -0400)]
Added suggestion to `function_item_references` lint and fixed warning message

Also updated tests accordingly and tweaked some wording in the lint declaration.

3 years agoAdded documentation for `function_item_references` lint
Ayrton [Wed, 21 Oct 2020 21:19:21 +0000 (17:19 -0400)]
Added documentation for `function_item_references` lint

Added documentation for `function_item_references` lint to the rustc book and
fixed comments in the lint checker itself.

3 years agoFixed compiler error in lint checker triggered by associated types
Ayrton [Tue, 6 Oct 2020 21:55:46 +0000 (17:55 -0400)]
Fixed compiler error in lint checker triggered by associated types

When a function argument bound by `Pointer` is an associated type, we only
perform substitutions using the parameters from the callsite but don't attempt
to normalize since it may not succeed. A simplified version of the scenario that
triggered this error was added as a test case. Also fixed `Pointer::fmt` which
was being double-counted when called outside of macros and added a test case for
this.

3 years agoRemoved test for unhandled case in function_item_references lint
Ayrton [Tue, 6 Oct 2020 15:59:14 +0000 (11:59 -0400)]
Removed test for unhandled case in function_item_references lint

Removed test for the unhandled case of calls to `fn f<T>(x: &T)` where `x` is a
function reference and is formatted as a pointer in `f`. This compiles since
`&T` implements `Pointer`, but is unlikely to occur in practice. Also tweaked
the lint's wording and modified tests accordingly.

3 years agoChanged lint to check for `std::fmt::Pointer` and `transmute`
Ayrton [Tue, 6 Oct 2020 13:51:10 +0000 (09:51 -0400)]
Changed lint to check for `std::fmt::Pointer` and `transmute`

The lint checks arguments in calls to `transmute` or functions that have
`Pointer` as a trait bound and displays a warning if the argument is a function
reference. Also checks for `std::fmt::Pointer::fmt` to handle formatting macros
although it doesn't depend on the exact expansion of the macro or formatting
internals. `std::fmt::Pointer` and `std::fmt::Pointer::fmt` were also added as
diagnostic items and symbols.

3 years agomodified lint to work with MIR
Ayrton [Fri, 11 Sep 2020 02:53:14 +0000 (22:53 -0400)]
modified lint to work with MIR

Working with MIR let's us exclude expressions like `&fn_name as &dyn Something`
and `(&fn_name)()`. Also added ABI, unsafety and whether a function is variadic
in the lint suggestion, included the `&` in the span of the lint and updated the
test.

3 years agochanged lint to suggest casting to the proper function type and added a test
Ayrton [Fri, 4 Sep 2020 13:45:09 +0000 (09:45 -0400)]
changed lint to suggest casting to the proper function type and added a test

3 years agoadded a lint against function references
Ayrton [Wed, 19 Aug 2020 04:30:49 +0000 (00:30 -0400)]
added a lint against function references

this lint suggests casting function references to `*const ()`

3 years agoFix test
Nathan Whitaker [Tue, 27 Oct 2020 14:10:30 +0000 (10:10 -0400)]
Fix test

3 years agoAuto merge of #78434 - jonas-schievink:disable-miropt, r=wesleywiser
bors [Tue, 27 Oct 2020 13:57:54 +0000 (13:57 +0000)]
Auto merge of #78434 - jonas-schievink:disable-miropt, r=wesleywiser

Disable "optimization to avoid load of address" in InstCombine

Same as #78195, fixes https://github.com/rust-lang/rust/issues/78192 (again).

3 years agoAuto merge of #78227 - SergioBenitez:test-stdout-threading, r=m-ou-se
bors [Tue, 27 Oct 2020 11:43:18 +0000 (11:43 +0000)]
Auto merge of #78227 - SergioBenitez:test-stdout-threading, r=m-ou-se

Capture output from threads spawned in tests

This is revival of #75172.

Original text:
> Fixes #42474.
>
> r? `@​dtolnay` since you expressed interest in this, but feel free to redirect if you aren't the right person anymore.

---

Closes #75172.

3 years agoDisable "optimization to avoid load of address" in InstCombine
Jonas Schievink [Tue, 27 Oct 2020 09:59:28 +0000 (10:59 +0100)]
Disable "optimization to avoid load of address" in InstCombine

3 years agoAuto merge of #77502 - varkor:const-generics-suggest-enclosing-braces, r=petrochenkov
bors [Tue, 27 Oct 2020 09:25:54 +0000 (09:25 +0000)]
Auto merge of #77502 - varkor:const-generics-suggest-enclosing-braces, r=petrochenkov

Suggest that expressions that look like const generic arguments should be enclosed in brackets

I pulled out the changes for const expressions from https://github.com/rust-lang/rust/pull/71592 (without the trait object diagnostic changes) and made some small changes; the implementation is `@estebank's.`

We're also going to want to make some changes separately to account for trait objects (they result in poor diagnostics, as is evident from one of the test cases here), such as an adaption of https://github.com/rust-lang/rust/pull/72273.

Fixes https://github.com/rust-lang/rust/issues/70753.

r? `@petrochenkov`

3 years agoAuto merge of #77317 - varkor:break-diverging-value, r=nikomatsakis
bors [Tue, 27 Oct 2020 07:10:55 +0000 (07:10 +0000)]
Auto merge of #77317 - varkor:break-diverging-value, r=nikomatsakis

Fix control flow check for breaking with diverging values

Fixes https://github.com/rust-lang/rust/issues/77156.

3 years agoAuto merge of #78359 - ssomers:btree_cleanup_mem, r=Mark-Simulacrum
bors [Tue, 27 Oct 2020 04:01:52 +0000 (04:01 +0000)]
Auto merge of #78359 - ssomers:btree_cleanup_mem, r=Mark-Simulacrum

BTreeMap: move generic support functions out of navigate.rs

A preparatory step chipped off #78104, useful in general (if at all).

r? `@Mark-Simulacrum`

3 years agoFix bootstrap doctest failure
Nathan Whitaker [Tue, 27 Oct 2020 02:09:47 +0000 (22:09 -0400)]
Fix bootstrap doctest failure

3 years agoAuto merge of #78421 - JohnTitor:rollup-bq2d7fo, r=JohnTitor
bors [Tue, 27 Oct 2020 01:36:12 +0000 (01:36 +0000)]
Auto merge of #78421 - JohnTitor:rollup-bq2d7fo, r=JohnTitor

Rollup of 16 pull requests

Successful merges:

 - #76635 (Add [T]::as_chunks(_mut))
 - #77703 (add system-llvm-libunwind config option)
 - #78219 (Prefer to use `print_def_path`)
 - #78298 (Add test for bad NLL higher-ranked subtype)
 - #78332 (Update description for error E0308)
 - #78342 (Use check-pass in single-use-lifetime ui tests)
 - #78347 (Add lexicographical comparison doc)
 - #78348 (Make some functions private that don't have to be public)
 - #78349 (Use its own `TypeckResults` to avoid ICE)
 - #78375 (Use ? in core/std macros)
 - #78377 (Fix typo in debug statement)
 - #78388 (Add some regression tests)
 - #78394 (fix(docs): typo in BufWriter documentation)
 - #78396 (Add compiler support for LLVM's x86_64 ERMSB feature)
 - #78405 (Fix typo in lint description)
 - #78412 (Improve formatting of hash collections docs)

Failed merges:

r? `@ghost`

3 years agoRollup merge of #78412 - camelid:cleanup-hash-docs, r=jonas-schievink
Yuki Okushi [Mon, 26 Oct 2020 23:45:30 +0000 (08:45 +0900)]
Rollup merge of #78412 - camelid:cleanup-hash-docs, r=jonas-schievink

Improve formatting of hash collections docs

3 years agoRollup merge of #78405 - notriddle:patch-3, r=lcnr
Yuki Okushi [Mon, 26 Oct 2020 23:45:27 +0000 (08:45 +0900)]
Rollup merge of #78405 - notriddle:patch-3, r=lcnr

Fix typo in lint description

3 years agoRollup merge of #78396 - josephlr:ermsb, r=petrochenkov
Yuki Okushi [Mon, 26 Oct 2020 23:45:24 +0000 (08:45 +0900)]
Rollup merge of #78396 - josephlr:ermsb, r=petrochenkov

Add compiler support for LLVM's x86_64 ERMSB feature

This change is needed for compiler-builtins to check for this feature
when implementing memcpy/memset. See:
  https://github.com/rust-lang/compiler-builtins/pull/365

Without this change, the following code compiles, but does nothing:
```rust
#[cfg(target_feature = "ermsb")]
pub unsafe fn ermsb_memcpy() { ... }
```

The change just does compile-time detection. I think that runtime
detection will have to come in a follow-up CL to std-detect.

Like all the CPU feature flags, this just references #44839

Signed-off-by: Joe Richey <joerichey@google.com>
3 years agoRollup merge of #78394 - rubik:master, r=m-ou-se
Yuki Okushi [Mon, 26 Oct 2020 23:45:20 +0000 (08:45 +0900)]
Rollup merge of #78394 - rubik:master, r=m-ou-se

fix(docs): typo in BufWriter documentation

This PR fixes a small typo in the BufWriter documentation. The current documentation looks like this:

![2020-10-26-111501_438x83_scrot](https://user-images.githubusercontent.com/238549/97160357-83d3a000-177c-11eb-8a35-3cdd3a7d89de.png)

The `<u8>` at the end is mangled by Markdown. This PR makes the `BufWriter` documentation like the `BufReader` one:

https://github.com/rust-lang/rust/blob/master/library/std/src/io/buffered/bufreader.rs#L16

I'm tagging Steve as per the Rustc dev guide.

r? @steveklabnik

3 years agoRollup merge of #78388 - camelid:regression-tests, r=lcnr
Yuki Okushi [Mon, 26 Oct 2020 23:45:17 +0000 (08:45 +0900)]
Rollup merge of #78388 - camelid:regression-tests, r=lcnr

Add some regression tests

Closes #75763.
Closes #76179.

3 years agoRollup merge of #78377 - LeSeulArtichaut:patch-docs, r=jonas-schievink
Yuki Okushi [Mon, 26 Oct 2020 23:45:14 +0000 (08:45 +0900)]
Rollup merge of #78377 - LeSeulArtichaut:patch-docs, r=jonas-schievink

Fix typo in debug statement

3 years agoRollup merge of #78375 - taiki-e:question-in-macros, r=kennytm
Yuki Okushi [Mon, 26 Oct 2020 23:45:10 +0000 (08:45 +0900)]
Rollup merge of #78375 - taiki-e:question-in-macros, r=kennytm

Use ? in core/std macros

3 years agoRollup merge of #78349 - JohnTitor:issue-75962, r=davidtwco
Yuki Okushi [Mon, 26 Oct 2020 23:45:07 +0000 (08:45 +0900)]
Rollup merge of #78349 - JohnTitor:issue-75962, r=davidtwco

Use its own `TypeckResults` to avoid ICE

Fixes #75962

3 years agoRollup merge of #78348 - jyn514:pub-crate, r=GuillaumeGomez
Yuki Okushi [Mon, 26 Oct 2020 23:45:04 +0000 (08:45 +0900)]
Rollup merge of #78348 - jyn514:pub-crate, r=GuillaumeGomez

Make some functions private that don't have to be public

r? @GuillaumeGomez

3 years agoRollup merge of #78347 - Rustin-Liu:rustin-patch-doc, r=kennytm
Yuki Okushi [Mon, 26 Oct 2020 23:45:01 +0000 (08:45 +0900)]
Rollup merge of #78347 - Rustin-Liu:rustin-patch-doc, r=kennytm

Add lexicographical comparison doc

close https://github.com/rust-lang/rust/issues/72255

3 years agoRollup merge of #78342 - oliviacrain:checkmate-pass, r=Mark-Simulacrum
Yuki Okushi [Mon, 26 Oct 2020 23:44:57 +0000 (08:44 +0900)]
Rollup merge of #78342 - oliviacrain:checkmate-pass, r=Mark-Simulacrum

Use check-pass in single-use-lifetime ui tests

Rationale: the `single_use_lifetimes` lint is used during late name resolution, which is within the scope of `check-pass` and does not require codegen or linking.

Helps remove some FIXMES associated with #62277. Additionally tidies touched test files.

3 years agoRollup merge of #78332 - PoignardAzur:doc_E0308, r=camelid
Yuki Okushi [Mon, 26 Oct 2020 23:44:54 +0000 (08:44 +0900)]
Rollup merge of #78332 - PoignardAzur:doc_E0308, r=camelid

Update description for error E0308

Fixes #76462

r? @camelid

3 years agoRollup merge of #78298 - Aaron1011:fix/nll-ranked-test, r=Mark-Simulacrum
Yuki Okushi [Mon, 26 Oct 2020 23:44:51 +0000 (08:44 +0900)]
Rollup merge of #78298 - Aaron1011:fix/nll-ranked-test, r=Mark-Simulacrum

Add test for bad NLL higher-ranked subtype

Fixes #57642

3 years agoRollup merge of #78219 - JohnTitor:print-def-path, r=estebank
Yuki Okushi [Mon, 26 Oct 2020 23:44:47 +0000 (08:44 +0900)]
Rollup merge of #78219 - JohnTitor:print-def-path, r=estebank

Prefer to use `print_def_path`

Follow-up of https://github.com/rust-lang/rust/pull/71310#discussion_r415438577

3 years agoRollup merge of #77703 - Keruspe:system-libunwind, r=Mark-Simulacrum
Yuki Okushi [Mon, 26 Oct 2020 23:44:44 +0000 (08:44 +0900)]
Rollup merge of #77703 - Keruspe:system-libunwind, r=Mark-Simulacrum

add system-llvm-libunwind config option

allows using the system-wide llvm-libunwind as the unwinder

Workaround for #76020

3 years agoRollup merge of #76635 - scottmcm:slice-as-chunks, r=LukasKalbertodt
Yuki Okushi [Mon, 26 Oct 2020 23:44:41 +0000 (08:44 +0900)]
Rollup merge of #76635 - scottmcm:slice-as-chunks, r=LukasKalbertodt

Add [T]::as_chunks(_mut)

Allows getting the slices directly, rather than just through an iterator as in `array_chunks(_mut)`.  The constructors for those iterators are then written in terms of these methods, so the iterator constructors no longer have any `unsafe` of their own.

Unstable, of course. #74985

3 years agoAuto merge of #77876 - tmiasko:simplify-locals, r=wesleywiser
bors [Mon, 26 Oct 2020 23:22:39 +0000 (23:22 +0000)]
Auto merge of #77876 - tmiasko:simplify-locals, r=wesleywiser

Remove unused set-discriminant statements and assignments regardless of rvalue

* Represent use counts with u32
* Unify use count visitors
* Change RemoveStatements visitor into a function
* Remove unused set-discriminant statements
* Use exhaustive match to clarify what is being optimized
* Remove unused assignments regardless of rvalue kind

3 years agoAddress review comments
Nathan Whitaker [Mon, 26 Oct 2020 23:19:06 +0000 (19:19 -0400)]
Address review comments

3 years agoImplement -Z function-sections=yes|no
Anthony Ramine [Mon, 26 Oct 2020 19:55:07 +0000 (20:55 +0100)]
Implement -Z function-sections=yes|no

This lets rustc users tweak whether all functions should be put in their own
TEXT section, using whatever default value the target defines if the flag
is missing.

3 years agoFix doctest
Nathan Whitaker [Tue, 22 Sep 2020 16:38:50 +0000 (12:38 -0400)]
Fix doctest

3 years agoRemove lint from clippy
Nathan Whitaker [Tue, 22 Sep 2020 16:23:22 +0000 (12:23 -0400)]
Remove lint from clippy

3 years agoWrite docs for lint / fix review nit
Nathan Whitaker [Tue, 22 Sep 2020 15:20:06 +0000 (11:20 -0400)]
Write docs for lint / fix review nit

3 years agoAddress review comments
Nathan Whitaker [Mon, 21 Sep 2020 20:32:28 +0000 (16:32 -0400)]
Address review comments

3 years agoChange to warn by default / fix typo
Nathan Whitaker [Sun, 23 Aug 2020 18:21:58 +0000 (14:21 -0400)]
Change to warn by default / fix typo

3 years agoTweak diagnostic
Nathan Whitaker [Tue, 18 Aug 2020 23:37:50 +0000 (19:37 -0400)]
Tweak diagnostic

3 years agoUpdate doctest
Nathan Whitaker [Tue, 18 Aug 2020 22:47:52 +0000 (18:47 -0400)]
Update doctest

3 years agoAddress review comments
Nathan Whitaker [Tue, 18 Aug 2020 21:02:23 +0000 (17:02 -0400)]
Address review comments

3 years agoAdd basic test
Nathan Whitaker [Tue, 18 Aug 2020 16:09:33 +0000 (12:09 -0400)]
Add basic test

3 years agoUplift temporary-cstring-as-ptr into rustc
Nathan Whitaker [Tue, 18 Aug 2020 15:25:21 +0000 (11:25 -0400)]
Uplift temporary-cstring-as-ptr into rustc

3 years agoSuggest expressions that look like const generic arguments should be enclosed in...
varkor [Sat, 3 Oct 2020 18:30:32 +0000 (19:30 +0100)]
Suggest expressions that look like const generic arguments should be enclosed in brackets

Co-Authored-By: Esteban Kuber <github@kuber.com.ar>