Auto merge of #149631 - matthiaskrgr:rollup-jbx443u, r=matthiaskrgr

Rollup of 12 pull requests

Successful merges:

 - rust-lang/rust#147841 (Fix ICE when applying test macro to crate root)
 - rust-lang/rust#149147 (Fix unused_assignments false positives from macros)
 - rust-lang/rust#149183 (Use `TypingMode::PostAnalysis` in `try_evaluate_const`)
 - rust-lang/rust#149456 (std: don't call `current_os_id` from signal handler)
 - rust-lang/rust#149501 (CTFE: avoid emitting a hard error on generic normalization failures)
 - rust-lang/rust#149528 (reword error for invalid range patterns)
 - rust-lang/rust#149539 (Additional test for uN::{gather,scatter}_bits)
 - rust-lang/rust#149549 (Regression test for system register `ttbr0_el2`)
 - rust-lang/rust#149550 (Disable native-lib for x check miri)
 - rust-lang/rust#149554 (build-manifest: generate MSI and MINGW arrays from rustc)
 - rust-lang/rust#149557 (c-variadic: bpf and spirv do not support c-variadic definitions)
 - rust-lang/rust#149569 (Fix mailmap issue)

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2025-12-04 08:18:30 +00:00
commit b1b08cdef5
53 changed files with 814 additions and 414 deletions

View file

@ -43,6 +43,7 @@ Andre Bogus <bogusandre@gmail.com>
Andre Bogus <bogusandre@gmail.com> <andre.bogus@aleph-alpha.de>
Andre Bogus <bogusandre@gmail.com> <andre.bogus@ankordata.de>
Andrea Ciliberti <meziu210@icloud.com>
Andreas Gal <gal@mozilla.com> <andreas.gal@gmail.com>
Andreas Jonson <andjo403@users.noreply.github.com>
Andrew Gauger <andygauge@gmail.com>
@ -87,7 +88,9 @@ bjorn3 <17426603+bjorn3@users.noreply.github.com> <bjorn3@users.noreply.github.c
bjorn3 <17426603+bjorn3@users.noreply.github.com> <bjorn3_gh@protonmail.com>
Björn Steinbrink <bsteinbr@gmail.com> <B.Steinbrink@gmx.de>
blake2-ppc <ulrik.sverdrup@gmail.com> <blake2-ppc>
blyxyas <blyxyas@gmail.com> Alejandra González <blyxyas@gmail.com>
Alejandra González <blyxyas@goose.love> blyxyas <blyxyas@gmail.com>
Alejandra González <blyxyas@goose.love> blyxyas <blyxyas@goose.love>
Alejandra González <blyxyas@goose.love> Alejandra González <blyxyas@gmail.com>
boolean_coercion <booleancoercion@gmail.com>
Boris Egorov <jightuse@gmail.com> <egorov@linux.com>
bors <bors@rust-lang.org> bors[bot] <26634292+bors[bot]@users.noreply.github.com>

View file

@ -80,6 +80,8 @@ ast_passes_c_variadic_must_be_unsafe =
ast_passes_c_variadic_no_extern = `...` is not supported for non-extern functions
.help = only `extern "C"` and `extern "C-unwind"` functions may have a C variable argument list
ast_passes_c_variadic_not_supported = the `{$target}` target does not support c-variadic functions
ast_passes_const_and_c_variadic = functions cannot be both `const` and C-variadic
.const = `const` because of this
.variadic = C-variadic because of this

View file

@ -710,6 +710,14 @@ impl<'a> AstValidator<'a> {
match fn_ctxt {
FnCtxt::Foreign => return,
FnCtxt::Free | FnCtxt::Assoc(_) => {
if !self.sess.target.arch.supports_c_variadic_definitions() {
self.dcx().emit_err(errors::CVariadicNotSupported {
variadic_span: variadic_param.span,
target: &*self.sess.target.llvm_target,
});
return;
}
match sig.header.ext {
Extern::Implicit(_) => {
if !matches!(sig.header.safety, Safety::Unsafe(_)) {

View file

@ -733,6 +733,14 @@ pub(crate) struct CoroutineAndCVariadic {
pub variadic_span: Span,
}
#[derive(Diagnostic)]
#[diag(ast_passes_c_variadic_not_supported)]
pub(crate) struct CVariadicNotSupported<'a> {
#[primary_span]
pub variadic_span: Span,
pub target: &'a str,
}
#[derive(Diagnostic)]
#[diag(ast_passes_pattern_in_foreign, code = E0130)]
// FIXME: deduplicate with rustc_lint (`BuiltinLintDiag::PatternsInFnsWithoutBody`)

View file

@ -34,10 +34,6 @@ pub(crate) fn expand_test_case(
check_builtin_macro_attribute(ecx, meta_item, sym::test_case);
warn_on_duplicate_attribute(ecx, &anno_item, sym::test_case);
if !ecx.ecfg.should_test {
return vec![];
}
let sp = ecx.with_def_site_ctxt(attr_sp);
let (mut item, is_stmt) = match anno_item {
Annotatable::Item(item) => (item, false),
@ -54,6 +50,10 @@ pub(crate) fn expand_test_case(
}
};
if !ecx.ecfg.should_test {
return vec![];
}
// `#[test_case]` is valid on functions, consts, and statics. Only modify
// the item in those cases.
match &mut item.kind {
@ -113,22 +113,17 @@ pub(crate) fn expand_test_or_bench(
item: Annotatable,
is_bench: bool,
) -> Vec<Annotatable> {
// If we're not in test configuration, remove the annotated item
if !cx.ecfg.should_test {
return vec![];
}
let (item, is_stmt) = match item {
Annotatable::Item(i) => (i, false),
Annotatable::Stmt(box ast::Stmt { kind: ast::StmtKind::Item(i), .. }) => (i, true),
other => {
not_testable_error(cx, attr_sp, None);
not_testable_error(cx, is_bench, attr_sp, None);
return vec![other];
}
};
let ast::ItemKind::Fn(fn_) = &item.kind else {
not_testable_error(cx, attr_sp, Some(&item));
not_testable_error(cx, is_bench, attr_sp, Some(&item));
return if is_stmt {
vec![Annotatable::Stmt(Box::new(cx.stmt_item(item.span, item)))]
} else {
@ -136,6 +131,11 @@ pub(crate) fn expand_test_or_bench(
};
};
// If we're not in test configuration, remove the annotated item
if !cx.ecfg.should_test {
return vec![];
}
if let Some(attr) = attr::find_by_name(&item.attrs, sym::naked) {
cx.dcx().emit_err(errors::NakedFunctionTestingAttribute {
testing_span: attr_sp,
@ -405,9 +405,10 @@ pub(crate) fn expand_test_or_bench(
}
}
fn not_testable_error(cx: &ExtCtxt<'_>, attr_sp: Span, item: Option<&ast::Item>) {
fn not_testable_error(cx: &ExtCtxt<'_>, is_bench: bool, attr_sp: Span, item: Option<&ast::Item>) {
let dcx = cx.dcx();
let msg = "the `#[test]` attribute may only be used on a non-associated function";
let name = if is_bench { "bench" } else { "test" };
let msg = format!("the `#[{name}]` attribute may only be used on a free function");
let level = match item.map(|i| &i.kind) {
// These were a warning before #92959 and need to continue being that to avoid breaking
// stable user code (#94508).
@ -426,12 +427,16 @@ fn not_testable_error(cx: &ExtCtxt<'_>, attr_sp: Span, item: Option<&ast::Item>)
),
);
}
err.with_span_label(attr_sp, "the `#[test]` macro causes a function to be run as a test and has no effect on non-functions")
.with_span_suggestion(attr_sp,
err.span_label(attr_sp, format!("the `#[{name}]` macro causes a function to be run as a test and has no effect on non-functions"));
if !is_bench {
err.with_span_suggestion(attr_sp,
"replace with conditional compilation to make the item only exist when tests are being run",
"#[cfg(test)]",
Applicability::MaybeIncorrect)
.emit();
Applicability::MaybeIncorrect).emit();
} else {
err.emit();
}
}
fn get_location_info(cx: &ExtCtxt<'_>, fn_: &ast::Fn) -> (Symbol, usize, usize, usize, usize) {

View file

@ -11,7 +11,9 @@ use rustc_middle::ty::layout::{
self, FnAbiError, FnAbiOf, FnAbiOfHelpers, FnAbiRequest, LayoutError, LayoutOf,
LayoutOfHelpers, TyAndLayout,
};
use rustc_middle::ty::{self, GenericArgsRef, Ty, TyCtxt, TypeFoldable, TypingEnv, Variance};
use rustc_middle::ty::{
self, GenericArgsRef, Ty, TyCtxt, TypeFoldable, TypeVisitableExt, TypingEnv, Variance,
};
use rustc_middle::{mir, span_bug};
use rustc_span::Span;
use rustc_target::callconv::FnAbi;
@ -84,10 +86,31 @@ impl<'tcx, M: Machine<'tcx>> LayoutOfHelpers<'tcx> for InterpCx<'tcx, M> {
#[inline]
fn handle_layout_err(
&self,
err: LayoutError<'tcx>,
mut err: LayoutError<'tcx>,
_: Span,
_: Ty<'tcx>,
) -> InterpErrorKind<'tcx> {
// FIXME(#149283): This is really hacky and is only used to hide type
// system bugs. We use it as a temporary fix for #149081.
//
// While it's expected that we sometimes get ambiguity errors when
// entering another generic environment while the current environment
// itself is still generic, we should never fail to entirely prove
// something.
match err {
LayoutError::NormalizationFailure(ty, _) => {
if ty.has_non_region_param() {
err = LayoutError::TooGeneric(ty);
}
}
LayoutError::Unknown(_)
| LayoutError::SizeOverflow(_)
| LayoutError::InvalidSimd { .. }
| LayoutError::TooGeneric(_)
| LayoutError::ReferencesError(_)
| LayoutError::Cycle(_) => {}
}
err_inval!(Layout(err))
}
}
@ -112,7 +135,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
/// and allows wrapping the actual [LayoutOf::layout_of] with a tracing span.
/// See [LayoutOf::layout_of] for the original documentation.
#[inline(always)]
pub fn layout_of(&self, ty: Ty<'tcx>) -> <Self as LayoutOfHelpers<'tcx>>::LayoutOfResult {
pub fn layout_of(&self, ty: Ty<'tcx>) -> Result<TyAndLayout<'tcx>, InterpErrorKind<'tcx>> {
let _trace = enter_trace_span!(M, layouting::layout_of, ty = ?ty.kind());
LayoutOf::layout_of(self, ty)
}

View file

@ -250,11 +250,11 @@ mir_build_loop_match_unsupported_type =
.note = only integers, floats, bool, char, and enums without fields are supported
mir_build_lower_range_bound_must_be_less_than_or_equal_to_upper =
lower range bound must be less than or equal to upper
lower bound for range pattern must be less than or equal to upper bound
.label = lower bound larger than upper bound
.teach_note = When matching against a range, the compiler verifies that the range is non-empty. Range patterns include both end-points, so this is equivalent to requiring the start of the range to be less than or equal to the end of the range.
mir_build_lower_range_bound_must_be_less_than_upper = lower range bound must be less than upper
mir_build_lower_range_bound_must_be_less_than_upper = lower bound for range pattern must be less than upper bound
mir_build_more_information = for more information, visit https://doc.rust-lang.org/book/ch19-02-refutability.html
@ -506,6 +506,8 @@ mir_build_unused_unsafe = unnecessary `unsafe` block
mir_build_unused_unsafe_enclosing_block_label = because it's nested under this `unsafe` block
mir_build_upper_range_bound_cannot_be_min = exclusive upper bound for a range bound cannot be the minimum
mir_build_variant_defined_here = not covered
mir_build_wrap_suggestion = consider wrapping the function body in an unsafe block

View file

@ -776,6 +776,13 @@ pub(crate) struct LowerRangeBoundMustBeLessThanUpper {
pub(crate) span: Span,
}
#[derive(Diagnostic)]
#[diag(mir_build_upper_range_bound_cannot_be_min, code = E0579)]
pub(crate) struct UpperRangeBoundCannotBeMin {
#[primary_span]
pub(crate) span: Span,
}
#[derive(LintDiagnostic)]
#[diag(mir_build_leading_irrefutable_let_patterns)]
#[note]

View file

@ -273,6 +273,9 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
teach: self.tcx.sess.teach(E0030),
})
}
RangeEnd::Excluded if lo_expr.is_none() => {
self.tcx.dcx().emit_err(UpperRangeBoundCannotBeMin { span })
}
RangeEnd::Excluded => {
self.tcx.dcx().emit_err(LowerRangeBoundMustBeLessThanUpper { span })
}

View file

@ -75,6 +75,11 @@ pub(crate) fn check_liveness<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> Den
return DenseBitSet::new_empty(0);
}
// Don't run unused pass for items generated by foreign macros
if tcx.def_span(parent).in_external_macro(tcx.sess.source_map()) {
return DenseBitSet::new_empty(0);
}
let mut body = &*tcx.mir_promoted(def_id).0.borrow();
let mut body_mem;

View file

@ -1925,6 +1925,24 @@ impl Arch {
Self::Other(name) => rustc_span::Symbol::intern(name),
}
}
pub fn supports_c_variadic_definitions(&self) -> bool {
use Arch::*;
match self {
// These targets just do not support c-variadic definitions.
Bpf | SpirV => false,
// We don't know if the target supports c-variadic definitions, but we don't want
// to needlessly restrict custom target.json configurations.
Other(_) => true,
AArch64 | AmdGpu | Arm | Arm64EC | Avr | CSky | Hexagon | LoongArch32 | LoongArch64
| M68k | Mips | Mips32r6 | Mips64 | Mips64r6 | Msp430 | Nvptx64 | PowerPC
| PowerPC64 | PowerPC64LE | RiscV32 | RiscV64 | S390x | Sparc | Sparc64 | Wasm32
| Wasm64 | X86 | X86_64 | Xtensa => true,
}
}
}
crate::target_spec_enum! {

View file

@ -681,7 +681,7 @@ pub fn try_evaluate_const<'tcx>(
(args, typing_env)
}
_ => {
Some(ty::AnonConstKind::MCG) | Some(ty::AnonConstKind::NonTypeSystem) | None => {
// We are only dealing with "truly" generic/uninferred constants here:
// - GCEConsts have been handled separately
// - Repeat expr count back compat consts have also been handled separately
@ -700,7 +700,7 @@ pub fn try_evaluate_const<'tcx>(
// Since there is no generic parameter, we can just drop the environment
// to prevent query cycle.
let typing_env = infcx.typing_env(ty::ParamEnv::empty());
let typing_env = ty::TypingEnv::fully_monomorphized();
(uv.args, typing_env)
}

View file

@ -387,6 +387,68 @@ macro_rules! uint_module {
}
}
#[cfg(not(miri))] // Miri is too slow
#[test]
fn test_lots_of_gather_scatter() {
// Generate a handful of bit patterns to use as inputs
let xs = {
let mut xs = vec![];
let mut x: $T = !0;
let mut w = $T::BITS;
while w > 0 {
w >>= 1;
xs.push(x);
xs.push(!x);
x ^= x << w;
}
xs
};
if $T::BITS == 8 {
assert_eq!(&xs, &[0xff, 0x00, 0x0f, 0xf0, 0x33, 0xcc, 0x55, 0xaa]);
}
// `256 * (BITS / 5)` masks
let sparse_masks = (i8::MIN..=i8::MAX)
.map(|i| (i as i128 as $T).rotate_right(4))
.flat_map(|x| (0..$T::BITS).step_by(5).map(move |r| x.rotate_right(r)));
for sparse in sparse_masks {
// Collect the set bits to sequential low bits
let dense = sparse.gather_bits(sparse);
let count = sparse.count_ones();
assert_eq!(count, dense.count_ones());
assert_eq!(count, dense.trailing_ones());
// Check that each bit is individually mapped correctly
let mut t = sparse;
let mut bit = 1 as $T;
for _ in 0..count {
let lowest_one = t.isolate_lowest_one();
assert_eq!(lowest_one, bit.scatter_bits(sparse));
assert_eq!(bit, lowest_one.gather_bits(sparse));
t ^= lowest_one;
bit <<= 1;
}
// Other bits are ignored
assert_eq!(0, bit.wrapping_neg().scatter_bits(sparse));
assert_eq!(0, (!sparse).gather_bits(sparse));
for &x in &xs {
// Gather bits from `x & sparse` to `dense`
let dx = x.gather_bits(sparse);
assert_eq!(dx & !dense, 0);
// Scatter bits from `x & dense` to `sparse`
let sx = x.scatter_bits(sparse);
assert_eq!(sx & !sparse, 0);
// The other recovers the input (within the mask)
assert_eq!(dx.scatter_bits(sparse), x & sparse);
assert_eq!(sx.gather_bits(sparse), x & dense);
}
}
}
test_runtime_and_compiletime! {
fn test_div_floor() {
assert_eq_const_safe!($T: (8 as $T).div_floor(3), 2);

View file

@ -109,14 +109,14 @@ fn handle_rt_panic<T>(e: Box<dyn Any + Send>) -> T {
// `compiler/rustc_session/src/config/sigpipe.rs`.
#[cfg_attr(test, allow(dead_code))]
unsafe fn init(argc: isize, argv: *const *const u8, sigpipe: u8) {
// Remember the main thread ID to give it the correct name.
// SAFETY: this is the only time and place where we call this function.
unsafe { main_thread::set(thread::current_id()) };
#[cfg_attr(target_os = "teeos", allow(unused_unsafe))]
unsafe {
sys::init(argc, argv, sigpipe)
};
// Remember the main thread ID to give it the correct name.
// SAFETY: this is the only time and place where we call this function.
unsafe { main_thread::set(thread::current_id()) };
}
/// Clean up the thread-local runtime state. This *should* be run after all other

View file

@ -8,8 +8,8 @@ pub struct Handler {
}
impl Handler {
pub unsafe fn new(thread_name: Option<Box<str>>) -> Handler {
make_handler(false, thread_name)
pub unsafe fn new() -> Handler {
make_handler(false)
}
fn null() -> Handler {
@ -117,8 +117,15 @@ mod imp {
if let Some(thread_info) = thread_info
&& thread_info.guard_page_range.contains(&fault_addr)
{
let name = thread_info.thread_name.as_deref().unwrap_or("<unknown>");
let tid = crate::thread::current_os_id();
// Hey you! Yes, you modifying the stack overflow message!
// Please make sure that all functions called here are
// actually async-signal-safe. If they're not, try retrieving
// the information beforehand and storing it in `ThreadInfo`.
// Thank you!
// - says Jonas after having had to watch his carefully
// written code get made unsound again.
let tid = thread_info.tid;
let name = thread_info.name.as_deref().unwrap_or("<unknown>");
rtprintpanic!("\nthread '{name}' ({tid}) has overflowed its stack\n");
rtabort!("stack overflow");
}
@ -164,12 +171,12 @@ mod imp {
if !NEED_ALTSTACK.load(Ordering::Relaxed) {
// haven't set up our sigaltstack yet
NEED_ALTSTACK.store(true, Ordering::Release);
let handler = unsafe { make_handler(true, None) };
let handler = unsafe { make_handler(true) };
MAIN_ALTSTACK.store(handler.data, Ordering::Relaxed);
mem::forget(handler);
if let Some(guard_page_range) = guard_page_range.take() {
set_current_info(guard_page_range, Some(Box::from("main")));
set_current_info(guard_page_range);
}
}
@ -240,14 +247,14 @@ mod imp {
/// # Safety
/// Mutates the alternate signal stack
#[forbid(unsafe_op_in_unsafe_fn)]
pub unsafe fn make_handler(main_thread: bool, thread_name: Option<Box<str>>) -> Handler {
pub unsafe fn make_handler(main_thread: bool) -> Handler {
if cfg!(panic = "immediate-abort") || !NEED_ALTSTACK.load(Ordering::Acquire) {
return Handler::null();
}
if !main_thread {
if let Some(guard_page_range) = unsafe { current_guard() } {
set_current_info(guard_page_range, thread_name);
set_current_info(guard_page_range);
}
}
@ -633,10 +640,7 @@ mod imp {
pub unsafe fn cleanup() {}
pub unsafe fn make_handler(
_main_thread: bool,
_thread_name: Option<Box<str>>,
) -> super::Handler {
pub unsafe fn make_handler(_main_thread: bool) -> super::Handler {
super::Handler::null()
}
@ -720,10 +724,7 @@ mod imp {
pub unsafe fn cleanup() {}
pub unsafe fn make_handler(
main_thread: bool,
_thread_name: Option<Box<str>>,
) -> super::Handler {
pub unsafe fn make_handler(main_thread: bool) -> super::Handler {
if !main_thread {
reserve_stack();
}

View file

@ -32,8 +32,9 @@ use crate::sync::atomic::{AtomicUsize, Ordering};
use crate::sys::os::errno_location;
pub struct ThreadInfo {
pub tid: u64,
pub name: Option<Box<str>>,
pub guard_page_range: Range<usize>,
pub thread_name: Option<Box<str>>,
}
static LOCK: Mutex<()> = Mutex::new(());
@ -108,14 +109,17 @@ fn spin_lock_in_setup(this: usize) -> UnlockOnDrop {
}
}
pub fn set_current_info(guard_page_range: Range<usize>, thread_name: Option<Box<str>>) {
pub fn set_current_info(guard_page_range: Range<usize>) {
let tid = crate::thread::current_os_id();
let name = crate::thread::with_current_name(|name| name.map(Box::from));
let this = errno_location().addr();
let _lock_guard = LOCK.lock();
let _spin_guard = spin_lock_in_setup(this);
// SAFETY: we own the spin lock, so `THREAD_INFO` cannot be aliased.
let thread_info = unsafe { &mut *(&raw mut THREAD_INFO) };
thread_info.insert(this, ThreadInfo { guard_page_range, thread_name });
thread_info.insert(this, ThreadInfo { tid, name, guard_page_range });
}
pub fn delete_current_info() {

View file

@ -14,7 +14,7 @@ use crate::sys::weak::dlsym;
#[cfg(any(target_os = "solaris", target_os = "illumos", target_os = "nto",))]
use crate::sys::weak::weak;
use crate::sys::{os, stack_overflow};
use crate::thread::{ThreadInit, current};
use crate::thread::ThreadInit;
use crate::time::Duration;
use crate::{cmp, io, ptr};
#[cfg(not(any(
@ -111,10 +111,9 @@ impl Thread {
let init = Box::from_raw(data as *mut ThreadInit);
let rust_start = init.init();
// Set up our thread name and stack overflow handler which may get triggered
// if we run out of stack.
let thread = current();
let _handler = stack_overflow::Handler::new(thread.name().map(Box::from));
// Now that the thread information is set, set up our stack
// overflow handler.
let _handler = stack_overflow::Handler::new();
rust_start();
}

View file

@ -662,6 +662,7 @@ macro_rules! tool_check_step {
$(, allow_features: $allow_features:expr )?
// Features that should be enabled when checking
$(, enable_features: [$($enable_features:expr),*] )?
$(, default_features: $default_features:expr )?
$(, default: $default:literal )?
$( , )?
}
@ -708,8 +709,13 @@ macro_rules! tool_check_step {
_value
};
let extra_features: &[&str] = &[$($($enable_features),*)?];
let default_features = {
let mut _value = true;
$( _value = $default_features; )?
_value
};
let mode: Mode = $mode;
run_tool_check_step(builder, compiler, target, $path, mode, allow_features, extra_features);
run_tool_check_step(builder, compiler, target, $path, mode, allow_features, extra_features, default_features);
}
fn metadata(&self) -> Option<StepMetadata> {
@ -720,6 +726,7 @@ macro_rules! tool_check_step {
}
/// Used by the implementation of `Step::run` in `tool_check_step!`.
#[allow(clippy::too_many_arguments)]
fn run_tool_check_step(
builder: &Builder<'_>,
compiler: CompilerForCheck,
@ -728,6 +735,7 @@ fn run_tool_check_step(
mode: Mode,
allow_features: &str,
extra_features: &[&str],
default_features: bool,
) {
let display_name = path.rsplit('/').next().unwrap();
@ -761,6 +769,10 @@ fn run_tool_check_step(
cargo.arg("--all-targets");
}
if !default_features {
cargo.arg("--no-default-features");
}
let stamp = BuildStamp::new(&builder.cargo_out(build_compiler, mode, target))
.with_prefix(&format!("{display_name}-check"));
@ -778,7 +790,12 @@ tool_check_step!(Rustdoc {
// behavior, treat it as in-tree so that any new warnings in clippy will be
// rejected.
tool_check_step!(Clippy { path: "src/tools/clippy", mode: Mode::ToolRustcPrivate });
tool_check_step!(Miri { path: "src/tools/miri", mode: Mode::ToolRustcPrivate });
tool_check_step!(Miri {
path: "src/tools/miri",
mode: Mode::ToolRustcPrivate,
enable_features: ["stack-cache"],
default_features: false,
});
tool_check_step!(CargoMiri { path: "src/tools/miri/cargo-miri", mode: Mode::ToolRustcPrivate });
tool_check_step!(Rustfmt { path: "src/tools/rustfmt", mode: Mode::ToolRustcPrivate });
tool_check_step!(RustAnalyzer {

View file

@ -60,7 +60,7 @@ fn main() {
let mut output = String::new();
writeln!(output, "static HOSTS: &[&str] = &[").unwrap();
for host in targets.hosts {
for host in &targets.hosts {
writeln!(output, " {:?},", host).unwrap();
}
writeln!(output, "];").unwrap();
@ -71,6 +71,22 @@ fn main() {
}
writeln!(output, "];").unwrap();
writeln!(output, "static MSI_INSTALLERS: &[&str] = &[").unwrap();
for host in &targets.hosts {
if host.contains("-windows-") {
writeln!(output, " {:?},", host).unwrap();
}
}
writeln!(output, "];").unwrap();
writeln!(output, "static MINGW: &[&str] = &[").unwrap();
for host in targets.hosts {
if host.contains("-windows-gnu") {
writeln!(output, " {:?},", host).unwrap();
}
}
writeln!(output, "];").unwrap();
std::fs::write(PathBuf::from(std::env::var_os("OUT_DIR").unwrap()).join("targets.rs"), output)
.unwrap();
}

View file

@ -29,18 +29,8 @@ static DOCS_FALLBACK: &[(&str, &str)] = &[
("", "x86_64-unknown-linux-gnu"),
];
static MSI_INSTALLERS: &[&str] = &[
"aarch64-pc-windows-msvc",
"i686-pc-windows-gnu",
"i686-pc-windows-msvc",
"x86_64-pc-windows-gnu",
"x86_64-pc-windows-msvc",
];
static PKG_INSTALLERS: &[&str] = &["x86_64-apple-darwin", "aarch64-apple-darwin"];
static MINGW: &[&str] = &["i686-pc-windows-gnu", "x86_64-pc-windows-gnu"];
static NIGHTLY_ONLY_COMPONENTS: &[PkgType] =
&[PkgType::Miri, PkgType::JsonDocs, PkgType::RustcCodegenCranelift];

View file

@ -1,2 +0,0 @@
//@ known-bug: #114920
#![core::prelude::v1::test]

View file

@ -0,0 +1,11 @@
//! Regression test for #97724, recognising ttbr0_el2 as a valid armv8 system register
//@ only-aarch64
//@ build-pass
use std::arch::asm;
static PT: [u64; 512] = [0; 512];
fn main() {
unsafe {
asm!("msr ttbr0_el2, {pt}", pt = in(reg) &PT as *const _ );
}
}

View file

@ -3,6 +3,6 @@
fn main() {
match 5u32 {
1000 ..= 5 => {}
//~^ ERROR lower range bound must be less than or equal to upper
//~^ ERROR lower bound for range pattern must be less than or equal to upper bound
}
}

View file

@ -1,4 +1,4 @@
error[E0030]: lower range bound must be less than or equal to upper
error[E0030]: lower bound for range pattern must be less than or equal to upper bound
--> $DIR/E0030-teach.rs:5:9
|
LL | 1000 ..= 5 => {}

View file

@ -1,6 +1,6 @@
fn main() {
match 5u32 {
1000 ..= 5 => {}
//~^ ERROR lower range bound must be less than or equal to upper
//~^ ERROR lower bound for range pattern must be less than or equal to upper bound
}
}

View file

@ -1,4 +1,4 @@
error[E0030]: lower range bound must be less than or equal to upper
error[E0030]: lower bound for range pattern must be less than or equal to upper bound
--> $DIR/E0030.rs:3:9
|
LL | 1000 ..= 5 => {}

View file

@ -0,0 +1,48 @@
#![feature(test)]
// test is a built-in macro, not a built-in attribute, but it kind of acts like both.
// check its target checking anyway here
#[test]
//~^ ERROR the `#[test]` attribute may only be used on a free function
mod test {
mod inner { #![test] }
//~^ ERROR inner macro attributes are unstable
//~| ERROR the `#[test]` attribute may only be used on a free function
#[test]
//~^ ERROR the `#[test]` attribute may only be used on a free function
struct S;
#[test]
//~^ ERROR the `#[test]` attribute may only be used on a free function
type T = S;
#[test]
//~^ ERROR the `#[test]` attribute may only be used on a free function
impl S { }
}
// At time of unit test authorship, if compiling without `--test` then
// non-crate-level #[bench] attributes seem to be ignored.
#[bench]
//~^ ERROR the `#[bench]` attribute may only be used on a free function
mod bench {
mod inner { #![bench] }
//~^ ERROR inner macro attributes are unstable
//~| ERROR the `#[bench]` attribute may only be used on a free function
#[bench]
//~^ ERROR the `#[bench]` attribute may only be used on a free function
struct S;
#[bench]
//~^ ERROR the `#[bench]` attribute may only be used on a free function
type T = S;
#[bench]
//~^ ERROR the `#[bench]` attribute may only be used on a free function
impl S { }
}
fn main() {}

View file

@ -0,0 +1,151 @@
error: the `#[test]` attribute may only be used on a free function
--> $DIR/gating-of-test-attrs.rs:5:1
|
LL | #[test]
| ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions
LL |
LL | / mod test {
LL | | mod inner { #![test] }
... |
LL | | impl S { }
LL | | }
| |_- expected a non-associated function, found a module
|
help: replace with conditional compilation to make the item only exist when tests are being run
|
LL - #[test]
LL + #[cfg(test)]
|
error[E0658]: inner macro attributes are unstable
--> $DIR/gating-of-test-attrs.rs:8:20
|
LL | mod inner { #![test] }
| ^^^^
|
= note: see issue #54726 <https://github.com/rust-lang/rust/issues/54726> for more information
= help: add `#![feature(custom_inner_attributes)]` 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: the `#[test]` attribute may only be used on a free function
--> $DIR/gating-of-test-attrs.rs:8:17
|
LL | mod inner { #![test] }
| ------------^^^^^^^^--
| | |
| | the `#[test]` macro causes a function to be run as a test and has no effect on non-functions
| expected a non-associated function, found a module
|
help: replace with conditional compilation to make the item only exist when tests are being run
|
LL - mod inner { #![test] }
LL + mod inner { #[cfg(test)] }
|
error: the `#[test]` attribute may only be used on a free function
--> $DIR/gating-of-test-attrs.rs:12:5
|
LL | #[test]
| ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions
LL |
LL | struct S;
| --------- expected a non-associated function, found a struct
|
help: replace with conditional compilation to make the item only exist when tests are being run
|
LL - #[test]
LL + #[cfg(test)]
|
error: the `#[test]` attribute may only be used on a free function
--> $DIR/gating-of-test-attrs.rs:16:5
|
LL | #[test]
| ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions
LL |
LL | type T = S;
| ----------- expected a non-associated function, found a type alias
|
help: replace with conditional compilation to make the item only exist when tests are being run
|
LL - #[test]
LL + #[cfg(test)]
|
error: the `#[test]` attribute may only be used on a free function
--> $DIR/gating-of-test-attrs.rs:20:5
|
LL | #[test]
| ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions
LL |
LL | impl S { }
| ---------- expected a non-associated function, found an implementation
|
help: replace with conditional compilation to make the item only exist when tests are being run
|
LL - #[test]
LL + #[cfg(test)]
|
error: the `#[bench]` attribute may only be used on a free function
--> $DIR/gating-of-test-attrs.rs:28:1
|
LL | #[bench]
| ^^^^^^^^ the `#[bench]` macro causes a function to be run as a test and has no effect on non-functions
LL |
LL | / mod bench {
LL | | mod inner { #![bench] }
... |
LL | | impl S { }
LL | | }
| |_- expected a non-associated function, found a module
error[E0658]: inner macro attributes are unstable
--> $DIR/gating-of-test-attrs.rs:31:20
|
LL | mod inner { #![bench] }
| ^^^^^
|
= note: see issue #54726 <https://github.com/rust-lang/rust/issues/54726> for more information
= help: add `#![feature(custom_inner_attributes)]` 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: the `#[bench]` attribute may only be used on a free function
--> $DIR/gating-of-test-attrs.rs:31:17
|
LL | mod inner { #![bench] }
| ------------^^^^^^^^^--
| | |
| | the `#[bench]` macro causes a function to be run as a test and has no effect on non-functions
| expected a non-associated function, found a module
error: the `#[bench]` attribute may only be used on a free function
--> $DIR/gating-of-test-attrs.rs:35:5
|
LL | #[bench]
| ^^^^^^^^ the `#[bench]` macro causes a function to be run as a test and has no effect on non-functions
LL |
LL | struct S;
| --------- expected a non-associated function, found a struct
error: the `#[bench]` attribute may only be used on a free function
--> $DIR/gating-of-test-attrs.rs:39:5
|
LL | #[bench]
| ^^^^^^^^ the `#[bench]` macro causes a function to be run as a test and has no effect on non-functions
LL |
LL | type T = S;
| ----------- expected a non-associated function, found a type alias
error: the `#[bench]` attribute may only be used on a free function
--> $DIR/gating-of-test-attrs.rs:43:5
|
LL | #[bench]
| ^^^^^^^^ the `#[bench]` macro causes a function to be run as a test and has no effect on non-functions
LL |
LL | impl S { }
| ---------- expected a non-associated function, found an implementation
error: aborting due to 12 previous errors
For more information about this error, try `rustc --explain E0658`.

View file

@ -33,7 +33,6 @@
//@ check-pass
#![feature(test)]
#![warn(unused_attributes, unknown_lints)]
//~^ NOTE the lint level is defined here
//~| NOTE the lint level is defined here
@ -250,38 +249,6 @@ mod macro_export {
//~| HELP remove the attribute
}
// At time of unit test authorship, if compiling without `--test` then
// non-crate-level #[test] attributes seem to be ignored.
#[test]
mod test { mod inner { #![test] }
fn f() { }
struct S;
type T = S;
impl S { }
}
// At time of unit test authorship, if compiling without `--test` then
// non-crate-level #[bench] attributes seem to be ignored.
#[bench]
mod bench {
mod inner { #![bench] }
#[bench]
struct S;
#[bench]
type T = S;
#[bench]
impl S { }
}
#[path = "3800"]
mod path {
mod inner { #![path="3800"] }

View file

@ -9,36 +9,36 @@ macro_rules! m {
fn main() {
m!(0, ..u8::MIN);
//~^ ERROR lower range bound must be less than upper
//~^ ERROR exclusive upper bound for a range bound cannot be the minimum
m!(0, ..u16::MIN);
//~^ ERROR lower range bound must be less than upper
//~^ ERROR exclusive upper bound for a range bound cannot be the minimum
m!(0, ..u32::MIN);
//~^ ERROR lower range bound must be less than upper
//~^ ERROR exclusive upper bound for a range bound cannot be the minimum
m!(0, ..u64::MIN);
//~^ ERROR lower range bound must be less than upper
//~^ ERROR exclusive upper bound for a range bound cannot be the minimum
m!(0, ..u128::MIN);
//~^ ERROR lower range bound must be less than upper
//~^ ERROR exclusive upper bound for a range bound cannot be the minimum
m!(0, ..i8::MIN);
//~^ ERROR lower range bound must be less than upper
//~^ ERROR exclusive upper bound for a range bound cannot be the minimum
m!(0, ..i16::MIN);
//~^ ERROR lower range bound must be less than upper
//~^ ERROR exclusive upper bound for a range bound cannot be the minimum
m!(0, ..i32::MIN);
//~^ ERROR lower range bound must be less than upper
//~^ ERROR exclusive upper bound for a range bound cannot be the minimum
m!(0, ..i64::MIN);
//~^ ERROR lower range bound must be less than upper
//~^ ERROR exclusive upper bound for a range bound cannot be the minimum
m!(0, ..i128::MIN);
//~^ ERROR lower range bound must be less than upper
//~^ ERROR exclusive upper bound for a range bound cannot be the minimum
m!(0f16, ..f16::NEG_INFINITY);
//~^ ERROR lower range bound must be less than upper
//~^ ERROR exclusive upper bound for a range bound cannot be the minimum
m!(0f32, ..f32::NEG_INFINITY);
//~^ ERROR lower range bound must be less than upper
//~^ ERROR exclusive upper bound for a range bound cannot be the minimum
m!(0f64, ..f64::NEG_INFINITY);
//~^ ERROR lower range bound must be less than upper
//~^ ERROR exclusive upper bound for a range bound cannot be the minimum
m!(0f128, ..f128::NEG_INFINITY);
//~^ ERROR lower range bound must be less than upper
//~^ ERROR exclusive upper bound for a range bound cannot be the minimum
m!('a', ..'\u{0}');
//~^ ERROR lower range bound must be less than upper
//~^ ERROR exclusive upper bound for a range bound cannot be the minimum
}

View file

@ -1,88 +1,88 @@
error[E0579]: lower range bound must be less than upper
error[E0579]: exclusive upper bound for a range bound cannot be the minimum
--> $DIR/half-open-range-pats-thir-lower-empty.rs:11:11
|
LL | m!(0, ..u8::MIN);
| ^^^^^^^^^
error[E0579]: lower range bound must be less than upper
error[E0579]: exclusive upper bound for a range bound cannot be the minimum
--> $DIR/half-open-range-pats-thir-lower-empty.rs:13:11
|
LL | m!(0, ..u16::MIN);
| ^^^^^^^^^^
error[E0579]: lower range bound must be less than upper
error[E0579]: exclusive upper bound for a range bound cannot be the minimum
--> $DIR/half-open-range-pats-thir-lower-empty.rs:15:11
|
LL | m!(0, ..u32::MIN);
| ^^^^^^^^^^
error[E0579]: lower range bound must be less than upper
error[E0579]: exclusive upper bound for a range bound cannot be the minimum
--> $DIR/half-open-range-pats-thir-lower-empty.rs:17:11
|
LL | m!(0, ..u64::MIN);
| ^^^^^^^^^^
error[E0579]: lower range bound must be less than upper
error[E0579]: exclusive upper bound for a range bound cannot be the minimum
--> $DIR/half-open-range-pats-thir-lower-empty.rs:19:11
|
LL | m!(0, ..u128::MIN);
| ^^^^^^^^^^^
error[E0579]: lower range bound must be less than upper
error[E0579]: exclusive upper bound for a range bound cannot be the minimum
--> $DIR/half-open-range-pats-thir-lower-empty.rs:22:11
|
LL | m!(0, ..i8::MIN);
| ^^^^^^^^^
error[E0579]: lower range bound must be less than upper
error[E0579]: exclusive upper bound for a range bound cannot be the minimum
--> $DIR/half-open-range-pats-thir-lower-empty.rs:24:11
|
LL | m!(0, ..i16::MIN);
| ^^^^^^^^^^
error[E0579]: lower range bound must be less than upper
error[E0579]: exclusive upper bound for a range bound cannot be the minimum
--> $DIR/half-open-range-pats-thir-lower-empty.rs:26:11
|
LL | m!(0, ..i32::MIN);
| ^^^^^^^^^^
error[E0579]: lower range bound must be less than upper
error[E0579]: exclusive upper bound for a range bound cannot be the minimum
--> $DIR/half-open-range-pats-thir-lower-empty.rs:28:11
|
LL | m!(0, ..i64::MIN);
| ^^^^^^^^^^
error[E0579]: lower range bound must be less than upper
error[E0579]: exclusive upper bound for a range bound cannot be the minimum
--> $DIR/half-open-range-pats-thir-lower-empty.rs:30:11
|
LL | m!(0, ..i128::MIN);
| ^^^^^^^^^^^
error[E0579]: lower range bound must be less than upper
error[E0579]: exclusive upper bound for a range bound cannot be the minimum
--> $DIR/half-open-range-pats-thir-lower-empty.rs:33:14
|
LL | m!(0f16, ..f16::NEG_INFINITY);
| ^^^^^^^^^^^^^^^^^^^
error[E0579]: lower range bound must be less than upper
error[E0579]: exclusive upper bound for a range bound cannot be the minimum
--> $DIR/half-open-range-pats-thir-lower-empty.rs:35:14
|
LL | m!(0f32, ..f32::NEG_INFINITY);
| ^^^^^^^^^^^^^^^^^^^
error[E0579]: lower range bound must be less than upper
error[E0579]: exclusive upper bound for a range bound cannot be the minimum
--> $DIR/half-open-range-pats-thir-lower-empty.rs:37:14
|
LL | m!(0f64, ..f64::NEG_INFINITY);
| ^^^^^^^^^^^^^^^^^^^
error[E0579]: lower range bound must be less than upper
error[E0579]: exclusive upper bound for a range bound cannot be the minimum
--> $DIR/half-open-range-pats-thir-lower-empty.rs:39:15
|
LL | m!(0f128, ..f128::NEG_INFINITY);
| ^^^^^^^^^^^^^^^^^^^^
error[E0579]: lower range bound must be less than upper
error[E0579]: exclusive upper bound for a range bound cannot be the minimum
--> $DIR/half-open-range-pats-thir-lower-empty.rs:42:13
|
LL | m!('a', ..'\u{0}');

View file

@ -0,0 +1,7 @@
#[macro_export]
macro_rules! unused_assign {
($x:ident) => {
let mut $x = 1;
$x = 2;
};
}

View file

@ -0,0 +1,10 @@
//@ check-pass
//@ aux-build:aux_issue_147648.rs
#![deny(unused_assignments)]
extern crate aux_issue_147648;
fn main() {
aux_issue_147648::unused_assign!(y);
}

View file

@ -202,7 +202,7 @@ fn invalid_range_pattern(state: f32) {
break 'blk 2.5;
}
4.0..3.0 => {
//~^ ERROR lower range bound must be less than upper
//~^ ERROR lower bound for range pattern must be less than upper bound
todo!()
}
}

View file

@ -121,7 +121,7 @@ LL ~ State::A => State::B,
LL ~ State::B | State::C => todo!(),
|
error[E0579]: lower range bound must be less than upper
error[E0579]: lower bound for range pattern must be less than upper bound
--> $DIR/invalid.rs:204:17
|
LL | 4.0..3.0 => {

View file

@ -1,11 +0,0 @@
// AST-based macro attributes expanding to an empty expression produce an error and not ICE.
#![feature(custom_test_frameworks)]
#![feature(stmt_expr_attributes)]
#![feature(test)]
fn main() {
let _ = #[test] 0; //~ ERROR removing an expression is not supported in this position
let _ = #[bench] 1; //~ ERROR removing an expression is not supported in this position
let _ = #[test_case] 2; //~ ERROR removing an expression is not supported in this position
}

View file

@ -1,20 +0,0 @@
error: removing an expression is not supported in this position
--> $DIR/attr-empty-expr.rs:8:13
|
LL | let _ = #[test] 0;
| ^^^^^^^
error: removing an expression is not supported in this position
--> $DIR/attr-empty-expr.rs:9:13
|
LL | let _ = #[bench] 1;
| ^^^^^^^^
error: removing an expression is not supported in this position
--> $DIR/attr-empty-expr.rs:10:13
|
LL | let _ = #[test_case] 2;
| ^^^^^^^^^^^^
error: aborting due to 3 previous errors

View file

@ -5,8 +5,8 @@ macro_rules! cbor_map {
}
fn main() {
cbor_map! { #[test(test)] 4};
//~^ ERROR removing an expression is not supported in this position
cbor_map! { #[test(test)] 4i32};
//~^ ERROR the `#[test]` attribute may only be used on a free function
//~| ERROR attribute must be of the form `#[test]`
//~| WARNING this was previously accepted by the compiler but is being phased out
}

View file

@ -1,13 +1,19 @@
error: removing an expression is not supported in this position
error: the `#[test]` attribute may only be used on a free function
--> $DIR/issue-111749.rs:8:17
|
LL | cbor_map! { #[test(test)] 4};
| ^^^^^^^^^^^^^
LL | cbor_map! { #[test(test)] 4i32};
| ^^^^^^^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions
|
help: replace with conditional compilation to make the item only exist when tests are being run
|
LL - cbor_map! { #[test(test)] 4i32};
LL + cbor_map! { #[cfg(test)] 4i32};
|
error: attribute must be of the form `#[test]`
--> $DIR/issue-111749.rs:8:17
|
LL | cbor_map! { #[test(test)] 4};
LL | cbor_map! { #[test(test)] 4i32};
| ^^^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
@ -20,7 +26,7 @@ Future incompatibility report: Future breakage diagnostic:
error: attribute must be of the form `#[test]`
--> $DIR/issue-111749.rs:8:17
|
LL | cbor_map! { #[test(test)] 4};
LL | cbor_map! { #[test(test)] 4i32};
| ^^^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!

View file

@ -0,0 +1,10 @@
// Regression test for rust-lang/rust#114920
//
// Applying `#![test]` to the crate root used to ICE,
// when referring to the attribute with full path specifically.
#![core::prelude::v1::test]
//~^ ERROR inner macro attributes are unstable
//~| ERROR the `#[test]` attribute may only be used on a free function
fn main() {}

View file

@ -0,0 +1,25 @@
error[E0658]: inner macro attributes are unstable
--> $DIR/test-on-crate-root.rs:5:4
|
LL | #![core::prelude::v1::test]
| ^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #54726 <https://github.com/rust-lang/rust/issues/54726> for more information
= help: add `#![feature(custom_inner_attributes)]` 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: the `#[test]` attribute may only be used on a free function
--> $DIR/test-on-crate-root.rs:5:1
|
LL | #![core::prelude::v1::test]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions
|
help: replace with conditional compilation to make the item only exist when tests are being run
|
LL - #![core::prelude::v1::test]
LL + #[cfg(test)]
|
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0658`.

View file

@ -1,19 +1,19 @@
fn main() {
match 5 {
6 ..= 1 => { }
//~^ ERROR lower range bound must be less than or equal to upper
//~^ ERROR lower bound for range pattern must be less than or equal to upper bound
_ => { }
};
match 5 {
0 .. 0 => { }
//~^ ERROR lower range bound must be less than upper
//~^ ERROR lower bound for range pattern must be less than upper bound
_ => { }
};
match 5u64 {
0xFFFF_FFFF_FFFF_FFFF ..= 1 => { }
//~^ ERROR lower range bound must be less than or equal to upper
//~^ ERROR lower bound for range pattern must be less than or equal to upper bound
_ => { }
};
}

View file

@ -1,16 +1,16 @@
error[E0030]: lower range bound must be less than or equal to upper
error[E0030]: lower bound for range pattern must be less than or equal to upper bound
--> $DIR/match-range-fail-2.rs:3:9
|
LL | 6 ..= 1 => { }
| ^^^^^^^ lower bound larger than upper bound
error[E0579]: lower range bound must be less than upper
error[E0579]: lower bound for range pattern must be less than upper bound
--> $DIR/match-range-fail-2.rs:9:9
|
LL | 0 .. 0 => { }
| ^^^^^^
error[E0030]: lower range bound must be less than or equal to upper
error[E0030]: lower bound for range pattern must be less than or equal to upper bound
--> $DIR/match-range-fail-2.rs:15:9
|
LL | 0xFFFF_FFFF_FFFF_FFFF ..= 1 => { }

View file

@ -15,7 +15,7 @@ fn main() {
// There isn't really a way to detect these
1..=TOO_BIG => {}
//~^ ERROR lower range bound must be less than or equal to upper
//~^ ERROR lower bound for range pattern must be less than or equal to upper bound
_ => {}
}

View file

@ -10,7 +10,7 @@ error: literal out of range for `u8`
LL | 1..=256 => {}
| ^^^ this value does not fit into the type `u8` whose range is `0..=255`
error[E0030]: lower range bound must be less than or equal to upper
error[E0030]: lower bound for range pattern must be less than or equal to upper bound
--> $DIR/validate-range-endpoints.rs:17:9
|
LL | 1..=TOO_BIG => {}

View file

@ -2,6 +2,6 @@
fn align_offset_weird_strides() {
#[test]
//~^ ERROR the `#[test]` attribute may only be used on a non-associated function
//~^ ERROR the `#[test]` attribute may only be used on a free function
struct A5(u32, u8);
}

View file

@ -1,4 +1,4 @@
error: the `#[test]` attribute may only be used on a non-associated function
error: the `#[test]` attribute may only be used on a free function
--> $DIR/issue-109816.rs:4:5
|
LL | #[test]

View file

@ -4,12 +4,12 @@ struct A {}
impl A {
#[test]
//~^ ERROR the `#[test]` attribute may only be used on a non-associated function
//~^ ERROR the `#[test]` attribute may only be used on a free function
fn new() -> A {
A {}
}
#[test]
//~^ ERROR the `#[test]` attribute may only be used on a non-associated function
//~^ ERROR the `#[test]` attribute may only be used on a free function
fn recovery_witness() -> A {
A {}
}

View file

@ -1,4 +1,4 @@
error: the `#[test]` attribute may only be used on a non-associated function
error: the `#[test]` attribute may only be used on a free function
--> $DIR/test-attr-non-associated-functions.rs:6:5
|
LL | #[test]
@ -10,7 +10,7 @@ LL - #[test]
LL + #[cfg(test)]
|
error: the `#[test]` attribute may only be used on a non-associated function
error: the `#[test]` attribute may only be used on a free function
--> $DIR/test-attr-non-associated-functions.rs:11:5
|
LL | #[test]

View file

@ -1,9 +1,9 @@
//@ compile-flags: --test
#[test] //~ ERROR: the `#[test]` attribute may only be used on a non-associated function
#[test] //~ ERROR: the `#[test]` attribute may only be used on a free function
mod test {}
#[test] //~ ERROR: the `#[test]` attribute may only be used on a non-associated function
#[test] //~ ERROR: the `#[test]` attribute may only be used on a free function
mod loooooooooooooong_teeeeeeeeeest {
/*
this is a comment
@ -17,37 +17,37 @@ mod loooooooooooooong_teeeeeeeeeest {
*/
}
#[test] //~ ERROR: the `#[test]` attribute may only be used on a non-associated function
#[test] //~ ERROR: the `#[test]` attribute may only be used on a free function
extern "C" {}
#[test] //~ ERROR: the `#[test]` attribute may only be used on a non-associated function
#[test] //~ ERROR: the `#[test]` attribute may only be used on a free function
trait Foo {}
#[test] //~ ERROR: the `#[test]` attribute may only be used on a non-associated function
#[test] //~ ERROR: the `#[test]` attribute may only be used on a free function
impl Foo for i32 {}
#[test] //~ ERROR: the `#[test]` attribute may only be used on a non-associated function
#[test] //~ ERROR: the `#[test]` attribute may only be used on a free function
const FOO: i32 = -1_i32;
#[test] //~ ERROR: the `#[test]` attribute may only be used on a non-associated function
#[test] //~ ERROR: the `#[test]` attribute may only be used on a free function
static BAR: u64 = 10_000_u64;
#[test] //~ ERROR: the `#[test]` attribute may only be used on a non-associated function
#[test] //~ ERROR: the `#[test]` attribute may only be used on a free function
enum MyUnit {
Unit,
}
#[test] //~ ERROR: the `#[test]` attribute may only be used on a non-associated function
#[test] //~ ERROR: the `#[test]` attribute may only be used on a free function
struct NewI32(i32);
#[test] //~ ERROR: the `#[test]` attribute may only be used on a non-associated function
#[test] //~ ERROR: the `#[test]` attribute may only be used on a free function
union Spooky {
x: i32,
y: u32,
}
#[repr(C, align(64))]
#[test] //~ ERROR: the `#[test]` attribute may only be used on a non-associated function
#[test] //~ ERROR: the `#[test]` attribute may only be used on a free function
#[derive(Copy, Clone, Debug)]
struct MoreAttrs {
a: i32,
@ -58,7 +58,7 @@ macro_rules! foo {
() => {};
}
#[test] //~ WARN: the `#[test]` attribute may only be used on a non-associated function
#[test] //~ WARN: the `#[test]` attribute may only be used on a free function
foo!();
// make sure it doesn't erroneously trigger on a real test

View file

@ -1,4 +1,4 @@
error: the `#[test]` attribute may only be used on a non-associated function
error: the `#[test]` attribute may only be used on a free function
--> $DIR/test-on-not-fn.rs:3:1
|
LL | #[test]
@ -12,7 +12,7 @@ LL - #[test]
LL + #[cfg(test)]
|
error: the `#[test]` attribute may only be used on a non-associated function
error: the `#[test]` attribute may only be used on a free function
--> $DIR/test-on-not-fn.rs:6:1
|
LL | #[test]
@ -32,7 +32,7 @@ LL - #[test]
LL + #[cfg(test)]
|
error: the `#[test]` attribute may only be used on a non-associated function
error: the `#[test]` attribute may only be used on a free function
--> $DIR/test-on-not-fn.rs:20:1
|
LL | #[test]
@ -46,7 +46,7 @@ LL - #[test]
LL + #[cfg(test)]
|
error: the `#[test]` attribute may only be used on a non-associated function
error: the `#[test]` attribute may only be used on a free function
--> $DIR/test-on-not-fn.rs:23:1
|
LL | #[test]
@ -60,7 +60,7 @@ LL - #[test]
LL + #[cfg(test)]
|
error: the `#[test]` attribute may only be used on a non-associated function
error: the `#[test]` attribute may only be used on a free function
--> $DIR/test-on-not-fn.rs:26:1
|
LL | #[test]
@ -74,7 +74,7 @@ LL - #[test]
LL + #[cfg(test)]
|
error: the `#[test]` attribute may only be used on a non-associated function
error: the `#[test]` attribute may only be used on a free function
--> $DIR/test-on-not-fn.rs:29:1
|
LL | #[test]
@ -88,7 +88,7 @@ LL - #[test]
LL + #[cfg(test)]
|
error: the `#[test]` attribute may only be used on a non-associated function
error: the `#[test]` attribute may only be used on a free function
--> $DIR/test-on-not-fn.rs:32:1
|
LL | #[test]
@ -102,7 +102,7 @@ LL - #[test]
LL + #[cfg(test)]
|
error: the `#[test]` attribute may only be used on a non-associated function
error: the `#[test]` attribute may only be used on a free function
--> $DIR/test-on-not-fn.rs:35:1
|
LL | #[test]
@ -118,7 +118,7 @@ LL - #[test]
LL + #[cfg(test)]
|
error: the `#[test]` attribute may only be used on a non-associated function
error: the `#[test]` attribute may only be used on a free function
--> $DIR/test-on-not-fn.rs:40:1
|
LL | #[test]
@ -132,7 +132,7 @@ LL - #[test]
LL + #[cfg(test)]
|
error: the `#[test]` attribute may only be used on a non-associated function
error: the `#[test]` attribute may only be used on a free function
--> $DIR/test-on-not-fn.rs:43:1
|
LL | #[test]
@ -149,7 +149,7 @@ LL - #[test]
LL + #[cfg(test)]
|
error: the `#[test]` attribute may only be used on a non-associated function
error: the `#[test]` attribute may only be used on a free function
--> $DIR/test-on-not-fn.rs:50:1
|
LL | #[test]
@ -167,7 +167,7 @@ LL - #[test]
LL + #[cfg(test)]
|
warning: the `#[test]` attribute may only be used on a non-associated function
warning: the `#[test]` attribute may only be used on a free function
--> $DIR/test-on-not-fn.rs:61:1
|
LL | #[test]

View file

@ -0,0 +1,25 @@
//@ compile-flags: -Copt-level=3 --crate-type=rlib
//@ build-pass
// A regression test for #149081. The environment of `size` and `align`
// currently means that the item bound of`T::Assoc` doesn't hold. This can
// result in normalization failures and ICE during MIR optimizations.
//
// This will no longer be an issue once #149283 is implemented.
pub fn align<T: WithAssoc<Assoc = U>, U>() -> usize {
std::mem::align_of::<Wrapper<T>>()
}
pub fn size<T: WithAssoc<Assoc = U>, U>() -> usize {
std::mem::size_of::<Wrapper<T>>()
}
pub struct Wrapper<T: WithAssoc> {
assoc2: <T::Assoc as WithAssoc>::Assoc,
value: T,
}
pub trait WithAssoc {
type Assoc: WithAssoc;
}