about summary refs log tree commit diff
path: root/compiler/rustc_codegen_gcc/src
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2022-07-27 17:55:05 +0200
committerGitHub <noreply@github.com>2022-07-27 17:55:05 +0200
commitdda74fe8c94db92b0e7d67ba8d34aee19e6d0d86 (patch)
treeb5a4355ae9a1e9c3f94d381b9a643a6c49ddb0b9 /compiler/rustc_codegen_gcc/src
parent9e7b7d5e1c9199f372107e0ace1733c11d09fe37 (diff)
parent7bab769b58db292721ddcb73cc6a7e56cb2b08ab (diff)
downloadrust-dda74fe8c94db92b0e7d67ba8d34aee19e6d0d86.tar.gz
rust-dda74fe8c94db92b0e7d67ba8d34aee19e6d0d86.zip
Rollup merge of #99710 - davidtwco:internal-lint-opts, r=lcnr
lint: add bad opt access internal lint

Prompted by [Zulip discussion](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/sess.2Ecrate_types.28.29.20vs.20sess.2Eopts.2Ecrate_types/near/290682847).

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.

**Leave a comment if there's an option I should add this to.**
Diffstat (limited to 'compiler/rustc_codegen_gcc/src')
0 files changed, 0 insertions, 0 deletions