diff options
Diffstat (limited to 'tests')
126 files changed, 1203 insertions, 263 deletions
diff --git a/tests/codegen-units/item-collection/closures.rs b/tests/codegen-units/item-collection/closures.rs index 5fc80230925..864f98817a8 100644 --- a/tests/codegen-units/item-collection/closures.rs +++ b/tests/codegen-units/item-collection/closures.rs @@ -10,3 +10,9 @@ pub async fn async_fn() {} pub fn closure() { let _ = || {}; } + +//~ MONO_ITEM fn A::{constant#0}::{closure#0} @@ +trait A where + [(); (|| {}, 1).1]: Sized, +{ +} diff --git a/tests/codegen-units/item-collection/drop-glue-eager.rs b/tests/codegen-units/item-collection/drop-glue-eager.rs new file mode 100644 index 00000000000..c81074de490 --- /dev/null +++ b/tests/codegen-units/item-collection/drop-glue-eager.rs @@ -0,0 +1,56 @@ +// Ensure that we *eagerly* monomorphize drop instances for structs with lifetimes. + +//@ compile-flags:-Zprint-mono-items=eager +//@ compile-flags:--crate-type=lib + +//~ MONO_ITEM fn std::ptr::drop_in_place::<StructWithDrop> - shim(Some(StructWithDrop)) +struct StructWithDrop { + x: i32, +} + +impl Drop for StructWithDrop { + //~ MONO_ITEM fn <StructWithDrop as std::ops::Drop>::drop + fn drop(&mut self) {} +} + +struct StructNoDrop { + x: i32, +} + +//~ MONO_ITEM fn std::ptr::drop_in_place::<EnumWithDrop> - shim(Some(EnumWithDrop)) +enum EnumWithDrop { + A(i32), +} + +impl Drop for EnumWithDrop { + //~ MONO_ITEM fn <EnumWithDrop as std::ops::Drop>::drop + fn drop(&mut self) {} +} + +enum EnumNoDrop { + A(i32), +} + +// We should be able to monomorphize drops for struct with lifetimes. +impl<'a> Drop for StructWithDropAndLt<'a> { + //~ MONO_ITEM fn <StructWithDropAndLt<'_> as std::ops::Drop>::drop + fn drop(&mut self) {} +} + +//~ MONO_ITEM fn std::ptr::drop_in_place::<StructWithDropAndLt<'_>> - shim(Some(StructWithDropAndLt<'_>)) +struct StructWithDropAndLt<'a> { + x: &'a i32, +} + +// Make sure we don't ICE when checking impossible predicates for the struct. +// Regression test for <https://github.com/rust-lang/rust/issues/135515>. +//~ MONO_ITEM fn std::ptr::drop_in_place::<StructWithLtAndPredicate<'_>> - shim(Some(StructWithLtAndPredicate<'_>)) +struct StructWithLtAndPredicate<'a: 'a> { + x: &'a i32, +} + +// We should be able to monomorphize drops for struct with lifetimes. +impl<'a> Drop for StructWithLtAndPredicate<'a> { + //~ MONO_ITEM fn <StructWithLtAndPredicate<'_> as std::ops::Drop>::drop + fn drop(&mut self) {} +} diff --git a/tests/debuginfo/thread.rs b/tests/debuginfo/thread.rs index dc8cb083219..0415f586f5d 100644 --- a/tests/debuginfo/thread.rs +++ b/tests/debuginfo/thread.rs @@ -12,15 +12,15 @@ // cdb-check:join_handle,d [Type: std::thread::JoinHandle<tuple$<> >] // cdb-check: [...] __0 [Type: std::thread::JoinInner<tuple$<> >] // -// cdb-command:dx -r3 t,d +// cdb-command:dx t,d // cdb-check:t,d : [...] [Type: std::thread::Thread *] -// cdb-check: [...] __0 : Other [Type: enum2$<std::thread::Inner>] -// cdb-check: [...] __0 [Type: core::pin::Pin<alloc::sync::Arc<std::thread::OtherInner,[...]> >] +// cdb-check:[...] inner [...][Type: core::pin::Pin<alloc::sync::Arc<std::thread::Inner,alloc::alloc::Global> >] use std::thread; #[allow(unused_variables)] -fn main() { +fn main() +{ let join_handle = thread::spawn(|| { println!("Initialize a thread"); }); diff --git a/tests/incremental/overlapping-impls-in-new-solver-issue-135514.rs b/tests/incremental/overlapping-impls-in-new-solver-issue-135514.rs new file mode 100644 index 00000000000..8fcc913fa37 --- /dev/null +++ b/tests/incremental/overlapping-impls-in-new-solver-issue-135514.rs @@ -0,0 +1,40 @@ +// Regression test for #135514 where the new solver didn't properly record deps for incremental +// compilation, similarly to `track-deps-in-new-solver.rs`. +// +// In this specially crafted example, @steffahn was able to trigger unsoundness with an overlapping +// impl that was accepted during the incremental rebuild. + +//@ revisions: cpass1 cfail2 +//@ compile-flags: -Znext-solver + +pub trait Trait {} + +pub struct S0<T>(T); + +pub struct S<T>(T); +impl<T> Trait for S<T> where S0<T>: Trait {} + +pub struct W; + +pub trait Other { + type Choose<L, R>; +} + +// first impl +impl<T: Trait> Other for T { + type Choose<L, R> = L; +} + +// second impl +impl<T> Other for S<T> { + //[cfail2]~^ ERROR conflicting implementations of trait + type Choose<L, R> = R; +} + +#[cfg(cpass1)] +impl Trait for W {} + +#[cfg(cfail2)] +impl Trait for S<W> {} + +fn main() {} diff --git a/tests/run-make/rustdoc-default-output/output-default.stdout b/tests/run-make/rustdoc-default-output/output-default.stdout index c2d9309ba2e..c1b246e849c 100644 --- a/tests/run-make/rustdoc-default-output/output-default.stdout +++ b/tests/run-make/rustdoc-default-output/output-default.stdout @@ -194,7 +194,8 @@ Options: --doctest-compilation-args add arguments to be used when compiling doctests --disable-minification - removed + disable the minification of CSS/JS files + (perma-unstable, do not use with cached files) --plugin-path DIR removed, see issue #44136 <https://github.com/rust-lang/rust/issues/44136> for diff --git a/tests/rustdoc-gui/links-color.goml b/tests/rustdoc-gui/links-color.goml index ad1b5e801ca..8d26b826479 100644 --- a/tests/rustdoc-gui/links-color.goml +++ b/tests/rustdoc-gui/links-color.goml @@ -5,6 +5,7 @@ go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" // This is needed so that the text color is computed. show-text: true +// First we check the links of the different items. define-function: ( "check-colors", [theme, mod, macro, struct, enum, trait, fn, type, union, keyword, @@ -36,6 +37,11 @@ define-function: ( }, ALL, ) + move-cursor-to: ".desc a[href='long_code_block_link/index.html']" + assert-css: ( + ".desc a[href='long_code_block_link/index.html']", + {"text-decoration": "underline solid " + |mod|}, + ) }, ) diff --git a/tests/rustdoc-js-std/return-based-sort.js b/tests/rustdoc-js-std/return-based-sort.js new file mode 100644 index 00000000000..30baf1cd36e --- /dev/null +++ b/tests/rustdoc-js-std/return-based-sort.js @@ -0,0 +1,30 @@ +// test that `clone`-like functions are sorted lower when +// a search is based soley on return type + +const FILTER_CRATE = "core"; + +const EXPECTED = [ + { + 'query': '-> AllocError', + 'others': [ + { 'path': 'core::alloc::Allocator', 'name': 'allocate' }, + { 'path': 'core::alloc::AllocError', 'name': 'clone' }, + ], + }, + { + 'query': 'AllocError', + 'returned': [ + { 'path': 'core::alloc::Allocator', 'name': 'allocate' }, + { 'path': 'core::alloc::AllocError', 'name': 'clone' }, + ], + }, + { + 'query': '-> &str', + 'others': [ + // type_name_of_val should not be consider clone-like + { 'path': 'core::any', 'name': 'type_name_of_val' }, + // this returns `Option<&str>`, and thus should be sorted lower + { 'path': 'core::str::Split', 'name': 'next' }, + ], + }, +] diff --git a/tests/rustdoc-json/return_private.rs b/tests/rustdoc-json/return_private.rs index 0b341e2bda7..c238a536e0d 100644 --- a/tests/rustdoc-json/return_private.rs +++ b/tests/rustdoc-json/return_private.rs @@ -6,7 +6,7 @@ mod secret { } //@ has "$.index[*][?(@.name=='get_secret')].inner.function" -//@ is "$.index[*][?(@.name=='get_secret')].inner.function.sig.output.resolved_path.name" \"secret::Secret\" +//@ is "$.index[*][?(@.name=='get_secret')].inner.function.sig.output.resolved_path.name" \"Secret\" pub fn get_secret() -> secret::Secret { secret::Secret } diff --git a/tests/rustdoc/jump-to-def-pats.rs b/tests/rustdoc/jump-to-def-pats.rs new file mode 100644 index 00000000000..147902b44cf --- /dev/null +++ b/tests/rustdoc/jump-to-def-pats.rs @@ -0,0 +1,52 @@ +// This test ensures that patterns also get a link generated. + +//@ compile-flags: -Zunstable-options --generate-link-to-definition + +#![crate_name = "foo"] + +//@ has 'src/foo/jump-to-def-pats.rs.html' + +use std::fmt; + +pub enum MyEnum<T, E> { + Ok(T), + Err(E), + Some(T), + None, +} + +pub enum X { + A, +} + +pub fn foo() -> Result<(), ()> { + // FIXME: would be nice to be able to check both the class and the href at the same time so + // we could check the text as well... + //@ has - '//a[@class="prelude-val"]/@href' '{{channel}}/core/result/enum.Result.html#variant.Ok' + //@ has - '//a[@href="{{channel}}/core/result/enum.Result.html#variant.Ok"]' 'Ok' + Ok(()) +} + +impl<T, E> fmt::Display for MyEnum<T, E> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + //@ has - '//a[@href="#12"]' 'Self::Ok' + Self::Ok(_) => f.write_str("MyEnum::Ok"), + //@ has - '//a[@href="#13"]' 'MyEnum::Err' + MyEnum::Err(_) => f.write_str("MyEnum::Err"), + //@ has - '//a[@href="#14"]' 'Self::Some' + Self::Some(_) => f.write_str("MyEnum::Some"), + //@ has - '//a[@href="#15"]' 'Self::None' + Self::None => f.write_str("MyEnum::None"), + } + } +} + +impl X { + fn p(&self) -> &str { + match self { + //@ has - '//a[@href="#19"]' 'Self::A' + Self::A => "X::A", + } + } +} diff --git a/tests/ui/associated-types/issue-91231.rs b/tests/ui/associated-types/issue-91231.rs index d1c99fd44fa..a04ab60a7fc 100644 --- a/tests/ui/associated-types/issue-91231.rs +++ b/tests/ui/associated-types/issue-91231.rs @@ -3,7 +3,7 @@ #![feature(extern_types)] #![allow(dead_code)] -extern { +extern "C" { type Extern; } diff --git a/tests/ui/async-await/async-closures/fn-exception-target-features.stderr b/tests/ui/async-await/async-closures/fn-exception-target-features.stderr index db5895108bb..37977b45250 100644 --- a/tests/ui/async-await/async-closures/fn-exception-target-features.stderr +++ b/tests/ui/async-await/async-closures/fn-exception-target-features.stderr @@ -1,11 +1,12 @@ -error[E0277]: the trait bound `fn() -> Pin<Box<(dyn Future<Output = ()> + 'static)>> {target_feature}: AsyncFn()` is not satisfied +error[E0277]: the trait bound `#[target_features] fn() -> Pin<Box<(dyn Future<Output = ()> + 'static)>> {target_feature}: AsyncFn()` is not satisfied --> $DIR/fn-exception-target-features.rs:16:10 | LL | test(target_feature); - | ---- ^^^^^^^^^^^^^^ the trait `AsyncFn()` is not implemented for fn item `fn() -> Pin<Box<(dyn Future<Output = ()> + 'static)>> {target_feature}` + | ---- ^^^^^^^^^^^^^^ unsatisfied trait bound | | | required by a bound introduced by this call | + = help: the trait `AsyncFn()` is not implemented for fn item `#[target_features] fn() -> Pin<Box<(dyn Future<Output = ()> + 'static)>> {target_feature}` note: required by a bound in `test` --> $DIR/fn-exception-target-features.rs:13:17 | diff --git a/tests/ui/attributes/key-value-expansion.rs b/tests/ui/attributes/key-value-expansion.rs index e5700a75935..9034e0a7398 100644 --- a/tests/ui/attributes/key-value-expansion.rs +++ b/tests/ui/attributes/key-value-expansion.rs @@ -39,7 +39,7 @@ bug!(); macro_rules! doc_comment { ($x:expr) => { #[doc = $x] - extern {} + extern "C" {} }; } diff --git a/tests/ui/borrowck/issue-92157.rs b/tests/ui/borrowck/issue-92157.rs index 3a6f8908b21..a2b685cdf6e 100644 --- a/tests/ui/borrowck/issue-92157.rs +++ b/tests/ui/borrowck/issue-92157.rs @@ -5,7 +5,7 @@ #[cfg(target_os = "linux")] #[link(name = "c")] -extern {} +extern "C" {} #[lang = "start"] fn start<T>(_main: fn() -> T, _argc: isize, _argv: *const *const u8) -> isize { diff --git a/tests/ui/closures/binder/nested-closures-regions.stderr b/tests/ui/closures/binder/nested-closures-regions.stderr index a30339ac67b..909cbcaa808 100644 --- a/tests/ui/closures/binder/nested-closures-regions.stderr +++ b/tests/ui/closures/binder/nested-closures-regions.stderr @@ -9,7 +9,7 @@ LL | for<'a> || -> () { for<'c> |_: &'a ()| -> () {}; }; extern "rust-call" fn((&(),)), (), ] - = note: late-bound region is '?4 + = note: late-bound region is '?3 = note: late-bound region is '?2 = note: number of external vids: 3 = note: where '?1: '?2 @@ -26,7 +26,7 @@ LL | for<'a> || -> () { for<'c> |_: &'a ()| -> () {}; }; extern "rust-call" fn(()), (), ] - = note: late-bound region is '?2 + = note: late-bound region is '?1 note: no external requirements --> $DIR/nested-closures-regions.rs:7:1 diff --git a/tests/ui/coherence/coherence-negative-impls-copy.rs b/tests/ui/coherence/coherence-negative-impls-copy.rs index 377d750f8ba..c0d852180a5 100644 --- a/tests/ui/coherence/coherence-negative-impls-copy.rs +++ b/tests/ui/coherence/coherence-negative-impls-copy.rs @@ -18,7 +18,7 @@ impl !Copy for WithDrop {} struct Type; trait Trait {} -extern { +extern "C" { type ExternType; } diff --git a/tests/ui/conditional-compilation/cfg_accessible-not_sure.rs b/tests/ui/conditional-compilation/cfg_accessible-not_sure.rs index e357d3c6cb5..2ac57f35674 100644 --- a/tests/ui/conditional-compilation/cfg_accessible-not_sure.rs +++ b/tests/ui/conditional-compilation/cfg_accessible-not_sure.rs @@ -63,7 +63,7 @@ const B: bool = true; // ForeignType::unresolved - error -extern { +extern "C" { type ForeignType; } diff --git a/tests/ui/const-generics/type-mismatch-in-nested-goal.current.stderr b/tests/ui/const-generics/type-mismatch-in-nested-goal.current.stderr new file mode 100644 index 00000000000..c6fb07926c8 --- /dev/null +++ b/tests/ui/const-generics/type-mismatch-in-nested-goal.current.stderr @@ -0,0 +1,45 @@ +error: the constant `N` is not of type `bool` + --> $DIR/type-mismatch-in-nested-goal.rs:9:50 + | +LL | fn needs_a<const N: usize>(_: [u8; N]) where (): A<N> {} + | ^^^^ expected `bool`, found `usize` + | +note: required by a const generic parameter in `A` + --> $DIR/type-mismatch-in-nested-goal.rs:5:9 + | +LL | trait A<const B: bool> {} + | ^^^^^^^^^^^^^ required by this const generic parameter in `A` + +error: the constant `true` is not of type `usize` + --> $DIR/type-mismatch-in-nested-goal.rs:13:13 + | +LL | needs_a([]); + | ------- ^^ expected `usize`, found `bool` + | | + | required by a bound introduced by this call + | +note: required by a const generic parameter in `needs_a` + --> $DIR/type-mismatch-in-nested-goal.rs:9:12 + | +LL | fn needs_a<const N: usize>(_: [u8; N]) where (): A<N> {} + | ^^^^^^^^^^^^^^ required by this const generic parameter in `needs_a` + +error[E0308]: mismatched types + --> $DIR/type-mismatch-in-nested-goal.rs:13:13 + | +LL | needs_a([]); + | ------- ^^ expected an array with a size of true, found one with a size of 0 + | | + | arguments to this function are incorrect + | + = note: expected array `[u8; true]` + found array `[_; 0]` +note: function defined here + --> $DIR/type-mismatch-in-nested-goal.rs:9:4 + | +LL | fn needs_a<const N: usize>(_: [u8; N]) where (): A<N> {} + | ^^^^^^^ ---------- + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/const-generics/type-mismatch-in-nested-goal.next.stderr b/tests/ui/const-generics/type-mismatch-in-nested-goal.next.stderr new file mode 100644 index 00000000000..c6fb07926c8 --- /dev/null +++ b/tests/ui/const-generics/type-mismatch-in-nested-goal.next.stderr @@ -0,0 +1,45 @@ +error: the constant `N` is not of type `bool` + --> $DIR/type-mismatch-in-nested-goal.rs:9:50 + | +LL | fn needs_a<const N: usize>(_: [u8; N]) where (): A<N> {} + | ^^^^ expected `bool`, found `usize` + | +note: required by a const generic parameter in `A` + --> $DIR/type-mismatch-in-nested-goal.rs:5:9 + | +LL | trait A<const B: bool> {} + | ^^^^^^^^^^^^^ required by this const generic parameter in `A` + +error: the constant `true` is not of type `usize` + --> $DIR/type-mismatch-in-nested-goal.rs:13:13 + | +LL | needs_a([]); + | ------- ^^ expected `usize`, found `bool` + | | + | required by a bound introduced by this call + | +note: required by a const generic parameter in `needs_a` + --> $DIR/type-mismatch-in-nested-goal.rs:9:12 + | +LL | fn needs_a<const N: usize>(_: [u8; N]) where (): A<N> {} + | ^^^^^^^^^^^^^^ required by this const generic parameter in `needs_a` + +error[E0308]: mismatched types + --> $DIR/type-mismatch-in-nested-goal.rs:13:13 + | +LL | needs_a([]); + | ------- ^^ expected an array with a size of true, found one with a size of 0 + | | + | arguments to this function are incorrect + | + = note: expected array `[u8; true]` + found array `[_; 0]` +note: function defined here + --> $DIR/type-mismatch-in-nested-goal.rs:9:4 + | +LL | fn needs_a<const N: usize>(_: [u8; N]) where (): A<N> {} + | ^^^^^^^ ---------- + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/const-generics/type-mismatch-in-nested-goal.rs b/tests/ui/const-generics/type-mismatch-in-nested-goal.rs new file mode 100644 index 00000000000..fd29019f89b --- /dev/null +++ b/tests/ui/const-generics/type-mismatch-in-nested-goal.rs @@ -0,0 +1,17 @@ +//@ revisions: current next +//@[next] compile-flags: -Znext-solver +//@ ignore-compare-mode-next-solver (explicit revisions) + +trait A<const B: bool> {} + +impl A<true> for () {} + +fn needs_a<const N: usize>(_: [u8; N]) where (): A<N> {} +//~^ ERROR the constant `N` is not of type `bool` + +pub fn main() { + needs_a([]); + //~^ ERROR the constant `true` is not of type `usize` + //~| ERROR mismatched types + // FIXME(const_generics): we should hide this error as we've already errored above +} diff --git a/tests/ui/consts/const-block-const-bound.rs b/tests/ui/consts/const-block-const-bound.rs index 596aac09b31..b4b89a93e75 100644 --- a/tests/ui/consts/const-block-const-bound.rs +++ b/tests/ui/consts/const-block-const-bound.rs @@ -1,5 +1,3 @@ -//@ known-bug: #103507 - #![allow(unused)] #![feature(const_trait_impl, negative_impls, const_destruct)] @@ -16,6 +14,6 @@ impl Drop for UnconstDrop { fn main() { const { f(UnconstDrop); - //FIXME ~^ ERROR can't drop + //~^ ERROR trait bound `UnconstDrop: const Destruct` is not satisfied } } diff --git a/tests/ui/consts/const-block-const-bound.stderr b/tests/ui/consts/const-block-const-bound.stderr index 0931eff2175..14c62fb4d25 100644 --- a/tests/ui/consts/const-block-const-bound.stderr +++ b/tests/ui/consts/const-block-const-bound.stderr @@ -1,5 +1,5 @@ error[E0277]: the trait bound `UnconstDrop: const Destruct` is not satisfied - --> $DIR/const-block-const-bound.rs:18:11 + --> $DIR/const-block-const-bound.rs:16:11 | LL | f(UnconstDrop); | - ^^^^^^^^^^^ @@ -7,7 +7,7 @@ LL | f(UnconstDrop); | required by a bound introduced by this call | note: required by a bound in `f` - --> $DIR/const-block-const-bound.rs:8:15 + --> $DIR/const-block-const-bound.rs:6:15 | LL | const fn f<T: ~const Destruct>(x: T) {} | ^^^^^^ required by this bound in `f` diff --git a/tests/ui/consts/const-eval/validation-ice-extern-type-field.rs b/tests/ui/consts/const-eval/validation-ice-extern-type-field.rs index 3502409d576..8a32b170c40 100644 --- a/tests/ui/consts/const-eval/validation-ice-extern-type-field.rs +++ b/tests/ui/consts/const-eval/validation-ice-extern-type-field.rs @@ -1,6 +1,6 @@ #![feature(extern_types)] -extern { +extern "C" { type Opaque; } diff --git a/tests/ui/consts/issue-94675.rs b/tests/ui/consts/issue-94675.rs index 2e30eebb07b..e1c6861c510 100644 --- a/tests/ui/consts/issue-94675.rs +++ b/tests/ui/consts/issue-94675.rs @@ -1,5 +1,3 @@ -//@ known-bug: #103507 - #![feature(const_trait_impl, const_vec_string_slice)] struct Foo<'a> { @@ -9,9 +7,7 @@ struct Foo<'a> { impl<'a> Foo<'a> { const fn spam(&mut self, baz: &mut Vec<u32>) { self.bar[0] = baz.len(); - //FIXME ~^ ERROR: cannot call - //FIXME ~| ERROR: cannot call - //FIXME ~| ERROR: the trait bound + //~^ ERROR: cannot call } } diff --git a/tests/ui/consts/issue-94675.stderr b/tests/ui/consts/issue-94675.stderr index 8cad13724f2..63a86b45633 100644 --- a/tests/ui/consts/issue-94675.stderr +++ b/tests/ui/consts/issue-94675.stderr @@ -1,5 +1,5 @@ error[E0015]: cannot call non-const operator in constant functions - --> $DIR/issue-94675.rs:11:17 + --> $DIR/issue-94675.rs:9:17 | LL | self.bar[0] = baz.len(); | ^^^ diff --git a/tests/ui/consts/promoted-const-drop.rs b/tests/ui/consts/promoted-const-drop.rs index e09c30ea785..1d1897e15d4 100644 --- a/tests/ui/consts/promoted-const-drop.rs +++ b/tests/ui/consts/promoted-const-drop.rs @@ -1,4 +1,4 @@ -#![feature(const_trait_impl)] +#![feature(const_trait_impl, const_destruct)] struct A(); diff --git a/tests/ui/consts/promoted_const_call.rs b/tests/ui/consts/promoted_const_call.rs index c3920ff7241..79cb2ea2a02 100644 --- a/tests/ui/consts/promoted_const_call.rs +++ b/tests/ui/consts/promoted_const_call.rs @@ -1,6 +1,4 @@ -//@ known-bug: #103507 - -#![feature(const_trait_impl)] +#![feature(const_trait_impl, const_destruct)] struct Panic; impl const Drop for Panic { fn drop(&mut self) { panic!(); } } @@ -8,15 +6,15 @@ impl const Drop for Panic { fn drop(&mut self) { panic!(); } } pub const fn id<T>(x: T) -> T { x } pub const C: () = { let _: &'static _ = &id(&Panic); - //FIXME ~^ ERROR: temporary value dropped while borrowed - //FIXME ~| ERROR: temporary value dropped while borrowed + //~^ ERROR: temporary value dropped while borrowed + //~| ERROR: temporary value dropped while borrowed }; fn main() { let _: &'static _ = &id(&Panic); - //FIXME ~^ ERROR: temporary value dropped while borrowed - //FIXME ~| ERROR: temporary value dropped while borrowed + //~^ ERROR: temporary value dropped while borrowed + //~| ERROR: temporary value dropped while borrowed let _: &'static _ = &&(Panic, 0).1; - //FIXME~^ ERROR: temporary value dropped while borrowed - //FIXME~| ERROR: temporary value dropped while borrowed + //~^ ERROR: temporary value dropped while borrowed + //~| ERROR: temporary value dropped while borrowed } diff --git a/tests/ui/consts/promoted_const_call.stderr b/tests/ui/consts/promoted_const_call.stderr index 40c6d083b06..7a9cdd68704 100644 --- a/tests/ui/consts/promoted_const_call.stderr +++ b/tests/ui/consts/promoted_const_call.stderr @@ -1,17 +1,25 @@ -error[E0493]: destructor of `Panic` cannot be evaluated at compile-time - --> $DIR/promoted_const_call.rs:10:30 +error[E0716]: temporary value dropped while borrowed + --> $DIR/promoted_const_call.rs:8:26 | LL | let _: &'static _ = &id(&Panic); - | ^^^^^ - value is dropped here - | | - | the destructor for this type cannot be evaluated in constants + | ---------- ^^^^^^^^^^ creates a temporary value which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` +... +LL | }; + | - temporary value is freed at the end of this statement + +error[E0716]: temporary value dropped while borrowed + --> $DIR/promoted_const_call.rs:8:30 | - = note: see issue #133214 <https://github.com/rust-lang/rust/issues/133214> for more information - = help: add `#![feature(const_destruct)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date +LL | let _: &'static _ = &id(&Panic); + | ---------- ^^^^^ - temporary value is freed at the end of this statement + | | | + | | creates a temporary value which is freed while still in use + | type annotation requires that borrow lasts for `'static` error[E0716]: temporary value dropped while borrowed - --> $DIR/promoted_const_call.rs:16:26 + --> $DIR/promoted_const_call.rs:14:26 | LL | let _: &'static _ = &id(&Panic); | ---------- ^^^^^^^^^^ creates a temporary value which is freed while still in use @@ -22,7 +30,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promoted_const_call.rs:16:30 + --> $DIR/promoted_const_call.rs:14:30 | LL | let _: &'static _ = &id(&Panic); | ---------- ^^^^^ - temporary value is freed at the end of this statement @@ -31,7 +39,7 @@ LL | let _: &'static _ = &id(&Panic); | type annotation requires that borrow lasts for `'static` error[E0716]: temporary value dropped while borrowed - --> $DIR/promoted_const_call.rs:19:26 + --> $DIR/promoted_const_call.rs:17:26 | LL | let _: &'static _ = &&(Panic, 0).1; | ---------- ^^^^^^^^^^^^^ creates a temporary value which is freed while still in use @@ -42,7 +50,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promoted_const_call.rs:19:27 + --> $DIR/promoted_const_call.rs:17:27 | LL | let _: &'static _ = &&(Panic, 0).1; | ---------- ^^^^^^^^^^ creates a temporary value which is freed while still in use @@ -52,7 +60,6 @@ LL | let _: &'static _ = &&(Panic, 0).1; LL | } | - temporary value is freed at the end of this statement -error: aborting due to 5 previous errors +error: aborting due to 6 previous errors -Some errors have detailed explanations: E0493, E0716. -For more information about an error, try `rustc --explain E0493`. +For more information about this error, try `rustc --explain E0716`. diff --git a/tests/ui/delegation/glob-non-impl.rs b/tests/ui/delegation/glob-non-impl.rs index d523731eeb3..e3a4061fb15 100644 --- a/tests/ui/delegation/glob-non-impl.rs +++ b/tests/ui/delegation/glob-non-impl.rs @@ -11,7 +11,7 @@ trait OtherTrait { reuse Trait::*; //~ ERROR glob delegation is only supported in impls } -extern { +extern "C" { reuse Trait::*; //~ ERROR delegation is not supported in `extern` blocks } diff --git a/tests/ui/enum-discriminant/eval-error.rs b/tests/ui/enum-discriminant/eval-error.rs new file mode 100644 index 00000000000..f2c3b581627 --- /dev/null +++ b/tests/ui/enum-discriminant/eval-error.rs @@ -0,0 +1,37 @@ +union Foo { + a: str, + //~^ ERROR the size for values of type `str` cannot be known at compilation time + //~| ERROR field must implement `Copy` or be wrapped in `ManuallyDrop<...>` +} + +enum Bar { + Boo = { + let _: Option<Foo> = None; + 0 + }, +} + +union Foo2 {} +//~^ ERROR unions cannot have zero fields + +enum Bar2 { + Boo = { + let _: Option<Foo2> = None; + 0 + }, +} + +#[repr(u8, packed)] +//~^ ERROR attribute should be applied to a struct or union +enum Foo3 { + A +} + +enum Bar3 { + Boo = { + let _: Option<Foo3> = None; + 0 + }, +} + +fn main() {} diff --git a/tests/ui/enum-discriminant/eval-error.stderr b/tests/ui/enum-discriminant/eval-error.stderr new file mode 100644 index 00000000000..0f12308de3c --- /dev/null +++ b/tests/ui/enum-discriminant/eval-error.stderr @@ -0,0 +1,51 @@ +error: unions cannot have zero fields + --> $DIR/eval-error.rs:14:1 + | +LL | union Foo2 {} + | ^^^^^^^^^^^^^ + +error[E0517]: attribute should be applied to a struct or union + --> $DIR/eval-error.rs:24:12 + | +LL | #[repr(u8, packed)] + | ^^^^^^ +LL | +LL | / enum Foo3 { +LL | | A +LL | | } + | |_- not a struct or union + +error[E0277]: the size for values of type `str` cannot be known at compilation time + --> $DIR/eval-error.rs:2:8 + | +LL | a: str, + | ^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `str` + = note: no field of a union may have a dynamically sized type + = help: change the field's type to have a statically known size +help: borrowed types always have a statically known size + | +LL | a: &str, + | + +help: the `Box` type always has a statically known size and allocates its contents in the heap + | +LL | a: Box<str>, + | ++++ + + +error[E0740]: field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union + --> $DIR/eval-error.rs:2:5 + | +LL | a: str, + | ^^^^^^ + | + = note: union fields must not have drop side-effects, which is currently enforced via either `Copy` or `ManuallyDrop<...>` +help: wrap the field type in `ManuallyDrop<...>` + | +LL | a: std::mem::ManuallyDrop<str>, + | +++++++++++++++++++++++ + + +error: aborting due to 4 previous errors + +Some errors have detailed explanations: E0277, E0517, E0740. +For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/extern/extern-type-diag-not-similar.rs b/tests/ui/extern/extern-type-diag-not-similar.rs index 39d00a6c1bc..cd3eec9f1f7 100644 --- a/tests/ui/extern/extern-type-diag-not-similar.rs +++ b/tests/ui/extern/extern-type-diag-not-similar.rs @@ -4,11 +4,11 @@ // because they are both extern types. #![feature(extern_types)] -extern { +extern "C" { type ShouldNotBeMentioned; } -extern { +extern "C" { type Foo; } diff --git a/tests/ui/extern/issue-10025.rs b/tests/ui/extern/issue-10025.rs index 140012f4a16..9be0f616fd2 100644 --- a/tests/ui/extern/issue-10025.rs +++ b/tests/ui/extern/issue-10025.rs @@ -1,5 +1,5 @@ //@ run-pass -#![allow(dead_code)] +#![allow(dead_code, missing_abi)] unsafe extern fn foo() {} unsafe extern "C" fn bar() {} diff --git a/tests/ui/extern/issue-95829.rs b/tests/ui/extern/issue-95829.rs index c5ae4c68265..493d53d2532 100644 --- a/tests/ui/extern/issue-95829.rs +++ b/tests/ui/extern/issue-95829.rs @@ -1,6 +1,6 @@ //@ edition:2018 -extern { +extern "C" { async fn L() { //~ ERROR: incorrect function inside `extern` block //~^ ERROR: functions in `extern` blocks cannot have `async` qualifier async fn M() {} diff --git a/tests/ui/extern/issue-95829.stderr b/tests/ui/extern/issue-95829.stderr index 2f396b8cc04..2acd0fa3a26 100644 --- a/tests/ui/extern/issue-95829.stderr +++ b/tests/ui/extern/issue-95829.stderr @@ -1,8 +1,8 @@ error: incorrect function inside `extern` block --> $DIR/issue-95829.rs:4:14 | -LL | extern { - | ------ `extern` blocks define existing foreign functions and functions inside of them cannot have a body +LL | extern "C" { + | ---------- `extern` blocks define existing foreign functions and functions inside of them cannot have a body LL | async fn L() { | ______________^___- | | | @@ -18,8 +18,8 @@ LL | | } error: functions in `extern` blocks cannot have `async` qualifier --> $DIR/issue-95829.rs:4:5 | -LL | extern { - | ------ in this `extern` block +LL | extern "C" { + | ---------- in this `extern` block LL | async fn L() { | ^^^^^ help: remove the `async` qualifier diff --git a/tests/ui/extern/not-in-block.rs b/tests/ui/extern/not-in-block.rs index d3bcafdef7b..c2161635090 100644 --- a/tests/ui/extern/not-in-block.rs +++ b/tests/ui/extern/not-in-block.rs @@ -1,4 +1,5 @@ #![crate_type = "lib"] +#![allow(missing_abi)] extern fn none_fn(x: bool) -> i32; //~^ ERROR free function without a body diff --git a/tests/ui/extern/not-in-block.stderr b/tests/ui/extern/not-in-block.stderr index 2544949ab17..f86c279a234 100644 --- a/tests/ui/extern/not-in-block.stderr +++ b/tests/ui/extern/not-in-block.stderr @@ -1,5 +1,5 @@ error: free function without a body - --> $DIR/not-in-block.rs:3:1 + --> $DIR/not-in-block.rs:4:1 | LL | extern fn none_fn(x: bool) -> i32; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -14,7 +14,7 @@ LL | extern { fn none_fn(x: bool) -> i32; } | ~~~~~~~~ + error: free function without a body - --> $DIR/not-in-block.rs:5:1 + --> $DIR/not-in-block.rs:6:1 | LL | extern "C" fn c_fn(x: bool) -> i32; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/foreign/issue-91370-foreign-fn-block-impl.rs b/tests/ui/foreign/issue-91370-foreign-fn-block-impl.rs index 2ac3ca29355..e8634de86ea 100644 --- a/tests/ui/foreign/issue-91370-foreign-fn-block-impl.rs +++ b/tests/ui/foreign/issue-91370-foreign-fn-block-impl.rs @@ -1,6 +1,6 @@ // Regression test for issue #91370. -extern { +extern "C" { //~^ `extern` blocks define existing foreign functions fn f() { //~^ incorrect function inside `extern` block diff --git a/tests/ui/foreign/issue-91370-foreign-fn-block-impl.stderr b/tests/ui/foreign/issue-91370-foreign-fn-block-impl.stderr index fea2ab61e92..155fdf9d09a 100644 --- a/tests/ui/foreign/issue-91370-foreign-fn-block-impl.stderr +++ b/tests/ui/foreign/issue-91370-foreign-fn-block-impl.stderr @@ -1,8 +1,8 @@ error: incorrect function inside `extern` block --> $DIR/issue-91370-foreign-fn-block-impl.rs:5:8 | -LL | extern { - | ------ `extern` blocks define existing foreign functions and functions inside of them cannot have a body +LL | extern "C" { + | ---------- `extern` blocks define existing foreign functions and functions inside of them cannot have a body LL | LL | fn f() { | ________^___- diff --git a/tests/ui/impl-trait/normalize-tait-in-const.rs b/tests/ui/impl-trait/normalize-tait-in-const.rs index 1fd543b72e7..a735ef76673 100644 --- a/tests/ui/impl-trait/normalize-tait-in-const.rs +++ b/tests/ui/impl-trait/normalize-tait-in-const.rs @@ -1,4 +1,5 @@ -//@ known-bug: #103507 +//! This is a regression test for <https://github.com/rust-lang/rust/issues/103507>. +//@ known-bug: #110395 #![feature(type_alias_impl_trait)] #![feature(const_trait_impl, const_destruct)] diff --git a/tests/ui/impl-trait/normalize-tait-in-const.stderr b/tests/ui/impl-trait/normalize-tait-in-const.stderr index f4e8a872cec..c6cd1b139c5 100644 --- a/tests/ui/impl-trait/normalize-tait-in-const.stderr +++ b/tests/ui/impl-trait/normalize-tait-in-const.stderr @@ -1,5 +1,5 @@ error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/normalize-tait-in-const.rs:26:35 + --> $DIR/normalize-tait-in-const.rs:27:35 | LL | const fn with_positive<F: for<'a> ~const Fn(&'a Alias<'a>) + ~const Destruct>(fun: F) { | ^^^^^^ can't be applied to `Fn` @@ -8,7 +8,7 @@ note: `Fn` can't be used with `~const` because it isn't annotated with `#[const_ --> $SRC_DIR/core/src/ops/function.rs:LL:COL error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/normalize-tait-in-const.rs:26:35 + --> $DIR/normalize-tait-in-const.rs:27:35 | LL | const fn with_positive<F: for<'a> ~const Fn(&'a Alias<'a>) + ~const Destruct>(fun: F) { | ^^^^^^ can't be applied to `Fn` @@ -18,7 +18,7 @@ note: `Fn` can't be used with `~const` because it isn't annotated with `#[const_ = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0015]: cannot call non-const closure in constant functions - --> $DIR/normalize-tait-in-const.rs:27:5 + --> $DIR/normalize-tait-in-const.rs:28:5 | LL | fun(filter_positive()); | ^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/invalid/invalid-rustc_legacy_const_generics-arguments.rs b/tests/ui/invalid/invalid-rustc_legacy_const_generics-arguments.rs index 6eabd9b1015..73a0363904a 100644 --- a/tests/ui/invalid/invalid-rustc_legacy_const_generics-arguments.rs +++ b/tests/ui/invalid/invalid-rustc_legacy_const_generics-arguments.rs @@ -21,7 +21,7 @@ struct S; #[rustc_legacy_const_generics(0usize)] //~ ERROR suffixed literals are not allowed in attributes fn foo6<const X: usize>() {} -extern { +extern "C" { #[rustc_legacy_const_generics(1)] //~ ERROR attribute should be applied to a function fn foo7<const X: usize>(); //~ ERROR foreign items may not have const parameters } diff --git a/tests/ui/invalid_dispatch_from_dyn_impls.stderr b/tests/ui/invalid_dispatch_from_dyn_impls.stderr index 168ed37d0e6..02718334c73 100644 --- a/tests/ui/invalid_dispatch_from_dyn_impls.stderr +++ b/tests/ui/invalid_dispatch_from_dyn_impls.stderr @@ -1,4 +1,4 @@ -error[E0378]: the trait `DispatchFromDyn` may only be implemented for structs containing the field being coerced, ZST fields with 1 byte alignment, and nothing else +error[E0378]: the trait `DispatchFromDyn` may only be implemented for structs containing the field being coerced, ZST fields with 1 byte alignment that don't mention type/const generics, and nothing else --> $DIR/invalid_dispatch_from_dyn_impls.rs:10:1 | LL | / impl<T, U> DispatchFromDyn<WrapperWithExtraField<U>> for WrapperWithExtraField<T> @@ -35,7 +35,7 @@ LL | | where LL | | T: Unsize<U>, | |_________________^ -error[E0378]: the trait `DispatchFromDyn` may only be implemented for structs containing the field being coerced, ZST fields with 1 byte alignment, and nothing else +error[E0378]: the trait `DispatchFromDyn` may only be implemented for structs containing the field being coerced, ZST fields with 1 byte alignment that don't mention type/const generics, and nothing else --> $DIR/invalid_dispatch_from_dyn_impls.rs:46:1 | LL | / impl<T: ?Sized, U: ?Sized> DispatchFromDyn<OverAligned<U>> for OverAligned<T> diff --git a/tests/ui/issues/issue-25901.rs b/tests/ui/issues/issue-25901.rs index bfcee1ac503..0ca34da95f5 100644 --- a/tests/ui/issues/issue-25901.rs +++ b/tests/ui/issues/issue-25901.rs @@ -2,7 +2,7 @@ struct A; struct B; static S: &'static B = &A; -//~^ ERROR cannot perform conditionally-const deref coercion +//~^ ERROR cannot perform non-const deref coercion use std::ops::Deref; diff --git a/tests/ui/issues/issue-25901.stderr b/tests/ui/issues/issue-25901.stderr index a954f38af83..233b5bfee50 100644 --- a/tests/ui/issues/issue-25901.stderr +++ b/tests/ui/issues/issue-25901.stderr @@ -1,4 +1,4 @@ -error[E0658]: cannot perform conditionally-const deref coercion on `A` in statics +error[E0015]: cannot perform non-const deref coercion on `A` in statics --> $DIR/issue-25901.rs:4:24 | LL | static S: &'static B = &A; @@ -10,11 +10,14 @@ note: deref defined here | LL | type Target = B; | ^^^^^^^^^^^ +note: impl defined here, but it is not `const` + --> $DIR/issue-25901.rs:9:1 + | +LL | impl Deref for A { + | ^^^^^^^^^^^^^^^^ = note: calls in statics are limited to constant functions, tuple structs and tuple variants - = note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information - = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + = note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)` error: aborting due to 1 previous error -For more information about this error, try `rustc --explain E0658`. +For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/layout/base-layout-is-sized-ice-123078.rs b/tests/ui/layout/base-layout-is-sized-ice-123078.rs index b1c33e15075..15f11145f84 100644 --- a/tests/ui/layout/base-layout-is-sized-ice-123078.rs +++ b/tests/ui/layout/base-layout-is-sized-ice-123078.rs @@ -8,7 +8,6 @@ struct S { } const C: S = unsafe { std::mem::transmute(()) }; -//~^ ERROR cannot transmute between types of different sizes, or dependently-sized types const _: [(); { C; 0 diff --git a/tests/ui/layout/base-layout-is-sized-ice-123078.stderr b/tests/ui/layout/base-layout-is-sized-ice-123078.stderr index 455bd2cbf8b..9181368533a 100644 --- a/tests/ui/layout/base-layout-is-sized-ice-123078.stderr +++ b/tests/ui/layout/base-layout-is-sized-ice-123078.stderr @@ -16,16 +16,6 @@ help: the `Box` type always has a statically known size and allocates its conten LL | a: Box<[u8]>, | ++++ + -error[E0512]: cannot transmute between types of different sizes, or dependently-sized types - --> $DIR/base-layout-is-sized-ice-123078.rs:10:23 - | -LL | const C: S = unsafe { std::mem::transmute(()) }; - | ^^^^^^^^^^^^^^^^^^^ - | - = note: source type: `()` (0 bits) - = note: target type: `S` (size can vary because of [u8]) - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error -Some errors have detailed explanations: E0277, E0512. -For more information about an error, try `rustc --explain E0277`. +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/layout/debug.stderr b/tests/ui/layout/debug.stderr index 1fc55511384..319c0de26a9 100644 --- a/tests/ui/layout/debug.stderr +++ b/tests/ui/layout/debug.stderr @@ -590,7 +590,7 @@ LL | type Impossible = (str, str); = help: the trait `Sized` is not implemented for `str` = note: only the last element of a tuple may have a dynamically sized type -error: the type `EmptyUnion` has an unknown layout +error: the type has an unknown layout --> $DIR/debug.rs:83:1 | LL | union EmptyUnion {} diff --git a/tests/ui/link-native-libs/issue-109144.rs b/tests/ui/link-native-libs/issue-109144.rs index 2f740e55389..6970a4989bb 100644 --- a/tests/ui/link-native-libs/issue-109144.rs +++ b/tests/ui/link-native-libs/issue-109144.rs @@ -1,4 +1,4 @@ #![crate_type = "lib"] #[link(kind = "static", modifiers = "+whole-archive,+bundle")] //~^ ERROR `#[link]` attribute requires a `name = "string"` argument -extern {} +extern "C" {} diff --git a/tests/ui/link-native-libs/suggest-libname-only-1.stderr b/tests/ui/link-native-libs/suggest-libname-only-1.stderr index e142835a9d6..aae8f7de966 100644 --- a/tests/ui/link-native-libs/suggest-libname-only-1.stderr +++ b/tests/ui/link-native-libs/suggest-libname-only-1.stderr @@ -1,6 +1,14 @@ +warning: extern declarations without an explicit ABI are deprecated + --> $DIR/suggest-libname-only-1.rs:7:1 + | +LL | extern { } + | ^^^^^^ help: explicitly specify the C ABI: `extern "C"` + | + = note: `#[warn(missing_abi)]` on by default + error: could not find native static library `libfoo.a`, perhaps an -L flag is missing? | = help: only provide the library name `foo`, not the full filename -error: aborting due to 1 previous error +error: aborting due to 1 previous error; 1 warning emitted diff --git a/tests/ui/link-native-libs/suggest-libname-only-2.stderr b/tests/ui/link-native-libs/suggest-libname-only-2.stderr index 392d2f01f61..a2adaee3f97 100644 --- a/tests/ui/link-native-libs/suggest-libname-only-2.stderr +++ b/tests/ui/link-native-libs/suggest-libname-only-2.stderr @@ -1,6 +1,14 @@ +warning: extern declarations without an explicit ABI are deprecated + --> $DIR/suggest-libname-only-2.rs:7:1 + | +LL | extern { } + | ^^^^^^ help: explicitly specify the C ABI: `extern "C"` + | + = note: `#[warn(missing_abi)]` on by default + error: could not find native static library `bar.lib`, perhaps an -L flag is missing? | = help: only provide the library name `bar`, not the full filename -error: aborting due to 1 previous error +error: aborting due to 1 previous error; 1 warning emitted diff --git a/tests/ui/lint/function-item-references.rs b/tests/ui/lint/function-item-references.rs index 918d72e28a9..4f2fc4de863 100644 --- a/tests/ui/lint/function-item-references.rs +++ b/tests/ui/lint/function-item-references.rs @@ -11,7 +11,7 @@ fn baz(x: u32, y: u32) -> u32 { x + y } unsafe fn unsafe_fn() { } extern "C" fn c_fn() { } unsafe extern "C" fn unsafe_c_fn() { } -unsafe extern fn variadic(_x: u32, _args: ...) { } +unsafe extern "C" fn variadic(_x: u32, _args: ...) { } fn take_generic_ref<'a, T>(_x: &'a T) { } fn take_generic_array<T, const N: usize>(_x: [T; N]) { } fn multiple_generic<T, U>(_x: T, _y: U) { } diff --git a/tests/ui/lint/lint-ctypes.rs b/tests/ui/lint/lint-ctypes.rs index dae07930aba..6dd9be10a48 100644 --- a/tests/ui/lint/lint-ctypes.rs +++ b/tests/ui/lint/lint-ctypes.rs @@ -72,7 +72,7 @@ extern "C" { pub fn transparent_fn(p: TransparentBadFn); //~ ERROR: uses type `Box<u32>` pub fn raw_array(arr: [u8; 8]); //~ ERROR: uses type `[u8; 8]` - pub fn no_niche_a(a: Option<UnsafeCell<extern fn()>>); + pub fn no_niche_a(a: Option<UnsafeCell<extern "C" fn()>>); //~^ ERROR: uses type `Option<UnsafeCell<extern "C" fn()>>` pub fn no_niche_b(b: Option<UnsafeCell<&i32>>); //~^ ERROR: uses type `Option<UnsafeCell<&i32>>` diff --git a/tests/ui/lint/lint-ctypes.stderr b/tests/ui/lint/lint-ctypes.stderr index 2c81c7b8e4b..8137ae868d3 100644 --- a/tests/ui/lint/lint-ctypes.stderr +++ b/tests/ui/lint/lint-ctypes.stderr @@ -227,8 +227,8 @@ LL | pub fn raw_array(arr: [u8; 8]); error: `extern` block uses type `Option<UnsafeCell<extern "C" fn()>>`, which is not FFI-safe --> $DIR/lint-ctypes.rs:75:26 | -LL | pub fn no_niche_a(a: Option<UnsafeCell<extern fn()>>); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe +LL | pub fn no_niche_a(a: Option<UnsafeCell<extern "C" fn()>>); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe | = help: consider adding a `#[repr(C)]`, `#[repr(transparent)]`, or integer `#[repr(...)]` attribute to this enum = note: enum has no representation hint diff --git a/tests/ui/macros/issue-68060.rs b/tests/ui/macros/issue-68060.rs index 1a826bd60e0..4eddb96848c 100644 --- a/tests/ui/macros/issue-68060.rs +++ b/tests/ui/macros/issue-68060.rs @@ -3,8 +3,6 @@ fn main() { .map( #[target_feature(enable = "")] //~^ ERROR: attribute should be applied to a function - //~| ERROR: feature named `` is not valid - //~| NOTE: `` is not valid for this target #[track_caller] //~^ ERROR: `#[track_caller]` on closures is currently unstable //~| NOTE: see issue #87417 diff --git a/tests/ui/macros/issue-68060.stderr b/tests/ui/macros/issue-68060.stderr index 5724a9ea438..ef2246d5bd6 100644 --- a/tests/ui/macros/issue-68060.stderr +++ b/tests/ui/macros/issue-68060.stderr @@ -7,14 +7,8 @@ LL | #[target_feature(enable = "")] LL | |_| (), | ------ not a function definition -error: the feature named `` is not valid for this target - --> $DIR/issue-68060.rs:4:30 - | -LL | #[target_feature(enable = "")] - | ^^^^^^^^^^^ `` is not valid for this target - error[E0658]: `#[track_caller]` on closures is currently unstable - --> $DIR/issue-68060.rs:8:13 + --> $DIR/issue-68060.rs:6:13 | LL | #[track_caller] | ^^^^^^^^^^^^^^^ @@ -23,6 +17,6 @@ LL | #[track_caller] = help: add `#![feature(closure_track_caller)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/nll/closure-requirements/escape-argument-callee.stderr b/tests/ui/nll/closure-requirements/escape-argument-callee.stderr index a7a59dccf22..a445534c8d8 100644 --- a/tests/ui/nll/closure-requirements/escape-argument-callee.stderr +++ b/tests/ui/nll/closure-requirements/escape-argument-callee.stderr @@ -17,7 +17,7 @@ LL | let mut closure = expect_sig(|p, y| *p = y); | - - ^^^^^^ assignment requires that `'1` must outlive `'2` | | | | | has type `&'1 i32` - | has type `&'?2 mut &'2 i32` + | has type `&'?1 mut &'2 i32` note: no external requirements --> $DIR/escape-argument-callee.rs:20:1 diff --git a/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-comparing-against-free.stderr b/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-comparing-against-free.stderr index 0094d7a50d3..621c1ea083b 100644 --- a/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-comparing-against-free.stderr +++ b/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-comparing-against-free.stderr @@ -20,7 +20,7 @@ LL | foo(cell, |cell_a, cell_x| { LL | cell_a.set(cell_x.get()); // forces 'x: 'a, error in closure | ^^^^^^^^^^^^^^^^^^^^^^^^ `cell_x` escapes the closure body here | - = note: requirement occurs because of the type `Cell<&'?8 u32>`, which makes the generic argument `&'?8 u32` invariant + = note: requirement occurs because of the type `Cell<&'?9 u32>`, which makes the generic argument `&'?9 u32` invariant = note: the struct `Cell<T>` is invariant over the parameter `T` = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance diff --git a/tests/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-no-bounds.stderr b/tests/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-no-bounds.stderr index 4558ff50674..f48ed2823dd 100644 --- a/tests/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-no-bounds.stderr +++ b/tests/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-no-bounds.stderr @@ -16,9 +16,9 @@ error: lifetime may not live long enough --> $DIR/propagate-fail-to-approximate-longer-no-bounds.rs:37:9 | LL | establish_relationships(&cell_a, &cell_b, |_outlives, x, y| { - | --------- - has type `&'?7 Cell<&'1 u32>` + | --------- - has type `&'?6 Cell<&'1 u32>` | | - | has type `&'?5 Cell<&'2 &'?1 u32>` + | has type `&'?4 Cell<&'2 &'?1 u32>` LL | // Only works if 'x: 'y: LL | demand_y(x, y, x.get()) | ^^^^^^^^^^^^^^^^^^^^^^^ argument requires that `'1` must outlive `'2` diff --git a/tests/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-wrong-bounds.stderr b/tests/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-wrong-bounds.stderr index 83173ae80c0..a090e94593f 100644 --- a/tests/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-wrong-bounds.stderr +++ b/tests/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-wrong-bounds.stderr @@ -16,9 +16,9 @@ error: lifetime may not live long enough --> $DIR/propagate-fail-to-approximate-longer-wrong-bounds.rs:41:9 | LL | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| { - | ---------- ---------- has type `&'?8 Cell<&'2 &'?2 u32>` + | ---------- ---------- has type `&'?7 Cell<&'2 &'?2 u32>` | | - | has type `&'?6 Cell<&'1 &'?1 u32>` + | has type `&'?5 Cell<&'1 &'?1 u32>` LL | // Only works if 'x: 'y: LL | demand_y(x, y, x.get()) | ^^^^^^^^^^^^^^^^^^^^^^^ argument requires that `'1` must outlive `'2` diff --git a/tests/ui/offset-of/offset-of-dst-field.rs b/tests/ui/offset-of/offset-of-dst-field.rs index 5ae15f32357..2e0bdb151e1 100644 --- a/tests/ui/offset-of/offset-of-dst-field.rs +++ b/tests/ui/offset-of/offset-of-dst-field.rs @@ -16,7 +16,7 @@ struct Beta { z: dyn Trait, } -extern { +extern "C" { type Extern; } diff --git a/tests/ui/parser/bad-fn-ptr-qualifier.fixed b/tests/ui/parser/bad-fn-ptr-qualifier.fixed index 558a27cd456..e2a2f9486b7 100644 --- a/tests/ui/parser/bad-fn-ptr-qualifier.fixed +++ b/tests/ui/parser/bad-fn-ptr-qualifier.fixed @@ -4,9 +4,9 @@ pub type T0 = fn(); //~ ERROR an `fn` pointer type cannot be `const` pub type T1 = extern "C" fn(); //~ ERROR an `fn` pointer type cannot be `const` -pub type T2 = unsafe extern fn(); //~ ERROR an `fn` pointer type cannot be `const` +pub type T2 = unsafe extern "C" fn(); //~ ERROR an `fn` pointer type cannot be `const` pub type T3 = fn(); //~ ERROR an `fn` pointer type cannot be `async` -pub type T4 = extern fn(); //~ ERROR an `fn` pointer type cannot be `async` +pub type T4 = extern "C" fn(); //~ ERROR an `fn` pointer type cannot be `async` pub type T5 = unsafe extern "C" fn(); //~ ERROR an `fn` pointer type cannot be `async` pub type T6 = unsafe extern "C" fn(); //~^ ERROR an `fn` pointer type cannot be `const` @@ -14,9 +14,9 @@ pub type T6 = unsafe extern "C" fn(); pub type FTT0 = for<'a> fn(); //~ ERROR an `fn` pointer type cannot be `const` pub type FTT1 = for<'a> extern "C" fn(); //~ ERROR an `fn` pointer type cannot be `const` -pub type FTT2 = for<'a> unsafe extern fn(); //~ ERROR an `fn` pointer type cannot be `const` +pub type FTT2 = for<'a> unsafe extern "C" fn(); //~ ERROR an `fn` pointer type cannot be `const` pub type FTT3 = for<'a> fn(); //~ ERROR an `fn` pointer type cannot be `async` -pub type FTT4 = for<'a> extern fn(); //~ ERROR an `fn` pointer type cannot be `async` +pub type FTT4 = for<'a> extern "C" fn(); //~ ERROR an `fn` pointer type cannot be `async` pub type FTT5 = for<'a> unsafe extern "C" fn(); //~^ ERROR an `fn` pointer type cannot be `async` pub type FTT6 = for<'a> unsafe extern "C" fn(); diff --git a/tests/ui/parser/bad-fn-ptr-qualifier.rs b/tests/ui/parser/bad-fn-ptr-qualifier.rs index 9750f480935..f2611c93b17 100644 --- a/tests/ui/parser/bad-fn-ptr-qualifier.rs +++ b/tests/ui/parser/bad-fn-ptr-qualifier.rs @@ -4,9 +4,9 @@ pub type T0 = const fn(); //~ ERROR an `fn` pointer type cannot be `const` pub type T1 = const extern "C" fn(); //~ ERROR an `fn` pointer type cannot be `const` -pub type T2 = const unsafe extern fn(); //~ ERROR an `fn` pointer type cannot be `const` +pub type T2 = const unsafe extern "C" fn(); //~ ERROR an `fn` pointer type cannot be `const` pub type T3 = async fn(); //~ ERROR an `fn` pointer type cannot be `async` -pub type T4 = async extern fn(); //~ ERROR an `fn` pointer type cannot be `async` +pub type T4 = async extern "C" fn(); //~ ERROR an `fn` pointer type cannot be `async` pub type T5 = async unsafe extern "C" fn(); //~ ERROR an `fn` pointer type cannot be `async` pub type T6 = const async unsafe extern "C" fn(); //~^ ERROR an `fn` pointer type cannot be `const` @@ -14,9 +14,9 @@ pub type T6 = const async unsafe extern "C" fn(); pub type FTT0 = for<'a> const fn(); //~ ERROR an `fn` pointer type cannot be `const` pub type FTT1 = for<'a> const extern "C" fn(); //~ ERROR an `fn` pointer type cannot be `const` -pub type FTT2 = for<'a> const unsafe extern fn(); //~ ERROR an `fn` pointer type cannot be `const` +pub type FTT2 = for<'a> const unsafe extern "C" fn(); //~ ERROR an `fn` pointer type cannot be `const` pub type FTT3 = for<'a> async fn(); //~ ERROR an `fn` pointer type cannot be `async` -pub type FTT4 = for<'a> async extern fn(); //~ ERROR an `fn` pointer type cannot be `async` +pub type FTT4 = for<'a> async extern "C" fn(); //~ ERROR an `fn` pointer type cannot be `async` pub type FTT5 = for<'a> async unsafe extern "C" fn(); //~^ ERROR an `fn` pointer type cannot be `async` pub type FTT6 = for<'a> const async unsafe extern "C" fn(); diff --git a/tests/ui/parser/bad-fn-ptr-qualifier.stderr b/tests/ui/parser/bad-fn-ptr-qualifier.stderr index 523ee47b0c9..ddc8bac678c 100644 --- a/tests/ui/parser/bad-fn-ptr-qualifier.stderr +++ b/tests/ui/parser/bad-fn-ptr-qualifier.stderr @@ -29,15 +29,15 @@ LL + pub type T1 = extern "C" fn(); error: an `fn` pointer type cannot be `const` --> $DIR/bad-fn-ptr-qualifier.rs:7:15 | -LL | pub type T2 = const unsafe extern fn(); - | -----^^^^^^^^^^^^^^^^^^^ +LL | pub type T2 = const unsafe extern "C" fn(); + | -----^^^^^^^^^^^^^^^^^^^^^^^ | | | `const` because of this | help: remove the `const` qualifier | -LL - pub type T2 = const unsafe extern fn(); -LL + pub type T2 = unsafe extern fn(); +LL - pub type T2 = const unsafe extern "C" fn(); +LL + pub type T2 = unsafe extern "C" fn(); | error: an `fn` pointer type cannot be `async` @@ -57,15 +57,15 @@ LL + pub type T3 = fn(); error: an `fn` pointer type cannot be `async` --> $DIR/bad-fn-ptr-qualifier.rs:9:15 | -LL | pub type T4 = async extern fn(); - | -----^^^^^^^^^^^^ +LL | pub type T4 = async extern "C" fn(); + | -----^^^^^^^^^^^^^^^^ | | | `async` because of this | help: remove the `async` qualifier | -LL - pub type T4 = async extern fn(); -LL + pub type T4 = extern fn(); +LL - pub type T4 = async extern "C" fn(); +LL + pub type T4 = extern "C" fn(); | error: an `fn` pointer type cannot be `async` @@ -141,15 +141,15 @@ LL + pub type FTT1 = for<'a> extern "C" fn(); error: an `fn` pointer type cannot be `const` --> $DIR/bad-fn-ptr-qualifier.rs:17:17 | -LL | pub type FTT2 = for<'a> const unsafe extern fn(); - | ^^^^^^^^-----^^^^^^^^^^^^^^^^^^^ +LL | pub type FTT2 = for<'a> const unsafe extern "C" fn(); + | ^^^^^^^^-----^^^^^^^^^^^^^^^^^^^^^^^ | | | `const` because of this | help: remove the `const` qualifier | -LL - pub type FTT2 = for<'a> const unsafe extern fn(); -LL + pub type FTT2 = for<'a> unsafe extern fn(); +LL - pub type FTT2 = for<'a> const unsafe extern "C" fn(); +LL + pub type FTT2 = for<'a> unsafe extern "C" fn(); | error: an `fn` pointer type cannot be `async` @@ -169,15 +169,15 @@ LL + pub type FTT3 = for<'a> fn(); error: an `fn` pointer type cannot be `async` --> $DIR/bad-fn-ptr-qualifier.rs:19:17 | -LL | pub type FTT4 = for<'a> async extern fn(); - | ^^^^^^^^-----^^^^^^^^^^^^ +LL | pub type FTT4 = for<'a> async extern "C" fn(); + | ^^^^^^^^-----^^^^^^^^^^^^^^^^ | | | `async` because of this | help: remove the `async` qualifier | -LL - pub type FTT4 = for<'a> async extern fn(); -LL + pub type FTT4 = for<'a> extern fn(); +LL - pub type FTT4 = for<'a> async extern "C" fn(); +LL + pub type FTT4 = for<'a> extern "C" fn(); | error: an `fn` pointer type cannot be `async` diff --git a/tests/ui/parser/bad-lit-suffixes.rs b/tests/ui/parser/bad-lit-suffixes.rs index c614f493885..f29dc53d322 100644 --- a/tests/ui/parser/bad-lit-suffixes.rs +++ b/tests/ui/parser/bad-lit-suffixes.rs @@ -1,10 +1,10 @@ #![feature(rustc_attrs)] -extern +extern //~ WARN missing_abi "C"suffix //~ ERROR suffixes on string literals are invalid fn foo() {} -extern +extern //~ WARN missing_abi "C"suffix //~ ERROR suffixes on string literals are invalid {} diff --git a/tests/ui/parser/bad-lit-suffixes.stderr b/tests/ui/parser/bad-lit-suffixes.stderr index b5dacdf7d0d..121db2058f1 100644 --- a/tests/ui/parser/bad-lit-suffixes.stderr +++ b/tests/ui/parser/bad-lit-suffixes.stderr @@ -49,6 +49,20 @@ LL | #[rustc_layout_scalar_valid_range_start(0suffix)] | = help: the suffix must be one of the numeric types (`u32`, `isize`, `f32`, etc.) +warning: extern declarations without an explicit ABI are deprecated + --> $DIR/bad-lit-suffixes.rs:3:1 + | +LL | extern + | ^^^^^^ help: explicitly specify the C ABI: `extern "C"` + | + = note: `#[warn(missing_abi)]` on by default + +warning: extern declarations without an explicit ABI are deprecated + --> $DIR/bad-lit-suffixes.rs:7:1 + | +LL | extern + | ^^^^^^ help: explicitly specify the C ABI: `extern "C"` + error: suffixes on string literals are invalid --> $DIR/bad-lit-suffixes.rs:12:5 | @@ -149,5 +163,5 @@ LL | 1.0e10suffix; | = help: valid suffixes are `f32` and `f64` -error: aborting due to 21 previous errors +error: aborting due to 21 previous errors; 2 warnings emitted diff --git a/tests/ui/parser/issues/issue-87217-keyword-order/wrong-unsafe.rs b/tests/ui/parser/issues/issue-87217-keyword-order/wrong-unsafe.rs index 34b687a0f52..5ecf804de09 100644 --- a/tests/ui/parser/issues/issue-87217-keyword-order/wrong-unsafe.rs +++ b/tests/ui/parser/issues/issue-87217-keyword-order/wrong-unsafe.rs @@ -1,4 +1,5 @@ //@ edition:2018 +#![allow(missing_abi)] // There is an order to respect for keywords before a function: // `<visibility>, const, async, unsafe, extern, "<ABI>"` diff --git a/tests/ui/parser/issues/issue-87217-keyword-order/wrong-unsafe.stderr b/tests/ui/parser/issues/issue-87217-keyword-order/wrong-unsafe.stderr index 0e9f7c51e1a..232da9acef3 100644 --- a/tests/ui/parser/issues/issue-87217-keyword-order/wrong-unsafe.stderr +++ b/tests/ui/parser/issues/issue-87217-keyword-order/wrong-unsafe.stderr @@ -1,5 +1,5 @@ error: expected `fn`, found keyword `unsafe` - --> $DIR/wrong-unsafe.rs:9:8 + --> $DIR/wrong-unsafe.rs:10:8 | LL | extern unsafe fn test() {} | -------^^^^^^ diff --git a/tests/ui/parser/item-kw-case-mismatch.fixed b/tests/ui/parser/item-kw-case-mismatch.fixed index f5afa482712..4ee8f9c19dc 100644 --- a/tests/ui/parser/item-kw-case-mismatch.fixed +++ b/tests/ui/parser/item-kw-case-mismatch.fixed @@ -25,7 +25,7 @@ const unsafe fn _e() {} //~| ERROR keyword `unsafe` is written in the wrong case //~| ERROR keyword `fn` is written in the wrong case -unsafe extern fn _f() {} +unsafe extern "C" fn _f() {} //~^ ERROR keyword `unsafe` is written in the wrong case //~| ERROR keyword `extern` is written in the wrong case diff --git a/tests/ui/parser/item-kw-case-mismatch.rs b/tests/ui/parser/item-kw-case-mismatch.rs index ea224e08a00..6c858b848cf 100644 --- a/tests/ui/parser/item-kw-case-mismatch.rs +++ b/tests/ui/parser/item-kw-case-mismatch.rs @@ -25,7 +25,7 @@ CONST UNSAFE FN _e() {} //~| ERROR keyword `unsafe` is written in the wrong case //~| ERROR keyword `fn` is written in the wrong case -unSAFE EXTern fn _f() {} +unSAFE EXTern "C" fn _f() {} //~^ ERROR keyword `unsafe` is written in the wrong case //~| ERROR keyword `extern` is written in the wrong case diff --git a/tests/ui/parser/item-kw-case-mismatch.stderr b/tests/ui/parser/item-kw-case-mismatch.stderr index 0abc59e064a..36df72b5cad 100644 --- a/tests/ui/parser/item-kw-case-mismatch.stderr +++ b/tests/ui/parser/item-kw-case-mismatch.stderr @@ -111,23 +111,23 @@ LL | CONST UNSAFE fn _e() {} error: keyword `unsafe` is written in the wrong case --> $DIR/item-kw-case-mismatch.rs:28:1 | -LL | unSAFE EXTern fn _f() {} +LL | unSAFE EXTern "C" fn _f() {} | ^^^^^^ | help: write it in the correct case | -LL | unsafe EXTern fn _f() {} +LL | unsafe EXTern "C" fn _f() {} | ~~~~~~ error: keyword `extern` is written in the wrong case --> $DIR/item-kw-case-mismatch.rs:28:8 | -LL | unSAFE EXTern fn _f() {} +LL | unSAFE EXTern "C" fn _f() {} | ^^^^^^ | help: write it in the correct case | -LL | unSAFE extern fn _f() {} +LL | unSAFE extern "C" fn _f() {} | ~~~~~~ error: keyword `extern` is written in the wrong case diff --git a/tests/ui/parser/lit-err-in-macro.rs b/tests/ui/parser/lit-err-in-macro.rs index cff8ee6b40c..ca117ac4a15 100644 --- a/tests/ui/parser/lit-err-in-macro.rs +++ b/tests/ui/parser/lit-err-in-macro.rs @@ -1,6 +1,6 @@ macro_rules! f { ($abi:literal) => { - extern $abi fn f() {} + extern $abi fn f() {} //~ WARN missing_abi } } diff --git a/tests/ui/parser/lit-err-in-macro.stderr b/tests/ui/parser/lit-err-in-macro.stderr index 12e6d519060..fc2603d0b10 100644 --- a/tests/ui/parser/lit-err-in-macro.stderr +++ b/tests/ui/parser/lit-err-in-macro.stderr @@ -4,5 +4,17 @@ error: suffixes on string literals are invalid LL | f!("Foo"__); | ^^^^^^^ invalid suffix `__` -error: aborting due to 1 previous error +warning: extern declarations without an explicit ABI are deprecated + --> $DIR/lit-err-in-macro.rs:3:9 + | +LL | extern $abi fn f() {} + | ^^^^^^ help: explicitly specify the C ABI: `extern "C"` +... +LL | f!("Foo"__); + | ----------- in this macro invocation + | + = note: `#[warn(missing_abi)]` on by default + = note: this warning originates in the macro `f` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 1 previous error; 1 warning emitted diff --git a/tests/ui/parser/recover/recover-const-async-fn-ptr.rs b/tests/ui/parser/recover/recover-const-async-fn-ptr.rs index 2d8a3858aa6..45d75349599 100644 --- a/tests/ui/parser/recover/recover-const-async-fn-ptr.rs +++ b/tests/ui/parser/recover/recover-const-async-fn-ptr.rs @@ -2,9 +2,9 @@ type T0 = const fn(); //~ ERROR an `fn` pointer type cannot be `const` type T1 = const extern "C" fn(); //~ ERROR an `fn` pointer type cannot be `const` -type T2 = const unsafe extern fn(); //~ ERROR an `fn` pointer type cannot be `const` +type T2 = const unsafe extern "C" fn(); //~ ERROR an `fn` pointer type cannot be `const` type T3 = async fn(); //~ ERROR an `fn` pointer type cannot be `async` -type T4 = async extern fn(); //~ ERROR an `fn` pointer type cannot be `async` +type T4 = async extern "C" fn(); //~ ERROR an `fn` pointer type cannot be `async` type T5 = async unsafe extern "C" fn(); //~ ERROR an `fn` pointer type cannot be `async` type T6 = const async unsafe extern "C" fn(); //~^ ERROR an `fn` pointer type cannot be `const` @@ -12,9 +12,9 @@ type T6 = const async unsafe extern "C" fn(); type FT0 = for<'a> const fn(); //~ ERROR an `fn` pointer type cannot be `const` type FT1 = for<'a> const extern "C" fn(); //~ ERROR an `fn` pointer type cannot be `const` -type FT2 = for<'a> const unsafe extern fn(); //~ ERROR an `fn` pointer type cannot be `const` +type FT2 = for<'a> const unsafe extern "C" fn(); //~ ERROR an `fn` pointer type cannot be `const` type FT3 = for<'a> async fn(); //~ ERROR an `fn` pointer type cannot be `async` -type FT4 = for<'a> async extern fn(); //~ ERROR an `fn` pointer type cannot be `async` +type FT4 = for<'a> async extern "C" fn(); //~ ERROR an `fn` pointer type cannot be `async` type FT5 = for<'a> async unsafe extern "C" fn(); //~ ERROR an `fn` pointer type cannot be `async` type FT6 = for<'a> const async unsafe extern "C" fn(); //~^ ERROR an `fn` pointer type cannot be `const` diff --git a/tests/ui/parser/recover/recover-const-async-fn-ptr.stderr b/tests/ui/parser/recover/recover-const-async-fn-ptr.stderr index 8e5b76163ad..9112a0e135a 100644 --- a/tests/ui/parser/recover/recover-const-async-fn-ptr.stderr +++ b/tests/ui/parser/recover/recover-const-async-fn-ptr.stderr @@ -29,15 +29,15 @@ LL + type T1 = extern "C" fn(); error: an `fn` pointer type cannot be `const` --> $DIR/recover-const-async-fn-ptr.rs:5:11 | -LL | type T2 = const unsafe extern fn(); - | -----^^^^^^^^^^^^^^^^^^^ +LL | type T2 = const unsafe extern "C" fn(); + | -----^^^^^^^^^^^^^^^^^^^^^^^ | | | `const` because of this | help: remove the `const` qualifier | -LL - type T2 = const unsafe extern fn(); -LL + type T2 = unsafe extern fn(); +LL - type T2 = const unsafe extern "C" fn(); +LL + type T2 = unsafe extern "C" fn(); | error: an `fn` pointer type cannot be `async` @@ -57,15 +57,15 @@ LL + type T3 = fn(); error: an `fn` pointer type cannot be `async` --> $DIR/recover-const-async-fn-ptr.rs:7:11 | -LL | type T4 = async extern fn(); - | -----^^^^^^^^^^^^ +LL | type T4 = async extern "C" fn(); + | -----^^^^^^^^^^^^^^^^ | | | `async` because of this | help: remove the `async` qualifier | -LL - type T4 = async extern fn(); -LL + type T4 = extern fn(); +LL - type T4 = async extern "C" fn(); +LL + type T4 = extern "C" fn(); | error: an `fn` pointer type cannot be `async` @@ -141,15 +141,15 @@ LL + type FT1 = for<'a> extern "C" fn(); error: an `fn` pointer type cannot be `const` --> $DIR/recover-const-async-fn-ptr.rs:15:12 | -LL | type FT2 = for<'a> const unsafe extern fn(); - | ^^^^^^^^-----^^^^^^^^^^^^^^^^^^^ +LL | type FT2 = for<'a> const unsafe extern "C" fn(); + | ^^^^^^^^-----^^^^^^^^^^^^^^^^^^^^^^^ | | | `const` because of this | help: remove the `const` qualifier | -LL - type FT2 = for<'a> const unsafe extern fn(); -LL + type FT2 = for<'a> unsafe extern fn(); +LL - type FT2 = for<'a> const unsafe extern "C" fn(); +LL + type FT2 = for<'a> unsafe extern "C" fn(); | error: an `fn` pointer type cannot be `async` @@ -169,15 +169,15 @@ LL + type FT3 = for<'a> fn(); error: an `fn` pointer type cannot be `async` --> $DIR/recover-const-async-fn-ptr.rs:17:12 | -LL | type FT4 = for<'a> async extern fn(); - | ^^^^^^^^-----^^^^^^^^^^^^ +LL | type FT4 = for<'a> async extern "C" fn(); + | ^^^^^^^^-----^^^^^^^^^^^^^^^^ | | | `async` because of this | help: remove the `async` qualifier | -LL - type FT4 = for<'a> async extern fn(); -LL + type FT4 = for<'a> extern fn(); +LL - type FT4 = for<'a> async extern "C" fn(); +LL + type FT4 = for<'a> extern "C" fn(); | error: an `fn` pointer type cannot be `async` diff --git a/tests/ui/parser/recover/recover-fn-ptr-with-generics.rs b/tests/ui/parser/recover/recover-fn-ptr-with-generics.rs index 76c56a715d2..ab2cfc961df 100644 --- a/tests/ui/parser/recover/recover-fn-ptr-with-generics.rs +++ b/tests/ui/parser/recover/recover-fn-ptr-with-generics.rs @@ -19,7 +19,7 @@ fn main() { type Hmm = fn<>(); //~^ ERROR function pointer types may not have generic parameters - let _: extern fn<'a: 'static>(); + let _: extern "C" fn<'a: 'static>(); //~^ ERROR function pointer types may not have generic parameters //~| ERROR bounds cannot be used in this context diff --git a/tests/ui/parser/recover/recover-fn-ptr-with-generics.stderr b/tests/ui/parser/recover/recover-fn-ptr-with-generics.stderr index 6b6cb2d6bdd..9023856ef24 100644 --- a/tests/ui/parser/recover/recover-fn-ptr-with-generics.stderr +++ b/tests/ui/parser/recover/recover-fn-ptr-with-generics.stderr @@ -59,15 +59,15 @@ LL | type Hmm = fn<>(); | ^^ error: function pointer types may not have generic parameters - --> $DIR/recover-fn-ptr-with-generics.rs:22:21 + --> $DIR/recover-fn-ptr-with-generics.rs:22:25 | -LL | let _: extern fn<'a: 'static>(); - | ^^^^^^^^^^^^^ +LL | let _: extern "C" fn<'a: 'static>(); + | ^^^^^^^^^^^^^ | help: consider moving the lifetime parameter to a `for` parameter list | -LL - let _: extern fn<'a: 'static>(); -LL + let _: for<'a> extern fn(); +LL - let _: extern "C" fn<'a: 'static>(); +LL + let _: for<'a> extern "C" fn(); | error: function pointer types may not have generic parameters @@ -101,10 +101,10 @@ LL | type Identity = fn<T>(T) -> T; | ^ not found in this scope error: bounds cannot be used in this context - --> $DIR/recover-fn-ptr-with-generics.rs:22:26 + --> $DIR/recover-fn-ptr-with-generics.rs:22:30 | -LL | let _: extern fn<'a: 'static>(); - | ^^^^^^^ +LL | let _: extern "C" fn<'a: 'static>(); + | ^^^^^^^ error: aborting due to 12 previous errors diff --git a/tests/ui/parser/recover/recover-missing-semi-before-item.fixed b/tests/ui/parser/recover/recover-missing-semi-before-item.fixed index 6f85452c6fb..871fa0d24ec 100644 --- a/tests/ui/parser/recover/recover-missing-semi-before-item.fixed +++ b/tests/ui/parser/recover/recover-missing-semi-before-item.fixed @@ -28,7 +28,7 @@ fn for_fn() { fn for_extern() { let foo = 3; //~ ERROR expected `;`, found keyword `extern` - extern fn foo() {} + extern "C" fn foo() {} } fn for_impl() { diff --git a/tests/ui/parser/recover/recover-missing-semi-before-item.rs b/tests/ui/parser/recover/recover-missing-semi-before-item.rs index f75945b55c2..de92603a74c 100644 --- a/tests/ui/parser/recover/recover-missing-semi-before-item.rs +++ b/tests/ui/parser/recover/recover-missing-semi-before-item.rs @@ -28,7 +28,7 @@ fn for_fn() { fn for_extern() { let foo = 3 //~ ERROR expected `;`, found keyword `extern` - extern fn foo() {} + extern "C" fn foo() {} } fn for_impl() { diff --git a/tests/ui/parser/recover/recover-missing-semi-before-item.stderr b/tests/ui/parser/recover/recover-missing-semi-before-item.stderr index 61c43f2f189..3b55cd9ddd0 100644 --- a/tests/ui/parser/recover/recover-missing-semi-before-item.stderr +++ b/tests/ui/parser/recover/recover-missing-semi-before-item.stderr @@ -35,7 +35,7 @@ error: expected `;`, found keyword `extern` | LL | let foo = 3 | ^ help: add `;` here -LL | extern fn foo() {} +LL | extern "C" fn foo() {} | ------ unexpected token error: expected `;`, found keyword `impl` diff --git a/tests/ui/privacy/sysroot-private.default.stderr b/tests/ui/privacy/sysroot-private.default.stderr new file mode 100644 index 00000000000..845d4558d13 --- /dev/null +++ b/tests/ui/privacy/sysroot-private.default.stderr @@ -0,0 +1,39 @@ +error[E0405]: cannot find trait `Equivalent` in this scope + --> $DIR/sysroot-private.rs:26:18 + | +LL | trait Trait2<K>: Equivalent<K> {} + | ^^^^^^^^^^ not found in this scope + +error[E0412]: cannot find type `K` in this scope + --> $DIR/sysroot-private.rs:31:35 + | +LL | fn trait_member<T>(val: &T, key: &K) -> bool { + | - ^ + | | + | similarly named type parameter `T` defined here + | +help: a type parameter with a similar name exists + | +LL | fn trait_member<T>(val: &T, key: &T) -> bool { + | ~ +help: you might be missing a type parameter + | +LL | fn trait_member<T, K>(val: &T, key: &K) -> bool { + | +++ + +error[E0220]: associated type `ExpressionStack` not found for `Trait` + --> $DIR/sysroot-private.rs:21:31 + | +LL | type AssociatedTy = dyn Trait<ExpressionStack = i32, Bar = i32>; + | ^^^^^^^^^^^^^^^ help: `Trait` has the following associated type: `Bar` + +error[E0425]: cannot find function `memchr2` in this scope + --> $DIR/sysroot-private.rs:39:5 + | +LL | memchr2(b'a', b'b', buf) + | ^^^^^^^ not found in this scope + +error: aborting due to 4 previous errors + +Some errors have detailed explanations: E0220, E0405, E0412, E0425. +For more information about an error, try `rustc --explain E0220`. diff --git a/tests/ui/privacy/sysroot-private.rs b/tests/ui/privacy/sysroot-private.rs new file mode 100644 index 00000000000..67ab67c7f5c --- /dev/null +++ b/tests/ui/privacy/sysroot-private.rs @@ -0,0 +1,42 @@ +//! Test that private dependencies of `std` that live in the sysroot do not reach through to +//! diagnostics. +//! +//! This test would be more robust if we could patch the sysroot with an "evil" crate that +//! provided known types that we control; however, this would effectively require rebuilding +//! `std` (or patching crate metadata). So, this test relies on what is currently public API +//! of `std`'s dependencies, but may not be robust against dependency upgrades/changes. + +//@ only-unix Windows sysroots seem to not expose this dependency +//@ revisions: default rustc_private_enabled + +// Enabling `rustc_private` should `std`'s dependencies accessible, so they should show up +// in diagnostics. NB: not all diagnostics are affected by this. +#![cfg_attr(rustc_private_enabled, feature(rustc_private))] +#![crate_type = "lib"] + +trait Trait { type Bar; } + +// Attempt to get a suggestion for `gimli::read::op::EvaluationStoreage`, which should not be +// present in diagnostics (it is a dependency of the compiler). +type AssociatedTy = dyn Trait<ExpressionStack = i32, Bar = i32>; +//~^ ERROR associated type `ExpressionStack` not found +//[rustc_private_enabled]~| NOTE there is an associated type `ExpressionStack` in the trait `gimli::read::op::EvaluationStorage` + +// Attempt to get a suggestion for `hashbrown::Equivalent` +trait Trait2<K>: Equivalent<K> {} +//~^ ERROR cannot find trait +//~| NOTE not found + +// Attempt to get a suggestion for `hashbrown::Equivalent::equivalent` +fn trait_member<T>(val: &T, key: &K) -> bool { + //~^ ERROR cannot find type `K` + //~| NOTE similarly named + val.equivalent(key) +} + +// Attempt to get a suggestion for `memchr::memchr2` +fn free_function(buf: &[u8]) -> Option<usize> { + memchr2(b'a', b'b', buf) + //~^ ERROR cannot find function + //~| NOTE not found +} diff --git a/tests/ui/privacy/sysroot-private.rustc_private_enabled.stderr b/tests/ui/privacy/sysroot-private.rustc_private_enabled.stderr new file mode 100644 index 00000000000..98e6922428a --- /dev/null +++ b/tests/ui/privacy/sysroot-private.rustc_private_enabled.stderr @@ -0,0 +1,39 @@ +error[E0405]: cannot find trait `Equivalent` in this scope + --> $DIR/sysroot-private.rs:26:18 + | +LL | trait Trait2<K>: Equivalent<K> {} + | ^^^^^^^^^^ not found in this scope + +error[E0412]: cannot find type `K` in this scope + --> $DIR/sysroot-private.rs:31:35 + | +LL | fn trait_member<T>(val: &T, key: &K) -> bool { + | - ^ + | | + | similarly named type parameter `T` defined here + | +help: a type parameter with a similar name exists + | +LL | fn trait_member<T>(val: &T, key: &T) -> bool { + | ~ +help: you might be missing a type parameter + | +LL | fn trait_member<T, K>(val: &T, key: &K) -> bool { + | +++ + +error[E0220]: associated type `ExpressionStack` not found for `Trait` + --> $DIR/sysroot-private.rs:21:31 + | +LL | type AssociatedTy = dyn Trait<ExpressionStack = i32, Bar = i32>; + | ^^^^^^^^^^^^^^^ there is an associated type `ExpressionStack` in the trait `gimli::read::op::EvaluationStorage` + +error[E0425]: cannot find function `memchr2` in this scope + --> $DIR/sysroot-private.rs:39:5 + | +LL | memchr2(b'a', b'b', buf) + | ^^^^^^^ not found in this scope + +error: aborting due to 4 previous errors + +Some errors have detailed explanations: E0220, E0405, E0412, E0425. +For more information about an error, try `rustc --explain E0220`. diff --git a/tests/ui/proc-macro/inner-attrs.stderr b/tests/ui/proc-macro/inner-attrs.stderr index ee8732c650d..3ab180be821 100644 --- a/tests/ui/proc-macro/inner-attrs.stderr +++ b/tests/ui/proc-macro/inner-attrs.stderr @@ -22,5 +22,13 @@ error: expected non-macro inner attribute, found attribute macro `print_attr` LL | #![print_attr] | ^^^^^^^^^^ not a non-macro inner attribute -error: aborting due to 4 previous errors +warning: extern declarations without an explicit ABI are deprecated + --> $DIR/inner-attrs.rs:82:1 + | +LL | extern { + | ^^^^^^ help: explicitly specify the C ABI: `extern "C"` + | + = note: `#[warn(missing_abi)]` on by default + +error: aborting due to 4 previous errors; 1 warning emitted diff --git a/tests/ui/proc-macro/issue-66286.rs b/tests/ui/proc-macro/issue-66286.rs index 57d1af26e93..882f87fa4ac 100644 --- a/tests/ui/proc-macro/issue-66286.rs +++ b/tests/ui/proc-macro/issue-66286.rs @@ -5,7 +5,7 @@ extern crate issue_66286; #[issue_66286::vec_ice] -pub extern fn foo(_: Vec(u32)) -> u32 { +pub extern "C" fn foo(_: Vec(u32)) -> u32 { //~^ ERROR: parenthesized type parameters may only be used with a `Fn` trait 0 } diff --git a/tests/ui/proc-macro/issue-66286.stderr b/tests/ui/proc-macro/issue-66286.stderr index fc4c2062fd7..c92bed1b563 100644 --- a/tests/ui/proc-macro/issue-66286.stderr +++ b/tests/ui/proc-macro/issue-66286.stderr @@ -1,13 +1,13 @@ error[E0214]: parenthesized type parameters may only be used with a `Fn` trait - --> $DIR/issue-66286.rs:8:22 + --> $DIR/issue-66286.rs:8:26 | -LL | pub extern fn foo(_: Vec(u32)) -> u32 { - | ^^^^^^^^ only `Fn` traits may use parentheses +LL | pub extern "C" fn foo(_: Vec(u32)) -> u32 { + | ^^^^^^^^ only `Fn` traits may use parentheses | help: use angle brackets instead | -LL | pub extern fn foo(_: Vec<u32>) -> u32 { - | ~ ~ +LL | pub extern "C" fn foo(_: Vec<u32>) -> u32 { + | ~ ~ error: aborting due to 1 previous error diff --git a/tests/ui/rfcs/rfc-2396-target_feature-11/fn-ptr.stderr b/tests/ui/rfcs/rfc-2396-target_feature-11/fn-ptr.stderr index cc941be5479..a2bda229d10 100644 --- a/tests/ui/rfcs/rfc-2396-target_feature-11/fn-ptr.stderr +++ b/tests/ui/rfcs/rfc-2396-target_feature-11/fn-ptr.stderr @@ -10,13 +10,8 @@ LL | let foo: fn() = foo; | expected due to this | = note: expected fn pointer `fn()` - found fn item `fn() {foo}` - = note: fn items are distinct from fn pointers + found fn item `#[target_features] fn() {foo}` = note: functions with `#[target_feature]` can only be coerced to `unsafe` function pointers -help: consider casting to a fn pointer - | -LL | let foo: fn() = foo as fn(); - | ~~~~~~~~~~~ error: aborting due to 1 previous error diff --git a/tests/ui/rfcs/rfc-2396-target_feature-11/fn-traits.rs b/tests/ui/rfcs/rfc-2396-target_feature-11/fn-traits.rs index 3c370a1b8f3..3eae79faf42 100644 --- a/tests/ui/rfcs/rfc-2396-target_feature-11/fn-traits.rs +++ b/tests/ui/rfcs/rfc-2396-target_feature-11/fn-traits.rs @@ -21,9 +21,9 @@ fn call_once(f: impl FnOnce()) { } fn main() { - call(foo); //~ ERROR expected a `Fn()` closure, found `fn() {foo}` - call_mut(foo); //~ ERROR expected a `FnMut()` closure, found `fn() {foo}` - call_once(foo); //~ ERROR expected a `FnOnce()` closure, found `fn() {foo}` + call(foo); //~ ERROR expected a `Fn()` closure, found `#[target_features] fn() {foo}` + call_mut(foo); //~ ERROR expected a `FnMut()` closure, found `#[target_features] fn() {foo}` + call_once(foo); //~ ERROR expected a `FnOnce()` closure, found `#[target_features] fn() {foo}` call(foo_unsafe); //~^ ERROR expected a `Fn()` closure, found `unsafe fn() {foo_unsafe}` diff --git a/tests/ui/rfcs/rfc-2396-target_feature-11/fn-traits.stderr b/tests/ui/rfcs/rfc-2396-target_feature-11/fn-traits.stderr index 4c07f4d6b99..2915b9ad1b3 100644 --- a/tests/ui/rfcs/rfc-2396-target_feature-11/fn-traits.stderr +++ b/tests/ui/rfcs/rfc-2396-target_feature-11/fn-traits.stderr @@ -1,13 +1,13 @@ -error[E0277]: expected a `Fn()` closure, found `fn() {foo}` +error[E0277]: expected a `Fn()` closure, found `#[target_features] fn() {foo}` --> $DIR/fn-traits.rs:24:10 | LL | call(foo); - | ---- ^^^ expected an `Fn()` closure, found `fn() {foo}` + | ---- ^^^ expected an `Fn()` closure, found `#[target_features] fn() {foo}` | | | required by a bound introduced by this call | - = help: the trait `Fn()` is not implemented for fn item `fn() {foo}` - = note: wrap the `fn() {foo}` in a closure with no arguments: `|| { /* code */ }` + = help: the trait `Fn()` is not implemented for fn item `#[target_features] fn() {foo}` + = note: wrap the `#[target_features] fn() {foo}` in a closure with no arguments: `|| { /* code */ }` = note: `#[target_feature]` functions do not implement the `Fn` traits note: required by a bound in `call` --> $DIR/fn-traits.rs:11:17 @@ -15,16 +15,16 @@ note: required by a bound in `call` LL | fn call(f: impl Fn()) { | ^^^^ required by this bound in `call` -error[E0277]: expected a `FnMut()` closure, found `fn() {foo}` +error[E0277]: expected a `FnMut()` closure, found `#[target_features] fn() {foo}` --> $DIR/fn-traits.rs:25:14 | LL | call_mut(foo); - | -------- ^^^ expected an `FnMut()` closure, found `fn() {foo}` + | -------- ^^^ expected an `FnMut()` closure, found `#[target_features] fn() {foo}` | | | required by a bound introduced by this call | - = help: the trait `FnMut()` is not implemented for fn item `fn() {foo}` - = note: wrap the `fn() {foo}` in a closure with no arguments: `|| { /* code */ }` + = help: the trait `FnMut()` is not implemented for fn item `#[target_features] fn() {foo}` + = note: wrap the `#[target_features] fn() {foo}` in a closure with no arguments: `|| { /* code */ }` = note: `#[target_feature]` functions do not implement the `Fn` traits note: required by a bound in `call_mut` --> $DIR/fn-traits.rs:15:25 @@ -32,16 +32,16 @@ note: required by a bound in `call_mut` LL | fn call_mut(mut f: impl FnMut()) { | ^^^^^^^ required by this bound in `call_mut` -error[E0277]: expected a `FnOnce()` closure, found `fn() {foo}` +error[E0277]: expected a `FnOnce()` closure, found `#[target_features] fn() {foo}` --> $DIR/fn-traits.rs:26:15 | LL | call_once(foo); - | --------- ^^^ expected an `FnOnce()` closure, found `fn() {foo}` + | --------- ^^^ expected an `FnOnce()` closure, found `#[target_features] fn() {foo}` | | | required by a bound introduced by this call | - = help: the trait `FnOnce()` is not implemented for fn item `fn() {foo}` - = note: wrap the `fn() {foo}` in a closure with no arguments: `|| { /* code */ }` + = help: the trait `FnOnce()` is not implemented for fn item `#[target_features] fn() {foo}` + = note: wrap the `#[target_features] fn() {foo}` in a closure with no arguments: `|| { /* code */ }` = note: `#[target_feature]` functions do not implement the `Fn` traits note: required by a bound in `call_once` --> $DIR/fn-traits.rs:19:22 diff --git a/tests/ui/rfcs/rfc-2396-target_feature-11/trait-impl.rs b/tests/ui/rfcs/rfc-2396-target_feature-11/trait-impl.rs index df575b0f6b6..a2ac6ff45fc 100644 --- a/tests/ui/rfcs/rfc-2396-target_feature-11/trait-impl.rs +++ b/tests/ui/rfcs/rfc-2396-target_feature-11/trait-impl.rs @@ -13,6 +13,7 @@ impl Foo for Bar { #[target_feature(enable = "sse2")] //~^ ERROR cannot be applied to safe trait method fn foo(&self) {} + //~^ ERROR method `foo` has an incompatible type for trait #[target_feature(enable = "sse2")] unsafe fn unsf_foo(&self) {} diff --git a/tests/ui/rfcs/rfc-2396-target_feature-11/trait-impl.stderr b/tests/ui/rfcs/rfc-2396-target_feature-11/trait-impl.stderr index 00efbb52f15..1ab1fad64cc 100644 --- a/tests/ui/rfcs/rfc-2396-target_feature-11/trait-impl.stderr +++ b/tests/ui/rfcs/rfc-2396-target_feature-11/trait-impl.stderr @@ -7,8 +7,22 @@ LL | LL | fn foo(&self) {} | ------------- not an `unsafe` function +error[E0053]: method `foo` has an incompatible type for trait + --> $DIR/trait-impl.rs:15:5 + | +LL | fn foo(&self) {} + | ^^^^^^^^^^^^^ expected safe fn, found unsafe fn + | +note: type in trait + --> $DIR/trait-impl.rs:6:5 + | +LL | fn foo(&self); + | ^^^^^^^^^^^^^^ + = note: expected signature `fn(&Bar)` + found signature `#[target_features] fn(&Bar)` + error: `#[target_feature(..)]` cannot be applied to safe trait method - --> $DIR/trait-impl.rs:22:5 + --> $DIR/trait-impl.rs:23:5 | LL | #[target_feature(enable = "sse2")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot be applied to safe trait method @@ -16,5 +30,6 @@ LL | LL | fn foo(&self) {} | ------------- not an `unsafe` function -error: aborting due to 2 previous errors +error: aborting due to 3 previous errors +For more information about this error, try `rustc --explain E0053`. diff --git a/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-not-foreign-fn.rs b/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-not-foreign-fn.rs index f33a3d62e26..5982c771033 100644 --- a/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-not-foreign-fn.rs +++ b/tests/ui/rfcs/rfc-2627-raw-dylib/link-ordinal-not-foreign-fn.rs @@ -11,7 +11,7 @@ fn test() {} static mut imported_val: i32 = 123; #[link(name = "exporter", kind = "raw-dylib")] -extern { +extern "C" { #[link_ordinal(13)] fn imported_function(); diff --git a/tests/ui/rust-2024/unsafe-attributes/unsafe-attributes-fix.fixed b/tests/ui/rust-2024/unsafe-attributes/unsafe-attributes-fix.fixed index 586881d1807..8b179f7ef93 100644 --- a/tests/ui/rust-2024/unsafe-attributes/unsafe-attributes-fix.fixed +++ b/tests/ui/rust-2024/unsafe-attributes/unsafe-attributes-fix.fixed @@ -4,7 +4,7 @@ macro_rules! tt { ($e:tt) => { #$e - extern fn foo() {} + extern "C" fn foo() {} } } @@ -13,7 +13,7 @@ macro_rules! ident { #[unsafe($e)] //~^ ERROR: unsafe attribute used without unsafe //~| WARN this is accepted in the current edition - extern fn bar() {} + extern "C" fn bar() {} } } @@ -22,21 +22,21 @@ macro_rules! ident2 { #[unsafe($e = $l)] //~^ ERROR: unsafe attribute used without unsafe //~| WARN this is accepted in the current edition - extern fn bars() {} + extern "C" fn bars() {} } } macro_rules! meta { ($m:meta) => { #[$m] - extern fn baz() {} + extern "C" fn baz() {} } } macro_rules! meta2 { ($m:meta) => { #[$m] - extern fn baw() {} + extern "C" fn baw() {} } } diff --git a/tests/ui/rust-2024/unsafe-attributes/unsafe-attributes-fix.rs b/tests/ui/rust-2024/unsafe-attributes/unsafe-attributes-fix.rs index 03e122c7d57..34e5a6b96e3 100644 --- a/tests/ui/rust-2024/unsafe-attributes/unsafe-attributes-fix.rs +++ b/tests/ui/rust-2024/unsafe-attributes/unsafe-attributes-fix.rs @@ -4,7 +4,7 @@ macro_rules! tt { ($e:tt) => { #$e - extern fn foo() {} + extern "C" fn foo() {} } } @@ -13,7 +13,7 @@ macro_rules! ident { #[$e] //~^ ERROR: unsafe attribute used without unsafe //~| WARN this is accepted in the current edition - extern fn bar() {} + extern "C" fn bar() {} } } @@ -22,21 +22,21 @@ macro_rules! ident2 { #[$e = $l] //~^ ERROR: unsafe attribute used without unsafe //~| WARN this is accepted in the current edition - extern fn bars() {} + extern "C" fn bars() {} } } macro_rules! meta { ($m:meta) => { #[$m] - extern fn baz() {} + extern "C" fn baz() {} } } macro_rules! meta2 { ($m:meta) => { #[$m] - extern fn baw() {} + extern "C" fn baw() {} } } diff --git a/tests/ui/self/arbitrary-self-from-method-substs-ice.rs b/tests/ui/self/arbitrary-self-from-method-substs-ice.rs index 2d6df816bb1..46e4afd8532 100644 --- a/tests/ui/self/arbitrary-self-from-method-substs-ice.rs +++ b/tests/ui/self/arbitrary-self-from-method-substs-ice.rs @@ -11,7 +11,7 @@ impl Foo { //~^ ERROR invalid generic `self` parameter type //~| ERROR destructor of `R` cannot be evaluated at compile-time self.0 - //~^ ERROR cannot perform conditionally-const deref coercion on `R` in constant functions + //~^ ERROR cannot perform non-const deref coercion on `R` in constant functions } } diff --git a/tests/ui/self/arbitrary-self-from-method-substs-ice.stderr b/tests/ui/self/arbitrary-self-from-method-substs-ice.stderr index e6319d5a2c9..f217370b024 100644 --- a/tests/ui/self/arbitrary-self-from-method-substs-ice.stderr +++ b/tests/ui/self/arbitrary-self-from-method-substs-ice.stderr @@ -1,4 +1,4 @@ -error[E0658]: cannot perform conditionally-const deref coercion on `R` in constant functions +error[E0015]: cannot perform non-const deref coercion on `R` in constant functions --> $DIR/arbitrary-self-from-method-substs-ice.rs:13:9 | LL | self.0 @@ -6,9 +6,6 @@ LL | self.0 | = note: attempting to deref into `Foo` = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants - = note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information - = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0493]: destructor of `R` cannot be evaluated at compile-time --> $DIR/arbitrary-self-from-method-substs-ice.rs:10:43 @@ -30,5 +27,5 @@ LL | const fn get<R: Deref<Target = Self>>(self: R) -> u32 { error: aborting due to 3 previous errors -Some errors have detailed explanations: E0493, E0658, E0801. -For more information about an error, try `rustc --explain E0493`. +Some errors have detailed explanations: E0015, E0493, E0801. +For more information about an error, try `rustc --explain E0015`. diff --git a/tests/ui/self/dispatch-from-dyn-zst-transmute-zst-nonzst.rs b/tests/ui/self/dispatch-from-dyn-zst-transmute-zst-nonzst.rs new file mode 100644 index 00000000000..71f198f7dc7 --- /dev/null +++ b/tests/ui/self/dispatch-from-dyn-zst-transmute-zst-nonzst.rs @@ -0,0 +1,25 @@ +// We used to allow erroneous `DispatchFromDyn` impls whose RHS type contained +// fields that weren't ZSTs. I don't believe this was possible to abuse, but +// it's at least nice to give users better errors. + +#![feature(arbitrary_self_types)] +#![feature(unsize)] +#![feature(dispatch_from_dyn)] + +use std::marker::Unsize; +use std::ops::DispatchFromDyn; + +struct Dispatchable<T: ?Sized, Z> { + _ptr: Box<T>, + z: Z, +} + +impl<T, U> DispatchFromDyn<Dispatchable<U, i32>> for Dispatchable<T, ()> +//~^ ERROR implementing the `DispatchFromDyn` trait requires multiple coercions +where + T: Unsize<U> + ?Sized, + U: ?Sized, +{ +} + +fn main() {} diff --git a/tests/ui/self/dispatch-from-dyn-zst-transmute-zst-nonzst.stderr b/tests/ui/self/dispatch-from-dyn-zst-transmute-zst-nonzst.stderr new file mode 100644 index 00000000000..1f13c51f679 --- /dev/null +++ b/tests/ui/self/dispatch-from-dyn-zst-transmute-zst-nonzst.stderr @@ -0,0 +1,16 @@ +error[E0378]: implementing the `DispatchFromDyn` trait requires multiple coercions + --> $DIR/dispatch-from-dyn-zst-transmute-zst-nonzst.rs:17:1 + | +LL | / impl<T, U> DispatchFromDyn<Dispatchable<U, i32>> for Dispatchable<T, ()> +LL | | +LL | | where +LL | | T: Unsize<U> + ?Sized, +LL | | U: ?Sized, + | |______________^ + | + = note: the trait `DispatchFromDyn` may only be implemented for a coercion between structures with a single field being coerced + = note: currently, 2 fields need coercions: `_ptr` (`Box<T>` to `Box<U>`), `z` (`()` to `i32`) + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0378`. diff --git a/tests/ui/self/dispatch-from-dyn-zst-transmute.rs b/tests/ui/self/dispatch-from-dyn-zst-transmute.rs new file mode 100644 index 00000000000..57c255b4d7b --- /dev/null +++ b/tests/ui/self/dispatch-from-dyn-zst-transmute.rs @@ -0,0 +1,34 @@ +#![feature(arbitrary_self_types)] +#![feature(unsize)] +#![feature(dispatch_from_dyn)] + +use std::marker::PhantomData; +use std::marker::Unsize; +use std::ops::DispatchFromDyn; +use std::ops::Deref; + +struct IsSendToken<T: ?Sized>(PhantomData<fn(T) -> T>); + +struct Foo<'a, U: ?Sized> { + token: IsSendToken<U>, + ptr: &'a U, +} + +impl<'a, T, U> DispatchFromDyn<Foo<'a, U>> for Foo<'a, T> +//~^ ERROR implementing the `DispatchFromDyn` trait requires multiple coercions +where + T: Unsize<U> + ?Sized, + U: ?Sized {} + +trait Bar { + fn f(self: Foo<'_, Self>); +} + +impl<U: ?Sized> Deref for Foo<'_, U> { + type Target = U; + fn deref(&self) -> &U { + self.ptr + } +} + +fn main() {} diff --git a/tests/ui/self/dispatch-from-dyn-zst-transmute.stderr b/tests/ui/self/dispatch-from-dyn-zst-transmute.stderr new file mode 100644 index 00000000000..5a8ae88b5f1 --- /dev/null +++ b/tests/ui/self/dispatch-from-dyn-zst-transmute.stderr @@ -0,0 +1,16 @@ +error[E0378]: implementing the `DispatchFromDyn` trait requires multiple coercions + --> $DIR/dispatch-from-dyn-zst-transmute.rs:17:1 + | +LL | / impl<'a, T, U> DispatchFromDyn<Foo<'a, U>> for Foo<'a, T> +LL | | +LL | | where +LL | | T: Unsize<U> + ?Sized, +LL | | U: ?Sized {} + | |_____________^ + | + = note: the trait `DispatchFromDyn` may only be implemented for a coercion between structures with a single field being coerced + = note: currently, 2 fields need coercions: `token` (`IsSendToken<T>` to `IsSendToken<U>`), `ptr` (`&'a T` to `&'a U`) + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0378`. diff --git a/tests/ui/self/phantomdata-in-coerce-and-dispatch-impls.rs b/tests/ui/self/phantomdata-in-coerce-and-dispatch-impls.rs new file mode 100644 index 00000000000..9c7e33830f5 --- /dev/null +++ b/tests/ui/self/phantomdata-in-coerce-and-dispatch-impls.rs @@ -0,0 +1,25 @@ +//@ check-pass + +#![feature(coerce_unsized, dispatch_from_dyn, unsize)] + +use std::marker::Unsize; +use std::ops::{CoerceUnsized, DispatchFromDyn}; +use std::marker::PhantomData; + +trait Mirror { + type Assoc; +} +impl<T> Mirror for T { + type Assoc = T; +} + +struct W<T: 'static> { + t: &'static T, + f: <PhantomData<T> as Mirror>::Assoc, +} + +impl<T, U> CoerceUnsized<W<U>> for W<T> where T: Unsize<U> {} + +impl<T, U> DispatchFromDyn<W<U>> for W<T> where T: Unsize<U> {} + +fn main() {} diff --git a/tests/ui/simd/type-generic-monomorphisation-extern-nonnull-ptr.rs b/tests/ui/simd/type-generic-monomorphisation-extern-nonnull-ptr.rs index a969295c9f9..65c57c42530 100644 --- a/tests/ui/simd/type-generic-monomorphisation-extern-nonnull-ptr.rs +++ b/tests/ui/simd/type-generic-monomorphisation-extern-nonnull-ptr.rs @@ -6,7 +6,7 @@ use std::ptr::NonNull; -extern { +extern "C" { type Extern; } diff --git a/tests/ui/stability-attribute/accidental-stable-in-unstable.rs b/tests/ui/stability-attribute/accidental-stable-in-unstable.rs index 86a9d2066eb..a36a78ee442 100644 --- a/tests/ui/stability-attribute/accidental-stable-in-unstable.rs +++ b/tests/ui/stability-attribute/accidental-stable-in-unstable.rs @@ -8,3 +8,4 @@ use core::unicode::UNICODE_VERSION; //~ ERROR use of unstable library feature `u // Known accidental stabilizations with known users // fully stable @ core::mem::transmute use core::intrinsics::transmute; // depended upon by rand_core +//~^WARN deprecated diff --git a/tests/ui/stability-attribute/accidental-stable-in-unstable.stderr b/tests/ui/stability-attribute/accidental-stable-in-unstable.stderr index 9943e6d7ac6..16e3676aa65 100644 --- a/tests/ui/stability-attribute/accidental-stable-in-unstable.stderr +++ b/tests/ui/stability-attribute/accidental-stable-in-unstable.stderr @@ -7,6 +7,14 @@ LL | use core::unicode::UNICODE_VERSION; = help: add `#![feature(unicode_internals)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error: aborting due to 1 previous error +warning: use of deprecated module `std::intrinsics`: import this function via `std::mem` instead + --> $DIR/accidental-stable-in-unstable.rs:10:23 + | +LL | use core::intrinsics::transmute; // depended upon by rand_core + | ^^^^^^^^^ + | + = note: `#[warn(deprecated)]` on by default + +error: aborting due to 1 previous error; 1 warning emitted For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/stability-attribute/allowed-through-unstable.rs b/tests/ui/stability-attribute/allowed-through-unstable.rs index 29911a70be9..e03417a4dae 100644 --- a/tests/ui/stability-attribute/allowed-through-unstable.rs +++ b/tests/ui/stability-attribute/allowed-through-unstable.rs @@ -6,4 +6,5 @@ extern crate allowed_through_unstable_core; use allowed_through_unstable_core::unstable_module::OldStableTraitAllowedThoughUnstable; +use allowed_through_unstable_core::unstable_module::OldStableTraitAllowedThoughUnstableWithDeprecation; //~WARN use of deprecated module `allowed_through_unstable_core::unstable_module`: use the new path instead use allowed_through_unstable_core::unstable_module::NewStableTraitNotAllowedThroughUnstable; //~ ERROR use of unstable library feature `unstable_test_feature` diff --git a/tests/ui/stability-attribute/allowed-through-unstable.stderr b/tests/ui/stability-attribute/allowed-through-unstable.stderr index 00eea9f730d..8d07b0cf9e8 100644 --- a/tests/ui/stability-attribute/allowed-through-unstable.stderr +++ b/tests/ui/stability-attribute/allowed-through-unstable.stderr @@ -1,5 +1,13 @@ +warning: use of deprecated module `allowed_through_unstable_core::unstable_module`: use the new path instead + --> $DIR/allowed-through-unstable.rs:9:53 + | +LL | use allowed_through_unstable_core::unstable_module::OldStableTraitAllowedThoughUnstableWithDeprecation; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: `#[warn(deprecated)]` on by default + error[E0658]: use of unstable library feature `unstable_test_feature` - --> $DIR/allowed-through-unstable.rs:9:5 + --> $DIR/allowed-through-unstable.rs:10:5 | LL | use allowed_through_unstable_core::unstable_module::NewStableTraitNotAllowedThroughUnstable; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -8,6 +16,6 @@ LL | use allowed_through_unstable_core::unstable_module::NewStableTraitNotAllowe = help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error: aborting due to 1 previous error +error: aborting due to 1 previous error; 1 warning emitted For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/stability-attribute/auxiliary/allowed-through-unstable-core.rs b/tests/ui/stability-attribute/auxiliary/allowed-through-unstable-core.rs index b597009a309..9dfbb451d04 100644 --- a/tests/ui/stability-attribute/auxiliary/allowed-through-unstable-core.rs +++ b/tests/ui/stability-attribute/auxiliary/allowed-through-unstable-core.rs @@ -10,5 +10,9 @@ pub mod unstable_module { pub trait OldStableTraitAllowedThoughUnstable {} #[stable(feature = "stable_test_feature", since = "1.2.0")] + #[rustc_allowed_through_unstable_modules = "use the new path instead"] + pub trait OldStableTraitAllowedThoughUnstableWithDeprecation {} + + #[stable(feature = "stable_test_feature", since = "1.2.0")] pub trait NewStableTraitNotAllowedThroughUnstable {} } diff --git a/tests/ui/stability-attribute/missing-const-stability.rs b/tests/ui/stability-attribute/missing-const-stability.rs index 19820730736..c3e72e83948 100644 --- a/tests/ui/stability-attribute/missing-const-stability.rs +++ b/tests/ui/stability-attribute/missing-const-stability.rs @@ -22,6 +22,7 @@ impl Foo { #[stable(feature = "stable", since = "1.0.0")] #[const_trait] pub trait Bar { +//~^ ERROR trait has missing const stability attribute #[stable(feature = "stable", since = "1.0.0")] fn fun(); } diff --git a/tests/ui/stability-attribute/missing-const-stability.stderr b/tests/ui/stability-attribute/missing-const-stability.stderr index baa4c34af06..09461e6fb54 100644 --- a/tests/ui/stability-attribute/missing-const-stability.stderr +++ b/tests/ui/stability-attribute/missing-const-stability.stderr @@ -4,8 +4,18 @@ error: function has missing const stability attribute LL | pub const fn foo() {} | ^^^^^^^^^^^^^^^^^^^^^ +error: trait has missing const stability attribute + --> $DIR/missing-const-stability.rs:24:1 + | +LL | / pub trait Bar { +LL | | +LL | | #[stable(feature = "stable", since = "1.0.0")] +LL | | fn fun(); +LL | | } + | |_^ + error: function has missing const stability attribute - --> $DIR/missing-const-stability.rs:36:1 + --> $DIR/missing-const-stability.rs:37:1 | LL | pub const unsafe fn size_of_val<T>(x: *const T) -> usize { 42 } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -16,5 +26,5 @@ error: associated function has missing const stability attribute LL | pub const fn foo() {} | ^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 3 previous errors +error: aborting due to 4 previous errors diff --git a/tests/ui/statics/uninhabited-static.rs b/tests/ui/statics/uninhabited-static.rs index a0f83f45079..0f7c5ae6ef4 100644 --- a/tests/ui/statics/uninhabited-static.rs +++ b/tests/ui/statics/uninhabited-static.rs @@ -2,7 +2,7 @@ #![deny(uninhabited_static)] enum Void {} -extern { +extern "C" { static VOID: Void; //~ ERROR static of uninhabited type //~| WARN: previously accepted static NEVER: !; //~ ERROR static of uninhabited type diff --git a/tests/ui/target-feature/invalid-attribute.rs b/tests/ui/target-feature/invalid-attribute.rs index 2f951c4a00a..c0f5b6b2fb2 100644 --- a/tests/ui/target-feature/invalid-attribute.rs +++ b/tests/ui/target-feature/invalid-attribute.rs @@ -97,6 +97,7 @@ impl Foo {} trait Quux { fn foo(); //~ NOTE `foo` from trait + //~^ NOTE: type in trait } impl Quux for Foo { @@ -106,6 +107,9 @@ impl Quux for Foo { //~| NOTE: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date fn foo() {} //~^ NOTE not an `unsafe` function + //~| ERROR: incompatible type for trait + //~| NOTE: expected safe fn, found unsafe fn + //~| NOTE: expected signature `fn()` } fn main() { diff --git a/tests/ui/target-feature/invalid-attribute.stderr b/tests/ui/target-feature/invalid-attribute.stderr index bf48911edec..10fcf65bb9a 100644 --- a/tests/ui/target-feature/invalid-attribute.stderr +++ b/tests/ui/target-feature/invalid-attribute.stderr @@ -126,7 +126,7 @@ LL | impl Foo {} | ----------- not a function definition error: attribute should be applied to a function definition - --> $DIR/invalid-attribute.rs:112:5 + --> $DIR/invalid-attribute.rs:116:5 | LL | #[target_feature(enable = "sse2")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -138,7 +138,7 @@ LL | | } | |_____- not a function definition error: attribute should be applied to a function definition - --> $DIR/invalid-attribute.rs:120:5 + --> $DIR/invalid-attribute.rs:124:5 | LL | #[target_feature(enable = "sse2")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -193,7 +193,7 @@ LL | fn foo(); | --------- `foo` from trait error[E0658]: `#[target_feature(..)]` can only be applied to `unsafe` functions - --> $DIR/invalid-attribute.rs:103:5 + --> $DIR/invalid-attribute.rs:104:5 | LL | #[target_feature(enable = "sse2")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -205,7 +205,21 @@ LL | fn foo() {} = help: add `#![feature(target_feature_11)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error: aborting due to 23 previous errors +error[E0053]: method `foo` has an incompatible type for trait + --> $DIR/invalid-attribute.rs:108:5 + | +LL | fn foo() {} + | ^^^^^^^^ expected safe fn, found unsafe fn + | +note: type in trait + --> $DIR/invalid-attribute.rs:99:5 + | +LL | fn foo(); + | ^^^^^^^^^ + = note: expected signature `fn()` + found signature `#[target_features] fn()` + +error: aborting due to 24 previous errors -Some errors have detailed explanations: E0046, E0658. +Some errors have detailed explanations: E0046, E0053, E0658. For more information about an error, try `rustc --explain E0046`. diff --git a/tests/ui/traits/const-traits/auxiliary/staged-api.rs b/tests/ui/traits/const-traits/auxiliary/staged-api.rs index abe22db702c..933a25769dc 100644 --- a/tests/ui/traits/const-traits/auxiliary/staged-api.rs +++ b/tests/ui/traits/const-traits/auxiliary/staged-api.rs @@ -4,6 +4,7 @@ #![stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")] +#[rustc_const_unstable(feature = "unstable", issue = "none")] #[const_trait] pub trait MyTrait { #[stable(feature = "rust1", since = "1.0.0")] diff --git a/tests/ui/traits/const-traits/call-const-trait-method-pass.rs b/tests/ui/traits/const-traits/call-const-trait-method-pass.rs index b854b422b3a..3004647ede0 100644 --- a/tests/ui/traits/const-traits/call-const-trait-method-pass.rs +++ b/tests/ui/traits/const-traits/call-const-trait-method-pass.rs @@ -1,6 +1,6 @@ //@ known-bug: #110395 -#![feature(const_trait_impl)] +#![feature(const_trait_impl, const_ops)] struct Int(i32); diff --git a/tests/ui/traits/const-traits/const-and-non-const-impl.rs b/tests/ui/traits/const-traits/const-and-non-const-impl.rs index 6b96fcf0ae3..85e2c5d3df6 100644 --- a/tests/ui/traits/const-traits/const-and-non-const-impl.rs +++ b/tests/ui/traits/const-traits/const-and-non-const-impl.rs @@ -1,6 +1,6 @@ //@ known-bug: #110395 -#![feature(const_trait_impl)] +#![feature(const_trait_impl, const_ops)] pub struct Int(i32); diff --git a/tests/ui/traits/const-traits/cross-crate.stocknc.stderr b/tests/ui/traits/const-traits/cross-crate.stocknc.stderr index 2358731c901..fb47bf9169f 100644 --- a/tests/ui/traits/const-traits/cross-crate.stocknc.stderr +++ b/tests/ui/traits/const-traits/cross-crate.stocknc.stderr @@ -1,13 +1,10 @@ -error[E0658]: cannot call conditionally-const method `<cross_crate::NonConst as cross_crate::MyTrait>::func` in constant functions +error[E0015]: cannot call non-const method `<cross_crate::NonConst as cross_crate::MyTrait>::func` in constant functions --> $DIR/cross-crate.rs:19:14 | LL | NonConst.func(); | ^^^^^^ | = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants - = note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information - = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: cannot call conditionally-const method `<cross_crate::Const as cross_crate::MyTrait>::func` in constant functions --> $DIR/cross-crate.rs:22:11 @@ -22,4 +19,5 @@ LL | Const.func(); error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0658`. +Some errors have detailed explanations: E0015, E0658. +For more information about an error, try `rustc --explain E0015`. diff --git a/tests/ui/traits/const-traits/generic-bound.rs b/tests/ui/traits/const-traits/generic-bound.rs index 5eb236acde2..99de21471b2 100644 --- a/tests/ui/traits/const-traits/generic-bound.rs +++ b/tests/ui/traits/const-traits/generic-bound.rs @@ -1,6 +1,6 @@ //@ check-pass -#![feature(const_trait_impl)] +#![feature(const_trait_impl, const_ops)] use std::marker::PhantomData; diff --git a/tests/ui/traits/const-traits/syntactical-unstable.rs b/tests/ui/traits/const-traits/syntactical-unstable.rs new file mode 100644 index 00000000000..e192e80fabd --- /dev/null +++ b/tests/ui/traits/const-traits/syntactical-unstable.rs @@ -0,0 +1,34 @@ +//@ aux-build:staged-api.rs + +// Ensure that we enforce const stability of traits in `~const`/`const` bounds. + +#![feature(const_trait_impl)] + +use std::ops::Deref; + +extern crate staged_api; +use staged_api::MyTrait; + +#[const_trait] +trait Foo: ~const MyTrait { + //~^ ERROR use of unstable const library feature `unstable` + type Item: ~const MyTrait; + //~^ ERROR use of unstable const library feature `unstable` +} + +const fn where_clause<T>() where T: ~const MyTrait {} +//~^ ERROR use of unstable const library feature `unstable` + +const fn nested<T>() where T: Deref<Target: ~const MyTrait> {} +//~^ ERROR use of unstable const library feature `unstable` + +const fn rpit() -> impl ~const MyTrait { Local } +//~^ ERROR use of unstable const library feature `unstable` + +struct Local; +impl const MyTrait for Local { +//~^ ERROR use of unstable const library feature `unstable` + fn func() {} +} + +fn main() {} diff --git a/tests/ui/traits/const-traits/syntactical-unstable.stderr b/tests/ui/traits/const-traits/syntactical-unstable.stderr new file mode 100644 index 00000000000..a2ce2f2b6e9 --- /dev/null +++ b/tests/ui/traits/const-traits/syntactical-unstable.stderr @@ -0,0 +1,67 @@ +error[E0658]: use of unstable const library feature `unstable` + --> $DIR/syntactical-unstable.rs:13:19 + | +LL | trait Foo: ~const MyTrait { + | ------ ^^^^^^^ + | | + | trait is not stable as const yet + | + = help: add `#![feature(unstable)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error[E0658]: use of unstable const library feature `unstable` + --> $DIR/syntactical-unstable.rs:19:44 + | +LL | const fn where_clause<T>() where T: ~const MyTrait {} + | ------ ^^^^^^^ + | | + | trait is not stable as const yet + | + = help: add `#![feature(unstable)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error[E0658]: use of unstable const library feature `unstable` + --> $DIR/syntactical-unstable.rs:22:52 + | +LL | const fn nested<T>() where T: Deref<Target: ~const MyTrait> {} + | ------ ^^^^^^^ + | | + | trait is not stable as const yet + | + = help: add `#![feature(unstable)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error[E0658]: use of unstable const library feature `unstable` + --> $DIR/syntactical-unstable.rs:25:32 + | +LL | const fn rpit() -> impl ~const MyTrait { Local } + | ------ ^^^^^^^ + | | + | trait is not stable as const yet + | + = help: add `#![feature(unstable)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error[E0658]: use of unstable const library feature `unstable` + --> $DIR/syntactical-unstable.rs:29:12 + | +LL | impl const MyTrait for Local { + | ^^^^^^^ trait is not stable as const yet + | + = help: add `#![feature(unstable)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error[E0658]: use of unstable const library feature `unstable` + --> $DIR/syntactical-unstable.rs:15:23 + | +LL | type Item: ~const MyTrait; + | ------ ^^^^^^^ + | | + | trait is not stable as const yet + | + = help: add `#![feature(unstable)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error: aborting due to 6 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/traits/const-traits/trait-default-body-stability.rs b/tests/ui/traits/const-traits/trait-default-body-stability.rs index 5f7486eb176..567f1b3c284 100644 --- a/tests/ui/traits/const-traits/trait-default-body-stability.rs +++ b/tests/ui/traits/const-traits/trait-default-body-stability.rs @@ -38,6 +38,7 @@ impl const FromResidual for T { } #[stable(feature = "foo", since = "1.0")] +#[rustc_const_unstable(feature = "const_tr", issue = "none")] #[const_trait] pub trait Tr { #[stable(feature = "foo", since = "1.0")] diff --git a/tests/ui/traits/const-traits/trait-default-body-stability.stderr b/tests/ui/traits/const-traits/trait-default-body-stability.stderr index 77b81211e81..a13d9a1e075 100644 --- a/tests/ui/traits/const-traits/trait-default-body-stability.stderr +++ b/tests/ui/traits/const-traits/trait-default-body-stability.stderr @@ -17,7 +17,7 @@ LL | impl const FromResidual for T { = note: adding a non-const method body in the future would be a breaking change error[E0015]: `?` is not allowed on `T` in constant functions - --> $DIR/trait-default-body-stability.rs:45:9 + --> $DIR/trait-default-body-stability.rs:46:9 | LL | T? | ^^ @@ -25,7 +25,7 @@ LL | T? = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants error[E0015]: `?` is not allowed on `T` in constant functions - --> $DIR/trait-default-body-stability.rs:45:9 + --> $DIR/trait-default-body-stability.rs:46:9 | LL | T? | ^^ diff --git a/tests/ui/traits/next-solver/known-type-outlives-has-constraints.rs b/tests/ui/traits/next-solver/known-type-outlives-has-constraints.rs new file mode 100644 index 00000000000..55fea005ea1 --- /dev/null +++ b/tests/ui/traits/next-solver/known-type-outlives-has-constraints.rs @@ -0,0 +1,13 @@ +//@ compile-flags: -Znext-solver +//@ check-pass + +trait Norm { + type Out; +} +impl<'a, T: 'a> Norm for &'a T { + type Out = T; +} + +fn hello<'a, T: 'a>() where <&'a T as Norm>::Out: 'a {} + +fn main() {} diff --git a/tests/ui/traits/trait-upcasting/impossible-method-modulo-binders-2.rs b/tests/ui/traits/trait-upcasting/impossible-method-modulo-binders-2.rs new file mode 100644 index 00000000000..c03b5145aa7 --- /dev/null +++ b/tests/ui/traits/trait-upcasting/impossible-method-modulo-binders-2.rs @@ -0,0 +1,39 @@ +//@ build-pass +//@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@[next] compile-flags: -Znext-solver +// Regression test for #135462. +#![allow(coherence_leak_check)] + +type A = fn(&'static ()); +type B = fn(&()); + +trait Bound<P: WithAssoc>: From<GetAssoc<P>> { +} +impl Bound<B> for String {} + +trait Trt<T> { + fn __(&self, x: T) where T: Bound<A> { + T::from(()); + } +} + +impl<T, S> Trt<T> for S {} + +type GetAssoc<T> = <T as WithAssoc>::Ty; + +trait WithAssoc { + type Ty; +} + +impl WithAssoc for B { + type Ty = String; +} + +impl WithAssoc for A { + type Ty = (); +} + +fn main() { + let x: &'static dyn Trt<String> = &(); +} diff --git a/tests/ui/traits/trait-upcasting/impossible-method-modulo-binders.rs b/tests/ui/traits/trait-upcasting/impossible-method-modulo-binders.rs new file mode 100644 index 00000000000..63ad1c0a060 --- /dev/null +++ b/tests/ui/traits/trait-upcasting/impossible-method-modulo-binders.rs @@ -0,0 +1,40 @@ +//@ build-pass +//@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@[next] compile-flags: -Znext-solver + +trait Foo {} +impl Foo for fn(&'static ()) {} + +trait Bar { + type Assoc: Default; +} +impl<T: Foo> Bar for T { + type Assoc = usize; +} +impl Bar for fn(&()) { + type Assoc = (); +} + +fn needs_foo<T: Foo>() -> usize { + needs_bar::<T>() +} + +fn needs_bar<T: Bar>() -> <T as Bar>::Assoc { + Default::default() +} + +trait Evil<T> { + fn bad(&self) + where + T: Foo, + { + needs_foo::<T>(); + } +} + +impl Evil<fn(&())> for () {} + +fn main() { + let x: &dyn Evil<fn(&())> = &(); +} diff --git a/tests/ui/traits/trait-upcasting/prefer-lower-candidates.rs b/tests/ui/traits/trait-upcasting/prefer-lower-candidates.rs new file mode 100644 index 00000000000..4bc59b09fb5 --- /dev/null +++ b/tests/ui/traits/trait-upcasting/prefer-lower-candidates.rs @@ -0,0 +1,29 @@ +//@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@[next] compile-flags: -Znext-solver +//@ check-pass + +// Ensure we don't have ambiguity when upcasting to two supertraits +// that are identical modulo normalization. + +#![feature(trait_upcasting)] + +trait Supertrait<T> { + fn method(&self) {} +} +impl<T> Supertrait<T> for () {} + +trait Identity { + type Selff; +} +impl<Selff> Identity for Selff { + type Selff = Selff; +} +trait Trait<P>: Supertrait<()> + Supertrait<<P as Identity>::Selff> {} + +impl<P> Trait<P> for () {} + +fn main() { + let x: &dyn Trait<()> = &(); + let x: &dyn Supertrait<()> = x; +} diff --git a/tests/ui/unpretty/expanded-exhaustive.rs b/tests/ui/unpretty/expanded-exhaustive.rs index 26c253d049b..31af323ecda 100644 --- a/tests/ui/unpretty/expanded-exhaustive.rs +++ b/tests/ui/unpretty/expanded-exhaustive.rs @@ -452,15 +452,15 @@ mod items { /// ItemKind::Fn mod item_fn { pub const unsafe extern "C" fn f() {} - pub async unsafe extern fn g() {} + pub async unsafe extern "C" fn g() {} fn h<'a, T>() where T: 'a {} trait TraitItems { - unsafe extern fn f(); + unsafe extern "C" fn f(); } impl TraitItems for _ { - default unsafe extern fn f() {} + default unsafe extern "C" fn f() {} } } @@ -472,7 +472,7 @@ mod items { /// ItemKind::ForeignMod mod item_foreign_mod { unsafe extern "C++" {} - unsafe extern {} + unsafe extern "C" {} } /// ItemKind::GlobalAsm diff --git a/tests/ui/unpretty/expanded-exhaustive.stdout b/tests/ui/unpretty/expanded-exhaustive.stdout index bd7aa1117cc..11066c90edb 100644 --- a/tests/ui/unpretty/expanded-exhaustive.stdout +++ b/tests/ui/unpretty/expanded-exhaustive.stdout @@ -433,13 +433,13 @@ mod items { /// ItemKind::Fn mod item_fn { pub const unsafe extern "C" fn f() {} - pub async unsafe extern fn g() {} + pub async unsafe extern "C" fn g() {} fn h<'a, T>() where T: 'a {} trait TraitItems { - unsafe extern fn f(); + unsafe extern "C" fn f(); } impl TraitItems for _ { - default unsafe extern fn f() {} + default unsafe extern "C" fn f() {} } } /// ItemKind::Mod @@ -447,7 +447,7 @@ mod items { /// ItemKind::ForeignMod mod item_foreign_mod { unsafe extern "C++" {} - unsafe extern {} + unsafe extern "C" {} } /// ItemKind::GlobalAsm mod item_global_asm { |
