Commit Graph

9675 Commits

Author SHA1 Message Date
Vadim Petrochenkov
5989400e2e resolve: Pre-compute non-reexport module children
Instead of repeating the same logic by walking HIR during metadata encoding.

The only difference is that we are no longer encoding `macro_rules` items, but we never currently need them as a part of this list.
They can be encoded separately if this need ever arises.

`module_reexports` is also un-querified, because I don't see any reasons to make it a query, only overhead.
2023-04-12 15:22:03 +03:00
Philipp Krones
6b95029f17 Merge commit '83e42a2337dadac915c956d125f1d69132f36425' into clippyup 2023-04-11 15:31:08 +02:00
Ben Kimock
fe129a022a Merge from rustc 2023-04-10 07:55:57 -04:00
bors
d048c1130f Auto merge of #110031 - compiler-errors:generic-elaboration, r=b-naber
Make elaboration generic over input

Combines all the `elaborate_*` family of functions into just one, which is an iterator over the same type that you pass in (e.g. elaborating `Predicate` gives `Predicate`s, elaborating `Obligation`s gives `Obligation`s, etc.)
2023-04-09 00:18:10 +00:00
Michael Goulet
0963a66ab3 Make elaborator generic 2023-04-06 23:30:22 +00:00
Gary Guo
293c1a1a6a Fix tools 2023-04-06 09:34:16 +01:00
Gary Guo
f5ac844296 Refactor unwind from Option to a new enum 2023-04-06 09:34:16 +01:00
Oli Scherer
e9c7fb10b9 Rename ast::Static to ast::StaticItem to match ast::ConstItem 2023-04-04 15:34:40 +00:00
Oli Scherer
e610ddfa5e box a bunch of large types 2023-04-04 13:58:50 +00:00
Oli Scherer
ff7636db6a Split out ast::ItemKind::Const into its own struct 2023-04-04 09:44:50 +00:00
Oli Scherer
929696d754 rust-analyzer guided tuple field to named field 2023-04-04 09:44:50 +00:00
Oli Scherer
a6beddcc5a rust-analyzer guided enum variant structification 2023-04-04 09:44:45 +00:00
Oli Scherer
a937f49c17 Merge from rustc 2023-04-04 08:01:31 +00:00
bors
6a6a262f7b Auto merge of #109010 - compiler-errors:rtn, r=eholk
Initial support for return type notation (RTN)

See: https://smallcultfollowing.com/babysteps/blog/2023/02/13/return-type-notation-send-bounds-part-2/

1. Only supports `T: Trait<method(): Send>` style bounds, not `<T as Trait>::method(): Send`. Checking validity and injecting an implicit binder for all of the late-bound method generics is harder to do for the latter.
    * I'd add this in a follow-up.
3. ~Doesn't support RTN in general type position, i.e. no `let x: <T as Trait>::method() = ...`~
    * I don't think we actually want this.
5. Doesn't add syntax for "eliding" the function args -- i.e. for now, we write `method(): Send` instead of `method(..): Send`.
    * May be a hazard if we try to add it in the future. I'll probably add it in a follow-up later, with a structured suggestion to change `method()` to `method(..)` once we add it.
7. ~I'm not in love with the feature gate name 😺~
    * I renamed it to `return_type_notation` ✔️

Follow-up PRs will probably add support for `where T::method(): Send` bounds. I'm not sure if we ever want to support return-type-notation in arbitrary type positions. I may also make the bounds require `..` in the args list later.

r? `@ghost`
2023-03-31 18:04:12 +00:00
bors
3c964ea46c Auto merge of #98112 - saethlin:mir-alignment-checks, r=oli-obk
Insert alignment checks for pointer dereferences when debug assertions are enabled

Closes https://github.com/rust-lang/rust/issues/54915

- [x] Jake tells me this sounds like a place to use `MirPatch`, but I can't figure out how to insert a new basic block with a new terminator in the middle of an existing basic block, using `MirPatch`. (if nobody else backs up this point I'm checking this as "not actually a good idea" because the code looks pretty clean to me after rearranging it a bit)
- [x] Using `CastKind::PointerExposeAddress` is definitely wrong, we don't want to expose. Calling a function to get the pointer address seems quite excessive. ~I'll see if I can add a new `CastKind`.~ `CastKind::Transmute` to the rescue!
- [x] Implement a more helpful panic message like slice bounds checking.

r? `@oli-obk`
2023-03-31 08:50:35 +00:00
Trevor Gross
4cf5bdc60c Stabilize a portion of 'once_cell'
Move items not part of this stabilization to 'lazy_cell' or 'once_cell_try'
2023-03-29 18:04:44 -04:00
Matthias Krüger
d57abf382b Rollup merge of #108548 - jamen:master, r=compiler-errors
Clarify the 'use a constant in a pattern' error message

```rs
use std::borrow::Cow;

const ERROR_CODE: Cow<'_, str> = Cow::Borrowed("23505");

fn main() {
    let x = Cow::from("23505");

    match x {
        ERROR_CODE => {}
    }
}
```
```
error: to use a constant of type `Cow` in a pattern, `Cow` must be annotated with `#[derive(PartialEq, Eq)]`
 --> src/main.rs:9:9
  |
9 |         ERROR_CODE => {}
  |         ^^^^^^^^^^

error: could not compile `playground` due to previous error
```

It seems helpful to link to StructuralEq in this message. I was a little confused, because `Cow<'_, str>` implements PartialEq and Eq, but they're not derived, which I learned is necessary for structural equality and using constants in patterns (thanks to the Rust community Discord server)

For tests, should I update every occurrence of this message? I see tests where this is still a warning and I'm not sure if I should update those.
2023-03-28 07:01:08 +02:00
Michael Goulet
fc6262fa0c Add (..) syntax for RTN 2023-03-28 01:14:28 +00:00
Guillaume Gomez
538e8bdcc8 Rollup merge of #109354 - Swatinem:rm-closureid, r=compiler-errors
Remove the `NodeId` of `ast::ExprKind::Async`

This is a followup to https://github.com/rust-lang/rust/pull/104833#pullrequestreview-1314537416.

In my original attempt, I was using `LoweringContext::expr`, which was not correct as it creates a fresh `DefId`.
It now uses the correct `DefId` for the wrapping `Expr`, and also makes forwarding `#[track_caller]` attributes more explicit.
2023-03-27 18:56:19 +02:00
Jamen Marz
28b80059ed Add notes to non-structural const in pattern error message 2023-03-27 11:08:11 -04:00
Michael Goulet
db4e4afce8 Don't elaborate non-obligations into obligations 2023-03-26 20:33:54 +00:00
Philipp Krones
8df896c076 Merge commit 'd5e2a7aca55ed49fc943b7a07a8eba05ab5a0079' into clippyup 2023-03-24 14:26:19 +01:00
Ralf Jung
b6495af39a Merge from rustc 2023-03-24 10:38:17 +01:00
Ben Kimock
f96e38becb Fix clippy 2023-03-23 20:19:45 -04:00
Ben Kimock
765c6b865c A MIR transform that checks pointers are aligned 2023-03-23 18:23:06 -04:00
bors
58eb9964cc Auto merge of #108442 - scottmcm:mir-transmute, r=oli-obk
Add `CastKind::Transmute` to MIR

~~Nothing actually produces it in this commit, so I don't know how to test it, but it also means it shouldn't be possible for it to break anything.~~

Includes lowering `transmute` calls to it, so it's used.

Zulip Conversation: <https://rust-lang.zulipchat.com/#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/Good.20first.20isssue/near/321849610>
2023-03-23 18:43:04 +00:00
bors
f34590478b Auto merge of #109517 - matthiaskrgr:rollup-m3orqzd, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #108541 (Suppress `opaque_hidden_inferred_bound` for nested RPITs)
 - #109137 (resolve: Querify most cstore access methods (subset 2))
 - #109380 (add `known-bug` test for unsoundness issue)
 - #109462 (Make alias-eq have a relation direction (and rename it to alias-relate))
 - #109475 (Simpler checked shifts in MIR building)
 - #109504 (Stabilize `arc_into_inner` and `rc_into_inner`.)
 - #109506 (make param bound vars visibly bound vars with -Zverbose)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-03-23 12:35:05 +00:00
Oli Scherer
95bb48667b Merge from rustc 2023-03-23 07:33:19 +00:00
Michael Goulet
b506eb5338 Rename AliasEq -> AliasRelate 2023-03-23 05:56:40 +00:00
Scott McMurray
8bdd54e8c6 Add CastKind::Transmute to MIR
Updates `interpret`, `codegen_ssa`, and `codegen_cranelift` to consume the new cast instead of the intrinsic.

Includes `CastTransmute` for custom MIR building, to be able to test the extra UB.
2023-03-22 15:15:41 -07:00
Ralf Jung
8889587197 Merge from rustc 2023-03-22 16:40:18 +01:00
Vadim Petrochenkov
cae7b87711 rustc: Remove unused Session argument from some attribute functions 2023-03-22 13:55:55 +04:00
bors
6db2d5989f Auto merge of #109119 - lcnr:trait-system-cleanup, r=compiler-errors
a general type system cleanup

removes the helper functions `traits::fully_solve_X` as they add more complexity then they are worth. It's confusing which of these helpers should be used in which context.

changes the way we deal with overflow to always add depth in `evaluate_predicates_recursively`. It may make sense to actually fully transition to not have `recursion_depth` on obligations but that's probably a bit too much for this PR.

also removes some other small - and imo unnecessary - helpers.

r? types
2023-03-22 05:33:18 +00:00
Michael Goulet
6f62887968 Use local key in providers 2023-03-21 15:38:51 +00:00
lcnr
5810f1fe3c remove some trait solver helpers
they add more complexity then they are worth. It's confusing
which of these helpers should be used in which context.
2023-03-21 09:57:20 +01:00
Arpad Borsos
1e17a443b3 Remove the NodeId of ast::ExprKind::Async 2023-03-19 19:01:31 +01:00
Matthias Krüger
60fe49c54c Rollup merge of #108958 - clubby789:unbox-the-hir, r=compiler-errors
Remove box expressions from HIR

After #108516, `#[rustc_box]` is used at HIR->THIR lowering and this is no longer emitted, so it can be removed.

This is based on top of #108471 to help with conflicts, so 43490488ccacd1a822e9c621f5ed6fca99959a0b is the only relevant commit (sorry for all the duplicated pings!)

````@rustbot```` label +S-blocked
2023-03-17 08:42:37 +01:00
Mara Bos
d1b28f3a5f Fix clippy. 2023-03-16 12:08:07 +01:00
clubby789
f2eddc5924 Remove box expressions from HIR 2023-03-14 17:18:26 +00:00
bors
491f63214a Auto merge of #104833 - Swatinem:async-identity-future, r=compiler-errors
Remove `identity_future` indirection

This was previously needed because the indirection used to hide some unexplained lifetime errors, which it turned out were related to the `min_choice` algorithm.

Removing the indirection also solves a couple of cycle errors, large moves and makes async blocks support the `#[track_caller]`annotation.

Fixes https://github.com/rust-lang/rust/issues/104826.
2023-03-14 10:12:58 +00:00
bors
ff23e48c30 Auto merge of #108471 - clubby789:unbox-the-syntax, r=Nilstrieb,est31
Remove `box_syntax`

r? `@Nilstrieb`

This removes the feature `box_syntax`, which allows the use of `box <expr>` to create a Box, and finalises removing use of the feature from the compiler. `box_patterns` (allowing the use of `box <pat>` in a pattern) is unaffected.
It also removes `ast::ExprKind::Box` - the only way to create a 'box' expression now is with the rustc-internal `#[rustc_box]` attribute.
As a temporary measure to help users move away, `box <expr>` now parses the inner expression, and emits a `MachineApplicable` lint to replace it with `Box::new`

Closes #49733
2023-03-13 10:41:50 +00:00
bors
e07c6b4899 Auto merge of #108872 - cjgillot:simp-const-prop, r=oli-obk
Strengthen state tracking in const-prop

Some/many of the changes are replicated between both the const-prop lint and the const-prop optimization.

Behaviour changes:
- const-prop opt does not give a span to propagated values. This was useless as that span's primary purpose is to diagnose evaluation failure in codegen.
- we remove the `OnlyPropagateInto` mode. It was only used for function arguments, which are better modeled by a write before entry.
- the tracking of assignments and discriminants make clearer that we do nothing in `NoPropagation` mode or on indirect places.
2023-03-12 23:27:52 +00:00
clubby789
15f24234c8 Remove box_syntax from AST and use in tools 2023-03-12 13:19:46 +00:00
clubby789
213a22efb9 Remove uses of box_syntax in rustc and tools 2023-03-12 13:19:46 +00:00
Matthias Krüger
7449912989 Rollup merge of #108950 - cjgillot:inherit-less, r=compiler-errors
Directly construct Inherited in typeck.

Using `InheritedBuilder` + a closure does not seem necessary any more.

+ a few opportunistic simplifications to typeck entry point.
2023-03-11 12:55:44 +01:00
bors
7333b36fa4 Auto merge of #104527 - ferrocene:pa-more-licenses, r=pnkfelix
Add more license annotations

This PR updates the `.reuse/dep5` file to include more accurate licensing data for everything in the repository (*excluding* submodules and dependencies). Some decisions were made in this PR:

* The standard copyright attribution for files maintained by us is "The Rust Project Developers (see https://thanks.rust-lang.org)", to avoid having to maintain an in-tree `AUTHORS` file.
* For files that have specific licensing terms, we added the terms to the `.reuse/dep5` rather than adding SPDX comments in the files themselves.
* REUSE picks up any comment/text line with `Copyright` on it, so I had to sprinkle around `REUSE-IgnoreStart` and `REUSE-IgnoreEnd` comments.

The rendered `COPYRIGHT` file is available at https://gist.github.com/pietroalbini/efb81103f69596d39758114f3f6a8688.

r? `@pnkfelix`
2023-03-11 01:17:23 +00:00
bors
15d7278df8 Auto merge of #108974 - flip1995:clippyup, r=Manishearth
Update Clippy

r? `@Manishearth`

cc `@m-ou-se` This sync also includes https://github.com/rust-lang/rust-clippy/pull/10275
2023-03-10 20:08:26 +00:00
Camille GILLOT
5c85cd9fee Directly construct Inherited. 2023-03-10 19:22:55 +00:00
Philipp Krones
cf8a67d9ad Merge commit '3c06e0b1ce003912f8fe0536d3a7fe22558e38cf' into clippyup 2023-03-10 10:53:50 +01:00
Camille GILLOT
27910cbcbd Introduce a no-op PlaceMention statement for let _ =. 2023-03-09 17:45:13 +00:00