Commit Graph

21146 Commits

Author SHA1 Message Date
Matthias Krüger
d26e07b91a
Rollup merge of #106747 - yanchen4791:issue-105507-fix, r=estebank
Add 'static lifetime suggestion when GAT implied 'static requirement from HRTB

Fix for issue #105507

The problem:
When generic associated types (GATs) are from higher-ranked trait bounds (HRTB), they are implied 'static requirement (see
[Implied 'static requirement from higher-ranked trait bounds](https://blog.rust-lang.org/2022/10/28/gats-stabilization.html#implied-static-requirement-from-higher-ranked-trait-bounds) for more details). If the user did not explicitly specify the `'static` lifetime when using the GAT, the current error message will only point out the type `does not live long enough` where the type is used, but not where the GAT is specified and how to fix the problem.

The solution:
Add notes at the span where the problematic GATs are specified and suggestions of how to fix the problem by adding `'static` lifetime at the right spans.
2023-01-18 06:59:20 +01:00
Boxy
1171fe5c45 i am free 2023-01-18 04:45:43 +00:00
Boxy
a2a50f96f3 actually print out non local anon consts 2023-01-18 04:07:39 +00:00
Boxy
4ca5368a12 defer array len printing to const arg printing 2023-01-18 04:07:39 +00:00
Ezra Shaw
b73cdf1b29
special case removing & suggestion 2023-01-18 13:14:56 +13:00
Tomasz Miąsko
7fe68571fa Lazy dominator tree construction in borrowck
Motivated by the observation that sometimes constructed dominator tree
was never queried.
2023-01-17 22:00:41 +01:00
bors
edefa4189f Auto merge of #106998 - matthiaskrgr:rollup-hmfisji, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #104505 (Remove double spaces after dots in comments)
 - #106784 (prevent E0512 from emitting [type error] by checking the references_error)
 - #106834 (new trait solver: only consider goal changed if response is not identity)
 - #106889 (Mention the lack of `windows_mut` in `windows`)
 - #106963 (Use `scope_expr_id` from `ProbeCtxt`)
 - #106970 (Switch to `EarlyBinder` for `item_bounds` query)
 - #106980 (Hide `_use_mk_alias_ty_instead` in `<AliasTy as Debug>::fmt`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-01-17 20:53:05 +00:00
yanchen4791
aadd58ef7a Add 'static lifetime suggestion when GAT implied 'static requirement from HRTB 2023-01-17 11:52:45 -08:00
Matthias Krüger
48bd3ab81d
Rollup merge of #106980 - Nilstrieb:_use_mk_manual_debug_impl_instead, r=lcnr
Hide `_use_mk_alias_ty_instead` in `<AliasTy as Debug>::fmt`
2023-01-17 20:21:28 +01:00
Matthias Krüger
3d7677d91a
Rollup merge of #106970 - kylematsuda:earlybinder-item-bounds, r=lcnr
Switch to `EarlyBinder` for `item_bounds` query

Part of the work to finish #105779 (also see https://github.com/rust-lang/types-team/issues/78).

Several queries `X` have a `bound_X` variant that wraps the output in `EarlyBinder`. This adds `EarlyBinder` to the return type of the `item_bounds` query and removes `bound_item_bounds`.

r? `@lcnr`
2023-01-17 20:21:28 +01:00
Matthias Krüger
28081833c6
Rollup merge of #106963 - compiler-errors:scope-expr-dupe, r=michaelwoerister
Use `scope_expr_id` from `ProbeCtxt`

We already store it in the `ProbeCtxt`, so just retrieve it from there.
2023-01-17 20:21:27 +01:00
Matthias Krüger
fc9e2c1081
Rollup merge of #106834 - compiler-errors:new-solver-did-changed, r=lcnr
new trait solver: only consider goal changed if response is not identity

I think this is the right way of implementing it..

r? `@lcnr`
2023-01-17 20:21:26 +01:00
Matthias Krüger
4ee5e09e19
Rollup merge of #106784 - lyming2007:issue-106695-fix, r=WaffleLapkin
prevent E0512 from emitting [type error] by checking the references_error

but still emit E0512
this will fix #106695
2023-01-17 20:21:26 +01:00
Matthias Krüger
68f12338af
Rollup merge of #104505 - WaffleLapkin:no-double-spaces-in-comments, r=jackh726
Remove double spaces after dots in comments

Most of the comments do not have double spaces, so I assume these are typos.
2023-01-17 20:21:25 +01:00
Michael Goulet
148e4f73dc new trait solver: only consider goal changed if response is not identity 2023-01-17 17:40:38 +00:00
bors
3984bc5833 Auto merge of #106294 - Nilstrieb:noundef-everything, r=nikic
Put `noundef` on all scalars that don't allow uninit

Previously, it was only put on scalars with range validity invariants like bool, was uninit was obviously invalid for those.

Since then, we have normatively declared all uninit primitives to be undefined behavior and can therefore put `noundef` on them.

The remaining concern was the `mem::uninitialized` function, which cause quite a lot of UB in the older parts of the ecosystem. After #99182, this function now doesn't return uninit values anymore, making users of it safe from this change.

The only real sources of UB where people could encounter uninit primitives are `MaybeUninit::uninit().assume_init()`, which has always be clear in the docs about being UB and from heap allocations (like reading from the spare capacity of a vec). This is hopefully rare enough to not break anything.

cc `@nagisa` `@scottmcm` `@nikic`
2023-01-17 17:39:48 +00:00
Yiming Lei
d1478a5600 delay E0512 as a bug by checking the references_error
fix #106695
2023-01-17 09:20:15 -08:00
Kyle Matsuda
fc942eed7f change item_bounds query to return EarlyBinder; remove bound_item_bounds query 2023-01-17 08:55:28 -07:00
Dylan DPC
e6e7c3990e
Rollup merge of #106962 - compiler-errors:use-sugg-span, r=oli-obk
Fix use suggestion span

Fixes #106954
2023-01-17 20:33:05 +05:30
Dylan DPC
26c0a38994
Rollup merge of #106951 - tmiasko:rm-simplify-initial, r=oli-obk
Remove ineffective run of SimplifyConstCondition

There are no constant conditions at this stage.
2023-01-17 20:33:05 +05:30
Dylan DPC
f91f369949
Rollup merge of #106148 - chenyukang:yukang/fix-105061-unused, r=lcnr
Fix unused_parens issue for higher ranked function pointers

fixes #105061

r? `@lcnr`
2023-01-17 20:33:03 +05:30
nils
cb00bc035b Hide _use_mk_alias_ty_instead in <AliasTy as Debug>::fmt 2023-01-17 15:04:05 +01:00
nils
b7cb77fed9 Document how to get the type of a default associated type 2023-01-17 14:01:29 +01:00
bors
f34cc658eb Auto merge of #106612 - JakobDegen:cleanup-wf, r=tmiasko
Document wf constraints on control flow in cleanup blocks

Was recently made aware of [this code](a377893da2/compiler/rustc_codegen_ssa/src/mir/analyze.rs (L247-L368)), which has this potential ICE: a377893da2/compiler/rustc_codegen_ssa/src/mir/analyze.rs (L308-L314)

Roughly speaking, the code there is attempting to partition the cleanup blocks into funclets that satisfy a "unique successor" property, and the ICE is set off if that's not possible. This PR documents the well-formedness constraints that MIR must satisfy to avoid setting off that ICE.

The constraints documented are slightly stronger than the cases in which the ICE would have been set off in that code. This is necessary though, since whether or not that ICE gets set off can depend on iteration order in some graphs.

This sort of constraint is kind of ugly, but I don't know a better alternative at the moment. It's worth knowing that two important optimizations are still correct:
 - Removing edges in the cfg: Fewer edges => fewer paths => stronger dominance relations => more contractions, and more contractions can't turn a forest into not-a-forest.
 - Contracting an edge u -> v when u only has one successor and v only has one predecessor: u already dominated v, so this contraction was going to happen anyway.

There is definitely a MIR opt somewhere that can run afoul of this, but I don't know where it is. `@saethlin` was able to set it off though, so maybe he'll be able to shed some light on it.

r? `@RalfJung` I suppose, and cc `@tmiasko` who might have insight/opinions on this
2023-01-17 11:34:35 +00:00
Maybe Waffle
6a28fb42a8 Remove double spaces after dots in comments 2023-01-17 08:09:33 +00:00
Maybe Waffle
4a6d9de828 Untouch back perf sensetive code 😅 2023-01-17 07:48:20 +00:00
Maybe Waffle
c21b1f742e Self review suggestions
- add back accidentally removed new lines
- try to deref in patterns, rather than in expressions
  (maybe this was the reason of perf regression?...)
2023-01-17 07:48:20 +00:00
Maybe Waffle
8d3c90ae13 Review suggestions 2023-01-17 07:48:20 +00:00
Maybe Waffle
98f30e833a Undo questionable changes 2023-01-17 07:48:19 +00:00
Waffle Maybe
66751ea73e tidy
rustfmt, pleaaaaase, start supporting rust

Co-authored-by: nils <48135649+Nilstrieb@users.noreply.github.com>
2023-01-17 07:48:19 +00:00
Maybe Waffle
09485eaae1 rustc_hir_analysis: remove ref patterns 2023-01-17 07:48:19 +00:00
Maybe Waffle
d60e772e14 rustc_hir_analysis: some general code improvements 2023-01-17 07:48:19 +00:00
Maybe Waffle
360e978437 Don't call closures immediately, use try{} blocks 2023-01-17 07:48:19 +00:00
Maybe Waffle
bddbf38af2 rustc_expand: remove ref patterns 2023-01-17 07:48:19 +00:00
Maybe Waffle
fc6cda8603 rustc_data_structures: remove ref patterns and other artifacts of the past 2023-01-17 07:48:19 +00:00
Maybe Waffle
3dca58e249 rustc_const_eval: remove ref patterns (+some pattern matching imps) 2023-01-17 07:48:19 +00:00
bors
159ba8a92c Auto merge of #106627 - Ezrashaw:no-e0711-without-staged-api, r=Mark-Simulacrum
fix: don't emit `E0711` if `staged_api` not enabled

Fixes #106589

Simple fix, added UI test.

As an aside, it seems a lot of features are susceptible to this, `E0711` stands out to me because it's perma-unstable and we are effectively exposing an implementation detail.
2023-01-17 07:20:32 +00:00
Nilstrieb
af23ad93cd Improve comments 2023-01-17 08:14:35 +01:00
Nilstrieb
645c0fddd2 Put noundef on all scalars that don't allow uninit
Previously, it was only put on scalars with range validity invariants
like bool, was uninit was obviously invalid for those.

Since then, we have normatively declared all uninit primitives to be
undefined behavior and can therefore put `noundef` on them.

The remaining concern was the `mem::uninitialized` function, which cause
quite a lot of UB in the older parts of the ecosystem. This function now
doesn't return uninit values anymore, making users of it safe from this
change.

The only real sources of UB where people could encounter uninit
primitives are `MaybeUninit::uninit().assume_init()`, which has always
be clear in the docs about being UB and from heap allocations (like
reading from the spare capacity of a vec. This is hopefully rare enough
to not break anything.
2023-01-17 08:14:35 +01:00
Matthias Krüger
5162e39bff
Rollup merge of #106953 - kylematsuda:early-binder-docs, r=jackh726
Document `EarlyBinder::subst_identity` and `skip_binder`

Finishing implementing #105779 will change several commonly used queries to return `EarlyBinder` by default. This PR adds documentation for two of the methods used to access data inside the `EarlyBinder`. I tried to summarize some of the [discussion from the issue](https://github.com/rust-lang/rust/issues/105779#issuecomment-1375512647) in writing this.

r? `@lcnr`
2023-01-17 05:25:23 +01:00
Matthias Krüger
9bcc46ee90
Rollup merge of #106949 - compiler-errors:is-poly, r=BoxyUwU
ConstBlocks are poly if their substs are poly

r? `@BoxyUwU`

fixes #106926
2023-01-17 05:25:23 +01:00
Matthias Krüger
6b49435480
Rollup merge of #106829 - compiler-errors:more-alias-combine, r=spastorino
Unify `Opaque`/`Projection` handling in region outlives code

They share basically identical paths in most places which are even easier to unify now that they're both `ty::Alias`

r? types
2023-01-17 05:25:22 +01:00
Matthias Krüger
9cda9e0ab6
Rollup merge of #106712 - Ezrashaw:impl-ref-trait, r=estebank
make error emitted on `impl &Trait` nicer

Fixes #106694

Turned out to be simpler than I thought, also added UI test.

Before: ([playground](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=9bda53271ef3a8886793cf427b8cea91))
```text
error: expected one of `:`, ``@`,` or `|`, found `)`
 --> src/main.rs:2:22
  |
2 | fn foo(_: impl &Trait) {}
  |                      ^ expected one of `:`, ``@`,` or `|`
  |
  = note: anonymous parameters are removed in the 2018 edition (see RFC 1685)
help: if this is a parameter name, give it a type
  |
2 | fn foo(_: impl Trait: &TypeName) {}
  |                ~~~~~~~~~~~~~~~~
help: if this is a type, explicitly ignore the parameter name
  |
2 | fn foo(_: impl _: &Trait) {}
  |                ++

error: expected one of `!`, `(`, `)`, `,`, `?`, `for`, `~`, lifetime, or path, found `&`
 --> src/main.rs:2:16
  |
2 | fn foo(_: impl &Trait) {}
  |               -^ expected one of 9 possible tokens
  |               |
  |               help: missing `,`

error: expected one of `!`, `(`, `,`, `=`, `>`, `?`, `for`, `~`, lifetime, or path, found `&`
 --> src/main.rs:3:11
  |
3 | fn bar<T: &Trait>(_: T) {}
  |           ^ expected one of 10 possible tokens
```

After:
```text
error: expected a trait, found type
 --> <anon>:2:16
  |
2 | fn foo(_: impl &Trait) {}
  |                -^^^^^
  |                |
  |                help: consider removing the indirection

error: expected a trait, found type
 --> <anon>:3:11
  |
3 | fn bar<T: &Trait>(_: T) {}
  |           -^^^^^
  |           |
  |           help: consider removing the indirection
```
2023-01-17 05:25:21 +01:00
Matthias Krüger
f74044259a
Rollup merge of #106591 - Ezrashaw:attempted-integer-identifer, r=Estebank
suggestion for attempted integer identifier in patterns

Fixes #106552

Implemented a suggestion on `E0005` that occurs when no bindings are present and the pattern is a literal integer.
2023-01-17 05:25:21 +01:00
Michael Goulet
21725774a2 note -> help 2023-01-17 03:09:49 +00:00
Michael Goulet
716ea5f19c Fix use suggestion span 2023-01-17 03:06:38 +00:00
Michael Goulet
e8ebd43eeb Use scope_expr_id from ProbeCtxt 2023-01-16 23:03:05 +00:00
Jakob Degen
4bc963eba6 Avoid trivial checks on cleanup control flow in MIR validator 2023-01-16 15:01:16 -08:00
Jakob Degen
ec3d993410 Add cycle checking to cleanup control flow validation 2023-01-16 14:51:33 -08:00
Jakob Degen
f49126e3d6 Document wf constraints on control flow in cleanup blocks
Also fixes a bug in dominator computation
2023-01-16 14:51:33 -08:00
Kyle Matsuda
1ae1c49c50 document EarlyBinder::subst_identity and skip_binder 2023-01-16 14:00:31 -07:00
Michael Goulet
9f6fef9657 Properly pluralize 'generic constants' 2023-01-16 20:21:29 +00:00
Michael Goulet
fdaac4e48e ConstBlocks are poly if their substs are poly 2023-01-16 20:09:31 +00:00
Matthias Krüger
d2a8a9fb36
Rollup merge of #106940 - oli-obk:tait_error, r=compiler-errors
Improve a TAIT error and add an error code plus documentation

cc https://github.com/rust-lang/rust/issues/106858
2023-01-16 20:29:39 +01:00
Matthias Krüger
37378ee7da
Rollup merge of #106912 - gftea:pr-106736, r=Nilstrieb
check -Z query-dep-graph is enabled if -Z dump-dep-graph (#106736)

PR to solve #106736, r? `@cjgillot`
2023-01-16 20:29:39 +01:00
Matthias Krüger
8ea26ca17f
Rollup merge of #106835 - compiler-errors:new-solver-gat-rebase-oops, r=lcnr
new trait solver: rebase impl substs for gats correctly

you might've caught this while working on projection code, if so then you can close this pr

r? `@lcnr`
2023-01-16 20:29:38 +01:00
Oli Scherer
6b69b5e460 Improve a TAIT error and add an error code plus documentation 2023-01-16 16:54:14 +00:00
bors
481725984b Auto merge of #106853 - TimNN:undo-remap, r=oli-obk
Heuristically undo path prefix mappings.

Because the compiler produces better diagnostics if it can find the source of (potentially remapped) dependencies.

The new test fails without the other changes in this PR. Let me know if you have better suggestions for the test directory. I moved the existing remapping test to be in the same location as the new one.

Some more context: I'm exploring running UI tests with remapped paths by default in https://github.com/rust-lang/rust/pull/105924 and this was one of the issues discovered.

This may also be useful in the context of https://github.com/rust-lang/rfcs/pull/3127 ("New rustc and Cargo options to allow path sanitisation by default").
2023-01-16 15:11:28 +00:00
Michael Goulet
3a4fdcf86c Encode const mir for closures if they're const 2023-01-16 14:59:27 +00:00
Oli Scherer
1355559367 Avoid an unnecessary allocation 2023-01-16 14:46:44 +00:00
Oli Scherer
44ef075aeb Remove a now-useless function call 2023-01-16 14:46:44 +00:00
Oli Scherer
c8a0561321 Avoid one more call site to Compiler::expansion 2023-01-16 14:46:44 +00:00
Oli Scherer
9f5cd03153 Move compiler input and ouput paths into session 2023-01-16 14:46:44 +00:00
Oli Scherer
42f75f1e46 Group some commonly passed together values into a struct 2023-01-16 14:46:40 +00:00
yukang
9d74bb832f comments feedback 2023-01-16 20:44:14 +08:00
bors
af669c2684 Auto merge of #106850 - cjgillot:issue-106141, r=oli-obk
Make the inlining destination a Local.

Fixes https://github.com/rust-lang/rust/issues/106141
2023-01-16 12:30:49 +00:00
Takayuki Maeda
fe96c11aba fix #104440 2023-01-16 21:06:34 +09:00
gftea
2c5583efbd check -Z query-dep-graph is enabled if -Z dump-dep-graph (#106736) 2023-01-16 11:09:53 +01:00
bors
a5bfc25c93 Auto merge of #106872 - dtolnay:nbsp, r=fee1-dead
Emit only one nbsp error per file

Fixes #106101.

See https://github.com/rust-lang/rust/issues/106098 for an explanation of how someone would end up with a large number of these nbsp characters in their source code, which is why I think rustc needs to handle this specific case in a friendlier way.
2023-01-16 09:37:08 +00:00
Oli Scherer
f5c601492e Remove redundant input_path field from Config 2023-01-16 08:03:06 +00:00
Oli Scherer
6b1a789fb6 remove some arguments that can also be fed at the caller side 2023-01-16 08:03:06 +00:00
Oli Scherer
9e9c871a78 Remove prepare_outputs 2023-01-16 08:03:06 +00:00
Ezra Shaw
ca1178f022
make CastError::NeedsDeref create a MachineApplicable suggestion + other misc fixes 2023-01-16 20:24:01 +13:00
bors
d12412c90f Auto merge of #106395 - compiler-errors:rework-predicates, r=eholk
Rework some `predicates_of`/`{Generic,Instantiated}Predicates` code

1. Make `instantiate_own` return an iterator, since it's a bit more efficient and easier to work with
2. Remove `bound_{explicit,}_predicates_of` -- these `bound_` methods in particular were a bit awkward to work with since `ty::GenericPredicates` *already* acts kinda like an `EarlyBinder` with its own `instantiate_*` methods, and had only a few call sites anyways.
3. Implement `IntoIterator` for `InstantiatedPredicates`, since it's *very* commonly being `zip`'d together.
2023-01-16 05:55:59 +00:00
Ezra Shaw
fcd5ed21b7
fix dropping diagnostic without emit 2023-01-16 16:18:56 +13:00
Tomasz Miąsko
d21696ae46 Remove ineffective run of SimplifyConstCondition
There are no constant conditions at this stage.
2023-01-16 00:00:00 +00:00
Matthias Krüger
fc78b1e7f9
Rollup merge of #106909 - compiler-errors:only-types-can-be, r=estebank
Only suggest adding type param if path being resolved was a type
2023-01-15 21:17:36 +01:00
Matthias Krüger
8bd67dd12d
Rollup merge of #106906 - matthiaskrgr:clone, r=Nilstrieb
remove redundant clones
2023-01-15 21:17:35 +01:00
Matthias Krüger
5321ad574d
Rollup merge of #106900 - clubby789:unused-braces-regression, r=estebank
Fix regression in `unused_braces` with macros

Fixes #106899
2023-01-15 21:17:35 +01:00
Matthias Krüger
5610231454
Rollup merge of #106896 - Ezrashaw:str-cast-bool-emptyness, r=compiler-errors
suggest `is_empty` for collections when casting to `bool`

Fixes #106883

Matches on slices, `String` and `str`. It would be nice to do this with something like `Deref<Target=str>` as well, but AFAIK it's not possible in this part of the compiler.
2023-01-15 21:17:34 +01:00
Michael Goulet
566202b975 Only suggest adding type param if path being resolved was a type 2023-01-15 16:33:08 +00:00
Michael Goulet
90df86f474 Remove bound_{explicit,}_item_bounds 2023-01-15 15:36:06 +00:00
Michael Goulet
e1533a26f7 drive-by: assert when iterating through InstantiatedPredicates 2023-01-15 15:36:06 +00:00
Michael Goulet
9b28edb6d7 Make InstantiatedPredicates impl IntoIterator 2023-01-15 15:36:06 +00:00
Michael Goulet
91fd862df0 instantiate_own doesn't need to return a pair of vectors 2023-01-15 15:29:53 +00:00
bors
ae4d89dfb5 Auto merge of #106742 - compiler-errors:new-solver-make-it-not-ice, r=lcnr
Implement some FIXME methods in the new trait solver

Implement just enough of the solver's response logic to make it not ICE.

Also, fix a bug with `no_bound_vars` call failing due to canonical bound vars.

r? `@lcnr`
2023-01-15 15:07:27 +00:00
Matthias Krüger
665d4ea98d remove redundant clones 2023-01-15 15:02:02 +01:00
bors
fc11ee02ee Auto merge of #106171 - compiler-errors:consolidate-extract_callable_info, r=estebank,lcnr
Consolidate two almost duplicated fn info extraction routines

Moves `extract_callable_info` up to trait selection, because it was being (almost) duplicated fully there for similar diagnostic purposes. This also generalizes the diagnostics we can give slightly (see UI test).
2023-01-15 12:10:36 +00:00
Ezra Shaw
92ced4a12e
suggest is_empty for collections when casting to bool 2023-01-15 22:17:54 +13:00
clubby789
295f5483fe Fix regression in unused_braces with macros 2023-01-15 05:08:30 +00:00
Matthias Krüger
cc02ecc010
Rollup merge of #106863 - anden3:compiler-double-spaces, r=Nilstrieb
Remove various double spaces in compiler source comments.

Was asked to do it by `@Nilstrieb`
2023-01-15 01:01:37 +01:00
Matthias Krüger
980bf1979e
Rollup merge of #106859 - tialaramex:master, r=Nilstrieb
Suggestion for type mismatch when we need a u8 but the programmer wrote a char literal

Today Rust just points out that we have a char and we need a u8, but if I wrote 'A' then I could fix this by just writing b'A' instead. This code should detect the case where we're about to report a type mismatch of this kind, and the programmer wrote a char literal, and the char they wrote is ASCII, so therefore just prefixing b to make a byte literal will do what they meant.

I have definitely written this mistake more than once, it's not difficult to figure out what to do, but the compiler might as well tell us anyway.

I provided a test with two simple examples where the suggestion is appropriate, and one where it is not because the char literal is not ASCII, showing that the suggestion is only triggered in the former cases.

I have contributed only a small typo doc fix before, so this is my first substantive rustc change.
2023-01-15 01:01:36 +01:00
Matthias Krüger
d7fcd01f67
Rollup merge of #106072 - eopb:dyn-derive, r=estebank
fix: misleading "add dyn keyword before derive macro" suggestion

Fixes #106071
2023-01-15 01:01:36 +01:00
Ezra Shaw
e590b93499
make error emitted on impl &Trait nicer 2023-01-15 12:23:46 +13:00
Nick Lamb
130d02b62e Improve E0308: suggest user meant to use byte literal, w/ tests and fix
suggested by Nilstrieb

Co-authored-by: nils <48135649+Nilstrieb@users.noreply.github.com>
2023-01-14 21:27:14 +00:00
bors
afaf3e07aa Auto merge of #106866 - matthiaskrgr:rollup-r063s44, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #105526 (libcore: make result of iter::from_generator Clone)
 - #106563 (Fix `unused_braces` on generic const expr macro call)
 - #106661 (Stop probing for statx unless necessary)
 - #106820 (Deprioritize fulfillment errors that come from expansions.)
 - #106828 (rustdoc: remove `docblock` class from notable trait popover)
 - #106849 (Allocate one less vec while parsing arrays)
 - #106855 (rustdoc: few small cleanups)
 - #106860 (Remove various double spaces in the libraries.)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-01-14 20:53:37 +00:00
David Tolnay
dab06ccdab
Emit only one nbsp error per file 2023-01-14 11:06:22 -08:00
Matthias Krüger
9db8e6d5e9
Rollup merge of #106849 - WaffleLapkin:unvec, r=Nilstrieb
Allocate one less vec while parsing arrays

Probably does not matter, but imo a little bit nicer.
2023-01-14 18:45:28 +01:00
Matthias Krüger
f04f97cea4
Rollup merge of #106820 - m-ou-se:macro-type-error-thing, r=estebank
Deprioritize fulfillment errors that come from expansions.

Fixes (part of?) #69455
2023-01-14 18:45:27 +01:00
Matthias Krüger
d7bc758638
Rollup merge of #106563 - clubby789:gce-macro-braces, r=TaKO8Ki
Fix `unused_braces` on generic const expr macro call

Fixes #106545

`@rustbot` label +A-const-generics +A-lint
2023-01-14 18:45:26 +01:00
bors
b8f9cb345a Auto merge of #106696 - kylematsuda:early-binder, r=lcnr
Switch to `EarlyBinder` for `const_param_default` and `impl_trait_ref` queries

Part of the work to close #105779 and implement https://github.com/rust-lang/types-team/issues/78.

Several queries `X` have a `bound_X` variant that wraps the output in `EarlyBinder`. This PR adds `EarlyBinder` to the return type of  `const_param_default` and `impl_trait_ref`, and removes their `bound_X` variants.

r? `@lcnr`
2023-01-14 17:44:30 +00:00
André Vennberg
0e65003c9e Fix some missed double spaces. 2023-01-14 18:23:40 +01:00
Camille GILLOT
389d52c1eb Remove visit_place. 2023-01-14 17:04:02 +00:00
André Vennberg
da3623abab Removed various double spaces in compiler source comments. 2023-01-14 17:34:59 +01:00
clubby789
4f64de83bc Fix unused_braces on generic const expr macro call 2023-01-14 15:49:08 +00:00
Mara Bos
6821adb651 Deprioritize fulfillment errors that come from expansions. 2023-01-14 14:05:26 +01:00
Tim Neumann
869df76764 Heuristically undo path prefix mappings.
Because the compiler produces better diagnostics if it can find the
source of (potentially remapped) dependencies.
2023-01-14 12:49:37 +00:00
Ethan Brierley
1caec6fa1d fix: misleading add dyn to derive macro suggestion 2023-01-14 12:14:06 +00:00
Camille GILLOT
de9a5b076a Make the inlining destination a Local. 2023-01-14 12:09:06 +00:00
Matthias Krüger
81da2a19fa
Rollup merge of #106846 - WaffleLapkin:pico_parse_ref, r=TaKO8Ki
Improve some comments and names in parser

Just a tiny drive-by cleanup.
2023-01-14 13:04:27 +01:00
Matthias Krüger
8c538f7d83
Rollup merge of #106788 - estebank:elaborate_pred_E0599, r=compiler-errors
Tweak E0599 and elaborate_predicates

CC https://github.com/rust-lang/rust/issues/86377.
2023-01-14 13:04:26 +01:00
Matthias Krüger
108b5f462b
Rollup merge of #106752 - sulami:master, r=estebank
Emit a hint for bad call return types due to generic arguments

When the return type of a function call depends on the type of an argument, e.g.

```
fn foo<T>(x: T) -> T {
    x
}
```

and the expected type is set due to either an explicitly typed binding, or because the call to the function is in a tail position without semicolon, the current error implies that the argument in the call has the wrong type.

This new hint highlights that the expected type doesn't match the returned type, which matches the argument type, and that that's why we're flagging the argument type.

Fixes #43608.
2023-01-14 13:04:26 +01:00
Matthias Krüger
3fa9be9094
Rollup merge of #106665 - JulianKnodt:better_fn_trait_note, r=cjgillot
Add note when `FnPtr` vs. `FnDef` impl trait

I encountered an instance where an `FnPtr` implemented a trait, but I was passing an `FnDef`. I was confused for an hour and to examine the source code of the trait's crate's tests in order to understand how to cast it properly (it didn't help that it was behind a reference). To the end user, it might not be immediately obvious that they are different and how to convert from an `FnDef` to an `FnPtr`, but it is necessary to cast to the generic function in order to compile. It is thus useful to suggest `as` in the help note, (even if the `Fn` output implements the trait).
2023-01-14 13:04:25 +01:00
Matthias Krüger
8e0eecdba6
Rollup merge of #106566 - clubby789:contiguous-weird-unicode, r=cjgillot
Emit a single error for contiguous sequences of unknown tokens

Closes #106101

On encountering a sequence of identical source characters which are unknown tokens, note the amount of subsequent characters and advance past them silently. The old behavior was to emit an error and 'help' note for every single one.

`@rustbot` label +A-diagnostics +A-parser
2023-01-14 13:04:24 +01:00
Maybe Waffle
ea13023b36 Allocate one less vec in parser/expr.rs 2023-01-14 11:44:25 +00:00
Maybe Waffle
f7850c5368 Improve comments in parser/expr.rs 2023-01-14 11:29:22 +00:00
Maybe Waffle
ecb1ad11d9 Make LhsExpr::AlreadyParsed a named struct 2023-01-14 11:28:14 +00:00
kadmin
2de9d679ad Add note when FnPtr vs. FnDef impl trait
I encountered an instance where an `FnPtr` implemented a trait, but I was passing an `FnDef`. To
the end user, there is really no way to differentiate each of them, but it is necessary to cast
to the generic function in order to compile. It is thus useful to suggest `as` in the help note,
(even if the Fn output implements the trait).
2023-01-14 10:37:56 +00:00
yukang
c67903ef21 fix issues in unused lint 2023-01-14 17:11:04 +08:00
yukang
7d99866bfc fix #105061, Fix unused_parens issue for higher ranked function pointers 2023-01-14 17:11:04 +08:00
Ezra Shaw
be1a6db9f8
fix: don't emit E0711 if staged_api not enabled 2023-01-14 22:04:42 +13:00
bors
44a500c8c1 Auto merge of #106646 - Amanieu:ilp32-object, r=Mark-Simulacrum
Fix aarch64-unknown-linux-gnu_ilp32 target

This was broken because the synthetic object files produced by rustc were for 64-bit AArch64, which caused link failures when combined with 32-bit ILP32 object files.

This PR updates the object crate to 0.30.1 which adds support for generating ILP32 AArch64 object files.
2023-01-14 08:33:09 +00:00
Kyle Matsuda
6e969ea85e fix various subst_identity vs skip_binder 2023-01-14 00:30:03 -07:00
Kyle Matsuda
f29a334c90 change impl_trait_ref query to return EarlyBinder; remove bound_impl_trait_ref query; add EarlyBinder to impl_trait_ref in metadata 2023-01-14 00:29:56 -07:00
Kyle Matsuda
be130b57d4 change usages of impl_trait_ref to bound_impl_trait_ref 2023-01-14 00:23:32 -07:00
Kyle Matsuda
ef58baf8b8 change const_param_default query to return EarlyBinder; remove bound_const_param_default query; add EarlyBinder to const_param_default in metadata 2023-01-14 00:13:07 -07:00
Kyle Matsuda
bd6c63597b change usages of const_param_default query to bound_const_param_default 2023-01-14 00:13:07 -07:00
Kyle Matsuda
c84917ad2e add EarlyBinder::subst_identity; impl ParameterizedOverTcx (needed for rustc_metadata) and Value for EarlyBinder 2023-01-14 00:13:06 -07:00
Michael Goulet
05f664a441 new trait solver: rebase impl substs for gats correctly 2023-01-14 04:47:10 +00:00
Yuki Okushi
7d02116832
Rollup merge of #106816 - TimNN:rental-remap, r=oli-obj
Update `rental` hack to work with remapped paths.

This PR simply switches to an already-existing helper instead of hard-coding a specific enum variant. The new revision of the test fails without the other changes in this PR.

Context: I'm exploring running UI tests with remapped paths by default in #105924 and the rental test was one of the ones that failed.

This may also be useful in the context of https://github.com/rust-lang/rfcs/pull/3127 ("New rustc and Cargo options to allow path sanitisation by default").
2023-01-14 12:04:37 +09:00
Yuki Okushi
6486b02105
Rollup merge of #106707 - ehuss:remove-dupe-sha-1, r=Mark-Simulacrum
Remove duplicate sha-1 dependency

[`sha-1`](https://crates.io/crates/sha-1) is more or less a duplicate of [`sha1`](https://crates.io/crates/sha1). The `sha-1` is deprecated and no longer updated. This updates the dependencies to use the new name.

Some other dependencies that got updated as a consequence:
* The updated pest dependencies are currently only used by mdbook, and shouldn't have any issues.
* ucd-trie 0.1.3 to 0.1.5: No changelog, but looks like some tables were updated for new unicode versions: https://github.com/BurntSushi/ucd-generate/commits/master/ucd-trie. This is only used by pest (and thus mdbook).
* thiserror 1.33 to 1.38: Nothing significant in the notes at https://github.com/dtolnay/thiserror/releases.
2023-01-14 12:04:34 +09:00
Michael Goulet
1ea6862db3 Unify Opaque/Projection handling in region outlives code 2023-01-13 23:53:28 +00:00
Ezra Shaw
1babece1e8
suggest fix for attempted integer identifier in patterns 2023-01-14 12:51:20 +13:00
Michael Goulet
75074e0e52 Delay normalization bugs instead of reporting them 2023-01-13 23:19:36 +00:00
Michael Goulet
16cfadbfe8 Suggest lifetime bound in illegal Copy impl 2023-01-13 23:06:29 +00:00
Michael Goulet
333c6bf523 copy self type is implied wf 2023-01-13 23:06:29 +00:00
Michael Goulet
8cf7f40a89 Check ADT fields for copy implementations considering regions 2023-01-13 23:06:29 +00:00
Michael Goulet
c1a7dbc0e3 Rebase conflicts 2023-01-13 22:43:17 +00:00
Michael Goulet
b2df88bae1 Consolidate two almost duplicated fn info extraction routines 2023-01-13 22:43:17 +00:00
Esteban Küber
22a0e4fa6e Do not incorrectly suggest restricting implied bounds
When we have already suggested bounds that imply the about to be
suggested bound, skip them.
2023-01-13 20:50:34 +00:00
Tim Neumann
496edf97c5 Update rental hack to work with remapped paths. 2023-01-13 20:36:03 +00:00
Esteban Küber
3d6b09e53e Keep obligation chain when elaborating obligations 2023-01-13 18:20:23 +00:00
Esteban Küber
f6e6d2a035 Elaborate unmet obligations in E0599 for more context 2023-01-13 18:20:23 +00:00
Matthias Krüger
f7093826a4
Rollup merge of #106813 - oli-obk:sess_cleanup, r=GuillaumeGomez,petrochenkov
Remove redundant session field

There was already a session available in the resolver, so we access that session.
2023-01-13 19:16:45 +01:00
Matthias Krüger
278e02a5b6
Rollup merge of #106797 - FawazTirmizi:dev/issues/104284, r=bjorn3
riscv: Fix ELF header flags

The previous version added both `EF_RISCV_FLOAT_ABI_DOUBLE` and `EF_RISCV_RVC` if the "D" extension was enabled on riscv64 targets. riscv32 targets were not accounted for. This patch changes this so that:

- Only add `EF_RISCV_RVC` if the "C" extension is enabled
- Add `EF_RISCV_FLOAT_ABI_SINGLE` if the "F" extension is enabled and the "D" extension is not
- Add these ELF flags for riscv32 as well

Fixes #104284

r? rust-lang/risc-v
2023-01-13 19:16:45 +01:00
Matthias Krüger
e4d0104754
Rollup merge of #106678 - Veykril:proc-macro-panic-abort, r=eholk
Warn when using panic-strategy abort for proc-macro crates

See https://github.com/rust-lang/rust/issues/82320, this simply warns for now as that seems like the best step that can be immediately taken (opposed to straight up rejecting or ignoring)
2023-01-13 19:16:43 +01:00
Matthias Krüger
57b371ab14
Rollup merge of #106641 - chenyukang:yukang/fix-105761-segguest-this, r=estebank
Provide help on closures capturing self causing borrow checker errors

Fixes #105761

r? ````@estebank````
2023-01-13 19:16:43 +01:00
Matthias Krüger
c6e3a47843
Rollup merge of #106585 - estebank:issue-46585, r=compiler-errors
When suggesting writing a fully qualified path probe for appropriate types

Address the more common part of #46585.
2023-01-13 19:16:42 +01:00
Matthias Krüger
f9dde54a11
Rollup merge of #106489 - jschwe:fix_linker_detection, r=petrochenkov
Fix linker detection for linker (drivers) with a version postfix (e.g. clang-12 instead of clang)

Linker (drivers) such as clang / gcc or lld often have a version postfix matching the regex "-\d+$".
Previously, linker detection did not account for the possible version postfix and the fallback value was used, which can cause linker errors due to wrong arguments.
Also remove the check for `-clang`, since there are no architecture specific variants of clang (to my knowledge).

Fixes #106454
2023-01-13 19:16:42 +01:00
Matthias Krüger
1dc43b2e8b
Rollup merge of #106465 - compiler-errors:bump-IMPLIED_BOUNDS_ENTAILMENT, r=lcnr
Bump `IMPLIED_BOUNDS_ENTAILMENT` to Deny + ReportNow

https://github.com/rust-lang/rust/pull/105575#issuecomment-1357201969

> and then later in the same cycle increase the lint to `deny` and change it to `FutureCompatReportNow` in this nightly cycle.

r? ```@lcnr``` when they're back from holiday 😄
2023-01-13 19:16:41 +01:00