1
Fork 0
rust/compiler/rustc_mir_transform/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
..
coverage Rename debugging_opts to unstable_opts 2022-07-13 17:47:06 -05:00
inline consistently use VTable over Vtable (matching stable stdlib API RawWakerVTable) 2022-07-20 17:12:07 -04:00
abort_unwinding_calls.rs Rename debugging_opts to unstable_opts 2022-07-13 17:47:06 -05:00
add_call_guards.rs Move predecessors from Body to BasicBlocks 2022-07-07 08:11:49 +02:00
add_moves_for_packed_drops.rs Adopt let else in more places 2022-02-19 17:27:43 +01:00
add_retag.rs has_deref: simpler comparison, ty fix 2022-07-22 17:35:28 +03:00
check_const_item_mutation.rs lint: LintDiagnosticBuilder into rustc_errors 2022-07-05 16:00:20 +01:00
check_packed_ref.rs Remove erroneous E0133 code from an error message. 2022-07-26 12:54:24 +10:00
check_unsafety.rs use body's param-env when checking if type needs drop 2022-07-17 10:56:12 -07:00
cleanup_post_borrowck.rs Move rustc_mir::transform to rustc_mir_transform. 2021-09-07 00:43:14 +02:00
const_debuginfo.rs Rename debugging_opts to unstable_opts 2022-07-13 17:47:06 -05:00
const_goto.rs enhance ConstGoto mir-opt by moving up StorageDead statements 2022-04-06 15:17:41 +08:00
const_prop.rs removed CanConstProp + Visitor 2022-07-25 13:54:49 +00:00
const_prop_lint.rs removed CanConstProp + Visitor 2022-07-25 13:54:49 +00:00
dead_store_elimination.rs Make MIR basic blocks field public 2022-07-07 08:11:49 +02:00
deaggregator.rs Make MIR basic blocks field public 2022-07-07 08:11:49 +02:00
deduplicate_blocks.rs Remove in_band_lifetimes from rustc_mir_transform 2021-12-07 21:04:40 -08:00
deref_separator.rs add new rval, pull deref early 2022-07-12 14:26:41 +03:00
dest_prop.rs Rename debugging_opts to unstable_opts 2022-07-13 17:47:06 -05:00
dump_mir.rs Inline on_mir_pass and add inline to dump_mir 2021-10-14 15:26:59 -05:00
early_otherwise_branch.rs Rename debugging_opts to unstable_opts 2022-07-13 17:47:06 -05:00
elaborate_box_derefs.rs Make MIR basic blocks field public 2022-07-07 08:11:49 +02:00
elaborate_drops.rs add new rval, pull deref early 2022-07-12 14:26:41 +03:00
ffi_unwind_calls.rs Add a explanation about required panic strategy computation 2022-06-09 16:51:08 +01:00
function_item_references.rs Refactor call terminator to always hold a destination place 2022-05-23 17:49:04 -04:00
generator.rs Rename debugging_opts to unstable_opts 2022-07-13 17:47:06 -05:00
inline.rs consistently use VTable over Vtable (matching stable stdlib API RawWakerVTable) 2022-07-20 17:12:07 -04:00
instcombine.rs Make MIR basic blocks field public 2022-07-07 08:11:49 +02:00
lib.rs Stabilize let_chains 2022-07-16 20:17:58 -03:00
lower_intrinsics.rs Make MIR basic blocks field public 2022-07-07 08:11:49 +02:00
lower_slice_len.rs lint: add bad opt access internal lint 2022-07-27 11:24:27 +01:00
marker.rs Add pass for simple phase change 2021-12-02 17:31:38 -08:00
match_branches.rs Make MIR basic blocks field public 2022-07-07 08:11:49 +02:00
multiple_return_terminators.rs Update passes with new interface 2021-12-02 17:31:38 -08:00
normalize_array_len.rs Make MIR basic blocks field public 2022-07-07 08:11:49 +02:00
nrvo.rs Move predecessors from Body to BasicBlocks 2022-07-07 08:11:49 +02:00
pass_manager.rs Rename debugging_opts to unstable_opts 2022-07-13 17:47:06 -05:00
remove_false_edges.rs Separate RemoveFalseEdges from SimplifyBranches 2021-11-30 17:14:48 -08:00
remove_noop_landing_pads.rs implement valtrees as the type-system representation for constant values 2022-06-14 16:07:11 +02:00
remove_storage_markers.rs Make MIR basic blocks field public 2022-07-07 08:11:49 +02:00
remove_uninit_drops.rs lower let-else in MIR instead 2022-07-11 23:20:36 +02:00
remove_unneeded_drops.rs Make MIR basic blocks field public 2022-07-07 08:11:49 +02:00
remove_zsts.rs Make MIR basic blocks field public 2022-07-07 08:11:49 +02:00
required_consts.rs Rename the ConstS::val field as kind. 2022-06-14 13:06:44 +10:00
reveal_all.rs lint: add bad opt access internal lint 2022-07-27 11:24:27 +01:00
separate_const_switch.rs add new rval, pull deref early 2022-07-12 14:26:41 +03:00
shim.rs consistently use VTable over Vtable (matching stable stdlib API RawWakerVTable) 2022-07-20 17:12:07 -04:00
simplify.rs Remove reachable coverage without counters 2022-07-25 14:14:49 +02:00
simplify_branches.rs Auto merge of #91279 - scottmcm:small-refactor, r=nagisa 2021-12-06 13:04:18 +00:00
simplify_comparison_integral.rs fix most compiler/ doctests 2022-05-02 17:40:30 -07:00
simplify_try.rs Rename debugging_opts to unstable_opts 2022-07-13 17:47:06 -05:00
uninhabited_enum_branching.rs Remove unused StableMap and StableSet types from rustc_data_structures 2022-07-20 13:11:39 +02:00
unreachable_prop.rs Remove deprecated LLVM-style inline assembly 2022-01-12 18:51:31 +01:00