rust/compiler/rustc_error_messages/locales/en-US
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
..
borrowck.ftl Migrate some rustc_borrowck diagnostics to SessionDiagnostic 2022-06-28 22:41:56 +00:00
builtin_macros.ftl Use dashes instead of underscores in fluent names 2022-07-08 03:37:36 +00:00
const_eval.ftl simplify plurals in fluent messages using hir::ConstContext 2022-07-08 03:48:10 +00:00
expand.ftl use subdiagnostic for message 2022-07-10 23:43:46 +00:00
lint.ftl Update invalid atomic ordering lint 2022-07-18 12:02:11 +02:00
parser.ftl migrate check_for_for_in_in_typo diagnostic 2022-05-31 16:28:05 -05:00
passes.ftl lint: add bad opt access internal lint 2022-07-27 11:24:27 +01:00
privacy.ftl errors: lint on LintDiagnosticBuilder::build 2022-07-15 16:13:47 +01:00
typeck.ftl Deactivate feature gate explicit_generic_args_with_impl_trait 2022-06-06 12:21:49 +01:00