about summary refs log tree commit diff
path: root/compiler/rustc_lint/src
AgeCommit message (Collapse)AuthorLines
2022-01-22Rollup merge of #93153 - tmiasko:reject-unsupported-naked-functions, r=AmanieuMatthias Krüger-0/+5
Reject unsupported naked functions Transition unsupported naked functions future incompatibility lint into an error: * Naked functions must contain a single inline assembly block. Introduced as future incompatibility lint in 1.50 #79653. Change into an error fixes a soundness issue described in #32489. * Naked functions must not use any forms of inline attribute. Introduced as future incompatibility lint in 1.56 #87652. Closes #32490. Closes #32489. r? ```@Amanieu``` ```@npmccallum``` ```@joshtriplett```
2022-01-21Remove a span from hir::ExprKind::MethodCallCameron Steffen-6/+6
2022-01-21Reject unsupported naked functionsTomasz Miąsko-0/+5
Transition unsupported naked functions future incompatibility lint into an error: * Naked functions must contain a single inline assembly block. Introduced as future incompatibility lint in 1.50 #79653. Change into an error fixes a soundness issue described in #32489. * Naked functions must not use any forms of inline attribute. Introduced as future incompatibility lint in 1.56 #87652.
2022-01-20Rollup merge of #92704 - 5225225:std_mem_transmute_ref_t_mut_t, ↵Matthias Krüger-3/+3
r=michaelwoerister Change lint message to be stronger for &T -> &mut T transmute The old message implied that it's only UB if you use the reference to mutate, which (as far as I know) is not true. As in, the following program has UB, and a &T -> &mut T transmute is effectively an `unreachable_unchecked`. ```rust fn main() { #[allow(mutable_transmutes)] unsafe { let _ = std::mem::transmute::<&i32, &mut i32>(&0); } } ``` In the future, it might be a good idea to use the edition system to make this a hard error, since I don't think it is *ever* defined behaviour? Unless we rule that `&UnsafeCell<i32> -> &mut i32` is fine. (That, and you always could just use `.get()`, so you're not losing anything)
2022-01-19Add links to the reference and rust by example for asm! docs and lintsAmanieu d'Antras-0/+4
2022-01-16Replace NestedVisitorMap with NestedFilterCameron Steffen-14/+8
2022-01-16Rollup merge of #92646 - mdibaiee:76935/pass-by-value, r=lcnrMatthias Krüger-33/+100
feat: rustc_pass_by_value lint attribute Useful for thin wrapper attributes that are best passed as value instead of reference. Fixes #76935
2022-01-16Auto merge of #92805 - BoxyUwU:revert-lazy-anon-const-substs, r=lcnrbors-8/+5
partially revertish `lazily "compute" anon const default substs` reverts #87280 except for some of the changes around `ty::Unevaluated` having a visitor and a generic for promoted why revert: <https://github.com/rust-lang/rust/pull/92805#issuecomment-1010736049> r? `@lcnr`
2022-01-15Reduce use of local_def_id_to_hir_id.Camille GILLOT-3/+2
2022-01-15Return a LocalDefId in get_parent_item.Camille GILLOT-1/+1
2022-01-15initial revertEllen-8/+5
2022-01-11rustc_pass_by_value: handle inferred generic types (with _)Mahdi Dibaiee-9/+5
2022-01-11rustc_pass_by_value: handle generic and const type parametersMahdi Dibaiee-14/+19
2022-01-11rustc_pass_by_value: allow types with no parameters on selfMahdi Dibaiee-13/+5
includes minor refactorings
2022-01-10rustc_pass_by_value remove dependency on rustc_diagnostic_itemMahdi Dibaiee-7/+4
2022-01-10rustc_pass_by_value lint: add test on custom typesMahdi Dibaiee-0/+1
2022-01-09Make message for &T -> &mut T transmute more accurate5225225-3/+3
2022-01-09Compute most of Public/Exported access level in rustc_resolveLamb-1/+2
Mak DefId to AccessLevel map in resolve for export hir_id to accesslevel in resolve and applied in privacy using local def id removing tracing probes making function not recursive and adding comments Move most of Exported/Public res to rustc_resolve moving public/export res to resolve fix missing stability attributes in core, std and alloc move code to access_levels.rs return for some kinds instead of going through them Export correctness, macro changes, comments add comment for import binding add comment for import binding renmae to access level visitor, remove comments, move fn as closure, remove new_key fmt fix rebase fix rebase fmt fmt fix: move macro def to rustc_resolve fix: reachable AccessLevel for enum variants fmt fix: missing stability attributes for other architectures allow unreachable pub in rustfmt fix: missing impl access level + renaming export to reexport Missing impl access level was found thanks to a test in clippy
2022-01-09feat: pass_by_value lint attributeMahdi Dibaiee-33/+109
Useful for thin wrapper attributes that are best passed as value instead of reference.
2021-12-21Rollup merge of #91770 - TaKO8Ki:suggest-adding-cfg-test, r=joshtriplettMatthias Krüger-1/+9
Suggest adding a `#[cfg(test)]` to to a test module closes #88138
2021-12-19Auto merge of #91957 - nnethercote:rm-SymbolStr, r=oli-obkbors-20/+19
Remove `SymbolStr` This was originally proposed in https://github.com/rust-lang/rust/pull/74554#discussion_r466203544. As well as removing the icky `SymbolStr` type, it allows the removal of a lot of `&` and `*` occurrences. Best reviewed one commit at a time. r? `@oli-obk`
2021-12-19Rollup merge of #91956 - notriddle:notriddle/unused-parens-range, r=nagisaMatthias Krüger-1/+4
fix(rustc_lint): better detect when parens are necessary Fixes #90807
2021-12-18Rollup merge of #92032 - petrochenkov:extblockpath, r=oli-obkMatthias Krüger-2/+2
hir: Do not introduce dummy type names for `extern` blocks in def paths Use a separate nameless `DefPathData` variant instead. Extracted from https://github.com/rust-lang/rust/pull/91795.
2021-12-18hir: Do not introduce dummy type names for `extern` blocks in def pathsVadim Petrochenkov-2/+2
Use a separate nameless `DefPathData` variant instead
2021-12-18Rollup merge of #91818 - camelid:unused-result-type, r=jackh726Matthias Krüger-1/+3
Show the unused type for `unused_results` lint I think it's helpful to know what type was unused when looking at these warnings. The type will likely determine whether the result *should* be used, or whether it should just be ignored. Including the type also matches the behavior of the `must_use` lint: unused `SomeType` that must be used.
2021-12-18Rollup merge of #89090 - cjgillot:bare-dyn, r=jackh726Matthias Krüger-10/+0
Lint bare traits in AstConv. Removing the lint from lowering allows to: - make lowering querification easier; - have the lint implementation in only one place. r? `@estebank`
2021-12-17fix(rustc_lint): mark the parens around `(1..loop {})` as unusedMichael Howell-1/+1
2021-12-16suggest adding a `#[cfg(test)]` to test modulesTakayuki Maeda-1/+9
remove a empty line import `module_to_string` use `contains("test")` show a suggestion in case module starts_with/ends_with "test" replace `parent` with `containing`
2021-12-15fix(rustc_lint): better detect when parens are necessaryMichael Howell-1/+4
Fixes #90807
2021-12-15Remove unnecessary sigils around `Symbol::as_str()` calls.Nicholas Nethercote-14/+13
2021-12-15Remove `SymbolStr`.Nicholas Nethercote-6/+6
By changing `as_str()` to take `&self` instead of `self`, we can just return `&str`. We're still lying about lifetimes, but it's a smaller lie than before, where `SymbolStr` contained a (fake) `&'static str`!
2021-12-15Rollup merge of #91881 - Patrick-Poitras:stabilize-iter-zip, r=scottmcmMatthias Krüger-1/+0
Stabilize `iter::zip` Hello all! As the tracking issue (#83574) for `iter::zip` completed the final commenting period without any concerns being raised, I hereby submit this stabilization PR on the issue. As the pull request that introduced the feature (#82917) states, the `iter::zip` function is a shorter way to zip two iterators. As it's generally a quality-of-life/ergonomic improvement, it has been integrated into the codebase without any trouble, and has been used in many places across the rust compiler and standard library since March without any issues. For more details, I would refer to `@cuviper's` original PR, or the [function's documentation](https://doc.rust-lang.org/std/iter/fn.zip.html).
2021-12-15Rollup merge of #90939 - estebank:wg-af-polish, r=tmandryMatthias Krüger-1/+1
Tweak errors coming from `for`-loop, `?` and `.await` desugaring * Suggest removal of `.await` on non-`Future` expression * Keep track of obligations introduced by desugaring * Remove span pointing at method for obligation errors coming from desugaring * Point at called local sync `fn` and suggest making it `async` ``` error[E0277]: `()` is not a future --> $DIR/unnecessary-await.rs:9:10 | LL | boo().await; | -----^^^^^^ `()` is not a future | | | this call returns `()` | = help: the trait `Future` is not implemented for `()` help: do not `.await` the expression | LL - boo().await; LL + boo(); | help: alternatively, consider making `fn boo` asynchronous | LL | async fn boo () {} | +++++ ``` Fix #66731.
2021-12-14Stabilize iter::zip.PFPoitras-1/+0
2021-12-13Keep info on pre-desugaring expression for better "incorrect `.await`" ↵Esteban Kuber-1/+1
suggestion Keep the `HirId` of `.await`ed expressions so in the case of a `fn` call on on a sync `fn`, we can suggest maybe turning it into an `async fn`.
2021-12-12Address review feedbackAmanieu d'Antras-1/+0
2021-12-12Stabilize asm! and global_asm!Amanieu d'Antras-5/+3
They are also removed from the prelude as per the decision in https://github.com/rust-lang/rust/issues/87228. stdarch and compiler-builtins are updated to work with the new, stable asm! and global_asm! macros.
2021-12-11Show the unused type for `unused_results` lintNoah Lev-1/+3
I think it's helpful to know what type was unused when looking at these warnings. The type will likely determine whether the result *should* be used, or whether it should just be ignored. Including the type also matches the behavior of the `must_use` lint: unused `SomeType` that must be used.
2021-12-11Remove useless variant.Camille GILLOT-20/+1
2021-12-09Remove redundant [..]sest31-1/+1
2021-12-04Lint bare traits in AstConv.Camille GILLOT-10/+0
2021-12-03Use let_else in some more places in rustc_lintest31-69/+52
2021-12-02Rollup merge of #91394 - Mark-Simulacrum:bump-stage0, r=pietroalbiniMatthias Krüger-1/+0
Bump stage0 compiler r? `@pietroalbini` (or anyone else)
2021-12-01Auto merge of #91255 - b-naber:normalization-ice, r=jackh276bors-1/+3
Implement version of normalize_erasing_regions that allows for normalization failure Fixes https://github.com/rust-lang/rust/issues/59324 Fixes https://github.com/rust-lang/rust/issues/67684 Fixes https://github.com/rust-lang/rust/issues/69398 Fixes https://github.com/rust-lang/rust/issues/71113 Fixes https://github.com/rust-lang/rust/issues/82079 Fixes #85103 Fixes https://github.com/rust-lang/rust/issues/88856 Fixes #91231 Fixes https://github.com/rust-lang/rust/issues/91234 Previously we called `normalize_erasing_regions` inside `layout_of`. `normalize_erasing_regions` assumes that the normalization succeeds. Since some `layout_of` calls happen before typecheck has finished, we introduce a new variant that allows for returning an error.
2021-12-01implement version of normalize_erasing_regions that doesn't assume value is ↵b-naber-1/+3
normalizable
2021-12-01Rollup merge of #90985 - camsteffen:diag-name-usage, r=jackh726Matthias Krüger-48/+52
Use `get_diagnostic_name` more
2021-11-30Emit a warning on generic parameters with doc commentsJoshua Nelson-0/+4
2021-11-30Apply cfg-bootstrap switchMark Rousskov-1/+0
2021-11-28Take a LocalDefId in expect_*item.Camille GILLOT-1/+1
2021-11-16Use get_diagnostic_name moreCameron Steffen-48/+52