diff --git a/compiler/rustc_codegen_llvm/src/intrinsic.rs b/compiler/rustc_codegen_llvm/src/intrinsic.rs index 481f75f337d63..c6aae89f1e51e 100644 --- a/compiler/rustc_codegen_llvm/src/intrinsic.rs +++ b/compiler/rustc_codegen_llvm/src/intrinsic.rs @@ -560,6 +560,12 @@ impl<'ll, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> { return Ok(()); } + sym::amdgpu_dispatch_ptr => { + let val = self.call_intrinsic("llvm.amdgcn.dispatch.ptr", &[], &[]); + // Relying on `LLVMBuildPointerCast` to produce an addrspacecast + self.pointercast(val, self.type_ptr()) + } + _ if name.as_str().starts_with("simd_") => { // Unpack non-power-of-2 #[repr(packed, simd)] arguments. // This gives them the expected layout of a regular #[repr(simd)] vector. diff --git a/compiler/rustc_codegen_ssa/src/mir/intrinsic.rs b/compiler/rustc_codegen_ssa/src/mir/intrinsic.rs index f4fae40d8828f..f5ee9406f4bf1 100644 --- a/compiler/rustc_codegen_ssa/src/mir/intrinsic.rs +++ b/compiler/rustc_codegen_ssa/src/mir/intrinsic.rs @@ -112,6 +112,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { | sym::unreachable | sym::cold_path | sym::breakpoint + | sym::amdgpu_dispatch_ptr | sym::assert_zero_valid | sym::assert_mem_uninitialized_valid | sym::assert_inhabited diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs index 05ecb35bc5a4f..f645c7fe7dea5 100644 --- a/compiler/rustc_hir/src/hir.rs +++ b/compiler/rustc_hir/src/hir.rs @@ -4525,6 +4525,26 @@ impl ItemKind<'_> { _ => return None, }) } + + pub fn recovered(&self) -> bool { + match self { + ItemKind::Struct( + _, + _, + VariantData::Struct { recovered: ast::Recovered::Yes(_), .. }, + ) => true, + ItemKind::Union( + _, + _, + VariantData::Struct { recovered: ast::Recovered::Yes(_), .. }, + ) => true, + ItemKind::Enum(_, _, def) => def.variants.iter().any(|v| match v.data { + VariantData::Struct { recovered: ast::Recovered::Yes(_), .. } => true, + _ => false, + }), + _ => false, + } + } } // The bodies for items are stored "out of line", in a separate diff --git a/compiler/rustc_hir_analysis/src/check/intrinsic.rs b/compiler/rustc_hir_analysis/src/check/intrinsic.rs index c84c1a8ca16d8..d3d167f6e2544 100644 --- a/compiler/rustc_hir_analysis/src/check/intrinsic.rs +++ b/compiler/rustc_hir_analysis/src/check/intrinsic.rs @@ -70,6 +70,7 @@ fn intrinsic_operation_unsafety(tcx: TyCtxt<'_>, intrinsic_id: LocalDefId) -> hi | sym::add_with_overflow | sym::aggregate_raw_ptr | sym::align_of + | sym::amdgpu_dispatch_ptr | sym::assert_inhabited | sym::assert_mem_uninitialized_valid | sym::assert_zero_valid @@ -286,6 +287,7 @@ pub(crate) fn check_intrinsic_type( let (n_tps, n_cts, inputs, output) = match intrinsic_name { sym::autodiff => (4, 0, vec![param(0), param(1), param(2)], param(3)), sym::abort => (0, 0, vec![], tcx.types.never), + sym::amdgpu_dispatch_ptr => (0, 0, vec![], Ty::new_imm_ptr(tcx, tcx.types.unit)), sym::unreachable => (0, 0, vec![], tcx.types.never), sym::breakpoint => (0, 0, vec![], tcx.types.unit), sym::size_of | sym::align_of | sym::variant_count => (1, 0, vec![], tcx.types.usize), diff --git a/compiler/rustc_hir_analysis/src/check/wfcheck.rs b/compiler/rustc_hir_analysis/src/check/wfcheck.rs index cfc7e57cc14e7..8b50eceb26e49 100644 --- a/compiler/rustc_hir_analysis/src/check/wfcheck.rs +++ b/compiler/rustc_hir_analysis/src/check/wfcheck.rs @@ -2160,7 +2160,12 @@ fn report_bivariance<'tcx>( const_param_help, }); diag.code(E0392); - diag.emit() + if item.kind.recovered() { + // Silence potentially redundant error, as the item had a parse error. + diag.delay_as_bug() + } else { + diag.emit() + } } /// Detects cases where an ADT/LTA is trivially cyclical -- we want to detect this so diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index 4080c1cd59ec7..98db0df593bec 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -458,6 +458,7 @@ symbols! { alu32, always, amdgpu, + amdgpu_dispatch_ptr, analysis, and, and_then, diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/need_type_info.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/need_type_info.rs index 0a2442b71e78f..e3c8bfe4a452a 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/infer/need_type_info.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/infer/need_type_info.rs @@ -488,7 +488,30 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { } let Some(InferSource { span, kind }) = local_visitor.infer_source else { - return self.bad_inference_failure_err(failure_span, arg_data, error_code); + let silence = if let DefKind::AssocFn = self.tcx.def_kind(body_def_id) + && let parent = self.tcx.parent(body_def_id.into()) + && self.tcx.is_automatically_derived(parent) + && let Some(parent) = parent.as_local() + && let hir::Node::Item(item) = self.tcx.hir_node_by_def_id(parent) + && let hir::ItemKind::Impl(imp) = item.kind + && let hir::TyKind::Path(hir::QPath::Resolved(_, path)) = imp.self_ty.kind + && let Res::Def(DefKind::Struct | DefKind::Enum | DefKind::Union, def_id) = path.res + && let Some(def_id) = def_id.as_local() + && let hir::Node::Item(item) = self.tcx.hir_node_by_def_id(def_id) + { + // We have encountered an inference error within an automatically derived `impl`, + // from a `#[derive(..)]` on an item that had a parse error. Because the parse + // error might have caused the expanded code to be malformed, we silence the + // inference error. + item.kind.recovered() + } else { + false + }; + let mut err = self.bad_inference_failure_err(failure_span, arg_data, error_code); + if silence { + err.downgrade_to_delayed_bug(); + } + return err; }; let (source_kind, name, long_ty_path) = kind.ty_localized_msg(self); diff --git a/library/core/src/intrinsics/gpu.rs b/library/core/src/intrinsics/gpu.rs new file mode 100644 index 0000000000000..9e7624841d0c6 --- /dev/null +++ b/library/core/src/intrinsics/gpu.rs @@ -0,0 +1,23 @@ +//! Intrinsics for GPU targets. +//! +//! Intrinsics in this module are intended for use on GPU targets. +//! They can be target specific but in general GPU targets are similar. + +#![unstable(feature = "gpu_intrinsics", issue = "none")] + +/// Returns a pointer to the HSA kernel dispatch packet. +/// +/// A `gpu-kernel` on amdgpu is always launched through a kernel dispatch packet. +/// The dispatch packet contains the workgroup size, launch size and other data. +/// The content is defined by the [HSA Platform System Architecture Specification], +/// which is implemented e.g. in AMD's [hsa.h]. +/// The intrinsic returns a unit pointer so that rustc does not need to know the packet struct. +/// The pointer is valid for the whole lifetime of the program. +/// +/// [HSA Platform System Architecture Specification]: https://hsafoundation.com/wp-content/uploads/2021/02/HSA-SysArch-1.2.pdf +/// [hsa.h]: https://github.com/ROCm/rocm-systems/blob/rocm-7.1.0/projects/rocr-runtime/runtime/hsa-runtime/inc/hsa.h#L2959 +#[rustc_nounwind] +#[rustc_intrinsic] +#[cfg(target_arch = "amdgpu")] +#[must_use = "returns a pointer that does nothing unless used"] +pub fn amdgpu_dispatch_ptr() -> *const (); diff --git a/library/core/src/intrinsics/mod.rs b/library/core/src/intrinsics/mod.rs index 20f34036b25c9..8d112b4c5d187 100644 --- a/library/core/src/intrinsics/mod.rs +++ b/library/core/src/intrinsics/mod.rs @@ -60,6 +60,7 @@ use crate::{mem, ptr}; mod bounds; pub mod fallback; +pub mod gpu; pub mod mir; pub mod simd; diff --git a/library/core/src/num/f128.rs b/library/core/src/num/f128.rs index bf99fee4fc78a..65afdd2969b82 100644 --- a/library/core/src/num/f128.rs +++ b/library/core/src/num/f128.rs @@ -34,13 +34,13 @@ pub mod consts { /// The golden ratio (φ) #[unstable(feature = "f128", issue = "116909")] - // Also, #[unstable(feature = "more_float_constants", issue = "146939")] - pub const PHI: f128 = 1.61803398874989484820458683436563811772030917980576286213545_f128; + pub const GOLDEN_RATIO: f128 = + 1.61803398874989484820458683436563811772030917980576286213545_f128; /// The Euler-Mascheroni constant (γ) #[unstable(feature = "f128", issue = "116909")] - // Also, #[unstable(feature = "more_float_constants", issue = "146939")] - pub const EGAMMA: f128 = 0.577215664901532860606512090082402431042159335939923598805767_f128; + pub const EULER_GAMMA: f128 = + 0.577215664901532860606512090082402431042159335939923598805767_f128; /// π/2 #[unstable(feature = "f128", issue = "116909")] diff --git a/library/core/src/num/f16.rs b/library/core/src/num/f16.rs index f39ee22871d5f..bcf0f3fc45c29 100644 --- a/library/core/src/num/f16.rs +++ b/library/core/src/num/f16.rs @@ -36,13 +36,11 @@ pub mod consts { /// The golden ratio (φ) #[unstable(feature = "f16", issue = "116909")] - // Also, #[unstable(feature = "more_float_constants", issue = "146939")] - pub const PHI: f16 = 1.618033988749894848204586834365638118_f16; + pub const GOLDEN_RATIO: f16 = 1.618033988749894848204586834365638118_f16; /// The Euler-Mascheroni constant (γ) #[unstable(feature = "f16", issue = "116909")] - // Also, #[unstable(feature = "more_float_constants", issue = "146939")] - pub const EGAMMA: f16 = 0.577215664901532860606512090082402431_f16; + pub const EULER_GAMMA: f16 = 0.577215664901532860606512090082402431_f16; /// π/2 #[unstable(feature = "f16", issue = "116909")] diff --git a/library/core/src/num/f32.rs b/library/core/src/num/f32.rs index 6fe4285374b23..f7f16b57a526a 100644 --- a/library/core/src/num/f32.rs +++ b/library/core/src/num/f32.rs @@ -292,12 +292,12 @@ pub mod consts { pub const TAU: f32 = 6.28318530717958647692528676655900577_f32; /// The golden ratio (φ) - #[unstable(feature = "more_float_constants", issue = "146939")] - pub const PHI: f32 = 1.618033988749894848204586834365638118_f32; + #[stable(feature = "euler_gamma_golden_ratio", since = "CURRENT_RUSTC_VERSION")] + pub const GOLDEN_RATIO: f32 = 1.618033988749894848204586834365638118_f32; /// The Euler-Mascheroni constant (γ) - #[unstable(feature = "more_float_constants", issue = "146939")] - pub const EGAMMA: f32 = 0.577215664901532860606512090082402431_f32; + #[stable(feature = "euler_gamma_golden_ratio", since = "CURRENT_RUSTC_VERSION")] + pub const EULER_GAMMA: f32 = 0.577215664901532860606512090082402431_f32; /// π/2 #[stable(feature = "rust1", since = "1.0.0")] diff --git a/library/core/src/num/f64.rs b/library/core/src/num/f64.rs index d0aca152415e2..f021c88f2235f 100644 --- a/library/core/src/num/f64.rs +++ b/library/core/src/num/f64.rs @@ -292,12 +292,12 @@ pub mod consts { pub const TAU: f64 = 6.28318530717958647692528676655900577_f64; /// The golden ratio (φ) - #[unstable(feature = "more_float_constants", issue = "146939")] - pub const PHI: f64 = 1.618033988749894848204586834365638118_f64; + #[stable(feature = "euler_gamma_golden_ratio", since = "CURRENT_RUSTC_VERSION")] + pub const GOLDEN_RATIO: f64 = 1.618033988749894848204586834365638118_f64; /// The Euler-Mascheroni constant (γ) - #[unstable(feature = "more_float_constants", issue = "146939")] - pub const EGAMMA: f64 = 0.577215664901532860606512090082402431_f64; + #[stable(feature = "euler_gamma_golden_ratio", since = "CURRENT_RUSTC_VERSION")] + pub const EULER_GAMMA: f64 = 0.577215664901532860606512090082402431_f64; /// π/2 #[stable(feature = "rust1", since = "1.0.0")] diff --git a/library/coretests/tests/floats/f128.rs b/library/coretests/tests/floats/f128.rs deleted file mode 100644 index 8e4f0c9899e1c..0000000000000 --- a/library/coretests/tests/floats/f128.rs +++ /dev/null @@ -1,50 +0,0 @@ -// FIXME(f16_f128): only tested on platforms that have symbols and aren't buggy -#![cfg(target_has_reliable_f128)] - -use super::assert_biteq; - -// Note these tolerances make sense around zero, but not for more extreme exponents. - -/// Default tolerances. Works for values that should be near precise but not exact. Roughly -/// the precision carried by `100 * 100`. -#[allow(unused)] -const TOL: f128 = 1e-12; - -/// For operations that are near exact, usually not involving math of different -/// signs. -#[allow(unused)] -const TOL_PRECISE: f128 = 1e-28; - -// FIXME(f16_f128,miri): many of these have to be disabled since miri does not yet support -// the intrinsics. - -#[test] -fn test_from() { - assert_biteq!(f128::from(false), 0.0); - assert_biteq!(f128::from(true), 1.0); - assert_biteq!(f128::from(u8::MIN), 0.0); - assert_biteq!(f128::from(42_u8), 42.0); - assert_biteq!(f128::from(u8::MAX), 255.0); - assert_biteq!(f128::from(i8::MIN), -128.0); - assert_biteq!(f128::from(42_i8), 42.0); - assert_biteq!(f128::from(i8::MAX), 127.0); - assert_biteq!(f128::from(u16::MIN), 0.0); - assert_biteq!(f128::from(42_u16), 42.0); - assert_biteq!(f128::from(u16::MAX), 65535.0); - assert_biteq!(f128::from(i16::MIN), -32768.0); - assert_biteq!(f128::from(42_i16), 42.0); - assert_biteq!(f128::from(i16::MAX), 32767.0); - assert_biteq!(f128::from(u32::MIN), 0.0); - assert_biteq!(f128::from(42_u32), 42.0); - assert_biteq!(f128::from(u32::MAX), 4294967295.0); - assert_biteq!(f128::from(i32::MIN), -2147483648.0); - assert_biteq!(f128::from(42_i32), 42.0); - assert_biteq!(f128::from(i32::MAX), 2147483647.0); - // FIXME(f16_f128): Uncomment these tests once the From<{u64,i64}> impls are added. - // assert_eq!(f128::from(u64::MIN), 0.0); - // assert_eq!(f128::from(42_u64), 42.0); - // assert_eq!(f128::from(u64::MAX), 18446744073709551615.0); - // assert_eq!(f128::from(i64::MIN), -9223372036854775808.0); - // assert_eq!(f128::from(42_i64), 42.0); - // assert_eq!(f128::from(i64::MAX), 9223372036854775807.0); -} diff --git a/library/coretests/tests/floats/f16.rs b/library/coretests/tests/floats/f16.rs deleted file mode 100644 index 3cff4259de54f..0000000000000 --- a/library/coretests/tests/floats/f16.rs +++ /dev/null @@ -1,35 +0,0 @@ -// FIXME(f16_f128): only tested on platforms that have symbols and aren't buggy -#![cfg(target_has_reliable_f16)] - -use super::assert_biteq; - -/// Tolerance for results on the order of 10.0e-2 -#[allow(unused)] -const TOL_N2: f16 = 0.0001; - -/// Tolerance for results on the order of 10.0e+0 -#[allow(unused)] -const TOL_0: f16 = 0.01; - -/// Tolerance for results on the order of 10.0e+2 -#[allow(unused)] -const TOL_P2: f16 = 0.5; - -/// Tolerance for results on the order of 10.0e+4 -#[allow(unused)] -const TOL_P4: f16 = 10.0; - -// FIXME(f16_f128,miri): many of these have to be disabled since miri does not yet support -// the intrinsics. - -#[test] -fn test_from() { - assert_biteq!(f16::from(false), 0.0); - assert_biteq!(f16::from(true), 1.0); - assert_biteq!(f16::from(u8::MIN), 0.0); - assert_biteq!(f16::from(42_u8), 42.0); - assert_biteq!(f16::from(u8::MAX), 255.0); - assert_biteq!(f16::from(i8::MIN), -128.0); - assert_biteq!(f16::from(42_i8), 42.0); - assert_biteq!(f16::from(i8::MAX), 127.0); -} diff --git a/library/coretests/tests/floats/mod.rs b/library/coretests/tests/floats/mod.rs index 63d5b8fb2c6e9..87e21b21f310d 100644 --- a/library/coretests/tests/floats/mod.rs +++ b/library/coretests/tests/floats/mod.rs @@ -375,9 +375,6 @@ macro_rules! float_test { }; } -mod f128; -mod f16; - float_test! { name: num, attrs: { @@ -1582,3 +1579,78 @@ float_test! { assert_biteq!((flt(-3.2)).mul_add(2.4, neg_inf), neg_inf); } } + +float_test! { + name: from, + attrs: { + f16: #[cfg(any(miri, target_has_reliable_f16))], + f128: #[cfg(any(miri, target_has_reliable_f128))], + }, + test { + assert_biteq!(Float::from(false), Float::ZERO); + assert_biteq!(Float::from(true), Float::ONE); + + assert_biteq!(Float::from(u8::MIN), Float::ZERO); + assert_biteq!(Float::from(42_u8), 42.0); + assert_biteq!(Float::from(u8::MAX), 255.0); + + assert_biteq!(Float::from(i8::MIN), -128.0); + assert_biteq!(Float::from(42_i8), 42.0); + assert_biteq!(Float::from(i8::MAX), 127.0); + } +} + +float_test! { + name: from_u16_i16, + attrs: { + f16: #[cfg(false)], + const f16: #[cfg(false)], + f128: #[cfg(any(miri, target_has_reliable_f128))], + }, + test { + assert_biteq!(Float::from(u16::MIN), Float::ZERO); + assert_biteq!(Float::from(42_u16), 42.0); + assert_biteq!(Float::from(u16::MAX), 65535.0); + assert_biteq!(Float::from(i16::MIN), -32768.0); + assert_biteq!(Float::from(42_i16), 42.0); + assert_biteq!(Float::from(i16::MAX), 32767.0); + } +} + +float_test! { + name: from_u32_i32, + attrs: { + f16: #[cfg(false)], + const f16: #[cfg(false)], + f32: #[cfg(false)], + const f32: #[cfg(false)], + f128: #[cfg(any(miri, target_has_reliable_f128))], + }, + test { + assert_biteq!(Float::from(u32::MIN), Float::ZERO); + assert_biteq!(Float::from(42_u32), 42.0); + assert_biteq!(Float::from(u32::MAX), 4294967295.0); + assert_biteq!(Float::from(i32::MIN), -2147483648.0); + assert_biteq!(Float::from(42_i32), 42.0); + assert_biteq!(Float::from(i32::MAX), 2147483647.0); + } +} + +// FIXME(f16_f128): Uncomment and adapt these tests once the From<{u64,i64}> impls are added. +// float_test! { +// name: from_u64_i64, +// attrs: { +// f16: #[cfg(false)], +// f32: #[cfg(false)], +// f64: #[cfg(false)], +// f128: #[cfg(any(miri, target_has_reliable_f128))], +// }, +// test { +// assert_biteq!(Float::from(u64::MIN), Float::ZERO); +// assert_biteq!(Float::from(42_u64), 42.0); +// assert_biteq!(Float::from(u64::MAX), 18446744073709551615.0); +// assert_biteq!(Float::from(i64::MIN), -9223372036854775808.0); +// assert_biteq!(Float::from(42_i64), 42.0); +// assert_biteq!(Float::from(i64::MAX), 9223372036854775807.0); +// } +// } diff --git a/tests/codegen-llvm/amdgpu-dispatch-ptr.rs b/tests/codegen-llvm/amdgpu-dispatch-ptr.rs new file mode 100644 index 0000000000000..00bde96c3d596 --- /dev/null +++ b/tests/codegen-llvm/amdgpu-dispatch-ptr.rs @@ -0,0 +1,27 @@ +// Tests the amdgpu_dispatch_ptr intrinsic. + +//@ compile-flags: --crate-type=rlib --target amdgcn-amd-amdhsa -Ctarget-cpu=gfx900 +//@ needs-llvm-components: amdgpu +//@ add-minicore +#![feature(intrinsics, no_core, rustc_attrs)] +#![no_core] + +extern crate minicore; + +pub struct DispatchPacket { + pub header: u16, + pub setup: u16, + pub workgroup_size_x: u16, // and more +} + +#[rustc_intrinsic] +#[rustc_nounwind] +fn amdgpu_dispatch_ptr() -> *const (); + +// CHECK-LABEL: @get_dispatch_data +// CHECK: %[[ORIG_PTR:[^ ]+]] = {{(tail )?}}call ptr addrspace(4) @llvm.amdgcn.dispatch.ptr() +// CHECK-NEXT: %[[PTR:[^ ]+]] = addrspacecast ptr addrspace(4) %[[ORIG_PTR]] to ptr +#[unsafe(no_mangle)] +pub fn get_dispatch_data() -> &'static DispatchPacket { + unsafe { &*(amdgpu_dispatch_ptr() as *const _) } +} diff --git a/tests/ui/array-slice-vec/closure-in-array-len.rs b/tests/ui/array-slice-vec/closure-in-array-len.rs new file mode 100644 index 0000000000000..ce13e0f160815 --- /dev/null +++ b/tests/ui/array-slice-vec/closure-in-array-len.rs @@ -0,0 +1,6 @@ +//! regression test for +struct Foo( + fn([u8; |x: u8| {}]), //~ ERROR mismatched types +); + +fn main() {} diff --git a/tests/ui/issues/issue-50600.stderr b/tests/ui/array-slice-vec/closure-in-array-len.stderr similarity index 70% rename from tests/ui/issues/issue-50600.stderr rename to tests/ui/array-slice-vec/closure-in-array-len.stderr index e3ae7f144c35b..decdde042c6f7 100644 --- a/tests/ui/issues/issue-50600.stderr +++ b/tests/ui/array-slice-vec/closure-in-array-len.stderr @@ -1,11 +1,11 @@ error[E0308]: mismatched types - --> $DIR/issue-50600.rs:2:13 + --> $DIR/closure-in-array-len.rs:3:13 | LL | fn([u8; |x: u8| {}]), | ^^^^^^^^^^ expected `usize`, found closure | = note: expected type `usize` - found closure `{closure@$DIR/issue-50600.rs:2:13: 2:20}` + found closure `{closure@$DIR/closure-in-array-len.rs:3:13: 3:20}` error: aborting due to 1 previous error diff --git a/tests/ui/issues/issue-51714.rs b/tests/ui/array-slice-vec/return-in-array-len.rs similarity index 91% rename from tests/ui/issues/issue-51714.rs rename to tests/ui/array-slice-vec/return-in-array-len.rs index 03b50b7963ea5..dea1bb2818bb2 100644 --- a/tests/ui/issues/issue-51714.rs +++ b/tests/ui/array-slice-vec/return-in-array-len.rs @@ -1,3 +1,4 @@ +//! regression test for fn main() { //~^ NOTE: not the enclosing function body //~| NOTE: not the enclosing function body diff --git a/tests/ui/issues/issue-51714.stderr b/tests/ui/array-slice-vec/return-in-array-len.stderr similarity index 87% rename from tests/ui/issues/issue-51714.stderr rename to tests/ui/array-slice-vec/return-in-array-len.stderr index da3e3caea29a3..974a748edc938 100644 --- a/tests/ui/issues/issue-51714.stderr +++ b/tests/ui/array-slice-vec/return-in-array-len.stderr @@ -1,5 +1,5 @@ error[E0572]: return statement outside of function body - --> $DIR/issue-51714.rs:6:13 + --> $DIR/return-in-array-len.rs:7:13 | LL | / fn main() { ... | @@ -10,7 +10,7 @@ LL | | } | |_- ...not the enclosing function body error[E0572]: return statement outside of function body - --> $DIR/issue-51714.rs:10:10 + --> $DIR/return-in-array-len.rs:11:10 | LL | / fn main() { ... | @@ -21,7 +21,7 @@ LL | | } | |_- ...not the enclosing function body error[E0572]: return statement outside of function body - --> $DIR/issue-51714.rs:14:10 + --> $DIR/return-in-array-len.rs:15:10 | LL | / fn main() { ... | @@ -32,7 +32,7 @@ LL | | } | |_- ...not the enclosing function body error[E0572]: return statement outside of function body - --> $DIR/issue-51714.rs:18:10 + --> $DIR/return-in-array-len.rs:19:10 | LL | / fn main() { ... | diff --git a/tests/ui/issues/issue-17503.rs b/tests/ui/array-slice-vec/slice-of-multi-ref.rs similarity index 75% rename from tests/ui/issues/issue-17503.rs rename to tests/ui/array-slice-vec/slice-of-multi-ref.rs index 6c966b5319cd9..b4917f594d832 100644 --- a/tests/ui/issues/issue-17503.rs +++ b/tests/ui/array-slice-vec/slice-of-multi-ref.rs @@ -1,3 +1,4 @@ +//! regression test for //@ run-pass fn main() { let s: &[isize] = &[0, 1, 2, 3, 4]; diff --git a/tests/ui/derives/derive-hygiene-struct-builder.rs b/tests/ui/derives/derive-hygiene-struct-builder.rs new file mode 100644 index 0000000000000..95245a3b3f5a1 --- /dev/null +++ b/tests/ui/derives/derive-hygiene-struct-builder.rs @@ -0,0 +1,10 @@ +//! regression test for +//! struct named "builder" conflicted with derive macro internals. +//@ run-pass +#![allow(dead_code)] +#![allow(non_camel_case_types)] + +#[derive(Debug)] +struct builder; + +fn main() {} diff --git a/tests/ui/dst/unsized-str-mutability.rs b/tests/ui/dst/unsized-str-mutability.rs new file mode 100644 index 0000000000000..d84fa001fd679 --- /dev/null +++ b/tests/ui/dst/unsized-str-mutability.rs @@ -0,0 +1,8 @@ +//! regression test for +//! Test that HIR ty lowering doesn't forget about mutability of `&mut str`. +//@ run-pass + +fn main() { + fn foo(_: &mut T) {} + let _f: fn(&mut str) = foo; +} diff --git a/tests/ui/for-loop-while/break-outside-loop.rs b/tests/ui/for-loop-while/break-outside-loop.rs index 26769b30dd5f0..06c513aa8457b 100644 --- a/tests/ui/for-loop-while/break-outside-loop.rs +++ b/tests/ui/for-loop-while/break-outside-loop.rs @@ -1,25 +1,41 @@ struct Foo { - t: String + t: String, } -fn cond() -> bool { true } +fn cond() -> bool { + true +} -fn foo(_: F) where F: FnOnce() {} +fn foo(_: F) +where + F: FnOnce(), +{ +} fn main() { let pth = break; //~ ERROR: `break` outside of a loop - if cond() { continue } //~ ERROR: `continue` outside of a loop + if cond() { + continue; //~ ERROR: `continue` outside of a loop + } while cond() { - if cond() { break } - if cond() { continue } + if cond() { + break; + } + if cond() { + continue; + } foo(|| { - if cond() { break } //~ ERROR: `break` inside of a closure - if cond() { continue } //~ ERROR: `continue` inside of a closure + if cond() { + break; //~ ERROR: `break` inside of a closure + } + if cond() { + continue; //~ ERROR: `continue` inside of a closure + } }) } - let rs: Foo = Foo{t: pth}; + let rs: Foo = Foo { t: pth }; let unconstrained = break; //~ ERROR: `break` outside of a loop @@ -32,4 +48,10 @@ fn main() { //~| ERROR `break` inside of a closure }; } + + // Make sure that a continue span actually contains the keyword. (#28105) + continue //~ ERROR `continue` outside of a loop + ; + break //~ ERROR `break` outside of a loop + ; } diff --git a/tests/ui/for-loop-while/break-outside-loop.stderr b/tests/ui/for-loop-while/break-outside-loop.stderr index 9092f34df3549..7dbff2d412458 100644 --- a/tests/ui/for-loop-while/break-outside-loop.stderr +++ b/tests/ui/for-loop-while/break-outside-loop.stderr @@ -1,5 +1,5 @@ error[E0767]: use of unreachable label `'lab` - --> $DIR/break-outside-loop.rs:30:19 + --> $DIR/break-outside-loop.rs:46:19 | LL | 'lab: loop { | ---- unreachable label defined here @@ -10,49 +10,62 @@ LL | break 'lab; = note: labels are unreachable through functions, closures, async blocks and modules error[E0268]: `break` outside of a loop or labeled block - --> $DIR/break-outside-loop.rs:10:15 + --> $DIR/break-outside-loop.rs:16:15 | LL | let pth = break; | ^^^^^ cannot `break` outside of a loop or labeled block error[E0268]: `continue` outside of a loop - --> $DIR/break-outside-loop.rs:11:17 + --> $DIR/break-outside-loop.rs:18:9 | -LL | if cond() { continue } - | ^^^^^^^^ cannot `continue` outside of a loop +LL | continue; + | ^^^^^^^^ cannot `continue` outside of a loop error[E0267]: `break` inside of a closure - --> $DIR/break-outside-loop.rs:17:25 + --> $DIR/break-outside-loop.rs:30:17 | LL | foo(|| { | -- enclosing closure -LL | if cond() { break } - | ^^^^^ cannot `break` inside of a closure +LL | if cond() { +LL | break; + | ^^^^^ cannot `break` inside of a closure error[E0267]: `continue` inside of a closure - --> $DIR/break-outside-loop.rs:18:25 + --> $DIR/break-outside-loop.rs:33:17 | LL | foo(|| { | -- enclosing closure -LL | if cond() { break } -LL | if cond() { continue } - | ^^^^^^^^ cannot `continue` inside of a closure +... +LL | continue; + | ^^^^^^^^ cannot `continue` inside of a closure error[E0268]: `break` outside of a loop or labeled block - --> $DIR/break-outside-loop.rs:24:25 + --> $DIR/break-outside-loop.rs:40:25 | LL | let unconstrained = break; | ^^^^^ cannot `break` outside of a loop or labeled block error[E0267]: `break` inside of a closure - --> $DIR/break-outside-loop.rs:30:13 + --> $DIR/break-outside-loop.rs:46:13 | LL | || { | -- enclosing closure LL | break 'lab; | ^^^^^^^^^^ cannot `break` inside of a closure -error: aborting due to 7 previous errors +error[E0268]: `continue` outside of a loop + --> $DIR/break-outside-loop.rs:53:5 + | +LL | continue + | ^^^^^^^^ cannot `continue` outside of a loop + +error[E0268]: `break` outside of a loop or labeled block + --> $DIR/break-outside-loop.rs:55:5 + | +LL | break + | ^^^^^ cannot `break` outside of a loop or labeled block + +error: aborting due to 9 previous errors Some errors have detailed explanations: E0267, E0268, E0767. For more information about an error, try `rustc --explain E0267`. diff --git a/tests/ui/issues/issue-22706.rs b/tests/ui/generics/type-args-on-module-in-bound.rs similarity index 63% rename from tests/ui/issues/issue-22706.rs rename to tests/ui/generics/type-args-on-module-in-bound.rs index bb8a58d3d2ecc..96ca37407cfcb 100644 --- a/tests/ui/issues/issue-22706.rs +++ b/tests/ui/generics/type-args-on-module-in-bound.rs @@ -1,3 +1,4 @@ +//! regression test for fn is_copy::Copy>() {} //~^ ERROR type arguments are not allowed on module `marker` [E0109] fn main() {} diff --git a/tests/ui/issues/issue-22706.stderr b/tests/ui/generics/type-args-on-module-in-bound.stderr similarity index 88% rename from tests/ui/issues/issue-22706.stderr rename to tests/ui/generics/type-args-on-module-in-bound.stderr index 309e11a25f1ac..ac70ae63e90b4 100644 --- a/tests/ui/issues/issue-22706.stderr +++ b/tests/ui/generics/type-args-on-module-in-bound.stderr @@ -1,5 +1,5 @@ error[E0109]: type arguments are not allowed on module `marker` - --> $DIR/issue-22706.rs:1:29 + --> $DIR/type-args-on-module-in-bound.rs:2:29 | LL | fn is_copy::Copy>() {} | ------ ^^^ type argument not allowed diff --git a/tests/ui/issues/issue-16725.rs b/tests/ui/issues/issue-16725.rs deleted file mode 100644 index 7741f828c4740..0000000000000 --- a/tests/ui/issues/issue-16725.rs +++ /dev/null @@ -1,8 +0,0 @@ -//@ aux-build:issue-16725.rs - -extern crate issue_16725 as foo; - -fn main() { - unsafe { foo::bar(); } - //~^ ERROR: function `bar` is private -} diff --git a/tests/ui/issues/issue-17361.rs b/tests/ui/issues/issue-17361.rs deleted file mode 100644 index 6f6fc42db3835..0000000000000 --- a/tests/ui/issues/issue-17361.rs +++ /dev/null @@ -1,8 +0,0 @@ -//@ run-pass -// Test that HIR ty lowering doesn't forget about mutability of `&mut str`. - - -fn main() { - fn foo(_: &mut T) {} - let _f: fn(&mut str) = foo; -} diff --git a/tests/ui/issues/issue-22577.rs b/tests/ui/issues/issue-22577.rs deleted file mode 100644 index 0fa284cc7c0c2..0000000000000 --- a/tests/ui/issues/issue-22577.rs +++ /dev/null @@ -1,25 +0,0 @@ -//@ run-pass -#![allow(dead_code)] - -use std::{fs, net}; - -fn assert_both() {} -fn assert_send() {} - -fn main() { - assert_both::(); - assert_both::(); - assert_both::(); - assert_both::(); - assert_both::(); - assert_both::(); - - assert_both::(); - assert_both::(); - assert_both::(); - assert_both::(); - assert_both::(); - assert_both::(); - assert_both::(); - assert_both::(); -} diff --git a/tests/ui/issues/issue-28105.rs b/tests/ui/issues/issue-28105.rs deleted file mode 100644 index 1e8d2d6ccf132..0000000000000 --- a/tests/ui/issues/issue-28105.rs +++ /dev/null @@ -1,8 +0,0 @@ -// Make sure that a continue span actually contains the keyword. - -fn main() { - continue //~ ERROR `continue` outside of a loop - ; - break //~ ERROR `break` outside of a loop - ; -} diff --git a/tests/ui/issues/issue-28105.stderr b/tests/ui/issues/issue-28105.stderr deleted file mode 100644 index f450256f3ecf5..0000000000000 --- a/tests/ui/issues/issue-28105.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0268]: `continue` outside of a loop - --> $DIR/issue-28105.rs:4:5 - | -LL | continue - | ^^^^^^^^ cannot `continue` outside of a loop - -error[E0268]: `break` outside of a loop or labeled block - --> $DIR/issue-28105.rs:6:5 - | -LL | break - | ^^^^^ cannot `break` outside of a loop or labeled block - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0268`. diff --git a/tests/ui/issues/issue-28433.rs b/tests/ui/issues/issue-28433.rs deleted file mode 100644 index 2298ad240d560..0000000000000 --- a/tests/ui/issues/issue-28433.rs +++ /dev/null @@ -1,12 +0,0 @@ -enum Bird { - pub Duck, - //~^ ERROR visibility qualifiers are not permitted here - Goose, - pub(crate) Dove - //~^ ERROR visibility qualifiers are not permitted here -} - - -fn main() { - let y = Bird::Goose; -} diff --git a/tests/ui/issues/issue-28433.stderr b/tests/ui/issues/issue-28433.stderr deleted file mode 100644 index 0fa67e35f1d4b..0000000000000 --- a/tests/ui/issues/issue-28433.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error[E0449]: visibility qualifiers are not permitted here - --> $DIR/issue-28433.rs:2:5 - | -LL | pub Duck, - | ^^^ help: remove the qualifier - | - = note: enum variants and their fields always share the visibility of the enum they are in - -error[E0449]: visibility qualifiers are not permitted here - --> $DIR/issue-28433.rs:5:5 - | -LL | pub(crate) Dove - | ^^^^^^^^^^ help: remove the qualifier - | - = note: enum variants and their fields always share the visibility of the enum they are in - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0449`. diff --git a/tests/ui/issues/issue-42453.rs b/tests/ui/issues/issue-42453.rs deleted file mode 100644 index 9ed9080e8a92e..0000000000000 --- a/tests/ui/issues/issue-42453.rs +++ /dev/null @@ -1,10 +0,0 @@ -//@ run-pass -#![allow(dead_code)] -#![allow(non_camel_case_types)] - -#[derive(Debug)] -struct builder; - -fn main() { - -} diff --git a/tests/ui/issues/issue-43057.rs b/tests/ui/issues/issue-43057.rs deleted file mode 100644 index 4dd1fe461f1b4..0000000000000 --- a/tests/ui/issues/issue-43057.rs +++ /dev/null @@ -1,14 +0,0 @@ -//@ check-pass -#![allow(unused)] - -macro_rules! column { - ($i:ident) => { - $i - }; -} - -fn foo() -> ! { - panic!(); -} - -fn main() {} diff --git a/tests/ui/issues/issue-50600.rs b/tests/ui/issues/issue-50600.rs deleted file mode 100644 index 963e607afcfd4..0000000000000 --- a/tests/ui/issues/issue-50600.rs +++ /dev/null @@ -1,5 +0,0 @@ -struct Foo ( - fn([u8; |x: u8| {}]), //~ ERROR mismatched types -); - -fn main() {} diff --git a/tests/ui/issues/issue-28109.rs b/tests/ui/label/undeclared-label-span.rs similarity index 54% rename from tests/ui/issues/issue-28109.rs rename to tests/ui/label/undeclared-label-span.rs index 755a539b5003e..c6f38c067192a 100644 --- a/tests/ui/issues/issue-28109.rs +++ b/tests/ui/label/undeclared-label-span.rs @@ -1,4 +1,5 @@ -// Make sure that label for continue and break is spanned correctly +//! regression test for +//! Make sure that label for continue and break is spanned correctly. fn main() { loop { diff --git a/tests/ui/issues/issue-28109.stderr b/tests/ui/label/undeclared-label-span.stderr similarity index 79% rename from tests/ui/issues/issue-28109.stderr rename to tests/ui/label/undeclared-label-span.stderr index 0f918d3b6f702..e5451b4655d86 100644 --- a/tests/ui/issues/issue-28109.stderr +++ b/tests/ui/label/undeclared-label-span.stderr @@ -1,11 +1,11 @@ error[E0426]: use of undeclared label `'b` - --> $DIR/issue-28109.rs:6:9 + --> $DIR/undeclared-label-span.rs:7:9 | LL | 'b | ^^ undeclared label `'b` error[E0426]: use of undeclared label `'c` - --> $DIR/issue-28109.rs:9:9 + --> $DIR/undeclared-label-span.rs:10:9 | LL | 'c | ^^ undeclared label `'c` diff --git a/tests/ui/macros/column-macro-collision.rs b/tests/ui/macros/column-macro-collision.rs new file mode 100644 index 0000000000000..7acf491888aff --- /dev/null +++ b/tests/ui/macros/column-macro-collision.rs @@ -0,0 +1,17 @@ +//! regression test for +//! user-defined `column!` macro must not shadow +//! the built-in `column!()` used internally by `panic!()`. +//@ check-pass +#![allow(unused)] + +macro_rules! column { + ($i:ident) => { + $i + }; +} + +fn foo() -> ! { + panic!(); +} + +fn main() {} diff --git a/tests/ui/issues/issue-27008.rs b/tests/ui/mismatched_types/array-repeat-unit-struct.rs similarity index 61% rename from tests/ui/issues/issue-27008.rs rename to tests/ui/mismatched_types/array-repeat-unit-struct.rs index 20aa4f282c7e6..db05e1daedbd1 100644 --- a/tests/ui/issues/issue-27008.rs +++ b/tests/ui/mismatched_types/array-repeat-unit-struct.rs @@ -1,3 +1,5 @@ +//! regression test for + struct S; fn main() { diff --git a/tests/ui/issues/issue-27008.stderr b/tests/ui/mismatched_types/array-repeat-unit-struct.stderr similarity index 83% rename from tests/ui/issues/issue-27008.stderr rename to tests/ui/mismatched_types/array-repeat-unit-struct.stderr index b4bfaa2786332..9a9cc946f82a1 100644 --- a/tests/ui/issues/issue-27008.stderr +++ b/tests/ui/mismatched_types/array-repeat-unit-struct.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/issue-27008.rs:4:17 + --> $DIR/array-repeat-unit-struct.rs:6:17 | LL | let b = [0; S]; | ^ expected `usize`, found `S` diff --git a/tests/ui/issues/issue-24819.rs b/tests/ui/mismatched_types/vec-hashset-type-mismatch.rs similarity index 68% rename from tests/ui/issues/issue-24819.rs rename to tests/ui/mismatched_types/vec-hashset-type-mismatch.rs index 97d288e5cb144..3724a423d0dd6 100644 --- a/tests/ui/issues/issue-24819.rs +++ b/tests/ui/mismatched_types/vec-hashset-type-mismatch.rs @@ -1,3 +1,4 @@ +//! regression test for //@ dont-require-annotations: NOTE use std::collections::HashSet; @@ -9,5 +10,4 @@ fn main() { //~| NOTE expected `&mut HashSet`, found `&mut Vec<_>` } -fn foo(h: &mut HashSet) { -} +fn foo(h: &mut HashSet) {} diff --git a/tests/ui/issues/issue-24819.stderr b/tests/ui/mismatched_types/vec-hashset-type-mismatch.stderr similarity index 79% rename from tests/ui/issues/issue-24819.stderr rename to tests/ui/mismatched_types/vec-hashset-type-mismatch.stderr index e144f37d6e48b..e778422d00642 100644 --- a/tests/ui/issues/issue-24819.stderr +++ b/tests/ui/mismatched_types/vec-hashset-type-mismatch.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/issue-24819.rs:7:9 + --> $DIR/vec-hashset-type-mismatch.rs:8:9 | LL | foo(&mut v); | --- ^^^^^^ expected `&mut HashSet`, found `&mut Vec<_>` @@ -9,9 +9,9 @@ LL | foo(&mut v); = note: expected mutable reference `&mut HashSet` found mutable reference `&mut Vec<_>` note: function defined here - --> $DIR/issue-24819.rs:12:4 + --> $DIR/vec-hashset-type-mismatch.rs:13:4 | -LL | fn foo(h: &mut HashSet) { +LL | fn foo(h: &mut HashSet) {} | ^^^ -------------------- error: aborting due to 1 previous error diff --git a/tests/ui/issues/auxiliary/issue-16725.rs b/tests/ui/privacy/auxiliary/private-extern-fn.rs similarity index 100% rename from tests/ui/issues/auxiliary/issue-16725.rs rename to tests/ui/privacy/auxiliary/private-extern-fn.rs diff --git a/tests/ui/privacy/privacy-sanity.rs b/tests/ui/privacy/privacy-sanity.rs index 6622089dda6d7..fcd03394d631b 100644 --- a/tests/ui/privacy/privacy-sanity.rs +++ b/tests/ui/privacy/privacy-sanity.rs @@ -25,6 +25,14 @@ pub extern "C" { //~ ERROR visibility qualifiers are not permitted here pub static St: u8; } +enum Bird { + pub Duck, + //~^ ERROR visibility qualifiers are not permitted here + pub(crate) Dove, + //~^ ERROR visibility qualifiers are not permitted here + Goose, +} + const MAIN: u8 = { pub trait Tr { fn f(); @@ -79,4 +87,11 @@ fn main() { pub fn f(); pub static St: u8; } + enum Bird { + pub Duck, + //~^ ERROR visibility qualifiers are not permitted here + pub(crate) Dove, + //~^ ERROR visibility qualifiers are not permitted here + Goose, + } } diff --git a/tests/ui/privacy/privacy-sanity.stderr b/tests/ui/privacy/privacy-sanity.stderr index 0acb05cbabaa7..fd643357335a1 100644 --- a/tests/ui/privacy/privacy-sanity.stderr +++ b/tests/ui/privacy/privacy-sanity.stderr @@ -47,7 +47,23 @@ LL | pub extern "C" { = note: place qualifiers on individual foreign items instead error[E0449]: visibility qualifiers are not permitted here - --> $DIR/privacy-sanity.rs:39:5 + --> $DIR/privacy-sanity.rs:29:5 + | +LL | pub Duck, + | ^^^ help: remove the qualifier + | + = note: enum variants and their fields always share the visibility of the enum they are in + +error[E0449]: visibility qualifiers are not permitted here + --> $DIR/privacy-sanity.rs:31:5 + | +LL | pub(crate) Dove, + | ^^^^^^^^^^ help: remove the qualifier + | + = note: enum variants and their fields always share the visibility of the enum they are in + +error[E0449]: visibility qualifiers are not permitted here + --> $DIR/privacy-sanity.rs:47:5 | LL | pub impl Tr for S { | ^^^ help: remove the qualifier @@ -55,7 +71,7 @@ LL | pub impl Tr for S { = note: trait items always share the visibility of their trait error[E0449]: visibility qualifiers are not permitted here - --> $DIR/privacy-sanity.rs:40:9 + --> $DIR/privacy-sanity.rs:48:9 | LL | pub fn f() {} | ^^^ help: remove the qualifier @@ -63,7 +79,7 @@ LL | pub fn f() {} = note: trait items always share the visibility of their trait error[E0449]: visibility qualifiers are not permitted here - --> $DIR/privacy-sanity.rs:41:9 + --> $DIR/privacy-sanity.rs:49:9 | LL | pub const C: u8 = 0; | ^^^ help: remove the qualifier @@ -71,7 +87,7 @@ LL | pub const C: u8 = 0; = note: trait items always share the visibility of their trait error[E0449]: visibility qualifiers are not permitted here - --> $DIR/privacy-sanity.rs:42:9 + --> $DIR/privacy-sanity.rs:50:9 | LL | pub type T = u8; | ^^^ help: remove the qualifier @@ -79,7 +95,7 @@ LL | pub type T = u8; = note: trait items always share the visibility of their trait error[E0449]: visibility qualifiers are not permitted here - --> $DIR/privacy-sanity.rs:44:5 + --> $DIR/privacy-sanity.rs:52:5 | LL | pub impl S { | ^^^ help: remove the qualifier @@ -87,7 +103,7 @@ LL | pub impl S { = note: place qualifiers on individual impl items instead error[E0449]: visibility qualifiers are not permitted here - --> $DIR/privacy-sanity.rs:49:5 + --> $DIR/privacy-sanity.rs:57:5 | LL | pub extern "C" { | ^^^ help: remove the qualifier @@ -95,7 +111,7 @@ LL | pub extern "C" { = note: place qualifiers on individual foreign items instead error[E0449]: visibility qualifiers are not permitted here - --> $DIR/privacy-sanity.rs:68:5 + --> $DIR/privacy-sanity.rs:76:5 | LL | pub impl Tr for S { | ^^^ help: remove the qualifier @@ -103,7 +119,7 @@ LL | pub impl Tr for S { = note: trait items always share the visibility of their trait error[E0449]: visibility qualifiers are not permitted here - --> $DIR/privacy-sanity.rs:69:9 + --> $DIR/privacy-sanity.rs:77:9 | LL | pub fn f() {} | ^^^ help: remove the qualifier @@ -111,7 +127,7 @@ LL | pub fn f() {} = note: trait items always share the visibility of their trait error[E0449]: visibility qualifiers are not permitted here - --> $DIR/privacy-sanity.rs:70:9 + --> $DIR/privacy-sanity.rs:78:9 | LL | pub const C: u8 = 0; | ^^^ help: remove the qualifier @@ -119,7 +135,7 @@ LL | pub const C: u8 = 0; = note: trait items always share the visibility of their trait error[E0449]: visibility qualifiers are not permitted here - --> $DIR/privacy-sanity.rs:71:9 + --> $DIR/privacy-sanity.rs:79:9 | LL | pub type T = u8; | ^^^ help: remove the qualifier @@ -127,7 +143,7 @@ LL | pub type T = u8; = note: trait items always share the visibility of their trait error[E0449]: visibility qualifiers are not permitted here - --> $DIR/privacy-sanity.rs:73:5 + --> $DIR/privacy-sanity.rs:81:5 | LL | pub impl S { | ^^^ help: remove the qualifier @@ -135,13 +151,29 @@ LL | pub impl S { = note: place qualifiers on individual impl items instead error[E0449]: visibility qualifiers are not permitted here - --> $DIR/privacy-sanity.rs:78:5 + --> $DIR/privacy-sanity.rs:86:5 | LL | pub extern "C" { | ^^^ help: remove the qualifier | = note: place qualifiers on individual foreign items instead -error: aborting due to 18 previous errors +error[E0449]: visibility qualifiers are not permitted here + --> $DIR/privacy-sanity.rs:91:9 + | +LL | pub Duck, + | ^^^ help: remove the qualifier + | + = note: enum variants and their fields always share the visibility of the enum they are in + +error[E0449]: visibility qualifiers are not permitted here + --> $DIR/privacy-sanity.rs:93:9 + | +LL | pub(crate) Dove, + | ^^^^^^^^^^ help: remove the qualifier + | + = note: enum variants and their fields always share the visibility of the enum they are in + +error: aborting due to 22 previous errors For more information about this error, try `rustc --explain E0449`. diff --git a/tests/ui/privacy/private-extern-fn-visibility.rs b/tests/ui/privacy/private-extern-fn-visibility.rs new file mode 100644 index 0000000000000..39f2c3c003d57 --- /dev/null +++ b/tests/ui/privacy/private-extern-fn-visibility.rs @@ -0,0 +1,11 @@ +//! regression test for +//@ aux-build:private-extern-fn.rs + +extern crate private_extern_fn as foo; + +fn main() { + unsafe { + foo::bar(); + //~^ ERROR: function `bar` is private + } +} diff --git a/tests/ui/issues/issue-16725.stderr b/tests/ui/privacy/private-extern-fn-visibility.stderr similarity index 60% rename from tests/ui/issues/issue-16725.stderr rename to tests/ui/privacy/private-extern-fn-visibility.stderr index dcb7d58b0f961..8b1fa512b5de2 100644 --- a/tests/ui/issues/issue-16725.stderr +++ b/tests/ui/privacy/private-extern-fn-visibility.stderr @@ -1,11 +1,11 @@ error[E0603]: function `bar` is private - --> $DIR/issue-16725.rs:6:19 + --> $DIR/private-extern-fn-visibility.rs:8:14 | -LL | unsafe { foo::bar(); } - | ^^^ private function +LL | foo::bar(); + | ^^^ private function | note: the function `bar` is defined here - --> $DIR/auxiliary/issue-16725.rs:2:5 + --> $DIR/auxiliary/private-extern-fn.rs:2:5 | LL | fn bar(); | ^^^^^^^^^ diff --git a/tests/ui/issues/issue-22894.rs b/tests/ui/static/static-str-deref-ref.rs similarity index 51% rename from tests/ui/issues/issue-22894.rs rename to tests/ui/static/static-str-deref-ref.rs index e8fc680f04224..86c37e527657c 100644 --- a/tests/ui/issues/issue-22894.rs +++ b/tests/ui/static/static-str-deref-ref.rs @@ -1,3 +1,4 @@ +//! regression test for //@ build-pass #[allow(dead_code)] static X: &'static str = &*""; diff --git a/tests/ui/structs/parse-error-with-type-param.fixed b/tests/ui/structs/parse-error-with-type-param.fixed new file mode 100644 index 0000000000000..46d1c27228435 --- /dev/null +++ b/tests/ui/structs/parse-error-with-type-param.fixed @@ -0,0 +1,14 @@ +//@ run-rustfix +// #141403 +#![allow(dead_code)] + +#[derive(Clone)] +struct B { + a: A<(T, u32)>, // <- note, comma is missing here + /// asdf + //~^ ERROR found a documentation comment that doesn't document anything + b: u32, +} +#[derive(Clone)] +struct A(T); +fn main() {} diff --git a/tests/ui/structs/parse-error-with-type-param.rs b/tests/ui/structs/parse-error-with-type-param.rs new file mode 100644 index 0000000000000..27a9fc854f577 --- /dev/null +++ b/tests/ui/structs/parse-error-with-type-param.rs @@ -0,0 +1,14 @@ +//@ run-rustfix +// #141403 +#![allow(dead_code)] + +#[derive(Clone)] +struct B { + a: A<(T, u32)> // <- note, comma is missing here + /// asdf + //~^ ERROR found a documentation comment that doesn't document anything + b: u32, +} +#[derive(Clone)] +struct A(T); +fn main() {} diff --git a/tests/ui/structs/parse-error-with-type-param.stderr b/tests/ui/structs/parse-error-with-type-param.stderr new file mode 100644 index 0000000000000..d01eae193b147 --- /dev/null +++ b/tests/ui/structs/parse-error-with-type-param.stderr @@ -0,0 +1,18 @@ +error[E0585]: found a documentation comment that doesn't document anything + --> $DIR/parse-error-with-type-param.rs:8:5 + | +LL | struct B { + | - while parsing this struct +LL | a: A<(T, u32)> // <- note, comma is missing here +LL | /// asdf + | ^^^^^^^^ + | + = help: doc comments must come before what they document, if a comment was intended use `//` +help: missing comma here + | +LL | a: A<(T, u32)>, // <- note, comma is missing here + | + + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0585`. diff --git a/tests/ui/threads-sendsync/std-sync-right-kind-impls.rs b/tests/ui/threads-sendsync/std-sync-right-kind-impls.rs index b2d22631c1a5e..42135fe1c45bd 100644 --- a/tests/ui/threads-sendsync/std-sync-right-kind-impls.rs +++ b/tests/ui/threads-sendsync/std-sync-right-kind-impls.rs @@ -1,6 +1,6 @@ //@ run-pass -use std::sync; +use std::{fs, net, sync}; fn assert_both() {} @@ -12,4 +12,20 @@ fn main() { assert_both::>(); assert_both::>(); assert_both::(); + + assert_both::(); + assert_both::(); + assert_both::(); + assert_both::(); + assert_both::(); + assert_both::(); + + assert_both::(); + assert_both::(); + assert_both::(); + assert_both::(); + assert_both::(); + assert_both::(); + assert_both::(); + assert_both::(); }