Commit graph

1569 commits

Author SHA1 Message Date
Esteban Kuber
446b46673d Point at bounds when comparing impl items to trait 2021-11-20 18:54:31 +00:00
Esteban Kuber
6b9d910639 Point at source of trait bound obligations in more places
Be more thorough in using `ItemObligation` and `BindingObligation` when
evaluating obligations so that we can point at trait bounds that
introduced unfulfilled obligations. We no longer incorrectly point at
unrelated trait bounds (`substs-ppaux.verbose.stderr`).

In particular, we now point at trait bounds on method calls.

We no longer point at "obvious" obligation sources (we no longer have a
note pointing at `Trait` saying "required by a bound in `Trait`", like
in `associated-types-no-suitable-supertrait*`).

Address part of #89418.
2021-11-20 18:54:31 +00:00
Matthias Krüger
7354bb331e
Rollup merge of #90575 - m-ou-se:compatible-variant-improvements, r=estebank
Improve suggestions for compatible variants on type mismatch.

Fixes #90553.

Before:
![image](https://user-images.githubusercontent.com/783247/140385675-6ff41090-eca2-41bc-b161-99c5dabfec61.png)

After:
![image](https://user-images.githubusercontent.com/783247/140385748-20cf26b5-ea96-4e56-8af2-5fe1ab16fd3b.png)

r? `````@estebank`````
2021-11-20 10:21:12 +01:00
bors
e8423e6c44 Auto merge of #91033 - JohnTitor:rollup-sr9zg6o, r=JohnTitor
Rollup of 8 pull requests

Successful merges:

 - #89258 (Make char conversion functions unstably const)
 - #90578 (add const generics test)
 - #90633 (Refactor single variant `Candidate` enum into a struct)
 - #90800 (bootstap: create .cargo/config only if not present)
 - #90942 (windows: Return the "Not Found" error when a path is empty)
 - #90947 (Move some tests to more reasonable directories - 9.5)
 - #90961 (Suggest removal of arguments for unit variant, not replacement)
 - #90990 (Arenas cleanup)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-11-19 06:13:29 +00:00
Yuki Okushi
c74ff8b563
Rollup merge of #90961 - estebank:suggest-removal-of-call, r=nagisa
Suggest removal of arguments for unit variant, not replacement
2021-11-19 13:06:37 +09:00
bors
ce3f3a5ffa Auto merge of #90329 - nbdd0121:typeck, r=nagisa
Try all stable method candidates first before trying unstable ones

Currently we try methods in this order in each step:
* Stable by value
* Unstable by value
* Stable autoref
* Unstable autoref
* ...

This PR changes it to first try pick methods without any unstable candidates, and if none is found, try again to pick unstable ones.

Fix #90320
CC #88971, hopefully would allow us to rename the "unstable_*" methods for integer impls back.

`@rustbot` label T-compiler T-libs-api
2021-11-19 03:00:46 +00:00
bors
cc946fcd32 Auto merge of #91019 - JohnTitor:rollup-q95ra7r, r=JohnTitor
Rollup of 8 pull requests

Successful merges:

 - #90386 (Add `-Zassert-incr-state` to assert state of incremental cache)
 - #90438 (Clean up mess for --show-coverage documentation)
 - #90480 (Mention `Vec::remove` in `Vec::swap_remove`'s docs)
 - #90607 (Make slice->str conversion and related functions `const`)
 - #90750 (rustdoc: Replace where-bounded Clean impl with simple function)
 - #90895 (require full validity when determining the discriminant of a value)
 - #90989 (Avoid suggesting literal formatting that turns into member access)
 - #91002 (rustc: Remove `#[rustc_synthetic]`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-11-18 20:23:26 +00:00
Yuki Okushi
08c1639fd9
Rollup merge of #91002 - petrochenkov:nosynth, r=davidtwco
rustc: Remove `#[rustc_synthetic]`

This function parameter attribute was introduced in https://github.com/rust-lang/rust/pull/44866 as an intermediate step in implementing `impl Trait`, it's not necessary or used anywhere by itself.

Noticed while reviewing https://github.com/rust-lang/rust/pull/90947.
2021-11-19 02:22:59 +09:00
Yuki Okushi
dfbbb3b900
Rollup merge of #90989 - notriddle:notriddle/rustc-suggest-float-ending-in-dot, r=sanxiyn
Avoid suggesting literal formatting that turns into member access

Fixes #90974
2021-11-19 02:22:59 +09:00
bors
b6f580acc0 Auto merge of #90382 - alexcrichton:wasm64-libstd, r=joshtriplett
std: Get the standard library compiling for wasm64

This commit goes through and updates various `#[cfg]` as appropriate to
get the wasm64-unknown-unknown target behaving similarly to the
wasm32-unknown-unknown target. Most of this is just updating various
conditions for `target_arch = "wasm32"` to also account for `target_arch
= "wasm64"` where appropriate. This commit also lists `wasm64` as an
allow-listed architecture to not have the `restricted_std` feature
enabled, enabling experimentation with `-Z build-std` externally.

The main goal of this commit is to enable playing around with
`wasm64-unknown-unknown` externally via `-Z build-std` in a way that's
similar to the `wasm32-unknown-unknown` target. These targets are
effectively the same and only differ in their pointer size, but wasm64
is much newer and has much less ecosystem/library support so it'll still
take time to get wasm64 fully-fledged.
2021-11-18 17:19:27 +00:00
Vadim Petrochenkov
91e02177a1 rustc: Remove #[rustc_synthetic]
This function parameter attribute was introduced in https://github.com/rust-lang/rust/pull/44866 as an intermediate step in implementing `impl Trait`, it's not necessary or used anywhere by itself.
2021-11-18 14:32:29 +08:00
Michael Howell
a7261c32f4 Avoid suggesting literal formatting that turns into member access
Fixes #90974
2021-11-17 17:23:15 -07:00
Matthias Krüger
469faa2b66
Rollup merge of #90901 - rukai:improve_manuallydrop_help, r=estebank
Improve ManuallyDrop suggestion

closes https://github.com/rust-lang/rust/issues/90585
* Fixes the recommended change to use ManuallyDrop as per the issue
* Changes the note to a help
* improves the span so it only points at the type.
2021-11-17 15:58:06 +01:00
Matthias Krüger
23ad7a7697
Rollup merge of #90884 - Nilstrieb:fix-span-trivial-trait-bound, r=estebank
Fix span for non-satisfied trivial trait bounds

The spans for "trait bound not satisfied" errors in trivial trait bounds referenced the entire item (fn, impl, struct) before.
Now they only reference the obligation itself (`String: Copy`)

Address #90869
2021-11-17 15:58:04 +01:00
Esteban Kuber
4ca4e094ab Suggest removal of arguments for unit variant, not replacement 2021-11-16 20:40:35 +00:00
Mara Bos
09e4a75f29 Use span_suggestions instead of multipart_suggestions. 2021-11-16 19:53:00 +01:00
Mara Bos
b331b66082 Improve compatible enum variant suggestions. 2021-11-16 19:52:58 +01:00
Mara Bos
453e2423e6 Improve suggestion for unit Option/Result at the end of a block. 2021-11-16 19:52:58 +01:00
Yuki Okushi
b17de50a41
Rollup merge of #90803 - TaKO8Ki:suggest-chars-on-attempt-to-iter, r=estebank
Suggest `&str.chars()` on attempt to `&str.iter()`

closes #90786
2021-11-16 15:59:39 +09:00
Taylor Yu
1a50725a4d refactor is_param_bound 2021-11-15 22:31:56 -06:00
bors
b053550847 Auto merge of #90827 - matthewjasper:assoc-item-cleanup-2, r=cjgillot
Assoc item cleanup Part 2

- Remove `AssocItem` from `RegionVariableOrigin::AutoRef`
- Use the `associated_item_def_ids` query instead of the `associated_items` query when possible

The change to `ObligationCauseCode` from #90639 is omitted because it caused a perf regression.

r? `@cjgillot`
2021-11-15 23:27:59 +00:00
bors
c26746af5a Auto merge of #90473 - joshtriplett:stabilize-format-args-capture, r=Mark-Simulacrum
stabilize format args capture

Works as expected, and there are widespread reports of success with it, as well as interest in it.

RFC: rust-lang/rfcs#2795
Tracking issue: https://github.com/rust-lang/rust/issues/67984

Addressing items from the tracking issue:

- We don't support capturing arguments from a non-literal format string like `format_args!(concat!(...))`. We could add that in a future enhancement, or we can decide that it isn't supported (as suggested in https://github.com/rust-lang/rust/issues/67984#issuecomment-801394736 ).
- I've updated the documentation.
- `panic!` now supports capture as well.
- There are potentially opportunities to further improve diagnostics for invalid usage, such as if it looks like the user tried to use an expression rather than a variable. However, such cases are all already caught and provide reasonable syntax errors now, and we can always provided even friendlier diagnostics in the future.
2021-11-15 16:10:19 +00:00
Josh Triplett
8c9bfaa5f3 Stabilize format_args_capture
Works as expected, and there are widespread reports of success with it,
as well as interest in it.
2021-11-15 10:14:29 +01:00
bors
d5a0c7cb03 Auto merge of #90645 - terrarier2111:master, r=estebank
Implement diagnostic for String conversion

This is my first real contribution to rustc, any feedback is highly appreciated.
This should fix https://github.com/rust-lang/rust/issues/89856

Thanks to `@estebank` for guiding me.
2021-11-15 06:55:01 +00:00
Lucas Kent
62acf7f96d feedback 2021-11-15 14:51:56 +11:00
Takayuki Maeda
d562f487c9 suggest &str.chars() on attempt to &str.iter()
check if `String` or `&String` or `&str`

Update compiler/rustc_typeck/src/check/method/suggest.rs

Co-authored-by: Esteban Kuber <estebank@users.noreply.github.com>

remove some trailing whitespace
2021-11-15 12:37:01 +09:00
Gary Guo
6a207f23eb Try all stable candidates first before trying unstable ones 2021-11-15 02:14:54 +00:00
Gary Guo
9740050726 Add self ty to pick 2021-11-15 01:28:30 +00:00
Lucas Kent
f980f813e1 Improve ManuallyDrop suggestion 2021-11-15 00:04:34 +11:00
Nilstrieb
24acf86029 Fix span for non-satisfied trivial trait bounds
The spans for "trait bound not satisfied" errors in trivial trait bounds referenced the entire item (fn, impl, struct) before.
Now they only reference the obligation itself (`String: Copy`)

Address #90869
2021-11-14 11:38:52 +01:00
Matthias Krüger
e273fab434
Rollup merge of #90840 - BoxyUwU:lolripme, r=jackh726
relate lifetime in `TypeOutlives` bounds on drop impls

Fixes #90838
2021-11-13 22:35:04 +01:00
Matthias Krüger
b35af0d04d
Rollup merge of #90771 - asterycs:fix/trait-object-error-code, r=michaelwoerister
Fix trait object error code

closes #90768

I `grep`:d and changed the occurrences that seemed relevant. Please let me know what you think and if anything is missing!
2021-11-13 22:35:03 +01:00
threadexception
829a5288ec Implement diagnostic for String conversion
Co-authored-by: Esteban Kuber <estebank@users.noreply.github.com>
2021-11-13 15:17:44 +01:00
Ellen
875024ca6b oops... 2021-11-12 20:50:25 +00:00
Matthew Jasper
ba518ffdd3 Use associated_item_def_ids more 2021-11-11 23:15:57 +00:00
Matthew Jasper
3ea84e879a Remove unused field of RegionVariableOrigin 2021-11-11 23:15:47 +00:00
bors
3d29b68077 Auto merge of #90648 - matthewjasper:assoc-item-cleanup, r=cjgillot
Assoc item cleanup

This removes some fields from ObligationCauseCode

Split out of #90639
2021-11-11 15:15:15 +00:00
bors
1d34cb4efc Auto merge of #89550 - lcnr:coherence-specialization, r=nikomatsakis
do not emit overlap errors for impls failing the orphan check

this should finally allow us to merge #86986, see https://github.com/rust-lang/rust/pull/86986#discussion_r716059345 for more details.

r? `@nikomatsakis` cc `@eddyb`
2021-11-11 05:47:37 +00:00
Jimmy Envall
fc9624c673 Fix trait object error code 2021-11-10 18:49:30 +01:00
Alex Crichton
a3b9405ae7 Use more robust checks in rustc for wasm 2021-11-10 08:35:42 -08:00
Alex Crichton
d2a3c24a95 Update more rustc/libtest things for wasm64
* Add wasm64 variants for inline assembly along the same lines as wasm32
* Update a few directives in libtest to check for `target_family`
  instead of `target_arch`
* Update some rustc codegen and typechecks specialized for wasm32 to
  also work for wasm64.
2021-11-10 08:35:42 -08:00
lcnr
1296719c06 no overlap errors after failing the orphan check 2021-11-10 15:10:19 +01:00
inquisitivecrystal
9a987b0466 Add ty::Visibility::is_public() 2021-11-09 18:35:00 -08:00
Matthias Krüger
610b4e503c
Rollup merge of #90035 - SparrowLii:rfc2528, r=jackh726
implement rfc-2528 type_changing-struct-update

This PR implement rfc2528-type_changing-struct-update.
The main change process is as follows:
1. Move the processing part of `base_expr` into `check_expr_struct_fields` to avoid returning `remaining_fields` (a relatively complex hash table)
2. Before performing the type consistency check(`check_expr_has_type_or_error`), if the `type_changing_struct_update` feature is set, enter a different processing flow, otherwise keep the original flow
3. In the case of the same structure definition, check each field in `remaining_fields`. If the field in `base_expr` is not the suptype of the field in `adt_ty`, an error(`FeildMisMatch`) will be reported.

The MIR part does not need to be changed, because only the items contained in `remaining_fields` will be extracted from `base_expr` when MIR is generated. This means that fields with different types in `base_expr` will not be used
Updates #86618
cc `@nikomatsakis`
2021-11-09 19:00:41 +01:00
Matthias Krüger
fd74c93403
Rollup merge of #89561 - nbdd0121:const_typeck, r=nikomatsakis
Type inference for inline consts

Fixes #78132
Fixes #78174
Fixes #81857
Fixes #89964

Perform type checking/inference of inline consts in the same context as the outer def, similar to what is currently done to closure.

Doing so would require `closure_base_def_id` of the inline const to return the outer def, and since `closure_base_def_id` can be called on non-local crate (and thus have no HIR available), a new `DefKind` is created for inline consts.

The type of the generated anon const can capture lifetime of outer def, so we couldn't just use the typeck result as the type of the inline const's def. Closure has a similar issue, and it uses extra type params `CK, CS, U` to capture closure kind, input/output signature and upvars. I use a similar approach for inline consts, letting it have an extra type param `R`, and then `typeof(InlineConst<[paremt generics], R>)` would just be `R`. In borrowck region requirements are also propagated to the outer MIR body just like it's currently done for closure.

With this PR, inline consts in expression position are quitely usable now; however the usage in pattern position is still incomplete -- since those does not remain in the MIR borrowck couldn't verify the lifetime there. I have left an ignored test as a FIXME.

Some disucssions can be found on [this Zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/260443-project-const-generics/topic/inline.20consts.20typeck).
cc `````@spastorino````` `````@lcnr`````
r? `````@nikomatsakis`````

`````@rustbot````` label A-inference F-inline_const T-compiler
2021-11-09 19:00:40 +01:00
bors
07acdb48a0 Auto merge of #90724 - JohnTitor:rollup-zg0kbm3, r=JohnTitor
Rollup of 6 pull requests

Successful merges:

 - #87530 (Add comments regarding superfluous `!Sync` impls)
 - #90591 (treat illumos like solaris in failing ui tests which need it)
 - #90678 (Add some GATs-related regression tests)
 - #90688 (enable `dotprod` target feature in arm)
 - #90708 (Add a note about feature(explicit_generic_args_with_impl_trait) to the relevant error message)
 - #90720 (Update cargo)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-11-09 14:12:54 +00:00
Yuki Okushi
f1fef6be7f
Rollup merge of #90708 - NieDzejkob:feature-note, r=jackh726
Add a note about feature(explicit_generic_args_with_impl_trait) to the relevant error message

Fixes #90615
2021-11-09 22:02:25 +09:00
bors
eee8b9c7ba Auto merge of #90700 - fee1-dead:select-returns-vec, r=davidtwco
Make `select_*` methods return `Vec` for `TraitEngine`

This reduces some complexity as an empty vec means no errors and non-empty vec means errors occurred.
2021-11-09 11:16:38 +00:00
Jakub Kądziołka
048e1c942d
Add a note about feature(explicit_generic_args_with_impl_trait) to the relevant error message 2021-11-08 19:49:41 +01:00
Deadbeef
d863021521
fmt 2021-11-08 23:55:51 +08:00