Commit graph

8692 commits

Author SHA1 Message Date
Yuki Okushi
d4cc8774d5
Suggest a case insensitive match name regardless of levenshtein distance 2021-10-17 04:51:22 +09:00
Matthias Krüger
502d57b32d
Rollup merge of #89915 - jackh726:outlives_cleanup, r=nikomatsakis
Some outlives cleanup

No semantic changes here, only moving code around + using `LocalDefId` instead of `HirId`

r? ````@nikomatsakis````
2021-10-16 08:02:25 +02:00
Matthias Krüger
e8efe0931a
Rollup merge of #89914 - jackh726:gat_genericboundfailure, r=estebank
Emit impl difference error for GenericBoundFailure too

Fixes #86787

r? ````@estebank````
2021-10-16 08:02:24 +02:00
Matthias Krüger
27a7ced29f
Rollup merge of #89912 - davidtwco:issue-89280-split-lines-multiple-lines, r=oli-obk
emitter: current substitution can be multi-line

Fixes #89280.

In `splice_lines`, there is some arithmetic to compute the required alignment such that future substitutions in a suggestion are aligned correctly. However, this assumed that the current substitution's span was only on a single line. In circumstances where this was not true, it could result in a arithmetic overflow when the substitution's end column was less than the substitution's start column.

r? ````@oli-obk````
2021-10-16 08:02:24 +02:00
Matthias Krüger
dfed1a6c07
Rollup merge of #89898 - Amanieu:remove_alloc_prelude, r=joshtriplett
Remove alloc::prelude

As per the libs team decision in #58935.

Closes #58935
2021-10-16 08:02:21 +02:00
jackh726
2b5b456e23 Move some outlives bounds things from rustc_trait_selection to rustc_typeck 2021-10-15 12:14:19 -04:00
jackh726
d3fa07c72e Use LocalDefId directly in more places in wfcheck 2021-10-15 12:14:02 -04:00
jackh726
a7c132de55 Move push_outlives_components to rustc_infer 2021-10-15 12:13:35 -04:00
jackh726
c4f9eb1e5a Emit impl difference error for GenericBoundFailure too 2021-10-15 11:41:39 -04:00
David Wood
d2dc0f3b0f emitter: current substitution can be multi-line
In `splice_lines`, there is some arithmetic to compute the required
alignment such that future substitutions in a suggestion are aligned
correctly. However, this assumed that the current substitution's span
was only on a single line. In circumstances where this was not true, it
could result in a arithmetic overflow when the substitution's end
column was less than the substitution's start column.

Signed-off-by: David Wood <david.wood@huawei.com>
2021-10-15 15:30:43 +00:00
bors
72d66064e7 Auto merge of #89903 - matthiaskrgr:rollup-s0c69xl, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #86011 (move implicit `Sized` predicate to end of list)
 - #89821 (Add a strange test for `unsafe_code` lint.)
 - #89859 (add dedicated error variant for writing the discriminant of an uninhabited enum variant)
 - #89870 (Suggest Box::pin when Pin::new is used instead)
 - #89880 (Use non-checking TLS relocation in aarch64 asm! sym test.)
 - #89885 (add long explanation for E0183)
 - #89894 (Remove unused dependencies from rustc_const_eval)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-10-15 05:59:49 +00:00
Matthias Krüger
e45c222793
Rollup merge of #89894 - camsteffen:unused-deps, r=Mark-Simulacrum
Remove unused dependencies from rustc_const_eval
2021-10-15 07:44:50 +02:00
Matthias Krüger
e3099e7d8c
Rollup merge of #89885 - cameron1024:long-explanation-E0183, r=GuillaumeGomez
add long explanation for E0183

Addresses #61137
2021-10-15 07:44:49 +02:00
Matthias Krüger
e2c28ad1e7
Rollup merge of #89870 - tmandry:box-pin, r=estebank
Suggest Box::pin when Pin::new is used instead

This fixes an incorrect diagnostic.

**Based on #89390**; only the last commit is specific to this PR. "Ignore whitespace changes" also helps here.
2021-10-15 07:44:47 +02:00
Matthias Krüger
345d483e95
Rollup merge of #89859 - RalfJung:write-discriminant, r=oli-obk
add dedicated error variant for writing the discriminant of an uninhabited enum variant

This is conceptually different from hitting an `Unreachable` terminator. Also add some sanity check making sure we don't write discriminants of things that do not have discriminants.

r? ``@oli-obk``
2021-10-15 07:44:47 +02:00
Matthias Krüger
36a1076d24
Rollup merge of #86011 - tlyu:correct-sized-bound-spans, r=estebank
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.

Fixes #85998, at least partially. ~~Based on #85979, but only the last 2 commits are new for this pull request.~~ (edit: rebased) A full fix would need to deal with where-clauses, and that seems difficult. Basically, predicates are being collected in multiple stages, and there are two places where implicit `Sized` predicates can be inserted: once for generic parameters, and once for where-clauses. I think this insertion is happening too early, and we should actually do it only at points where we collect all of the relevant trait bounds for a type parameter.

I could use some help interpreting the changes to the stderr output. It looks like reordering the predicates changed some diagnostics that don't obviously have anything to do with `Sized` bounds. Possibly some error reporting code is making assumptions about ordering of predicates? The diagnostics for src/test/ui/derives/derives-span-Hash-*.rs seem to have improved, no longer pointing at the type parameter identifier, but src/test/ui/type-alias-impl-trait/generic_duplicate_param_use9.rs became less verbose for some reason.

I also ran into an instance of #84970 while working on this, but I kind of expected that could happen, because I'm reordering predicates. I can open a separate issue on that if it would be helpful.

``@estebank`` this seems likely to conflict (slightly?) with your work on #85947; how would you like to resolve that?
2021-10-15 07:44:44 +02:00
bors
313e71a253 Auto merge of #89884 - Mark-Simulacrum:revert-enum-discr, r=wesleywiser
Revert enum discriminants

Reverts stabilization of arbitrary enum discriminants per https://github.com/rust-lang/rust/issues/88621#issuecomment-929482371.

Reopens #60553.
2021-10-15 02:55:58 +00:00
Amanieu d'Antras
8007dfa3b2 Remove alloc::prelude
As per the libs team decision in #58935.

Closes #58935
2021-10-15 01:41:31 +02:00
Cameron Steffen
64d18d4c51 Remove unused dependencies from rustc_const_eval 2021-10-14 15:42:42 -05:00
cameron1024
cca39148f3 add long explanation for E0183 2021-10-14 17:44:04 +01:00
bors
e1e9319d93 Auto merge of #89882 - matthiaskrgr:rollup-1dh7pz8, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #89390 (Fix incorrect Box::pin suggestion)
 - #89433 (Fix ctrl-c causing reads of stdin to return empty on Windows.)
 - #89823 (Switch order of terms to prevent overflow)
 - #89865 (Allow static linking LLVM with ThinLTO)
 - #89873 (Add missing word to `FromStr` trait documentation)
 - #89878 (Fix missing remaining compiler specific cfg information)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-10-14 16:23:10 +00:00
Mark Rousskov
8485e6fdec Revert "Stabilize arbitrary_enum_discriminant"
This reverts commit 7a62f29f31.
2021-10-14 10:57:56 -04:00
Matthias Krüger
29081f95e9
Rollup merge of #89823 - jackh726:project-overflow, r=oli-obk
Switch order of terms to prevent overflow

Fixes #89639

r? ``@pnkfelix``
2021-10-14 16:06:45 +02:00
Matthias Krüger
f9c9774aea
Rollup merge of #89390 - tmandry:issue-72117, r=estebank
Fix incorrect Box::pin suggestion

The suggestion checked if `Pin<Box<T>>` could be coeerced to the expected
type, but did not check predicates created by the coercion. We now
look for predicates that definitely cannot be satisfied before giving
the suggestion.

The suggestion is still marked MaybeIncorrect because we allow predicates that
are still ambiguous and can't be proven.

Fixes #72117.
2021-10-14 16:06:43 +02:00
Ralf Jung
c5a68cf0a6 add dedicated error variant for writing the discriminant of an uninhabited enum variant 2021-10-14 10:03:20 -04:00
bors
0a56eb11fa Auto merge of #88698 - Noble-Mushtak:master, r=nikomatsakis,oli-obk
Add check that live_region is live in sanitize_promoted

This pull request fixes #88434 by adding a check in `sanitize_promoted` to ensure that only regions which are actually live are added to the `liveness_constraints` of the `BorrowCheckContext`.

To implement this change, I needed to add a method to `LivenessValues` which gets the elements contained by a region:

    /// Returns an iterator of all the elements contained by the region `r`
    crate fn get_elements(&self, row: N) -> impl Iterator<Item = Location> + '_

Then, inside `sanitize_promoted`, we check whether the iterator returned by this method is non-empty to ensure that the region is actually live at at least one location before adding that region to the `liveness_constraints` of the `BorrowCheckContext`.

This is my first pull request to the Rust repo, so any feedback on how I can improve this pull request or if there is a better way to fix this issue would be very appreciated.
2021-10-14 13:21:46 +00:00
bors
c34ac8747c Auto merge of #89247 - fee1-dead:const-eval-select, r=oli-obk
Add `const_eval_select` intrinsic

Adds an intrinsic that calls a given function when evaluated at compiler time, but generates a call to another function when called at runtime.

See https://github.com/rust-lang/const-eval/issues/7 for previous discussion.

r? `@oli-obk.`
2021-10-14 10:06:30 +00:00
Deadbeef
26b78ccd31
Fix const stability 2021-10-14 07:07:34 +00:00
Tyler Mandry
d18502d6b3 Suggest Box::pin when Pin::new is used instead 2021-10-14 01:06:25 +00:00
bors
8c852bc15a Auto merge of #89858 - matthiaskrgr:rollup-evsnr2e, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #89347 (suggestion for typoed crate or module)
 - #89670 (Improve `std:🧵:available_parallelism` docs)
 - #89757 (Use shallow clones for submodules)
 - #89759 (Assemble the compiler when running `x.py build`)
 - #89846 (Add `riscv32imc-esp-espidf` to 1.56 changelog)
 - #89853 (Update the 1.56.0 release header for consistency)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-10-13 23:27:57 +00:00
Tyler Mandry
a8558e9efa Exit early if expected type is not an adt 2021-10-13 23:26:01 +00:00
Tyler Mandry
485ae9f2c0 Always check predicates in can_coerce
This only changed two tests and I consider both changes an improvement.
2021-10-13 23:26:00 +00:00
Tyler Mandry
5c14433c00 Fix incorrect Box::pin suggestion
The suggestion checked if Pin<Box<T>> could be coeerced to the expected
type, but did not check predicates created by the coercion. We now
look for predicates that definitely cannot be satisfied before giving
the suggestion.

The suggestion is marked MaybeIncorrect because we allow predicates that
are still ambiguous and can't be proven.
2021-10-13 23:26:00 +00:00
Tyler Mandry
2c31c31bb8 Fix line length 2021-10-13 23:26:00 +00:00
Matthias Krüger
efac68b93c
Rollup merge of #89347 - TaKO8Ki:crate-or-module-typo, r=estebank
suggestion for typoed crate or module

Previously, the compiler didn't suggest similarly named crates or modules. This pull request adds a suggestion for typoed crates or modules.

#76208

before:

```
error[E0433]: failed to resolve: use of undeclared type or module `chono`
 --> src/main.rs:2:5
  |
2 | use chono::prelude::*;
  |     ^^^^^ use of undeclared type or module `chono`
```

after:

```
error[E0433]: failed to resolve: use of undeclared type or module `chono`
 --> src/main.rs:2:5
  |
2 | use chono::prelude::*;
  |     ^^^^^
  |     |
  |     use of undeclared crate or module `chono`
  |     help: a similar crate or module exists: `chrono`
```
2021-10-13 22:51:00 +02:00
bors
dfc5add915 Auto merge of #89555 - oli-obk:nll_member_constraint_diag, r=estebank
Remove textual span from diagnostic string

This is an unnecessary repetition, as the diagnostic prints the span anyway in the source path right below the message.

I further removed the identification of the node, as that does not give any new information in any of the cases that are changed in tests.

EDIT: also inserted a suggestion that other diagnostics were already emitting
2021-10-13 20:36:10 +00:00
bors
eeb16a2a89 Auto merge of #89822 - tmiasko:overflap-duplicates, r=cjgillot
Deduplicate regions ids before merging them

The merging code does not expect to see any duplicates.

Fixes #89820.

r? `@cjgillot`
2021-10-13 16:42:53 +00:00
bors
81117ff930 Auto merge of #89847 - JohnTitor:rollup-xfymeo4, r=JohnTitor
Rollup of 12 pull requests

Successful merges:

 - #89768 (add some more testcases)
 - #89777 (Edit explanation of test for nested type ascriptions)
 - #89781 (Add missing words in `Infallible` docs)
 - #89782 (Improve CJK font in rustdoc)
 - #89794 (Add #[must_use] to to_value conversions)
 - #89814 (Fix uppercase/lowercase error)
 - #89816 (Fix invalid rules in .gitignore)
 - #89817 (Add #[inline] to int log10 functions.)
 - #89818 (Use Option::map_or instead of open coding it)
 - #89828 (Fix config.toml overflow-checks options)
 - #89840 (fix the stage0 tools config file path in `config.toml.example`)
 - #89845 (Add davidtwco to the `.mailmap`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-10-13 13:41:48 +00:00
Yuki Okushi
6eb0a5f0e8
Rollup merge of #89818 - LingMan:map_or, r=oli-obk
Use Option::map_or instead of open coding it

````@rustbot```` modify labels +C-cleanup +T-compiler
2021-10-13 21:55:17 +09:00
Oli Scherer
888ba509ea Re-use logic for adding a suggestion when a lifetime bound is missing on an impl trait 2021-10-13 10:53:44 +00:00
Oli Scherer
d435101537 Use a label instead of a note for member constraint errors 2021-10-13 10:53:44 +00:00
Oli Scherer
15f93473f1 Remove textual span from diagnostic string 2021-10-13 10:53:44 +00:00
bors
5728bd64b4 Auto merge of #89587 - camelid:all-candidates, r=petrochenkov
Include rmeta candidates in "multiple matching crates" error

Only dylib and rlib candidates were included in the error. I think the
reason is that at the time this error was originally implemented, rmeta
crate sources were represented different from dylib and rlib sources.
I wrote up more detailed analysis in [this comment][1].

The new version of the code is also a bit easier to read and should be
more robust to future changes since it uses `CrateSources::paths()`.

I also changed the code to sort the candidates to make the output deterministic;
added full stderr tests for the error; and added a long error code explanation.

[1]: https://github.com/rust-lang/rust/pull/88675#issuecomment-935282436

cc `@Mark-Simulacrum` `@jyn514`
2021-10-13 10:38:12 +00:00
Takayuki Maeda
f819e6d59c suggestion for typoed crate or module
avoid suggesting the same name

sort candidates

fix a message

use `opt_def_id` instead of `def_id`

move `find_similarly_named_module_or_crate` to rustc_resolve/src/diagnostics.rs
2021-10-13 12:17:02 +09:00
Tomasz Miąsko
8aaf4ab59a Deduplicate regions ids before merging them
The merging code does not expect to see any duplicates.
2021-10-13 00:00:00 +00:00
bors
d7c97a02d1 Auto merge of #89105 - DevinR528:reachable-fix, r=Nadrieril
Fix: non_exhaustive_omitted_patterns by filtering unstable and doc hidden variants

Fixes: #89042

Now that #86809 has been merged there are cases (std::io::ErrorKind) where unstable feature gated variants were included in warning/error messages when the feature was not turned on. This filters those variants out of the return of `SplitWildcard::new`.

Variants marked `doc(hidden)` are filtered out of the witnesses list in `Usefulness::apply_constructor`.

Probably worth a perf run 🤷 since this area can be sensitive.
2021-10-12 20:54:15 +00:00
Noah Lev
cc6a09009d Add long explanation for E0464
The test is copied from `src/test/ui/crate-loading/crateresolve1.rs` and
its auxiliary tests. I added it to the `compile_fail` code example check
exemption list since it's hard if not impossible to reproduce this error
in a standalone code example.
2021-10-12 13:10:12 -07:00
Noah Lev
2e56b6f98e Include rmeta candidates in "multiple matching crates" error
Only dylib and rlib candidates were included in the error. I think the
reason is that at the time this error was originally implemented, rmeta
crate sources were represented different from dylib and rlib sources.
I wrote up more detailed analysis in [this comment][1].

The new version of the code is also a bit easier to read and should be
more robust to future changes since it uses `CrateSources::paths()`.

[1]: https://github.com/rust-lang/rust/pull/88675#issuecomment-935282436
2021-10-12 13:10:11 -07:00
Noah Lev
6792c6a851 Sort candidate libraries by source path in error
This makes the error output deterministic and thus testable.
2021-10-12 13:08:32 -07:00
jackh726
9855e7dc7b Switch order of terms to prevent overflow 2021-10-12 11:14:31 -04:00