Matthias Krüger
611bbcb044
clippy::perf fixes
2022-07-20 11:48:11 +02:00
bors
9a7b7d5e50
Auto merge of #98180 - notriddle:notriddle/rustdoc-fn, r=petrochenkov,GuillaumeGomez
...
Improve the function pointer docs
This is #97842 but for function pointers instead of tuples. The concept is basically the same.
* Reduce duplicate impls; show `fn (T₁, T₂, …, Tₙ)` and include a sentence saying that there exists up to twelve of them.
* Show `Copy` and `Clone`.
* Show auto traits like `Send` and `Sync`, and blanket impls like `Any`.
https://notriddle.com/notriddle-rustdoc-test/std/primitive.fn.html
2022-07-19 19:36:57 +00:00
Michael Howell
5271e32c46
Improve the function pointer docs
...
* Reduce duplicate impls; show only the `fn (T)` and include a sentence
saying that there exists up to twelve of them.
* Show `Copy` and `Clone`.
* Show auto traits like `Send` and `Sync`, and blanket impls like `Any`.
2022-07-19 08:52:24 -07:00
Matthias Krüger
e6a100baa2
Rollup merge of #99438 - WaffleLapkin:dont_wrap_in_non_zero, r=compiler-errors
...
Improve suggestions for `NonZeroT` <- `T` coercion error
Currently, when encountering a type mismatch error with `NonZeroT` and `T` (for example `NonZeroU8` and `u8`) we errorneusly suggest wrapping expression in `NonZeroT`:
```text
error[E0308]: mismatched types
--> ./t.rs:7:35
|
7 | let _: std::num::NonZeroU64 = 1;
| -------------------- ^ expected struct `NonZeroU64`, found integer
| |
| expected due to this
|
help: try wrapping the expression in `std::num::NonZeroU64`
|
7 | let _: std::num::NonZeroU64 = std::num::NonZeroU64(1);
| +++++++++++++++++++++ +
```
I've removed this suggestion and added suggestions to call `new` (for `Option<NonZeroT>` <- `T` case) or `new` and `unwrap` (for `NonZeroT` <- `T` case):
```text
error[E0308]: mismatched types
--> ./t.rs:7:35
|
7 | let _: std::num::NonZeroU64 = 1;
| -------------------- ^ expected struct `NonZeroU64`, found integer
| |
| expected due to this
|
help: Consider calling `NonZeroU64::new`
|
7 | let _: std::num::NonZeroU64 = NonZeroU64::new(1).unwrap();
| ++++++++++++++++ ++++++++++
error[E0308]: mismatched types
--> ./t.rs:8:43
|
8 | let _: Option<std::num::NonZeroU64> = 1;
| ---------------------------- ^ expected enum `Option`, found integer
| |
| expected due to this
|
= note: expected enum `Option<NonZeroU64>`
found type `{integer}`
help: Consider calling `NonZeroU64::new`
|
8 | let _: Option<std::num::NonZeroU64> = NonZeroU64::new(1);
| ++++++++++++++++ +
```
r? `@compiler-errors`
2022-07-19 13:30:49 +02:00
Matthias Krüger
4815f94c51
Rollup merge of #99401 - TaKO8Ki:avoid-symbol-to-&str-conversions, r=nnethercote
...
Avoid `Symbol` to `&str` conversions
`Symbol::as_str` is a slowish operation, so this patch removes some usages of it.
2022-07-19 13:30:46 +02:00
Michael Goulet
136f017258
Use LocalDefId in OpaqueTypeKey
2022-07-19 02:08:49 +00:00
Maybe Waffle
5bd88dfa8a
Add a note about privacy to wrapping suggestion
2022-07-19 02:33:36 +04:00
Maybe Waffle
2edad7d77c
Apply suggestions from the review
...
- Use `expr.hir_id.owner` instead of `self.tcx.parent_module(expr.hir_id)`
- Use `.type_at()` instead of `.first()` + `.expect_ty()`
- Use single `.find()` with `&&` condition
Co-authored-by: Michael Goulet <michael@errs.io>
2022-07-19 02:15:56 +04:00
Maybe Waffle
da2752e00f
check accessibility before suggesting wrapping expressions
2022-07-19 01:16:25 +04:00
Maybe Waffle
7163e7ff65
Suggest a fix for NonZero*
<- *
coercion error
2022-07-19 00:13:29 +04:00
Maybe Waffle
37c21d6fc7
Do not suggest "wrapping the expression in std::num::NonZeroU64
"
2022-07-18 21:55:47 +04:00
Dylan DPC
60c1068c92
Rollup merge of #99351 - compiler-errors:arg-mismatch-blame, r=davidtwco
...
Use `typeck_results` to get accurate qpath res for arg mismatch error
Improves error message from "function" to actually what we're calling (e.g. enum variant constrcutor) in a few cases 😸
2022-07-18 21:14:47 +05:30
Takayuki Maeda
a22934bea1
avoid Symbol
to &str
conversions
2022-07-18 14:25:34 +09:00
Yuki Okushi
3c2175b8a2
Rollup merge of #99356 - compiler-errors:tait-in-assoc-ty-supertraits, r=oli-obk
...
Do not constraint TAITs when checking impl/trait item compatibility
Check out the UI test for the example.
Open to other approaches to fix this issue -- ideally we _would_ be able to collect this opaque type constraint in a way to use it in `find_opaque_ty_constraints`, so we can report a better mismatch error in the incompatible case, and just allow it in the compatible case. But that seems like a bigger refactor, so I wouldn't want to start it unless someone else thought it was a good idea.
cc #99348
r? ``@oli-obk``
2022-07-18 08:39:59 +09:00
Yuki Okushi
cc35c787aa
Rollup merge of #99350 - compiler-errors:issue-99240, r=fee1-dead
...
Be more precise when suggesting removal of parens on unit ctor
* Fixes #99240 by only suggesting to remove parens on path exprs, not arbitrary expressions with enum type
* Generalizes by suggesting removal of parens on unit struct, too, because why not?
2022-07-18 08:39:58 +09:00
Michael Goulet
7a45a60418
use rustc_hir_pretty::qpath_to_string to avoid span_to_snippet when rendering path
2022-07-17 04:58:38 +00:00
Michael Goulet
23cb89ea38
Do not constraint TAITs when checking impl/trait item compatibility
2022-07-16 18:36:08 -07:00
Caio
3266460749
Stabilize let_chains
2022-07-16 20:17:58 -03:00
Michael Goulet
75a1b1cf06
Use typeck_results to get accurate qpath res for arg mismatch error
2022-07-16 22:29:52 +00:00
Michael Goulet
04c590b7ef
Be more precise when suggesting removal of parens on unit adt ctor
2022-07-16 22:15:41 +00:00
Matthias Krüger
6277ac2fb8
Rollup merge of #99342 - TaKO8Ki:avoid-symbol-to-string-conversions, r=compiler-errors
...
Avoid some `Symbol` to `String` conversions
This patch removes some Symbol to String conversions.
2022-07-16 22:30:56 +02:00
Matthias Krüger
4805c215c8
Rollup merge of #99316 - tshepang:clearer, r=compiler-errors
...
docs: add missing word
2022-07-16 22:30:53 +02:00
Takayuki Maeda
c54d4ada26
avoid some Symbol
to String
conversions
2022-07-17 04:09:20 +09:00
Tshepang Mbambo
653a214632
docs: add missing word
2022-07-16 12:11:43 +02:00
Will Crichton
e5bb7d80d6
Propagate Expectation around binop typeck code to construct more precise trait obligations for binops.
2022-07-15 18:06:18 -07:00
lcnr
16b2acc7c0
hir typeck: fulfillment_cx
ignore regions
2022-07-15 17:01:32 +02:00
lcnr
5bd8c960f5
provide generic_param_scope
for region errors
2022-07-15 16:53:20 +02:00
lcnr
b955fa7dd0
don't require FnCtxt
to check global asm
2022-07-15 16:53:20 +02:00
lcnr
4b56fd9341
try to avoid FnCtxt
during wf
2022-07-15 16:53:18 +02:00
lcnr
29d0390b97
remove unnecessary select_obligations_where_possible
...
this was previously used for opaque types but became unnecessary
after #89024
2022-07-15 16:40:39 +02:00
lcnr
2b730a3610
remove impl_implied_bounds
from FnCtxt
2022-07-15 16:40:39 +02:00
Dylan DPC
24f0e1499e
Rollup merge of #99119 - TaKO8Ki:remove-string-matching-about-methods, r=cjgillot
...
Refactor: remove a string matching about methods
This patch remove a string matching about methods and adds some rustfix tests.
2022-07-15 15:53:38 +05:30
Dylan DPC
e0e6f1d1cb
Rollup merge of #98869 - compiler-errors:stop_guessing_head_span, r=cjgillot
...
Remove some usages of `guess_head_span`
No need to pass things through `guess_head_span` if they already point to the head span.
Only major change is that we point to the head span of `enum`s on some errors now, which I prefer.
r? `@cjgillot`
2022-07-15 15:53:37 +05:30
Takayuki Maeda
45b88aff10
simplify suggest_deref_ref_or_into
2022-07-15 14:29:15 +09:00
Michael Goulet
fcfb3e92a0
Remove some more usages of guess_head_span
2022-07-15 05:23:47 +00:00
Michael Goulet
4b890f3474
Remove some span_of_impl+unwrap
2022-07-15 03:17:21 +00:00
Michael Goulet
03bfbe1fb3
Move item_span from check_item_type into each function
2022-07-15 03:17:21 +00:00
Michael Goulet
78efaf43e4
remove tcx from ObligationCauseCode::span
2022-07-15 03:17:20 +00:00
Michael Goulet
57f7618f62
Remove some usages of guess_head_span from typeck
2022-07-15 03:17:20 +00:00
Michael Goulet
aad2334ecb
Make item spans more consistent
2022-07-15 03:17:20 +00:00
Michael Goulet
d25abdc0c5
Point out custom Fn-family trait impl
2022-07-14 23:36:46 +00:00
Michael Goulet
ddb7003b79
Add support for APIT and RPIT callables in label_fn_like
2022-07-14 23:29:03 +00:00
bors
24699bcbad
Auto merge of #95956 - yaahc:stable-in-unstable, r=cjgillot
...
Support unstable moves via stable in unstable items
part of https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/moving.20items.20to.20core.20unstably and a blocker of https://github.com/rust-lang/rust/pull/90328 .
The libs-api team needs the ability to move an already stable item to a new location unstably, in this case for Error in core. Otherwise these changes are insta-stable making them much harder to merge.
This PR attempts to solve the problem by checking the stability of path segments as well as the last item in the path itself, which is currently the only thing checked.
2022-07-14 13:42:09 +00:00
bors
f1a8854f9b
Auto merge of #99231 - Dylan-DPC:rollup-0tl8c0o, r=Dylan-DPC
...
Rollup of 5 pull requests
Successful merges:
- #97720 (Always create elided lifetime parameters for functions)
- #98315 (Stabilize `core::ffi:c_*` and rexport in `std::ffi`)
- #98705 (Implement `for<>` lifetime binder for closures)
- #99126 (remove allow(rustc::potential_query_instability) in rustc_span)
- #99139 (Give a better error when `x dist` fails for an optional tool)
Failed merges:
r? `@ghost`
`@rustbot` modify labels: rollup
2022-07-14 11:00:30 +00:00
Dylan DPC
e5a86d7358
Rollup merge of #98705 - WaffleLapkin:closure_binder, r=cjgillot
...
Implement `for<>` lifetime binder for closures
This PR implements RFC 3216 ([TI](https://github.com/rust-lang/rust/issues/97362 )) and allows code like the following:
```rust
let _f = for<'a, 'b> |a: &'a A, b: &'b B| -> &'b C { b.c(a) };
// ^^^^^^^^^^^--- new!
```
cc ``@Aaron1011`` ``@cjgillot``
2022-07-14 14:14:21 +05:30
bors
0ed9c64c3e
Auto merge of #98975 - jyn514:unstable_opts, r=wesleywiser
...
Rename `debugging_opts` to `unstable_opts`
This is no longer used only for debugging options (e.g. `-Zoutput-width`, `-Zallow-features`).
Rename it to be more clear.
cc https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Codegen.20options.20.2F.20debugging.20options
r? `@Amanieu` cc `@nikic` `@joshtriplett`
2022-07-14 08:14:31 +00:00
bors
8a392a5992
Auto merge of #98754 - jyn514:non-trivial-drop, r=compiler-errors
...
Fix drop-tracking ICE when a struct containing a field with a significant drop is used across an await
Previously, drop-tracking would incorrectly assume the struct would be dropped immediately, which was not true.
Fixes #98476 . Also fixes https://github.com/rust-lang/rust/issues/98477 , I think because the parent HIR node for type variables is the whole function instead of the expression where the variable is used.
r? `@eholk`
2022-07-14 02:22:48 +00:00
Joshua Nelson
3c9765cff1
Rename debugging_opts
to unstable_opts
...
This is no longer used only for debugging options (e.g. `-Zoutput-width`, `-Zallow-features`).
Rename it to be more clear.
2022-07-13 17:47:06 -05:00
Ralf Jung
07fe9882cc
add array tests, cleanup, tidy, and bless
2022-07-13 18:31:29 -04:00
Ralf Jung
5bf6017b87
remove untagged_union feature gate
2022-07-13 18:27:28 -04:00