Commit Graph

239020 Commits

Author SHA1 Message Date
bors
82b804c744 Auto merge of #118023 - matthiaskrgr:rollup-i9skwic, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #117338 (Remove asmjs)
 - #117549 (Use `copied` instead of manual `map`)
 - #117745 (Emit smir)
 - #117964 (When using existing fn as module, don't claim it doesn't exist)
 - #118006 (clarify `fn discriminant` guarantees: only free lifetimes may get erased)
 - #118016 (Add stable mir members to triagebot config)
 - #118022 (Miri subtree update)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-11-17 22:58:19 +00:00
Matthias Krüger
8acb27c165
Rollup merge of #118022 - saethlin:miri, r=saethlin
Miri subtree update
2023-11-17 23:04:25 +01:00
Matthias Krüger
d1f18492a0
Rollup merge of #118016 - celinval:main, r=compiler-errors
Add stable mir members to triagebot config

I also added the two crates from the project to `[assign.owners]` so it automatically assign to a project member changes to those crates.
2023-11-17 23:04:24 +01:00
Matthias Krüger
e06a6d3ebe
Rollup merge of #118006 - lcnr:discriminant-docs, r=compiler-errors
clarify `fn discriminant` guarantees: only free lifetimes may get erased

cc https://github.com/rust-lang/rust/pull/104299/files#r1397082347

don't think this necessitates a backport by itself, but should imo be included if one were to exist.

r? types
2023-11-17 23:04:24 +01:00
Matthias Krüger
8792e81f29
Rollup merge of #117964 - estebank:issue-81232, r=petrochenkov
When using existing fn as module, don't claim it doesn't exist

Tweak wording of module not found in resolve, when the name exists but belongs to a non-`mod` item.

Fix #81232.
2023-11-17 23:04:23 +01:00
Matthias Krüger
6227455345
Rollup merge of #117745 - ouz-a:emit_smir, r=celinval
Emit smir

This adds ability to `-Zunpretty=smir` and get smir output of a Rust file, this is obliviously pretty basic compared to `mir` output but I think we could iteratively improve it, and even at this state this is useful for us.

r? ``@celinval``
2023-11-17 23:04:23 +01:00
Matthias Krüger
aa2289d3bc
Rollup merge of #117549 - DaniPopes:more-copied, r=b-naber
Use `copied` instead of manual `map`
2023-11-17 23:04:22 +01:00
Matthias Krüger
ca3a02836e
Rollup merge of #117338 - workingjubilee:asmjs-meets-thanatos, r=b-naber
Remove asmjs

Fulfills [MCP 668](https://github.com/rust-lang/compiler-team/issues/668).

`asmjs-unknown-emscripten` does not work as-specified, and lacks essential upstream support for generating asm.js, so it should not exist at all.
2023-11-17 23:04:21 +01:00
bors
2831701757 Auto merge of #114292 - estebank:issue-71039, r=b-naber
More detail when expecting expression but encountering bad macro argument

On nested macro invocations where the same macro fragment changes fragment type from one to the next, point at the chain of invocations and at the macro fragment definition place, explaining that the change has occurred.

Fix #71039.

```
error: expected expression, found pattern `1 + 1`
  --> $DIR/trace_faulty_macros.rs:49:37
   |
LL |     (let $p:pat = $e:expr) => {test!(($p,$e))};
   |                   -------                -- this is interpreted as expression, but it is expected to be pattern
   |                   |
   |                   this macro fragment matcher is expression
...
LL |     (($p:pat, $e:pat)) => {let $p = $e;};
   |               ------                ^^ expected expression
   |               |
   |               this macro fragment matcher is pattern
...
LL |     test!(let x = 1+1);
   |     ------------------
   |     |             |
   |     |             this is expected to be expression
   |     in this macro invocation
   |
   = note: when forwarding a matched fragment to another macro-by-example, matchers in the second macro will see an opaque AST of the fragment type, not the underlying tokens
   = note: this error originates in the macro `test` (in Nightly builds, run with -Z macro-backtrace for more info)
```
2023-11-17 20:57:12 +00:00
ouz-a
92657f163a use new apis and add new function 2023-11-17 23:28:17 +03:00
Celina G. Val
99371ce7e0 Add stable mir members to triagebot config 2023-11-17 11:46:39 -08:00
bors
f6dcaee23f Auto merge of #111922 - vaporoxx:feat-searcher, r=dtolnay
feat: implement `DoubleEndedSearcher` for `CharArray[Ref]Searcher`

This PR implements `DoubleEndedSearcher` for both `CharArraySearcher` and `CharArrayRefSearcher`. I'm not sure whether this was just overlooked or if there is a reason for it, but since it behaves exactly like `CharSliceSearcher`, I think the implementations should be appropriate.
2023-11-17 18:47:34 +00:00
bors
e886137e18 Auto merge of #117993 - nnethercote:streamline-Linker, r=bjorn3
Streamline `Linker`

r? `@bjorn3`
2023-11-17 16:49:58 +00:00
bors
069a4af48b Auto merge of #117944 - lcnr:region-refactor-uwu, r=BoxyUwU
some additional region refactorings

the commits are selfcontained 

r? `@BoxyUwU`
2023-11-17 14:27:20 +00:00
bors
4d7f952a02 Auto merge of #112422 - aliemjay:implied-bounds-placeholders, r=lcnr
ignore implied bounds with placeholders

given the following code:
```rust
trait Trait {
    type Ty<'a> where Self: 'a;
}

impl<T> Trait for T {
    type Ty<'a> = () where Self: 'a;
}

struct Foo<T: Trait>(T)
where
    for<'x> T::Ty<'x>: Sized;
```

when computing the implied bounds from `Foo<X>` we incorrectly get the bound `X: !x` from the normalization of ` for<'x> <X as Trait>::Ty::<'x>: Sized`. This is a a known bug! we shouldn't use the constraints that arise from normalization as implied bounds. See #109628.

Ignore these bounds for now. This should prevent later ICEs.

Fixes #112250
Fixes #107409
2023-11-17 12:16:53 +00:00
lcnr
3b0e1d23b7 only free lifetimes may get erased 2023-11-17 11:03:52 +00:00
Oğuz Ağcayazı
71c990470a move pretty into stable_mir 2023-11-17 13:28:43 +03:00
Oğuz Ağcayazı
3883645a9b change smir to StableMir 2023-11-17 13:28:07 +03:00
Oğuz Ağcayazı
c821603484 remove unwrap 2023-11-17 13:28:07 +03:00
Oğuz Ağcayazı
ebd9c145f6 better formatting for statements 2023-11-17 13:28:07 +03:00
Oğuz Ağcayazı
0f0e9baf19 cover statements 2023-11-17 13:28:07 +03:00
Oğuz Ağcayazı
ae179a04b6 emit basic smir 2023-11-17 13:28:07 +03:00
bors
78efca8845 Auto merge of #117278 - lcnr:try-normalize-ty, r=compiler-errors
new solver normalization improvements

cool beans

At the core of this PR is a `try_normalize_ty` which stops for rigid aliases by using `commit_if_ok`.

Reworks alias-relate to fully normalize both the lhs and rhs and then equate the resulting rigid (or inference) types. This fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/68 by avoiding the exponential blowup. Also supersedes #116369 by only defining opaque types if the hidden type is rigid.

I removed the stability check in `EvalCtxt::evaluate_goal` due to https://github.com/rust-lang/trait-system-refactor-initiative/issues/75. While I personally have opinions on how to fix it, that still requires further t-types/`@nikomatsakis` buy-in, so I removed that for now. Once we've decided on our approach there, we can revert this commit.

r? `@compiler-errors`
2023-11-17 10:16:41 +00:00
lcnr
40b154e53c rename bound region instantiation
- `erase_late_bound_regions` -> `instantiate_bound_regions_with_erased`
- `replace_late_bound_regions_X` -> `instantiate_bound_regions_X`
2023-11-17 09:29:48 +00:00
lcnr
41cfb20abb replace unnecessary folder impls with fold_region 2023-11-17 08:58:18 +00:00
bors
ee5ef3aac9 Auto merge of #118003 - matthiaskrgr:rollup-80t3uky, r=matthiaskrgr
Rollup of 3 pull requests

Successful merges:

 - #115476 (document ABI compatibility)
 - #117688 (Misc changes to StableMIR required to Kani use case.)
 - #117998 (On resolve error of `[rest..]`, suggest `[rest @ ..]`)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-11-17 07:53:40 +00:00
Matthias Krüger
488c2aac29
Rollup merge of #117998 - estebank:issue-88404, r=TaKO8Ki
On resolve error of `[rest..]`, suggest `[rest @ ..]`

When writing a pattern to collect multiple entries of a slice in a single binding, it is easy to misremember or typo the appropriate syntax to do so, instead writing the experimental `X..` pattern syntax. When we encounter a resolve error because `X` isn't available, we suggest `X @ ..` as an alternative.

```
error[E0425]: cannot find value `rest` in this scope
  --> $DIR/range-pattern-meant-to-be-slice-rest-pattern.rs:3:13
   |
LL |         [1, rest..] => println!("{rest:?}"),
   |             ^^^^ not found in this scope
   |
help: if you meant to collect the rest of the slice in `rest`, use the at operator
   |
LL |         [1, rest @ ..] => println!("{rest:?}"),
   |                  +
```

Fix #88404.
2023-11-17 08:10:27 +01:00
Matthias Krüger
c188486267
Rollup merge of #117688 - celinval:smir-kani-reach, r=compiler-errors
Misc changes to StableMIR required to Kani use case.

First, I wanted to say that I can split this review into multiple if it makes reviewing easier. I bundled them up, since I've been testing them together (See https://github.com/rust-lang/project-stable-mir/pull/51 for the set of more thorough checks).

So far, this review includes 3 commits:

1. Add more APIs and fix `Instance::body`
    - Add more APIs to retrieve information about types.
    - Add a few more instance resolution options. For the drop shim, we return None if the drop body is empty. Not sure it will be enough.
    - Make `Instance::body()` return an Option<Body>, since not every instance might have an available body. For example, foreign instances, virtual instances, dependencies.
2. Fix a bug on MIRVisitor
    - We were not iterating over all local variables due to a typo.
3. Add more SMIR internal impl and callback return value
    - In cases like Kani, we will invoke the rustc_internal run command directly for now. It would be handly to be able to have a callback that can return a value.
    - We also need extra methods to convert stable constructs into internal ones, so we can break down the transition into finer grain commits.
    - For the internal implementation of Region, we're always returning `ReErased` for now.
2023-11-17 08:10:26 +01:00
Matthias Krüger
1cabedc256
Rollup merge of #115476 - RalfJung:abi-compat-docs, r=Mark-Simulacrum
document ABI compatibility

I don't think we have any central place where we document our ABI compatibility rules, so let's create one. The `fn()` pointer type seems like a good place since ABI questions can only become relevant when invoking a function through a function pointer.

This will likely need T-lang FCP.
2023-11-17 08:10:26 +01:00
Ralf Jung
8f03a55566 linking in general has more pitfalls than just call ABI 2023-11-17 08:02:28 +01:00
Nicholas Nethercote
9582172964 Make Compiler::sess private.
Like `Compiler::codegen_backend`.
2023-11-17 17:30:41 +11:00
Nicholas Nethercote
4a57b80f3f Remove a low-value local variable. 2023-11-17 17:30:40 +11:00
Nicholas Nethercote
94c9075b27 Rename Linker::prepare_outputs as output_filenames.
It matches the type, and a noun makes more sense than a verb.

The `output_filenames` function still uses a profiling label named
`prepare_outputs`, but I think that makes sense as a verb and can be
left unchanged.
2023-11-17 17:30:38 +11:00
Nicholas Nethercote
aed8e1f3b6 Move CodegenBackend out of Linker.
It can easily be passed in. And that removes the single clone of
`Compiler::codegen_backend`, which means it no longer needs to be `Lrc`.
2023-11-17 17:30:36 +11:00
Nicholas Nethercote
de91b6d249 Move Session out of Linker.
It can easily be passed in. And that removes the single clone of
`Compiler::session`, which means it no longer needs to be `Lrc`.
2023-11-17 17:14:17 +11:00
Nicholas Nethercote
3560122bfc Streamline Queries::linker. 2023-11-17 17:14:17 +11:00
bors
00bfd6b273 Auto merge of #117985 - lnicola:sync-from-ra, r=lnicola
Subtree update of `rust-analyzer`

r? `@ghost`

Out of band, but required for https://github.com/rust-lang/rust/pull/117981.
2023-11-17 05:55:59 +00:00
bors
4770d91093 Auto merge of #118001 - TaKO8Ki:rollup-fedlwwj, r=TaKO8Ki
Rollup of 5 pull requests

Successful merges:

 - #117649 (Move `lint_store`)
 - #117850 (bootstrap: simplify setting unstable-options for tools)
 - #117889 (docs(release): Clarify cargo entries)
 - #117946 (avoid exhaustive i16 test in Miri)
 - #117963 (`rustc_query_system` cleanups)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-11-17 03:57:57 +00:00
Takayuki Maeda
68f5762ff0
Rollup merge of #117963 - nnethercote:rustc_query_system, r=compiler-errors
`rustc_query_system` cleanups

Minor cleanups.

r? `@compiler-errors`
2023-11-17 12:56:32 +09:00
Takayuki Maeda
c77cb7a3f6
Rollup merge of #117946 - RalfJung:miri-libcore-test, r=Mark-Simulacrum
avoid exhaustive i16 test in Miri

https://github.com/rust-lang/rust/pull/116301 added a test that is way too slow to be running in Miri. So let's only test a few hopefully representative cases.
2023-11-17 12:56:31 +09:00
Takayuki Maeda
3c0f22d99c
Rollup merge of #117889 - epage:docs, r=Mark-Simulacrum
docs(release): Clarify cargo entries

Trying to make these easier to scan and more understandable out of the context of their PR
2023-11-17 12:56:31 +09:00
Takayuki Maeda
3644594cf3
Rollup merge of #117850 - onur-ozkan:fix-116538, r=Mark-Simulacrum
bootstrap: simplify setting unstable-options for tools

Previously, we unconditionally(instead of `if path == "src/tools/clippy" || ..`) set this (to prevent recompiling tools between `x check $tool` and '` check $another_tool` executions) specifically for tools in the `x check` step. This PR relocates that logic to `fn prepare_tool_cargo`, making it step-agnostic.

Fixes #116538
Fixes #117983
2023-11-17 12:56:30 +09:00
Takayuki Maeda
2b2dd2514e
Rollup merge of #117649 - nnethercote:mv-lint_store, r=cjgillot
Move `lint_store`

Some nice cleanups enabled by the removal of compiler plugins.

r? `@cjgillot`
2023-11-17 12:56:30 +09:00
bors
15a791fa35 Auto merge of #117987 - bjorn3:sync_cg_clif-2023-11-16, r=bjorn3
Subtree sync for rustc_codegen_cranelift

The main highlights this time are support for AES and SHA256 crypto intrinsics on x86_64 by lowering to inline asm.

r? `@ghost`

`@rustbot` label +A-codegen +A-cranelift +T-compiler
2023-11-17 01:59:59 +00:00
Esteban Küber
5c3e01a340 On resolve error of [rest..], suggest [rest @ ..]
When writing a pattern to collect multiple entries of a slice in a
single binding, it is easy to misremember or typo the appropriate syntax
to do so, instead writing the experimental `X..` pattern syntax. When we
encounter a resolve error because `X` isn't available, we suggest
`X @ ..` as an alternative.

```
error[E0425]: cannot find value `rest` in this scope
  --> $DIR/range-pattern-meant-to-be-slice-rest-pattern.rs:3:13
   |
LL |         [1, rest..] => println!("{rest:?}"),
   |             ^^^^ not found in this scope
   |
help: if you meant to collect the rest of the slice in `rest`, use the at operator
   |
LL |         [1, rest @ ..] => println!("{rest:?}"),
   |                  +
```

Fix #88404.
2023-11-17 00:55:55 +00:00
bors
f2f526cafa Auto merge of #117996 - matthiaskrgr:rollup-sp48bl4, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #117892 (Detect more `=>` typos)
 - #117959 (Better handle type errors involving `Self` literals)
 - #117980 (fix: Update CONTRIBUTING.md recommend -> recommended)
 - #117982 (bootstrap: only show PGO warnings when verbose)
 - #117990 (Tweak error and move tests)

Failed merges:

 - #117944 (some additional region refactorings)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-11-17 00:03:54 +00:00
Matthias Krüger
a5d7f8bcf2
Rollup merge of #117990 - estebank:issue-100825-part-deux, r=Nilstrieb
Tweak error and move tests

r? `@Nilstrieb`

Split off #117565.
2023-11-17 00:41:24 +01:00
Matthias Krüger
f82fefd11e
Rollup merge of #117982 - cuviper:quiet-pgo, r=onur-ozkan
bootstrap: only show PGO warnings when verbose

Building rustc with `--rust-profile-use` is currently dumping a lot of
warnings of "no profile data available for function" from `rustc_smir`
and `stable_mir`. These simply aren't exercised by the current profile-
gathering steps, but that's to be expected for new or experimental
functionality. I think for most people, these warnings will be just
noise, so it makes sense to only have them in verbose builds.
2023-11-17 00:41:24 +01:00
Matthias Krüger
7437151212
Rollup merge of #117980 - WhistlingZephyr:patch-1, r=Dylan-DPC
fix: Update CONTRIBUTING.md recommend -> recommended

Redo of https://github.com/rust-lang/rust/pull/116529.
2023-11-17 00:41:24 +01:00
Matthias Krüger
dd49c39e02
Rollup merge of #117959 - estebank:issue-76086, r=compiler-errors
Better handle type errors involving `Self` literals

When encountering a type error involving a `Self` literal, point at the self type of the enclosing `impl` and suggest using the actual type name instead.

```
error[E0308]: mismatched types
  --> $DIR/struct-path-self-type-mismatch.rs:13:9
   |
LL |   impl<T> Foo<T> {
   |        -  ------ this is the type of the `Self` literal
   |        |
   |        found type parameter
LL |       fn new<U>(u: U) -> Foo<U> {
   |              -           ------ expected `Foo<U>` because of return type
   |              |
   |              expected type parameter
LL | /         Self {
LL | |
LL | |             inner: u
LL | |
LL | |         }
   | |_________^ expected `Foo<U>`, found `Foo<T>`
   |
   = note: expected struct `Foo<U>`
              found struct `Foo<T>`
   = note: a type parameter was expected, but a different one was found; you might be missing a type parameter or trait bound
   = note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters
help: use the type name directly
   |
LL |         Foo::<U> {
   |         ~~~~~~~~
```
Fix #76086.
2023-11-17 00:41:23 +01:00