Auto merge of #140650 - tgross35:rollup-0mp4h1s, r=tgross35 · rust-lang/rust@54d024e (original) (raw)

`@@ -4,6 +4,7 @@ use std::path::PathBuf;

`

4

4

`use rustc_ast::{LitKind, MetaItem, MetaItemInner, MetaItemKind, MetaItemLit};

`

5

5

`use rustc_errors::codes::*;

`

6

6

`use rustc_errors::{ErrorGuaranteed, struct_span_code_err};

`

``

7

`+

use rustc_hir as hir;

`

7

8

`use rustc_hir::def_id::{DefId, LocalDefId};

`

8

9

`use rustc_hir::{AttrArgs, Attribute};

`

9

10

`use rustc_macros::LintDiagnostic;

`

`@@ -13,17 +14,16 @@ use rustc_middle::ty::{self, GenericArgsRef, GenericParamDef, GenericParamDefKin

`

13

14

`use rustc_session::lint::builtin::UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES;

`

14

15

`use rustc_span::{Span, Symbol, sym};

`

15

16

`use tracing::{debug, info};

`

16

``

`-

use {rustc_attr_parsing as attr, rustc_hir as hir};

`

17

17

``

18

18

`use super::{ObligationCauseCode, PredicateObligation};

`

19

19

`use crate::error_reporting::TypeErrCtxt;

`

20

``

`-

use crate::error_reporting::traits::on_unimplemented_condition::{Condition, ConditionOptions};

`

``

20

`+

use crate::error_reporting::traits::on_unimplemented_condition::{

`

``

21

`+

ConditionOptions, OnUnimplementedCondition,

`

``

22

`+

};

`

21

23

`use crate::error_reporting::traits::on_unimplemented_format::{

`

22

24

`Ctx, FormatArgs, FormatString, FormatWarning,

`

23

25

`};

`

24

``

`-

use crate::errors::{

`

25

``

`-

EmptyOnClauseInOnUnimplemented, InvalidOnClauseInOnUnimplemented, NoValueInOnUnimplemented,

`

26

``

`-

};

`

``

26

`+

use crate::errors::{InvalidOnClause, NoValueInOnUnimplemented};

`

27

27

`use crate::infer::InferCtxtExt;

`

28

28

``

29

29

`impl<'tcx> TypeErrCtxt<'_, 'tcx> {

`

`@@ -306,21 +306,21 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {

`

306

306

`#[derive(Clone, Debug)]

`

307

307

`pub struct OnUnimplementedFormatString {

`

308

308

`` /// Symbol of the format string, i.e. "content"

``

309

``

`-

pub symbol: Symbol,

`

``

309

`+

symbol: Symbol,

`

310

310

`` ///The span of the format string, i.e. "content"

``

311

``

`-

pub span: Span,

`

312

``

`-

pub is_diagnostic_namespace_variant: bool,

`

``

311

`+

span: Span,

`

``

312

`+

is_diagnostic_namespace_variant: bool,

`

313

313

`}

`

314

314

``

315

315

`#[derive(Debug)]

`

316

316

`pub struct OnUnimplementedDirective {

`

317

``

`-

pub condition: Option,

`

318

``

`-

pub subcommands: Vec,

`

319

``

`-

pub message: Option<(Span, OnUnimplementedFormatString)>,

`

320

``

`-

pub label: Option<(Span, OnUnimplementedFormatString)>,

`

321

``

`-

pub notes: Vec,

`

322

``

`-

pub parent_label: Option,

`

323

``

`-

pub append_const_msg: Option,

`

``

317

`+

condition: Option,

`

``

318

`+

subcommands: Vec,

`

``

319

`+

message: Option<(Span, OnUnimplementedFormatString)>,

`

``

320

`+

label: Option<(Span, OnUnimplementedFormatString)>,

`

``

321

`+

notes: Vec,

`

``

322

`+

parent_label: Option,

`

``

323

`+

append_const_msg: Option,

`

324

324

`}

`

325

325

``

326

326

`` /// For the #[rustc_on_unimplemented] attribute

``

`@@ -427,18 +427,12 @@ impl<'tcx> OnUnimplementedDirective {

`

427

427

`} else {

`

428

428

`let cond = item_iter

`

429

429

`.next()

`

430

``

`-

.ok_or_else(|| tcx.dcx().emit_err(EmptyOnClauseInOnUnimplemented { span }))?

`

431

``

`-

.meta_item_or_bool()

`

432

``

`-

.ok_or_else(|| tcx.dcx().emit_err(InvalidOnClauseInOnUnimplemented { span }))?;

`

433

``

`-

attr::eval_condition(cond, &tcx.sess, Some(tcx.features()), &mut |cfg| {

`

434

``

`-

if let Some(value) = cfg.value

`

435

``

`-

&& let Err(guar) = parse_value(value, cfg.span)

`

436

``

`-

{

`

437

``

`-

errored = Some(guar);

`

438

``

`-

}

`

439

``

`-

true

`

440

``

`-

});

`

441

``

`-

Some(Condition { inner: cond.clone() })

`

``

430

`+

.ok_or_else(|| tcx.dcx().emit_err(InvalidOnClause::Empty { span }))?;

`

``

431

+

``

432

`+

match OnUnimplementedCondition::parse(cond) {

`

``

433

`+

Ok(condition) => Some(condition),

`

``

434

`+

Err(e) => return Err(tcx.dcx().emit_err(e)),

`

``

435

`+

}

`

442

436

`};

`

443

437

``

444

438

`let mut message = None;

`

`@@ -724,7 +718,7 @@ impl<'tcx> OnUnimplementedDirective {

`

724

718

` result

`

725

719

`}

`

726

720

``

727

``

`-

pub fn evaluate(

`

``

721

`+

pub(crate) fn evaluate(

`

728

722

`&self,

`

729

723

`tcx: TyCtxt<'tcx>,

`

730

724

`trait_ref: ty::TraitRef<'tcx>,

`

`@@ -744,7 +738,7 @@ impl<'tcx> OnUnimplementedDirective {

`

744

738

`for command in self.subcommands.iter().chain(Some(self)).rev() {

`

745

739

`debug!(?command);

`

746

740

`if let Some(ref condition) = command.condition

`

747

``

`-

&& !condition.matches_predicate(tcx, condition_options)

`

``

741

`+

&& !condition.matches_predicate(condition_options)

`

748

742

`{

`

749

743

`debug!("evaluate: skipping {:?} due to condition", command);

`

750

744

`continue;

`