Auto merge of #134374 - matthiaskrgr:rollup-2tbbrxq, r=matthiaskrgr
Rollup of 5 pull requests Successful merges: - #134314 (Make sure to use normalized ty for unevaluated const in default struct value) - #134342 (crashes: more tests) - #134357 (Fix `trimmed_def_paths` ICE in the function ptr comparison lint) - #134369 (Update spelling of "referring") - #134372 (Disable `tests/ui/associated-consts/issue-93775.rs` on windows msvc) Failed merges: - #134365 (Rename `rustc_mir_build::build` to `builder`) r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
eedc229049
25 changed files with 309 additions and 65 deletions
|
|
@ -813,7 +813,7 @@ lint_unexpected_cfg_doc_cargo = see <https://doc.rust-lang.org/nightly/rustc/che
|
|||
lint_unexpected_cfg_doc_rustc = see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
|
||||
|
||||
lint_unexpected_cfg_from_external_macro_origin = using a cfg inside a {$macro_kind} will use the cfgs from the destination crate and not the ones from the defining crate
|
||||
lint_unexpected_cfg_from_external_macro_refer = try refering to `{$macro_name}` crate for guidance on how handle this unexpected cfg
|
||||
lint_unexpected_cfg_from_external_macro_refer = try referring to `{$macro_name}` crate for guidance on how handle this unexpected cfg
|
||||
lint_unexpected_cfg_name = unexpected `cfg` condition name: `{$name}`
|
||||
lint_unexpected_cfg_name_expected_names = expected names are: {$possibilities}{$and_more ->
|
||||
[0] {""}
|
||||
|
|
|
|||
|
|
@ -1816,14 +1816,14 @@ pub(crate) enum AmbiguousWidePointerComparisonsAddrSuggestion<'a> {
|
|||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
pub(crate) enum UnpredictableFunctionPointerComparisons<'a> {
|
||||
pub(crate) enum UnpredictableFunctionPointerComparisons<'a, 'tcx> {
|
||||
#[diag(lint_unpredictable_fn_pointer_comparisons)]
|
||||
#[note(lint_note_duplicated_fn)]
|
||||
#[note(lint_note_deduplicated_fn)]
|
||||
#[note(lint_note_visit_fn_addr_eq)]
|
||||
Suggestion {
|
||||
#[subdiagnostic]
|
||||
sugg: UnpredictableFunctionPointerComparisonsSuggestion<'a>,
|
||||
sugg: UnpredictableFunctionPointerComparisonsSuggestion<'a, 'tcx>,
|
||||
},
|
||||
#[diag(lint_unpredictable_fn_pointer_comparisons)]
|
||||
#[note(lint_note_duplicated_fn)]
|
||||
|
|
@ -1833,22 +1833,40 @@ pub(crate) enum UnpredictableFunctionPointerComparisons<'a> {
|
|||
}
|
||||
|
||||
#[derive(Subdiagnostic)]
|
||||
#[multipart_suggestion(
|
||||
lint_fn_addr_eq_suggestion,
|
||||
style = "verbose",
|
||||
applicability = "maybe-incorrect"
|
||||
)]
|
||||
pub(crate) struct UnpredictableFunctionPointerComparisonsSuggestion<'a> {
|
||||
pub ne: &'a str,
|
||||
pub cast_right: String,
|
||||
pub deref_left: &'a str,
|
||||
pub deref_right: &'a str,
|
||||
#[suggestion_part(code = "{ne}std::ptr::fn_addr_eq({deref_left}")]
|
||||
pub left: Span,
|
||||
#[suggestion_part(code = ", {deref_right}")]
|
||||
pub middle: Span,
|
||||
#[suggestion_part(code = "{cast_right})")]
|
||||
pub right: Span,
|
||||
pub(crate) enum UnpredictableFunctionPointerComparisonsSuggestion<'a, 'tcx> {
|
||||
#[multipart_suggestion(
|
||||
lint_fn_addr_eq_suggestion,
|
||||
style = "verbose",
|
||||
applicability = "maybe-incorrect"
|
||||
)]
|
||||
FnAddrEq {
|
||||
ne: &'a str,
|
||||
deref_left: &'a str,
|
||||
deref_right: &'a str,
|
||||
#[suggestion_part(code = "{ne}std::ptr::fn_addr_eq({deref_left}")]
|
||||
left: Span,
|
||||
#[suggestion_part(code = ", {deref_right}")]
|
||||
middle: Span,
|
||||
#[suggestion_part(code = ")")]
|
||||
right: Span,
|
||||
},
|
||||
#[multipart_suggestion(
|
||||
lint_fn_addr_eq_suggestion,
|
||||
style = "verbose",
|
||||
applicability = "maybe-incorrect"
|
||||
)]
|
||||
FnAddrEqWithCast {
|
||||
ne: &'a str,
|
||||
deref_left: &'a str,
|
||||
deref_right: &'a str,
|
||||
fn_sig: rustc_middle::ty::PolyFnSig<'tcx>,
|
||||
#[suggestion_part(code = "{ne}std::ptr::fn_addr_eq({deref_left}")]
|
||||
left: Span,
|
||||
#[suggestion_part(code = ", {deref_right}")]
|
||||
middle: Span,
|
||||
#[suggestion_part(code = " as {fn_sig})")]
|
||||
right: Span,
|
||||
},
|
||||
}
|
||||
|
||||
pub(crate) struct ImproperCTypes<'a> {
|
||||
|
|
|
|||
|
|
@ -483,29 +483,36 @@ fn lint_fn_pointer<'tcx>(
|
|||
let middle = l_span.shrink_to_hi().until(r_span.shrink_to_lo());
|
||||
let right = r_span.shrink_to_hi().until(e.span.shrink_to_hi());
|
||||
|
||||
// We only check for a right cast as `FnDef` == `FnPtr` is not possible,
|
||||
// only `FnPtr == FnDef` is possible.
|
||||
let cast_right = if !r_ty.is_fn_ptr() {
|
||||
let fn_sig = r_ty.fn_sig(cx.tcx);
|
||||
format!(" as {fn_sig}")
|
||||
} else {
|
||||
String::new()
|
||||
};
|
||||
let sugg =
|
||||
// We only check for a right cast as `FnDef` == `FnPtr` is not possible,
|
||||
// only `FnPtr == FnDef` is possible.
|
||||
if !r_ty.is_fn_ptr() {
|
||||
let fn_sig = r_ty.fn_sig(cx.tcx);
|
||||
|
||||
cx.emit_span_lint(
|
||||
UNPREDICTABLE_FUNCTION_POINTER_COMPARISONS,
|
||||
e.span,
|
||||
UnpredictableFunctionPointerComparisons::Suggestion {
|
||||
sugg: UnpredictableFunctionPointerComparisonsSuggestion {
|
||||
UnpredictableFunctionPointerComparisonsSuggestion::FnAddrEqWithCast {
|
||||
ne,
|
||||
fn_sig,
|
||||
deref_left,
|
||||
deref_right,
|
||||
left,
|
||||
middle,
|
||||
right,
|
||||
}
|
||||
} else {
|
||||
UnpredictableFunctionPointerComparisonsSuggestion::FnAddrEq {
|
||||
ne,
|
||||
deref_left,
|
||||
deref_right,
|
||||
left,
|
||||
middle,
|
||||
right,
|
||||
cast_right,
|
||||
},
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
cx.emit_span_lint(
|
||||
UNPREDICTABLE_FUNCTION_POINTER_COMPARISONS,
|
||||
e.span,
|
||||
UnpredictableFunctionPointerComparisons::Suggestion { sugg },
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ declare_lint! {
|
|||
///
|
||||
/// This lint is meant to be used with the (unstable) rustfmt setting `group_imports = "StdExternalCrate"`.
|
||||
/// That setting makes rustfmt group `self::`, `super::`, and `crate::` imports separately from those
|
||||
/// refering to other crates. However, rustfmt cannot know whether `use c::S;` refers to a local module `c`
|
||||
/// referring to other crates. However, rustfmt cannot know whether `use c::S;` refers to a local module `c`
|
||||
/// or an external crate `c`, so it always gets categorized as an import from another crate.
|
||||
/// To ensure consistent grouping of imports from the local crate, all local imports must
|
||||
/// start with `self::`, `super::`, or `crate::`. This lint can be used to enforce that style.
|
||||
|
|
|
|||
|
|
@ -367,14 +367,20 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
.collect()
|
||||
}
|
||||
AdtExprBase::DefaultFields(field_types) => {
|
||||
itertools::zip_eq(field_names, &**field_types)
|
||||
.map(|(n, ty)| match fields_map.get(&n) {
|
||||
itertools::zip_eq(field_names, field_types)
|
||||
.map(|(n, &ty)| match fields_map.get(&n) {
|
||||
Some(v) => v.clone(),
|
||||
None => match variant.fields[n].value {
|
||||
Some(def) => {
|
||||
let value = Const::from_unevaluated(this.tcx, def)
|
||||
.instantiate(this.tcx, args);
|
||||
this.literal_operand(expr_span, value)
|
||||
let value = Const::Unevaluated(
|
||||
UnevaluatedConst::new(def, args),
|
||||
ty,
|
||||
);
|
||||
Operand::Constant(Box::new(ConstOperand {
|
||||
span: expr_span,
|
||||
user_ty: None,
|
||||
const_: value,
|
||||
}))
|
||||
}
|
||||
None => {
|
||||
let name = variant.fields[n].name;
|
||||
|
|
|
|||
23
tests/crashes/130797.rs
Normal file
23
tests/crashes/130797.rs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
//@ known-bug: #130797
|
||||
|
||||
trait Transform {
|
||||
type Output<'a>;
|
||||
}
|
||||
trait Propagate<O> {}
|
||||
trait AddChild<C> {
|
||||
fn add_child(&self) {}
|
||||
}
|
||||
|
||||
pub struct Node<T>(T);
|
||||
impl<T> AddChild<Box<dyn for<'b> Propagate<T::Output<'b>>>> for Node<T> where T: Transform {}
|
||||
|
||||
fn make_graph_root() {
|
||||
Node(Dummy).add_child()
|
||||
}
|
||||
|
||||
struct Dummy;
|
||||
impl Transform for Dummy {
|
||||
type Output<'a> = ();
|
||||
}
|
||||
|
||||
pub fn main() {}
|
||||
21
tests/crashes/132103.rs
Normal file
21
tests/crashes/132103.rs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
//@ known-bug: #132103
|
||||
//@compile-flags: -Zvalidate-mir --edition=2018 -Zinline-mir=yes
|
||||
use core::future::{async_drop_in_place, Future};
|
||||
use core::mem::{self};
|
||||
use core::pin::pin;
|
||||
use core::task::{Context, Waker};
|
||||
|
||||
async fn test_async_drop<T>(x: T) {
|
||||
let mut x = mem::MaybeUninit::new(x);
|
||||
pin!(unsafe { async_drop_in_place(x.as_mut_ptr()) });
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let waker = Waker::noop();
|
||||
let mut cx = Context::from_waker(&waker);
|
||||
|
||||
let fut = pin!(async {
|
||||
test_async_drop(test_async_drop(0)).await;
|
||||
});
|
||||
fut.poll(&mut cx);
|
||||
}
|
||||
36
tests/crashes/132960.rs
Normal file
36
tests/crashes/132960.rs
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
//@ known-bug: #132960
|
||||
|
||||
#![feature(adt_const_params, const_ptr_read, generic_const_exprs)]
|
||||
|
||||
const fn concat_strs<const A: &'static str, const B: &'static str>() -> &'static str
|
||||
where
|
||||
[(); A.len()]:,
|
||||
[(); B.len()]:,
|
||||
[(); A.len() + B.len()]:,
|
||||
{
|
||||
#[repr(C)]
|
||||
#[repr(C)]
|
||||
|
||||
const fn concat_arr<const M: usize, const N: usize>(a: [u8; M], b: [u8; N]) -> [u8; M + N] {}
|
||||
|
||||
struct Inner<const A: &'static str, const B: &'static str>;
|
||||
impl<const A: &'static str, const B: &'static str> Inner<A, B>
|
||||
where
|
||||
[(); A.len()]:,
|
||||
[(); B.len()]:,
|
||||
[(); A.len() + B.len()]:,
|
||||
{
|
||||
const ABSTR: &'static str = unsafe {
|
||||
std::str::from_utf8_unchecked(&concat_arr(
|
||||
A.as_ptr().cast().read(),
|
||||
B.as_ptr().cast().read(),
|
||||
))
|
||||
};
|
||||
}
|
||||
|
||||
Inner::<A, B>::ABSTR
|
||||
}
|
||||
|
||||
const FOO: &str = "foo";
|
||||
const BAR: &str = "bar";
|
||||
const FOOBAR: &str = concat_strs::<FOO, BAR>();
|
||||
8
tests/crashes/133117.rs
Normal file
8
tests/crashes/133117.rs
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
//@ known-bug: #133117
|
||||
|
||||
fn main() {
|
||||
match () {
|
||||
(!|!) if true => {}
|
||||
(!|!) if true => {}
|
||||
}
|
||||
}
|
||||
43
tests/crashes/133252.rs
Normal file
43
tests/crashes/133252.rs
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
//@ known-bug: #133252
|
||||
//@ edition:2021
|
||||
use std::future::Future;
|
||||
|
||||
trait Owned: 'static {}
|
||||
fn ice() -> impl Future<Output = &'static dyn Owned> {
|
||||
async {
|
||||
let not_static = 0;
|
||||
force_send(async_load(¬_static));
|
||||
loop {}
|
||||
}
|
||||
}
|
||||
|
||||
fn force_send<T: Send>(_: T) {}
|
||||
|
||||
fn async_load<'a, T: LoadQuery<'a>>(this: T) -> impl Future {
|
||||
async {
|
||||
this.get_future().await;
|
||||
}
|
||||
}
|
||||
|
||||
trait LoadQuery<'a>: Sized {
|
||||
type LoadFuture: Future;
|
||||
|
||||
fn get_future(self) -> Self::LoadFuture {
|
||||
loop {}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> LoadQuery<'a> for &'a u8 {
|
||||
type LoadFuture = SimpleFuture;
|
||||
}
|
||||
|
||||
struct SimpleFuture;
|
||||
impl Future for SimpleFuture {
|
||||
type Output = ();
|
||||
fn poll(
|
||||
self: std::pin::Pin<&mut Self>,
|
||||
_: &mut std::task::Context<'_>,
|
||||
) -> std::task::Poll<Self::Output> {
|
||||
loop {}
|
||||
}
|
||||
}
|
||||
7
tests/crashes/133613.rs
Normal file
7
tests/crashes/133613.rs
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
//@ known-bug: #133613
|
||||
|
||||
struct Wrapper<'a>();
|
||||
|
||||
trait IntFactory {
|
||||
fn stream(&self) -> impl IntFactory<stream(..): IntFactory<stream(..): Send>>;
|
||||
}
|
||||
17
tests/crashes/134174.rs
Normal file
17
tests/crashes/134174.rs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
//@ known-bug: #134175
|
||||
//@compile-flags: -Zvalidate-mir -Zinline-mir=yes
|
||||
use std::vec::IntoIter;
|
||||
|
||||
pub(crate) trait Foo: Iterator<Item = <Self as Foo>::Key> {
|
||||
type Key;
|
||||
}
|
||||
|
||||
impl Foo for IntoIter<i16> {}
|
||||
|
||||
fn sum_foo<F: Foo<Key = i32>>(f: F) -> i32 {
|
||||
f.fold(0, |a, b| a + b)
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let x = sum_foo(vec![11, 10, 1].into_iter());
|
||||
}
|
||||
9
tests/crashes/134334.rs
Normal file
9
tests/crashes/134334.rs
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
//@ known-bug: #134334
|
||||
//@ only-x86_64
|
||||
|
||||
#[repr(simd)]
|
||||
struct A();
|
||||
|
||||
fn main() {
|
||||
std::arch::asm!("{}", in(xmm_reg) A());
|
||||
}
|
||||
12
tests/crashes/134335.rs
Normal file
12
tests/crashes/134335.rs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
//@ known-bug: #134335
|
||||
//@compile-flags: -Zunstable-options --edition=2024 --crate-type=lib
|
||||
pub async fn async_closure(x: &mut i32) {
|
||||
let c = async move || {
|
||||
*x += 1;
|
||||
};
|
||||
call_once(c).await;
|
||||
}
|
||||
|
||||
fn call_once<T>(f: impl FnOnce() -> T) -> T {
|
||||
f()
|
||||
}
|
||||
|
|
@ -1,3 +1,7 @@
|
|||
//@ ignore-windows-msvc
|
||||
// FIXME(#132111, #133432): this test is flaky on windows msvc, it sometimes fail but it sometimes
|
||||
// passes.
|
||||
|
||||
//@ build-pass
|
||||
// ignore-tidy-linelength
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ LL | cfg_macro::my_lib_macro!();
|
|||
|
|
||||
= help: expected names are: `clippy`, `debug_assertions`, `doc`, `doctest`, `feature`, `fmt_debug`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `rustfmt`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `ub_checks`, `unix`, and `windows`
|
||||
= note: using a cfg inside a macro will use the cfgs from the destination crate and not the ones from the defining crate
|
||||
= help: try refering to `cfg_macro::my_lib_macro` crate for guidance on how handle this unexpected cfg
|
||||
= help: try referring to `cfg_macro::my_lib_macro` crate for guidance on how handle this unexpected cfg
|
||||
= help: the macro `cfg_macro::my_lib_macro` may come from an old version of the `cfg_macro` crate, try updating your dependency with `cargo update -p cfg_macro`
|
||||
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
|
||||
= note: `#[warn(unexpected_cfgs)]` on by default
|
||||
|
|
@ -20,7 +20,7 @@ LL | cfg_macro::my_lib_macro_value!();
|
|||
|
|
||||
= note: expected values for `panic` are: `abort` and `unwind`
|
||||
= note: using a cfg inside a macro will use the cfgs from the destination crate and not the ones from the defining crate
|
||||
= help: try refering to `cfg_macro::my_lib_macro_value` crate for guidance on how handle this unexpected cfg
|
||||
= help: try referring to `cfg_macro::my_lib_macro_value` crate for guidance on how handle this unexpected cfg
|
||||
= help: the macro `cfg_macro::my_lib_macro_value` may come from an old version of the `cfg_macro` crate, try updating your dependency with `cargo update -p cfg_macro`
|
||||
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
|
||||
= note: this warning originates in the macro `cfg_macro::my_lib_macro_value` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
|
@ -33,7 +33,7 @@ LL | cfg_macro::my_lib_macro_feature!();
|
|||
|
|
||||
= note: no expected values for `feature`
|
||||
= note: using a cfg inside a macro will use the cfgs from the destination crate and not the ones from the defining crate
|
||||
= help: try refering to `cfg_macro::my_lib_macro_feature` crate for guidance on how handle this unexpected cfg
|
||||
= help: try referring to `cfg_macro::my_lib_macro_feature` crate for guidance on how handle this unexpected cfg
|
||||
= help: the macro `cfg_macro::my_lib_macro_feature` may come from an old version of the `cfg_macro` crate, try updating your dependency with `cargo update -p cfg_macro`
|
||||
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
|
||||
= note: this warning originates in the macro `cfg_macro::my_lib_macro_feature` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ LL | cfg_macro::my_lib_macro!();
|
|||
|
|
||||
= help: expected names are: `clippy`, `debug_assertions`, `doc`, `doctest`, `feature`, `fmt_debug`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `rustfmt`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `ub_checks`, `unix`, and `windows`
|
||||
= note: using a cfg inside a macro will use the cfgs from the destination crate and not the ones from the defining crate
|
||||
= help: try refering to `cfg_macro::my_lib_macro` crate for guidance on how handle this unexpected cfg
|
||||
= help: try referring to `cfg_macro::my_lib_macro` crate for guidance on how handle this unexpected cfg
|
||||
= help: to expect this configuration use `--check-cfg=cfg(my_lib_cfg)`
|
||||
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
|
||||
= note: `#[warn(unexpected_cfgs)]` on by default
|
||||
|
|
@ -20,7 +20,7 @@ LL | cfg_macro::my_lib_macro_value!();
|
|||
|
|
||||
= note: expected values for `panic` are: `abort` and `unwind`
|
||||
= note: using a cfg inside a macro will use the cfgs from the destination crate and not the ones from the defining crate
|
||||
= help: try refering to `cfg_macro::my_lib_macro_value` crate for guidance on how handle this unexpected cfg
|
||||
= help: try referring to `cfg_macro::my_lib_macro_value` crate for guidance on how handle this unexpected cfg
|
||||
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
|
||||
= note: this warning originates in the macro `cfg_macro::my_lib_macro_value` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
|
|
@ -33,7 +33,7 @@ LL | cfg_macro::my_lib_macro_feature!();
|
|||
= note: no expected values for `feature`
|
||||
= help: to expect this configuration use `--check-cfg=cfg(feature, values("UNEXPECTED_FEATURE"))`
|
||||
= note: using a cfg inside a macro will use the cfgs from the destination crate and not the ones from the defining crate
|
||||
= help: try refering to `cfg_macro::my_lib_macro_feature` crate for guidance on how handle this unexpected cfg
|
||||
= help: try referring to `cfg_macro::my_lib_macro_feature` crate for guidance on how handle this unexpected cfg
|
||||
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
|
||||
= note: this warning originates in the macro `cfg_macro::my_lib_macro_feature` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
|
|
|
|||
16
tests/ui/lint/fn-ptr-comparisons-134345.rs
Normal file
16
tests/ui/lint/fn-ptr-comparisons-134345.rs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
// This check veifies that we do not ICE when not showing a user type
|
||||
// in the suggestions/diagnostics.
|
||||
//
|
||||
// cf. https://github.com/rust-lang/rust/issues/134345
|
||||
//
|
||||
//@ check-pass
|
||||
|
||||
struct A;
|
||||
|
||||
fn fna(_a: A) {}
|
||||
|
||||
#[allow(unpredictable_function_pointer_comparisons)]
|
||||
fn main() {
|
||||
let fa: fn(A) = fna;
|
||||
let _ = fa == fna;
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
error: the `#[default]` attribute may only be used on unit enum variants or variants where every field has a default value
|
||||
--> $DIR/default-field-values-failures.rs:47:5
|
||||
--> $DIR/failures.rs:47:5
|
||||
|
|
||||
LL | Variant {}
|
||||
| ^^^^^^^
|
||||
|
|
@ -7,7 +7,7 @@ LL | Variant {}
|
|||
= help: consider a manual implementation of `Default`
|
||||
|
||||
error: generic parameters may not be used in const operations
|
||||
--> $DIR/default-field-values-failures.rs:22:23
|
||||
--> $DIR/failures.rs:22:23
|
||||
|
|
||||
LL | bat: i32 = <Qux<{ C }> as T>::K,
|
||||
| ^ cannot perform const operation using `C`
|
||||
|
|
@ -16,19 +16,19 @@ LL | bat: i32 = <Qux<{ C }> as T>::K,
|
|||
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions
|
||||
|
||||
error: default fields are not supported in tuple structs
|
||||
--> $DIR/default-field-values-failures.rs:26:22
|
||||
--> $DIR/failures.rs:26:22
|
||||
|
|
||||
LL | pub struct Rak(i32 = 42);
|
||||
| ^^ default fields are only supported on structs
|
||||
|
||||
error: generic `Self` types are currently not permitted in anonymous constants
|
||||
--> $DIR/default-field-values-failures.rs:20:14
|
||||
--> $DIR/failures.rs:20:14
|
||||
|
|
||||
LL | bar: S = Self::S,
|
||||
| ^^^^
|
||||
|
||||
error[E0277]: the trait bound `S: Default` is not satisfied
|
||||
--> $DIR/default-field-values-failures.rs:14:5
|
||||
--> $DIR/failures.rs:14:5
|
||||
|
|
||||
LL | #[derive(Debug, Default)]
|
||||
| ------- in this derive macro expansion
|
||||
|
|
@ -44,13 +44,13 @@ LL | pub struct S;
|
|||
|
|
||||
|
||||
error: missing mandatory field `bar`
|
||||
--> $DIR/default-field-values-failures.rs:53:21
|
||||
--> $DIR/failures.rs:53:21
|
||||
|
|
||||
LL | let _ = Bar { .. };
|
||||
| ^
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/default-field-values-failures.rs:57:17
|
||||
--> $DIR/failures.rs:57:17
|
||||
|
|
||||
LL | let _ = Rak(..);
|
||||
| --- ^^ expected `i32`, found `RangeFull`
|
||||
|
|
@ -58,29 +58,29 @@ LL | let _ = Rak(..);
|
|||
| arguments to this struct are incorrect
|
||||
|
|
||||
note: tuple struct defined here
|
||||
--> $DIR/default-field-values-failures.rs:26:12
|
||||
--> $DIR/failures.rs:26:12
|
||||
|
|
||||
LL | pub struct Rak(i32 = 42);
|
||||
| ^^^
|
||||
help: you might have meant to use `..` to skip providing a value for expected fields, but this is only supported on non-tuple struct literals; it is instead interpreted as a `std::ops::RangeFull` literal
|
||||
--> $DIR/default-field-values-failures.rs:57:17
|
||||
--> $DIR/failures.rs:57:17
|
||||
|
|
||||
LL | let _ = Rak(..);
|
||||
| ^^
|
||||
|
||||
error[E0061]: this struct takes 1 argument but 2 arguments were supplied
|
||||
--> $DIR/default-field-values-failures.rs:59:13
|
||||
--> $DIR/failures.rs:59:13
|
||||
|
|
||||
LL | let _ = Rak(0, ..);
|
||||
| ^^^ -- unexpected argument #2 of type `RangeFull`
|
||||
|
|
||||
help: you might have meant to use `..` to skip providing a value for expected fields, but this is only supported on non-tuple struct literals; it is instead interpreted as a `std::ops::RangeFull` literal
|
||||
--> $DIR/default-field-values-failures.rs:59:20
|
||||
--> $DIR/failures.rs:59:20
|
||||
|
|
||||
LL | let _ = Rak(0, ..);
|
||||
| ^^
|
||||
note: tuple struct defined here
|
||||
--> $DIR/default-field-values-failures.rs:26:12
|
||||
--> $DIR/failures.rs:26:12
|
||||
|
|
||||
LL | pub struct Rak(i32 = 42);
|
||||
| ^^^
|
||||
|
|
@ -91,18 +91,18 @@ LL + let _ = Rak(0);
|
|||
|
|
||||
|
||||
error[E0061]: this struct takes 1 argument but 2 arguments were supplied
|
||||
--> $DIR/default-field-values-failures.rs:61:13
|
||||
--> $DIR/failures.rs:61:13
|
||||
|
|
||||
LL | let _ = Rak(.., 0);
|
||||
| ^^^ -- unexpected argument #1 of type `RangeFull`
|
||||
|
|
||||
help: you might have meant to use `..` to skip providing a value for expected fields, but this is only supported on non-tuple struct literals; it is instead interpreted as a `std::ops::RangeFull` literal
|
||||
--> $DIR/default-field-values-failures.rs:61:17
|
||||
--> $DIR/failures.rs:61:17
|
||||
|
|
||||
LL | let _ = Rak(.., 0);
|
||||
| ^^
|
||||
note: tuple struct defined here
|
||||
--> $DIR/default-field-values-failures.rs:26:12
|
||||
--> $DIR/failures.rs:26:12
|
||||
|
|
||||
LL | pub struct Rak(i32 = 42);
|
||||
| ^^^
|
||||
|
|
@ -1,13 +1,13 @@
|
|||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/default-field-values-invalid-const.rs:5:19
|
||||
--> $DIR/invalid-const.rs:5:19
|
||||
|
|
||||
LL | pub bax: u8 = panic!("asdf"),
|
||||
| ^^^^^^^^^^^^^^ the evaluated program panicked at 'asdf', $DIR/default-field-values-invalid-const.rs:5:19
|
||||
| ^^^^^^^^^^^^^^ the evaluated program panicked at 'asdf', $DIR/invalid-const.rs:5:19
|
||||
|
|
||||
= note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error[E0080]: evaluation of `Baz::<C>::bat::{constant#0}` failed
|
||||
--> $DIR/default-field-values-invalid-const.rs:11:19
|
||||
--> $DIR/invalid-const.rs:11:19
|
||||
|
|
||||
LL | pub bat: u8 = 130 + 130,
|
||||
| ^^^^^^^^^ attempt to compute `130_u8 + 130_u8`, which would overflow
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
//@ check-pass
|
||||
|
||||
#![feature(default_field_values)]
|
||||
|
||||
struct Value<const VALUE: u8>;
|
||||
|
||||
impl<const VALUE: u8> Value<VALUE> {
|
||||
pub const VALUE: Self = Self;
|
||||
}
|
||||
|
||||
pub struct WithUse {
|
||||
_use: Value<{ 0 + 0 }> = Value::VALUE
|
||||
}
|
||||
|
||||
const _: WithUse = WithUse { .. };
|
||||
|
||||
fn main() {}
|
||||
Loading…
Add table
Add a link
Reference in a new issue