1
Fork 0

Auto merge of #127614 - matthiaskrgr:rollup-8geziwi, r=matthiaskrgr

Rollup of 8 pull requests

Successful merges:

 - #124599 (Suggest borrowing on fn argument that is `impl AsRef`)
 - #127572 (Don't mark `DEBUG_EVENT` struct as `repr(packed)`)
 - #127588 (core: Limit remaining f16 doctests to x86_64 linux)
 - #127591 (Make sure that labels are defined after the primary span in diagnostics)
 - #127598 (Allows `#[diagnostic::do_not_recommend]` to supress trait impls in suggestions as well)
 - #127599 (Rename `lazy_cell_consume` to `lazy_cell_into_inner`)
 - #127601 (check is_ident before parse_ident)
 - #127605 (Remove extern "wasm" ABI)

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2024-07-11 22:56:52 +00:00
commit 5e311f933d
45 changed files with 447 additions and 409 deletions

View file

@ -445,6 +445,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
} else { } else {
(None, &[][..], 0) (None, &[][..], 0)
}; };
let mut can_suggest_clone = true;
if let Some(def_id) = def_id if let Some(def_id) = def_id
&& let node = self.infcx.tcx.hir_node_by_def_id(def_id) && let node = self.infcx.tcx.hir_node_by_def_id(def_id)
&& let Some(fn_sig) = node.fn_sig() && let Some(fn_sig) = node.fn_sig()
@ -452,24 +453,73 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
&& let Some(pos) = args.iter().position(|arg| arg.hir_id == expr.hir_id) && let Some(pos) = args.iter().position(|arg| arg.hir_id == expr.hir_id)
&& let Some(arg) = fn_sig.decl.inputs.get(pos + offset) && let Some(arg) = fn_sig.decl.inputs.get(pos + offset)
{ {
let mut span: MultiSpan = arg.span.into(); let mut is_mut = false;
span.push_span_label( if let hir::TyKind::Path(hir::QPath::Resolved(None, path)) = arg.kind
arg.span, && let Res::Def(DefKind::TyParam, param_def_id) = path.res
"this parameter takes ownership of the value".to_string(), && self
); .infcx
let descr = match node.fn_kind() { .tcx
Some(hir::intravisit::FnKind::ItemFn(..)) | None => "function", .predicates_of(def_id)
Some(hir::intravisit::FnKind::Method(..)) => "method", .instantiate_identity(self.infcx.tcx)
Some(hir::intravisit::FnKind::Closure) => "closure", .predicates
}; .into_iter()
span.push_span_label(ident.span, format!("in this {descr}")); .any(|pred| {
err.span_note( if let ty::ClauseKind::Trait(predicate) = pred.kind().skip_binder()
span, && [
format!( self.infcx.tcx.get_diagnostic_item(sym::AsRef),
"consider changing this parameter type in {descr} `{ident}` to borrow \ self.infcx.tcx.get_diagnostic_item(sym::AsMut),
instead if owning the value isn't necessary", self.infcx.tcx.get_diagnostic_item(sym::Borrow),
), self.infcx.tcx.get_diagnostic_item(sym::BorrowMut),
); ]
.contains(&Some(predicate.def_id()))
&& let ty::Param(param) = predicate.self_ty().kind()
&& let generics = self.infcx.tcx.generics_of(def_id)
&& let param = generics.type_param(*param, self.infcx.tcx)
&& param.def_id == param_def_id
{
if [
self.infcx.tcx.get_diagnostic_item(sym::AsMut),
self.infcx.tcx.get_diagnostic_item(sym::BorrowMut),
]
.contains(&Some(predicate.def_id()))
{
is_mut = true;
}
true
} else {
false
}
})
{
// The type of the argument corresponding to the expression that got moved
// is a type parameter `T`, which is has a `T: AsRef` obligation.
err.span_suggestion_verbose(
expr.span.shrink_to_lo(),
"borrow the value to avoid moving it",
format!("&{}", if is_mut { "mut " } else { "" }),
Applicability::MachineApplicable,
);
can_suggest_clone = is_mut;
} else {
let mut span: MultiSpan = arg.span.into();
span.push_span_label(
arg.span,
"this parameter takes ownership of the value".to_string(),
);
let descr = match node.fn_kind() {
Some(hir::intravisit::FnKind::ItemFn(..)) | None => "function",
Some(hir::intravisit::FnKind::Method(..)) => "method",
Some(hir::intravisit::FnKind::Closure) => "closure",
};
span.push_span_label(ident.span, format!("in this {descr}"));
err.span_note(
span,
format!(
"consider changing this parameter type in {descr} `{ident}` to \
borrow instead if owning the value isn't necessary",
),
);
}
} }
let place = &self.move_data.move_paths[mpi].place; let place = &self.move_data.move_paths[mpi].place;
let ty = place.ty(self.body, self.infcx.tcx).ty; let ty = place.ty(self.body, self.infcx.tcx).ty;
@ -487,9 +537,10 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
ClosureKind::Coroutine(CoroutineKind::Desugared(_, CoroutineSource::Block)), ClosureKind::Coroutine(CoroutineKind::Desugared(_, CoroutineSource::Block)),
.. ..
} = move_spans } = move_spans
&& can_suggest_clone
{ {
self.suggest_cloning(err, ty, expr, None, Some(move_spans)); self.suggest_cloning(err, ty, expr, None, Some(move_spans));
} else if self.suggest_hoisting_call_outside_loop(err, expr) { } else if self.suggest_hoisting_call_outside_loop(err, expr) && can_suggest_clone {
// The place where the type moves would be misleading to suggest clone. // The place where the type moves would be misleading to suggest clone.
// #121466 // #121466
self.suggest_cloning(err, ty, expr, None, Some(move_spans)); self.suggest_cloning(err, ty, expr, None, Some(move_spans));

View file

@ -6,7 +6,6 @@ use rustc_middle::middle::codegen_fn_attrs::{CodegenFnAttrFlags, PatchableFuncti
use rustc_middle::ty::{self, TyCtxt}; use rustc_middle::ty::{self, TyCtxt};
use rustc_session::config::{FunctionReturn, OptLevel}; use rustc_session::config::{FunctionReturn, OptLevel};
use rustc_span::symbol::sym; use rustc_span::symbol::sym;
use rustc_target::spec::abi::Abi;
use rustc_target::spec::{FramePointer, SanitizerSet, StackProbeType, StackProtector}; use rustc_target::spec::{FramePointer, SanitizerSet, StackProbeType, StackProtector};
use smallvec::SmallVec; use smallvec::SmallVec;
@ -482,7 +481,7 @@ pub fn from_fn_attrs<'ll, 'tcx>(
return; return;
} }
let mut function_features = function_features let function_features = function_features
.iter() .iter()
.flat_map(|feat| { .flat_map(|feat| {
llvm_util::to_llvm_features(cx.tcx.sess, feat).into_iter().map(|f| format!("+{f}")) llvm_util::to_llvm_features(cx.tcx.sess, feat).into_iter().map(|f| format!("+{f}"))
@ -504,17 +503,6 @@ pub fn from_fn_attrs<'ll, 'tcx>(
let name = name.as_str(); let name = name.as_str();
to_add.push(llvm::CreateAttrStringValue(cx.llcx, "wasm-import-name", name)); to_add.push(llvm::CreateAttrStringValue(cx.llcx, "wasm-import-name", name));
} }
// The `"wasm"` abi on wasm targets automatically enables the
// `+multivalue` feature because the purpose of the wasm abi is to match
// the WebAssembly specification, which has this feature. This won't be
// needed when LLVM enables this `multivalue` feature by default.
if !cx.tcx.is_closure_like(instance.def_id()) {
let abi = cx.tcx.fn_sig(instance.def_id()).skip_binder().abi();
if abi == Abi::Wasm {
function_features.push("+multivalue".to_string());
}
}
} }
let global_features = cx.tcx.global_backend_features(()).iter().map(|s| s.as_str()); let global_features = cx.tcx.global_backend_features(()).iter().map(|s| s.as_str());

View file

@ -215,6 +215,9 @@ declare_features! (
/// Permits specifying whether a function should permit unwinding or abort on unwind. /// Permits specifying whether a function should permit unwinding or abort on unwind.
(removed, unwind_attributes, "1.56.0", Some(58760), Some("use the C-unwind ABI instead")), (removed, unwind_attributes, "1.56.0", Some(58760), Some("use the C-unwind ABI instead")),
(removed, visible_private_types, "1.0.0", None, None), (removed, visible_private_types, "1.0.0", None, None),
/// Allows `extern "wasm" fn`
(removed, wasm_abi, "CURRENT_RUSTC_VERSION", Some(83788),
Some("non-standard wasm ABI is no longer supported")),
// !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! // !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!!
// Features are listed in alphabetical order. Tidy will fail if you don't keep it this way. // Features are listed in alphabetical order. Tidy will fail if you don't keep it this way.
// !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! // !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!!

View file

@ -640,8 +640,6 @@ declare_features! (
(unstable, unsized_tuple_coercion, "1.20.0", Some(42877)), (unstable, unsized_tuple_coercion, "1.20.0", Some(42877)),
/// Allows using the `#[used(linker)]` (or `#[used(compiler)]`) attribute. /// Allows using the `#[used(linker)]` (or `#[used(compiler)]`) attribute.
(unstable, used_with_arg, "1.60.0", Some(93798)), (unstable, used_with_arg, "1.60.0", Some(93798)),
/// Allows `extern "wasm" fn`
(unstable, wasm_abi, "1.53.0", Some(83788)),
/// Allows `do yeet` expressions /// Allows `do yeet` expressions
(unstable, yeet_expr, "1.62.0", Some(96373)), (unstable, yeet_expr, "1.62.0", Some(96373)),
// !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! // !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!!

View file

@ -269,6 +269,7 @@ impl DiagnosticDeriveVariantBuilder {
let field_binding = &binding_info.binding; let field_binding = &binding_info.binding;
let inner_ty = FieldInnerTy::from_type(&field.ty); let inner_ty = FieldInnerTy::from_type(&field.ty);
let mut seen_label = false;
field field
.attrs .attrs
@ -280,6 +281,14 @@ impl DiagnosticDeriveVariantBuilder {
} }
let name = attr.path().segments.last().unwrap().ident.to_string(); let name = attr.path().segments.last().unwrap().ident.to_string();
if name == "primary_span" && seen_label {
span_err(attr.span().unwrap(), format!("`#[primary_span]` must be placed before labels, since it overwrites the span of the diagnostic")).emit();
}
if name == "label" {
seen_label = true;
}
let needs_clone = let needs_clone =
name == "primary_span" && matches!(inner_ty, FieldInnerTy::Vec(_)); name == "primary_span" && matches!(inner_ty, FieldInnerTy::Vec(_));
let (binding, needs_destructure) = if needs_clone { let (binding, needs_destructure) = if needs_clone {

View file

@ -1212,7 +1212,6 @@ pub fn fn_can_unwind(tcx: TyCtxt<'_>, fn_def_id: Option<DefId>, abi: SpecAbi) ->
| RiscvInterruptM | RiscvInterruptM
| RiscvInterruptS | RiscvInterruptS
| CCmseNonSecureCall | CCmseNonSecureCall
| Wasm
| Unadjusted => false, | Unadjusted => false,
Rust | RustCall | RustCold | RustIntrinsic => { Rust | RustCall | RustCold | RustIntrinsic => {
tcx.sess.panic_strategy() == PanicStrategy::Unwind tcx.sess.panic_strategy() == PanicStrategy::Unwind

View file

@ -387,8 +387,8 @@ impl<'a> Parser<'a> {
let span = if is_pub { self.prev_token.span.to(ident_span) } else { ident_span }; let span = if is_pub { self.prev_token.span.to(ident_span) } else { ident_span };
let insert_span = ident_span.shrink_to_lo(); let insert_span = ident_span.shrink_to_lo();
let ident = if (!is_const let ident = if self.token.is_ident()
|| self.look_ahead(1, |t| *t == token::OpenDelim(Delimiter::Parenthesis))) && (!is_const || self.look_ahead(1, |t| *t == token::OpenDelim(Delimiter::Parenthesis)))
&& self.look_ahead(1, |t| { && self.look_ahead(1, |t| {
[ [
token::Lt, token::Lt,

View file

@ -1089,8 +1089,8 @@ pub(crate) struct ToolWasAlreadyRegistered {
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(resolve_tool_only_accepts_identifiers)] #[diag(resolve_tool_only_accepts_identifiers)]
pub(crate) struct ToolOnlyAcceptsIdentifiers { pub(crate) struct ToolOnlyAcceptsIdentifiers {
#[label]
#[primary_span] #[primary_span]
#[label]
pub(crate) span: Span, pub(crate) span: Span,
pub(crate) tool: Symbol, pub(crate) tool: Symbol,
} }

View file

@ -466,7 +466,6 @@ impl RustcInternal for Abi {
Abi::AvrInterrupt => rustc_target::spec::abi::Abi::AvrInterrupt, Abi::AvrInterrupt => rustc_target::spec::abi::Abi::AvrInterrupt,
Abi::AvrNonBlockingInterrupt => rustc_target::spec::abi::Abi::AvrNonBlockingInterrupt, Abi::AvrNonBlockingInterrupt => rustc_target::spec::abi::Abi::AvrNonBlockingInterrupt,
Abi::CCmseNonSecureCall => rustc_target::spec::abi::Abi::CCmseNonSecureCall, Abi::CCmseNonSecureCall => rustc_target::spec::abi::Abi::CCmseNonSecureCall,
Abi::Wasm => rustc_target::spec::abi::Abi::Wasm,
Abi::System { unwind } => rustc_target::spec::abi::Abi::System { unwind }, Abi::System { unwind } => rustc_target::spec::abi::Abi::System { unwind },
Abi::RustIntrinsic => rustc_target::spec::abi::Abi::RustIntrinsic, Abi::RustIntrinsic => rustc_target::spec::abi::Abi::RustIntrinsic,
Abi::RustCall => rustc_target::spec::abi::Abi::RustCall, Abi::RustCall => rustc_target::spec::abi::Abi::RustCall,

View file

@ -909,7 +909,6 @@ impl<'tcx> Stable<'tcx> for rustc_target::spec::abi::Abi {
abi::Abi::AvrInterrupt => Abi::AvrInterrupt, abi::Abi::AvrInterrupt => Abi::AvrInterrupt,
abi::Abi::AvrNonBlockingInterrupt => Abi::AvrNonBlockingInterrupt, abi::Abi::AvrNonBlockingInterrupt => Abi::AvrNonBlockingInterrupt,
abi::Abi::CCmseNonSecureCall => Abi::CCmseNonSecureCall, abi::Abi::CCmseNonSecureCall => Abi::CCmseNonSecureCall,
abi::Abi::Wasm => Abi::Wasm,
abi::Abi::System { unwind } => Abi::System { unwind }, abi::Abi::System { unwind } => Abi::System { unwind },
abi::Abi::RustIntrinsic => Abi::RustIntrinsic, abi::Abi::RustIntrinsic => Abi::RustIntrinsic,
abi::Abi::RustCall => Abi::RustCall, abi::Abi::RustCall => Abi::RustCall,

View file

@ -1,6 +1,6 @@
use crate::abi::{self, Abi, Align, FieldsShape, Size}; use crate::abi::{self, Abi, Align, FieldsShape, Size};
use crate::abi::{HasDataLayout, TyAbiInterface, TyAndLayout}; use crate::abi::{HasDataLayout, TyAbiInterface, TyAndLayout};
use crate::spec::{self, HasTargetSpec, HasWasmCAbiOpt}; use crate::spec::{self, HasTargetSpec, HasWasmCAbiOpt, WasmCAbi};
use rustc_macros::HashStable_Generic; use rustc_macros::HashStable_Generic;
use rustc_span::Symbol; use rustc_span::Symbol;
use std::fmt; use std::fmt;
@ -854,7 +854,8 @@ impl<'a, Ty> FnAbi<'a, Ty> {
return Ok(()); return Ok(());
} }
match &cx.target_spec().arch[..] { let spec = cx.target_spec();
match &spec.arch[..] {
"x86" => { "x86" => {
let flavor = if let spec::abi::Abi::Fastcall { .. } let flavor = if let spec::abi::Abi::Fastcall { .. }
| spec::abi::Abi::Vectorcall { .. } = abi | spec::abi::Abi::Vectorcall { .. } = abi
@ -901,9 +902,7 @@ impl<'a, Ty> FnAbi<'a, Ty> {
"sparc" => sparc::compute_abi_info(cx, self), "sparc" => sparc::compute_abi_info(cx, self),
"sparc64" => sparc64::compute_abi_info(cx, self), "sparc64" => sparc64::compute_abi_info(cx, self),
"nvptx64" => { "nvptx64" => {
if cx.target_spec().adjust_abi(cx, abi, self.c_variadic) if cx.target_spec().adjust_abi(abi, self.c_variadic) == spec::abi::Abi::PtxKernel {
== spec::abi::Abi::PtxKernel
{
nvptx64::compute_ptx_kernel_abi_info(cx, self) nvptx64::compute_ptx_kernel_abi_info(cx, self)
} else { } else {
nvptx64::compute_abi_info(self) nvptx64::compute_abi_info(self)
@ -912,13 +911,14 @@ impl<'a, Ty> FnAbi<'a, Ty> {
"hexagon" => hexagon::compute_abi_info(self), "hexagon" => hexagon::compute_abi_info(self),
"xtensa" => xtensa::compute_abi_info(cx, self), "xtensa" => xtensa::compute_abi_info(cx, self),
"riscv32" | "riscv64" => riscv::compute_abi_info(cx, self), "riscv32" | "riscv64" => riscv::compute_abi_info(cx, self),
"wasm32" | "wasm64" => { "wasm32" => {
if cx.target_spec().adjust_abi(cx, abi, self.c_variadic) == spec::abi::Abi::Wasm { if spec.os == "unknown" && cx.wasm_c_abi_opt() == WasmCAbi::Legacy {
wasm::compute_wasm_abi_info(self) wasm::compute_wasm_abi_info(self)
} else { } else {
wasm::compute_c_abi_info(cx, self) wasm::compute_c_abi_info(cx, self)
} }
} }
"wasm64" => wasm::compute_c_abi_info(cx, self),
"bpf" => bpf::compute_abi_info(self), "bpf" => bpf::compute_abi_info(self),
arch => { arch => {
return Err(AdjustForForeignAbiError::Unsupported { return Err(AdjustForForeignAbiError::Unsupported {

View file

@ -48,7 +48,6 @@ pub enum Abi {
AvrInterrupt, AvrInterrupt,
AvrNonBlockingInterrupt, AvrNonBlockingInterrupt,
CCmseNonSecureCall, CCmseNonSecureCall,
Wasm,
System { System {
unwind: bool, unwind: bool,
}, },
@ -123,7 +122,6 @@ const AbiDatas: &[AbiData] = &[
AbiData { abi: Abi::AvrInterrupt, name: "avr-interrupt" }, AbiData { abi: Abi::AvrInterrupt, name: "avr-interrupt" },
AbiData { abi: Abi::AvrNonBlockingInterrupt, name: "avr-non-blocking-interrupt" }, AbiData { abi: Abi::AvrNonBlockingInterrupt, name: "avr-non-blocking-interrupt" },
AbiData { abi: Abi::CCmseNonSecureCall, name: "C-cmse-nonsecure-call" }, AbiData { abi: Abi::CCmseNonSecureCall, name: "C-cmse-nonsecure-call" },
AbiData { abi: Abi::Wasm, name: "wasm" },
AbiData { abi: Abi::System { unwind: false }, name: "system" }, AbiData { abi: Abi::System { unwind: false }, name: "system" },
AbiData { abi: Abi::System { unwind: true }, name: "system-unwind" }, AbiData { abi: Abi::System { unwind: true }, name: "system-unwind" },
AbiData { abi: Abi::RustIntrinsic, name: "rust-intrinsic" }, AbiData { abi: Abi::RustIntrinsic, name: "rust-intrinsic" },
@ -149,6 +147,9 @@ pub fn lookup(name: &str) -> Result<Abi, AbiUnsupported> {
"riscv-interrupt-u" => AbiUnsupported::Reason { "riscv-interrupt-u" => AbiUnsupported::Reason {
explain: "user-mode interrupt handlers have been removed from LLVM pending standardization, see: https://reviews.llvm.org/D149314", explain: "user-mode interrupt handlers have been removed from LLVM pending standardization, see: https://reviews.llvm.org/D149314",
}, },
"wasm" => AbiUnsupported::Reason {
explain: "non-standard wasm ABI is no longer supported",
},
_ => AbiUnsupported::Unrecognized, _ => AbiUnsupported::Unrecognized,
@ -241,10 +242,6 @@ pub fn is_stable(name: &str) -> Result<(), AbiDisabled> {
feature: sym::abi_c_cmse_nonsecure_call, feature: sym::abi_c_cmse_nonsecure_call,
explain: "C-cmse-nonsecure-call ABI is experimental and subject to change", explain: "C-cmse-nonsecure-call ABI is experimental and subject to change",
}), }),
"wasm" => Err(AbiDisabled::Unstable {
feature: sym::wasm_abi,
explain: "wasm ABI is experimental and subject to change",
}),
_ => Err(AbiDisabled::Unrecognized), _ => Err(AbiDisabled::Unrecognized),
} }
} }
@ -287,16 +284,15 @@ impl Abi {
AvrInterrupt => 23, AvrInterrupt => 23,
AvrNonBlockingInterrupt => 24, AvrNonBlockingInterrupt => 24,
CCmseNonSecureCall => 25, CCmseNonSecureCall => 25,
Wasm => 26,
// Cross-platform ABIs // Cross-platform ABIs
System { unwind: false } => 27, System { unwind: false } => 26,
System { unwind: true } => 28, System { unwind: true } => 27,
RustIntrinsic => 29, RustIntrinsic => 28,
RustCall => 30, RustCall => 29,
Unadjusted => 31, Unadjusted => 30,
RustCold => 32, RustCold => 31,
RiscvInterruptM => 33, RiscvInterruptM => 32,
RiscvInterruptS => 34, RiscvInterruptS => 33,
}; };
debug_assert!( debug_assert!(
AbiDatas AbiDatas

View file

@ -2608,22 +2608,8 @@ impl DerefMut for Target {
impl Target { impl Target {
/// Given a function ABI, turn it into the correct ABI for this target. /// Given a function ABI, turn it into the correct ABI for this target.
pub fn adjust_abi<C>(&self, cx: &C, abi: Abi, c_variadic: bool) -> Abi pub fn adjust_abi(&self, abi: Abi, c_variadic: bool) -> Abi {
where
C: HasWasmCAbiOpt,
{
match abi { match abi {
Abi::C { .. } => {
if self.arch == "wasm32"
&& self.os == "unknown"
&& cx.wasm_c_abi_opt() == WasmCAbi::Legacy
{
Abi::Wasm
} else {
abi
}
}
// On Windows, `extern "system"` behaves like msvc's `__stdcall`. // On Windows, `extern "system"` behaves like msvc's `__stdcall`.
// `__stdcall` only applies on x86 and on non-variadic functions: // `__stdcall` only applies on x86 and on non-variadic functions:
// https://learn.microsoft.com/en-us/cpp/cpp/stdcall?view=msvc-170 // https://learn.microsoft.com/en-us/cpp/cpp/stdcall?view=msvc-170
@ -2676,7 +2662,6 @@ impl Target {
Msp430Interrupt => self.arch == "msp430", Msp430Interrupt => self.arch == "msp430",
RiscvInterruptM | RiscvInterruptS => ["riscv32", "riscv64"].contains(&&self.arch[..]), RiscvInterruptM | RiscvInterruptS => ["riscv32", "riscv64"].contains(&&self.arch[..]),
AvrInterrupt | AvrNonBlockingInterrupt => self.arch == "avr", AvrInterrupt | AvrNonBlockingInterrupt => self.arch == "avr",
Wasm => ["wasm32", "wasm64"].contains(&&self.arch[..]),
Thiscall { .. } => self.arch == "x86", Thiscall { .. } => self.arch == "x86",
// On windows these fall-back to platform native calling convention (C) when the // On windows these fall-back to platform native calling convention (C) when the
// architecture is not supported. // architecture is not supported.

View file

@ -1776,6 +1776,19 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
true true
}; };
// we filter before checking if `impl_candidates` is empty
// to get the fallback solution if we filtered out any impls
let impl_candidates = impl_candidates
.into_iter()
.cloned()
.filter(|cand| {
!self.tcx.has_attrs_with_path(
cand.impl_def_id,
&[sym::diagnostic, sym::do_not_recommend],
)
})
.collect::<Vec<_>>();
let def_id = trait_ref.def_id(); let def_id = trait_ref.def_id();
if impl_candidates.is_empty() { if impl_candidates.is_empty() {
if self.tcx.trait_is_auto(def_id) if self.tcx.trait_is_auto(def_id)
@ -1788,6 +1801,12 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
let mut impl_candidates: Vec<_> = self let mut impl_candidates: Vec<_> = self
.tcx .tcx
.all_impls(def_id) .all_impls(def_id)
// ignore `do_not_recommend` items
.filter(|def_id| {
!self
.tcx
.has_attrs_with_path(*def_id, &[sym::diagnostic, sym::do_not_recommend])
})
// Ignore automatically derived impls and `!Trait` impls. // Ignore automatically derived impls and `!Trait` impls.
.filter_map(|def_id| self.tcx.impl_trait_header(def_id)) .filter_map(|def_id| self.tcx.impl_trait_header(def_id))
.filter_map(|header| { .filter_map(|header| {

View file

@ -324,7 +324,7 @@ fn fn_sig_for_fn_abi<'tcx>(
#[inline] #[inline]
fn conv_from_spec_abi(tcx: TyCtxt<'_>, abi: SpecAbi, c_variadic: bool) -> Conv { fn conv_from_spec_abi(tcx: TyCtxt<'_>, abi: SpecAbi, c_variadic: bool) -> Conv {
use rustc_target::spec::abi::Abi::*; use rustc_target::spec::abi::Abi::*;
match tcx.sess.target.adjust_abi(&tcx, abi, c_variadic) { match tcx.sess.target.adjust_abi(abi, c_variadic) {
RustIntrinsic | Rust | RustCall => Conv::Rust, RustIntrinsic | Rust | RustCall => Conv::Rust,
// This is intentionally not using `Conv::Cold`, as that has to preserve // This is intentionally not using `Conv::Cold`, as that has to preserve
@ -352,7 +352,6 @@ fn conv_from_spec_abi(tcx: TyCtxt<'_>, abi: SpecAbi, c_variadic: bool) -> Conv {
AvrNonBlockingInterrupt => Conv::AvrNonBlockingInterrupt, AvrNonBlockingInterrupt => Conv::AvrNonBlockingInterrupt,
RiscvInterruptM => Conv::RiscvInterrupt { kind: RiscvInterruptKind::Machine }, RiscvInterruptM => Conv::RiscvInterrupt { kind: RiscvInterruptKind::Machine },
RiscvInterruptS => Conv::RiscvInterrupt { kind: RiscvInterruptKind::Supervisor }, RiscvInterruptS => Conv::RiscvInterrupt { kind: RiscvInterruptKind::Supervisor },
Wasm => Conv::C,
// These API constants ought to be more specific... // These API constants ought to be more specific...
Cdecl { .. } => Conv::C, Cdecl { .. } => Conv::C,

View file

@ -1045,7 +1045,6 @@ pub enum Abi {
AvrInterrupt, AvrInterrupt,
AvrNonBlockingInterrupt, AvrNonBlockingInterrupt,
CCmseNonSecureCall, CCmseNonSecureCall,
Wasm,
System { unwind: bool }, System { unwind: bool },
RustIntrinsic, RustIntrinsic,
RustCall, RustCall,

View file

@ -184,6 +184,7 @@ pub trait Borrow<Borrowed: ?Sized> {
/// an underlying type by providing a mutable reference. See [`Borrow<T>`] /// an underlying type by providing a mutable reference. See [`Borrow<T>`]
/// for more information on borrowing as another type. /// for more information on borrowing as another type.
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
#[rustc_diagnostic_item = "BorrowMut"]
pub trait BorrowMut<Borrowed: ?Sized>: Borrow<Borrowed> { pub trait BorrowMut<Borrowed: ?Sized>: Borrow<Borrowed> {
/// Mutably borrows from an owned value. /// Mutably borrows from an owned value.
/// ///

View file

@ -67,7 +67,7 @@ impl<T, F: FnOnce() -> T> LazyCell<T, F> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// #![feature(lazy_cell_consume)] /// #![feature(lazy_cell_into_inner)]
/// ///
/// use std::cell::LazyCell; /// use std::cell::LazyCell;
/// ///
@ -78,7 +78,7 @@ impl<T, F: FnOnce() -> T> LazyCell<T, F> {
/// assert_eq!(&*lazy, "HELLO, WORLD!"); /// assert_eq!(&*lazy, "HELLO, WORLD!");
/// assert_eq!(LazyCell::into_inner(lazy).ok(), Some("HELLO, WORLD!".to_string())); /// assert_eq!(LazyCell::into_inner(lazy).ok(), Some("HELLO, WORLD!".to_string()));
/// ``` /// ```
#[unstable(feature = "lazy_cell_consume", issue = "125623")] #[unstable(feature = "lazy_cell_into_inner", issue = "125623")]
pub fn into_inner(this: Self) -> Result<T, F> { pub fn into_inner(this: Self) -> Result<T, F> {
match this.state.into_inner() { match this.state.into_inner() {
State::Init(data) => Ok(data), State::Init(data) => Ok(data),

View file

@ -353,12 +353,15 @@ impl f16 {
/// ///
/// ``` /// ```
/// #![feature(f16)] /// #![feature(f16)]
/// # // FIXME(f16_f128): LLVM crashes on s390x, llvm/llvm-project#50374
/// # #[cfg(all(target_arch = "x86_64", target_os = "linux"))] {
/// ///
/// let f = 7.0_f16; /// let f = 7.0_f16;
/// let g = -7.0_f16; /// let g = -7.0_f16;
/// ///
/// assert!(f.is_sign_positive()); /// assert!(f.is_sign_positive());
/// assert!(!g.is_sign_positive()); /// assert!(!g.is_sign_positive());
/// # }
/// ``` /// ```
#[inline] #[inline]
#[must_use] #[must_use]
@ -376,12 +379,15 @@ impl f16 {
/// ///
/// ``` /// ```
/// #![feature(f16)] /// #![feature(f16)]
/// # // FIXME(f16_f128): LLVM crashes on s390x, llvm/llvm-project#50374
/// # #[cfg(all(target_arch = "x86_64", target_os = "linux"))] {
/// ///
/// let f = 7.0_f16; /// let f = 7.0_f16;
/// let g = -7.0_f16; /// let g = -7.0_f16;
/// ///
/// assert!(!f.is_sign_negative()); /// assert!(!f.is_sign_negative());
/// assert!(g.is_sign_negative()); /// assert!(g.is_sign_negative());
/// # }
/// ``` /// ```
#[inline] #[inline]
#[must_use] #[must_use]
@ -694,9 +700,12 @@ impl f16 {
/// ///
/// ``` /// ```
/// #![feature(f16)] /// #![feature(f16)]
/// # // FIXME(f16_f128): LLVM crashes on s390x, llvm/llvm-project#50374
/// # #[cfg(all(target_arch = "x86_64", target_os = "linux"))] {
/// ///
/// let bytes = 12.5f16.to_be_bytes(); /// let bytes = 12.5f16.to_be_bytes();
/// assert_eq!(bytes, [0x4a, 0x40]); /// assert_eq!(bytes, [0x4a, 0x40]);
/// # }
/// ``` /// ```
#[inline] #[inline]
#[unstable(feature = "f16", issue = "116909")] #[unstable(feature = "f16", issue = "116909")]
@ -715,9 +724,12 @@ impl f16 {
/// ///
/// ``` /// ```
/// #![feature(f16)] /// #![feature(f16)]
/// # // FIXME(f16_f128): LLVM crashes on s390x, llvm/llvm-project#50374
/// # #[cfg(all(target_arch = "x86_64", target_os = "linux"))] {
/// ///
/// let bytes = 12.5f16.to_le_bytes(); /// let bytes = 12.5f16.to_le_bytes();
/// assert_eq!(bytes, [0x40, 0x4a]); /// assert_eq!(bytes, [0x40, 0x4a]);
/// # }
/// ``` /// ```
#[inline] #[inline]
#[unstable(feature = "f16", issue = "116909")] #[unstable(feature = "f16", issue = "116909")]
@ -742,6 +754,8 @@ impl f16 {
/// ///
/// ``` /// ```
/// #![feature(f16)] /// #![feature(f16)]
/// # // FIXME(f16_f128): LLVM crashes on s390x, llvm/llvm-project#50374
/// # #[cfg(all(target_arch = "x86_64", target_os = "linux"))] {
/// ///
/// let bytes = 12.5f16.to_ne_bytes(); /// let bytes = 12.5f16.to_ne_bytes();
/// assert_eq!( /// assert_eq!(
@ -752,6 +766,7 @@ impl f16 {
/// [0x40, 0x4a] /// [0x40, 0x4a]
/// } /// }
/// ); /// );
/// # }
/// ``` /// ```
#[inline] #[inline]
#[unstable(feature = "f16", issue = "116909")] #[unstable(feature = "f16", issue = "116909")]

View file

@ -386,7 +386,7 @@ fn test_interior_nul_in_env_value_is_error() {
fn test_creation_flags() { fn test_creation_flags() {
use crate::os::windows::process::CommandExt; use crate::os::windows::process::CommandExt;
use crate::sys::c::{BOOL, DWORD, INFINITE}; use crate::sys::c::{BOOL, DWORD, INFINITE};
#[repr(C, packed)] #[repr(C)]
struct DEBUG_EVENT { struct DEBUG_EVENT {
pub event_code: DWORD, pub event_code: DWORD,
pub process_id: DWORD, pub process_id: DWORD,

View file

@ -107,7 +107,7 @@ impl<T, F: FnOnce() -> T> LazyLock<T, F> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// #![feature(lazy_cell_consume)] /// #![feature(lazy_cell_into_inner)]
/// ///
/// use std::sync::LazyLock; /// use std::sync::LazyLock;
/// ///
@ -118,7 +118,7 @@ impl<T, F: FnOnce() -> T> LazyLock<T, F> {
/// assert_eq!(&*lazy, "HELLO, WORLD!"); /// assert_eq!(&*lazy, "HELLO, WORLD!");
/// assert_eq!(LazyLock::into_inner(lazy).ok(), Some("HELLO, WORLD!".to_string())); /// assert_eq!(LazyLock::into_inner(lazy).ok(), Some("HELLO, WORLD!".to_string()));
/// ``` /// ```
#[unstable(feature = "lazy_cell_consume", issue = "125623")] #[unstable(feature = "lazy_cell_into_inner", issue = "125623")]
pub fn into_inner(mut this: Self) -> Result<T, F> { pub fn into_inner(mut this: Self) -> Result<T, F> {
let state = this.once.state(); let state = this.once.state();
match state { match state {

View file

@ -1,87 +0,0 @@
#![crate_type = "cdylib"]
#![deny(warnings)]
#![feature(wasm_abi)]
#[repr(C)]
#[derive(PartialEq, Debug)]
pub struct TwoI32 {
pub a: i32,
pub b: i32,
}
#[no_mangle]
pub extern "wasm" fn return_two_i32() -> TwoI32 {
TwoI32 { a: 1, b: 2 }
}
#[repr(C)]
#[derive(PartialEq, Debug)]
pub struct TwoI64 {
pub a: i64,
pub b: i64,
}
#[no_mangle]
pub extern "wasm" fn return_two_i64() -> TwoI64 {
TwoI64 { a: 3, b: 4 }
}
#[repr(C)]
#[derive(PartialEq, Debug)]
pub struct TwoF32 {
pub a: f32,
pub b: f32,
}
#[no_mangle]
pub extern "wasm" fn return_two_f32() -> TwoF32 {
TwoF32 { a: 5., b: 6. }
}
#[repr(C)]
#[derive(PartialEq, Debug)]
pub struct TwoF64 {
pub a: f64,
pub b: f64,
}
#[no_mangle]
pub extern "wasm" fn return_two_f64() -> TwoF64 {
TwoF64 { a: 7., b: 8. }
}
#[repr(C)]
#[derive(PartialEq, Debug)]
pub struct Mishmash {
pub a: f64,
pub b: f32,
pub c: i32,
pub d: i64,
pub e: TwoI32,
}
#[no_mangle]
pub extern "wasm" fn return_mishmash() -> Mishmash {
Mishmash { a: 9., b: 10., c: 11, d: 12, e: TwoI32 { a: 13, b: 14 } }
}
#[link(wasm_import_module = "host")]
extern "wasm" {
fn two_i32() -> TwoI32;
fn two_i64() -> TwoI64;
fn two_f32() -> TwoF32;
fn two_f64() -> TwoF64;
fn mishmash() -> Mishmash;
}
#[no_mangle]
pub unsafe extern "C" fn call_imports() {
assert_eq!(two_i32(), TwoI32 { a: 100, b: 101 });
assert_eq!(two_i64(), TwoI64 { a: 102, b: 103 });
assert_eq!(two_f32(), TwoF32 { a: 104., b: 105. });
assert_eq!(two_f64(), TwoF64 { a: 106., b: 107. });
assert_eq!(
mishmash(),
Mishmash { a: 108., b: 109., c: 110, d: 111, e: TwoI32 { a: 112, b: 113 } }
);
}

View file

@ -1,22 +0,0 @@
(module
(func (export "two_i32") (result i32 i32)
i32.const 100
i32.const 101)
(func (export "two_i64") (result i64 i64)
i64.const 102
i64.const 103)
(func (export "two_f32") (result f32 f32)
f32.const 104
f32.const 105)
(func (export "two_f64") (result f64 f64)
f64.const 106
f64.const 107)
(func (export "mishmash") (result f64 f32 i32 i64 i32 i32)
f64.const 108
f32.const 109
i32.const 110
i64.const 111
i32.const 112
i32.const 113)
)

View file

@ -1,29 +0,0 @@
//@ only-wasm32-wasip1
//@ needs-wasmtime
use run_make_support::{cmd, rustc};
use std::path::Path;
fn main() {
rustc().input("foo.rs").target("wasm32-wasip1").run();
let file = Path::new("foo.wasm");
run(&file, "return_two_i32", "1\n2\n");
run(&file, "return_two_i64", "3\n4\n");
run(&file, "return_two_f32", "5\n6\n");
run(&file, "return_two_f64", "7\n8\n");
run(&file, "return_mishmash", "9\n10\n11\n12\n13\n14\n");
run(&file, "call_imports", "");
}
fn run(file: &Path, method: &str, expected_output: &str) {
cmd("wasmtime")
.arg("run")
.arg("--preload=host=host.wat")
.arg("--invoke")
.arg(method)
.arg(file)
.run()
.assert_stdout_equals(expected_output);
}

View file

@ -0,0 +1,4 @@
extern "wasm" fn test() {}
//~^ ERROR invalid ABI: found `wasm`
fn main() {}

View file

@ -0,0 +1,12 @@
error[E0703]: invalid ABI: found `wasm`
--> $DIR/removed-wasm-abi.rs:1:8
|
LL | extern "wasm" fn test() {}
| ^^^^^^ invalid ABI
|
= note: invoke `rustc --print=calling-conventions` for a full list of supported calling conventions
= note: non-standard wasm ABI is no longer supported
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0703`.

View file

@ -1,53 +1,47 @@
error[E0570]: `"ptx-kernel"` is not a supported ABI for the current target error[E0570]: `"ptx-kernel"` is not a supported ABI for the current target
--> $DIR/unsupported.rs:29:1 --> $DIR/unsupported.rs:28:1
| |
LL | extern "ptx-kernel" fn ptx() {} LL | extern "ptx-kernel" fn ptx() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"wasm"` is not a supported ABI for the current target
--> $DIR/unsupported.rs:31:1
|
LL | extern "wasm" fn wasm() {}
| ^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"aapcs"` is not a supported ABI for the current target error[E0570]: `"aapcs"` is not a supported ABI for the current target
--> $DIR/unsupported.rs:33:1 --> $DIR/unsupported.rs:30:1
| |
LL | extern "aapcs" fn aapcs() {} LL | extern "aapcs" fn aapcs() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target
--> $DIR/unsupported.rs:39:1 --> $DIR/unsupported.rs:36:1
| |
LL | extern "msp430-interrupt" fn msp430() {} LL | extern "msp430-interrupt" fn msp430() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target
--> $DIR/unsupported.rs:41:1 --> $DIR/unsupported.rs:38:1
| |
LL | extern "avr-interrupt" fn avr() {} LL | extern "avr-interrupt" fn avr() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"riscv-interrupt-m"` is not a supported ABI for the current target error[E0570]: `"riscv-interrupt-m"` is not a supported ABI for the current target
--> $DIR/unsupported.rs:43:1 --> $DIR/unsupported.rs:40:1
| |
LL | extern "riscv-interrupt-m" fn riscv() {} LL | extern "riscv-interrupt-m" fn riscv() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"x86-interrupt"` is not a supported ABI for the current target error[E0570]: `"x86-interrupt"` is not a supported ABI for the current target
--> $DIR/unsupported.rs:48:1 --> $DIR/unsupported.rs:45:1
| |
LL | extern "x86-interrupt" fn x86() {} LL | extern "x86-interrupt" fn x86() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"thiscall"` is not a supported ABI for the current target error[E0570]: `"thiscall"` is not a supported ABI for the current target
--> $DIR/unsupported.rs:53:1 --> $DIR/unsupported.rs:50:1
| |
LL | extern "thiscall" fn thiscall() {} LL | extern "thiscall" fn thiscall() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: use of calling convention not supported on this target warning: use of calling convention not supported on this target
--> $DIR/unsupported.rs:59:1 --> $DIR/unsupported.rs:56:1
| |
LL | extern "stdcall" fn stdcall() {} LL | extern "stdcall" fn stdcall() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -56,6 +50,6 @@ LL | extern "stdcall" fn stdcall() {}
= note: for more information, see issue #87678 <https://github.com/rust-lang/rust/issues/87678> = note: for more information, see issue #87678 <https://github.com/rust-lang/rust/issues/87678>
= note: `#[warn(unsupported_calling_conventions)]` on by default = note: `#[warn(unsupported_calling_conventions)]` on by default
error: aborting due to 8 previous errors; 1 warning emitted error: aborting due to 7 previous errors; 1 warning emitted
For more information about this error, try `rustc --explain E0570`. For more information about this error, try `rustc --explain E0570`.

View file

@ -1,47 +1,41 @@
error[E0570]: `"ptx-kernel"` is not a supported ABI for the current target error[E0570]: `"ptx-kernel"` is not a supported ABI for the current target
--> $DIR/unsupported.rs:29:1 --> $DIR/unsupported.rs:28:1
| |
LL | extern "ptx-kernel" fn ptx() {} LL | extern "ptx-kernel" fn ptx() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"wasm"` is not a supported ABI for the current target
--> $DIR/unsupported.rs:31:1
|
LL | extern "wasm" fn wasm() {}
| ^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target
--> $DIR/unsupported.rs:39:1 --> $DIR/unsupported.rs:36:1
| |
LL | extern "msp430-interrupt" fn msp430() {} LL | extern "msp430-interrupt" fn msp430() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target
--> $DIR/unsupported.rs:41:1 --> $DIR/unsupported.rs:38:1
| |
LL | extern "avr-interrupt" fn avr() {} LL | extern "avr-interrupt" fn avr() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"riscv-interrupt-m"` is not a supported ABI for the current target error[E0570]: `"riscv-interrupt-m"` is not a supported ABI for the current target
--> $DIR/unsupported.rs:43:1 --> $DIR/unsupported.rs:40:1
| |
LL | extern "riscv-interrupt-m" fn riscv() {} LL | extern "riscv-interrupt-m" fn riscv() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"x86-interrupt"` is not a supported ABI for the current target error[E0570]: `"x86-interrupt"` is not a supported ABI for the current target
--> $DIR/unsupported.rs:48:1 --> $DIR/unsupported.rs:45:1
| |
LL | extern "x86-interrupt" fn x86() {} LL | extern "x86-interrupt" fn x86() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"thiscall"` is not a supported ABI for the current target error[E0570]: `"thiscall"` is not a supported ABI for the current target
--> $DIR/unsupported.rs:53:1 --> $DIR/unsupported.rs:50:1
| |
LL | extern "thiscall" fn thiscall() {} LL | extern "thiscall" fn thiscall() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: use of calling convention not supported on this target warning: use of calling convention not supported on this target
--> $DIR/unsupported.rs:59:1 --> $DIR/unsupported.rs:56:1
| |
LL | extern "stdcall" fn stdcall() {} LL | extern "stdcall" fn stdcall() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -50,6 +44,6 @@ LL | extern "stdcall" fn stdcall() {}
= note: for more information, see issue #87678 <https://github.com/rust-lang/rust/issues/87678> = note: for more information, see issue #87678 <https://github.com/rust-lang/rust/issues/87678>
= note: `#[warn(unsupported_calling_conventions)]` on by default = note: `#[warn(unsupported_calling_conventions)]` on by default
error: aborting due to 7 previous errors; 1 warning emitted error: aborting due to 6 previous errors; 1 warning emitted
For more information about this error, try `rustc --explain E0570`. For more information about this error, try `rustc --explain E0570`.

View file

@ -1,39 +1,33 @@
error[E0570]: `"ptx-kernel"` is not a supported ABI for the current target error[E0570]: `"ptx-kernel"` is not a supported ABI for the current target
--> $DIR/unsupported.rs:29:1 --> $DIR/unsupported.rs:28:1
| |
LL | extern "ptx-kernel" fn ptx() {} LL | extern "ptx-kernel" fn ptx() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"wasm"` is not a supported ABI for the current target
--> $DIR/unsupported.rs:31:1
|
LL | extern "wasm" fn wasm() {}
| ^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"aapcs"` is not a supported ABI for the current target error[E0570]: `"aapcs"` is not a supported ABI for the current target
--> $DIR/unsupported.rs:33:1 --> $DIR/unsupported.rs:30:1
| |
LL | extern "aapcs" fn aapcs() {} LL | extern "aapcs" fn aapcs() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target
--> $DIR/unsupported.rs:39:1 --> $DIR/unsupported.rs:36:1
| |
LL | extern "msp430-interrupt" fn msp430() {} LL | extern "msp430-interrupt" fn msp430() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target
--> $DIR/unsupported.rs:41:1 --> $DIR/unsupported.rs:38:1
| |
LL | extern "avr-interrupt" fn avr() {} LL | extern "avr-interrupt" fn avr() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"riscv-interrupt-m"` is not a supported ABI for the current target error[E0570]: `"riscv-interrupt-m"` is not a supported ABI for the current target
--> $DIR/unsupported.rs:43:1 --> $DIR/unsupported.rs:40:1
| |
LL | extern "riscv-interrupt-m" fn riscv() {} LL | extern "riscv-interrupt-m" fn riscv() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 6 previous errors error: aborting due to 5 previous errors
For more information about this error, try `rustc --explain E0570`. For more information about this error, try `rustc --explain E0570`.

View file

@ -1,47 +1,41 @@
error[E0570]: `"ptx-kernel"` is not a supported ABI for the current target error[E0570]: `"ptx-kernel"` is not a supported ABI for the current target
--> $DIR/unsupported.rs:29:1 --> $DIR/unsupported.rs:28:1
| |
LL | extern "ptx-kernel" fn ptx() {} LL | extern "ptx-kernel" fn ptx() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"wasm"` is not a supported ABI for the current target
--> $DIR/unsupported.rs:31:1
|
LL | extern "wasm" fn wasm() {}
| ^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"aapcs"` is not a supported ABI for the current target error[E0570]: `"aapcs"` is not a supported ABI for the current target
--> $DIR/unsupported.rs:33:1 --> $DIR/unsupported.rs:30:1
| |
LL | extern "aapcs" fn aapcs() {} LL | extern "aapcs" fn aapcs() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target
--> $DIR/unsupported.rs:39:1 --> $DIR/unsupported.rs:36:1
| |
LL | extern "msp430-interrupt" fn msp430() {} LL | extern "msp430-interrupt" fn msp430() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target
--> $DIR/unsupported.rs:41:1 --> $DIR/unsupported.rs:38:1
| |
LL | extern "avr-interrupt" fn avr() {} LL | extern "avr-interrupt" fn avr() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"x86-interrupt"` is not a supported ABI for the current target error[E0570]: `"x86-interrupt"` is not a supported ABI for the current target
--> $DIR/unsupported.rs:48:1 --> $DIR/unsupported.rs:45:1
| |
LL | extern "x86-interrupt" fn x86() {} LL | extern "x86-interrupt" fn x86() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"thiscall"` is not a supported ABI for the current target error[E0570]: `"thiscall"` is not a supported ABI for the current target
--> $DIR/unsupported.rs:53:1 --> $DIR/unsupported.rs:50:1
| |
LL | extern "thiscall" fn thiscall() {} LL | extern "thiscall" fn thiscall() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: use of calling convention not supported on this target warning: use of calling convention not supported on this target
--> $DIR/unsupported.rs:59:1 --> $DIR/unsupported.rs:56:1
| |
LL | extern "stdcall" fn stdcall() {} LL | extern "stdcall" fn stdcall() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -50,6 +44,6 @@ LL | extern "stdcall" fn stdcall() {}
= note: for more information, see issue #87678 <https://github.com/rust-lang/rust/issues/87678> = note: for more information, see issue #87678 <https://github.com/rust-lang/rust/issues/87678>
= note: `#[warn(unsupported_calling_conventions)]` on by default = note: `#[warn(unsupported_calling_conventions)]` on by default
error: aborting due to 7 previous errors; 1 warning emitted error: aborting due to 6 previous errors; 1 warning emitted
For more information about this error, try `rustc --explain E0570`. For more information about this error, try `rustc --explain E0570`.

View file

@ -1,47 +1,41 @@
error[E0570]: `"ptx-kernel"` is not a supported ABI for the current target error[E0570]: `"ptx-kernel"` is not a supported ABI for the current target
--> $DIR/unsupported.rs:29:1 --> $DIR/unsupported.rs:28:1
| |
LL | extern "ptx-kernel" fn ptx() {} LL | extern "ptx-kernel" fn ptx() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"wasm"` is not a supported ABI for the current target
--> $DIR/unsupported.rs:31:1
|
LL | extern "wasm" fn wasm() {}
| ^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"aapcs"` is not a supported ABI for the current target error[E0570]: `"aapcs"` is not a supported ABI for the current target
--> $DIR/unsupported.rs:33:1 --> $DIR/unsupported.rs:30:1
| |
LL | extern "aapcs" fn aapcs() {} LL | extern "aapcs" fn aapcs() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target
--> $DIR/unsupported.rs:39:1 --> $DIR/unsupported.rs:36:1
| |
LL | extern "msp430-interrupt" fn msp430() {} LL | extern "msp430-interrupt" fn msp430() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target
--> $DIR/unsupported.rs:41:1 --> $DIR/unsupported.rs:38:1
| |
LL | extern "avr-interrupt" fn avr() {} LL | extern "avr-interrupt" fn avr() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"x86-interrupt"` is not a supported ABI for the current target error[E0570]: `"x86-interrupt"` is not a supported ABI for the current target
--> $DIR/unsupported.rs:48:1 --> $DIR/unsupported.rs:45:1
| |
LL | extern "x86-interrupt" fn x86() {} LL | extern "x86-interrupt" fn x86() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"thiscall"` is not a supported ABI for the current target error[E0570]: `"thiscall"` is not a supported ABI for the current target
--> $DIR/unsupported.rs:53:1 --> $DIR/unsupported.rs:50:1
| |
LL | extern "thiscall" fn thiscall() {} LL | extern "thiscall" fn thiscall() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: use of calling convention not supported on this target warning: use of calling convention not supported on this target
--> $DIR/unsupported.rs:59:1 --> $DIR/unsupported.rs:56:1
| |
LL | extern "stdcall" fn stdcall() {} LL | extern "stdcall" fn stdcall() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -50,6 +44,6 @@ LL | extern "stdcall" fn stdcall() {}
= note: for more information, see issue #87678 <https://github.com/rust-lang/rust/issues/87678> = note: for more information, see issue #87678 <https://github.com/rust-lang/rust/issues/87678>
= note: `#[warn(unsupported_calling_conventions)]` on by default = note: `#[warn(unsupported_calling_conventions)]` on by default
error: aborting due to 7 previous errors; 1 warning emitted error: aborting due to 6 previous errors; 1 warning emitted
For more information about this error, try `rustc --explain E0570`. For more information about this error, try `rustc --explain E0570`.

View file

@ -19,7 +19,6 @@
abi_ptx, abi_ptx,
abi_msp430_interrupt, abi_msp430_interrupt,
abi_avr_interrupt, abi_avr_interrupt,
wasm_abi,
abi_x86_interrupt, abi_x86_interrupt,
abi_riscv_interrupt abi_riscv_interrupt
)] )]
@ -28,8 +27,6 @@ trait Sized {}
extern "ptx-kernel" fn ptx() {} extern "ptx-kernel" fn ptx() {}
//~^ ERROR is not a supported ABI //~^ ERROR is not a supported ABI
extern "wasm" fn wasm() {}
//~^ ERROR is not a supported ABI
extern "aapcs" fn aapcs() {} extern "aapcs" fn aapcs() {}
//[x64]~^ ERROR is not a supported ABI //[x64]~^ ERROR is not a supported ABI
//[i686]~^^ ERROR is not a supported ABI //[i686]~^^ ERROR is not a supported ABI

View file

@ -1,47 +1,41 @@
error[E0570]: `"ptx-kernel"` is not a supported ABI for the current target error[E0570]: `"ptx-kernel"` is not a supported ABI for the current target
--> $DIR/unsupported.rs:29:1 --> $DIR/unsupported.rs:28:1
| |
LL | extern "ptx-kernel" fn ptx() {} LL | extern "ptx-kernel" fn ptx() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"wasm"` is not a supported ABI for the current target
--> $DIR/unsupported.rs:31:1
|
LL | extern "wasm" fn wasm() {}
| ^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"aapcs"` is not a supported ABI for the current target error[E0570]: `"aapcs"` is not a supported ABI for the current target
--> $DIR/unsupported.rs:33:1 --> $DIR/unsupported.rs:30:1
| |
LL | extern "aapcs" fn aapcs() {} LL | extern "aapcs" fn aapcs() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target
--> $DIR/unsupported.rs:39:1 --> $DIR/unsupported.rs:36:1
| |
LL | extern "msp430-interrupt" fn msp430() {} LL | extern "msp430-interrupt" fn msp430() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target
--> $DIR/unsupported.rs:41:1 --> $DIR/unsupported.rs:38:1
| |
LL | extern "avr-interrupt" fn avr() {} LL | extern "avr-interrupt" fn avr() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"riscv-interrupt-m"` is not a supported ABI for the current target error[E0570]: `"riscv-interrupt-m"` is not a supported ABI for the current target
--> $DIR/unsupported.rs:43:1 --> $DIR/unsupported.rs:40:1
| |
LL | extern "riscv-interrupt-m" fn riscv() {} LL | extern "riscv-interrupt-m" fn riscv() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"thiscall"` is not a supported ABI for the current target error[E0570]: `"thiscall"` is not a supported ABI for the current target
--> $DIR/unsupported.rs:53:1 --> $DIR/unsupported.rs:50:1
| |
LL | extern "thiscall" fn thiscall() {} LL | extern "thiscall" fn thiscall() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: use of calling convention not supported on this target warning: use of calling convention not supported on this target
--> $DIR/unsupported.rs:59:1 --> $DIR/unsupported.rs:56:1
| |
LL | extern "stdcall" fn stdcall() {} LL | extern "stdcall" fn stdcall() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -50,6 +44,6 @@ LL | extern "stdcall" fn stdcall() {}
= note: for more information, see issue #87678 <https://github.com/rust-lang/rust/issues/87678> = note: for more information, see issue #87678 <https://github.com/rust-lang/rust/issues/87678>
= note: `#[warn(unsupported_calling_conventions)]` on by default = note: `#[warn(unsupported_calling_conventions)]` on by default
error: aborting due to 7 previous errors; 1 warning emitted error: aborting due to 6 previous errors; 1 warning emitted
For more information about this error, try `rustc --explain E0570`. For more information about this error, try `rustc --explain E0570`.

View file

@ -0,0 +1,18 @@
error[E0277]: the trait bound `(): Foo` is not satisfied
--> $DIR/supress_suggestions_in_help.rs:23:11
|
LL | check(());
| ----- ^^ the trait `Foo` is not implemented for `()`
| |
| required by a bound introduced by this call
|
= help: the trait `Foo` is implemented for `i32`
note: required by a bound in `check`
--> $DIR/supress_suggestions_in_help.rs:20:18
|
LL | fn check(a: impl Foo) {}
| ^^^ required by this bound in `check`
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0277`.

View file

@ -0,0 +1,18 @@
error[E0277]: the trait bound `(): Foo` is not satisfied
--> $DIR/supress_suggestions_in_help.rs:23:11
|
LL | check(());
| ----- ^^ the trait `Foo` is not implemented for `()`
| |
| required by a bound introduced by this call
|
= help: the trait `Foo` is implemented for `i32`
note: required by a bound in `check`
--> $DIR/supress_suggestions_in_help.rs:20:18
|
LL | fn check(a: impl Foo) {}
| ^^^ required by this bound in `check`
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0277`.

View file

@ -0,0 +1,25 @@
//@ revisions: current next
//@ ignore-compare-mode-next-solver (explicit revisions)
//@[next] compile-flags: -Znext-solver
#![feature(do_not_recommend)]
trait Foo {}
#[diagnostic::do_not_recommend]
impl<A> Foo for (A,) {}
#[diagnostic::do_not_recommend]
impl<A, B> Foo for (A, B) {}
#[diagnostic::do_not_recommend]
impl<A, B, C> Foo for (A, B, C) {}
impl Foo for i32 {}
fn check(a: impl Foo) {}
fn main() {
check(());
//~^ ERROR the trait bound `(): Foo` is not satisfied
}

View file

@ -1,26 +0,0 @@
//@ needs-llvm-components: webassembly
//@ compile-flags: --target=wasm32-unknown-unknown --crate-type=rlib
#![no_core]
#![feature(no_core, lang_items)]
#[lang="sized"]
trait Sized { }
extern "wasm" fn fu() {} //~ ERROR wasm ABI is experimental
trait T {
extern "wasm" fn mu(); //~ ERROR wasm ABI is experimental
extern "wasm" fn dmu() {} //~ ERROR wasm ABI is experimental
}
struct S;
impl T for S {
extern "wasm" fn mu() {} //~ ERROR wasm ABI is experimental
}
impl S {
extern "wasm" fn imu() {} //~ ERROR wasm ABI is experimental
}
type TAU = extern "wasm" fn(); //~ ERROR wasm ABI is experimental
extern "wasm" {} //~ ERROR wasm ABI is experimental

View file

@ -1,73 +0,0 @@
error[E0658]: wasm ABI is experimental and subject to change
--> $DIR/feature-gate-wasm_abi.rs:8:8
|
LL | extern "wasm" fn fu() {}
| ^^^^^^
|
= note: see issue #83788 <https://github.com/rust-lang/rust/issues/83788> for more information
= help: add `#![feature(wasm_abi)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0658]: wasm ABI is experimental and subject to change
--> $DIR/feature-gate-wasm_abi.rs:11:12
|
LL | extern "wasm" fn mu();
| ^^^^^^
|
= note: see issue #83788 <https://github.com/rust-lang/rust/issues/83788> for more information
= help: add `#![feature(wasm_abi)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0658]: wasm ABI is experimental and subject to change
--> $DIR/feature-gate-wasm_abi.rs:12:12
|
LL | extern "wasm" fn dmu() {}
| ^^^^^^
|
= note: see issue #83788 <https://github.com/rust-lang/rust/issues/83788> for more information
= help: add `#![feature(wasm_abi)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0658]: wasm ABI is experimental and subject to change
--> $DIR/feature-gate-wasm_abi.rs:17:12
|
LL | extern "wasm" fn mu() {}
| ^^^^^^
|
= note: see issue #83788 <https://github.com/rust-lang/rust/issues/83788> for more information
= help: add `#![feature(wasm_abi)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0658]: wasm ABI is experimental and subject to change
--> $DIR/feature-gate-wasm_abi.rs:21:12
|
LL | extern "wasm" fn imu() {}
| ^^^^^^
|
= note: see issue #83788 <https://github.com/rust-lang/rust/issues/83788> for more information
= help: add `#![feature(wasm_abi)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0658]: wasm ABI is experimental and subject to change
--> $DIR/feature-gate-wasm_abi.rs:24:19
|
LL | type TAU = extern "wasm" fn();
| ^^^^^^
|
= note: see issue #83788 <https://github.com/rust-lang/rust/issues/83788> for more information
= help: add `#![feature(wasm_abi)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0658]: wasm ABI is experimental and subject to change
--> $DIR/feature-gate-wasm_abi.rs:26:8
|
LL | extern "wasm" {}
| ^^^^^^
|
= note: see issue #83788 <https://github.com/rust-lang/rust/issues/83788> for more information
= help: add `#![feature(wasm_abi)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error: aborting due to 7 previous errors
For more information about this error, try `rustc --explain E0658`.

View file

@ -0,0 +1,37 @@
//@ run-rustfix
#![allow(unused_mut)]
use std::borrow::{Borrow, BorrowMut};
use std::convert::{AsMut, AsRef};
struct Bar;
impl AsRef<Bar> for Bar {
fn as_ref(&self) -> &Bar {
self
}
}
impl AsMut<Bar> for Bar {
fn as_mut(&mut self) -> &mut Bar {
self
}
}
fn foo<T: AsRef<Bar>>(_: T) {}
fn qux<T: AsMut<Bar>>(_: T) {}
fn bat<T: Borrow<T>>(_: T) {}
fn baz<T: BorrowMut<T>>(_: T) {}
pub fn main() {
let bar = Bar;
foo(&bar);
let _baa = bar; //~ ERROR use of moved value
let mut bar = Bar;
qux(&mut bar);
let _baa = bar; //~ ERROR use of moved value
let bar = Bar;
bat(&bar);
let _baa = bar; //~ ERROR use of moved value
let mut bar = Bar;
baz(&mut bar);
let _baa = bar; //~ ERROR use of moved value
}

View file

@ -0,0 +1,37 @@
//@ run-rustfix
#![allow(unused_mut)]
use std::borrow::{Borrow, BorrowMut};
use std::convert::{AsMut, AsRef};
struct Bar;
impl AsRef<Bar> for Bar {
fn as_ref(&self) -> &Bar {
self
}
}
impl AsMut<Bar> for Bar {
fn as_mut(&mut self) -> &mut Bar {
self
}
}
fn foo<T: AsRef<Bar>>(_: T) {}
fn qux<T: AsMut<Bar>>(_: T) {}
fn bat<T: Borrow<T>>(_: T) {}
fn baz<T: BorrowMut<T>>(_: T) {}
pub fn main() {
let bar = Bar;
foo(bar);
let _baa = bar; //~ ERROR use of moved value
let mut bar = Bar;
qux(bar);
let _baa = bar; //~ ERROR use of moved value
let bar = Bar;
bat(bar);
let _baa = bar; //~ ERROR use of moved value
let mut bar = Bar;
baz(bar);
let _baa = bar; //~ ERROR use of moved value
}

View file

@ -0,0 +1,79 @@
error[E0382]: use of moved value: `bar`
--> $DIR/moved-value-on-as-ref-arg.rs:27:16
|
LL | let bar = Bar;
| --- move occurs because `bar` has type `Bar`, which does not implement the `Copy` trait
LL | foo(bar);
| --- value moved here
LL | let _baa = bar;
| ^^^ value used here after move
|
help: borrow the value to avoid moving it
|
LL | foo(&bar);
| +
error[E0382]: use of moved value: `bar`
--> $DIR/moved-value-on-as-ref-arg.rs:30:16
|
LL | let mut bar = Bar;
| ------- move occurs because `bar` has type `Bar`, which does not implement the `Copy` trait
LL | qux(bar);
| --- value moved here
LL | let _baa = bar;
| ^^^ value used here after move
|
note: if `Bar` implemented `Clone`, you could clone the value
--> $DIR/moved-value-on-as-ref-arg.rs:5:1
|
LL | struct Bar;
| ^^^^^^^^^^ consider implementing `Clone` for this type
...
LL | qux(bar);
| --- you could clone this value
help: borrow the value to avoid moving it
|
LL | qux(&mut bar);
| ++++
error[E0382]: use of moved value: `bar`
--> $DIR/moved-value-on-as-ref-arg.rs:33:16
|
LL | let bar = Bar;
| --- move occurs because `bar` has type `Bar`, which does not implement the `Copy` trait
LL | bat(bar);
| --- value moved here
LL | let _baa = bar;
| ^^^ value used here after move
|
help: borrow the value to avoid moving it
|
LL | bat(&bar);
| +
error[E0382]: use of moved value: `bar`
--> $DIR/moved-value-on-as-ref-arg.rs:36:16
|
LL | let mut bar = Bar;
| ------- move occurs because `bar` has type `Bar`, which does not implement the `Copy` trait
LL | baz(bar);
| --- value moved here
LL | let _baa = bar;
| ^^^ value used here after move
|
note: if `Bar` implemented `Clone`, you could clone the value
--> $DIR/moved-value-on-as-ref-arg.rs:5:1
|
LL | struct Bar;
| ^^^^^^^^^^ consider implementing `Clone` for this type
...
LL | baz(bar);
| --- you could clone this value
help: borrow the value to avoid moving it
|
LL | baz(&mut bar);
| ++++
error: aborting due to 4 previous errors
For more information about this error, try `rustc --explain E0382`.

View file

@ -0,0 +1,2 @@
const!(&raw mut a);
//~^ ERROR expected identifier, found `!`

View file

@ -0,0 +1,8 @@
error: expected identifier, found `!`
--> $DIR/ice-issue-127600.rs:1:6
|
LL | const!(&raw mut a);
| ^ expected identifier
error: aborting due to 1 previous error

View file

@ -0,0 +1,6 @@
#![feature(register_tool)]
#![register_tool(1)]
//~^ ERROR `register_tool` only accepts identifiers
fn main() {}

View file

@ -0,0 +1,8 @@
error: `register_tool` only accepts identifiers
--> $DIR/invalid-tool.rs:3:18
|
LL | #![register_tool(1)]
| ^ not an identifier
error: aborting due to 1 previous error