Fix error message for direct usage of sess.opts.crate_types

This commit is contained in:
bjorn3 2024-11-09 21:22:25 +00:00
parent 0a619dbc5d
commit e8b10297b5
3 changed files with 3 additions and 3 deletions

View File

@ -130,7 +130,7 @@ top_level_options!(
pub struct Options { pub struct Options {
/// The crate config requested for the session, which may be combined /// The crate config requested for the session, which may be combined
/// with additional crate configurations during the compile process. /// with additional crate configurations during the compile process.
#[rustc_lint_opt_deny_field_access("use `Session::crate_types` instead of this field")] #[rustc_lint_opt_deny_field_access("use `TyCtxt::crate_types` instead of this field")]
crate_types: Vec<CrateType> [TRACKED], crate_types: Vec<CrateType> [TRACKED],
optimize: OptLevel [TRACKED], optimize: OptLevel [TRACKED],
/// Include the `debug_assertions` flag in dependency tracking, since it /// Include the `debug_assertions` flag in dependency tracking, since it

View File

@ -15,7 +15,7 @@ pub fn access_bad_option(sess: Session) {
//~^ ERROR use `Session::split_debuginfo` instead of this field //~^ ERROR use `Session::split_debuginfo` instead of this field
let _ = sess.opts.crate_types; let _ = sess.opts.crate_types;
//~^ ERROR use `Session::crate_types` instead of this field //~^ ERROR use `TyCtxt::crate_types` instead of this field
let _ = sess.opts.crate_name; let _ = sess.opts.crate_name;
// okay! // okay!

View File

@ -10,7 +10,7 @@ note: the lint level is defined here
LL | #![deny(rustc::bad_opt_access)] LL | #![deny(rustc::bad_opt_access)]
| ^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^
error: use `Session::crate_types` instead of this field error: use `TyCtxt::crate_types` instead of this field
--> $DIR/bad_opt_access.rs:17:13 --> $DIR/bad_opt_access.rs:17:13
| |
LL | let _ = sess.opts.crate_types; LL | let _ = sess.opts.crate_types;