mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-23 13:13:17 +00:00
Automatically taint InferCtxt when errors are emitted
This commit is contained in:
parent
5988078aa2
commit
86c8eae774
@ -360,7 +360,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'_, '_, 'cx, 'tcx> {
|
||||
let named_key = self.regioncx.name_regions(self.infcx.tcx, key);
|
||||
let named_region = self.regioncx.name_regions(self.infcx.tcx, member_region);
|
||||
let diag = unexpected_hidden_region_diagnostic(
|
||||
self.infcx.tcx,
|
||||
self.infcx,
|
||||
self.mir_def_id(),
|
||||
span,
|
||||
named_ty,
|
||||
|
@ -285,7 +285,7 @@ impl<'tcx> InferCtxt<'tcx> {
|
||||
}
|
||||
|
||||
if let Err(guar) =
|
||||
check_opaque_type_parameter_valid(self.tcx, opaque_type_key, instantiated_ty.span)
|
||||
check_opaque_type_parameter_valid(self, opaque_type_key, instantiated_ty.span)
|
||||
{
|
||||
return Ty::new_error(self.tcx, guar);
|
||||
}
|
||||
@ -294,6 +294,10 @@ impl<'tcx> InferCtxt<'tcx> {
|
||||
.remap_generic_params_to_declaration_params(opaque_type_key, self.tcx, false)
|
||||
.ty;
|
||||
|
||||
if let Err(e) = definition_ty.error_reported() {
|
||||
return Ty::new_error(self.tcx, e);
|
||||
}
|
||||
|
||||
// `definition_ty` does not live in of the current inference context,
|
||||
// so lets make sure that we don't accidentally misuse our current `infcx`.
|
||||
match check_opaque_type_well_formed(
|
||||
@ -387,10 +391,11 @@ fn check_opaque_type_well_formed<'tcx>(
|
||||
/// [rustc-dev-guide chapter]:
|
||||
/// https://rustc-dev-guide.rust-lang.org/opaque-types-region-infer-restrictions.html
|
||||
fn check_opaque_type_parameter_valid<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
infcx: &InferCtxt<'tcx>,
|
||||
opaque_type_key: OpaqueTypeKey<'tcx>,
|
||||
span: Span,
|
||||
) -> Result<(), ErrorGuaranteed> {
|
||||
let tcx = infcx.tcx;
|
||||
let opaque_generics = tcx.generics_of(opaque_type_key.def_id);
|
||||
let opaque_env = LazyOpaqueTyEnv::new(tcx, opaque_type_key.def_id);
|
||||
let mut seen_params: FxIndexMap<_, Vec<_>> = FxIndexMap::default();
|
||||
@ -420,7 +425,7 @@ fn check_opaque_type_parameter_valid<'tcx>(
|
||||
|
||||
opaque_env.param_is_error(i)?;
|
||||
|
||||
return Err(tcx.dcx().emit_err(NonGenericOpaqueTypeParam {
|
||||
return Err(infcx.dcx().emit_err(NonGenericOpaqueTypeParam {
|
||||
ty: arg,
|
||||
kind,
|
||||
span,
|
||||
@ -438,7 +443,7 @@ fn check_opaque_type_parameter_valid<'tcx>(
|
||||
.collect();
|
||||
#[allow(rustc::diagnostic_outside_of_impl)]
|
||||
#[allow(rustc::untranslatable_diagnostic)]
|
||||
return Err(tcx
|
||||
return Err(infcx
|
||||
.dcx()
|
||||
.struct_span_err(span, "non-defining opaque type use in defining scope")
|
||||
.with_span_note(spans, format!("{descr} used multiple times"))
|
||||
|
@ -510,7 +510,7 @@ pub struct Diag<'a, G: EmissionGuarantee = ErrorGuaranteed> {
|
||||
// would be bad.
|
||||
impl<G> !Clone for Diag<'_, G> {}
|
||||
|
||||
rustc_data_structures::static_assert_size!(Diag<'_, ()>, 2 * std::mem::size_of::<usize>());
|
||||
rustc_data_structures::static_assert_size!(Diag<'_, ()>, 3 * std::mem::size_of::<usize>());
|
||||
|
||||
impl<G: EmissionGuarantee> Deref for Diag<'_, G> {
|
||||
type Target = DiagInner;
|
||||
|
@ -63,6 +63,7 @@ use rustc_span::source_map::SourceMap;
|
||||
use rustc_span::{Loc, Span, DUMMY_SP};
|
||||
use std::backtrace::{Backtrace, BacktraceStatus};
|
||||
use std::borrow::Cow;
|
||||
use std::cell::Cell;
|
||||
use std::error::Report;
|
||||
use std::fmt;
|
||||
use std::hash::Hash;
|
||||
@ -98,9 +99,9 @@ rustc_fluent_macro::fluent_messages! { "../messages.ftl" }
|
||||
|
||||
// `PResult` is used a lot. Make sure it doesn't unintentionally get bigger.
|
||||
#[cfg(target_pointer_width = "64")]
|
||||
rustc_data_structures::static_assert_size!(PResult<'_, ()>, 16);
|
||||
rustc_data_structures::static_assert_size!(PResult<'_, ()>, 24);
|
||||
#[cfg(target_pointer_width = "64")]
|
||||
rustc_data_structures::static_assert_size!(PResult<'_, bool>, 16);
|
||||
rustc_data_structures::static_assert_size!(PResult<'_, bool>, 24);
|
||||
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash, Encodable, Decodable)]
|
||||
pub enum SuggestionStyle {
|
||||
@ -417,6 +418,7 @@ pub struct DiagCtxt {
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct DiagCtxtHandle<'a> {
|
||||
dcx: &'a DiagCtxt,
|
||||
tainted_with_errors: Option<&'a Cell<Option<ErrorGuaranteed>>>,
|
||||
}
|
||||
|
||||
impl<'a> std::ops::Deref for DiagCtxtHandle<'a> {
|
||||
@ -752,7 +754,14 @@ impl DiagCtxt {
|
||||
}
|
||||
|
||||
pub fn handle<'a>(&'a self) -> DiagCtxtHandle<'a> {
|
||||
DiagCtxtHandle { dcx: self }
|
||||
DiagCtxtHandle { dcx: self, tainted_with_errors: None }
|
||||
}
|
||||
|
||||
pub fn taintable_handle<'a>(
|
||||
&'a self,
|
||||
tainted_with_errors: &'a Cell<Option<ErrorGuaranteed>>,
|
||||
) -> DiagCtxtHandle<'a> {
|
||||
DiagCtxtHandle { dcx: self, tainted_with_errors: Some(tainted_with_errors) }
|
||||
}
|
||||
}
|
||||
|
||||
@ -795,7 +804,9 @@ impl<'a> DiagCtxtHandle<'a> {
|
||||
// can be used to create a backtrace at the stashing site insted of whenever the
|
||||
// diagnostic context is dropped and thus delayed bugs are emitted.
|
||||
Error => Some(self.span_delayed_bug(span, format!("stashing {key:?}"))),
|
||||
DelayedBug => return self.inner.borrow_mut().emit_diagnostic(diag),
|
||||
DelayedBug => {
|
||||
return self.inner.borrow_mut().emit_diagnostic(diag, self.tainted_with_errors);
|
||||
}
|
||||
ForceWarning(_) | Warning | Note | OnceNote | Help | OnceHelp | FailureNote | Allow
|
||||
| Expect(_) => None,
|
||||
};
|
||||
@ -947,16 +958,19 @@ impl<'a> DiagCtxtHandle<'a> {
|
||||
(0, _) => {
|
||||
// Use `ForceWarning` rather than `Warning` to guarantee emission, e.g. with a
|
||||
// configuration like `--cap-lints allow --force-warn bare_trait_objects`.
|
||||
inner.emit_diagnostic(DiagInner::new(
|
||||
ForceWarning(None),
|
||||
DiagMessage::Str(warnings),
|
||||
));
|
||||
inner.emit_diagnostic(
|
||||
DiagInner::new(ForceWarning(None), DiagMessage::Str(warnings)),
|
||||
None,
|
||||
);
|
||||
}
|
||||
(_, 0) => {
|
||||
inner.emit_diagnostic(DiagInner::new(Error, errors));
|
||||
inner.emit_diagnostic(DiagInner::new(Error, errors), self.tainted_with_errors);
|
||||
}
|
||||
(_, _) => {
|
||||
inner.emit_diagnostic(DiagInner::new(Error, format!("{errors}; {warnings}")));
|
||||
inner.emit_diagnostic(
|
||||
DiagInner::new(Error, format!("{errors}; {warnings}")),
|
||||
self.tainted_with_errors,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -987,14 +1001,14 @@ impl<'a> DiagCtxtHandle<'a> {
|
||||
"For more information about an error, try `rustc --explain {}`.",
|
||||
&error_codes[0]
|
||||
);
|
||||
inner.emit_diagnostic(DiagInner::new(FailureNote, msg1));
|
||||
inner.emit_diagnostic(DiagInner::new(FailureNote, msg2));
|
||||
inner.emit_diagnostic(DiagInner::new(FailureNote, msg1), None);
|
||||
inner.emit_diagnostic(DiagInner::new(FailureNote, msg2), None);
|
||||
} else {
|
||||
let msg = format!(
|
||||
"For more information about this error, try `rustc --explain {}`.",
|
||||
&error_codes[0]
|
||||
);
|
||||
inner.emit_diagnostic(DiagInner::new(FailureNote, msg));
|
||||
inner.emit_diagnostic(DiagInner::new(FailureNote, msg), None);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1020,7 +1034,7 @@ impl<'a> DiagCtxtHandle<'a> {
|
||||
}
|
||||
|
||||
pub fn emit_diagnostic(&self, diagnostic: DiagInner) -> Option<ErrorGuaranteed> {
|
||||
self.inner.borrow_mut().emit_diagnostic(diagnostic)
|
||||
self.inner.borrow_mut().emit_diagnostic(diagnostic, self.tainted_with_errors)
|
||||
}
|
||||
|
||||
pub fn emit_artifact_notification(&self, path: &Path, artifact_type: &str) {
|
||||
@ -1080,7 +1094,7 @@ impl<'a> DiagCtxtHandle<'a> {
|
||||
// Here the diagnostic is given back to `emit_diagnostic` where it was first
|
||||
// intercepted. Now it should be processed as usual, since the unstable expectation
|
||||
// id is now stable.
|
||||
inner.emit_diagnostic(diag);
|
||||
inner.emit_diagnostic(diag, self.tainted_with_errors);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1430,13 +1444,17 @@ impl DiagCtxtInner {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
guar = guar.or(self.emit_diagnostic(diag));
|
||||
guar = guar.or(self.emit_diagnostic(diag, None));
|
||||
}
|
||||
guar
|
||||
}
|
||||
|
||||
// Return value is only `Some` if the level is `Error` or `DelayedBug`.
|
||||
fn emit_diagnostic(&mut self, mut diagnostic: DiagInner) -> Option<ErrorGuaranteed> {
|
||||
fn emit_diagnostic(
|
||||
&mut self,
|
||||
mut diagnostic: DiagInner,
|
||||
taint: Option<&Cell<Option<ErrorGuaranteed>>>,
|
||||
) -> Option<ErrorGuaranteed> {
|
||||
match diagnostic.level {
|
||||
Expect(expect_id) | ForceWarning(Some(expect_id)) => {
|
||||
// The `LintExpectationId` can be stable or unstable depending on when it was
|
||||
@ -1609,6 +1627,9 @@ impl DiagCtxtInner {
|
||||
if is_lint {
|
||||
self.lint_err_guars.push(guar);
|
||||
} else {
|
||||
if let Some(taint) = taint {
|
||||
taint.set(Some(guar));
|
||||
}
|
||||
self.err_guars.push(guar);
|
||||
}
|
||||
self.panic_if_treat_err_as_bug();
|
||||
@ -1718,8 +1739,8 @@ impl DiagCtxtInner {
|
||||
// `-Ztreat-err-as-bug`, which we don't want.
|
||||
let note1 = "no errors encountered even though delayed bugs were created";
|
||||
let note2 = "those delayed bugs will now be shown as internal compiler errors";
|
||||
self.emit_diagnostic(DiagInner::new(Note, note1));
|
||||
self.emit_diagnostic(DiagInner::new(Note, note2));
|
||||
self.emit_diagnostic(DiagInner::new(Note, note1), None);
|
||||
self.emit_diagnostic(DiagInner::new(Note, note2), None);
|
||||
|
||||
for bug in bugs {
|
||||
if let Some(out) = &mut out {
|
||||
@ -1752,7 +1773,7 @@ impl DiagCtxtInner {
|
||||
}
|
||||
bug.level = Bug;
|
||||
|
||||
self.emit_diagnostic(bug);
|
||||
self.emit_diagnostic(bug, None);
|
||||
}
|
||||
|
||||
// Panic with `DelayedBugPanic` to avoid "unexpected panic" messages.
|
||||
|
@ -319,7 +319,7 @@ impl<'a, 'tcx> CastCheck<'tcx> {
|
||||
} else {
|
||||
errors::CannotCastToBoolHelp::Unsupported(self.span)
|
||||
};
|
||||
fcx.tcx.dcx().emit_err(errors::CannotCastToBool { span: self.span, expr_ty, help });
|
||||
fcx.dcx().emit_err(errors::CannotCastToBool { span: self.span, expr_ty, help });
|
||||
}
|
||||
CastError::CastToChar => {
|
||||
let mut err = type_error_struct!(
|
||||
|
@ -638,7 +638,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
// Set expectation to error in that case and set tainted
|
||||
// by error (#114529)
|
||||
let coerce_to = opt_coerce_to.unwrap_or_else(|| {
|
||||
let guar = tcx.dcx().span_delayed_bug(
|
||||
let guar = self.dcx().span_delayed_bug(
|
||||
expr.span,
|
||||
"illegal break with value found but no error reported",
|
||||
);
|
||||
@ -1716,7 +1716,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
} else {
|
||||
error_happened = true;
|
||||
let guar = if let Some(prev_span) = seen_fields.get(&ident) {
|
||||
tcx.dcx().emit_err(FieldMultiplySpecifiedInInitializer {
|
||||
self.dcx().emit_err(FieldMultiplySpecifiedInInitializer {
|
||||
span: field.ident.span,
|
||||
prev_span: *prev_span,
|
||||
ident,
|
||||
@ -1757,7 +1757,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
if adt_kind == AdtKind::Union {
|
||||
if hir_fields.len() != 1 {
|
||||
struct_span_code_err!(
|
||||
tcx.dcx(),
|
||||
self.dcx(),
|
||||
span,
|
||||
E0784,
|
||||
"union expressions should have exactly one field",
|
||||
|
@ -170,7 +170,7 @@ impl<'tcx> TypeInformationCtxt<'tcx> for &FnCtxt<'_, 'tcx> {
|
||||
}
|
||||
|
||||
fn report_error(&self, span: Span, msg: impl ToString) -> Self::Error {
|
||||
self.tcx.dcx().span_delayed_bug(span, msg.to_string())
|
||||
self.dcx().span_delayed_bug(span, msg.to_string())
|
||||
}
|
||||
|
||||
fn error_reported_in_ty(&self, ty: Ty<'tcx>) -> Result<(), Self::Error> {
|
||||
|
@ -1182,7 +1182,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
name: self.tcx.item_name(def.did()).to_ident_string(),
|
||||
});
|
||||
if ty.raw.has_param() {
|
||||
let guar = self.tcx.dcx().emit_err(errors::SelfCtorFromOuterItem {
|
||||
let guar = self.dcx().emit_err(errors::SelfCtorFromOuterItem {
|
||||
span: path_span,
|
||||
impl_span: tcx.def_span(impl_def_id),
|
||||
sugg,
|
||||
@ -1207,7 +1207,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
// Check the visibility of the ctor.
|
||||
let vis = tcx.visibility(ctor_def_id);
|
||||
if !vis.is_accessible_from(tcx.parent_module(hir_id).to_def_id(), tcx) {
|
||||
tcx.dcx()
|
||||
self.dcx()
|
||||
.emit_err(CtorIsPrivate { span, def: tcx.def_path_str(adt_def.did()) });
|
||||
}
|
||||
let new_res = Res::Def(DefKind::Ctor(CtorOf::Struct, ctor_kind), ctor_def_id);
|
||||
@ -1216,7 +1216,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
(new_res, Some(user_args.args))
|
||||
}
|
||||
_ => {
|
||||
let mut err = tcx.dcx().struct_span_err(
|
||||
let mut err = self.dcx().struct_span_err(
|
||||
span,
|
||||
"the `Self` constructor can only be used with tuple or unit structs",
|
||||
);
|
||||
|
@ -238,7 +238,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
// Otherwise, there's a mismatch, so clear out what we're expecting, and set
|
||||
// our input types to err_args so we don't blow up the error messages
|
||||
let guar = struct_span_code_err!(
|
||||
tcx.dcx(),
|
||||
self.dcx(),
|
||||
call_span,
|
||||
E0059,
|
||||
"cannot use call notation; the first type parameter \
|
||||
@ -453,7 +453,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
.map(|vars| self.resolve_vars_if_possible(vars)),
|
||||
);
|
||||
|
||||
self.set_tainted_by_errors(self.report_arg_errors(
|
||||
self.report_arg_errors(
|
||||
compatibility_diagonal,
|
||||
formal_and_expected_inputs,
|
||||
provided_args,
|
||||
@ -462,7 +462,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
fn_def_id,
|
||||
call_span,
|
||||
call_expr,
|
||||
));
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -788,7 +788,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
format!("arguments to this {call_name} are incorrect"),
|
||||
);
|
||||
} else {
|
||||
err = tcx.dcx().struct_span_err(
|
||||
err = self.dcx().struct_span_err(
|
||||
full_call_span,
|
||||
format!(
|
||||
"{call_name} takes {}{} but {} {} supplied",
|
||||
@ -848,7 +848,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
span_bug!(error_span, "expected errors from argument matrix");
|
||||
} else {
|
||||
let mut err =
|
||||
tcx.dcx().create_err(errors::ArgMismatchIndeterminate { span: error_span });
|
||||
self.dcx().create_err(errors::ArgMismatchIndeterminate { span: error_span });
|
||||
suggest_confusable(&mut err);
|
||||
return err.emit();
|
||||
}
|
||||
@ -953,14 +953,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
|
||||
let mut err = if formal_and_expected_inputs.len() == provided_args.len() {
|
||||
struct_span_code_err!(
|
||||
tcx.dcx(),
|
||||
self.dcx(),
|
||||
full_call_span,
|
||||
E0308,
|
||||
"arguments to this {} are incorrect",
|
||||
call_name,
|
||||
)
|
||||
} else {
|
||||
tcx.dcx()
|
||||
self.dcx()
|
||||
.struct_span_err(
|
||||
full_call_span,
|
||||
format!(
|
||||
|
@ -52,7 +52,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
// Note: this path is currently not reached in any test, so any
|
||||
// example that triggers this would be worth minimizing and
|
||||
// converting into a test.
|
||||
tcx.dcx().span_bug(span, "argument to transmute has inference variables");
|
||||
self.dcx().span_bug(span, "argument to transmute has inference variables");
|
||||
}
|
||||
// Transmutes that are only changing lifetimes are always ok.
|
||||
if from == to {
|
||||
@ -76,7 +76,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
if let (&ty::FnDef(..), SizeSkeleton::Known(size_to, _)) = (from.kind(), sk_to)
|
||||
&& size_to == Pointer(dl.instruction_address_space).size(&tcx)
|
||||
{
|
||||
struct_span_code_err!(tcx.dcx(), span, E0591, "can't transmute zero-sized type")
|
||||
struct_span_code_err!(self.dcx(), span, E0591, "can't transmute zero-sized type")
|
||||
.with_note(format!("source type: {from}"))
|
||||
.with_note(format!("target type: {to}"))
|
||||
.with_help("cast with `as` to a pointer instead")
|
||||
@ -116,7 +116,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
};
|
||||
|
||||
let mut err = struct_span_code_err!(
|
||||
tcx.dcx(),
|
||||
self.dcx(),
|
||||
span,
|
||||
E0512,
|
||||
"cannot transmute between types of different sizes, \
|
||||
|
@ -705,7 +705,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
let mut err = if is_write && let SelfSource::MethodCall(rcvr_expr) = source {
|
||||
self.suggest_missing_writer(rcvr_ty, rcvr_expr)
|
||||
} else {
|
||||
let mut err = tcx.dcx().create_err(NoAssociatedItem {
|
||||
let mut err = self.dcx().create_err(NoAssociatedItem {
|
||||
span,
|
||||
item_kind,
|
||||
item_name,
|
||||
@ -1194,7 +1194,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
span: item_span,
|
||||
..
|
||||
})) => {
|
||||
tcx.dcx().span_delayed_bug(
|
||||
self.dcx().span_delayed_bug(
|
||||
*item_span,
|
||||
"auto trait is invoked with no method error, but no error reported?",
|
||||
);
|
||||
@ -2361,7 +2361,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
);
|
||||
if pick.is_ok() {
|
||||
let range_span = parent_expr.span.with_hi(expr.span.hi());
|
||||
return Err(tcx.dcx().emit_err(errors::MissingParenthesesInRange {
|
||||
return Err(self.dcx().emit_err(errors::MissingParenthesesInRange {
|
||||
span,
|
||||
ty_str: ty_str.to_string(),
|
||||
method_name: item_name.as_str().to_string(),
|
||||
@ -2420,7 +2420,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
&& let SelfSource::MethodCall(expr) = source
|
||||
{
|
||||
let mut err = struct_span_code_err!(
|
||||
tcx.dcx(),
|
||||
self.dcx(),
|
||||
span,
|
||||
E0689,
|
||||
"can't call {} `{}` on ambiguous numeric type `{}`",
|
||||
|
@ -698,7 +698,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
&& let MutblCap::WeaklyNot(and_pat_span) = pat_info.max_ref_mutbl
|
||||
{
|
||||
let mut err = struct_span_code_err!(
|
||||
self.tcx.dcx(),
|
||||
self.dcx(),
|
||||
ident.span,
|
||||
E0596,
|
||||
"cannot borrow as mutable inside an `&` pattern"
|
||||
@ -1010,7 +1010,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
let (res, opt_ty, segments) = path_resolution;
|
||||
match res {
|
||||
Res::Err => {
|
||||
let e = tcx.dcx().span_delayed_bug(qpath.span(), "`Res::Err` but no error emitted");
|
||||
let e =
|
||||
self.dcx().span_delayed_bug(qpath.span(), "`Res::Err` but no error emitted");
|
||||
self.set_tainted_by_errors(e);
|
||||
return Ty::new_error(tcx, e);
|
||||
}
|
||||
@ -1191,7 +1192,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
let (res, opt_ty, segments) =
|
||||
self.resolve_ty_and_res_fully_qualified_call(qpath, pat.hir_id, pat.span);
|
||||
if res == Res::Err {
|
||||
let e = tcx.dcx().span_delayed_bug(pat.span, "`Res::Err` but no error emitted");
|
||||
let e = self.dcx().span_delayed_bug(pat.span, "`Res::Err` but no error emitted");
|
||||
self.set_tainted_by_errors(e);
|
||||
on_error(e);
|
||||
return Ty::new_error(tcx, e);
|
||||
@ -1207,7 +1208,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
|
||||
let variant = match res {
|
||||
Res::Err => {
|
||||
tcx.dcx().span_bug(pat.span, "`Res::Err` but no error emitted");
|
||||
self.dcx().span_bug(pat.span, "`Res::Err` but no error emitted");
|
||||
}
|
||||
Res::Def(DefKind::AssocConst | DefKind::AssocFn, _) => {
|
||||
let e = report_unexpected_res(res);
|
||||
@ -1549,10 +1550,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
// Report an error if an incorrect number of fields was specified.
|
||||
if adt.is_union() {
|
||||
if fields.len() != 1 {
|
||||
tcx.dcx().emit_err(errors::UnionPatMultipleFields { span: pat.span });
|
||||
self.dcx().emit_err(errors::UnionPatMultipleFields { span: pat.span });
|
||||
}
|
||||
if has_rest_pat {
|
||||
tcx.dcx().emit_err(errors::UnionPatDotDot { span: pat.span });
|
||||
self.dcx().emit_err(errors::UnionPatDotDot { span: pat.span });
|
||||
}
|
||||
} else if !unmentioned_fields.is_empty() {
|
||||
let accessible_unmentioned_fields: Vec<_> = unmentioned_fields
|
||||
@ -1690,7 +1691,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
pat: &'tcx Pat<'tcx>,
|
||||
variant: &ty::VariantDef,
|
||||
args: ty::GenericArgsRef<'tcx>,
|
||||
) -> Diag<'tcx> {
|
||||
) -> Diag<'a> {
|
||||
let tcx = self.tcx;
|
||||
let (field_names, t, plural) = if let [field] = inexistent_fields {
|
||||
(format!("a field named `{}`", field.ident), "this", "")
|
||||
@ -1710,7 +1711,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
};
|
||||
let spans = inexistent_fields.iter().map(|field| field.ident.span).collect::<Vec<_>>();
|
||||
let mut err = struct_span_code_err!(
|
||||
tcx.dcx(),
|
||||
self.dcx(),
|
||||
spans,
|
||||
E0026,
|
||||
"{} `{}` does not have {}",
|
||||
|
@ -305,16 +305,17 @@ fn label_msg_span(
|
||||
}
|
||||
}
|
||||
|
||||
#[instrument(level = "trace", skip(tcx))]
|
||||
pub fn unexpected_hidden_region_diagnostic<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
#[instrument(level = "trace", skip(infcx))]
|
||||
pub fn unexpected_hidden_region_diagnostic<'a, 'tcx>(
|
||||
infcx: &'a InferCtxt<'tcx>,
|
||||
generic_param_scope: LocalDefId,
|
||||
span: Span,
|
||||
hidden_ty: Ty<'tcx>,
|
||||
hidden_region: ty::Region<'tcx>,
|
||||
opaque_ty_key: ty::OpaqueTypeKey<'tcx>,
|
||||
) -> Diag<'tcx> {
|
||||
let mut err = tcx.dcx().create_err(errors::OpaqueCapturesLifetime {
|
||||
) -> Diag<'a> {
|
||||
let tcx = infcx.tcx;
|
||||
let mut err = infcx.dcx().create_err(errors::OpaqueCapturesLifetime {
|
||||
span,
|
||||
opaque_ty: Ty::new_opaque(tcx, opaque_ty_key.def_id.to_def_id(), opaque_ty_key.args),
|
||||
opaque_ty_span: tcx.def_span(opaque_ty_key.def_id),
|
||||
@ -2215,7 +2216,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
||||
span,
|
||||
self.type_error_additional_suggestions(&trace, terr),
|
||||
);
|
||||
let mut diag = self.tcx.dcx().create_err(failure_code);
|
||||
let mut diag = self.dcx().create_err(failure_code);
|
||||
self.note_type_err(&mut diag, &trace.cause, None, Some(trace.values), terr, false, false);
|
||||
diag
|
||||
}
|
||||
@ -2357,14 +2358,14 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
||||
origin: Option<SubregionOrigin<'tcx>>,
|
||||
bound_kind: GenericKind<'tcx>,
|
||||
sub: Region<'tcx>,
|
||||
) -> Diag<'tcx> {
|
||||
) -> Diag<'a> {
|
||||
if let Some(SubregionOrigin::CompareImplItemObligation {
|
||||
span,
|
||||
impl_item_def_id,
|
||||
trait_item_def_id,
|
||||
}) = origin
|
||||
{
|
||||
return self.report_extra_impl_obligation(
|
||||
return self.infcx.report_extra_impl_obligation(
|
||||
span,
|
||||
impl_item_def_id,
|
||||
trait_item_def_id,
|
||||
@ -2790,7 +2791,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for SameTypeModuloInfer<'_, 'tcx> {
|
||||
}
|
||||
|
||||
impl<'tcx> InferCtxt<'tcx> {
|
||||
fn report_inference_failure(&self, var_origin: RegionVariableOrigin) -> Diag<'tcx> {
|
||||
fn report_inference_failure(&self, var_origin: RegionVariableOrigin) -> Diag<'_> {
|
||||
let br_string = |br: ty::BoundRegionKind| {
|
||||
let mut s = match br {
|
||||
ty::BrNamed(_, name) => name.to_string(),
|
||||
@ -2829,7 +2830,7 @@ impl<'tcx> InferCtxt<'tcx> {
|
||||
};
|
||||
|
||||
struct_span_code_err!(
|
||||
self.tcx.dcx(),
|
||||
self.dcx(),
|
||||
var_origin.span(),
|
||||
E0495,
|
||||
"cannot infer an appropriate lifetime{} due to conflicting requirements",
|
||||
|
@ -245,7 +245,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
||||
})
|
||||
}
|
||||
infer::CompareImplItemObligation { span, impl_item_def_id, trait_item_def_id } => {
|
||||
let mut err = self.report_extra_impl_obligation(
|
||||
let mut err = self.infcx.report_extra_impl_obligation(
|
||||
span,
|
||||
impl_item_def_id,
|
||||
trait_item_def_id,
|
||||
|
@ -685,7 +685,7 @@ impl<'tcx> InferOk<'tcx, ()> {
|
||||
|
||||
impl<'tcx> InferCtxt<'tcx> {
|
||||
pub fn dcx(&self) -> DiagCtxtHandle<'_> {
|
||||
self.tcx.dcx()
|
||||
self.tcx.dcx().taintable_handle(&self.tainted_by_errors)
|
||||
}
|
||||
|
||||
pub fn defining_opaque_types(&self) -> &'tcx ty::List<LocalDefId> {
|
||||
@ -1089,19 +1089,7 @@ impl<'tcx> InferCtxt<'tcx> {
|
||||
/// inference variables, regionck errors).
|
||||
#[must_use = "this method does not have any side effects"]
|
||||
pub fn tainted_by_errors(&self) -> Option<ErrorGuaranteed> {
|
||||
if let Some(guar) = self.tainted_by_errors.get() {
|
||||
Some(guar)
|
||||
} else if self.dcx().err_count_excluding_lint_errs() > self.err_count_on_creation {
|
||||
// Errors reported since this infcx was made. Lint errors are
|
||||
// excluded to avoid some being swallowed in the presence of
|
||||
// non-lint errors. (It's arguable whether or not this exclusion is
|
||||
// important.)
|
||||
let guar = self.dcx().has_errors().unwrap();
|
||||
self.set_tainted_by_errors(guar);
|
||||
Some(guar)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
self.tainted_by_errors.get()
|
||||
}
|
||||
|
||||
/// Set the "tainted by errors" flag to true. We call this when we
|
||||
@ -1328,8 +1316,7 @@ impl<'tcx> InferCtxt<'tcx> {
|
||||
bug!("`{value:?}` is not fully resolved");
|
||||
}
|
||||
if value.has_infer_regions() {
|
||||
let guar =
|
||||
self.tcx.dcx().delayed_bug(format!("`{value:?}` is not fully resolved"));
|
||||
let guar = self.dcx().delayed_bug(format!("`{value:?}` is not fully resolved"));
|
||||
Ok(self.tcx.fold_regions(value, |re, _| {
|
||||
if re.is_var() { ty::Region::new_error(self.tcx, guar) } else { re }
|
||||
}))
|
||||
|
@ -156,7 +156,7 @@ impl<'tcx> InferCtxt<'tcx> {
|
||||
if self.can_define_opaque_ty(b_def_id)
|
||||
&& self.tcx.is_type_alias_impl_trait(b_def_id)
|
||||
{
|
||||
self.tcx.dcx().emit_err(OpaqueHiddenTypeDiag {
|
||||
self.dcx().emit_err(OpaqueHiddenTypeDiag {
|
||||
span,
|
||||
hidden_type: self.tcx.def_span(b_def_id),
|
||||
opaque_type: self.tcx.def_span(def_id),
|
||||
|
@ -12,15 +12,15 @@ use std::fmt;
|
||||
use std::iter;
|
||||
|
||||
impl<'tcx> InferCtxt<'tcx> {
|
||||
pub fn report_extra_impl_obligation(
|
||||
&self,
|
||||
pub fn report_extra_impl_obligation<'a>(
|
||||
&'a self,
|
||||
error_span: Span,
|
||||
impl_item_def_id: LocalDefId,
|
||||
trait_item_def_id: DefId,
|
||||
requirement: &dyn fmt::Display,
|
||||
) -> Diag<'tcx> {
|
||||
) -> Diag<'a> {
|
||||
let mut err = struct_span_code_err!(
|
||||
self.tcx.dcx(),
|
||||
self.dcx(),
|
||||
error_span,
|
||||
E0276,
|
||||
"impl has stricter requirements than trait"
|
||||
|
@ -1101,7 +1101,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
||||
&& let ty::FnPtr(sig) = by_ref_captures.kind()
|
||||
&& !sig.skip_binder().output().is_unit()
|
||||
{
|
||||
let mut err = self.tcx.dcx().create_err(AsyncClosureNotFn {
|
||||
let mut err = self.dcx().create_err(AsyncClosureNotFn {
|
||||
span: self.tcx.def_span(closure_def_id),
|
||||
kind: expected_kind.as_str(),
|
||||
});
|
||||
@ -2884,7 +2884,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
||||
self.suggest_unsized_bound_if_applicable(err, obligation);
|
||||
if let Some(span) = err.span.primary_span()
|
||||
&& let Some(mut diag) =
|
||||
self.tcx.dcx().steal_non_err(span, StashKey::AssociatedTypeSuggestion)
|
||||
self.dcx().steal_non_err(span, StashKey::AssociatedTypeSuggestion)
|
||||
&& let Ok(ref mut s1) = err.suggestions
|
||||
&& let Ok(ref mut s2) = diag.suggestions
|
||||
{
|
||||
|
@ -13,13 +13,16 @@ fn main() {
|
||||
|
||||
let x: u64;
|
||||
asm!("{}", in(reg) x);
|
||||
//~^ ERROR isn't initialized
|
||||
let mut y: u64;
|
||||
asm!("{}", inout(reg) y);
|
||||
//~^ ERROR isn't initialized
|
||||
let _ = y;
|
||||
|
||||
// Outputs require mutable places
|
||||
|
||||
let v: Vec<u64> = vec![0, 1, 2];
|
||||
//~^ ERROR is not declared as mutable
|
||||
asm!("{}", in(reg) v[0]);
|
||||
asm!("{}", out(reg) v[0]);
|
||||
asm!("{}", inout(reg) v[0]);
|
||||
|
@ -1,5 +1,5 @@
|
||||
error: invalid `sym` operand
|
||||
--> $DIR/type-check-2.rs:35:24
|
||||
--> $DIR/type-check-2.rs:38:24
|
||||
|
|
||||
LL | asm!("{}", sym x);
|
||||
| ^ is a local variable
|
||||
@ -7,7 +7,7 @@ LL | asm!("{}", sym x);
|
||||
= help: `sym` operands must refer to either a function or a static
|
||||
|
||||
error: invalid `sym` operand
|
||||
--> $DIR/type-check-2.rs:86:19
|
||||
--> $DIR/type-check-2.rs:89:19
|
||||
|
|
||||
LL | global_asm!("{}", sym C);
|
||||
| ^^^^^ is an `i32`
|
||||
@ -15,7 +15,7 @@ LL | global_asm!("{}", sym C);
|
||||
= help: `sym` operands must refer to either a function or a static
|
||||
|
||||
error: invalid `sym` operand
|
||||
--> $DIR/type-check-2.rs:33:20
|
||||
--> $DIR/type-check-2.rs:36:20
|
||||
|
|
||||
LL | asm!("{}", sym C);
|
||||
| ^^^^^ is an `i32`
|
||||
@ -23,15 +23,15 @@ LL | asm!("{}", sym C);
|
||||
= help: `sym` operands must refer to either a function or a static
|
||||
|
||||
error: arguments for inline assembly must be copyable
|
||||
--> $DIR/type-check-2.rs:40:32
|
||||
--> $DIR/type-check-2.rs:43:32
|
||||
|
|
||||
LL | asm!("{}", in(xmm_reg) SimdNonCopy(0.0, 0.0, 0.0, 0.0));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: `SimdNonCopy` does not implement the Copy trait
|
||||
|
||||
error: cannot use value of type `{closure@$DIR/type-check-2.rs:52:28: 52:36}` for inline assembly
|
||||
--> $DIR/type-check-2.rs:52:28
|
||||
error: cannot use value of type `{closure@$DIR/type-check-2.rs:55:28: 55:36}` for inline assembly
|
||||
--> $DIR/type-check-2.rs:55:28
|
||||
|
|
||||
LL | asm!("{}", in(reg) |x: i32| x);
|
||||
| ^^^^^^^^^^
|
||||
@ -39,7 +39,7 @@ LL | asm!("{}", in(reg) |x: i32| x);
|
||||
= note: only integers, floats, SIMD vectors, pointers and function pointers can be used as arguments for inline assembly
|
||||
|
||||
error: cannot use value of type `Vec<i32>` for inline assembly
|
||||
--> $DIR/type-check-2.rs:54:28
|
||||
--> $DIR/type-check-2.rs:57:28
|
||||
|
|
||||
LL | asm!("{}", in(reg) vec![0]);
|
||||
| ^^^^^^^
|
||||
@ -48,7 +48,7 @@ LL | asm!("{}", in(reg) vec![0]);
|
||||
= note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: cannot use value of type `(i32, i32, i32)` for inline assembly
|
||||
--> $DIR/type-check-2.rs:56:28
|
||||
--> $DIR/type-check-2.rs:59:28
|
||||
|
|
||||
LL | asm!("{}", in(reg) (1, 2, 3));
|
||||
| ^^^^^^^^^
|
||||
@ -56,7 +56,7 @@ LL | asm!("{}", in(reg) (1, 2, 3));
|
||||
= note: only integers, floats, SIMD vectors, pointers and function pointers can be used as arguments for inline assembly
|
||||
|
||||
error: cannot use value of type `[i32; 3]` for inline assembly
|
||||
--> $DIR/type-check-2.rs:58:28
|
||||
--> $DIR/type-check-2.rs:61:28
|
||||
|
|
||||
LL | asm!("{}", in(reg) [1, 2, 3]);
|
||||
| ^^^^^^^^^
|
||||
@ -64,7 +64,7 @@ LL | asm!("{}", in(reg) [1, 2, 3]);
|
||||
= note: only integers, floats, SIMD vectors, pointers and function pointers can be used as arguments for inline assembly
|
||||
|
||||
error: cannot use value of type `fn() {main}` for inline assembly
|
||||
--> $DIR/type-check-2.rs:66:31
|
||||
--> $DIR/type-check-2.rs:69:31
|
||||
|
|
||||
LL | asm!("{}", inout(reg) f);
|
||||
| ^
|
||||
@ -72,12 +72,56 @@ LL | asm!("{}", inout(reg) f);
|
||||
= note: only integers, floats, SIMD vectors, pointers and function pointers can be used as arguments for inline assembly
|
||||
|
||||
error: cannot use value of type `&mut i32` for inline assembly
|
||||
--> $DIR/type-check-2.rs:69:31
|
||||
--> $DIR/type-check-2.rs:72:31
|
||||
|
|
||||
LL | asm!("{}", inout(reg) r);
|
||||
| ^
|
||||
|
|
||||
= note: only integers, floats, SIMD vectors, pointers and function pointers can be used as arguments for inline assembly
|
||||
|
||||
error: aborting due to 10 previous errors
|
||||
error[E0381]: used binding `x` isn't initialized
|
||||
--> $DIR/type-check-2.rs:15:28
|
||||
|
|
||||
LL | let x: u64;
|
||||
| - binding declared here but left uninitialized
|
||||
LL | asm!("{}", in(reg) x);
|
||||
| ^ `x` used here but it isn't initialized
|
||||
|
|
||||
help: consider assigning a value
|
||||
|
|
||||
LL | let x: u64 = 42;
|
||||
| ++++
|
||||
|
||||
error[E0381]: used binding `y` isn't initialized
|
||||
--> $DIR/type-check-2.rs:18:9
|
||||
|
|
||||
LL | let mut y: u64;
|
||||
| ----- binding declared here but left uninitialized
|
||||
LL | asm!("{}", inout(reg) y);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ `y` used here but it isn't initialized
|
||||
|
|
||||
help: consider assigning a value
|
||||
|
|
||||
LL | let mut y: u64 = 42;
|
||||
| ++++
|
||||
|
||||
error[E0596]: cannot borrow `v` as mutable, as it is not declared as mutable
|
||||
--> $DIR/type-check-2.rs:24:13
|
||||
|
|
||||
LL | let v: Vec<u64> = vec![0, 1, 2];
|
||||
| ^ not mutable
|
||||
...
|
||||
LL | asm!("{}", out(reg) v[0]);
|
||||
| - cannot borrow as mutable
|
||||
LL | asm!("{}", inout(reg) v[0]);
|
||||
| - cannot borrow as mutable
|
||||
|
|
||||
help: consider changing this to be mutable
|
||||
|
|
||||
LL | let mut v: Vec<u64> = vec![0, 1, 2];
|
||||
| +++
|
||||
|
||||
error: aborting due to 13 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0381, E0596.
|
||||
For more information about an error, try `rustc --explain E0381`.
|
||||
|
@ -13,4 +13,5 @@ impl Foo for isize {
|
||||
pub fn main() {
|
||||
let x: isize = Foo::<A = usize>::bar();
|
||||
//~^ ERROR associated item constraints are not allowed here
|
||||
//~| ERROR cannot call
|
||||
}
|
||||
|
@ -4,6 +4,22 @@ error[E0229]: associated item constraints are not allowed here
|
||||
LL | let x: isize = Foo::<A = usize>::bar();
|
||||
| ^^^^^^^^^ associated item constraint not allowed here
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
error[E0790]: cannot call associated function on trait without specifying the corresponding `impl` type
|
||||
--> $DIR/associated-types-eq-expr-path.rs:14:20
|
||||
|
|
||||
LL | fn bar() -> isize;
|
||||
| ------------------ `Foo::bar` defined here
|
||||
...
|
||||
LL | let x: isize = Foo::<A = usize>::bar();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ cannot call associated function of trait
|
||||
|
|
||||
help: use the fully-qualified path to the only available implementation
|
||||
|
|
||||
LL - let x: isize = Foo::<A = usize>::bar();
|
||||
LL + let x: isize = <isize as Foo<A = usize>>::bar();
|
||||
|
|
||||
|
||||
For more information about this error, try `rustc --explain E0229`.
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0229, E0790.
|
||||
For more information about an error, try `rustc --explain E0229`.
|
||||
|
@ -8,6 +8,7 @@ fn foo<T: Trait>() {
|
||||
bar::<<T as Trait>::ASSOC>();
|
||||
//~^ ERROR: expected associated type, found associated constant `Trait::ASSOC`
|
||||
//~| ERROR: unresolved item provided when a constant was expected
|
||||
//~| ERROR type annotations needed
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
@ -15,7 +15,19 @@ help: if this generic argument was intended as a const parameter, surround it wi
|
||||
LL | bar::<{ <T as Trait>::ASSOC }>();
|
||||
| + +
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error[E0284]: type annotations needed
|
||||
--> $DIR/assoc_const_as_type_argument.rs:8:5
|
||||
|
|
||||
LL | bar::<<T as Trait>::ASSOC>();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer the value of the const parameter `N` declared on the function `bar`
|
||||
|
|
||||
note: required by a const generic parameter in `bar`
|
||||
--> $DIR/assoc_const_as_type_argument.rs:5:8
|
||||
|
|
||||
LL | fn bar<const N: usize>() {}
|
||||
| ^^^^^^^^^^^^^^ required by this const generic parameter in `bar`
|
||||
|
||||
Some errors have detailed explanations: E0575, E0747.
|
||||
For more information about an error, try `rustc --explain E0575`.
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0284, E0575, E0747.
|
||||
For more information about an error, try `rustc --explain E0284`.
|
||||
|
@ -17,7 +17,7 @@ LL | let _: [u8; bar::<N>()];
|
||||
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions
|
||||
|
||||
error: generic parameters may not be used in const operations
|
||||
--> $DIR/const-arg-in-const-arg.rs:18:23
|
||||
--> $DIR/const-arg-in-const-arg.rs:19:23
|
||||
|
|
||||
LL | let _: [u8; faz::<'a>(&())];
|
||||
| ^^ cannot perform const operation using `'a`
|
||||
@ -26,7 +26,7 @@ LL | let _: [u8; faz::<'a>(&())];
|
||||
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions
|
||||
|
||||
error: generic parameters may not be used in const operations
|
||||
--> $DIR/const-arg-in-const-arg.rs:20:23
|
||||
--> $DIR/const-arg-in-const-arg.rs:21:23
|
||||
|
|
||||
LL | let _: [u8; baz::<'a>(&())];
|
||||
| ^^ cannot perform const operation using `'a`
|
||||
@ -35,7 +35,7 @@ LL | let _: [u8; baz::<'a>(&())];
|
||||
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions
|
||||
|
||||
error: generic parameters may not be used in const operations
|
||||
--> $DIR/const-arg-in-const-arg.rs:21:23
|
||||
--> $DIR/const-arg-in-const-arg.rs:22:23
|
||||
|
|
||||
LL | let _: [u8; faz::<'b>(&())];
|
||||
| ^^ cannot perform const operation using `'b`
|
||||
@ -44,7 +44,7 @@ LL | let _: [u8; faz::<'b>(&())];
|
||||
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions
|
||||
|
||||
error: generic parameters may not be used in const operations
|
||||
--> $DIR/const-arg-in-const-arg.rs:23:23
|
||||
--> $DIR/const-arg-in-const-arg.rs:24:23
|
||||
|
|
||||
LL | let _: [u8; baz::<'b>(&())];
|
||||
| ^^ cannot perform const operation using `'b`
|
||||
@ -53,7 +53,7 @@ LL | let _: [u8; baz::<'b>(&())];
|
||||
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions
|
||||
|
||||
error: generic parameters may not be used in const operations
|
||||
--> $DIR/const-arg-in-const-arg.rs:26:23
|
||||
--> $DIR/const-arg-in-const-arg.rs:27:23
|
||||
|
|
||||
LL | let _ = [0; bar::<N>()];
|
||||
| ^ cannot perform const operation using `N`
|
||||
@ -62,7 +62,7 @@ LL | let _ = [0; bar::<N>()];
|
||||
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions
|
||||
|
||||
error: generic parameters may not be used in const operations
|
||||
--> $DIR/const-arg-in-const-arg.rs:28:23
|
||||
--> $DIR/const-arg-in-const-arg.rs:30:23
|
||||
|
|
||||
LL | let _ = [0; faz::<'a>(&())];
|
||||
| ^^ cannot perform const operation using `'a`
|
||||
@ -71,7 +71,7 @@ LL | let _ = [0; faz::<'a>(&())];
|
||||
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions
|
||||
|
||||
error: generic parameters may not be used in const operations
|
||||
--> $DIR/const-arg-in-const-arg.rs:30:23
|
||||
--> $DIR/const-arg-in-const-arg.rs:32:23
|
||||
|
|
||||
LL | let _ = [0; baz::<'a>(&())];
|
||||
| ^^ cannot perform const operation using `'a`
|
||||
@ -80,7 +80,7 @@ LL | let _ = [0; baz::<'a>(&())];
|
||||
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions
|
||||
|
||||
error: generic parameters may not be used in const operations
|
||||
--> $DIR/const-arg-in-const-arg.rs:31:23
|
||||
--> $DIR/const-arg-in-const-arg.rs:33:23
|
||||
|
|
||||
LL | let _ = [0; faz::<'b>(&())];
|
||||
| ^^ cannot perform const operation using `'b`
|
||||
@ -89,7 +89,7 @@ LL | let _ = [0; faz::<'b>(&())];
|
||||
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions
|
||||
|
||||
error: generic parameters may not be used in const operations
|
||||
--> $DIR/const-arg-in-const-arg.rs:33:23
|
||||
--> $DIR/const-arg-in-const-arg.rs:35:23
|
||||
|
|
||||
LL | let _ = [0; baz::<'b>(&())];
|
||||
| ^^ cannot perform const operation using `'b`
|
||||
@ -98,7 +98,7 @@ LL | let _ = [0; baz::<'b>(&())];
|
||||
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions
|
||||
|
||||
error: generic parameters may not be used in const operations
|
||||
--> $DIR/const-arg-in-const-arg.rs:34:24
|
||||
--> $DIR/const-arg-in-const-arg.rs:36:24
|
||||
|
|
||||
LL | let _: Foo<{ foo::<T>() }>;
|
||||
| ^ cannot perform const operation using `T`
|
||||
@ -107,7 +107,7 @@ LL | let _: Foo<{ foo::<T>() }>;
|
||||
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions
|
||||
|
||||
error: generic parameters may not be used in const operations
|
||||
--> $DIR/const-arg-in-const-arg.rs:35:24
|
||||
--> $DIR/const-arg-in-const-arg.rs:37:24
|
||||
|
|
||||
LL | let _: Foo<{ bar::<N>() }>;
|
||||
| ^ cannot perform const operation using `N`
|
||||
@ -116,7 +116,7 @@ LL | let _: Foo<{ bar::<N>() }>;
|
||||
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions
|
||||
|
||||
error: generic parameters may not be used in const operations
|
||||
--> $DIR/const-arg-in-const-arg.rs:37:24
|
||||
--> $DIR/const-arg-in-const-arg.rs:40:24
|
||||
|
|
||||
LL | let _: Foo<{ faz::<'a>(&()) }>;
|
||||
| ^^ cannot perform const operation using `'a`
|
||||
@ -125,7 +125,7 @@ LL | let _: Foo<{ faz::<'a>(&()) }>;
|
||||
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions
|
||||
|
||||
error: generic parameters may not be used in const operations
|
||||
--> $DIR/const-arg-in-const-arg.rs:39:24
|
||||
--> $DIR/const-arg-in-const-arg.rs:42:24
|
||||
|
|
||||
LL | let _: Foo<{ baz::<'a>(&()) }>;
|
||||
| ^^ cannot perform const operation using `'a`
|
||||
@ -134,7 +134,7 @@ LL | let _: Foo<{ baz::<'a>(&()) }>;
|
||||
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions
|
||||
|
||||
error: generic parameters may not be used in const operations
|
||||
--> $DIR/const-arg-in-const-arg.rs:40:24
|
||||
--> $DIR/const-arg-in-const-arg.rs:43:24
|
||||
|
|
||||
LL | let _: Foo<{ faz::<'b>(&()) }>;
|
||||
| ^^ cannot perform const operation using `'b`
|
||||
@ -143,7 +143,7 @@ LL | let _: Foo<{ faz::<'b>(&()) }>;
|
||||
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions
|
||||
|
||||
error: generic parameters may not be used in const operations
|
||||
--> $DIR/const-arg-in-const-arg.rs:42:24
|
||||
--> $DIR/const-arg-in-const-arg.rs:45:24
|
||||
|
|
||||
LL | let _: Foo<{ baz::<'b>(&()) }>;
|
||||
| ^^ cannot perform const operation using `'b`
|
||||
@ -152,7 +152,7 @@ LL | let _: Foo<{ baz::<'b>(&()) }>;
|
||||
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions
|
||||
|
||||
error: generic parameters may not be used in const operations
|
||||
--> $DIR/const-arg-in-const-arg.rs:43:27
|
||||
--> $DIR/const-arg-in-const-arg.rs:46:27
|
||||
|
|
||||
LL | let _ = Foo::<{ foo::<T>() }>;
|
||||
| ^ cannot perform const operation using `T`
|
||||
@ -161,7 +161,7 @@ LL | let _ = Foo::<{ foo::<T>() }>;
|
||||
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions
|
||||
|
||||
error: generic parameters may not be used in const operations
|
||||
--> $DIR/const-arg-in-const-arg.rs:44:27
|
||||
--> $DIR/const-arg-in-const-arg.rs:47:27
|
||||
|
|
||||
LL | let _ = Foo::<{ bar::<N>() }>;
|
||||
| ^ cannot perform const operation using `N`
|
||||
@ -170,7 +170,7 @@ LL | let _ = Foo::<{ bar::<N>() }>;
|
||||
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions
|
||||
|
||||
error: generic parameters may not be used in const operations
|
||||
--> $DIR/const-arg-in-const-arg.rs:46:27
|
||||
--> $DIR/const-arg-in-const-arg.rs:50:27
|
||||
|
|
||||
LL | let _ = Foo::<{ faz::<'a>(&()) }>;
|
||||
| ^^ cannot perform const operation using `'a`
|
||||
@ -179,7 +179,7 @@ LL | let _ = Foo::<{ faz::<'a>(&()) }>;
|
||||
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions
|
||||
|
||||
error: generic parameters may not be used in const operations
|
||||
--> $DIR/const-arg-in-const-arg.rs:48:27
|
||||
--> $DIR/const-arg-in-const-arg.rs:52:27
|
||||
|
|
||||
LL | let _ = Foo::<{ baz::<'a>(&()) }>;
|
||||
| ^^ cannot perform const operation using `'a`
|
||||
@ -188,7 +188,7 @@ LL | let _ = Foo::<{ baz::<'a>(&()) }>;
|
||||
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions
|
||||
|
||||
error: generic parameters may not be used in const operations
|
||||
--> $DIR/const-arg-in-const-arg.rs:49:27
|
||||
--> $DIR/const-arg-in-const-arg.rs:53:27
|
||||
|
|
||||
LL | let _ = Foo::<{ faz::<'b>(&()) }>;
|
||||
| ^^ cannot perform const operation using `'b`
|
||||
@ -197,7 +197,7 @@ LL | let _ = Foo::<{ faz::<'b>(&()) }>;
|
||||
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions
|
||||
|
||||
error: generic parameters may not be used in const operations
|
||||
--> $DIR/const-arg-in-const-arg.rs:51:27
|
||||
--> $DIR/const-arg-in-const-arg.rs:55:27
|
||||
|
|
||||
LL | let _ = Foo::<{ baz::<'b>(&()) }>;
|
||||
| ^^ cannot perform const operation using `'b`
|
||||
@ -216,8 +216,20 @@ help: if this generic argument was intended as a const parameter, surround it wi
|
||||
LL | let _: [u8; bar::<{ N }>()];
|
||||
| + +
|
||||
|
||||
error[E0284]: type annotations needed
|
||||
--> $DIR/const-arg-in-const-arg.rs:16:17
|
||||
|
|
||||
LL | let _: [u8; bar::<N>()];
|
||||
| ^^^^^^^^ cannot infer the value of the const parameter `N` declared on the function `bar`
|
||||
|
|
||||
note: required by a const generic parameter in `bar`
|
||||
--> $DIR/const-arg-in-const-arg.rs:9:14
|
||||
|
|
||||
LL | const fn bar<const N: usize>() -> usize { N }
|
||||
| ^^^^^^^^^^^^^^ required by this const generic parameter in `bar`
|
||||
|
||||
error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present
|
||||
--> $DIR/const-arg-in-const-arg.rs:18:23
|
||||
--> $DIR/const-arg-in-const-arg.rs:19:23
|
||||
|
|
||||
LL | let _: [u8; faz::<'a>(&())];
|
||||
| ^^
|
||||
@ -229,7 +241,7 @@ LL | const fn faz<'a>(_: &'a ()) -> usize { 13 }
|
||||
| ^^
|
||||
|
||||
error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present
|
||||
--> $DIR/const-arg-in-const-arg.rs:21:23
|
||||
--> $DIR/const-arg-in-const-arg.rs:22:23
|
||||
|
|
||||
LL | let _: [u8; faz::<'b>(&())];
|
||||
| ^^
|
||||
@ -241,7 +253,7 @@ LL | const fn faz<'a>(_: &'a ()) -> usize { 13 }
|
||||
| ^^
|
||||
|
||||
error[E0747]: unresolved item provided when a constant was expected
|
||||
--> $DIR/const-arg-in-const-arg.rs:35:24
|
||||
--> $DIR/const-arg-in-const-arg.rs:37:24
|
||||
|
|
||||
LL | let _: Foo<{ bar::<N>() }>;
|
||||
| ^
|
||||
@ -251,8 +263,20 @@ help: if this generic argument was intended as a const parameter, surround it wi
|
||||
LL | let _: Foo<{ bar::<{ N }>() }>;
|
||||
| + +
|
||||
|
||||
error[E0284]: type annotations needed
|
||||
--> $DIR/const-arg-in-const-arg.rs:37:18
|
||||
|
|
||||
LL | let _: Foo<{ bar::<N>() }>;
|
||||
| ^^^^^^^^ cannot infer the value of the const parameter `N` declared on the function `bar`
|
||||
|
|
||||
note: required by a const generic parameter in `bar`
|
||||
--> $DIR/const-arg-in-const-arg.rs:9:14
|
||||
|
|
||||
LL | const fn bar<const N: usize>() -> usize { N }
|
||||
| ^^^^^^^^^^^^^^ required by this const generic parameter in `bar`
|
||||
|
||||
error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present
|
||||
--> $DIR/const-arg-in-const-arg.rs:37:24
|
||||
--> $DIR/const-arg-in-const-arg.rs:40:24
|
||||
|
|
||||
LL | let _: Foo<{ faz::<'a>(&()) }>;
|
||||
| ^^
|
||||
@ -264,7 +288,7 @@ LL | const fn faz<'a>(_: &'a ()) -> usize { 13 }
|
||||
| ^^
|
||||
|
||||
error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present
|
||||
--> $DIR/const-arg-in-const-arg.rs:40:24
|
||||
--> $DIR/const-arg-in-const-arg.rs:43:24
|
||||
|
|
||||
LL | let _: Foo<{ faz::<'b>(&()) }>;
|
||||
| ^^
|
||||
@ -276,7 +300,7 @@ LL | const fn faz<'a>(_: &'a ()) -> usize { 13 }
|
||||
| ^^
|
||||
|
||||
error: constant expression depends on a generic parameter
|
||||
--> $DIR/const-arg-in-const-arg.rs:25:17
|
||||
--> $DIR/const-arg-in-const-arg.rs:26:17
|
||||
|
|
||||
LL | let _ = [0; foo::<T>()];
|
||||
| ^^^^^^^^^^
|
||||
@ -284,7 +308,7 @@ LL | let _ = [0; foo::<T>()];
|
||||
= note: this may fail depending on what value the parameter takes
|
||||
|
||||
error[E0747]: unresolved item provided when a constant was expected
|
||||
--> $DIR/const-arg-in-const-arg.rs:26:23
|
||||
--> $DIR/const-arg-in-const-arg.rs:27:23
|
||||
|
|
||||
LL | let _ = [0; bar::<N>()];
|
||||
| ^
|
||||
@ -294,8 +318,20 @@ help: if this generic argument was intended as a const parameter, surround it wi
|
||||
LL | let _ = [0; bar::<{ N }>()];
|
||||
| + +
|
||||
|
||||
error[E0284]: type annotations needed
|
||||
--> $DIR/const-arg-in-const-arg.rs:27:17
|
||||
|
|
||||
LL | let _ = [0; bar::<N>()];
|
||||
| ^^^^^^^^ cannot infer the value of the const parameter `N` declared on the function `bar`
|
||||
|
|
||||
note: required by a const generic parameter in `bar`
|
||||
--> $DIR/const-arg-in-const-arg.rs:9:14
|
||||
|
|
||||
LL | const fn bar<const N: usize>() -> usize { N }
|
||||
| ^^^^^^^^^^^^^^ required by this const generic parameter in `bar`
|
||||
|
||||
error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present
|
||||
--> $DIR/const-arg-in-const-arg.rs:28:23
|
||||
--> $DIR/const-arg-in-const-arg.rs:30:23
|
||||
|
|
||||
LL | let _ = [0; faz::<'a>(&())];
|
||||
| ^^
|
||||
@ -307,7 +343,7 @@ LL | const fn faz<'a>(_: &'a ()) -> usize { 13 }
|
||||
| ^^
|
||||
|
||||
error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present
|
||||
--> $DIR/const-arg-in-const-arg.rs:31:23
|
||||
--> $DIR/const-arg-in-const-arg.rs:33:23
|
||||
|
|
||||
LL | let _ = [0; faz::<'b>(&())];
|
||||
| ^^
|
||||
@ -319,7 +355,7 @@ LL | const fn faz<'a>(_: &'a ()) -> usize { 13 }
|
||||
| ^^
|
||||
|
||||
error[E0747]: unresolved item provided when a constant was expected
|
||||
--> $DIR/const-arg-in-const-arg.rs:44:27
|
||||
--> $DIR/const-arg-in-const-arg.rs:47:27
|
||||
|
|
||||
LL | let _ = Foo::<{ bar::<N>() }>;
|
||||
| ^
|
||||
@ -329,8 +365,20 @@ help: if this generic argument was intended as a const parameter, surround it wi
|
||||
LL | let _ = Foo::<{ bar::<{ N }>() }>;
|
||||
| + +
|
||||
|
||||
error[E0284]: type annotations needed
|
||||
--> $DIR/const-arg-in-const-arg.rs:47:21
|
||||
|
|
||||
LL | let _ = Foo::<{ bar::<N>() }>;
|
||||
| ^^^^^^^^ cannot infer the value of the const parameter `N` declared on the function `bar`
|
||||
|
|
||||
note: required by a const generic parameter in `bar`
|
||||
--> $DIR/const-arg-in-const-arg.rs:9:14
|
||||
|
|
||||
LL | const fn bar<const N: usize>() -> usize { N }
|
||||
| ^^^^^^^^^^^^^^ required by this const generic parameter in `bar`
|
||||
|
||||
error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present
|
||||
--> $DIR/const-arg-in-const-arg.rs:46:27
|
||||
--> $DIR/const-arg-in-const-arg.rs:50:27
|
||||
|
|
||||
LL | let _ = Foo::<{ faz::<'a>(&()) }>;
|
||||
| ^^
|
||||
@ -342,7 +390,7 @@ LL | const fn faz<'a>(_: &'a ()) -> usize { 13 }
|
||||
| ^^
|
||||
|
||||
error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present
|
||||
--> $DIR/const-arg-in-const-arg.rs:49:27
|
||||
--> $DIR/const-arg-in-const-arg.rs:53:27
|
||||
|
|
||||
LL | let _ = Foo::<{ faz::<'b>(&()) }>;
|
||||
| ^^
|
||||
@ -353,7 +401,7 @@ note: the late bound lifetime parameter is introduced here
|
||||
LL | const fn faz<'a>(_: &'a ()) -> usize { 13 }
|
||||
| ^^
|
||||
|
||||
error: aborting due to 36 previous errors
|
||||
error: aborting due to 40 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0747, E0794.
|
||||
For more information about an error, try `rustc --explain E0747`.
|
||||
Some errors have detailed explanations: E0284, E0747, E0794.
|
||||
For more information about an error, try `rustc --explain E0284`.
|
||||
|
@ -15,6 +15,7 @@ fn test<'a, 'b, T, const N: usize>() where &'b (): Sized {
|
||||
let _: [u8; foo::<T>()]; //[min]~ ERROR generic parameters may not
|
||||
let _: [u8; bar::<N>()]; //[min]~ ERROR generic parameters may not
|
||||
//[min]~^ ERROR unresolved item provided when a constant was expected
|
||||
//[min]~| ERROR type annotations needed
|
||||
let _: [u8; faz::<'a>(&())]; //[min]~ ERROR generic parameters may not
|
||||
//[min]~^ ERROR cannot specify lifetime arguments
|
||||
let _: [u8; baz::<'a>(&())]; //[min]~ ERROR generic parameters may not
|
||||
@ -25,6 +26,7 @@ fn test<'a, 'b, T, const N: usize>() where &'b (): Sized {
|
||||
let _ = [0; foo::<T>()]; //[min]~ ERROR constant expression depends on a generic parameter
|
||||
let _ = [0; bar::<N>()]; //[min]~ ERROR generic parameters may not
|
||||
//[min]~^ ERROR unresolved item provided when a constant was expected
|
||||
//[min]~| ERROR type annotations needed
|
||||
let _ = [0; faz::<'a>(&())]; //[min]~ ERROR generic parameters may not
|
||||
//[min]~^ ERROR cannot specify lifetime arguments
|
||||
let _ = [0; baz::<'a>(&())]; //[min]~ ERROR generic parameters may not
|
||||
@ -34,6 +36,7 @@ fn test<'a, 'b, T, const N: usize>() where &'b (): Sized {
|
||||
let _: Foo<{ foo::<T>() }>; //[min]~ ERROR generic parameters may not
|
||||
let _: Foo<{ bar::<N>() }>; //[min]~ ERROR generic parameters may not
|
||||
//[min]~^ ERROR unresolved item provided when a constant was expected
|
||||
//[min]~| ERROR type annotations needed
|
||||
let _: Foo<{ faz::<'a>(&()) }>; //[min]~ ERROR generic parameters may not
|
||||
//[min]~^ ERROR cannot specify lifetime arguments
|
||||
let _: Foo<{ baz::<'a>(&()) }>; //[min]~ ERROR generic parameters may not
|
||||
@ -43,6 +46,7 @@ fn test<'a, 'b, T, const N: usize>() where &'b (): Sized {
|
||||
let _ = Foo::<{ foo::<T>() }>; //[min]~ ERROR generic parameters may not
|
||||
let _ = Foo::<{ bar::<N>() }>; //[min]~ ERROR generic parameters may not
|
||||
//[min]~^ ERROR unresolved item provided when a constant was expected
|
||||
//[min]~| ERROR type annotations needed
|
||||
let _ = Foo::<{ faz::<'a>(&()) }>; //[min]~ ERROR generic parameters may not
|
||||
//[min]~^ ERROR cannot specify lifetime arguments
|
||||
let _ = Foo::<{ baz::<'a>(&()) }>; //[min]~ ERROR generic parameters may not
|
||||
|
@ -2,6 +2,7 @@
|
||||
#![allow(incomplete_features)]
|
||||
|
||||
type Foo = impl Sized;
|
||||
//~^ ERROR: unconstrained opaque type
|
||||
|
||||
fn with_bound<const N: usize>() -> Foo
|
||||
where
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/opaque_type.rs:10:17
|
||||
--> $DIR/opaque_type.rs:11:17
|
||||
|
|
||||
LL | type Foo = impl Sized;
|
||||
| ---------- the found opaque type
|
||||
@ -11,12 +11,20 @@ LL | let _: [u8; (N / 2) as Foo] = [0; (N / 2) as usize];
|
||||
found opaque type `Foo`
|
||||
|
||||
error[E0605]: non-primitive cast: `usize` as `Foo`
|
||||
--> $DIR/opaque_type.rs:10:17
|
||||
--> $DIR/opaque_type.rs:11:17
|
||||
|
|
||||
LL | let _: [u8; (N / 2) as Foo] = [0; (N / 2) as usize];
|
||||
| ^^^^^^^^^^^^^^ an `as` expression can only be used to convert between primitive types or to coerce to a specific trait object
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error: unconstrained opaque type
|
||||
--> $DIR/opaque_type.rs:4:12
|
||||
|
|
||||
LL | type Foo = impl Sized;
|
||||
| ^^^^^^^^^^
|
||||
|
|
||||
= note: `Foo` must be used in combination with a concrete type within the same module
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0308, E0605.
|
||||
For more information about an error, try `rustc --explain E0308`.
|
||||
|
@ -30,7 +30,31 @@ help: add `#![feature(generic_arg_infer)]` to the crate attributes to enable
|
||||
LL + #![feature(generic_arg_infer)]
|
||||
|
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
error[E0284]: type annotations needed
|
||||
--> $DIR/issue-62878.rs:10:5
|
||||
|
|
||||
LL | foo::<_, { [1] }>();
|
||||
| ^^^^^^^^^^^^^^^^^ cannot infer the value of the const parameter `N` declared on the function `foo`
|
||||
|
|
||||
note: required by a const generic parameter in `foo`
|
||||
--> $DIR/issue-62878.rs:5:8
|
||||
|
|
||||
LL | fn foo<const N: usize, const A: [u8; N]>() {}
|
||||
| ^^^^^^^^^^^^^^ required by this const generic parameter in `foo`
|
||||
|
||||
Some errors have detailed explanations: E0747, E0770.
|
||||
For more information about an error, try `rustc --explain E0747`.
|
||||
error[E0284]: type annotations needed
|
||||
--> $DIR/issue-62878.rs:10:5
|
||||
|
|
||||
LL | foo::<_, { [1] }>();
|
||||
| ^^^^^^^^^^^^^^^^^ cannot infer the value of the const parameter `A` declared on the function `foo`
|
||||
|
|
||||
note: required by a const generic parameter in `foo`
|
||||
--> $DIR/issue-62878.rs:5:24
|
||||
|
|
||||
LL | fn foo<const N: usize, const A: [u8; N]>() {}
|
||||
| ^^^^^^^^^^^^^^^^ required by this const generic parameter in `foo`
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0284, E0747, E0770.
|
||||
For more information about an error, try `rustc --explain E0284`.
|
||||
|
@ -9,4 +9,6 @@ fn foo<const N: usize, const A: [u8; N]>() {}
|
||||
fn main() {
|
||||
foo::<_, { [1] }>();
|
||||
//[min]~^ ERROR: type provided when a constant was expected
|
||||
//[min]~| ERROR type annotations needed
|
||||
//[min]~| ERROR type annotations needed
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ fn b() {
|
||||
//~^ ERROR expected trait, found constant `BAR`
|
||||
//~| ERROR expected trait, found constant `BAR`
|
||||
//~| ERROR type provided when a constant was expected
|
||||
//~| ERROR type annotations needed
|
||||
}
|
||||
fn c() {
|
||||
foo::<3 + 3>(); //~ ERROR expressions must be enclosed in braces
|
||||
|
@ -10,7 +10,7 @@ LL | foo::<{ BAR + 3 }>();
|
||||
| + +
|
||||
|
||||
error: expressions must be enclosed in braces to be used as const generic arguments
|
||||
--> $DIR/const-expression-suggest-missing-braces.rs:17:11
|
||||
--> $DIR/const-expression-suggest-missing-braces.rs:18:11
|
||||
|
|
||||
LL | foo::<3 + 3>();
|
||||
| ^^^^^
|
||||
@ -21,7 +21,7 @@ LL | foo::<{ 3 + 3 }>();
|
||||
| + +
|
||||
|
||||
error: expected one of `,` or `>`, found `-`
|
||||
--> $DIR/const-expression-suggest-missing-braces.rs:20:15
|
||||
--> $DIR/const-expression-suggest-missing-braces.rs:21:15
|
||||
|
|
||||
LL | foo::<BAR - 3>();
|
||||
| ^ expected one of `,` or `>`
|
||||
@ -32,7 +32,7 @@ LL | foo::<{ BAR - 3 }>();
|
||||
| + +
|
||||
|
||||
error: expected one of `,` or `>`, found `-`
|
||||
--> $DIR/const-expression-suggest-missing-braces.rs:23:15
|
||||
--> $DIR/const-expression-suggest-missing-braces.rs:24:15
|
||||
|
|
||||
LL | foo::<BAR - BAR>();
|
||||
| ^ expected one of `,` or `>`
|
||||
@ -43,7 +43,7 @@ LL | foo::<{ BAR - BAR }>();
|
||||
| + +
|
||||
|
||||
error: expressions must be enclosed in braces to be used as const generic arguments
|
||||
--> $DIR/const-expression-suggest-missing-braces.rs:26:11
|
||||
--> $DIR/const-expression-suggest-missing-braces.rs:27:11
|
||||
|
|
||||
LL | foo::<100 - BAR>();
|
||||
| ^^^^^^^^^
|
||||
@ -54,7 +54,7 @@ LL | foo::<{ 100 - BAR }>();
|
||||
| + +
|
||||
|
||||
error: expected one of `,` or `>`, found `(`
|
||||
--> $DIR/const-expression-suggest-missing-braces.rs:29:19
|
||||
--> $DIR/const-expression-suggest-missing-braces.rs:30:19
|
||||
|
|
||||
LL | foo::<bar<i32>()>();
|
||||
| ^ expected one of `,` or `>`
|
||||
@ -65,7 +65,7 @@ LL | foo::<{ bar<i32>() }>();
|
||||
| + +
|
||||
|
||||
error: expected one of `,` or `>`, found `(`
|
||||
--> $DIR/const-expression-suggest-missing-braces.rs:32:21
|
||||
--> $DIR/const-expression-suggest-missing-braces.rs:33:21
|
||||
|
|
||||
LL | foo::<bar::<i32>()>();
|
||||
| ^ expected one of `,` or `>`
|
||||
@ -76,7 +76,7 @@ LL | foo::<{ bar::<i32>() }>();
|
||||
| + +
|
||||
|
||||
error: expected one of `,` or `>`, found `(`
|
||||
--> $DIR/const-expression-suggest-missing-braces.rs:35:21
|
||||
--> $DIR/const-expression-suggest-missing-braces.rs:36:21
|
||||
|
|
||||
LL | foo::<bar::<i32>() + BAR>();
|
||||
| ^ expected one of `,` or `>`
|
||||
@ -87,7 +87,7 @@ LL | foo::<{ bar::<i32>() + BAR }>();
|
||||
| + +
|
||||
|
||||
error: expected one of `,` or `>`, found `(`
|
||||
--> $DIR/const-expression-suggest-missing-braces.rs:38:21
|
||||
--> $DIR/const-expression-suggest-missing-braces.rs:39:21
|
||||
|
|
||||
LL | foo::<bar::<i32>() - BAR>();
|
||||
| ^ expected one of `,` or `>`
|
||||
@ -98,7 +98,7 @@ LL | foo::<{ bar::<i32>() - BAR }>();
|
||||
| + +
|
||||
|
||||
error: expected one of `,` or `>`, found `-`
|
||||
--> $DIR/const-expression-suggest-missing-braces.rs:41:15
|
||||
--> $DIR/const-expression-suggest-missing-braces.rs:42:15
|
||||
|
|
||||
LL | foo::<BAR - bar::<i32>()>();
|
||||
| ^ expected one of `,` or `>`
|
||||
@ -109,7 +109,7 @@ LL | foo::<{ BAR - bar::<i32>() }>();
|
||||
| + +
|
||||
|
||||
error: expected one of `,` or `>`, found `-`
|
||||
--> $DIR/const-expression-suggest-missing-braces.rs:44:15
|
||||
--> $DIR/const-expression-suggest-missing-braces.rs:45:15
|
||||
|
|
||||
LL | foo::<BAR - bar::<i32>()>();
|
||||
| ^ expected one of `,` or `>`
|
||||
@ -137,7 +137,19 @@ error[E0747]: type provided when a constant was expected
|
||||
LL | foo::<BAR + BAR>();
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: aborting due to 14 previous errors
|
||||
error[E0284]: type annotations needed
|
||||
--> $DIR/const-expression-suggest-missing-braces.rs:11:5
|
||||
|
|
||||
LL | foo::<BAR + BAR>();
|
||||
| ^^^^^^^^^^^^^^^^ cannot infer the value of the const parameter `C` declared on the function `foo`
|
||||
|
|
||||
note: required by a const generic parameter in `foo`
|
||||
--> $DIR/const-expression-suggest-missing-braces.rs:1:8
|
||||
|
|
||||
LL | fn foo<const C: usize>() {}
|
||||
| ^^^^^^^^^^^^^^ required by this const generic parameter in `foo`
|
||||
|
||||
Some errors have detailed explanations: E0404, E0747.
|
||||
For more information about an error, try `rustc --explain E0404`.
|
||||
error: aborting due to 15 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0284, E0404, E0747.
|
||||
For more information about an error, try `rustc --explain E0284`.
|
||||
|
@ -16,6 +16,7 @@ fn make_marker() -> impl Marker<gimme_a_const!(marker)> {
|
||||
//~| ERROR: type provided when a constant was expected
|
||||
Example::<gimme_a_const!(marker)>
|
||||
//~^ ERROR: type provided when a constant was expected
|
||||
//~| ERROR type annotations needed
|
||||
}
|
||||
|
||||
fn from_marker(_: impl Marker<{
|
||||
@ -35,9 +36,11 @@ fn main() {
|
||||
}>;
|
||||
|
||||
let _fail = Example::<external_macro!()>;
|
||||
//~^ ERROR: type provided when a constant was expected
|
||||
//~^ ERROR: type provided when a constant
|
||||
//~| ERROR type annotations needed
|
||||
|
||||
let _fail = Example::<gimme_a_const!()>;
|
||||
//~^ ERROR unexpected end of macro invocation
|
||||
//~| ERROR: type provided when a constant was expected
|
||||
//~| ERROR type annotations needed
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
error: expected type, found `{`
|
||||
--> $DIR/macro-fail.rs:30:27
|
||||
--> $DIR/macro-fail.rs:31:27
|
||||
|
|
||||
LL | fn make_marker() -> impl Marker<gimme_a_const!(marker)> {
|
||||
| ----------------------
|
||||
@ -13,7 +13,7 @@ LL | ($rusty: ident) => {{ let $rusty = 3; *&$rusty }}
|
||||
= note: this error originates in the macro `gimme_a_const` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: expected type, found `{`
|
||||
--> $DIR/macro-fail.rs:30:27
|
||||
--> $DIR/macro-fail.rs:31:27
|
||||
|
|
||||
LL | Example::<gimme_a_const!(marker)>
|
||||
| ----------------------
|
||||
@ -41,7 +41,7 @@ LL | let _fail = Example::<external_macro!()>;
|
||||
= note: this error originates in the macro `external_macro` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: unexpected end of macro invocation
|
||||
--> $DIR/macro-fail.rs:40:25
|
||||
--> $DIR/macro-fail.rs:42:25
|
||||
|
|
||||
LL | macro_rules! gimme_a_const {
|
||||
| -------------------------- when calling this macro
|
||||
@ -50,7 +50,7 @@ LL | let _fail = Example::<gimme_a_const!()>;
|
||||
| ^^^^^^^^^^^^^^^^ missing tokens in macro arguments
|
||||
|
|
||||
note: while trying to match meta-variable `$rusty:ident`
|
||||
--> $DIR/macro-fail.rs:30:8
|
||||
--> $DIR/macro-fail.rs:31:8
|
||||
|
|
||||
LL | ($rusty: ident) => {{ let $rusty = 3; *&$rusty }}
|
||||
| ^^^^^^^^^^^^^
|
||||
@ -75,18 +75,63 @@ error[E0747]: type provided when a constant was expected
|
||||
LL | Example::<gimme_a_const!(marker)>
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0284]: type annotations needed
|
||||
--> $DIR/macro-fail.rs:17:3
|
||||
|
|
||||
LL | Example::<gimme_a_const!(marker)>
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer the value of the const parameter `N` declared on the struct `Example`
|
||||
|
|
||||
note: required by a const generic parameter in `Example`
|
||||
--> $DIR/macro-fail.rs:1:16
|
||||
|
|
||||
LL | struct Example<const N: usize>;
|
||||
| ^^^^^^^^^^^^^^ required by this const generic parameter in `Example`
|
||||
|
||||
error[E0747]: type provided when a constant was expected
|
||||
--> $DIR/macro-fail.rs:37:25
|
||||
--> $DIR/macro-fail.rs:38:25
|
||||
|
|
||||
LL | let _fail = Example::<external_macro!()>;
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0747]: type provided when a constant was expected
|
||||
--> $DIR/macro-fail.rs:40:25
|
||||
--> $DIR/macro-fail.rs:42:25
|
||||
|
|
||||
LL | let _fail = Example::<gimme_a_const!()>;
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 9 previous errors
|
||||
error[E0284]: type annotations needed for `Example<_>`
|
||||
--> $DIR/macro-fail.rs:38:7
|
||||
|
|
||||
LL | let _fail = Example::<external_macro!()>;
|
||||
| ^^^^^ ---------------------------- type must be known at this point
|
||||
|
|
||||
note: required by a const generic parameter in `Example`
|
||||
--> $DIR/macro-fail.rs:1:16
|
||||
|
|
||||
LL | struct Example<const N: usize>;
|
||||
| ^^^^^^^^^^^^^^ required by this const generic parameter in `Example`
|
||||
help: consider giving `_fail` an explicit type, where the value of const parameter `N` is specified
|
||||
|
|
||||
LL | let _fail: Example<N> = Example::<external_macro!()>;
|
||||
| ++++++++++++
|
||||
|
||||
For more information about this error, try `rustc --explain E0747`.
|
||||
error[E0284]: type annotations needed for `Example<_>`
|
||||
--> $DIR/macro-fail.rs:42:7
|
||||
|
|
||||
LL | let _fail = Example::<gimme_a_const!()>;
|
||||
| ^^^^^ --------------------------- type must be known at this point
|
||||
|
|
||||
note: required by a const generic parameter in `Example`
|
||||
--> $DIR/macro-fail.rs:1:16
|
||||
|
|
||||
LL | struct Example<const N: usize>;
|
||||
| ^^^^^^^^^^^^^^ required by this const generic parameter in `Example`
|
||||
help: consider giving `_fail` an explicit type, where the value of const parameter `N` is specified
|
||||
|
|
||||
LL | let _fail: Example<N> = Example::<gimme_a_const!()>;
|
||||
| ++++++++++++
|
||||
|
||||
error: aborting due to 12 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0284, E0747.
|
||||
For more information about an error, try `rustc --explain E0284`.
|
||||
|
@ -3,8 +3,10 @@
|
||||
fn example<const N: usize>() {}
|
||||
|
||||
fn other() {
|
||||
example::<[usize; 3]>();
|
||||
//~^ ERROR type provided when a const
|
||||
example::<[usize; 4+5]>();
|
||||
//~^ ERROR type provided when a const
|
||||
example::<[usize; 3]>();
|
||||
//~^ ERROR type provided when a const
|
||||
//~| ERROR type annotations needed
|
||||
example::<[usize; 4 + 5]>();
|
||||
//~^ ERROR type provided when a const
|
||||
//~| ERROR type annotations needed
|
||||
}
|
||||
|
@ -1,15 +1,40 @@
|
||||
error[E0747]: type provided when a constant was expected
|
||||
--> $DIR/suggest_const_for_array.rs:6:13
|
||||
--> $DIR/suggest_const_for_array.rs:6:15
|
||||
|
|
||||
LL | example::<[usize; 3]>();
|
||||
| ^^^^^^^^^^ help: array type provided where a `usize` was expected, try: `{ 3 }`
|
||||
LL | example::<[usize; 3]>();
|
||||
| ^^^^^^^^^^ help: array type provided where a `usize` was expected, try: `{ 3 }`
|
||||
|
||||
error[E0747]: type provided when a constant was expected
|
||||
--> $DIR/suggest_const_for_array.rs:8:13
|
||||
--> $DIR/suggest_const_for_array.rs:9:15
|
||||
|
|
||||
LL | example::<[usize; 4+5]>();
|
||||
| ^^^^^^^^^^^^ help: array type provided where a `usize` was expected, try: `{ 4+5 }`
|
||||
LL | example::<[usize; 4 + 5]>();
|
||||
| ^^^^^^^^^^^^^^ help: array type provided where a `usize` was expected, try: `{ 4 + 5 }`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error[E0284]: type annotations needed
|
||||
--> $DIR/suggest_const_for_array.rs:6:5
|
||||
|
|
||||
LL | example::<[usize; 3]>();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ cannot infer the value of the const parameter `N` declared on the function `example`
|
||||
|
|
||||
note: required by a const generic parameter in `example`
|
||||
--> $DIR/suggest_const_for_array.rs:3:12
|
||||
|
|
||||
LL | fn example<const N: usize>() {}
|
||||
| ^^^^^^^^^^^^^^ required by this const generic parameter in `example`
|
||||
|
||||
For more information about this error, try `rustc --explain E0747`.
|
||||
error[E0284]: type annotations needed
|
||||
--> $DIR/suggest_const_for_array.rs:9:5
|
||||
|
|
||||
LL | example::<[usize; 4 + 5]>();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer the value of the const parameter `N` declared on the function `example`
|
||||
|
|
||||
note: required by a const generic parameter in `example`
|
||||
--> $DIR/suggest_const_for_array.rs:3:12
|
||||
|
|
||||
LL | fn example<const N: usize>() {}
|
||||
| ^^^^^^^^^^^^^^ required by this const generic parameter in `example`
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0284, E0747.
|
||||
For more information about an error, try `rustc --explain E0284`.
|
||||
|
@ -3,4 +3,5 @@ fn foo<U>() {}
|
||||
fn main() {
|
||||
foo::<main>()
|
||||
//~^ ERROR constant provided when a type was expected
|
||||
//~| ERROR type annotations needed
|
||||
}
|
||||
|
@ -7,6 +7,13 @@ LL | foo::<main>()
|
||||
= help: `main` is a function item, not a type
|
||||
= help: function item types cannot be named directly
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
error[E0282]: type annotations needed
|
||||
--> $DIR/generic-function-item-where-type.rs:4:5
|
||||
|
|
||||
LL | foo::<main>()
|
||||
| ^^^^^^^^^^^ cannot infer type of the type parameter `U` declared on the function `foo`
|
||||
|
||||
For more information about this error, try `rustc --explain E0747`.
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0282, E0747.
|
||||
For more information about an error, try `rustc --explain E0282`.
|
||||
|
@ -2,6 +2,7 @@
|
||||
use std::fmt::Debug;
|
||||
|
||||
fn a<'a>() -> impl Fn(&'a u8) -> (impl Debug + '_) {
|
||||
//~^ ERROR cannot resolve opaque type
|
||||
|x| x
|
||||
//~^ ERROR expected generic lifetime parameter, found `'_`
|
||||
}
|
||||
|
@ -1,11 +1,19 @@
|
||||
error[E0792]: expected generic lifetime parameter, found `'_`
|
||||
--> $DIR/impl-fn-predefined-lifetimes.rs:5:9
|
||||
--> $DIR/impl-fn-predefined-lifetimes.rs:6:9
|
||||
|
|
||||
LL | fn a<'a>() -> impl Fn(&'a u8) -> (impl Debug + '_) {
|
||||
| -- this generic parameter must be used with a generic lifetime parameter
|
||||
LL |
|
||||
LL | |x| x
|
||||
| ^
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
error[E0720]: cannot resolve opaque type
|
||||
--> $DIR/impl-fn-predefined-lifetimes.rs:4:35
|
||||
|
|
||||
LL | fn a<'a>() -> impl Fn(&'a u8) -> (impl Debug + '_) {
|
||||
| ^^^^^^^^^^^^^^^ cannot resolve opaque type
|
||||
|
||||
For more information about this error, try `rustc --explain E0792`.
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0720, E0792.
|
||||
For more information about an error, try `rustc --explain E0720`.
|
||||
|
@ -5,6 +5,7 @@
|
||||
use std::mem::transmute;
|
||||
fn foo() -> impl Sized {
|
||||
//~^ ERROR cycle detected when computing type of
|
||||
//~| WARN function cannot return without recursing
|
||||
unsafe {
|
||||
transmute::<_, u8>(foo());
|
||||
}
|
||||
|
@ -24,6 +24,18 @@ LL | fn foo() -> impl Sized {
|
||||
| ^^^^^^^^^^
|
||||
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
warning: function cannot return without recursing
|
||||
--> $DIR/in-defining-scope.rs:6:1
|
||||
|
|
||||
LL | fn foo() -> impl Sized {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ cannot return without recursing
|
||||
...
|
||||
LL | transmute::<_, u8>(foo());
|
||||
| ----- recursive call site
|
||||
|
|
||||
= help: a `loop` may express intention better if this is on purpose
|
||||
= note: `#[warn(unconditional_recursion)]` on by default
|
||||
|
||||
error: aborting due to 1 previous error; 1 warning emitted
|
||||
|
||||
For more information about this error, try `rustc --explain E0391`.
|
||||
|
@ -1,5 +1,6 @@
|
||||
struct Take(Take);
|
||||
//~^ ERROR has infinite size
|
||||
//~| ERROR cycle
|
||||
|
||||
// check that we don't hang trying to find the tail of a recursive struct (#79437)
|
||||
fn foo() -> Take {
|
||||
|
@ -10,7 +10,7 @@ LL | struct Take(Box<Take>);
|
||||
| ++++ +
|
||||
|
||||
error[E0072]: recursive type `Foo` has infinite size
|
||||
--> $DIR/infinite-struct.rs:10:1
|
||||
--> $DIR/infinite-struct.rs:11:1
|
||||
|
|
||||
LL | struct Foo {
|
||||
| ^^^^^^^^^^
|
||||
@ -26,6 +26,17 @@ error: reached the recursion limit finding the struct tail for `Take`
|
||||
|
|
||||
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]`
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
error[E0391]: cycle detected when computing when `Take` needs drop
|
||||
--> $DIR/infinite-struct.rs:1:1
|
||||
|
|
||||
LL | struct Take(Take);
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
= note: ...which immediately requires computing when `Take` needs drop again
|
||||
= note: cycle used when computing whether `Take` needs drop
|
||||
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
|
||||
|
||||
For more information about this error, try `rustc --explain E0072`.
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0072, E0391.
|
||||
For more information about an error, try `rustc --explain E0072`.
|
||||
|
@ -1,26 +0,0 @@
|
||||
//@ compile-flags: --edition 2024 -Z unstable-options
|
||||
|
||||
fn main() {}
|
||||
|
||||
unsafe fn _foo() {
|
||||
static mut X: i32 = 1;
|
||||
static mut Y: i32 = 1;
|
||||
|
||||
let _y = &X;
|
||||
//~^ ERROR creating a shared reference to a mutable static [E0796]
|
||||
|
||||
let ref _a = X;
|
||||
//~^ ERROR creating a shared reference to a mutable static [E0796]
|
||||
|
||||
let ref mut _a = X;
|
||||
//~^ ERROR creating a mutable reference to a mutable static [E0796]
|
||||
|
||||
let (_b, _c) = (&X, &mut Y);
|
||||
//~^ ERROR creating a shared reference to a mutable static [E0796]
|
||||
//~^^ ERROR creating a mutable reference to a mutable static [E0796]
|
||||
|
||||
foo(&X);
|
||||
//~^ ERROR creating a shared reference to a mutable static [E0796]
|
||||
}
|
||||
|
||||
fn foo<'a>(_x: &'a i32) {}
|
@ -1,75 +0,0 @@
|
||||
error[E0796]: creating a shared reference to a mutable static
|
||||
--> $DIR/reference-of-mut-static-unsafe-fn.rs:9:14
|
||||
|
|
||||
LL | let _y = &X;
|
||||
| ^^ shared reference to mutable static
|
||||
|
|
||||
= note: this shared reference has lifetime `'static`, but if the static ever gets mutated, or a mutable reference is created, then any further use of this shared reference is Undefined Behavior
|
||||
help: use `addr_of!` instead to create a raw pointer
|
||||
|
|
||||
LL | let _y = addr_of!(X);
|
||||
| ~~~~~~~~~~~
|
||||
|
||||
error[E0796]: creating a shared reference to a mutable static
|
||||
--> $DIR/reference-of-mut-static-unsafe-fn.rs:12:18
|
||||
|
|
||||
LL | let ref _a = X;
|
||||
| ^ shared reference to mutable static
|
||||
|
|
||||
= note: this shared reference has lifetime `'static`, but if the static ever gets mutated, or a mutable reference is created, then any further use of this shared reference is Undefined Behavior
|
||||
help: use `addr_of!` instead to create a raw pointer
|
||||
|
|
||||
LL | let ref _a = addr_of!(X);
|
||||
| ~~~~~~~~~~~
|
||||
|
||||
error[E0796]: creating a mutable reference to a mutable static
|
||||
--> $DIR/reference-of-mut-static-unsafe-fn.rs:15:22
|
||||
|
|
||||
LL | let ref mut _a = X;
|
||||
| ^ mutable reference to mutable static
|
||||
|
|
||||
= note: this mutable reference has lifetime `'static`, but if the static gets accessed (read or written) by any other means, or any other reference is created, then any further use of this mutable reference is Undefined Behavior
|
||||
help: use `addr_of_mut!` instead to create a raw pointer
|
||||
|
|
||||
LL | let ref mut _a = addr_of_mut!(X);
|
||||
| ~~~~~~~~~~~~~~~
|
||||
|
||||
error[E0796]: creating a shared reference to a mutable static
|
||||
--> $DIR/reference-of-mut-static-unsafe-fn.rs:18:21
|
||||
|
|
||||
LL | let (_b, _c) = (&X, &mut Y);
|
||||
| ^^ shared reference to mutable static
|
||||
|
|
||||
= note: this shared reference has lifetime `'static`, but if the static ever gets mutated, or a mutable reference is created, then any further use of this shared reference is Undefined Behavior
|
||||
help: use `addr_of!` instead to create a raw pointer
|
||||
|
|
||||
LL | let (_b, _c) = (addr_of!(X), &mut Y);
|
||||
| ~~~~~~~~~~~
|
||||
|
||||
error[E0796]: creating a mutable reference to a mutable static
|
||||
--> $DIR/reference-of-mut-static-unsafe-fn.rs:18:25
|
||||
|
|
||||
LL | let (_b, _c) = (&X, &mut Y);
|
||||
| ^^^^^^ mutable reference to mutable static
|
||||
|
|
||||
= note: this mutable reference has lifetime `'static`, but if the static gets accessed (read or written) by any other means, or any other reference is created, then any further use of this mutable reference is Undefined Behavior
|
||||
help: use `addr_of_mut!` instead to create a raw pointer
|
||||
|
|
||||
LL | let (_b, _c) = (&X, addr_of_mut!(Y));
|
||||
| ~~~~~~~~~~~~~~~
|
||||
|
||||
error[E0796]: creating a shared reference to a mutable static
|
||||
--> $DIR/reference-of-mut-static-unsafe-fn.rs:22:9
|
||||
|
|
||||
LL | foo(&X);
|
||||
| ^^ shared reference to mutable static
|
||||
|
|
||||
= note: this shared reference has lifetime `'static`, but if the static ever gets mutated, or a mutable reference is created, then any further use of this shared reference is Undefined Behavior
|
||||
help: use `addr_of!` instead to create a raw pointer
|
||||
|
|
||||
LL | foo(addr_of!(X));
|
||||
| ~~~~~~~~~~~
|
||||
|
||||
error: aborting due to 6 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0796`.
|
@ -1,91 +0,0 @@
|
||||
error: creating a shared reference to mutable static is discouraged
|
||||
--> $DIR/reference-of-mut-static.rs:16:18
|
||||
|
|
||||
LL | let _y = &X;
|
||||
| ^^ shared reference to mutable static
|
||||
|
|
||||
= note: for more information, see issue #114447 <https://github.com/rust-lang/rust/issues/114447>
|
||||
= note: this will be a hard error in the 2024 edition
|
||||
= note: this shared reference has lifetime `'static`, but if the static ever gets mutated, or a mutable reference is created, then any further use of this shared reference is Undefined Behavior
|
||||
note: the lint level is defined here
|
||||
--> $DIR/reference-of-mut-static.rs:6:9
|
||||
|
|
||||
LL | #![deny(static_mut_refs)]
|
||||
| ^^^^^^^^^^^^^^^
|
||||
help: use `addr_of!` instead to create a raw pointer
|
||||
|
|
||||
LL | let _y = addr_of!(X);
|
||||
| ~~~~~~~~~~~
|
||||
|
||||
error: creating a mutable reference to mutable static is discouraged
|
||||
--> $DIR/reference-of-mut-static.rs:20:18
|
||||
|
|
||||
LL | let _y = &mut X;
|
||||
| ^^^^^^ mutable reference to mutable static
|
||||
|
|
||||
= note: for more information, see issue #114447 <https://github.com/rust-lang/rust/issues/114447>
|
||||
= note: this will be a hard error in the 2024 edition
|
||||
= note: this mutable reference has lifetime `'static`, but if the static gets accessed (read or written) by any other means, or any other reference is created, then any further use of this mutable reference is Undefined Behavior
|
||||
help: use `addr_of_mut!` instead to create a raw pointer
|
||||
|
|
||||
LL | let _y = addr_of_mut!(X);
|
||||
| ~~~~~~~~~~~~~~~
|
||||
|
||||
error: creating a shared reference to mutable static is discouraged
|
||||
--> $DIR/reference-of-mut-static.rs:28:22
|
||||
|
|
||||
LL | let ref _a = X;
|
||||
| ^ shared reference to mutable static
|
||||
|
|
||||
= note: for more information, see issue #114447 <https://github.com/rust-lang/rust/issues/114447>
|
||||
= note: this will be a hard error in the 2024 edition
|
||||
= note: this shared reference has lifetime `'static`, but if the static ever gets mutated, or a mutable reference is created, then any further use of this shared reference is Undefined Behavior
|
||||
help: use `addr_of!` instead to create a raw pointer
|
||||
|
|
||||
LL | let ref _a = addr_of!(X);
|
||||
| ~~~~~~~~~~~
|
||||
|
||||
error: creating a shared reference to mutable static is discouraged
|
||||
--> $DIR/reference-of-mut-static.rs:32:25
|
||||
|
|
||||
LL | let (_b, _c) = (&X, &Y);
|
||||
| ^^ shared reference to mutable static
|
||||
|
|
||||
= note: for more information, see issue #114447 <https://github.com/rust-lang/rust/issues/114447>
|
||||
= note: this will be a hard error in the 2024 edition
|
||||
= note: this shared reference has lifetime `'static`, but if the static ever gets mutated, or a mutable reference is created, then any further use of this shared reference is Undefined Behavior
|
||||
help: use `addr_of!` instead to create a raw pointer
|
||||
|
|
||||
LL | let (_b, _c) = (addr_of!(X), &Y);
|
||||
| ~~~~~~~~~~~
|
||||
|
||||
error: creating a shared reference to mutable static is discouraged
|
||||
--> $DIR/reference-of-mut-static.rs:32:29
|
||||
|
|
||||
LL | let (_b, _c) = (&X, &Y);
|
||||
| ^^ shared reference to mutable static
|
||||
|
|
||||
= note: for more information, see issue #114447 <https://github.com/rust-lang/rust/issues/114447>
|
||||
= note: this will be a hard error in the 2024 edition
|
||||
= note: this shared reference has lifetime `'static`, but if the static ever gets mutated, or a mutable reference is created, then any further use of this shared reference is Undefined Behavior
|
||||
help: use `addr_of!` instead to create a raw pointer
|
||||
|
|
||||
LL | let (_b, _c) = (&X, addr_of!(Y));
|
||||
| ~~~~~~~~~~~
|
||||
|
||||
error: creating a shared reference to mutable static is discouraged
|
||||
--> $DIR/reference-of-mut-static.rs:38:13
|
||||
|
|
||||
LL | foo(&X);
|
||||
| ^^ shared reference to mutable static
|
||||
|
|
||||
= note: for more information, see issue #114447 <https://github.com/rust-lang/rust/issues/114447>
|
||||
= note: this will be a hard error in the 2024 edition
|
||||
= note: this shared reference has lifetime `'static`, but if the static ever gets mutated, or a mutable reference is created, then any further use of this shared reference is Undefined Behavior
|
||||
help: use `addr_of!` instead to create a raw pointer
|
||||
|
|
||||
LL | foo(addr_of!(X));
|
||||
| ~~~~~~~~~~~
|
||||
|
||||
error: aborting due to 6 previous errors
|
||||
|
@ -1,75 +0,0 @@
|
||||
error[E0796]: creating a shared reference to a mutable static
|
||||
--> $DIR/reference-of-mut-static.rs:16:18
|
||||
|
|
||||
LL | let _y = &X;
|
||||
| ^^ shared reference to mutable static
|
||||
|
|
||||
= note: this shared reference has lifetime `'static`, but if the static ever gets mutated, or a mutable reference is created, then any further use of this shared reference is Undefined Behavior
|
||||
help: use `addr_of!` instead to create a raw pointer
|
||||
|
|
||||
LL | let _y = addr_of!(X);
|
||||
| ~~~~~~~~~~~
|
||||
|
||||
error[E0796]: creating a mutable reference to a mutable static
|
||||
--> $DIR/reference-of-mut-static.rs:20:18
|
||||
|
|
||||
LL | let _y = &mut X;
|
||||
| ^^^^^^ mutable reference to mutable static
|
||||
|
|
||||
= note: this mutable reference has lifetime `'static`, but if the static gets accessed (read or written) by any other means, or any other reference is created, then any further use of this mutable reference is Undefined Behavior
|
||||
help: use `addr_of_mut!` instead to create a raw pointer
|
||||
|
|
||||
LL | let _y = addr_of_mut!(X);
|
||||
| ~~~~~~~~~~~~~~~
|
||||
|
||||
error[E0796]: creating a shared reference to a mutable static
|
||||
--> $DIR/reference-of-mut-static.rs:28:22
|
||||
|
|
||||
LL | let ref _a = X;
|
||||
| ^ shared reference to mutable static
|
||||
|
|
||||
= note: this shared reference has lifetime `'static`, but if the static ever gets mutated, or a mutable reference is created, then any further use of this shared reference is Undefined Behavior
|
||||
help: use `addr_of!` instead to create a raw pointer
|
||||
|
|
||||
LL | let ref _a = addr_of!(X);
|
||||
| ~~~~~~~~~~~
|
||||
|
||||
error[E0796]: creating a shared reference to a mutable static
|
||||
--> $DIR/reference-of-mut-static.rs:32:25
|
||||
|
|
||||
LL | let (_b, _c) = (&X, &Y);
|
||||
| ^^ shared reference to mutable static
|
||||
|
|
||||
= note: this shared reference has lifetime `'static`, but if the static ever gets mutated, or a mutable reference is created, then any further use of this shared reference is Undefined Behavior
|
||||
help: use `addr_of!` instead to create a raw pointer
|
||||
|
|
||||
LL | let (_b, _c) = (addr_of!(X), &Y);
|
||||
| ~~~~~~~~~~~
|
||||
|
||||
error[E0796]: creating a shared reference to a mutable static
|
||||
--> $DIR/reference-of-mut-static.rs:32:29
|
||||
|
|
||||
LL | let (_b, _c) = (&X, &Y);
|
||||
| ^^ shared reference to mutable static
|
||||
|
|
||||
= note: this shared reference has lifetime `'static`, but if the static ever gets mutated, or a mutable reference is created, then any further use of this shared reference is Undefined Behavior
|
||||
help: use `addr_of!` instead to create a raw pointer
|
||||
|
|
||||
LL | let (_b, _c) = (&X, addr_of!(Y));
|
||||
| ~~~~~~~~~~~
|
||||
|
||||
error[E0796]: creating a shared reference to a mutable static
|
||||
--> $DIR/reference-of-mut-static.rs:38:13
|
||||
|
|
||||
LL | foo(&X);
|
||||
| ^^ shared reference to mutable static
|
||||
|
|
||||
= note: this shared reference has lifetime `'static`, but if the static ever gets mutated, or a mutable reference is created, then any further use of this shared reference is Undefined Behavior
|
||||
help: use `addr_of!` instead to create a raw pointer
|
||||
|
|
||||
LL | foo(addr_of!(X));
|
||||
| ~~~~~~~~~~~
|
||||
|
||||
error: aborting due to 6 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0796`.
|
@ -1,50 +0,0 @@
|
||||
//@ revisions: e2021 e2024
|
||||
|
||||
//@ [e2021] edition:2021
|
||||
//@ [e2024] compile-flags: --edition 2024 -Z unstable-options
|
||||
|
||||
#![deny(static_mut_refs)]
|
||||
|
||||
use std::ptr::{addr_of, addr_of_mut};
|
||||
|
||||
fn main() {
|
||||
static mut X: i32 = 1;
|
||||
|
||||
static mut Y: i32 = 1;
|
||||
|
||||
unsafe {
|
||||
let _y = &X;
|
||||
//[e2024]~^ ERROR creating a shared reference to a mutable static [E0796]
|
||||
//[e2021]~^^ ERROR shared reference to mutable static is discouraged [static_mut_refs]
|
||||
|
||||
let _y = &mut X;
|
||||
//[e2024]~^ ERROR creating a mutable reference to a mutable static [E0796]
|
||||
//[e2021]~^^ ERROR mutable reference to mutable static is discouraged [static_mut_refs]
|
||||
|
||||
let _z = addr_of_mut!(X);
|
||||
|
||||
let _p = addr_of!(X);
|
||||
|
||||
let ref _a = X;
|
||||
//[e2024]~^ ERROR creating a shared reference to a mutable static [E0796]
|
||||
//[e2021]~^^ ERROR shared reference to mutable static is discouraged [static_mut_refs]
|
||||
|
||||
let (_b, _c) = (&X, &Y);
|
||||
//[e2024]~^ ERROR creating a shared reference to a mutable static [E0796]
|
||||
//[e2021]~^^ ERROR shared reference to mutable static is discouraged [static_mut_refs]
|
||||
//[e2024]~^^^ ERROR creating a shared reference to a mutable static [E0796]
|
||||
//[e2021]~^^^^ ERROR shared reference to mutable static is discouraged [static_mut_refs]
|
||||
|
||||
foo(&X);
|
||||
//[e2024]~^ ERROR creating a shared reference to a mutable static [E0796]
|
||||
//[e2021]~^^ ERROR shared reference to mutable static is discouraged [static_mut_refs]
|
||||
|
||||
static mut Z: &[i32; 3] = &[0, 1, 2];
|
||||
|
||||
let _ = Z.len();
|
||||
let _ = Z[0];
|
||||
let _ = format!("{:?}", Z);
|
||||
}
|
||||
}
|
||||
|
||||
fn foo<'a>(_x: &'a i32) {}
|
@ -10,6 +10,15 @@ help: use `addr_of!` instead to create a raw pointer
|
||||
LL | let _x = addr_of!(X);
|
||||
| ~~~~~~~~~~~
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
error[E0133]: use of mutable static is unsafe and requires unsafe block
|
||||
--> $DIR/reference-to-mut-static-safe.rs:9:15
|
||||
|
|
||||
LL | let _x = &X;
|
||||
| ^ use of mutable static
|
||||
|
|
||||
= note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior
|
||||
|
||||
For more information about this error, try `rustc --explain E0796`.
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0133, E0796.
|
||||
For more information about an error, try `rustc --explain E0133`.
|
||||
|
@ -8,6 +8,6 @@ fn main() {
|
||||
|
||||
let _x = &X;
|
||||
//[e2024]~^ creating a shared reference to a mutable static [E0796]
|
||||
//[e2021]~^^ use of mutable static is unsafe and requires unsafe function or block [E0133]
|
||||
//~^^ use of mutable static is unsafe and requires unsafe
|
||||
//[e2021]~^^^ shared reference to mutable static is discouraged [static_mut_refs]
|
||||
}
|
||||
|
@ -3,24 +3,26 @@
|
||||
fn main() {}
|
||||
|
||||
unsafe fn _foo() {
|
||||
static mut X: i32 = 1;
|
||||
static mut Y: i32 = 1;
|
||||
unsafe {
|
||||
static mut X: i32 = 1;
|
||||
static mut Y: i32 = 1;
|
||||
|
||||
let _y = &X;
|
||||
//~^ ERROR creating a shared reference to a mutable static [E0796]
|
||||
let _y = &X;
|
||||
//~^ ERROR creating a shared reference to a mutable static [E0796]
|
||||
|
||||
let ref _a = X;
|
||||
//~^ ERROR creating a shared reference to a mutable static [E0796]
|
||||
let ref _a = X;
|
||||
//~^ ERROR creating a shared reference to a mutable static [E0796]
|
||||
|
||||
let ref mut _a = X;
|
||||
//~^ ERROR creating a mutable reference to a mutable static [E0796]
|
||||
let ref mut _a = X;
|
||||
//~^ ERROR creating a mutable reference to a mutable static [E0796]
|
||||
|
||||
let (_b, _c) = (&X, &mut Y);
|
||||
//~^ ERROR creating a shared reference to a mutable static [E0796]
|
||||
//~^^ ERROR creating a mutable reference to a mutable static [E0796]
|
||||
let (_b, _c) = (&X, &mut Y);
|
||||
//~^ ERROR creating a shared reference to a mutable static [E0796]
|
||||
//~^^ ERROR creating a mutable reference to a mutable static [E0796]
|
||||
|
||||
foo(&X);
|
||||
//~^ ERROR creating a shared reference to a mutable static [E0796]
|
||||
foo(&X);
|
||||
//~^ ERROR creating a shared reference to a mutable static [E0796]
|
||||
}
|
||||
}
|
||||
|
||||
fn foo<'a>(_x: &'a i32) {}
|
||||
|
@ -1,74 +1,74 @@
|
||||
error[E0796]: creating a shared reference to a mutable static
|
||||
--> $DIR/reference-to-mut-static-unsafe-fn.rs:9:14
|
||||
--> $DIR/reference-to-mut-static-unsafe-fn.rs:10:18
|
||||
|
|
||||
LL | let _y = &X;
|
||||
| ^^ shared reference to mutable static
|
||||
LL | let _y = &X;
|
||||
| ^^ shared reference to mutable static
|
||||
|
|
||||
= note: this shared reference has lifetime `'static`, but if the static ever gets mutated, or a mutable reference is created, then any further use of this shared reference is Undefined Behavior
|
||||
help: use `addr_of!` instead to create a raw pointer
|
||||
|
|
||||
LL | let _y = addr_of!(X);
|
||||
| ~~~~~~~~~~~
|
||||
|
||||
error[E0796]: creating a shared reference to a mutable static
|
||||
--> $DIR/reference-to-mut-static-unsafe-fn.rs:12:18
|
||||
|
|
||||
LL | let ref _a = X;
|
||||
| ^ shared reference to mutable static
|
||||
|
|
||||
= note: this shared reference has lifetime `'static`, but if the static ever gets mutated, or a mutable reference is created, then any further use of this shared reference is Undefined Behavior
|
||||
help: use `addr_of!` instead to create a raw pointer
|
||||
|
|
||||
LL | let ref _a = addr_of!(X);
|
||||
LL | let _y = addr_of!(X);
|
||||
| ~~~~~~~~~~~
|
||||
|
||||
error[E0796]: creating a mutable reference to a mutable static
|
||||
--> $DIR/reference-to-mut-static-unsafe-fn.rs:15:22
|
||||
|
|
||||
LL | let ref mut _a = X;
|
||||
| ^ mutable reference to mutable static
|
||||
|
|
||||
= note: this mutable reference has lifetime `'static`, but if the static gets accessed (read or written) by any other means, or any other reference is created, then any further use of this mutable reference is Undefined Behavior
|
||||
help: use `addr_of_mut!` instead to create a raw pointer
|
||||
|
|
||||
LL | let ref mut _a = addr_of_mut!(X);
|
||||
| ~~~~~~~~~~~~~~~
|
||||
|
||||
error[E0796]: creating a shared reference to a mutable static
|
||||
--> $DIR/reference-to-mut-static-unsafe-fn.rs:18:21
|
||||
--> $DIR/reference-to-mut-static-unsafe-fn.rs:13:22
|
||||
|
|
||||
LL | let (_b, _c) = (&X, &mut Y);
|
||||
| ^^ shared reference to mutable static
|
||||
LL | let ref _a = X;
|
||||
| ^ shared reference to mutable static
|
||||
|
|
||||
= note: this shared reference has lifetime `'static`, but if the static ever gets mutated, or a mutable reference is created, then any further use of this shared reference is Undefined Behavior
|
||||
help: use `addr_of!` instead to create a raw pointer
|
||||
|
|
||||
LL | let (_b, _c) = (addr_of!(X), &mut Y);
|
||||
| ~~~~~~~~~~~
|
||||
LL | let ref _a = addr_of!(X);
|
||||
| ~~~~~~~~~~~
|
||||
|
||||
error[E0796]: creating a mutable reference to a mutable static
|
||||
--> $DIR/reference-to-mut-static-unsafe-fn.rs:18:25
|
||||
--> $DIR/reference-to-mut-static-unsafe-fn.rs:16:26
|
||||
|
|
||||
LL | let (_b, _c) = (&X, &mut Y);
|
||||
| ^^^^^^ mutable reference to mutable static
|
||||
LL | let ref mut _a = X;
|
||||
| ^ mutable reference to mutable static
|
||||
|
|
||||
= note: this mutable reference has lifetime `'static`, but if the static gets accessed (read or written) by any other means, or any other reference is created, then any further use of this mutable reference is Undefined Behavior
|
||||
help: use `addr_of_mut!` instead to create a raw pointer
|
||||
|
|
||||
LL | let (_b, _c) = (&X, addr_of_mut!(Y));
|
||||
| ~~~~~~~~~~~~~~~
|
||||
LL | let ref mut _a = addr_of_mut!(X);
|
||||
| ~~~~~~~~~~~~~~~
|
||||
|
||||
error[E0796]: creating a shared reference to a mutable static
|
||||
--> $DIR/reference-to-mut-static-unsafe-fn.rs:22:9
|
||||
--> $DIR/reference-to-mut-static-unsafe-fn.rs:19:25
|
||||
|
|
||||
LL | foo(&X);
|
||||
| ^^ shared reference to mutable static
|
||||
LL | let (_b, _c) = (&X, &mut Y);
|
||||
| ^^ shared reference to mutable static
|
||||
|
|
||||
= note: this shared reference has lifetime `'static`, but if the static ever gets mutated, or a mutable reference is created, then any further use of this shared reference is Undefined Behavior
|
||||
help: use `addr_of!` instead to create a raw pointer
|
||||
|
|
||||
LL | foo(addr_of!(X));
|
||||
| ~~~~~~~~~~~
|
||||
LL | let (_b, _c) = (addr_of!(X), &mut Y);
|
||||
| ~~~~~~~~~~~
|
||||
|
||||
error[E0796]: creating a mutable reference to a mutable static
|
||||
--> $DIR/reference-to-mut-static-unsafe-fn.rs:19:29
|
||||
|
|
||||
LL | let (_b, _c) = (&X, &mut Y);
|
||||
| ^^^^^^ mutable reference to mutable static
|
||||
|
|
||||
= note: this mutable reference has lifetime `'static`, but if the static gets accessed (read or written) by any other means, or any other reference is created, then any further use of this mutable reference is Undefined Behavior
|
||||
help: use `addr_of_mut!` instead to create a raw pointer
|
||||
|
|
||||
LL | let (_b, _c) = (&X, addr_of_mut!(Y));
|
||||
| ~~~~~~~~~~~~~~~
|
||||
|
||||
error[E0796]: creating a shared reference to a mutable static
|
||||
--> $DIR/reference-to-mut-static-unsafe-fn.rs:23:13
|
||||
|
|
||||
LL | foo(&X);
|
||||
| ^^ shared reference to mutable static
|
||||
|
|
||||
= note: this shared reference has lifetime `'static`, but if the static ever gets mutated, or a mutable reference is created, then any further use of this shared reference is Undefined Behavior
|
||||
help: use `addr_of!` instead to create a raw pointer
|
||||
|
|
||||
LL | foo(addr_of!(X));
|
||||
| ~~~~~~~~~~~
|
||||
|
||||
error: aborting due to 6 previous errors
|
||||
|
||||
|
@ -44,18 +44,6 @@ LL |
|
||||
LL | call(operation).await
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0792]: expected generic lifetime parameter, found `'any`
|
||||
--> $DIR/hkl_forbidden4.rs:23:1
|
||||
|
|
||||
LL | type FutNothing<'a> = impl 'a + Future<Output = ()>;
|
||||
| -- this generic parameter must be used with a generic lifetime parameter
|
||||
...
|
||||
LL | / {
|
||||
LL | |
|
||||
LL | |
|
||||
LL | | }
|
||||
| |_^
|
||||
|
||||
error: concrete type differs from previous defining opaque type use
|
||||
--> $DIR/hkl_forbidden4.rs:13:1
|
||||
|
|
||||
@ -68,6 +56,18 @@ note: previous use here
|
||||
LL | call(operation).await
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0792]: expected generic lifetime parameter, found `'any`
|
||||
--> $DIR/hkl_forbidden4.rs:23:1
|
||||
|
|
||||
LL | type FutNothing<'a> = impl 'a + Future<Output = ()>;
|
||||
| -- this generic parameter must be used with a generic lifetime parameter
|
||||
...
|
||||
LL | / {
|
||||
LL | |
|
||||
LL | |
|
||||
LL | | }
|
||||
| |_^
|
||||
|
||||
error: aborting due to 6 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0792`.
|
||||
|
@ -5,6 +5,8 @@ type Bug<T, U> = impl Fn(T) -> U + Copy; //~ ERROR cycle detected
|
||||
|
||||
const CONST_BUG: Bug<u8, ()> = unsafe { std::mem::transmute(|_: u8| ()) };
|
||||
//~^ ERROR: non-defining opaque type use
|
||||
//~| ERROR: item does not constrain
|
||||
//~| ERROR: item does not constrain
|
||||
|
||||
fn make_bug<T, U: From<T>>() -> Bug<T, U> {
|
||||
|x| x.into() //~ ERROR the trait bound `U: From<T>` is not satisfied
|
||||
|
@ -36,14 +36,40 @@ LL | type Bug<T, U> = impl Fn(T) -> U + Copy;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
|
||||
|
||||
error: item does not constrain `Bug::{opaque#0}`, but has it in its signature
|
||||
--> $DIR/issue-53092-2.rs:6:7
|
||||
|
|
||||
LL | const CONST_BUG: Bug<u8, ()> = unsafe { std::mem::transmute(|_: u8| ()) };
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: consider moving the opaque type's declaration and defining uses into a separate module
|
||||
note: this opaque type is in the signature
|
||||
--> $DIR/issue-53092-2.rs:4:18
|
||||
|
|
||||
LL | type Bug<T, U> = impl Fn(T) -> U + Copy;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: item does not constrain `Bug::{opaque#0}`, but has it in its signature
|
||||
--> $DIR/issue-53092-2.rs:6:61
|
||||
|
|
||||
LL | const CONST_BUG: Bug<u8, ()> = unsafe { std::mem::transmute(|_: u8| ()) };
|
||||
| ^^^^^^^
|
||||
|
|
||||
= note: consider moving the opaque type's declaration and defining uses into a separate module
|
||||
note: this opaque type is in the signature
|
||||
--> $DIR/issue-53092-2.rs:4:18
|
||||
|
|
||||
LL | type Bug<T, U> = impl Fn(T) -> U + Copy;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0277]: the trait bound `U: From<T>` is not satisfied
|
||||
--> $DIR/issue-53092-2.rs:10:5
|
||||
--> $DIR/issue-53092-2.rs:12:5
|
||||
|
|
||||
LL | |x| x.into()
|
||||
| ^^^^^^^^^^^^ the trait `From<T>` is not implemented for `U`
|
||||
|
|
||||
note: required by a bound in `make_bug`
|
||||
--> $DIR/issue-53092-2.rs:9:19
|
||||
--> $DIR/issue-53092-2.rs:11:19
|
||||
|
|
||||
LL | fn make_bug<T, U: From<T>>() -> Bug<T, U> {
|
||||
| ^^^^^^^ required by this bound in `make_bug`
|
||||
@ -52,7 +78,7 @@ help: consider restricting type parameter `U`
|
||||
LL | type Bug<T, U: std::convert::From<T>> = impl Fn(T) -> U + Copy;
|
||||
| +++++++++++++++++++++++
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
error: aborting due to 5 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0277, E0391, E0792.
|
||||
For more information about an error, try `rustc --explain E0277`.
|
||||
|
Loading…
Reference in New Issue
Block a user