Skip to content

Commit 7caad69

Browse files
committed
Auto merge of #131354 - matthiaskrgr:rollup-hprnng2, r=matthiaskrgr
Rollup of 4 pull requests Successful merges: - #131331 (Revert "warn_old_master_branch" check) - #131344 (Avoid `&Lrc<T>` in various places) - #131346 (Restrict `ignore-mode-*` directives) - #131353 (Add documentation for `runtest::check_rustdoc_test_option` method) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 0b16baa + fd2278d commit 7caad69

File tree

23 files changed

+53
-128
lines changed

23 files changed

+53
-128
lines changed

compiler/rustc_codegen_ssa/src/back/write.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ use rustc_ast::attr;
1111
use rustc_data_structures::fx::{FxHashMap, FxIndexMap};
1212
use rustc_data_structures::memmap::Mmap;
1313
use rustc_data_structures::profiling::{SelfProfilerRef, VerboseTimingGuard};
14-
use rustc_data_structures::sync::Lrc;
1514
use rustc_errors::emitter::Emitter;
1615
use rustc_errors::translation::Translate;
1716
use rustc_errors::{
@@ -1889,7 +1888,7 @@ impl SharedEmitter {
18891888
}
18901889

18911890
impl Translate for SharedEmitter {
1892-
fn fluent_bundle(&self) -> Option<&Lrc<FluentBundle>> {
1891+
fn fluent_bundle(&self) -> Option<&FluentBundle> {
18931892
None
18941893
}
18951894

@@ -1924,7 +1923,7 @@ impl Emitter for SharedEmitter {
19241923
);
19251924
}
19261925

1927-
fn source_map(&self) -> Option<&Lrc<SourceMap>> {
1926+
fn source_map(&self) -> Option<&SourceMap> {
19281927
None
19291928
}
19301929
}

compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ pub struct AnnotateSnippetEmitter {
3434
}
3535

3636
impl Translate for AnnotateSnippetEmitter {
37-
fn fluent_bundle(&self) -> Option<&Lrc<FluentBundle>> {
38-
self.fluent_bundle.as_ref()
37+
fn fluent_bundle(&self) -> Option<&FluentBundle> {
38+
self.fluent_bundle.as_deref()
3939
}
4040

4141
fn fallback_fluent_bundle(&self) -> &FluentBundle {
@@ -69,8 +69,8 @@ impl Emitter for AnnotateSnippetEmitter {
6969
);
7070
}
7171

72-
fn source_map(&self) -> Option<&Lrc<SourceMap>> {
73-
self.source_map.as_ref()
72+
fn source_map(&self) -> Option<&SourceMap> {
73+
self.source_map.as_deref()
7474
}
7575

7676
fn should_show_explain(&self) -> bool {

compiler/rustc_errors/src/emitter.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ pub trait Emitter: Translate {
205205
false
206206
}
207207

208-
fn source_map(&self) -> Option<&Lrc<SourceMap>>;
208+
fn source_map(&self) -> Option<&SourceMap>;
209209

210210
/// Formats the substitutions of the primary_span
211211
///
@@ -481,8 +481,8 @@ pub trait Emitter: Translate {
481481
}
482482

483483
impl Translate for HumanEmitter {
484-
fn fluent_bundle(&self) -> Option<&Lrc<FluentBundle>> {
485-
self.fluent_bundle.as_ref()
484+
fn fluent_bundle(&self) -> Option<&FluentBundle> {
485+
self.fluent_bundle.as_deref()
486486
}
487487

488488
fn fallback_fluent_bundle(&self) -> &FluentBundle {
@@ -491,8 +491,8 @@ impl Translate for HumanEmitter {
491491
}
492492

493493
impl Emitter for HumanEmitter {
494-
fn source_map(&self) -> Option<&Lrc<SourceMap>> {
495-
self.sm.as_ref()
494+
fn source_map(&self) -> Option<&SourceMap> {
495+
self.sm.as_deref()
496496
}
497497

498498
fn emit_diagnostic(&mut self, mut diag: DiagInner) {
@@ -540,7 +540,7 @@ pub struct SilentEmitter {
540540
}
541541

542542
impl Translate for SilentEmitter {
543-
fn fluent_bundle(&self) -> Option<&Lrc<FluentBundle>> {
543+
fn fluent_bundle(&self) -> Option<&FluentBundle> {
544544
None
545545
}
546546

@@ -552,7 +552,7 @@ impl Translate for SilentEmitter {
552552
}
553553

554554
impl Emitter for SilentEmitter {
555-
fn source_map(&self) -> Option<&Lrc<SourceMap>> {
555+
fn source_map(&self) -> Option<&SourceMap> {
556556
None
557557
}
558558

compiler/rustc_errors/src/json.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ enum EmitTyped<'a> {
111111
}
112112

113113
impl Translate for JsonEmitter {
114-
fn fluent_bundle(&self) -> Option<&Lrc<FluentBundle>> {
115-
self.fluent_bundle.as_ref()
114+
fn fluent_bundle(&self) -> Option<&FluentBundle> {
115+
self.fluent_bundle.as_deref()
116116
}
117117

118118
fn fallback_fluent_bundle(&self) -> &FluentBundle {
@@ -172,7 +172,7 @@ impl Emitter for JsonEmitter {
172172
}
173173
}
174174

175-
fn source_map(&self) -> Option<&Lrc<SourceMap>> {
175+
fn source_map(&self) -> Option<&SourceMap> {
176176
Some(&self.sm)
177177
}
178178

compiler/rustc_errors/src/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ use registry::Registry;
5959
use rustc_data_structures::AtomicRef;
6060
use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet};
6161
use rustc_data_structures::stable_hasher::{Hash128, StableHasher};
62-
use rustc_data_structures::sync::{Lock, Lrc};
62+
use rustc_data_structures::sync::Lock;
6363
pub use rustc_error_messages::{
6464
DiagMessage, FluentBundle, LanguageIdentifier, LazyFallbackBundle, MultiSpan, SpanLabel,
6565
SubdiagMessage, fallback_fluent_bundle, fluent_bundle,
@@ -685,13 +685,13 @@ impl DiagCtxt {
685685
unimplemented!("false emitter must only used during `wrap_emitter`")
686686
}
687687

688-
fn source_map(&self) -> Option<&Lrc<SourceMap>> {
688+
fn source_map(&self) -> Option<&SourceMap> {
689689
unimplemented!("false emitter must only used during `wrap_emitter`")
690690
}
691691
}
692692

693693
impl translation::Translate for FalseEmitter {
694-
fn fluent_bundle(&self) -> Option<&Lrc<FluentBundle>> {
694+
fn fluent_bundle(&self) -> Option<&FluentBundle> {
695695
unimplemented!("false emitter must only used during `wrap_emitter`")
696696
}
697697

compiler/rustc_errors/src/tests.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use rustc_data_structures::sync::{IntoDynSyncSend, Lrc};
1+
use rustc_data_structures::sync::IntoDynSyncSend;
22
use rustc_error_messages::fluent_bundle::resolver::errors::{ReferenceKind, ResolverError};
33
use rustc_error_messages::{DiagMessage, langid};
44

@@ -12,7 +12,7 @@ struct Dummy {
1212
}
1313

1414
impl Translate for Dummy {
15-
fn fluent_bundle(&self) -> Option<&Lrc<FluentBundle>> {
15+
fn fluent_bundle(&self) -> Option<&FluentBundle> {
1616
None
1717
}
1818

compiler/rustc_errors/src/translation.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use std::borrow::Cow;
22
use std::env;
33
use std::error::Report;
44

5-
use rustc_data_structures::sync::Lrc;
65
pub use rustc_error_messages::FluentArgs;
76
use tracing::{debug, trace};
87

@@ -33,7 +32,7 @@ pub trait Translate {
3332
/// Return `FluentBundle` with localized diagnostics for the locale requested by the user. If no
3433
/// language was requested by the user then this will be `None` and `fallback_fluent_bundle`
3534
/// should be used.
36-
fn fluent_bundle(&self) -> Option<&Lrc<FluentBundle>>;
35+
fn fluent_bundle(&self) -> Option<&FluentBundle>;
3736

3837
/// Return `FluentBundle` with localized diagnostics for the default locale of the compiler.
3938
/// Used when the user has not requested a specific language or when a localized diagnostic is

compiler/rustc_infer/src/infer/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -749,7 +749,7 @@ impl<'tcx> InferCtxt<'tcx> {
749749
definition_span: Span,
750750
hidden_ty: Ty<'tcx>,
751751
region: ty::Region<'tcx>,
752-
in_regions: &Lrc<Vec<ty::Region<'tcx>>>,
752+
in_regions: Lrc<Vec<ty::Region<'tcx>>>,
753753
) {
754754
self.inner.borrow_mut().unwrap_region_constraints().member_constraint(
755755
key,

compiler/rustc_infer/src/infer/opaque_types/mod.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,15 @@ impl<'tcx> InferCtxt<'tcx> {
358358
// not currently sound until we have existential regions.
359359
concrete_ty.visit_with(&mut ConstrainOpaqueTypeRegionVisitor {
360360
tcx: self.tcx,
361-
op: |r| self.member_constraint(opaque_type_key, span, concrete_ty, r, &choice_regions),
361+
op: |r| {
362+
self.member_constraint(
363+
opaque_type_key,
364+
span,
365+
concrete_ty,
366+
r,
367+
choice_regions.clone(),
368+
)
369+
},
362370
});
363371
}
364372
}

compiler/rustc_infer/src/infer/region_constraints/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ impl<'tcx> RegionConstraintCollector<'_, 'tcx> {
522522
definition_span: Span,
523523
hidden_ty: Ty<'tcx>,
524524
member_region: ty::Region<'tcx>,
525-
choice_regions: &Lrc<Vec<ty::Region<'tcx>>>,
525+
choice_regions: Lrc<Vec<ty::Region<'tcx>>>,
526526
) {
527527
debug!("member_constraint({:?} in {:#?})", member_region, choice_regions);
528528

@@ -535,7 +535,7 @@ impl<'tcx> RegionConstraintCollector<'_, 'tcx> {
535535
definition_span,
536536
hidden_ty,
537537
member_region,
538-
choice_regions: choice_regions.clone(),
538+
choice_regions,
539539
});
540540
}
541541

compiler/rustc_lint/src/late.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use std::any::Any;
1818
use std::cell::Cell;
1919

2020
use rustc_data_structures::stack::ensure_sufficient_stack;
21-
use rustc_data_structures::sync::{Lrc, join};
21+
use rustc_data_structures::sync::join;
2222
use rustc_hir as hir;
2323
use rustc_hir::def_id::{LocalDefId, LocalModDefId};
2424
use rustc_hir::{HirId, intravisit as hir_visit};
@@ -36,8 +36,7 @@ use crate::{LateContext, LateLintPass, LintStore};
3636
///
3737
/// This function exists because [`Session::lint_store`] is type-erased.
3838
pub fn unerased_lint_store(sess: &Session) -> &LintStore {
39-
let store: &Lrc<_> = sess.lint_store.as_ref().unwrap();
40-
let store: &dyn Any = &**store;
39+
let store: &dyn Any = sess.lint_store.as_deref().unwrap();
4140
store.downcast_ref().unwrap()
4241
}
4342

compiler/rustc_span/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1380,7 +1380,7 @@ pub enum ExternalSourceKind {
13801380
}
13811381

13821382
impl ExternalSource {
1383-
pub fn get_source(&self) -> Option<&Lrc<String>> {
1383+
pub fn get_source(&self) -> Option<&str> {
13841384
match self {
13851385
ExternalSource::Foreign { kind: ExternalSourceKind::Present(ref src), .. } => Some(src),
13861386
_ => None,

compiler/rustc_span/src/source_map/tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ fn t10() {
257257
);
258258
imported_src_file.add_external_src(|| Some(unnormalized.to_string()));
259259
assert_eq!(
260-
imported_src_file.external_src.borrow().get_source().unwrap().as_ref(),
260+
imported_src_file.external_src.borrow().get_source().unwrap(),
261261
normalized,
262262
"imported source file should be normalized"
263263
);

src/bootstrap/src/core/build_steps/format.rs

+1
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ fn get_modified_rs_files(build: &Builder<'_>) -> Result<Option<Vec<String>>, Str
9393
if !verify_rustfmt_version(build) {
9494
return Ok(None);
9595
}
96+
9697
get_git_modified_files(&build.config.git_config(), Some(&build.config.src), &["rs"])
9798
}
9899

src/bootstrap/src/core/sanity.rs

-4
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ use std::ffi::{OsStr, OsString};
1313
use std::path::PathBuf;
1414
use std::{env, fs};
1515

16-
use build_helper::git::warn_old_master_branch;
17-
1816
use crate::Build;
1917
#[cfg(not(feature = "bootstrap-self-test"))]
2018
use crate::builder::Builder;
@@ -382,6 +380,4 @@ $ pacman -R cmake && pacman -S mingw-w64-x86_64-cmake
382380
if let Some(ref s) = build.config.ccache {
383381
cmd_finder.must_have(s);
384382
}
385-
386-
warn_old_master_branch(&build.config.git_config(), &build.config.src);
387383
}

src/librustdoc/passes/lint/check_code_block_syntax.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ struct BufferEmitter {
145145
}
146146

147147
impl Translate for BufferEmitter {
148-
fn fluent_bundle(&self) -> Option<&Lrc<rustc_errors::FluentBundle>> {
148+
fn fluent_bundle(&self) -> Option<&rustc_errors::FluentBundle> {
149149
None
150150
}
151151

@@ -169,7 +169,7 @@ impl Emitter for BufferEmitter {
169169
}
170170
}
171171

172-
fn source_map(&self) -> Option<&Lrc<SourceMap>> {
172+
fn source_map(&self) -> Option<&SourceMap> {
173173
None
174174
}
175175
}

src/tools/build_helper/src/git.rs

-64
Original file line numberDiff line numberDiff line change
@@ -196,67 +196,3 @@ pub fn get_git_untracked_files(
196196
.collect();
197197
Ok(Some(files))
198198
}
199-
200-
/// Print a warning if the branch returned from `updated_master_branch` is old
201-
///
202-
/// For certain configurations of git repository, this remote will not be
203-
/// updated when running `git pull`.
204-
///
205-
/// This can result in formatting thousands of files instead of a dozen,
206-
/// so we should warn the user something is wrong.
207-
pub fn warn_old_master_branch(config: &GitConfig<'_>, git_dir: &Path) {
208-
if crate::ci::CiEnv::is_ci() {
209-
// this warning is useless in CI,
210-
// and CI probably won't have the right branches anyway.
211-
return;
212-
}
213-
// this will be overwritten by the actual name, if possible
214-
let mut updated_master = "the upstream master branch".to_string();
215-
match warn_old_master_branch_(config, git_dir, &mut updated_master) {
216-
Ok(branch_is_old) => {
217-
if !branch_is_old {
218-
return;
219-
}
220-
// otherwise fall through and print the rest of the warning
221-
}
222-
Err(err) => {
223-
eprintln!("warning: unable to check if {updated_master} is old due to error: {err}")
224-
}
225-
}
226-
eprintln!(
227-
"warning: {updated_master} is used to determine if files have been modified\n\
228-
warning: if it is not updated, this may cause files to be needlessly reformatted"
229-
);
230-
}
231-
232-
pub fn warn_old_master_branch_(
233-
config: &GitConfig<'_>,
234-
git_dir: &Path,
235-
updated_master: &mut String,
236-
) -> Result<bool, Box<dyn std::error::Error>> {
237-
use std::time::Duration;
238-
*updated_master = updated_master_branch(config, Some(git_dir))?;
239-
let branch_path = git_dir.join(".git/refs/remotes").join(&updated_master);
240-
const WARN_AFTER: Duration = Duration::from_secs(60 * 60 * 24 * 10);
241-
let meta = match std::fs::metadata(&branch_path) {
242-
Ok(meta) => meta,
243-
Err(err) => {
244-
let gcd = git_common_dir(&git_dir)?;
245-
if branch_path.starts_with(&gcd) {
246-
return Err(Box::new(err));
247-
}
248-
std::fs::metadata(Path::new(&gcd).join("refs/remotes").join(&updated_master))?
249-
}
250-
};
251-
if meta.modified()?.elapsed()? > WARN_AFTER {
252-
eprintln!("warning: {updated_master} has not been updated in 10 days");
253-
Ok(true)
254-
} else {
255-
Ok(false)
256-
}
257-
}
258-
259-
fn git_common_dir(dir: &Path) -> Result<String, String> {
260-
output_result(Command::new("git").arg("-C").arg(dir).arg("rev-parse").arg("--git-common-dir"))
261-
.map(|x| x.trim().to_string())
262-
}

src/tools/clippy/clippy_utils/src/source.rs

+1
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ impl SourceFileRange {
287287
self.sf
288288
.src
289289
.as_ref()
290+
.map(|src| src.as_str())
290291
.or_else(|| self.sf.external_src.get().and_then(|src| src.get_source()))
291292
.and_then(|x| x.get(self.range.clone()))
292293
}

src/tools/compiletest/src/command-list.rs

-15
Original file line numberDiff line numberDiff line change
@@ -64,23 +64,8 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
6464
"ignore-loongarch64",
6565
"ignore-macabi",
6666
"ignore-macos",
67-
"ignore-mode-assembly",
68-
"ignore-mode-codegen",
69-
"ignore-mode-codegen-units",
7067
"ignore-mode-coverage-map",
7168
"ignore-mode-coverage-run",
72-
"ignore-mode-crashes",
73-
"ignore-mode-debuginfo",
74-
"ignore-mode-incremental",
75-
"ignore-mode-js-doc-test",
76-
"ignore-mode-mir-opt",
77-
"ignore-mode-pretty",
78-
"ignore-mode-run-make",
79-
"ignore-mode-run-pass-valgrind",
80-
"ignore-mode-rustdoc",
81-
"ignore-mode-rustdoc-json",
82-
"ignore-mode-ui",
83-
"ignore-mode-ui-fulldeps",
8469
"ignore-msp430",
8570
"ignore-msvc",
8671
"ignore-musl",

0 commit comments

Comments
 (0)