Commit graph

1866 commits

Author SHA1 Message Date
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
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
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
Mark Rousskov
e023158145 Permit uninhabited enums to cast into ints
This essentially reverts part of #6204.
2020-09-01 10:01:28 -04: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
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
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
Ivan Tham
85a400d44e
Remove notrust in rustc_middle
Fix #19599

This confuse people, no trust or not rust?
Or not rust no trust? Only trust rust ^^
2020-08-31 22:10:09 +08:00
Aleksey Kladov
67f16431aa
Rollup merge of #76075 - marmeladema:remove-once-cell-crate, r=matklad
datastructures: replace `once_cell` crate with an impl from std

Fixes #75700

r? @matklad

We might need a perf run for this change.
2020-08-31 15:22:42 +02:00
marmeladema
68500ffacb datastructures: replace once_cell crate with an impl from std 2020-08-30 20:06:14 +01:00
Erik Desjardins
68217c9e0f ignore zst offsets instead 2020-08-30 14:58:03 -04:00
Erik Desjardins
e5d85f917b allow reordering of the last field of a MaybeUnsized struct if it's a ZST 2020-08-30 14:58:03 -04:00
David Wood
6ff471b1cf
ty: remove obsolete printer
This commit removes the obsolete printer and replaces all uses of it
with `FmtPrinter`. Of the replaced uses, all but one use was in `debug!`
logging, two cases were notable:

- `MonoItem::to_string` is used in `-Z print-mono-items` and therefore
  affects the output of all codegen-units tests.
- `DefPathBasedNames` was used in `librustc_codegen_llvm/type_of.rs`
  with `LLVMStructCreateNamed` and that'll now get different values, but
  this should result in no functional change.

Signed-off-by: David Wood <david@davidtw.co>
2020-08-30 18:59:07 +01:00
David Wood
0f2bd56b29
lint/ty: move fns to avoid abstraction violation
This commit moves `transparent_newtype_field` and `is_zst` to
`LateContext` where they are used, rather than being on the `VariantDef`
and `TyS` types.

Signed-off-by: David Wood <david@davidtw.co>
2020-08-30 18:57:46 +01:00
mark
9e5f7d5631 mv compiler to compiler/ 2020-08-30 18:45:07 +03:00