Commit Graph

1191 Commits

Author SHA1 Message Date
bors
bfffe406fb Auto merge of #101138 - Rejyr:diagnostic-migration-rustc-lint-pt2, r=davidtwco
Migrate `rustc_lint` lint diagnostics

Part 2 of [Migrate `rustc_lint` errors to `SessionDiagnostic`](https://github.com/rust-lang/rust/pull/100776)

r? `@davidtwco`

# TODO
- [x] Refactor some lints manually implementing `DecorateLint` to use `Option<Subdiagnostic>`.
- [x] Add `#[rustc_lint_diagnostics]` to lint functions in `context.rs`.
- [x] Migrate `hidden_unicode_codepoints.rs`.
- [x] Migrate `UnsafeCode` in `builtin.rs`.
- [x] Migrate the rest of `builtin.rs`.
2023-01-13 02:13:00 +00:00
Arthur Carcano
797f247997 Mark ZST as FFI-safe if all its fields are PhantomData
Modify the linting behavior and add the corresponding
regression test
2023-01-12 12:21:35 +01:00
bors
8ecaad85f6 Auto merge of #105919 - uweigand:s390x-stack-overflow, r=Nilstrieb
Fix stack overflow in recursive AST walk in early lint

The src/test/ui/issues/issue-74564-if-expr-stack-overflow.rs test case added to verify https://github.com/rust-lang/rust/issues/74564 still crashes with a stack overflow on s390x-ibm-linux.

Symptom is a very deep recursion in compiler/rustc_lint/src/early.rs:
    fn visit_expr(&mut self, e: &'a ast::Expr) {
        self.with_lint_attrs(e.id, &e.attrs, |cx| {
            lint_callback!(cx, check_expr, e);
            ast_visit::walk_expr(cx, e);
        })
    }
(where walk_expr recursively calls back into visit_expr).  The crash happens at a nesting depth of over 17000 stack frames when using the default 8 MB stack size on s390x.

This patch fixes the problem by adding a ensure_sufficient_stack call to the with_lint_attrs routine (which also should take care of all the other mutually recursive visitors here).

Fixes part of https://github.com/rust-lang/rust/issues/105383.
2023-01-11 08:50:38 +00:00
Rejyr
88e5dd2530 refactor: cleanup 2023-01-09 18:57:02 -05:00
Rejyr
fe09291036 migrate: deref_into_dyn_supertrait.rs 2023-01-09 18:57:02 -05:00
Rejyr
f38db48dbd add: allow lints in lints.rs 2023-01-09 18:57:02 -05:00
Rejyr
758140e196 migrate: rest of builtin.rs without builtin_asm_labels 2023-01-09 18:56:59 -05:00
Rejyr
587d49766b migrate: UnsafeCode in builtin.rs 2023-01-09 17:07:25 -05:00
Rejyr
c06a2426b2 migrate: hidden_unicode_codepoints.rs 2023-01-09 17:07:25 -05:00
Rejyr
ce72f942d7 add: #[rustc_lint_diagnostics] for more context.rs functions. 2023-01-09 17:07:25 -05:00
Rejyr
78fce795d8 refactor: refactor to derive for some lints. 2023-01-09 17:07:25 -05:00
Rejyr
ca7df9a2a9 migrate: for_loops_over_fallibles.rs 2023-01-09 17:07:25 -05:00
Rejyr
3c1a1f3643 migrate: expect.rs 2023-01-09 17:07:25 -05:00
Rejyr
6ffecd2059 migrate(wip): builtin.rs 2023-01-09 17:07:25 -05:00
Rejyr
0b19227524 migrate: internal.rs 2023-01-09 17:07:25 -05:00
Rejyr
5ffaae758e migrate: ImproperCTypes 2023-01-09 17:07:25 -05:00
Rejyr
e610047940 migrate: let_underscore.rs
fix: NonBindingLetSub
2023-01-09 17:07:25 -05:00
Rejyr
80df25e160 migrate: levels.rs 2023-01-09 17:07:25 -05:00
Rejyr
ab66ea61cf add: emit{,_spanned}_lint for LintLevelsBuilder
add: `emit_spanned_lint` and `emit_lint` for `LintLevelsBuilder`
migrate: `DeprecatedLintName`
2023-01-09 17:07:25 -05:00
Rejyr
f9289c35fb refactor: comment about lint location 2023-01-09 17:07:25 -05:00
Rejyr
a0614ec2c3 fix: merge conflict 2023-01-09 17:07:25 -05:00
Rejyr
dc00aa3114 update: lints.rs for renamed traits
update: `lints.rs` for renamed `SessionSubdiagnostic` and `AddSubdiagnostic`

fix: NonSnakeCaseDiagSub

fix: OverflowingBinHexSign
2023-01-09 17:07:25 -05:00
Rejyr
e3bb2ebfbf add: lints for errors.rs 2023-01-09 17:07:25 -05:00
Rejyr
8b897bbce6 migrate: early.rs and enum_intrinsics_non_enums.rs 2023-01-09 17:07:25 -05:00
Rejyr
c63ba52562 migrate: array_into_iter.rs 2023-01-09 17:07:25 -05:00
Rejyr
95d3e0cb78 migrate: methods.rs 2023-01-09 17:07:25 -05:00
Rejyr
3f69c1b523 migrate: non_ascii_idents.rs 2023-01-09 17:07:25 -05:00
Rejyr
384010b9f4 migrate: non_fmt_panic.rs 2023-01-09 17:07:25 -05:00
Rejyr
a9bbe31519 migrate: nonstandard_style.rs 2023-01-09 17:07:25 -05:00
Rejyr
56fc66d196 migrate: noop_method_call.rs 2023-01-09 17:07:25 -05:00
Rejyr
6fb3a38f9b migrate: pass_by_value.rs 2023-01-09 17:07:25 -05:00
Rejyr
c3a6801f8e migrate: redundant_semicolon.rs 2023-01-09 17:07:25 -05:00
Rejyr
a42afa0444 migrate: traits.rs 2023-01-09 17:07:25 -05:00
Rejyr
e5ae9d019c migrate: unused.rs 2023-01-09 17:07:25 -05:00
Rejyr
d44ccaa56f migrate: types.rs 2023-01-09 17:07:25 -05:00
Rejyr
5a90537b62 add: lints.rs
add: `lints.rs`
refactor: move `InvalidAtomicOrderingDiag` to `lints.rs`
2023-01-09 17:07:25 -05:00
Michael Goulet
5ce6311f34
Rollup merge of #106403 - compiler-errors:rename-hir-methods, r=cjgillot
Rename `hir::Map::{get_,find_}parent_node` to `hir::Map::{,opt_}parent_id`, and add `hir::Map::{get,find}_parent`

The `hir::Map::get_parent_node` function doesn't return a `Node`, and I think that's quite confusing. Let's rename it to something that sounds more like something that gets the parent hir id => `hir::Map::parent_id`. Same with `find_parent_node` => `opt_parent_id`.

Also, combine `hir.get(hir.parent_id(hir_id))` and similar `hir.find(hir.parent_id(hir_id))` function into new functions that actually retrieve the parent node in one call. This last commit is the only one that might need to be looked at closely.
2023-01-04 20:36:28 -08:00
Michael Goulet
2baee88bdb Address comments 2023-01-04 00:51:50 +00:00
Michael Goulet
7690fe3bc6 Simplify some iterator combinators 2023-01-04 00:48:07 +00:00
Michael Goulet
b1b19bd851 get_parent and find_parent 2023-01-04 00:43:13 +00:00
Michael Goulet
a313ef05a7 rename get_parent_node to parent_id 2023-01-04 00:43:13 +00:00
Rageking8
e808a69911 fix dupe word typos 2023-01-03 15:48:16 +08:00
Michael Goulet
5b74a33b8d
Rollup merge of #106248 - dtolnay:revertupcastlint, r=jackh726
Revert "Implement allow-by-default `multiple_supertrait_upcastable` lint"

This is a clean revert of #105484.

I confirmed that reverting that PR fixes the regression reported in #106247. ~~I can't say I understand what this code is doing, but maybe it can be re-landed with a different implementation.~~ **Edit:** https://github.com/rust-lang/rust/issues/106247#issuecomment-1367174384 has an explanation of why #105484 ends up surfacing spurious `where_clause_object_safety` errors. The implementation of `where_clause_object_safety` assumes we only check whether a trait is object safe when somebody actually uses that trait with `dyn`. However the implementation of `multiple_supertrait_upcastable` added in the problematic PR involves checking *every* trait for whether it is object-safe.

FYI `@nbdd0121` `@compiler-errors`
2022-12-30 21:26:34 -08:00
Matthias Krüger
c610aeb592
Rollup merge of #106221 - Nilstrieb:rptr-more-like-ref-actually, r=compiler-errors
Rename `Rptr` to `Ref` in AST and HIR

The name makes a lot more sense, and `ty::TyKind` calls it `Ref` already as well.
2022-12-29 13:16:04 +01:00
David Tolnay
06ec0bf8b0
Revert "Implement allow-by-default multiple_supertrait_upcastable lint"
This reverts commit 5e44a65517.
2022-12-29 00:47:23 -08:00
Nilstrieb
9067e4417e Rename Rptr to Ref in AST and HIR
The name makes a lot more sense, and `ty::TyKind` calls it `Ref` already
as well.
2022-12-28 18:52:36 +01:00
fee1-dead
8b3d0c4cf9
Rollup merge of #105484 - nbdd0121:upcast, r=compiler-errors
Implement allow-by-default `multiple_supertrait_upcastable` lint

The lint detects when an object-safe trait has multiple supertraits.

Enabled in libcore and liballoc as they are low-level enough that many embedded programs will use them.

r? `@nikomatsakis`
2022-12-28 15:51:41 +08:00
Michael Goulet
18bf19c3a9
Rollup merge of #106064 - lukas-code:outlives-macro, r=cjgillot
Partially fix `explicit_outlives_requirements` lint in macros

Show the suggestion if and only if the bounds are from the same source context.

fixes https://github.com/rust-lang/rust/issues/106044
fixes https://github.com/rust-lang/rust/issues/106063
2022-12-27 12:33:35 -08:00
Matthias Krüger
b8d71fc41f
Rollup merge of #105515 - estebank:issue-104141, r=oli-obk
Account for macros in const generics

Fix #104141.
2022-12-27 08:57:45 +01:00
Lukas Markeffsky
1eba6c404f address review comments + better tests 2022-12-26 16:35:21 +01:00