Skip to content

Rollup of 4 pull requests #131354

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions compiler/rustc_codegen_ssa/src/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use rustc_ast::attr;
use rustc_data_structures::fx::{FxHashMap, FxIndexMap};
use rustc_data_structures::memmap::Mmap;
use rustc_data_structures::profiling::{SelfProfilerRef, VerboseTimingGuard};
use rustc_data_structures::sync::Lrc;
use rustc_errors::emitter::Emitter;
use rustc_errors::translation::Translate;
use rustc_errors::{
Expand Down Expand Up @@ -1889,7 +1888,7 @@ impl SharedEmitter {
}

impl Translate for SharedEmitter {
fn fluent_bundle(&self) -> Option<&Lrc<FluentBundle>> {
fn fluent_bundle(&self) -> Option<&FluentBundle> {
None
}

Expand Down Expand Up @@ -1924,7 +1923,7 @@ impl Emitter for SharedEmitter {
);
}

fn source_map(&self) -> Option<&Lrc<SourceMap>> {
fn source_map(&self) -> Option<&SourceMap> {
None
}
}
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ pub struct AnnotateSnippetEmitter {
}

impl Translate for AnnotateSnippetEmitter {
fn fluent_bundle(&self) -> Option<&Lrc<FluentBundle>> {
self.fluent_bundle.as_ref()
fn fluent_bundle(&self) -> Option<&FluentBundle> {
self.fluent_bundle.as_deref()
}

fn fallback_fluent_bundle(&self) -> &FluentBundle {
Expand Down Expand Up @@ -69,8 +69,8 @@ impl Emitter for AnnotateSnippetEmitter {
);
}

fn source_map(&self) -> Option<&Lrc<SourceMap>> {
self.source_map.as_ref()
fn source_map(&self) -> Option<&SourceMap> {
self.source_map.as_deref()
}

fn should_show_explain(&self) -> bool {
Expand Down
14 changes: 7 additions & 7 deletions compiler/rustc_errors/src/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ pub trait Emitter: Translate {
false
}

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

/// Formats the substitutions of the primary_span
///
Expand Down Expand Up @@ -481,8 +481,8 @@ pub trait Emitter: Translate {
}

impl Translate for HumanEmitter {
fn fluent_bundle(&self) -> Option<&Lrc<FluentBundle>> {
self.fluent_bundle.as_ref()
fn fluent_bundle(&self) -> Option<&FluentBundle> {
self.fluent_bundle.as_deref()
}

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

impl Emitter for HumanEmitter {
fn source_map(&self) -> Option<&Lrc<SourceMap>> {
self.sm.as_ref()
fn source_map(&self) -> Option<&SourceMap> {
self.sm.as_deref()
}

fn emit_diagnostic(&mut self, mut diag: DiagInner) {
Expand Down Expand Up @@ -540,7 +540,7 @@ pub struct SilentEmitter {
}

impl Translate for SilentEmitter {
fn fluent_bundle(&self) -> Option<&Lrc<FluentBundle>> {
fn fluent_bundle(&self) -> Option<&FluentBundle> {
None
}

Expand All @@ -552,7 +552,7 @@ impl Translate for SilentEmitter {
}

impl Emitter for SilentEmitter {
fn source_map(&self) -> Option<&Lrc<SourceMap>> {
fn source_map(&self) -> Option<&SourceMap> {
None
}

Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_errors/src/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ enum EmitTyped<'a> {
}

impl Translate for JsonEmitter {
fn fluent_bundle(&self) -> Option<&Lrc<FluentBundle>> {
self.fluent_bundle.as_ref()
fn fluent_bundle(&self) -> Option<&FluentBundle> {
self.fluent_bundle.as_deref()
}

fn fallback_fluent_bundle(&self) -> &FluentBundle {
Expand Down Expand Up @@ -172,7 +172,7 @@ impl Emitter for JsonEmitter {
}
}

fn source_map(&self) -> Option<&Lrc<SourceMap>> {
fn source_map(&self) -> Option<&SourceMap> {
Some(&self.sm)
}

Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_errors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ use registry::Registry;
use rustc_data_structures::AtomicRef;
use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet};
use rustc_data_structures::stable_hasher::{Hash128, StableHasher};
use rustc_data_structures::sync::{Lock, Lrc};
use rustc_data_structures::sync::Lock;
pub use rustc_error_messages::{
DiagMessage, FluentBundle, LanguageIdentifier, LazyFallbackBundle, MultiSpan, SpanLabel,
SubdiagMessage, fallback_fluent_bundle, fluent_bundle,
Expand Down Expand Up @@ -685,13 +685,13 @@ impl DiagCtxt {
unimplemented!("false emitter must only used during `wrap_emitter`")
}

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

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

Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_errors/src/tests.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use rustc_data_structures::sync::{IntoDynSyncSend, Lrc};
use rustc_data_structures::sync::IntoDynSyncSend;
use rustc_error_messages::fluent_bundle::resolver::errors::{ReferenceKind, ResolverError};
use rustc_error_messages::{DiagMessage, langid};

Expand All @@ -12,7 +12,7 @@ struct Dummy {
}

impl Translate for Dummy {
fn fluent_bundle(&self) -> Option<&Lrc<FluentBundle>> {
fn fluent_bundle(&self) -> Option<&FluentBundle> {
None
}

Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_errors/src/translation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use std::borrow::Cow;
use std::env;
use std::error::Report;

use rustc_data_structures::sync::Lrc;
pub use rustc_error_messages::FluentArgs;
use tracing::{debug, trace};

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

/// Return `FluentBundle` with localized diagnostics for the default locale of the compiler.
/// Used when the user has not requested a specific language or when a localized diagnostic is
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_infer/src/infer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,7 @@ impl<'tcx> InferCtxt<'tcx> {
definition_span: Span,
hidden_ty: Ty<'tcx>,
region: ty::Region<'tcx>,
in_regions: &Lrc<Vec<ty::Region<'tcx>>>,
in_regions: Lrc<Vec<ty::Region<'tcx>>>,
) {
self.inner.borrow_mut().unwrap_region_constraints().member_constraint(
key,
Expand Down
10 changes: 9 additions & 1 deletion compiler/rustc_infer/src/infer/opaque_types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,15 @@ impl<'tcx> InferCtxt<'tcx> {
// not currently sound until we have existential regions.
concrete_ty.visit_with(&mut ConstrainOpaqueTypeRegionVisitor {
tcx: self.tcx,
op: |r| self.member_constraint(opaque_type_key, span, concrete_ty, r, &choice_regions),
op: |r| {
self.member_constraint(
opaque_type_key,
span,
concrete_ty,
r,
choice_regions.clone(),
)
},
});
}
}
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_infer/src/infer/region_constraints/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ impl<'tcx> RegionConstraintCollector<'_, 'tcx> {
definition_span: Span,
hidden_ty: Ty<'tcx>,
member_region: ty::Region<'tcx>,
choice_regions: &Lrc<Vec<ty::Region<'tcx>>>,
choice_regions: Lrc<Vec<ty::Region<'tcx>>>,
) {
debug!("member_constraint({:?} in {:#?})", member_region, choice_regions);

Expand All @@ -535,7 +535,7 @@ impl<'tcx> RegionConstraintCollector<'_, 'tcx> {
definition_span,
hidden_ty,
member_region,
choice_regions: choice_regions.clone(),
choice_regions,
});
}

Expand Down
5 changes: 2 additions & 3 deletions compiler/rustc_lint/src/late.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use std::any::Any;
use std::cell::Cell;

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

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_span/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1380,7 +1380,7 @@ pub enum ExternalSourceKind {
}

impl ExternalSource {
pub fn get_source(&self) -> Option<&Lrc<String>> {
pub fn get_source(&self) -> Option<&str> {
match self {
ExternalSource::Foreign { kind: ExternalSourceKind::Present(ref src), .. } => Some(src),
_ => None,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_span/src/source_map/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ fn t10() {
);
imported_src_file.add_external_src(|| Some(unnormalized.to_string()));
assert_eq!(
imported_src_file.external_src.borrow().get_source().unwrap().as_ref(),
imported_src_file.external_src.borrow().get_source().unwrap(),
normalized,
"imported source file should be normalized"
);
Expand Down
1 change: 1 addition & 0 deletions src/bootstrap/src/core/build_steps/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ fn get_modified_rs_files(build: &Builder<'_>) -> Result<Option<Vec<String>>, Str
if !verify_rustfmt_version(build) {
return Ok(None);
}

get_git_modified_files(&build.config.git_config(), Some(&build.config.src), &["rs"])
}

Expand Down
4 changes: 0 additions & 4 deletions src/bootstrap/src/core/sanity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ use std::ffi::{OsStr, OsString};
use std::path::PathBuf;
use std::{env, fs};

use build_helper::git::warn_old_master_branch;

use crate::Build;
#[cfg(not(feature = "bootstrap-self-test"))]
use crate::builder::Builder;
Expand Down Expand Up @@ -382,6 +380,4 @@ $ pacman -R cmake && pacman -S mingw-w64-x86_64-cmake
if let Some(ref s) = build.config.ccache {
cmd_finder.must_have(s);
}

warn_old_master_branch(&build.config.git_config(), &build.config.src);
}
4 changes: 2 additions & 2 deletions src/librustdoc/passes/lint/check_code_block_syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ struct BufferEmitter {
}

impl Translate for BufferEmitter {
fn fluent_bundle(&self) -> Option<&Lrc<rustc_errors::FluentBundle>> {
fn fluent_bundle(&self) -> Option<&rustc_errors::FluentBundle> {
None
}

Expand All @@ -169,7 +169,7 @@ impl Emitter for BufferEmitter {
}
}

fn source_map(&self) -> Option<&Lrc<SourceMap>> {
fn source_map(&self) -> Option<&SourceMap> {
None
}
}
64 changes: 0 additions & 64 deletions src/tools/build_helper/src/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,67 +196,3 @@ pub fn get_git_untracked_files(
.collect();
Ok(Some(files))
}

/// Print a warning if the branch returned from `updated_master_branch` is old
///
/// For certain configurations of git repository, this remote will not be
/// updated when running `git pull`.
///
/// This can result in formatting thousands of files instead of a dozen,
/// so we should warn the user something is wrong.
pub fn warn_old_master_branch(config: &GitConfig<'_>, git_dir: &Path) {
if crate::ci::CiEnv::is_ci() {
// this warning is useless in CI,
// and CI probably won't have the right branches anyway.
return;
}
// this will be overwritten by the actual name, if possible
let mut updated_master = "the upstream master branch".to_string();
match warn_old_master_branch_(config, git_dir, &mut updated_master) {
Ok(branch_is_old) => {
if !branch_is_old {
return;
}
// otherwise fall through and print the rest of the warning
}
Err(err) => {
eprintln!("warning: unable to check if {updated_master} is old due to error: {err}")
}
}
eprintln!(
"warning: {updated_master} is used to determine if files have been modified\n\
warning: if it is not updated, this may cause files to be needlessly reformatted"
);
}

pub fn warn_old_master_branch_(
config: &GitConfig<'_>,
git_dir: &Path,
updated_master: &mut String,
) -> Result<bool, Box<dyn std::error::Error>> {
use std::time::Duration;
*updated_master = updated_master_branch(config, Some(git_dir))?;
let branch_path = git_dir.join(".git/refs/remotes").join(&updated_master);
const WARN_AFTER: Duration = Duration::from_secs(60 * 60 * 24 * 10);
let meta = match std::fs::metadata(&branch_path) {
Ok(meta) => meta,
Err(err) => {
let gcd = git_common_dir(&git_dir)?;
if branch_path.starts_with(&gcd) {
return Err(Box::new(err));
}
std::fs::metadata(Path::new(&gcd).join("refs/remotes").join(&updated_master))?
}
};
if meta.modified()?.elapsed()? > WARN_AFTER {
eprintln!("warning: {updated_master} has not been updated in 10 days");
Ok(true)
} else {
Ok(false)
}
}

fn git_common_dir(dir: &Path) -> Result<String, String> {
output_result(Command::new("git").arg("-C").arg(dir).arg("rev-parse").arg("--git-common-dir"))
.map(|x| x.trim().to_string())
}
1 change: 1 addition & 0 deletions src/tools/clippy/clippy_utils/src/source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ impl SourceFileRange {
self.sf
.src
.as_ref()
.map(|src| src.as_str())
.or_else(|| self.sf.external_src.get().and_then(|src| src.get_source()))
.and_then(|x| x.get(self.range.clone()))
}
Expand Down
15 changes: 0 additions & 15 deletions src/tools/compiletest/src/command-list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,23 +64,8 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
"ignore-loongarch64",
"ignore-macabi",
"ignore-macos",
"ignore-mode-assembly",
"ignore-mode-codegen",
"ignore-mode-codegen-units",
"ignore-mode-coverage-map",
"ignore-mode-coverage-run",
"ignore-mode-crashes",
"ignore-mode-debuginfo",
"ignore-mode-incremental",
"ignore-mode-js-doc-test",
"ignore-mode-mir-opt",
"ignore-mode-pretty",
"ignore-mode-run-make",
"ignore-mode-run-pass-valgrind",
"ignore-mode-rustdoc",
"ignore-mode-rustdoc-json",
"ignore-mode-ui",
"ignore-mode-ui-fulldeps",
"ignore-msp430",
"ignore-msvc",
"ignore-musl",
Expand Down
Loading
Loading