Commit Graph

18340 Commits

Author SHA1 Message Date
Cameron Steffen
88d71504dd Use tcx.require_lang_item 2022-10-29 16:09:15 -05:00
Cameron Steffen
1c8e658820 Use LanguageItems::require less 2022-10-29 16:04:10 -05:00
Cameron Steffen
a6180ede5c Simplify lang item groups 2022-10-29 16:04:10 -05:00
Cameron Steffen
6621279a75 Cleanup weak lang items 2022-10-29 16:04:10 -05:00
Cameron Steffen
1e349fb0dd Use an array in LanguageItems 2022-10-29 16:04:10 -05:00
Cameron Steffen
f808430497 Factor out ITEM_REFS 2022-10-29 16:04:10 -05:00
Cameron Steffen
ebfa1f0185 Encode LangItem directly 2022-10-29 16:04:10 -05:00
Cameron Steffen
99de57ae13 Improve LanguageItems api 2022-10-29 16:04:04 -05:00
bors
5e97720429 Auto merge of #103450 - cjgillot:elision-nodedup, r=Mark-Simulacrum
Do not consider repeated lifetime params for elision.

Fixes https://github.com/rust-lang/rust/issues/103330
2022-10-29 17:32:45 +00:00
Guillaume Gomez
679771f147
Rollup merge of #103699 - compiler-errors:dyn-star-cast-bad, r=TaKO8Ki
Emit proper error when casting to `dyn*`

Fixes #103679
2022-10-29 14:18:05 +02:00
Guillaume Gomez
2414a4c31a
Rollup merge of #103625 - WaffleLapkin:no_tyctxt_dogs_allowed, r=compiler-errors
Accept `TyCtxt` instead of `TyCtxtAt` in `Ty::is_*` functions

Functions in answer:

- `Ty::is_freeze`
- `Ty::is_sized`
- `Ty::is_unpin`
- `Ty::is_copy_modulo_regions`

This allows to remove a lot of useless `.at(DUMMY_SP)`, making the code a bit nicer :3

r? `@compiler-errors`
2022-10-29 14:18:03 +02:00
Guillaume Gomez
692a22e735
Rollup merge of #103618 - nnethercote:rename-OwnerId-fields, r=compiler-errors
Rename some `OwnerId` fields.

`@spastorino` noticed some silly expressions like `item_id.def_id.def_id`.

This commit renames several `def_id: OwnerId` fields as `owner_id`, so those expressions become `item_id.owner_id.def_id`.

`item_id.owner_id.local_def_id` would be even clearer, but the use of `def_id` for values of type `LocalDefId` is *very* widespread, so I left that alone.

r? `@compiler-errors`
2022-10-29 14:18:03 +02:00
Guillaume Gomez
07b5c6bdaa
Rollup merge of #103415 - compiler-errors:tiny-perf-increase-on-diagnostic, r=TaKO8Ki
filter candidates in pick probe for diagnostics

Fixes #103411, though also fine with closing this PR if my opinion (https://github.com/rust-lang/rust/issues/103411#issuecomment-1287900069) is shared that this doesn't need to  be fixed.

```
~/rust3$ time rustc +nightly ~/test.rs 2>/dev/null

real    0m4.853s
user    0m4.837s
sys     0m0.016s

~/rust3$ time rustc +rust3 ~/test.rs 2>/dev/null

real    0m0.193s
user    0m0.169s
sys     0m0.024s
```

Also fixes #103427.
2022-10-29 14:18:02 +02:00
Nicholas Nethercote
c8c25ce5a1 Rename some OwnerId fields.
spastorino noticed some silly expressions like `item_id.def_id.def_id`.

This commit renames several `def_id: OwnerId` fields as `owner_id`, so
those expressions become `item_id.owner_id.def_id`.

`item_id.owner_id.local_def_id` would be even clearer, but the use of
`def_id` for values of type `LocalDefId` is *very* widespread, so I left
that alone.
2022-10-29 20:28:38 +11:00
bors
33b530e040 Auto merge of #103714 - matthiaskrgr:rollup-kajt3i8, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #102961 (Make `CStr::from_ptr` `const`.)
 - #103342 (Add test for issue 98634)
 - #103383 (Note scope of TAIT more accurately)
 - #103656 (Specialize ToString for Symbol)
 - #103663 (rustdoc: remove redundant CSS/DOM `div.search-container`)
 - #103664 (rustdoc-json-types: Improve ItemSummary::path docs)
 - #103704 (Add a test for TAIT used with impl/dyn Trait inside RPIT)

Failed merges:

 - #103618 (Rename some `OwnerId` fields.)

r? `@ghost`
`@rustbot` modify labels: rollup
2022-10-29 09:21:35 +00:00
Matthias Krüger
f41b1bfd0f
Rollup merge of #103656 - camsteffen:symbol-to-string, r=compiler-errors
Specialize ToString for Symbol
2022-10-29 08:57:36 +02:00
Matthias Krüger
790a716420
Rollup merge of #103383 - compiler-errors:tait-scope, r=oli-obk
Note scope of TAIT more accurately

This maybe explains why the person was confused in #101897, since we say "same module" but really should've said "same impl".

r? ``@oli-obk``
2022-10-29 08:57:35 +02:00
bors
607878d069 Auto merge of #102698 - michaelwoerister:unord-collections, r=lncr
Introduce UnordMap, UnordSet, and UnordBag (MCP 533)

This is the start of implementing [MCP 533](https://github.com/rust-lang/compiler-team/issues/533).

I followed `@eddyb's` suggestion of naming the collection types `Unord(Map/Set/Bag)` which is a bit easier to type than `Unordered(Map/Set/Bag)`

r? `@eddyb`
2022-10-29 06:20:48 +00:00
bors
33b55ac39f Auto merge of #102233 - petrochenkov:effvis, r=jackh726
privacy: Rename "accessibility levels" to "effective visibilities"

And a couple of other naming and comment tweaks.

Related to https://github.com/rust-lang/rust/issues/48054

For `enum Level` I initially used naming `enum EffectiveVisibilityLevel`, but it was too long and inconvenient because it's used pretty often.
So I shortened it to just `Level`, if it needs to be used from some context where this name would be ambiguous, then it can be imported with renaming like `use rustc_middle::privacy::Level as EffVisLevel` or something.
2022-10-29 03:08:59 +00:00
Cameron Steffen
298253af98 Specialize ToString for Symbol 2022-10-28 16:42:47 -05:00
bors
9565dfeb4e Auto merge of #103683 - fee1-dead-contrib:fix-deferred-cast-checks-constness, r=oli-obk
Retain ParamEnv constness when running deferred cast checks

Fixes #103677.
2022-10-28 19:28:41 +00:00
Michael Goulet
c4420135fe Emit proper error when casting to Ddyn-star 2022-10-28 17:33:06 +00:00
bors
77e7b74ad5 Auto merge of #103071 - wesleywiser:fix_inlined_line_numbers, r=davidtwco
Fix line numbers for MIR inlined code

`should_collapse_debuginfo` detects if the specified span is part of a
macro expansion however it does this by checking if the span is anything
other than a normal (non-expanded) kind, then the span sequence is
walked backwards to the root span.

This doesn't work when the MIR inliner inlines code as it creates spans
with expansion information set to `ExprKind::Inlined` and results in the
line number being attributed to the inline callsite rather than the
normal line number of the inlined code.

Fixes #103068
2022-10-28 16:27:56 +00:00
bors
5237c4d83d Auto merge of #102674 - CastilloDel:master, r=oli-obk
Remove allow(rustc::potential_query_instability) in rustc_const_eval

The use of FxHashMap has been replaced with FxIndexMap.

Related to #84447
2022-10-28 12:52:17 +00:00
Deadbeef
a990b4c1d0 Retain ParamEnv constness when running deferred cast checks
Fixes #103677.
2022-10-28 12:03:24 +00:00
bors
a9ef10019f Auto merge of #103671 - matthiaskrgr:rollup-iuugpep, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #102642 (Add tests for static async functions in traits)
 - #103283 (Add suggestions for unsafe impl error codes)
 - #103523 (Fix unwanted merge of inline doc comments for impl blocks)
 - #103550 (diagnostics: do not suggest static candidates as traits to import)
 - #103641 (Don't carry MIR location in `ConstraintCategory::CallArgument`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-10-28 09:41:40 +00:00
Matthias Krüger
ab0d9dfefe
Rollup merge of #103609 - BoxyUwU:fix_impl_self_cycle, r=compiler-errors
Emit a nicer error on `impl Self {`

currently it emits a "cycle detected error" but this PR makes it emit a more user friendly error specifically saying that `Self` is disallowed in that position. this is a pretty hacky fix so i dont expect this to be merged (I basically only made this PR because i wanted to see if CI passes)

r? ``@compiler-errors``
2022-10-28 07:06:46 +02:00
Matthias Krüger
112fd022cd
Rollup merge of #103608 - compiler-errors:rpitit-early-lt, r=cjgillot
Remap early bound lifetimes in return-position `impl Trait` in traits too

Fixes part of #103457

r? ``@cjgillot,`` though feel free to reassign, just thought you'd have sufficient context to review.
2022-10-28 07:06:46 +02:00
Matthias Krüger
84663cee39
Rollup merge of #103641 - compiler-errors:issue-103624, r=cjgillot
Don't carry MIR location in `ConstraintCategory::CallArgument`

It turns out that `ConstraintCategory::CallArgument` cannot just carry a MIR location in it, since we may bubble them up to totally different MIR bodies.

So instead, revert the commit a6b5f95fb0, and instead just erase regions from the original `Option<Ty<'tcx>>` that it carried, so that it doesn't ICE with the changes in #103220.

Best reviewed in parts -- the first is just a revert, and the second is where the meaningful changes happen.

Fixes #103624
2022-10-28 07:06:43 +02:00
Matthias Krüger
f541ad9165
Rollup merge of #103550 - notriddle:notriddle/no-suggest-static-candidates, r=wesleywiser
diagnostics: do not suggest static candidates as traits to import

If it's a static candidate, then it's already implemented. Do not suggest it a second time for implementing.

Partial fix for #102354
2022-10-28 07:06:43 +02:00
Matthias Krüger
270e0c5357
Rollup merge of #103283 - nbarrios1337:unsafe-impl-suggestions, r=cjgillot
Add suggestions for unsafe impl error codes

Adds suggestions for users to add `unsafe` to trait impls that should be `unsafe`, and remove `unsafe` from trait impls that do not require `unsafe`

With the folllowing code:

```rust
struct Foo {}

struct Bar {}

trait Safe {}

unsafe trait Unsafe {}

impl Safe for Foo {} // ok

impl Unsafe for Foo {} // E0200

unsafe impl Safe for Bar {} // E0199

unsafe impl Unsafe for Bar {} // ok

// omitted empty main fn
```

The current rustc output is:
```
error[E0199]: implementing the trait `Safe` is not unsafe
  --> e0200.rs:13:1
   |
13 | unsafe impl Safe for Bar {} // E0199
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0200]: the trait `Unsafe` requires an `unsafe impl` declaration
  --> e0200.rs:11:1
   |
11 | impl Unsafe for Foo {} // E0200
   | ^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 2 previous errors

Some errors have detailed explanations: E0199, E0200.
For more information about an error, try `rustc --explain E0199`.
```

With this PR, the future rustc output would be:
```
error[E0199]: implementing the trait `Safe` is not unsafe
  --> ../../temp/e0200.rs:13:1
   |
13 | unsafe impl Safe for Bar {} // E0199
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
help: remove `unsafe` from this trait implementation
   |
13 - unsafe impl Safe for Bar {} // E0199
13 + impl Safe for Bar {} // E0199
   |

error[E0200]: the trait `Unsafe` requires an `unsafe impl` declaration
  --> ../../temp/e0200.rs:11:1
   |
11 | impl Unsafe for Foo {} // E0200
   | ^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: the trait `Unsafe` enforces invariants that the compiler can't check. Review the trait documentation and make sure this implementation upholds those invariants before adding the `unsafe` keyword
help: add `unsafe` to this trait implementation
   |
11 | unsafe impl Unsafe for Foo {} // E0200
   | ++++++

error: aborting due to 2 previous errors

Some errors have detailed explanations: E0199, E0200.
For more information about an error, try `rustc --explain E0199`.
```

``@rustbot`` label +T-compiler +A-diagnostics +A-suggestion-diagnostics
2022-10-28 07:06:42 +02:00
Boxy
b3425587a6 tidy + move logic to fn 2022-10-27 22:29:16 +01:00
Boxy
ca5a6e43dd use proper spans 2022-10-27 22:18:26 +01:00
Boxy
c00ff9c4d0 DoIt 2022-10-27 21:48:47 +01:00
Camille GILLOT
cb1e7d9676 Only ban duplication across parameters. 2022-10-27 19:04:48 +00:00
Michael Goulet
4e0c27bbfd Erase regions from CallArgument, add test + bless 2022-10-27 16:26:55 +00:00
Michael Goulet
dce44faf5b Revert "Make ClosureOutlivesRequirement not rely on an unresolved type"
This reverts commit a6b5f95fb0.
2022-10-27 16:15:11 +00:00
Maybe Waffle
dc53c8f25f Update tooling 2022-10-27 18:41:26 +04:00
Michael Woerister
9117ea9758 Introduce UnordMap, UnordSet, and UnordBag (see MCP 533)
MCP 533: https://github.com/rust-lang/compiler-team/issues/533

Also, as an example, substitute UnordMap for FxHashMap in
used_trait_imports query result.
2022-10-27 13:23:26 +00:00
Matthias Krüger
f9dfb6e32f
Rollup merge of #103544 - Nilstrieb:no-recovery-pls, r=compiler-errors
Add flag to forbid recovery in the parser

To start the effort of fixing #103534, this adds a new flag to the parser, which forbids the parser from doing recovery, which it shouldn't do in macros.

This doesn't add any new checks for recoveries yet and is just here to bikeshed the names for the functions here before doing more.

r? `@compiler-errors`
2022-10-27 15:03:58 +02:00
Matthias Krüger
4a01cab4b7
Rollup merge of #103524 - petrochenkov:modchild4, r=cjgillot
rustc_metadata: Add struct and variant constructors to module children at encoding time

instead of decoding time.

Continuation of https://github.com/rust-lang/rust/pull/95899.
The last time it caused some ICEs from generator use, but not everything seems ok.
2022-10-27 15:03:57 +02:00
Matthias Krüger
16e74c78a1
Rollup merge of #103255 - oli-obk:opaque_wrong_eq_relation, r=compiler-errors
Clean up hidden type registration

work on https://github.com/rust-lang/rust/issues/101186

Actually passing down the relation and using it instead of `eq` for the hidden type comparison has *no* effect whatsoever and allows for no further improvements at the call sites. I decided the increased complexity was not worth it and thus did not include that change in this PR.

r? `@compiler-errors`
2022-10-27 15:03:55 +02:00
Maybe Waffle
a17ccfa621 Accept TyCtxt instead of TyCtxtAt in Ty::is_* functions
Functions in answer:

- `Ty::is_freeze`
- `Ty::is_sized`
- `Ty::is_unpin`
- `Ty::is_copy_modulo_regions`
2022-10-27 15:06:08 +04:00
bors
0da281b606 Auto merge of #103623 - matthiaskrgr:rollup-318yc1t, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #103035 (Even nicer errors from assert_unsafe_precondition)
 - #103106 (Try to say that memory outside the AM is always exposed)
 - #103475 (Make param index generation a bit more robust)
 - #103525 (Move a wf-check into the site where the value is instantiated)
 - #103564 (library: allow some unused things in Miri)
 - #103586 (Process registered region obligation in `resolve_regions_with_wf_tys`)
 - #103592 (rustdoc: remove redundant CSS selector `.notable-traits .notable`)
 - #103593 (Remove an unused parser function (`Expr::returns`))
 - #103611 (Add test for issue 103574)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-10-27 10:05:16 +00:00
Matthias Krüger
0f0c044228
Rollup merge of #103593 - compiler-errors:nit-remove-returns, r=fee1-dead
Remove an unused parser function (`Expr::returns`)

I removed the only usage in #97474
2022-10-27 09:25:12 +02:00
Matthias Krüger
bf53e712c0
Rollup merge of #103586 - compiler-errors:issue-103573, r=jackh726
Process registered region obligation in `resolve_regions_with_wf_tys`

Fixes #103573
2022-10-27 09:25:11 +02:00
Matthias Krüger
2bd49c34e5
Rollup merge of #103525 - oli-obk:const_impl_on_non_const_trait, r=lcnr
Move a wf-check into the site where the value is instantiated

r? ``@lcnr``
2022-10-27 09:25:10 +02:00
Matthias Krüger
d7ad6ad9ad
Rollup merge of #103475 - oli-obk:generic_param_indices, r=lcnr
Make param index generation a bit more robust

r? ````@lcnr````

While not really necessary for closure and anon const ids, it's strictly more correct
2022-10-27 09:25:09 +02:00
bors
9dd3d29ec8 Auto merge of #103601 - compiler-errors:no-opaque-probe-in-nll-relate, r=oli-obk
Remove `commit_if_ok` probe from NLL type relation

It was not really necessary to add the `commit_if_ok` in #100092 -- I added it to protect us against weird inference error messages due to recursive RPIT calls, but we are always on the error path when this happens anyways, and I can't come up with an example that makes this manifest.

Fixes #103599

r? `@oli-obk` since you reviewed #100092, feel free to re-roll.

🅱️ 📢  beta-nominating this since it's on beta (which forks in ~a week~ two days 😨) -- worst case we could revert the original PR on beta and land this on nightly, to give it some extra soak time...
2022-10-27 07:24:39 +00:00
Michael Goulet
b1cc95da23 Remap early bound lifetimes too 2022-10-27 00:28:54 +00:00