Skip to content

Commit 02e0843

Browse files
committed
Improve dead code analysis for structs and traits defined locally
1 parent 64ebd39 commit 02e0843

File tree

51 files changed

+585
-184
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+585
-184
lines changed

compiler/rustc_incremental/messages.ftl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,4 @@ incremental_unrecognized_depnode = unrecognized `DepNode` variant: {$name}
9999
100100
incremental_unrecognized_depnode_label = dep-node label `{$label}` not recognized
101101
102-
incremental_write_dep_graph = failed to write dependency graph to `{$path}`: {$err}
103-
104102
incremental_write_new = failed to write {$name} to `{$path}`: {$err}

compiler/rustc_incremental/src/errors.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -272,13 +272,6 @@ pub struct LoadDepGraph {
272272
pub err: std::io::Error,
273273
}
274274

275-
#[derive(Diagnostic)]
276-
#[diag(incremental_write_dep_graph)]
277-
pub struct WriteDepGraph<'a> {
278-
pub path: &'a Path,
279-
pub err: std::io::Error,
280-
}
281-
282275
#[derive(Diagnostic)]
283276
#[diag(incremental_move_dep_graph)]
284277
pub struct MoveDepGraph<'a> {

compiler/rustc_passes/src/dead.rs

Lines changed: 242 additions & 121 deletions
Large diffs are not rendered by default.

compiler/rustc_transmute/src/maybe_transmutable/query_context.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use crate::layout;
44
pub(crate) trait QueryContext {
55
type Def: layout::Def;
66
type Ref: layout::Ref;
7-
type Scope: Copy;
87
}
98

109
#[cfg(test)]
@@ -28,7 +27,6 @@ pub(crate) mod test {
2827
impl QueryContext for UltraMinimal {
2928
type Def = Def;
3029
type Ref = !;
31-
type Scope = ();
3230
}
3331
}
3432

@@ -41,7 +39,5 @@ mod rustc {
4139
impl<'tcx> super::QueryContext for TyCtxt<'tcx> {
4240
type Def = layout::rustc::Def<'tcx>;
4341
type Ref = layout::rustc::Ref<'tcx>;
44-
45-
type Scope = Ty<'tcx>;
4642
}
4743
}

library/core/src/default.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ use crate::ascii::Char as AsciiChar;
103103
/// ```
104104
#[cfg_attr(not(test), rustc_diagnostic_item = "Default")]
105105
#[stable(feature = "rust1", since = "1.0.0")]
106-
#[cfg_attr(not(bootstrap), rustc_trivial_field_reads)]
107106
pub trait Default: Sized {
108107
/// Returns the "default value" for a type.
109108
///

tests/ui/associated-type-bounds/union-bounds.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
trait Tr1: Copy { type As1: Copy; }
66
trait Tr2: Copy { type As2: Copy; }
7-
trait Tr3: Copy { type As3: Copy; }
7+
trait Tr3: Copy { #[allow(dead_code)] type As3: Copy; }
88
trait Tr4<'a>: Copy { type As4: Copy; }
99
trait Tr5: Copy { type As5: Copy; }
1010

tests/ui/associated-types/impl-wf-cycle-5.fixed

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ impl Fiz for bool {}
1111

1212
trait Grault {
1313
type A;
14+
#[allow(dead_code)]
1415
type B;
1516
}
1617

tests/ui/associated-types/impl-wf-cycle-5.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ impl Fiz for bool {}
1111

1212
trait Grault {
1313
type A;
14+
#[allow(dead_code)]
1415
type B;
1516
}
1617

tests/ui/associated-types/impl-wf-cycle-5.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0275]: overflow evaluating the requirement `<(T,) as Grault>::A == _`
2-
--> $DIR/impl-wf-cycle-5.rs:22:1
2+
--> $DIR/impl-wf-cycle-5.rs:23:1
33
|
44
LL | / impl<T> Grault for (T,)
55
LL | |
@@ -12,7 +12,7 @@ LL | type A = ();
1212
| ------ associated type `<(T,) as Grault>::A` is specified here
1313
|
1414
note: required for `(T,)` to implement `Grault`
15-
--> $DIR/impl-wf-cycle-5.rs:22:9
15+
--> $DIR/impl-wf-cycle-5.rs:23:9
1616
|
1717
LL | impl<T> Grault for (T,)
1818
| ^^^^^^ ^^^^

tests/ui/associated-types/impl-wf-cycle-6.fixed

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ impl Fiz for bool {}
1111

1212
trait Grault {
1313
type A;
14+
#[allow(dead_code)]
1415
type B;
1516
}
1617

0 commit comments

Comments
 (0)