summary refs log tree commit diff
path: root/compiler/rustc_lint/src
AgeCommit message (Collapse)AuthorLines
2021-06-10Add support for using qualified paths with structs in expression and patternRyan Levick-2/+2
position.
2021-06-08Rollup merge of #85906 - LingMan:iter_find, r=matthewjasperYuki Okushi-8/+3
Use `Iterator::find` instead of open-coding it ```@rustbot``` modify labels +C-cleanup +T-compiler
2021-06-07Rollup merge of #85912 - LingMan:iter_any, r=nagisaGuillaume Gomez-9/+4
Use `Iterator::any` and `filter_map` instead of open-coding them ``@rustbot`` modify labels +C-cleanup +T-compiler
2021-06-05Auto merge of #85457 - jyn514:remove-doc-include, r=GuillaumeGomezbors-1/+1
Remove `doc(include)` This nightly feature is redundant now that `extended_key_value_attributes` is stable (https://github.com/rust-lang/rust/pull/83366). `@rust-lang/rustdoc` not sure if you think this needs FCP; there was already an FCP in #82539, but technically it was for deprecating, not removing the feature altogether. This should not be merged before #83366. cc `@petrochenkov`
2021-06-05Rollup merge of #85853 - marmeladema:improper-ctypes-definitions-boxed-dst, ↵Yuki Okushi-4/+11
r=petrochenkov Warn against boxed DST in `improper_ctypes_definitions` lint Fixes #85714
2021-06-04Auto merge of #85788 - rylev:force-warns, r=nikomatsakisbors-14/+39
Support for force-warns Implements https://github.com/rust-lang/rust/issues/85512. This PR adds a new command line option `force-warns` which will force the provided lints to warn even if they are allowed by some other mechanism such as `#![allow(warnings)]`. Some remaining issues: * https://github.com/rust-lang/rust/issues/85512 mentions that `force-warns` should also be capable of taking lint groups instead of individual lints. This is not implemented. * If a lint has a higher warning level than `warn`, this will cause that lint to warn instead. We probably want to allow the lint to error if it is set to a higher lint and is not allowed somewhere else. * One test is currently ignored because it's not working - when a deny-by-default lint is allowed, it does not currently warn under `force-warns`. I'm not sure why, but I wanted to get this in before the weekend. r? `@nikomatsakis`
2021-06-04Remove `doc(include)`Joshua Nelson-1/+1
2021-06-04Rollup merge of #85850 - bjorn3:less_feature_gates, r=jyn514Yuki Okushi-2/+0
Remove unused feature gates The first commit removes a usage of a feature gate, but I don't expect it to be controversial as the feature gate was only used to workaround a limitation of rust in the past. (closures never being `Clone`) The second commit uses `#[allow_internal_unstable]` to avoid leaking the `trusted_step` feature gate usage from inside the index newtype macro. It didn't work for the `min_specialization` feature gate though. The third commit removes (almost) all feature gates from the compiler that weren't used anyway.
2021-06-03Warn against boxed DST in `improper_ctypes_definitions` lintmarmeladema-4/+11
2021-06-03Rollup merge of #85900 - LingMan:pat_mat, r=petrochenkovYuki Okushi-19/+7
Use pattern matching instead of checking lengths explicitly This piece of code checks that there are exaclty two variants, one having exactly one field, the other having exactly zero fields. If any of these conditions is violated, it returns `None`. Otherwise it assigns that one field's ty to `field_ty`. Instead of fiddling with indices and length checks explicitly, use pattern matching to simplify this. `@rustbot` modify labels +C-cleanup +T-compiler
2021-06-02Restrict access to crate_name.Camille GILLOT-1/+1
Also remove original_crate_name, which had the exact same implementation
2021-06-02Force warn on lint groups as wellRyan Levick-16/+32
2021-06-01Use pattern matching instead of checking lengths explicitlyLingMan-19/+7
This piece of code checks that there are exaclty two variants, one having exactly one field, the other having exactly zero fields. If any of these conditions is violated, it returns `None`. Otherwise it assigns that one field's ty to `field_ty`. Instead of fiddling with indices and length checks explicitly, use pattern matching to simplify this.
2021-06-01Use `Iterator::any` and `filter_map` instead of open-coding themLingMan-9/+4
2021-06-01Use `Iterator::find` instead of open-coding itLingMan-8/+3
2021-06-01Fix issues and add testRyan Levick-1/+1
2021-06-01Revert "Reduce the amount of untracked state in TyCtxt"Camille Gillot-1/+1
2021-05-31Remove unused feature gatesbjorn3-2/+0
2021-05-30Restrict access to crate_name.Camille GILLOT-1/+1
Also remove original_crate_name, which had the exact same implementation
2021-05-28Initial support for force-warnsRyan Levick-0/+9
2021-05-26Lint against non-camelCase trait alias namesSmitty-0/+1
Type aliases are linted as such, so (unstable) trait aliases should be treated the same way.
2021-05-24remove cfg(bootstrap)Pietro Albini-1/+0
2021-05-17Auto merge of #85178 - cjgillot:local-crate, r=oli-obkbors-8/+6
Remove CrateNum parameter for queries that only work on local crate The pervasive `CrateNum` parameter is a remnant of the multi-crate rustc idea. Using `()` as query key in those cases avoids having to worry about the validity of the query key.
2021-05-15Fix unused attributes on macro_rules.Eric Huss-0/+4
2021-05-12Use () for privacy.Camille GILLOT-3/+3
2021-05-12Use () for lint_levels.Camille GILLOT-5/+3
2021-05-12Implement span quoting for proc-macrosAaron Hill-9/+21
This PR implements span quoting, allowing proc-macros to produce spans pointing *into their own crate*. This is used by the unstable `proc_macro::quote!` macro, allowing us to get error messages like this: ``` error[E0412]: cannot find type `MissingType` in this scope --> $DIR/auxiliary/span-from-proc-macro.rs:37:20 | LL | pub fn error_from_attribute(_args: TokenStream, _input: TokenStream) -> TokenStream { | ----------------------------------------------------------------------------------- in this expansion of procedural macro `#[error_from_attribute]` ... LL | field: MissingType | ^^^^^^^^^^^ not found in this scope | ::: $DIR/span-from-proc-macro.rs:8:1 | LL | #[error_from_attribute] | ----------------------- in this macro invocation ``` Here, `MissingType` occurs inside the implementation of the proc-macro `#[error_from_attribute]`. Previosuly, this would always result in a span pointing at `#[error_from_attribute]` This will make many proc-macro-related error message much more useful - when a proc-macro generates code containing an error, users will get an error message pointing directly at that code (within the macro definition), instead of always getting a span pointing at the macro invocation site. This is implemented as follows: * When a proc-macro crate is being *compiled*, it causes the `quote!` macro to get run. This saves all of the sapns in the input to `quote!` into the metadata of *the proc-macro-crate* (which we are currently compiling). The `quote!` macro then expands to a call to `proc_macro::Span::recover_proc_macro_span(id)`, where `id` is an opaque identifier for the span in the crate metadata. * When the same proc-macro crate is *run* (e.g. it is loaded from disk and invoked by some consumer crate), the call to `proc_macro::Span::recover_proc_macro_span` causes us to load the span from the proc-macro crate's metadata. The proc-macro then produces a `TokenStream` containing a `Span` pointing into the proc-macro crate itself. The recursive nature of 'quote!' can be difficult to understand at first. The file `src/test/ui/proc-macro/quote-debug.stdout` shows the output of the `quote!` macro, which should make this eaier to understand. This PR also supports custom quoting spans in custom quote macros (e.g. the `quote` crate). All span quoting goes through the `proc_macro::quote_span` method, which can be called by a custom quote macro to perform span quoting. An example of this usage is provided in `src/test/ui/proc-macro/auxiliary/custom-quote.rs` Custom quoting currently has a few limitations: In order to quote a span, we need to generate a call to `proc_macro::Span::recover_proc_macro_span`. However, proc-macros support renaming the `proc_macro` crate, so we can't simply hardcode this path. Previously, the `quote_span` method used the path `crate::Span` - however, this only works when it is called by the builtin `quote!` macro in the same crate. To support being called from arbitrary crates, we need access to the name of the `proc_macro` crate to generate a path. This PR adds an additional argument to `quote_span` to specify the name of the `proc_macro` crate. Howver, this feels kind of hacky, and we may want to change this before stabilizing anything quote-related. Additionally, using `quote_span` currently requires enabling the `proc_macro_internals` feature. The builtin `quote!` macro has an `#[allow_internal_unstable]` attribute, but this won't work for custom quote implementations. This will likely require some additional tricks to apply `allow_internal_unstable` to the span of `proc_macro::Span::recover_proc_macro_span`.
2021-05-10Rollup merge of #85075 - ptrojahn:panic_warning, r=jackh726Dylan DPC-6/+11
Improve "panic message is not a string literal" warning This warning always referenced panic! even in case of an assert. Related to #84656
2021-05-09Improve "panic message is not a string literal" warningPaul Trojahn-6/+11
This warning always referenced panic! even in case of an assert. Related to #84656
2021-05-07Fix duplicate unknown lint errorsCameron Steffen-3/+3
2021-05-04Auto merge of #83213 - rylev:update-lints-to-errors, r=nikomatsakisbors-26/+55
Update BARE_TRAIT_OBJECT and ELLIPSIS_INCLUSIVE_RANGE_PATTERNS to errors in Rust 2021 This addresses https://github.com/rust-lang/rust/pull/81244 by updating two lints to errors in the Rust 2021 edition. r? `@estebank`
2021-05-02Change 'NULL' to 'null'Brent Kerby-2/+2
2021-04-28Auto merge of #83386 - mark-i-m:stabilize-pat2015, r=nikomatsakisbors-1/+1
Stabilize `:pat_param` and remove `:pat2021` Blocked on #83384 cc `@rust-lang/lang` #79278 If I understand `@nikomatsakis` in https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/or.20patterns/near/231133873, another FCP is not needed. r? `@nikomatsakis`
2021-04-19fix few typosklensy-1/+1
2021-04-18Auto merge of #83799 - crlf0710:stablize_non_ascii_idents, r=Manishearthbors-28/+9
Stablize `non-ascii-idents` This is the stablization PR for RFC 2457. Currently this is waiting on fcp in [tracking issue](https://github.com/rust-lang/rust/issues/55467). r? `@Manishearth`
2021-04-18Auto merge of #84064 - hyd-dev:unknown-lints, r=petrochenkovbors-43/+38
Do not ignore path segments in the middle in `#[allow]`/`#[warn]`/`#[deny]`/`#[forbid]` attributes Fixes #83477.
2021-04-17Do not ignore path segments in the middle in ↵hyd-dev-43/+38
`#[allow]`/`#[warn]`/`#[deny]`/`#[forbid]` attributes
2021-04-15rename pat2015 to pat_parammark-1/+1
2021-04-15Run buffered lints attached to anon constsAaron Hill-0/+1
Fixes #84195
2021-04-14Auto merge of #83948 - ABouttefeux:lint-nullprt-deref, r=RalfJungbors-0/+88
add lint deref_nullptr detecting when a null ptr is dereferenced fixes #83856 changelog: add lint that detect code like ```rust unsafe { &*core::ptr::null::<i32>() }; unsafe { addr_of!(std::ptr::null::<i32>()) }; let x: i32 = unsafe {*core::ptr::null()}; let x: i32 = unsafe {*core::ptr::null_mut()}; unsafe {*(0 as *const i32)}; unsafe {*(core::ptr::null() as *const i32)}; ``` ``` warning: Dereferencing a null pointer causes undefined behavior --> src\main.rs:5:26 | 5 | let x: i32 = unsafe {*core::ptr::null()}; | ^^^^^^^^^^^^^^^^^^ | | | a null pointer is dereferenced | this code causes undefined behavior when executed | = note: `#[warn(deref_nullptr)]` on by default ``` Limitation: It does not detect code like ```rust const ZERO: usize = 0; unsafe {*(ZERO as *const i32)}; ``` or code where `0` is not directly a literal
2021-04-13Add compatibility info to lintsRyan Levick-1/+5
2021-04-12Turn old edition lints (anonymous-parameters, keyword-idents) into ↵Manish Goregaokar-4/+7
warn-by-default on 2015
2021-04-09changes based on reviewAliénore Bouttefeux-6/+4
2021-04-08Rollup merge of #83980 - pierwill:fix-compiler-librustc-names, r=davidtwcoDylan DPC-1/+1
Fix outdated crate names in compiler docs Changes `librustc_X` to `rustc_X`, only in documentation comments. Plain code comments are left unchanged.
2021-04-08Rollup merge of #81764 - jyn514:lint-links, r=GuillaumeGomezDylan DPC-3/+4
Stabilize `rustdoc::bare_urls` lint Closes https://github.com/rust-lang/rust/issues/77501. Closes https://github.com/rust-lang/rust/issues/83598.
2021-04-08Fix outdated crate names in compiler docspierwill-1/+1
Changes `librustc_X` to `rustc_X`, only in documentation comments. Plain code comments are left unchanged. Also fix incorrect file paths.
2021-04-08Change how edition is determinedRyan Levick-2/+2
2021-04-08Update BARE_TRAIT_OBJECT and ELLIPSIS_INCLUSIVE_RANGE_PATTERNS to errors in ↵Ryan Levick-25/+50
Rust 2021
2021-04-08fix lint docAliénore Bouttefeux-18/+7
2021-04-07change documentation of lintAliénore Bouttefeux-5/+14