Skip to content

Commit

Permalink
Remove dead error code.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjgillot committed Sep 23, 2023
1 parent 6aa1268 commit baa64b0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 47 deletions.
4 changes: 3 additions & 1 deletion compiler/rustc_error_codes/src/error_codes/E0698.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#### Note: this error code is no longer emitted by the compiler.

When using generators (or async) all type variables must be bound so a
generator can be constructed.

Erroneous code example:

```edition2018,compile_fail,E0698
```edition2018,compile_fail,E0282
async fn bar<T>() -> () {}
async fn foo() {
Expand Down
13 changes: 1 addition & 12 deletions compiler/rustc_infer/src/errors/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ use rustc_span::{symbol::Ident, BytePos, Span};

use crate::fluent_generated as fluent;
use crate::infer::error_reporting::{
need_type_info::{GeneratorKindAsDiagArg, UnderspecifiedArgKind},
nice_region_error::placeholder_error::Highlighted,
need_type_info::UnderspecifiedArgKind, nice_region_error::placeholder_error::Highlighted,
ObligationCauseAsDiagArg,
};

Expand Down Expand Up @@ -86,16 +85,6 @@ pub struct AmbiguousReturn<'a> {
pub multi_suggestions: Vec<SourceKindMultiSuggestion<'a>>,
}

#[derive(Diagnostic)]
#[diag(infer_need_type_info_in_generator, code = "E0698")]
pub struct NeedTypeInfoInGenerator<'a> {
#[primary_span]
pub span: Span,
pub generator_kind: GeneratorKindAsDiagArg,
#[subdiagnostic]
pub bad_label: InferenceBadError<'a>,
}

// Used when a better one isn't available
#[derive(Subdiagnostic)]
#[label(infer_label_bad)]
Expand Down
35 changes: 1 addition & 34 deletions compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::errors::{
AmbiguousImpl, AmbiguousReturn, AnnotationRequired, InferenceBadError, NeedTypeInfoInGenerator,
AmbiguousImpl, AmbiguousReturn, AnnotationRequired, InferenceBadError,
SourceKindMultiSuggestion, SourceKindSubdiag,
};
use crate::infer::error_reporting::TypeErrCtxt;
Expand Down Expand Up @@ -595,39 +595,6 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
}
}

impl<'tcx> InferCtxt<'tcx> {
pub fn need_type_info_err_in_generator(
&self,
kind: hir::GeneratorKind,
span: Span,
ty: ty::Term<'tcx>,
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
let ty = self.resolve_vars_if_possible(ty);
let data = self.extract_inference_diagnostics_data(ty.into(), None);

NeedTypeInfoInGenerator {
bad_label: data.make_bad_error(span),
span,
generator_kind: GeneratorKindAsDiagArg(kind),
}
.into_diagnostic(&self.tcx.sess.parse_sess.span_diagnostic)
}
}

pub struct GeneratorKindAsDiagArg(pub hir::GeneratorKind);

impl IntoDiagnosticArg for GeneratorKindAsDiagArg {
fn into_diagnostic_arg(self) -> rustc_errors::DiagnosticArgValue<'static> {
let kind = match self.0 {
hir::GeneratorKind::Async(hir::AsyncGeneratorKind::Block) => "async_block",
hir::GeneratorKind::Async(hir::AsyncGeneratorKind::Closure) => "async_closure",
hir::GeneratorKind::Async(hir::AsyncGeneratorKind::Fn) => "async_fn",
hir::GeneratorKind::Gen => "generator",
};
rustc_errors::DiagnosticArgValue::Str(kind.into())
}
}

#[derive(Debug)]
struct InferSource<'tcx> {
span: Span,
Expand Down

0 comments on commit baa64b0

Please sign in to comment.