Commit Graph

266 Commits

Author SHA1 Message Date
Nilstrieb
41e8d152dc Show number in error message even for one error
Co-authored-by: Adrian <adrian.iosdev@gmail.com>
2023-11-24 19:15:52 +01:00
Deadbeef
16040a1628 Add Span to TraitBoundModifier 2023-11-24 14:32:05 +00:00
Esteban Küber
ec50f1c90b When failing to import core, suggest std 2023-11-22 19:30:47 +00:00
Nadrieril
98ac114847 Add some tests 2023-11-22 02:14:42 +01:00
bors
a04d56b36d Auto merge of #117817 - fmease:deny-more-tilde-const, r=fee1-dead
Deny more `~const` trait bounds

thereby fixing a family of ICEs (delayed bugs) for `feature(const_trait_impl, effects)` code.

As discussed
r? `@fee1-dead`
2023-11-12 04:40:44 +00:00
León Orell Valerian Liehr
8ce5d784a6
Deny more ~const trait bounds 2023-11-12 00:00:12 +01:00
bors
fdaaaf9f92 Auto merge of #116930 - RalfJung:raw-ptr-match, r=davidtwco
patterns: reject raw pointers that are not just integers

Matching against `0 as *const i32` is fine, matching against `&42 as *const i32` is not.

This extends the existing check against function pointers and wide pointers: we now uniformly reject all these pointer types during valtree construction, and then later lint because of that. See [here](https://github.com/rust-lang/rust/pull/116930#issuecomment-1784654073) for some more explanation and context.

Also fixes https://github.com/rust-lang/rust/issues/116929.

Cc `@oli-obk` `@lcnr`
2023-11-08 20:42:32 +00:00
Matthias Krüger
8a34fea835
Rollup merge of #117516 - matthiaskrgr:test_effects_113375_oob, r=fee1-dead
add test for #113375

Fixes #113375

r? `@fee1-dead`
2023-11-06 20:31:55 +01:00
Matthias Krüger
1683df7d3b
Rollup merge of #117190 - matthiaskrgr:test_effects_113381, r=fee1-dead
add test for #113381

Fixes #113381

r? fee1-dead
2023-11-06 20:31:54 +01:00
Nadrieril
f0e8330879 Suggest to set lint level on whole match 2023-11-04 14:44:00 +01:00
Nadrieril
61d0fc7cf5 Warn when lint level is set on a match arm 2023-11-04 14:44:00 +01:00
Nadrieril
7b19fb88be Add tests 2023-11-04 14:44:00 +01:00
Takayuki Maeda
9b9ea77641
Rollup merge of #117343 - Nadrieril:cleanup_check_match, r=davidtwco
Cleanup `rustc_mir_build/../check_match.rs`

The file had become pretty unwieldy, with a fair amount of duplication. As a bonus, I discovered that we weren't running some pattern checks in if-let chains.

I recommend looking commit-by-commit. The last commit is a whim, I think it makes more sense that way but I don't hold this opinion strongly.
2023-11-04 12:44:44 +09:00
Nadrieril
746197c08a Tweak spans for "adt defined here" note 2023-11-03 18:26:16 +01:00
Michael Goulet
c83f642f12 Pretty print Fn traits in rustc_on_unimplemented 2023-11-02 20:57:05 +00:00
Matthias Krüger
666cad9a5f add test for #113375
Fixes #113375
2023-11-02 16:16:56 +01:00
Matthias Krüger
384f7382ba add test for #113381
Fixes #113381

r? fee1-dead
2023-11-02 15:59:54 +01:00
John Millikin
0f41bc21b9 Stabilize C string literals 2023-11-01 09:16:34 +09:00
León Orell Valerian Liehr
5eb76fac7c
Rollup merge of #117205 - weiznich:multiple_notes_for_on_unimplemented, r=compiler-errors
Allows `#[diagnostic::on_unimplemented]` attributes to have multiple

notes

This commit extends the `#[diagnostic::on_unimplemented]` (and `#[rustc_on_unimplemented]`) attributes to allow multiple `note` options. This enables emitting multiple notes for custom error messages. For now I've opted to not change any of the existing usages of `#[rustc_on_unimplemented]` and just updated the relevant compile tests.

r? `@compiler-errors`

I'm happy to adjust any of the existing changed location to emit the old error message if that's desired.
2023-10-30 10:48:18 +01:00
Ralf Jung
70a8e157ab make pointer_structural_match warn-by-default 2023-10-28 17:02:18 +02:00
Ralf Jung
af6c7e0ca1 also lint against fn ptr and raw ptr nested inside the const 2023-10-28 17:02:18 +02:00
Ralf Jung
bec88ad4aa patterns: reject raw pointers that are not just integers 2023-10-28 17:02:18 +02:00
bors
59bb9505bc Auto merge of #103208 - cjgillot:match-fake-read, r=oli-obk,RalfJung
Allow partially moved values in match

This PR attempts to unify the behaviour between `let _ = PLACE`, `let _: TY = PLACE;` and `match PLACE { _ => {} }`.
The logical conclusion is that the `match` version should not check for uninitialised places nor check that borrows are still live.

The `match PLACE {}` case is handled by keeping a `FakeRead` in the unreachable fallback case to verify that `PLACE` has a legal value.

Schematically, `match PLACE { arms }` in surface rust becomes in MIR:
```rust
PlaceMention(PLACE)
match PLACE {
  // Decision tree for the explicit arms
  arms,
  // An extra fallback arm
  _ => {
    FakeRead(ForMatchedPlace, PLACE);
    unreachable
  }
}
```

`match *borrow { _ => {} }` continues to check that `*borrow` is live, but does not read the value.
`match *borrow {}` both checks that `*borrow` is live, and fake-reads the value.

Continuation of ~https://github.com/rust-lang/rust/pull/102256~ ~https://github.com/rust-lang/rust/pull/104844~

Fixes https://github.com/rust-lang/rust/issues/99180 https://github.com/rust-lang/rust/issues/53114
2023-10-27 18:51:43 +00:00
Georg Semmler
160b1793b2
Allows #[diagnostic::on_unimplemented] attributes to have multiple
notes

This commit extends the `#[diagnostic::on_unimplemented]` (and
`#[rustc_on_unimplemented]`) attributes to allow multiple `note`
options. This enables emitting multiple notes for custom error messages.
For now I've opted to not change any of the existing usages of
`#[rustc_on_unimplemented]` and just updated the relevant compile tests.
2023-10-27 12:42:42 +02:00
Deadbeef
47efc90366 Deny providing explicit effect params 2023-10-26 08:24:25 +00:00
Camille GILLOT
ec28dc7aa7 Use PlaceMention for match scrutinees. 2023-10-24 15:30:17 +00:00
David Tolnay
6a02e20fb5
Update since stability attributes in tests 2023-10-23 13:04:47 -07:00
Matthias Krüger
4681eb6c94
Rollup merge of #117034 - Nadrieril:fix-117033, r=cjgillot
Don't crash on empty match in the `nonexhaustive_omitted_patterns` lint

Oops

Fixes https://github.com/rust-lang/rust/issues/117033
2023-10-22 09:15:42 +02:00
Nadrieril
a134f1624c Fix #117033 2023-10-21 23:04:17 +02:00
Matthias Krüger
31865b7bfb
Rollup merge of #116992 - estebank:issue-69492, r=oli-obk
Mention the syntax for `use` on `mod foo;` if `foo` doesn't exist

Newcomers might get confused that `mod` is the only way of defining scopes, and that it can be used as if it were `use`.

Fix #69492.
2023-10-21 21:23:01 +02:00
Esteban Küber
2cca435717 Mention the syntax for use on mod foo; if foo doesn't exist
Newcomers might get confused that `mod` is the only way of defining
scopes, and that it can be used as if it were `use`.

Fix #69492.
2023-10-21 15:56:01 +00:00
bors
786c94a4eb Auto merge of #116734 - Nadrieril:lint-per-column, r=cjgillot
Lint `non_exhaustive_omitted_patterns` by columns

This is a rework of the `non_exhaustive_omitted_patterns` lint to make it more consistent. The intent of the lint is to help consumers of `non_exhaustive` enums ensure they stay up-to-date with all upstream variants. This rewrite fixes two cases we didn't handle well before:

First, because of details of exhaustiveness checking, the following wouldn't lint `Enum::C` as missing:
```rust
match Some(x) {
    Some(Enum::A) => {}
    Some(Enum::B) => {}
    _ => {}
}
```

Second, because of the fundamental workings of exhaustiveness checking, the following would treat the `true` and `false` cases separately and thus lint about missing variants:
```rust
match (true, x) {
    (true, Enum::A) => {}
    (true, Enum::B) => {}
    (false, Enum::C) => {}
    _ => {}
}
```
Moreover, it would correctly not lint in the case where the pair is flipped, because of asymmetry in how exhaustiveness checking proceeds.

A drawback is that it no longer makes sense to set the lint level per-arm. This will silently break the lint for current users of it (but it's behind a feature gate so that's ok).

The new approach is now independent of the exhaustiveness algorithm; it's a separate pass that looks at patterns column by column. This is another of the motivations for this: I'm glad to move it out of the algorithm, it was akward there.

This PR is almost identical to https://github.com/rust-lang/rust/pull/111651. cc `@eholk` who reviewed it at the time. Compared to then, I'm more confident this is the right approach.
2023-10-21 11:04:19 +00:00
Oli Scherer
e96ce20b34 s/generator/coroutine/ 2023-10-20 21:14:01 +00:00
Oli Scherer
60956837cf s/Generator/Coroutine/ 2023-10-20 21:10:38 +00:00
bors
616e37919c Auto merge of #116756 - fee1-dead-contrib:dupe-those-bounds, r=oli-obk
Duplicate `~const` bounds with a non-const one in effects desugaring

This should unblock #116058.

r? `@oli-obk`
2023-10-17 12:16:54 +00:00
Deadbeef
f0f89d6d43 Duplicate ~const bounds with a non-const one in effects desugaring 2023-10-15 08:59:38 +00:00
Nadrieril
ca869e3334 Lint non_exhaustive_omitted_patterns per column 2023-10-14 19:39:18 +02:00
Nadrieril
2d45df3caa Add and prepare tests 2023-10-14 19:39:18 +02:00
Michael Goulet
59315b8a63 Stabilize AFIT and RPITIT 2023-10-13 21:01:36 +00:00
Ali MJ Al-Nasrawy
a8830631b9 remove trailing dots 2023-10-08 10:06:17 +00:00
Ali MJ Al-Nasrawy
996ffcb718 always show and explain sub region 2023-10-08 09:59:51 +00:00
Alex Macleod
5453a9f34d Add a note to duplicate diagnostics 2023-10-05 01:04:41 +00:00
Raekye
884af362f2 Validate ~const trait bounds on associated fns.
Previously, any associated function could have `~const` trait bounds on
generic parameters, which could lead to ICEs when these bounds were used
on associated functions of non-`#[const_trait] trait` or
non-`impl const` blocks.

Includes changes as per @fee1-dead's comments in #116210.
2023-09-30 19:00:45 -04:00
bors
e4133ba9b1 Auto merge of #116077 - matthiaskrgr:rollup-2y1buzg, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #115770 (Match on elem first while building move paths)
 - #115999 (Capture scrutinee of if let guards correctly)
 - #116056 (Make unsized casts illegal)
 - #116061 (Remove TaKO8Ki from review rotation)
 - #116062 (Change `start` to `#[start]` in some diagnosis)
 - #116067 (Open the FileEncoder file for reading and writing)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-09-22 21:46:07 +00:00
bors
aadb5718dd Auto merge of #116001 - fmease:validate-crate-name-extern-cli-opt, r=est31
[breaking change] Validate crate name in `--extern` [MCP 650]

Reject non-ASCII-identifier crate names passed to the CLI option `--extern` (`rustc`, `rustdoc`).
Implements [MCP 650](https://github.com/rust-lang/compiler-team/issues/650) (except that we only allow ASCII identifiers not arbitrary Rust identifiers).
Fixes #113035.

[As mentioned on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/Disallow.20non-identifier-valid.20--extern.20cr.E2.80.A6.20compiler-team.23650/near/376826988), doing a crater run probably doesn't make sense since it wouldn't yield anything. Most users don't interact with `rustc` directly but only ever through Cargo which always passes a valid crate name to `--extern` when it invokes `rustc` and `rustdoc`. In any case, the user wouldn't be able to use such a crate name in the source code anyway.

Note that I'm not using [`rustc_session::output::validate_crate_name`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_session/output/fn.validate_crate_name.html) (used for `--crate-name` and `#![crate_name]`) since the latter doesn't reject non-ASCII crate names and ones that start with a digit.

As an aside, I've also thought about getting rid of `validate_crate_name` entirely in a separate PR (with another MCP) in favor of `is_ascii_ident` to reject more weird `--crate-name`s, `#![crate_name]`s and file names but I think that would lead to a lot of actual breakage, namely because of file names starting with a digit. In `tests/ui` 9 tests would be impacted for example.

CC `@estebank`
r? `@est31`
2023-09-22 19:57:07 +00:00
Eduardo Sánchez Muñoz
17dfabff9c Change start to #[start] in some diagnosis
They refer to a function with the `start` attribute, but not necessarily named `start`.
2023-09-22 15:58:43 +02:00
bors
8759de0a49 Auto merge of #114776 - fee1-dead-contrib:enable-effects-in-libcore, r=oli-obk
Enable effects for libcore

~~r? `@oli-obk~~`

forgot you are on vacation, oops
2023-09-22 07:00:52 +00:00
León Orell Valerian Liehr
8d81d5a909
Validate crate name in CLI option --extern 2023-09-20 18:50:40 +02:00
Deadbeef
2063ebc3ea bless the known-bug tests 2023-09-20 03:02:14 +00:00
Deadbeef
04eec37dc2 Enable effects for libcore 2023-09-20 03:02:14 +00:00
Matthew Jasper
b49140295c Add more if let guard tests 2023-09-19 12:48:40 +00:00
bors
ae9465fee3 Auto merge of #115859 - compiler-errors:effect-fallback, r=fee1-dead
Fallback effects even if types also fallback

`||` is short circuiting, so if we do ty/int var fallback, we *don't* do effect fallback 😸

r? `@fee1-dead` or `@oli-obk`

Fixes #115791
Fixes #115842
2023-09-15 00:05:28 +00:00
Michael Goulet
5c907a7859 Fallback effects even if types also fall back 2023-09-14 21:08:42 +00:00
bors
dac91a82e1 Auto merge of #115677 - matthewjasper:let-expr-recovery, r=b-naber
Improve invalid let expression handling

- Move all of the checks for valid let expression positions to parsing.
- Add a field to ExprKind::Let in AST/HIR to mark whether it's in a valid location.
- Suppress some later errors and MIR construction for invalid let expressions.
- Fix a (drop) scope issue that was also responsible for #104172.

Fixes #104172
Fixes #104868
2023-09-14 19:56:55 +00:00
Matthew Jasper
e324a59eb6 Address review comments
- Add doc comment to new type
- Restore "only supported directly in conditions of `if` and `while` expressions" note
- Rename variant with clearer name
2023-09-13 15:00:31 +00:00
Matthew Jasper
b011a0a13b Reduce double errors for invalid let expressions
Previously some invalid let expressions would result in both a feature
error and a parsing error. Avoid this and ensure that we only emit the
parsing error when this happens.
2023-09-11 16:17:06 +00:00
Matthew Jasper
333388fd3c Move let expression checking to parsing
There was an incomplete version of the check in parsing and a second
version in AST validation. This meant that some, but not all, invalid
uses were allowed inside macros/disabled cfgs. It also means that later
passes have a hard time knowing when the let expression is in a valid
location, sometimes causing ICEs.

- Add a field to ExprKind::Let in AST/HIR to mark whether it's in a
  valid location.
- Suppress later errors and MIR construction for invalid let
  expressions.
2023-09-11 15:51:18 +00:00
Matthew Jasper
7b61f7f002 Don't create drop scopes after item statements
These scopes would not exist in MIR and can cause ICEs with invalid uses
of let expressions.
2023-09-11 15:51:18 +00:00
Deadbeef
84a490712a Implement fallback for effect param 2023-09-10 07:48:47 +00:00
bors
21305f4d5f Auto merge of #115270 - sebastiantoh:issue-105479, r=Nadrieril
Add note on non-exhaustiveness when matching on str and nested non-exhaustive enums

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

r? `@Nadrieril`
2023-09-03 19:31:47 +00:00
Sebastian Toh
d87b87d10e Improve clarity of diagnostic message on non-exhaustive matches 2023-09-03 19:55:11 +08:00
bors
f4555ef5e1 Auto merge of #111752 - dingxiangfei2009:lower-or-pattern, r=cjgillot
Lower `Or` pattern without allocating place

cc `@azizghuloum` `@cjgillot`

Related to #111583 and #111644

While reviewing #111644, it occurs to me that while we directly lower conjunctive predicates, which are connected with `&&`, into the desirable control flow, today we don't directly lower the disjunctive predicates, which are connected with `||`, in the similar fashion. Instead, we allocate a place for the boolean temporary to hold the result of evaluating the `||` expression.

Usually I would expect optimization at later stages to "inline" the evaluation of boolean predicates into simple CFG, but #111583 is an example where `&&` is failing to be optimized away and the assembly shows that both the expensive operands are evaluated. Therefore, I would like to make a small change to make the CFG a bit more straight-forward without invoking the `as_temp` machinery, and plus avoid allocating the place to hold the boolean result as well.
2023-09-01 10:54:56 +00:00
Michael Goulet
bf66723c0e Test and note unsafe ctor to fn ptr coercion
Also remove a note that I don't consider to be very useful in context.
2023-08-30 15:09:40 -07:00
Ding Xiang Fei
d9ed11872f
lower bare boolean expression with if-construct 2023-08-30 17:24:11 +08:00
Ding Xiang Fei
e5453b4806
lower ExprKind::Use, LogicalOp::Or and UnOp::Not
Co-authored-by: Abdulaziz Ghuloum <aghuloum@gmail.com>
2023-08-30 17:24:10 +08:00
Sebastian Toh
43dd8613a3 Add note when matching on nested non-exhaustive enums 2023-08-28 14:50:32 +08:00
Esteban Küber
ef11db803c Remove unnecessary select_obligations_where_possible and redundant errors 2023-08-26 19:35:54 +00:00
Esteban Küber
bac0e556f0 On let binding type point to type parameter that introduced unmet bound
On the following example, point at `String` instead of the whole type:

```
error[E0277]: the trait bound `String: Copy` is not satisfied
  --> $DIR/own-bound-span.rs:14:24
   |
LL |     let _: <S as D>::P<String>;
   |                        ^^^^^^ the trait `Copy` is not implemented for `String`
   |
note: required by a bound in `D::P`
  --> $DIR/own-bound-span.rs:4:15
   |
LL |     type P<T: Copy>;
   |               ^^^^ required by this bound in `D::P`
```
2023-08-26 02:23:25 +00:00
Michael Goulet
13e8b13e15 Handle Self in paths too 2023-08-25 19:05:38 +00:00
Matthew Jasper
d3c3c17abb Add more tests for if_let_guard 2023-08-24 16:29:08 +01:00
Guillaume Gomez
e4b9e72e58
Rollup merge of #114827 - compiler-errors:next-solver-dyn-safe-candidates, r=lcnr
Only consider object candidates for object-safe dyn types in new solver

We apparently allow this per RFC2027 💀

r? lcnr
2023-08-15 14:29:48 +02:00
Michael Goulet
e8ab56fbb4 Only consider object candidates for object-safe dyn types 2023-08-15 01:01:44 +00:00
Deadbeef
f441fa08da Remove constness from ImplSource::Param 2023-08-14 02:17:30 +00:00
Deadbeef
057be381c6 Fix ICE 2023-08-07 17:16:10 +00:00
Deadbeef
6c1e3bb6e9 bless tests 2023-08-06 13:34:53 +00:00
Deadbeef
92f4c59e48 lower impl const to bind to host effect param 2023-08-06 13:34:53 +00:00
Deadbeef
4fec845c3f Remove constness from TraitPredicate 2023-08-02 15:38:00 +00:00
Deadbeef
df3f9fdf5a Effects: don't print host param in diagnostics 2023-07-29 14:55:35 +00:00
Deadbeef
2d59451274 update tests, adding known-bug 2023-07-27 15:51:02 +00:00
Deadbeef
0d9c871736 add proc macro test 2023-07-23 10:09:43 +00:00
Deadbeef
df9bd80d74 reimplement C string literals 2023-07-23 06:54:07 +00:00
bors
1c44af9b79 Auto merge of #111836 - calebzulawski:target-feature-closure, r=workingjubilee
Fix #[inline(always)] on closures with target feature 1.1

Fixes #108655.  I think this is the most obvious solution that isn't overly complicated.  The comment includes more justification, but I think this is likely better than demoting the `#[inline(always)]` to `#[inline]`, since existing code is unaffected.
2023-07-23 00:16:03 +00:00
Dylan DPC
dbb6b1ac31
Rollup merge of #113754 - cjgillot:simplify-foreign, r=petrochenkov
Simplify native_libs query

Drive-by cleanup I saw while implementing https://github.com/rust-lang/rust/pull/113734
2023-07-19 22:37:07 +05:30
bors
77e24f90f5 Auto merge of #112591 - jfgoog:better-dlltool-diagnostics, r=WaffleLapkin
Better diagnostics for dlltool errors.

When dlltool fails, show the full command that was executed. In particular, llvm-dlltool is not very helpful, printing a generic usage message rather than what actually went wrong, so stdout and stderr aren't of much use when troubleshooting.
2023-07-19 07:27:50 +00:00
Camille GILLOT
09743b9ebf Bless ui tests. 2023-07-18 18:15:45 +00:00
James Farrell
c59b82353d Better diagnostics for dlltool errors.
When dlltool fails, show the full command that was executed. In
particular, llvm-dlltool is not very helpful, printing a generic usage
message rather than what actually went wrong, so stdout and stderr
aren't of much use when troubleshooting.
2023-07-17 20:20:01 +00:00
bors
da1d099f91 Auto merge of #112945 - compiler-errors:tighten-span-of-adjustment-error, r=oli-obk
(re-)tighten sourceinfo span of adjustments in MIR

Diagnostics rely on the spans of MIR statements being (approximately) correct in order to give suggestions relative to that span (i.e. `shrink_to_hi` and `shrink_to_lo`).

I discovered that we're *intentionally* lowering THIR exprs with their parent expr's span if they come from adjustments that are due to a parent expression. While I understand why that may be desirable to demonstrate the relationship of an adjustment and the expression that requires it, it leads to

1. very verbose borrowck output
2. incorrect spans for suggestions

Some diagnostics get around that by giving suggestions relative to other spans we've collected during MIR lowering, such as the span of the method's identifier (e.g. `name` in `.name()`), but this doesn't work too well when things come from desugaring.

I assume it also has lead to numerous tweaks and complications to diagnostics code down the road, which this PR doesn't necessarily aim to fix but may open the gates to fixing later... The last three commits are simplifications due to the fact that we can assume that the move span actually points to what is being moved (and a test).

This regressed in #89110, which was debated somewhat in #90286. cc `@Aaron1011` who originally made this change.

r? diagnostics

Fixes #113547
Fixes #111016
2023-07-12 12:11:09 +00:00
Michael Goulet
fe870424a7 Do not set up wrong span for adjustments 2023-07-10 20:09:26 +00:00
Santiago Pastorino
20429af7a3
Replace RPITIT current impl with new strategy that lowers as a GAT 2023-07-08 18:21:34 -03:00
fee1-dead
1830b80c2d
Rollup merge of #113334 - fmease:revert-lexing-c-str-lits, r=compiler-errors
Revert the lexing of `c"…"` string literals

Fixes \[after beta-backport\] #113235.
Further progress is tracked in #113333.

This PR *manually* reverts parts of #108801 (since a git-revert would've been too coarse-grained & messy)
and git-reverts #111647.

CC `@fee1-dead` (#108801) `@klensy` (#111647)
r? `@compiler-errors`

`@rustbot` label F-c_str_literals beta-nominated
2023-07-06 09:20:33 +08:00
León Orell Valerian Liehr
22fd6a6abf
Add regression test 2023-07-05 13:45:12 +02:00
León Orell Valerian Liehr
c6643b50ea
Revert the lexing of c_str_literals 2023-07-05 13:11:17 +02:00
Deadbeef
30b21b758a add test 2023-07-04 11:47:46 +00:00
bors
6fc0273b5a Auto merge of #112320 - compiler-errors:do-not-impl-via-obj, r=lcnr
Add `implement_via_object` to `rustc_deny_explicit_impl` to control object candidate assembly

Some built-in traits are special, since they are used to prove facts about the program that are important for later phases of compilation such as codegen and CTFE. For example, the `Unsize` trait is used to assert to the compiler that we are able to unsize a type into another type. It doesn't have any methods because it doesn't actually *instruct* the compiler how to do this unsizing, but this is later used (alongside an exhaustive match of combinations of unsizeable types) during codegen to generate unsize coercion code.

Due to this, these built-in traits are incompatible with the type erasure provided by object types. For example, the existence of `dyn Unsize<T>` does not mean that the compiler is able to unsize `Box<dyn Unsize<T>>` into `Box<T>`, since `Unsize` is a *witness* to the fact that a type can be unsized, and it doesn't actually encode that unsizing operation in its vtable as mentioned above.

The old trait solver gets around this fact by having complex control flow that never considers object bounds for certain built-in traits:
2f896da247/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs (L61-L132)

However, candidate assembly in the new solver is much more lovely, and I'd hate to add this list of opt-out cases into the new solver. Instead of maintaining this complex and hard-coded control flow, instead we can make this a property of the trait via a built-in attribute. We already have such a build attribute that's applied to every single trait that we care about: `rustc_deny_explicit_impl`. This PR adds `implement_via_object` as a meta-item to that attribute that allows us to opt a trait out of object-bound candidate assembly as well.

r? `@lcnr`
2023-06-20 08:42:37 +00:00
Michael Goulet
ca68cf0d46 Merge attrs, better validation 2023-06-20 04:38:55 +00:00
Deadbeef
89c24af133 Better error for non const PartialEq call generated by match 2023-06-18 05:24:38 +00:00
许杰友 Jieyou Xu (Joe)
edafbaffb2
Adjust UI tests for unit_bindings
- Either explicitly annotate `let x: () = expr;` where `x` has unit
  type, or remove the unit binding to leave only `expr;` instead.
- Fix disjoint-capture-in-same-closure test
2023-06-12 20:24:48 +08:00
Maybe Waffle
9d3482c403 Better group RFC ui tests together 2023-06-05 16:09:46 +00:00
Caleb Zulawski
ddb16e2884 Fix #[inline(always)] on closures with target feature 1.1 2023-05-22 00:13:40 -04:00
Deadbeef
6d905a8cc1 fix tidy 2023-05-02 10:32:08 +00:00
Deadbeef
abb181dfd9 make it semantic error 2023-05-02 10:32:08 +00:00
Deadbeef
bf3ca5979e try gating early, add non-ascii test 2023-05-02 10:32:08 +00:00
Deadbeef
a49570fd20 fix TODO comments 2023-05-02 10:32:07 +00:00
Deadbeef
76d1f93896 update and add a few tests 2023-05-02 10:30:09 +00:00
Léo Lanteri Thauvin
963305bda8 Forbid the use of #[target_feature] on start 2023-03-12 14:57:38 +01:00
Léo Lanteri Thauvin
db26693982 Forbid the use of #[target_feature] on main 2023-03-12 14:57:38 +01:00
Léo Lanteri Thauvin
ad2bcb5c0e Forbid #[target_feature] on safe default implementations 2023-03-10 13:50:51 +01:00
Léo Lanteri Thauvin
bfe5189904 Revert "Stabilize #![feature(target_feature_11)]"
This reverts commit b379d216ee.
2023-03-02 13:41:17 +01:00
Léo Lanteri Thauvin
b379d216ee Stabilize #![feature(target_feature_11)] 2023-02-01 08:53:02 +01:00
Esteban Küber
d86835769c Make structured suggestion for fn casting verbose 2023-01-30 21:55:25 +00:00
Esteban Küber
5ae8e23816 Mention fn coercion rules (needs to be expanded) 2023-01-30 21:51:33 +00:00
Esteban Küber
62ba3e70a1 Modify primary span label for E0308
The previous output was unintuitive to users.
2023-01-30 20:12:19 +00:00
Matthias Krüger
9e3f330656
Rollup merge of #106897 - estebank:issue-99430, r=davidtwco
Tweak E0597

CC #99430
2023-01-25 22:19:52 +01:00
Matthew J Perez
1e22280f23
Add suggestions for function pointers
- On compiler-error's suggestion of moving this lower down the stack,
along the path of `report_mismatched_types()`, which is used
by `rustc_hir_analysis` and `rustc_hir_typeck`.
- update ui tests, add test
- add suggestions for references to fn pointers
- modify `TypeErrCtxt::same_type_modulo_infer` to take `T: relate::Relate` instead of `Ty`
2023-01-24 14:02:56 -05:00
Esteban Küber
656db98bd9 Tweak E0597
CC #99430
2023-01-15 19:46:20 +00:00
Albert Larsan
cf2dff2b1e
Move /src/test to /tests 2023-01-11 09:32:08 +00:00