Skip to content

Commit 63f4513

Browse files
committed
Auto merge of rust-lang#151381 - JonathanBrouwer:rollup-zvO3tIH, r=JonathanBrouwer
Rollup of 15 pull requests Successful merges: - rust-lang#148623 (Ignore `#[doc(hidden)]` items when computing trimmed paths for printing) - rust-lang#150550 (Miscellaneous cleanups to borrowck related code) - rust-lang#150879 (Remove the diagnostic lints) - rust-lang#150895 (rustc_errors: Add (heuristic) Syntax Highlighting for `rustc --explain`) - rust-lang#150987 (remote-test-server: Fix header in batch mode) - rust-lang#151004 (std: implement `sleep_until` on Apple platforms) - rust-lang#151045 (Simplify some literal-value negations with `u128::wrapping_neg`) - rust-lang#151119 (Support pointers in type reflection) - rust-lang#151171 (Do not recover from `Trait()` if generic list is unterminated) - rust-lang#151231 (HIR typeck cleanup: clarify and re-style `check_expr_unop`) - rust-lang#151249 (Parse ident with allowing recovery when trying to diagnose) - rust-lang#151295 (THIR patterns: Use `ty::Value` in more places throughout `const_to_pat`) - rust-lang#151326 (Remove `DiagMessage::Translated` in favour of `DiagMessage::Str`) - rust-lang#151361 (add test for issue 61463) - rust-lang#151371 (Add `S-blocked` to `labels_blocking_approval`) r? @ghost
2 parents d940e56 + a3c4575 commit 63f4513

File tree

236 files changed

+1244
-1281
lines changed

Some content is hidden

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

236 files changed

+1244
-1281
lines changed

Cargo.lock

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3767,6 +3767,7 @@ dependencies = [
37673767
name = "rustc_driver_impl"
37683768
version = "0.0.0"
37693769
dependencies = [
3770+
"anstyle",
37703771
"ctrlc",
37713772
"jiff",
37723773
"libc",
@@ -3792,6 +3793,7 @@ dependencies = [
37923793
"rustc_index",
37933794
"rustc_infer",
37943795
"rustc_interface",
3796+
"rustc_lexer",
37953797
"rustc_lint",
37963798
"rustc_log",
37973799
"rustc_macros",

compiler/rustc_ast/src/token.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -625,12 +625,12 @@ impl TokenKind {
625625
}
626626

627627
impl Token {
628-
pub fn new(kind: TokenKind, span: Span) -> Self {
628+
pub const fn new(kind: TokenKind, span: Span) -> Self {
629629
Token { kind, span }
630630
}
631631

632632
/// Some token that will be thrown away later.
633-
pub fn dummy() -> Self {
633+
pub const fn dummy() -> Self {
634634
Token::new(TokenKind::Question, DUMMY_SP)
635635
}
636636

compiler/rustc_ast_lowering/src/stability.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ pub(crate) fn extern_abi_enabled(
2929
})
3030
}
3131

32-
#[allow(rustc::untranslatable_diagnostic)]
3332
pub(crate) fn gate_unstable_abi(sess: &Session, features: &Features, span: Span, abi: ExternAbi) {
3433
match extern_abi_enabled(features, span, abi) {
3534
Ok(_) => (),

compiler/rustc_ast_passes/src/feature_gate.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,11 @@ use crate::errors;
1313
macro_rules! gate {
1414
($visitor:expr, $feature:ident, $span:expr, $explain:expr) => {{
1515
if !$visitor.features.$feature() && !$span.allows_unstable(sym::$feature) {
16-
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
1716
feature_err(&$visitor.sess, sym::$feature, $span, $explain).emit();
1817
}
1918
}};
2019
($visitor:expr, $feature:ident, $span:expr, $explain:expr, $help:expr) => {{
2120
if !$visitor.features.$feature() && !$span.allows_unstable(sym::$feature) {
22-
// FIXME: make this translatable
23-
#[allow(rustc::diagnostic_outside_of_impl)]
24-
#[allow(rustc::untranslatable_diagnostic)]
2521
feature_err(&$visitor.sess, sym::$feature, $span, $explain).with_help($help).emit();
2622
}
2723
}};
@@ -31,13 +27,11 @@ macro_rules! gate {
3127
macro_rules! gate_alt {
3228
($visitor:expr, $has_feature:expr, $name:expr, $span:expr, $explain:expr) => {{
3329
if !$has_feature && !$span.allows_unstable($name) {
34-
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
3530
feature_err(&$visitor.sess, $name, $span, $explain).emit();
3631
}
3732
}};
3833
($visitor:expr, $has_feature:expr, $name:expr, $span:expr, $explain:expr, $notes: expr) => {{
3934
if !$has_feature && !$span.allows_unstable($name) {
40-
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
4135
let mut diag = feature_err(&$visitor.sess, $name, $span, $explain);
4236
for note in $notes {
4337
diag.note(*note);
@@ -491,7 +485,6 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) {
491485
&& (!visitor.features.gen_blocks() && !span.allows_unstable(sym::gen_blocks))
492486
&& (!visitor.features.yield_expr() && !span.allows_unstable(sym::yield_expr))
493487
{
494-
#[allow(rustc::untranslatable_diagnostic)]
495488
// Emit yield_expr as the error, since that will be sufficient. You can think of it
496489
// as coroutines and gen_blocks imply yield_expr.
497490
feature_err(&visitor.sess, sym::yield_expr, *span, "yield syntax is experimental")
@@ -523,7 +516,6 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) {
523516
if !visitor.features.min_generic_const_args()
524517
&& !span.allows_unstable(sym::min_generic_const_args)
525518
{
526-
#[allow(rustc::untranslatable_diagnostic)]
527519
feature_err(
528520
&visitor.sess,
529521
sym::min_generic_const_args,
@@ -559,7 +551,6 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) {
559551
if let Ok(snippet) = sm.span_to_snippet(span)
560552
&& snippet == "!"
561553
{
562-
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
563554
feature_err(sess, sym::never_patterns, span, "`!` patterns are experimental")
564555
.emit();
565556
} else {

compiler/rustc_attr_parsing/src/attributes/cfg.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,6 @@ fn try_gate_cfg(name: Symbol, span: Span, sess: &Session, features: Option<&Feat
412412
}
413413
}
414414

415-
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
416415
fn gate_cfg(gated_cfg: &GatedCfg, cfg_span: Span, sess: &Session, features: &Features) {
417416
let (cfg, feature, has_feature) = gated_cfg;
418417
if !has_feature(features) && !cfg_span.allows_unstable(*feature) {

compiler/rustc_attr_parsing/src/attributes/link_attrs.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,6 @@ impl<S: Stage> CombineAttributeParser<S> for LinkParser {
141141

142142
macro report_unstable_modifier($feature: ident) {
143143
if !features.$feature() {
144-
// FIXME: make this translatable
145-
#[expect(rustc::untranslatable_diagnostic)]
146144
feature_err(
147145
sess,
148146
sym::$feature,

compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -164,21 +164,6 @@ impl<S: Stage> SingleAttributeParser<S> for RustcLegacyConstGenericsParser {
164164
}
165165
}
166166

167-
pub(crate) struct RustcLintDiagnosticsParser;
168-
169-
impl<S: Stage> NoArgsAttributeParser<S> for RustcLintDiagnosticsParser {
170-
const PATH: &[Symbol] = &[sym::rustc_lint_diagnostics];
171-
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
172-
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
173-
Allow(Target::Fn),
174-
Allow(Target::Method(MethodKind::Inherent)),
175-
Allow(Target::Method(MethodKind::Trait { body: false })),
176-
Allow(Target::Method(MethodKind::Trait { body: true })),
177-
Allow(Target::Method(MethodKind::TraitImpl)),
178-
]);
179-
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcLintDiagnostics;
180-
}
181-
182167
pub(crate) struct RustcLintOptDenyFieldAccessParser;
183168

184169
impl<S: Stage> SingleAttributeParser<S> for RustcLintOptDenyFieldAccessParser {

compiler/rustc_attr_parsing/src/attributes/transparency.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ use super::prelude::*;
44

55
pub(crate) struct TransparencyParser;
66

7-
// FIXME(jdonszelmann): make these proper diagnostics
8-
#[allow(rustc::untranslatable_diagnostic)]
9-
#[allow(rustc::diagnostic_outside_of_impl)]
107
impl<S: Stage> SingleAttributeParser<S> for TransparencyParser {
118
const PATH: &[Symbol] = &[sym::rustc_macro_transparency];
129
const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepInnermost;

compiler/rustc_attr_parsing/src/context.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,11 @@ use crate::attributes::rustc_dump::{
7575
use crate::attributes::rustc_internal::{
7676
RustcHasIncoherentInherentImplsParser, RustcLayoutScalarValidRangeEndParser,
7777
RustcLayoutScalarValidRangeStartParser, RustcLegacyConstGenericsParser,
78-
RustcLintDiagnosticsParser, RustcLintOptDenyFieldAccessParser, RustcLintOptTyParser,
79-
RustcLintQueryInstabilityParser, RustcLintUntrackedQueryInformationParser, RustcMainParser,
80-
RustcMustImplementOneOfParser, RustcNeverReturnsNullPointerParser,
81-
RustcNoImplicitAutorefsParser, RustcNounwindParser, RustcObjectLifetimeDefaultParser,
82-
RustcOffloadKernelParser, RustcScalableVectorParser, RustcSimdMonomorphizeLaneLimitParser,
78+
RustcLintOptDenyFieldAccessParser, RustcLintOptTyParser, RustcLintQueryInstabilityParser,
79+
RustcLintUntrackedQueryInformationParser, RustcMainParser, RustcMustImplementOneOfParser,
80+
RustcNeverReturnsNullPointerParser, RustcNoImplicitAutorefsParser, RustcNounwindParser,
81+
RustcObjectLifetimeDefaultParser, RustcOffloadKernelParser, RustcScalableVectorParser,
82+
RustcSimdMonomorphizeLaneLimitParser,
8383
};
8484
use crate::attributes::semantics::MayDangleParser;
8585
use crate::attributes::stability::{
@@ -289,7 +289,6 @@ attribute_parsers!(
289289
Single<WithoutArgs<RustcDumpUserArgs>>,
290290
Single<WithoutArgs<RustcDumpVtable>>,
291291
Single<WithoutArgs<RustcHasIncoherentInherentImplsParser>>,
292-
Single<WithoutArgs<RustcLintDiagnosticsParser>>,
293292
Single<WithoutArgs<RustcLintOptTyParser>>,
294293
Single<WithoutArgs<RustcLintQueryInstabilityParser>>,
295294
Single<WithoutArgs<RustcLintUntrackedQueryInformationParser>>,

compiler/rustc_borrowck/src/borrow_set.rs

Lines changed: 39 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -253,19 +253,52 @@ impl<'a, 'tcx> Visitor<'tcx> for GatherBorrows<'a, 'tcx> {
253253
}
254254

255255
let region = region.as_var();
256-
257-
let borrow = BorrowData {
256+
let borrow = |activation_location| BorrowData {
258257
kind,
259258
region,
260259
reserve_location: location,
261-
activation_location: TwoPhaseActivation::NotTwoPhase,
260+
activation_location,
262261
borrowed_place,
263262
assigned_place: *assigned_place,
264263
};
265-
let (idx, _) = self.location_map.insert_full(location, borrow);
266-
let idx = BorrowIndex::from(idx);
267264

268-
self.insert_as_pending_if_two_phase(location, assigned_place, kind, idx);
265+
let idx = if !kind.is_two_phase_borrow() {
266+
debug!(" -> {:?}", location);
267+
let (idx, _) = self
268+
.location_map
269+
.insert_full(location, borrow(TwoPhaseActivation::NotTwoPhase));
270+
BorrowIndex::from(idx)
271+
} else {
272+
// When we encounter a 2-phase borrow statement, it will always
273+
// be assigning into a temporary TEMP:
274+
//
275+
// TEMP = &foo
276+
//
277+
// so extract `temp`.
278+
let Some(temp) = assigned_place.as_local() else {
279+
span_bug!(
280+
self.body.source_info(location).span,
281+
"expected 2-phase borrow to assign to a local, not `{:?}`",
282+
assigned_place,
283+
);
284+
};
285+
286+
// Consider the borrow not activated to start. When we find an activation, we'll update
287+
// this field.
288+
let (idx, _) = self
289+
.location_map
290+
.insert_full(location, borrow(TwoPhaseActivation::NotActivated));
291+
let idx = BorrowIndex::from(idx);
292+
293+
// Insert `temp` into the list of pending activations. From
294+
// now on, we'll be on the lookout for a use of it. Note that
295+
// we are guaranteed that this use will come after the
296+
// assignment.
297+
let prev = self.pending_activations.insert(temp, idx);
298+
assert_eq!(prev, None, "temporary associated with multiple two phase borrows");
299+
300+
idx
301+
};
269302

270303
self.local_map.entry(borrowed_place.local).or_default().insert(idx);
271304
}
@@ -334,62 +367,3 @@ impl<'a, 'tcx> Visitor<'tcx> for GatherBorrows<'a, 'tcx> {
334367
self.super_rvalue(rvalue, location)
335368
}
336369
}
337-
338-
impl<'a, 'tcx> GatherBorrows<'a, 'tcx> {
339-
/// If this is a two-phase borrow, then we will record it
340-
/// as "pending" until we find the activating use.
341-
fn insert_as_pending_if_two_phase(
342-
&mut self,
343-
start_location: Location,
344-
assigned_place: &mir::Place<'tcx>,
345-
kind: mir::BorrowKind,
346-
borrow_index: BorrowIndex,
347-
) {
348-
debug!(
349-
"Borrows::insert_as_pending_if_two_phase({:?}, {:?}, {:?})",
350-
start_location, assigned_place, borrow_index,
351-
);
352-
353-
if !kind.allows_two_phase_borrow() {
354-
debug!(" -> {:?}", start_location);
355-
return;
356-
}
357-
358-
// When we encounter a 2-phase borrow statement, it will always
359-
// be assigning into a temporary TEMP:
360-
//
361-
// TEMP = &foo
362-
//
363-
// so extract `temp`.
364-
let Some(temp) = assigned_place.as_local() else {
365-
span_bug!(
366-
self.body.source_info(start_location).span,
367-
"expected 2-phase borrow to assign to a local, not `{:?}`",
368-
assigned_place,
369-
);
370-
};
371-
372-
// Consider the borrow not activated to start. When we find an activation, we'll update
373-
// this field.
374-
{
375-
let borrow_data = &mut self.location_map[borrow_index.as_usize()];
376-
borrow_data.activation_location = TwoPhaseActivation::NotActivated;
377-
}
378-
379-
// Insert `temp` into the list of pending activations. From
380-
// now on, we'll be on the lookout for a use of it. Note that
381-
// we are guaranteed that this use will come after the
382-
// assignment.
383-
let old_value = self.pending_activations.insert(temp, borrow_index);
384-
if let Some(old_index) = old_value {
385-
span_bug!(
386-
self.body.source_info(start_location).span,
387-
"found already pending activation for temp: {:?} \
388-
at borrow_index: {:?} with associated data {:?}",
389-
temp,
390-
old_index,
391-
self.location_map[old_index.as_usize()]
392-
);
393-
}
394-
}
395-
}

0 commit comments

Comments
 (0)