about summary refs log tree commit diff
path: root/compiler/rustc_lint/src
AgeCommit message (Collapse)AuthorLines
2024-10-22Auto merge of #129935 - RalfJung:unsupported_calling_conventions, ↵bors-0/+1
r=compiler-errors make unsupported_calling_conventions a hard error This has been a future-compat lint (not shown in dependencies) since Rust 1.55, released 3 years ago. Hopefully that was enough time so this can be made a hard error now. Given that long timeframe, I think it's justified to skip the "show in dependencies" stage. There were [not many crates hitting this](https://github.com/rust-lang/rust/pull/86231#issuecomment-866300943) even when the lint was originally added. This should get cratered, and I assume then it needs a t-compiler FCP. (t-compiler because this looks entirely like an implementation oversight -- for the vast majority of ABIs, we already have a hard error, but some were initially missed, and we are finally fixing that.) Fixes https://github.com/rust-lang/rust/pull/87678
2024-10-21Auto merge of #130628 - workingjubilee:clean-up-result-ffi-guarantees, ↵bors-5/+0
r=RalfJung Finish stabilization of `result_ffi_guarantees` The internal linting has been changed, so all that is left is making sure we stabilize what we want to stabilize.
2024-10-21Auto merge of #130950 - compiler-errors:yeet-eval, r=BoxyUwUbors-2/+2
Continue to get rid of `ty::Const::{try_}eval*` This PR mostly does: * Removes all of the `try_eval_*` and `eval_*` helpers from `ty::Const`, and replace their usages with `try_to_*`. * Remove `ty::Const::eval`. * Rename `ty::Const::normalize` to `ty::Const::normalize_internal`. This function is still used in the normalization code itself. * Fix some weirdness around the `TransmuteFrom` goal. I'm happy to split it out further; for example, I could probably land the first part which removes the helpers, or the changes to codegen which are more obvious than the changes to tools. r? BoxyUwU Part of https://github.com/rust-lang/rust/issues/130704
2024-10-20Rollup merge of #121560 - Noratrieb:stop-lint-macro-nonsense, r=jieyouxuMatthias Krüger-1/+4
Allow `#[deny]` inside `#[forbid]` as a no-op Forbid cannot be overriden. When someome tries to do this anyways, it results in a hard error. That makes sense. Except it doesn't, because macros. Macros may reasonably use `#[deny]` (or `#[warn]` for an allow-by-default lint) in their expansion to assert that their expanded code follows the lint. This is doesn't work when the output gets expanded into a `forbid()` context. This is pretty silly, since both the macros and the code agree on the lint! By making it a warning instead, we remove the problem with the macro, which is now nothing as warnings are suppressed in macro expanded code, while still telling users that something is up. fixes #121483
2024-10-20make unsupported_calling_conventions a hard errorRalf Jung-0/+1
2024-10-19compiler: Remove outdated commentJubilee Young-1/+0
2024-10-19compiler: Fully stabilize `result_ffi_guarantees`Jubilee Young-4/+0
2024-10-19Rollup merge of #116863 - workingjubilee:non-exhaustive-is-not-ffi-unsafe, ↵Matthias Krüger-20/+66
r=jieyouxu warn less about non-exhaustive in ffi Bindgen allows generating `#[non_exhaustive] #[repr(u32)]` enums. This results in nonintuitive nonlocal `improper_ctypes` warnings, even when the types are otherwise perfectly valid in C. Adjust for actual tooling expectations by avoiding warning on simple enums with only unit variants. Closes https://github.com/rust-lang/rust/issues/116831
2024-10-19Get rid of const eval_* and try_eval_* helpersMichael Goulet-2/+2
2024-10-18compiler: Embed consensus in `lint::types::improper_ctypes`Jubilee Young-28/+65
Extracting this logic into a module makes it easier to write down, and more importantly, later find, the actual decisions we've made.
2024-10-18Allow `#[deny(..)]` inside `#[forbid(..)]` as a no-op with a warningNoratrieb-1/+4
Forbid cannot be overriden. When someome tries to do this anyways, it results in a hard error. That makes sense. Except it doesn't, because macros. Macros may reasonably use `#[deny]` in their expansion to assert that their expanded code follows the lint. This is doesn't work when the output gets expanded into a `forbid()` context. This is pretty silly, since both the macros and the code agree on the lint! Therefore, we allow `#[deny(..)]`ing a lint that's already forbidden, keeping the level at forbid.
2024-10-15update bootstrap configsJosh Stone-1/+1
2024-10-15Rollup merge of #131652 - compiler-errors:modifiers, r=Nadrieril,jieyouxuMatthias Krüger-2/+3
Move polarity into `PolyTraitRef` rather than storing it on the side Arguably we could move these modifiers into `TraitRef` instead of `PolyTraitRef`, but I see `TraitRef` as simply the *path* part of the trait ref. It doesn't really matter -- refactoring this further is much easier now.
2024-10-14Move trait bound modifiers into hir::PolyTraitRefMichael Goulet-2/+3
2024-10-13Also use outermost const-anon for impl items in `non_local_defs` lintUrgau-3/+7
2024-10-11Rollup merge of #131565 - Urgau:non_local_def-rm-deprecate, r=compiler-errorsTrevor Gross-3/+0
Remove deprecation note in the `non_local_definitions` lint This PR removes the edition deprecation note emitted by the `non_local_definitions` lint. Specifically this part: ``` = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363> ``` because it [didn't make the cut](https://github.com/rust-lang/rust/issues/120363#issuecomment-2407833300) for the 2024 edition. `@rustbot` label +L-non_local_definitions
2024-10-11Rollup merge of #131546 - surechen:fix_129833, r=jieyouxuTrevor Gross-1/+9
Make unused_parens's suggestion considering expr's attributes. For the expr with attributes, like `let _ = (#[inline] || println!("Hello!"));`, the suggestion's span should contains the attributes, or the suggestion will remove them. fixes #129833
2024-10-12Make unused_parens's suggestion considering expr's attributessurechen-1/+9
For the expr with attributes, like `let _ = (#[inline] || println!("Hello!"));`, the suggestion's span should contains the attributes, or the suggestion will remove them. fixes #129833
2024-10-11Remove deprecation note in the `non_local_definitions` warningUrgau-3/+0
2024-10-11Rollup merge of #131498 - Urgau:transparent-const-anons, r=lcnrMatthias Krüger-31/+59
Consider outermost const-anon in `non_local_def` lint This PR change the logic for finding the parent of the `impl` definition in the `non_local_definitions` lint to consider multiple level of const-anon items, instead of only one currently. I also took the opportunity to cleanup the related code. cc ``@traviscross`` Fixes https://github.com/rust-lang/rust/issues/131474
2024-10-11Consider outermost const-anon in non_local_def lintUrgau-31/+59
2024-10-08Reserve guarded string literals (RFC 3593)Peter Jaszkowiak-0/+10
2024-10-07Auto merge of #131354 - matthiaskrgr:rollup-hprnng2, r=matthiaskrgrbors-3/+2
Rollup of 4 pull requests Successful merges: - #131331 (Revert "warn_old_master_branch" check) - #131344 (Avoid `&Lrc<T>` in various places) - #131346 (Restrict `ignore-mode-*` directives) - #131353 (Add documentation for `runtest::check_rustdoc_test_option` method) r? `@ghost` `@rustbot` modify labels: rollup
2024-10-07Auto merge of #131235 - ↵bors-1/+1
codemountains:rename-nestedmetaitem-to-metaitemlnner, r=nnethercote Rename `NestedMetaItem` to `MetaItemInner` Fixes #131087 r? `@nnethercote`
2024-10-07Remove an unnecessary `&Lrc<_>` local variable.Nicholas Nethercote-3/+2
2024-10-06Auto merge of #129670 - est31:cfg_attr_crate_type_name_error, r=Urgaubors-14/+5
Make deprecated_cfg_attr_crate_type_name a hard error Turns the forward compatibility lint added by #83744 into a hard error, so now, while the `#![crate_name]` and `#![crate_type]` attributes are still allowed in raw form, they are now forbidden to be nested inside a `#![cfg_attr()]` attribute. The following will now be an error: ```Rust #![cfg_attr(foo, crate_name = "foobar")] #![cfg_attr(foo, crate_type = "bin")] ``` This code will continue working and is not deprecated: ```Rust #![crate_name = "foobar"] #![crate_type = "lib"] ``` The reasoning for this is explained in #83744: it allows us to not have to cfg-expand in order to determine the crate's type and name. As of filing the PR, exactly two years have passed since #99784 has been merged, which has turned the lint's default warning level into an error, so there has been ample time to move off the now-forbidden syntax. cc #91632 - tracking issue for the lint
2024-10-06Rename NestedMetaItem to MetaItemInnercodemountains-1/+1
2024-10-05Auto merge of #129244 - cjgillot:opaque-hir, r=compiler-errorsbors-8/+8
Make opaque types regular HIR nodes Having opaque types as HIR owner introduces all sorts of complications. This PR proposes to make them regular HIR nodes instead. I haven't gone through all the test changes yet, so there may be a few surprises. Many thanks to `@camelid` for the first draft. Fixes https://github.com/rust-lang/rust/issues/129023 Fixes #129099 Fixes #125843 Fixes #119716 Fixes #121422
2024-10-05Make deprecated_cfg_attr_crate_type_name a hard errorest31-14/+5
2024-10-04rm `ItemKind::OpaqueTy`Noah Lev-8/+8
This introduce an additional collection of opaques on HIR, as they can no longer be listed using the free item list.
2024-10-04Rollup merge of #130518 - scottmcm:stabilize-controlflow-extra, r=dtolnayJubilee-1/+0
Stabilize the `map`/`value` methods on `ControlFlow` And fix the stability attribute on the `pub use` in `core::ops`. libs-api in https://github.com/rust-lang/rust/issues/75744#issuecomment-2231214910 seemed reasonably happy with naming for these, so let's try for an FCP. Summary: ```rust impl<B, C> ControlFlow<B, C> { pub fn break_value(self) -> Option<B>; pub fn map_break<T>(self, f: impl FnOnce(B) -> T) -> ControlFlow<T, C>; pub fn continue_value(self) -> Option<C>; pub fn map_continue<T>(self, f: impl FnOnce(C) -> T) -> ControlFlow<B, T>; } ``` Resolves #75744 ``@rustbot`` label +needs-fcp +t-libs-api -t-libs --- Aside, in case it keeps someone else from going down the same dead end: I looked at the `{break,continue}_value` methods and tried to make them `const` as part of this, but that's disallowed because of not having `const Drop`, so put it back to not even unstably-const.
2024-10-04Auto merge of #130157 - eduardosm:stabilize-const_float_classify, r=RalfJungbors-14/+10
Stabilize `const_float_classify` Tracking issue: https://github.com/rust-lang/rust/issues/72505 Also reverts https://github.com/rust-lang/rust/pull/114486 Closes https://github.com/rust-lang/rust/issues/72505 Stabilized const API: ```rust impl f32 { pub const fn is_nan(self) -> bool; pub const fn is_infinite(self) -> bool; pub const fn is_finite(self) -> bool; pub const fn is_subnormal(self) -> bool; pub const fn is_normal(self) -> bool; pub const fn classify(self) -> FpCategory; pub const fn is_sign_positive(self) -> bool; pub const fn is_sign_negative(self) -> bool; } impl f64 { pub const fn is_nan(self) -> bool; pub const fn is_infinite(self) -> bool; pub const fn is_finite(self) -> bool; pub const fn is_subnormal(self) -> bool; pub const fn is_normal(self) -> bool; pub const fn classify(self) -> FpCategory; pub const fn is_sign_positive(self) -> bool; pub const fn is_sign_negative(self) -> bool; } ``` cc `@rust-lang/wg-const-eval` `@rust-lang/libs-api`
2024-10-02Move in_trait into OpaqueTyOriginMichael Goulet-4/+6
2024-10-02Use named fields for OpaqueTyOriginMichael Goulet-5/+5
2024-09-30Rollup merge of #131035 - dingxiangfei2009:tweak-if-let-rescope-lint, r=jieyouxuMatthias Krüger-2/+28
Preserve brackets around if-lets and skip while-lets r? `@jieyouxu` Tracked by #124085 Fresh out of #129466, we have discovered 9 crates that the lint did not successfully migrate because the span of `if let` includes the surrounding brackets `(..)` like the following, which surprised me a bit. ```rust if (if let .. { .. } else { .. }) { // ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // the span somehow includes the surrounding brackets } ``` There is one crate that failed the migration because some suggestion spans cross the macro expansion boundaries. Surely there is no way to patch them with `match` rewrite. To handle this case, we will instead require all spans to be tested for admissibility as suggestion spans. Besides, there are 4 false negative cases discovered with desugared-`while let`. We don't need to lint them, because the `else` branch surely contains exactly one statement because the drop order is not changed whatsoever in this case. ```rust while let Some(value) = droppy().get() { .. } // is desugared into loop { if let Some(value) = droppy().get() { .. } else { break; // here can be nothing observable in this block } } ``` I believe this is the one and only false positive that I have found. I think we have finally nailed all the corner cases this time.
2024-09-30apply suggestionsDing Xiang Fei-1/+2
2024-09-30preserve brackets around if-lets and skip while-letsDing Xiang Fei-2/+27
2024-09-29cleanup: don't `.into()` identical typesMatthias Krüger-1/+1
2024-09-28Rollup merge of #130924 - surechen:fix_130851, r=compiler-errorsMatthias Krüger-3/+3
Make clashing_extern_declarations considering generic args for ADT field In following example, G<u16> should be recognized as different from G<u32> : ```rust #[repr(C)] pub struct G<T> { g: [T; 4] } pub mod x { extern "C" { pub fn g(_: super::G<u16>); } } pub mod y { extern "C" { pub fn g(_: super::G<u32>); } } ``` fixes #130851
2024-09-27Rollup merge of #130826 - fmease:compiler-mv-obj-safe-dyn-compat, ↵Matthias Krüger-4/+4
r=compiler-errors Compiler: Rename "object safe" to "dyn compatible" Completed T-lang FCP: https://github.com/rust-lang/lang-team/issues/286#issuecomment-2338905118. Tracking issue: https://github.com/rust-lang/rust/issues/130852 Excludes `compiler/rustc_codegen_cranelift` (to be filed separately). Includes Stable MIR. Regarding https://github.com/rust-lang/rust/labels/relnotes, I guess I will manually open a https://github.com/rust-lang/rust/labels/relnotes-tracking-issue since this change affects everything (compiler, library, tools, docs, books, everyday language). r? ghost
2024-09-27Make clashing_extern_declarations considering generic args for ADT fieldsurechen-3/+3
fixes #130851
2024-09-26Fix the misleading diagnostic for let_underscore_drop on type without Drop ↵makai410-1/+1
implementation
2024-09-25Stabilize the `map`/`value` methods on `ControlFlow`Scott McMurray-1/+0
And fix the stability attribute on the `pub use` in `core::ops`.
2024-09-25Revert "Avoid invalid NaN lint machine-applicable suggestion in const context"Eduardo Sánchez Muñoz-14/+10
Reverts PR https://github.com/rust-lang/rust/pull/114486 (commit 1305a43d0a0c02cb224ab626745bd94af59c6098)
2024-09-25Compiler: Rename "object safe" to "dyn compatible"León Orell Valerian Liehr-4/+4
2024-09-24Auto merge of #130768 - compiler-errors:rollup-8ncjy55, r=compiler-errorsbors-17/+3
Rollup of 7 pull requests Successful merges: - #129545 (rustdoc: redesign toolbar and disclosure widgets) - #130618 (Skip query in get_parent_item when possible.) - #130727 (Check vtable projections for validity in miri) - #130750 (Add new Tier-3 target: `loongarch64-unknown-linux-ohos`) - #130758 (Revert "Add recursion limit to FFI safety lint") - #130759 (Update books) - #130762 (stabilize const_intrinsic_copy) r? `@ghost` `@rustbot` modify labels: rollup
2024-09-23Rollup merge of #130758 - compiler-errors:ctype-recursion-limit, r=jieyouxuMichael Goulet-17/+3
Revert "Add recursion limit to FFI safety lint" It's not necessarily clear if warning when we hit the recursion limit is the right thing to do, first of all. **More importantly**, this PR was implemented incorrectly in the first place; it was not decrementing the recursion limit when stepping out of a type, so it would trigger when a ctype has more than RECURSION_LIMIT fields *anywhere* in the type's set of recursively reachable fields. Reverts #130598 Reopens #130310 Fixes #130757
2024-09-24Auto merge of #127117 - Urgau:non_local_def-syntactic, r=BoxyUwUbors-306/+40
Rework `non_local_definitions` lint to only use a syntactic heuristic This PR reworks the `non_local_definitions` lint to only use a syntactic heuristic, i.e. not use a type-system logic for whenever an `impl` is local or not. Instead the new logic wanted by T-lang in https://github.com/rust-lang/rust/issues/126768#issuecomment-2192634762, which is to consider every paths in `Self` and `Trait` and to no longer use the type-system inference trick. `@rustbot` labels +L-non_local_definitions Fixes #126768
2024-09-23Revert "Add recursion limit to FFI safety lint"Michael Goulet-17/+3
This reverts commit 716044751b7a36c634be709e37923e3dbdf53888.
2024-09-23add unqualified_local_imports lintRalf Jung-0/+96