diff options
Diffstat (limited to '')
64 files changed, 453 insertions, 1141 deletions
diff --git a/tests/ui-fulldeps/internal-lints/span_use_eq_ctxt.rs b/tests/ui-fulldeps/internal-lints/span_use_eq_ctxt.rs new file mode 100644 index 000000000..aeb68bf05 --- /dev/null +++ b/tests/ui-fulldeps/internal-lints/span_use_eq_ctxt.rs @@ -0,0 +1,15 @@ +// Test the `rustc::span_use_eq_ctxt` internal lint +// #[cfg(bootstrap)] +// ignore-stage1 +// compile-flags: -Z unstable-options + +#![feature(rustc_private)] +#![deny(rustc::span_use_eq_ctxt)] +#![crate_type = "lib"] + +extern crate rustc_span; +use rustc_span::Span; + +pub fn f(s: Span, t: Span) -> bool { + s.ctxt() == t.ctxt() //~ ERROR use `.eq_ctxt()` instead of `.ctxt() == .ctxt()` +} diff --git a/tests/ui-fulldeps/internal-lints/span_use_eq_ctxt.stderr b/tests/ui-fulldeps/internal-lints/span_use_eq_ctxt.stderr new file mode 100644 index 000000000..3d8a7dd1e --- /dev/null +++ b/tests/ui-fulldeps/internal-lints/span_use_eq_ctxt.stderr @@ -0,0 +1,14 @@ +error: use `.eq_ctxt()` instead of `.ctxt() == .ctxt()` + --> $DIR/span_use_eq_ctxt.rs:14:5 + | +LL | s.ctxt() == t.ctxt() + | ^^^^^^^^^^^^^^^^^^^^ + | +note: the lint level is defined here + --> $DIR/span_use_eq_ctxt.rs:7:9 + | +LL | #![deny(rustc::span_use_eq_ctxt)] + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/tests/ui-fulldeps/internal-lints/ty_tykind_usage.rs b/tests/ui-fulldeps/internal-lints/ty_tykind_usage.rs index 3f7429a5f..ae7f341fe 100644 --- a/tests/ui-fulldeps/internal-lints/ty_tykind_usage.rs +++ b/tests/ui-fulldeps/internal-lints/ty_tykind_usage.rs @@ -29,8 +29,8 @@ fn main() { TyKind::FnPtr(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` TyKind::Dynamic(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` TyKind::Closure(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` - TyKind::Generator(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` - TyKind::GeneratorWitness(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` + TyKind::Coroutine(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` + TyKind::CoroutineWitness(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` TyKind::Never => (), //~ ERROR usage of `ty::TyKind::<kind>` TyKind::Tuple(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` TyKind::Alias(..) => (), //~ ERROR usage of `ty::TyKind::<kind>` diff --git a/tests/ui-fulldeps/internal-lints/ty_tykind_usage.stderr b/tests/ui-fulldeps/internal-lints/ty_tykind_usage.stderr index 1f49d6b64..45b7c26fa 100644 --- a/tests/ui-fulldeps/internal-lints/ty_tykind_usage.stderr +++ b/tests/ui-fulldeps/internal-lints/ty_tykind_usage.stderr @@ -109,13 +109,13 @@ LL | TyKind::Closure(..) => (), error: usage of `ty::TyKind::<kind>` --> $DIR/ty_tykind_usage.rs:32:9 | -LL | TyKind::Generator(..) => (), +LL | TyKind::Coroutine(..) => (), | ^^^^^^ help: try using `ty::<kind>` directly: `ty` error: usage of `ty::TyKind::<kind>` --> $DIR/ty_tykind_usage.rs:33:9 | -LL | TyKind::GeneratorWitness(..) => (), +LL | TyKind::CoroutineWitness(..) => (), | ^^^^^^ help: try using `ty::<kind>` directly: `ty` error: usage of `ty::TyKind::<kind>` diff --git a/tests/ui-fulldeps/plugin/auxiliary/empty-plugin.rs b/tests/ui-fulldeps/plugin/auxiliary/empty-plugin.rs deleted file mode 100644 index c24cdc97a..000000000 --- a/tests/ui-fulldeps/plugin/auxiliary/empty-plugin.rs +++ /dev/null @@ -1,9 +0,0 @@ -// force-host - -#![feature(rustc_private)] - -extern crate rustc_driver; -use rustc_driver::plugin::Registry; - -#[no_mangle] -fn __rustc_plugin_registrar(_: &mut Registry) {} diff --git a/tests/ui-fulldeps/plugin/auxiliary/issue-40001-plugin.rs b/tests/ui-fulldeps/plugin/auxiliary/issue-40001-plugin.rs deleted file mode 100644 index 3f6caecaa..000000000 --- a/tests/ui-fulldeps/plugin/auxiliary/issue-40001-plugin.rs +++ /dev/null @@ -1,61 +0,0 @@ -#![feature(plugin, rustc_private)] -#![crate_type = "dylib"] - -extern crate rustc_ast_pretty; -extern crate rustc_driver; -extern crate rustc_hir; -extern crate rustc_lint; -#[macro_use] -extern crate rustc_session; -extern crate rustc_ast; -extern crate rustc_span; - -use rustc_ast_pretty::pprust; -use rustc_driver::plugin::Registry; -use rustc_hir as hir; -use rustc_hir::intravisit; -use rustc_hir::Node; -use rustc_lint::{LateContext, LateLintPass, LintContext}; -use rustc_span::def_id::LocalDefId; -use rustc_span::source_map; - -#[no_mangle] -fn __rustc_plugin_registrar(reg: &mut Registry) { - reg.lint_store.register_lints(&[&MISSING_ALLOWED_ATTR]); - reg.lint_store.register_late_pass(|_| Box::new(MissingAllowedAttrPass)); -} - -declare_lint! { - MISSING_ALLOWED_ATTR, - Deny, - "Checks for missing `allowed_attr` attribute" -} - -declare_lint_pass!(MissingAllowedAttrPass => [MISSING_ALLOWED_ATTR]); - -impl<'tcx> LateLintPass<'tcx> for MissingAllowedAttrPass { - fn check_fn( - &mut self, - cx: &LateContext<'tcx>, - _: intravisit::FnKind<'tcx>, - _: &'tcx hir::FnDecl, - _: &'tcx hir::Body, - span: source_map::Span, - def_id: LocalDefId, - ) { - let id = cx.tcx.hir().local_def_id_to_hir_id(def_id); - let item = match cx.tcx.hir().get(id) { - Node::Item(item) => item, - _ => cx.tcx.hir().expect_item(cx.tcx.hir().get_parent_item(id).def_id), - }; - - let allowed = |attr| pprust::attribute_to_string(attr).contains("allowed_attr"); - if !cx.tcx.hir().attrs(item.hir_id()).iter().any(allowed) { - cx.lint( - MISSING_ALLOWED_ATTR, - "Missing 'allowed_attr' attribute", - |lint| lint.set_span(span) - ); - } - } -} diff --git a/tests/ui-fulldeps/plugin/auxiliary/lint-for-crate.rs b/tests/ui-fulldeps/plugin/auxiliary/lint-for-crate.rs deleted file mode 100644 index 6304c07d2..000000000 --- a/tests/ui-fulldeps/plugin/auxiliary/lint-for-crate.rs +++ /dev/null @@ -1,43 +0,0 @@ -// force-host - -#![feature(rustc_private)] - -extern crate rustc_driver; -extern crate rustc_hir; -extern crate rustc_lint; -#[macro_use] -extern crate rustc_session; -extern crate rustc_ast; -extern crate rustc_span; - -use rustc_ast::attr; -use rustc_driver::plugin::Registry; -use rustc_lint::{LateContext, LateLintPass, LintContext}; -use rustc_span::def_id::CRATE_DEF_ID; -use rustc_span::symbol::Symbol; - -declare_lint! { - CRATE_NOT_OKAY, - Warn, - "crate not marked with #![crate_okay]" -} - -declare_lint_pass!(Pass => [CRATE_NOT_OKAY]); - -impl<'tcx> LateLintPass<'tcx> for Pass { - fn check_crate(&mut self, cx: &LateContext) { - let attrs = cx.tcx.hir().attrs(rustc_hir::CRATE_HIR_ID); - let span = cx.tcx.def_span(CRATE_DEF_ID); - if !attr::contains_name(attrs, Symbol::intern("crate_okay")) { - cx.lint(CRATE_NOT_OKAY, "crate is not marked with #![crate_okay]", |lint| { - lint.set_span(span) - }); - } - } -} - -#[no_mangle] -fn __rustc_plugin_registrar(reg: &mut Registry) { - reg.lint_store.register_lints(&[&CRATE_NOT_OKAY]); - reg.lint_store.register_late_pass(|_| Box::new(Pass)); -} diff --git a/tests/ui-fulldeps/plugin/auxiliary/lint-group-plugin-test.rs b/tests/ui-fulldeps/plugin/auxiliary/lint-group-plugin-test.rs deleted file mode 100644 index 150f0c6b9..000000000 --- a/tests/ui-fulldeps/plugin/auxiliary/lint-group-plugin-test.rs +++ /dev/null @@ -1,43 +0,0 @@ -// force-host - -#![feature(rustc_private)] - -// Load rustc as a plugin to get macros. -extern crate rustc_driver; -extern crate rustc_hir; -extern crate rustc_lint; -#[macro_use] -extern crate rustc_session; - -use rustc_driver::plugin::Registry; -use rustc_lint::{LateContext, LateLintPass, LintContext, LintId}; - -declare_lint!(TEST_LINT, Warn, "Warn about items named 'lintme'"); - -declare_lint!(PLEASE_LINT, Warn, "Warn about items named 'pleaselintme'"); - -declare_lint_pass!(Pass => [TEST_LINT, PLEASE_LINT]); - -impl<'tcx> LateLintPass<'tcx> for Pass { - fn check_item(&mut self, cx: &LateContext, it: &rustc_hir::Item) { - match it.ident.as_str() { - "lintme" => cx.lint(TEST_LINT, "item is named 'lintme'", |lint| lint.set_span(it.span)), - "pleaselintme" => { - cx.lint(PLEASE_LINT, "item is named 'pleaselintme'", |lint| lint.set_span(it.span)) - } - _ => {} - } - } -} - -#[no_mangle] -fn __rustc_plugin_registrar(reg: &mut Registry) { - reg.lint_store.register_lints(&[&TEST_LINT, &PLEASE_LINT]); - reg.lint_store.register_late_pass(|_| Box::new(Pass)); - reg.lint_store.register_group( - true, - "lint_me", - None, - vec![LintId::of(&TEST_LINT), LintId::of(&PLEASE_LINT)], - ); -} diff --git a/tests/ui-fulldeps/plugin/auxiliary/lint-plugin-test.rs b/tests/ui-fulldeps/plugin/auxiliary/lint-plugin-test.rs deleted file mode 100644 index acc5fe760..000000000 --- a/tests/ui-fulldeps/plugin/auxiliary/lint-plugin-test.rs +++ /dev/null @@ -1,33 +0,0 @@ -// force-host - -#![feature(rustc_private)] - -extern crate rustc_ast; - -// Load rustc as a plugin to get macros -extern crate rustc_driver; -extern crate rustc_lint; -#[macro_use] -extern crate rustc_session; - -use rustc_ast::ast; -use rustc_driver::plugin::Registry; -use rustc_lint::{EarlyContext, EarlyLintPass, LintContext}; - -declare_lint!(TEST_LINT, Warn, "Warn about items named 'lintme'"); - -declare_lint_pass!(Pass => [TEST_LINT]); - -impl EarlyLintPass for Pass { - fn check_item(&mut self, cx: &EarlyContext, it: &ast::Item) { - if it.ident.name.as_str() == "lintme" { - cx.lint(TEST_LINT, "item is named 'lintme'", |lint| lint.set_span(it.span)); - } - } -} - -#[no_mangle] -fn __rustc_plugin_registrar(reg: &mut Registry) { - reg.lint_store.register_lints(&[&TEST_LINT]); - reg.lint_store.register_early_pass(|| Box::new(Pass)); -} diff --git a/tests/ui-fulldeps/plugin/auxiliary/lint-tool-test.rs b/tests/ui-fulldeps/plugin/auxiliary/lint-tool-test.rs deleted file mode 100644 index 21de4aa70..000000000 --- a/tests/ui-fulldeps/plugin/auxiliary/lint-tool-test.rs +++ /dev/null @@ -1,52 +0,0 @@ -#![feature(rustc_private)] - -extern crate rustc_ast; - -// Load rustc as a plugin to get macros -extern crate rustc_driver; -extern crate rustc_lint; -#[macro_use] -extern crate rustc_session; - -use rustc_ast as ast; -use rustc_driver::plugin::Registry; -use rustc_lint::{EarlyContext, EarlyLintPass, LintContext, LintId}; - -declare_tool_lint!(pub clippy::TEST_LINT, Warn, "Warn about stuff"); -declare_tool_lint!( - /// Some docs - pub clippy::TEST_GROUP, - Warn, "Warn about other stuff" -); - -declare_tool_lint!( - /// Some docs - pub rustc::TEST_RUSTC_TOOL_LINT, - Deny, - "Deny internal stuff" -); - -declare_lint_pass!(Pass => [TEST_LINT, TEST_GROUP, TEST_RUSTC_TOOL_LINT]); - -impl EarlyLintPass for Pass { - fn check_item(&mut self, cx: &EarlyContext, it: &ast::Item) { - if it.ident.name.as_str() == "lintme" { - cx.lint(TEST_LINT, "item is named 'lintme'", |lint| lint.set_span(it.span)); - } - if it.ident.name.as_str() == "lintmetoo" { - cx.lint(TEST_GROUP, "item is named 'lintmetoo'", |lint| lint.set_span(it.span)); - } - } -} - -#[no_mangle] -fn __rustc_plugin_registrar(reg: &mut Registry) { - reg.lint_store.register_lints(&[&TEST_RUSTC_TOOL_LINT, &TEST_LINT, &TEST_GROUP]); - reg.lint_store.register_early_pass(|| Box::new(Pass)); - reg.lint_store.register_group( - true, - "clippy::group", - Some("clippy_group"), - vec![LintId::of(&TEST_LINT), LintId::of(&TEST_GROUP)], - ); -} diff --git a/tests/ui-fulldeps/plugin/auxiliary/lto-syntax-extension-lib.rs b/tests/ui-fulldeps/plugin/auxiliary/lto-syntax-extension-lib.rs deleted file mode 100644 index 954a1e554..000000000 --- a/tests/ui-fulldeps/plugin/auxiliary/lto-syntax-extension-lib.rs +++ /dev/null @@ -1,5 +0,0 @@ -// no-prefer-dynamic - -#![crate_type = "rlib"] - -pub fn foo() {} diff --git a/tests/ui-fulldeps/plugin/auxiliary/lto-syntax-extension-plugin.rs b/tests/ui-fulldeps/plugin/auxiliary/lto-syntax-extension-plugin.rs deleted file mode 100644 index 9b075c1a5..000000000 --- a/tests/ui-fulldeps/plugin/auxiliary/lto-syntax-extension-plugin.rs +++ /dev/null @@ -1,11 +0,0 @@ -// force-host - -#![feature(rustc_private)] - -extern crate rustc_middle; -extern crate rustc_driver; - -use rustc_driver::plugin::Registry; - -#[no_mangle] -fn __rustc_plugin_registrar(_reg: &mut Registry) {} diff --git a/tests/ui-fulldeps/plugin/auxiliary/multiple-plugins-1.rs b/tests/ui-fulldeps/plugin/auxiliary/multiple-plugins-1.rs deleted file mode 100644 index fd6e9e20f..000000000 --- a/tests/ui-fulldeps/plugin/auxiliary/multiple-plugins-1.rs +++ /dev/null @@ -1,10 +0,0 @@ -#![crate_type = "dylib"] -#![feature(rustc_private)] - -extern crate rustc_middle; -extern crate rustc_driver; - -use rustc_driver::plugin::Registry; - -#[no_mangle] -fn __rustc_plugin_registrar(_: &mut Registry) {} diff --git a/tests/ui-fulldeps/plugin/auxiliary/multiple-plugins-2.rs b/tests/ui-fulldeps/plugin/auxiliary/multiple-plugins-2.rs deleted file mode 100644 index fd6e9e20f..000000000 --- a/tests/ui-fulldeps/plugin/auxiliary/multiple-plugins-2.rs +++ /dev/null @@ -1,10 +0,0 @@ -#![crate_type = "dylib"] -#![feature(rustc_private)] - -extern crate rustc_middle; -extern crate rustc_driver; - -use rustc_driver::plugin::Registry; - -#[no_mangle] -fn __rustc_plugin_registrar(_: &mut Registry) {} diff --git a/tests/ui-fulldeps/plugin/auxiliary/outlive-expansion-phase.rs b/tests/ui-fulldeps/plugin/auxiliary/outlive-expansion-phase.rs deleted file mode 100644 index e83dfe804..000000000 --- a/tests/ui-fulldeps/plugin/auxiliary/outlive-expansion-phase.rs +++ /dev/null @@ -1,24 +0,0 @@ -// force-host - -#![feature(rustc_private)] - -extern crate rustc_middle; -extern crate rustc_driver; - -use std::any::Any; -use std::cell::RefCell; -use rustc_driver::plugin::Registry; - -struct Foo { - foo: isize -} - -impl Drop for Foo { - fn drop(&mut self) {} -} - -#[no_mangle] -fn __rustc_plugin_registrar(_: &mut Registry) { - thread_local!(static FOO: RefCell<Option<Box<Any+Send>>> = RefCell::new(None)); - FOO.with(|s| *s.borrow_mut() = Some(Box::new(Foo { foo: 10 }) as Box<Any+Send>)); -} diff --git a/tests/ui-fulldeps/plugin/auxiliary/rlib-crate-test.rs b/tests/ui-fulldeps/plugin/auxiliary/rlib-crate-test.rs deleted file mode 100644 index 3ba73538e..000000000 --- a/tests/ui-fulldeps/plugin/auxiliary/rlib-crate-test.rs +++ /dev/null @@ -1,12 +0,0 @@ -// no-prefer-dynamic - -#![crate_type = "rlib"] -#![feature(rustc_private)] - -extern crate rustc_middle; -extern crate rustc_driver; - -use rustc_driver::plugin::Registry; - -#[no_mangle] -fn __rustc_plugin_registrar(_: &mut Registry) {} diff --git a/tests/ui-fulldeps/plugin/feature-gate-plugin.rs b/tests/ui-fulldeps/plugin/feature-gate-plugin.rs deleted file mode 100644 index 85eaf5336..000000000 --- a/tests/ui-fulldeps/plugin/feature-gate-plugin.rs +++ /dev/null @@ -1,8 +0,0 @@ -// aux-build:empty-plugin.rs -// ignore-stage1 - -#![plugin(empty_plugin)] -//~^ ERROR compiler plugins are deprecated -//~| WARN use of deprecated attribute `plugin`: compiler plugins are deprecated - -fn main() {} diff --git a/tests/ui-fulldeps/plugin/feature-gate-plugin.stderr b/tests/ui-fulldeps/plugin/feature-gate-plugin.stderr deleted file mode 100644 index 5e40561c7..000000000 --- a/tests/ui-fulldeps/plugin/feature-gate-plugin.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error[E0658]: compiler plugins are deprecated - --> $DIR/feature-gate-plugin.rs:4:1 - | -LL | #![plugin(empty_plugin)] - | ^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #29597 <https://github.com/rust-lang/rust/issues/29597> for more information - = help: add `#![feature(plugin)]` to the crate attributes to enable - -warning: use of deprecated attribute `plugin`: compiler plugins are deprecated. See https://github.com/rust-lang/rust/pull/64675 - --> $DIR/feature-gate-plugin.rs:4:1 - | -LL | #![plugin(empty_plugin)] - | ^^^^^^^^^^^^^^^^^^^^^^^^ help: may be removed in a future compiler version - | - = note: `#[warn(deprecated)]` on by default - -error: aborting due to previous error; 1 warning emitted - -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui-fulldeps/plugin/gated-plugin.rs b/tests/ui-fulldeps/plugin/gated-plugin.rs deleted file mode 100644 index 85eaf5336..000000000 --- a/tests/ui-fulldeps/plugin/gated-plugin.rs +++ /dev/null @@ -1,8 +0,0 @@ -// aux-build:empty-plugin.rs -// ignore-stage1 - -#![plugin(empty_plugin)] -//~^ ERROR compiler plugins are deprecated -//~| WARN use of deprecated attribute `plugin`: compiler plugins are deprecated - -fn main() {} diff --git a/tests/ui-fulldeps/plugin/gated-plugin.stderr b/tests/ui-fulldeps/plugin/gated-plugin.stderr deleted file mode 100644 index f48f1eab6..000000000 --- a/tests/ui-fulldeps/plugin/gated-plugin.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error[E0658]: compiler plugins are deprecated - --> $DIR/gated-plugin.rs:4:1 - | -LL | #![plugin(empty_plugin)] - | ^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #29597 <https://github.com/rust-lang/rust/issues/29597> for more information - = help: add `#![feature(plugin)]` to the crate attributes to enable - -warning: use of deprecated attribute `plugin`: compiler plugins are deprecated. See https://github.com/rust-lang/rust/pull/64675 - --> $DIR/gated-plugin.rs:4:1 - | -LL | #![plugin(empty_plugin)] - | ^^^^^^^^^^^^^^^^^^^^^^^^ help: may be removed in a future compiler version - | - = note: `#[warn(deprecated)]` on by default - -error: aborting due to previous error; 1 warning emitted - -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui-fulldeps/plugin/issue-15778-fail.rs b/tests/ui-fulldeps/plugin/issue-15778-fail.rs deleted file mode 100644 index beecaadf9..000000000 --- a/tests/ui-fulldeps/plugin/issue-15778-fail.rs +++ /dev/null @@ -1,9 +0,0 @@ -// aux-build:lint-for-crate.rs -// ignore-stage1 -// compile-flags: -D crate-not-okay - -#![feature(plugin)] //~ ERROR crate is not marked with #![crate_okay] -#![plugin(lint_for_crate)] -//~^ WARN use of deprecated attribute `plugin` - -pub fn main() { } diff --git a/tests/ui-fulldeps/plugin/issue-15778-fail.stderr b/tests/ui-fulldeps/plugin/issue-15778-fail.stderr deleted file mode 100644 index a37893e12..000000000 --- a/tests/ui-fulldeps/plugin/issue-15778-fail.stderr +++ /dev/null @@ -1,22 +0,0 @@ -warning: use of deprecated attribute `plugin`: compiler plugins are deprecated. See https://github.com/rust-lang/rust/pull/64675 - --> $DIR/issue-15778-fail.rs:6:1 - | -LL | #![plugin(lint_for_crate)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: may be removed in a future compiler version - | - = note: `#[warn(deprecated)]` on by default - -error: crate is not marked with #![crate_okay] - --> $DIR/issue-15778-fail.rs:5:1 - | -LL | / #![feature(plugin)] -LL | | #![plugin(lint_for_crate)] -LL | | -LL | | -LL | | pub fn main() { } - | |_________________^ - | - = note: requested on the command line with `-D crate-not-okay` - -error: aborting due to previous error; 1 warning emitted - diff --git a/tests/ui-fulldeps/plugin/issue-40001.rs b/tests/ui-fulldeps/plugin/issue-40001.rs deleted file mode 100644 index e14338fdb..000000000 --- a/tests/ui-fulldeps/plugin/issue-40001.rs +++ /dev/null @@ -1,10 +0,0 @@ -// run-pass -// aux-build:issue-40001-plugin.rs -// ignore-stage1 - -#![feature(plugin, register_tool)] -#![plugin(issue_40001_plugin)] //~ WARNING compiler plugins are deprecated -#![register_tool(plugin)] - -#[plugin::allowed_attr] -fn main() {} diff --git a/tests/ui-fulldeps/plugin/issue-40001.stderr b/tests/ui-fulldeps/plugin/issue-40001.stderr deleted file mode 100644 index 73ec06924..000000000 --- a/tests/ui-fulldeps/plugin/issue-40001.stderr +++ /dev/null @@ -1,10 +0,0 @@ -warning: use of deprecated attribute `plugin`: compiler plugins are deprecated. See https://github.com/rust-lang/rust/pull/64675 - --> $DIR/issue-40001.rs:6:1 - | -LL | #![plugin(issue_40001_plugin)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: may be removed in a future compiler version - | - = note: `#[warn(deprecated)]` on by default - -warning: 1 warning emitted - diff --git a/tests/ui-fulldeps/plugin/lint-group-plugin-deny-cmdline.rs b/tests/ui-fulldeps/plugin/lint-group-plugin-deny-cmdline.rs deleted file mode 100644 index 9f8a87960..000000000 --- a/tests/ui-fulldeps/plugin/lint-group-plugin-deny-cmdline.rs +++ /dev/null @@ -1,17 +0,0 @@ -// aux-build:lint-group-plugin-test.rs -// ignore-stage1 -// compile-flags: -D lint-me - -#![feature(plugin)] - -#![plugin(lint_group_plugin_test)] -//~^ WARN use of deprecated attribute `plugin` - -fn lintme() { } //~ ERROR item is named 'lintme' - -fn pleaselintme() { } //~ ERROR item is named 'pleaselintme' - -pub fn main() { - lintme(); - pleaselintme(); -} diff --git a/tests/ui-fulldeps/plugin/lint-group-plugin-deny-cmdline.stderr b/tests/ui-fulldeps/plugin/lint-group-plugin-deny-cmdline.stderr deleted file mode 100644 index 6e17bbde0..000000000 --- a/tests/ui-fulldeps/plugin/lint-group-plugin-deny-cmdline.stderr +++ /dev/null @@ -1,28 +0,0 @@ -warning: use of deprecated attribute `plugin`: compiler plugins are deprecated. See https://github.com/rust-lang/rust/pull/64675 - --> $DIR/lint-group-plugin-deny-cmdline.rs:7:1 - | -LL | #![plugin(lint_group_plugin_test)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: may be removed in a future compiler version - | - = note: `#[warn(deprecated)]` on by default - -error: item is named 'lintme' - --> $DIR/lint-group-plugin-deny-cmdline.rs:10:1 - | -LL | fn lintme() { } - | ^^^^^^^^^^^^^^^ - | - = note: `-D test-lint` implied by `-D lint-me` - = help: to override `-D lint-me` add `#[allow(test_lint)]` - -error: item is named 'pleaselintme' - --> $DIR/lint-group-plugin-deny-cmdline.rs:12:1 - | -LL | fn pleaselintme() { } - | ^^^^^^^^^^^^^^^^^^^^^ - | - = note: `-D please-lint` implied by `-D lint-me` - = help: to override `-D lint-me` add `#[allow(please_lint)]` - -error: aborting due to 2 previous errors; 1 warning emitted - diff --git a/tests/ui-fulldeps/plugin/lint-group-plugin.rs b/tests/ui-fulldeps/plugin/lint-group-plugin.rs deleted file mode 100644 index 7b74be7a9..000000000 --- a/tests/ui-fulldeps/plugin/lint-group-plugin.rs +++ /dev/null @@ -1,17 +0,0 @@ -// run-pass -// aux-build:lint-group-plugin-test.rs -// ignore-stage1 - -#![feature(plugin)] -#![plugin(lint_group_plugin_test)] //~ WARNING use of deprecated attribute -#![allow(dead_code)] - -fn lintme() { } //~ WARNING item is named 'lintme' -fn pleaselintme() { } //~ WARNING item is named 'pleaselintme' - -#[allow(lint_me)] -pub fn main() { - fn lintme() { } - - fn pleaselintme() { } -} diff --git a/tests/ui-fulldeps/plugin/lint-group-plugin.stderr b/tests/ui-fulldeps/plugin/lint-group-plugin.stderr deleted file mode 100644 index 6f429dad0..000000000 --- a/tests/ui-fulldeps/plugin/lint-group-plugin.stderr +++ /dev/null @@ -1,26 +0,0 @@ -warning: use of deprecated attribute `plugin`: compiler plugins are deprecated. See https://github.com/rust-lang/rust/pull/64675 - --> $DIR/lint-group-plugin.rs:6:1 - | -LL | #![plugin(lint_group_plugin_test)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: may be removed in a future compiler version - | - = note: `#[warn(deprecated)]` on by default - -warning: item is named 'lintme' - --> $DIR/lint-group-plugin.rs:9:1 - | -LL | fn lintme() { } - | ^^^^^^^^^^^^^^^ - | - = note: `#[warn(test_lint)]` on by default - -warning: item is named 'pleaselintme' - --> $DIR/lint-group-plugin.rs:10:1 - | -LL | fn pleaselintme() { } - | ^^^^^^^^^^^^^^^^^^^^^ - | - = note: `#[warn(please_lint)]` on by default - -warning: 3 warnings emitted - diff --git a/tests/ui-fulldeps/plugin/lint-plugin-cmdline-allow.rs b/tests/ui-fulldeps/plugin/lint-plugin-cmdline-allow.rs deleted file mode 100644 index 1cc16e2fd..000000000 --- a/tests/ui-fulldeps/plugin/lint-plugin-cmdline-allow.rs +++ /dev/null @@ -1,12 +0,0 @@ -// check-pass -// aux-build:lint-plugin-test.rs -// ignore-stage1 -// compile-flags: -A test-lint - -#![feature(plugin)] -#![plugin(lint_plugin_test)] //~ WARNING compiler plugins are deprecated - -fn lintme() { } - -pub fn main() { -} diff --git a/tests/ui-fulldeps/plugin/lint-plugin-cmdline-allow.stderr b/tests/ui-fulldeps/plugin/lint-plugin-cmdline-allow.stderr deleted file mode 100644 index f06703a27..000000000 --- a/tests/ui-fulldeps/plugin/lint-plugin-cmdline-allow.stderr +++ /dev/null @@ -1,10 +0,0 @@ -warning: use of deprecated attribute `plugin`: compiler plugins are deprecated. See https://github.com/rust-lang/rust/pull/64675 - --> $DIR/lint-plugin-cmdline-allow.rs:7:1 - | -LL | #![plugin(lint_plugin_test)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: may be removed in a future compiler version - | - = note: `#[warn(deprecated)]` on by default - -warning: 1 warning emitted - diff --git a/tests/ui-fulldeps/plugin/lint-plugin-cmdline-load.rs b/tests/ui-fulldeps/plugin/lint-plugin-cmdline-load.rs deleted file mode 100644 index 0bd95dfbd..000000000 --- a/tests/ui-fulldeps/plugin/lint-plugin-cmdline-load.rs +++ /dev/null @@ -1,13 +0,0 @@ -// check-pass -// aux-build:lint-plugin-test.rs -// ignore-stage1 -// compile-flags: -Z crate-attr=plugin(lint_plugin_test) - -#![feature(plugin)] - -fn lintme() { } //~ WARNING item is named 'lintme' - -#[allow(test_lint)] -pub fn main() { - fn lintme() { } -} diff --git a/tests/ui-fulldeps/plugin/lint-plugin-cmdline-load.stderr b/tests/ui-fulldeps/plugin/lint-plugin-cmdline-load.stderr deleted file mode 100644 index 82679c9e1..000000000 --- a/tests/ui-fulldeps/plugin/lint-plugin-cmdline-load.stderr +++ /dev/null @@ -1,18 +0,0 @@ -warning: item is named 'lintme' - --> $DIR/lint-plugin-cmdline-load.rs:8:1 - | -LL | fn lintme() { } - | ^^^^^^^^^^^^^^^ - | - = note: `#[warn(test_lint)]` on by default - -warning: use of deprecated attribute `plugin`: compiler plugins are deprecated. See https://github.com/rust-lang/rust/pull/64675 - --> <crate attribute>:1:1 - | -LL | plugin(lint_plugin_test) - | ^^^^^^^^^^^^^^^^^^^^^^^^ help: may be removed in a future compiler version - | - = note: `#[warn(deprecated)]` on by default - -warning: 2 warnings emitted - diff --git a/tests/ui-fulldeps/plugin/lint-plugin-deny-attr.rs b/tests/ui-fulldeps/plugin/lint-plugin-deny-attr.rs deleted file mode 100644 index 04230a8e8..000000000 --- a/tests/ui-fulldeps/plugin/lint-plugin-deny-attr.rs +++ /dev/null @@ -1,13 +0,0 @@ -// aux-build:lint-plugin-test.rs -// ignore-stage1 - -#![feature(plugin)] -#![plugin(lint_plugin_test)] -//~^ WARN use of deprecated attribute `plugin` -#![deny(test_lint)] - -fn lintme() { } //~ ERROR item is named 'lintme' - -pub fn main() { - lintme(); -} diff --git a/tests/ui-fulldeps/plugin/lint-plugin-deny-attr.stderr b/tests/ui-fulldeps/plugin/lint-plugin-deny-attr.stderr deleted file mode 100644 index 5e8891bf1..000000000 --- a/tests/ui-fulldeps/plugin/lint-plugin-deny-attr.stderr +++ /dev/null @@ -1,22 +0,0 @@ -error: item is named 'lintme' - --> $DIR/lint-plugin-deny-attr.rs:9:1 - | -LL | fn lintme() { } - | ^^^^^^^^^^^^^^^ - | -note: the lint level is defined here - --> $DIR/lint-plugin-deny-attr.rs:7:9 - | -LL | #![deny(test_lint)] - | ^^^^^^^^^ - -warning: use of deprecated attribute `plugin`: compiler plugins are deprecated. See https://github.com/rust-lang/rust/pull/64675 - --> $DIR/lint-plugin-deny-attr.rs:5:1 - | -LL | #![plugin(lint_plugin_test)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: may be removed in a future compiler version - | - = note: `#[warn(deprecated)]` on by default - -error: aborting due to previous error; 1 warning emitted - diff --git a/tests/ui-fulldeps/plugin/lint-plugin-deny-cmdline.rs b/tests/ui-fulldeps/plugin/lint-plugin-deny-cmdline.rs deleted file mode 100644 index c460cfd5f..000000000 --- a/tests/ui-fulldeps/plugin/lint-plugin-deny-cmdline.rs +++ /dev/null @@ -1,13 +0,0 @@ -// aux-build:lint-plugin-test.rs -// ignore-stage1 -// compile-flags: -D test-lint - -#![feature(plugin)] -#![plugin(lint_plugin_test)] -//~^ WARN use of deprecated attribute `plugin` - -fn lintme() { } //~ ERROR item is named 'lintme' - -pub fn main() { - lintme(); -} diff --git a/tests/ui-fulldeps/plugin/lint-plugin-deny-cmdline.stderr b/tests/ui-fulldeps/plugin/lint-plugin-deny-cmdline.stderr deleted file mode 100644 index d5d6b5352..000000000 --- a/tests/ui-fulldeps/plugin/lint-plugin-deny-cmdline.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error: item is named 'lintme' - --> $DIR/lint-plugin-deny-cmdline.rs:9:1 - | -LL | fn lintme() { } - | ^^^^^^^^^^^^^^^ - | - = note: requested on the command line with `-D test-lint` - -warning: use of deprecated attribute `plugin`: compiler plugins are deprecated. See https://github.com/rust-lang/rust/pull/64675 - --> $DIR/lint-plugin-deny-cmdline.rs:6:1 - | -LL | #![plugin(lint_plugin_test)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: may be removed in a future compiler version - | - = note: `#[warn(deprecated)]` on by default - -error: aborting due to previous error; 1 warning emitted - diff --git a/tests/ui-fulldeps/plugin/lint-plugin-forbid-attrs.rs b/tests/ui-fulldeps/plugin/lint-plugin-forbid-attrs.rs deleted file mode 100644 index cf31b3ec1..000000000 --- a/tests/ui-fulldeps/plugin/lint-plugin-forbid-attrs.rs +++ /dev/null @@ -1,16 +0,0 @@ -// aux-build:lint-plugin-test.rs -// ignore-stage1 - -#![feature(plugin)] -#![plugin(lint_plugin_test)] -//~^ WARN use of deprecated attribute `plugin` -#![forbid(test_lint)] - -fn lintme() {} //~ ERROR item is named 'lintme' - -#[allow(test_lint)] -//~^ ERROR allow(test_lint) incompatible -//~| ERROR allow(test_lint) incompatible -pub fn main() { - lintme(); -} diff --git a/tests/ui-fulldeps/plugin/lint-plugin-forbid-attrs.stderr b/tests/ui-fulldeps/plugin/lint-plugin-forbid-attrs.stderr deleted file mode 100644 index ae34b25cc..000000000 --- a/tests/ui-fulldeps/plugin/lint-plugin-forbid-attrs.stderr +++ /dev/null @@ -1,41 +0,0 @@ -error[E0453]: allow(test_lint) incompatible with previous forbid - --> $DIR/lint-plugin-forbid-attrs.rs:11:9 - | -LL | #![forbid(test_lint)] - | --------- `forbid` level set here -... -LL | #[allow(test_lint)] - | ^^^^^^^^^ overruled by previous forbid - -error: item is named 'lintme' - --> $DIR/lint-plugin-forbid-attrs.rs:9:1 - | -LL | fn lintme() {} - | ^^^^^^^^^^^^^^ - | -note: the lint level is defined here - --> $DIR/lint-plugin-forbid-attrs.rs:7:11 - | -LL | #![forbid(test_lint)] - | ^^^^^^^^^ - -error[E0453]: allow(test_lint) incompatible with previous forbid - --> $DIR/lint-plugin-forbid-attrs.rs:11:9 - | -LL | #![forbid(test_lint)] - | --------- `forbid` level set here -... -LL | #[allow(test_lint)] - | ^^^^^^^^^ overruled by previous forbid - -warning: use of deprecated attribute `plugin`: compiler plugins are deprecated. See https://github.com/rust-lang/rust/pull/64675 - --> $DIR/lint-plugin-forbid-attrs.rs:5:1 - | -LL | #![plugin(lint_plugin_test)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: may be removed in a future compiler version - | - = note: `#[warn(deprecated)]` on by default - -error: aborting due to 3 previous errors; 1 warning emitted - -For more information about this error, try `rustc --explain E0453`. diff --git a/tests/ui-fulldeps/plugin/lint-plugin-forbid-cmdline.rs b/tests/ui-fulldeps/plugin/lint-plugin-forbid-cmdline.rs deleted file mode 100644 index b9d1aa85a..000000000 --- a/tests/ui-fulldeps/plugin/lint-plugin-forbid-cmdline.rs +++ /dev/null @@ -1,15 +0,0 @@ -// aux-build:lint-plugin-test.rs -// ignore-stage1 -// compile-flags: -F test-lint - -#![feature(plugin)] -#![plugin(lint_plugin_test)] -//~^ WARN use of deprecated attribute `plugin` -fn lintme() { } //~ ERROR item is named 'lintme' - -#[allow(test_lint)] //~ ERROR allow(test_lint) incompatible - //~| ERROR allow(test_lint) incompatible - -pub fn main() { - lintme(); -} diff --git a/tests/ui-fulldeps/plugin/lint-plugin-forbid-cmdline.stderr b/tests/ui-fulldeps/plugin/lint-plugin-forbid-cmdline.stderr deleted file mode 100644 index 491c4d206..000000000 --- a/tests/ui-fulldeps/plugin/lint-plugin-forbid-cmdline.stderr +++ /dev/null @@ -1,35 +0,0 @@ -error[E0453]: allow(test_lint) incompatible with previous forbid - --> $DIR/lint-plugin-forbid-cmdline.rs:10:9 - | -LL | #[allow(test_lint)] - | ^^^^^^^^^ overruled by previous forbid - | - = note: `forbid` lint level was set on command line - -error: item is named 'lintme' - --> $DIR/lint-plugin-forbid-cmdline.rs:8:1 - | -LL | fn lintme() { } - | ^^^^^^^^^^^^^^^ - | - = note: requested on the command line with `-F test-lint` - -error[E0453]: allow(test_lint) incompatible with previous forbid - --> $DIR/lint-plugin-forbid-cmdline.rs:10:9 - | -LL | #[allow(test_lint)] - | ^^^^^^^^^ overruled by previous forbid - | - = note: `forbid` lint level was set on command line - -warning: use of deprecated attribute `plugin`: compiler plugins are deprecated. See https://github.com/rust-lang/rust/pull/64675 - --> $DIR/lint-plugin-forbid-cmdline.rs:6:1 - | -LL | #![plugin(lint_plugin_test)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: may be removed in a future compiler version - | - = note: `#[warn(deprecated)]` on by default - -error: aborting due to 3 previous errors; 1 warning emitted - -For more information about this error, try `rustc --explain E0453`. diff --git a/tests/ui-fulldeps/plugin/lint-plugin.rs b/tests/ui-fulldeps/plugin/lint-plugin.rs deleted file mode 100644 index 66057eea6..000000000 --- a/tests/ui-fulldeps/plugin/lint-plugin.rs +++ /dev/null @@ -1,13 +0,0 @@ -// run-pass -// aux-build:lint-plugin-test.rs -// ignore-stage1 -#![feature(plugin)] -#![plugin(lint_plugin_test)] //~ WARNING use of deprecated attribute -#![allow(dead_code)] - -fn lintme() { } //~ WARNING item is named 'lintme' - -#[allow(test_lint)] -pub fn main() { - fn lintme() { } -} diff --git a/tests/ui-fulldeps/plugin/lint-plugin.stderr b/tests/ui-fulldeps/plugin/lint-plugin.stderr deleted file mode 100644 index dd5d3d72e..000000000 --- a/tests/ui-fulldeps/plugin/lint-plugin.stderr +++ /dev/null @@ -1,18 +0,0 @@ -warning: item is named 'lintme' - --> $DIR/lint-plugin.rs:8:1 - | -LL | fn lintme() { } - | ^^^^^^^^^^^^^^^ - | - = note: `#[warn(test_lint)]` on by default - -warning: use of deprecated attribute `plugin`: compiler plugins are deprecated. See https://github.com/rust-lang/rust/pull/64675 - --> $DIR/lint-plugin.rs:5:1 - | -LL | #![plugin(lint_plugin_test)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: may be removed in a future compiler version - | - = note: `#[warn(deprecated)]` on by default - -warning: 2 warnings emitted - diff --git a/tests/ui-fulldeps/plugin/lint-tool-cmdline-allow.rs b/tests/ui-fulldeps/plugin/lint-tool-cmdline-allow.rs deleted file mode 100644 index 83a8b3e1a..000000000 --- a/tests/ui-fulldeps/plugin/lint-tool-cmdline-allow.rs +++ /dev/null @@ -1,12 +0,0 @@ -// check-pass -// aux-build:lint-tool-test.rs -// ignore-stage1 -// compile-flags: -A test-lint - -#![feature(plugin)] -#![plugin(lint_tool_test)] //~ WARNING compiler plugins are deprecated - -fn lintme() {} -//~^ WARNING item is named 'lintme' [clippy::test_lint] - -pub fn main() {} diff --git a/tests/ui-fulldeps/plugin/lint-tool-cmdline-allow.stderr b/tests/ui-fulldeps/plugin/lint-tool-cmdline-allow.stderr deleted file mode 100644 index 0e6617959..000000000 --- a/tests/ui-fulldeps/plugin/lint-tool-cmdline-allow.stderr +++ /dev/null @@ -1,34 +0,0 @@ -warning: lint name `test_lint` is deprecated and may not have an effect in the future. - | - = help: change it to clippy::test_lint - = note: requested on the command line with `-A test_lint` - = note: `#[warn(renamed_and_removed_lints)]` on by default - -warning: lint name `test_lint` is deprecated and may not have an effect in the future. - | - = help: change it to clippy::test_lint - = note: requested on the command line with `-A test_lint` - -warning: item is named 'lintme' - --> $DIR/lint-tool-cmdline-allow.rs:9:1 - | -LL | fn lintme() {} - | ^^^^^^^^^^^^^^ - | - = note: `#[warn(clippy::test_lint)]` on by default - -warning: use of deprecated attribute `plugin`: compiler plugins are deprecated. See https://github.com/rust-lang/rust/pull/64675 - --> $DIR/lint-tool-cmdline-allow.rs:7:1 - | -LL | #![plugin(lint_tool_test)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: may be removed in a future compiler version - | - = note: `#[warn(deprecated)]` on by default - -warning: lint name `test_lint` is deprecated and may not have an effect in the future. - | - = help: change it to clippy::test_lint - = note: requested on the command line with `-A test_lint` - -warning: 5 warnings emitted - diff --git a/tests/ui-fulldeps/plugin/lint-tool-test.rs b/tests/ui-fulldeps/plugin/lint-tool-test.rs deleted file mode 100644 index f92bcd213..000000000 --- a/tests/ui-fulldeps/plugin/lint-tool-test.rs +++ /dev/null @@ -1,36 +0,0 @@ -// aux-build:lint-tool-test.rs -// ignore-stage1 -// compile-flags: --cfg foo - -#![feature(plugin)] -#![plugin(lint_tool_test)] -//~^ WARN use of deprecated attribute `plugin` -#![allow(dead_code)] -#![cfg_attr(foo, warn(test_lint))] -//~^ WARNING lint name `test_lint` is deprecated and may not have an effect in the future -//~| WARNING lint name `test_lint` is deprecated and may not have an effect in the future -//~| WARNING lint name `test_lint` is deprecated and may not have an effect in the future -#![deny(clippy_group)] -//~^ WARNING lint name `clippy_group` is deprecated and may not have an effect in the future -//~| WARNING lint name `clippy_group` is deprecated and may not have an effect in the future -//~| WARNING lint name `clippy_group` is deprecated and may not have an effect in the future - -fn lintme() { } //~ ERROR item is named 'lintme' - -#[allow(clippy::group)] -fn lintmetoo() {} - -#[allow(clippy::test_lint)] -pub fn main() { - fn lintme() { } - fn lintmetoo() { } //~ ERROR item is named 'lintmetoo' -} - -#[allow(test_group)] -//~^ WARNING lint name `test_group` is deprecated and may not have an effect in the future -//~| WARNING lint name `test_group` is deprecated and may not have an effect in the future -//~| WARNING lint name `test_group` is deprecated and may not have an effect in the future -#[deny(this_lint_does_not_exist)] //~ WARNING unknown lint: `this_lint_does_not_exist` -fn hello() { - fn lintmetoo() { } -} diff --git a/tests/ui-fulldeps/plugin/lint-tool-test.stderr b/tests/ui-fulldeps/plugin/lint-tool-test.stderr deleted file mode 100644 index 027cf8f80..000000000 --- a/tests/ui-fulldeps/plugin/lint-tool-test.stderr +++ /dev/null @@ -1,95 +0,0 @@ -warning: lint name `test_lint` is deprecated and may not have an effect in the future. - --> $DIR/lint-tool-test.rs:9:23 - | -LL | #![cfg_attr(foo, warn(test_lint))] - | ^^^^^^^^^ help: change it to: `clippy::test_lint` - | - = note: `#[warn(renamed_and_removed_lints)]` on by default - -warning: lint name `clippy_group` is deprecated and may not have an effect in the future. - --> $DIR/lint-tool-test.rs:13:9 - | -LL | #![deny(clippy_group)] - | ^^^^^^^^^^^^ help: change it to: `clippy::group` - -warning: lint name `test_group` is deprecated and may not have an effect in the future. - --> $DIR/lint-tool-test.rs:29:9 - | -LL | #[allow(test_group)] - | ^^^^^^^^^^ help: change it to: `clippy::test_group` - -warning: lint name `test_lint` is deprecated and may not have an effect in the future. - --> $DIR/lint-tool-test.rs:9:23 - | -LL | #![cfg_attr(foo, warn(test_lint))] - | ^^^^^^^^^ help: change it to: `clippy::test_lint` - -warning: lint name `clippy_group` is deprecated and may not have an effect in the future. - --> $DIR/lint-tool-test.rs:13:9 - | -LL | #![deny(clippy_group)] - | ^^^^^^^^^^^^ help: change it to: `clippy::group` - -error: item is named 'lintme' - --> $DIR/lint-tool-test.rs:18:1 - | -LL | fn lintme() { } - | ^^^^^^^^^^^^^^^ - | -note: the lint level is defined here - --> $DIR/lint-tool-test.rs:13:9 - | -LL | #![deny(clippy_group)] - | ^^^^^^^^^^^^ - = note: `#[deny(clippy::test_lint)]` implied by `#[deny(clippy::group)]` - -error: item is named 'lintmetoo' - --> $DIR/lint-tool-test.rs:26:5 - | -LL | fn lintmetoo() { } - | ^^^^^^^^^^^^^^^^^^ - | - = note: `#[deny(clippy::test_group)]` implied by `#[deny(clippy::group)]` - -warning: lint name `test_group` is deprecated and may not have an effect in the future. - --> $DIR/lint-tool-test.rs:29:9 - | -LL | #[allow(test_group)] - | ^^^^^^^^^^ help: change it to: `clippy::test_group` - -warning: unknown lint: `this_lint_does_not_exist` - --> $DIR/lint-tool-test.rs:33:8 - | -LL | #[deny(this_lint_does_not_exist)] - | ^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: `#[warn(unknown_lints)]` on by default - -warning: use of deprecated attribute `plugin`: compiler plugins are deprecated. See https://github.com/rust-lang/rust/pull/64675 - --> $DIR/lint-tool-test.rs:6:1 - | -LL | #![plugin(lint_tool_test)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: may be removed in a future compiler version - | - = note: `#[warn(deprecated)]` on by default - -warning: lint name `test_lint` is deprecated and may not have an effect in the future. - --> $DIR/lint-tool-test.rs:9:23 - | -LL | #![cfg_attr(foo, warn(test_lint))] - | ^^^^^^^^^ help: change it to: `clippy::test_lint` - -warning: lint name `clippy_group` is deprecated and may not have an effect in the future. - --> $DIR/lint-tool-test.rs:13:9 - | -LL | #![deny(clippy_group)] - | ^^^^^^^^^^^^ help: change it to: `clippy::group` - -warning: lint name `test_group` is deprecated and may not have an effect in the future. - --> $DIR/lint-tool-test.rs:29:9 - | -LL | #[allow(test_group)] - | ^^^^^^^^^^ help: change it to: `clippy::test_group` - -error: aborting due to 2 previous errors; 11 warnings emitted - diff --git a/tests/ui-fulldeps/plugin/lto-syntax-extension.rs b/tests/ui-fulldeps/plugin/lto-syntax-extension.rs deleted file mode 100644 index 5964e70f1..000000000 --- a/tests/ui-fulldeps/plugin/lto-syntax-extension.rs +++ /dev/null @@ -1,15 +0,0 @@ -// run-pass -// aux-build:lto-syntax-extension-lib.rs -// aux-build:lto-syntax-extension-plugin.rs -// compile-flags:-C lto -// ignore-stage1 -// no-prefer-dynamic - -#![feature(plugin)] -#![plugin(lto_syntax_extension_plugin)] //~ WARNING compiler plugins are deprecated - -extern crate lto_syntax_extension_lib; - -fn main() { - lto_syntax_extension_lib::foo(); -} diff --git a/tests/ui-fulldeps/plugin/lto-syntax-extension.stderr b/tests/ui-fulldeps/plugin/lto-syntax-extension.stderr deleted file mode 100644 index 555493f32..000000000 --- a/tests/ui-fulldeps/plugin/lto-syntax-extension.stderr +++ /dev/null @@ -1,10 +0,0 @@ -warning: use of deprecated attribute `plugin`: compiler plugins are deprecated. See https://github.com/rust-lang/rust/pull/64675 - --> $DIR/lto-syntax-extension.rs:9:1 - | -LL | #![plugin(lto_syntax_extension_plugin)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: may be removed in a future compiler version - | - = note: `#[warn(deprecated)]` on by default - -warning: 1 warning emitted - diff --git a/tests/ui-fulldeps/plugin/macro-crate-rlib.rs b/tests/ui-fulldeps/plugin/macro-crate-rlib.rs deleted file mode 100644 index 38bd34053..000000000 --- a/tests/ui-fulldeps/plugin/macro-crate-rlib.rs +++ /dev/null @@ -1,9 +0,0 @@ -// aux-build:rlib-crate-test.rs -// ignore-stage1 -// ignore-cross-compile gives a different error message - -#![feature(plugin)] -#![plugin(rlib_crate_test)] -//~^ ERROR: plugin `rlib_crate_test` only found in rlib format, but must be available in dylib - -fn main() {} diff --git a/tests/ui-fulldeps/plugin/macro-crate-rlib.stderr b/tests/ui-fulldeps/plugin/macro-crate-rlib.stderr deleted file mode 100644 index 0651cee56..000000000 --- a/tests/ui-fulldeps/plugin/macro-crate-rlib.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0457]: plugin `rlib_crate_test` only found in rlib format, but must be available in dylib format - --> $DIR/macro-crate-rlib.rs:6:11 - | -LL | #![plugin(rlib_crate_test)] - | ^^^^^^^^^^^^^^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0457`. diff --git a/tests/ui-fulldeps/plugin/multiple-plugins.rs b/tests/ui-fulldeps/plugin/multiple-plugins.rs deleted file mode 100644 index 9af3ebd57..000000000 --- a/tests/ui-fulldeps/plugin/multiple-plugins.rs +++ /dev/null @@ -1,12 +0,0 @@ -// run-pass -// aux-build:multiple-plugins-1.rs -// aux-build:multiple-plugins-2.rs -// ignore-stage1 - -// Check that the plugin registrar of multiple plugins doesn't conflict - -#![feature(plugin)] -#![plugin(multiple_plugins_1)] //~ WARN use of deprecated attribute `plugin` -#![plugin(multiple_plugins_2)] //~ WARN use of deprecated attribute `plugin` - -fn main() {} diff --git a/tests/ui-fulldeps/plugin/multiple-plugins.stderr b/tests/ui-fulldeps/plugin/multiple-plugins.stderr deleted file mode 100644 index 878ffabfc..000000000 --- a/tests/ui-fulldeps/plugin/multiple-plugins.stderr +++ /dev/null @@ -1,16 +0,0 @@ -warning: use of deprecated attribute `plugin`: compiler plugins are deprecated. See https://github.com/rust-lang/rust/pull/64675 - --> $DIR/multiple-plugins.rs:9:1 - | -LL | #![plugin(multiple_plugins_1)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: may be removed in a future compiler version - | - = note: `#[warn(deprecated)]` on by default - -warning: use of deprecated attribute `plugin`: compiler plugins are deprecated. See https://github.com/rust-lang/rust/pull/64675 - --> $DIR/multiple-plugins.rs:10:1 - | -LL | #![plugin(multiple_plugins_2)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: may be removed in a future compiler version - -warning: 2 warnings emitted - diff --git a/tests/ui-fulldeps/plugin/outlive-expansion-phase.rs b/tests/ui-fulldeps/plugin/outlive-expansion-phase.rs deleted file mode 100644 index fb22888d9..000000000 --- a/tests/ui-fulldeps/plugin/outlive-expansion-phase.rs +++ /dev/null @@ -1,8 +0,0 @@ -// run-pass -// aux-build:outlive-expansion-phase.rs -// ignore-stage1 - -#![feature(plugin)] -#![plugin(outlive_expansion_phase)] //~ WARNING compiler plugins are deprecated - -pub fn main() {} diff --git a/tests/ui-fulldeps/plugin/outlive-expansion-phase.stderr b/tests/ui-fulldeps/plugin/outlive-expansion-phase.stderr deleted file mode 100644 index e40a08ae7..000000000 --- a/tests/ui-fulldeps/plugin/outlive-expansion-phase.stderr +++ /dev/null @@ -1,10 +0,0 @@ -warning: use of deprecated attribute `plugin`: compiler plugins are deprecated. See https://github.com/rust-lang/rust/pull/64675 - --> $DIR/outlive-expansion-phase.rs:6:1 - | -LL | #![plugin(outlive_expansion_phase)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: may be removed in a future compiler version - | - = note: `#[warn(deprecated)]` on by default - -warning: 1 warning emitted - diff --git a/tests/ui-fulldeps/plugin/plugin-args.rs b/tests/ui-fulldeps/plugin/plugin-args.rs deleted file mode 100644 index 488f2b775..000000000 --- a/tests/ui-fulldeps/plugin/plugin-args.rs +++ /dev/null @@ -1,9 +0,0 @@ -// aux-build:empty-plugin.rs -// ignore-stage1 - -#![feature(plugin)] -#![plugin(empty_plugin(args))] -//~^ ERROR malformed `plugin` attribute -//~| WARNING compiler plugins are deprecated - -fn main() {} diff --git a/tests/ui-fulldeps/plugin/plugin-args.stderr b/tests/ui-fulldeps/plugin/plugin-args.stderr deleted file mode 100644 index 177f33005..000000000 --- a/tests/ui-fulldeps/plugin/plugin-args.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0498]: malformed `plugin` attribute - --> $DIR/plugin-args.rs:5:11 - | -LL | #![plugin(empty_plugin(args))] - | ^^^^^^^^^^^^^^^^^^ malformed attribute - -warning: use of deprecated attribute `plugin`: compiler plugins are deprecated. See https://github.com/rust-lang/rust/pull/64675 - --> $DIR/plugin-args.rs:5:1 - | -LL | #![plugin(empty_plugin(args))] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: may be removed in a future compiler version - | - = note: `#[warn(deprecated)]` on by default - -error: aborting due to previous error; 1 warning emitted - -For more information about this error, try `rustc --explain E0498`. diff --git a/tests/ui-fulldeps/plugin/plugin-as-extern-crate.rs b/tests/ui-fulldeps/plugin/plugin-as-extern-crate.rs deleted file mode 100644 index 4d26e08d8..000000000 --- a/tests/ui-fulldeps/plugin/plugin-as-extern-crate.rs +++ /dev/null @@ -1,10 +0,0 @@ -// check-pass -// aux-build:empty-plugin.rs -// ignore-cross-compile -// -// empty_plugin will not compile on a cross-compiled target because -// librustc_ast is not compiled for it. - -extern crate empty_plugin; // OK, plugin crates are still crates - -fn main() {} diff --git a/tests/ui-fulldeps/pprust-expr-roundtrip.rs b/tests/ui-fulldeps/pprust-expr-roundtrip.rs index 541be7ebb..685a029dc 100644 --- a/tests/ui-fulldeps/pprust-expr-roundtrip.rs +++ b/tests/ui-fulldeps/pprust-expr-roundtrip.rs @@ -38,9 +38,9 @@ use rustc_ast::*; use rustc_ast_pretty::pprust; use rustc_parse::new_parser_from_source_str; use rustc_session::parse::ParseSess; -use rustc_span::source_map::FilePathMapping; -use rustc_span::source_map::{FileName, Spanned, DUMMY_SP}; +use rustc_span::source_map::{FilePathMapping, Spanned}; use rustc_span::symbol::Ident; +use rustc_span::{FileName, DUMMY_SP}; use thin_vec::{thin_vec, ThinVec}; fn parse_expr(ps: &ParseSess, src: &str) -> Option<P<Expr>> { @@ -130,7 +130,7 @@ fn iter_exprs(depth: usize, f: &mut dyn FnMut(P<Expr>)) { iter_exprs(depth - 1, &mut |e| { g(ExprKind::Closure(Box::new(Closure { binder: ClosureBinder::NotPresent, - capture_clause: CaptureBy::Value, + capture_clause: CaptureBy::Value { move_kw: DUMMY_SP }, constness: Const::No, asyncness: Async::No, movability: Movability::Movable, diff --git a/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr b/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr index ca09f1f01..014cd5a73 100644 --- a/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr +++ b/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr @@ -414,6 +414,8 @@ error: `#[lint(...)]` is not a valid attribute | LL | #[lint(no_crate_example, code = "E0123")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: diagnostic slug not specified --> $DIR/diagnostic-derive.rs:601:1 diff --git a/tests/ui-fulldeps/stable-mir/check_instance.rs b/tests/ui-fulldeps/stable-mir/check_instance.rs new file mode 100644 index 000000000..a34087775 --- /dev/null +++ b/tests/ui-fulldeps/stable-mir/check_instance.rs @@ -0,0 +1,122 @@ +// run-pass +//! Test that users are able to use stable mir APIs to retrieve monomorphized instances + +// ignore-stage1 +// ignore-cross-compile +// ignore-remote +// ignore-windows-gnu mingw has troubles with linking https://github.com/rust-lang/rust/pull/116837 +// edition: 2021 + +#![feature(rustc_private)] +#![feature(assert_matches)] +#![feature(control_flow_enum)] + +extern crate rustc_middle; +#[macro_use] +extern crate rustc_smir; +extern crate rustc_driver; +extern crate rustc_interface; +extern crate stable_mir; + +use mir::{mono::Instance, TerminatorKind::*}; +use rustc_middle::ty::TyCtxt; +use rustc_smir::rustc_internal; +use stable_mir::ty::{RigidTy, TyKind}; +use stable_mir::*; +use std::io::Write; +use std::ops::ControlFlow; + +const CRATE_NAME: &str = "input"; + +/// This function uses the Stable MIR APIs to get information about the test crate. +fn test_stable_mir(_tcx: TyCtxt<'_>) -> ControlFlow<()> { + let items = stable_mir::all_local_items(); + + // Get all items and split generic vs monomorphic items. + let (generic, mono): (Vec<_>, Vec<_>) = + items.into_iter().partition(|item| item.requires_monomorphization()); + assert_eq!(mono.len(), 3, "Expected 2 mono functions and one constant"); + assert_eq!(generic.len(), 2, "Expected 2 generic functions"); + + // For all monomorphic items, get the correspondent instances. + let instances = mono + .iter() + .filter_map(|item| mir::mono::Instance::try_from(*item).ok()) + .collect::<Vec<mir::mono::Instance>>(); + assert_eq!(instances.len(), mono.len()); + + // For all generic items, try_from should fail. + assert!(generic.iter().all(|item| mir::mono::Instance::try_from(*item).is_err())); + + for instance in instances { + test_body(instance.body()) + } + ControlFlow::Continue(()) +} + +/// Inspect the instance body +fn test_body(body: mir::Body) { + for term in body.blocks.iter().map(|bb| &bb.terminator) { + match &term.kind { + Call { func, .. } => { + let TyKind::RigidTy(ty) = func.ty(body.locals()).kind() else { unreachable!() }; + let RigidTy::FnDef(def, args) = ty else { unreachable!() }; + let result = Instance::resolve(def, &args); + assert!(result.is_ok()); + } + Goto { .. } | Assert { .. } | SwitchInt { .. } | Return | Drop { .. } => { + /* Do nothing */ + } + _ => { + unreachable!("Unexpected terminator {term:?}") + } + } + } +} + +/// This test will generate and analyze a dummy crate using the stable mir. +/// For that, it will first write the dummy crate into a file. +/// Then it will create a `StableMir` using custom arguments and then +/// it will run the compiler. +fn main() { + let path = "instance_input.rs"; + generate_input(&path).unwrap(); + let args = vec![ + "rustc".to_string(), + "-Cpanic=abort".to_string(), + "--crate-type=lib".to_string(), + "--crate-name".to_string(), + CRATE_NAME.to_string(), + path.to_string(), + ]; + run!(args, tcx, test_stable_mir(tcx)).unwrap(); +} + +fn generate_input(path: &str) -> std::io::Result<()> { + let mut file = std::fs::File::create(path)?; + write!( + file, + r#" + pub fn ty_param<T>(t: &T) -> T where T: Clone {{ + t.clone() + }} + + pub fn const_param<const LEN: usize>(a: [bool; LEN]) -> bool {{ + LEN > 0 && a[0] + }} + + pub fn monomorphic() {{ + let v = vec![10]; + let dup = ty_param(&v); + assert_eq!(v, dup); + }} + + pub mod foo {{ + pub fn bar_mono(i: i32) -> i64 {{ + i as i64 + }} + }} + "# + )?; + Ok(()) +} diff --git a/tests/ui-fulldeps/stable-mir/compilation-result.rs b/tests/ui-fulldeps/stable-mir/compilation-result.rs index 3ec1519fb..fc56e2481 100644 --- a/tests/ui-fulldeps/stable-mir/compilation-result.rs +++ b/tests/ui-fulldeps/stable-mir/compilation-result.rs @@ -4,19 +4,22 @@ // ignore-stage1 // ignore-cross-compile // ignore-remote +// ignore-windows-gnu mingw has troubles with linking https://github.com/rust-lang/rust/pull/116837 // edition: 2021 #![feature(rustc_private)] #![feature(assert_matches)] extern crate rustc_middle; +#[macro_use] extern crate rustc_smir; +extern crate rustc_driver; +extern crate rustc_interface; extern crate stable_mir; use rustc_middle::ty::TyCtxt; use rustc_smir::rustc_internal; use std::io::Write; -use std::ops::ControlFlow; /// This test will generate and analyze a dummy crate using the stable mir. /// For that, it will first write the dummy crate into a file. @@ -33,28 +36,26 @@ fn main() { } fn test_continue(args: Vec<String>) { - let continue_fn = |_: TyCtxt| ControlFlow::Continue::<(), bool>(true); - let result = rustc_internal::StableMir::new(args, continue_fn).run(); + let result = run!(args, ControlFlow::Continue::<(), bool>(true)); assert_eq!(result, Ok(true)); } fn test_break(args: Vec<String>) { - let continue_fn = |_: TyCtxt| ControlFlow::Break::<bool, i32>(false); - let result = rustc_internal::StableMir::new(args, continue_fn).run(); + let result = run!(args, ControlFlow::Break::<bool, i32>(false)); assert_eq!(result, Err(stable_mir::CompilerError::Interrupted(false))); } +#[allow(unreachable_code)] fn test_skipped(mut args: Vec<String>) { args.push("--version".to_string()); - let unreach_fn = |_: TyCtxt| -> ControlFlow<()> { unreachable!() }; - let result = rustc_internal::StableMir::new(args, unreach_fn).run(); + let result = run!(args, unreachable!() as ControlFlow<()>); assert_eq!(result, Err(stable_mir::CompilerError::Skipped)); } +#[allow(unreachable_code)] fn test_failed(mut args: Vec<String>) { args.push("--cfg=broken".to_string()); - let unreach_fn = |_: TyCtxt| -> ControlFlow<()> { unreachable!() }; - let result = rustc_internal::StableMir::new(args, unreach_fn).run(); + let result = run!(args, unreachable!() as ControlFlow<()>); assert_eq!(result, Err(stable_mir::CompilerError::CompilationFailed)); } diff --git a/tests/ui-fulldeps/stable-mir/crate-info.rs b/tests/ui-fulldeps/stable-mir/crate-info.rs index ce4ee3c24..ed6b786f5 100644 --- a/tests/ui-fulldeps/stable-mir/crate-info.rs +++ b/tests/ui-fulldeps/stable-mir/crate-info.rs @@ -4,6 +4,7 @@ // ignore-stage1 // ignore-cross-compile // ignore-remote +// ignore-windows-gnu mingw has troubles with linking https://github.com/rust-lang/rust/pull/116837 // edition: 2021 #![feature(rustc_private)] @@ -12,14 +13,17 @@ extern crate rustc_hir; extern crate rustc_middle; +#[macro_use] extern crate rustc_smir; +extern crate rustc_driver; +extern crate rustc_interface; extern crate stable_mir; use rustc_hir::def::DefKind; use rustc_middle::ty::TyCtxt; use rustc_smir::rustc_internal; - -use stable_mir::fold::Foldable; +use stable_mir::mir::mono::Instance; +use stable_mir::ty::{RigidTy, TyKind}; use std::assert_matches::assert_matches; use std::io::Write; use std::ops::ControlFlow; @@ -38,59 +42,59 @@ fn test_stable_mir(_tcx: TyCtxt<'_>) -> ControlFlow<()> { let items = stable_mir::all_local_items(); assert!(get_item(&items, (DefKind::Fn, "foo::bar")).is_some()); - // Find the `std` crate. - assert!(stable_mir::find_crate("std").is_some()); + // Find the `std` crate and assert that there is only one of it. + assert!(stable_mir::find_crates("std").len() == 1); let bar = get_item(&items, (DefKind::Fn, "bar")).unwrap(); let body = bar.body(); - assert_eq!(body.locals.len(), 2); + assert_eq!(body.locals().len(), 2); assert_eq!(body.blocks.len(), 1); let block = &body.blocks[0]; assert_eq!(block.statements.len(), 1); - match &block.statements[0] { - stable_mir::mir::Statement::Assign(..) => {} + match &block.statements[0].kind { + stable_mir::mir::StatementKind::Assign(..) => {} other => panic!("{other:?}"), } - match &block.terminator { - stable_mir::mir::Terminator::Return => {} + match &block.terminator.kind { + stable_mir::mir::TerminatorKind::Return => {} other => panic!("{other:?}"), } let foo_bar = get_item(&items, (DefKind::Fn, "foo_bar")).unwrap(); let body = foo_bar.body(); - assert_eq!(body.locals.len(), 7); + assert_eq!(body.locals().len(), 5); assert_eq!(body.blocks.len(), 4); let block = &body.blocks[0]; - match &block.terminator { - stable_mir::mir::Terminator::Call { .. } => {} + match &block.terminator.kind { + stable_mir::mir::TerminatorKind::Call { .. } => {} other => panic!("{other:?}"), } let types = get_item(&items, (DefKind::Fn, "types")).unwrap(); let body = types.body(); - assert_eq!(body.locals.len(), 6); + assert_eq!(body.locals().len(), 6); assert_matches!( - body.locals[0].kind(), + body.locals()[0].ty.kind(), stable_mir::ty::TyKind::RigidTy(stable_mir::ty::RigidTy::Bool) ); assert_matches!( - body.locals[1].kind(), + body.locals()[1].ty.kind(), stable_mir::ty::TyKind::RigidTy(stable_mir::ty::RigidTy::Bool) ); assert_matches!( - body.locals[2].kind(), + body.locals()[2].ty.kind(), stable_mir::ty::TyKind::RigidTy(stable_mir::ty::RigidTy::Char) ); assert_matches!( - body.locals[3].kind(), + body.locals()[3].ty.kind(), stable_mir::ty::TyKind::RigidTy(stable_mir::ty::RigidTy::Int(stable_mir::ty::IntTy::I32)) ); assert_matches!( - body.locals[4].kind(), + body.locals()[4].ty.kind(), stable_mir::ty::TyKind::RigidTy(stable_mir::ty::RigidTy::Uint(stable_mir::ty::UintTy::U64)) ); assert_matches!( - body.locals[5].kind(), + body.locals()[5].ty.kind(), stable_mir::ty::TyKind::RigidTy(stable_mir::ty::RigidTy::Float( stable_mir::ty::FloatTy::F64 )) @@ -100,8 +104,8 @@ fn test_stable_mir(_tcx: TyCtxt<'_>) -> ControlFlow<()> { let body = drop.body(); assert_eq!(body.blocks.len(), 2); let block = &body.blocks[0]; - match &block.terminator { - stable_mir::mir::Terminator::Drop { .. } => {} + match &block.terminator.kind { + stable_mir::mir::TerminatorKind::Drop { .. } => {} other => panic!("{other:?}"), } @@ -109,47 +113,25 @@ fn test_stable_mir(_tcx: TyCtxt<'_>) -> ControlFlow<()> { let body = assert.body(); assert_eq!(body.blocks.len(), 2); let block = &body.blocks[0]; - match &block.terminator { - stable_mir::mir::Terminator::Assert { .. } => {} + match &block.terminator.kind { + stable_mir::mir::TerminatorKind::Assert { .. } => {} other => panic!("{other:?}"), } let monomorphic = get_item(&items, (DefKind::Fn, "monomorphic")).unwrap(); - for block in monomorphic.body().blocks { - match &block.terminator { - stable_mir::mir::Terminator::Call { func, .. } => match func { - stable_mir::mir::Operand::Constant(c) => match &c.literal.literal { - stable_mir::ty::ConstantKind::Allocated(alloc) => { - assert!(alloc.bytes.is_empty()); - match c.literal.ty.kind() { - stable_mir::ty::TyKind::RigidTy(stable_mir::ty::RigidTy::FnDef( - def, - mut args, - )) => { - let func = def.body(); - match func.locals[1] - .fold(&mut args) - .continue_value() - .unwrap() - .kind() - { - stable_mir::ty::TyKind::RigidTy( - stable_mir::ty::RigidTy::Uint(_), - ) => {} - stable_mir::ty::TyKind::RigidTy( - stable_mir::ty::RigidTy::Tuple(_), - ) => {} - other => panic!("{other:?}"), - } - } - other => panic!("{other:?}"), - } - } + let instance = Instance::try_from(monomorphic.clone()).unwrap(); + for block in instance.body().blocks { + match &block.terminator.kind { + stable_mir::mir::TerminatorKind::Call { func, .. } => { + let TyKind::RigidTy(ty) = func.ty(&body.locals()).kind() else { unreachable!() }; + let RigidTy::FnDef(def, args) = ty else { unreachable!() }; + let next_func = Instance::resolve(def, &args).unwrap(); + match next_func.body().locals()[1].ty.kind() { + TyKind::RigidTy(RigidTy::Uint(_)) | TyKind::RigidTy(RigidTy::Tuple(_)) => {} other => panic!("{other:?}"), - }, - other => panic!("{other:?}"), - }, - stable_mir::mir::Terminator::Return => {} + } + } + stable_mir::mir::TerminatorKind::Return => {} other => panic!("{other:?}"), } } @@ -158,6 +140,29 @@ fn test_stable_mir(_tcx: TyCtxt<'_>) -> ControlFlow<()> { // Ensure we don't panic trying to get the body of a constant. foo_const.body(); + let locals_fn = get_item(&items, (DefKind::Fn, "locals")).unwrap(); + let body = locals_fn.body(); + assert_eq!(body.locals().len(), 4); + assert_matches!( + body.ret_local().ty.kind(), + stable_mir::ty::TyKind::RigidTy(stable_mir::ty::RigidTy::Char) + ); + assert_eq!(body.arg_locals().len(), 2); + assert_matches!( + body.arg_locals()[0].ty.kind(), + stable_mir::ty::TyKind::RigidTy(stable_mir::ty::RigidTy::Int(stable_mir::ty::IntTy::I32)) + ); + assert_matches!( + body.arg_locals()[1].ty.kind(), + stable_mir::ty::TyKind::RigidTy(stable_mir::ty::RigidTy::Uint(stable_mir::ty::UintTy::U64)) + ); + assert_eq!(body.inner_locals().len(), 1); + // If conditions have an extra inner local to hold their results + assert_matches!( + body.inner_locals()[0].ty.kind(), + stable_mir::ty::TyKind::RigidTy(stable_mir::ty::RigidTy::Bool) + ); + ControlFlow::Continue(()) } @@ -185,7 +190,7 @@ fn main() { CRATE_NAME.to_string(), path.to_string(), ]; - rustc_internal::StableMir::new(args, test_stable_mir).run().unwrap(); + run!(args, tcx, test_stable_mir(tcx)).unwrap(); } fn generate_input(path: &str) -> std::io::Result<()> { @@ -229,6 +234,14 @@ fn generate_input(path: &str) -> std::io::Result<()> { pub fn assert(x: i32) -> i32 {{ x + 1 + }} + + pub fn locals(a: i32, _: u64) -> char {{ + if a > 5 {{ + 'a' + }} else {{ + 'b' + }} }}"# )?; Ok(()) diff --git a/tests/ui-fulldeps/stable-mir/smir_internal.rs b/tests/ui-fulldeps/stable-mir/smir_internal.rs new file mode 100644 index 000000000..b0596b188 --- /dev/null +++ b/tests/ui-fulldeps/stable-mir/smir_internal.rs @@ -0,0 +1,64 @@ +// run-pass +//! Test that users are able to use retrieve internal constructs from stable ones to help with +//! the migration. + +// ignore-stage1 +// ignore-cross-compile +// ignore-remote +// ignore-windows-gnu mingw has troubles with linking https://github.com/rust-lang/rust/pull/116837 +// edition: 2021 + +#![feature(rustc_private)] +#![feature(assert_matches)] +#![feature(control_flow_enum)] + +#[macro_use] +extern crate rustc_smir; +extern crate rustc_driver; +extern crate rustc_interface; +extern crate rustc_middle; +extern crate stable_mir; + +use rustc_middle::ty::TyCtxt; +use rustc_smir::rustc_internal; +use std::io::Write; +use std::ops::ControlFlow; + +const CRATE_NAME: &str = "input"; + +fn test_translation(_tcx: TyCtxt<'_>) -> ControlFlow<()> { + let main_fn = stable_mir::entry_fn().unwrap(); + let body = main_fn.body(); + let orig_ty = body.locals()[0].ty; + let rustc_ty = rustc_internal::internal(&orig_ty); + assert!(rustc_ty.is_unit()); + ControlFlow::Continue(()) +} + +/// This test will generate and analyze a dummy crate using the stable mir. +/// For that, it will first write the dummy crate into a file. +/// Then it will create a `StableMir` using custom arguments and then +/// it will run the compiler. +fn main() { + let path = "internal_input.rs"; + generate_input(&path).unwrap(); + let args = vec![ + "rustc".to_string(), + "--crate-name".to_string(), + CRATE_NAME.to_string(), + path.to_string(), + ]; + run!(args, tcx, test_translation(tcx)).unwrap(); +} + +fn generate_input(path: &str) -> std::io::Result<()> { + let mut file = std::fs::File::create(path)?; + write!( + file, + r#" + pub fn main() {{ + }} + "# + )?; + Ok(()) +} diff --git a/tests/ui-fulldeps/stable-mir/smir_visitor.rs b/tests/ui-fulldeps/stable-mir/smir_visitor.rs new file mode 100644 index 000000000..de5148bb5 --- /dev/null +++ b/tests/ui-fulldeps/stable-mir/smir_visitor.rs @@ -0,0 +1,148 @@ +// run-pass +//! Sanity check Stable MIR Visitor + +// ignore-stage1 +// ignore-cross-compile +// ignore-remote +// ignore-windows-gnu mingw has troubles with linking https://github.com/rust-lang/rust/pull/116837 +// edition: 2021 + +#![feature(rustc_private)] +#![feature(assert_matches)] +#![feature(control_flow_enum)] + +extern crate rustc_middle; +#[macro_use] +extern crate rustc_smir; +extern crate rustc_driver; +extern crate rustc_interface; +extern crate stable_mir; + +use std::collections::HashSet; +use rustc_middle::ty::TyCtxt; +use rustc_smir::rustc_internal; +use stable_mir::*; +use stable_mir::mir::MirVisitor; +use std::io::Write; +use std::ops::ControlFlow; + +const CRATE_NAME: &str = "input"; + +fn test_visitor(_tcx: TyCtxt<'_>) -> ControlFlow<()> { + let main_fn = stable_mir::entry_fn(); + let main_body = main_fn.unwrap().body(); + let main_visitor = TestVisitor::collect(&main_body); + assert!(main_visitor.ret_val.is_some()); + assert!(main_visitor.args.is_empty()); + assert!(main_visitor.tys.contains(&main_visitor.ret_val.unwrap().ty)); + assert!(!main_visitor.calls.is_empty()); + + let exit_fn = main_visitor.calls.last().unwrap(); + assert!(exit_fn.mangled_name().contains("exit_fn"), "Unexpected last function: {exit_fn:?}"); + + let exit_body = exit_fn.body(); + let exit_visitor = TestVisitor::collect(&exit_body); + assert!(exit_visitor.ret_val.is_some()); + assert_eq!(exit_visitor.args.len(), 1); + assert!(exit_visitor.tys.contains(&exit_visitor.ret_val.unwrap().ty)); + assert!(exit_visitor.tys.contains(&exit_visitor.args[0].ty)); + ControlFlow::Continue(()) +} + +struct TestVisitor<'a> { + pub body: &'a mir::Body, + pub tys: HashSet<ty::Ty>, + pub ret_val: Option<mir::LocalDecl>, + pub args: Vec<mir::LocalDecl>, + pub calls: Vec<mir::mono::Instance> +} + +impl<'a> TestVisitor<'a> { + fn collect(body: &'a mir::Body) -> TestVisitor<'a> { + let mut visitor = TestVisitor { + body: &body, + tys: Default::default(), + ret_val: None, + args: vec![], + calls: vec![], + }; + visitor.visit_body(&body); + visitor + } +} + +impl<'a> mir::MirVisitor for TestVisitor<'a> { + fn visit_ty(&mut self, ty: &ty::Ty, _location: mir::visit::Location) { + self.tys.insert(*ty); + self.super_ty(ty) + } + + fn visit_ret_decl(&mut self, local: mir::Local, decl: &mir::LocalDecl) { + assert!(local == mir::RETURN_LOCAL); + assert!(self.ret_val.is_none()); + self.ret_val = Some(decl.clone()); + self.super_ret_decl(local, decl); + } + + fn visit_arg_decl(&mut self, local: mir::Local, decl: &mir::LocalDecl) { + self.args.push(decl.clone()); + assert_eq!(local, self.args.len()); + self.super_arg_decl(local, decl); + } + + fn visit_terminator(&mut self, term: &mir::Terminator, location: mir::visit::Location) { + if let mir::TerminatorKind::Call { func, .. } = &term.kind { + let ty::TyKind::RigidTy(ty) = func.ty(self.body.locals()).kind() else { unreachable! + () }; + let ty::RigidTy::FnDef(def, args) = ty else { unreachable!() }; + self.calls.push(mir::mono::Instance::resolve(def, &args).unwrap()); + } + self.super_terminator(term, location); + } +} + +/// This test will generate and analyze a dummy crate using the stable mir. +/// For that, it will first write the dummy crate into a file. +/// Then it will create a `StableMir` using custom arguments and then +/// it will run the compiler. +fn main() { + let path = "sim_visitor_input.rs"; + generate_input(&path).unwrap(); + let args = vec![ + "rustc".to_string(), + "-Cpanic=abort".to_string(), + "--crate-name".to_string(), + CRATE_NAME.to_string(), + path.to_string(), + ]; + run!(args, tcx, test_visitor(tcx)).unwrap(); +} + +fn generate_input(path: &str) -> std::io::Result<()> { + let mut file = std::fs::File::create(path)?; + write!( + file, + r#" + fn main() -> std::process::ExitCode {{ + let inputs = Inputs::new(); + let total = inputs.values.iter().sum(); + exit_fn(total) + }} + + fn exit_fn(code: u8) -> std::process::ExitCode {{ + std::process::ExitCode::from(code) + }} + + struct Inputs {{ + values: [u8; 3], + }} + + impl Inputs {{ + fn new() -> Inputs {{ + Inputs {{ values: [0, 1, 2] }} + }} + }} + "# + )?; + Ok(()) +} |