Commit graph

8822 commits

Author SHA1 Message Date
Camille GILLOT
7a209bb7a5 Justify untracked access. 2021-10-12 20:53:29 +02:00
jackh726
9855e7dc7b Switch order of terms to prevent overflow 2021-10-12 11:14:31 -04:00
the8472
6cdf8030f0
Rollup merge of #89809 - tmiasko:remap-real-predicate, r=michaelwoerister
Remap ssa RealPredicate to llvm RealPredicate

to avoid relying on the discriminant of the former for FFI purposes
2021-10-12 14:53:13 +02:00
the8472
4ce1ce1f76
Rollup merge of #89784 - Mark-Simulacrum:delete-cache-hit-tracking, r=petrochenkov
Remove built-in query cache_hit tracking

This was already only enabled in debug_assertions builds. Generally, it seems
like most use cases that would use this could also use the -Zself-profile flag
which also tracks cache hits (in all builds), and so the extra cfg's and such
are not really necessary.

This is largely just a small cleanup though, which primarily is intended to make
other changes easier by avoiding the need to deal with this field.
2021-10-12 14:53:09 +02:00
LingMan
7943c9c446 Use Option::map_or instead of open coding it 2021-10-12 14:47:52 +02:00
Devin Ragotzy
2a042d6105 Filter unstable and doc hidden variants in usefulness checking
Add test cases for unstable variants
Add test cases for doc hidden variants
Move is_doc_hidden to method on TyCtxt
Add unstable variants test to reachable-patterns ui test
Rename reachable-patterns -> omitted-patterns
2021-10-12 08:22:25 -04:00
Tomasz Miąsko
ce7713d6b4 Remap ssa RealPredicate to llvm RealPredicate
to avoid relying on the discriminant of the former for FFI purposes
2021-10-12 11:55:45 +02:00
Camille GILLOT
c5628a5e65 Use invalid local id for zeroth node parent. 2021-10-12 08:41:53 +02:00
Deadbeef
5387b6542f
Add const_eval_select intrinsic 2021-10-12 05:42:23 +00:00
bors
97e3b30285 Auto merge of #89791 - matthiaskrgr:rollup-1lhxh5b, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #89471 (Use Ancestory to check default fn in const impl instead of comparing idents)
 - #89643 (Fix inherent impl overlap check.)
 - #89651 (Add `Poll::ready` and revert stabilization of `task::ready!`)
 - #89675 (Re-use TypeChecker instead of passing around some of its fields )
 - #89710 (Add long explanation for error E0482)
 - #89756 (Greatly reduce amount of debuginfo compiled for bootstrap itself)
 - #89760 (Remove hack ignoring unused attributes for stage 0 std)
 - #89772 (Fix function-names test for GDB 10.1)
 - #89785 (Fix ICE when compiling nightly std/rustc on beta compiler)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-10-12 00:20:34 +00:00
Matthias Krüger
f94a325496
Rollup merge of #89785 - nbdd0121:master, r=Mark-Simulacrum
Fix ICE when compiling nightly std/rustc on beta compiler

Fix #89775

#89479 renames a lot of diagnostic items, but it happens that the beta compiler assumes that there must be DefId with `rustc_diagnostic_item = "send_trait"`, causing an ICE when compiling stage 0 std or stage 1 compiler. So gate it with `cfg(bootstrap)`.

The unwrap is also removed, so that existence of the diagnostic item is not required. I ripgreped the code base and this seems the only place where `unwrap` is called on the return value of `get_diagnostic_item`.
2021-10-11 23:45:53 +02:00
Matthias Krüger
57504aafe8
Rollup merge of #89710 - sireliah:e0482, r=GuillaumeGomez
Add long explanation for error E0482

This is longer explanation for error E0482 in the #61137.

Please take a look and leave some feedback!
2021-10-11 23:45:50 +02:00
Matthias Krüger
fde2412b23
Rollup merge of #89675 - oli-obk:type_checker, r=davidtwco
Re-use TypeChecker instead of passing around some of its fields

In the future (for lazy TAIT) we will need more of its fields, but even ignoring that, this change seems reasonable on its own to me.
2021-10-11 23:45:49 +02:00
Matthias Krüger
b80dd9e445
Rollup merge of #89643 - cjgillot:overlap, r=matthewjasper
Fix inherent impl overlap check.

The current implementation of the overlap check was slightly buggy, and unified the wrong connected component in the `ids.len() <= 1` case. This became visible in another PR which changed the iteration order of items.

r? ``@matthewjasper`` since you reviewed the other PR.
2021-10-11 23:45:46 +02:00
Matthias Krüger
412301b26a
Rollup merge of #89471 - nbdd0121:const3, r=fee1-dead
Use Ancestory to check default fn in const impl instead of comparing idents

Fixes https://rust-lang.zulipchat.com/#narrow/stream/146212-t-compiler.2Fconst-eval/topic/Const.20trait.20impl.20inside.20macro
2021-10-11 23:45:46 +02:00
bors
7cc8c44871 Auto merge of #89648 - nbdd0121:issue-89606, r=nikomatsakis
Ignore type of projections for upvar capturing

Fix #89606

Ignore type of projections for upvar capturing. Originally HashMap is used, and the hash/eq implementation of Place takes the type of projections into account. These types may differ by lifetime which causes #89606 to ICE.

I originally considered erasing regions but `place.ty()` is used when creating upvar tuple type, more than just serving as a key type, so I switched to a linear comparison with custom eq (`compare_place_ignore_ty`) instead.

r? `@wesleywiser`

`@rustbot` label +T-compiler
2021-10-11 21:39:11 +00:00
Camille GILLOT
6b7995195a Remove unused function. 2021-10-11 22:36:46 +02:00
Camille GILLOT
12b39e5912 Make naming more explicit. 2021-10-11 22:36:37 +02:00
Mark Rousskov
127373822e Remove built-in cache_hit tracking
This was already only enabled in debug_assertions builds. Generally, it seems
like most use cases that would use this could also use the -Zself-profile flag
which also tracks cache hits (in all builds), and so the extra cfg's and such
are not really necessary.

This is largely just a small cleanup though, which primarily is intended to make
other changes easier by avoiding the need to deal with this field.
2021-10-11 16:33:49 -04:00
Gary Guo
148f456cc6 Fix ICE 89775 2021-10-11 20:52:36 +01:00
sireliah
0fde6f672f Clarify the error descriptions 2021-10-11 21:48:35 +02:00
Gary Guo
de940fc725 Use Ancestory to check default fn in const impl instead of comparing idents 2021-10-11 18:19:54 +01:00
bors
5b210643eb Auto merge of #83908 - Flying-Toast:master, r=davidtwco
Add enum_intrinsics_non_enums lint

There is a clippy lint to prevent calling [`mem::discriminant`](https://doc.rust-lang.org/std/mem/fn.discriminant.html) with a non-enum type. I think the lint is worthy of being included in rustc, given that `discriminant::<T>()` where `T` is a non-enum has an unspecified return value, and there are no valid use cases where you'd actually want this.

I've also made the lint check [variant_count](https://doc.rust-lang.org/core/mem/fn.variant_count.html) (#73662).

closes #83899
2021-10-11 17:12:14 +00:00
bors
1067e2ca5e Auto merge of #89767 - GuillaumeGomez:rollup-sczixhk, r=GuillaumeGomez
Rollup of 7 pull requests

Successful merges:

 - #89655 (bootstrap: don't use `--merges` to look for commit hashes for downloading artifacts)
 - #89726 (Add #[must_use] to alloc constructors)
 - #89729 (Add #[must_use] to core and std constructors)
 - #89743 (Fix RUSTC_LOG handling)
 - #89753 (Add #[must_use] to from_value conversions)
 - #89754 (Cleanup .item-table CSS)
 - #89761 (⬆️ rust-analyzer)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-10-11 14:16:15 +00:00
Guillaume Gomez
9183942e83
Rollup merge of #89743 - matthewjasper:env-log-fix, r=jyn514
Fix RUSTC_LOG handling

Rustc was incorrectly reading the value of `RUSTC_LOG` as the environment vairable with the logging configuration, rather than the logging configuration itself.
2021-10-11 14:11:44 +02:00
bors
6ae8912a3e Auto merge of #89709 - clemenswasser:apply_clippy_suggestions_2, r=petrochenkov
Apply clippy suggestions for rustc and core
2021-10-11 11:14:47 +00:00
Flying-Toast
59b186d99a
Add enum_intrinsics_non_enums lint 2021-10-11 09:46:27 +02:00
Clemens Wasser
14b6cf6fd7 Remove unnecessary variable 2021-10-11 08:11:30 +02:00
bors
9a757817c3 Auto merge of #89597 - michaelwoerister:improve-vtable-debuginfo, r=wesleywiser
Create more accurate debuginfo for vtables.

Before this PR all vtables would have the same name (`"vtable"`) in debuginfo. Now they get an unambiguous name that identifies the implementing type and the trait that is being implemented.

This is only one of several possible improvements:
- This PR describes vtables as arrays of `*const u8` pointers. It would nice to describe them as structs where function pointer is represented by a field with a name indicative of the method it maps to. However, this requires coming up with a naming scheme that avoids clashes between methods with the same name (which is possible if the vtable contains multiple traits).
- The PR does not update the debuginfo we generate for the vtable-pointer field in a fat `dyn` pointer. Right now there does not seem to be an easy way of getting ahold of a vtable-layout without also knowing the concrete self-type of a trait object.

r? `@wesleywiser`
2021-10-11 04:31:47 +00:00
Matthias Krüger
9d307f1ed4
Rollup merge of #89722 - jkugelman:cannonical-typo, r=joshtriplett
Fix spelling: Cannonical -> Canonical
2021-10-11 00:34:40 +02:00
bors
41dfaaa3c6 Auto merge of #89739 - matthiaskrgr:rollup-kskwqy5, r=matthiaskrgr
Rollup of 11 pull requests

Successful merges:

 - #88374 (Fix documentation in Cell)
 - #88713 (Improve docs for int_log)
 - #89428 (Feature gate the non_exhaustive_omitted_patterns lint)
 - #89438 (docs: `std:#️⃣:Hash` should ensure prefix-free data)
 - #89520 (Don't rebuild GUI test crates every time you run test src/test/rustdoc-gui)
 - #89705 (Cfg hide no_global_oom_handling and no_fp_fmt_parse)
 - #89713 (Fix ABNF of inline asm options)
 - #89718 (Add #[must_use] to is_condition tests)
 - #89719 (Add #[must_use] to char escape methods)
 - #89720 (Add #[must_use] to math and bit manipulation methods)
 - #89735 (Stabilize proc_macro::is_available)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-10-10 19:05:13 +00:00
Matthew Jasper
9e6e89af69 Fix RUSTC_LOG handling
Rustc was incorrectly reading the value of `RUSTC_LOG` as the
environment vairable with the logging configuration, rather than the
logging configuration itself.
2021-10-10 19:59:36 +01:00
Matthias Krüger
cfa5391f0b
Rollup merge of #89428 - DevinR528:reachable-featuregate, r=Nadrieril,camelid
Feature gate the non_exhaustive_omitted_patterns lint

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

Add the machinery to gate the new `non_exhaustive_omitted_patterns` lint.

relates to https://github.com/rust-lang/rust/pull/89105 and https://github.com/rust-lang/rust/pull/89423
2021-10-10 18:22:19 +02:00
bors
68dfa07e3b Auto merge of #89633 - rhysd:issue-65230, r=petrochenkov
Show detailed expected/found types in error message when trait paths are the same

Fixes #65230.

### Issue solved by this PR

```rust
trait T {
    type U;
    fn f(&self) -> Self::U;
}

struct X<'a>(&'a mut i32);

impl<'a> T for X<'a> {
    type U = &'a i32;
    fn f(&self) -> Self::U {
        self.0
    }
}

fn main() {}
```

Compiler generates the following note:

```
note: ...so that the types are compatible
  --> test.rs:10:28
   |
10 |       fn f(&self) -> Self::U {
   |  ____________________________^
11 | |         self.0
12 | |     }
   | |_____^
   = note: expected `T`
              found `T`
```

This note is not useful since the expected type and the found type are the same.

### How this PR solve the issue

When the expected type and the found type are exactly the same in string representation, the note falls back to the detailed string representation of trait ref:

```
note: ...so that the types are compatible
  --> test.rs:10:28
   |
10 |       fn f(&self) -> Self::U {
   |  ____________________________^
11 | |         self.0
12 | |     }
   | |_____^
   = note: expected `<X<'a> as T>`
              found `<X<'_> as T>`
```

So that a user can notice what was different between the expected one and the found one.
2021-10-10 15:59:28 +00:00
Eduard-Mihai Burtescu
f14e8dd4e7 ty::pretty: prevent infinite recursion for extern crate paths. 2021-10-10 18:58:28 +03:00
Eduard-Mihai Burtescu
152e40377a ty::pretty: document "dummy Span extern crate" special-case in try_print_visible_def_path_recur. 2021-10-10 18:18:30 +03:00
Clemens Wasser
b8c151c9d2 Remove for loop range 2021-10-10 16:32:16 +02:00
Clemens Wasser
71dd0b928b Apply clippy suggestions 2021-10-10 15:38:19 +02:00
bors
9e8356c6ad Auto merge of #88952 - skrap:add-armv7-uclibc, r=nagisa
Add new tier-3 target: armv7-unknown-linux-uclibceabihf

This change adds a new tier-3 target: armv7-unknown-linux-uclibceabihf

This target is primarily used in embedded linux devices where system resources are slim and glibc is deemed too heavyweight.  Cross compilation C toolchains are available [here](https://toolchains.bootlin.com/) or via [buildroot](https://buildroot.org).

The change is based largely on a previous PR #79380 with a few minor modifications.  The author of that PR was unable to push the PR forward, and graciously allowed me to take it over.

Per the [target tier 3 policy](https://github.com/rust-lang/rfcs/blob/master/text/2803-target-tier-policy.md), I volunteer to be the "target maintainer".

This is my first PR to Rust itself, so I apologize if I've missed things!
2021-10-10 08:16:22 +00:00
John Kugelman
169113935f Fix spelling: Cannonical -> Canonical 2021-10-10 00:44:34 -04:00
Camille GILLOT
0431fdb113 Compute full HIR hash during lowering. 2021-10-10 00:05:49 +02:00
Camille GILLOT
41e80b85cf Directly use AttributeMap inside OwnerInfo. 2021-10-10 00:05:35 +02:00
Camille GILLOT
1c7f85f17c Perform indexing during lowering.
Do not access DefId<->HirId maps before they are initialized.
2021-10-09 23:47:59 +02:00
Camille GILLOT
c09eaea484 Make index_hir incremental. 2021-10-09 23:14:59 +02:00
sireliah
a94e39e7f4 Add long explanation for error E0482 2021-10-09 21:49:09 +02:00
Camille GILLOT
ed3c8e86cb Hash during lowering. 2021-10-09 19:44:55 +02:00
Camille GILLOT
457de08487 Forbid hashing HIR outside of indexing. 2021-10-09 18:38:28 +02:00
bors
15491d7b6b Auto merge of #89343 - Mark-Simulacrum:no-args-queries, r=cjgillot
Refactor fingerprint reconstruction

This PR replaces can_reconstruct_query_key with fingerprint_style, which returns the style of the fingerprint for that query. This allows us to avoid trying to extract a DefId (or equivalent) from keys which *are* reconstructible because they're () but not as DefIds.

This is done with the goal of fixing -Zdump-dep-graph, which seems to have broken a while ago (I didn't try to bisect). Currently even on a `fn main() {}` file it'll ICE (you need to also pass -Zquery-dep-graph for it to work at all), and this patch indirectly fixes the cause of that ICE. This also adds a test for it continuing to work.
2021-10-09 13:13:07 +00:00
Camille GILLOT
cd1ace488f Use an IndexVec for bodies. 2021-10-09 14:01:09 +02:00
Camille GILLOT
48a339ddbb Store lowering outputs per owner. 2021-10-09 11:56:29 +02:00
Matthias Krüger
5ebb6a8fd9
Rollup merge of #89641 - asquared31415:asm-feature-attr-regs, r=oli-obk
make #[target_feature] work with `asm` register classes

Fixes #89289
2021-10-09 11:56:00 +02:00
Matthias Krüger
9d14b6505b
Rollup merge of #89634 - hawkw:eliza/enable-err-warn, r=oli-obk
rustc_driver: Enable the `WARN` log level by default

This commit changes the `tracing_subscriber` initialization in
`rustc_driver` so that the `WARN` verbosity level is enabled by default
when the `RUSTC_LOG` env variable is empty. If the `RUSTC_LOG` env
variable is set, the filter string in the environment variable is
honored, instead.

Fixes #76824
Closes #89623

cc ``@eddyb,`` ``@oli-obk``
2021-10-09 11:55:59 +02:00
Matthias Krüger
03a34a291d
Rollup merge of #89605 - camelid:fix-version, r=nagisa
Fix stabilization version for `bindings_after_at`

According to the release notes and its PR milestone, it was stabilized
in 1.56.0.
2021-10-09 11:55:58 +02:00
Camille GILLOT
f9e1de979d Stop referring to hir::Crate in hir_pretty. 2021-10-09 11:19:44 +02:00
Gary Guo
7275cfa47c Explicit PlaceAncestryRelation::SamePlace and handle like Descendant 2021-10-09 06:49:47 +01:00
Devin Ragotzy
14338786fd Add feature gate to non_exhaustive_omitted_patterns lint
Actually add the feature to the lints ui test
Add tracking issue to the feature declaration
Rename feature gate to non_exhaustive_omitted_patterns_lint
Add more omitted_patterns lint feature gate
2021-10-08 17:40:39 -04:00
bors
f8751436ff Auto merge of #89683 - GuillaumeGomez:rollup-q2mjd9m, r=GuillaumeGomez
Rollup of 6 pull requests

Successful merges:

 - #86506 (Don't normalize xform_ret_ty during method candidate assembly )
 - #89538 (Make rustdoc not highlight `->` and `=>` as operators)
 - #89649 (clippy::complexity fixes)
 - #89668 (Cfg hide more conditions for core and alloc)
 - #89669 (Remove special-casing of never primitive in rustdoc-json-types)
 - #89672 (Remove unwrap_or! macro)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-10-08 21:13:27 +00:00
Guillaume Gomez
cda07c740c
Rollup merge of #89672 - klensy:unwrap-or-macro, r=jackh726
Remove unwrap_or! macro

Removes `unwrap_or!` macro and replaces it with `match`.

It's kinda cleanup, as rustc_ast not the best place for this macro and this is used only in 2 places anyway.
2021-10-08 22:30:43 +02:00
Guillaume Gomez
836597a881
Rollup merge of #89649 - matthiaskrgr:clippycompl, r=jyn514
clippy::complexity fixes
2021-10-08 22:30:40 +02:00
Guillaume Gomez
32502404e5
Rollup merge of #86506 - b-naber:gen_trait_impl_inconsistent, r=jackh726
Don't normalize xform_ret_ty during method candidate assembly

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

Normalizing the return type of a method candidate together with the expected receiver type of the method can lead to valid method candidates being rejected during probing. Specifically in the example of the fixed issue we have a `self_ty` of the form `&A<&[Coef]>` whereas the `impl_ty` of the method would be `&A<_>`, if we normalize the projection in the return type we unify the inference variable with `Cont`, which will lead us to reject the candidate in the sup type check in `consider_probe`. Since we don't actually need the normalized return type during candidate assembly, we postpone the normalization until we consider candidates in `consider_probe`.
2021-10-08 22:30:38 +02:00
bors
54bb4fec68 Auto merge of #89666 - rusticstuff:disable_new_llvm_pass_manager_on_s390x_take_two, r=nagisa
Default to disabling the new pass manager for the s390x arch targets.

This hack disables the new LLVM pass manager by default for s390x arch targets until the performance issues are fixed (see #89609). The command line option `-Z new-llvm-pass-manager=(yes|no)` continues to take precedence over this default.
2021-10-08 18:12:50 +00:00
Matthias Krüger
e6f77a1787 clippy::complexity fixes 2021-10-08 20:07:44 +02:00
Oli Scherer
49b06a2b60 Directly call relate_types function instead of having a method wrapper 2021-10-08 17:53:41 +00:00
Oli Scherer
597090ee14 Re-use TypeChecker instead of passing around some of its fields 2021-10-08 17:51:56 +00:00
klensy
77fce75ba1 remove unwrap_or! macro 2021-10-08 19:32:16 +03:00
rhysd
7b9ddbdcf2 Show detailed expected/found types in error message when trait paths are the same 2021-10-09 00:07:37 +09:00
bors
87df4dd70f Auto merge of #89644 - matthiaskrgr:clippy_perf_okt, r=jyn514
some clippy::perf fixes
2021-10-08 14:35:00 +00:00
Hans Kratz
4593d78e96 Default to disabling the new pass manager for the s390x targets. 2021-10-08 15:05:07 +02:00
bors
e0aaffd8a4 Auto merge of #89576 - tom7980:issue-89275-fix, r=estebank
Prevent error reporting from outputting a recursion error if it finds an ambiguous trait impl during suggestions

Closes #89275

This fixes the compiler reporting a recursion error during another already in progress error by trying to make a conversion method suggestion and encounters ambiguous trait implementations that can convert a the original type into a type that can then be recursively converted into itself via another method in the trait.

Updated OverflowError struct to be an enum so I could differentiate between passes - it's no longer a ZST but I don't think that should be a problem as they only generate when there's an error in compiling code anyway
2021-10-08 11:44:45 +00:00
bors
44995f7afb Auto merge of #89619 - michaelwoerister:incr-vtables, r=nagisa
Turn vtable_allocation() into a query

This PR removes the untracked vtable-const-allocation cache from the `tcx` and turns the `vtable_allocation()` method into a query.

The change is pretty straightforward and should be backportable without too much effort.

Fixes https://github.com/rust-lang/rust/issues/89598.
2021-10-08 09:04:06 +00:00
b-naber
cbf91532a7 dont normalize return type during candidate assembly in method probing 2021-10-08 10:55:44 +02:00
Michael Woerister
61c5a6d644 Create more accurate debuginfo for vtables.
Before this commit all vtables would have the same name "vtable" in
debuginfo. Now they get a name that identifies the implementing type
and the trait that is being implemented.
2021-10-08 10:33:47 +02:00
Jubilee
30e068f58b
Rollup merge of #89622 - m-ou-se:debug-assert-2021, r=estebank
Use correct edition for panic in [debug_]assert!().

See https://github.com/rust-lang/rust/issues/88638#issuecomment-915472783
2021-10-07 20:26:15 -07:00
Jubilee
aed1801841
Rollup merge of #89476 - cjgillot:expn-id, r=petrochenkov
Correct decoding of foreign expansions during incr. comp.

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

The original issue was due to a wrong assertion in `expn_hash_to_expn_id`.

The secondary issue was due to a mismatch between the encoding and decoding paths for expansions that are created after the TyCtxt is created.
2021-10-07 20:26:14 -07:00
Jubilee
6c17601a2e
Rollup merge of #89025 - ricobbe:raw-dylib-link-ordinal, r=michaelwoerister
Implement `#[link_ordinal(n)]`

Allows the use of `#[link_ordinal(n)]` with `#[link(kind = "raw-dylib")]`, allowing Rust to link against DLLs that export symbols by ordinal rather than by name.  As long as the ordinal matches, the name of the function in Rust is not required to match the name of the corresponding function in the exporting DLL.

Part of #58713.
2021-10-07 20:26:11 -07:00
Jubilee
cbb561fdab
Rollup merge of #88137 - joshtriplett:osx-strip-symbols-no-option, r=michaelwoerister
On macOS, make strip="symbols" not pass any options to strip

This makes the output with `strip="symbols"` match the result of just
calling `strip` on the output binary, minimizing the size of the binary.
2021-10-07 20:26:10 -07:00
Jubilee
6c2d4bf3f7
Rollup merge of #87918 - mikebenfield:pr-afdo, r=nikic
Enable AutoFDO.

This largely involves implementing the options debug-info-for-profiling
and profile-sample-use and forwarding them on to LLVM.

AutoFDO can be used on x86-64 Linux like this:
rustc -O -Clink-arg='Wl,--no-rosegment' -Cdebug-info-for-profiling main.rs -o main
perf record -b ./main
create_llvm_prof --binary=main --out=code.prof
rustc -O -Cprofile-sample-use=code.prof main.rs -o main2

Now `main2` will have feedback directed optimization applied to it.

The create_llvm_prof tool can be obtained from this github repository:
https://github.com/google/autofdo

The option -Clink-arg='Wl,--no-rosegment' is necessary to avoid lld
putting an extra RO segment before the executable code, which would make
the binary silently incompatible with create_llvm_prof.
2021-10-07 20:26:09 -07:00
Gary Guo
5481201160 Ignore projection type when determining upvar ancestory 2021-10-08 04:00:10 +01:00
Taylor Yu
df03b083c9 move implicit Sized predicate to end of list
In `Bounds::predicates()`, move the implicit `Sized` predicate to the
end of the generated list. This means that if there is an explicit
`Sized` bound, it will be checked first, and any resulting
diagnostics will have a more useful span.
2021-10-07 20:24:56 -05:00
Noble-Mushtak
8fc329f5d2 Add check that region is live in sanitize_promoted 2021-10-07 18:20:23 -04:00
Camille GILLOT
54c3299b3a Remove eval_always for HIR queries.
They depend on `hir_crate` and `index_hir`.
2021-10-07 23:12:28 +02:00
Camille GILLOT
a3f98a7501 Fix inherent impl overlap check. 2021-10-07 22:42:18 +02:00
Matthias Krüger
ff6601e0fc some clippy::perf fixes 2021-10-07 22:31:33 +02:00
asquared31415
271da7d8bc make #[target_feature] work with asm register classes 2021-10-07 15:42:18 -04:00
Eliza Weisman
0e79545c30
lol i forgot the syntax for my own crate's macros
T_____T

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2021-10-07 12:03:15 -07:00
Eliza Weisman
b6f09a19b2
comma-related changes
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2021-10-07 11:29:47 -07:00
Michael Woerister
b7cc99142a Turn tcx.vtable_allocation() into a query. 2021-10-07 20:03:00 +02:00
Eliza Weisman
e00eac8b9c
use structured fields in some existing warnings
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2021-10-07 10:48:48 -07:00
Eliza Weisman
928c787fce
make them structured while i'm here
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2021-10-07 10:46:47 -07:00
Eliza Weisman
01803025d2
demote rustc_peek traces look not user-facing
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2021-10-07 10:45:39 -07:00
bors
5641481ad7 Auto merge of #89629 - GuillaumeGomez:rollup-s4r8me6, r=GuillaumeGomez
Rollup of 7 pull requests

Successful merges:

 - #89298 (Issue 89193 - Fix ICE when using `usize` and `isize` with SIMD gathers )
 - #89461 (Add `deref_into_dyn_supertrait` lint.)
 - #89477 (Move items related to computing diffs to a separate file)
 - #89559 (RustWrapper: adapt for LLVM API change)
 - #89585 (Emit item no type error even if type inference fails)
 - #89596 (Make cfg imply doc(cfg))
 - #89615 (Add InferCtxt::with_opaque_type_inference to get_body_with_borrowck_facts)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-10-07 17:17:25 +00:00
Eliza Weisman
eb67bf9368
Update compiler/rustc_driver/src/lib.rs
Co-authored-by: Joshua Nelson <github@jyn.dev>
2021-10-07 09:52:51 -07:00
Eliza Weisman
e7f04857ef
rustc_driver: Enable the WARN log level by default
This commit changes the `tracing_subscriber` initialization in
`rustc_driver` so that the `WARN` verbosity level is enabled by default
when the `RUSTC_LOG` env variable is empty. If the `RUSTC_LOG` env
variable is set, the filter string in the environment variable is
honored, instead.

Fixes #76824
Closes #89623

cc @eddyb, @oli-obk
2021-10-07 09:23:42 -07:00
Guillaume Gomez
0fbb011eb4
Rollup merge of #89615 - willcrichton:fix-get-body-with-borrowck-facts, r=oli-obk
Add InferCtxt::with_opaque_type_inference to get_body_with_borrowck_facts

`mir_borrowck` uses `with_opaque_type_inference` before calling `do_mir_borrowck`: 0eabf25b90/compiler/rustc_borrowck/src/lib.rs (L132)

However `get_body_with_borrowck_facts` does not. Therefore I get an ICE eg when calling this function on the bodies of an async function as described here: https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/.E2.9C.94.20ICE.20when.20using.20get_body_with_borrowck_facts.20with.20async

This change fixes that bug.

r? `@nikomatsakis`
2021-10-07 16:24:54 +02:00
Guillaume Gomez
e32328bdc5
Rollup merge of #89596 - GuillaumeGomez:implicit-doc-cfg, r=jyn514
Make cfg imply doc(cfg)

This is a reopening of #79341, rebased and modified a bit (we made a lot of refactoring in rustdoc's types so they needed to be reflected in this PR as well):

 * `hidden_cfg` is now in the `Cache` instead of `DocContext` because `cfg` information isn't stored anymore on `clean::Attributes` type but instead computed on-demand, so we need this information in later parts of rustdoc.
 * I removed the `bool_to_options` feature (which makes the code a bit simpler to read for `SingleExt` trait implementation.
 * I updated the version for the feature.

There is only one thing I couldn't figure out: [this comment](https://github.com/rust-lang/rust/pull/79341#discussion_r561855624)

> I think I'll likely scrap the whole `SingleExt` extension trait as the diagnostics for 0 and >1 items should be different.

How/why should they differ?

EDIT: this part has been solved, the current code was fine, just needed a little simplification.

cc `@Nemo157`
r? `@jyn514`

Original PR description:

This is only active when the `doc_cfg` feature is active.

The implicit cfg can be overridden via `#[doc(cfg(...))]`, so e.g. to hide a `#[cfg]` you can use something like:

```rust
#[cfg(unix)]
#[doc(cfg(all()))]
pub struct Unix;
```

By adding `#![doc(cfg_hide(foobar))]` to the crate attributes the cfg `#[cfg(foobar)]` (and _only_ that _exact_ cfg) will not be implicitly treated as a `doc(cfg)` to render a message in the documentation.
2021-10-07 16:24:53 +02:00
Guillaume Gomez
de0b4f9444
Rollup merge of #89585 - nbdd0121:issue-89574, r=estebank
Emit item no type error even if type inference fails

Fix #89574

The stashed error should be emitted regardless whether ty references error or not.
2021-10-07 16:24:52 +02:00
Guillaume Gomez
110d289846
Rollup merge of #89559 - krasimirgg:llvm-14-fatal_error_handler_t, r=nagisa
RustWrapper: adapt for LLVM API change

No functional changes intended.

The LLVM commit
e463b69736
changed an argument of fatal_error_handler_t from std::string to char*.
This adapts RustWrapper accordingly.
2021-10-07 16:24:51 +02:00
Guillaume Gomez
ab276b82b0
Rollup merge of #89461 - crlf0710:dyn_upcasting_lint, r=nikomatsakis
Add `deref_into_dyn_supertrait` lint.

Initial implementation of #89460. Resolves #89190.
Maybe also worth a beta backport if necessary.

r? `@nikomatsakis`
2021-10-07 16:24:49 +02:00
Guillaume Gomez
1584b6a796
Rollup merge of #89298 - gcohara:issue89193, r=workingjubilee
Issue 89193 - Fix ICE when using `usize` and `isize` with SIMD gathers

closes #89193
r? `@workingjubilee`
2021-10-07 16:24:48 +02:00
bors
0157cc977f Auto merge of #89534 - camsteffen:diag-name, r=oli-obk
Introduce `tcx.get_diagnostic_name`

Introduces a "reverse lookup" for diagnostic items. This is mainly intended for `@rust-lang/clippy` which often does a long series of `is_diagnostic_item` calls for the same `DefId`.

r? `@oli-obk`
2021-10-07 14:22:16 +00:00
Ryan Levick
757f76ef73 Update to measureme v10 2021-10-07 15:08:44 +02:00
Mara Bos
afe5335b97 Use correct edition for panic in [debug_]assert!() etc. 2021-10-07 14:27:08 +02:00
Ryan Levick
947a33bf20 Add support for artifact size profiling 2021-10-07 14:22:29 +02:00
bors
680ff86391 Auto merge of #86525 - shamatar:array_len_opt, r=oli-obk
Array `.len()` MIR optimization pass

This pass kind-of works back the `[T; N].len()` call that at the moment is first coerced as `&[T; N]` -> `&[T]` and then uses `&[T].len()`. Depends on #86383
2021-10-07 11:34:40 +00:00
Michael Woerister
a1e2c0f0ad Remove untracked vtable-const-allocation cache from tcx 2021-10-07 11:27:35 +02:00
bors
ca8078d7b2 Auto merge of #89495 - Mark-Simulacrum:add-inlines, r=michaelwoerister
Add two inline annotations for hot functions

These two functions are essentially no-ops (and compile to just a load and
return), but show up in process_obligations profiles with a high call count --
so worthwhile to try and inline them. This is not normally possible as they're
non-generic, so they don't get offered for inlining by our current algorithm.
2021-10-07 06:23:23 +00:00
bors
d3e6770efb Auto merge of #89454 - erikdesjardins:perfattrcheck, r=nikomatsakis
perf: only check for `rustc_trivial_field_reads` attribute on traits, not items, impls, etc.

The checks that are removed in this PR (originally added in #85200) caused a small perf regression: https://github.com/rust-lang/rust/pull/88824#issuecomment-932664761

Since the attribute is currently only applied to traits, I don't think it's worth keeping the additional checks for now.
If/when we decide to apply the attribute somewhere else, we can (partially) revert this and reevaluate the perf impact.

r? `@nikomatsakis` cc `@FabianWolff`
2021-10-07 03:42:05 +00:00
Mark Rousskov
6f78eed1c7 Query the fingerprint style during key reconstruction
Keys can be reconstructed from fingerprints that are not DefPathHash, but then
we cannot extract a DefId from them.
2021-10-06 22:19:48 -04:00
Will Crichton
549a68b73e Add InferCtxt::with_opaque_type_inference to get_body_with_borrowck_facts 2021-10-06 19:07:56 -07:00
Michael Benfield
a17193dbb9 Enable AutoFDO.
This largely involves implementing the options debug-info-for-profiling
and profile-sample-use and forwarding them on to LLVM.

AutoFDO can be used on x86-64 Linux like this:
rustc -O -Cdebug-info-for-profiling main.rs -o main
perf record -b ./main
create_llvm_prof --binary=main --out=code.prof
rustc -O -Cprofile-sample-use=code.prof main.rs -o main2

Now `main2` will have feedback directed optimization applied to it.

The create_llvm_prof tool can be obtained from this github repository:
https://github.com/google/autofdo

Fixes #64892.
2021-10-06 19:36:52 +00:00
Manish Goregaokar
f5bfa3450a
Rollup merge of #89528 - FabianWolff:issue-89497, r=jackh726
Fix suggestion to borrow when casting from pointer to reference

Fixes #89497.
2021-10-06 12:33:21 -07:00
Manish Goregaokar
b01594051c
Rollup merge of #89501 - Aaron1011:escaping-name-regions, r=davidtwco
Note specific regions involved in 'borrowed data escapes' error

Fixes #67007

Currently, a 'borrowed data escapes' error does not mention
the specific lifetime involved (except indirectly through a suggestion
about adding a lifetime bound). We now explain the specific lifetime
relationship that failed to hold, which improves otherwise vague
error messages.
2021-10-06 12:33:19 -07:00
Manish Goregaokar
b87a9a8a7c
Rollup merge of #89329 - tmiasko:print-type-sizes-no-fields, r=jackh726
print-type-sizes: skip field printing for primitives

Fixes #86528.
2021-10-06 12:33:18 -07:00
Alexander
a31518fbf4 opt-level >= 4 2021-10-06 20:37:24 +02:00
Guillaume Gomez
8fac41a530 Clean up code a bit:
* Remove "bool_to_options" feature
 * Update version for compiler feature
 * rustfmt
2021-10-06 20:23:57 +02:00
Cameron Steffen
b6cab80c18 Use get_diagnostic_name 2021-10-06 13:10:08 -05:00
Camille GILLOT
4028b093e4 Do not ICE if some foreign expansions were not encoded.
The metadata encoder does not necessarily encode all expansions, only
those which are referenced in other metadata fields.
2021-10-06 19:10:08 +02:00
Camille GILLOT
daf8903e8e Do not re-hash foreign spans. 2021-10-06 19:10:07 +02:00
Camille GILLOT
ce21756ed3 Access Session while decoding expn_id. 2021-10-06 19:06:20 +02:00
Noah Lev
6189d0a116 Fix stabilization version for bindings_after_at
According to the release notes and its PR milestone, it was stabilized
in 1.56.0.
2021-10-06 09:34:39 -07:00
Alexander
d61f95fead fix import 2021-10-06 17:45:54 +02:00
Alexander
94e1413f60 reset and cleanup 2021-10-06 17:31:35 +02:00
Jonah Petri
bc3eb354e7 add platform support details file for armv7-unknown-linux-uclibc 2021-10-06 14:33:13 +00:00
Yannick Koehler
11381a5a3a Add new target armv7-unknown-linux-uclibceabihf
Co-authored-by: Jonah Petri <jonah@petri.us>
2021-10-06 14:33:13 +00:00
Cameron Steffen
33b9b95305 Introduce get_diagnostic_name 2021-10-06 08:40:28 -05:00
bors
d7539a6af0 Auto merge of #89323 - estebank:derive-binop, r=petrochenkov
Consider unfulfilled obligations in binop errors

When encountering a binop where the types would have been accepted, if
all the predicates had been fulfilled, include information about the
predicates and suggest appropriate `#[derive]`s if possible.

Fix #84515.
2021-10-06 06:20:25 +00:00
Gary Guo
a15879d662 Emit item no type error even if type inference fails 2021-10-06 01:53:21 +01:00
Esteban Kuber
e8fc076f23 Consider unfulfilled obligations in binop errors
When encountering a binop where the types would have been accepted, if
all the predicates had been fulfilled, include information about the
predicates and suggest appropriate `#[derive]`s if possible.

Point at trait(s) that needs to be `impl`emented.
2021-10-05 23:34:13 +00:00
Tom Farmer
0950d5afe2 Issue 89275 fix and test
Issue 89275 fix and test

Fix librustdoc OverflowError usage

rust tidy run

Issue 89275 fix and test
2021-10-05 22:43:06 +01:00
Manish Goregaokar
5f8b1614d1
Rollup merge of #89546 - joshtriplett:grow-metadata-faster, r=petrochenkov
Make an initial guess for metadata size to reduce buffer resizes

When reading metadata, the compiler starts with a `Vec::new()`, which will need to grow repeatedly as the metadata gets decompressed into it. Reduce the number of resizes by starting out at the size of the compressed data.
2021-10-05 12:52:49 -07:00
Manish Goregaokar
f71b3e2b46
Rollup merge of #89532 - ecstatic-morse:maybe-live-locals-enum, r=oli-obk,tmiasko
Document behavior of  `MaybeLiveLocals` regarding enums and field-senstivity

This arose from a [discussion on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/MaybeLiveLocals.20and.20Discriminants) where a new contributor attempted to implement a dead-store elimination pass using this analysis. They ran into a nasty hack around `SetDiscriminant` the effect of which is to lets handle assignments of literals to enum-typed locals (e.g. `x = Some(4)`) correctly. This took me a while to figure out.

Document this oddity, so the next person will have an easier time, and add a test to enshrine the current behavior.

r? ``@tmiasko``
2021-10-05 12:52:48 -07:00
Manish Goregaokar
048b0fd98d
Rollup merge of #89523 - Aaron1011:derive-future-compat, r=wesleywiser
Make `proc_macro_derive_resolution_fallback` a future-breakage lint

When `cargo report future-incompatibilities` is stabilized
(see #71249), this will cause dependencies that trigger
this lint to be included in the report.
2021-10-05 12:52:47 -07:00
Manish Goregaokar
80f1f0d169
Rollup merge of #89442 - GuillaumeGomez:duplicated-doc-alias, r=estebank
Add check for duplicated doc aliases

r? ``@estebank``
2021-10-05 12:52:45 -07:00
Manish Goregaokar
0352a2820d
Rollup merge of #89317 - JulianKnodt:precise_errors, r=BoxyUwU
Move generic error message to separate branches

This decomposes an error message in generic constants into more specific branches, for better
readability.

r? ``@lcnr``
2021-10-05 12:52:44 -07:00
Manish Goregaokar
60b9c5d1a9
Rollup merge of #88871 - FabianWolff:issue-88403, r=jackh726
Fix suggestion for nested struct patterns

Fixes #88403, and also a similar problem where the unused binding is in a function parameter pattern.
2021-10-05 12:52:43 -07:00
Manish Goregaokar
960e49e89b
Rollup merge of #88706 - ThePuzzlemaker:issue-88609, r=jackh726
Normalize associated type projections when checking return type of main

This fixes #88609.

Previously, the return type of `fn main()` would not have any associated type projections within normalized before checking if it implements the standard library trait `std::process::Termination`. This commit appears to fix it.

This feels vaguely symptomatic of a problem in the underlying trait solving engine, but I am not sure how I would solve that. I am unsure why the example in #88609 with `assert_impl_termination` and `fn foo()` work, but simply `fn main()` doesn't. The way that I solved this is also probably not the best way to do this, so please let me know if there is a better way to do this.

I have added a build-pass regression test for this issue.
2021-10-05 12:52:41 -07:00
Aaron Hill
3c974adb4c
Note specific regions involved in 'borrowed data escapes' error
Fixes #67007

Currently, a 'borrowed data escapes' error does not mention
the specific lifetime involved (except indirectly through a suggestion
about adding a lifetime bound). We now explain the specific lifetime
relationship that failed to hold, which improves otherwise vague
error messages.
2021-10-05 13:25:03 -05:00
Joshua Nelson
56e5f61494 Add cfg_hide to the list of known attributes 2021-10-05 18:15:30 +02:00
Joshua Nelson
e36a370f08 Add test case for doc_cfg_hide feature gate 2021-10-05 18:15:30 +02:00
Wim Looman
18fdd816b7 Allow adding a set of cfg's to hide from being implicitly doc(cfg)'d
By adding #![doc(cfg_hide(foobar))] to the crate attributes the cfg
 #[cfg(foobar)] (and _only_ that _exact_ cfg) will not be implicitly
treated as a doc(cfg) to render a message in the documentation.
2021-10-05 18:04:15 +02:00
Krasimir Georgiev
67a82e20cf RustWrapper: adapt for LLVM API change of fatal_error_handler_t
No functional changes intended.

The LLVM commit
e463b69736
changed an argument of fatal_error_handler_t from std::string to char*.
This adapts RustWrapper accordingly.
2021-10-05 16:31:36 +02:00
bors
25ec827385 Auto merge of #89363 - oli-obk:in_tracing_we_trust, r=Mark-Simulacrum
Fix performance regression with #[instrument]

linked tracing PR: https://github.com/tokio-rs/tracing/pull/1600

regression introduced by #89048
2021-10-05 12:52:43 +00:00
bors
55111d656f Auto merge of #89266 - cjgillot:session-ich, r=michaelwoerister
Move ICH to rustc_query_system

Based on https://github.com/rust-lang/rust/pull/89183

The StableHashingContext does not need to be in rustc_middle.

This PR moves it to rustc_query_system. This will avoid a dependency between rustc_ast_lowering and rustc_middle in https://github.com/rust-lang/rust/pull/89124.
2021-10-05 09:45:11 +00:00
Manish Goregaokar
bf62c6d710
Rollup merge of #89504 - Aaron1011:rpit-nll-static, r=nikomatsakis
Don't suggest replacing region with 'static in NLL

Fixes #73159

This is similar to #69350 - if the user didn't initially
write out a 'static lifetime, adding 'static in response to
a lifetime error is usually the wrong thing to do.
2021-10-04 23:56:24 -07:00
Manish Goregaokar
04314a6061
Rollup merge of #89482 - hkmatsumoto:patch-diagnostics, r=joshtriplett
Follow the diagnostic output style guide

Detected by #89455.
2021-10-04 23:56:23 -07:00
Manish Goregaokar
87f782ede6
Rollup merge of #89423 - DevinR528:reachable-fields, r=Nadrieril
Fix ICE caused by non_exaustive_omitted_patterns struct lint

fixes #89382

Add check that a list of `Pat`s is non empty to prevent ICE in `FnCtxt::lint_non_exhaustive_omitted_patterns`.

Is related to #89374 and #89105
2021-10-04 23:56:20 -07:00
Jubilee
c9158db1f3
Rollup merge of #89494 - FabianWolff:issue-84075, r=davidtwco
Deny `where` clauses on `auto` traits

Fixes #84075.
2021-10-04 21:12:43 -07:00
Jubilee
90e96f9fc3
Rollup merge of #89487 - FabianWolff:issue-89396, r=petrochenkov
Try to recover from a `=>` -> `=` or `->` typo in a match arm

Fixes #89396.
2021-10-04 21:12:42 -07:00
Jubilee
ec4145510e
Rollup merge of #89478 - zvavybir:master, r=jyn514
Fixed numerus of error message

When there are redundant trait requirements and these are hidden, a message is generated by the following code snippet:
`format!("{} redundant requirements hidden", count)`
But if there is only a single hidden requirement, it will still print this message in plural instead of singular.
2021-10-04 21:12:40 -07:00
Jubilee
c2bfe45e66
Rollup merge of #89473 - FabianWolff:issue-89469, r=joshtriplett
Fix extra `non_snake_case` warning for shorthand field bindings

Fixes #89469. The problem is the innermost `if` condition here:
d14731cb3c/compiler/rustc_lint/src/nonstandard_style.rs (L435-L452)

This code runs for every `PatKind::Binding`, so if a struct has multiple fields, say A and B, and both are bound in a pattern using shorthands, the call to `self.check_snake_case()` will indeed be skipped in the `check_pat()` call for `A`; but when `check_pat()` is called for `B`, the loop will still iterate over `A`, and `field.ident (= A) != ident (= B)` will be true. I have fixed this by only looking at non-shorthand bindings, and only the binding that `check_pat()` was actually called for.
2021-10-04 21:12:38 -07:00
Jubilee
36f173f0a9
Rollup merge of #89466 - Mark-Simulacrum:query-macros, r=oli-obk
Fix bug with query modifier parsing

The previous macro_rules! parsers failed when an additional modifier was added
with ambiguity errors. The error is pretty unclear as to what exactly the cause
here is, but this change simplifies the argument parsing code such that the
error is avoided.

Extracted from other work, and somewhat duplicates 0358edeb5 from #85830, but
this approach seems a little simpler to me. Not technically currently necessary but seems
like a good cleanup.
2021-10-04 21:12:37 -07:00
Jubilee
05b4cd6789
Rollup merge of #89413 - matthewjasper:spec-marker-fix, r=nikomatsakis
Correctly handle supertraits for min_specialization

Supertraits of specialization markers could circumvent checks for
min_specialization. Elaborating predicates prevents this.

r? ````@nikomatsakis````
2021-10-04 21:12:35 -07:00
Jubilee
4f6afee4e5
Rollup merge of #88090 - nbdd0121:inference, r=nikomatsakis
Perform type inference in range pattern

Fix #88074
2021-10-04 21:12:33 -07:00
Jubilee
99e6e3ff07
Rollup merge of #87993 - kornelski:try_reserve_stable, r=joshtriplett
Stabilize try_reserve

Stabilization PR for the [`try_reserve` feature](https://github.com/rust-lang/rust/issues/48043#issuecomment-898040475).
2021-10-04 21:12:33 -07:00
Josh Triplett
c35a700be2 Make an initial guess for metadata size to reduce buffer resizes 2021-10-04 19:23:13 -07:00
Dylan MacKenzie
02c2a35c66 Discuss field-sensitivity and enums in context of MaybeLiveLocals 2021-10-04 14:09:19 -07:00
Jubilee
9866b090f4
Rollup merge of #89508 - jhpratt:stabilize-const_panic, r=joshtriplett
Stabilize `const_panic`

Closes #51999

FCP completed in #89006

```@rustbot``` label +A-const-eval +A-const-fn +T-lang

cc ```@oli-obk``` for review (not `r?`'ing as not on lang team)
2021-10-04 13:58:17 -07:00
Jubilee
3d4467dfcc
Rollup merge of #89500 - FabianWolff:issue-87308, r=petrochenkov
Fix ICE with buffered lint referring to AST node deleted by everybody_loops

Fixes #87308. Note the following comment:
08759c691e/compiler/rustc_lint/src/early.rs (L415-L417)

As it turns out, this is not _always_ a bug, because `-Zunpretty=everybody_loops` causes a lot of AST nodes to be deleted, and thus some buffered lints will refer to non-existent node ids. To fix this, my changes simply ignore buffered lints if `-Zunpretty=everybody_loops` is enabled, which, from my understanding, shouldn't be a big issue because it only affects pretty-printing. Of course, a more elegant solution would only ignore buffered lints that actually point at deleted node ids, but I haven't figured out an easy way of achieving this.

For the concrete example in #87308, the buffered lint is created [here](08759c691e/compiler/rustc_expand/src/mbe/macro_rules.rs (L145-L151)) with the `lint_node_id` from [here](08759c691e/compiler/rustc_expand/src/mbe/macro_rules.rs (L319)), i.e. it points at the macro _expansion_, which then gets deleted by `ReplaceBodyWithLoop` [here](08759c691e/compiler/rustc_interface/src/passes.rs (L377)).
2021-10-04 13:58:16 -07:00
Jubilee
5352e17df3
Rollup merge of #89483 - hkmatsumoto:patch-diagnostics-2, r=estebank
Practice diagnostic message convention

Detected by #89455.

r? ```@estebank```
2021-10-04 13:58:15 -07:00
Jubilee
2bc89ce0bf
Rollup merge of #89453 - waywardmonkeys:consistent-supertrait-usage, r=nagisa
Consistently use 'supertrait'.

A subset of places referred to 'super-trait', so this changes them
to all use 'supertrait'. This matches 'supertype' and some other
usages. An exception is 'auto-trait' which is consistently used
in that manner.
2021-10-04 13:58:14 -07:00
Jubilee
08dd4148f1
Rollup merge of #89447 - FabianWolff:issue-89388, r=davidtwco
Improve error message for missing angle brackets in `[_]::method`

Fixes #89388.
2021-10-04 13:58:13 -07:00
Jubilee
9381d7a898
Rollup merge of #89407 - pierwill:recommend-clean-E0514, r=davidtwco
Recommend running `cargo clean` in E0514 output

This suggestion has worked for me before. Seems to me it could help others.
2021-10-04 13:58:10 -07:00
Jubilee
a2c6075dff
Rollup merge of #88451 - theo-lw:issue-87771, r=jackh726
Fix an ICE caused by type mismatch errors being ignored

This PR fixes #87771. It turns out that the check on `compiler/rustc_typeck/src/check/demand.rs:148` leads to the ICE. I removed it because the early return in [`check_expr_assign`](dec7fc3ced/compiler/rustc_typeck/src/check/expr.rs (L928)) already prevents unnecessary error messages from the call to `check_expr_coercable_to_type`.
2021-10-04 13:58:07 -07:00
Jubilee
4e9cf04c98
Rollup merge of #83655 - sebpop:arm64-outline-atomics, r=workingjubilee
[aarch64] add target feature outline-atomics

Enable outline-atomics by default as enabled in clang by the following commit
https://reviews.llvm.org/rGc5e7e649d537067dec7111f3de1430d0fc8a4d11

Performance improves by several orders of magnitude when using the LSE instructions
instead of the ARMv8.0 compatible load/store exclusive instructions.

Tested on Graviton2 aarch64-linux with
x.py build && x.py install && x.py test
2021-10-04 13:58:06 -07:00
Fabian Wolff
079c075f24 Use TokenKind::similar_tokens() 2021-10-04 22:13:00 +02:00
Fabian Wolff
388bcc1cb0 Fix suggestion to borrow when casting from pointer to reference 2021-10-04 21:15:02 +02:00
Guillaume Gomez
40fe064c63 Add a check for duplicated doc aliases in unused lint 2021-10-04 20:57:05 +02:00
Aaron Hill
32a5abc6fe
Make proc_macro_derive_resolution_fallback a future-breakage lint
When `cargo report future-incompatibilities` is stabilized
(see #71249), this will cause dependencies that trigger
this lint to be included in the report.
2021-10-04 11:05:48 -05:00
bors
a4797664ba Auto merge of #89489 - FabianWolff:issue-89485, r=oli-obk
Fix unsound optimization with explicit variant discriminants

Fixes #89485.
2021-10-04 10:09:04 +00:00
David Wood
b39e915981 polymorphize: don't normalize self-ty need substs
`characteristic_def_id_of_type` was being invoked during partitioning
for self types of impl blocks which had projections that depended on the
value of unused generic parameters of a function, resulting in an ICE in
the 'generic-names' debuginfo test. If partitioning is enabled and the
instance needs substitution then this is now skipped.

Signed-off-by: David Wood <david.wood@huawei.com>
2021-10-04 09:50:10 +00:00
Kornel
00152d8977 Stabilize try_reserve 2021-10-04 10:29:46 +01:00
kadmin
9cb30f465e Move generic error message to separate branches
This decomposes an error message in generic constants into more specific branches, for better
readability.
2021-10-04 06:49:49 +00:00
Jacob Pratt
bce8621983
Stabilize const_panic 2021-10-04 02:33:33 -04:00
Manish Goregaokar
5215b855b0
Rollup merge of #88481 - bjorn3:remove_feature_gates, r=cjgillot
Remove some feature gates

The first commit removes various feature gates that are unused. The second commit replaces some `Fn` implementations with `Iterator` implementations, which is much cleaner IMO. The third commit replaces an unboxed_closures feature gate with min_specialization. For some reason the unboxed_closures feature gate suppresses the min_specialization feature gate from triggering on an `TrustedStep` impl. The last comment just turns a regular comment into a doc comment as drive by cleanup. I can move it to a separate PR if preferred.
2021-10-03 23:13:20 -07:00
Aaron Hill
fdd8a0dde5
Don't suggest replacing region with 'static in NLL
Fixes #73159

This is similar to #69350 - if the user didn't initially
write out a 'static lifetime, adding 'static in response to
a lifetime error is usually the wrong thing to do.
2021-10-03 21:53:48 -05:00
bors
e737694a4d Auto merge of #88175 - camsteffen:let-desugar-span, r=Manishearth
Add expansion to while desugar spans

In the same vein as #88163, this reverts a change in Clippy behavior as a result of #80357 (and reverts some `#[allow]`s): This changes `clippy::blocks_in_if_conditions` to not fire on `while` loops. Though we might actually want Clippy to lint those cases, we should introduce the change purposefully, with tests, and possibly under a different lint name.

The actual change here is to add a desugaring expansion to the spans when lowering a `while` loop.

r? `@Manishearth`
2021-10-03 21:44:10 +00:00
Fabian Wolff
dd9b4763a4 Disable SimplifyBranchSame optimization for now 2021-10-03 22:58:24 +02:00
Fabian Wolff
20489eaca2 Update comments 2021-10-03 21:06:49 +02:00
Fabian Wolff
a28a78f247 Fix ICE with buffered lint referring to AST node deleted by everybody_loops 2021-10-03 21:04:36 +02:00
Mark Rousskov
1c2ad79f9d Add two inline annotations for hot functions
These two functions are essentially no-ops (and compile to just a load and
return), but show up in process_obligations profiles with a high call count --
so worthwhile to try and inline them away.
2021-10-03 12:43:43 -04:00
Fabian Wolff
e34fd54611 Deny where clauses on auto traits 2021-10-03 18:06:21 +02:00
bjorn3
9f4cb862ca Replace Fn impls with RPIT impls in rustc_index
This is cleaner and removes an unstable feature usage
2021-10-03 17:50:53 +02:00
Camille GILLOT
b2ed9c4007 Add some inlining. 2021-10-03 16:08:57 +02:00
Camille GILLOT
fedd7785fe Access StableHashingContext in rustc_query_system. 2021-10-03 16:08:55 +02:00
Camille GILLOT
471cb5c149 Fully remove rustc_middle::ich. 2021-10-03 16:08:55 +02:00
Camille GILLOT
02025d86ac Remove re-export. 2021-10-03 16:08:54 +02:00
Camille GILLOT
c355b2e5cd Move ICH to rustc_query_system. 2021-10-03 16:08:53 +02:00
Camille GILLOT
2d38c53767 Remove StableHashProvider. 2021-10-03 16:08:52 +02:00
Camille GILLOT
8961616e60 Move rustc_middle::middle::cstore to rustc_session. 2021-10-03 16:08:51 +02:00
Camille GILLOT
b66dfaaa64 Move some HashStable impls. 2021-10-03 16:08:50 +02:00
Fabian Wolff
529c35331b Fix unsound optimization with explicit variant discriminants 2021-10-03 16:04:38 +02:00
Fabian Wolff
9626f2bd84 Fix extra non_snake_case warning for shorthand field bindings 2021-10-03 14:33:14 +02:00
Fabian Wolff
cf19131cb3 Try to recover from a => -> = or -> typo in a match arm 2021-10-03 14:14:35 +02:00
Matthias Kaak
d6a7e74c81 Combined 4 commits into 1
Fixed numerus of error message

Removed superfluous argument

Using pluralize!() instead of code duplication

Adjusted a test
2021-10-03 11:53:12 +00:00
Hirochika Matsumoto
3818981ca1 Practice diagnostic message convention 2021-10-03 16:16:28 +09:00
Hirochika Matsumoto
fb0b1a5466 Follow the diagnostic output style guide 2021-10-03 14:28:39 +09:00
Charles Lew
250d1260e6 Add deref_into_dyn_supertrait lint. 2021-10-03 12:36:40 +08:00
bors
77f1e504a9 Auto merge of #89479 - camsteffen:diag-naming, r=Manishearth
Make diangostic item naming consistent

Right now there is about a 50/50 split of naming diagnostic items as `vec_type` vs `Vec`. So it is hard to guess a diagnostic item name with confidence. I know it's not great to change these retroactively, but I think it will be much easier to maintain consistency after consistency is established.
2021-10-03 03:43:21 +00:00
bors
c70b35efd8 Auto merge of #84267 - dtolnay:ptrunit, r=nagisa
Make *const (), *mut () okay for FFI

Pointer-to-() is used occasionally in the standard library to mean "pointer to none-of-your-business". Examples:

- `RawWakerVTable::new` https://doc.rust-lang.org/1.51.0/std/task/struct.RawWakerVTable.html#method.new
- `<*const T>::to_raw_parts` https://doc.rust-lang.org/nightly/std/primitive.pointer.html#method.to_raw_parts

I believe it's useful for the same purpose in FFI signatures, even while `()` itself is not FFI safe. The following should be allowed:

```rust
extern "C" {
    fn demo(pc: *const (), pm: *mut ());
}
```

Prior to this PR, those pointers were not considered okay for an extern signature.

```console
warning: `extern` block uses type `()`, which is not FFI-safe
 --> src/main.rs:2:17
  |
2 |     fn demo(pc: *const (), pm: *mut ());
  |                 ^^^^^^^^^ not FFI-safe
  |
  = note: `#[warn(improper_ctypes)]` on by default
  = help: consider using a struct instead
  = note: tuples have unspecified layout

warning: `extern` block uses type `()`, which is not FFI-safe
 --> src/main.rs:2:32
  |
2 |     fn demo(pc: *const (), pm: *mut ());
  |                                ^^^^^^^ not FFI-safe
  |
  = help: consider using a struct instead
  = note: tuples have unspecified layout
```
2021-10-03 00:41:49 +00:00
Cameron Steffen
eec856bfbc Make diangostic item names consistent 2021-10-02 19:38:19 -05:00