Commit Graph

1651 Commits

Author SHA1 Message Date
Matthias Krüger
5a017d3a57
Rollup merge of #108549 - clubby789:fix-link-cfg-issue, r=eholk
Remove issue number for `link_cfg`

Fixes #72059

Per #37406 and its [unstable book entry](https://doc.rust-lang.org/beta/unstable-book/language-features/link-cfg.html), this is an internal feature, and therefore perma-unstable and not being tracked
2023-03-23 19:55:44 +01:00
Matthias Krüger
bacf059f57
Rollup merge of #107880 - jieyouxu:issue-107563, r=petrochenkov
Lint ambiguous glob re-exports

Attempts to fix #107563.

We currently already emit errors for ambiguous re-exports when two names are re-exported *specifically*, i.e. not from glob exports. This PR attempts to emit deny-by-default lints for ambiguous glob re-exports.
2023-03-23 19:55:43 +01:00
Matthias Krüger
acd7f878ae
Rollup merge of #107718 - Zoxc:z-time, r=nnethercote
Add `-Z time-passes-format` to allow specifying a JSON output for `-Z time-passes`

This adds back the `-Z time` option as that is useful for [my rustc benchmark tool](https://github.com/Zoxc/rcb), reverting https://github.com/rust-lang/rust/pull/102725. It now uses nanoseconds and bytes as the units so it is renamed to `time-precise`.
2023-03-23 19:55:43 +01:00
Michael Goulet
e55f73ae47 Refine error spans for const args in hir typeck 2023-03-23 18:51:30 +00:00
bors
e216300876 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
df7fd9995f Auto merge of #108221 - petrochenkov:cratecfg, r=michaelwoerister
rustc_interface: Add a new query `pre_configure`

It partially expands crate attributes before the main expansion pass (without modifying the crate), and the produced preliminary crate attribute list is used for querying a few attributes that are required very early.

Crate-level cfg attributes on the crate itself are then expanded normally during the main expansion pass, like attributes on any other nodes.
This is a continuation of https://github.com/rust-lang/rust/pull/92473 and one more step to very unstable crate-level proc macro attributes maybe actually working.

Previously crate attributes were pre-configured simultaneously with feature extraction, and then written directly into `ast::Crate`.
2023-03-23 15:17:59 +00:00
bors
99c49d95cd 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
Vadim Petrochenkov
bec4eab3f9 rustdoc: Skip doc link resolution for non-exported items 2023-03-23 16:19:59 +04:00
Guillaume Gomez
c8c342c072 Add regression test for #109282 2023-03-23 12:53:30 +01:00
Vadim Petrochenkov
f26da39e04 Add some tests for the current #![cfg(FALSE)] crate behavior 2023-03-23 14:21:02 +04:00
bors
9a6b0c3326 Auto merge of #108355 - dpaoliello:dlltoolm, r=michaelwoerister
Fix cross-compiling with dlltool for raw-dylib

Fix for #103939

Issue Details:
When attempting to cross-compile using the `raw-dylib` feature and the GNU toolchain, rustc would attempt to find a cross-compiling version of dlltool (e.g., `i686-w64-mingw32-dlltool`). The has two issues 1) on Windows dlltool is always `dlltool` (no cross-compiling named versions exist) and 2) it only supported compiling to i686 and x86_64 resulting in ARM 32 and 64 compiling as x86_64.

Fix Details:
* On Windows always use the normal `dlltool` binary.
* Add the ARM64 cross-compiling dlltool name (support for this is coming: https://sourceware.org/bugzilla/show_bug.cgi?id=29964)
* Provide the `-m` argument to dlltool to indicate the target machine type.

(This is the first of two PRs to fix the remaining issues for the `raw-dylib` feature (#58713) that is blocking stabilization (#104218))
2023-03-23 09:51:32 +00:00
Matthias Krüger
7afed92749
Rollup merge of #109475 - scottmcm:simpler-shifts, r=WaffleLapkin
Simpler checked shifts in MIR building

Doing masking to check unsigned shift amounts is overcomplicated; just comparing the shift directly saves a statement and a temporary, as well as is much easier to read as a human.  And shifting by unsigned is the canonical case -- notably, all the library shifting methods (that don't support every type) take shift RHSs as `u32` -- so we might as well make that simpler since it's easy to do so.

This PR also changes *signed* shift amounts to `IntToInt` casts and then uses the same check as for unsigned.  The bit-masking is a nice trick, but for example LLVM actually canonicalizes it to an unsigned comparison anyway <https://rust.godbolt.org/z/8h59fMGT4> so I don't think it's worth the effort and the extra `Constant`.  (If MIR's `assert` was `assert_nz` then the masking might make sense, but when the `!=` uses another statement I think the comparison is better.)

To review, I suggest looking at 2ee0468c49 first -- that's the interesting code change and has a MIR diff.

My favourite part of the diff:
```diff
-        _20 = BitAnd(_19, const 340282366920938463463374607431768211448_u128); // scope 0 at $DIR/shifts.rs:+2:34: +2:44
-        _21 = Ne(move _20, const 0_u128); // scope 0 at $DIR/shifts.rs:+2:34: +2:44
-        assert(!move _21, "attempt to shift right by `{}`, which would overflow", _19) -> [success: bb3, unwind: bb7]; // scope 0 at $DIR/shifts.rs:+2:34: +2:44
+        _18 = Lt(_17, const 8_u128);     // scope 0 at $DIR/shifts.rs:+2:34: +2:44
+        assert(move _18, "attempt to shift right by `{}`, which would overflow", _17) -> [success: bb3, unwind: bb7]; // scope 0 at $DIR/shifts.rs:+2:34: +2:44
```
2023-03-23 08:35:35 +01:00
Matthias Krüger
5d28853efe
Rollup merge of #109462 - compiler-errors:alias-relate, r=BoxyUwU,lcnr
Make alias-eq have a relation direction (and rename it to alias-relate)

Emitting an "alias-eq" is too strict in some situations, since we don't always want strict equality between a projection and rigid ty. Adds a relation direction.

* I could probably just reuse this [`RelationDir`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_infer/infer/combine/enum.RelationDir.html) -- happy to uplift that struct into middle and use that instead, but I didn't feel compelled to... 🤷
* Some of the matching in `compute_alias_relate_goal` is a bit verbose -- I guess I could simplify it by using [`At::relate`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_infer/infer/at/struct.At.html#method.relate) and mapping the relation-dir to a variance.
* Alternatively, I coulld simplify things by making more helper functions on `EvalCtxt` (e.g. `EvalCtxt::relate_with_direction(T, T)` that also does the nested goal registration). No preference.

r? ```@lcnr``` cc ```@BoxyUwU``` though boxy can claim it if she wants
NOTE: first commit is all the changes, the second is just renaming stuff
2023-03-23 08:35:35 +01:00
Matthias Krüger
a26ac4cb94
Rollup merge of #109380 - Randl:patch-1, r=oli-obk
add `known-bug` test for unsoundness issue

Test for https://github.com/rust-lang/rust/issues/97156
2023-03-23 08:35:34 +01:00
Matthias Krüger
8ab490ff36
Rollup merge of #108541 - compiler-errors:lol-nested-rpits, r=oli-obk
Suppress `opaque_hidden_inferred_bound` for nested RPITs

They trigger too much, making repos like linkerd/linkerd2-proxy#2275 sad.

Ideally, at least for RPITs (and probably TAITs?), specifically when we have `impl Trait<Assoc = impl ..>`, that nested opaque should have the necessary `Assoc` item bounds elaborated into its own item bounds. But that's another story.

r? ```@oli-obk```
2023-03-23 08:35:33 +01:00
bors
84dd6dfd9d Auto merge of #109503 - matthiaskrgr:rollup-cnp7kdd, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #108954 (rustdoc: handle generics better when matching notable traits)
 - #109203 (refactor/feat: refactor identifier parsing a bit)
 - #109213 (Eagerly intern and check CrateNum/StableCrateId collisions)
 - #109358 (rustc: Remove unused `Session` argument from some attribute functions)
 - #109359 (Update stdarch)
 - #109378 (Remove Ty::is_region_ptr)
 - #109423 (Use region-erased self type during IAT selection)
 - #109447 (new solver cleanup + implement coherence)
 - #109501 (make link clickable)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-03-23 07:01:03 +00:00
Michael Goulet
e5189cc7e4 Nested impl traits trigger opaque_hidden_inferred_bound too much 2023-03-23 06:19:52 +00:00
Michael Goulet
5dc3fd7c05 Include relation direction in AliasEq predicate 2023-03-23 05:56:27 +00:00
Eric Huss
2da2ade0f7 Rename tests to ensure they don't have overlapping names.
Some tests will delete their output directory before starting.
The output directory is based on the test names.
If one test is the prefix of another test, then when that test
starts, it could try to delete the output directory of the other
test with the longer path.
2023-03-22 21:12:40 -07:00
bors
cf811810fe Auto merge of #109172 - scottmcm:move-codegen-issues-tests, r=WaffleLapkin
mv tests/codegen/issue-* tests/codegen/issues/

No changes to the contents; just a move.

Like how there's a <https://github.com/rust-lang/rust/tree/master/tests/ui/issues> folder.
2023-03-23 04:11:47 +00:00
Scott McMurray
64cce5fc7d 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
Matthias Krüger
28b9354bf6
Rollup merge of #109447 - lcnr:coherence, r=compiler-errors
new solver cleanup + implement coherence

the cleanup:
- change `Certainty::unify_and` to consider ambig + overflow to be ambig
- rename `trait_candidate_should_be_dropped_in_favor_of` to `candidate_should_be_dropped_in_favor_of`
- remove outdated fixme

For coherence I mostly just add an ambiguous candidate if the current trait ref is unknowable. I am doing the same for reservation impl where I also just add an ambiguous candidate.
2023-03-22 22:44:43 +01:00
Matthias Krüger
b22db3fca4
Rollup merge of #109423 - fmease:iat-selection-erase-regions-in-self-ty, r=compiler-errors
Use region-erased self type during IAT selection

Split off from #109410 as discussed.
Fixes #109299.

Re UI test: I use a reproducer of #109299 that contains a name resolution error instead of reproducer [`regionck-2.rs`](fc7ed4af16/tests/ui/associated-inherent-types/regionck-2.rs) (as found in the `AliasKind::Inherent` PR) since it would (incorrectly) pass typeck in this PR due to the lack of regionck and I'd rather not make *that* a regression test (with or without `known-bug`).

``@rustbot`` label F-inherent_associated_types

r? ``@compiler-errors``
2023-03-22 22:44:42 +01:00
Matthias Krüger
577d85f92f
Rollup merge of #109358 - petrochenkov:nosess, r=cjgillot
rustc: Remove unused `Session` argument from some attribute functions

(One auxiliary test file containing one of these functions was unused, so I removed it instead of updating.)
2023-03-22 22:44:41 +01:00
Matthias Krüger
950aa3ef86
Rollup merge of #109213 - oli-obk:cstore, r=cjgillot
Eagerly intern and check CrateNum/StableCrateId collisions

r? ``@cjgillot``

It seems better to check things ahead of time than checking them afterwards.
The [previous version](https://github.com/rust-lang/rust/pull/108390) was a bit nonsensical, so this addresses the feedback
2023-03-22 22:44:40 +01:00
Matthias Krüger
34fa6daa5c
Rollup merge of #109203 - Ezrashaw:refactor-ident-parsing, r=Nilstrieb
refactor/feat: refactor identifier parsing a bit

\+ error recovery for `expected_ident_found`

Prior art: #108854
2023-03-22 22:44:39 +01:00
Matthias Krüger
0392e2996e
Rollup merge of #108954 - notriddle:notriddle/notable-trait-generic, r=camelid
rustdoc: handle generics better when matching notable traits

This commit makes the `clean::Type::is_same` non-commutative (renaming it `is_doc_subtype_of`), so that a generic `impl` matches a concrete return, but a generic return does not match a concrete `impl`. It makes slice and vector Write for `u8` not match on every generic return value.

Fixes #100322

Fixes #55082

Preview:

* https://notriddle.com/rustdoc-demo-html-3/notable-trait-generic/std/vec/struct.Vec.html#method.new
* https://notriddle.com/rustdoc-demo-html-3/notable-trait-generic/std/vec/struct.Vec.html#method.from-12
* https://notriddle.com/rustdoc-demo-html-3/notable-trait-generic/std/iter/trait.Iterator.html#method.intersperse_with
* https://notriddle.com/rustdoc-demo-html-3/notable-trait-generic/std/string/struct.String.html#method.as_bytes
2023-03-22 22:44:39 +01:00
bors
8859fde21f Auto merge of #109497 - matthiaskrgr:rollup-6txuxm0, r=matthiaskrgr
Rollup of 10 pull requests

Successful merges:

 - #109373 (Set LLVM `LLVM_UNREACHABLE_OPTIMIZE` to `OFF`)
 - #109392 (Custom MIR: Allow optional RET type annotation)
 - #109394 (adapt tests/codegen/vec-shrink-panik for LLVM 17)
 - #109412 (rustdoc: Add GUI test for "Auto-hide item contents for large items" setting)
 - #109452 (Ignore the vendor directory for tidy tests.)
 - #109457 (Remove comment about reusing rib allocations)
 - #109461 (rustdoc: remove redundant `.content` prefix from span/a colors)
 - #109477 (`HirId` to `LocalDefId` cleanup)
 - #109489 (More general captures)
 - #109494 (Do not feed param_env for RPITITs impl side)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-03-22 21:35:02 +00:00
Daniel Paoliello
a90f342b03 Use -m option instead of looking for a cross-compiling version of dlltool 2023-03-22 14:30:28 -07:00
Scott McMurray
b537e6bc53 Generate simpler MIR for shifts 2023-03-22 13:32:12 -07:00
Matthias Krüger
6244b94377
Rollup merge of #109494 - spastorino:new-rpitit-18, r=compiler-errors
Do not feed param_env for RPITITs impl side

r? `@compiler-errors`

I don't think this needs more comments or things that we already have but please let me know if you want some comments or something else in this PR.
2023-03-22 20:08:05 +01:00
Matthias Krüger
a7570b022e
Rollup merge of #109412 - GuillaumeGomez:add-gui-test, r=notriddle
rustdoc: Add GUI test for "Auto-hide item contents for large items" setting

Part of https://github.com/rust-lang/rust/issues/66181.

The `browser-ui-test` version update is because there wasn't `null` check for attributes so I added it (PR is [here](https://github.com/GuillaumeGomez/browser-UI-test/pull/440)).

r? ``@notriddle``
2023-03-22 20:08:02 +01:00
Matthias Krüger
44942ad10f
Rollup merge of #109394 - krasimirgg:llvm-17-vec-panic, r=nikic
adapt tests/codegen/vec-shrink-panik for LLVM 17

After 0d4a709bb8 LLVM now doesn't generate references to panic_cannot_unwind:
https://buildkite.com/llvm-project/rust-llvm-integrate-prototype/builds/17978#0186ff55-ca6f-4bc5-b1ec-2622c77d0ed5/744-746

Adapted as suggested by ````@nikic```` on Zulip:
https://rust-lang.zulipchat.com/#narrow/stream/187780-t-compiler.2Fwg-llvm/topic/a.20couple.20codegen.20test.20failures.20after.20llvm.200d4a709bb876824a/near/342664944
>Okay, so LLVM now realizes that double panic is not possible, so that's fine.
2023-03-22 20:08:01 +01:00
Matthias Krüger
9545ab8e12
Rollup merge of #109392 - cbeuw:composite-ret, r=JakobDegen
Custom MIR: Allow optional RET type annotation

This currently doesn't compile because the type of `RET` is inferred, which fails if RET is a composite type and fields are initialised separately.
```rust
#![feature(custom_mir, core_intrinsics)]
extern crate core;
use core::intrinsics::mir::*;
#[custom_mir(dialect = "runtime", phase = "optimized")]
fn fn0() -> (i32, bool) {
    mir! ({
        RET.0 = 0;
        RET.1 = true;
        Return()
    })
}
```
```
error[E0282]: type annotations needed
 --> src/lib.rs:8:9
  |
8 |         RET.0 = 0;
  |         ^^^ cannot infer type

For more information about this error, try `rustc --explain E0282`.
```

This PR allows the user to manually specify the return type with `type RET = ...;` if required:

```rust
#[custom_mir(dialect = "runtime", phase = "optimized")]
fn fn0() -> (i32, bool) {
    mir! (
        type RET = (i32, bool);
        {
            RET.0 = 0;
            RET.1 = true;
            Return()
        }
    )
}
```

The syntax is not optimal, I'm happy to see other suggestions. Ideally I wanted it to be a normal type annotation like `let RET: ...;`, but this runs into the multiple parsing options error during macro expansion, as it can be parsed as a normal `let` declaration as well.

r? ```@oli-obk``` or ```@tmiasko``` or ```@JakobDegen```
2023-03-22 20:08:01 +01:00
Dylan DPC
eda88a30c7
Rollup merge of #109435 - oli-obk:🇨🇭🥚_copy_op, r=RalfJung
Detect uninhabited types early in const eval

r? `@RalfJung`

implements https://github.com/rust-lang/rust/pull/108442#discussion_r1143003840

this is a breaking change, as some UB during const eval is now detected instead of silently being ignored. Users can see this and other UB that may cause future breakage with `-Zextra-const-ub-checks` or just by running miri on their code, which sets that flag by default.
2023-03-23 00:00:35 +05:30
Dylan DPC
031640ccd2
Rollup merge of #109414 - spastorino:new-rpitit-16, r=compiler-errors
Do not consider synthesized RPITITs on missing items checks

Without this patch for `tests/ui/impl-trait/in-trait/dont-project-to-rpitit-with-no-value.rs` we get ...

```
warning: the feature `return_position_impl_trait_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes
 --> tests/ui/impl-trait/in-trait/dont-project-to-rpitit-with-no-value.rs:4:12
  |
4 | #![feature(return_position_impl_trait_in_trait)]
  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
  = note: `#[warn(incomplete_features)]` on by default

error[E0046]: not all trait items implemented, missing: `foo`, ``
  --> tests/ui/impl-trait/in-trait/dont-project-to-rpitit-with-no-value.rs:12:1
   |
8  |     fn foo(&self) -> impl Sized;
   |     ----------------------------
   |     |                |
   |     |                `` from trait
   |     `foo` from trait
...
12 | impl MyTrait for i32 {
   | ^^^^^^^^^^^^^^^^^^^^ missing `foo`, `` in implementation

error: aborting due to previous error; 1 warning emitted

For more information about this error, try `rustc --explain E0046`.
```

instead of ...

```
warning: the feature `return_position_impl_trait_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes
  --> $DIR/dont-project-to-rpitit-with-no-value.rs:4:12
   |
LL | #![feature(return_position_impl_trait_in_trait)]
   |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
   = note: `#[warn(incomplete_features)]` on by default

error[E0046]: not all trait items implemented, missing: `foo`
  --> $DIR/dont-project-to-rpitit-with-no-value.rs:12:1
   |
LL |     fn foo(&self) -> impl Sized;
   |     ---------------------------- `foo` from trait
...
LL | impl MyTrait for i32 {
   | ^^^^^^^^^^^^^^^^^^^^ missing `foo` in implementation

error: aborting due to previous error; 1 warning emitted

For more information about this error, try `rustc --explain E0046`.
```

r? `@compiler-errors`
2023-03-23 00:00:35 +05:30
Dylan DPC
b9151b2d70
Rollup merge of #109405 - compiler-errors:rpitit-as-opaques, r=spastorino
RPITITs are `DefKind::Opaque` with new lowering strategy

r? `@spastorino`

Kinda cherry-picked #109400
2023-03-23 00:00:34 +05:30
Dylan DPC
af3bd22783
Rollup merge of #109312 - petrochenkov:docice5, r=GuillaumeGomez
rustdoc: Cleanup parent module tracking for doc links

Keep ids of the documented items themselves, not their parent modules. Parent modules can be retreived from those ids when necessary.

Fixes https://github.com/rust-lang/rust/issues/108501.
That issue could be fixed in a more local way, but this refactoring is something that I wanted to do since https://github.com/rust-lang/rust/pull/93805 anyway.
2023-03-23 00:00:33 +05:30
Dylan DPC
14d06467f0
Rollup merge of #109179 - llogiq:intrinsically-option-as-slice, r=eholk
move Option::as_slice to intrinsic

````@scottmcm```` suggested on #109095 I use a direct approach of unpacking the operation in MIR lowering, so here's the implementation.

cc ````@nikic```` as this should hopefully unblock #107224 (though perhaps other changes to the prior implementation, which I left for bootstrapping, are needed).
2023-03-23 00:00:31 +05:30
Michael Goulet
8390c61690 Drive-by: Add -Ztrait-solver=next to canonical int var test 2023-03-22 18:26:33 +00:00
Michael Goulet
a34c92760c Implement non-const Destruct trait in new solver 2023-03-22 18:22:27 +00:00
Michael Goulet
08284449a2 Subst gat normalize pred correctly 2023-03-22 18:16:01 +00:00
Santiago Pastorino
1c9ad28dd2
Do not feed param_env for RPITITs impl side 2023-03-22 14:06:22 -03:00
Guillaume Gomez
e03b13ccb7 Update anonymous-reexport UI test 2023-03-22 16:05:20 +01:00
Guillaume Gomez
825f0888cc Move useless_anynous_reexport lint into unused_imports 2023-03-22 16:05:20 +01:00
lcnr
73c79cd806 stop special-casing 'static in evaluate 2023-03-22 11:37:57 +01:00
Vadim Petrochenkov
67a2c5bec8 rustc: Remove unused Session argument from some attribute functions 2023-03-22 13:55:55 +04:00
Scott McMurray
ec25f08748 Demonstration test for MIR building of checked shift operators 2023-03-22 01:37:11 -07:00
Nikita Popov
58ac25b453 Increase array size in array-map.rs
Make sure that the loop is not fully unrolled (which allows
eliminating the allocas) in LLVM 16 either.
2023-03-22 09:30:37 +01:00
Mu42
20f3f437d1 Fixes #109436: add parentheses properly 2023-03-22 13:52:24 +08:00
bors
9bdb4881c7 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
Santiago Pastorino
c1f3529c91 Always encode RPITITs 2023-03-21 23:35:46 +00:00
León Orell Valerian Liehr
293f21c876
iat selection: erase regions in self type 2023-03-21 23:53:58 +01:00
Santiago Pastorino
364a5d4b54
Do not consider synthesized RPITITs on missing items checks 2023-03-21 15:44:12 -03:00
Matthias Krüger
94d2028abd
Rollup merge of #109446 - spastorino:new-rpitit-17, r=compiler-errors
Do not suggest bounds restrictions for synthesized RPITITs

Before this PR we were getting ...

```
warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes
 --> tests/ui/async-await/in-trait/missing-send-bound.rs:5:12
  |
5 | #![feature(async_fn_in_trait)]
  |            ^^^^^^^^^^^^^^^^^
  |
  = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
  = note: `#[warn(incomplete_features)]` on by default

error: future cannot be sent between threads safely
  --> tests/ui/async-await/in-trait/missing-send-bound.rs:17:20
   |
17 |     assert_is_send(test::<T>());
   |                    ^^^^^^^^^^^ future returned by `test` is not `Send`
   |
   = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `impl Future<Output = ()>`
note: future is not `Send` as it awaits another future which is not `Send`
  --> tests/ui/async-await/in-trait/missing-send-bound.rs:13:5
   |
13 |     T::bar().await;
   |     ^^^^^^^^ await occurs here on type `impl Future<Output = ()>`, which is not `Send`
note: required by a bound in `assert_is_send`
  --> tests/ui/async-await/in-trait/missing-send-bound.rs:21:27
   |
21 | fn assert_is_send(_: impl Send) {}
   |                           ^^^^ required by this bound in `assert_is_send`
help: consider further restricting the associated type
   |
16 | fn test2<T: Foo>() where impl Future<Output = ()>: Send {
   |                    ++++++++++++++++++++++++++++++++++++

error: aborting due to previous error; 1 warning emitted
```

and we want this output ...

```
warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes
  --> $DIR/missing-send-bound.rs:5:12
   |
LL | #![feature(async_fn_in_trait)]
   |            ^^^^^^^^^^^^^^^^^
   |
   = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
   = note: `#[warn(incomplete_features)]` on by default

error: future cannot be sent between threads safely
  --> $DIR/missing-send-bound.rs:17:20
   |
LL |     assert_is_send(test::<T>());
   |                    ^^^^^^^^^^^ future returned by `test` is not `Send`
   |
   = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `impl Future<Output = ()>`
note: future is not `Send` as it awaits another future which is not `Send`
  --> $DIR/missing-send-bound.rs:13:5
   |
LL |     T::bar().await;
   |     ^^^^^^^^ await occurs here on type `impl Future<Output = ()>`, which is not `Send`
note: required by a bound in `assert_is_send`
  --> $DIR/missing-send-bound.rs:21:27
   |
LL | fn assert_is_send(_: impl Send) {}
   |                           ^^^^ required by this bound in `assert_is_send`

error: aborting due to previous error; 1 warning emitted
```

r? `@compiler-errors`
2023-03-21 19:00:15 +01:00
Matthias Krüger
fef1fc4349
Rollup merge of #109441 - oli-obk:fn_trait_new_solver, r=compiler-errors
Only implement Fn* traits for extern "Rust" safe function pointers and items

Since calling the function via an `Fn` trait will assume `extern "Rust"` ABI and not do any safety checks, only safe `extern "Rust"` function can implement the `Fn` traits. This syncs the logic between the old solver and the new solver.

r? `@compiler-errors`
2023-03-21 19:00:14 +01:00
Matthias Krüger
25b062d586
Rollup merge of #109403 - chenyukang:yukang/fix-109396, r=estebank
Avoid ICE of attempt to add with overflow in emitter

Fixes #109396
r? ```@estebank```
2023-03-21 19:00:13 +01:00
Matthias Krüger
081c607b0a
Rollup merge of #109336 - compiler-errors:constrain-to-ct-err, r=BoxyUwU
Constrain const vars to error if const types are mismatched

When equating two consts of different types, if either are const variables, constrain them to the correct const error kind.

This helps us avoid "successfully" matching a const against an impl signature but leaving unconstrained const vars, which will lead to incremental ICEs when we call const-eval queries during const projection.

Fixes #109296

The second commit in the stack fixes a regression in the first commit where we end up mentioning `[const error]` in an impl overlap error message. I think the error message changes for the better, but I could implement alternative strategies to avoid this without delaying the overlap error message...

r? `@BoxyUwU`
2023-03-21 19:00:12 +01:00
Matthias Krüger
ee330a3ff5
Rollup merge of #108729 - bvanjoi:fix-issue-97534, r=petrochenkov
fix: modify the condition that `resolve_imports` stops

close #97534
2023-03-21 19:00:12 +01:00
John Kåre Alsaker
f60d2eb6c1 Add -Z time-passes-format to allow specifying a JSON output for -Z time-passes 2023-03-21 18:18:25 +01:00
Santiago Pastorino
3b04ad2753
Do not suggest bounds restrictions for synthesized RPITITs 2023-03-21 13:18:32 -03:00
lcnr
47f24a881b new solver cleanup + coherence 2023-03-21 16:27:25 +01:00
Vadim Petrochenkov
d3a5541939 rustdoc: Cleanup parent module tracking for doc links
Keep ids of the documented items themselves, not their parent modules.
Parent modules can be retreived from those ids when necessary.
2023-03-21 17:36:57 +04:00
Oli Scherer
460ecd288a Eagerly intern and check CrateNum/StableCrateId collisions 2023-03-21 12:08:17 +00:00
nils
b2e48edded
Rollup merge of #109390 - cbeuw:aggregate-lit, r=oli-obk
Custom MIR: Support aggregate expressions

Add support for tuple, array and ADT expressions in custom mir

r? `````@oli-obk````` or `````@tmiasko````` or `````@JakobDegen`````
2023-03-21 13:00:25 +01:00
nils
66ba60a445
Rollup merge of #109240 - compiler-errors:dont-binder-twice, r=oli-obk
Walk un-shifted nested `impl Trait` in trait when setting up default trait method assumptions

Fixes a double subtraction in some binder math in return-position `impl Trait` in trait handling code.

Fixes #109239
2023-03-21 13:00:23 +01:00
nils
0ef4da126a
Rollup merge of #108842 - compiler-errors:non_lifetime_binders-object-safe, r=b-naber
Enforce non-lifetime-binders in supertrait preds are not object safe

We can't construct vtables for these supertraits.
2023-03-21 13:00:22 +01:00
Oli Scherer
a00413f680 Also check function items' signatures for Fn* trait compatibility 2023-03-21 11:50:14 +00:00
Oli Scherer
fb9e171ab7 Only implement Fn* traits for extern "Rust" safe function pointers. 2023-03-21 11:11:32 +00:00
Oli Scherer
f066d6785d Detect uninhabited types early in const eval. 2023-03-21 11:09:27 +00:00
lcnr
c63861b9d5 evaluate: improve and fix recursion depth handling 2023-03-21 09:57:22 +01:00
bors
ef03fda339 Auto merge of #106967 - saethlin:remove-vec-as-ptr-assume, r=thomcc
Remove the assume(!is_null) from Vec::as_ptr

At a guess, this code is leftover from LLVM was worse at keeping track of the niche information here. In any case, we don't need this anymore: Removing this `assume` doesn't get rid of the `nonnull` attribute on the return type.
2023-03-21 08:44:17 +00:00
yukang
8126ccb77d Return equal for two identical projections 2023-03-21 15:28:11 +08:00
Michael Howell
e600c0ba0e rustdoc: add support for type filters in arguments and generics
This makes sense, since the search index has the information in it,
and it's more useful for function signature searches since a
function signature search's item type is, by definition, some type
of function (there's more than one, but not very many).
2023-03-20 22:41:57 -07:00
bors
3ff4d56650 Auto merge of #108262 - ChrisDenton:libntdll, r=Mark-Simulacrum
Distribute libntdll.a with windows-gnu toolchains

This allows the OS loader to load essential functions (e.g. read/write file) at load time instead of lazily doing so at runtime.

r? libs
2023-03-21 02:23:27 +00:00
Chris Denton
154f5d7f71
Add ntdll to run-make-fulldeps extraflags 2023-03-21 00:08:30 +00:00
Michael Goulet
720cc40fa7 Enforce non-lifetime-binders in supertrait preds are not object safe 2023-03-20 22:38:57 +00:00
Guillaume Gomez
ab1573a887 Add GUI test for "Auto-hide item contents for large items" setting 2023-03-20 20:25:35 +01:00
yukang
cbb8066321 Avoid ICE of attempt to add with overflow in emitter 2023-03-21 01:23:28 +08:00
Krasimir Georgiev
e4a4064480 adapt tests/codegen/vec-shrink-panik for LLVM 17
After 0d4a709bb8
LLVM now doesn't generate references to panic_cannot_unwind:

@nikic:
https://rust-lang.zulipchat.com/#narrow/stream/187780-t-compiler.2Fwg-llvm/topic/a.20couple.20codegen.20test.20failures.20after.20llvm.200d4a709bb876824a/near/342664944
>Okay, so LLVM now realizes that double panic is not possible, so that's fine.
2023-03-20 15:33:57 +00:00
Evgenii Zheltonozhskii
009ed88789 Add known-bug test for typeid unsoundness issue 2023-03-20 16:38:38 +02:00
Andy Wang
8e4e55e524
Support aggregate expressions 2023-03-20 15:25:11 +01:00
Andy Wang
9da1da94ef
Allow optional RET type annotation 2023-03-20 12:21:19 +01:00
Scott McMurray
48011e2aa4 Also move the auxiliary file 2023-03-20 10:25:29 +00:00
Scott McMurray
5dfe37a504 mv tests/codegen/issue-* tests/codegen/issues/ 2023-03-20 10:25:29 +00:00
Matthias Krüger
f21c435801
Rollup merge of #109364 - compiler-errors:gat-const-arg, r=BoxyUwU
Only expect a GAT const param for `type_of` of GAT const arg

IDK why we were account for both `is_ty_or_const` instead of just for a const param, since we're computing the `type_of` a const param specifically.

Fixes #109300
2023-03-20 09:46:54 +01:00
Matthias Krüger
3efecba6e7
Rollup merge of #109307 - cjgillot:inline-location, r=compiler-errors
Ignore `Inlined` spans when computing caller location.

Fixes https://github.com/rust-lang/rust/issues/105538
2023-03-20 09:46:54 +01:00
Matthias Krüger
d86fd83ef6
Rollup merge of #109277 - spastorino:new-rpitit-14, r=compiler-errors
Fix generics_of for impl's RPITIT synthesized associated type

The only useful commit is the last one.

This makes `generics_of` for the impl side RPITIT copy from the trait's associated type and avoid the fn on the impl side which was previously wrongly used.
This solution is better but we still need to fix resolution of the generated generics.

r? ``@compiler-errors``
2023-03-20 09:46:53 +01:00
Matthias Krüger
0e8085a095
Rollup merge of #109266 - petrochenkov:docice4, r=petrochenkov
rustdoc: Correctly merge import's and its target's docs in one more case

Fixes https://github.com/rust-lang/rust/issues/108334.
Fixes https://github.com/rust-lang/rust/issues/108378.
Fixes https://github.com/rust-lang/rust/issues/108658.
2023-03-20 09:46:52 +01:00
Ezra Shaw
05b5046633
feat: implement error recovery in expected_ident_found 2023-03-20 20:54:41 +13:00
Matthias Krüger
130923586d
Rollup merge of #109375 - clubby789:unescape-deprecated-doc, r=jsha
rustdoc: Fix improper escaping of deprecation reasons

Fix #109374

r? `@jsha`
2023-03-20 07:10:35 +01:00
Matthias Krüger
eb1f8dc2cb
Rollup merge of #109370 - DaniPopes:issue-109334, r=Nilstrieb
fix ClashingExternDeclarations lint ICE

Fixes #109334

First "real" contribution, please let me know if I did something wrong.

As I understand it, it's OK if a `#[repr(transparent)]` type has no non-zero sized types (aka is a ZST itself) and the function should just return the type normally instead of panicking

r? `@Nilstrieb`
2023-03-20 07:10:34 +01:00
Matthias Krüger
39e09ac334
Rollup merge of #109351 - GuillaumeGomez:no-footnote-in-summary, r=notriddle
rustdoc: Remove footnote references from doc summary

Since it's one line, we don't have the footnote definition so it doesn't make sense to have the reference.

Part of https://github.com/rust-lang/rust/issues/109024.

r? `@notriddle`
2023-03-20 07:10:33 +01:00
Matthias Krüger
272afbe7f8
Rollup merge of #109331 - notriddle:notriddle/search-bag-semantics, r=GuillaumeGomez
rustdoc: implement bag semantics for function parameter search

This tweak to the function signature search engine makes things so that, if a type is repeated in the search query, it'll only match if the function actually includes it that many times.
2023-03-20 07:10:32 +01:00
Matthias Krüger
7c69f98563
Rollup merge of #109319 - aDotInTheVoid:rdj-variadic-test, r=notriddle
Add test for `c_variadic` in rustdoc-json

Helps with #81359
2023-03-20 07:10:31 +01:00
Matthias Krüger
5d3f460708
Rollup merge of #109301 - Ezrashaw:fix-ctf-ice, r=Nilstrieb
fix: fix ICE in `custom-test-frameworks` feature

Fixes #107454

Simple fix to emit error instead of ICEing. At some point, all the code in `tests.rs` should be refactored, there is a bit of duplication (this PR's code is repeated five times over lol).

r? `@Nilstrieb` (active on the linked issue?)
2023-03-20 07:10:31 +01:00
Matthias Krüger
c07679989a
Rollup merge of #109259 - GuillaumeGomez:fix-missing-private-inlining, r=notriddle
rustdoc: Fix missing private inlining

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

If the item isn't inlined, it shouldn't have been added into `view_item_stack`. The problem here was that it was not removed, preventing sub items to be inlined if they have a re-export in "upper levels".

cc `@epage`
r? `@notriddle`
2023-03-20 07:10:30 +01:00
clubby789
c74f2dc588 Fix improper escaping of deprecation reasons 2023-03-20 05:21:51 +00:00
Michael Goulet
9f80c75703 Walk un-shifted nested impl Trait in trait when setting up default trait method assumptions 2023-03-20 04:50:02 +00:00
bors
9d0eac4d02 Auto merge of #108148 - parthopdas:master, r=oli-obk
Implementing "<test_binary> --list --format json" for use by IDE test explorers / runners

Fixes #107307

PR 1 of 2 - wiring up just the new information + implement the command line changes i.e. --format json + tests

upcoming:
PR 2 of 2 - clean up "#[cfg(not(bootstrap))]" from PR 1

As per the discussions on
- MCP: https://rust-lang.zulipchat.com/#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/Implementing.20.22.3Ctest_binary.3E.20--list.20--form.E2.80.A6.20compiler-team.23592/near/328747548
- preRFC: https://internals.rust-lang.org/t/pre-rfc-implementing-test-binary-list-format-json-for-use-by-ide-test-explorers-runners/18308
- FYI on Discord: https://discord.com/channels/442252698964721669/459149169546887178/1075581549409484820
2023-03-20 03:24:27 +00:00
Michael Howell
5451fe7d7c rustdoc: implement bag semantics for function parameter search
This tweak to the function signature search engine makes things so that,
if a type is repeated in the search query, it'll only match if the
function actually includes it that many times.
2023-03-19 18:19:24 -07:00
DaniPopes
8ca0f61fe3
fix ClashingExternDeclarations lint ICE 2023-03-20 00:50:03 +01:00
Michael Goulet
252fa78283 Only expect a GAT const arg 2023-03-19 23:46:09 +00:00
许杰友 Jieyou Xu (Joe)
1f67949f0e
Lint ambiguous glob re-exports 2023-03-20 03:22:31 +08:00
Guillaume Gomez
5a752cd2ca Add test for footnote references in doc summary 2023-03-19 18:02:52 +01:00
bohan
1775722410 fix: modify the condition that resolve_imports stops 2023-03-19 20:18:45 +08:00
Dylan DPC
1f0fcf13f5
Rollup merge of #109243 - chenyukang:yukang/fix-ice-109144, r=petrochenkov
The name of NativeLib will be presented

Fixes #109144

I was working on a quick fix, but found change the name from `Option<Symbol>` to `Symbol` make life a little bit easier.
2023-03-19 15:33:59 +05:30
Dylan DPC
879d6f257b
Rollup merge of #109212 - Ezrashaw:no-similar-sugg-for-unstable, r=estebank
fix: don't suggest similar method when unstable

Fixes #109177

Don't display typo suggestions for unstable things, unless the feature flag is enabled.

AFAIK, there are two places this occurs:
- `rustc_resolve`: before type checking, effectively just `FnCtxt::Free`.
- `rustc_hir_typck`: during type checking, for `FnCtxt::Assoc(..)`s.

The linked issue is about the latter, obviously the issue is applicable to both.

r? `@estebank`
2023-03-19 15:33:58 +05:30
Dylan DPC
462e7e7a10
Rollup merge of #109003 - GuillaumeGomez:useless-anonymous-reexport-lint, r=cjgillot
Add `useless_anonymous_reexport` lint

This is a follow-up of https://github.com/rust-lang/rust/pull/108936. We once again show all anonymous re-exports in rustdoc, however we also wanted to add a lint to let users know that it very likely doesn't have the effect they think it has.
2023-03-19 15:33:57 +05:30
Dylan DPC
e9c25b4ad5
Rollup merge of #105793 - lukas-code:circular-deps, r=Mark-Simulacrum
Add note for mismatched types because of circular dependencies

If you have crate A with a dependency on crate B, and crate B with a dev-dependency on A, then you might see "mismatched types" errors on types that seem to be equal. This PR adds a note that explains that the types are different, because crate B is compiled twice, one time with `cfg(test)` and one time without.

I haven't found a good way to create circular dependencies in UI tests, so I abused the incremental tests instead. As a bonus, incremental tests support "cpass" now.

related to https://github.com/rust-lang/rust/issues/22750
2023-03-19 15:33:55 +05:30
Dylan DPC
993b775849
Rollup merge of #104100 - ink-feather-org:const_iter_range, r=the8472,fee1-dead
Allow using `Range` as an `Iterator` in const contexts.

~~based on #102225 by `@fee1-dead~~`
2023-03-19 15:33:55 +05:30
Ezra Shaw
c05bebcd67
fix: fix ICE in custom-test-frameworks feature 2023-03-19 22:11:17 +13:00
Ezra Shaw
b4e17a5098
refactor: improve "ident starts with number" error 2023-03-19 20:24:06 +13:00
Michael Goulet
9174edbae9 Delay overlap errors if errors are involved 2023-03-19 03:45:47 +00:00
Michael Goulet
322c7b6269 Constrain const vars to error if const types are mismatched 2023-03-19 03:45:47 +00:00
yukang
d5558e67ef The name of NativeLib will be presented 2023-03-19 11:23:19 +08:00
Nikita Popov
4192743ab7 Revert "Auto merge of #107224 - nikic:llvm-16, r=cuviper"
This reverts commit 4a04d086ca, reversing
changes made to 2d0a7def33.
2023-03-18 23:49:24 +01:00
Ben Kimock
a98ddb6de1 Enable inlining of diverging functions 2023-03-18 14:29:13 -04:00
Ben Kimock
2a628bd99c Remove duplicate switch targets 2023-03-18 14:29:13 -04:00
Ben Kimock
41eda69516 Remove duplicate unreachable blocks 2023-03-18 14:29:04 -04:00
bors
4a04d086ca Auto merge of #107224 - nikic:llvm-16, r=cuviper
Upgrade to LLVM 16

This updates Rust to LLVM 16. It also updates our host compiler for dist-x86_64-linux to LLVM 16. The reason for that is that Bolt from LLVM 15 is not capable of compiling LLVM 16 (https://github.com/llvm/llvm-project/issues/61114).

LLVM 16.0.0 has been [released](https://discourse.llvm.org/t/llvm-16-0-0-release/69326) on March 18, while Rust 1.70 will become stable on June 1.

Tested images: `dist-x86_64-linux`, `dist-riscv64-linux` (alt), `dist-x86_64-illumos`, `dist-various-1`, `dist-various-2`, `dist-powerpc-linux`, `wasm32`, `armhf-gnu`
Tested images until the usual IPv6 failures: `test-various`
2023-03-18 18:14:35 +00:00
Alona Enraght-Moony
26cae277c5 Add test for c_variadic in rustdoc-json 2023-03-18 17:59:29 +00:00
Camille GILLOT
be8b323929 Ignore Inlined spans when computing caller location. 2023-03-18 13:46:17 +00:00
Matthias Krüger
8417c93092
Rollup merge of #109238 - spastorino:new-rpitit-12, r=compiler-errors
Fix generics mismatch errors for RPITITs on -Zlower-impl-trait-in-trait-to-assoc-ty

This PR stops reporting errors due to different count of generics on the new synthesized associated types for RPITITs. Those were already reported when we compare the function on the triat with the function on the impl.

r? ``@compiler-errors``
2023-03-18 12:04:23 +01:00
Matthias Krüger
a79925d63f
Rollup merge of #109193 - spastorino:new-rpitit-11, r=compiler-errors
Add revisions for -Zlower-impl-trait-in-trait-to-assoc-ty fixed tests

Needs to go on top of #109198

r? ``@compiler-errors``
2023-03-18 12:04:22 +01:00
Matthias Krüger
9599f3cc54
Rollup merge of #107416 - czzrr:issue-80618, r=GuillaumeGomez
Error code E0794 for late-bound lifetime parameter error.

This PR addresses [#80618](https://github.com/rust-lang/rust/issues/80618).
2023-03-18 12:04:21 +01:00
onestacked
8a9d6bf4fd Mark DoubleEndedIterator as #[const_trait] using rustc_do_not_const_check, implement const Iterator and DoubleEndedIterator for Range. 2023-03-18 09:17:37 +01:00
Andre Bogus
27e9ee9bae move Option::as_slice to intrinsic 2023-03-18 07:15:15 +01:00
Ezra Shaw
0dc36fcd5b
fix: don't suggest similar method when unstable 2023-03-18 16:19:00 +13:00
Matthias Krüger
7e5705e5c6
Rollup merge of #109251 - MU001999:master, r=Nilstrieb
Suggest surrounding the macro with `{}` to interpret as a statement

Fixes #109237
2023-03-18 00:05:54 +01:00
Matthias Krüger
d91858b080
Rollup merge of #109248 - compiler-errors:get_fn_decl-aaa, r=WaffleLapkin
Pass the right HIR back from `get_fn_decl`

Fixes #109232

Makes sure that the `fn_id: HirId` that we pass to `suggest_missing_return_type` matches up with the `fn_decl: hir::FnDecl` that we pass to it, so the late-bound vars that we fetch from the former match up with the types in the latter...

This HIR suggestion code really needs a big refactor. I've tried to do it in the past (a couple of attempts), but it's a super tangled mess. It really shouldn't be passing around things like `hir::Node` and just deal with `LocalDefId`s everywhere... Anyways, I'd rather fix this ICE, now.
2023-03-18 00:05:54 +01:00
Matthias Krüger
dfd2b6493a
Rollup merge of #109222 - chenyukang:yukang/fix-109143, r=petrochenkov
Do not ICE for unexpected lifetime with ConstGeneric rib

Fixes #109143
r? ````@petrochenkov````

Combining this test with the previous test will affect the previous diagnostics, so I added a separate test case.
2023-03-18 00:05:53 +01:00
Matthias Krüger
55d5cd5e95
Rollup merge of #109200 - compiler-errors:issue-109191, r=WaffleLapkin
Fix index out of bounds in `suggest_trait_fn_ty_for_impl_fn_infer`

Fixes #109191
2023-03-18 00:05:52 +01:00
Matthias Krüger
0ee7539e96
Rollup merge of #109102 - compiler-errors:ambig-assoc-in-non-lt-binder, r=jackh726
Erase escaping late-bound regions when probing for ambiguous associated types

Fixes #109090
2023-03-18 00:05:52 +01:00
Santiago Pastorino
640c20272e
Fix generics_of for impl's RPITIT synthesized associated type 2023-03-17 20:01:57 -03:00
Santiago Pastorino
9139ed076d
Fix impl_trait_ty_to_ty substs 2023-03-17 16:28:00 -03:00
Santiago Pastorino
e0302bbc3b
Add revisions for -Zlower-impl-trait-in-trait-to-assoc-ty fixed tests 2023-03-17 16:01:53 -03:00
Santiago Pastorino
ae7fa1d269
Add generic parameters mismatch test for async in traits 2023-03-17 15:45:57 -03:00
Santiago Pastorino
c7cc1c7442
Fix generics mismatch errors for RPITITs on -Zlower-impl-trait-in-trait-to-assoc-ty 2023-03-17 15:36:02 -03:00
Guillaume Gomez
e9f29c4016 Add regression test for #109258 2023-03-17 17:04:23 +01:00
Michael Goulet
08c913279f Pass the right HIR back from get_fn_decl 2023-03-17 15:39:05 +00:00
Michael Goulet
79ad7cca45 Erase escaping late-bound regions when probing for ambiguous associated types 2023-03-17 15:33:24 +00:00
bors
03b01c5bec Auto merge of #109253 - matthiaskrgr:rollup-2xmv5zk, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #108958 (Remove box expressions from HIR)
 - #109044 (Prevent stable `libtest` from supporting `-Zunstable-options`)
 - #109155 (Fix riscv64 fuchsia LLVM target name)
 - #109156 (Fix linker detection for clang with prefix)
 - #109181 (inherit_overflow: adapt pattern to also work with v0 mangling)
 - #109198 (Install projection from RPITIT to default trait method opaque correctly)
 - #109215 (Use sort_by_key instead of sort_by)
 - #109229 (Fix invalid markdown link references)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-03-17 14:56:30 +00:00
Vadim Petrochenkov
5e0fc0459e rustdoc: Correctly merge import's and its target's docs in one more case 2023-03-17 18:46:27 +04:00
Nikita Popov
b238a76f65 Increase array size in array-map.rs
Make sure that the loop is not fully unrolled (which allows
eliminating the allocas) in LLVM 16 either.
2023-03-17 09:43:24 +01:00
bors
2d64f229a0 Auto merge of #109085 - tmiasko:index-based, r=WaffleLapkin
Use index based drop loop for slices and arrays

Instead of building two kinds of drop pair loops, of which only one will be eventually used at runtime in a given monomorphization, always use index based loop.
2023-03-17 08:17:21 +00:00
Matthias Krüger
246d989a30
Rollup merge of #109198 - compiler-errors:new-rpitit-default-body, r=spastorino
Install projection from RPITIT to default trait method opaque correctly

1. For new lowering strategy `-Zlower-impl-trait-in-trait-to-assoc-ty`, install the correct default trait method projection predicates (RPITIT -> opaque). This makes default trait body tests pass!

2. Fix two WF-checking bugs -- first, we want to make sure that we're always looking for an opaque type in `check_return_position_impl_trait_in_trait_bounds`. That's because the RPITIT projections are normalized to opaques during wfcheck. Second, fix RPITIT's param-envs by not adding the projection predicates that we install on trait methods to make default RPITITs work -- I left a comment why.

3. Also, just a small drive-by for `rustc_on_unimplemented`. Not sure if it affects any tests, but can't hurt.

r? ````@spastorino,```` based off of #109140
2023-03-17 08:42:40 +01:00
Matthias Krüger
edd6b42565
Rollup merge of #109181 - durin42:v0-mangle-inherit_overflow, r=Nilstrieb
inherit_overflow: adapt pattern to also work with v0 mangling

This test was failing under new-symbol-mangling = true. Adapt pattern to work in both cases.

Related to #106002 from December.
2023-03-17 08:42:39 +01:00
Mu42
550e3087d1 Suggest surrounding the macro with {} to interpret as a statement 2023-03-17 14:36:22 +08:00
yukang
827a990255 Do not ICE for unexpected lifetime with ConstGeneric rib 2023-03-17 07:36:18 +08:00
bors
511364e787 Auto merge of #108944 - cjgillot:clear-local-info, r=oli-obk
Wrap the whole LocalInfo in ClearCrossCrate.

MIR contains a lot of information about locals. The primary purpose of this information is the quality of borrowck diagnostics.

This PR aims to drop this information after MIR analyses are finished, ie. starting from post-cleanup runtime MIR.
2023-03-16 19:59:56 +00:00
bors
e386217dd9 Auto merge of #107270 - cjgillot:remove-zst, r=oli-obk
Replace ZST operands and debuginfo by constants.

This is work that ConstProp will not have to do.
Split from https://github.com/rust-lang/rust/pull/107267
2023-03-16 16:40:53 +00:00
Oli Scherer
480e042097 Add Debug and Clone derives for stable mir datastructures 2023-03-16 16:17:25 +00:00
Oli Scherer
942cac1b8d Implement a minimal subset of MIR statements and terminators for smir 2023-03-16 16:06:12 +00:00
Nikita Popov
30331828cb Use poison instead of undef
In cases where it is legal, we should prefer poison values over
undef values.

This replaces undef with poison for aggregate construction and
for uninhabited types. There are more places where we can likely
use poison, but I wanted to stay conservative to start with.

In particular the aggregate case is important for newer LLVM
versions, which are not able to handle an undef base value during
early optimization due to poison-propagation concerns.
2023-03-16 15:07:04 +01:00
bors
1203e0866e Auto merge of #106824 - m-ou-se:format-args-flatten, r=oli-obk
Flatten/inline format_args!() and (string and int) literal arguments into format_args!()

Implements https://github.com/rust-lang/rust/issues/78356

Gated behind `-Zflatten-format-args=yes`.

Part of #99012

This change inlines string literals, integer literals and nested format_args!() into format_args!() during ast lowering, making all of the following pairs result in equivalent hir:

```rust
println!("Hello, {}!", "World");
println!("Hello, World!");
```

```rust
println!("[info] {}", format_args!("error"));
println!("[info] error");
```

```rust
println!("[{}] {}", status, format_args!("error: {}", msg));
println!("[{}] error: {}", status, msg);
```

```rust
println!("{} + {} = {}", 1, 2, 1 + 2);
println!("1 + 2 = {}", 1 + 2);
```

And so on.

This is useful for macros. E.g. a `log::info!()` macro could just pass the tokens from the user directly into a `format_args!()` that gets efficiently flattened/inlined into a `format_args!("info: {}")`.

It also means that `dbg!(x)` will have its file, line, and expression name inlined:

```rust
eprintln!("[{}:{}] {} = {:#?}", file!(), line!(), stringify!(x), x); // before
eprintln!("[example.rs:1] x = {:#?}", x); // after
```

Which can be nice in some cases, but also means a lot more unique static strings than before if dbg!() is used a lot.
2023-03-16 13:46:52 +00:00
Mara Bos
a080165148 Bless -Zhelp output test. 2023-03-16 12:26:20 +01:00
Mara Bos
4d840223b0 Add test for -Zflatten-format-args=yes. 2023-03-16 12:16:27 +01:00
bors
7ac4b82ddd Auto merge of #109206 - matthiaskrgr:rollup-oev8ax6, r=matthiaskrgr
Rollup of 10 pull requests

Successful merges:

 - #108875 (rustdoc: fix type search for `Option` combinators)
 - #108971 (error-msg: impl better suggestion for `E0532`)
 - #109139 (rustdoc: DocFS: Replace rayon with threadpool and enable it for all targets)
 - #109151 (Assert def-kind is correct for alias types)
 - #109158 (error-msg: expand suggestion for `unused_def` lint)
 - #109166 (make `define_opaque_types` fully explicit)
 - #109171 (Some cleanups in our normalization logic)
 - #109180 (Unequal → Not equal)
 - #109185 (rustdoc: remove `std::` from primitive intra-doc link tooltips)
 - #109192 (Mention UEFI target promotion in release notes for 1.67.0)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-03-16 11:06:02 +00:00
Mara Bos
1d59081bfd Bless pretty tests. 2023-03-16 11:21:50 +01:00
Mara Bos
f2f6bcc499 Don't allow new const panic through format flattening.
panic!("a {}", "b") is still not allowed in const,
even if the hir flattens to panic!("a b").
2023-03-16 11:21:50 +01:00
Matthias Krüger
570636a586
Rollup merge of #109185 - notriddle:notriddle/primitive-tooltip, r=jsha
rustdoc: remove `std::` from primitive intra-doc link tooltips

Take the intra-doc link to the method `iter` from https://doc.rust-lang.org/nightly/std/slice/struct.Iter.html

Before: `method std::slice::iter`

After: `method slice::iter`
2023-03-16 08:57:09 +01:00
Matthias Krüger
36b82373e0
Rollup merge of #109158 - Ezrashaw:expand-sugg-for-unused-lint, r=Nilstrieb
error-msg: expand suggestion for `unused_def` lint

Fixes #108885

Expands `let _ = ..` suggestion into more positions.
2023-03-16 08:57:07 +01:00
Matthias Krüger
1385a32b62
Rollup merge of #108971 - Ezrashaw:E0532-better-binding-names, r=WaffleLapkin
error-msg: impl better suggestion for `E0532`

Fixes #106862

No test as there is already a test which is nearly identical to the example in the linked issue.
2023-03-16 08:57:05 +01:00
Matthias Krüger
aa881f16ec
Rollup merge of #108875 - notriddle:notriddle/return-trait, r=GuillaumeGomez
rustdoc: fix type search for `Option` combinators
2023-03-16 08:57:05 +01:00
bors
cd6c574af3 Auto merge of #108809 - lqd:fix-ignore, r=pietroalbini
fix ignore header in MSVC test

From `@pietroalbini's` [zulip message](https://rust-lang.zulipchat.com/#narrow/stream/326414-t-infra.2Fbootstrap/topic/better.20compiletest.20ignore.20messages/near/339845864)

> there are tests like `tests/ui/panic-runtime/unwind-tables-target-required.rs` which have `only-x86_64-windows-msvc` which I'm pretty sure is invalid

This test is currently ignored on x64 MSVC CI because of this incorrect target. We'll see if it still passes.

r? `@pietroalbini`
2023-03-16 07:35:20 +00:00
Michael Goulet
60da5de1c6 Fix index out of bounds in suggest_trait_fn_ty_for_impl_fn_infer 2023-03-16 04:02:56 +00:00
bors
18e305dfca Auto merge of #109183 - lqd:revert-107376, r=compiler-errors
Revert #107376 to fix potential `bincode` breakage and `rustc-perf` benchmark.

#107376 caused `rustc-perf`'s `webrender` benchmark to break, by regressing on the `bincode-1.3.3` crate.

~~This PR is a draft revert in case we can't land a fix soon enough, and we'd like to land the revert instead~~

(Though I myself think it'd be safer to do the revert, and run crater when relanding #107376.)

cc `@aliemjay`
2023-03-16 02:56:24 +00:00
Michael Goulet
ff7c3b854d Don't install default opaque projection predicates in RPITIT associated type's param-env 2023-03-16 01:59:41 +00:00
Michael Goulet
0949da8f4e Install projection from RPITIT to default trait method opaque correctly 2023-03-16 01:56:49 +00:00
bors
c90eb4825a Auto merge of #108282 - cjgillot:mir-checked-sh, r=tmiasko
Implement checked Shl/Shr at MIR building.

This does not require any special handling by codegen backends,
as the overflow behaviour is entirely determined by the rhs (shift amount).

This allows MIR ConstProp to remove the overflow check for constant shifts.

~There is an existing different behaviour between cg_llvm and cg_clif (cc `@bjorn3).`
I took cg_llvm's one as reference: overflow if `rhs < 0 || rhs > number_of_bits_in_lhs_ty`.~

EDIT: `cg_llvm` and `cg_clif` implement the overflow check differently. This PR uses `cg_llvm`'s implementation based on a `BitAnd` instead of `cg_clif`'s one based on an unsigned comparison.
2023-03-15 21:31:06 +00:00
Santiago Pastorino
c5c4340760
Add revisions to fixed tests in -Zlower-impl-trait-in-trait-to-assoc-ty 2023-03-15 16:58:37 -03:00
Michael Howell
683c12cb91 rustdoc: remove std:: from primitive intra-doc link tooltips 2023-03-15 11:34:37 -07:00
Augie Fackler
0b9b7dd5c6 inherit_overflow: adapt pattern to also work with v0 mangling
This test was failing under new-symbol-mangling = true. Adapt pattern to
work in both cases.

Related to #106002 from December.
2023-03-15 14:22:26 -04:00
Partha P. Das
3720753632
Implementing "<test_binary> --list --format json" #107307 #49359 2023-03-15 14:20:20 -04:00
Rémy Rakic
5ad1083e5b Revert "Auto merge of #107376 - aliemjay:remove-givens, r=lcnr"
This reverts commit e84e5ff04a, reversing
changes made to 1716932743.
2023-03-15 15:09:29 +00:00
bors
a167cbddac Auto merge of #109164 - Dylan-DPC:rollup-0bwxwos, r=Dylan-DPC
Rollup of 7 pull requests

Successful merges:

 - #108991 (add `enable-warnings` flag for llvm, and disable it by default.)
 - #109109 (Use `unused_generic_params` from crate metadata)
 - #109111 (Create dirs for build_triple)
 - #109136 (Simplify proc macro signature validity check)
 - #109150 (Update cargo)
 - #109154 (Fix MappingToUnit  to support no span of arg_ty)
 - #109157 (Remove mw from review rotation for a while)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-03-15 14:50:03 +00:00
Dylan DPC
19d575851a
Rollup merge of #109154 - chenyukang:yukang/fix-109152, r=compiler-errors
Fix MappingToUnit  to support no span of arg_ty

Fixes #109152
2023-03-15 17:51:33 +05:30
Dylan DPC
8c5ea6188f
Rollup merge of #109136 - compiler-errors:simplify-proc-macro-checking, r=oli-obk
Simplify proc macro signature validity check

Use an `ObligationCtxt` instead of `normalize_erasing_regions` + `DeepRejectCtxt`. This should both give us a more accurate error message, and also avoid issues like not-well-formed proc macro signatures. Also, let's fall back on the regular type mismatch error reporting for making these diagnostic notes, instead of hard-coding a bunch of specific diagnostics.

Fixes #109129
2023-03-15 17:51:32 +05:30
Dylan DPC
2aa3eea5fc
Rollup merge of #109109 - compiler-errors:polymorphize-foreign, r=Nilstrieb
Use `unused_generic_params` from crate metadata

Due to the way that `separate_provide_extern` interacted with the implementation of `<ty::InstanceDef<'tcx> as Key>::query_crate_is_local`, we actually never hit the foreign provider for `unused_generic_params`.

Additionally, since the *local* provider of `unused_generic_params` calls `should_polymorphize`, which always returns false if the def-id is foreign, this means that we never actually polymorphize monomorphic instances originating from foreign crates.

We don't actually encode `unused_generic_params` for items where all generics are used, so I had to tweak the foreign provider to fall back to `ty::UnusedGenericParams::new_all_used()` to avoid more ICEs when the above bugs were fixed.
2023-03-15 17:51:31 +05:30
bors
e4b9f86054 Auto merge of #109035 - scottmcm:ptr-read-should-know-undef, r=WaffleLapkin,JakobDegen
Ensure `ptr::read` gets all the same LLVM `load` metadata that dereferencing does

I was looking into `array::IntoIter` optimization, and noticed that it wasn't annotating the loads with `noundef` for simple things like `array::IntoIter<i32, N>`.  Trying to narrow it down, it seems that was because `MaybeUninit::assume_init_read` isn't marking the load as initialized (<https://rust.godbolt.org/z/Mxd8TPTnv>), which is unfortunate since that's basically its reason to exist.

The root cause is that `ptr::read` is currently implemented via the *untyped* `copy_nonoverlapping`, and thus the `load` doesn't get any type-aware metadata: no `noundef`, no `!range`.  This PR solves that by lowering `ptr::read(p)` to `copy *p` in MIR, for which the backends already do the right thing.

Fortuitiously, this also improves the IR we give to LLVM for things like `mem::replace`, and fixes a couple of long-standing bugs where `ptr::read` on `Copy` types was worse than `*`ing them.

Zulip conversation: <https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/Move.20array.3A.3AIntoIter.20to.20ManuallyDrop/near/341189936>

cc `@erikdesjardins` `@JakobDegen` `@workingjubilee` `@the8472`

Fixes #106369
Fixes #73258
2023-03-15 11:44:12 +00:00
Ezra Shaw
35103fe8ab
error-msg: expand suggestion for unused lint 2023-03-15 23:30:12 +13:00
Ezra Shaw
bd1732240b
error-msg: impl better suggestion for E0532 2023-03-15 22:19:54 +13:00
Scott McMurray
dfc3377954 Split the mem-replace codegen test
Apparently in CI it's getting generated in the opposite order, one function per file will make the test pass either way.
2023-03-15 00:57:08 -07:00
yukang
b3af5e2f8b Fix #109152, fix the scenario that we may can not get span of func 2023-03-15 14:07:39 +08:00
Scott McMurray
e7c6ad89cf Improved implementation and comments after code review feedback 2023-03-14 22:24:28 -07:00
bors
e84e5ff04a Auto merge of #107376 - aliemjay:remove-givens, r=lcnr
remove obsolete `givens` from regionck

Fixes #106567

r? `@lcnr` (feel free to reassign)
2023-03-15 02:50:58 +00:00
Tomasz Miąsko
cf0e78bd3b Use index based drop loop for slices and arrays
Instead of building two kinds of drop pair loops, of which only one will
be eventually used at runtime in a given monomorphization, always use
index based loop.
2023-03-14 21:29:32 +01:00
Camille GILLOT
e7b998c02a Bless incremental test. 2023-03-14 20:52:42 +01:00
Camille GILLOT
526a2c7521 ICE when checking LocalInfo on runtime MIR. 2023-03-14 20:52:42 +01:00
Camille GILLOT
bcb161def7 Wrap the whole LocalInfo in ClearCrossCrate. 2023-03-14 20:52:42 +01:00
Michael Goulet
00dc3b24b7 Tighter spans 2023-03-14 19:12:42 +00:00
Michael Goulet
9eae77381e Simplify proc macro signature validity check 2023-03-14 19:05:21 +00:00
bors
1716932743 Auto merge of #109130 - matthiaskrgr:rollup-dm3jza6, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #108722 (Support for Fuchsia RISC-V target)
 - #108880 (Remove tests/ui/impl-trait/in-trait/new-lowering-strategy in favor of using revisions on existing tests)
 - #108909 (Fix object safety checks for new RPITITs)
 - #108915 (Remove some direct calls to local_def_id_to_hir_id on diagnostics)
 - #108923 (Make fns from other crates with RPITIT work for -Zlower-impl-trait-in-trait-to-assoc-ty)
 - #109101 (Fall back to old metadata computation when type references errors)
 - #109105 (Don't ICE for late-bound consts across `AnonConstBoundary`)
 - #109110 (Don't codegen impossible to satisfy impls)
 - #109116 (Emit diagnostic when calling methods on the unit type in method chains)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-03-14 17:40:52 +00:00
Matthias Krüger
b17ee106d8
Rollup merge of #109116 - MaciejWas:add-modifies-receiver-diagn-when-method-not-found, r=petrochenkov
Emit diagnostic when calling methods on the unit type in method chains

Fixes #104204.

What this PR does: If a method is not found somewhere in a call chain, we check if we called earlier a method with signature `(&mut T, ...) -> ()`. If this is the case then we emit a diagnostic message.

For example given input:

```
vec![1, 2, 3].into_iter().collect::<Vec<i32>>().sort_by_key(|i| i).sort();
```

the current output is:
```
error[E0599]: no method named `sort` found for unit type `()` in the current scope
 --> hello.rs:3:72
  |
3 |     vec![1, 2, 3].into_iter().collect::<Vec<i32>>().sort_by_key(|i| i).sort();
  |                                                                        ^^^^ method not found in `()`

```

after this PR it will be:
```
error[E0599]: no method named `sort` found for unit type `()` in the current scope
 --> ./hello.rs:3:72
  |
3 |     vec![1, 2, 3].into_iter().collect::<Vec<i32>>().sort_by_key(|i| i).sort();
  |                                                                        ^^^^ method not found in `()`
  |

note: method `sort_by_key` modifies its receiver in-place, it is not meant to be used in method chains.
 --> ./hello.rs:3:53
  |
3 |     vec![1, 2, 3].into_iter().collect::<Vec<i32>>().sort_by_key(|i| i).sort();
  |                                                     ^^^^^^^^^^^ this call modifies its receiver in-place
```
2023-03-14 17:40:07 +01:00
Matthias Krüger
b88c675946
Rollup merge of #109110 - compiler-errors:impossible-impl-mono, r=jackh726
Don't codegen impossible to satisfy impls

Fixes #109098
2023-03-14 17:40:06 +01:00
Matthias Krüger
4c6b680955
Rollup merge of #109105 - compiler-errors:late-ct-in-anon-ct, r=oli-obk
Don't ICE for late-bound consts across `AnonConstBoundary`

Fixes #108194
2023-03-14 17:40:06 +01:00
Matthias Krüger
1f159b4894
Rollup merge of #109101 - compiler-errors:layout-err, r=michaelwoerister
Fall back to old metadata computation when type references errors

Projection is a bit too aggressive normalizing `<dyn Trait<[type error]> as Pointee>::Metadata` to `[type error]`, rather than to `DynMetadata<..>`. Side-step that by just falling back to the old structural metadata computation.

Fixes #109078
2023-03-14 17:40:05 +01:00
Matthias Krüger
21d15db1df
Rollup merge of #108923 - spastorino:new-rpitit-9, r=compiler-errors
Make fns from other crates with RPITIT work for -Zlower-impl-trait-in-trait-to-assoc-ty

Only the last two commits are meaningful.

r? `@compiler-errors`
2023-03-14 17:40:05 +01:00
Matthias Krüger
48934c48c6
Rollup merge of #108909 - spastorino:new-rpitit-7, r=compiler-errors
Fix object safety checks for new RPITITs

This one goes on top of #108869

r? `@compiler-errors`
2023-03-14 17:40:04 +01:00