1
Fork 0
rust/compiler/rustc_lint/src
David Wood 7bab769b58 lint: add bad opt access internal lint
Some command-line options accessible through `sess.opts` are best
accessed through wrapper functions on `Session`, `TyCtxt` or otherwise,
rather than through field access on the option struct in the `Session`.

Adds a new lint which triggers on those options that should be accessed
through a wrapper function so that this is prohibited. Options are
annotated with a new attribute `rustc_lint_opt_deny_field_access` which
can specify the error message (i.e. "use this other function instead")
to be emitted.

A simpler alternative would be to simply rename the options in the
option type so that it is clear they should not be used, however this
doesn't prevent uses, just discourages them. Another alternative would
be to make the option fields private, and adding accessor functions on
the option types, however the wrapper functions sometimes rely on
additional state from `Session` or `TyCtxt` which wouldn't be available
in an function on the option type, so the accessor would simply make the
field available and its use would be discouraged too.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-07-27 11:24:27 +01:00
..
nonstandard_style mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
array_into_iter.rs lint: port array-into-iter diagnostics 2022-06-30 08:59:19 +01:00
builtin.rs Erase regions before comparing signatures of foreign fns. 2022-07-19 19:36:45 +02:00
context.rs Only suggest if span is not erroneous 2022-07-15 17:32:34 +00:00
early.rs Auto merge of #99231 - Dylan-DPC:rollup-0tl8c0o, r=Dylan-DPC 2022-07-14 11:00:30 +00:00
enum_intrinsics_non_enums.rs Update TypeVisitor paths 2022-07-06 06:41:53 +01:00
expect.rs lint: port expectation diagnostics 2022-06-30 08:59:21 +01:00
hidden_unicode_codepoints.rs lint: port hidden unicode codepoints diagnostics 2022-06-30 08:59:21 +01:00
internal.rs lint: add bad opt access internal lint 2022-07-27 11:24:27 +01:00
late.rs Rename debugging_opts to unstable_opts 2022-07-13 17:47:06 -05:00
levels.rs lint: LintDiagnosticBuilder into rustc_errors 2022-07-05 16:00:20 +01:00
lib.rs lint: add bad opt access internal lint 2022-07-27 11:24:27 +01:00
methods.rs lint: port CString ptr diagnostics 2022-06-30 08:59:21 +01:00
non_ascii_idents.rs lint: port non-ascii-idents diagnostics 2022-06-30 08:59:21 +01:00
non_fmt_panic.rs lint: port non-fmt-panic diagnostics 2022-06-30 08:59:21 +01:00
nonstandard_style.rs lint: port non-standard style diagnostics 2022-06-30 08:59:21 +01:00
noop_method_call.rs Update TypeVisitor paths 2022-07-06 06:41:53 +01:00
pass_by_value.rs lint: port pass-by-value diagnostics 2022-06-30 08:59:21 +01:00
passes.rs Do not pass hir::Crate to lints. 2021-09-30 17:39:54 +02:00
redundant_semicolon.rs lint: port redundant semicolons diagnostics 2022-06-30 08:59:21 +01:00
tests.rs Update to last upstream version 2021-07-08 17:14:28 +02:00
traits.rs lint: port drop trait/glue diagnostics 2022-06-30 08:59:21 +01:00
types.rs Update invalid atomic ordering lint 2022-07-18 12:02:11 +02:00
unused.rs lint: port unused allocation diagnostics 2022-06-30 08:59:22 +01:00