Auto merge of #127096 - matthiaskrgr:rollup-kh7e0rh, r=matthiaskrgr

Rollup of 11 pull requests

Successful merges:

 - #123714 (Add test for fn pointer duplication.)
 - #124091 (Update AST validation module docs)
 - #127015 (Switch back `non_local_definitions` lint to allow-by-default)
 - #127016 (docs: check if the disambiguator matches its suffix)
 - #127029 (Fix Markdown tables in platform-support.md)
 - #127032 (Enable const casting for `f16` and `f128`)
 - #127055 (Mark Hasher::finish as #[must_use])
 - #127068 (Stall computing instance for drop shim until it has no unsubstituted const params)
 - #127070 (add () to the marker_impls macro for ConstParamTy)
 - #127071 (Remove (deprecated & unstable) {to,from}_bits pointer methods)
 - #127078 (Enable full tools and profiler for LoongArch Linux targets)

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2024-06-29 05:00:11 +00:00
commit d38cd229b7
45 changed files with 857 additions and 289 deletions

View file

@ -1,10 +1,20 @@
// Validate AST before lowering it to HIR.
//
// This pass is supposed to catch things that fit into AST data structures,
// but not permitted by the language. It runs after expansion when AST is frozen,
// so it can check for erroneous constructions produced by syntax extensions.
// This pass is supposed to perform only simple checks not requiring name resolution
// or type checking or some other kind of complex analysis.
//! Validate AST before lowering it to HIR.
//!
//! This pass intends to check that the constructed AST is *syntactically valid* to allow the rest
//! of the compiler to assume that the AST is valid. These checks cannot be performed during parsing
//! because attribute macros are allowed to accept certain pieces of invalid syntax such as a
//! function without body outside of a trait definition:
//!
//! ```ignore (illustrative)
//! #[my_attribute]
//! mod foo {
//! fn missing_body();
//! }
//! ```
//!
//! These checks are run post-expansion, after AST is frozen, to be able to check for erroneous
//! constructions produced by proc macros. This pass is only intended for simple checks that do not
//! require name resolution or type checking, or other kinds of complex analysis.
use itertools::{Either, Itertools};
use rustc_ast::ptr::P;

View file

@ -1,6 +1,6 @@
use std::assert_matches::assert_matches;
use rustc_apfloat::ieee::{Double, Single};
use rustc_apfloat::ieee::{Double, Half, Quad, Single};
use rustc_apfloat::{Float, FloatConvert};
use rustc_middle::mir::interpret::{InterpResult, PointerArithmetic, Scalar};
use rustc_middle::mir::CastKind;
@ -187,10 +187,10 @@ pub fn float_to_float_or_int(
bug!("FloatToFloat/FloatToInt cast: source type {} is not a float type", src.layout.ty)
};
let val = match fty {
FloatTy::F16 => unimplemented!("f16_f128"),
FloatTy::F16 => self.cast_from_float(src.to_scalar().to_f16()?, cast_to.ty),
FloatTy::F32 => self.cast_from_float(src.to_scalar().to_f32()?, cast_to.ty),
FloatTy::F64 => self.cast_from_float(src.to_scalar().to_f64()?, cast_to.ty),
FloatTy::F128 => unimplemented!("f16_f128"),
FloatTy::F128 => self.cast_from_float(src.to_scalar().to_f128()?, cast_to.ty),
};
Ok(ImmTy::from_scalar(val, cast_to))
}
@ -296,18 +296,18 @@ fn cast_from_int_like(
Float(fty) if signed => {
let v = v as i128;
match fty {
FloatTy::F16 => unimplemented!("f16_f128"),
FloatTy::F16 => Scalar::from_f16(Half::from_i128(v).value),
FloatTy::F32 => Scalar::from_f32(Single::from_i128(v).value),
FloatTy::F64 => Scalar::from_f64(Double::from_i128(v).value),
FloatTy::F128 => unimplemented!("f16_f128"),
FloatTy::F128 => Scalar::from_f128(Quad::from_i128(v).value),
}
}
// unsigned int -> float
Float(fty) => match fty {
FloatTy::F16 => unimplemented!("f16_f128"),
FloatTy::F16 => Scalar::from_f16(Half::from_u128(v).value),
FloatTy::F32 => Scalar::from_f32(Single::from_u128(v).value),
FloatTy::F64 => Scalar::from_f64(Double::from_u128(v).value),
FloatTy::F128 => unimplemented!("f16_f128"),
FloatTy::F128 => Scalar::from_f128(Quad::from_u128(v).value),
},
// u8 -> char
@ -321,7 +321,12 @@ fn cast_from_int_like(
/// Low-level cast helper function. Converts an apfloat `f` into int or float types.
fn cast_from_float<F>(&self, f: F, dest_ty: Ty<'tcx>) -> Scalar<M::Provenance>
where
F: Float + Into<Scalar<M::Provenance>> + FloatConvert<Single> + FloatConvert<Double>,
F: Float
+ Into<Scalar<M::Provenance>>
+ FloatConvert<Half>
+ FloatConvert<Single>
+ FloatConvert<Double>
+ FloatConvert<Quad>,
{
use rustc_type_ir::TyKind::*;
@ -358,10 +363,12 @@ fn adjust_nan<
}
// float -> float
Float(fty) => match fty {
FloatTy::F16 => unimplemented!("f16_f128"),
FloatTy::F16 => Scalar::from_f16(adjust_nan(self, f, f.convert(&mut false).value)),
FloatTy::F32 => Scalar::from_f32(adjust_nan(self, f, f.convert(&mut false).value)),
FloatTy::F64 => Scalar::from_f64(adjust_nan(self, f, f.convert(&mut false).value)),
FloatTy::F128 => unimplemented!("f16_f128"),
FloatTy::F128 => {
Scalar::from_f128(adjust_nan(self, f, f.convert(&mut false).value))
}
},
// That's it.
_ => span_bug!(self.cur_span(), "invalid float to {} cast", dest_ty),

View file

@ -50,7 +50,7 @@
/// All nested bodies (functions, enum discriminant, array length, consts) (expect for
/// `const _: Ty = { ... }` in top-level module, which is still undecided) are checked.
pub NON_LOCAL_DEFINITIONS,
Warn,
Allow,
"checks for non-local definitions",
report_in_external_macro
}

View file

@ -11,7 +11,7 @@
use rustc_middle::mir::visit::*;
use rustc_middle::mir::*;
use rustc_middle::ty::TypeVisitableExt;
use rustc_middle::ty::{self, Instance, InstanceKind, ParamEnv, Ty, TyCtxt};
use rustc_middle::ty::{self, Instance, InstanceKind, ParamEnv, Ty, TyCtxt, TypeFlags};
use rustc_session::config::{DebugInfo, OptLevel};
use rustc_span::source_map::Spanned;
use rustc_span::sym;
@ -306,6 +306,16 @@ fn check_mir_is_available(
InstanceKind::Intrinsic(_) | InstanceKind::Virtual(..) => {
return Err("instance without MIR (intrinsic / virtual)");
}
// FIXME(#127030): `ConstParamHasTy` has bad interactions with
// the drop shim builder, which does not evaluate predicates in
// the correct param-env for types being dropped. Stall resolving
// the MIR for this instance until all of its const params are
// substituted.
InstanceKind::DropGlue(_, Some(ty)) if ty.has_type_flags(TypeFlags::HAS_CT_PARAM) => {
return Err("still needs substitution");
}
// This cannot result in an immediate cycle since the callee MIR is a shim, which does
// not get any optimizations run on it. Any subsequent inlining may cause cycles, but we
// do not need to catch this here, we can wait until the inliner decides to continue

View file

@ -334,6 +334,7 @@ pub trait Hasher {
///
/// [`write`]: Hasher::write
#[stable(feature = "rust1", since = "1.0.0")]
#[must_use]
fn finish(&self) -> u64;
/// Writes some data into this `Hasher`.

View file

@ -996,15 +996,12 @@ pub trait ConstParamTy: StructuralPartialEq + Eq {}
bool,
char,
str /* Technically requires `[u8]: ConstParamTy` */,
(),
{T: ConstParamTy, const N: usize} [T; N],
{T: ConstParamTy} [T],
{T: ?Sized + ConstParamTy} &T,
}
// FIXME(adt_const_params): Add to marker_impls call above once not in bootstrap
#[unstable(feature = "adt_const_params", issue = "95174")]
impl ConstParamTy for () {}
/// A common trait implemented by all function pointers.
#[unstable(
feature = "fn_ptr_trait",

View file

@ -112,71 +112,6 @@ pub const fn cast_mut(self) -> *mut T {
self as _
}
/// Casts a pointer to its raw bits.
///
/// This is equivalent to `as usize`, but is more specific to enhance readability.
/// The inverse method is [`from_bits`](#method.from_bits).
///
/// In particular, `*p as usize` and `p as usize` will both compile for
/// pointers to numeric types but do very different things, so using this
/// helps emphasize that reading the bits was intentional.
///
/// # Examples
///
/// ```
/// #![feature(ptr_to_from_bits)]
/// # #[cfg(not(miri))] { // doctest does not work with strict provenance
/// let array = [13, 42];
/// let p0: *const i32 = &array[0];
/// assert_eq!(<*const _>::from_bits(p0.to_bits()), p0);
/// let p1: *const i32 = &array[1];
/// assert_eq!(p1.to_bits() - p0.to_bits(), 4);
/// # }
/// ```
#[unstable(feature = "ptr_to_from_bits", issue = "91126")]
#[deprecated(
since = "1.67.0",
note = "replaced by the `expose_provenance` method, or update your code \
to follow the strict provenance rules using its APIs"
)]
#[inline(always)]
pub fn to_bits(self) -> usize
where
T: Sized,
{
self as usize
}
/// Creates a pointer from its raw bits.
///
/// This is equivalent to `as *const T`, but is more specific to enhance readability.
/// The inverse method is [`to_bits`](#method.to_bits).
///
/// # Examples
///
/// ```
/// #![feature(ptr_to_from_bits)]
/// # #[cfg(not(miri))] { // doctest does not work with strict provenance
/// use std::ptr::NonNull;
/// let dangling: *const u8 = NonNull::dangling().as_ptr();
/// assert_eq!(<*const u8>::from_bits(1), dangling);
/// # }
/// ```
#[unstable(feature = "ptr_to_from_bits", issue = "91126")]
#[deprecated(
since = "1.67.0",
note = "replaced by the `ptr::with_exposed_provenance` function, or update \
your code to follow the strict provenance rules using its APIs"
)]
#[allow(fuzzy_provenance_casts)] // this is an unstable and semi-deprecated cast function
#[inline(always)]
pub fn from_bits(bits: usize) -> Self
where
T: Sized,
{
bits as Self
}
/// Gets the "address" portion of the pointer.
///
/// This is similar to `self as usize`, which semantically discards *provenance* and

View file

@ -117,72 +117,6 @@ pub const fn cast_const(self) -> *const T {
self as _
}
/// Casts a pointer to its raw bits.
///
/// This is equivalent to `as usize`, but is more specific to enhance readability.
/// The inverse method is [`from_bits`](pointer#method.from_bits-1).
///
/// In particular, `*p as usize` and `p as usize` will both compile for
/// pointers to numeric types but do very different things, so using this
/// helps emphasize that reading the bits was intentional.
///
/// # Examples
///
/// ```
/// #![feature(ptr_to_from_bits)]
/// # #[cfg(not(miri))] { // doctest does not work with strict provenance
/// let mut array = [13, 42];
/// let mut it = array.iter_mut();
/// let p0: *mut i32 = it.next().unwrap();
/// assert_eq!(<*mut _>::from_bits(p0.to_bits()), p0);
/// let p1: *mut i32 = it.next().unwrap();
/// assert_eq!(p1.to_bits() - p0.to_bits(), 4);
/// }
/// ```
#[unstable(feature = "ptr_to_from_bits", issue = "91126")]
#[deprecated(
since = "1.67.0",
note = "replaced by the `expose_provenance` method, or update your code \
to follow the strict provenance rules using its APIs"
)]
#[inline(always)]
pub fn to_bits(self) -> usize
where
T: Sized,
{
self as usize
}
/// Creates a pointer from its raw bits.
///
/// This is equivalent to `as *mut T`, but is more specific to enhance readability.
/// The inverse method is [`to_bits`](pointer#method.to_bits-1).
///
/// # Examples
///
/// ```
/// #![feature(ptr_to_from_bits)]
/// # #[cfg(not(miri))] { // doctest does not work with strict provenance
/// use std::ptr::NonNull;
/// let dangling: *mut u8 = NonNull::dangling().as_ptr();
/// assert_eq!(<*mut u8>::from_bits(1), dangling);
/// }
/// ```
#[unstable(feature = "ptr_to_from_bits", issue = "91126")]
#[deprecated(
since = "1.67.0",
note = "replaced by the `ptr::with_exposed_provenance_mut` function, or \
update your code to follow the strict provenance rules using its APIs"
)]
#[allow(fuzzy_provenance_casts)] // this is an unstable and semi-deprecated cast function
#[inline(always)]
pub fn from_bits(bits: usize) -> Self
where
T: Sized,
{
bits as Self
}
/// Gets the "address" portion of the pointer.
///
/// This is similar to `self as usize`, which semantically discards *provenance* and

View file

@ -25,5 +25,10 @@ ENV CC_loongarch64_unknown_linux_gnu=loongarch64-unknown-linux-gnu-gcc \
ENV HOSTS=loongarch64-unknown-linux-gnu
ENV RUST_CONFIGURE_ARGS --enable-extended --disable-docs
ENV RUST_CONFIGURE_ARGS \
--enable-extended \
--enable-full-tools \
--enable-profiler \
--disable-docs
ENV SCRIPT python3 ../x.py dist --host $HOSTS --target $HOSTS

View file

@ -27,7 +27,8 @@ ENV HOSTS=loongarch64-unknown-linux-musl
ENV RUST_CONFIGURE_ARGS \
--enable-extended \
--enable-lld \
--enable-full-tools \
--enable-profiler \
--disable-docs \
--set target.loongarch64-unknown-linux-musl.crt-static=false \
--musl-root-loongarch64=/x-tools/loongarch64-unknown-linux-musl/loongarch64-unknown-linux-musl/sysroot/usr

View file

@ -168,12 +168,12 @@ target | std | notes
`i686-unknown-freebsd` | ✓ | 32-bit FreeBSD [^x86_32-floats-return-ABI]
`i686-unknown-linux-musl` | ✓ | 32-bit Linux with musl 1.2.3 [^x86_32-floats-return-ABI]
[`i686-unknown-uefi`](platform-support/unknown-uefi.md) | ? | 32-bit UEFI
[`loongarch64-unknown-none`](platform-support/loongarch-none.md) | * | | LoongArch64 Bare-metal (LP64D ABI)
[`loongarch64-unknown-none-softfloat`](platform-support/loongarch-none.md) | * | | LoongArch64 Bare-metal (LP64S ABI)
[`loongarch64-unknown-none`](platform-support/loongarch-none.md) | * | LoongArch64 Bare-metal (LP64D ABI)
[`loongarch64-unknown-none-softfloat`](platform-support/loongarch-none.md) | * | LoongArch64 Bare-metal (LP64S ABI)
[`nvptx64-nvidia-cuda`](platform-support/nvptx64-nvidia-cuda.md) | * | --emit=asm generates PTX code that [runs on NVIDIA GPUs]
[`riscv32imac-unknown-none-elf`](platform-support/riscv32-unknown-none-elf.md) | * | Bare RISC-V (RV32IMAC ISA)
[`riscv32i-unknown-none-elf`](platform-support/riscv32-unknown-none-elf.md) | * | Bare RISC-V (RV32I ISA)
[`riscv32im-unknown-none-elf`](platform-support/riscv32-unknown-none-elf.md) | * | | Bare RISC-V (RV32IM ISA)
[`riscv32im-unknown-none-elf`](platform-support/riscv32-unknown-none-elf.md) | * | Bare RISC-V (RV32IM ISA)
[`riscv32imc-unknown-none-elf`](platform-support/riscv32-unknown-none-elf.md) | * | Bare RISC-V (RV32IMC ISA)
[`riscv32imafc-unknown-none-elf`](platform-support/riscv32-unknown-none-elf.md) | * | Bare RISC-V (RV32IMAFC ISA)
`riscv64gc-unknown-none-elf` | * | Bare RISC-V (RV64IMAFDC ISA)
@ -193,7 +193,7 @@ target | std | notes
`wasm32-unknown-unknown` | ✓ | WebAssembly
`wasm32-wasi` | ✓ | WebAssembly with WASI (undergoing a [rename to `wasm32-wasip1`][wasi-rename])
[`wasm32-wasip1`](platform-support/wasm32-wasip1.md) | ✓ | WebAssembly with WASI
[`wasm32-wasip1-threads`](platform-support/wasm32-wasip1-threads.md) | ✓ | | WebAssembly with WASI Preview 1 and threads
[`wasm32-wasip1-threads`](platform-support/wasm32-wasip1-threads.md) | ✓ | WebAssembly with WASI Preview 1 and threads
[`x86_64-apple-ios`](platform-support/apple-ios.md) | ✓ | 64-bit x86 iOS
[`x86_64-fortanix-unknown-sgx`](platform-support/x86_64-fortanix-unknown-sgx.md) | ✓ | [Fortanix ABI] for 64-bit Intel SGX
`x86_64-fuchsia` | ✓ | Alias for `x86_64-unknown-fuchsia`

View file

@ -1507,6 +1507,15 @@ impl Disambiguator {
fn from_str(link: &str) -> Result<Option<(Self, &str, &str)>, (String, Range<usize>)> {
use Disambiguator::{Kind, Namespace as NS, Primitive};
let suffixes = [
// If you update this list, please also update the relevant rustdoc book section!
("!()", DefKind::Macro(MacroKind::Bang)),
("!{}", DefKind::Macro(MacroKind::Bang)),
("![]", DefKind::Macro(MacroKind::Bang)),
("()", DefKind::Fn),
("!", DefKind::Macro(MacroKind::Bang)),
];
if let Some(idx) = link.find('@') {
let (prefix, rest) = link.split_at(idx);
let d = match prefix {
@ -1530,16 +1539,23 @@ fn from_str(link: &str) -> Result<Option<(Self, &str, &str)>, (String, Range<usi
"prim" | "primitive" => Primitive,
_ => return Err((format!("unknown disambiguator `{prefix}`"), 0..idx)),
};
for (suffix, kind) in suffixes {
if let Some(path_str) = rest.strip_suffix(suffix) {
if d.ns() != Kind(kind).ns() {
return Err((
format!("unmatched disambiguator `{prefix}` and suffix `{suffix}`"),
0..idx,
));
} else if path_str.len() > 1 {
// path_str != "@"
return Ok(Some((d, &path_str[1..], &rest[1..])));
}
}
}
Ok(Some((d, &rest[1..], &rest[1..])))
} else {
let suffixes = [
// If you update this list, please also update the relevant rustdoc book section!
("!()", DefKind::Macro(MacroKind::Bang)),
("!{}", DefKind::Macro(MacroKind::Bang)),
("![]", DefKind::Macro(MacroKind::Bang)),
("()", DefKind::Fn),
("!", DefKind::Macro(MacroKind::Bang)),
];
for (suffix, kind) in suffixes {
if let Some(path_str) = link.strip_suffix(suffix) {
// Avoid turning `!` or `()` into an empty string

View file

@ -0,0 +1,111 @@
//@ check-pass
//@ normalize-stderr-test: "nightly|beta|1\.[0-9][0-9]\.[0-9]" -> "$$CHANNEL"
//! [struct@m!()] //~ WARN: unmatched disambiguator `struct` and suffix `!()`
//! [struct@m!{}]
//! [struct@m![]]
//! [struct@f()] //~ WARN: unmatched disambiguator `struct` and suffix `()`
//! [struct@m!] //~ WARN: unmatched disambiguator `struct` and suffix `!`
//!
//! [enum@m!()] //~ WARN: unmatched disambiguator `enum` and suffix `!()`
//! [enum@m!{}]
//! [enum@m![]]
//! [enum@f()] //~ WARN: unmatched disambiguator `enum` and suffix `()`
//! [enum@m!] //~ WARN: unmatched disambiguator `enum` and suffix `!`
//!
//! [trait@m!()] //~ WARN: unmatched disambiguator `trait` and suffix `!()`
//! [trait@m!{}]
//! [trait@m![]]
//! [trait@f()] //~ WARN: unmatched disambiguator `trait` and suffix `()`
//! [trait@m!] //~ WARN: unmatched disambiguator `trait` and suffix `!`
//!
//! [module@m!()] //~ WARN: unmatched disambiguator `module` and suffix `!()`
//! [module@m!{}]
//! [module@m![]]
//! [module@f()] //~ WARN: unmatched disambiguator `module` and suffix `()`
//! [module@m!] //~ WARN: unmatched disambiguator `module` and suffix `!`
//!
//! [mod@m!()] //~ WARN: unmatched disambiguator `mod` and suffix `!()`
//! [mod@m!{}]
//! [mod@m![]]
//! [mod@f()] //~ WARN: unmatched disambiguator `mod` and suffix `()`
//! [mod@m!] //~ WARN: unmatched disambiguator `mod` and suffix `!`
//!
//! [const@m!()] //~ WARN: unmatched disambiguator `const` and suffix `!()`
//! [const@m!{}]
//! [const@m![]]
//! [const@f()] //~ WARN: incompatible link kind for `f`
//! [const@m!] //~ WARN: unmatched disambiguator `const` and suffix `!`
//!
//! [constant@m!()] //~ WARN: unmatched disambiguator `constant` and suffix `!()`
//! [constant@m!{}]
//! [constant@m![]]
//! [constant@f()] //~ WARN: incompatible link kind for `f`
//! [constant@m!] //~ WARN: unmatched disambiguator `constant` and suffix `!`
//!
//! [static@m!()] //~ WARN: unmatched disambiguator `static` and suffix `!()`
//! [static@m!{}]
//! [static@m![]]
//! [static@f()] //~ WARN: incompatible link kind for `f`
//! [static@m!] //~ WARN: unmatched disambiguator `static` and suffix `!`
//!
//! [function@m!()] //~ WARN: unmatched disambiguator `function` and suffix `!()`
//! [function@m!{}]
//! [function@m![]]
//! [function@f()]
//! [function@m!] //~ WARN: unmatched disambiguator `function` and suffix `!`
//!
//! [fn@m!()] //~ WARN: unmatched disambiguator `fn` and suffix `!()`
//! [fn@m!{}]
//! [fn@m![]]
//! [fn@f()]
//! [fn@m!] //~ WARN: unmatched disambiguator `fn` and suffix `!`
//!
//! [method@m!()] //~ WARN: unmatched disambiguator `method` and suffix `!()`
//! [method@m!{}]
//! [method@m![]]
//! [method@f()]
//! [method@m!] //~ WARN: unmatched disambiguator `method` and suffix `!`
//!
//! [derive@m!()] //~ WARN: incompatible link kind for `m`
//! [derive@m!{}] //~ WARN: incompatible link kind for `m`
//! [derive@m![]]
//! [derive@f()] //~ WARN: unmatched disambiguator `derive` and suffix `()`
//! [derive@m!] //~ WARN: incompatible link kind for `m`
//!
//! [type@m!()] //~ WARN: unmatched disambiguator `type` and suffix `!()`
//! [type@m!{}]
//! [type@m![]]
//! [type@f()] //~ WARN: unmatched disambiguator `type` and suffix `()`
//! [type@m!] //~ WARN: unmatched disambiguator `type` and suffix `!`
//!
//! [value@m!()] //~ WARN: unmatched disambiguator `value` and suffix `!()`
//! [value@m!{}]
//! [value@m![]]
//! [value@f()]
//! [value@m!] //~ WARN: unmatched disambiguator `value` and suffix `!`
//!
//! [macro@m!()]
//! [macro@m!{}]
//! [macro@m![]]
//! [macro@f()] //~ WARN: unmatched disambiguator `macro` and suffix `()`
//! [macro@m!]
//!
//! [prim@m!()] //~ WARN: unmatched disambiguator `prim` and suffix `!()`
//! [prim@m!{}]
//! [prim@m![]]
//! [prim@f()] //~ WARN: unmatched disambiguator `prim` and suffix `()`
//! [prim@m!] //~ WARN: unmatched disambiguator `prim` and suffix `!`
//!
//! [primitive@m!()] //~ WARN: unmatched disambiguator `primitive` and suffix `!()`
//! [primitive@m!{}]
//! [primitive@m![]]
//! [primitive@f()] //~ WARN: unmatched disambiguator `primitive` and suffix `()`
//! [primitive@m!] //~ WARN: unmatched disambiguator `primitive` and suffix `!`
#[macro_export]
macro_rules! m {
() => {};
}
pub fn f() {}

View file

@ -0,0 +1,395 @@
warning: unmatched disambiguator `struct` and suffix `!()`
--> $DIR/disambiguator-endswith-named-suffix.rs:4:6
|
LL | //! [struct@m!()]
| ^^^^^^
|
= note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators
= note: `#[warn(rustdoc::broken_intra_doc_links)]` on by default
warning: unmatched disambiguator `struct` and suffix `()`
--> $DIR/disambiguator-endswith-named-suffix.rs:7:6
|
LL | //! [struct@f()]
| ^^^^^^
|
= note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators
warning: unmatched disambiguator `struct` and suffix `!`
--> $DIR/disambiguator-endswith-named-suffix.rs:8:6
|
LL | //! [struct@m!]
| ^^^^^^
|
= note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators
warning: unmatched disambiguator `enum` and suffix `!()`
--> $DIR/disambiguator-endswith-named-suffix.rs:10:6
|
LL | //! [enum@m!()]
| ^^^^
|
= note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators
warning: unmatched disambiguator `enum` and suffix `()`
--> $DIR/disambiguator-endswith-named-suffix.rs:13:6
|
LL | //! [enum@f()]
| ^^^^
|
= note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators
warning: unmatched disambiguator `enum` and suffix `!`
--> $DIR/disambiguator-endswith-named-suffix.rs:14:6
|
LL | //! [enum@m!]
| ^^^^
|
= note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators
warning: unmatched disambiguator `trait` and suffix `!()`
--> $DIR/disambiguator-endswith-named-suffix.rs:16:6
|
LL | //! [trait@m!()]
| ^^^^^
|
= note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators
warning: unmatched disambiguator `trait` and suffix `()`
--> $DIR/disambiguator-endswith-named-suffix.rs:19:6
|
LL | //! [trait@f()]
| ^^^^^
|
= note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators
warning: unmatched disambiguator `trait` and suffix `!`
--> $DIR/disambiguator-endswith-named-suffix.rs:20:6
|
LL | //! [trait@m!]
| ^^^^^
|
= note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators
warning: unmatched disambiguator `module` and suffix `!()`
--> $DIR/disambiguator-endswith-named-suffix.rs:22:6
|
LL | //! [module@m!()]
| ^^^^^^
|
= note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators
warning: unmatched disambiguator `module` and suffix `()`
--> $DIR/disambiguator-endswith-named-suffix.rs:25:6
|
LL | //! [module@f()]
| ^^^^^^
|
= note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators
warning: unmatched disambiguator `module` and suffix `!`
--> $DIR/disambiguator-endswith-named-suffix.rs:26:6
|
LL | //! [module@m!]
| ^^^^^^
|
= note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators
warning: unmatched disambiguator `mod` and suffix `!()`
--> $DIR/disambiguator-endswith-named-suffix.rs:28:6
|
LL | //! [mod@m!()]
| ^^^
|
= note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators
warning: unmatched disambiguator `mod` and suffix `()`
--> $DIR/disambiguator-endswith-named-suffix.rs:31:6
|
LL | //! [mod@f()]
| ^^^
|
= note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators
warning: unmatched disambiguator `mod` and suffix `!`
--> $DIR/disambiguator-endswith-named-suffix.rs:32:6
|
LL | //! [mod@m!]
| ^^^
|
= note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators
warning: unmatched disambiguator `const` and suffix `!()`
--> $DIR/disambiguator-endswith-named-suffix.rs:34:6
|
LL | //! [const@m!()]
| ^^^^^
|
= note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators
warning: incompatible link kind for `f`
--> $DIR/disambiguator-endswith-named-suffix.rs:37:6
|
LL | //! [const@f()]
| ^^^^^^^^^ this link resolved to a function, which is not a constant
|
help: to link to the function, add parentheses
|
LL - //! [const@f()]
LL + //! [f()]
|
warning: unmatched disambiguator `const` and suffix `!`
--> $DIR/disambiguator-endswith-named-suffix.rs:38:6
|
LL | //! [const@m!]
| ^^^^^
|
= note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators
warning: unmatched disambiguator `constant` and suffix `!()`
--> $DIR/disambiguator-endswith-named-suffix.rs:40:6
|
LL | //! [constant@m!()]
| ^^^^^^^^
|
= note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators
warning: incompatible link kind for `f`
--> $DIR/disambiguator-endswith-named-suffix.rs:43:6
|
LL | //! [constant@f()]
| ^^^^^^^^^^^^ this link resolved to a function, which is not a constant
|
help: to link to the function, add parentheses
|
LL - //! [constant@f()]
LL + //! [f()]
|
warning: unmatched disambiguator `constant` and suffix `!`
--> $DIR/disambiguator-endswith-named-suffix.rs:44:6
|
LL | //! [constant@m!]
| ^^^^^^^^
|
= note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators
warning: unmatched disambiguator `static` and suffix `!()`
--> $DIR/disambiguator-endswith-named-suffix.rs:46:6
|
LL | //! [static@m!()]
| ^^^^^^
|
= note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators
warning: incompatible link kind for `f`
--> $DIR/disambiguator-endswith-named-suffix.rs:49:6
|
LL | //! [static@f()]
| ^^^^^^^^^^ this link resolved to a function, which is not a static
|
help: to link to the function, add parentheses
|
LL - //! [static@f()]
LL + //! [f()]
|
warning: unmatched disambiguator `static` and suffix `!`
--> $DIR/disambiguator-endswith-named-suffix.rs:50:6
|
LL | //! [static@m!]
| ^^^^^^
|
= note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators
warning: unmatched disambiguator `function` and suffix `!()`
--> $DIR/disambiguator-endswith-named-suffix.rs:52:6
|
LL | //! [function@m!()]
| ^^^^^^^^
|
= note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators
warning: unmatched disambiguator `function` and suffix `!`
--> $DIR/disambiguator-endswith-named-suffix.rs:56:6
|
LL | //! [function@m!]
| ^^^^^^^^
|
= note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators
warning: unmatched disambiguator `fn` and suffix `!()`
--> $DIR/disambiguator-endswith-named-suffix.rs:58:6
|
LL | //! [fn@m!()]
| ^^
|
= note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators
warning: unmatched disambiguator `fn` and suffix `!`
--> $DIR/disambiguator-endswith-named-suffix.rs:62:6
|
LL | //! [fn@m!]
| ^^
|
= note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators
warning: unmatched disambiguator `method` and suffix `!()`
--> $DIR/disambiguator-endswith-named-suffix.rs:64:6
|
LL | //! [method@m!()]
| ^^^^^^
|
= note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators
warning: unmatched disambiguator `method` and suffix `!`
--> $DIR/disambiguator-endswith-named-suffix.rs:68:6
|
LL | //! [method@m!]
| ^^^^^^
|
= note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators
warning: incompatible link kind for `m`
--> $DIR/disambiguator-endswith-named-suffix.rs:70:6
|
LL | //! [derive@m!()]
| ^^^^^^^^^^^ this link resolved to a macro, which is not a derive macro
|
help: to link to the macro, add an exclamation mark
|
LL - //! [derive@m!()]
LL + //! [m!!()]
|
warning: incompatible link kind for `m`
--> $DIR/disambiguator-endswith-named-suffix.rs:71:6
|
LL | //! [derive@m!{}]
| ^^^^^^^^^^^ this link resolved to a macro, which is not a derive macro
|
help: to link to the macro, add an exclamation mark
|
LL - //! [derive@m!{}]
LL + //! [m!!{}]
|
warning: unmatched disambiguator `derive` and suffix `()`
--> $DIR/disambiguator-endswith-named-suffix.rs:73:6
|
LL | //! [derive@f()]
| ^^^^^^
|
= note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators
warning: incompatible link kind for `m`
--> $DIR/disambiguator-endswith-named-suffix.rs:74:6
|
LL | //! [derive@m!]
| ^^^^^^^^^ this link resolved to a macro, which is not a derive macro
|
help: to link to the macro, add an exclamation mark
|
LL - //! [derive@m!]
LL + //! [m!!]
|
warning: unmatched disambiguator `type` and suffix `!()`
--> $DIR/disambiguator-endswith-named-suffix.rs:76:6
|
LL | //! [type@m!()]
| ^^^^
|
= note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators
warning: unmatched disambiguator `type` and suffix `()`
--> $DIR/disambiguator-endswith-named-suffix.rs:79:6
|
LL | //! [type@f()]
| ^^^^
|
= note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators
warning: unmatched disambiguator `type` and suffix `!`
--> $DIR/disambiguator-endswith-named-suffix.rs:80:6
|
LL | //! [type@m!]
| ^^^^
|
= note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators
warning: unmatched disambiguator `value` and suffix `!()`
--> $DIR/disambiguator-endswith-named-suffix.rs:82:6
|
LL | //! [value@m!()]
| ^^^^^
|
= note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators
warning: unmatched disambiguator `value` and suffix `!`
--> $DIR/disambiguator-endswith-named-suffix.rs:86:6
|
LL | //! [value@m!]
| ^^^^^
|
= note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators
warning: unmatched disambiguator `macro` and suffix `()`
--> $DIR/disambiguator-endswith-named-suffix.rs:91:6
|
LL | //! [macro@f()]
| ^^^^^
|
= note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators
warning: unmatched disambiguator `prim` and suffix `!()`
--> $DIR/disambiguator-endswith-named-suffix.rs:94:6
|
LL | //! [prim@m!()]
| ^^^^
|
= note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators
warning: unmatched disambiguator `prim` and suffix `()`
--> $DIR/disambiguator-endswith-named-suffix.rs:97:6
|
LL | //! [prim@f()]
| ^^^^
|
= note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators
warning: unmatched disambiguator `prim` and suffix `!`
--> $DIR/disambiguator-endswith-named-suffix.rs:98:6
|
LL | //! [prim@m!]
| ^^^^
|
= note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators
warning: unmatched disambiguator `primitive` and suffix `!()`
--> $DIR/disambiguator-endswith-named-suffix.rs:100:6
|
LL | //! [primitive@m!()]
| ^^^^^^^^^
|
= note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators
warning: unmatched disambiguator `primitive` and suffix `()`
--> $DIR/disambiguator-endswith-named-suffix.rs:103:6
|
LL | //! [primitive@f()]
| ^^^^^^^^^
|
= note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators
warning: unmatched disambiguator `primitive` and suffix `!`
--> $DIR/disambiguator-endswith-named-suffix.rs:104:6
|
LL | //! [primitive@m!]
| ^^^^^^^^^
|
= note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators
warning: 46 warnings emitted

View file

@ -0,0 +1,11 @@
//@ check-pass
//! [macro@m!] //~ WARN: unresolved link to `m`
//issue#126986
macro_rules! m {
() => {};
}
fn main() {}

View file

@ -0,0 +1,11 @@
warning: unresolved link to `m`
--> $DIR/disambiguator-macro-endswith-exclamatory.rs:3:6
|
LL | //! [macro@m!]
| ^^^^^^^^ no item named `m` in scope
|
= note: `macro_rules` named `m` exists in this crate, but it is not in scope at this link's location
= note: `#[warn(rustdoc::broken_intra_doc_links)]` on by default
warning: 1 warning emitted

View file

@ -4,6 +4,8 @@
//@ normalize-stderr-test: "tests/rustdoc-ui/doctest" -> "$$DIR"
//@ normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME"
#![doc(test(attr(warn(non_local_definitions))))]
//! ```
//! #[macro_export]
//! macro_rules! a_macro { () => {} }

View file

@ -1,5 +1,5 @@
warning: non-local `macro_rules!` definition, `#[macro_export]` macro should be written at top level module
--> $DIR/non_local_defs.rs:9:1
--> $DIR/non_local_defs.rs:11:1
|
LL | macro_rules! a_macro { () => {} }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -7,7 +7,11 @@ LL | macro_rules! a_macro { () => {} }
= help: remove the `#[macro_export]` or make this doc-test a standalone test with its own `fn main() { ... }`
= note: a `macro_rules!` definition is non-local if it is nested inside an item and has a `#[macro_export]` attribute
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
= note: `#[warn(non_local_definitions)]` on by default
note: the lint level is defined here
--> $DIR/non_local_defs.rs:8:9
|
LL | #![warn(non_local_definitions)]
| ^^^^^^^^^^^^^^^^^^^^^
warning: 1 warning emitted

View file

@ -1,6 +1,6 @@
running 1 test
test $DIR/non_local_defs.rs - (line 7) ... ok
test $DIR/non_local_defs.rs - (line 9) ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME

View file

@ -0,0 +1,18 @@
//@ compile-flags: -Zinline-mir=yes --crate-type=lib
//@ build-pass
use std::mem::ManuallyDrop;
pub struct Foo<T, const N: usize>([T; N]);
pub struct Dorp {}
impl Drop for Dorp {
fn drop(&mut self) {}
}
#[inline]
// SAFETY: call this with a valid allocation idk
pub unsafe fn drop<const M: usize>(x: *mut Foo<Dorp, M>) {
std::ptr::drop_in_place(x);
}

View file

@ -10,6 +10,8 @@
// of the `cargo update` suggestion we assert it here.
//@ error-pattern: `cargo update -p non_local_macro`
#![warn(non_local_definitions)]
extern crate non_local_macro;
struct LocalStruct;

View file

@ -1,5 +1,5 @@
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/cargo-update.rs:17:1
--> $DIR/cargo-update.rs:19:1
|
LL | non_local_macro::non_local_impl!(LocalStruct);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -14,7 +14,11 @@ LL | non_local_macro::non_local_impl!(LocalStruct);
= note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
= note: items in an anonymous const item (`const _: () = { ... }`) are treated as in the same scope as the anonymous const's declaration for the purpose of this lint
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
= note: `#[warn(non_local_definitions)]` on by default
note: the lint level is defined here
--> $DIR/cargo-update.rs:13:9
|
LL | #![warn(non_local_definitions)]
| ^^^^^^^^^^^^^^^^^^^^^
= note: this warning originates in the macro `non_local_macro::non_local_impl` (in Nightly builds, run with -Z macro-backtrace for more info)
warning: 1 warning emitted

View file

@ -2,6 +2,8 @@
//@ edition:2021
//@ rustc-env:CARGO_CRATE_NAME=non_local_def
#![warn(non_local_definitions)]
struct Test;
trait Uto {}

View file

@ -1,5 +1,5 @@
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/consts.rs:13:5
--> $DIR/consts.rs:15:5
|
LL | const Z: () = {
| -----------
@ -17,10 +17,14 @@ LL | impl Uto for &Test {}
= note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
= note: items in an anonymous const item (`const _: () = { ... }`) are treated as in the same scope as the anonymous const's declaration for the purpose of this lint
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
= note: `#[warn(non_local_definitions)]` on by default
note: the lint level is defined here
--> $DIR/consts.rs:5:9
|
LL | #![warn(non_local_definitions)]
| ^^^^^^^^^^^^^^^^^^^^^
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/consts.rs:24:5
--> $DIR/consts.rs:26:5
|
LL | static A: u32 = {
| ------------- move the `impl` block outside of this static `A`
@ -36,7 +40,7 @@ LL | impl Uto2 for Test {}
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/consts.rs:32:5
--> $DIR/consts.rs:34:5
|
LL | const B: u32 = {
| ------------ move the `impl` block outside of this constant `B`
@ -52,7 +56,7 @@ LL | impl Uto3 for Test {}
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/consts.rs:43:5
--> $DIR/consts.rs:45:5
|
LL | fn main() {
| --------- move the `impl` block outside of this function `main`
@ -65,7 +69,7 @@ LL | impl Test {
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/consts.rs:50:9
--> $DIR/consts.rs:52:9
|
LL | const {
| ___________-
@ -84,7 +88,7 @@ LL | | };
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/consts.rs:59:9
--> $DIR/consts.rs:61:9
|
LL | const _: u32 = {
| ------------ move the `impl` block outside of this constant `_` and up 2 bodies
@ -98,7 +102,7 @@ LL | impl Test {
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/consts.rs:72:9
--> $DIR/consts.rs:74:9
|
LL | let _a = || {
| -- move the `impl` block outside of this closure `<unnameable>` and up 2 bodies
@ -113,7 +117,7 @@ LL | impl Uto9 for Test {}
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/consts.rs:79:9
--> $DIR/consts.rs:81:9
|
LL | type A = [u32; {
| ____________________-

View file

@ -1,6 +1,8 @@
//@ check-pass
//@ edition:2021
#![warn(non_local_definitions)]
struct Dog;
fn main() {

View file

@ -1,5 +1,5 @@
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/exhaustive-trait.rs:7:5
--> $DIR/exhaustive-trait.rs:9:5
|
LL | fn main() {
| --------- move the `impl` block outside of this function `main`
@ -12,10 +12,14 @@ LL | impl PartialEq<()> for Dog {
= note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type
= note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
= note: `#[warn(non_local_definitions)]` on by default
note: the lint level is defined here
--> $DIR/exhaustive-trait.rs:4:9
|
LL | #![warn(non_local_definitions)]
| ^^^^^^^^^^^^^^^^^^^^^
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/exhaustive-trait.rs:14:5
--> $DIR/exhaustive-trait.rs:16:5
|
LL | fn main() {
| --------- move the `impl` block outside of this function `main`
@ -31,7 +35,7 @@ LL | impl PartialEq<()> for &Dog {
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/exhaustive-trait.rs:21:5
--> $DIR/exhaustive-trait.rs:23:5
|
LL | fn main() {
| --------- move the `impl` block outside of this function `main`
@ -47,7 +51,7 @@ LL | impl PartialEq<Dog> for () {
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/exhaustive-trait.rs:28:5
--> $DIR/exhaustive-trait.rs:30:5
|
LL | fn main() {
| --------- move the `impl` block outside of this function `main`
@ -63,7 +67,7 @@ LL | impl PartialEq<&Dog> for () {
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/exhaustive-trait.rs:35:5
--> $DIR/exhaustive-trait.rs:37:5
|
LL | fn main() {
| --------- move the `impl` block outside of this function `main`
@ -79,7 +83,7 @@ LL | impl PartialEq<Dog> for &Dog {
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/exhaustive-trait.rs:42:5
--> $DIR/exhaustive-trait.rs:44:5
|
LL | fn main() {
| --------- move the `impl` block outside of this function `main`

View file

@ -1,6 +1,8 @@
//@ check-pass
//@ edition:2021
#![warn(non_local_definitions)]
use std::fmt::Display;
trait Trait {}

View file

@ -1,5 +1,5 @@
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/exhaustive.rs:10:5
--> $DIR/exhaustive.rs:12:5
|
LL | fn main() {
| --------- move the `impl` block outside of this function `main`
@ -10,10 +10,14 @@ LL | impl Test {
|
= note: methods and associated constants are still usable outside the current expression, only `impl Local` and `impl dyn Local` can ever be private, and only if the type is nested in the same item as the `impl`
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
= note: `#[warn(non_local_definitions)]` on by default
note: the lint level is defined here
--> $DIR/exhaustive.rs:4:9
|
LL | #![warn(non_local_definitions)]
| ^^^^^^^^^^^^^^^^^^^^^
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/exhaustive.rs:15:5
--> $DIR/exhaustive.rs:17:5
|
LL | fn main() {
| --------- move the `impl` block outside of this function `main`
@ -29,7 +33,7 @@ LL | impl Display for Test {
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/exhaustive.rs:22:5
--> $DIR/exhaustive.rs:24:5
|
LL | fn main() {
| --------- move the `impl` block outside of this function `main`
@ -43,7 +47,7 @@ LL | impl dyn Trait {}
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/exhaustive.rs:25:5
--> $DIR/exhaustive.rs:27:5
|
LL | fn main() {
| --------- move the `impl` block outside of this function `main`
@ -59,7 +63,7 @@ LL | impl<T: Trait> Trait for Vec<T> { }
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/exhaustive.rs:28:5
--> $DIR/exhaustive.rs:30:5
|
LL | fn main() {
| --------- move the `impl` block outside of this function `main`
@ -75,7 +79,7 @@ LL | impl Trait for &dyn Trait {}
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/exhaustive.rs:31:5
--> $DIR/exhaustive.rs:33:5
|
LL | fn main() {
| --------- move the `impl` block outside of this function `main`
@ -91,7 +95,7 @@ LL | impl Trait for *mut Test {}
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/exhaustive.rs:34:5
--> $DIR/exhaustive.rs:36:5
|
LL | fn main() {
| --------- move the `impl` block outside of this function `main`
@ -107,7 +111,7 @@ LL | impl Trait for *mut [Test] {}
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/exhaustive.rs:37:5
--> $DIR/exhaustive.rs:39:5
|
LL | fn main() {
| --------- move the `impl` block outside of this function `main`
@ -123,7 +127,7 @@ LL | impl Trait for [Test; 8] {}
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/exhaustive.rs:40:5
--> $DIR/exhaustive.rs:42:5
|
LL | fn main() {
| --------- move the `impl` block outside of this function `main`
@ -139,7 +143,7 @@ LL | impl Trait for (Test,) {}
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/exhaustive.rs:43:5
--> $DIR/exhaustive.rs:45:5
|
LL | fn main() {
| --------- move the `impl` block outside of this function `main`
@ -155,7 +159,7 @@ LL | impl Trait for fn(Test) -> () {}
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/exhaustive.rs:46:5
--> $DIR/exhaustive.rs:48:5
|
LL | fn main() {
| --------- move the `impl` block outside of this function `main`
@ -171,7 +175,7 @@ LL | impl Trait for fn() -> Test {}
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/exhaustive.rs:50:9
--> $DIR/exhaustive.rs:52:9
|
LL | let _a = || {
| -- move the `impl` block outside of this closure `<unnameable>` and up 2 bodies
@ -186,7 +190,7 @@ LL | impl Trait for Test {}
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/exhaustive.rs:58:5
--> $DIR/exhaustive.rs:60:5
|
LL | impl Trait for *mut InsideMain {}
| ^^^^^-----^^^^^---------------
@ -198,28 +202,7 @@ LL | impl Trait for *mut InsideMain {}
= note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type
= note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
help: move the `impl` block outside of this function `main`
--> $DIR/exhaustive.rs:9:1
|
LL | fn main() {
| ^^^^^^^^^
...
LL | struct InsideMain;
| ----------------- may need to be moved as well
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/exhaustive.rs:60:5
|
LL | impl Trait for *mut [InsideMain] {}
| ^^^^^-----^^^^^-----------------
| | |
| | `*mut [InsideMain]` is not local
| `Trait` is not local
|
= note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type
= note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
help: move the `impl` block outside of this function `main`
--> $DIR/exhaustive.rs:9:1
--> $DIR/exhaustive.rs:11:1
|
LL | fn main() {
| ^^^^^^^^^
@ -231,16 +214,16 @@ LL | struct InsideMain;
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/exhaustive.rs:62:5
|
LL | impl Trait for [InsideMain; 8] {}
| ^^^^^-----^^^^^---------------
LL | impl Trait for *mut [InsideMain] {}
| ^^^^^-----^^^^^-----------------
| | |
| | `[InsideMain; 8]` is not local
| | `*mut [InsideMain]` is not local
| `Trait` is not local
|
= note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type
= note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
help: move the `impl` block outside of this function `main`
--> $DIR/exhaustive.rs:9:1
--> $DIR/exhaustive.rs:11:1
|
LL | fn main() {
| ^^^^^^^^^
@ -252,16 +235,16 @@ LL | struct InsideMain;
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/exhaustive.rs:64:5
|
LL | impl Trait for (InsideMain,) {}
| ^^^^^-----^^^^^-------------
LL | impl Trait for [InsideMain; 8] {}
| ^^^^^-----^^^^^---------------
| | |
| | `(InsideMain,)` is not local
| | `[InsideMain; 8]` is not local
| `Trait` is not local
|
= note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type
= note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
help: move the `impl` block outside of this function `main`
--> $DIR/exhaustive.rs:9:1
--> $DIR/exhaustive.rs:11:1
|
LL | fn main() {
| ^^^^^^^^^
@ -273,16 +256,16 @@ LL | struct InsideMain;
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/exhaustive.rs:66:5
|
LL | impl Trait for fn(InsideMain) -> () {}
| ^^^^^-----^^^^^--------------------
LL | impl Trait for (InsideMain,) {}
| ^^^^^-----^^^^^-------------
| | |
| | `fn(: InsideMain) -> ()` is not local
| | `(InsideMain,)` is not local
| `Trait` is not local
|
= note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type
= note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
help: move the `impl` block outside of this function `main`
--> $DIR/exhaustive.rs:9:1
--> $DIR/exhaustive.rs:11:1
|
LL | fn main() {
| ^^^^^^^^^
@ -294,16 +277,16 @@ LL | struct InsideMain;
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/exhaustive.rs:68:5
|
LL | impl Trait for fn() -> InsideMain {}
| ^^^^^-----^^^^^------------------
LL | impl Trait for fn(InsideMain) -> () {}
| ^^^^^-----^^^^^--------------------
| | |
| | `fn() -> InsideMain` is not local
| | `fn(: InsideMain) -> ()` is not local
| `Trait` is not local
|
= note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type
= note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
help: move the `impl` block outside of this function `main`
--> $DIR/exhaustive.rs:9:1
--> $DIR/exhaustive.rs:11:1
|
LL | fn main() {
| ^^^^^^^^^
@ -313,7 +296,28 @@ LL | struct InsideMain;
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/exhaustive.rs:72:9
--> $DIR/exhaustive.rs:70:5
|
LL | impl Trait for fn() -> InsideMain {}
| ^^^^^-----^^^^^------------------
| | |
| | `fn() -> InsideMain` is not local
| `Trait` is not local
|
= note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type
= note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
help: move the `impl` block outside of this function `main`
--> $DIR/exhaustive.rs:11:1
|
LL | fn main() {
| ^^^^^^^^^
...
LL | struct InsideMain;
| ----------------- may need to be moved as well
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/exhaustive.rs:74:9
|
LL | fn inside_inside() {
| ------------------ move the `impl` block outside of this function `inside_inside` and up 2 bodies
@ -328,7 +332,7 @@ LL | impl Display for InsideMain {
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/exhaustive.rs:79:9
--> $DIR/exhaustive.rs:81:9
|
LL | fn inside_inside() {
| ------------------ move the `impl` block outside of this function `inside_inside` and up 2 bodies

View file

@ -1,6 +1,8 @@
//@ check-pass
//@ edition:2021
#![warn(non_local_definitions)]
struct Cat;
struct Wrap<T>(T);

View file

@ -1,5 +1,5 @@
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/from-local-for-global.rs:8:5
--> $DIR/from-local-for-global.rs:10:5
|
LL | fn main() {
| --------- move the `impl` block outside of this function `main`
@ -12,10 +12,14 @@ LL | impl From<Cat> for () {
= note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type
= note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
= note: `#[warn(non_local_definitions)]` on by default
note: the lint level is defined here
--> $DIR/from-local-for-global.rs:4:9
|
LL | #![warn(non_local_definitions)]
| ^^^^^^^^^^^^^^^^^^^^^
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/from-local-for-global.rs:18:5
--> $DIR/from-local-for-global.rs:20:5
|
LL | impl From<Wrap<Wrap<Elephant>>> for () {
| ^^^^^----^^^^^^^^^^^^^^^^^^^^^^^^^^^--
@ -25,7 +29,7 @@ LL | impl From<Wrap<Wrap<Elephant>>> for () {
= note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type
= note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
help: move the `impl` block outside of this function `main`
--> $DIR/from-local-for-global.rs:7:1
--> $DIR/from-local-for-global.rs:9:1
|
LL | fn main() {
| ^^^^^^^^^
@ -35,7 +39,7 @@ LL | struct Elephant;
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/from-local-for-global.rs:32:5
--> $DIR/from-local-for-global.rs:34:5
|
LL | impl StillNonLocal for &Foo {}
| ^^^^^-------------^^^^^----
@ -47,7 +51,7 @@ LL | impl StillNonLocal for &Foo {}
= note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type
= note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
help: move the `impl` block outside of this function `only_global`
--> $DIR/from-local-for-global.rs:30:1
--> $DIR/from-local-for-global.rs:32:1
|
LL | fn only_global() {
| ^^^^^^^^^^^^^^^^
@ -56,7 +60,7 @@ LL | struct Foo;
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/from-local-for-global.rs:40:5
--> $DIR/from-local-for-global.rs:42:5
|
LL | impl From<Local1> for GlobalSameFunction {
| ^^^^^----^^^^^^^^^^^^^------------------
@ -67,7 +71,7 @@ LL | impl From<Local1> for GlobalSameFunction {
= note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type
= note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
help: move the `impl` block outside of this function `same_function`
--> $DIR/from-local-for-global.rs:38:1
--> $DIR/from-local-for-global.rs:40:1
|
LL | fn same_function() {
| ^^^^^^^^^^^^^^^^^^
@ -76,7 +80,7 @@ LL | struct Local1(GlobalSameFunction);
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/from-local-for-global.rs:48:5
--> $DIR/from-local-for-global.rs:50:5
|
LL | impl From<Local2> for GlobalSameFunction {
| ^^^^^----^^^^^^^^^^^^^------------------
@ -87,7 +91,7 @@ LL | impl From<Local2> for GlobalSameFunction {
= note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type
= note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
help: move the `impl` block outside of this function `same_function`
--> $DIR/from-local-for-global.rs:38:1
--> $DIR/from-local-for-global.rs:40:1
|
LL | fn same_function() {
| ^^^^^^^^^^^^^^^^^^

View file

@ -1,6 +1,8 @@
//@ check-pass
//@ edition:2021
#![warn(non_local_definitions)]
trait Global {}
fn main() {

View file

@ -1,5 +1,5 @@
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/generics.rs:9:5
--> $DIR/generics.rs:11:5
|
LL | impl<T: Local> Global for Vec<T> { }
| ^^^^^^^^^^^^^^^------^^^^^---^^^
@ -10,17 +10,21 @@ LL | impl<T: Local> Global for Vec<T> { }
= note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type
= note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
help: move the `impl` block outside of this function `main`
--> $DIR/generics.rs:6:1
--> $DIR/generics.rs:8:1
|
LL | fn main() {
| ^^^^^^^^^
LL | trait Local {};
| ----------- may need to be moved as well
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
= note: `#[warn(non_local_definitions)]` on by default
note: the lint level is defined here
--> $DIR/generics.rs:4:9
|
LL | #![warn(non_local_definitions)]
| ^^^^^^^^^^^^^^^^^^^^^
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/generics.rs:20:5
--> $DIR/generics.rs:22:5
|
LL | impl Uto7 for Test where Local: std::any::Any {}
| ^^^^^----^^^^^----
@ -31,7 +35,7 @@ LL | impl Uto7 for Test where Local: std::any::Any {}
= note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type
= note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
help: move the `impl` block outside of this function `bad`
--> $DIR/generics.rs:18:1
--> $DIR/generics.rs:20:1
|
LL | fn bad() {
| ^^^^^^^^
@ -40,7 +44,7 @@ LL | struct Local;
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/generics.rs:23:5
--> $DIR/generics.rs:25:5
|
LL | fn bad() {
| -------- move the `impl` block outside of this function `bad`
@ -56,7 +60,7 @@ LL | impl<T> Uto8 for T {}
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/generics.rs:32:5
--> $DIR/generics.rs:34:5
|
LL | impl Default for UwU<OwO> {
| ^^^^^-------^^^^^---^^^^^
@ -67,7 +71,7 @@ LL | impl Default for UwU<OwO> {
= note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type
= note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
help: move the `impl` block outside of this function `fun`
--> $DIR/generics.rs:29:1
--> $DIR/generics.rs:31:1
|
LL | fn fun() {
| ^^^^^^^^
@ -77,7 +81,7 @@ LL | struct OwO;
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/generics.rs:43:5
--> $DIR/generics.rs:45:5
|
LL | impl AsRef<Cat> for () {
| ^^^^^-----^^^^^^^^^^--
@ -88,7 +92,7 @@ LL | impl AsRef<Cat> for () {
= note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type
= note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
help: move the `impl` block outside of this function `meow`
--> $DIR/generics.rs:40:1
--> $DIR/generics.rs:42:1
|
LL | fn meow() {
| ^^^^^^^^^
@ -98,7 +102,7 @@ LL | struct Cat;
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/generics.rs:54:5
--> $DIR/generics.rs:56:5
|
LL | impl PartialEq<B> for G {
| ^^^^^---------^^^^^^^^-
@ -109,7 +113,7 @@ LL | impl PartialEq<B> for G {
= note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type
= note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
help: move the `impl` block outside of this function `fun2`
--> $DIR/generics.rs:51:1
--> $DIR/generics.rs:53:1
|
LL | fn fun2() {
| ^^^^^^^^^
@ -119,7 +123,7 @@ LL | struct B;
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/generics.rs:69:5
--> $DIR/generics.rs:71:5
|
LL | impl From<Wrap<Wrap<Lion>>> for () {
| ^^^^^----^^^^^^^^^^^^^^^^^^^^^^^--
@ -129,7 +133,7 @@ LL | impl From<Wrap<Wrap<Lion>>> for () {
= note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type
= note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
help: move the `impl` block outside of this function `rawr`
--> $DIR/generics.rs:66:1
--> $DIR/generics.rs:68:1
|
LL | fn rawr() {
| ^^^^^^^^^
@ -138,7 +142,7 @@ LL | struct Lion;
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/generics.rs:76:5
--> $DIR/generics.rs:78:5
|
LL | impl From<()> for Wrap<Lion> {
| ^^^^^----^^^^^^^^^----^^^^^^
@ -149,7 +153,7 @@ LL | impl From<()> for Wrap<Lion> {
= note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type
= note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
help: move the `impl` block outside of this function `rawr`
--> $DIR/generics.rs:66:1
--> $DIR/generics.rs:68:1
|
LL | fn rawr() {
| ^^^^^^^^^

View file

@ -1,6 +1,8 @@
//@ check-pass
//@ edition:2021
#![warn(non_local_definitions)]
macro_rules! m {
() => {
trait MacroTrait {}

View file

@ -1,5 +1,5 @@
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/inside-macro_rules.rs:9:13
--> $DIR/inside-macro_rules.rs:11:13
|
LL | fn my_func() {
| ------------ move the `impl` block outside of this function `my_func`
@ -16,7 +16,11 @@ LL | m!();
= note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type
= note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
= note: `#[warn(non_local_definitions)]` on by default
note: the lint level is defined here
--> $DIR/inside-macro_rules.rs:4:9
|
LL | #![warn(non_local_definitions)]
| ^^^^^^^^^^^^^^^^^^^^^
= note: this warning originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)
warning: 1 warning emitted

View file

@ -1,6 +1,8 @@
//@ check-pass
//@ edition:2021
#![warn(non_local_definitions)]
use std::fmt::Debug;
trait GlobalTrait {}

View file

@ -3,6 +3,8 @@
//@ aux-build:non_local_macro.rs
//@ rustc-env:CARGO_CRATE_NAME=non_local_def
#![warn(non_local_definitions)]
extern crate non_local_macro;
const B: u32 = {

View file

@ -1,5 +1,5 @@
warning: non-local `macro_rules!` definition, `#[macro_export]` macro should be written at top level module
--> $DIR/macro_rules.rs:10:5
--> $DIR/macro_rules.rs:12:5
|
LL | macro_rules! m0 { () => { } };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -7,10 +7,14 @@ LL | macro_rules! m0 { () => { } };
= help: remove the `#[macro_export]` or move this `macro_rules!` outside the of the current constant `B`
= note: a `macro_rules!` definition is non-local if it is nested inside an item and has a `#[macro_export]` attribute
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
= note: `#[warn(non_local_definitions)]` on by default
note: the lint level is defined here
--> $DIR/macro_rules.rs:6:9
|
LL | #![warn(non_local_definitions)]
| ^^^^^^^^^^^^^^^^^^^^^
warning: non-local `macro_rules!` definition, `#[macro_export]` macro should be written at top level module
--> $DIR/macro_rules.rs:16:1
--> $DIR/macro_rules.rs:18:1
|
LL | non_local_macro::non_local_macro_rules!(my_macro);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -22,7 +26,7 @@ LL | non_local_macro::non_local_macro_rules!(my_macro);
= note: this warning originates in the macro `non_local_macro::non_local_macro_rules` (in Nightly builds, run with -Z macro-backtrace for more info)
warning: non-local `macro_rules!` definition, `#[macro_export]` macro should be written at top level module
--> $DIR/macro_rules.rs:21:5
--> $DIR/macro_rules.rs:23:5
|
LL | macro_rules! m { () => { } };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -32,7 +36,7 @@ LL | macro_rules! m { () => { } };
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `macro_rules!` definition, `#[macro_export]` macro should be written at top level module
--> $DIR/macro_rules.rs:29:13
--> $DIR/macro_rules.rs:31:13
|
LL | macro_rules! m2 { () => { } };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View file

@ -1,5 +1,7 @@
//@ check-pass
#![warn(non_local_definitions)]
trait Trait<T> {}
fn main() {

View file

@ -1,5 +1,5 @@
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/suggest-moving-inner.rs:12:5
--> $DIR/suggest-moving-inner.rs:14:5
|
LL | impl<T> Trait<InsideMain> for &Vec<below::Type<(InsideMain, T)>>
| ^^^^^^^^-----^^^^^^^^^^^^^^^^^----------------------------------
@ -10,7 +10,7 @@ LL | impl<T> Trait<InsideMain> for &Vec<below::Type<(InsideMain, T)>>
= note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type
= note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
help: move the `impl` block outside of this function `main`
--> $DIR/suggest-moving-inner.rs:5:1
--> $DIR/suggest-moving-inner.rs:7:1
|
LL | fn main() {
| ^^^^^^^^^
@ -23,7 +23,11 @@ LL | struct InsideMain;
LL | trait HasFoo {}
| ------------ may need to be moved as well
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
= note: `#[warn(non_local_definitions)]` on by default
note: the lint level is defined here
--> $DIR/suggest-moving-inner.rs:3:9
|
LL | #![warn(non_local_definitions)]
| ^^^^^^^^^^^^^^^^^^^^^
warning: 1 warning emitted

View file

@ -3,6 +3,8 @@
// https://github.com/rust-lang/rust/issues/123573#issue-2229428739
#![warn(non_local_definitions)]
pub trait Test {}
impl<'a, T: 'a> Test for &[T] where &'a T: Test {}

View file

@ -1,5 +1,5 @@
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/trait-solver-overflow-123573.rs:12:5
--> $DIR/trait-solver-overflow-123573.rs:14:5
|
LL | impl Test for &Local {}
| ^^^^^----^^^^^------
@ -11,14 +11,18 @@ LL | impl Test for &Local {}
= note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type
= note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
help: move the `impl` block outside of this function `main`
--> $DIR/trait-solver-overflow-123573.rs:10:1
--> $DIR/trait-solver-overflow-123573.rs:12:1
|
LL | fn main() {
| ^^^^^^^^^
LL | struct Local {}
| ------------ may need to be moved as well
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
= note: `#[warn(non_local_definitions)]` on by default
note: the lint level is defined here
--> $DIR/trait-solver-overflow-123573.rs:6:9
|
LL | #![warn(non_local_definitions)]
| ^^^^^^^^^^^^^^^^^^^^^
warning: 1 warning emitted

View file

@ -1,6 +1,8 @@
//@ check-pass
//@ edition:2021
#![warn(non_local_definitions)]
trait Uto {}
struct Test;

View file

@ -1,5 +1,5 @@
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/weird-exprs.rs:8:5
--> $DIR/weird-exprs.rs:10:5
|
LL | type A = [u32; {
| ________________-
@ -16,10 +16,14 @@ LL | | }];
= note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type
= note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
= note: `#[warn(non_local_definitions)]` on by default
note: the lint level is defined here
--> $DIR/weird-exprs.rs:4:9
|
LL | #![warn(non_local_definitions)]
| ^^^^^^^^^^^^^^^^^^^^^
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/weird-exprs.rs:16:9
--> $DIR/weird-exprs.rs:18:9
|
LL | Discr = {
| _____________-
@ -38,7 +42,7 @@ LL | | }
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/weird-exprs.rs:25:9
--> $DIR/weird-exprs.rs:27:9
|
LL | let _array = [0i32; {
| _________________________-
@ -57,7 +61,7 @@ LL | | }];
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/weird-exprs.rs:34:9
--> $DIR/weird-exprs.rs:36:9
|
LL | type A = [u32; {
| ____________________-
@ -76,7 +80,7 @@ LL | | }];
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/weird-exprs.rs:41:9
--> $DIR/weird-exprs.rs:43:9
|
LL | fn a(_: [u32; {
| ___________________-
@ -95,7 +99,7 @@ LL | | }]) {}
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
--> $DIR/weird-exprs.rs:48:9
--> $DIR/weird-exprs.rs:50:9
|
LL | fn b() -> [u32; {
| _____________________-

View file

@ -0,0 +1,11 @@
//@ compile-flags:-O
#[inline]
fn foo() {}
pub static ADDR: fn() = foo;
#[inline(always)]
pub fn bar(x: fn()) -> bool {
x == ADDR
}

View file

@ -0,0 +1,21 @@
//! Verify that we correctly handle fn pointer provenance in MIR optimizations.
//! By asking to inline `static_fnptr::bar`, we have two copies of `static_fnptr::foo`, one in the
//! auxiliary crate and one in the local crate CGU.
//! `baz` must only consider the versions from upstream crate, and not try to compare with the
//! address of the CGU-local copy.
//! Related issue: #123670
//@ run-pass
//@ compile-flags:-Cno-prepopulate-passes -Copt-level=0
//@ aux-build:static_fnptr.rs
extern crate static_fnptr;
use static_fnptr::{ADDR, bar};
fn baz() -> bool {
bar(ADDR)
}
fn main() {
assert!(baz())
}