Commit graph

469 commits

Author SHA1 Message Date
Mara Bos
5cf025f076
Rollup merge of #88230 - steffahn:a_an, r=oli-obk
Fix typos “a”→“an”

Fix typos in comments; found using a regex to find some easy instance of incorrect usage of a vs. an.

While automation was used to find these, every change was checked manually.

Changes in submodules get separate PRs:
* https://github.com/rust-lang/stdarch/pull/1201
* https://github.com/rust-lang/cargo/pull/9821
* https://github.com/rust-lang/miri/pull/1874
* https://github.com/rust-lang/rls/pull/1746
* https://github.com/rust-analyzer/rust-analyzer/pull/9984
  _folks @ rust-analyzer are fast at merging…_
  * https://github.com/rust-analyzer/rust-analyzer/pull/9985
  * https://github.com/rust-analyzer/rust-analyzer/pull/9987
  * https://github.com/rust-analyzer/rust-analyzer/pull/9989

_For `clippy`, I don’t know if the changes should better better be moved to a PR to the original repo._

<hr>

This has some overlap with #88226, but neither is a strict superset of the other.

If you want multiple commits, I can split it up; in that case, make sure to suggest a criterion for splitting.
2021-08-23 20:45:49 +02:00
bors
91f9806208 Auto merge of #88166 - BoxyUwU:const-equate-canon, r=lcnr
canonicalize consts before calling try_unify_abstract_consts query

Fixes #88022
Fixes #86953
Fixes #77708
Fixes #82034
Fixes #85031

these ICEs were all caused by calling the `try_unify_abstract_consts` query with inference vars in substs

r? `@lcnr`
2021-08-22 18:00:22 +00:00
Frank Steffahn
bf88b113ea Fix typos “a”→“an” 2021-08-22 15:35:11 +02:00
bors
1eb187c16e Auto merge of #88139 - lcnr:marker-trait-attr, r=nikomatsakis
marker_traits: require `EvaluatedToOk` during winnowing

closes #84955, while it doesn't really fix it in a way that makes me happy it should prevent the issue for now and this
test can't be reproduced anyways, so it doesn't make much sense to keep it open.

fixes #84917 as only one of the impls depends on regions, so we now drop the ambiguous one instead of the correct one.

cc https://rust-lang.zulipchat.com/#narrow/stream/144729-wg-traits/topic/winnowing.20soundly/near/247899832

r? `@nikomatsakis`
2021-08-22 10:44:38 +00:00
bors
d3e2578c31 Auto merge of #88135 - crlf0710:trait_upcasting_part_3, r=nikomatsakis
Trait upcasting coercion (part 3)

By using separate candidates for each possible choice, this fixes type-checking issues in previous commits.

r? `@nikomatsakis`
2021-08-21 21:14:07 +00:00
bors
797095a686 Auto merge of #88149 - Mark-Simulacrum:prep-never-type, r=jackh726
Refactor fallback code to prepare for never type

This PR contains cherry-picks of some of `@nikomatsakis's` work from #79366, and shouldn't (AFAICT) represent any change in behavior. However, the refactoring is good regardless of the never type work being landed, and will reduce the size of those eventual PR(s) (and rebase pain).

I am not personally an expert on this code, and the commits are essentially 100% `@nikomatsakis's,` but they do seem reasonable to me by my understanding. Happy to edit with review, of course. Commits are best reviewed in sequence rather than all together.

r? `@jackh726` perhaps?
2021-08-21 01:29:12 +00:00
Anton Golov
b8fff95961 Require a box expression's type to be Sized 2021-08-20 16:25:52 +02:00
Niko Matsakis
947c0de028 introduce a Coerce predicate 2021-08-19 17:28:24 -04:00
Ellen
c2b61fbafe move code to InferCtxt method 2021-08-19 21:04:09 +01:00
Ellen
696c88d69c canonicalize const equate predicates 2021-08-19 19:47:38 +01:00
Charles Lew
c22dfab215 Add assertion to ensure the query doesn't get called before type infererence is done. 2021-08-20 02:37:00 +08:00
bors
3d0774d0dc Auto merge of #86700 - lqd:matthews-nll-hrtb-errors, r=nikomatsakis
Matthew's work on improving NLL's "higher-ranked subtype error"s

This PR rebases `@matthewjasper's` [branch](https://github.com/matthewjasper/rust/tree/nll-hrtb-errors) which has great work to fix the obscure higher-ranked subtype errors that are tracked in #57374.

These are a blocker to turning full NLLs on, and doing some internal cleanups to remove some of the old region code.

The goal is so `@nikomatsakis` can take a look at this early, and I'll then do my best to help do the changes and followup work to land this work, and move closer to turning off the migration mode.

I've only updated the branch and made it compile, removed a warning or two.

r? `@nikomatsakis`

(Here's the [zulip topic to discuss this](https://rust-lang.zulipchat.com/#narrow/stream/122657-t-compiler.2Fwg-nll/topic/.2357374.3A.20improving.20higher-ranked.20subtype.20errors.20via.20.2386700) that Niko wanted)
2021-08-18 15:54:59 +00:00
lcnr
3329f67f17 marker_traits: require EvaluatedToOk 2021-08-18 16:34:54 +02:00
Charles Lew
6b1c52ff25 Fold vtable_trait_upcasting_coercion_new_vptr_slot logic into obligation processing. 2021-08-18 13:00:27 +08:00
Charles Lew
1e605023ec Properly generate multiple candidates for trait upcasting coercion. 2021-08-18 13:00:27 +08:00
bors
aa8f27bf4d Auto merge of #87668 - estebank:tweak-bound-output, r=oli-obk
Use note for pointing at bound introducing requirement

Modify output for pointing where a trait bound obligation is introduced in an E0277 from using a span label to using a note in order to always preserve order of the output:

Before:
```
error[E0277]: `<<Self as Case1>::A as Iterator>::Item` doesn't implement `Debug`
  --> $DIR/bounds-on-assoc-in-trait.rs:18:28
   |
LL |     type A: Iterator<Item: Debug>;
   |                            ^^^^^ `<<Self as Case1>::A as Iterator>::Item` cannot be formatted using `{:?}` because it doesn't implement `Debug`
   |
  ::: $SRC_DIR/core/src/fmt/mod.rs:LL:COL
   |
LL | pub trait Debug {
   | --------------- required by this bound in `Debug`
   |
   = help: the trait `Debug` is not implemented for `<<Self as Case1>::A as Iterator>::Item`
```
After:
```
error[E0277]: `<<Self as Case1>::A as Iterator>::Item` doesn't implement `Debug`
  --> $DIR/bounds-on-assoc-in-trait.rs:18:28
   |
LL |     type A: Iterator<Item: Debug>;
   |                            ^^^^^ `<<Self as Case1>::A as Iterator>::Item` cannot be formatted using `{:?}` because it doesn't implement `Debug`
   |
   = help: the trait `Debug` is not implemented for `<<Self as Case1>::A as Iterator>::Item`
note: required by a bound in `Debug`
  --> $SRC_DIR/core/src/fmt/mod.rs:LL:COL
   |
LL | pub trait Debug {
   | ^^^^^^^^^^^^^^^ required by this bound in `Debug`
```
2021-08-17 06:59:49 +00:00
Esteban Küber
39f220ce12 Use note to point at bound introducing requirement 2021-08-16 17:47:22 +00:00
Matthew Jasper
4421dd17fa Return the canonicalized query from type ops 2021-08-15 08:44:36 +02:00
Deadbeef
f25d2bd53b
Assign FIXMEs to me and remove obsolete ones
Also fixed capitalization of documentation
2021-08-14 16:48:01 +00:00
Deadbeef
2931a9df2f
make check less conservative and add explanation 2021-08-13 09:28:52 +00:00
Deadbeef
869daad8fc
Fix tests 2021-08-13 09:28:51 +00:00
Deadbeef
bcf0e2f528
Fix assoc-type test 2021-08-13 09:28:50 +00:00
Deadbeef
01bb3710b5
Pass constness to SelectionContext 2021-08-13 09:28:50 +00:00
Deadbeef
3bab45d2ac
Make selection and evaluation caches use constness 2021-08-13 09:28:49 +00:00
Deadbeef
36ace4c0ad
fmt 2021-08-13 09:28:49 +00:00
Deadbeef
d356cd10f7
fmt 2021-08-13 09:26:34 +00:00
Deadbeef
4c8b6a20a9
Filter non-const impls when we expect a const one 2021-08-13 09:26:33 +00:00
Deadbeef
32390a0df6
move Constness into TraitPredicate 2021-08-13 09:26:33 +00:00
bors
d488de82f3 Auto merge of #87587 - oli-obk:lazy_tait, r=spastorino
Various refactorings of the TAIT infrastructure

Before this PR we used to store the opaque type knowledge outside the `InferCtxt`, so it got recomputed on every opaque type instantiation.

I also removed a feature gate check that makes no sense in the planned lazy TAIT resolution scheme

Each commit passes all tests, so this PR is best reviewed commit by commit.

r? `@spastorino`
2021-08-11 05:14:45 +00:00
Oli Scherer
93c4aa80b8 Don't collect into a Vec that is immediately being iterated on again. 2021-08-10 11:03:10 +00:00
Esteban Küber
f93cbedade Do not ICE on HIR based WF check when involving lifetimes
Fix #87549.
2021-08-09 07:01:35 +00:00
Oli Scherer
092e9ccd8a Point to the value instead of the TAIT declaration for obligation failures 2021-08-06 10:42:05 +00:00
Oli Scherer
b2c1919a3d Store the DefId of the currently typechecked item in InferCtxt
This allows opaque type inference to check for defining uses without having to pass down that def id via function arguments to every method that could possibly cause an opaque type to be compared with a concrete type
2021-08-06 10:39:23 +00:00
Oli Scherer
20371b94f6 Immediately register new opaque types in the global list.
Previously each opaque type instantiation would create new inference vars, even for the same opaque type/substs combination. Now there is a global map in InferCtxt that gets filled whenever we encounter an opaque type.
2021-08-06 10:39:08 +00:00
Oli Scherer
a30b548919 Split fold_opaque_ty 2021-08-06 10:23:11 +00:00
Oli Scherer
34182804e8 Move some code around in preparation of splitting a function 2021-08-06 10:21:01 +00:00
Oli Scherer
14021feea9 Remove a field that is computed later anyway 2021-08-06 10:18:31 +00:00
Oli Scherer
d99805982b Move opaque type cache into InferCtxt 2021-08-06 10:12:31 +00:00
bors
a6ece56152 Auto merge of #86400 - FabianWolff:issue-85735, r=estebank
Remove invalid suggestion involving `Fn` trait bound

This pull request closes #85735. The actual issue is a duplicate of #21974, but #85735 contains a further problem, which is an invalid suggestion if `Fn`/`FnMut`/`FnOnce` trait bounds are involved: The suggestion code checks whether the trait bound ends with `>` to determine whether it has any generic arguments, but the `Fn*` traits have a special syntax for generic arguments that doesn't involve angle brackets. The example given in #85735:
```rust
trait Foo {}
impl<'a, 'b, T> Foo for T
where
    T: FnMut(&'a ()),
    T: FnMut(&'b ()), {

    }
```
currently produces:
```
error[E0283]: type annotations needed
   --> src/lib.rs:4:8
    |
4   |       T: FnMut(&'a ()),
    |          ^^^^^^^^^^^^^ cannot infer type for type parameter `T`
    |
    = note: cannot satisfy `T: FnMut<(&'a (),)>`
help: consider specifying the type arguments in the function call
    |
4   |     T: FnMut(&'a ())::<Self, Args>,
    |                     ^^^^^^^^^^^^^^

error: aborting due to previous error
```
which is incorrect, because there is no function call, and applying the suggestion would lead to a parse error. With my changes, I get:
```
error[E0283]: type annotations needed
   --> test.rs:4:8
    |
4   |     T: FnMut(&'a ()),
    |        ^^^^^^^^^^^^^ cannot infer type for type parameter `T`
    |
   ::: [...]/library/core/src/ops/function.rs:147:1
    |
147 | pub trait FnMut<Args>: FnOnce<Args> {
    | ----------------------------------- required by this bound in `FnMut`
    |
    = note: cannot satisfy `T: FnMut<(&'a (),)>`

error: aborting due to previous error
```
i.e. I have added a check to prevent the invalid suggestion from being issued for `Fn*` bounds, while the underlying issue #21974 remains for now.
2021-08-03 19:48:54 +00:00
Fabian Wolff
f8c10ff8b7 Remove invalid suggestion involving Fn trait bound 2021-08-03 21:31:34 +02:00
bors
c6bc102fea Auto merge of #87515 - crlf0710:trait_upcasting_part2, r=bjorn3
Trait upcasting coercion (part2)

This is the second part of trait upcasting coercion implementation.

Currently this is blocked on #86264 .

The third part might be implemented using unsafety checking

r? `@bjorn3`
2021-08-03 16:58:56 +00:00
Yuki Okushi
14e92d7116
Do not suggest impl traits as type arguments 2021-08-03 20:05:50 +09:00
Charles Lew
63ed625313 Implement pointer casting. 2021-08-03 01:09:37 +08:00
bors
b53a93db2d Auto merge of #87535 - lf-:authors, r=Mark-Simulacrum
rfc3052 followup: Remove authors field from Cargo manifests

Since RFC 3052 soft deprecated the authors field, hiding it from
crates.io, docs.rs, and making Cargo not add it by default, and it is
not generally up to date/useful information for contributors, we may as well
remove it from crates in this repo.
2021-08-02 05:49:17 +00:00
bors
aadd6189ad Auto merge of #87449 - matthiaskrgr:clippyy_v2, r=nagisa
more clippy::complexity fixes

(also a couple of clippy::perf fixes)
2021-08-01 09:15:15 +00:00
bors
7069a8c2b7 Auto merge of #86264 - crlf0710:trait_upcasting_part1, r=nikomatsakis
Trait upcasting coercion (part1)

This revives the first part of earlier PR #60900 .

It's not very clear to me which parts of that pr was design decisions, so i decide to cut it into pieces and land them incrementally. This allows more eyes on the details.

This is the first part, it adds feature gates, adds feature gates tests, and implemented the unsize conversion part.
(I hope i have dealt with the `ExistentialTraitRef` values correctly...)

The next part will be implementing the pointer casting.
2021-07-31 07:46:14 +00:00
Charles Lew
fb4e0a0972 Implement trait upcasting coercion type-checking. 2021-07-31 00:51:39 +08:00
Esteban Küber
0b8f192cfe Use multispan suggestions more often
* Use more accurate span for `async move` suggestion
* Use more accurate span for deref suggestion
* Use `multipart_suggestion` more often
2021-07-30 09:26:31 -07:00
Jade
3cf820e17d rfc3052: Remove authors field from Cargo manifests
Since RFC 3052 soft deprecated the authors field anyway, hiding it from
crates.io, docs.rs, and making Cargo not add it by default, and it is
not generally up to date/useful information, we should remove it from
crates in this repo.
2021-07-29 14:56:05 -07:00
Fabian Wolff
dbd0fd2c2a Fix ICE in diagnostic_hir_wf_check 2021-07-28 01:41:52 +02:00