Skip to content

Commit

Permalink
rustc_lint: Remove lint plugin_as_library
Browse files Browse the repository at this point in the history
  • Loading branch information
petrochenkov committed Dec 1, 2019
1 parent db357a6 commit cf1ffb0
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 81 deletions.
12 changes: 0 additions & 12 deletions src/doc/rustc/src/lints/listing/warn-by-default.md
Expand Up @@ -307,18 +307,6 @@ warning: path statement with no effect
| |
``` ```


## plugin-as-library

This lint detects when compiler plugins are used as ordinary library in
non-plugin crate. Some example code that triggers this lint:

```rust,ignore
#![feature(plugin)]
#![plugin(macro_crate_test)]
extern crate macro_crate_test;
```

## private-in-public ## private-in-public


This lint detects private items in public interfaces not caught by the old implementation. Some This lint detects private items in public interfaces not caught by the old implementation. Some
Expand Down
3 changes: 1 addition & 2 deletions src/doc/unstable-book/src/language-features/plugin.md
Expand Up @@ -24,8 +24,7 @@ mechanics of defining and loading a plugin.
In the vast majority of cases, a plugin should *only* be used through In the vast majority of cases, a plugin should *only* be used through
`#![plugin]` and not through an `extern crate` item. Linking a plugin would `#![plugin]` and not through an `extern crate` item. Linking a plugin would
pull in all of libsyntax and librustc as dependencies of your crate. This is pull in all of libsyntax and librustc as dependencies of your crate. This is
generally unwanted unless you are building another plugin. The generally unwanted unless you are building another plugin.
`plugin_as_library` lint checks these guidelines.


The usual practice is to put compiler plugins in their own crate, separate from The usual practice is to put compiler plugins in their own crate, separate from
any `macro_rules!` macros or ordinary Rust code meant to be used by consumers any `macro_rules!` macros or ordinary Rust code meant to be used by consumers
Expand Down
42 changes: 1 addition & 41 deletions src/librustc_lint/builtin.rs
Expand Up @@ -24,7 +24,7 @@
use std::fmt::Write; use std::fmt::Write;


use rustc::hir::def::{Res, DefKind}; use rustc::hir::def::{Res, DefKind};
use rustc::hir::def_id::{DefId, LOCAL_CRATE}; use rustc::hir::def_id::DefId;
use rustc::ty::{self, Ty, TyCtxt, layout::VariantIdx}; use rustc::ty::{self, Ty, TyCtxt, layout::VariantIdx};
use rustc::{lint, util}; use rustc::{lint, util};
use rustc::lint::FutureIncompatibleInfo; use rustc::lint::FutureIncompatibleInfo;
Expand Down Expand Up @@ -800,45 +800,6 @@ impl EarlyLintPass for UnusedDocComment {
} }
} }


declare_lint! {
PLUGIN_AS_LIBRARY,
Warn,
"compiler plugin used as ordinary library in non-plugin crate"
}

declare_lint_pass!(PluginAsLibrary => [PLUGIN_AS_LIBRARY]);

impl<'a, 'tcx> LateLintPass<'a, 'tcx> for PluginAsLibrary {
fn check_item(&mut self, cx: &LateContext<'_, '_>, it: &hir::Item) {
if cx.tcx.plugin_registrar_fn(LOCAL_CRATE).is_some() {
// We're compiling a plugin; it's fine to link other plugins.
return;
}

match it.kind {
hir::ItemKind::ExternCrate(..) => (),
_ => return,
};

let def_id = cx.tcx.hir().local_def_id(it.hir_id);
let prfn = match cx.tcx.extern_mod_stmt_cnum(def_id) {
Some(cnum) => cx.tcx.plugin_registrar_fn(cnum),
None => {
// Probably means we aren't linking the crate for some reason.
//
// Not sure if / when this could happen.
return;
}
};

if prfn.is_some() {
cx.span_lint(PLUGIN_AS_LIBRARY,
it.span,
"compiler plugin used as an ordinary library");
}
}
}

declare_lint! { declare_lint! {
NO_MANGLE_CONST_ITEMS, NO_MANGLE_CONST_ITEMS,
Deny, Deny,
Expand Down Expand Up @@ -1268,7 +1229,6 @@ declare_lint_pass!(
MISSING_DEBUG_IMPLEMENTATIONS, MISSING_DEBUG_IMPLEMENTATIONS,
ANONYMOUS_PARAMETERS, ANONYMOUS_PARAMETERS,
UNUSED_DOC_COMMENTS, UNUSED_DOC_COMMENTS,
PLUGIN_AS_LIBRARY,
NO_MANGLE_CONST_ITEMS, NO_MANGLE_CONST_ITEMS,
NO_MANGLE_GENERIC_ITEMS, NO_MANGLE_GENERIC_ITEMS,
MUTABLE_TRANSMUTES, MUTABLE_TRANSMUTES,
Expand Down
3 changes: 1 addition & 2 deletions src/librustc_lint/lib.rs
Expand Up @@ -157,8 +157,6 @@ macro_rules! late_lint_mod_passes {
// Depends on types used in type definitions // Depends on types used in type definitions
MissingCopyImplementations: MissingCopyImplementations, MissingCopyImplementations: MissingCopyImplementations,


PluginAsLibrary: PluginAsLibrary,

// Depends on referenced function signatures in expressions // Depends on referenced function signatures in expressions
MutableTransmutes: MutableTransmutes, MutableTransmutes: MutableTransmutes,


Expand Down Expand Up @@ -350,6 +348,7 @@ fn register_builtins(store: &mut lint::LintStore, no_interleave_lints: bool) {
"converted into hard error, see https://github.com/rust-lang/rust/issues/35896"); "converted into hard error, see https://github.com/rust-lang/rust/issues/35896");
store.register_removed("nested_impl_trait", store.register_removed("nested_impl_trait",
"converted into hard error, see https://github.com/rust-lang/rust/issues/59014"); "converted into hard error, see https://github.com/rust-lang/rust/issues/59014");
store.register_removed("plugin_as_library", "plugins have been deprecated and retired");
} }


fn register_internals(store: &mut lint::LintStore) { fn register_internals(store: &mut lint::LintStore) {
Expand Down
7 changes: 1 addition & 6 deletions src/test/ui-fulldeps/macro-crate-multi-decorator.rs
@@ -1,9 +1,4 @@
// run-pass // check-pass

#![allow(plugin_as_library)]
#![allow(dead_code)]
#![allow(unused_variables)]
#![allow(unused_imports)]
// aux-build:macro-crate-test.rs // aux-build:macro-crate-test.rs
// ignore-stage1 // ignore-stage1


Expand Down
7 changes: 3 additions & 4 deletions src/test/ui-fulldeps/plugin-as-extern-crate.rs
@@ -1,11 +1,10 @@
// check-pass
// aux-build:empty-plugin.rs // aux-build:empty-plugin.rs
// ignore-cross-compile // ignore-cross-compile
// //
// empty_plugin will not compile on a cross-compiled target because // empty_plugin will not compile on a cross-compiled target because
// libsyntax is not compiled for it. // libsyntax is not compiled for it.


#![deny(plugin_as_library)] extern crate empty_plugin; // OK, plugin crates are still crates


extern crate empty_plugin; //~ ERROR compiler plugin used as an ordinary library fn main() {}

fn main() { }
14 changes: 0 additions & 14 deletions src/test/ui-fulldeps/plugin-as-extern-crate.stderr

This file was deleted.

0 comments on commit cf1ffb0

Please sign in to comment.