Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Add lint for missing Clone impls #58070

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 2 additions & 45 deletions src/doc/rustc/src/lints/listing/allowed-by-default.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,54 +126,11 @@ Lifetime elision elides this lifetime, but that is being deprecated.

## missing-copy-implementations

This lint detects potentially-forgotten implementations of `Copy`. Some
example code that triggers this lint:

```rust
pub struct Foo {
pub field: i32
}
```

When set to 'deny', this will produce:

```text
error: type could implement `Copy`; consider adding `impl Copy`
--> src/main.rs:3:1
|
3 | / pub struct Foo { //~ ERROR type could implement `Copy`; consider adding `impl Copy`
4 | | pub field: i32
5 | | }
| |_^
|
```

You can fix the lint by deriving `Copy`.

This lint is set to 'allow' because this code isn't bad; it's common to write
newtypes like this specifically so that a `Copy` type is no longer `Copy`.
This lint is deprecated and no longer used.

## missing-debug-implementations

This lint detects missing implementations of `fmt::Debug`. Some example code
that triggers this lint:

```rust
pub struct Foo;
```

When set to 'deny', this will produce:

```text
error: type does not implement `fmt::Debug`; consider adding #[derive(Debug)] or a manual implementation
--> src/main.rs:3:1
|
3 | pub struct Foo;
| ^^^^^^^^^^^^^^^
|
```

You can fix the lint by deriving `Debug`.
This lint is deprecated and no longer used.

## missing-docs

Expand Down
4 changes: 4 additions & 0 deletions src/librustc/middle/lang_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,10 @@ language_item_table! {

Arc, "arc", arc, Target::Struct;
Rc, "rc", rc, Target::Struct;

DefaultTraitLangItem, "default", default_trait, Target::Trait;
DisplayTraitLangItem, "display", display_trait, Target::Trait;
HashTraitLangItem, "hash", hash_trait, Target::Trait;
}

impl<'a, 'tcx, 'gcx> TyCtxt<'a, 'tcx, 'gcx> {
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_lint/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc {
declare_lint! {
pub MISSING_COPY_IMPLEMENTATIONS,
Allow,
"detects potentially-forgotten implementations of `Copy`"
"detects potentially-forgotten implementations of `Copy` (deprecated, do not use)"
}

#[derive(Copy, Clone)]
Expand Down Expand Up @@ -596,7 +596,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingCopyImplementations {
declare_lint! {
MISSING_DEBUG_IMPLEMENTATIONS,
Allow,
"detects missing implementations of fmt::Debug"
"detects missing implementations of fmt::Debug (deprecated, do not use)"
}

pub struct MissingDebugImplementations {
Expand Down