Commit graph

9496 commits

Author SHA1 Message Date
Esteban Kuber 962b2197a5 Annotate derived spans and move span suggestion code
* Annotate `derive`d spans from the user's code with the appropciate context
* Add `Span::can_be_used_for_suggestion` to query if the underlying span
  at the users' code
2021-12-03 18:41:40 +00:00
Esteban Kuber 8bee2b88c0 Remove some unnecessarily verbose code 2021-12-03 18:41:39 +00:00
Esteban Kuber fa3eebb26e Modify bounds_span to ignore bounds coming from a derive macro 2021-12-03 18:41:39 +00:00
Esteban Kuber e70105f971 Keep spans for generics in #[derive(_)] desugaring
Keep the spans for generics coming from a `derive`d Item, so that errors
and suggestions have better detail.

Fix #84003.
2021-12-03 18:41:39 +00:00
bors e5038e2099 Auto merge of #91455 - matthiaskrgr:rollup-gix2hy6, r=matthiaskrgr
Rollup of 4 iffy pull requests

Successful merges:

 - #89234 (Disallow non-c-like but "fieldless" ADTs from being casted to integer if they use arbitrary enum discriminant)
 - #91045 (Issue 90702 fix: Stop treating some crate loading failures as fatal errors)
 - #91394 (Bump stage0 compiler)
 - #91411 (Enable svh tests on msvc)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-12-02 14:53:20 +00:00
Matthias Krüger d96ce3ea8e
Rollup merge of #91394 - Mark-Simulacrum:bump-stage0, r=pietroalbini
Bump stage0 compiler

r? `@pietroalbini` (or anyone else)
2021-12-02 15:52:03 +01:00
Matthias Krüger 87ca333210
Rollup merge of #91045 - mjptree:issue-90702-fix, r=petrochenkov
Issue 90702 fix: Stop treating some crate loading failures as fatal errors

Surface mulitple `extern crate` resolution errors at a time.

This is achieved by creating a dummy crate, instead of aborting directly after the resolution error. The `ExternCrateError` has been added to allow propagating the resolution error from `rustc_metadata` crate to the `rustc_resolve` with a minimal public surface. The `import_extern_crate` function is a block that was factored out from `build_reduced_graph_for_item` for better organization. The only added functionality made to it where the added error handling in the `process_extern_crate` call. The remaining bits in this function are the same as before.

Resolves #90702

r? `@petrochenkov`
2021-12-02 15:52:01 +01:00
Matthias Krüger 0666a33a6b
Rollup merge of #89234 - nbdd0121:discr, r=jackh726
Disallow non-c-like but "fieldless" ADTs from being casted to integer if they use arbitrary enum discriminant

Code like

```rust
#[repr(u8)]
enum Enum {
    Foo /* = 0 */,
    Bar(),
    Baz{}
}

let x = Enum::Bar() as u8;
```

seems to be unintentionally allowed so we couldn't disallow them now ~~, but we could disallow them if arbitrary enum discriminant is used before 1.56 hits stable~~ (stabilization was reverted).

Related: #88621

`@rustbot` label +T-lang
2021-12-02 15:52:00 +01:00
bors 18bb8c61a9 Auto merge of #91354 - fee1-dead:const_env, r=spastorino
Cleanup: Eliminate ConstnessAnd

This is almost a behaviour-free change and purely a refactoring. "almost" because we appear to be using the wrong ParamEnv somewhere already, and this is now exposed by failing a test using the unstable `~const` feature.

We most definitely need to review all `without_const` and at some point should probably get rid of many of them by using `TraitPredicate` instead of `TraitRef`.

This is a continuation of https://github.com/rust-lang/rust/pull/90274.

r? `@oli-obk`

cc `@spastorino` `@ecstatic-morse`
2021-12-02 11:48:58 +00:00
bors a2b7b7891e Auto merge of #91003 - psumbera:sparc64-abi, r=nagisa
fix sparc64 ABI for aggregates with floating point members

Fixes #86163
2021-12-02 02:59:44 +00:00
bors 76938d64a4 Auto merge of #90446 - cjgillot:late-elided, r=jackh726
Lint elided lifetimes in path during lifetime resolution.

The lifetime elision lint is known to be brittle and can be redundant with later lifetime resolution errors. This PR aims to remove the redundancy by performing the lint after lifetime resolution.

This PR proposes to carry the information that an elision should be linted against by using a special `LifetimeName`. I am not certain this is the best solution, but it is certainly the easiest.

Fixes https://github.com/rust-lang/rust/issues/60199
Fixes https://github.com/rust-lang/rust/issues/55768
Fixes https://github.com/rust-lang/rust/issues/63110
Fixes https://github.com/rust-lang/rust/issues/71957
2021-12-01 23:22:43 +00:00
Michael 2ca9333011 Improve suggestion for extern crate self error message 2021-12-01 21:59:54 +00:00
Michael 62f4ce993e Stop treating extern crate loading failures as fatal errors 2021-12-01 21:04:13 +00:00
Michael 10b3a571d2 Factor out build reduced graph for extern crate 2021-12-01 21:04:12 +00:00
Gary Guo f7ef1c9f41 Disallow non-c-like but "fieldless" ADTs from being casted to integer...
... if they use arbitrary enum discriminant. Code like

```rust
enum Enum {
    Foo = 1,
    Bar(),
    Baz{}
}
```

seems to be unintentionally allowed so we couldn't disallow them now,
but we could disallow them if arbitrary enum discriminant is used before
1.56 hits stable.
2021-12-01 19:59:15 +00:00
Matthias Krüger 4a6e8a9c93
Rollup merge of #91425 - jyn514:treat-lint-err-as-bug, r=oli-obk
Include lint errors in error count for `-Ztreat-err-as-bug`

This was a regression from https://github.com/rust-lang/rust/pull/87337;
the `panic_if_treat_err_as_bug` function only checked the number of hard
errors, not the number of lint errors.

r? `@oli-obk`
2021-12-01 20:57:47 +01:00
Matthias Krüger 519a842c50
Rollup merge of #91313 - petrochenkov:cratexp, r=Aaron1011
expand: Turn `ast::Crate` into a first class expansion target

And stop creating a fake `mod` item for the crate root when expanding a crate, thus addressing FIXMEs left in https://github.com/rust-lang/rust/pull/82238, and making a step towards a proper support for crate-level macro attributes (cc #54726).

I haven't added token collection support for the whole crate in this PR, maybe later.
r? `@Aaron1011`
2021-12-01 20:57:43 +01:00
Joshua Nelson 9de8a4a6fa Include lint errors in error count for -Ztreat-err-as-bug
This was a regression from https://github.com/rust-lang/rust/pull/87337;
the `panic_if_treat_err_as_bug` function only checked the number of hard
errors, not the number of lint errors.
2021-12-01 16:39:55 +00:00
Deadbeef 5ebc99e5b2
Format 2021-12-01 23:33:37 +08:00
Deadbeef b64c40bc6f
TODO => FIXME 2021-12-01 23:32:36 +08:00
Deadbeef 6b07cec05c
Cache with consistent env and bound 2021-12-01 23:22:42 +08:00
bors f04a2f4b8e Auto merge of #91255 - b-naber:normalization-ice, r=jackh276
Implement version of normalize_erasing_regions that allows for normalization failure

Fixes https://github.com/rust-lang/rust/issues/59324
Fixes https://github.com/rust-lang/rust/issues/67684
Fixes https://github.com/rust-lang/rust/issues/69398
Fixes https://github.com/rust-lang/rust/issues/71113
Fixes https://github.com/rust-lang/rust/issues/82079
Fixes #85103
Fixes https://github.com/rust-lang/rust/issues/88856
Fixes #91231
Fixes https://github.com/rust-lang/rust/issues/91234

Previously we called `normalize_erasing_regions` inside `layout_of`. `normalize_erasing_regions` assumes that the normalization succeeds. Since some `layout_of` calls happen before typecheck has finished, we introduce a new variant that allows for returning an error.
2021-12-01 13:33:33 +00:00
b-naber 6952470095 rebase 2021-12-01 13:15:59 +01:00
b-naber 4d9a0bf21b address review 2021-12-01 12:12:40 +01:00
b-naber 84bcd40927 fix query description 2021-12-01 12:12:40 +01:00
b-naber 0b32cf3a8d remove static_assert_size on InterpError 2021-12-01 12:12:39 +01:00
b-naber ff448cfcee implement version of normalize_erasing_regions that doesn't assume value is normalizable 2021-12-01 12:12:38 +01:00
Matthias Krüger 4f252f1a91
Rollup merge of #91404 - nnethercote:fix-bad-NodeId-limit-checking, r=dtolnay
Fix bad `NodeId` limit checking.

`Resolver::next_node_id` converts a `u32` to a `usize` (which is
possibly bigger), does a checked add, and then converts the result back
to a `u32`. The `usize` conversion completely subverts the checked add!

This commit removes the conversion to/from `usize`.
2021-12-01 10:50:23 +01:00
Matthias Krüger c09c16c0df
Rollup merge of #91298 - FabianWolff:issue-91028-source-avail, r=cjgillot
Improve error message for `E0659` if the source is not available

Fixes #91028. The fix is similar to those in #89233 and #87088. With this change, instead of the dangling
```
note: `Option` could also refer to the enum defined here
```
I get
```
note: `Option` could also refer to an enum from prelude
```
If the standard library source code _is_ available, the output does not change.
2021-12-01 10:50:21 +01:00
Matthias Krüger d93df5775c
Rollup merge of #91207 - richkadel:rk-bump-coverage-version, r=tmandry
Add support for LLVM coverage mapping format versions 5 and 6

This PR cherry-pick's Swatinem's initial commit in unsubmitted PR #90047.

My additional commit augments Swatinem's great starting point, but adds full support for LLVM
Coverage Mapping Format version 6, conditionally, if compiling with LLVM 13.

Version 6 requires adding the compilation directory when file paths are
relative, and since Rustc coverage maps use relative paths, we should
add the expected compilation directory entry.

Note, however, that with the compilation directory, coverage reports
from `llvm-cov show` can now report file names (when the report includes
more than one file) with the full absolute path to the file.

This would be a problem for test results, but the workaround (for the
rust coverage tests) is to include an additional `llvm-cov show`
parameter: `--compilation-dir=.`
2021-12-01 10:50:20 +01:00
Matthias Krüger a4f46742c2
Rollup merge of #90985 - camsteffen:diag-name-usage, r=jackh726
Use `get_diagnostic_name` more
2021-12-01 10:50:18 +01:00
Matthias Krüger e68e5d2391
Rollup merge of #87160 - estebank:colon-recovery, r=nagisa
When recovering from a `:` in a pattern, use adequate AST pattern

If the suggestion to use `::` instead of `:` in the pattern isn't correct, a second resolution error will be emitted.
2021-12-01 10:50:18 +01:00
Petr Sumbera 128ceec92d fix sparc64 ABI for aggregates with floating point members 2021-12-01 10:03:45 +01:00
bors 2446a21595 Auto merge of #91324 - eggyal:avoid-uneccesary-clone-of-annotatable, r=Aaron1011
Avoid uneccessary clone of Annotatable

Addresses FIXME comment created in #82608

r? `@Aaron1011`
2021-12-01 06:18:39 +00:00
Nicholas Nethercote e7ee8230ce Fix bad NodeId limit checking.
`Resolver::next_node_id` converts a `u32` to a `usize` (which is
possibly bigger), does a checked add, and then converts the result back
to a `u32`. The `usize` conversion completely subverts the checked add!

This commit removes the conversion to/from `usize`.
2021-12-01 15:08:37 +11:00
Matthias Krüger 7baafb1f5e
Rollup merge of #91397 - jyn514:generic-param-docs, r=wesleywiser
Emit a warning on generic parameters with doc comments

Fixes https://github.com/rust-lang/rust/issues/90610
2021-11-30 23:43:33 +01:00
Matthias Krüger dc78cd4c61
Rollup merge of #91294 - cjgillot:process-elem, r=jackh726
Visit type in process_projection_elem.

Instead of reimplementing it for each visitor.
2021-11-30 23:43:31 +01:00
Camille GILLOT aa2450f41b Merge Implicit and ImplicitMissing. 2021-11-30 22:56:47 +01:00
Camille GILLOT 72dc29c260 Handle allow(elided_lifetimes_in_paths). 2021-11-30 22:55:07 +01:00
Camille GILLOT b621133200 Simplify lowering. 2021-11-30 22:55:07 +01:00
Camille GILLOT 5ea7ea8a57 Lint elided lifetimes in path during lifetime resolution. 2021-11-30 22:55:07 +01:00
Camille GILLOT ac03470c3b Flatten match. 2021-11-30 22:55:06 +01:00
Camille GILLOT c44e93086d Move report_elision_failure in diagnostics.rs. 2021-11-30 22:55:06 +01:00
Rich Kadel 0c57fab5fc Add conditional support for coverage map version 6
This commit augments Swatinem's initial commit in uncommitted PR #90047,
which was a great starting point, but did not fully support LLVM
Coverage Mapping Format version 6.

Version 6 requires adding the compilation directory when file paths are
relative, and since Rustc coverage maps use relative paths, we should
add the expected compilation directory entry.

Note, however, that with the compilation directory, coverage reports
from `llvm-cov show` can now report file names (when the report includes
more than one file) with the full absolute path to the file.

This would be a problem for test results, but the workaround (for the
rust coverage tests) is to include an additional `llvm-cov show`
parameter: `--compilation-dir=.`
2021-11-30 13:54:53 -08:00
Joshua Nelson bd894a0877 Emit a warning on generic parameters with doc comments 2021-11-30 18:49:55 +00:00
Mark Rousskov 971c549ca3 re-format with new rustfmt 2021-11-30 13:08:41 -05:00
Mark Rousskov b221c877e8 Apply cfg-bootstrap switch 2021-11-30 10:51:42 -05:00
bors 1c0287830e Auto merge of #91388 - JohnTitor:rollup-640o1e5, r=JohnTitor
Rollup of 8 pull requests

Successful merges:

 - #91243 (Don't treat unnormalized function arguments as well-formed)
 - #91250 (Refactor EmitterWriter::emit_suggestion_default )
 - #91317 (tests: Ignore `test/debuginfo/rc_arc.rs` on windows-gnu)
 - #91323 (CTFE: support assert_zero_valid and assert_uninit_valid)
 - #91358 (Fix small typo)
 - #91360 (⬆️ rust-analyzer)
 - #91368 (Don't re-export `MirPass`)
 - #91383 (Add `drop_while` as doc alias to `Iterator::skip_while`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-11-30 10:45:22 +00:00
Yuki Okushi 898f1e4717
Rollup merge of #91368 - ecstatic-morse:mir-pass-reexport, r=cjgillot
Don't re-export `MirPass`

`rust-analyzer` wants to use the `rustc_const_eval` one by default, which is weird.

r? ``@cjgillot``
2021-11-30 17:29:12 +09:00
Yuki Okushi 56c838cdc7
Rollup merge of #91358 - kd-collective:fix_typo, r=cjgillot
Fix small typo

Fix a typo in code commenting!
`accross` -> `across`
2021-11-30 17:29:10 +09:00