Commit Graph

211 Commits

Author SHA1 Message Date
Jana Dönszelmann 230ad7f639 fix problems with type checking 2025-12-12 11:28:58 +01:00
Jana Dönszelmann 8dfb2cdece EII type checking 2025-12-12 11:28:58 +01:00
bors bad50269f8 Auto merge of #147602 - JohnTitor:dedup-lifetime-capture-errors, r=estebank
Deduplicate higher-ranked lifetime capture errors in impl Trait

  Previously, when an `impl Trait` captured multiple higher-ranked
  lifetimes from an outer `impl Trait`, the compiler would emit a
  separate error for each captured lifetime. This resulted in verbose
  and confusing diagnostics, especially in edition 2024 where implicit
  captures caused duplicate errors.

  This commit introduces error accumulation that collects all capture
  spans and lifetime declaration spans, then emits a single consolidated
  diagnostic using MultiSpan. The new error shows all captured lifetimes
  with visual indicators and lists all declarations in a single note.

r? `@estebank`
Fixes https://github.com/rust-lang/rust/issues/143022
2025-12-10 06:52:27 +00:00
lcnr feb13036ef remove support for type-of 2025-11-25 10:19:44 +01:00
León Orell Valerian Liehr c262920059 Remove #[const_trait] 2025-11-08 07:37:15 +01:00
Esteban Küber 116bd92585 Always point at trait assoc item when generics don't match
Previously we only showed the trait's assoc item if the trait was local, because we were looking for a small span only for the generics, which we don't have for foreign traits. We now use `def_span` for the item, so we at least provide some context, even if its span is too wide.

```
error[E0195]: lifetime parameters or bounds on type `IntoIter` do not match the trait declaration
   --> tests/ui/lifetimes/missing-lifetime-in-assoc-type-4.rs:7:18
    |
7   |     type IntoIter<'a> = std::collections::btree_map::Values<'a, i32, T>;
    |                  ^^^^ lifetimes do not match type in trait
    |
   ::: /home/gh-estebank/rust/library/core/src/iter/traits/collect.rs:292:5
    |
292 |     type IntoIter: Iterator<Item = Self::Item>;
    |     ------------------------------------------ lifetimes in impl do not match this type in trait
```
2025-11-03 02:13:53 +00:00
Oli Scherer 375899c940 Allow unsizing pattern types with pointer base 2025-10-21 11:22:51 +00:00
Yuki Okushi e4194c7075 Deduplicate higher-ranked lifetime capture errors in impl Trait
Previously, when an `impl Trait` captured multiple higher-ranked
  lifetimes from an outer `impl Trait`, the compiler would emit a
  separate error for each captured lifetime. This resulted in verbose
  and confusing diagnostics, especially in edition 2024 where implicit
  captures caused duplicate errors.

  This commit introduces error accumulation that collects all capture
  spans and lifetime declaration spans, then emits a single consolidated
  diagnostic using MultiSpan. The new error shows all captured lifetimes
  with visual indicators and lists all declarations in a single note.
2025-10-12 16:51:28 +09:00
Folkert de Vries 98d3864310 cmse: rephrase error message when signature uses generics 2025-10-08 16:36:45 +02:00
Folkert de Vries b47de64cdb cmse: rephrase error message when types don't fit 2025-10-08 16:36:18 +02:00
Folkert de Vries f4d8bd3b47 cmse: more accurate spans for excess parameters
Use the span of the types that don't fit, rather than the span of the
whole signature.
2025-10-08 16:21:50 +02:00
Jana Dönszelmann 6087d89004 fixup limit handling code 2025-09-08 15:07:12 -07:00
lcnr d6a18e1867 change non-defining use error message 2025-08-25 14:20:18 +02:00
lcnr 14b0ba6a05 support non-defining uses in HIR typeck 2025-08-25 14:20:18 +02:00
Matthias Krüger f38891e697 Rollup merge of #142693 - fmease:unbound-bettering, r=compiler-errors
More robustly deal with relaxed bounds and improve their diagnostics

Scaffolding for https://github.com/rust-lang/rust/issues/135229 (CC https://github.com/rust-lang/rust/pull/135331)

Fixes https://github.com/rust-lang/rust/issues/136944 (6th commit).
Fixes https://github.com/rust-lang/rust/issues/142718 (8th commit).
2025-07-18 19:14:43 +02:00
Matthias Krüger 3acbb4d421 Rollup merge of #143699 - compiler-errors:async-drop-fund, r=oli-obk
Make `AsyncDrop` check that it's being implemented on a local ADT

Fixes https://github.com/rust-lang/rust/issues/143691
2025-07-18 14:49:17 +02:00
León Orell Valerian Liehr 82a02aefe0 HIR ty lowering: Validate PointeeSized bounds 2025-07-18 12:25:24 +02:00
León Orell Valerian Liehr cdc3d701cb Don't reject *multiple* relaxed bounds, reject *duplicate* ones.
Having multiple relaxed bounds like `?Sized + ?Iterator` is actually *fine*.
We actually want to reject *duplicate* relaxed bounds like `?Sized + ?Sized`
because these most certainly represent a user error.

Note that this doesn't mean that we accept more code because a bound like
`?Iterator` is still invalid as it's not relaxing a *default* trait and
the only way to define / use more default bounds is under the experimental
and internal feature `more_maybe_bounds` plus `lang_items` plus unstable
flag `-Zexperimental-default-bounds` (historical context: for the longest
time, bounds like `?Iterator` were actually allowed and lead to a hard
warning).

Ultimately, this simply *reframes* the diagnostic. The scope of
`more_maybe_bounds` / `-Zexperimental-default-bounds` remains unchanged
as well.
2025-07-18 12:24:56 +02:00
Deadbeef 69326878ee parse const trait Trait 2025-07-17 18:06:26 +08:00
Michael Goulet 728017ea8f Make AsyncDrop check that it's being implemented on a local ADT 2025-07-09 17:07:04 +00:00
David Wood 2057423506 hir_analysis: prohibit dyn PointeeSized 2025-06-27 17:01:47 +00:00
xizheyin d2d17c60bd Add runtime check to avoid overwrite arg easily in diag and store and restore snapshot when set subdiag arg
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-06-25 21:07:16 +08:00
Andrew Zhogin eee2d7b101 AsyncDrop trait without sync Drop generates an error 2025-06-18 09:04:34 +07:00
Matthias Krüger fe54c3a5eb Rollup merge of #142464 - RalfJung:variadic-fn-abi-error, r=workingjubilee
variadic functions: remove list of supported ABIs from error

I think this list is problematic for multiple reasons:
- It is bound to go out-of-date as it is in a very different place from where we actually define which functions support varagrs (`fn supports_varargs`).
- Many of the ABIs we list only work on some targets; it makes no sense to mention "aapcs" as a possible ABI when building for x86_64. (This led to a lot of confusion in https://github.com/rust-lang/rust/issues/110505 where the author thought they should use "cdecl" and then were promptly told that "cdecl" is not a legal ABI on their target.)
- Typically, when the programmer wrote `extern "foobar"`, it is because they need the "foobar" ABI. It is of little use to tell them that there are other ABIs with which varargs would work.

Cc ``@workingjubilee``
2025-06-14 11:27:11 +02:00
Ralf Jung 963fdbc852 variadic functions: remove list of supported ABIs from error 2025-06-13 18:10:06 +02:00
Folkert de Vries 5f73ce2b7e add extern "custom" functions 2025-06-12 20:27:10 +02:00
Ralf Jung 8808c9d34b intrinsics: use const generic to set atomic ordering 2025-06-07 21:45:58 +02:00
omahs 1caaa88700 Fix typos 2025-05-12 17:20:49 +00:00
Michael Goulet 3ab6051b95 Move inline_asm to typeck, properly handle aliases 2025-04-27 22:05:07 +00:00
Nicholas Nethercote 1b3fc585cb Rename some name variables as ident.
It bugs me when variables of type `Ident` are called `name`. It leads to
silly things like `name.name`. `Ident` variables should be called
`ident`, and `name` should be used for variables of type `Symbol`.

This commit improves things by by doing `s/name/ident/` on a bunch of
`Ident` variables. Not all of them, but a decent chunk.
2025-04-10 09:30:55 +10:00
xtex fdefffecb2 compiler: report error when trait object type param reference self
Fixes #139082.

Emits an error when `Self` is found in the projection bounds of a trait
object. In type aliases, `Self` has no meaning, so `type A = &'static
dyn B` where `trait B = Fn() -> Self` will expands to `type A = &'static
Fn() -> Self` which is illegal, causing the region solver to bail out
when hitting the uninferred Self.

Bug: #139082
Signed-off-by: xtex <xtexchooser@duck.com>
2025-04-03 17:35:51 +08:00
Oli Scherer cb4751d4b8 Implement #[define_opaque] attribute for functions. 2025-03-11 12:05:02 +00:00
Michael Goulet 1c3733aa69 Rollup merge of #137808 - jswrenn:droppy-unsafe-fields, r=nnethercote
Do not require that unsafe fields lack drop glue

Instead, we adopt the position that introducing an `unsafe` field itself carries a safety invariant: that if you assign an invariant to that field weaker than what the field's destructor requires, you must ensure that field is in a droppable state in your destructor.

See:
- https://github.com/rust-lang/rfcs/pull/3458#discussion_r1971676100
- https://rust-lang.zulipchat.com/#narrow/channel/213817-t-lang/topic/unsafe.20fields.20RFC/near/502113897

Tracking Issue: #132922
2025-03-06 12:22:19 -05:00
Michael Goulet aab7b145d0 Rollup merge of #137565 - compiler-errors:macro-ex, r=estebank
Try to point of macro expansion from resolver and method errors if it involves macro var

In the case that a macro caller passes an identifier into a macro generating a path or method expression, point out that identifier in the context of the *macro* so it's a bit more clear how the macro is involved in causing the error.

r? ``````````@estebank`````````` or reassign
2025-03-06 12:22:13 -05:00
Oli Scherer e8f7a382be Remove the Option part of range ends in the HIR 2025-03-06 10:47:40 +00:00
Michael Goulet 06072468fe Fix associated type errors too 2025-03-03 23:53:42 +00:00
Jack Wrenn 91034adf30 Do not require that unsafe fields lack drop glue
Instead, we adopt the position that introducing an `unsafe` field
itself carries a safety invariant: that if you assign an invariant
to that field weaker than what the field's destructor requires,
you must ensure that field is in a droppable state in your
destructor.

See:
- https://github.com/rust-lang/rfcs/pull/3458#discussion_r1971676100
- https://rust-lang.zulipchat.com/#narrow/channel/213817-t-lang/topic/unsafe.20fields.20RFC/near/502113897
2025-02-28 16:32:06 +00:00
Oli Scherer ffc955bcfb Don't require method impls for methods with Self:Sized bounds for impls for unsized types 2025-02-25 08:06:30 +00:00
Michael Goulet 5c5ed92c37 Simplify trait error message for CoercePointee validation 2025-02-24 19:34:54 +00:00
Michael Goulet 96d966b07a Consolidate and rework CoercePointee and DispatchFromDyn errors 2025-02-24 19:34:54 +00:00
Esteban Küber 693f7035f1 Make E0599 a structured error 2025-02-18 04:50:33 +00:00
Michael Goulet 72b4df3772 Implement lint for definition site item shadowing too 2025-02-13 05:45:53 +00:00
bors 552a959051 Auto merge of #136918 - GuillaumeGomez:rollup-f6h21gg, r=GuillaumeGomez
Rollup of 8 pull requests

Successful merges:

 - #134981 ( Explain that in paths generics can't be set on both the enum and the variant)
 - #136698 (Replace i686-unknown-redox target with i586-unknown-redox)
 - #136767 (improve host/cross target checking)
 - #136829 ([rustdoc] Move line numbers into the `<code>` directly)
 - #136875 (Rustc dev guide subtree update)
 - #136900 (compiler: replace `ExternAbi::name` calls with formatters)
 - #136913 (Put kobzol back on review rotation)
 - #136915 (documentation fix: `f16` and `f128` are not double-precision)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-02-12 12:42:25 +00:00
Jubilee Young 32fd1a7b72 compiler: replace ExternAbi::name calls with formatters
Most of these just format the ABI string, so... just format ExternAbi?
This makes it more consistent and less jank when we can do it.
2025-02-11 19:42:47 -08:00
Jubilee Young d97bde059a Revert "Stabilize extended_varargs_abi_support"
This reverts commit 685f189b43.
2025-02-11 17:22:27 -08:00
Ding Xiang Fei b9435056a7 move repr(transparent) checks to coherence 2025-02-09 20:40:43 +08:00
Ding Xiang Fei c067324637 rename the trait to validity and place a feature gate afront 2025-02-09 20:40:42 +08:00
Ding Xiang Fei de405dcb8f introduce CoercePointeeWellformed for coherence checks at typeck stage 2025-02-09 20:40:41 +08:00
Oli Scherer f0308938ba Use a different hir type for patterns in pattern types than we use in match patterns 2025-02-03 08:18:30 +00:00
Michael Goulet ac1c6c50f4 Use identifiers in diagnostics more often 2025-01-27 01:23:34 +00:00