1
Fork 0

Auto merge of #121383 - Dylan-DPC:rollup-735p4u4, r=Dylan-DPC

Rollup of 7 pull requests

Successful merges:

 - #121208 (Convert `delayed_bug`s to `bug`s.)
 - #121288 (make rustc_expand translatable)
 - #121304 (Add docs for extension proc-macro)
 - #121328 (Make --verbose imply -Z write-long-types-to-disk=no)
 - #121338 (Downgrade ambiguous_wide_pointer_comparisons suggestions to MaybeIncorrect)
 - #121361 (diagnostic items for legacy numeric modules)
 - #121375 (Print proper relative path for descriptive name check)

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2024-02-21 12:09:22 +00:00
commit 1d447a9946
55 changed files with 292 additions and 174 deletions

View file

@ -1636,9 +1636,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
if let Some(old_def_id) = self.orig_opt_local_def_id(param) { if let Some(old_def_id) = self.orig_opt_local_def_id(param) {
old_def_id old_def_id
} else { } else {
self.dcx() self.dcx().span_bug(lifetime.ident.span, "no def-id for fresh lifetime");
.span_delayed_bug(lifetime.ident.span, "no def-id for fresh lifetime");
continue;
} }
} }

View file

@ -626,9 +626,9 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
| GenericArgKind::Const(_), | GenericArgKind::Const(_),
_, _,
) => { ) => {
// HIR lowering sometimes doesn't catch this in erroneous // This was previously a `span_delayed_bug` and could be
// programs, so we need to use span_delayed_bug here. See #82126. // reached by the test for #82126, but no longer.
self.dcx().span_delayed_bug( self.dcx().span_bug(
hir_arg.span(), hir_arg.span(),
format!("unmatched arg and hir arg: found {kind:?} vs {hir_arg:?}"), format!("unmatched arg and hir arg: found {kind:?} vs {hir_arg:?}"),
); );

View file

@ -316,6 +316,9 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> {
.and(type_op::normalize::Normalize::new(ty)) .and(type_op::normalize::Normalize::new(ty))
.fully_perform(self.infcx, span) .fully_perform(self.infcx, span)
else { else {
// 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_delayed_bug(span, format!("failed to normalize {ty:?}")); tcx.dcx().span_delayed_bug(span, format!("failed to normalize {ty:?}"));
continue; continue;
}; };

View file

@ -154,8 +154,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
if argument_index + 1 >= body.local_decls.len() { if argument_index + 1 >= body.local_decls.len() {
self.tcx() self.tcx()
.dcx() .dcx()
.span_delayed_bug(body.span, "found more normalized_input_ty than local_decls"); .span_bug(body.span, "found more normalized_input_ty than local_decls");
break;
} }
// In MIR, argument N is stored in local N+1. // In MIR, argument N is stored in local N+1.

View file

@ -220,14 +220,13 @@ pub(crate) fn type_check<'mir, 'tcx>(
"opaque_type_map", "opaque_type_map",
), ),
); );
let mut hidden_type = infcx.resolve_vars_if_possible(decl.hidden_type); let hidden_type = infcx.resolve_vars_if_possible(decl.hidden_type);
trace!("finalized opaque type {:?} to {:#?}", opaque_type_key, hidden_type.ty.kind()); trace!("finalized opaque type {:?} to {:#?}", opaque_type_key, hidden_type.ty.kind());
if hidden_type.has_non_region_infer() { if hidden_type.has_non_region_infer() {
let reported = infcx.dcx().span_delayed_bug( infcx.dcx().span_bug(
decl.hidden_type.span, decl.hidden_type.span,
format!("could not resolve {:#?}", hidden_type.ty.kind()), format!("could not resolve {:#?}", hidden_type.ty.kind()),
); );
hidden_type.ty = Ty::new_error(infcx.tcx, reported);
} }
(opaque_type_key, hidden_type) (opaque_type_key, hidden_type)
@ -1089,10 +1088,9 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
); );
if result.is_err() { if result.is_err() {
self.infcx.dcx().span_delayed_bug( self.infcx
self.body.span, .dcx()
"failed re-defining predefined opaques in mir typeck", .span_bug(self.body.span, "failed re-defining predefined opaques in mir typeck");
);
} }
} }

View file

@ -393,11 +393,7 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir,
if ecx.tcx.is_ctfe_mir_available(def) { if ecx.tcx.is_ctfe_mir_available(def) {
Ok(ecx.tcx.mir_for_ctfe(def)) Ok(ecx.tcx.mir_for_ctfe(def))
} else if ecx.tcx.def_kind(def) == DefKind::AssocConst { } else if ecx.tcx.def_kind(def) == DefKind::AssocConst {
let guar = ecx ecx.tcx.dcx().bug("This is likely a const item that is missing from its impl");
.tcx
.dcx()
.delayed_bug("This is likely a const item that is missing from its impl");
throw_inval!(AlreadyReported(guar.into()));
} else { } else {
// `find_mir_or_eval_fn` checks that this is a const fn before even calling us, // `find_mir_or_eval_fn` checks that this is a const fn before even calling us,
// so this should be unreachable. // so this should be unreachable.

View file

@ -329,9 +329,7 @@ impl<'mir, 'tcx> Checker<'mir, 'tcx> {
fn check_static(&mut self, def_id: DefId, span: Span) { fn check_static(&mut self, def_id: DefId, span: Span) {
if self.tcx.is_thread_local_static(def_id) { if self.tcx.is_thread_local_static(def_id) {
self.tcx self.tcx.dcx().span_bug(span, "tls access is checked in `Rvalue::ThreadLocalRef`");
.dcx()
.span_delayed_bug(span, "tls access is checked in `Rvalue::ThreadLocalRef`");
} }
self.check_op_spanned(ops::StaticAccess, span) self.check_op_spanned(ops::StaticAccess, span)
} }

View file

@ -517,7 +517,7 @@ impl<'a, 'tcx> Visitor<'tcx> for CfgChecker<'a, 'tcx> {
fn visit_source_scope(&mut self, scope: SourceScope) { fn visit_source_scope(&mut self, scope: SourceScope) {
if self.body.source_scopes.get(scope).is_none() { if self.body.source_scopes.get(scope).is_none() {
self.tcx.dcx().span_delayed_bug( self.tcx.dcx().span_bug(
self.body.span, self.body.span,
format!( format!(
"broken MIR in {:?} ({}):\ninvalid source scope {:?}", "broken MIR in {:?} ({}):\ninvalid source scope {:?}",

View file

@ -22,6 +22,10 @@ expand_collapse_debuginfo_illegal =
expand_count_repetition_misplaced = expand_count_repetition_misplaced =
`count` can not be placed inside the inner-most repetition `count` can not be placed inside the inner-most repetition
expand_custom_attribute_panicked =
custom attribute panicked
.help = message: {$message}
expand_duplicate_matcher_binding = duplicate matcher binding expand_duplicate_matcher_binding = duplicate matcher binding
.label = duplicate binding .label = duplicate binding
.label2 = previous binding .label2 = previous binding
@ -115,6 +119,10 @@ expand_only_one_argument =
expand_only_one_word = expand_only_one_word =
must only be one word must only be one word
expand_proc_macro_derive_panicked =
proc-macro derive panicked
.help = message: {$message}
expand_proc_macro_derive_tokens = expand_proc_macro_derive_tokens =
proc-macro derive produced unparsable tokens proc-macro derive produced unparsable tokens

View file

@ -392,6 +392,36 @@ pub(crate) struct ProcMacroPanickedHelp {
pub message: String, pub message: String,
} }
#[derive(Diagnostic)]
#[diag(expand_proc_macro_derive_panicked)]
pub(crate) struct ProcMacroDerivePanicked {
#[primary_span]
pub span: Span,
#[subdiagnostic]
pub message: Option<ProcMacroDerivePanickedHelp>,
}
#[derive(Subdiagnostic)]
#[help(expand_help)]
pub(crate) struct ProcMacroDerivePanickedHelp {
pub message: String,
}
#[derive(Diagnostic)]
#[diag(expand_custom_attribute_panicked)]
pub(crate) struct CustomAttributePanicked {
#[primary_span]
pub span: Span,
#[subdiagnostic]
pub message: Option<CustomAttributePanickedHelp>,
}
#[derive(Subdiagnostic)]
#[help(expand_help)]
pub(crate) struct CustomAttributePanickedHelp {
pub message: String,
}
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(expand_proc_macro_derive_tokens)] #[diag(expand_proc_macro_derive_tokens)]
pub struct ProcMacroDeriveTokens { pub struct ProcMacroDeriveTokens {

View file

@ -93,11 +93,12 @@ impl base::AttrProcMacro for AttrProcMacro {
let server = proc_macro_server::Rustc::new(ecx); let server = proc_macro_server::Rustc::new(ecx);
self.client.run(&strategy, server, annotation, annotated, proc_macro_backtrace).map_err( self.client.run(&strategy, server, annotation, annotated, proc_macro_backtrace).map_err(
|e| { |e| {
let mut err = ecx.dcx().struct_span_err(span, "custom attribute panicked"); ecx.dcx().emit_err(errors::CustomAttributePanicked {
if let Some(s) = e.as_str() { span,
err.help(format!("message: {s}")); message: e.as_str().map(|message| errors::CustomAttributePanickedHelp {
} message: message.into(),
err.emit() }),
})
}, },
) )
} }
@ -146,11 +147,14 @@ impl MultiItemModifier for DeriveProcMacro {
match self.client.run(&strategy, server, input, proc_macro_backtrace) { match self.client.run(&strategy, server, input, proc_macro_backtrace) {
Ok(stream) => stream, Ok(stream) => stream,
Err(e) => { Err(e) => {
let mut err = ecx.dcx().struct_span_err(span, "proc-macro derive panicked"); ecx.dcx().emit_err({
if let Some(s) = e.as_str() { errors::ProcMacroDerivePanicked {
err.help(format!("message: {s}")); span,
} message: e.as_str().map(|message| {
err.emit(); errors::ProcMacroDerivePanickedHelp { message: message.into() }
}),
}
});
return ExpandResult::Ready(vec![]); return ExpandResult::Ready(vec![]);
} }
} }

View file

@ -1237,8 +1237,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
// trait reference. // trait reference.
let Some(trait_ref) = tcx.impl_trait_ref(impl_def_id) else { let Some(trait_ref) = tcx.impl_trait_ref(impl_def_id) else {
// A cycle error occurred, most likely. // A cycle error occurred, most likely.
let guar = tcx.dcx().span_delayed_bug(span, "expected cycle error"); tcx.dcx().span_bug(span, "expected cycle error");
return Err(guar);
}; };
self.one_bound_for_assoc_item( self.one_bound_for_assoc_item(

View file

@ -257,8 +257,7 @@ fn check_static_inhabited(tcx: TyCtxt<'_>, def_id: LocalDefId) {
fn check_opaque(tcx: TyCtxt<'_>, def_id: LocalDefId) { fn check_opaque(tcx: TyCtxt<'_>, def_id: LocalDefId) {
let item = tcx.hir().expect_item(def_id); let item = tcx.hir().expect_item(def_id);
let hir::ItemKind::OpaqueTy(hir::OpaqueTy { origin, .. }) = item.kind else { let hir::ItemKind::OpaqueTy(hir::OpaqueTy { origin, .. }) = item.kind else {
tcx.dcx().span_delayed_bug(item.span, "expected opaque item"); tcx.dcx().span_bug(item.span, "expected opaque item");
return;
}; };
// HACK(jynelson): trying to infer the type of `impl trait` breaks documenting // HACK(jynelson): trying to infer the type of `impl trait` breaks documenting
@ -382,10 +381,10 @@ fn check_opaque_meets_bounds<'tcx>(
Ok(()) => {} Ok(()) => {}
Err(ty_err) => { Err(ty_err) => {
let ty_err = ty_err.to_string(tcx); let ty_err = ty_err.to_string(tcx);
return Err(tcx.dcx().span_delayed_bug( tcx.dcx().span_bug(
span, span,
format!("could not unify `{hidden_ty}` with revealed type:\n{ty_err}"), format!("could not unify `{hidden_ty}` with revealed type:\n{ty_err}"),
)); );
} }
} }

View file

@ -734,11 +734,12 @@ pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>(
remapped_types.insert(def_id, ty::EarlyBinder::bind(ty)); remapped_types.insert(def_id, ty::EarlyBinder::bind(ty));
} }
Err(err) => { Err(err) => {
let reported = tcx.dcx().span_delayed_bug( // This code path is not reached in any tests, but may be
return_span, // reachable. If this is triggered, it should be converted to
format!("could not fully resolve: {ty} => {err:?}"), // `span_delayed_bug` and the triggering case turned into a
); // test.
remapped_types.insert(def_id, ty::EarlyBinder::bind(Ty::new_error(tcx, reported))); tcx.dcx()
.span_bug(return_span, format!("could not fully resolve: {ty} => {err:?}"));
} }
} }
} }
@ -917,7 +918,13 @@ impl<'tcx> ty::FallibleTypeFolder<TyCtxt<'tcx>> for RemapHiddenTyRegions<'tcx> {
.with_note(format!("hidden type inferred to be `{}`", self.ty)) .with_note(format!("hidden type inferred to be `{}`", self.ty))
.emit() .emit()
} }
_ => self.tcx.dcx().delayed_bug("should've been able to remap region"), _ => {
// This code path is not reached in any tests, but may be
// reachable. If this is triggered, it should be converted
// to `delayed_bug` and the triggering case turned into a
// test.
self.tcx.dcx().bug("should've been able to remap region");
}
}; };
return Err(guar); return Err(guar);
}; };
@ -1276,9 +1283,10 @@ fn compare_number_of_generics<'tcx>(
// inheriting the generics from will also have mismatched arguments, and // inheriting the generics from will also have mismatched arguments, and
// we'll report an error for that instead. Delay a bug for safety, though. // we'll report an error for that instead. Delay a bug for safety, though.
if trait_.is_impl_trait_in_trait() { if trait_.is_impl_trait_in_trait() {
return Err(tcx.dcx().delayed_bug( // FIXME: no tests trigger this. If you find example code that does
"errors comparing numbers of generics of trait/impl functions were not emitted", // trigger this, please add it to the test suite.
)); tcx.dcx()
.bug("errors comparing numbers of generics of trait/impl functions were not emitted");
} }
let matchings = [ let matchings = [

View file

@ -154,8 +154,10 @@ pub(super) fn check_refining_return_position_impl_trait_in_trait<'tcx>(
trait_m_sig.inputs_and_output, trait_m_sig.inputs_and_output,
)); ));
if !ocx.select_all_or_error().is_empty() { if !ocx.select_all_or_error().is_empty() {
tcx.dcx().delayed_bug("encountered errors when checking RPITIT refinement (selection)"); // This code path is not reached in any tests, but may be reachable. If
return; // this is triggered, it should be converted to `delayed_bug` and the
// triggering case turned into a test.
tcx.dcx().bug("encountered errors when checking RPITIT refinement (selection)");
} }
let outlives_env = OutlivesEnvironment::with_bounds( let outlives_env = OutlivesEnvironment::with_bounds(
param_env, param_env,
@ -163,13 +165,17 @@ pub(super) fn check_refining_return_position_impl_trait_in_trait<'tcx>(
); );
let errors = infcx.resolve_regions(&outlives_env); let errors = infcx.resolve_regions(&outlives_env);
if !errors.is_empty() { if !errors.is_empty() {
tcx.dcx().delayed_bug("encountered errors when checking RPITIT refinement (regions)"); // This code path is not reached in any tests, but may be reachable. If
return; // this is triggered, it should be converted to `delayed_bug` and the
// triggering case turned into a test.
tcx.dcx().bug("encountered errors when checking RPITIT refinement (regions)");
} }
// Resolve any lifetime variables that may have been introduced during normalization. // Resolve any lifetime variables that may have been introduced during normalization.
let Ok((trait_bounds, impl_bounds)) = infcx.fully_resolve((trait_bounds, impl_bounds)) else { let Ok((trait_bounds, impl_bounds)) = infcx.fully_resolve((trait_bounds, impl_bounds)) else {
tcx.dcx().delayed_bug("encountered errors when checking RPITIT refinement (resolution)"); // This code path is not reached in any tests, but may be reachable. If
return; // this is triggered, it should be converted to `delayed_bug` and the
// triggering case turned into a test.
tcx.dcx().bug("encountered errors when checking RPITIT refinement (resolution)");
}; };
// For quicker lookup, use an `IndexSet` (we don't use one earlier because // For quicker lookup, use an `IndexSet` (we don't use one earlier because

View file

@ -1087,14 +1087,8 @@ fn check_type_defn<'tcx>(
packed && { packed && {
let ty = tcx.type_of(variant.tail().did).instantiate_identity(); let ty = tcx.type_of(variant.tail().did).instantiate_identity();
let ty = tcx.erase_regions(ty); let ty = tcx.erase_regions(ty);
if ty.has_infer() { assert!(!ty.has_infer());
tcx.dcx() ty.needs_drop(tcx, tcx.param_env(item.owner_id))
.span_delayed_bug(item.span, format!("inference variables in {ty:?}"));
// Just treat unresolved type expression as if it needs drop.
true
} else {
ty.needs_drop(tcx, tcx.param_env(item.owner_id))
}
} }
}; };
// All fields (except for possibly the last) should be sized. // All fields (except for possibly the last) should be sized.

View file

@ -315,7 +315,7 @@ pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Generics {
if is_host_effect { if is_host_effect {
if let Some(idx) = host_effect_index { if let Some(idx) = host_effect_index {
tcx.dcx().span_delayed_bug( tcx.dcx().span_bug(
param.span, param.span,
format!("parent also has host effect param? index: {idx}, def: {def_id:?}"), format!("parent also has host effect param? index: {idx}, def: {def_id:?}"),
); );

View file

@ -1331,7 +1331,7 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
} }
} }
self.tcx.dcx().span_delayed_bug( self.tcx.dcx().span_bug(
lifetime_ref.ident.span, lifetime_ref.ident.span,
format!("Could not resolve {:?} in scope {:#?}", lifetime_ref, self.scope,), format!("Could not resolve {:?} in scope {:#?}", lifetime_ref, self.scope,),
); );
@ -1465,10 +1465,9 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
} }
} }
self.tcx.dcx().span_delayed_bug( self.tcx
self.tcx.hir().span(hir_id), .dcx()
format!("could not resolve {param_def_id:?}"), .span_bug(self.tcx.hir().span(hir_id), format!("could not resolve {param_def_id:?}"));
);
} }
#[instrument(level = "debug", skip(self))] #[instrument(level = "debug", skip(self))]

View file

@ -139,10 +139,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
| ty::Never | ty::Never
| ty::Dynamic(_, _, ty::DynStar) | ty::Dynamic(_, _, ty::DynStar)
| ty::Error(_) => { | ty::Error(_) => {
let guar = self self.dcx().span_bug(span, format!("`{t:?}` should be sized but is not?"));
.dcx()
.span_delayed_bug(span, format!("`{t:?}` should be sized but is not?"));
return Err(guar);
} }
}) })
} }

View file

@ -76,16 +76,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// While we don't allow *arbitrary* coercions here, we *do* allow // While we don't allow *arbitrary* coercions here, we *do* allow
// coercions from ! to `expected`. // coercions from ! to `expected`.
if ty.is_never() { if ty.is_never() {
if let Some(adjustments) = self.typeck_results.borrow().adjustments().get(expr.hir_id) { if let Some(_) = self.typeck_results.borrow().adjustments().get(expr.hir_id) {
let reported = self.dcx().span_delayed_bug( self.dcx()
expr.span, .span_bug(expr.span, "expression with never type wound up being adjusted");
"expression with never type wound up being adjusted",
);
return if let [Adjustment { kind: Adjust::NeverToAny, target }] = &adjustments[..] {
target.to_owned()
} else {
Ty::new_error(self.tcx(), reported)
};
} }
let adj_ty = self.next_ty_var(TypeVariableOrigin { let adj_ty = self.next_ty_var(TypeVariableOrigin {
@ -1322,10 +1315,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// the LUB of the breaks (possibly ! if none); else, it // the LUB of the breaks (possibly ! if none); else, it
// is nil. This makes sense because infinite loops // is nil. This makes sense because infinite loops
// (which would have type !) are only possible iff we // (which would have type !) are only possible iff we
// permit break with a value [1]. // permit break with a value.
if ctxt.coerce.is_none() && !ctxt.may_break { if ctxt.coerce.is_none() && !ctxt.may_break {
// [1] self.dcx().span_bug(body.span, "no coercion, but loop may not break");
self.dcx().span_delayed_bug(body.span, "no coercion, but loop may not break");
} }
ctxt.coerce.map(|c| c.complete(self)).unwrap_or_else(|| Ty::new_unit(self.tcx)) ctxt.coerce.map(|c| c.complete(self)).unwrap_or_else(|| Ty::new_unit(self.tcx))
} }

View file

@ -48,8 +48,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let to = normalize(to); let to = normalize(to);
trace!(?from, ?to); trace!(?from, ?to);
if from.has_non_region_infer() || to.has_non_region_infer() { if from.has_non_region_infer() || to.has_non_region_infer() {
tcx.dcx().span_delayed_bug(span, "argument to transmute has inference variables"); // Note: this path is currently not reached in any test, so any
return; // example that triggers this would be worth minimizing and
// converting into a test.
tcx.dcx().span_bug(span, "argument to transmute has inference variables");
} }
// Transmutes that are only changing lifetimes are always ok. // Transmutes that are only changing lifetimes are always ok.
if from == to { if from == to {

View file

@ -570,8 +570,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
_ => { _ => {
self.tcx() self.tcx()
.dcx() .dcx()
.span_delayed_bug(span, "struct or tuple struct pattern not applied to an ADT"); .span_bug(span, "struct or tuple struct pattern not applied to an ADT");
Err(())
} }
} }
} }
@ -583,8 +582,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
match ty.kind() { match ty.kind() {
ty::Tuple(args) => Ok(args.len()), ty::Tuple(args) => Ok(args.len()),
_ => { _ => {
self.tcx().dcx().span_delayed_bug(span, "tuple pattern not applied to a tuple"); self.tcx().dcx().span_bug(span, "tuple pattern not applied to a tuple");
Err(())
} }
} }
} }

View file

@ -804,11 +804,10 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
let trait_ref = principal.with_self_ty(self.tcx, self_ty); let trait_ref = principal.with_self_ty(self.tcx, self_ty);
self.elaborate_bounds(iter::once(trait_ref), |this, new_trait_ref, item| { self.elaborate_bounds(iter::once(trait_ref), |this, new_trait_ref, item| {
if new_trait_ref.has_non_region_bound_vars() { if new_trait_ref.has_non_region_bound_vars() {
this.dcx().span_delayed_bug( this.dcx().span_bug(
this.span, this.span,
"tried to select method from HRTB with non-lifetime bound vars", "tried to select method from HRTB with non-lifetime bound vars",
); );
return;
} }
let new_trait_ref = this.instantiate_bound_regions_with_erased(new_trait_ref); let new_trait_ref = this.instantiate_bound_regions_with_erased(new_trait_ref);

View file

@ -369,6 +369,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}; };
if let Some(file) = file { if let Some(file) = file {
err.note(format!("the full type name has been written to '{}'", file.display())); err.note(format!("the full type name has been written to '{}'", file.display()));
err.note(format!(
"consider using `--verbose` to print the full type name to the console"
));
} }
err err
@ -493,6 +496,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
if let Some(file) = ty_file { if let Some(file) = ty_file {
err.note(format!("the full type name has been written to '{}'", file.display(),)); err.note(format!("the full type name has been written to '{}'", file.display(),));
err.note(format!(
"consider using `--verbose` to print the full type name to the console"
));
} }
if rcvr_ty.references_error() { if rcvr_ty.references_error() {
err.downgrade_to_delayed_bug(); err.downgrade_to_delayed_bug();

View file

@ -1085,10 +1085,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let variant = match res { let variant = match res {
Res::Err => { Res::Err => {
let e = tcx.dcx().span_delayed_bug(pat.span, "`Res::Err` but no error emitted"); tcx.dcx().span_bug(pat.span, "`Res::Err` but no error emitted");
self.set_tainted_by_errors(e);
on_error(e);
return Ty::new_error(tcx, e);
} }
Res::Def(DefKind::AssocConst | DefKind::AssocFn, _) => { Res::Def(DefKind::AssocConst | DefKind::AssocFn, _) => {
let e = report_unexpected_res(res); let e = report_unexpected_res(res);

View file

@ -1935,6 +1935,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
"the full type name has been written to '{}'", "the full type name has been written to '{}'",
path.display(), path.display(),
)); ));
diag.note(format!("consider using `--verbose` to print the full type name to the console"));
} }
} }
} }

View file

@ -420,11 +420,9 @@ where
match b.kind() { match b.kind() {
ty::ConstKind::Infer(InferConst::Var(_)) if D::forbid_inference_vars() => { ty::ConstKind::Infer(InferConst::Var(_)) if D::forbid_inference_vars() => {
// Forbid inference variables in the RHS. // Forbid inference variables in the RHS.
self.infcx.dcx().span_delayed_bug( self.infcx
self.delegate.span(), .dcx()
format!("unexpected inference var {b:?}",), .span_bug(self.delegate.span(), format!("unexpected inference var {b:?}"));
);
Ok(a)
} }
// FIXME(invariance): see the related FIXME above. // FIXME(invariance): see the related FIXME above.
_ => self.infcx.super_combine_consts(self, a, b), _ => self.infcx.super_combine_consts(self, a, b),

View file

@ -1582,7 +1582,8 @@ pub enum AmbiguousWidePointerComparisons<'a> {
#[multipart_suggestion( #[multipart_suggestion(
lint_addr_metadata_suggestion, lint_addr_metadata_suggestion,
style = "verbose", style = "verbose",
applicability = "machine-applicable" // FIXME(#53934): make machine-applicable again
applicability = "maybe-incorrect"
)] )]
pub struct AmbiguousWidePointerComparisonsAddrMetadataSuggestion<'a> { pub struct AmbiguousWidePointerComparisonsAddrMetadataSuggestion<'a> {
pub ne: &'a str, pub ne: &'a str,
@ -1601,7 +1602,8 @@ pub enum AmbiguousWidePointerComparisonsAddrSuggestion<'a> {
#[multipart_suggestion( #[multipart_suggestion(
lint_addr_suggestion, lint_addr_suggestion,
style = "verbose", style = "verbose",
applicability = "machine-applicable" // FIXME(#53934): make machine-applicable again
applicability = "maybe-incorrect"
)] )]
AddrEq { AddrEq {
ne: &'a str, ne: &'a str,
@ -1617,7 +1619,8 @@ pub enum AmbiguousWidePointerComparisonsAddrSuggestion<'a> {
#[multipart_suggestion( #[multipart_suggestion(
lint_addr_suggestion, lint_addr_suggestion,
style = "verbose", style = "verbose",
applicability = "machine-applicable" // FIXME(#53934): make machine-applicable again
applicability = "maybe-incorrect"
)] )]
Cast { Cast {
deref_left: &'a str, deref_left: &'a str,

View file

@ -41,6 +41,20 @@ pub fn symbols(input: TokenStream) -> TokenStream {
symbols::symbols(input.into()).into() symbols::symbols(input.into()).into()
} }
/// Derive an extension trait for a given impl block. The trait name
/// goes into the parenthesized args of the macro, for greppability.
/// For example:
/// ```
/// use rustc_macros::extension;
/// #[extension(pub trait Foo)]
/// impl i32 { fn hello() {} }
/// ```
///
/// expands to:
/// ```
/// pub trait Foo { fn hello(); }
/// impl Foo for i32 { fn hello() {} }
/// ```
#[proc_macro_attribute] #[proc_macro_attribute]
pub fn extension(attr: TokenStream, input: TokenStream) -> TokenStream { pub fn extension(attr: TokenStream, input: TokenStream) -> TokenStream {
extension::extension(attr, input) extension::extension(attr, input)

View file

@ -351,7 +351,7 @@ impl<'tcx> TyCtxt<'tcx> {
}) })
.expect("could not write to `String`"); .expect("could not write to `String`");
if !self.sess.opts.unstable_opts.write_long_types_to_disk { if !self.sess.opts.unstable_opts.write_long_types_to_disk || self.sess.opts.verbose {
return regular; return regular;
} }

View file

@ -410,8 +410,7 @@ impl<'tcx> TypeckResults<'tcx> {
pub fn extract_binding_mode(&self, s: &Session, id: HirId, sp: Span) -> Option<BindingMode> { pub fn extract_binding_mode(&self, s: &Session, id: HirId, sp: Span) -> Option<BindingMode> {
self.pat_binding_modes().get(id).copied().or_else(|| { self.pat_binding_modes().get(id).copied().or_else(|| {
s.dcx().span_delayed_bug(sp, "missing binding mode"); s.dcx().span_bug(sp, "missing binding mode");
None
}) })
} }

View file

@ -110,15 +110,12 @@ fn lit_to_mir_constant<'tcx>(
let LitToConstInput { lit, ty, neg } = lit_input; let LitToConstInput { lit, ty, neg } = lit_input;
let trunc = |n| { let trunc = |n| {
let param_ty = ty::ParamEnv::reveal_all().and(ty); let param_ty = ty::ParamEnv::reveal_all().and(ty);
let width = let width = match tcx.layout_of(param_ty) {
tcx.layout_of(param_ty) Ok(layout) => layout.size,
.map_err(|_| { Err(_) => {
LitToConstError::Reported(tcx.dcx().delayed_bug(format!( tcx.dcx().bug(format!("couldn't compute width of literal: {:?}", lit_input.lit))
"couldn't compute width of literal: {:?}", }
lit_input.lit };
)))
})?
.size;
trace!("trunc {} with size {} and shift {}", n, width.bits(), 128 - width.bits()); trace!("trunc {} with size {} and shift {}", n, width.bits(), 128 - width.bits());
let result = width.truncate(n); let result = width.truncate(n);
trace!("trunc result: {}", result); trace!("trunc result: {}", result);

View file

@ -12,15 +12,12 @@ pub(crate) fn lit_to_const<'tcx>(
let trunc = |n| { let trunc = |n| {
let param_ty = ParamEnv::reveal_all().and(ty); let param_ty = ParamEnv::reveal_all().and(ty);
let width = let width = match tcx.layout_of(param_ty) {
tcx.layout_of(param_ty) Ok(layout) => layout.size,
.map_err(|_| { Err(_) => {
LitToConstError::Reported(tcx.dcx().delayed_bug(format!( tcx.dcx().bug(format!("couldn't compute width of literal: {:?}", lit_input.lit))
"couldn't compute width of literal: {:?}", }
lit_input.lit };
)))
})?
.size;
trace!("trunc {} with size {} and shift {}", n, width.bits(), 128 - width.bits()); trace!("trunc {} with size {} and shift {}", n, width.bits(), 128 - width.bits());
let result = width.truncate(n); let result = width.truncate(n);
trace!("trunc result: {}", result); trace!("trunc result: {}", result);
@ -59,15 +56,11 @@ pub(crate) fn lit_to_const<'tcx>(
} }
(ast::LitKind::Bool(b), ty::Bool) => ty::ValTree::from_scalar_int((*b).into()), (ast::LitKind::Bool(b), ty::Bool) => ty::ValTree::from_scalar_int((*b).into()),
(ast::LitKind::Float(n, _), ty::Float(fty)) => { (ast::LitKind::Float(n, _), ty::Float(fty)) => {
let bits = let bits = parse_float_into_scalar(*n, *fty, neg)
parse_float_into_scalar(*n, *fty, neg) .ok_or_else(|| {
.ok_or_else(|| { tcx.dcx().bug(format!("couldn't parse float literal: {:?}", lit_input.lit))
LitToConstError::Reported(tcx.dcx().delayed_bug(format!( })?
"couldn't parse float literal: {:?}", .assert_int();
lit_input.lit
)))
})?
.assert_int();
ty::ValTree::from_scalar_int(bits) ty::ValTree::from_scalar_int(bits)
} }
(ast::LitKind::Char(c), ty::Char) => ty::ValTree::from_scalar_int((*c).into()), (ast::LitKind::Char(c), ty::Char) => ty::ValTree::from_scalar_int((*c).into()),

View file

@ -175,7 +175,7 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
) -> Result<PatKind<'tcx>, ErrorGuaranteed> { ) -> Result<PatKind<'tcx>, ErrorGuaranteed> {
if lo_expr.is_none() && hi_expr.is_none() { if lo_expr.is_none() && hi_expr.is_none() {
let msg = "found twice-open range pattern (`..`) outside of error recovery"; let msg = "found twice-open range pattern (`..`) outside of error recovery";
return Err(self.tcx.dcx().span_delayed_bug(span, msg)); self.tcx.dcx().span_bug(span, msg);
} }
let (lo, lo_ascr, lo_inline) = self.lower_pattern_range_endpoint(lo_expr)?; let (lo, lo_ascr, lo_inline) = self.lower_pattern_range_endpoint(lo_expr)?;

View file

@ -1615,11 +1615,7 @@ impl<'tcx> MirPass<'tcx> for StateTransform {
(args.discr_ty(tcx), coroutine_kind.movability() == hir::Movability::Movable) (args.discr_ty(tcx), coroutine_kind.movability() == hir::Movability::Movable)
} }
_ => { _ => {
tcx.dcx().span_delayed_bug( tcx.dcx().span_bug(body.span, format!("unexpected coroutine type {coroutine_ty}"));
body.span,
format!("unexpected coroutine type {coroutine_ty}"),
);
return;
} }
}; };

View file

@ -380,7 +380,7 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
LookupResult::Parent(None) => {} LookupResult::Parent(None) => {}
LookupResult::Parent(Some(_)) => { LookupResult::Parent(Some(_)) => {
if !replace { if !replace {
self.tcx.dcx().span_delayed_bug( self.tcx.dcx().span_bug(
terminator.source_info.span, terminator.source_info.span,
format!("drop of untracked value {bb:?}"), format!("drop of untracked value {bb:?}"),
); );

View file

@ -3682,12 +3682,12 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
} }
Res::SelfCtor(_) => { Res::SelfCtor(_) => {
// We resolve `Self` in pattern position as an ident sometimes during recovery, // We resolve `Self` in pattern position as an ident sometimes during recovery,
// so delay a bug instead of ICEing. // so delay a bug instead of ICEing. (Note: is this no longer true? We now ICE. If
self.r.dcx().span_delayed_bug( // this triggers, please convert to a delayed bug and add a test.)
self.r.dcx().span_bug(
ident.span, ident.span,
"unexpected `SelfCtor` in pattern, expected identifier" "unexpected `SelfCtor` in pattern, expected identifier"
); );
None
} }
_ => span_bug!( _ => span_bug!(
ident.span, ident.span,

View file

@ -62,14 +62,11 @@ pub fn is_const_evaluatable<'tcx>(
match unexpanded_ct.kind() { match unexpanded_ct.kind() {
ty::ConstKind::Expr(_) => { ty::ConstKind::Expr(_) => {
// FIXME(generic_const_exprs): we have a `ConstKind::Expr` which is fully concrete, // FIXME(generic_const_exprs): we have a fully concrete `ConstKind::Expr`, but
// but currently it is not possible to evaluate `ConstKind::Expr` so we are unable // haven't implemented evaluating `ConstKind::Expr` yet, so we are unable to tell
// to tell if it is evaluatable or not. For now we just ICE until this is // if it is evaluatable or not. As this is unreachable for now, we can simple ICE
// implemented. // here.
Err(NotConstEvaluatable::Error(tcx.dcx().span_delayed_bug( tcx.dcx().span_bug(span, "evaluating `ConstKind::Expr` is not currently supported");
span,
"evaluating `ConstKind::Expr` is not currently supported",
)))
} }
ty::ConstKind::Unevaluated(uv) => { ty::ConstKind::Unevaluated(uv) => {
let concrete = infcx.const_eval_resolve(param_env, uv, Some(span)); let concrete = infcx.const_eval_resolve(param_env, uv, Some(span));

View file

@ -1283,6 +1283,9 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
"the full type name has been written to '{}'", "the full type name has been written to '{}'",
file.display() file.display()
)); ));
err.note(format!(
"consider using `--verbose` to print full type name to the console"
));
} }
if imm_ref_self_ty_satisfies_pred && mut_ref_self_ty_satisfies_pred { if imm_ref_self_ty_satisfies_pred && mut_ref_self_ty_satisfies_pred {
@ -2866,6 +2869,9 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
"the full name for the type has been written to '{}'", "the full name for the type has been written to '{}'",
file.display(), file.display(),
)); ));
err.note(format!(
"consider using `--verbose` to print the full type name to the console"
));
} }
} }
ObligationCauseCode::RepeatElementCopy { ObligationCauseCode::RepeatElementCopy {
@ -3333,6 +3339,9 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
"the full type name has been written to '{}'", "the full type name has been written to '{}'",
file.display(), file.display(),
)); ));
err.note(format!(
"consider using `--verbose` to print the full type name to the console"
));
} }
let mut parent_predicate = parent_trait_pred; let mut parent_predicate = parent_trait_pred;
let mut data = &data.derived; let mut data = &data.derived;
@ -3386,6 +3395,9 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
"the full type name has been written to '{}'", "the full type name has been written to '{}'",
file.display(), file.display(),
)); ));
err.note(format!(
"consider using `--verbose` to print the full type name to the console"
));
} }
} }
// #74711: avoid a stack overflow // #74711: avoid a stack overflow

View file

@ -3313,7 +3313,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
expected_trait_ref.self_ty().error_reported()?; expected_trait_ref.self_ty().error_reported()?;
let Some(found_trait_ty) = found_trait_ref.self_ty().no_bound_vars() else { let Some(found_trait_ty) = found_trait_ref.self_ty().no_bound_vars() else {
return Err(self.dcx().delayed_bug("bound vars outside binder")); self.dcx().bug("bound vars outside binder");
}; };
let found_did = match *found_trait_ty.kind() { let found_did = match *found_trait_ty.kind() {

View file

@ -172,7 +172,9 @@ fn do_normalize_predicates<'tcx>(
// the normalized predicates. // the normalized predicates.
let errors = infcx.resolve_regions(&outlives_env); let errors = infcx.resolve_regions(&outlives_env);
if !errors.is_empty() { if !errors.is_empty() {
tcx.dcx().span_delayed_bug( // @lcnr: Let's still ICE here for now. I want a test case
// for that.
tcx.dcx().span_bug(
span, span,
format!("failed region resolution while normalizing {elaborated_env:?}: {errors:?}"), format!("failed region resolution while normalizing {elaborated_env:?}: {errors:?}"),
); );

View file

@ -100,7 +100,7 @@ fn implied_outlives_bounds<'a, 'tcx>(
let errors = ocx.select_all_or_error(); let errors = ocx.select_all_or_error();
if !errors.is_empty() { if !errors.is_empty() {
infcx.dcx().span_delayed_bug( infcx.dcx().span_bug(
span, span,
"implied_outlives_bounds failed to solve obligations from instantiation", "implied_outlives_bounds failed to solve obligations from instantiation",
); );

View file

@ -645,11 +645,9 @@ pub fn compute_inherent_assoc_ty_args<'a, 'b, 'tcx>(
match selcx.infcx.at(&cause, param_env).eq(DefineOpaqueTypes::No, impl_ty, self_ty) { match selcx.infcx.at(&cause, param_env).eq(DefineOpaqueTypes::No, impl_ty, self_ty) {
Ok(mut ok) => obligations.append(&mut ok.obligations), Ok(mut ok) => obligations.append(&mut ok.obligations),
Err(_) => { Err(_) => {
tcx.dcx().span_delayed_bug( tcx.dcx().span_bug(
cause.span, cause.span,
format!( format!("{self_ty:?} was equal to {impl_ty:?} during selection but now it is not"),
"{self_ty:?} was a subtype of {impl_ty:?} during selection but now it is not"
),
); );
} }
} }
@ -1194,7 +1192,7 @@ fn assemble_candidates_from_impls<'cx, 'tcx>(
obligation.cause.span, obligation.cause.span,
format!("Cannot project an associated type from `{impl_source:?}`"), format!("Cannot project an associated type from `{impl_source:?}`"),
); );
return Err(()); return Err(())
} }
}; };

View file

@ -190,10 +190,9 @@ where
} }
} }
if !progress { if !progress {
return Err(infcx.dcx().span_delayed_bug( infcx
span, .dcx()
format!("ambiguity processing {obligations:?} from {self:?}"), .span_bug(span, format!("ambiguity processing {obligations:?} from {self:?}"));
));
} }
} }

View file

@ -90,8 +90,7 @@ fn univariant_uninterned<'tcx>(
let dl = cx.data_layout(); let dl = cx.data_layout();
let pack = repr.pack; let pack = repr.pack;
if pack.is_some() && repr.align.is_some() { if pack.is_some() && repr.align.is_some() {
cx.tcx.dcx().delayed_bug("struct cannot be packed and aligned"); cx.tcx.dcx().bug("struct cannot be packed and aligned");
return Err(cx.tcx.arena.alloc(LayoutError::Unknown(ty)));
} }
cx.univariant(dl, fields, repr, kind).ok_or_else(|| error(cx, LayoutError::SizeOverflow(ty))) cx.univariant(dl, fields, repr, kind).ok_or_else(|| error(cx, LayoutError::SizeOverflow(ty)))

View file

@ -337,7 +337,7 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for ImplTraitInAssocTypeCollector<'tcx> {
.instantiate(self.0.tcx, impl_args) .instantiate(self.0.tcx, impl_args)
.visit_with(self); .visit_with(self);
} else { } else {
self.0.tcx.dcx().span_delayed_bug( self.0.tcx.dcx().span_bug(
self.0.tcx.def_span(assoc.def_id), self.0.tcx.def_span(assoc.def_id),
"item had incorrect args", "item had incorrect args",
); );

View file

@ -309,29 +309,41 @@ mod internal_macros;
#[macro_use] #[macro_use]
mod int_macros; mod int_macros;
#[rustc_diagnostic_item = "i128_legacy_mod"]
#[path = "num/shells/i128.rs"] #[path = "num/shells/i128.rs"]
pub mod i128; pub mod i128;
#[rustc_diagnostic_item = "i16_legacy_mod"]
#[path = "num/shells/i16.rs"] #[path = "num/shells/i16.rs"]
pub mod i16; pub mod i16;
#[rustc_diagnostic_item = "i32_legacy_mod"]
#[path = "num/shells/i32.rs"] #[path = "num/shells/i32.rs"]
pub mod i32; pub mod i32;
#[rustc_diagnostic_item = "i64_legacy_mod"]
#[path = "num/shells/i64.rs"] #[path = "num/shells/i64.rs"]
pub mod i64; pub mod i64;
#[rustc_diagnostic_item = "i8_legacy_mod"]
#[path = "num/shells/i8.rs"] #[path = "num/shells/i8.rs"]
pub mod i8; pub mod i8;
#[rustc_diagnostic_item = "isize_legacy_mod"]
#[path = "num/shells/isize.rs"] #[path = "num/shells/isize.rs"]
pub mod isize; pub mod isize;
#[rustc_diagnostic_item = "u128_legacy_mod"]
#[path = "num/shells/u128.rs"] #[path = "num/shells/u128.rs"]
pub mod u128; pub mod u128;
#[rustc_diagnostic_item = "u16_legacy_mod"]
#[path = "num/shells/u16.rs"] #[path = "num/shells/u16.rs"]
pub mod u16; pub mod u16;
#[rustc_diagnostic_item = "u32_legacy_mod"]
#[path = "num/shells/u32.rs"] #[path = "num/shells/u32.rs"]
pub mod u32; pub mod u32;
#[rustc_diagnostic_item = "u64_legacy_mod"]
#[path = "num/shells/u64.rs"] #[path = "num/shells/u64.rs"]
pub mod u64; pub mod u64;
#[rustc_diagnostic_item = "u8_legacy_mod"]
#[path = "num/shells/u8.rs"] #[path = "num/shells/u8.rs"]
pub mod u8; pub mod u8;
#[rustc_diagnostic_item = "usize_legacy_mod"]
#[path = "num/shells/usize.rs"] #[path = "num/shells/usize.rs"]
pub mod usize; pub mod usize;

View file

@ -3938,10 +3938,15 @@ impl<'test> TestCx<'test> {
self.props.compare_output_lines_by_subset, self.props.compare_output_lines_by_subset,
); );
} else if !expected_fixed.is_empty() { } else if !expected_fixed.is_empty() {
panic!( if self.config.suite == "ui" {
"the `// run-rustfix` directive wasn't found but a `*.fixed` \ panic!(
file was found" "the `//@ run-rustfix` directive wasn't found but a `*.fixed` file was found"
); );
} else {
panic!(
"the `// run-rustfix` directive wasn't found but a `*.fixed` file was found"
);
}
} }
if errors > 0 { if errors > 0 {

View file

@ -162,7 +162,7 @@ pub fn check(path: &Path, bless: bool, bad: &mut bool) {
if !remaining_issue_names.remove(stripped_path) { if !remaining_issue_names.remove(stripped_path) {
tidy_error!( tidy_error!(
bad, bad,
"file `{stripped_path}` must begin with a descriptive name, consider `{{reason}}-issue-{issue_n}.rs`", "file `tests/{stripped_path}` must begin with a descriptive name, consider `{{reason}}-issue-{issue_n}.rs`",
issue_n = &test_name[1], issue_n = &test_name[1],
); );
} }

View file

@ -21,6 +21,7 @@ LL | | ))))))))))))))))))))))))))))));
= note: expected struct `Atype<Btype<..., ...>, ...>` = note: expected struct `Atype<Btype<..., ...>, ...>`
found enum `Result<Result<..., ...>, ...>` found enum `Result<Result<..., ...>, ...>`
= note: the full type name has been written to '$TEST_BUILD_DIR/diagnostic-width/long-E0308/long-E0308.long-type-hash.txt' = note: the full type name has been written to '$TEST_BUILD_DIR/diagnostic-width/long-E0308/long-E0308.long-type-hash.txt'
= note: consider using `--verbose` to print the full type name to the console
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/long-E0308.rs:57:26 --> $DIR/long-E0308.rs:57:26
@ -36,6 +37,7 @@ LL | | ))))))))))))))))))))))));
= note: expected enum `Option<Result<..., ...>>` = note: expected enum `Option<Result<..., ...>>`
found enum `Result<Result<..., ...>, ...>` found enum `Result<Result<..., ...>, ...>`
= note: the full type name has been written to '$TEST_BUILD_DIR/diagnostic-width/long-E0308/long-E0308.long-type-hash.txt' = note: the full type name has been written to '$TEST_BUILD_DIR/diagnostic-width/long-E0308/long-E0308.long-type-hash.txt'
= note: consider using `--verbose` to print the full type name to the console
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/long-E0308.rs:88:9 --> $DIR/long-E0308.rs:88:9
@ -55,6 +57,7 @@ LL | | > = ();
= note: expected struct `Atype<Btype<..., ...>, ...>` = note: expected struct `Atype<Btype<..., ...>, ...>`
found unit type `()` found unit type `()`
= note: the full type name has been written to '$TEST_BUILD_DIR/diagnostic-width/long-E0308/long-E0308.long-type-hash.txt' = note: the full type name has been written to '$TEST_BUILD_DIR/diagnostic-width/long-E0308/long-E0308.long-type-hash.txt'
= note: consider using `--verbose` to print the full type name to the console
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/long-E0308.rs:91:17 --> $DIR/long-E0308.rs:91:17
@ -72,6 +75,7 @@ LL | | ))))))))))))))))))))))));
= note: expected unit type `()` = note: expected unit type `()`
found enum `Result<Result<..., ...>, ...>` found enum `Result<Result<..., ...>, ...>`
= note: the full type name has been written to '$TEST_BUILD_DIR/diagnostic-width/long-E0308/long-E0308.long-type-hash.txt' = note: the full type name has been written to '$TEST_BUILD_DIR/diagnostic-width/long-E0308/long-E0308.long-type-hash.txt'
= note: consider using `--verbose` to print the full type name to the console
error: aborting due to 4 previous errors error: aborting due to 4 previous errors

View file

@ -0,0 +1,4 @@
struct DropNoMethod;
impl Drop for DropNoMethod {} //~ ERROR not all trait items implemented, missing: `drop`
fn main() {}

View file

@ -0,0 +1,11 @@
error[E0046]: not all trait items implemented, missing: `drop`
--> $DIR/missing-drop-method.rs:2:1
|
LL | impl Drop for DropNoMethod {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `drop` in implementation
|
= help: implement the missing item: `fn drop(&mut self) { todo!() }`
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0046`.

View file

@ -0,0 +1,13 @@
//@ run-rustfix
//@ rustfix-only-machine-applicable
//@ check-pass
// See <https://github.com/rust-lang/rust/issues/121330>.
fn cmp<T: ?Sized>(a: *mut T, b: *mut T) -> bool {
let _ = a == b;
//~^ WARN ambiguous wide pointer comparison
panic!();
}
fn main() {}

View file

@ -0,0 +1,13 @@
//@ run-rustfix
//@ rustfix-only-machine-applicable
//@ check-pass
// See <https://github.com/rust-lang/rust/issues/121330>.
fn cmp<T: ?Sized>(a: *mut T, b: *mut T) -> bool {
let _ = a == b;
//~^ WARN ambiguous wide pointer comparison
panic!();
}
fn main() {}

View file

@ -0,0 +1,18 @@
warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected
--> $DIR/ambiguous_wide_pointer_comparisons_suggestions.rs:8:13
|
LL | let _ = a == b;
| ^^^^^^
|
= note: `#[warn(ambiguous_wide_pointer_comparisons)]` on by default
help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses
|
LL | let _ = std::ptr::addr_eq(a, b);
| ++++++++++++++++++ ~ +
help: use explicit `std::ptr::eq` method to compare metadata and addresses
|
LL | let _ = std::ptr::eq(a, b);
| +++++++++++++ ~ +
warning: 1 warning emitted