Skip to content

Commit eef454f

Browse files
authored
Merge pull request rust-lang#4478 from rust-lang/rustup-2025-07-19
Automatic Rustup
2 parents 3799cbd + e11ea3d commit eef454f

File tree

403 files changed

+8189
-5091
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

403 files changed

+8189
-5091
lines changed

compiler/rustc_attr_data_structures/src/attributes.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,22 @@ pub enum DeprecatedSince {
110110
Err,
111111
}
112112

113+
#[derive(
114+
Copy,
115+
Debug,
116+
Eq,
117+
PartialEq,
118+
Encodable,
119+
Decodable,
120+
Clone,
121+
HashStable_Generic,
122+
PrintAttribute
123+
)]
124+
pub enum CoverageStatus {
125+
On,
126+
Off,
127+
}
128+
113129
impl Deprecation {
114130
/// Whether an item marked with #[deprecated(since = "X")] is currently
115131
/// deprecated (i.e., whether X is not greater than the current rustc
@@ -274,6 +290,9 @@ pub enum AttributeKind {
274290
/// Represents `#[const_trait]`.
275291
ConstTrait(Span),
276292

293+
/// Represents `#[coverage]`.
294+
Coverage(Span, CoverageStatus),
295+
277296
///Represents `#[rustc_deny_explicit_impl]`.
278297
DenyExplicitImpl(Span),
279298

compiler/rustc_attr_data_structures/src/encode_cross_crate.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ impl AttributeKind {
2828
ConstStability { .. } => Yes,
2929
ConstStabilityIndirect => No,
3030
ConstTrait(..) => No,
31+
Coverage(..) => No,
3132
DenyExplicitImpl(..) => No,
3233
Deprecation { .. } => Yes,
3334
DoNotImplementViaObject(..) => No,

compiler/rustc_attr_data_structures/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use rustc_ast::token::CommentKind;
2424
use rustc_ast::{AttrStyle, IntTy, UintTy};
2525
use rustc_ast_pretty::pp::Printer;
2626
use rustc_span::hygiene::Transparency;
27-
use rustc_span::{Span, Symbol};
27+
use rustc_span::{ErrorGuaranteed, Span, Symbol};
2828
pub use stability::*;
2929
use thin_vec::ThinVec;
3030
pub use version::*;
@@ -170,7 +170,7 @@ macro_rules! print_tup {
170170
}
171171

172172
print_tup!(A B C D E F G H);
173-
print_skip!(Span, ());
173+
print_skip!(Span, (), ErrorGuaranteed);
174174
print_disp!(u16, bool, NonZero<u32>);
175175
print_debug!(Symbol, UintTy, IntTy, Align, AttrStyle, CommentKind, Transparency);
176176

compiler/rustc_attr_data_structures/src/stability.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::num::NonZero;
22

33
use rustc_macros::{Decodable, Encodable, HashStable_Generic, PrintAttribute};
4-
use rustc_span::{Symbol, sym};
4+
use rustc_span::{ErrorGuaranteed, Symbol, sym};
55

66
use crate::{PrintAttribute, RustcVersion};
77

@@ -153,7 +153,7 @@ pub enum StableSince {
153153
/// Stabilized in the upcoming version, whatever number that is.
154154
Current,
155155
/// Failed to parse a stabilization version.
156-
Err,
156+
Err(ErrorGuaranteed),
157157
}
158158

159159
impl StabilityLevel {

compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use rustc_attr_data_structures::{AttributeKind, OptimizeAttr, UsedBy};
1+
use rustc_attr_data_structures::{AttributeKind, CoverageStatus, OptimizeAttr, UsedBy};
22
use rustc_feature::{AttributeTemplate, template};
33
use rustc_session::parse::feature_err;
44
use rustc_span::{Span, Symbol, sym};
@@ -52,6 +52,45 @@ impl<S: Stage> NoArgsAttributeParser<S> for ColdParser {
5252
const CREATE: fn(Span) -> AttributeKind = AttributeKind::Cold;
5353
}
5454

55+
pub(crate) struct CoverageParser;
56+
57+
impl<S: Stage> SingleAttributeParser<S> for CoverageParser {
58+
const PATH: &[Symbol] = &[sym::coverage];
59+
const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepOutermost;
60+
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
61+
const TEMPLATE: AttributeTemplate = template!(OneOf: &[sym::off, sym::on]);
62+
63+
fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser<'_>) -> Option<AttributeKind> {
64+
let Some(args) = args.list() else {
65+
cx.expected_specific_argument_and_list(cx.attr_span, vec!["on", "off"]);
66+
return None;
67+
};
68+
69+
let Some(arg) = args.single() else {
70+
cx.expected_single_argument(args.span);
71+
return None;
72+
};
73+
74+
let fail_incorrect_argument = |span| cx.expected_specific_argument(span, vec!["on", "off"]);
75+
76+
let Some(arg) = arg.meta_item() else {
77+
fail_incorrect_argument(args.span);
78+
return None;
79+
};
80+
81+
let status = match arg.path().word_sym() {
82+
Some(sym::off) => CoverageStatus::Off,
83+
Some(sym::on) => CoverageStatus::On,
84+
None | Some(_) => {
85+
fail_incorrect_argument(arg.span());
86+
return None;
87+
}
88+
};
89+
90+
Some(AttributeKind::Coverage(cx.attr_span, status))
91+
}
92+
}
93+
5594
pub(crate) struct ExportNameParser;
5695

5796
impl<S: Stage> SingleAttributeParser<S> for ExportNameParser {

compiler/rustc_attr_parsing/src/attributes/stability.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -292,12 +292,12 @@ pub(crate) fn parse_stability<S: Stage>(
292292
} else if let Some(version) = parse_version(since) {
293293
StableSince::Version(version)
294294
} else {
295-
cx.emit_err(session_diagnostics::InvalidSince { span: cx.attr_span });
296-
StableSince::Err
295+
let err = cx.emit_err(session_diagnostics::InvalidSince { span: cx.attr_span });
296+
StableSince::Err(err)
297297
}
298298
} else {
299-
cx.emit_err(session_diagnostics::MissingSince { span: cx.attr_span });
300-
StableSince::Err
299+
let err = cx.emit_err(session_diagnostics::MissingSince { span: cx.attr_span });
300+
StableSince::Err(err)
301301
};
302302

303303
match feature {

compiler/rustc_attr_parsing/src/context.rs

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ use crate::attributes::allow_unstable::{
1717
AllowConstFnUnstableParser, AllowInternalUnstableParser, UnstableFeatureBoundParser,
1818
};
1919
use crate::attributes::codegen_attrs::{
20-
ColdParser, ExportNameParser, NakedParser, NoMangleParser, OmitGdbPrettyPrinterSectionParser,
21-
OptimizeParser, TargetFeatureParser, TrackCallerParser, UsedParser,
20+
ColdParser, CoverageParser, ExportNameParser, NakedParser, NoMangleParser,
21+
OmitGdbPrettyPrinterSectionParser, OptimizeParser, TargetFeatureParser, TrackCallerParser,
22+
UsedParser,
2223
};
2324
use crate::attributes::confusables::ConfusablesParser;
2425
use crate::attributes::deprecation::DeprecationParser;
@@ -139,6 +140,7 @@ attribute_parsers!(
139140
// tidy-alphabetical-end
140141

141142
// tidy-alphabetical-start
143+
Single<CoverageParser>,
142144
Single<DeprecationParser>,
143145
Single<DummyParser>,
144146
Single<ExportNameParser>,
@@ -452,6 +454,25 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
452454
reason: AttributeParseErrorReason::ExpectedSpecificArgument {
453455
possibilities,
454456
strings: false,
457+
list: false,
458+
},
459+
})
460+
}
461+
462+
pub(crate) fn expected_specific_argument_and_list(
463+
&self,
464+
span: Span,
465+
possibilities: Vec<&'static str>,
466+
) -> ErrorGuaranteed {
467+
self.emit_err(AttributeParseError {
468+
span,
469+
attr_span: self.attr_span,
470+
template: self.template.clone(),
471+
attribute: self.attr_path.clone(),
472+
reason: AttributeParseErrorReason::ExpectedSpecificArgument {
473+
possibilities,
474+
strings: false,
475+
list: true,
455476
},
456477
})
457478
}
@@ -469,6 +490,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
469490
reason: AttributeParseErrorReason::ExpectedSpecificArgument {
470491
possibilities,
471492
strings: true,
493+
list: false,
472494
},
473495
})
474496
}

compiler/rustc_attr_parsing/src/session_diagnostics.rs

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -533,15 +533,22 @@ pub(crate) struct LinkOrdinalOutOfRange {
533533

534534
pub(crate) enum AttributeParseErrorReason {
535535
ExpectedNoArgs,
536-
ExpectedStringLiteral { byte_string: Option<Span> },
536+
ExpectedStringLiteral {
537+
byte_string: Option<Span>,
538+
},
537539
ExpectedIntegerLiteral,
538540
ExpectedAtLeastOneArgument,
539541
ExpectedSingleArgument,
540542
ExpectedList,
541543
UnexpectedLiteral,
542544
ExpectedNameValue(Option<Symbol>),
543545
DuplicateKey(Symbol),
544-
ExpectedSpecificArgument { possibilities: Vec<&'static str>, strings: bool },
546+
ExpectedSpecificArgument {
547+
possibilities: Vec<&'static str>,
548+
strings: bool,
549+
/// Should we tell the user to write a list when they didn't?
550+
list: bool,
551+
},
545552
}
546553

547554
pub(crate) struct AttributeParseError {
@@ -615,7 +622,11 @@ impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for AttributeParseError {
615622
format!("expected this to be of the form `{name} = \"...\"`"),
616623
);
617624
}
618-
AttributeParseErrorReason::ExpectedSpecificArgument { possibilities, strings } => {
625+
AttributeParseErrorReason::ExpectedSpecificArgument {
626+
possibilities,
627+
strings,
628+
list: false,
629+
} => {
619630
let quote = if strings { '"' } else { '`' };
620631
match possibilities.as_slice() {
621632
&[] => {}
@@ -641,6 +652,38 @@ impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for AttributeParseError {
641652
}
642653
}
643654
}
655+
AttributeParseErrorReason::ExpectedSpecificArgument {
656+
possibilities,
657+
strings,
658+
list: true,
659+
} => {
660+
let quote = if strings { '"' } else { '`' };
661+
match possibilities.as_slice() {
662+
&[] => {}
663+
&[x] => {
664+
diag.span_label(
665+
self.span,
666+
format!(
667+
"this attribute is only valid with {quote}{x}{quote} as an argument"
668+
),
669+
);
670+
}
671+
[first, second] => {
672+
diag.span_label(self.span, format!("this attribute is only valid with either {quote}{first}{quote} or {quote}{second}{quote} as an argument"));
673+
}
674+
[first @ .., second_to_last, last] => {
675+
let mut res = String::new();
676+
for i in first {
677+
res.push_str(&format!("{quote}{i}{quote}, "));
678+
}
679+
res.push_str(&format!(
680+
"{quote}{second_to_last}{quote} or {quote}{last}{quote}"
681+
));
682+
683+
diag.span_label(self.span, format!("this attribute is only valid with one of the following arguments: {res}"));
684+
}
685+
}
686+
}
644687
}
645688

646689
let suggestions = self.template.suggestions(false, &name);

compiler/rustc_borrowck/src/type_check/constraint_conversion.rs

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use rustc_data_structures::fx::FxHashSet;
12
use rustc_hir::def_id::LocalDefId;
23
use rustc_infer::infer::canonical::QueryRegionConstraints;
34
use rustc_infer::infer::outlives::env::RegionBoundPairs;
@@ -7,7 +8,7 @@ use rustc_infer::infer::{InferCtxt, SubregionOrigin};
78
use rustc_infer::traits::query::type_op::DeeplyNormalize;
89
use rustc_middle::bug;
910
use rustc_middle::ty::{
10-
self, GenericArgKind, Ty, TyCtxt, TypeFoldable, TypeVisitableExt, fold_regions,
11+
self, GenericArgKind, Ty, TyCtxt, TypeFoldable, TypeVisitableExt, elaborate, fold_regions,
1112
};
1213
use rustc_span::Span;
1314
use rustc_trait_selection::traits::query::type_op::{TypeOp, TypeOpOutput};
@@ -70,10 +71,12 @@ impl<'a, 'tcx> ConstraintConversion<'a, 'tcx> {
7071

7172
#[instrument(skip(self), level = "debug")]
7273
pub(super) fn convert_all(&mut self, query_constraints: &QueryRegionConstraints<'tcx>) {
73-
let QueryRegionConstraints { outlives } = query_constraints;
74+
let QueryRegionConstraints { outlives, assumptions } = query_constraints;
75+
let assumptions =
76+
elaborate::elaborate_outlives_assumptions(self.infcx.tcx, assumptions.iter().copied());
7477

7578
for &(predicate, constraint_category) in outlives {
76-
self.convert(predicate, constraint_category);
79+
self.convert(predicate, constraint_category, &assumptions);
7780
}
7881
}
7982

@@ -112,15 +115,20 @@ impl<'a, 'tcx> ConstraintConversion<'a, 'tcx> {
112115

113116
self.category = outlives_requirement.category;
114117
self.span = outlives_requirement.blame_span;
115-
self.convert(ty::OutlivesPredicate(subject, outlived_region), self.category);
118+
self.convert(
119+
ty::OutlivesPredicate(subject, outlived_region),
120+
self.category,
121+
&Default::default(),
122+
);
116123
}
117124
(self.category, self.span, self.from_closure) = backup;
118125
}
119126

120127
fn convert(
121128
&mut self,
122-
predicate: ty::OutlivesPredicate<'tcx, ty::GenericArg<'tcx>>,
129+
predicate: ty::ArgOutlivesPredicate<'tcx>,
123130
constraint_category: ConstraintCategory<'tcx>,
131+
higher_ranked_assumptions: &FxHashSet<ty::ArgOutlivesPredicate<'tcx>>,
124132
) {
125133
let tcx = self.infcx.tcx;
126134
debug!("generate: constraints at: {:#?}", self.locations);
@@ -150,7 +158,15 @@ impl<'a, 'tcx> ConstraintConversion<'a, 'tcx> {
150158
}
151159

152160
let mut next_outlives_predicates = vec![];
153-
for (ty::OutlivesPredicate(k1, r2), constraint_category) in outlives_predicates {
161+
for (pred, constraint_category) in outlives_predicates {
162+
// Constraint is implied by a coroutine's well-formedness.
163+
if self.infcx.tcx.sess.opts.unstable_opts.higher_ranked_assumptions
164+
&& higher_ranked_assumptions.contains(&pred)
165+
{
166+
continue;
167+
}
168+
169+
let ty::OutlivesPredicate(k1, r2) = pred;
154170
match k1.kind() {
155171
GenericArgKind::Lifetime(r1) => {
156172
let r1_vid = self.to_region_vid(r1);
@@ -266,14 +282,15 @@ impl<'a, 'tcx> ConstraintConversion<'a, 'tcx> {
266282
&self,
267283
ty: Ty<'tcx>,
268284
next_outlives_predicates: &mut Vec<(
269-
ty::OutlivesPredicate<'tcx, ty::GenericArg<'tcx>>,
285+
ty::ArgOutlivesPredicate<'tcx>,
270286
ConstraintCategory<'tcx>,
271287
)>,
272288
) -> Ty<'tcx> {
273289
match self.param_env.and(DeeplyNormalize { value: ty }).fully_perform(self.infcx, self.span)
274290
{
275291
Ok(TypeOpOutput { output: ty, constraints, .. }) => {
276-
if let Some(QueryRegionConstraints { outlives }) = constraints {
292+
// FIXME(higher_ranked_auto): What should we do with the assumptions here?
293+
if let Some(QueryRegionConstraints { outlives, assumptions: _ }) = constraints {
277294
next_outlives_predicates.extend(outlives.iter().copied());
278295
}
279296
ty

compiler/rustc_borrowck/src/type_check/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,11 @@ pub(crate) fn type_check<'tcx>(
131131
pre_obligations.is_empty(),
132132
"there should be no incoming region obligations = {pre_obligations:#?}",
133133
);
134+
let pre_assumptions = infcx.take_registered_region_assumptions();
135+
assert!(
136+
pre_assumptions.is_empty(),
137+
"there should be no incoming region assumptions = {pre_assumptions:#?}",
138+
);
134139

135140
debug!(?normalized_inputs_and_output);
136141

0 commit comments

Comments
 (0)