Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions compiler/rustc_abi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -399,8 +399,8 @@ pub enum TargetDataLayoutError<'a> {
}

#[cfg(feature = "nightly")]
impl<G> Diagnostic<'_, G> for TargetDataLayoutError<'_> {
fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_, G> {
impl Diagnostic<'_> for TargetDataLayoutError<'_> {
fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_> {
match self {
TargetDataLayoutError::InvalidAddressSpace { addr_space, err, cause } => {
Diag::new(dcx, level, msg!("invalid address space `{$addr_space}` for `{$cause}` in \"data-layout\": {$err}"))
Expand Down
10 changes: 4 additions & 6 deletions compiler/rustc_ast_lowering/src/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1759,12 +1759,10 @@ impl<'hir> LoweringContext<'_, 'hir> {
if !self.tcx.is_descendant_of(parent_module, did) {
// If the restriction path is not an ancestor of the item,
// emit an error and recover by lowering the restriction to `Unrestricted`.
self.dcx()
.create_err(RestrictionAncestorOnly {
span: path.span,
kind: resolving_kind,
})
.emit();
self.dcx().emit_err(RestrictionAncestorOnly {
span: path.span,
kind: resolving_kind,
});
hir::RestrictionKind::Unrestricted
} else {
hir::RestrictionKind::Restricted(self.arena.alloc(hir::Path {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_ast_lowering/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1751,7 +1751,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
},
feature,
)
.emit();
.emit_err();
hir::TyKind::Err(guar)
}
ImplTraitContext::Disallowed(position) => {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_ast_passes/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ pub(crate) struct EmptyLabelManySpans(pub Vec<Span>);

// The derive for `Vec<Span>` does multiple calls to `span_label`, adding commas between each
impl Subdiagnostic for EmptyLabelManySpans {
fn add_to_diag<G>(self, diag: &mut Diag<'_, G>) {
fn add_to_diag(self, diag: &mut Diag<'_>) {
diag.span_labels(self.0, "");
}
}
Expand Down
12 changes: 6 additions & 6 deletions compiler/rustc_attr_parsing/src/attributes/cfg_select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,13 @@ pub fn parse_cfg_select(
let mut branches = CfgSelectBranches::default();

while p.token != token::Eof {
p.recover_from_outer_attributes("`cfg_select` branches").map_err(|e| e.emit())?;
p.recover_from_outer_attributes("`cfg_select` branches").map_err(|e| e.emit_err())?;

if p.eat_keyword(exp!(Underscore)) {
let underscore = p.prev_token;
p.expect(exp!(FatArrow)).map_err(|e| e.emit())?;
p.expect(exp!(FatArrow)).map_err(|e| e.emit_err())?;

let tts = p.parse_cfg_select_branch_rhs().map_err(|e| e.emit())?;
let tts = p.parse_cfg_select_branch_rhs().map_err(|e| e.emit_err())?;
let span = underscore.span.to(p.token.span);

match branches.wildcard {
Expand All @@ -110,7 +110,7 @@ pub fn parse_cfg_select(
ShouldEmit::ErrorsAndLints { recovery: Recovery::Allowed },
AllowExprMetavar::Yes,
)
.map_err(|diag| diag.emit())?;
.map_err(|diag| diag.emit_err())?;
let cfg_span = meta.span();
let cfg = AttributeParser::parse_single_args(
sess,
Expand All @@ -132,9 +132,9 @@ pub fn parse_cfg_select(
&AttributeTemplate::default(),
)?;

p.expect(exp!(FatArrow)).map_err(|e| e.emit())?;
p.expect(exp!(FatArrow)).map_err(|e| e.emit_err())?;

let tts = p.parse_cfg_select_branch_rhs().map_err(|e| e.emit())?;
let tts = p.parse_cfg_select_branch_rhs().map_err(|e| e.emit_err())?;
let span = cfg_span.to(p.token.span);

match branches.wildcard {
Expand Down
10 changes: 5 additions & 5 deletions compiler/rustc_attr_parsing/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ impl<'f, 'sess: 'f> SharedContext<'f, 'sess> {
pub(crate) fn emit_lint(
&mut self,
lint: &'static Lint,
diagnostic: impl for<'x> Diagnostic<'x, ()> + DynSend + DynSync + 'static,
diagnostic: impl for<'x> Diagnostic<'x> + DynSend + DynSync + 'static,
span: impl Into<MultiSpan>,
) {
self.emit_lint_inner(
Expand All @@ -429,7 +429,7 @@ impl<'f, 'sess: 'f> SharedContext<'f, 'sess> {
}

pub(crate) fn emit_lint_with_sess<
F: for<'a> FnOnce(DiagCtxtHandle<'a>, Level, &Session) -> Diag<'a, ()>
F: for<'a> FnOnce(DiagCtxtHandle<'a>, Level, &Session) -> Diag<'a>
+ DynSend
+ DynSync
+ 'static,
Expand Down Expand Up @@ -895,9 +895,9 @@ pub enum ShouldEmit {
impl ShouldEmit {
pub(crate) fn emit_err(self, diag: Diag<'_>) -> ErrorGuaranteed {
match self {
ShouldEmit::EarlyFatal { .. } if diag.level() == Level::DelayedBug => diag.emit(),
ShouldEmit::EarlyFatal { .. } => diag.upgrade_to_fatal().emit(),
ShouldEmit::ErrorsAndLints { .. } => diag.emit(),
ShouldEmit::EarlyFatal { .. } if diag.level() == Level::DelayedBug => diag.emit_err(),
ShouldEmit::EarlyFatal { .. } => diag.upgrade_to_fatal().emit_fatal(),
ShouldEmit::ErrorsAndLints { .. } => diag.emit_err(),
ShouldEmit::Nothing => diag.delay_as_bug(),
}
}
Expand Down
14 changes: 7 additions & 7 deletions compiler/rustc_attr_parsing/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1476,9 +1476,9 @@ pub(crate) enum AttributeParseErrorSuggestions {
}

impl<'a> AttributeParseError<'a> {
fn render_expected_specific_argument<G>(
fn render_expected_specific_argument(
&self,
diag: &mut Diag<'_, G>,
diag: &mut Diag<'_>,
possibilities: &[Symbol],
strings: bool,
) {
Expand Down Expand Up @@ -1509,9 +1509,9 @@ impl<'a> AttributeParseError<'a> {
}
}

fn render_expected_specific_argument_list<G>(
fn render_expected_specific_argument_list(
&self,
diag: &mut Diag<'_, G>,
diag: &mut Diag<'_>,
possibilities: &[Symbol],
strings: bool,
) {
Expand Down Expand Up @@ -1543,7 +1543,7 @@ impl<'a> AttributeParseError<'a> {
}
}

fn render_suggestions<G>(&self, diag: &mut Diag<'_, G>) {
fn render_suggestions(&self, diag: &mut Diag<'_>) {
let description = self.description();

match &self.suggestions {
Expand Down Expand Up @@ -1592,8 +1592,8 @@ impl AttributeParseErrorSuggestions {
}
}

impl<'a, G> Diagnostic<'a, G> for AttributeParseError<'_> {
fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G> {
impl<'a> Diagnostic<'a> for AttributeParseError<'_> {
fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a> {
let name = self.path.to_string();

let description = self.description();
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_attr_parsing/src/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use crate::{AttributeTemplate, ShouldEmit};

pub struct EmitAttribute(
pub Box<
dyn for<'a> FnOnce(DiagCtxtHandle<'a>, Level, &Session) -> Diag<'a, ()>
dyn for<'a> FnOnce(DiagCtxtHandle<'a>, Level, &Session) -> Diag<'a>
+ DynSend
+ DynSync
+ 'static,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_attr_parsing/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ fn expr_to_lit<'sess>(
let lit = MetaItemLit {
symbol: token_lit.symbol,
suffix: token_lit.suffix,
kind: LitKind::Err(err.emit()),
kind: LitKind::Err(err.emit_err()),
span: expr.span,
};
Ok(Some(lit))
Expand Down
16 changes: 8 additions & 8 deletions compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ impl<'tcx> BorrowExplanation<'tcx> {
pub(crate) fn is_explained(&self) -> bool {
!matches!(self, BorrowExplanation::Unexplained)
}
pub(crate) fn add_explanation_to_diagnostic<G>(
pub(crate) fn add_explanation_to_diagnostic(
&self,
cx: &MirBorrowckCtxt<'_, '_, 'tcx>,
err: &mut Diag<'_, G>,
err: &mut Diag<'_>,
borrow_desc: &str,
borrow_span: Option<Span>,
multiple_borrow_span: Option<(Span, Span)>,
Expand Down Expand Up @@ -437,10 +437,10 @@ impl<'tcx> BorrowExplanation<'tcx> {
}
}

fn add_object_lifetime_default_note<G>(
fn add_object_lifetime_default_note(
&self,
tcx: TyCtxt<'tcx>,
err: &mut Diag<'_, G>,
err: &mut Diag<'_>,
unsize_ty: Ty<'tcx>,
) {
if let ty::Adt(def, args) = unsize_ty.kind() {
Expand Down Expand Up @@ -494,9 +494,9 @@ impl<'tcx> BorrowExplanation<'tcx> {
}
}

fn add_lifetime_bound_suggestion_to_diagnostic<G>(
fn add_lifetime_bound_suggestion_to_diagnostic(
&self,
err: &mut Diag<'_, G>,
err: &mut Diag<'_>,
category: &ConstraintCategory<'tcx>,
span: Span,
region_name: &RegionName,
Expand All @@ -523,14 +523,14 @@ impl<'tcx> BorrowExplanation<'tcx> {
}
}

fn suggest_rewrite_if_let<G>(
fn suggest_rewrite_if_let(
tcx: TyCtxt<'_>,
expr: &hir::Expr<'_>,
pat: &str,
init: &hir::Expr<'_>,
conseq: &hir::Expr<'_>,
alt: Option<&hir::Expr<'_>>,
err: &mut Diag<'_, G>,
err: &mut Diag<'_>,
) {
let source_map = tcx.sess.source_map();
err.span_note(
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_borrowck/src/diagnostics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -642,9 +642,9 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> {
///
/// This is very similar to `fn suggest_static_lifetime_for_gat_from_hrtb` which handles this
/// note for failed type tests instead of outlives errors.
fn add_placeholder_from_predicate_note<G>(
fn add_placeholder_from_predicate_note(
&self,
diag: &mut Diag<'_, G>,
diag: &mut Diag<'_>,
path: &[OutlivesConstraint<'tcx>],
) {
let tcx = self.infcx.tcx;
Expand Down Expand Up @@ -704,9 +704,9 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> {

/// Add a label to region errors and borrow explanations when outlives constraints arise from
/// proving a type implements `Sized` or `Copy`.
fn add_sized_or_copy_bound_info<G>(
fn add_sized_or_copy_bound_info(
&self,
err: &mut Diag<'_, G>,
err: &mut Diag<'_>,
blamed_category: ConstraintCategory<'tcx>,
path: &[OutlivesConstraint<'tcx>],
) {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/diagnostics/opaque_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ impl<'diag, 'tcx> MirBorrowckCtxt<'_, 'diag, 'tcx> {
{
last_unexpected_hidden_region =
Some((hidden_type.span, named_ty, named_key));
diag.emit()
diag.emit_err()
} else {
diag.delay_as_bug()
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/diagnostics/region_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ impl RegionName {
}
}

pub(crate) fn highlight_region_name<G>(&self, diag: &mut Diag<'_, G>) {
pub(crate) fn highlight_region_name(&self, diag: &mut Diag<'_>) {
match &self.source {
RegionNameSource::NamedLateParamRegion(span)
| RegionNameSource::NamedEarlyParamRegion(span) => {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/region_infer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
}

/// Adds annotations for `#[rustc_regions]`; see `UniversalRegions::annotate`.
pub(crate) fn annotate(&self, tcx: TyCtxt<'tcx>, err: &mut Diag<'_, ()>) {
pub(crate) fn annotate(&self, tcx: TyCtxt<'tcx>, err: &mut Diag<'_>) {
self.universal_regions().annotate(tcx, err)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ fn add_hidden_type<'tcx>(
prev.span = prev.span.substitute_dummy(hidden_ty.span);
} else {
let (Ok(guar) | Err(guar)) =
prev.build_mismatch_error(&hidden_ty, tcx).map(|d| d.emit());
prev.build_mismatch_error(&hidden_ty, tcx).map(|d| d.emit_err());
*prev = ty::DefinitionSiteHiddenType::new_error(tcx, guar);
}
} else {
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_borrowck/src/session_diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -659,13 +659,13 @@ pub(crate) struct SimdIntrinsicArgConst {
pub intrinsic: String,
}

pub(crate) struct TailExprDropOrder<F: FnOnce(&mut Diag<'_, ()>)> {
pub(crate) struct TailExprDropOrder<F: FnOnce(&mut Diag<'_>)> {
pub borrowed: Span,
pub callback: F,
}

impl<'a, F: FnOnce(&mut Diag<'_, ()>)> Diagnostic<'a, ()> for TailExprDropOrder<F> {
fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> {
impl<'a, F: FnOnce(&mut Diag<'_>)> Diagnostic<'a> for TailExprDropOrder<F> {
fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a> {
let Self { borrowed, callback } = self;
let mut diag = Diag::new(dcx, level, "relative drop order changing in Rust 2024")
.with_span_label(
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/universal_regions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ impl<'tcx> UniversalRegions<'tcx> {
/// that this region imposes on others. The methods in this file
/// handle the part about dumping the inference context internal
/// state.
pub(crate) fn annotate(&self, tcx: TyCtxt<'tcx>, err: &mut Diag<'_, ()>) {
pub(crate) fn annotate(&self, tcx: TyCtxt<'tcx>, err: &mut Diag<'_>) {
match self.defining_ty {
DefiningTy::Closure(def_id, args) => {
let v = with_no_trimmed_paths!(
Expand Down
20 changes: 9 additions & 11 deletions compiler/rustc_builtin_macros/src/asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ fn expand_preparsed_asm(
Ok(template_part) => template_part,
Err(err) => {
return ExpandResult::Ready(Err(match err {
Ok((err, _)) => err.emit(),
Ok((err, _)) => err.emit_err(),
Err(guar) => guar,
}));
}
Expand Down Expand Up @@ -407,7 +407,7 @@ fn expand_preparsed_asm(
if let Some((label, span)) = err.secondary_label {
e.span_label(span_in_template(span), label);
}
let guar = e.emit();
let guar = e.emit_err();
return ExpandResult::Ready(Err(guar));
}

Expand Down Expand Up @@ -481,12 +481,10 @@ fn expand_preparsed_asm(
Some(&idx) => Some(idx),
None => {
let span = arg.position_span;
ecx.dcx()
.create_err(diagnostics::AsmNoMatchedArgumentName {
name: name.to_owned(),
span: span_in_template(span),
})
.emit();
ecx.dcx().emit_err(diagnostics::AsmNoMatchedArgumentName {
name: name.to_owned(),
span: span_in_template(span),
});
None
}
}
Expand Down Expand Up @@ -602,7 +600,7 @@ pub(super) fn expand_asm<'cx>(
MacEager::expr(expr)
}
Err(err) => {
let guar = err.emit();
let guar = err.emit_err();
DummyResult::any(sp, guar)
}
})
Expand Down Expand Up @@ -632,7 +630,7 @@ pub(super) fn expand_naked_asm<'cx>(
MacEager::expr(expr)
}
Err(err) => {
let guar = err.emit();
let guar = err.emit_err();
DummyResult::any(sp, guar)
}
})
Expand Down Expand Up @@ -665,7 +663,7 @@ pub(super) fn expand_global_asm<'cx>(
}
}
Err(err) => {
let guar = err.emit();
let guar = err.emit_err();
DummyResult::any(sp, guar)
}
})
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_builtin_macros/src/assert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub(crate) fn expand_assert<'cx>(
let Assert { cond_expr, custom_message } = match parse_assert(cx, span, tts) {
Ok(assert) => assert,
Err(err) => {
let guar = err.emit();
let guar = err.emit_err();
return ExpandResult::Ready(DummyResult::any(span, guar));
}
};
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_builtin_macros/src/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ fn parse_cfg(cx: &ExtCtxt<'_>, span: Span, tts: TokenStream) -> Result<CfgEntry,
ShouldEmit::ErrorsAndLints { recovery: Recovery::Allowed },
AllowExprMetavar::Yes,
)
.map_err(|diag| diag.emit())?;
.map_err(|diag| diag.emit_err())?;
let cfg = AttributeParser::parse_single_args(
cx.sess,
span,
Expand Down
Loading
Loading