Skip to content

Commit 54d024e

Browse files
committed
Auto merge of #140650 - tgross35:rollup-0mp4h1s, r=tgross35
Rollup of 4 pull requests Successful merges: - #135734 (Correct `extract_if` sample equivalent.) - #140307 (Refactor rustc_on_unimplemented's filter parser) - #140644 (Revert "Avoid unused clones in Cloned<I> and Copied<I>") - #140648 (Update `compiler-builtins` to 0.1.157) r? `@ghost` `@rustbot` modify labels: rollup
2 parents cd55868 + 512dab0 commit 54d024e

File tree

14 files changed

+546
-367
lines changed

14 files changed

+546
-367
lines changed

Cargo.lock

-1
Original file line numberDiff line numberDiff line change
@@ -4502,7 +4502,6 @@ dependencies = [
45024502
"itertools",
45034503
"rustc_abi",
45044504
"rustc_ast",
4505-
"rustc_attr_parsing",
45064505
"rustc_data_structures",
45074506
"rustc_errors",
45084507
"rustc_fluent_macro",

compiler/rustc_trait_selection/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ edition = "2024"
88
itertools = "0.12"
99
rustc_abi = { path = "../rustc_abi" }
1010
rustc_ast = { path = "../rustc_ast" }
11-
rustc_attr_parsing = { path = "../rustc_attr_parsing" }
1211
rustc_data_structures = { path = "../rustc_data_structures" }
1312
rustc_errors = { path = "../rustc_errors" }
1413
rustc_fluent_macro = { path = "../rustc_fluent_macro" }

compiler/rustc_trait_selection/messages.ftl

+16-10
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,6 @@ trait_selection_dtcs_has_req_note = the used `impl` has a `'static` requirement
148148
trait_selection_dtcs_introduces_requirement = calling this method introduces the `impl`'s `'static` requirement
149149
trait_selection_dtcs_suggestion = consider relaxing the implicit `'static` requirement
150150
151-
trait_selection_empty_on_clause_in_rustc_on_unimplemented = empty `on`-clause in `#[rustc_on_unimplemented]`
152-
.label = empty on-clause here
153-
154151
trait_selection_explicit_lifetime_required_sugg_with_ident = add explicit lifetime `{$named}` to the type of `{$simple_ident}`
155152
156153
trait_selection_explicit_lifetime_required_sugg_with_param_type = add explicit lifetime `{$named}` to type
@@ -187,9 +184,6 @@ trait_selection_inherent_projection_normalization_overflow = overflow evaluating
187184
trait_selection_invalid_format_specifier = invalid format specifier
188185
.help = no format specifier are supported in this position
189186
190-
trait_selection_invalid_on_clause_in_rustc_on_unimplemented = invalid `on`-clause in `#[rustc_on_unimplemented]`
191-
.label = invalid on-clause here
192-
193187
trait_selection_label_bad = {$bad_kind ->
194188
*[other] cannot infer type
195189
[more_info] cannot infer {$prefix_kind ->
@@ -237,10 +231,6 @@ trait_selection_negative_positive_conflict = found both positive and negative im
237231
.positive_implementation_here = positive implementation here
238232
.positive_implementation_in_crate = positive implementation in crate `{$positive_impl_cname}`
239233
240-
trait_selection_no_value_in_rustc_on_unimplemented = this attribute must have a valid value
241-
.label = expected value here
242-
.note = eg `#[rustc_on_unimplemented(message="foo")]`
243-
244234
trait_selection_nothing = {""}
245235
246236
trait_selection_oc_cant_coerce_force_inline =
@@ -339,6 +329,22 @@ trait_selection_ril_introduced_by = requirement introduced by this return type
339329
trait_selection_ril_introduced_here = `'static` requirement introduced here
340330
trait_selection_ril_static_introduced_by = "`'static` lifetime requirement introduced by the return type
341331
332+
trait_selection_rustc_on_unimplemented_empty_on_clause = empty `on`-clause in `#[rustc_on_unimplemented]`
333+
.label = empty `on`-clause here
334+
trait_selection_rustc_on_unimplemented_expected_identifier = expected an identifier inside this `on`-clause
335+
.label = expected an identifier here, not `{$path}`
336+
trait_selection_rustc_on_unimplemented_expected_one_predicate_in_not = expected a single predicate in `not(..)`
337+
.label = unexpected quantity of predicates here
338+
trait_selection_rustc_on_unimplemented_invalid_flag = invalid flag in `on`-clause
339+
.label = expected one of the `crate_local`, `direct` or `from_desugaring` flags, not `{$invalid_flag}`
340+
trait_selection_rustc_on_unimplemented_invalid_predicate = this predicate is invalid
341+
.label = expected one of `any`, `all` or `not` here, not `{$invalid_pred}`
342+
trait_selection_rustc_on_unimplemented_missing_value = this attribute must have a value
343+
.label = expected value here
344+
.note = e.g. `#[rustc_on_unimplemented(message="foo")]`
345+
trait_selection_rustc_on_unimplemented_unsupported_literal_in_on = literals inside `on`-clauses are not supported
346+
.label = unexpected literal here
347+
342348
trait_selection_source_kind_closure_return =
343349
try giving this closure an explicit return type
344350

compiler/rustc_trait_selection/src/error_reporting/traits/on_unimplemented.rs

+23-29
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use std::path::PathBuf;
44
use rustc_ast::{LitKind, MetaItem, MetaItemInner, MetaItemKind, MetaItemLit};
55
use rustc_errors::codes::*;
66
use rustc_errors::{ErrorGuaranteed, struct_span_code_err};
7+
use rustc_hir as hir;
78
use rustc_hir::def_id::{DefId, LocalDefId};
89
use rustc_hir::{AttrArgs, Attribute};
910
use rustc_macros::LintDiagnostic;
@@ -13,17 +14,16 @@ use rustc_middle::ty::{self, GenericArgsRef, GenericParamDef, GenericParamDefKin
1314
use rustc_session::lint::builtin::UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES;
1415
use rustc_span::{Span, Symbol, sym};
1516
use tracing::{debug, info};
16-
use {rustc_attr_parsing as attr, rustc_hir as hir};
1717

1818
use super::{ObligationCauseCode, PredicateObligation};
1919
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+
};
2123
use crate::error_reporting::traits::on_unimplemented_format::{
2224
Ctx, FormatArgs, FormatString, FormatWarning,
2325
};
24-
use crate::errors::{
25-
EmptyOnClauseInOnUnimplemented, InvalidOnClauseInOnUnimplemented, NoValueInOnUnimplemented,
26-
};
26+
use crate::errors::{InvalidOnClause, NoValueInOnUnimplemented};
2727
use crate::infer::InferCtxtExt;
2828

2929
impl<'tcx> TypeErrCtxt<'_, 'tcx> {
@@ -306,21 +306,21 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
306306
#[derive(Clone, Debug)]
307307
pub struct OnUnimplementedFormatString {
308308
/// Symbol of the format string, i.e. `"content"`
309-
pub symbol: Symbol,
309+
symbol: Symbol,
310310
///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,
313313
}
314314

315315
#[derive(Debug)]
316316
pub struct OnUnimplementedDirective {
317-
pub condition: Option<Condition>,
318-
pub subcommands: Vec<OnUnimplementedDirective>,
319-
pub message: Option<(Span, OnUnimplementedFormatString)>,
320-
pub label: Option<(Span, OnUnimplementedFormatString)>,
321-
pub notes: Vec<OnUnimplementedFormatString>,
322-
pub parent_label: Option<OnUnimplementedFormatString>,
323-
pub append_const_msg: Option<AppendConstMessage>,
317+
condition: Option<OnUnimplementedCondition>,
318+
subcommands: Vec<OnUnimplementedDirective>,
319+
message: Option<(Span, OnUnimplementedFormatString)>,
320+
label: Option<(Span, OnUnimplementedFormatString)>,
321+
notes: Vec<OnUnimplementedFormatString>,
322+
parent_label: Option<OnUnimplementedFormatString>,
323+
append_const_msg: Option<AppendConstMessage>,
324324
}
325325

326326
/// For the `#[rustc_on_unimplemented]` attribute
@@ -427,18 +427,12 @@ impl<'tcx> OnUnimplementedDirective {
427427
} else {
428428
let cond = item_iter
429429
.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+
}
442436
};
443437

444438
let mut message = None;
@@ -724,7 +718,7 @@ impl<'tcx> OnUnimplementedDirective {
724718
result
725719
}
726720

727-
pub fn evaluate(
721+
pub(crate) fn evaluate(
728722
&self,
729723
tcx: TyCtxt<'tcx>,
730724
trait_ref: ty::TraitRef<'tcx>,
@@ -744,7 +738,7 @@ impl<'tcx> OnUnimplementedDirective {
744738
for command in self.subcommands.iter().chain(Some(self)).rev() {
745739
debug!(?command);
746740
if let Some(ref condition) = command.condition
747-
&& !condition.matches_predicate(tcx, condition_options)
741+
&& !condition.matches_predicate(condition_options)
748742
{
749743
debug!("evaluate: skipping {:?} due to condition", command);
750744
continue;

0 commit comments

Comments
 (0)