1
Fork 0
r? @ghost

changelog: none
This commit is contained in:
Philipp Krones 2024-11-14 17:32:56 +00:00 committed by GitHub
commit 786fbd6d68
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 37 additions and 39 deletions

View file

@ -56,7 +56,8 @@ impl<'tcx> LateLintPass<'tcx> for LargeConstArrays {
&& !item.span.from_expansion() && !item.span.from_expansion()
&& let ty = cx.tcx.type_of(item.owner_id).instantiate_identity() && let ty = cx.tcx.type_of(item.owner_id).instantiate_identity()
&& let ty::Array(element_type, cst) = ty.kind() && let ty::Array(element_type, cst) = ty.kind()
&& let Ok((_, ty::ValTree::Leaf(element_count))) = cst.eval_valtree(cx.tcx, ParamEnv::empty(), item.span) && let Some((ty::ValTree::Leaf(element_count), _)) = cx.tcx
.try_normalize_erasing_regions(ParamEnv::empty(), *cst).unwrap_or(*cst).try_to_valtree()
&& let element_count = element_count.to_target_usize(cx.tcx) && let element_count = element_count.to_target_usize(cx.tcx)
&& let Ok(element_size) = cx.layout_of(*element_type).map(|l| l.size.bytes()) && let Ok(element_size) = cx.layout_of(*element_type).map(|l| l.size.bytes())
&& u128::from(self.maximum_allowed_size) < u128::from(element_count) * u128::from(element_size) && u128::from(self.maximum_allowed_size) < u128::from(element_count) * u128::from(element_size)

View file

@ -8,9 +8,9 @@
//! Thank you! //! Thank you!
//! ~The `INTERNAL_METADATA_COLLECTOR` lint //! ~The `INTERNAL_METADATA_COLLECTOR` lint
use rustc_errors::{ use rustc_errors::{Applicability, Diag, DiagMessage, MultiSpan, SubdiagMessage};
Applicability, Diag, DiagMessage, EmissionGuarantee, MultiSpan, SubdiagMessage, SubstitutionPart, Suggestions, #[cfg(debug_assertions)]
}; use rustc_errors::{EmissionGuarantee, SubstitutionPart, Suggestions};
use rustc_hir::HirId; use rustc_hir::HirId;
use rustc_lint::{LateContext, Lint, LintContext}; use rustc_lint::{LateContext, Lint, LintContext};
use rustc_span::Span; use rustc_span::Span;
@ -38,6 +38,7 @@ fn docs_link(diag: &mut Diag<'_, ()>, lint: &'static Lint) {
/// only started triggered there. /// only started triggered there.
/// ///
/// This function makes sure we also validate them in debug clippy builds. /// This function makes sure we also validate them in debug clippy builds.
#[cfg(debug_assertions)]
fn validate_diag(diag: &Diag<'_, impl EmissionGuarantee>) { fn validate_diag(diag: &Diag<'_, impl EmissionGuarantee>) {
let suggestions = match &diag.suggestions { let suggestions = match &diag.suggestions {
Suggestions::Enabled(suggs) => &**suggs, Suggestions::Enabled(suggs) => &**suggs,

View file

@ -393,12 +393,8 @@ fn is_stable_const_fn(tcx: TyCtxt<'_>, def_id: DefId, msrv: &Msrv) -> bool {
msrv.meets(const_stab_rust_version) msrv.meets(const_stab_rust_version)
} else { } else {
// Unstable const fn, check if the feature is enabled. We need both the regular stability // Unstable const fn, check if the feature is enabled.
// feature and (if set) the const stability feature to const-call this function. tcx.features().enabled(const_stab.feature) && msrv.current().is_none()
let stab = tcx.lookup_stability(def_id);
let is_enabled = stab.is_some_and(|s| s.is_stable() || tcx.features().enabled(s.feature))
&& const_stab.feature.is_none_or(|f| tcx.features().enabled(f));
is_enabled && msrv.current().is_none()
} }
}) })
} }

View file

@ -1,4 +1,4 @@
[toolchain] [toolchain]
channel = "nightly-2024-11-07" channel = "nightly-2024-11-14"
components = ["cargo", "llvm-tools", "rust-src", "rust-std", "rustc", "rustc-dev", "rustfmt"] components = ["cargo", "llvm-tools", "rust-src", "rust-std", "rustc", "rustc-dev", "rustfmt"]
profile = "minimal" profile = "minimal"

View file

@ -3,7 +3,7 @@ error: empty line after doc comment
| |
LL | / /// for the crate LL | / /// for the crate
LL | | LL | |
| |_ | |_^
LL | fn first_in_crate() {} LL | fn first_in_crate() {}
| ------------------- the comment documents this function | ------------------- the comment documents this function
| |
@ -22,7 +22,7 @@ error: empty line after doc comment
| |
LL | / /// for the module LL | / /// for the module
LL | | LL | |
| |_ | |_^
LL | fn first_in_module() {} LL | fn first_in_module() {}
| -------------------- the comment documents this function | -------------------- the comment documents this function
| |
@ -39,7 +39,7 @@ error: empty line after doc comment
| |
LL | / /// # Indented LL | / /// # Indented
LL | | LL | |
| |_ | |_^
LL | /// Blank line LL | /// Blank line
LL | fn indented() {} LL | fn indented() {}
| ------------- the comment documents this function | ------------- the comment documents this function
@ -55,7 +55,7 @@ error: empty line after doc comment
| |
LL | / /// This should produce a warning LL | / /// This should produce a warning
LL | | LL | |
| |_ | |_^
LL | fn with_doc_and_newline() {} LL | fn with_doc_and_newline() {}
| ------------------------- the comment documents this function | ------------------------- the comment documents this function
| |
@ -69,7 +69,7 @@ LL | |
LL | | /** This is also a doc comment and is part of the warning LL | | /** This is also a doc comment and is part of the warning
LL | | */ LL | | */
LL | | LL | |
| |_ | |_^
... ...
LL | fn three_attributes() {} LL | fn three_attributes() {}
| --------------------- the comment documents this function | --------------------- the comment documents this function
@ -82,7 +82,7 @@ error: empty line after doc comment
LL | / /// docs for `old_code` LL | / /// docs for `old_code`
LL | | // fn old_code() {} LL | | // fn old_code() {}
LL | | LL | |
| |_ | |_^
LL | fn new_code() {} LL | fn new_code() {}
| ------------- the comment documents this function | ------------- the comment documents this function
| |
@ -102,7 +102,7 @@ LL | | /// Docs
LL | | /// for OldB LL | | /// for OldB
LL | | // struct OldB; LL | | // struct OldB;
LL | | LL | |
| |_ | |_^
... ...
LL | struct Multiple; LL | struct Multiple;
| --------------- the comment documents this struct | --------------- the comment documents this struct
@ -125,7 +125,7 @@ LL | / /**
LL | | * Meant to be inner doc comment LL | | * Meant to be inner doc comment
LL | | */ LL | | */
LL | | LL | |
| |_ | |_^
LL | fn first_in_module() {} LL | fn first_in_module() {}
| -------------------- the comment documents this function | -------------------- the comment documents this function
| |
@ -143,7 +143,7 @@ LL | | * Docs for `old_code`
LL | | */ LL | | */
LL | | /* fn old_code() {} */ LL | | /* fn old_code() {} */
LL | | LL | |
| |_ | |_^
... ...
LL | fn new_code() {} LL | fn new_code() {}
| ------------- the comment documents this function | ------------- the comment documents this function
@ -161,7 +161,7 @@ error: empty line after doc comment
LL | / /// Docs for `old_code2` LL | / /// Docs for `old_code2`
LL | | /* fn old_code2() {} */ LL | | /* fn old_code2() {} */
LL | | LL | |
| |_ | |_^
LL | /// Docs for `new_code2` LL | /// Docs for `new_code2`
LL | fn new_code2() {} LL | fn new_code2() {}
| -------------- the comment documents this function | -------------- the comment documents this function

View file

@ -3,7 +3,7 @@ error: empty line after outer attribute
| |
LL | / #[crate_type = "lib"] LL | / #[crate_type = "lib"]
LL | | LL | |
| |_ | |_^
LL | fn first_in_crate() {} LL | fn first_in_crate() {}
| ------------------- the attribute applies to this function | ------------------- the attribute applies to this function
| |
@ -20,7 +20,7 @@ error: empty line after outer attribute
| |
LL | / #[inline] LL | / #[inline]
LL | | LL | |
| |_ | |_^
LL | /// some comment LL | /// some comment
LL | fn with_one_newline_and_comment() {} LL | fn with_one_newline_and_comment() {}
| --------------------------------- the attribute applies to this function | --------------------------------- the attribute applies to this function
@ -32,7 +32,7 @@ error: empty line after outer attribute
| |
LL | / #[inline] LL | / #[inline]
LL | | LL | |
| |_ | |_^
LL | fn with_one_newline() {} LL | fn with_one_newline() {}
| --------------------- the attribute applies to this function | --------------------- the attribute applies to this function
| |
@ -44,7 +44,7 @@ error: empty lines after outer attribute
LL | / #[crate_type = "lib"] LL | / #[crate_type = "lib"]
LL | | LL | |
LL | | LL | |
| |_ | |_^
LL | fn with_two_newlines() {} LL | fn with_two_newlines() {}
| ---------------------- the attribute applies to this function | ---------------------- the attribute applies to this function
| |
@ -59,7 +59,7 @@ error: empty line after outer attribute
| |
LL | / #[doc = "doc attributes should be considered attributes"] LL | / #[doc = "doc attributes should be considered attributes"]
LL | | LL | |
| |_ | |_^
LL | enum Baz { LL | enum Baz {
| -------- the attribute applies to this enum | -------- the attribute applies to this enum
| |
@ -70,7 +70,7 @@ error: empty line after outer attribute
| |
LL | / #[repr(C)] LL | / #[repr(C)]
LL | | LL | |
| |_ | |_^
LL | struct Foo { LL | struct Foo {
| ---------- the attribute applies to this struct | ---------- the attribute applies to this struct
| |
@ -81,7 +81,7 @@ error: empty line after outer attribute
| |
LL | / #[allow(dead_code)] LL | / #[allow(dead_code)]
LL | | LL | |
| |_ | |_^
LL | mod foo {} LL | mod foo {}
| ------- the attribute applies to this module | ------- the attribute applies to this module
| |
@ -93,7 +93,7 @@ error: empty line after outer attribute
LL | / #[inline] LL | / #[inline]
LL | | // Still lint cases where the empty line does not immediately follow the attribute LL | | // Still lint cases where the empty line does not immediately follow the attribute
LL | | LL | |
| |_ | |_^
LL | fn comment_before_empty_line() {} LL | fn comment_before_empty_line() {}
| ------------------------------ the attribute applies to this function | ------------------------------ the attribute applies to this function
| |
@ -106,7 +106,7 @@ LL | / #[allow(unused)]
LL | | LL | |
LL | | // This comment is isolated LL | | // This comment is isolated
LL | | LL | |
| |_ | |_^
LL | pub fn isolated_comment() {} LL | pub fn isolated_comment() {}
| ------------------------- the attribute applies to this function | ------------------------- the attribute applies to this function
| |

View file

@ -3,7 +3,7 @@ error: this item has comments with 4 forward slashes (`////`). These look like d
| |
LL | / //// whoops LL | / //// whoops
LL | | fn a() {} LL | | fn a() {}
| |_ | |_^
| |
= note: `-D clippy::four-forward-slashes` implied by `-D warnings` = note: `-D clippy::four-forward-slashes` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::four_forward_slashes)]` = help: to override `-D warnings` add `#[allow(clippy::four_forward_slashes)]`
@ -18,7 +18,7 @@ error: this item has comments with 4 forward slashes (`////`). These look like d
LL | / //// whoops LL | / //// whoops
LL | | #[allow(dead_code)] LL | | #[allow(dead_code)]
LL | | fn b() {} LL | | fn b() {}
| |_ | |_^
| |
help: make this a doc comment by removing one `/` help: make this a doc comment by removing one `/`
| |
@ -32,7 +32,7 @@ LL | / //// whoops
LL | | //// two borked comments! LL | | //// two borked comments!
LL | | #[track_caller] LL | | #[track_caller]
LL | | fn c() {} LL | | fn c() {}
| |_ | |_^
| |
help: turn these into doc comments by removing one `/` help: turn these into doc comments by removing one `/`
| |
@ -46,7 +46,7 @@ error: this item has comments with 4 forward slashes (`////`). These look like d
LL | / //// between attributes LL | / //// between attributes
LL | | #[allow(dead_code)] LL | | #[allow(dead_code)]
LL | | fn g() {} LL | | fn g() {}
| |_ | |_^
| |
help: make this a doc comment by removing one `/` help: make this a doc comment by removing one `/`
| |
@ -58,7 +58,7 @@ error: this item has comments with 4 forward slashes (`////`). These look like d
| |
LL | / //// not very start of contents LL | / //// not very start of contents
LL | | fn h() {} LL | | fn h() {}
| |_ | |_^
| |
help: make this a doc comment by removing one `/` help: make this a doc comment by removing one `/`
| |

View file

@ -3,7 +3,7 @@ error: this item has comments with 4 forward slashes (`////`). These look like d
| |
LL | / //// borked doc comment on the first line. doesn't combust! LL | / //// borked doc comment on the first line. doesn't combust!
LL | | fn a() {} LL | | fn a() {}
| |_ | |_^
| |
= note: `-D clippy::four-forward-slashes` implied by `-D warnings` = note: `-D clippy::four-forward-slashes` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::four_forward_slashes)]` = help: to override `-D warnings` add `#[allow(clippy::four_forward_slashes)]`

View file

@ -6,7 +6,7 @@ LL | | /// A much longer explanation that goes into a lot more detail about
LL | | /// how the thing works, possibly with doclinks and so one, LL | | /// how the thing works, possibly with doclinks and so one,
LL | | /// and probably spanning a many rows. Blablabla, it needs to be over LL | | /// and probably spanning a many rows. Blablabla, it needs to be over
LL | | /// 200 characters so I needed to write something longeeeeeeer. LL | | /// 200 characters so I needed to write something longeeeeeeer.
| |_ | |_^
| |
= note: `-D clippy::too-long-first-doc-paragraph` implied by `-D warnings` = note: `-D clippy::too-long-first-doc-paragraph` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::too_long_first_doc_paragraph)]` = help: to override `-D warnings` add `#[allow(clippy::too_long_first_doc_paragraph)]`

View file

@ -23,7 +23,7 @@ error: first doc comment paragraph is too long
LL | / /// Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc turpis nunc, lacinia LL | / /// Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc turpis nunc, lacinia
LL | | /// a dolor in, pellentesque aliquet enim. Cras nec maximus sem. Mauris arcu libero, LL | | /// a dolor in, pellentesque aliquet enim. Cras nec maximus sem. Mauris arcu libero,
LL | | /// gravida non lacinia at, rhoncus eu lacus. LL | | /// gravida non lacinia at, rhoncus eu lacus.
| |_ | |_^
error: first doc comment paragraph is too long error: first doc comment paragraph is too long
--> tests/ui/too_long_first_doc_paragraph.rs:36:1 --> tests/ui/too_long_first_doc_paragraph.rs:36:1
@ -32,7 +32,7 @@ LL | / /// Lorem
LL | | /// ipsum dolor sit amet, consectetur adipiscing elit. Nunc turpis nunc, lacinia LL | | /// ipsum dolor sit amet, consectetur adipiscing elit. Nunc turpis nunc, lacinia
LL | | /// a dolor in, pellentesque aliquet enim. Cras nec maximus sem. Mauris arcu libero, LL | | /// a dolor in, pellentesque aliquet enim. Cras nec maximus sem. Mauris arcu libero,
LL | | /// gravida non lacinia at, rhoncus eu lacus. LL | | /// gravida non lacinia at, rhoncus eu lacus.
| |_ | |_^
error: aborting due to 3 previous errors error: aborting due to 3 previous errors