Commit Graph

21640 Commits

Author SHA1 Message Date
Dylan DPC
675976eb21
Rollup merge of #107685 - jieyouxu:issue-90027, r=compiler-errors
Suggest adding a return type for async functions

Fixes #90027.
2023-02-06 19:54:15 +05:30
Dylan DPC
8ddbfadda0
Rollup merge of #107580 - lenko-d:default_value_for_a_lifetime_generic_parameter_produces_confusing_diagnostic, r=compiler-errors
Recover from lifetimes with default lifetimes in generic args

Fixes [#107492](https://github.com/rust-lang/rust/issues/107492)
2023-02-06 19:54:14 +05:30
Dylan DPC
496adf81de
Rollup merge of #107553 - edward-shen:edward-shen/suggest-null-ptr, r=WaffleLapkin
Suggest std::ptr::null if literal 0 is given to a raw pointer function argument

Implementation feels a little sus (we're parsing the span for a `0`) but it seems to fall in line the string-expected-found-char condition right above this check, so I think it's fine.

Feedback appreciated on help text? I think it's consistent but it does sound a little awkward maybe?

Fixes #107517
2023-02-06 19:54:13 +05:30
bors
e7813fee92 Auto merge of #107667 - cjgillot:no-on-hit, r=lcnr,Zoxc
Remove `OnHit` callback from query caches.

This is not useful now that query results are `Copy`.
2023-02-06 09:09:09 +00:00
许杰友 Jieyou Xu (Joe)
6b05b80690
Suggest return type for async function without return type 2023-02-06 13:02:04 +08:00
bors
14ea63a7e0 Auto merge of #107627 - nnethercote:optimize-fold_ty, r=compiler-errors
Optimize `fold_ty`

Micro-optimizing the heck out of the important `fold_ty` methods.

r? `@oli-obk`
2023-02-05 23:13:41 +00:00
Nicholas Nethercote
4aec1345aa Split and inline TypeFreshener::fold_ty. 2023-02-06 09:16:15 +11:00
Nicholas Nethercote
fb8e6819aa Split and inline ShallowResolver::fold_ty. 2023-02-06 08:52:04 +11:00
Nicholas Nethercote
c2cf3f7b24 Inline OpportunisticVarResolver::fold_ty. 2023-02-06 08:52:04 +11:00
Nicholas Nethercote
f08a3371b0 Improve early bailout test in resolve_vars_if_possible.
`!t.has_non_region_infer()` is the test used in
`OpportunisticVarResolver`, and catches a few cases that
`!t.needs_infer()` misses.
2023-02-06 08:52:04 +11:00
Nicholas Nethercote
bac7628eae Put a ShallowResolver within OpportunisticVarResolver.
So one doesn't have to be constructed every time.
2023-02-06 08:50:48 +11:00
bors
75a0be98f2 Auto merge of #107526 - obeis:for-missing-iterator, r=estebank,compiler-errors
Recover form missing expression in `for` loop

Close #78537
r? `@estebank`
2023-02-05 20:33:05 +00:00
bors
a676496750 Auto merge of #107663 - matthiaskrgr:107423-point-at-EOF-code, r=compiler-errors
don't point at nonexisting code beyond EOF when warning about delims

Previously we would show this:
```
warning: unnecessary braces around block return value
 --> /tmp/bad.rs:1:8
  |
1 | fn a(){{{
  |        ^  ^
  |
  = note: `#[warn(unused_braces)]` on by default
help: remove these braces
  |
1 - fn a(){{{
1 + fn a(){{
  |
```

which is now hidden in this case.
We would create a span spanning between the pair of redundant {}s but there is only EOF instead of the `}` so we would previously point at nothing. This would cause the debug assertion ice to trigger. I would have loved to just only point at the second delim and say "you can remove that" but I'm not sure how to do that without refactoring the entire diagnostic which seems tricky. :( But given that this does not seem to regress any other tests we have, I think this edge-casey enough be acceptable.

Fixes https://github.com/rust-lang/rust/issues/107423

r? `@compiler-errors`
2023-02-05 17:32:26 +00:00
Obei Sideg
7a75278836 Recover from missing expression in for loop 2023-02-05 17:33:10 +03:00
bors
7f97aeaf73 Auto merge of #107679 - est31:less_import_overhead, r=compiler-errors
Less import overhead for errors

This removes huge (3+ lines) import lists found in files that had their error reporting migrated. These lists are bad for developer workflows as adding, removing, or editing a single error's name might cause a chain reaction that bloats the git diff. As the error struct names are long, the likelihood of such chain reactions is high.

Follows the suggestion by `@Nilstrieb` in the [zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/147480-t-compiler.2Fwg-diagnostics/topic/massive.20use.20statements) to replace the `use errors::{FooErr, BarErr};` with `use errors;` and then changing to `errors::FooErr` on the usage sites.

I have used sed to do most of the changes, i.e. something like:

```
sed -i -E 's/(create_err|create_feature_err|emit_err|create_note|emit_fatal|emit_warning)\(([[:alnum:]]+|[A-Z][[:alnum:]:]*)( \{|\))/\1(errors::\2\3/' path/to/file.rs
```

& then I manually fixed the errors that occured. Most manual changes were required in `compiler/rustc_parse/src/parser/expr.rs`.

r? `@compiler-errors`
2023-02-05 11:10:11 +00:00
Boxy
d85d906f8c emit ConstEquate in TypeRelating<D> 2023-02-05 07:24:54 +00:00
Edward Shen
32967296b4
Suggest null ptr if 0 is given as a raw ptr arg 2023-02-04 20:13:16 -08:00
est31
580cc89e9c rustc_session: remove huge error imports 2023-02-05 04:01:20 +01:00
est31
394fa192a9 rustc_parse: remove huge error imports 2023-02-05 03:48:17 +01:00
est31
b4a20abc48 rustc_interface: remove huge error imports 2023-02-05 03:48:08 +01:00
est31
a399f0ca84 rustc_passes: remove huge error imports 2023-02-05 03:47:58 +01:00
est31
3478b162f3 rustc_const_eval: remove huge error imports 2023-02-05 03:47:48 +01:00
est31
4442f13b03 rustc_metadata: remove huge error imports 2023-02-05 03:47:38 +01:00
est31
60e82aef64 rustc_expand: remove huge error imports 2023-02-05 03:47:22 +01:00
Lenko Donchev
d9f60052d2 Recover from default value for a lifetime in generic parameters. 2023-02-04 17:04:09 -06:00
bors
50d3ba5bcb Auto merge of #107672 - matthiaskrgr:rollup-7e6dbuk, r=matthiaskrgr
Rollup of 3 pull requests

Successful merges:

 - #107116 (consolidate bootstrap docs)
 - #107646 (Provide structured suggestion for binding needing type on E0594)
 - #107661 (Remove Esteban from review queues for a while)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-02-04 21:07:10 +00:00
Matthias Krüger
d381eca5dc
Rollup merge of #107646 - estebank:specific-span, r=compiler-errors
Provide structured suggestion for binding needing type on E0594

Partially address #45405.
2023-02-04 20:29:06 +01:00
bors
3de7d7fb22 Auto merge of #107549 - Zoxc:rustc-shared, r=jyn514
Move code in `rustc_driver` out to a new `rustc_driver_impl` crate to allow pipelining

That adds a `rustc_shared` library which contains all the rustc library crates in a single dylib. It takes over this role from `rustc_driver`. This is done so that `rustc_driver` can be compiled in parallel with other crates. `rustc_shared` is intentionally left empty so it only does linking.

An alternative could be to move the code currently in `rustc_driver` into a new crate to avoid changing the name of the distributed library.
2023-02-04 18:11:02 +00:00
Camille GILLOT
635ff8e2a8 Support parallel compiler. 2023-02-04 15:56:50 +00:00
Camille GILLOT
128f2224af Remove OnHit callback from query caches.
This is not useful now that query results are `Copy`.
2023-02-04 15:21:21 +00:00
bors
9dee4e4c42 Auto merge of #107267 - cjgillot:keep-aggregate, r=oli-obk
Do not deaggregate MIR

This turns out to simplify a lot of things.
I haven't checked the consequences for miri yet.

cc `@JakobDegen`
r? `@oli-obk`
2023-02-04 15:17:32 +00:00
Matthias Krüger
ed58c01959 don't point at nonexisting code beyond EOF when warning about unused delims
Previously we would show this:
```
warning: unnecessary braces around block return value
 --> /tmp/bad.rs:1:8
  |
1 | fn a(){{{
  |        ^  ^
  |
  = note: `#[warn(unused_braces)]` on by default
help: remove these braces
  |
1 - fn a(){{{
1 + fn a(){{
  |
```

which is now hidden in this case.
We would create a span spanning between the pair of redundant {}s but there is only EOF instead of the `}` so we would previously point at nothing.
This would cause the debug assertion ice to trigger.
I would have loved to just only point at the second delim and say "you can remove that" but I'm not sure how to do that without refactoring the entire diagnostic which seems tricky. :(
But given that this does not seem to regress any other tests we have, I think this edge-casey enough be acceptable.

Fixes https://github.com/rust-lang/rust/issues/107423

r? @compiler-errors
2023-02-04 13:36:14 +01:00
bors
91eb6f9acf Auto merge of #107591 - krasimirgg:llvm-17-pgoopts, r=cuviper
llvm-wrapper: adapt for LLVM API changes

Adapts the wrapper for 516e301752, where the constructor of PGOOptions gained a new FileSystem argument. Adapted to use the real file system, similarly to the changes inside of LLVM:
516e301752 (diff-f409934ba27ad86494f3012324e9a3995b56e0743609ded7a387ba62bbf5edb0R236)

Found via our experimental Rust + LLVM at HEAD bot: https://buildkite.com/llvm-project/rust-llvm-integrate-prototype/builds/16853#01860e2e-5eba-4f07-8359-0325913ff410/219-517
2023-02-04 03:41:57 +00:00
Esteban Küber
e6c56cda09 review comments 2023-02-03 23:41:39 +00:00
Michael Goulet
72599c69b5
Rollup merge of #107621 - compiler-errors:intern-external-constraints, r=lcnr
Intern external constraints in new solver

Makes the query response `Copy`, fixing a few FIXMEs.
2023-02-03 14:15:23 -08:00
Michael Goulet
1594b58ce7
Rollup merge of #107595 - michaelwoerister:retry_proc_macro_loading, r=petrochenkov
Retry opening proc-macro DLLs a few times on Windows.

On Windows, the compiler [sometimes](https://users.rust-lang.org/t/error-loadlibraryexw-failed/77603) fails with the message `error: LoadLibraryExW failed` when trying to load a proc-macro crate. The error seems to occur intermittently, similar to https://github.com/rust-lang/rust/issues/86929, however, it seems to be almost impossible to reproduce outside of CI environments and thus very hard to debug. The fact that the error only occurs intermittently makes me think that this is a timing related issue.

This PR is an attempt to mitigate the issue by letting the compiler retry a few times when encountering this specific error (which resolved the issue described in https://github.com/rust-lang/rust/issues/86929).
2023-02-03 14:15:22 -08:00
Michael Goulet
e99e05d135
Rollup merge of #107551 - fee1-dead-contrib:rm_const_fnmut_helper, r=oli-obk
Replace `ConstFnMutClosure` with const closures

Also fixes a parser bug. cc `@oli-obk` for compiler changes
2023-02-03 14:15:22 -08:00
Michael Goulet
0b5941aa11 Make const/fn return params more suggestable 2023-02-03 21:37:41 +00:00
Michael Goulet
41883fd19a intern external constraints 2023-02-03 21:36:59 +00:00
Esteban Küber
da1360d981 Provide structured suggestion for binding needing type on E0594
Partially address #45405.
2023-02-03 18:53:27 +00:00
bors
658fad6c55 Auto merge of #107642 - Dylan-DPC:rollup-edcqhm5, r=Dylan-DPC
Rollup of 6 pull requests

Successful merges:

 - #107082 (Autotrait bounds on dyn-safe trait methods)
 - #107427 (Add candidates for DiscriminantKind builtin)
 - #107539 (Emit warnings on unused parens in index expressions)
 - #107544 (Improve `TokenCursor`.)
 - #107585 (Don't cause a cycle when formatting query description that references a FnDef)
 - #107633 (Fix suggestion for coercing Option<&String> to Option<&str>)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-02-03 17:53:49 +00:00
Dylan DPC
c9270272df
Rollup merge of #107633 - clubby789:option-string-coerce-fix, r=Nilstrieb
Fix suggestion for coercing Option<&String> to Option<&str>

Fixes #107604

This also makes the diagnostic `MachineApplicable`, and runs `rustfix` to check we're not producing incorrect code.

``@rustbot`` label +A-diagnostics
2023-02-03 23:04:52 +05:30
Dylan DPC
d6f0c51e98
Rollup merge of #107585 - compiler-errors:fndef-sig-cycle, r=oli-obk
Don't cause a cycle when formatting query description that references a FnDef

When a function returns `-> _`, we use typeck to compute what the resulting type of the body _should_ be. If we call another query inside of typeck and hit a cycle error, we attempt to report the cycle error which requires us to compute all of the query descriptions for the stack.

However, if one of the queries in that cycle has a query description that references this function as a FnDef type, we'll cause a *second* cycle error from within the cycle error reporting code, since rendering a FnDef requires us to compute its signature. This causes an unwrap to ICE, since during the *second* cycle reporting code, we try to look for a job that isn't in the active jobs list.

We can avoid this by using `with_no_queries!` when computing these query descriptions.

Fixes #107089

The only drawback is that the rendering of opaque types in cycles regresses a bit :| I'm open to alternate suggestions about how we may handle this...
2023-02-03 23:04:52 +05:30
Dylan DPC
815dc9c480
Rollup merge of #107544 - nnethercote:improve-TokenCursor, r=petrochenkov
Improve `TokenCursor`.

Some small improvements, for things that were bugging me.

Best reviewed one commit at a time.

r? ``@petrochenkov``
2023-02-03 23:04:51 +05:30
Dylan DPC
d9db35785d
Rollup merge of #107539 - PossiblyAShrub:unused-parens-in-index, r=lcnr
Emit warnings on unused parens in index expressions

Fixes: #96606.

I am not sure what the best term for "index expression" is. Is there a better term we could use?
2023-02-03 23:04:51 +05:30
Dylan DPC
e1bf3a1386
Rollup merge of #107427 - detrumi:builtin-impl-candidates, r=compiler-errors
Add candidates for DiscriminantKind builtin

Part of #107379
2023-02-03 23:04:50 +05:30
David Tolnay
4501d3abe1
Autotrait bounds on dyn-safe trait methods 2023-02-03 08:33:40 -08:00
David Tolnay
9e1c600f74
Disallow impl autotrait for trait object 2023-02-03 08:33:40 -08:00
bors
9545094994 Auto merge of #107599 - clubby789:debug-less-ref, r=nnethercote
Don't generate unecessary `&&self.field` in deriving Debug

Since unsized fields may only be the last one in a struct, we only need to generate a double reference (`&&self.field`) for the  final one.

cc `@nnethercote`
2023-02-03 14:22:42 +00:00
clubby789
f874f6768c Fix suggestion for coercing Option<&String> to Option<&str> 2023-02-03 11:44:23 +00:00