diff options
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/ui-fulldeps/internal-lints/bad_opt_access.rs | 22 | ||||
| -rw-r--r-- | src/test/ui-fulldeps/internal-lints/bad_opt_access.stderr | 20 |
2 files changed, 42 insertions, 0 deletions
diff --git a/src/test/ui-fulldeps/internal-lints/bad_opt_access.rs b/src/test/ui-fulldeps/internal-lints/bad_opt_access.rs new file mode 100644 index 00000000000..d6bd6945e15 --- /dev/null +++ b/src/test/ui-fulldeps/internal-lints/bad_opt_access.rs @@ -0,0 +1,22 @@ +// compile-flags: -Z unstable-options + +// Test that accessing command line options by field access triggers a lint for those fields +// that have wrapper functions which should be used. + +#![crate_type = "lib"] +#![feature(rustc_private)] +#![deny(rustc::bad_opt_access)] + +extern crate rustc_session; +use rustc_session::Session; + +pub fn access_bad_option(sess: Session) { + let _ = sess.opts.cg.split_debuginfo; + //~^ ERROR use `Session::split_debuginfo` instead of this field + + let _ = sess.opts.crate_types; + //~^ ERROR use `Session::crate_types` instead of this field + + let _ = sess.opts.crate_name; + // okay! +} diff --git a/src/test/ui-fulldeps/internal-lints/bad_opt_access.stderr b/src/test/ui-fulldeps/internal-lints/bad_opt_access.stderr new file mode 100644 index 00000000000..e4145bff8be --- /dev/null +++ b/src/test/ui-fulldeps/internal-lints/bad_opt_access.stderr @@ -0,0 +1,20 @@ +error: use `Session::split_debuginfo` instead of this field + --> $DIR/bad_opt_access.rs:14:13 + | +LL | let _ = sess.opts.cg.split_debuginfo; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: the lint level is defined here + --> $DIR/bad_opt_access.rs:8:9 + | +LL | #![deny(rustc::bad_opt_access)] + | ^^^^^^^^^^^^^^^^^^^^^ + +error: use `Session::crate_types` instead of this field + --> $DIR/bad_opt_access.rs:17:13 + | +LL | let _ = sess.opts.crate_types; + | ^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + |
