diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ui/annotate-snippet/auxiliary/other_file.rs | 6 | ||||
| -rw-r--r-- | tests/ui/annotate-snippet/multiple-files.rs | 8 | ||||
| -rw-r--r-- | tests/ui/annotate-snippet/multiple-files.stderr | 11 | ||||
| -rw-r--r-- | tests/ui/consts/const-eval/nonnull_as_ref.rs | 8 | ||||
| -rw-r--r-- | tests/ui/consts/const-eval/nonnull_as_ref_ub.rs | 6 | ||||
| -rw-r--r-- | tests/ui/consts/const-eval/nonnull_as_ref_ub.stderr | 16 | ||||
| -rw-r--r-- | tests/ui/impl-trait/hidden-type-is-opaque-2.rs | 6 | ||||
| -rw-r--r-- | tests/ui/impl-trait/hidden-type-is-opaque-2.stderr | 24 | ||||
| -rw-r--r-- | tests/ui/mismatched_types/closure-ref-114180.rs | 8 | ||||
| -rw-r--r-- | tests/ui/mismatched_types/closure-ref-114180.stderr | 22 | ||||
| -rw-r--r-- | tests/ui/mismatched_types/ref-pat-suggestions.stderr | 44 | ||||
| -rw-r--r-- | tests/ui/privacy/unnameable_types.rs | 4 | ||||
| -rw-r--r-- | tests/ui/privacy/unnameable_types.stderr | 14 |
13 files changed, 134 insertions, 43 deletions
diff --git a/tests/ui/annotate-snippet/auxiliary/other_file.rs b/tests/ui/annotate-snippet/auxiliary/other_file.rs new file mode 100644 index 00000000000..6f5f412d086 --- /dev/null +++ b/tests/ui/annotate-snippet/auxiliary/other_file.rs @@ -0,0 +1,6 @@ +pub struct WithPrivateMethod; + +impl WithPrivateMethod { + /// Private to get an error involving two files + fn private_method(&self) {} +} diff --git a/tests/ui/annotate-snippet/multiple-files.rs b/tests/ui/annotate-snippet/multiple-files.rs new file mode 100644 index 00000000000..981cdbb10a9 --- /dev/null +++ b/tests/ui/annotate-snippet/multiple-files.rs @@ -0,0 +1,8 @@ +// aux-build:other_file.rs +// compile-flags: --error-format human-annotate-rs -Z unstable-options + +extern crate other_file; + +fn main() { + other_file::WithPrivateMethod.private_method(); +} diff --git a/tests/ui/annotate-snippet/multiple-files.stderr b/tests/ui/annotate-snippet/multiple-files.stderr new file mode 100644 index 00000000000..4236ec811d0 --- /dev/null +++ b/tests/ui/annotate-snippet/multiple-files.stderr @@ -0,0 +1,11 @@ +error[E0624]: method `private_method` is private + --> $DIR/multiple-files.rs:7:35 + | +LL | other_file::WithPrivateMethod.private_method(); + | ^^^^^^^^^^^^^^ private method + | + ::: $DIR/auxiliary/other_file.rs:5:5 + | +LL | fn private_method(&self) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^ private method defined here + | diff --git a/tests/ui/consts/const-eval/nonnull_as_ref.rs b/tests/ui/consts/const-eval/nonnull_as_ref.rs new file mode 100644 index 00000000000..eb4683e2c30 --- /dev/null +++ b/tests/ui/consts/const-eval/nonnull_as_ref.rs @@ -0,0 +1,8 @@ +// check-pass + +use std::ptr::NonNull; + +const NON_NULL: NonNull<u8> = unsafe { NonNull::new_unchecked((&42u8 as *const u8).cast_mut()) }; +const _: () = assert!(42 == *unsafe { NON_NULL.as_ref() }); + +fn main() {} diff --git a/tests/ui/consts/const-eval/nonnull_as_ref_ub.rs b/tests/ui/consts/const-eval/nonnull_as_ref_ub.rs new file mode 100644 index 00000000000..3b48e972923 --- /dev/null +++ b/tests/ui/consts/const-eval/nonnull_as_ref_ub.rs @@ -0,0 +1,6 @@ +use std::ptr::NonNull; + +const NON_NULL: NonNull<u8> = unsafe { NonNull::dangling() }; +const _: () = assert!(42 == *unsafe { NON_NULL.as_ref() }); + +fn main() {} diff --git a/tests/ui/consts/const-eval/nonnull_as_ref_ub.stderr b/tests/ui/consts/const-eval/nonnull_as_ref_ub.stderr new file mode 100644 index 00000000000..de93cb0c3ca --- /dev/null +++ b/tests/ui/consts/const-eval/nonnull_as_ref_ub.stderr @@ -0,0 +1,16 @@ +error[E0080]: evaluation of constant value failed + --> $SRC_DIR/core/src/ptr/non_null.rs:LL:COL + | + = note: dereferencing pointer failed: 0x1[noalloc] is a dangling pointer (it has no provenance) + | +note: inside `NonNull::<u8>::as_ref::<'_>` + --> $SRC_DIR/core/src/ptr/non_null.rs:LL:COL +note: inside `_` + --> $DIR/nonnull_as_ref_ub.rs:4:39 + | +LL | const _: () = assert!(42 == *unsafe { NON_NULL.as_ref() }); + | ^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/impl-trait/hidden-type-is-opaque-2.rs b/tests/ui/impl-trait/hidden-type-is-opaque-2.rs index 970d84120e0..212e7b10802 100644 --- a/tests/ui/impl-trait/hidden-type-is-opaque-2.rs +++ b/tests/ui/impl-trait/hidden-type-is-opaque-2.rs @@ -6,7 +6,8 @@ fn reify_as() -> Thunk<impl FnOnce(Continuation) -> Continuation> { Thunk::new(|mut cont| { - cont.reify_as(); //~ ERROR type annotations needed + //~^ ERROR type annotations needed + cont.reify_as(); cont }) } @@ -15,7 +16,8 @@ type Tait = impl FnOnce(Continuation) -> Continuation; fn reify_as_tait() -> Thunk<Tait> { Thunk::new(|mut cont| { - cont.reify_as(); //~ ERROR type annotations needed + //~^ ERROR type annotations needed + cont.reify_as(); cont }) } diff --git a/tests/ui/impl-trait/hidden-type-is-opaque-2.stderr b/tests/ui/impl-trait/hidden-type-is-opaque-2.stderr index 957052feba9..39bf2214232 100644 --- a/tests/ui/impl-trait/hidden-type-is-opaque-2.stderr +++ b/tests/ui/impl-trait/hidden-type-is-opaque-2.stderr @@ -1,14 +1,30 @@ error[E0282]: type annotations needed - --> $DIR/hidden-type-is-opaque-2.rs:9:9 + --> $DIR/hidden-type-is-opaque-2.rs:8:17 | +LL | Thunk::new(|mut cont| { + | ^^^^^^^^ +LL | LL | cont.reify_as(); - | ^^^^ cannot infer type + | ---- type must be known at this point + | +help: consider giving this closure parameter an explicit type + | +LL | Thunk::new(|mut cont: /* Type */| { + | ++++++++++++ error[E0282]: type annotations needed - --> $DIR/hidden-type-is-opaque-2.rs:18:9 + --> $DIR/hidden-type-is-opaque-2.rs:18:17 | +LL | Thunk::new(|mut cont| { + | ^^^^^^^^ +LL | LL | cont.reify_as(); - | ^^^^ cannot infer type + | ---- type must be known at this point + | +help: consider giving this closure parameter an explicit type + | +LL | Thunk::new(|mut cont: /* Type */| { + | ++++++++++++ error: aborting due to 2 previous errors diff --git a/tests/ui/mismatched_types/closure-ref-114180.rs b/tests/ui/mismatched_types/closure-ref-114180.rs new file mode 100644 index 00000000000..d84bdbedaf6 --- /dev/null +++ b/tests/ui/mismatched_types/closure-ref-114180.rs @@ -0,0 +1,8 @@ +// check-fail + +fn main() { + let mut v = vec![(1,)]; + let compare = |(a,), (e,)| todo!(); + v.sort_by(compare); + //~^ ERROR type mismatch in closure arguments +} diff --git a/tests/ui/mismatched_types/closure-ref-114180.stderr b/tests/ui/mismatched_types/closure-ref-114180.stderr new file mode 100644 index 00000000000..8a146d784e2 --- /dev/null +++ b/tests/ui/mismatched_types/closure-ref-114180.stderr @@ -0,0 +1,22 @@ +error[E0631]: type mismatch in closure arguments + --> $DIR/closure-ref-114180.rs:6:15 + | +LL | let compare = |(a,), (e,)| todo!(); + | ------------ found signature defined here +LL | v.sort_by(compare); + | ------- ^^^^^^^ expected due to this + | | + | required by a bound introduced by this call + | + = note: expected closure signature `for<'a, 'b> fn(&'a ({integer},), &'b ({integer},)) -> _` + found closure signature `fn((_,), (_,)) -> _` +note: required by a bound in `slice::<impl [T]>::sort_by` + --> $SRC_DIR/alloc/src/slice.rs:LL:COL +help: consider adjusting the signature so it borrows its arguments + | +LL | let compare = |&(a,), &(e,)| todo!(); + | + + + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0631`. diff --git a/tests/ui/mismatched_types/ref-pat-suggestions.stderr b/tests/ui/mismatched_types/ref-pat-suggestions.stderr index 62824004db5..148ed00b01d 100644 --- a/tests/ui/mismatched_types/ref-pat-suggestions.stderr +++ b/tests/ui/mismatched_types/ref-pat-suggestions.stderr @@ -103,10 +103,10 @@ error[E0308]: mismatched types --> $DIR/ref-pat-suggestions.rs:11:23 | LL | let _: fn(u32) = |&_a| (); - | ^-- - | || - | |expected due to this + | ^^^ + | | | expected `u32`, found `&_` + | expected due to this | = note: expected type `u32` found reference `&_` @@ -120,10 +120,10 @@ error[E0308]: mismatched types --> $DIR/ref-pat-suggestions.rs:12:23 | LL | let _: fn(u32) = |&mut _a| (); - | ^^^^^-- - | | | - | | expected due to this + | ^^^^^^^ + | | | expected `u32`, found `&mut _` + | expected due to this | = note: expected type `u32` found mutable reference `&mut _` @@ -142,10 +142,10 @@ error[E0308]: mismatched types --> $DIR/ref-pat-suggestions.rs:13:25 | LL | let _: fn(&u32) = |&&_a| (); - | ^-- - | || - | |expected due to this - | expected `u32`, found `&_` + | -^^^ + | || + | |expected `u32`, found `&_` + | expected due to this | = note: expected type `u32` found reference `&_` @@ -159,10 +159,10 @@ error[E0308]: mismatched types --> $DIR/ref-pat-suggestions.rs:14:33 | LL | let _: fn(&mut u32) = |&mut &_a| (); - | ^-- - | || - | |expected due to this - | expected `u32`, found `&_` + | -----^^^ + | | | + | | expected `u32`, found `&_` + | expected due to this | = note: expected type `u32` found reference `&_` @@ -176,10 +176,10 @@ error[E0308]: mismatched types --> $DIR/ref-pat-suggestions.rs:15:25 | LL | let _: fn(&u32) = |&&mut _a| (); - | ^^^^^-- - | | | - | | expected due to this - | expected `u32`, found `&mut _` + | -^^^^^^^ + | || + | |expected `u32`, found `&mut _` + | expected due to this | = note: expected type `u32` found mutable reference `&mut _` @@ -193,10 +193,10 @@ error[E0308]: mismatched types --> $DIR/ref-pat-suggestions.rs:16:33 | LL | let _: fn(&mut u32) = |&mut &mut _a| (); - | ^^^^^-- - | | | - | | expected due to this - | expected `u32`, found `&mut _` + | -----^^^^^^^ + | | | + | | expected `u32`, found `&mut _` + | expected due to this | = note: expected type `u32` found mutable reference `&mut _` diff --git a/tests/ui/privacy/unnameable_types.rs b/tests/ui/privacy/unnameable_types.rs index eae20dd9df3..46e24915259 100644 --- a/tests/ui/privacy/unnameable_types.rs +++ b/tests/ui/privacy/unnameable_types.rs @@ -11,12 +11,12 @@ mod m { pub trait PubTr { //~ ERROR trait `PubTr` is reachable but cannot be named const C : i32 = 0; - type Alias; //~ ERROR associated type `PubTr::Alias` is reachable but cannot be named + type Alias; fn f() {} } impl PubTr for PubStruct { - type Alias = i32; //~ ERROR associated type `<PubStruct as PubTr>::Alias` is reachable but cannot be named + type Alias = i32; fn f() {} } } diff --git a/tests/ui/privacy/unnameable_types.stderr b/tests/ui/privacy/unnameable_types.stderr index 25eb5c9434a..90412752575 100644 --- a/tests/ui/privacy/unnameable_types.stderr +++ b/tests/ui/privacy/unnameable_types.stderr @@ -22,17 +22,5 @@ error: trait `PubTr` is reachable but cannot be named LL | pub trait PubTr { | ^^^^^^^^^^^^^^^ reachable at visibility `pub`, but can only be named at visibility `pub(crate)` -error: associated type `PubTr::Alias` is reachable but cannot be named - --> $DIR/unnameable_types.rs:14:9 - | -LL | type Alias; - | ^^^^^^^^^^ reachable at visibility `pub`, but can only be named at visibility `pub(crate)` - -error: associated type `<PubStruct as PubTr>::Alias` is reachable but cannot be named - --> $DIR/unnameable_types.rs:19:9 - | -LL | type Alias = i32; - | ^^^^^^^^^^ reachable at visibility `pub`, but can only be named at visibility `pub(crate)` - -error: aborting due to 5 previous errors +error: aborting due to 3 previous errors |
