Commit Graph

3711 Commits

Author SHA1 Message Date
Maybe Waffle
b5d1228508 Add a (failing test) for issue 113840 2023-07-19 12:05:48 +00:00
bors
b657dc555b Auto merge of #113690 - aliemjay:opaque-defined-by-trait, r=compiler-errors
allow opaques to be defined by trait queries, again

This basically reverts #112963.

Moreover, all call-sites of `enter_canonical_trait_query` can now define opaque types, see the ui test `defined-by-user-annotation.rs`.

Fixes #113689

r? `@compiler-errors` `@oli-obk`
2023-07-19 05:40:58 +00:00
bors
d351515521 Auto merge of #113636 - compiler-errors:opaque-recursive-check-bad, r=oli-obk
Restrict recursive opaque type check

We have a recursive opaque check in writeback to avoid inferring the hidden of an opaque type to be itself:

33a2c2487a/compiler/rustc_hir_typeck/src/writeback.rs (L556-L575)

Issue #113619 treats `make_option2` as not defining the TAIT `TestImpl` since it is inferred to have the definition `TestImpl := B<TestImpl>`, which fails this check. This regressed in #102700 (5d15beb591), I think due to the refactoring that made us record the hidden types of TAITs during writeback.

However, nothing actually seems to go bad if we relax this recursion checker to only check for directly recursive definitions. This PR fixes #113619 by changing this recursive check from being a visitor to just checking that the hidden type is exactly the same as the opaque being inferred.

Alternatively, we may be able to fix #113619 by restricting this recursion check only to RPITs/async fns. It seems to only be possible to use misuse the recursion check to cause ICEs for TAITs (though I didn't try too hard to create a bad RPIT example... may be possible, actually.)

r? `@oli-obk`

--

Fixes #113314
2023-07-18 18:53:42 +00:00
Matthias Krüger
1b07da1d52
Rollup merge of #113823 - GuillaumeGomez:fix-results-search-alias-display, r=notriddle
Fix results search alias display

Currently it's displayed like this:

![Screenshot from 2023-07-18 14-23-35](https://github.com/rust-lang/rust/assets/3050060/119d8f18-b298-4e6f-9571-9f678fc19126)

With this fix:

![Screenshot from 2023-07-18 14-23-29](https://github.com/rust-lang/rust/assets/3050060/679d6241-420e-4f13-be78-dc061cbc488a)

r? `@notriddle`
2023-07-18 19:06:03 +02:00
Matthias Krüger
931d9f099a
Rollup merge of #113811 - jieyouxu:fix-unused-qualifications-suggestion, r=oli-obk
Fix removal span calculation of `unused_qualifications` suggestion

Given a path such as `std::ops::Index<str>`, calculate the unnecessary qualification removal span by computing the beginning of the entire span until the ident span of the last path segment, which handles generic arguments and lifetime arguments in the last path segment. Previous logic only kept the ident span of the last path segment which is incorrect.

Closes #113808.
2023-07-18 19:06:02 +02:00
Michael Goulet
6875589924 Add additional test 2023-07-18 15:56:03 +00:00
Michael Goulet
7db5f81853 Relax recursive opaque type check 2023-07-18 15:56:03 +00:00
Guillaume Gomez
8f5787abba Update rustdoc GUI tests 2023-07-18 14:34:24 +02:00
chenx97
d3727148a0 support for mips32r6 as a target_arch value 2023-07-18 18:58:18 +08:00
chenx97
c6e03cd951 support for mips64r6 as a target_arch value 2023-07-18 18:58:18 +08:00
bors
c44324a4fe Auto merge of #113677 - bryangarza:unevaluated-const-ice_issue-110892, r=davidtwco
Safe Transmute: Fix ICE (due to UnevaluatedConst)

This patch updates the code that looks at the `Assume` type when evaluating if transmutation is possible. An ICE was being triggered in the case that the `Assume` parameter contained an unevaluated const (in this test case, due to a function with missing parameter names).

Fixes #110892
2023-07-18 09:07:32 +00:00
bors
ec362f0ae8 Auto merge of #113574 - GuillaumeGomez:rustdoc-json-strip-hidden-impl, r=aDotInTheVoid,notriddle
Strip impl if not re-exported and is doc(hidden)

Part of #112852.

r? `@aDotInTheVoid`
2023-07-18 02:47:03 +00:00
许杰友 Jieyou Xu (Joe)
33bd453f35
Fix removal span calculation of unused_qualifications suggestion 2023-07-18 09:52:08 +08:00
bors
da6b55cc5e Auto merge of #89132 - Cyborus04:rc_allocator_support, r=Amanieu
Add support for allocators in `Rc` & `Arc`

Adds the ability for `std::rc:Rc`, `std::rc::Weak`, `std::sync::Arc`, and `std::sync::Weak` to live in custom allocators
2023-07-17 21:51:46 +00:00
Guillaume Gomez
c132cdbe5f Improve issue-112852 tests 2023-07-17 23:36:47 +02:00
bors
1787f31290 Auto merge of #113720 - eduardosm:miri-target-feature, r=RalfJung,oli-obk
miri: fail when calling a function that requires an unavailable target feature

miri will report an UB when calling a function that has a `#[target_feature(enable = ...)]` attribute is called and the required feature is not available.

"Available features" are the same that `is_x86_feature_detected!` (or equivalent) reports to be available during miri execution (which can be enabled or disabled with the `-C target-feature` flag).
2023-07-17 19:57:37 +00:00
Wesley Wiser
12bed9d8cc Update natvis to match full type names for Arc, Rc, Weak, etc
Also update a test case to have the correct whitespace in a type name.
2023-07-17 15:51:46 -04:00
Bryan Garza
ef50e204f3 Safe Transmute: Fix ICE (due to UnevaluatedConst)
This patch updates the code that looks at the `Assume` type when evaluating if
transmutation is possible. An ICE was being triggered in the case that the
`Assume` parameter contained an unevaluated const (in this test case, due to a
function with missing parameter names).

Fixes #110892
2023-07-17 09:43:35 -07:00
Matthias Krüger
93b9812be8
Rollup merge of #113770 - dtolnay:derivevoid, r=compiler-errors,nnethercote
Generate safe stable code for derives on empty enums

Generate `match *self {}` instead of `unsafe { core::intrinsics::unreachable() }`.

This is:

1. safe
2. stable

for the benefit of everyone looking at these derived impls through `cargo expand`.

[Both expansions compile to the same code at all optimization levels (including `0`).](https://rust.godbolt.org/z/P79joGMh3)
2023-07-17 12:58:54 +02:00
Matthias Krüger
eca9c0101c
Rollup merge of #113651 - lcnr:parent-def-id, r=compiler-errors
self type param infer, avoid ICE

fixes #113610, which is caused by 33a2c2487a/compiler/rustc_hir_analysis/src/collect/generics_of.rs (L190-L205)
2023-07-17 12:58:53 +02:00
bors
4c7af429f3 Auto merge of #113336 - compiler-errors:new-solver-iat, r=lcnr
Add support for inherent projections in new solver

Not hard to support these, and it cuts out a really big chunk of failing UI tests with `--compare-mode=next-solver`

r? `@lcnr` (feel free to reassign, anyone can review this)
2023-07-17 01:06:36 +00:00
bors
f1eab64d4f Auto merge of #113769 - matthiaskrgr:rollup-p6i1rco, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #113042 (Add Platform Support documentation for MIPS Release 6 targets)
 - #113539 (fixed typo)
 - #113614 (platform-support.md: It's now verified that NetBSD/riscv64 can self-h…)
 - #113750 (Add missing italicization to `sort_unstable_by_key` complexity )
 - #113755 (Normalize lazy type aliases when probing for ADTs)
 - #113756 (fix wrong link)
 - #113762 (Fix typo)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-07-16 23:14:36 +00:00
Matthias Krüger
b42ada2b12
Rollup merge of #113755 - fmease:probe-adt-norm-lazy-ty-alias, r=oli-obk
Normalize lazy type aliases when probing for ADTs

Fixes #113736.

r? ```@oli-obk```
2023-07-17 00:14:06 +02:00
David Tolnay
f441adc89a
Generate safe stable code for derives on empty enums
Generate `match *self {}` instead of `unsafe { core::intrinsics::unreachable() }`.

This is:

    1. safe
    2. stable

for the benefit of everyone looking at these derived impls through `cargo expand`.

Both expansions compile to the same code at all optimization levels (including `0`).
2023-07-16 15:02:08 -07:00
bors
0e8e857b11 Auto merge of #113742 - compiler-errors:dont-short-circuit-intercrate-global-preds, r=lcnr
Don't call `predicate_must_hold`-esque functions during fulfillment in intercrate

Fixes #113415

Given that this only happens in `translate_substs`, I don't actually think that this is something that you can weaponize, but it's still sketchy regardless.

r? `@lcnr`
2023-07-16 21:30:37 +00:00
Michael Goulet
c9ce51b5c7 Check GAT, IAT, and weak type where clauses during projection 2023-07-16 21:14:38 +00:00
Michael Goulet
085ae9e8b4 Add support for inherent projections 2023-07-16 21:14:38 +00:00
bors
c4083faade Auto merge of #113545 - cjgillot:query-entry, r=compiler-errors
Check entry type as part of item type checking.

This code is currently executed inside the root `analysis` query.
Instead, check it during `check_for_entry_fn(CRATE_DEF_ID)` to hopefully avoid some re-executions.

`CRATE_DEF_ID` is chosen by considering that entry fn are typically at crate root, so the corresponding HIR should already be in the dependencies.
2023-07-16 18:54:18 +00:00
bors
11da267fdb Auto merge of #112239 - jieyouxu:targeted-no-method-suggestions, r=cjgillot
Add `#[rustc_confusables]` attribute to allow targeted "no method" error suggestions on standard library types

After this PR, the standard library developer can annotate methods on e.g. `BTreeSet::push` with `#[rustc_confusables("insert")]`. When the user mistypes `btreeset.push()`, `BTreeSet::insert` will be suggested if there are no other candidates to suggest. This PR lays the foundations for contributors to add `rustc_confusables` annotations to standard library types for targeted suggestions, as specified in #59450, or to address cases such as #108437.

### Example

Assume `BTreeSet` is the standard library type:

```
// Standard library definition
#![feature(rustc_attrs)]

struct BTreeSet;

impl BTreeSet {
    #[rustc_confusables("push")]
    fn insert(&self) {}
}

// User code
fn main() {
    let x = BTreeSet {};
    x.push();
}
```

A new suggestion (which has lower precedence than suggestions for misspellings and only is shown when there are no misspellings suggestions) will be added to hint the user maybe they intended to write `x.insert()` instead:

```
error[E0599]: no method named `push` found for struct `BTreeSet` in the current scope
  --> test.rs:12:7
   |
3  | struct BTreeSet;
   | --------------- method `push` not found for this struct
...
12 |     x.push();
   |       ^^^^ method not found in `BTreeSet`
   |
help: you might have meant to use `insert`
   |
12 |     x.insert();
   |       ~~~~~~

error: aborting due to previous error
```
2023-07-16 15:25:03 +00:00
lcnr
e449daad6c stop mentioning number of applicate implementations 2023-07-16 15:36:19 +02:00
lcnr
19d46b690a self type param infer, avoid ICE 2023-07-16 15:29:08 +02:00
bors
4a07b2baf5 Auto merge of #113557 - Amanieu:no-builtins-prelude, r=petrochenkov
Hide `compiler_builtins` in the prelude

This crate is a private implementation detail. We only need to insert it into the crate graph for linking and should not expose any of its public API.

Fixes #113533
2023-07-16 13:19:14 +00:00
许杰友 Jieyou Xu (Joe)
08c77a6eb4
Add infrastructure #[rustc_confusables] attribute to allow targeted
"no method" errors on standard library types

The standard library developer can annotate methods on e.g.
`BTreeSet::push` with `#[rustc_confusables("insert")]`. When the user
mistypes `btreeset.push()`, `BTreeSet::insert` will be suggested if
there are no other candidates to suggest.
2023-07-16 19:22:03 +08:00
Eduardo Sánchez Muñoz
3e8ce42d42 Add const-eval test for #[target_feature(enable = ...)] function calls 2023-07-16 13:20:06 +02:00
bors
55be59d2ce Auto merge of #113626 - Urgau:dedup-native-static-libs, r=petrochenkov
De-duplicate consecutive libs when printing native-static-libs

This PR adds a de-duplicate step just before printing the `native-static-libs`.

This step de-duplicates all the consecutive libs based only on the relevant comparison elements (this exclude spans, ast elements, ...).

Fixes https://github.com/rust-lang/rust/issues/113209
2023-07-16 10:59:45 +00:00
León Orell Valerian Liehr
c856c74764
Normalize lazy type aliases when probing for ADTs 2023-07-16 12:38:43 +02:00
Michael Goulet
8f178d1b0c Don't call predicate_must_hold during fulfillment in intercrate 2023-07-16 01:56:16 +00:00
bors
4124617c6e Auto merge of #113606 - jyn514:parallel-compiler-cleanup, r=cjgillot
Don't require each rustc_interface tool to opt-in to parallel_compiler

Previously, forgetting to call `interface::set_thread_safe_mode` would cause the following ICE:
```
thread 'rustc' panicked at 'uninitialized dyn_thread_safe mode!', /rustc/dfe0683138de0959b6ab6a039b54d9347f6a6355/compiler/rustc_data_structures/src/sync.rs:74:18
```

This calls `set_thread_safe_mode` in `interface::run_compiler` to avoid requiring it in the caller.

Fixes `tests/run-make-fulldeps/issue-19371` when parallel-compiler is enabled.

r? `@SparrowLii` cc https://github.com/rust-lang/rust/issues/75760
2023-07-15 22:23:05 +00:00
Camille GILLOT
87233da5c2 Check entry type as part of item type checking. 2023-07-15 22:02:16 +00:00
Matthias Krüger
5f94c876ad
Rollup merge of #113724 - GuillaumeGomez:migrate-gui-test-color-21, r=notriddle
Migrate GUI colors test to original CSS color format

Follow-up of https://github.com/rust-lang/rust/pull/111459.

r? `@notriddle`
2023-07-15 19:42:53 +02:00
Matthias Krüger
331b5baddd
Rollup merge of #113709 - notriddle:notriddle/src, r=GuillaumeGomez
rustdoc: use src consistently over source in CSS/JS

The two terms have been used, inconsistently, in closely related spots like the `src/` directory vs `source-files.js`, and with things like `src-sidebar-toggle` vs the `source-sidebar`. This PR changes most use of `source` to `src` instead (except the localStorage configuration variables, which would be very complicated to migrate).

It also renames `.srclink` to `.src`. This is mostly aiming to cut out one of those many little peanut-butter bits of bloat, and is consistent with how other link classes are done (like how you have `a.mod` stylesheet rules, but there's also a `mod` class put on the body tag).
2023-07-15 19:42:53 +02:00
Matthias Krüger
9b8be2f0e1
Rollup merge of #113663 - syvb:non_inherited_unsafe_thir, r=cjgillot
Implement "items do not inherit unsafety" note for THIR unsafeck

Implements the "items do not inherit unsafety from separate enclosing items" note from the MIR unsafety checker in the THIR unsafety checker (`-Z thir-unsafeck`) to maintain parity between the two unsafety checkers. The logic to find the separate enclosing item is nearly the same as in the MIR unsafety checker.
2023-07-15 19:42:52 +02:00
Matthias Krüger
da18cf8572
Rollup merge of #113625 - compiler-errors:structurally-norm-in-selection, r=lcnr
Structurally normalize in selection

We need to do this because of the fact that we're checking the `Ty::kind` on a type during selection, but goals passed into select are not necessarily normalized.

Right now, we're (kinda) unnecessarily normalizing the RHS of a trait upcasting goal, which is broken for different reasons (#113393). But I'm waiting for this PR to land before discussing that one.

r? `@lcnr`
2023-07-15 19:42:51 +02:00
syvb
2cfe8ed37d Implement "items do not inherit unsafety" for THIR unsafeck 2023-07-15 11:59:38 -04:00
bors
7a17f577b3 Auto merge of #112157 - erikdesjardins:align, r=nikic
Resurrect: rustc_target: Add alignment to indirectly-passed by-value types, correcting the alignment of byval on x86 in the process.

Same as #111551, which I [accidentally closed](https://github.com/rust-lang/rust/pull/111551#issuecomment-1571222612) :/

---

This resurrects PR #103830, which has sat idle for a while.

Beyond #103830, this also:
- fixes byval alignment for types containing vectors on Darwin (see `tests/codegen/align-byval-vector.rs`)
- fixes byval alignment for overaligned types on x86 Windows (see `tests/codegen/align-byval.rs`)
- fixes ABI for types with 128bit requested alignment on ARM64 Linux (see `tests/codegen/aarch64-struct-align-128.rs`)

r? `@nikic`

---

`@pcwalton's` original PR description is reproduced below:

Commit 88e4d2c from five years ago removed
support for alignment on indirectly-passed arguments because of problems with
the `i686-pc-windows-msvc` target. Unfortunately, the `memcpy` optimizations I
recently added to LLVM 16 depend on this to forward `memcpy`s. This commit
attempts to fix the problems with `byval` parameters on that target and now
correctly adds the `align` attribute.

The problem is summarized in [this comment] by `@eddyb.` Briefly, 32-bit x86 has
special alignment rules for `byval` parameters: for the most part, their
alignment is forced to 4. This is not well-documented anywhere but in the Clang
source. I looked at the logic in Clang `TargetInfo.cpp` and tried to replicate
it here. The relevant methods in that file are
`X86_32ABIInfo::getIndirectResult()` and
`X86_32ABIInfo::getTypeStackAlignInBytes()`. The `align` parameter attribute
for `byval` parameters in LLVM must match the platform ABI, or miscompilations
will occur. Note that this doesn't use the approach suggested by eddyb, because
I felt it was overkill to store the alignment in `on_stack` when special
handling is really only needed for 32-bit x86.

As a side effect, this should fix #80127, because it will make the `align`
parameter attribute for `byval` parameters match the platform ABI on LLVM
x86-64.

[this comment]: #80822 (comment)
2023-07-15 15:39:53 +00:00
Guillaume Gomez
2778b71155 Migrate GUI colors test to original CSS color format 2023-07-15 15:14:06 +02:00
Michael Howell
e72fba4160 rustdoc: use src consistently over source in JavaScript
Since the directory that contains source files is called `src`,
it makes sense to name the scripts that way, too.
2023-07-14 16:54:14 -07:00
Michael Howell
34bc8fbea3 rustdoc: use src consistently over source in code
The CSS uses an inconsistent mix of both. This commit switches
it to always use `src`.
2023-07-14 16:38:01 -07:00
Erik Desjardins
2daacf5af9 i686-windows: make requested alignment > 4 special case apply transitively 2023-07-14 17:48:13 -04:00
bors
ad963232d9 Auto merge of #113471 - compiler-errors:new-solver-norm-escaping, r=lcnr
Allow escaping bound vars during `normalize_erasing_regions` in new solver

Add `AllowEscapingBoundVars` to `deeply_normalize`, and use it in the new solver in the `query_normalize` routine.

Ideally, we'd make all `query_normalize` calls handle pass in `AllowEscapingBoundVars` individually, because really the only `query_normalize` call that needs `AllowEscapingBoundVars::Yes` is the one in `try_normalize_generic_arg_after_erasing_regions`, but I think that's kind of overkill. I am happy to be convinced otherwise, though.

r? `@lcnr`
2023-07-14 21:14:30 +00:00