Commit graph

132202 commits

Author SHA1 Message Date
Yuki Okushi 5e3cc6e913
Rollup merge of #78475 - RalfJung:validity-comment, r=oli-obk
fix a comment in validity check

A few things changed since that comment was written; update it to the current reality.

r? @oli-obk
2020-10-29 12:08:55 +09:00
Yuki Okushi 7eb7b5a4af
Rollup merge of #78470 - camelid:fixup-std-path-intra-doc, r=jyn514
Clean up intra-doc links in `std::path`
2020-10-29 12:08:53 +09:00
Yuki Okushi a7a0538802
Rollup merge of #78460 - varkor:turbofish-string-generic, r=lcnr
Adjust turbofish help message for const generics

Types are no longer special. (This message arguably only makes sense with `min_const_generics` or more, but we'll be there soon.)

r? @lcnr
2020-10-29 12:08:50 +09:00
Yuki Okushi 2555e07be1
Rollup merge of #78428 - JulianKnodt:invalid_patterns, r=lcnr
MinConstGenerics UI test for invalid values for bool & char

This adds a test for `feature(min_const_generics)` with some invalid values for bools and chars and ensures that they do not ICE and error with understandable messages.

r? @lcnr
2020-10-29 12:08:48 +09:00
Yuki Okushi 270d2e0c2e
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
2020-10-29 12:08:40 +09:00
Yuki Okushi 2008d1bb0b
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
2020-10-29 12:08:38 +09:00
Ian Jackson 776e204609 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>
2020-10-28 21:29:21 +00:00
Ian Jackson 1d6c860277
Add a comment about non-panicking of splitn().next().unwrap()
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2020-10-28 21:25:47 +00:00
Ian Jackson 39b80cb7c0 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>
2020-10-28 20:13:31 +00:00
bors 31ee872db5 Auto merge of #78415 - tgnottingham:expn_id_tag_hash, r=Aaron1011
rustc_span: avoid hashing ExpnId tag when using cached hash
2020-10-28 20:03:55 +00:00
Ian Jackson 709efd9df6 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>
2020-10-28 18:01:06 +00:00
Ian Jackson d8a4497561 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>
2020-10-28 17:54:07 +00:00
Ian Jackson 5cd96d638c 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>
2020-10-28 17:54:06 +00:00
bors 3dddf6ac1e 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.
2020-10-28 17:47:36 +00:00
Ian Jackson 2e10475fdd 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>
2020-10-28 15:44:59 +00:00
bors 717eb6ccea 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`
2020-10-28 14:52:20 +00:00
varkor a6d01da716 Remove irrelevant FIXME 2020-10-28 10:47:27 +00:00
varkor 6c73adf324 Adjust turbofish help message for const generics 2020-10-28 10:47:27 +00:00
Ralf Jung c90ef979de fix a comment in validity check 2020-10-28 10:39:21 +01:00
bors 2eb4fc800a 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.
2020-10-28 03:58:32 +00:00
Camelid 0217edbd29
Clean up intra-doc links in std::path 2020-10-27 20:54:30 -07:00
bors db241bb0c8 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`
2020-10-28 01:40:06 +00:00
Dylan DPC 6967005e6e
Rollup merge of #78453 - Storyyeller:patch-1, r=jonas-schievink
Fix typo in comments
2020-10-28 01:21:39 +01:00
Dylan DPC 3349b6847f
Rollup merge of #78447 - bugadani:typo, r=matthewjasper
Fix typo in  comment

I hope I got all the typos in that word. :)
2020-10-28 01:21:37 +01:00
Dylan DPC 14b4ed20c7
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
2020-10-28 01:21:34 +01:00
Dylan DPC c9279c845d
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
2020-10-28 01:21:31 +01:00
Dylan DPC c3f842baee
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
2020-10-28 01:21:27 +01:00
Dylan DPC 892ebe9afe
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]`
2020-10-28 01:21:24 +01:00
Dylan DPC 1a64e570c6
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
2020-10-28 01:21:21 +01:00
Dylan DPC 54ea0f9ccd
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
2020-10-28 01:21:18 +01:00
Dylan DPC 86a4a38177
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
2020-10-28 01:21:10 +01:00
Dylan DPC 346aeef496
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.
2020-10-28 01:21:08 +01:00
bors 90e6d0d46b 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`
2020-10-27 22:59:13 +00:00
kadmin eb8e8bd8bf Add UI test for invalid values for bool & char 2020-10-27 22:54:41 +00:00
Robert Grosse 710c1f4aca
Fix typo in comments 2020-10-27 14:23:58 -07:00
kadmin 23c4a46eff Add const_fn in generics test 2020-10-27 19:22:13 +00:00
Santiago Pastorino cc9ab1cd58
Merge unsized locals pat tests 2020-10-27 14:45:42 -03:00
Santiago Pastorino 00fd703eb7
Use unsized_feature_enabled helper function 2020-10-27 14:45:42 -03:00
Santiago Pastorino 9584b00b1d
is -> are both 2020-10-27 14:45:41 -03:00
Santiago Pastorino 4760338ad2
Bless tests again 2020-10-27 14:45:41 -03:00
Santiago Pastorino 89eac50a87
Hide outermost_fn_param_pat, it's an internal detail 2020-10-27 14:45:40 -03:00
Santiago Pastorino f0fe0a6eba
or -> and 2020-10-27 14:45:40 -03:00
Santiago Pastorino 8b8b6392ba
Add comment explaining why in these tests unsized locals are not accepted 2020-10-27 14:45:40 -03:00
Santiago Pastorino 497ee0e1ff
param -> parameter, pat -> pattern 2020-10-27 14:45:39 -03:00
Santiago Pastorino bdd1b85f95
Rename within_fn_param to outermost_fn_param_pat 2020-10-27 14:45:39 -03:00
Santiago Pastorino ca41681bf0
Do not use unsized_fn_params in patterns 2020-10-27 14:45:38 -03:00
Santiago Pastorino 58018d438b
Properly restore within_fn_param value to the previous state 2020-10-27 14:45:38 -03:00
Santiago Pastorino a3470b13ab
Test that unsized locals fail when turning unsized_fn_params feature flag on 2020-10-27 14:45:37 -03:00
Santiago Pastorino f0a71f7f4d
Better test unsized_fn_params 2020-10-27 14:45:37 -03:00
Santiago Pastorino 70b8c79a96
Bless issue-53448 test 2020-10-27 14:45:36 -03:00