Skip to content

Commit

Permalink
Clippy fixes, rename stuff to match RFC
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron1011 committed Feb 1, 2019
1 parent 12f9b79 commit d60214c
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/librustc/lint/builtin.rs
Expand Up @@ -126,7 +126,7 @@ declare_lint! {
}

declare_lint! {
pub LEAKED_PRIVATE_DEPENDENCY,
pub EXTERNAL_PRIVATE_DEPENDENCY,
Warn,
"public interface leaks type from a private dependency"
}
Expand Down Expand Up @@ -411,7 +411,7 @@ impl LintPass for HardwiredLints {
TRIVIAL_CASTS,
TRIVIAL_NUMERIC_CASTS,
PRIVATE_IN_PUBLIC,
LEAKED_PRIVATE_DEPENDENCY,
EXTERNAL_PRIVATE_DEPENDENCY,
PUB_USE_OF_PRIVATE_EXTERN_CRATE,
INVALID_TYPE_PARAM_DEFAULT,
CONST_ERR,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/session/config.rs
Expand Up @@ -1928,7 +1928,7 @@ pub fn build_session_options_and_crate_config(
let mut extern_public: FxHashSet<String> = matches.opt_strs("extern-public").
iter().cloned().collect();

// TODO - come up with a better way of handling this
// FIXME - come up with a better way of handling this
extern_public.insert("core".to_string());
extern_public.insert("std".to_string());

Expand Down
2 changes: 0 additions & 2 deletions src/librustc_lint/builtin.rs
Expand Up @@ -1883,5 +1883,3 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ExplicitOutlivesRequirements {
}

}


2 changes: 1 addition & 1 deletion src/librustc_lint/lib.rs
Expand Up @@ -230,7 +230,7 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) {
edition: None,
},
FutureIncompatibleInfo {
id: LintId::of(LEAKED_PRIVATE_DEPENDENCY),
id: LintId::of(EXTERNAL_PRIVATE_DEPENDENCY),
reference: "issue #44663 <https://github.com/rust-lang/rust/issues/44663>",
edition: None,
},
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_privacy/lib.rs
Expand Up @@ -1496,7 +1496,7 @@ impl<'a, 'tcx: 'a> SearchInterfaceForPrivateItemsVisitor<'a, 'tcx> {

fn check_def_id(&mut self, def_id: DefId, kind: &str, descr: &dyn fmt::Display) -> bool {
if self.leaks_private_dep(def_id) {
self.tcx.lint_node(lint::builtin::LEAKED_PRIVATE_DEPENDENCY,
self.tcx.lint_node(lint::builtin::EXTERNAL_PRIVATE_DEPENDENCY,
self.item_id,
self.span,
&format!("{} `{}` from private dependency '{}' in public \
Expand Down
1 change: 1 addition & 0 deletions src/test/ui/feature-gates/auxiliary/pub_dep.rs
@@ -0,0 +1 @@
pub struct PubType;
@@ -0,0 +1,20 @@
// This test is different from other feature gate tests.
// Instead of checking that an error occurs without the feature gate,
// it checks that *no* errors/warnings occurs without the feature gate.
// This is due to the fact that 'public_private_dependencies' just enables
// a lint, so disabling it shouldn't cause any code to stop compiling.

// run-pass
// aux-build:pub_dep.rs

// Without ![feature(public_private_dependencies)],
// this should do nothing/
#![deny(external_private_dependency)]

extern crate pub_dep;

pub struct Foo {
pub field: pub_dep::PubType
}

fn main() {}
8 changes: 4 additions & 4 deletions src/test/ui/privacy/pub-priv-dep/pub-priv1.rs
Expand Up @@ -2,7 +2,7 @@
// aux-build:pub_dep.rs
// compile-flags: --extern-public=pub_dep
#![feature(public_private_dependencies)]
#![deny(leaked_private_dependency)]
#![deny(external_private_dependency)]

// This crate is a private dependency
extern crate priv_dep;
Expand All @@ -20,15 +20,15 @@ struct PrivateType {

pub struct PublicType {
pub field: OtherType,
//~^ ERROR type `priv_dep::OtherType` from private dependency 'priv_dep' in public interface [leaked_private_dependency]
//~^ ERROR type `priv_dep::OtherType` from private dependency 'priv_dep' in public interface
//~| WARNING this was previously accepted
priv_field: OtherType, // Private field - this is fine
pub other_field: PubType // Type from public dependency - this is fine
}

impl PublicType {
pub fn pub_fn(param: OtherType) {}
//~^ ERROR type `priv_dep::OtherType` from private dependency 'priv_dep' in public interface [leaked_private_dependency]
//~^ ERROR type `priv_dep::OtherType` from private dependency 'priv_dep' in public interface
//~| WARNING this was previously accepted

fn priv_fn(param: OtherType) {}
Expand All @@ -37,7 +37,7 @@ impl PublicType {
pub trait MyPubTrait {
type Foo: OtherTrait;
}
//~^^^ ERROR trait `priv_dep::OtherTrait` from private dependency 'priv_dep' in public interface [leaked_private_dependency]
//~^^^ ERROR trait `priv_dep::OtherTrait` from private dependency 'priv_dep' in public interface
//~| WARNING this was previously accepted


Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/privacy/pub-priv-dep/pub-priv1.stderr
Expand Up @@ -7,8 +7,8 @@ LL | pub field: OtherType,
note: lint level defined here
--> $DIR/pub-priv1.rs:5:9
|
LL | #![deny(leaked_private_dependency)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^
LL | #![deny(external_private_dependency)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #44663 <https://github.com/rust-lang/rust/issues/44663>

Expand Down

0 comments on commit d60214c

Please sign in to comment.