about summary refs log tree commit diff
path: root/compiler/rustc_error_codes/src
AgeCommit message (Collapse)AuthorLines
2025-07-18Don't reject *multiple* relaxed bounds, reject *duplicate* ones.León Orell Valerian Liehr-5/+5
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-15New example for E0536Jonathan Brouwer-9/+7
2025-06-25compiler: Trim the misleading C of C-cmse from errorsJubilee Young-13/+13
2025-06-18convert the `optimize` attribute to a new parserJana Dönszelmann-1/+8
2025-06-17make error codes reflect reality betterJana Dönszelmann-9/+71
2025-06-07intrinsics: use const generic to set atomic orderingRalf Jung-29/+7
2025-06-05doc: Fix inverted meaning in E0783.mdmaflcko-1/+1
2025-05-28Stabilise `repr128`beetrees-9/+3
2025-05-02resolve: Support imports of associated types and glob imports from traitsVadim Petrochenkov-1/+5
2025-05-01Rollup merge of #138703 - pudongair:master, r=workingjubileeGuillaume Gomez-1/+1
chore: remove redundant words in comment remove redundant words in comment
2025-04-20stabilize `naked_functions`Folkert de Vries-2/+0
2025-04-19Make `#[naked]` an unsafe attributeFolkert de Vries-2/+2
2025-04-13error on unsafe attributes in pre-2024 editionsFolkert de Vries-7/+8
the `no_mangle`, `link_section` and `export_name` attributes are exceptions, and can still be used without an unsafe in earlier editions
2025-04-09Remove some dead or leftover code related to rustc-intrinsic abi removalOli Scherer-2/+4
2025-04-06update/bless testsBennet Bleßmann-5/+5
2025-03-26chore: remove redundant words in commentpudongair-1/+1
Signed-off-by: pudongair <744355276@qq.com>
2025-03-25Avoid `kw::Empty` when dealing with `rustc_allowed_through_unstable_modules`.Nicholas Nethercote-1/+1
The existing code produces `Some(kw::Empty)` for these invalid forms: - a non-name-value, e.g. `#[rustc_allowed_through_unstable_modules]` - a non-string arg, e.g. `#[rustc_allowed_through_unstable_modules = 3]` The new code avoids the `kw::Empty` and is a little shorter. It will produce `None` in those cases, which means E0789 won't be produced if the `stable` attribute is missing for these invalid forms. This doesn't matter, because these invalid forms will trigger an "malformed `rustc_allowed_through_unstable_modules` attribute" anyway.
2025-03-21Rollup merge of #138364 - BLANKatGITHUB:compiler, r=RalfJungMatthias Krüger-25/+17
ports the compiler test cases to new rust_intrinsic format pr is part of #132735
2025-03-19Allow builtin macros to be used more than once.Mara Bos-39/+3
This removes E0773 "A builtin-macro was defined more than once."
2025-03-18updated compiler tests for rustc_intrinsic'aaishwarymishra@gmail.com-25/+17
Update compiler/rustc_error_codes/src/error_codes/E0622.md Co-authored-by: Ralf Jung <post@ralfj.de> reverted chages on E0622.md updated E0622.md
2025-03-14Clarify "owned data" in E0515.mdMarijn Schouten-3/+6
This clarifies the explanation of why this is not allowed and also what to do instead. Fixes 62071 PS There was suggestion of adding a link to the book. I did not yet do that, but if desired that could be added.
2025-03-12Rollup merge of #138331 - nnethercote:use-RUSTC_LINT_FLAGS-more, ↵Matthias Krüger-1/+0
r=onur-ozkan,jieyouxu Use `RUSTC_LINT_FLAGS` more An alternative to the failed #138084. Fixes #138106. r? ````@jieyouxu````
2025-03-11Auto merge of #128440 - oli-obk:defines, r=lcnrbors-0/+4
Add `#[define_opaques]` attribute and require it for all type-alias-impl-trait sites that register a hidden type Instead of relying on the signature of items to decide whether they are constraining an opaque type, the opaque types that the item constrains must be explicitly listed. A previous version of this PR used an actual attribute, but had to keep the resolved `DefId`s in a side table. Now we just lower to fields in the AST that have no surface syntax, instead a builtin attribute macro fills in those fields where applicable. Note that for convenience referencing opaque types in associated types from associated methods on the same impl will not require an attribute. If that causes problems `#[defines()]` can be used to overwrite the default of searching for opaques in the signature. One wart of this design is that closures and static items do not have generics. So since I stored the opaques in the generics of functions, consts and methods, I would need to add a custom field to closures and statics to track this information. During a T-types discussion we decided to just not do this for now. fixes #131298
2025-03-11Implement `#[define_opaque]` attribute for functions.Oli Scherer-0/+4
2025-03-11Remove `#![warn(unreachable_pub)]` from all `compiler/` crates.Nicholas Nethercote-1/+0
It's no longer necessary now that `-Wunreachable_pub` is being passed.
2025-03-10Revert "Use workspace lints for crates in `compiler/` #138084"许杰友 Jieyou Xu (Joe)-0/+1
Revert <https://github.com/rust-lang/rust/pull/138084> to buy time to consider options that avoids breaking downstream usages of cargo on distributed `rustc-src` artifacts, where such cargo invocations fail due to inability to inherit `lints` from workspace root manifest's `workspace.lints` (this is only valid for the source rust-lang/rust workspace, but not really the distributed `rustc-src` artifacts). This breakage was reported in <https://github.com/rust-lang/rust/issues/138304>. This reverts commit 48caf81484b50dca5a5cebb614899a3df81ca898, reversing changes made to c6662879b27f5161e95f39395e3c9513a7b97028.
2025-03-08Remove `#![warn(unreachable_pub)]` from all `compiler/` crates.Nicholas Nethercote-1/+0
(Except for `rustc_codegen_cranelift`.) It's no longer necessary now that `unreachable_pub` is in the workspace lints.
2025-03-05Rollup merge of #136764 - ↵许杰友 Jieyou Xu (Joe)-0/+42
traviscross:TC/make-ptr_cast_add_auto_to_object-hard-error, r=oli-obk Make `ptr_cast_add_auto_to_object` lint into hard error In Rust 1.81, we added a FCW lint (including linting in dependencies) against pointer casts that add an auto trait to dyn bounds. This was part of work making casts of pointers involving trait objects stricter, and was part of the work needed to restabilize trait upcasting. We considered just making this a hard error, but opted against it at that time due to breakage found by crater. This breakage was mostly due to the `anymap` crate which has been a persistent problem for us. It's now a year later, and the fact that this is not yet a hard error is giving us pause about stabilizing arbitrary self types and `derive(CoercePointee)`. So let's see about making a hard error of this. r? ghost cc ```@adetaylor``` ```@Darksonn``` ```@BoxyUwU``` ```@RalfJung``` ```@compiler-errors``` ```@oli-obk``` ```@WaffleLapkin``` Related: - https://github.com/rust-lang/rust/pull/135881 - https://github.com/rust-lang/rust/issues/136702 - https://github.com/rust-lang/rust/pull/136776 Tracking: - https://github.com/rust-lang/rust/issues/127323 - https://github.com/rust-lang/rust/issues/44874 - https://github.com/rust-lang/rust/issues/123430
2025-03-03Add ``dyn`` keywordKirill Podoprigora-2/+2
2025-02-27Update E0133 docs for 2024 editionEric Huss-1/+2
2025-02-24Rollup merge of #137489 - ↵Michael Goulet-11/+3
RalfJung:no-more-rustc_intrinsic_must_be_overridden, r=oli-obk remove `#[rustc_intrinsic_must_be_overridde]` In https://github.com/rust-lang/rust/pull/135031, we gained support for just leaving away the body. Now that the bootstrap compiler got bumped, stop using the old style and remove support for it. r? `@oli-obk` There are a few more mentions of this attribute in RA code that I didn't touch; Cc `@rust-lang/rust-analyzer`
2025-02-24Consolidate and rework CoercePointee and DispatchFromDyn errorsMichael Goulet-117/+44
2025-02-24remove support for rustc_intrinsic_must_be_overridden from the compilerRalf Jung-11/+3
2025-02-22Make `ptr_cast_add_auto_to_object` lint into hard errorTravis Cross-0/+42
In Rust 1.81, we added a FCW lint (including linting in dependencies) against pointer casts that add an auto trait to dyn bounds. This was part of work making casts of pointers involving trait objects stricter which was needed to restabilize trait upcasting. We considered just making this a hard error at the time, but opted against it due to breakage found by crater. This breakage was mostly due to the `anymap` crate which has been a persistent problem for us. It's now a year later, and the fact that this is not yet a hard error is giving us pause about stabilizing arbitrary self types and `derive(CoercePointee)`. So let's now make a hard error of this.
2025-02-15fix: Alloc new errorcode E0803 for E0495xizheyin-0/+47
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-02-10fix the error code documentDing Xiang Fei-0/+14
2025-02-09introduce CoercePointeeWellformed for coherence checks at typeck stageDing Xiang Fei-0/+81
2025-01-25Auto merge of #133154 - estebank:issue-133137, r=wesleywiserbors-1/+1
Reword resolve errors caused by likely missing crate in dep tree Reword label and add `help`: ``` error[E0432]: unresolved import `some_novel_crate` --> f704.rs:1:5 | 1 | use some_novel_crate::Type; | ^^^^^^^^^^^^^^^^ use of unresolved module or unlinked crate `some_novel_crate` | = help: if you wanted to use a crate named `some_novel_crate`, use `cargo add some_novel_crate` to add it to your `Cargo.toml` ``` Fix #133137.
2025-01-24Properly report error when object type param default references selfMichael Goulet-7/+5
2025-01-24Reword "crate not found" resolve messageEsteban Küber-1/+1
``` error[E0432]: unresolved import `some_novel_crate` --> file.rs:1:5 | 1 | use some_novel_crate::Type; | ^^^^^^^^^^^^^^^^ use of unresolved module or unlinked crate `some_novel_crate` ``` On resolve errors where there might be a missing crate, mention `cargo add foo`: ``` error[E0433]: failed to resolve: use of unresolved module or unlinked crate `nope` --> $DIR/conflicting-impl-with-err.rs:4:11 | LL | impl From<nope::Thing> for Error { | ^^^^ use of unresolved module or unlinked crate `nope` | = help: if you wanted to use a crate named `nope`, use `cargo add nope` to add it to your `Cargo.toml` ```
2025-01-22Refactor dyn-compatibility error and suggestionsTaylor Cramer-3/+3
This CL makes a number of small changes to dyn compatibility errors: - "object safety" has been renamed to "dyn-compatibility" throughout - "Convert to enum" suggestions are no longer generated when there exists a type-generic impl of the trait or an impl for `dyn OtherTrait` - Several error messages are reorganized for user readability Additionally, the dyn compatibility error creation code has been split out into functions. cc #132713 cc #133267
2025-01-21Auto merge of #134299 - RalfJung:remove-start, r=compiler-errorsbors-67/+10
remove support for the (unstable) #[start] attribute As explained by `@Noratrieb:` `#[start]` should be deleted. It's nothing but an accidentally leaked implementation detail that's a not very useful mix between "portable" entrypoint logic and bad abstraction. I think the way the stable user-facing entrypoint should work (and works today on stable) is pretty simple: - `std`-using cross-platform programs should use `fn main()`. the compiler, together with `std`, will then ensure that code ends up at `main` (by having a platform-specific entrypoint that gets directed through `lang_start` in `std` to `main` - but that's just an implementation detail) - `no_std` platform-specific programs should use `#![no_main]` and define their own platform-specific entrypoint symbol with `#[no_mangle]`, like `main`, `_start`, `WinMain` or `my_embedded_platform_wants_to_start_here`. most of them only support a single platform anyways, and need cfg for the different platform's ways of passing arguments or other things *anyways* `#[start]` is in a super weird position of being neither of those two. It tries to pretend that it's cross-platform, but its signature is a total lie. Those arguments are just stubbed out to zero on ~~Windows~~ wasm, for example. It also only handles the platform-specific entrypoints for a few platforms that are supported by `std`, like Windows or Unix-likes. `my_embedded_platform_wants_to_start_here` can't use it, and neither could a libc-less Linux program. So we have an attribute that only works in some cases anyways, that has a signature that's a total lie (and a signature that, as I might want to add, has changed recently, and that I definitely would not be comfortable giving *any* stability guarantees on), and where there's a pretty easy way to get things working without it in the first place. Note that this feature has **not** been RFCed in the first place. *This comment was posted [in May](https://github.com/rust-lang/rust/issues/29633#issuecomment-2088596042) and so far nobody spoke up in that issue with a usecase that would require keeping the attribute.* Closes https://github.com/rust-lang/rust/issues/29633 try-job: x86_64-gnu-nopt try-job: x86_64-msvc-1 try-job: x86_64-msvc-2 try-job: test-various
2025-01-21remove support for the #[start] attributeRalf Jung-67/+10
2025-01-17Rollup merge of #135604 - estebank:docs-e0207, r=jieyouxuMatthias Krüger-0/+24
Expand docs for `E0207` with additional example Add an example to E0207 docs showing how to tie the lifetime of the self type to an associated type in an impl when the trait *doesn't* have a lifetime to begin with. CC #135589.
2025-01-16Expand docs for `E0207` with additional exampleEsteban Küber-0/+24
2025-01-16Implement `use` associated items of traitsFrank King-6/+6
2024-12-25Rewrite the error-code docs for coverage attributes [E0788]Zalathar-19/+17
2024-12-23Note def descr in NonConstFunctionCallMichael Goulet-1/+1
2024-12-21Use E0665 for missing `#[default]` errorEsteban Küber-8/+7
Use orphaned error code for the same error it belonged to before. ``` error[E0665]: `#[derive(Default)]` on enum with no `#[default]` --> $DIR/macros-nonfatal-errors.rs:42:10 | LL | #[derive(Default)] | ^^^^^^^ LL | / enum NoDeclaredDefault { LL | | Foo, LL | | Bar, LL | | } | |_- this enum needs a unit variant marked with `#[default]` | = note: this error originates in the derive macro `Default` (in Nightly builds, run with -Z macro-backtrace for more info) help: make this unit variant default by placing `#[default]` on it | LL | #[default] Foo, | ~~~~~~~~~~~~~~ help: make this unit variant default by placing `#[default]` on it | LL | #[default] Bar, | ~~~~~~~~~~~~~~ ```
2024-12-21Mention `#[default]` in E0655 code indexEsteban Küber-3/+15