Skip to content

Commit c7519d4

Browse files
committed
Update tests
1 parent 40878ca commit c7519d4

File tree

276 files changed

+1049
-234
lines changed

Some content is hidden

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

276 files changed

+1049
-234
lines changed

Diff for: compiler/rustc_span/src/source_map/tests.rs

+2-47
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
use super::*;
22

3+
use rustc_data_structures::sync::FreezeLock;
4+
35
fn init_source_map() -> SourceMap {
46
let sm = SourceMap::new(FilePathMapping::empty());
57
sm.new_source_file(PathBuf::from("blork.rs").into(), "first line.\nsecond line".to_string());
@@ -263,53 +265,6 @@ fn t10() {
263265
);
264266
}
265267

266-
/// Returns the span corresponding to the `n`th occurrence of `substring` in `source_text`.
267-
trait SourceMapExtension {
268-
fn span_substr(
269-
&self,
270-
file: &Lrc<SourceFile>,
271-
source_text: &str,
272-
substring: &str,
273-
n: usize,
274-
) -> Span;
275-
}
276-
277-
impl SourceMapExtension for SourceMap {
278-
fn span_substr(
279-
&self,
280-
file: &Lrc<SourceFile>,
281-
source_text: &str,
282-
substring: &str,
283-
n: usize,
284-
) -> Span {
285-
eprintln!(
286-
"span_substr(file={:?}/{:?}, substring={:?}, n={})",
287-
file.name, file.start_pos, substring, n
288-
);
289-
let mut i = 0;
290-
let mut hi = 0;
291-
loop {
292-
let offset = source_text[hi..].find(substring).unwrap_or_else(|| {
293-
panic!(
294-
"source_text `{}` does not have {} occurrences of `{}`, only {}",
295-
source_text, n, substring, i
296-
);
297-
});
298-
let lo = hi + offset;
299-
hi = lo + substring.len();
300-
if i == n {
301-
let span = Span::with_root_ctxt(
302-
BytePos(lo as u32 + file.start_pos.0),
303-
BytePos(hi as u32 + file.start_pos.0),
304-
);
305-
assert_eq!(&self.span_to_snippet(span).unwrap()[..], substring);
306-
return span;
307-
}
308-
i += 1;
309-
}
310-
}
311-
}
312-
313268
// Takes a unix-style path and returns a platform specific path.
314269
fn path(p: &str) -> PathBuf {
315270
path_str(p).into()

Diff for: library/core/tests/macros.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#[allow(dead_code)]
12
trait Trait {
23
fn blah(&self);
34
}

Diff for: library/std/src/sys_common/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,14 @@ cfg_if::cfg_if! {
5959

6060
/// A trait for viewing representations from std types
6161
#[doc(hidden)]
62+
#[allow(dead_code)] // not used on all platforms
6263
pub trait AsInner<Inner: ?Sized> {
6364
fn as_inner(&self) -> &Inner;
6465
}
6566

6667
/// A trait for viewing representations from std types
6768
#[doc(hidden)]
69+
#[allow(dead_code)] // not used on all platforms
6870
pub trait AsInnerMut<Inner: ?Sized> {
6971
fn as_inner_mut(&mut self) -> &mut Inner;
7072
}

Diff for: src/tools/miri/tests/fail/dyn-call-trait-mismatch.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
trait T1 {
2+
#[allow(dead_code)]
23
fn method1(self: Box<Self>);
34
}
45
trait T2 {

Diff for: src/tools/miri/tests/fail/dyn-upcast-trait-mismatch.rs

+6
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,36 @@
22
#![allow(incomplete_features)]
33

44
trait Foo: PartialEq<i32> + std::fmt::Debug + Send + Sync {
5+
#[allow(dead_code)]
56
fn a(&self) -> i32 {
67
10
78
}
89

10+
#[allow(dead_code)]
911
fn z(&self) -> i32 {
1012
11
1113
}
1214

15+
#[allow(dead_code)]
1316
fn y(&self) -> i32 {
1417
12
1518
}
1619
}
1720

1821
trait Bar: Foo {
22+
#[allow(dead_code)]
1923
fn b(&self) -> i32 {
2024
20
2125
}
2226

27+
#[allow(dead_code)]
2328
fn w(&self) -> i32 {
2429
21
2530
}
2631
}
2732

2833
trait Baz: Bar {
34+
#[allow(dead_code)]
2935
fn c(&self) -> i32 {
3036
30
3137
}

Diff for: src/tools/miri/tests/pass/cast-rfc0401-vtable-kinds.rs

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ trait Foo<T> {
99
}
1010
}
1111

12+
#[allow(dead_code)]
1213
trait Bar {
1314
fn bar(&self) {
1415
println!("Bar!");

Diff for: src/tools/miri/tests/pass/dyn-upcast.rs

+3
Original file line numberDiff line numberDiff line change
@@ -383,14 +383,17 @@ fn struct_() {
383383

384384
fn replace_vptr() {
385385
trait A {
386+
#[allow(dead_code)]
386387
fn foo_a(&self);
387388
}
388389

389390
trait B {
391+
#[allow(dead_code)]
390392
fn foo_b(&self);
391393
}
392394

393395
trait C: A + B {
396+
#[allow(dead_code)]
394397
fn foo_c(&self);
395398
}
396399

Diff for: src/tools/miri/tests/pass/weak_memory/weak.rs

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use std::sync::atomic::Ordering::*;
1111
use std::sync::atomic::{fence, AtomicUsize};
1212
use std::thread::spawn;
1313

14+
#[allow(dead_code)]
1415
#[derive(Copy, Clone)]
1516
struct EvilSend<T>(pub T);
1617

Diff for: src/tools/tidy/src/ui_tests.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ use std::path::{Path, PathBuf};
1313
// desirable, because large numbers of files are unwieldy in general. See issue
1414
// #73494.
1515
const ENTRY_LIMIT: usize = 900;
16-
const ISSUES_ENTRY_LIMIT: usize = 1807;
17-
const ROOT_ENTRY_LIMIT: usize = 868;
16+
// FIXME: The following limits should be reduced eventually.
17+
const ISSUES_ENTRY_LIMIT: usize = 1819;
18+
const ROOT_ENTRY_LIMIT: usize = 870;
1819

1920
const EXPECTED_TEST_FILE_EXTENSIONS: &[&str] = &[
2021
"rs", // test source files

Diff for: tests/codegen-units/item-collection/instantiation-through-vtable.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ fn start(_: isize, _: *const *const u8) -> isize {
2626
//~ MONO_ITEM fn std::ptr::drop_in_place::<Struct<u32>> - shim(None) @@ instantiation_through_vtable-cgu.0[Internal]
2727
//~ MONO_ITEM fn <Struct<u32> as Trait>::foo
2828
//~ MONO_ITEM fn <Struct<u32> as Trait>::bar
29-
let _ = &s1 as &Trait;
29+
let r1 = &s1 as &Trait;
30+
r1.foo();
31+
r1.bar();
3032

3133
let s1 = Struct { _a: 0u64 };
3234
//~ MONO_ITEM fn std::ptr::drop_in_place::<Struct<u64>> - shim(None) @@ instantiation_through_vtable-cgu.0[Internal]

Diff for: tests/codegen-units/item-collection/trait-method-default-impl.rs

+3
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,8 @@ fn start(_: isize, _: *const *const u8) -> isize {
5757
//~ MONO_ITEM fn <u32 as SomeGenericTrait<i16>>::bar::<()>
5858
0u32.bar(0i16, ());
5959

60+
0i8.foo();
61+
0i32.foo();
62+
6063
0
6164
}

Diff for: tests/codegen-units/item-collection/unsizing.rs

+2
Original file line numberDiff line numberDiff line change
@@ -75,5 +75,7 @@ fn start(_: isize, _: *const *const u8) -> isize {
7575
//~ MONO_ITEM fn <u32 as Trait>::foo
7676
let _wrapper_sized = wrapper_sized as Wrapper<Trait>;
7777

78+
false.foo();
79+
7880
0
7981
}

Diff for: tests/ui-fulldeps/rustc_encodable_hygiene.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// run-pass
1+
// check-pass
22

33
#![feature(rustc_private)]
44

Diff for: tests/ui/anon-params/anon-params-deprecated.fixed

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// edition:2015
66
// run-rustfix
77

8+
#[allow(dead_code)]
89
trait T {
910
fn foo(_: i32); //~ WARNING anonymous parameters are deprecated
1011
//~| WARNING this is accepted in the current edition

Diff for: tests/ui/anon-params/anon-params-deprecated.rs

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// edition:2015
66
// run-rustfix
77

8+
#[allow(dead_code)]
89
trait T {
910
fn foo(i32); //~ WARNING anonymous parameters are deprecated
1011
//~| WARNING this is accepted in the current edition

Diff for: tests/ui/anon-params/anon-params-deprecated.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
warning: anonymous parameters are deprecated and will be removed in the next edition
2-
--> $DIR/anon-params-deprecated.rs:9:12
2+
--> $DIR/anon-params-deprecated.rs:10:12
33
|
44
LL | fn foo(i32);
55
| ^^^ help: try naming the parameter or explicitly ignoring it: `_: i32`
@@ -13,7 +13,7 @@ LL | #![warn(anonymous_parameters)]
1313
| ^^^^^^^^^^^^^^^^^^^^
1414

1515
warning: anonymous parameters are deprecated and will be removed in the next edition
16-
--> $DIR/anon-params-deprecated.rs:12:30
16+
--> $DIR/anon-params-deprecated.rs:13:30
1717
|
1818
LL | fn bar_with_default_impl(String, String) {}
1919
| ^^^^^^ help: try naming the parameter or explicitly ignoring it: `_: String`
@@ -22,7 +22,7 @@ LL | fn bar_with_default_impl(String, String) {}
2222
= note: for more information, see issue #41686 <https://github.com/rust-lang/rust/issues/41686>
2323

2424
warning: anonymous parameters are deprecated and will be removed in the next edition
25-
--> $DIR/anon-params-deprecated.rs:12:38
25+
--> $DIR/anon-params-deprecated.rs:13:38
2626
|
2727
LL | fn bar_with_default_impl(String, String) {}
2828
| ^^^^^^ help: try naming the parameter or explicitly ignoring it: `_: String`

Diff for: tests/ui/associated-consts/associated-const-outer-ty-refs.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
// run-pass
1+
// check-pass
2+
23
trait Lattice {
34
const BOTTOM: Self;
45
}

Diff for: tests/ui/associated-consts/associated-const-type-parameters.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ fn sub<A: Foo, B: Foo>() -> i32 {
2727
A::X - B::X
2828
}
2929

30-
trait Bar: Foo {
30+
trait Bar: Foo { //~ WARN trait `Bar` is never used
3131
const Y: i32 = Self::X;
3232
}
3333

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
warning: trait `Bar` is never used
2+
--> $DIR/associated-const-type-parameters.rs:30:7
3+
|
4+
LL | trait Bar: Foo {
5+
| ^^^
6+
|
7+
= note: `#[warn(dead_code)]` on by default
8+
9+
warning: 1 warning emitted
10+

Diff for: tests/ui/associated-type-bounds/dyn-impl-trait-type.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use std::ops::Add;
66

77
trait Tr1 { type As1; fn mk(&self) -> Self::As1; }
8-
trait Tr2<'a> { fn tr2(self) -> &'a Self; }
8+
trait Tr2<'a> { fn tr2(self) -> &'a Self; } //~ WARN method `tr2` is never used
99

1010
fn assert_copy<T: Copy>(x: T) { let _x = x; let _x = x; }
1111
fn assert_static<T: 'static>(_: T) {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
warning: method `tr2` is never used
2+
--> $DIR/dyn-impl-trait-type.rs:8:20
3+
|
4+
LL | trait Tr2<'a> { fn tr2(self) -> &'a Self; }
5+
| --- ^^^
6+
| |
7+
| method in this trait
8+
|
9+
= note: `#[warn(dead_code)]` on by default
10+
11+
warning: 1 warning emitted
12+

Diff for: tests/ui/associated-type-bounds/dyn-rpit-and-let.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use std::ops::Add;
88

99
trait Tr1 { type As1; fn mk(&self) -> Self::As1; }
10-
trait Tr2<'a> { fn tr2(self) -> &'a Self; }
10+
trait Tr2<'a> { fn tr2(self) -> &'a Self; } //~ WARN method `tr2` is never used
1111

1212
fn assert_copy<T: Copy>(x: T) { let _x = x; let _x = x; }
1313
fn assert_static<T: 'static>(_: T) {}
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
warning: method `tr2` is never used
2+
--> $DIR/dyn-rpit-and-let.rs:10:20
3+
|
4+
LL | trait Tr2<'a> { fn tr2(self) -> &'a Self; }
5+
| --- ^^^
6+
| |
7+
| method in this trait
8+
|
9+
= note: `#[warn(dead_code)]` on by default
10+
11+
warning: 1 warning emitted
12+

Diff for: tests/ui/associated-type-bounds/rpit.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use std::ops::Add;
66

77
trait Tr1 { type As1; fn mk(self) -> Self::As1; }
8-
trait Tr2<'a> { fn tr2(self) -> &'a Self; }
8+
trait Tr2<'a> { fn tr2(self) -> &'a Self; } //~ WARN method `tr2` is never used
99

1010
fn assert_copy<T: Copy>(x: T) { let _x = x; let _x = x; }
1111
fn assert_static<T: 'static>(_: T) {}

Diff for: tests/ui/associated-type-bounds/rpit.stderr

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
warning: method `tr2` is never used
2+
--> $DIR/rpit.rs:8:20
3+
|
4+
LL | trait Tr2<'a> { fn tr2(self) -> &'a Self; }
5+
| --- ^^^
6+
| |
7+
| method in this trait
8+
|
9+
= note: `#[warn(dead_code)]` on by default
10+
11+
warning: 1 warning emitted
12+

Diff for: tests/ui/associated-type-bounds/suggest-contraining-assoc-type-because-of-assoc-const.fixed

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// run-rustfix
2+
#![allow(dead_code)]
23
trait O {
34
type M;
45
}

Diff for: tests/ui/associated-type-bounds/suggest-contraining-assoc-type-because-of-assoc-const.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// run-rustfix
2+
#![allow(dead_code)]
23
trait O {
34
type M;
45
}

Diff for: tests/ui/associated-type-bounds/suggest-contraining-assoc-type-because-of-assoc-const.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0308]: mismatched types
2-
--> $DIR/suggest-contraining-assoc-type-because-of-assoc-const.rs:12:21
2+
--> $DIR/suggest-contraining-assoc-type-because-of-assoc-const.rs:13:21
33
|
44
LL | const N: C::M = 4u8;
55
| ^^^ expected associated type, found `u8`

Diff for: tests/ui/associated-type-bounds/trait-alias-impl-trait.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// run-pass
22

3+
#![allow(dead_code)]
34
#![feature(associated_type_bounds)]
45
#![feature(type_alias_impl_trait)]
56

Diff for: tests/ui/associated-types/associated-types-for-unimpl-trait.fixed

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// run-rustfix
2+
#![allow(dead_code)]
23
#![allow(unused_variables)]
34

45
trait Get {

Diff for: tests/ui/associated-types/associated-types-for-unimpl-trait.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// run-rustfix
2+
#![allow(dead_code)]
23
#![allow(unused_variables)]
34

45
trait Get {

Diff for: tests/ui/associated-types/associated-types-for-unimpl-trait.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0277]: the trait bound `Self: Get` is not satisfied
2-
--> $DIR/associated-types-for-unimpl-trait.rs:10:40
2+
--> $DIR/associated-types-for-unimpl-trait.rs:11:40
33
|
44
LL | fn uhoh<U:Get>(&self, foo: U, bar: <Self as Get>::Value) {}
55
| ^^^^^^^^^^^^^^^^^^^^ the trait `Get` is not implemented for `Self`

Diff for: tests/ui/associated-types/associated-types-in-bound-type-arg.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// run-pass
1+
// check-pass
22
// Test the case where we resolve `C::Result` and the trait bound
33
// itself includes a `Self::Item` shorthand.
44
//

Diff for: tests/ui/associated-types/associated-types-issue-20220.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use std::vec;
66

7-
trait IntoIteratorX {
7+
trait IntoIteratorX { //~ WARN trait `IntoIteratorX` is never used
88
type Item;
99
type IntoIter: Iterator<Item=Self::Item>;
1010

0 commit comments

Comments
 (0)