Skip to content

Commit 2fc16d5

Browse files
committed
Update tests
1 parent 9bc0e5b commit 2fc16d5

33 files changed

+92
-76
lines changed

compiler/rustc_middle/src/hir/nested_filter.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use rustc_hir::intravisit::nested_filter::NestedFilter;
1111
/// to use `visit_all_item_likes_in_crate()` as an outer loop,
1212
/// and to have the visitor that visits the contents of each item
1313
/// using this setting.
14-
pub struct OnlyBodies(());
14+
pub struct OnlyBodies;
1515
impl<'hir> NestedFilter<'hir> for OnlyBodies {
1616
type Map = crate::hir::map::Map<'hir>;
1717
const INTER: bool = false;

library/alloc/src/string.rs

+3
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,7 @@ pub struct FromUtf8Error {
420420
///
421421
/// assert!(String::from_utf16(v).is_err());
422422
/// ```
423+
#[cfg(not(no_global_oom_handling))]
423424
#[stable(feature = "rust1", since = "1.0.0")]
424425
#[derive(Debug)]
425426
pub struct FromUtf16Error(());
@@ -2069,6 +2070,7 @@ impl fmt::Display for FromUtf8Error {
20692070
}
20702071
}
20712072

2073+
#[cfg(not(no_global_oom_handling))]
20722074
#[stable(feature = "rust1", since = "1.0.0")]
20732075
impl fmt::Display for FromUtf16Error {
20742076
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
@@ -2084,6 +2086,7 @@ impl Error for FromUtf8Error {
20842086
}
20852087
}
20862088

2089+
#[cfg(not(no_global_oom_handling))]
20872090
#[stable(feature = "rust1", since = "1.0.0")]
20882091
impl Error for FromUtf16Error {
20892092
#[allow(deprecated)]

tests/codegen-units/item-collection/generic-impl.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,17 @@ impl<T> Struct<T> {
2424
}
2525
}
2626

27-
pub struct LifeTimeOnly<'a> {
27+
pub struct _LifeTimeOnly<'a> {
2828
_a: &'a u32
2929
}
3030

31-
impl<'a> LifeTimeOnly<'a> {
31+
impl<'a> _LifeTimeOnly<'a> {
3232

33-
//~ MONO_ITEM fn LifeTimeOnly::<'_>::foo
33+
//~ MONO_ITEM fn _LifeTimeOnly::<'_>::foo
3434
pub fn foo(&self) {}
35-
//~ MONO_ITEM fn LifeTimeOnly::<'_>::bar
35+
//~ MONO_ITEM fn _LifeTimeOnly::<'_>::bar
3636
pub fn bar(&'a self) {}
37-
//~ MONO_ITEM fn LifeTimeOnly::<'_>::baz
37+
//~ MONO_ITEM fn _LifeTimeOnly::<'_>::baz
3838
pub fn baz<'b>(&'b self) {}
3939

4040
pub fn non_instantiated<T>(&self) {}

tests/codegen-units/item-collection/overloaded-operators.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55

66
use std::ops::{Index, IndexMut, Add, Deref};
77

8-
pub struct Indexable {
8+
pub struct _Indexable {
99
data: [u8; 3]
1010
}
1111

12-
impl Index<usize> for Indexable {
12+
impl Index<usize> for _Indexable {
1313
type Output = u8;
1414

15-
//~ MONO_ITEM fn <Indexable as std::ops::Index<usize>>::index
15+
//~ MONO_ITEM fn <_Indexable as std::ops::Index<usize>>::index
1616
fn index(&self, index: usize) -> &Self::Output {
1717
if index >= 3 {
1818
&self.data[0]
@@ -22,8 +22,8 @@ impl Index<usize> for Indexable {
2222
}
2323
}
2424

25-
impl IndexMut<usize> for Indexable {
26-
//~ MONO_ITEM fn <Indexable as std::ops::IndexMut<usize>>::index_mut
25+
impl IndexMut<usize> for _Indexable {
26+
//~ MONO_ITEM fn <_Indexable as std::ops::IndexMut<usize>>::index_mut
2727
fn index_mut(&mut self, index: usize) -> &mut Self::Output {
2828
if index >= 3 {
2929
&mut self.data[0]
@@ -34,25 +34,25 @@ impl IndexMut<usize> for Indexable {
3434
}
3535

3636

37-
//~ MONO_ITEM fn <Equatable as std::cmp::PartialEq>::eq
38-
//~ MONO_ITEM fn <Equatable as std::cmp::PartialEq>::ne
37+
//~ MONO_ITEM fn <_Equatable as std::cmp::PartialEq>::eq
38+
//~ MONO_ITEM fn <_Equatable as std::cmp::PartialEq>::ne
3939
#[derive(PartialEq)]
40-
pub struct Equatable(u32);
40+
pub struct _Equatable(u32);
4141

4242

43-
impl Add<u32> for Equatable {
43+
impl Add<u32> for _Equatable {
4444
type Output = u32;
4545

46-
//~ MONO_ITEM fn <Equatable as std::ops::Add<u32>>::add
46+
//~ MONO_ITEM fn <_Equatable as std::ops::Add<u32>>::add
4747
fn add(self, rhs: u32) -> u32 {
4848
self.0 + rhs
4949
}
5050
}
5151

52-
impl Deref for Equatable {
52+
impl Deref for _Equatable {
5353
type Target = u32;
5454

55-
//~ MONO_ITEM fn <Equatable as std::ops::Deref>::deref
55+
//~ MONO_ITEM fn <_Equatable as std::ops::Deref>::deref
5656
fn deref(&self) -> &Self::Target {
5757
&self.0
5858
}

tests/ui/coherence/re-rebalance-coherence.rs

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
extern crate re_rebalance_coherence_lib as lib;
55
use lib::*;
66

7+
#[allow(dead_code)]
78
struct Oracle;
89
impl Backend for Oracle {}
910
impl<'a, T:'a, Tab> QueryFragment<Oracle> for BatchInsert<'a, T, Tab> {}

tests/ui/const-generics/defaults/repr-c-issue-82792.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
//@ run-pass
44

5+
#[allow(dead_code)]
56
#[repr(C)]
67
pub struct Loaf<T: Sized, const N: usize = 1> {
78
head: [T; N],

tests/ui/const-generics/generic_const_exprs/associated-consts.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ impl BlockCipher for BarCipher {
1616
const BLOCK_SIZE: usize = 32;
1717
}
1818

19-
pub struct Block<C>(#[allow(dead_code)] C);
19+
#[allow(dead_code)]
20+
pub struct Block<C>(C);
2021

2122
pub fn test<C: BlockCipher, const M: usize>()
2223
where

tests/ui/const-generics/transparent-maybeunit-array-wrapper.rs

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use std::mem::MaybeUninit;
88

9+
#[allow(dead_code)]
910
#[repr(transparent)]
1011
pub struct MaybeUninitWrapper<const N: usize>(MaybeUninit<[u64; N]>);
1112

tests/ui/derives/clone-debug-dead-code-in-the-same-struct.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#![forbid(dead_code)]
22

33
#[derive(Debug)]
4-
pub struct Whatever {
4+
pub struct Whatever { //~ ERROR struct `Whatever` is never constructed
55
pub field0: (),
6-
field1: (), //~ ERROR fields `field1`, `field2`, `field3`, and `field4` are never read
6+
field1: (),
77
field2: (),
88
field3: (),
99
field4: (),

tests/ui/derives/clone-debug-dead-code-in-the-same-struct.stderr

+3-13
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,9 @@
1-
error: fields `field1`, `field2`, `field3`, and `field4` are never read
2-
--> $DIR/clone-debug-dead-code-in-the-same-struct.rs:6:5
1+
error: struct `Whatever` is never constructed
2+
--> $DIR/clone-debug-dead-code-in-the-same-struct.rs:4:12
33
|
44
LL | pub struct Whatever {
5-
| -------- fields in this struct
6-
LL | pub field0: (),
7-
LL | field1: (),
8-
| ^^^^^^
9-
LL | field2: (),
10-
| ^^^^^^
11-
LL | field3: (),
12-
| ^^^^^^
13-
LL | field4: (),
14-
| ^^^^^^
5+
| ^^^^^^^^
156
|
16-
= note: `Whatever` has a derived impl for the trait `Debug`, but this is intentionally ignored during dead code analysis
177
note: the lint level is defined here
188
--> $DIR/clone-debug-dead-code-in-the-same-struct.rs:1:11
199
|

tests/ui/issues/issue-5708.rs

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ pub trait MyTrait<T> {
4444
fn dummy(&self, t: T) -> T { panic!() }
4545
}
4646

47+
#[allow(dead_code)]
4748
pub struct MyContainer<'a, T:'a> {
4849
foos: Vec<&'a (dyn MyTrait<T>+'a)> ,
4950
}

tests/ui/lint/dead-code/lint-dead-code-1.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ impl SemiUsedStruct {
4949
struct StructUsedAsField;
5050
pub struct StructUsedInEnum;
5151
struct StructUsedInGeneric;
52+
#[allow(dead_code)]
5253
pub struct PubStruct2 {
53-
#[allow(dead_code)]
5454
struct_used_as_field: *const StructUsedAsField
5555
}
5656

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#![deny(dead_code)]
2+
3+
trait Trait {
4+
const UNUSED_CONST: i32; //~ ERROR associated constant `UNUSED_CONST` is never used
5+
const USED_CONST: i32;
6+
7+
fn foo(&self) {}
8+
}
9+
10+
pub struct T(());
11+
12+
impl Trait for T {
13+
const UNUSED_CONST: i32 = 0;
14+
const USED_CONST: i32 = 1;
15+
}
16+
17+
fn main() {
18+
T(()).foo();
19+
T::USED_CONST;
20+
}

tests/ui/lint/dead-code/unused_assoc_const.stderr tests/ui/lint/dead-code/unused-assoc-const.stderr

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
error: associated constant `I` is never used
2-
--> $DIR/unused_assoc_const.rs:4:11
1+
error: associated constant `UNUSED_CONST` is never used
2+
--> $DIR/unused-assoc-const.rs:4:11
33
|
44
LL | trait Trait {
55
| ----- associated constant in this trait
6-
LL | const I: i32;
7-
| ^
6+
LL | const UNUSED_CONST: i32;
7+
| ^^^^^^^^^^^^
88
|
99
note: the lint level is defined here
10-
--> $DIR/unused_assoc_const.rs:1:9
10+
--> $DIR/unused-assoc-const.rs:1:9
1111
|
1212
LL | #![deny(dead_code)]
1313
| ^^^^^^^^^

tests/ui/lint/dead-code/unused_pub_struct.stderr tests/ui/lint/dead-code/unused-pub-struct.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
error: struct `NeverConstructed` is never constructed
2-
--> $DIR/unused_pub_struct.rs:3:12
2+
--> $DIR/unused-pub-struct.rs:3:12
33
|
44
LL | pub struct NeverConstructed(());
55
| ^^^^^^^^^^^^^^^^
66
|
77
note: the lint level is defined here
8-
--> $DIR/unused_pub_struct.rs:1:9
8+
--> $DIR/unused-pub-struct.rs:1:9
99
|
1010
LL | #![deny(dead_code)]
1111
| ^^^^^^^^^

tests/ui/lint/dead-code/unused_assoc_const.rs

-17
This file was deleted.

tests/ui/parser/recover/recover-where-clause-before-tuple-struct-body-0.fixed

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
// Regression test for issues #100790 and #106439.
22
//@ run-rustfix
33

4-
pub struct Example(#[allow(dead_code)] usize)
4+
#[allow(dead_code)]
5+
pub struct Example(usize)
56
where
67
(): Sized;
78
//~^^^ ERROR where clauses are not allowed before tuple struct bodies

tests/ui/parser/recover/recover-where-clause-before-tuple-struct-body-0.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
// Regression test for issues #100790 and #106439.
22
//@ run-rustfix
33

4+
#[allow(dead_code)]
45
pub struct Example
56
where
67
(): Sized,
7-
(#[allow(dead_code)] usize);
8+
(usize);
89
//~^^^ ERROR where clauses are not allowed before tuple struct bodies
910

1011
struct _Demo

tests/ui/parser/recover/recover-where-clause-before-tuple-struct-body-0.stderr

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
error: where clauses are not allowed before tuple struct bodies
2-
--> $DIR/recover-where-clause-before-tuple-struct-body-0.rs:5:1
2+
--> $DIR/recover-where-clause-before-tuple-struct-body-0.rs:6:1
33
|
44
LL | pub struct Example
55
| ------- while parsing this tuple struct
66
LL | / where
77
LL | | (): Sized,
88
| |______________^ unexpected where clause
9-
LL | (#[allow(dead_code)] usize);
10-
| --------------------------- the struct body
9+
LL | (usize);
10+
| ------- the struct body
1111
|
1212
help: move the body before the where clause
1313
|
14-
LL ~ pub struct Example(#[allow(dead_code)] usize)
14+
LL ~ pub struct Example(usize)
1515
LL | where
1616
LL ~ (): Sized;
1717
|
1818

1919
error: where clauses are not allowed before tuple struct bodies
20-
--> $DIR/recover-where-clause-before-tuple-struct-body-0.rs:11:1
20+
--> $DIR/recover-where-clause-before-tuple-struct-body-0.rs:12:1
2121
|
2222
LL | struct _Demo
2323
| ----- while parsing this tuple struct

tests/ui/pub/pub-ident-struct-4.fixed

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//@ run-rustfix
22

3-
pub struct T(#[allow(dead_code)] String);
3+
#[allow(dead_code)]
4+
pub struct T(String);
45
//~^ ERROR missing `struct` for struct definition
56

67
fn main() {}

tests/ui/pub/pub-ident-struct-4.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//@ run-rustfix
22

3-
pub T(#[allow(dead_code)] String);
3+
#[allow(dead_code)]
4+
pub T(String);
45
//~^ ERROR missing `struct` for struct definition
56

67
fn main() {}

tests/ui/pub/pub-ident-struct-4.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
error: missing `struct` for struct definition
2-
--> $DIR/pub-ident-struct-4.rs:3:4
2+
--> $DIR/pub-ident-struct-4.rs:4:4
33
|
4-
LL | pub T(#[allow(dead_code)] String);
4+
LL | pub T(String);
55
| ^
66
|
77
help: add `struct` here to parse `T` as a public struct
88
|
9-
LL | pub struct T(#[allow(dead_code)] String);
9+
LL | pub struct T(String);
1010
| ++++++
1111

1212
error: aborting due to 1 previous error

tests/ui/regions/regions-issue-21422.rs

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
//@ pretty-expanded FIXME #23616
77

8+
#[allow(dead_code)]
89
pub struct P<'a> {
910
_ptr: *const &'a u8,
1011
}

tests/ui/structs-enums/newtype-struct-with-dtor.rs

+2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
#![allow(unused_variables)]
44
//@ pretty-expanded FIXME #23616
55

6+
#[allow(dead_code)]
67
pub struct Fd(u32);
78

9+
#[allow(dead_code)]
810
fn foo(a: u32) {}
911

1012
impl Drop for Fd {
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//@ run-pass
2-
pub struct Z(#[allow(dead_code)] &'static Z);
2+
#[allow(dead_code)]
3+
pub struct Z(&'static Z);
34

45
pub fn main() {}

tests/ui/suggestions/derive-clone-for-eq.fixed

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//@ run-rustfix
22
// https://github.com/rust-lang/rust/issues/79076
33

4+
#[allow(dead_code)]
45
#[derive(Clone, Eq)] //~ ERROR [E0277]
56
pub struct Struct<T: std::clone::Clone>(T);
67

0 commit comments

Comments
 (0)