Commit Graph

110017 Commits

Author SHA1 Message Date
bors
5e3f1b148d Auto merge of #75382 - JulianKnodt:match_branches, r=oli-obk
First iteration of simplify match branches

This is a simple MIR pass that attempts to convert
```
   bb0: {
        StorageLive(_2);
        _3 = discriminant(_1);
        switchInt(move _3) -> [0isize: bb2, otherwise: bb1];
    }

    bb1: {
        _2 = const false;
        goto -> bb3;
    }

    bb2: {
        _2 = const true;
        goto -> bb3;
    }
```
into
```
    bb0: {
        StorageLive(_2);
        _3 = discriminant(_1);
        _2 = _3 == 0;
        goto -> bb3;
    }
```
There are still missing components(like checking if the assignments are bools).
Was hoping that this could get some review though.

Handles #75141

r? @oli-obk
2020-08-13 19:26:35 +00:00
Dylan MacKenzie
662871f1cc Add no-opt standard library builders
We already have builders which built standard library *test*s without
optimizations, but we previously did not have builders which built the standard
library itself without optimizations and then tested that.

This adds those builds for i686 and x86_64 linux.
2020-08-13 15:18:13 -04:00
Guillaume Gomez
0ce97fc511 Fix code examples 2020-08-13 21:07:56 +02:00
Guillaume Gomez
406719bf24 Improve wording 2020-08-13 20:13:49 +02:00
bors
b6396b75e7 Auto merge of #74793 - tmiasko:san-macos, r=Mark-Simulacrum
Link sanitizers when creating dynamic libraries on macOS

Link sanitizer runtime when creating dynamic libraries on macOS
to resolve sanitizer runtime symbols and avoid failure at link time.

Closes #74571.
2020-08-13 17:22:36 +00:00
bors
0a49057dd3 Auto merge of #75443 - lcnr:opaque-normalize, r=nikomatsakis
allow escaping bound vars when normalizing `ty::Opaque`

implements https://github.com/rust-lang/rust/issues/75313#issuecomment-672216146 and fixes #75313

cc @eddyb @RalfJung

r? @nikomatsakis
2020-08-13 15:03:40 +00:00
Bastian Kauschke
cd53760cc7 merge as_local_hir_id with local_def_id_to_hir_id 2020-08-13 16:55:16 +02:00
Tomasz Miąsko
91f87bc9bc Set CMAKE_SYSTEM_NAME when cross-compiling
Configure CMAKE_SYSTEM_NAME when cross-compiling in `configure_cmake`,
to tell CMake about target system. Previously this was done only for
LLVM step and now applies more generally to steps using cmake.
2020-08-13 14:51:06 +02:00
bors
a0c290f951 Auto merge of #75212 - JulianKnodt:array_map, r=LukasKalbertodt
Add `array` lang item and `[T; N]::map(f: FnMut(T) -> S)`

This introduces an `array` lang item so functions can be defined on top of `[T; N]`. This was previously not done because const-generics was not complete enough to allow for this. Now it is in a state that is usable enough to start adding functions.

The function added is a monadic (I think?) map from `[T; N] -> [S; N]`. Until transmute can function on arrays, it also allocates an extra temporary array, but this can be removed at some point.

r? @lcnr
2020-08-13 12:43:12 +00:00
Michael Woerister
08d951768f self-profile: Cache more query key strings when doing self-profiling. 2020-08-13 14:14:33 +02:00
Guillaume Gomez
bbad31df2f Clean up E0752 explanation 2020-08-13 13:07:27 +02:00
Mateusz Mikuła
c75f7f90c8 Add LLD flags for MinGW 2020-08-13 12:32:46 +02:00
bors
1a7d9f52bc Auto merge of #75322 - JulianKnodt:revisions, r=lcnr
Add a bunch of const-generic revisions for `min_const_generics`

This adds a bunch of revisions to `const-generic` tests which is part of #75279, but doesn't cover everything.

r? @lcnr
2020-08-13 10:31:57 +00:00
Matthias Krüger
2100e67126 make rustc-docs component available to rustup 2020-08-13 11:29:48 +02:00
bors
3fbed1739c Auto merge of #75478 - RalfJung:miri, r=RalfJung
update miri

Fixes https://github.com/rust-lang/rust/issues/75441
2020-08-13 08:24:00 +00:00
kadmin
46e5699af9 Add 64bit / 32bit files 2020-08-13 08:20:26 +00:00
Tomasz Miąsko
4fbbc81e5f Link sanitizers when creating dynamic libraries on macOS 2020-08-13 09:45:55 +02:00
Ralf Jung
7e4456f92f update miri 2020-08-13 09:18:46 +02:00
kadmin
9ef5b884b2 bless diff
Just output the current bless'd MIR diff
The tests are still fairly broken rn
2020-08-13 06:59:57 +00:00
kadmin
f51422b474 Update to pick Eq or Ne 2020-08-13 06:59:57 +00:00
kadmin
bce5eb0c08 Update w/ comments from oli
This also updates a check to ensure that this is only applied to bools
2020-08-13 06:59:57 +00:00
kadmin
6c0f2a9446 Update to actually use transform 2020-08-13 06:59:57 +00:00
kadmin
a6c2cb42d0 First iteration of simplify match branches 2020-08-13 06:59:57 +00:00
bors
d69b0997d7 Auto merge of #75431 - ehuss:platform-support, r=Mark-Simulacrum
Move platform support to the rustc book.

This moves the [Platform Support](https://forge.rust-lang.org/release/platform-support.html) page from the forge to the rustc book. There are several reasons for doing this:

* The forge is not really oriented towards end-users (it mostly contains infrastructure, governance and policy, internal team pages, etc.). This platform support page is useful to user to know which targets are supported.
* This page can now be updated in-sync with any PRs that add or remove a target, or change its status.
* This is now automatically checked on CI to verify the list does not get out of sync. Currently it only checks the presence/absence of an entry, but more sophisticated checks could be added in the future.

I'm not 100% certain this is the best location, but I think it fits. I'd like to see the rustc guide continue to grow, including things like linking information and more platform-specific details.
2020-08-13 06:17:25 +00:00
bors
814bc4fe93 Auto merge of #75426 - ehuss:update-cargo, r=ehuss
Update cargo

7 commits in 1653f354644834073d6d2541e27fae94588e685e..ab32ee88dade1b50c77347599e82ca2de3fb8a51
2020-08-04 23:14:37 +0000 to 2020-08-10 17:44:43 +0000
- Build manpage archive deterministically (rust-lang/cargo#8600)
- doc: Qualify GNU licenses in example license field (rust-lang/cargo#8604)
- Fix jobserver_exists test on single-cpu systems (rust-lang/cargo#8598)
- Fix small typo in reference/profiles.md (rust-lang/cargo#8605)
- Default cargo publish to the alt registry if it's the only allowed one (rust-lang/cargo#8571)
- cargo install with specific yanked version gives confusing "not found" error (rust-lang/cargo#8565)
- Fix typo (rust-lang/cargo#8589)
2020-08-13 04:20:51 +00:00
kadmin
f6411e4c66 Add Array Impl Lang Item in various places
Add basic test

And also run fmt which is where the other changes are from

Fix mut issues

These only appear when running tests, so resolved by adding mut

Swap order of forget

Add pub and rm guard impl

Add explicit type to guard

Add safety note

Change guard type from T to S

It should never have been T, as it guards over [MaybeUninit<S>; N]
Also add feature to test
2020-08-13 03:50:57 +00:00
kadmin
d8718183b2 Create lang item array and add map fn
This creates the language item for arrays, and adds the map fn which is like map in options or
iterators. It currently allocates an extra array, unfortunately.

Added fixme for transmuting

Fix typo

Add drop guard
2020-08-13 03:50:54 +00:00
Yuki Okushi
76ac5d61e4
Rollup merge of #75473 - JulianKnodt:swap_order_oops, r=varkor
Flip order of const & type

Fix swapped order of consts & types in error message introduced in #74953

r? @varkor cc @lcnr
2020-08-13 11:05:48 +09:00
Yuki Okushi
4cf55a67dd
Rollup merge of #75457 - Mark-Simulacrum:llvm-clean, r=cuviper
Remove some dead variants in LLVM FFI

r? @nikic or @cuviper
2020-08-13 11:05:44 +09:00
Yuki Okushi
a62dd23c5c
Rollup merge of #75451 - GuillaumeGomez:cleanup-e0751, r=pickfire
Clean up E0751 explanation

r? @Dylan-DPC

cc @pickfire
2020-08-13 11:05:40 +09:00
Yuki Okushi
845fb94da4
Rollup merge of #75449 - RalfJung:const-prop-test, r=wesleywiser
add regression test for #74739 (mir const-prop bug)

Fixes https://github.com/rust-lang/rust/issues/74739
2020-08-13 11:05:38 +09:00
Yuki Okushi
d90a4b8ae9
Rollup merge of #75372 - estebank:lt-sugg-in-type, r=lcnr
Fix suggestion to use lifetime in type and in assoc const

_Do not merge until #75363 has landed, as it has the test case for this._

* Account for associated types
* Associated `const`s can't have generics (fix #74264)
* Do not suggest duplicate lifetimes and suggest `for<'a>` more (fix #72404)
2020-08-13 11:05:35 +09:00
Yuki Okushi
d0414b57b4
Rollup merge of #75201 - Hirrolot:hirrolot/fix-clippy-warnings, r=varkor
Fix some Clippy warnings in librustc_serialize
2020-08-13 11:05:33 +09:00
kadmin
c48d45bf6b Flip order of const & type 2020-08-12 23:19:07 +00:00
Rich Kadel
d4593af78f Change registered "program name" for -Cllvm-args usage messages
While debugging a codegen issue, I tried adding LLVM options with
the rustc -Cllvm-args option, and was confused by the error and usage
messaging.

The LLVM "program name" argument is set to "rustc", and command line
error messages make it look like invalid arguments are "rustc"
arguments, not LLVM.

I changed this argument so error messages and the "-help" usage feedback
is easier to understand and react to. (Clang does something similar.)
2020-08-12 16:11:17 -07:00
Mark Rousskov
e09cca09ac Add option to use the new symbol mangling in rustc/std 2020-08-12 18:42:42 -04:00
Ruben Gonzalez
b38e571e9c
Fix E0741 error code explanation
Use OK ! like other explanations
2020-08-12 23:42:10 +02:00
bors
576d27c5a6 Auto merge of #75396 - RalfJung:miri-spans, r=oli-obk
Miri: improve spans of required_const failures

In https://github.com/rust-lang/rust/pull/75339 I added a loop evaluating all consts required by a function body. Unfortunately, if one of their evaluations fails, then the span used for that was that of the first statement in the function body, which happened to work form some existing test but is not sensible in general.

This PR changes it to point to the whole function instead, which is at least not wrong.

r? @oli-obk
2020-08-12 20:44:19 +00:00
kadmin
5c0b416dde Update stderr files
And also fix some comments as suggested by lcnr
2020-08-12 20:04:36 +00:00
Mark Rousskov
bff104d4db Remove unused tcx parameter 2020-08-12 16:00:44 -04:00
bors
ef1d58e7c9 Auto merge of #75354 - estebank:tuple-struct-as-struct-pat, r=petrochenkov
Detect tuple variants used as struct pattern and suggest correct pattern

Fix #61326

r? @petrochenkov
2020-08-12 18:50:20 +00:00
Ralf Jung
0e26f9b994 fix LocalInfo doc comment 2020-08-12 19:40:29 +02:00
Mark Rousskov
486c48b570 Remove ArchiveKind::Other
Also unused since introduction in #35174
2020-08-12 12:03:44 -04:00
Mark Rousskov
7a0b195188 Remove CodeGenOptLevel::Other
Also introduced in #35174, and immediately unused.
2020-08-12 12:01:31 -04:00
Mark Rousskov
fc163ed4ee Remove AsmDialect::Other
Added in #35174, this was already unused (and new uses have not been introduced
since then).
2020-08-12 11:59:17 -04:00
Mark Rousskov
f043c8fa48 Remove FileType::Other
Added in #35174, this was already unused (and new uses have not been introduced
since then).
2020-08-12 11:55:45 -04:00
Eric Huss
ce717476ff Add a script to verify the Platform Support page is up-to-date. 2020-08-12 08:40:22 -07:00
Guillaume Gomez
f11b2e521e Improve wording 2020-08-12 16:51:29 +02:00
Guillaume Gomez
d0704d5d36 Clean up E0751 explanation 2020-08-12 14:15:44 +02:00
Pietro Albini
8345f323b3
toolstate: remove embedded-resources alumni from toolstate 2020-08-12 13:53:50 +02:00
Ralf Jung
0d6ff997a5 add regression test for #74739 (mir const-prop bug) 2020-08-12 12:50:24 +02:00
Ralf Jung
fd32fe9bb9 fix span of stack size error 2020-08-12 11:14:49 +02:00
Guillaume Gomez
fc6fb3fb8f Allow #[doc(alias)] on impl const items 2020-08-12 11:09:24 +02:00
Ralf Jung
a505e773a5 fix typos
Co-authored-by: Oliver Scherer <github35764891676564198441@oli-obk.de>
2020-08-12 10:48:08 +02:00
Ralf Jung
d21e0118d0 more precise span for erroneous consts during CTFE/Miri 2020-08-12 10:48:08 +02:00
Ralf Jung
4b4d43fe6a bless tests 2020-08-12 10:48:08 +02:00
Ralf Jung
d6c988b3a7 miri: fall back to whole-function span when loc==None 2020-08-12 10:48:08 +02:00
bors
5989bf4872 Auto merge of #75321 - estebank:js-goes-gaga, r=davidtwco
Detect JS-style `===` and `!==` and recover

Fix #75312.
2020-08-12 08:40:36 +00:00
kadmin
9bf40f10bc Add missing tests in root const-gen dir 2020-08-12 08:30:17 +00:00
kadmin
be650a7ecd Add a bunch of revisions
This adds a bunch of revisions to const-generic tests
2020-08-12 08:30:17 +00:00
Ralf Jung
5154b66586 only set frame location during push after preamble is done 2020-08-12 09:59:03 +02:00
Bastian Kauschke
d2398eee0f allow escaping bound vars when normalizing ty::Opaque 2020-08-12 09:08:34 +02:00
bors
4745cbe83e Auto merge of #75205 - Aaron1011:fix/auto-trait-proj-ice, r=nikomatsakis
Handle projection predicates in the param env for auto-trait docs

Fixes #72213

Any predicates in the param env are guaranteed to hold, so we don't need
to do any additional processing of them if we come across them as
sub-obligations of a different predicate. This allows us to avoid adding
the same predicate to the computed ParamEnv multiple times (but with
different regions each time), which causes an ambiguity error during
fulfillment.
2020-08-12 06:42:49 +00:00
bors
c94ed5ca91 Auto merge of #75436 - JohnTitor:rollup-ss0lxds, r=JohnTitor
Rollup of 9 pull requests

Successful merges:

 - #74521 (older toolchains not valid anymore)
 - #74960 (Fix regionck failure when converting Index to IndexMut)
 - #75234 (Update asm! documentation in unstable book)
 - #75368 (Move to doc links inside the prelude)
 - #75371 (Move to doc links inside std/time.rs)
 - #75394 (Add a function to `TyCtxt` for computing an `Allocation` for a `static` item's initializer)
 - #75395 (Switch to intra-doc links in library/std/src/os/*/fs.rs)
 - #75422 (Accept more safety comments)
 - #75424 (fix wrong word in documentation)

Failed merges:

r? @ghost
2020-08-12 04:43:38 +00:00
Yuki Okushi
a8b0a3ca8e
Rollup merge of #75422 - poliorcetics:tidy-accept-more-safety-comments, r=Mark-Simulacrum
Accept more safety comments

This accepts more `// SAFETY:` comments from `tidy`.

This is done after the current behaviour of requiring text one the same line (because spaces are stripped so the last space never pass if there is no text on the same line) bit me once more in #75066

This could potentially accept empty `// SAFETY:` comments but `tidy` is an internal tool used only here so my reasoning is reviews will catch those.
2020-08-12 12:07:19 +09:00
Yuki Okushi
5ef0a0a7f8
Rollup merge of #75394 - oli-obk:get_static, r=RalfJung
Add a function to `TyCtxt` for computing an `Allocation` for a `static` item's initializer

r? @RalfJung

miri-side: https://github.com/rust-lang/miri/issues/1507

split out of https://github.com/rust-lang/rust/pull/74949#discussion_r468100991 to make that PR leaner
2020-08-12 12:07:15 +09:00
Yuki Okushi
0bdb83942d
Rollup merge of #75234 - Amanieu:asm_unstable_book, r=nikomatsakis
Update asm! documentation in unstable book

- Update the list of supported architectures.
- Clarify issues with LLVM's use of reserved registers.
2020-08-12 12:07:10 +09:00
Yuki Okushi
43babed7e2
Rollup merge of #74960 - nbdd0121:typeck, r=nikomatsakis
Fix regionck failure when converting Index to IndexMut

Fixes #74933

Consider an overloaded index expression `base[index]`. Without knowing whether it will be mutated, this will initially be desugared into `<U as Index<T>>::index(&base, index)` for some `U` and `T`. Let `V` be the `expr_ty_adjusted` of `index`.

If this expression ends up being used in any mutable context (or used in a function call with `&mut self` receiver before #72280), we will need to fix it up. The current code will rewrite it to `<U as IndexMut<V>>::index_mut(&mut base, index)`. In most cases this is fine as `V` will be equal to `T`, however this is not always true when `V/T` are references, as they may have different region.

This issue is quite subtle before #72280 as this code path is only used to fixup function receivers, but after #72280 we've made this a common path.

The solution is basically just rewrite it to `<U as IndexMut<T>>::index_mut(&mut base, index)`. `T` can retrieved in the fixup path using `node_substs`.
2020-08-12 12:07:08 +09:00
bors
840dbe7654 Auto merge of #75427 - Xanewok:update-rls, r=Dylan-DPC
Update RLS and Rustfmt

Closes #74811
Closes #74812

r? @calebcartwright
2020-08-12 02:49:01 +00:00
bors
8da42ddbf6 Auto merge of #75405 - flip1995:clippyup, r=Manishearth
Update Clippy

Biweekly Clippy update (2 days late, since I wanted to wait for https://github.com/rust-lang/rust/pull/75098)

r? @Manishearth
2020-08-12 00:34:19 +00:00
Igor Matuszewski
cb40a1c4c9 Update RLS and Rustfmt 2020-08-12 01:25:46 +02:00
Eric Huss
392116e021 Platform Support page updates.
A few updates:
- Some minor wording and formatting changes.
- Remove the `cargo` column.
- Explain the columns up-front.
- Add no-wrap on the target-triple, which looks better to me.
- Minor mention on how to install support for a built-in target via rustup.
2020-08-11 16:05:43 -07:00
Eric Huss
1902983f45 Move forge platform-support to the rustc book. 2020-08-11 16:02:00 -07:00
bors
873fc463bd Auto merge of #74802 - Mark-Simulacrum:reland-74069, r=nnethercote
Reland #74069

Investigation in #74716 has concluded that this PR is indeed not a regression (and in fact the rollup itself is not either).

This reverts the revert in #74611.

r? @nnethercote cc @eddyb
2020-08-11 21:23:00 +00:00
Guillaume Gomez
3b6e4a84f9 Move #[doc(alias)] attribute checks in rustc 2020-08-11 23:21:06 +02:00
Guillaume Gomez
51db2a65dd Put back attributes check pass in rustdoc 2020-08-11 23:21:06 +02:00
Guillaume Gomez
9d252ba928 Remove invalid #[doc(alias)] from doc-alias search-index test 2020-08-11 23:21:05 +02:00
Guillaume Gomez
b04fda8b69 Add doc(alias) attribute checks for associated consts and associated types 2020-08-11 23:21:05 +02:00
Guillaume Gomez
23a2ba6e53 Add more tests for doc alias 2020-08-11 23:21:05 +02:00
Guillaume Gomez
213dc41fe7 Add checks for doc alias on which item it's used 2020-08-11 23:21:05 +02:00
Eric Huss
7291c6dccd Update cargo 2020-08-11 13:59:37 -07:00
Mark Rousskov
a3c73ca88c Remove SynchronizationScope::Other
Added in b761538997, it started out already
unused.
2020-08-11 16:16:28 -04:00
Esteban Küber
6a3deb0ae0 Suggest using 'static in assoc consts and suggest when multiple lts are needed 2020-08-11 13:02:14 -07:00
Alexis Bourget
883dffa4c9 Accept more safety comments (notably those that are on multiple lines without text after SAFETY:) 2020-08-11 21:59:25 +02:00
Tyler Mandry
a028c3176a
Rollup merge of #75408 - mati865:update-ci-comment, r=pietroalbini
Update MinGW comments in ci.yml
2020-08-11 12:28:39 -07:00
Tyler Mandry
d38997e4d9
Rollup merge of #75403 - giraffate:update_comment_in_fn, r=ecstatic-morse
Update comment for function

`rustc::lint::builtin` -> `rustc_session::lint::builtin`
2020-08-11 12:28:35 -07:00
Tyler Mandry
a4211977d7
Rollup merge of #75393 - GuillaumeGomez:fix-help-shortcut, r=pickfire
Fully handle "?" shortcut

Fixes #75386.

cc @runiq
2020-08-11 12:28:34 -07:00
Tyler Mandry
c18b64c866
Rollup merge of #75378 - petrochenkov:isident, r=Mark-Simulacrum
Introduce `rustc_lexer::is_ident` and use it in couple of places

Implements the suggestion from https://github.com/rust-lang/rust/pull/74537#issuecomment-662261979.
2020-08-11 12:28:32 -07:00
Nathaniel McCallum
050fb380aa Don't spill operands onto the stack in naked functions
Currently, the code spills operands onto the stack for the purpose of
debuginfo. However, naked functions can only contain an asm block. Therefore,
attempting to spill the operands on the stack is undefined behavior.

Fixes https://github.com/rust-lang/rust/issues/42779
cc https://github.com/rust-lang/rust/issues/32408
2020-08-11 15:02:03 -04:00
Nathaniel McCallum
0356bb9fbb Revert "Suppress debuginfo on naked function arguments"
This reverts commit 25670749b4.

This commit does not actually fix the problem. It merely removes the name of
the argument from the LLVM output. Even without the name, Rust codegen still
spills the (nameless) variable onto the stack which is the root cause. The root
cause is solved in the next commit.
2020-08-11 15:00:23 -04:00
Esteban Küber
becd479482 review comment: simplify code by using slice pat 2020-08-11 11:06:21 -07:00
Esteban Küber
b9585fda7b When suggesting for lts, consider existing lifetime names
Fix #72404.
2020-08-11 11:06:21 -07:00
Esteban Küber
7956b1cef7 Assoc consts don't have generics
Fix #74264.
2020-08-11 11:06:21 -07:00
Esteban Küber
0f7205f202 Fix suggestion to use lifetime in type 2020-08-11 11:06:17 -07:00
Esteban Küber
17ada052e7 Detect tuple variants used as struct pattern and suggest correct pattern 2020-08-11 10:23:52 -07:00
Guillaume Gomez
fdf2fe18a1 Fully handle "?" shortcut 2020-08-11 18:28:01 +02:00
flip1995
d6b991d3a0
Merge commit '09bd400243ed6f7059fedc0c1623aae3792521d6' into clippyup 2020-08-11 17:50:45 +02:00
bors
cbe7c5ce70 Auto merge of #73656 - oli-obk:deaggregate-is-cleanup, r=wesleywiser
move Deaggregate pass to post_borrowck_cleanup

Reopen of #71946

Only the second commit is from this PR, the other commit is a bugfix that's in the process of getting merged. I'll rebase once that's done

In #70073 MIR pass handling got reorganized, but with the goal of not changing behavior (except for disabling some optimizations on opt-level = 0). But there we realized that the Deaggregator pass, while conceptually more of a "cleanup" pass (and one that should be run before optimizations), was run in the middle of the optimization chain. Likely this is an accident of history, so I suggest we try and clean that up by making it a proper cleanup pass.

This does change mir-opt output, because deaggregation now runs before const-prop instead of after.

r? @wesleywiser @rust-lang/wg-mir-opt

cc @RalfJung
2020-08-11 15:38:14 +00:00
Ralf Jung
307d0d8f51 move Deaggregate pass to post_borrowck_cleanup 2020-08-11 17:09:15 +02:00
Mateusz Mikuła
24177319ca Update MinGW comments in ci.yml 2020-08-11 16:31:32 +02:00
Takayuki Nakata
62502a9403 Update comment for function
`rustc::lint::builtin` -> `rustc_session::lint::builtin`
2020-08-11 22:34:23 +09:00
bors
09bd400243 Auto merge of #5891 - flip1995:rustup, r=flip1995
Rustup

r? @ghost

Sync back rust-lang/rust#75098

changelog: none
2020-08-11 12:32:10 +00:00
Oliver Scherer
1a0a4acd41 Add a function to TyCtxt for computing an Allocation for a static item's initializer 2020-08-11 12:24:54 +02:00
Oliver Scherer
34c3c0dae5 Make <*const T>::is_null const fn 2020-08-11 11:45:47 +02:00
Yuki Okushi
532002853d
Rollup merge of #75360 - pickfire:patch-4, r=GuillaumeGomez
Add sample fix for E0749

Even though the description is clear but the solution may not be as straightforward.
Adding a suggested fix from documentation side.

r? @GuillaumeGomez

However, this suggestion should be shown in rustc itself for easy fix, the documentation should also reflect on the changes in rustc. Currently,
```
error[E0749]: negative impls cannot have any items
 --> test.rs:6:5
  |
6 |     type Foo = i32; // error!
  |     ^^^^^^^^^^^^^^^

error: aborting due to previous error

For more information about this error, try `rustc --explain E0749`.
```
rustc should tell the user to remove it.
2020-08-11 16:23:59 +09:00
Yuki Okushi
ca462d36ff
Rollup merge of #75359 - lcnr:unused-delims-trim, r=oli-obk
unused_delims: trim expr

improves rustfix output.
2020-08-11 16:23:57 +09:00
Yuki Okushi
0a8d4db4d8
Rollup merge of #75353 - estebank:tiny, r=jyn514
Tiny cleanup, remove unnecessary `unwrap`

Remove unnecessary `unwrap`.
2020-08-11 16:23:56 +09:00
Yuki Okushi
e51a839030
Rollup merge of #75352 - estebank:incorrect-tuple-struct-pat, r=oli-obk
Tweak conditions for E0026 and E0769

When we have a tuple struct used with struct we don't want to suggest using the (valid) struct syntax with numeric field names. Instead we want to suggest the expected syntax.

Given

```rust
fn main() {
    match MyOption::MySome(42) {
        MyOption::MySome { x: 42 } => (),
        _ => (),
    }
}
```

We now emit E0769 "tuple variant `MyOption::MySome` written as struct variant" instead of E0026 "variant `MyOption::MySome` does not have a field named `x`".
2020-08-11 16:23:54 +09:00
Yuki Okushi
a75bdfa230
Rollup merge of #75347 - fusion-engineering-forks:rustdoc-nat-sort, r=GuillaumeGomez
Rustdoc: Fix natural ordering to look at all numbers.

The old implementation only looks at numbers at the end, but not in other places in a name: `u8` and `u16` got sorted properly, but `u8_bla` and `u16_bla` did not.

![image](https://user-images.githubusercontent.com/783247/89740226-28e8b180-da87-11ea-885d-77a7c8a6ba00.png)
2020-08-11 16:23:52 +09:00
Yuki Okushi
f50f1c79b8
Rollup merge of #75338 - RalfJung:const-eval-stack-size-check, r=oli-obk
move stack size check to const_eval machine

This is consistent with how we enforce the step limit. In particular, we do not want this limit checked for Miri-the-tool.
2020-08-11 16:23:50 +09:00
Yuki Okushi
06f296a005
Rollup merge of #75333 - davidtwco:polymorphization-75260-fixes, r=lcnr
polymorphize: constrain unevaluated const handling

This PR constrains the support added for handling unevaluated consts in polymorphization (introduced in #75260) by:

- Skipping associated constants as this causes cycle errors.
- Skipping promoted constants when they contain `Self` as this ensures `T` is used in constants of the form `<Self as Foo<T>>`.

Due to an oversight on my part, when landing #75260 and #75255, some tests started failing when polymorphization was enabled that I didn't notice until after landing - this PR fixes the regressions from #75260.

r? @lcnr
2020-08-11 16:23:49 +09:00
Yuki Okushi
c27779f59b
Rollup merge of #75226 - pnadon:miri-undef-uninit, r=RalfJung
Miri: Renamed "undef" to "uninit"

Renamed remaining references to "undef" to "uninit" when referring to Miri.

Impacted directories are:

- `src/librustc_codegen_llvm/consts.rs`
- `src/librustc_middle/mir/interpret/`
- `src/librustc_middle/ty/print/pretty.rs`
- `src/librustc_mir/`
- `src/tools/clippy/clippy_lints/src/consts.rs`

Upon building Miri based on the new changes it was verified that no changes needed to be made with the Miri project.

Related issue #71193
2020-08-11 16:23:47 +09:00
bors
7189ca604a Auto merge of #75383 - Dylan-DPC:rollup-6hi36zn, r=Dylan-DPC
Rollup of 10 pull requests

Successful merges:

 - #75098 (Clippy pointer cast lint experiment)
 - #75249 (Only add a border for the rust logo)
 - #75315 (Avoid deleting temporary files on error)
 - #75316 (Don't try to use wasm intrinsics on vectors)
 - #75337 (instance: only polymorphize upvar substs)
 - #75339 (evaluate required_consts when pushing stack frame in Miri engine)
 - #75363 (Use existing `infcx` when emitting trait impl diagnostic)
 - #75366 (Add help button)
 - #75369 (Move to intra-doc links in /library/core/src/borrow.rs)
 - #75379 (Use intra-doc links in /library/core/src/cmp.rs)

Failed merges:

r? @ghost
2020-08-11 01:38:31 +00:00
Dylan DPC
51ed33d8c2
Rollup merge of #75366 - GuillaumeGomez:help-button, r=jyn514
Add help button

Part of #75197.

Here is a screenshot of the result:

![Screenshot from 2020-08-10 16-53-20](https://user-images.githubusercontent.com/3050060/89796547-14112a00-db2a-11ea-9f25-57b30ab68f9b.png)

r? @jyn514
2020-08-11 01:56:43 +02:00
Dylan DPC
dff868e3da
Rollup merge of #75363 - Aaron1011:fix/diag-infcx, r=lcnr
Use existing `infcx` when emitting trait impl diagnostic

Fixes #75361
Fixes #74918

Previously, we were creating a new `InferCtxt`, which caused an ICE when
used with type variables from the existing `InferCtxt`
2020-08-11 01:56:41 +02:00
Dylan DPC
9edec571cb
Rollup merge of #75339 - RalfJung:eval-required, r=oli-obk
evaluate required_consts when pushing stack frame in Miri engine

[Just like codegen](https://github.com/rust-lang/rust/pull/70820/files#diff-32c57af5c8e23eb048f55d1e955e5cd5R194), Miri needs to make sure all `required_consts` evaluate successfully, to catch post-monomorphization errors.

While at it I also moved the const_eval error reporting logic into rustc_mir::const_eval::error; there is no reason it should be in `rustc_middle`. I kept this in a separate commit for easier reviewing.

Helps with https://github.com/rust-lang/miri/issues/1382. I will add a test on the Miri side (done now: https://github.com/rust-lang/miri/pull/1504).
r? @oli-obk
2020-08-11 01:56:39 +02:00
Dylan DPC
1e41af3c8c
Rollup merge of #75337 - davidtwco:polymorphization-75255-fixes, r=eddyb
instance: only polymorphize upvar substs

This PR restricts the substitution polymorphization added in #75255 to only apply to the tupled upvar substitution, rather than all substitutions, fixing a bunch of regressions when polymorphization is
enabled.

Due to an oversight on my part, when landing #75260 and #75255, some tests started failing when polymorphization was enabled that I didn't notice until after landing - this PR fixes the regressions from #75255. #75336 has been filed to make sure that we don't forget to try make this change again in future, as it does enable some optimisations.

r? @lcnr
2020-08-11 01:56:38 +02:00
Dylan DPC
2932638d34
Rollup merge of #75316 - alexcrichton:fix-wasm-simd, r=oli-obk
Don't try to use wasm intrinsics on vectors

This commit fixes an issue with #74695 where the fptosi and fptoui
specializations on wasm were accidentally used on vector types by the
`simd_cast` intrinsic. This issue showed up as broken CI for the stdsimd
crate. Here this commit simply skips the specialization on vector kinds
flowing into `fpto{s,u}i`.
2020-08-11 01:56:36 +02:00
Dylan DPC
992988bbc5
Rollup merge of #75315 - Mark-Simulacrum:save-temps, r=ecstatic-morse
Avoid deleting temporary files on error

Previously if the compiler error'd, fatally, then temporary directories which
should be preserved by -Csave-temps would be deleted due to fatal compiler
errors being implemented as panics.

cc @infinity0

(Hopefully) fixes #75275, but I haven't tested
2020-08-11 01:56:34 +02:00
Dylan DPC
2ad7c1687f
Rollup merge of #75249 - GuillaumeGomez:rust-logo-border, r=Manishearth
Only add a border for the rust logo

![Screenshot from 2020-08-07 11-22-51](https://user-images.githubusercontent.com/3050060/89631113-9dadc700-d8a0-11ea-8063-ad40207decaa.png)
![Screenshot from 2020-08-07 11-19-47](https://user-images.githubusercontent.com/3050060/89631114-9e465d80-d8a0-11ea-96ba-1d6926c8e7a9.png)
![Screenshot from 2020-08-07 11-19-41](https://user-images.githubusercontent.com/3050060/89631117-9edef400-d8a0-11ea-9c66-0df3d8c1ac2d.png)

I didn't add a border for the light theme though, as I felt it as unnecessary.

r? @Manishearth
2020-08-11 01:56:32 +02:00
Dylan DPC
63d1e372a6
Rollup merge of #75098 - Ryan1729:clippy-pointer-cast-lint-experiment, r=oli-obk
Clippy pointer cast lint experiment

This PR is an experiment about exposing more parts of `rustc_typeck` for use in `clippy`. In particular, the code that checks where a cast is valid or not was exposed, which necessitated exposing [`FnCtxt`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_typeck/check/struct.FnCtxt.html), and figuring out how to create an instance of that type inside `clippy`.

This was prompted by [this clippy issue](https://github.com/rust-lang/rust-clippy/issues/2064).

r? @oli-obk
2020-08-11 01:56:30 +02:00
bors
3bb5a863c8 Auto merge of #74005 - estebank:type-ascription-redux, r=petrochenkov
Clean up errors in typeck and resolve

* Tweak ordering of suggestions
* Do not suggest similarly named enclosing item
* Point at item definition in foreign crates
* Add missing primary label

CC #34255.
2020-08-10 23:50:39 +00:00
Matthias Krüger
f59ec1945f run cargo dev update-lints 2020-08-10 23:57:08 +02:00
bors
770bd3d1d0 Auto merge of #75349 - nnethercote:tweak-confusable-idents-checking, r=petrochenkov
Tweak confusable idents checking

The confusable idents checking does some sub-optimal things with symbols.

r? @petrochenkov
cc @crlf0710
2020-08-10 21:47:29 +00:00
Mark Rousskov
6bbf4558ac Feature gate is always present 2020-08-11 00:08:04 +03:00
Vadim Petrochenkov
20c5044465 Introduce rustc_lexer::is_ident and use it in couple of places 2020-08-11 00:08:04 +03:00
bors
d495ef527c Auto merge of #75127 - jyn514:impl-trait, r=pnkfelix
Fix async-std by special-casing rustdoc in typeck

https://github.com/rust-lang/rust/issues/75100
2020-08-10 19:33:25 +00:00
Esteban Küber
54f1b43130 Add missing primary label 2020-08-10 12:04:10 -07:00
Esteban Küber
6c0755a7dc Point at item definition in foreign crates 2020-08-10 12:04:10 -07:00
Esteban Küber
089810a1cb Do not suggest similarly named enclosing item 2020-08-10 12:04:10 -07:00
Esteban Küber
eef284be59 Tweak ordering of suggestions
Modify logic to make it easier to follow and recover labels that would
otherwise be lost.
2020-08-10 12:04:10 -07:00
Esteban Küber
308b5585f3 Detect JS-style === and !== and recover
Fix #75312.
2020-08-10 11:44:09 -07:00
bors
1275cc15d6 Auto merge of #74936 - GuillaumeGomez:const-rustc_const_unstable, r=jyn514
Don't print "const" keyword on non-nightly build if rustc_const_unstable is used on the item

Fixes #74579.
2020-08-10 17:12:42 +00:00
Ivan Tham
a7f61bf3bb
Remove empty fn main from E0749 2020-08-11 01:06:30 +08:00
bors
08324fe6f7 Auto merge of #74953 - JulianKnodt:master, r=lcnr
Remove restriction on type parameters preceding consts w/ feature const-generics

Removed the restriction on type parameters preceding const parameters when the feature const-generics is enabled.

Builds on #74676, which deals with unsorted generic parameters. This just lifts the check in lowering the AST to HIR that permits consts and types to be reordered with respect to each other. Lifetimes still must precede both

This change is not intended for min-const-generics, and is gated behind the `#![feature(const_generics)]`.

One thing is that it also permits type parameters without a default to come after consts, which I expected to not work, and was hoping to get more guidance on whether that should be permitted or how to prevent it otherwise.

I did not go through the RFC process for this pull request because there was prior work to get this feature added. In the previous PR that was cited, work was done to enable this change.

r? @lcnr
2020-08-10 15:19:46 +00:00
Guillaume Gomez
2a281e0a76 Add test for rustc_const_unstable on methods 2020-08-10 16:57:25 +02:00
Guillaume Gomez
a34bc7961a Add help button 2020-08-10 16:52:19 +02:00
Ivan Tham
8cb1a2f8a2
Use : rather than . in example description
Co-authored-by: Guillaume Gomez <guillaume1.gomez@gmail.com>
2020-08-10 22:46:15 +08:00
Ivan Tham
a2d7c33aa8
Split fix into another section for E0749 2020-08-10 22:33:17 +08:00
bors
4c336d4626 Auto merge of #75357 - RalfJung:miri, r=RalfJung
update Miri

Fixes https://github.com/rust-lang/rust/issues/75274
Cc @rust-lang/miri r? @ghost
2020-08-10 13:01:44 +00:00
Philipp Krones
8ee57eed79
Rollup merge of #5869 - wiomoc:feature/implicit-self, r=ebroto,flip1995
New lint against `Self` as an arbitrary self type

Fixes #5861

changelog: * [`needless_arbitrary_self_type`] [#5869](https://github.com/rust-lang/rust-clippy/pull/5869)
2020-08-10 14:56:26 +02:00
Philipp Krones
9da5b6d1d0
Rollup merge of #5825 - giraffate:same_item_push, r=Manishearth
Add the new lint `same_item_push`

changelog: Add the new lint `same_item_push`

Fixed #4078. As I said in https://github.com/rust-lang/rust-clippy/issues/4078#issuecomment-658184195, I referrerd to https://github.com/rust-lang/rust-clippy/pull/4647.
2020-08-10 14:56:25 +02:00
David Wood
20f4e16824
polymorphize: constrain unevaluated const handling
This commit constrains the support added for handling unevaluated consts
in polymorphization (introduced in #75260) by:

- Skipping associated constants as this causes cycle errors.
- Skipping promoted constants when they contain `Self` as this ensures
  `T` is used in constants of the form `<Self as Foo<T>>`.

Signed-off-by: David Wood <david@davidtw.co>
2020-08-10 13:23:19 +01:00
Aaron Hill
4ed0c6a464
Use existing infcx when emitting trait impl diagnostic
Fixes #75361
Fixes #74918

Previously, we were creating a new `InferCtxt`, which caused an ICE when
used with type variables from the existing `InferCtxt`
2020-08-10 08:08:15 -04:00
Ivan Tham
ec23f4ed3f
Add sample fix for E0749
Even though the description is clear but the solution may not be as straightforward.
Adding a suggested fix.
2020-08-10 18:51:14 +08:00
Bastian Kauschke
66db8e52d7 unused_delims: trim expr 2020-08-10 12:04:51 +02:00
Ralf Jung
fd3851aadb add test for unused erroneous const in CTFE 2020-08-10 10:58:53 +02:00
Ralf Jung
26ec7e9dd9 update Miri 2020-08-10 10:06:23 +02:00
pawanbisht62
7c4ef37e19
Merge branch 'master' into feature/incorporate-tracing 2020-08-10 13:19:24 +05:30
kadmin
64f6437822 Convert Eq impl to check Ord::Equal 2020-08-10 05:54:55 +00:00
bors
13290e83a6 Auto merge of #75204 - cuviper:freebsd11, r=Mark-Simulacrum
Upgrade the FreeBSD toolchain to version 11.4

FreeBSD 10 reached its end-of-life in October 2018, and that toolchain
caused issues in the LLVM 11 upgrade (#73526) that are resolved with the
toolchain from FreeBSD 11.

Closes #72390.
2020-08-10 05:34:53 +00:00
bors
568f6195bb Auto merge of #74410 - mati865:mingw-no-self-contained-when-cross-compiling, r=petrochenkov
MinGW: disable self-contained mode when cross compiling

When cross compiling users have to provide own linker and libraries anyway.
Using rust provided MinGW crt objects is harmful here and has no benefits.

cc https://github.com/rust-lang/rust/issues/68887
2020-08-10 02:08:35 +00:00
Esteban Küber
7e0180906b Small cleanup
Remove unnecessary `unwrap`.
2020-08-09 17:48:32 -07:00
Esteban Küber
9149ec74db Tweak conditions for E0026 and E0769
When we have a tuple struct used with struct we don't want to suggest using
the (valid) struct syntax with numeric field names. Instead we want to
suggest the expected syntax.

Given

```rust
fn main() {
    match MyOption::MySome(42) {
        MyOption::MySome { x: 42 } => (),
        _ => (),
    }
}
```

We now emit E0769 "tuple variant `MyOption::MySome` written as struct variant"
instead of E0026 "variant `MyOption::MySome` does not have a field named `x`".
2020-08-09 17:12:57 -07:00
bors
cee62c17aa Auto merge of #75351 - JohnTitor:rollup-q9udsyx, r=JohnTitor
Rollup of 8 pull requests

Successful merges:

 - #74200 (Std panicking unsafe block in unsafe fn)
 - #75286 (Add additional case for Path starts with)
 - #75318 (Resolve `char` as a primitive even if there is a module in scope)
 - #75320 (Detect likely `for foo of bar` JS syntax)
 - #75328 (Cleanup E0749)
 - #75344 (Rename "Important traits" to "Notable traits")
 - #75348 (Move to intra-doc links in library/core/src/time.rs)
 - #75350 (Do not ICE when lowering invalid extern fn with bodies)

Failed merges:

r? @ghost
2020-08-10 00:09:45 +00:00
Yuki Okushi
5369619693
Rollup merge of #75350 - estebank:foreign-fn-with-body-ice, r=davidtwco
Do not ICE when lowering invalid extern fn with bodies

Fix #75283.
2020-08-10 09:08:03 +09:00
Yuki Okushi
8176240788
Rollup merge of #75344 - camelid:rename-important-to-notable-traits, r=Manishearth
Rename "Important traits" to "Notable traits"

Fixes #75245.

---

* Rename it in the UI
* Rename the CSS classes
2020-08-10 09:07:59 +09:00
Yuki Okushi
f6c41fbed7
Rollup merge of #75328 - GuillaumeGomez:cleanup-e0749, r=Dylan-DPC
Cleanup E0749

r? @pickfire
2020-08-10 09:07:57 +09:00
Yuki Okushi
d8ac403fd1
Rollup merge of #75320 - estebank:js-for-i-of-x, r=davidtwco
Detect likely `for foo of bar` JS syntax

Fix #75311.
2020-08-10 09:07:56 +09:00
Yuki Okushi
968740a3a3
Rollup merge of #75318 - jyn514:primitive, r=manishearth
Resolve `char` as a primitive even if there is a module in scope

Closes https://github.com/rust-lang/rust/issues/58699.
r? @Manishearth
2020-08-10 09:07:54 +09:00
Esteban Küber
bdf426afe7 Do not ICE when lowering invalid extern fn with bodies
Fix #75283.
2020-08-09 15:14:54 -07:00
bors
f5fef3c715 Auto merge of #75345 - Aaron1011:fix/no-std-hygiene, r=petrochenkov
Remove normalization of `Span` debug output in proc-macro tests

Fixes #74800

The definition of `is_x86_feature_detected!` (and similar macros)
depends on the platform - it is produced by a `cfg_if!` invocation on
x86, and a plain `#[cfg]` on other platforms. Since it is part of the
prelude, we will end up importing different hygiene information
depending on the platform. This previously required us to avoid printing raw
`SyntaxContext` ids in any tests that uses the standard library, since
the captured output will be platform-dependent.

Previously, we replaced all `SyntaxContext` ids with "#CTXT", and the
raw `Span` lo/hi bytes with "LO..HI".

This commit adds `#![no_std]` and `extern crate std` to all proc-macro
tests that print spans. This suppresses the prelude import, while
still using lang items from `std` (which gives us a buildable binary).
With this apporach, we will only load hygiene information for things
which we explicitly import. This lets us re-add
`-Z unpretty=expanded,hygiene`, since its output can now be made stable
across all platforms.

Additionally, we use `-Z span-debug` in more places, which lets us avoid
the "LO..HI" normalization hack.
2020-08-09 22:08:02 +00:00
Nicholas Nethercote
0a597bd98f Remove CowBoxSymStr.
`CowBoxSymStr` is a type that either holds a `SymbolStr` (which is much
the same as a `Symbol`), or an owned string. When computing skeletons,
a `SymbolStr` is stored if the skeleton is the same as the original
string, otherwise an owned string is stored.

So, basically, `CowBoxSymStr` is a type for string interning. But we
already have one of those: `Symbol` itself. This PR removes
`CowBoxSymStr`, using `Symbol` instead. A good thing about this is that
it avoids storing `SymbolStr` values in `skeleton_map`, something that
is discouraged.

The PR also inlines and removes the `calc_skeleton()` function because
that simplifies the code.
2020-08-10 07:12:59 +10:00
Nicholas Nethercote
75b67c2d5e Fix symbol ordering for confusable idents detection.
Confusable idents detection uses a type `BTreeMap<Symbol, Span>`. This is
highly dubious given that `Symbol` doesn't guarantee a meaningful order. (In
practice, it currently gives an order that mostly matches source code order.)

As a result, changes in `Symbol` representation make the
`lint-confusable-idents.rs` test fail, because this error message:

> identifier pair considered confusable between `s` and `s`

is changed to this:

> identifier pair considered confusable between `s` and `s`

and the corresponding span pointers get swapped erroneously, leading to
an incorrect "previous identifier" label.

This commit sorts the relevant symbols by span before doing the checking,
which ensures that the ident that appears first in the code will be mentioned
first in the message. The commit also extends the test slightly to be more
thorough.
2020-08-10 07:12:59 +10:00
Mara Bos
8c705f83db Rustdoc: Fix natural ordering to look at all numbers.
The old implementation only looks at numbers at the end, but not in
other places in a name: "u8" and "u16" got sorted properly, but "u8_bla"
and "u16_bla" did not.
2020-08-09 23:05:35 +02:00
bors
18f3be7704 Auto merge of #75278 - cuviper:indexmap, r=Mark-Simulacrum
Upgrade indexmap and use it more

First this upgrades `indexmap` to 1.5.1, which is now based on `hashbrown::raw::RawTable`. This means it shares a lot of the same performance characteristics for insert, lookup, etc., while keeping items in insertion order.

Then across various rustc crates, this replaces a lot of `Vec`+`HashMap` pairs with a single `IndexMap` or `IndexSet`.

Closes #60608.
r? @eddyb
2020-08-09 20:08:50 +00:00
Josh Stone
ca0b89aa04 rustc_span: note the perf loss seen from IndexSet in symbol::Interner 2020-08-09 12:41:09 -07:00
Josh Stone
1d03ffe0bc rustc_typeck: use IndexSet in InteriorVisitor 2020-08-09 12:25:22 -07:00
Josh Stone
b258817115 rustc_typeck: use IndexSet in UniquePredicates 2020-08-09 12:25:22 -07:00
Josh Stone
7d1547d300 rustc_span: use IndexSet in SpanInterner 2020-08-09 12:25:22 -07:00
Josh Stone
4efc7e92fa rustc_mir_build: use IndexMap in TestKind::SwitchInt 2020-08-09 12:25:22 -07:00
Josh Stone
c61f1c8bfa rustc_mir: use IndexSet in PlaceholderIndices 2020-08-09 12:25:22 -07:00
Josh Stone
42e7a0cb3a rustc_mir: use IndexMap in BorrowSet 2020-08-09 12:25:22 -07:00
Josh Stone
952daa20b4 rustc_middle: use IndexSet in OnDiskCache 2020-08-09 12:25:22 -07:00
Josh Stone
2fa6e44c8d rustc_metadata: use IndexSet in EncodeContext 2020-08-09 12:25:22 -07:00
Josh Stone
d3c70b8af5 rustc_data_structures: use IndexSet in TransitiveRelation 2020-08-09 12:25:21 -07:00
Josh Stone
1f71f0f2b5 rustc_codegen_llvm: use IndexSet in CoverageMapGenerator 2020-08-09 12:25:21 -07:00
Josh Stone
997a766b32 Upgrade indexmap to 1.5.1, now using hashbrown! 2020-08-09 12:25:21 -07:00
Camelid
f3cc957f2e Rename "Important traits" to "Notable traits"
* Rename it in the UI
* Rename the CSS classes
2020-08-09 12:09:05 -07:00
Aaron Hill
db6b3c1ce4
Remove normalization of Span debug output in proc-macro tests
Fixes #74800

The definition of `is_x86_feature_detected!` (and similar macros)
depends on the platform - it is produced by a `cfg_if!` invocation on
x86, and a plain `#[cfg]` on other platforms. Since it is part of the
prelude, we will end up importing different hygiene information
depending on the platform. This previously required us to avoid printing raw
`SyntaxContext` ids in any tests that uses the standard library, since
the captured output will be platform-dependent.

Previously, we replaced all `SyntaxContext` ids with "#CTXT", and the
raw `Span` lo/hi bytes with "LO..HI".

This commit adds `#![no_std]` and `extern crate std` to all proc-macro
tests that print spans. This suppresses the prelude import, while
still using lang items from `std` (which gives us a buildable binary).
With this apporach, we will only load hygiene information for things
which we explicitly import. This lets us re-add
`-Z unpretty=expanded,hygiene`, since its output can now be made stable
across all platforms.

Additionally, we use `-Z span-debug` in more places, which lets us avoid
the "LO..HI" normalization hack.
2020-08-09 14:41:51 -04:00
bors
39e593ab14 Auto merge of #75137 - Aaron1011:fix/hygiene-skip-expndata, r=petrochenkov
Don't serialize ExpnData for foreign crates

When we encode an ExpnId into the crate metadata, we write out the
CrateNum of the crate that 'owns' the corresponding `ExpnData`, which
is later used to decode the `ExpnData` from its owning crate.

However, we current serialize the `ExpnData` for all `ExpnIds` that we
serialize, even if the `ExpnData` was already serialized into a foreign
crate. This commit skips encoding this kind of `ExpnData`, which should
hopefully speed up metadata encoding and reduce the total metadata size.
2020-08-09 18:19:34 +00:00
Josh Stone
29f5e5c574 Upgrade the FreeBSD toolchain to version 11.4
FreeBSD 10 reached its end-of-life in October 2018, and that toolchain
caused issues in the LLVM 11 upgrade (#73526) that are resolved with the
toolchain from FreeBSD 11.
2020-08-09 10:38:52 -07:00
Ralf Jung
1fa7203161 bless MIR 2020-08-09 18:54:56 +02:00
Ralf Jung
a0e057540e evaluate required_consts when pushing stack frame in Miri engine 2020-08-09 18:14:28 +02:00
Ralf Jung
aec6df9b94 move stack size check to const_eval machine 2020-08-09 18:01:37 +02:00
Greg V
2f39477ecf Add sanitizer support on FreeBSD 2020-08-09 17:51:41 +03:00
bors
543f03d241 Auto merge of #75134 - Aaron1011:feature/expn-data-parent-hash, r=petrochenkov
Hash parent ExpnData

cc https://github.com/rust-lang/rust/pull/72121#discussion_r460528326
2020-08-09 14:29:42 +00:00
David Wood
fd41bdeff0
instance: only polymorphize upvar substs
This commit restricts the substitution polymorphization added in #75255
to only apply to the tupled upvar substitution, rather than all
substitutions, fixing a bunch of regressions when polymorphization is
enabled.

Signed-off-by: David Wood <david@davidtw.co>
2020-08-09 14:53:33 +01:00
Ralf Jung
bff69c9525 move const_eval error reporting logic into rustc_mir::const_eval::error 2020-08-09 15:37:32 +02:00
Aaron Hill
ef49032297
Add comment about the lack of ExpnData serialization for proc-macro crates 2020-08-09 08:43:11 -04:00
Joshua Nelson
b11e2f2341 Give precedence to primitives over modules
This has less surprising behavior when there is a module with the same
name as a primitive in scope.
2020-08-09 08:34:21 -04:00
Mark Rousskov
2627eedde9 Avoid deleting temporary files on error
Previously if the compiler error'd, fatally, then temporary directories which
should be preserved by -Csave-temps would be deleted due to fatal compiler
errors being implemented as panics.
2020-08-09 08:28:15 -04:00
Guillaume Gomez
4e78760137 Remove E0749 from untested error codes 2020-08-09 13:53:27 +02:00
Guillaume Gomez
cc54a1f930 Clean up E0749 explanation 2020-08-09 13:53:27 +02:00
Vadim Petrochenkov
bef1ee3857 tests: Mark ui/asm/bad-arch.rs as requiring wasm llvm backend 2020-08-09 11:40:48 +03:00
kadmin
be0d6f1c06 Change Ord impl for ParamKindOrd
Updated tests and error msgs

Update stderr from test

Update w/ lcnr comments

Change some tests around, and also updated Ord implementation for ParamKindOrd

Update w/ nits from lcnr
2020-08-09 07:41:26 +00:00
kadmin
4f461f5d12 Switched to unordered field in ParamKindOrd
Run fmt
2020-08-09 07:41:26 +00:00
kadmin
1ae1a6332c Add ParamKindOrd::ConstUnordered variant 2020-08-09 07:41:26 +00:00
kadmin
319c4f45e0 Blessed old test where error message had changed
Added minor fmt change to ast_validation
2020-08-09 07:41:26 +00:00
kadmin
b8352eb2d1 Test lifetimes after types after consts forbidden
Added more complex test and changed error message
2020-08-09 07:41:24 +00:00
kadmin
f8588284af Added +1 test for only works w/ feat const gen
Added this test to ensure that reordering the parameters only works with the feature const
generics enabled.

Fixed nits

Also added another test to verify that intermixed lifetimes are forbidden
2020-08-09 07:41:22 +00:00
Ryan1729
d2e7293078 add allow unused_unsafe and allow dead_code 2020-08-09 00:39:14 -06:00
Ryan1729
58b8b11791 fix unary minus on usize and unused variable errors in .fixed file 2020-08-09 00:28:56 -06:00
Ryan1729
0fbf450afc add a test example of where transmutes_expressible_as_ptr_casts should not suggest anything 2020-08-09 00:15:56 -06:00
Esteban Küber
4dbe0ac928 Detect likely for foo of bar JS syntax
Fix #75311.
2020-08-08 20:53:40 -07:00
Esteban Küber
0a4f4e87e0 Fix ICE #75307 in format
Remove usages of `unwrap` (even when some are safe today).
2020-08-08 20:11:16 -07:00
Ryan1729
b02bf05690 update stderr for transmutes_expressible_as_ptr_casts 2020-08-08 21:03:41 -06:00
Alex Crichton
b21a3de35f Don't try to use wasm intrinsics on vectors
This commit fixes an issue with #74695 where the fptosi and fptoui
specializations on wasm were accidentally used on vector types by the
`simd_cast` intrinsic. This issue showed up as broken CI for the stdsimd
crate. Here this commit simply skips the specialization on vector kinds
flowing into `fpto{s,u}i`.
2020-08-08 18:09:40 -07:00
Yuki Okushi
e6dfd308d3
Rollup merge of #75292 - slanterns:cleanup-E0502, r=GuillaumeGomez
Clean up E0502

`ref` on an entire `let` pattern is discouraged, take a reference with `&` instead.
2020-08-09 06:41:39 +09:00
Yuki Okushi
bc3ee48fd2
Rollup merge of #75291 - GuillaumeGomez:cleanup-e0750, r=pickfire
Clean up E0750

r? @Dylan-DPC
2020-08-09 06:41:37 +09:00
Yuki Okushi
55f2490a59
Rollup merge of #75290 - rust-lang:min_const_generics-version, r=jonas-schievink
fix `min_const_generics` version

https://github.com/rust-lang/rust/pull/74877#discussion_r467451813

> This should be 1.47.0
2020-08-09 06:41:35 +09:00
Yuki Okushi
5bbdc73ebc
Rollup merge of #74712 - strom-und-spiele:E0271-cleanup, r=Mark-Simulacrum
Update E0271 explanation

When reading the explanation, I got confused by it. I hope the wording is clearer now.
2020-08-09 06:41:14 +09:00
Guillaume Gomez
17db7a4b5c Remove E0750 from unchecked error codes 2020-08-08 21:18:05 +02:00
Guillaume Gomez
259d350111 Clean up E0750 explanation 2020-08-08 21:17:36 +02:00
bors
3f091baba4 Auto merge of #75260 - davidtwco:polymorphization-promoted-substs, r=lcnr
polymorphize: unevaluated constants

This PR makes polymorphization visit the promoted MIR of unevaluated constants with available promoted MIR instead of visiting the substitutions of that constant - which will mark all of the generic parameters as used; in addition polymorphization will now visit non-promoted unevaluated constants rather than visit their substs.

r? @lcnr
2020-08-08 15:57:12 +00:00
Joshua Nelson
a306e12874 Add another test 2020-08-08 10:19:56 -04:00
Philippe Nadon
0c6e8b61b6 Miri: Renamed "undef" to "uninit"
Renamed remaining references to "undef" to "uninit" when referring to Miri.

Impacted directories are:

- src/librustc_codegen_llvm/consts.rs
- src/librustc_middle/mir/interpret/
- src/librustc_middle/ty/print/pretty.rs
- src/librustc_mir/
- src/tools/clippy/clippy_lints/src/consts.rs

Upon building Miri based on the new changes it was verified that no changes needed to be made with the Miri project.

Related issue #71193
2020-08-08 07:53:47 -06:00
bors
2bac92bba1 Auto merge of #74533 - nikic:issue-74425, r=eddyb
Emit == null instead of <= null for niche check

When the niche maximum is zero, emit a "== zero" check instead of a "<= zero" check. In particular, this avoids the awkward case of "<= null". While LLVM does canonicalize this to "== null", this apparently doesn't happen for constant expressions, leading to the issue in #74425. While that can be addressed on the LLVM side, it still seems prudent to emit sensible IR here, because this will allow null checks to be optimized earlier in the pipeline.

Fixes #74425.
2020-08-08 13:33:53 +00:00
Slanterns
d8cf9aa693
Use & instead of let ref in E0502
`ref` on an entire `let` pattern is discouraged, take a reference with `&` instead.
2020-08-08 20:26:56 +08:00
Bastian Kauschke
ad6d23777b
fix min_const_generics version 2020-08-08 13:35:42 +02:00
strom-und-spiele
7e68b7d10a Update E0271.md
remove references to non existing code,
expand solution suggestions
remove unneeded code in solution
2020-08-08 11:01:34 +02:00
Nikita Popov
7e5c7cf8e3 Emit == null instead of <= null
When the niche maximum is zero, emit a "== zero" check instead of
a "<= zero" check. In particular, this avoid the awkward case of
"<= null". While LLVM does canonicalize this to "!= null", this
appently doesn't happen for constant expressions, leading to the
issue in #74425. While that can be addressed on the LLVM side, it
still seems prudent to emit sensible IR here, because this will
allow null checks to be optimized earlier in the pipeline.

Fixes #74425.
2020-08-08 10:45:15 +02:00
bors
e61621c307 Auto merge of #74932 - nnethercote:rm-ast-session-globals, r=petrochenkov
Remove `librustc_ast` session globals

By moving the data onto `Session`.

r? @petrochenkov
2020-08-08 05:58:57 +00:00
kadmin
18481cbec9 Rm restriction on ord of default types w/ consts 2020-08-08 04:40:07 +00:00
julianknodt
58b1a04b9e Allow types to come after consts in AST validation 2020-08-08 04:40:07 +00:00
bors
1d100ba26c Auto merge of #75276 - JohnTitor:rollup-rz4hs0w, r=JohnTitor
Rollup of 7 pull requests

Successful merges:

 - #75224 (Don't call a function in function-arguments-naked.rs)
 - #75237 (Display elided lifetime for non-reference type in doc)
 - #75250 (make MaybeUninit::as_(mut_)ptr const)
 - #75253 (clean up const-hacks in int endianess conversion functions)
 - #75259 (Add missing backtick)
 - #75267 (Small cleanup)
 - #75270 (fix a couple of clippy findings)

Failed merges:

r? @ghost
2020-08-08 03:54:33 +00:00
Yuki Okushi
21bfe529c7
Rollup merge of #75270 - matthiaskrgr:clippy_aug_1, r=Dylan-DPC
fix a couple of clippy findings
2020-08-08 11:36:12 +09:00
Yuki Okushi
81546de429
Rollup merge of #75267 - estebank:cleanup, r=Dylan-DPC
Small cleanup

* Add docstring to `Parser` field
* Remove unnecessary `unwrap`
* Remove unnecessary borrow
* Fix indentation of some `teach`text output
2020-08-08 11:36:10 +09:00
Yuki Okushi
2c1fe50362
Rollup merge of #75259 - giraffate:add_missing_backtick, r=lcnr
Add missing backtick
2020-08-08 11:36:09 +09:00
Yuki Okushi
255434d83c
Rollup merge of #75237 - nbdd0121:rustdoc, r=jyn514
Display elided lifetime for non-reference type in doc

In edition 2018 we encourage writing `<'_>` explicitly, so rustdoc should display like such as well.

Fixes #75225

~~Somehow when I run the compiled rustdoc using `cargo +stage2 doc` on other crates, it correctly produces `<'_>`, but I couldn't get the std doc to do the same with `./x.py doc --stage 2`. Might this be related to the recent change to x.py about how the doc is built?~~
2020-08-08 11:36:03 +09:00
Yuki Okushi
f5d2ffd7fb
Rollup merge of #75224 - Aaron1011:fix/function-arguments-naked, r=Amanieu
Don't call a function in function-arguments-naked.rs

Fixes #75096

It's U.B. to use anything other than inline assmebling in a naked
function. Fortunately, the `#break` directive works fine without
anything in the function body.
2020-08-08 11:36:02 +09:00
Nicholas Nethercote
96dd044827 Increase recursion_limit in librustc_plugin_impl.
To avoid rustdoc problems.
2020-08-08 12:05:10 +10:00
Nicholas Nethercote
3dc8a36958 Eliminate librustc_hir's dependency on librustc_session. 2020-08-08 12:03:44 +10:00
Nicholas Nethercote
e539dd65f8 Eliminate the SessionGlobals from librustc_ast.
By moving `{known,used}_attrs` from `SessionGlobals` to `Session`. This
means they are accessed via the `Session`, rather than via TLS. A few
`Attr` methods and `librustc_ast` functions are now methods of
`Session`.

All of this required passing a `Session` to lots of functions that didn't
already have one. Some of these functions also had arguments removed, because
those arguments could be accessed directly via the `Session` argument.

`contains_feature_attr()` was dead, and is removed.

Some functions were moved from `librustc_ast` elsewhere because they now need
to access `Session`, which isn't available in that crate.
- `entry_point_type()` --> `librustc_builtin_macros`
- `global_allocator_spans()` --> `librustc_metadata`
- `is_proc_macro_attr()` --> `Session`
2020-08-08 12:03:42 +10:00
Nicholas Nethercote
d6fa011f62 Remove some unnecessary uses of Option.
These arguments are never `None`.
2020-08-08 12:02:45 +10:00
bors
f9c2177ddc Auto merge of #74877 - lcnr:min_const_generics, r=oli-obk
Implement the `min_const_generics` feature gate

Implements both https://github.com/rust-lang/lang-team/issues/37 and https://github.com/rust-lang/compiler-team/issues/332.

Adds the new feature gate `#![feature(min_const_generics)]`.
This feature gate adds the following limitations to using const generics:
- generic parameters must only be used in types if they are trivial. (either `N` or `{ N }`)
- generic parameters must be either integers, `bool` or `char`.

We do allow arbitrary expressions in associated consts though, meaning that the following is allowed,
even if `<[u8; 0] as Foo>::ASSOC` is not const evaluatable.
```rust
trait Foo {
    const ASSOC: usize;
}

impl<const N: usize> Foo for [u8; N] {
    const ASSOC: usize = 64 / N;
}
```

r? @varkor cc @eddyb @withoutboats
2020-08-08 01:48:35 +00:00
Joshua Nelson
b146000e91 EXTREMELY hacky fix
This runs _just_ enough of typeck that later queries don't panic.
Because this is in the same part of the compiler that errors on `impl
Trait`, this special-cases impl Trait for rustdoc and no one else.
Everything is fine.
2020-08-07 21:26:12 -04:00
Gary Guo
541fbbb6fa Cross-crate doc inlining test case for elided lifetime 2020-08-08 01:07:43 +01:00
bors
f3a9de9b08 Auto merge of #75048 - eggyal:force-no-tco-start-backtrace-frame, r=Mark-Simulacrum
Prevent `__rust_begin_short_backtrace` frames from being tail-call optimised away

I've stumbled across some situations where there (unexpectedly) was no `__rust_begin_short_backtrace` frame on the stack during unwinding.

On closer examination, it appeared that the calls to that function had been tail-call optimised away.

This PR follows [@bjorn3's suggestion on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Disabling.20tail.20call.20optimisation.3F/near/205699133), by adding calls to `black_box` that hint to rustc not to perform TCO.

Fixes #47429
2020-08-08 00:00:52 +00:00
Matthias Krüger
a605e51056 fix clippy::needless_return: remove unneeded return statements 2020-08-08 00:57:37 +02:00
Matthias Krüger
ff692ab14f fix clippy::clone_on_copy: don't clone types that are copy 2020-08-08 00:57:30 +02:00
Matthias Krüger
15dcda36e6 fix clippy::map_clone: use .cloned() instead of .map(|x| x.clone()) 2020-08-08 00:57:21 +02:00
Matthias Krüger
4ba1a19463 fix clippy::into_iter_on_ref: use .iter() instead of into_iter() on references. 2020-08-08 00:57:15 +02:00
Matthias Krüger
ea9ccfa42c fix clippy::while_let_loop: use while let{} instead of loop { if ... break; } 2020-08-08 00:57:09 +02:00
Matthias Krüger
f95cfe573a fix clippy::redundant_closure: remove redundant closures and call functions directly 2020-08-08 00:57:03 +02:00
Gary Guo
505d157814 Display elided lifetime for external paths 2020-08-07 23:41:07 +01:00
Gary Guo
63c0d9ca51 Display elided lifetime for non-reference type in doc 2020-08-07 23:35:07 +01:00
Matthias Krüger
057730c4b1 fix clippy::len_zero: use is_empty() instead of comparing .len() to zero 2020-08-07 22:47:32 +02:00
Matthias Krüger
eccc2fe503 fix clippy::unneeded_wildcard_pattern: remove redundant wildcard pattern 2020-08-07 22:47:32 +02:00
Matthias Krüger
f6b1857353 fix clippy::unnecessary_mut_passed: function arg is not required to be mutable 2020-08-07 22:47:32 +02:00