about summary refs log tree commit diff
path: root/compiler/rustc_lint/src
AgeCommit message (Collapse)AuthorLines
2024-07-09add lint for inline asm labels that look like binaryasquared31415-34/+129
2024-07-08Update a f16/f128 FIXME to be more accurateTrevor Gross-1/+2
2024-07-08Move trait selection error reporting to its own top-level moduleMichael Goulet-3/+3
2024-07-07iter_identity is a better nameMichael Goulet-6/+2
2024-07-05Rollup merge of #127221 - Urgau:check-cfg-std-diag, r=pnkfelixMichael Goulet-6/+12
Improve well known value check-cfg diagnostic for the standard library This PR adjust the current logic for hidding the rustc/Cargo suggestion to add a value to a well-known name to exclude the standard library and rustc crates. This is done in order to improve the contributor experience, in particular when adding a new target, which often requires adding some cfgs like `target_os` which may not be available yet in stage0. <details> The diagnostic code would look like this. ```text error: unexpected `cfg` condition value: `blable` --> library/core/src/lib.rs:369:7 | 369 | #[cfg(target_os = "blable")] | ^^^^^^^^^^^^^^^^^^^^ | = note: expected values for `target_os` are: `aix`, `android`, `cuda`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `hermit`, `horizon`, `hurd`, `illumos`, `ios`, `l4re`, `linux`, `macos`, `netbsd`, `none`, `nto`, `openbsd`, `psp`, `redox`, `solaris`, `solid_asp3`, `teeos`, `tvos`, `uefi`, `unknown`, `visionos`, `vita`, `vxworks`, `wasi`, `watchos`, and `windows` and 2 more = help: consider using a Cargo feature instead = help: or consider adding in `Cargo.toml` the `check-cfg` lint config for the lint: [lints.rust] unexpected_cfgs = { level = "warn", check-cfg = ['cfg(target_os, values("blable"))'] } = help: or consider adding `println!("cargo::rustc-check-cfg=cfg(target_os, values(\"blable\"))");` to the top of the `build.rs` = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration = note: `-D unexpected-cfgs` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(unexpected_cfgs)]` ``` </details>
2024-07-02Instance::resolve -> Instance::try_resolve, and other nitsMichael Goulet-3/+5
2024-07-01Improve well known value check-cfg diagnostic for the standard libraryUrgau-6/+12
2024-06-30Rollup merge of #126018 - nnethercote:rm-box_pointers-lint, r=lcnrMatthias Krüger-86/+7
Remove the `box_pointers` lint. As the comment says, this lint "is mostly historical, and not particularly useful". It's not worth keeping it around. r? ``@estebank``
2024-06-29Rollup merge of #127045 - compiler-errors:explicit, r=oli-obkMatthias Krüger-1/+1
Rename `super_predicates_of` and similar queries to `explicit_*` to note that they're not elaborated Rename: * `super_predicates_of` -> `explicit_super_predicates_of` * `implied_predicates_of` -> `explicit_implied_predicates_of` * `supertraits_containing_assoc_item` -> `explicit_supertraits_containing_assoc_item` This makes it clearer that, unlike (for example) [`TyCtxt::super_traits_of`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.TyCtxt.html#method.super_traits_of), we don't automatically elaborate this set of predicates. r? ``@lcnr`` or ``@oli-obk`` or someone from t-types idc
2024-06-28Make it into a structured suggestion, maybe-incorrectMichael Goulet-2/+21
2024-06-28Basic lint detecting closure-returning-async-blockMichael Goulet-0/+113
2024-06-28Only require symbol name for @feature_gateMichael Goulet-5/+4
2024-06-28Rollup merge of #127015 - Urgau:non_local_def-tmp-allow, r=lqdMatthias Krüger-1/+1
Switch back `non_local_definitions` lint to allow-by-default This PR switch back (again) the `non_local_definitions` lint to allow-by-default as T-lang is requesting some (major) changes in the lint inner workings in https://github.com/rust-lang/rust/issues/126768#issuecomment-2192634762. This PR will need to be beta-backported, as the lint is currently warn-by-default in beta.
2024-06-27Make queries more explicitMichael Goulet-1/+1
2024-06-27Switch back `non_local_definitions` lint to allow-by-defaultUrgau-1/+1
as request T-lang is requesting some major changes in the lint inner workings in #126768#issuecomment-2192634762
2024-06-27Remove the `box_pointers` lint.Nicholas Nethercote-86/+7
As the comment says, this lint "is mostly historical, and not particularly useful". It's not worth keeping it around.
2024-06-25RFC 2383: Stabilize `lint_reasons` :tada:xFrednet-15/+0
2024-06-25Auto merge of #125741 - petrochenkov:atvisord, r=davidtwcobors-0/+10
ast: Standardize visiting order for attributes and node IDs This should only affect `macro_rules` scopes and order of diagnostics. Also add a deprecation lint for `macro_rules` called outside of their scope, like in https://github.com/rust-lang/rust/issues/124535.
2024-06-24Split out IntoIterator and non-Iterator constructors for ↵Michael Goulet-1/+1
AliasTy/AliasTerm/TraitRef/projection
2024-06-24resolve: Implement a lint for out-of-scope use of `macro_rules`Vadim Petrochenkov-0/+10
2024-06-23Add hard error and migration lint for unsafe attrscarbotaniuman-0/+31
2024-06-21Rename a bunch of thingsMichael Goulet-1/+1
2024-06-19Rollup merge of #126422 - Urgau:doctest-impl-non-local-def, r=fmease许杰友 Jieyou Xu (Joe)-46/+55
Suggest using a standalone doctest for non-local impl defs This PR tweaks the lint output of the `non_local_definitions` lint to suggest using a standalone doctest instead of a moving the `impl` def to an impossible place as was already done with `macro_rules!` case in https://github.com/rust-lang/rust/pull/124568. Fixes #126339 r? ```@fmease```
2024-06-18Remove redundant argument from `subdiagnostic` methodOli Scherer-3/+3
2024-06-18Use a dedicated type instead of a reference for the diagnostic contextOli Scherer-2/+2
This paves the way for tracking more state (e.g. error tainting) in the diagnostic context handle
2024-06-17Rework precise capturing syntaxMichael Goulet-8/+12
2024-06-17Rollup merge of #125258 - compiler-errors:static-if-no-lt, r=nnethercote许杰友 Jieyou Xu (Joe)-3/+14
Resolve elided lifetimes in assoc const to static if no other lifetimes are in scope Implements the change to elided lifetime resolution in *associated consts* subject to FCP here: https://github.com/rust-lang/rust/issues/125190#issue-2301532282 Specifically, walk the enclosing lifetime ribs in an associated const, and if we find no other lifetimes, then resolve to `'static`. Also make it work for traits, but don't lint -- just give a hard error in that case.
2024-06-16boxed_slice_into_iter: tiny doc correctionKalle Wachsmuth-1/+1
2024-06-15Also simplify macro_rules doctest codeUrgau-10/+6
2024-06-15Suggest standalone doctest for non-local impl defsUrgau-38/+51
2024-06-15Auto merge of #125722 - Urgau:non_local_defs-macro-to-change, r=estebankbors-3/+19
Indicate in `non_local_defs` lint that the macro needs to change This PR adds a note to indicate that the macro needs to change in the `non_local_definitions` lint output. Address https://github.com/rust-lang/rust/pull/125089#discussion_r1616311862 Fixes #125681 r? `@estebank`
2024-06-14Use is_lang_item more aggressivelyMichael Goulet-10/+10
2024-06-14Resolve elided lifetimes in assoc const to static if no other lifetimes are ↵Michael Goulet-3/+14
in scope
2024-06-12Auto merge of #126273 - pietroalbini:pa-bootstrap-update, r=Mark-Simulacrumbors-2/+2
Bump stage0 to 1.80.0 r? `@Mark-Simulacrum`
2024-06-12Auto merge of #126319 - workingjubilee:rollup-lendnud, r=workingjubileebors-3/+5
Rollup of 16 pull requests Successful merges: - #123374 (DOC: Add FFI example for slice::from_raw_parts()) - #124514 (Recommend to never display zero disambiguators when demangling v0 symbols) - #125978 (Cleanup: HIR ty lowering: Consolidate the places that do assoc item probing & access checking) - #125980 (Nvptx remove direct passmode) - #126187 (For E0277 suggest adding `Result` return type for function when using QuestionMark `?` in the body.) - #126210 (docs(core): make more const_ptr doctests assert instead of printing) - #126249 (Simplify `[T; N]::try_map` signature) - #126256 (Add {{target}} substitution to compiletest) - #126263 (Make issue-122805.rs big endian compatible) - #126281 (set_env: State the conclusion upfront) - #126286 (Make `storage-live.rs` robust against rustc internal changes.) - #126287 (Update a cranelift patch file for formatting changes.) - #126301 (Use `tidy` to sort crate attributes for all compiler crates.) - #126305 (Make PathBuf less Ok with adding UTF-16 then `into_string`) - #126310 (Migrate run make prefer rlib) - #126314 (fix RELEASES: we do not support upcasting to auto traits) r? `@ghost` `@rustbot` modify labels: rollup
2024-06-12Add a `fn main() {}` to a doctest to prevent the test from being wrapped in ↵Oli Scherer-0/+2
a `fn main() {}` body
2024-06-12Use `tidy` to sort crate attributes for all compiler crates.Nicholas Nethercote-3/+5
We already do this for a number of crates, e.g. `rustc_middle`, `rustc_span`, `rustc_metadata`, `rustc_span`, `rustc_errors`. For the ones we don't, in many cases the attributes are a mess. - There is no consistency about order of attribute kinds (e.g. `allow`/`deny`/`feature`). - Within attribute kind groups (e.g. the `feature` attributes), sometimes the order is alphabetical, and sometimes there is no particular order. - Sometimes the attributes of a particular kind aren't even grouped all together, e.g. there might be a `feature`, then an `allow`, then another `feature`. This commit extends the existing sorting to all compiler crates, increasing consistency. If any new attribute line is added there is now only one place it can go -- no need for arbitrary decisions. Exceptions: - `rustc_log`, `rustc_next_trait_solver` and `rustc_type_ir_macros`, because they have no crate attributes. - `rustc_codegen_gcc`, because it's quasi-external to rustc (e.g. it's ignored in `rustfmt.toml`).
2024-06-11Rollup merge of #125659 - tbu-:pr_rm_isize, r=pnkfelix许杰友 Jieyou Xu (Joe)-1/+1
Remove usage of `isize` in example `isize` is a rare integer type, replace it with a more common one.
2024-06-11replace version placeholderPietro Albini-2/+2
2024-06-11Rollup merge of #125913 - fmease:early-lints-spruce-up-some-diags, r=Nadrieril许杰友 Jieyou Xu (Joe)-2/+7
Spruce up the diagnostics of some early lints Implement the various "*(note to myself) in a follow-up PR we should turn parts of this message into a subdiagnostic (help msg or even struct sugg)*" drive-by comments I left in #124417 during my review. For context, before #124417, only a few early lints touched/decorated/customized their diagnostic because the former API made it a bit awkward. Likely because of that, things that should've been subdiagnostics were just crammed into the primary message. This PR rectifies this.
2024-06-06Rollup merge of #126040 - Urgau:unreachable_pub-fields-less, r=petrochenkovJubilee-6/+15
Don't warn on fields in the `unreachable_pub` lint This PR restrict the `unreachable_pub` lint by not linting on `pub` fields of `pub(restricted)` structs and unions. This is done because that can quickly clutter the code for an uncertain value, in particular since the "real" visibility is defined by the parent (the struct it-self). This is meant to address one of the last concern of the `unreachable_pub` lint. r? ``@petrochenkov``
2024-06-06Don't warn on fields in the `unreachable_pub` lintUrgau-6/+15
2024-06-06Auto merge of #124482 - spastorino:unsafe-extern-blocks, r=oli-obkbors-3/+13
Unsafe extern blocks This implements RFC 3484. Tracking issue #123743 and RFC https://github.com/rust-lang/rfcs/pull/3484 This is better reviewed commit by commit.
2024-06-05Make MISSING_UNSAFE_ON_EXTERN lint emit future compat info with suggestion ↵Santiago Pastorino-3/+6
to prepend unsafe
2024-06-04Rollup merge of #125596 - nnethercote:rental-hard-error, r=estebankGuillaume Gomez-11/+0
Convert `proc_macro_back_compat` lint to an unconditional error. We still check for the `rental`/`allsorts-rental` crates. But now if they are detected we just emit a fatal error, instead of emitting a warning and providing alternative behaviour. The original "hack" implementing alternative behaviour was added in #73345. The lint was added in #83127. The tracking issue is #83125. The direct motivation for the change is that providing the alternative behaviour is interfering with #125174 and follow-on work. r? ``@estebank``
2024-06-04Handle safety keyword for extern block inner itemsSantiago Pastorino-3/+3
2024-06-04Make extern blocks without unsafe warn in edition 2024Santiago Pastorino-0/+7
2024-06-04Rollup merge of #125750 - compiler-errors:expect, r=lcnr许杰友 Jieyou Xu (Joe)-1/+1
Align `Term` methods with `GenericArg` methods, add `Term::expect_*` * `Term::ty` -> `Term::as_type`. * `Term::ct` -> `Term::as_const`. * Adds `Term::expect_type` and `Term::expect_const`, and uses them in favor of `.ty().unwrap()`, etc. I could also shorten these to `as_ty` and then do `GenericArg::as_ty` as well, but I do think the `as_` is important to signal that this is a conversion method, and not a getter, like `Const::ty` is. r? types
2024-06-03Align Term methods with GenericArg methodsMichael Goulet-1/+1
2024-06-03check_is_object_safe -> is_object_safeMichael Goulet-2/+2