Skip to content

Commit 7356ff7

Browse files
committed
Implement other logics
1 parent dd067a6 commit 7356ff7

File tree

31 files changed

+132
-9
lines changed

31 files changed

+132
-9
lines changed

compiler/rustc_attr_data_structures/src/encode_cross_crate.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ impl AttributeKind {
7070
TrackCaller(..) => Yes,
7171
TypeConst(..) => Yes,
7272
UnsafeSpecializationMarker(..) => No,
73+
UnstableFeatureBound(..) => No,
7374
Used { .. } => No,
7475
// tidy-alphabetical-end
7576
}

compiler/rustc_attr_parsing/src/context.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ use rustc_hir::{AttrArgs, AttrItem, AttrPath, Attribute, HashIgnoredAttrId, HirI
1313
use rustc_session::Session;
1414
use rustc_span::{DUMMY_SP, ErrorGuaranteed, Span, Symbol, sym};
1515

16-
use crate::attributes::allow_unstable::{AllowConstFnUnstableParser, AllowInternalUnstableParser};
16+
use crate::attributes::allow_unstable::{
17+
AllowConstFnUnstableParser, AllowInternalUnstableParser, UnstableFeatureBoundParser,
18+
};
1719
use crate::attributes::codegen_attrs::{
1820
ColdParser, ExportNameParser, NakedParser, NoMangleParser, OmitGdbPrettyPrinterSectionParser,
1921
OptimizeParser, TargetFeatureParser, TrackCallerParser, UsedParser,
@@ -133,6 +135,7 @@ attribute_parsers!(
133135
Combine<AllowInternalUnstableParser>,
134136
Combine<ReprParser>,
135137
Combine<TargetFeatureParser>,
138+
Combine<UnstableFeatureBoundParser>,
136139
// tidy-alphabetical-end
137140

138141
// tidy-alphabetical-start

compiler/rustc_feature/src/builtin_attrs.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,10 @@ pub static BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
683683
template!(List: r#"feature = "name", reason = "...", issue = "N""#), DuplicatesOk,
684684
EncodeCrossCrate::Yes
685685
),
686+
ungated!(
687+
unstable_feature_bound, Normal, template!(Word, List: "feat1, feat2, ..."),
688+
DuplicatesOk, EncodeCrossCrate::No,
689+
),
686690
ungated!(
687691
rustc_const_unstable, Normal, template!(List: r#"feature = "name""#),
688692
DuplicatesOk, EncodeCrossCrate::Yes

compiler/rustc_hir_analysis/src/check/wfcheck.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2212,12 +2212,16 @@ impl<'tcx> WfCheckingCtxt<'_, 'tcx> {
22122212
let implied_obligations = traits::elaborate(tcx, predicates_with_span);
22132213

22142214
for (pred, obligation_span) in implied_obligations {
2215-
// We lower empty bounds like `Vec<dyn Copy>:` as
2216-
// `WellFormed(Vec<dyn Copy>)`, which will later get checked by
2217-
// regular WF checking
2218-
if let ty::ClauseKind::WellFormed(..) = pred.kind().skip_binder() {
2219-
continue;
2215+
match pred.kind().skip_binder() {
2216+
// We lower empty bounds like `Vec<dyn Copy>:` as
2217+
// `WellFormed(Vec<dyn Copy>)`, which will later get checked by
2218+
// regular WF checking
2219+
ty::ClauseKind::WellFormed(..)
2220+
// Unstable feature goals cannot be proven in an empty environment so skip them
2221+
| ty::ClauseKind::UnstableFeature(..) => continue,
2222+
_ => {}
22202223
}
2224+
22212225
// Match the existing behavior.
22222226
if pred.is_global() && !pred.has_type_flags(TypeFlags::HAS_BINDER_VARS) {
22232227
let pred = self.normalize(span, None, pred);

compiler/rustc_hir_analysis/src/collect/predicates_of.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -778,6 +778,7 @@ pub(super) fn assert_only_contains_predicates_from<'tcx>(
778778
ty::ClauseKind::RegionOutlives(_)
779779
| ty::ClauseKind::ConstArgHasType(_, _)
780780
| ty::ClauseKind::WellFormed(_)
781+
| ty::ClauseKind::UnstableFeature(_)
781782
| ty::ClauseKind::ConstEvaluatable(_) => {
782783
bug!(
783784
"unexpected non-`Self` predicate when computing \
@@ -805,6 +806,7 @@ pub(super) fn assert_only_contains_predicates_from<'tcx>(
805806
| ty::ClauseKind::ConstArgHasType(_, _)
806807
| ty::ClauseKind::WellFormed(_)
807808
| ty::ClauseKind::ConstEvaluatable(_)
809+
| ty::ClauseKind::UnstableFeature(_)
808810
| ty::ClauseKind::HostEffect(..) => {
809811
bug!(
810812
"unexpected non-`Self` predicate when computing \

compiler/rustc_hir_analysis/src/impl_wf_check/min_specialization.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,7 @@ fn trait_specialization_kind<'tcx>(
499499
| ty::ClauseKind::ConstArgHasType(..)
500500
| ty::ClauseKind::WellFormed(_)
501501
| ty::ClauseKind::ConstEvaluatable(..)
502+
| ty::ClauseKind::UnstableFeature(_)
502503
| ty::ClauseKind::HostEffect(..) => None,
503504
}
504505
}

compiler/rustc_hir_analysis/src/outlives/explicit.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ impl<'tcx> ExplicitPredicatesMap<'tcx> {
5454
| ty::ClauseKind::ConstArgHasType(_, _)
5555
| ty::ClauseKind::WellFormed(_)
5656
| ty::ClauseKind::ConstEvaluatable(_)
57+
| ty::ClauseKind::UnstableFeature(_)
5758
| ty::ClauseKind::HostEffect(..) => {}
5859
}
5960
}

compiler/rustc_hir_typeck/src/fn_ctxt/inspect_obligations.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
5454
| ty::PredicateKind::Clause(ty::ClauseKind::ConstEvaluatable(..))
5555
| ty::PredicateKind::ConstEquate(..)
5656
| ty::PredicateKind::Clause(ty::ClauseKind::HostEffect(..))
57+
| ty::PredicateKind::Clause(ty::ClauseKind::UnstableFeature(_))
5758
| ty::PredicateKind::Ambiguous => false,
5859
}
5960
}

compiler/rustc_hir_typeck/src/method/probe.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -921,6 +921,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
921921
| ty::ClauseKind::ConstArgHasType(_, _)
922922
| ty::ClauseKind::WellFormed(_)
923923
| ty::ClauseKind::ConstEvaluatable(_)
924+
| ty::ClauseKind::UnstableFeature(_)
924925
| ty::ClauseKind::HostEffect(..) => None,
925926
}
926927
});

compiler/rustc_lint/src/builtin.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1519,8 +1519,9 @@ impl<'tcx> LateLintPass<'tcx> for TrivialConstraints {
15191519
ClauseKind::TypeOutlives(..) |
15201520
ClauseKind::RegionOutlives(..) => "lifetime",
15211521

1522+
ClauseKind::UnstableFeature(_)
15221523
// `ConstArgHasType` is never global as `ct` is always a param
1523-
ClauseKind::ConstArgHasType(..)
1524+
| ClauseKind::ConstArgHasType(..)
15241525
// Ignore projections, as they can only be global
15251526
// if the trait bound is global
15261527
| ClauseKind::Projection(..)

0 commit comments

Comments
 (0)