Commit Graph

185 Commits

Author SHA1 Message Date
Dylan DPC
3d834bc0d3
Rollup merge of #76293 - Amjad50:incompatible_features_error, r=lcnr
Implementation of incompatible features error

Proposal of a new error: Incompatible features

This error should happen if two features which are not compatible are used together.

For now the only incompatible features are `const_generics` and `min_const_generics`

fixes #76280
2020-09-07 01:17:50 +02:00
Dylan DPC
6545985888
Rollup merge of #76274 - scottmcm:fix-76271, r=petrochenkov
Allow try blocks as the argument to return expressions

Fixes #76271

I don't think this needs to be edition-aware (phew) since `return try` in 2015 is also the start of an expression, just with a struct literal instead of a block (`return try { x: 4, y: 5 }`).
2020-09-07 01:17:46 +02:00
Ralf Jung
720293b640 do not premote non-ZST mutable references ever 2020-09-06 14:14:27 +02:00
Sasha
84fc6fd2d0 Fix documentation for TyCtxt::all_impls 2020-09-06 12:10:46 +02:00
Simon Vandel Sillesen
9b0fc6202b Generalize to Eq(true, _place) and Eq(_place, true) 2020-09-06 11:51:44 +02:00
Simon Vandel Sillesen
c2693db264 Add peephold optimization that simplifies Ne(_1, false) and Ne(false, _1) into _1
This was observed emitted from the MatchBranchSimplification pass.
2020-09-06 11:51:44 +02:00
bors
ffaf158608 Auto merge of #76331 - Aaron1011:fix/group-compat-hack-test, r=petrochenkov
Account for version number in NtIdent hack

Issue #74616 tracks a backwards-compatibility hack for certain macros.
This has is implemented by hard-coding the filenames and macro names of
certain code that we want to continue to compile.

However, the initial implementation of the hack was based on the
directory structure when building the crate from its repository (e.g.
`js-sys/src/lib.rs`). When the crate is build as a dependency, it will
include a version number from the clone from the cargo registry (e.g.
`js-sys-0.3.17/src/lib.rs`), which would fail the check.

This commit modifies the backwards-compatibility hack to check that
desired crate name (`js-sys` or `time-macros-impl`) is a prefix of the
proper part of the path.

See https://github.com/rust-lang/rust/issues/76070#issuecomment-687215646
for more details.
2020-09-06 06:15:28 +00:00
bors
94b8eb80ab Auto merge of #76307 - sunfishcode:wasm-no-eh-frame-header, r=alexcrichton
Disable use of `--eh-frame-hdr` on wasm32.

Set wasm32's `TargetOptions::eh_frame_header` to false so that we don't pass `--eh-frame-hdr` to `wasm-ld`, which doesn't support that flag.

r? @alexcrichton
2020-09-06 01:58:35 +00:00
Dylan DPC
85cee57fd7
Rollup merge of #76285 - matklad:censor-spacing, r=petrochenkov
Move jointness censoring to proc_macro

Proc-macro API currently exposes jointness in `Punct` tokens. That is,
`+` in `+one` is **non** joint.

Our lexer produces jointness info for all tokens, so we need to censor
it *somewhere*

Previously we did this in a lexer, but it makes more sense to do this
in a proc-macro server.

r? @petrochenkov
2020-09-05 16:28:36 +02:00
Dylan DPC
b4d3873024
Rollup merge of #76263 - tmiasko:inline-codegen-fn-attrs, r=ecstatic-morse
inliner: Check for codegen fn attributes compatibility

* Check for target features compatibility
* Check for no_sanitize attribute compatibility

Fixes #76259.
2020-09-05 16:28:34 +02:00
Dylan DPC
79b8f59185
Rollup merge of #76254 - tmiasko:fold-len, r=wesleywiser
Fold length constant in Rvalue::Repeat

Fixes #76248.
2020-09-05 16:28:30 +02:00
Dylan DPC
e160d2b3e0
Rollup merge of #75741 - workingjubilee:refactor-byteorder, r=matthewjasper
Refactor byteorder to std in rustc_middle

Use std::io::{Read, Write} and {to, from}_{le, be}_bytes methods in
order to remove byteorder from librustc_middle's dependency graph.
2020-09-05 16:28:17 +02:00
bors
81a769f261 Auto merge of #75584 - RalfJung:union-no-deref, r=matthewjasper
do not apply DerefMut on union field

This implements the part of [RFC 2514](https://github.com/rust-lang/rfcs/blob/master/text/2514-union-initialization-and-drop.md) about `DerefMut`. Unlike described in the RFC, we only apply this warning specifically when doing `DerefMut` of a `ManuallyDrop` field; that is really the case we are worried about here.

@matthewjasper suggested I patch `convert_place_derefs_to_mutable` and `convert_place_op_to_mutable` for this, but I could not find anything to do in `convert_place_op_to_mutable` and this is sufficient to make the test pass. However, maybe there are some other cases this misses? I have no familiarity with this code.

This is a breaking change *in theory*, if someone used `ManuallyDrop<T>` in a union field and relied on automatic `DerefMut`. But on stable this means `T: Copy`, so the `ManuallyDrop` is rather pointless.

Cc https://github.com/rust-lang/rust/issues/55149
2020-09-05 11:47:01 +00:00
bors
02fe30971e Auto merge of #75888 - GuillaumeGomez:trait-impl-assoc-const-doc-alias, r=ollie27
Add check for doc alias on assoc const in trait impl

Fixes #73721.

r? @ollie27
2020-09-05 09:35:17 +00:00
Mara Bos
61ac138b5c Disable atomics on avr target.
`max_atomic_width` was missing in the spec, which means it fell back to
the pointer width of 16 bits.
2020-09-05 11:35:01 +02:00
Jubilee Young
2df552b406 Fix big endian read/write
Co-authored-by: matthewjasper <mjjasper1@gmail.com>
2020-09-04 21:51:29 -07:00
Jubilee Young
dc00efff9f Explain contract of {read, write}_target_uint 2020-09-04 21:51:28 -07:00
Jubilee
fe2a867125 Be explicit that we're handling bytes
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-09-04 21:51:28 -07:00
Jubilee Young
74b4eea64d Remove reference to byteorder limits 2020-09-04 21:51:28 -07:00
Jubilee Young
b97d4131fe Refactor byteorder to std in rustc_middle
Use std::io::{Read, Write} and {to, from}_{le, be}_bytes methods in
order to remove byteorder from librustc_middle's dependency graph.
2020-09-04 21:51:17 -07:00
Caleb Cartwright
08e35155b4 rustc_expand: remove pub visibility for rustfmt 2020-09-04 19:44:11 -05:00
Scott McMurray
59e37332b0 Add BREAK too, and improve the comments 2020-09-04 16:28:23 -07:00
Jack Huey
0aa215305a kind -> kind() 2020-09-04 19:17:57 -04:00
Jack Huey
f690569465 Review comments 2020-09-04 19:12:54 -04:00
Jack Huey
76c728901e More chalk work 2020-09-04 19:12:54 -04:00
Jack Huey
d66452c3e5 Upgrade chalk to 0.21 2020-09-04 19:12:54 -04:00
Jonas Schievink
bcfd15b09c Remove unused duplicated trivial_dropck_outlives 2020-09-04 22:24:03 +02:00
bors
42d896afbd Auto merge of #76315 - lcnr:map-track-caller, r=Mark-Simulacrum
add `#[track_caller]` to `local_def_id_to_hir_id`

Improves one of the more frequent ICE
2020-09-04 19:05:20 +00:00
Aaron Hill
9e7ef659e1
Account for version number in NtIdent hack
Issue #74616 tracks a backwards-compatibility hack for certain macros.
This has is implemented by hard-coding the filenames and macro names of
certain code that we want to continue to compile.

However, the initial implementation of the hack was based on the
directory structure when building the crate from its repository (e.g.
`js-sys/src/lib.rs`). When the crate is build as a dependency, it will
include a version number from the clone from the cargo registry (e.g.
`js-sys-0.3.17/src/lib.rs`), which would fail the check.

This commit modifies the backwards-compatibility hack to check that
desired crate name (`js-sys` or `time-macros-impl`) is a prefix of the
proper part of the path.

See https://github.com/rust-lang/rust/issues/76070#issuecomment-687215646
for more details.
2020-09-04 13:10:23 -04:00
LeSeulArtichaut
4d28a82c59 ty.flags -> ty.flags() 2020-09-04 18:28:20 +02:00
LeSeulArtichaut
3e14b684dd Change ty.kind to a method 2020-09-04 17:47:51 +02:00
Amjad Alsharafi
8f2d9069a8 Implementation of incompatible features error
If two features are defined as incompatible, using them together would
result in an error
2020-09-04 22:17:28 +08:00
Scott McMurray
fac272688e Use ops::ControlFlow in graph::iterate 2020-09-04 01:45:10 -07:00
Bastian Kauschke
cdd5d60b47 add track_caller to local_def_id_to_hir_id 2020-09-04 09:24:44 +02:00
bors
4ffb5c5954 Auto merge of #76004 - richkadel:llvm-coverage-map-gen-6b.5, r=tmandry
Tools, tests, and experimenting with MIR-derived coverage counters

Leverages the new mir_dump output file in HTML+CSS (from #76074) to visualize coverage code regions
and the MIR features that they came from (including overlapping spans).

See example below.

The `run-make-fulldeps/instrument-coverage` test has been refactored to maximize test coverage and reduce code duplication. The new tests support testing with and without `-Clink-dead-code`, so Rust coverage can be tested on MSVC (which, currently, only works with `link-dead-code` _disabled_).

New tests validate coverage region generation and coverage reports with multiple counters per function. Starting with a simple `if-else` branch tests, coverage tests for each additional syntax type can be added by simply dropping in a new Rust sample program.

Includes a basic, MIR-block-based implementation of coverage injection,
available via `-Zexperimental-coverage`. This implementation has known
flaws and omissions, but is simple enough to validate the new tools and
tests.

The existing `-Zinstrument-coverage` option currently enables
function-level coverage only, which at least appears to generate
accurate coverage reports at that level.

Experimental coverage is not accurate at this time. When branch coverage
works as intended, the `-Zexperimental-coverage` option should be
removed.

This PR replaces the bulk of PR #75828, with the remaining parts of
that PR distributed among other separate and indentpent PRs.

This PR depends on two of those other PRs: #76002, #76003 and #76074

Rust compiler MCP rust-lang/compiler-team#278

Relevant issue: #34701 - Implement support for LLVMs code coverage
instrumentation

![Screen-Recording-2020-08-21-at-2](https://user-images.githubusercontent.com/3827298/90972923-ff417880-e4d1-11ea-92bb-8713c6198f6d.gif)

r? @tmandry
FYI: @wesleywiser
2020-09-04 01:31:07 +00:00
Wesley Wiser
903c0399e7 Enable the SimplifyArmIdentity MIR optimization at mir-opt-level=1 2020-09-03 21:16:30 -04:00
Dan Gohman
2bc4c03eb8 Disable use of --eh-frame-hdr on wasm32. 2020-09-03 17:50:48 -07:00
Tomasz Miąsko
326b772609 inliner: Check for no_sanitize attribute compatibility 2020-09-04 20:01:15 +02:00
Tomasz Miąsko
cbc396fdfb inliner: Check for target features compatibility 2020-09-04 19:36:45 +02:00
bors
af3c6e733a Auto merge of #73996 - da-x:short-unique-paths, r=petrochenkov
diagnostics: shorten paths of unique symbols

This is a step towards implementing a fix for #50310, and continuation of the discussion in [Pre-RFC: Nicer Types In Diagnostics - compiler - Rust Internals](https://internals.rust-lang.org/t/pre-rfc-nicer-types-in-diagnostics/11139). Impressed upon me from previous discussion in #21934 that an RFC for this is not needed, and I should just come up with code.

The recent improvements to `use` suggestions that I've contributed have given rise to this implementation. Contrary to previous suggestions, it's rather simple logic, and I believe it only reduces the amount of cognitive load that a developer would need when reading type errors.

-----

If a symbol name can only be imported from one place, and as long as it was not glob-imported anywhere in the current crate, we can trim its printed path to the last component.

This has wide implications on error messages with types, for example, shortening `std::vec::Vec` to just `Vec`, as long as there is no other `Vec` importable from anywhere.
2020-09-03 23:27:45 +00:00
Aleksey Kladov
09d3db2e59 Optimize Cursor::look_ahead
Cloning a tt is cheap, but not free (there's Arc inside).
2020-09-03 23:28:22 +02:00
Guillaume Gomez
6e43ff5cea Add check for doc alias on associated const in trait impls 2020-09-03 22:11:29 +02:00
Aleksey Kladov
ccf41dd5eb Rename IsJoint -> Spacing
To match better naming from proc-macro
2020-09-03 17:32:45 +02:00
Aleksey Kladov
4231fbc0a8 Condense StringReader's API to a single function 2020-09-03 15:52:15 +02:00
Aleksey Kladov
850c3219fb Move jointness censoring to proc_macro
Proc-macro API currently exposes jointness in `Punct` tokens. That is,
`+` in `+one` is **non** joint.

Our lexer produces jointness info for all tokens, so we need to censor
it *somewhere*

Previously we did this in a lexer, but it makes more sense to do this
in a proc-macro server.
2020-09-03 15:22:07 +02:00
Dan Aloni
e7d7615105 rustc_lint: avoid trimmed paths for ty_find_init_error 2020-09-03 14:36:58 +03:00
Dan Aloni
51742be6d8 specialization_graph: avoid trimmed paths for OverlapError 2020-09-03 14:09:50 +03:00
Rich Kadel
51d692cf77 Tools, tests, and experimenting with MIR-derived coverage counters
Adds a new mir_dump output file in HTML/CSS to visualize code regions
and the MIR features that they came from (including overlapping spans).
See example below:

Includes a basic, MIR-block-based implementation of coverage injection,
available via `-Zexperimental-coverage`. This implementation has known
flaws and omissions, but is simple enough to validate the new tools and
tests.

The existing `-Zinstrument-coverage` option currently enables
function-level coverage only, which at least appears to generate
accurate coverage reports at that level.

Experimental coverage is not accurate at this time. When branch coverage
works as intended, the `-Zexperimental-coverage` option should be
removed.

This PR replaces the bulk of PR #75828, with the remaining parts of
that PR distributed among other separate and indentpent PRs.

This PR depends on three of those other PRs: #76000, #76002, and

Rust compiler MCP rust-lang/compiler-team#278

Relevant issue: #34701 - Implement support for LLVMs code coverage
instrumentation

![Screen-Recording-2020-08-21-at-2](https://user-images.githubusercontent.com/3827298/90972923-ff417880-e4d1-11ea-92bb-8713c6198f6d.gif)
2020-09-03 00:20:29 -07:00
Dan Aloni
c5a61319da rustc_driver: have TrimmedDefPaths::GoodPath only for rustc
`run_compiler` is used by clippy and other tools, which should not have
the trimmed paths feature enabled by default, until we see it works well
for them.

Would also be nice to rename `TimePassesCallbacks` however it's a
submodule change.
2020-09-03 09:41:43 +03:00
Scott McMurray
791f93c796 Allow try blocks as the argument to return expressions
Fixes 76271
2020-09-02 23:39:50 -07:00
Dylan DPC
cd6829382d
Rollup merge of #76245 - tmiasko:inline-generators, r=ecstatic-morse
inliner: Avoid query cycles when optimizing generators

The HIR Id trick is insufficient to prevent query cycles when optimizing
generators, since merely requesting a layout of a generator also
computes its `optimized_mir`.

Make no attempts to inline functions into generators within the same
crate to avoid query cycles.

Fixes #76181.
2020-09-03 02:22:14 +02:00
Dylan DPC
a4e30a6ae7
Rollup merge of #76167 - mati865:mingw-self-contained-heuristic, r=petrochenkov
Replace MinGW library hack with heuristic controlling link mode

Depends on https://github.com/rust-lang/rust/pull/76158
Closes https://github.com/rust-lang/rust/issues/68887
2020-09-03 02:22:06 +02:00
bors
51f79b618d Auto merge of #76233 - cuviper:unhasher, r=Mark-Simulacrum
Avoid rehashing Fingerprint as a map key

This introduces a no-op `Unhasher` for map keys that are already hash-
like, for example `Fingerprint` and its wrapper `DefPathHash`. For these
we can directly produce the `u64` hash for maps. The first use of this
is `def_path_hash_to_def_id: Option<UnhashMap<DefPathHash, DefId>>`.

cc #56308
r? @eddyb
2020-09-02 22:16:22 +00:00
bors
80fc9b0ecb Auto merge of #76160 - scileo:format-recovery, r=petrochenkov
Improve recovery on malformed format call

The token following a format expression should be a comma. However, when it is replaced with a similar token (such as a dot), then the corresponding error is emitted, but the token is treated as a comma, and the parsing step continues.

r? @petrochenkov
2020-09-02 19:29:27 +00:00
Dan Aloni
07e7823c01 pretty: trim paths of unique symbols
If a symbol name can only be imported from one place for a type, and
as long as it was not glob-imported anywhere in the current crate, we
can trim its printed path and print only the name.

This has wide implications on error messages with types, for example,
shortening `std::vec::Vec` to just `Vec`, as long as there is no other
`Vec` importable anywhere.

This adds a new '-Z trim-diagnostic-paths=false' option to control this
feature.

On the good path, with no diagnosis printed, we should try to avoid
issuing this query, so we need to prevent trimmed_def_paths query on
several cases.

This change also relies on a previous commit that differentiates
between `Debug` and `Display` on various rustc types, where the latter
is trimmed and presented to the user and the former is not.
2020-09-02 22:26:37 +03:00
Tomasz Miąsko
af19262ab4 Fold length constant in Rvalue::Repeat 2020-09-02 19:06:47 +02:00
Sasha
3524c3ef43 Improve recovery on malformed format call
If a comma in a format call is replaced with a similar token, then we
emit an error and continue parsing, instead of stopping at this point.
2020-09-02 13:18:19 +02:00
Dan Aloni
7b2deb5628 rustc_{errors,session}: add delay_good_path_bug
The first use case of this detection of regression for trimmed paths
computation, that is in the case of rustc, which should be computed only
in case of errors or warnings.

Our current user of this method is deeply nested, being a side effect
from `Display` formatting on lots of rustc types. So taking only the
caller to the error message is not enough - we should collect the
traceback instead.
2020-09-02 10:43:17 +03:00
Dan Aloni
75a042e74b Fix some unwanted uses of Debug formatting on user-facing messages
While formatting for user diagnostics used `Display` for all most cases,
some small amount of cases used `Debug` instead.  Until now, `Display`
and `Debug` yielded the same output for many types. However, with path
trimming, we want to show a shorter path for the user, these cases need
fixing.
2020-09-02 10:40:10 +03:00
bors
da897dfb6d Auto merge of #76216 - marmeladema:use-once-cell-from-std, r=matklad
compiler: use `OnceCell` from std

Fixes #76192

The only remaining direct use of `lazy_static` crate is in `src/bootstrap`  but I am not sure how I can remove that dependency for now.

r? @matklad
2020-09-02 06:46:21 +00:00
bors
b4acb11033 Auto merge of #76170 - matklad:notrivia, r=petrochenkov
Remove trivia tokens

r? @ghost
2020-09-02 03:19:38 +00:00
Josh Stone
469ca379d6 Avoid rehashing Fingerprint as a map key
This introduces a no-op `Unhasher` for map keys that are already hash-
like, for example `Fingerprint` and its wrapper `DefPathHash`. For these
we can directly produce the `u64` hash for maps. The first use of this
is `def_path_hash_to_def_id: Option<UnhashMap<DefPathHash, DefId>>`.
2020-09-01 18:27:02 -07:00
Tyler Mandry
56b5de2f29
Rollup merge of #76218 - petrochenkov:shebang3, r=matklad
lexer: Tiny improvement to shebang detection

Lexer now discerns between regular comments and doc comments, so use that.
The change only affects the choice of reported errors.
2020-09-01 18:24:46 -07:00
Tyler Mandry
4a6aa350c7
Rollup merge of #76158 - mati865:self-contained-option, r=petrochenkov
Stabilise link-self-contained option

MCP has been accepted: https://github.com/rust-lang/compiler-team/issues/343

I'll add improved heuristic in next PR.
2020-09-01 18:24:36 -07:00
Tyler Mandry
b01d0b1414
Rollup merge of #76143 - jyn514:duplicate-builtin-macros, r=petrochenkov
Give a better error message for duplicate built-in macros

Minor follow-up to https://github.com/rust-lang/rust/pull/75176 giving a better error message for duplicate builtin macros. This would have made it a little easier to debug.

r? @petrochenkov
2020-09-01 18:24:35 -07:00
Tyler Mandry
738b8eadfd
Rollup merge of #76132 - Aaron1011:mac-call-stmt, r=petrochenkov
Factor out StmtKind::MacCall fields into `MacCallStmt` struct

In PR #76130, I add a fourth field, which makes using a tuple variant
somewhat unwieldy.
2020-09-01 18:24:33 -07:00
Tyler Mandry
5f28831a40
Rollup merge of #76074 - richkadel:llvm-coverage-map-gen-6b.5.1, r=wesleywiser
Add new `-Z dump-mir-spanview` option

Similar to `-Z dump-mir-graphviz`, this adds the option to write
HTML+CSS files that allow users to analyze the spans associated with MIR
elements (by individual statement, just terminator, or overall basic
block).

This PR was split out from PR #76004, and exposes an API for spanview
HTML+CSS files that is also used to analyze code regions chosen for
coverage instrumentation (in a follow-on PR).

Rust compiler MCP rust-lang/compiler-team#278

Relevant issue: #34701 - Implement support for LLVMs code coverage
instrumentation

r? @tmandry
FYI @wesleywiser
2020-09-01 18:24:25 -07:00
Tomasz Miąsko
6c51ec96bb inliner: Avoid query cycles when optimizing generators
The HIR Id trick is insufficient to prevent query cycles when optimizing
generators, since merely requesting a layout of a generator also
computes its `optimized_mir`.

Make no attempts to inline functions into generators within the same
crate to avoid query cycles.
2020-09-02 00:00:00 +00:00
Vadim Petrochenkov
b1491eacfc lexer: Tiny improvement to shebang detection
Lexer now discerns between regular comments and doc comments, so use that.
The change only affects the choice of reported errors.
2020-09-02 00:40:19 +03:00
marmeladema
99c96c5bfe driver: replace lazy_static by SyncLazy from std 2020-09-01 22:06:47 +01:00
marmeladema
73a7204983 feature: replace lazy_static by SyncLazy from std 2020-09-01 22:06:47 +01:00
marmeladema
67b8f9491c hir: replace lazy_static by SyncLazy from std 2020-09-01 22:06:47 +01:00
marmeladema
1b650d0fea datastructures: replace lazy_static by SyncLazy from std 2020-09-01 22:06:47 +01:00
marmeladema
bd49eec3d7 interface: use OnceCell from standard library 2020-09-01 22:06:39 +01:00
bors
130359cb05 Auto merge of #76010 - Aaron1011:fix/cfg-generic-param, r=petrochenkov
Run cfg-stripping on generic parameters before invoking derive macros

Fixes #75930

This changes the tokens seen by a proc-macro. However, ising a `#[cfg]` attribute
on a generic paramter is unusual, and combining it with a proc-macro
derive is probably even more unusual. I don't expect this to cause any
breakage.
2020-09-01 20:03:55 +00:00
Mateusz Mikuła
770231e54d Replace MinGW library hack with heuristic controlling link mode 2020-09-01 19:52:39 +02:00
Kornel
7ec1de062a Clarify message about unresolved use 2020-09-01 18:38:14 +01:00
bors
397db054cb Auto merge of #75529 - bugadani:bounds-check, r=nagisa
Eliminate some other bound checks when index comes from an enum

#36962 introduced an assumption for the upper limit of the enum's value. This PR adds an assumption to the lower value as well.

I've modified the original codegen test to show that derived (in that case, adding 1) values also don't generate bounds checks.

However, this test is actually carefully crafted to not hit a bug: if the enum's variants are modified to 1 and 2 instead of 2 and 3, the test fails by adding a bounds check. I suppose this is an LLVM issue and #75525, while not exactly in this context should be tracking it.

I'm not at all confident if this patch can be accepted, or even if it _should_ be accepted in this state. But I'm curious about what others think :)

~Improves~ Should improve #13926 but does not close it because it's not exactly predictable, where bounds checks may pop up against the assumptions.
2020-09-01 13:36:52 +00:00
jumbatm
5956254172 Fix typos in E0224 2020-09-01 23:05:56 +10:00
jumbatm
57edf88b40 Replace some trivial struct_span_err!s in typeck. 2020-09-01 23:05:56 +10:00
Joshua Nelson
be2947d0b7 Give a better error message for duplicate built-in macros
Previously, this would say no such macro existed, but this was
misleading, since the macro _did_ exist, it was just already seen.

- Say where the macro was previously defined
- Add long-form error message
2020-09-01 08:34:17 -04:00
jumbatm
93eaf15646 Add SessionDiagnostic derive macro.
Co-authored-by: Oliver Scherer <github35764891676564198441@oli-obk.de>
2020-09-01 22:02:45 +10:00
Aleksey Kladov
fabd8a6834 Simplify TokenTreesReader
This `joint_to_prev` bit of state is no longer needed.
2020-09-01 11:46:49 +02:00
Aleksey Kladov
5326361fc0 Remove trivia tokens 2020-09-01 11:39:11 +02:00
Aleksey Kladov
8f24c2ec9d Don't emit trivia tokens 2020-09-01 11:39:11 +02:00
bors
6f1bbf5ee0 Auto merge of #76071 - khyperia:configurable_to_immediate, r=eddyb
Make to_immediate/from_immediate configurable by backends

`librustc_codegen_ssa` has the concept of an immediate vs. memory type, and `librustc_codegen_llvm` uses this distinction to implement `bool`s being `i8` in memory, and `i1` in immediate contexts. However, some of that implementation leaked into `codegen_ssa` when converting to/from immediate values. So, move those methods into builder traits, so that behavior can be configured by backends.

This is useful if a backend is able to keep bools as bools, or, needs to do more trickery than just bools to bytes.

(Note that there's already a large amount of things abstracted with "immediate types" - this is just bringing this particular thing in line to be abstracted as well)

---

Pinging @eddyb since that's who I was talking about this change with when they suggested I submit a PR.
2020-09-01 07:44:34 +00:00
Rich Kadel
6b5869a0ae Add new -Z dump-mir-spanview option
Similar to `-Z dump-mir-graphviz`, this adds the option to write
HTML+CSS files that allow users to analyze the spans associated with MIR
elements (by individual statement, just terminator, or overall basic
block).

This PR was split out from PR #76004, and exposes an API for spanview
HTML+CSS files that is also used to analyze code regions chosen for
coverage instrumentation (in a follow-on PR).

Rust compiler MCP rust-lang/compiler-team#278

Relevant issue: #34701 - Implement support for LLVMs code coverage
instrumentation
2020-08-31 22:57:55 -07:00
Tyler Mandry
8d328d785f
Rollup merge of #76178 - matklad:et, r=Mark-Simulacrum
Update expect-test to 1.0

The only change is that `expect_file` now uses path relative to the
current file (same as `include!`). Before, it used paths relative to
the workspace root, which makes no sense.
2020-08-31 19:18:31 -07:00
Tyler Mandry
90e4bfa952
Rollup merge of #76166 - matklad:privatereader, r=petrochenkov
Make `StringReader` private

r? @ghost

closes #75619
2020-08-31 19:18:28 -07:00
Tyler Mandry
9df193b6b2
Rollup merge of #76161 - pickfire:patch-3, r=pickfire
Remove notrust in rustc_middle

Fix #19599

This confuse people, no trust or not rust?
Or not rust no trust? Only trust rust ^^

Superseeds https://github.com/rust-lang/rust/pull/76063
r? @matklad
2020-08-31 19:18:24 -07:00
Tyler Mandry
4f276202f5
Rollup merge of #76103 - GuillaumeGomez:cleanup-e0769, r=Dylan-DPC
Clean up E0769

r? @pickfire

cc @Dylan-DPC
2020-08-31 19:18:19 -07:00
Tyler Mandry
5033203121
Rollup merge of #76059 - GuillaumeGomez:cleanup-e0764, r=Dylan-DPC,pickfire
Clean up E0764

r? @Dylan-DPC
2020-08-31 19:18:18 -07:00
Tyler Mandry
934127cca5
Rollup merge of #76003 - richkadel:llvm-coverage-map-gen-6b.4, r=wesleywiser
Adds two source span utility functions used in source-based coverage

`span.is_empty()` - returns true if `lo()` and `hi()` are equal. This is
not only a convenience, but makes it clear that a `Span` can be empty
(that is, retrieving the source for an empty `Span` will return an empty
string), and codifies the (otherwise undocumented--in the rustc_span
package, at least) fact that `Span` is a half-open interval (where
`hi()` is the open end).

`source_map.lookup_file_span()` - returns an enclosing `Span`
representing the start and end positions of the file enclosing the given
`BytePos`. This gives developers a clear way to quickly determine if any
any other `BytePos` or `Span` is also from the same file (for example,
by simply calling `file_span.contains(span)`).

This results in much simpler code and is much more runtime efficient
compared with the obvious alternative: calling `source_map.lookup_line()`
for any two `Span`'s byte positions, handle both arms of the `Result`
(both contain the file), and then compare files. It is also more
efficient than the non-public method `lookup_source_file_idx()` for each
`BytePos`, because, while comparing the internal source file indexes
would be efficient, looking up the source file index for every `BytePos`
or `Span` to be compared requires a binary search (worst case
performance being O(log n) for every lookup).

`source_map.lookup_file_span()` performs the binary search only once, to
get the `file_span` result that can be used to compare to any number of
other `BytePos` or `Span` values and those comparisons are always O(1).

This PR was split out from PR #75828 .

r? @tmandry
FYI: @wesleywiser
2020-08-31 19:18:16 -07:00
Tyler Mandry
6d834a4046
Rollup merge of #76002 - richkadel:llvm-coverage-map-gen-6b.3, r=tmandry
Fix `-Z instrument-coverage` on MSVC

Found that `-C link-dead-code` (which was enabled automatically
under `-Z instrument-coverage`) was causing the linking error that
resulted in segmentation faults in coverage instrumented binaries. Link
dead code is now disabled under MSVC, allowing `-Z instrument-coverage`
to be enabled under MSVC for the first time.

More details are included in Issue #76038 .

Note this PR makes it possible to support `Z instrument-coverage` but
does not enable instrument coverage for MSVC in existing tests. It will be
enabled in another PR to follow this one (both PRs coming from original
PR #75828).

r? @tmandry
FYI: @wesleywiser
2020-08-31 19:18:14 -07:00
Rich Kadel
7225f66887 Adds two source span utility functions used in source-based coverage
`span.is_empty()` - returns true if `lo()` and `hi()` are equal. This is
not only a convenience, but makes it clear that a `Span` can be empty
(that is, retrieving the source for an empty `Span` will return an empty
string), and codifies the (otherwise undocumented--in the rustc_span
package, at least) fact that `Span` is a half-open interval (where
`hi()` is the open end).

`source_map.lookup_file_span()` - returns an enclosing `Span`
representing the start and end positions of the file enclosing the given
`BytePos`. This gives developers a clear way to quickly determine if any
any other `BytePos` or `Span` is also from the same file (for example,
by simply calling `file_span.contains(span)`).

This results in much simpler code and is much more runtime efficient
compared with the obvious alternative: calling `source_map.lookup_line()`
for any two `Span`'s byte positions, handle both arms of the `Result`
(both contain the file), and then compare files. It is also more
efficient than the non-public method `lookup_source_file_idx()` for each
`BytePos`, because, while comparing the internal source file indexes
would be efficient, looking up the source file index for every `BytePos`
or `Span` to be compared requires a binary search (worst case
performance being O(log n) for every lookup).

`source_map.lookup_file_span()` performs the binary search only once, to
get the `file_span` result that can be used to compare to any number of
other `BytePos` or `Span` values and those comparisons are always O(1).
2020-08-31 18:41:57 -07:00
Rich Kadel
ddb054aee8 Fix -Z instrument-coverage on MSVC
Found that -C link-dead-code (which was enabled automatically
under -Z instrument-coverage) was causing the linking error that
resulted in segmentation faults in coverage instrumented binaries. Link
dead code is now disabled under MSVC, allowing `-Z instrument-coverage`
to be enabled under MSVC for the first time.

More details are included in Issue #76038.

(This PR was broken out from PR #75828)
2020-08-31 18:41:13 -07:00
bors
d824b23514 Auto merge of #75931 - estebank:suggest-if-let, r=petrochenkov
Suggest `if let x = y` when encountering `if x = y`

Detect potential cases where `if let` was meant but `let` was left out.

Fix #44990.
2020-09-01 00:26:01 +00:00
Aleksey Kladov
5716c3e18d Update expect-test to 1.0
The only change is that `expect_file` now uses path relative to the
current file (same as `include!`). Before, it used paths relative to
the workspace root, which makes no sense.
2020-08-31 21:04:09 +02:00
Guillaume Gomez
153f966d00 Clean up E0764 explanation 2020-08-31 20:14:37 +02:00
Guillaume Gomez
f3ae96ecd5 Clean up E0769 explanation 2020-08-31 20:10:57 +02:00