Skip to content

Commit

Permalink
Auto merge of #118300 - compiler-errors:rollup-cm3i8fg, r=compiler-er…
Browse files Browse the repository at this point in the history
…rors

Rollup of 7 pull requests

Successful merges:

 - #117651 (coverage: Simplify building coverage expressions based on sums)
 - #117968 (Stabilize `ptr::addr_eq`)
 - #118158 (Reduce fluent boilerplate)
 - #118201 (Miscellaneous `ObligationCauseCode` cleanups)
 - #118288 (Use `is_{some,ok}_and` more in the compiler)
 - #118289 (`is_{some,ok}_and` for rustdoc)
 - #118290 (Don't ICE when encountering placeholders in implied bounds computation)

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed Nov 26, 2023
2 parents ee80c8d + 2eccebb commit 33f6af8
Show file tree
Hide file tree
Showing 81 changed files with 632 additions and 792 deletions.
3 changes: 0 additions & 3 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3716,7 +3716,6 @@ dependencies = [
"rustc_const_eval",
"rustc_data_structures",
"rustc_error_codes",
"rustc_error_messages",
"rustc_errors",
"rustc_expand",
"rustc_feature",
Expand Down Expand Up @@ -3771,7 +3770,6 @@ dependencies = [
"intl-memoizer",
"rustc_baked_icu_data",
"rustc_data_structures",
"rustc_fluent_macro",
"rustc_macros",
"rustc_serialize",
"rustc_span",
Expand Down Expand Up @@ -3869,7 +3867,6 @@ dependencies = [
"rustc_arena",
"rustc_ast",
"rustc_data_structures",
"rustc_error_messages",
"rustc_index",
"rustc_macros",
"rustc_serialize",
Expand Down
7 changes: 2 additions & 5 deletions compiler/rustc_ast_lowering/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,7 @@ use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::sorted_map::SortedMap;
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_data_structures::sync::Lrc;
use rustc_errors::{
DiagnosticArgFromDisplay, DiagnosticMessage, Handler, StashKey, SubdiagnosticMessage,
};
use rustc_fluent_macro::fluent_messages;
use rustc_errors::{DiagnosticArgFromDisplay, Handler, StashKey};
use rustc_hir as hir;
use rustc_hir::def::{DefKind, LifetimeRes, Namespace, PartialRes, PerNS, Res};
use rustc_hir::def_id::{LocalDefId, CRATE_DEF_ID, LOCAL_CRATE};
Expand Down Expand Up @@ -94,7 +91,7 @@ mod lifetime_collector;
mod pat;
mod path;

fluent_messages! { "../messages.ftl" }
rustc_fluent_macro::fluent_messages! { "../messages.ftl" }

struct LoweringContext<'a, 'hir> {
tcx: TyCtxt<'hir>,
Expand Down
5 changes: 1 addition & 4 deletions compiler/rustc_ast_passes/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,10 @@
#![deny(rustc::untranslatable_diagnostic)]
#![deny(rustc::diagnostic_outside_of_impl)]

use rustc_errors::{DiagnosticMessage, SubdiagnosticMessage};
use rustc_fluent_macro::fluent_messages;

pub mod ast_validation;
mod errors;
pub mod feature_gate;
pub mod node_count;
pub mod show_span;

fluent_messages! { "../messages.ftl" }
rustc_fluent_macro::fluent_messages! { "../messages.ftl" }
5 changes: 1 addition & 4 deletions compiler/rustc_attr/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
#[macro_use]
extern crate rustc_macros;

use rustc_errors::{DiagnosticMessage, SubdiagnosticMessage};
use rustc_fluent_macro::fluent_messages;

mod builtin;
mod session_diagnostics;

Expand All @@ -29,4 +26,4 @@ pub use rustc_ast::attr::*;

pub(crate) use rustc_session::HashStableContext;

fluent_messages! { "../messages.ftl" }
rustc_fluent_macro::fluent_messages! { "../messages.ftl" }
5 changes: 2 additions & 3 deletions compiler/rustc_borrowck/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ extern crate tracing;

use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
use rustc_data_structures::graph::dominators::Dominators;
use rustc_errors::{Diagnostic, DiagnosticBuilder, DiagnosticMessage, SubdiagnosticMessage};
use rustc_fluent_macro::fluent_messages;
use rustc_errors::{Diagnostic, DiagnosticBuilder};
use rustc_hir as hir;
use rustc_hir::def_id::LocalDefId;
use rustc_index::bit_set::{BitSet, ChunkedBitSet};
Expand Down Expand Up @@ -98,7 +97,7 @@ use places_conflict::{places_conflict, PlaceConflictBias};
use region_infer::RegionInferenceContext;
use renumber::RegionCtxt;

fluent_messages! { "../messages.ftl" }
rustc_fluent_macro::fluent_messages! { "../messages.ftl" }

// FIXME(eddyb) perhaps move this somewhere more centrally.
#[derive(Debug)]
Expand Down
4 changes: 1 addition & 3 deletions compiler/rustc_builtin_macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@ extern crate tracing;

use crate::deriving::*;

use rustc_errors::{DiagnosticMessage, SubdiagnosticMessage};
use rustc_expand::base::{MacroExpanderFn, ResolverExpand, SyntaxExtensionKind};
use rustc_expand::proc_macro::BangProcMacro;
use rustc_fluent_macro::fluent_messages;
use rustc_span::symbol::sym;

mod alloc_error_handler;
Expand Down Expand Up @@ -59,7 +57,7 @@ pub mod proc_macro_harness;
pub mod standard_library_imports;
pub mod test_harness;

fluent_messages! { "../messages.ftl" }
rustc_fluent_macro::fluent_messages! { "../messages.ftl" }

pub fn register_builtin_macros(resolver: &mut dyn ResolverExpand) {
let mut register = |name, kind| resolver.register_builtin_macro(name, kind);
Expand Down
5 changes: 2 additions & 3 deletions compiler/rustc_codegen_gcc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@ use rustc_codegen_ssa::target_features::supported_target_features;
use rustc_data_structures::fx::FxIndexMap;
use rustc_data_structures::sync::IntoDynSyncSend;
use rustc_codegen_ssa::traits::{CodegenBackend, ExtraBackendMethods, ThinBufferMethods, WriteBackendMethods};
use rustc_errors::{DiagnosticMessage, ErrorGuaranteed, Handler, SubdiagnosticMessage};
use rustc_fluent_macro::fluent_messages;
use rustc_errors::{ErrorGuaranteed, Handler};
use rustc_metadata::EncodedMetadata;
use rustc_middle::dep_graph::{WorkProduct, WorkProductId};
use rustc_middle::util::Providers;
Expand All @@ -116,7 +115,7 @@ use tempfile::TempDir;
use crate::back::lto::ModuleBuffer;
use crate::gcc_util::target_cpu;

fluent_messages! { "../messages.ftl" }
rustc_fluent_macro::fluent_messages! { "../messages.ftl" }

pub struct PrintOnPanic<F: Fn() -> String>(pub F);

Expand Down
5 changes: 2 additions & 3 deletions compiler/rustc_codegen_llvm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ use rustc_codegen_ssa::traits::*;
use rustc_codegen_ssa::ModuleCodegen;
use rustc_codegen_ssa::{CodegenResults, CompiledModule};
use rustc_data_structures::fx::FxIndexMap;
use rustc_errors::{DiagnosticMessage, ErrorGuaranteed, FatalError, Handler, SubdiagnosticMessage};
use rustc_fluent_macro::fluent_messages;
use rustc_errors::{ErrorGuaranteed, FatalError, Handler};
use rustc_metadata::EncodedMetadata;
use rustc_middle::dep_graph::{WorkProduct, WorkProductId};
use rustc_middle::ty::TyCtxt;
Expand Down Expand Up @@ -92,7 +91,7 @@ mod type_of;
mod va_arg;
mod value;

fluent_messages! { "../messages.ftl" }
rustc_fluent_macro::fluent_messages! { "../messages.ftl" }

#[derive(Clone)]
pub struct LlvmCodegenBackend(());
Expand Down
4 changes: 1 addition & 3 deletions compiler/rustc_codegen_ssa/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ extern crate rustc_middle;
use rustc_ast as ast;
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_data_structures::sync::Lrc;
use rustc_errors::{DiagnosticMessage, SubdiagnosticMessage};
use rustc_fluent_macro::fluent_messages;
use rustc_hir::def_id::CrateNum;
use rustc_middle::dep_graph::WorkProduct;
use rustc_middle::middle::debugger_visualizer::DebuggerVisualizerFile;
Expand Down Expand Up @@ -60,7 +58,7 @@ pub mod mono_item;
pub mod target_features;
pub mod traits;

fluent_messages! { "../messages.ftl" }
rustc_fluent_macro::fluent_messages! { "../messages.ftl" }

pub struct ModuleCodegen<M> {
/// The name of the module. When the crate may be saved between
Expand Down
4 changes: 1 addition & 3 deletions compiler/rustc_const_eval/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,9 @@ pub mod util;

pub use errors::ReportErrorExt;

use rustc_errors::{DiagnosticMessage, SubdiagnosticMessage};
use rustc_fluent_macro::fluent_messages;
use rustc_middle::{ty, util::Providers};

fluent_messages! { "../messages.ftl" }
rustc_fluent_macro::fluent_messages! { "../messages.ftl" }

pub fn provide(providers: &mut Providers) {
const_eval::provide(providers);
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_driver_impl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ rustc_codegen_ssa = { path = "../rustc_codegen_ssa" }
rustc_const_eval = { path = "../rustc_const_eval" }
rustc_data_structures = { path = "../rustc_data_structures" }
rustc_error_codes = { path = "../rustc_error_codes" }
rustc_error_messages = { path = "../rustc_error_messages" }
rustc_errors = { path = "../rustc_errors" }
rustc_expand = { path = "../rustc_expand" }
rustc_feature = { path = "../rustc_feature" }
Expand Down
6 changes: 2 additions & 4 deletions compiler/rustc_driver_impl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@ use rustc_data_structures::profiling::{
use rustc_data_structures::sync::SeqCst;
use rustc_errors::registry::{InvalidErrorCode, Registry};
use rustc_errors::{markdown, ColorConfig};
use rustc_errors::{DiagnosticMessage, ErrorGuaranteed, Handler, PResult, SubdiagnosticMessage};
use rustc_errors::{ErrorGuaranteed, Handler, PResult};
use rustc_feature::find_gated_cfg;
use rustc_fluent_macro::fluent_messages;
use rustc_interface::util::{self, collect_crate_types, get_codegen_backend};
use rustc_interface::{interface, Queries};
use rustc_lint::unerased_lint_store;
Expand Down Expand Up @@ -102,7 +101,7 @@ use crate::session_diagnostics::{
RLinkWrongFileType, RlinkNotAFile, RlinkUnableToRead,
};

fluent_messages! { "../messages.ftl" }
rustc_fluent_macro::fluent_messages! { "../messages.ftl" }

pub static DEFAULT_LOCALE_RESOURCES: &[&str] = &[
// tidy-alphabetical-start
Expand All @@ -114,7 +113,6 @@ pub static DEFAULT_LOCALE_RESOURCES: &[&str] = &[
rustc_builtin_macros::DEFAULT_LOCALE_RESOURCE,
rustc_codegen_ssa::DEFAULT_LOCALE_RESOURCE,
rustc_const_eval::DEFAULT_LOCALE_RESOURCE,
rustc_error_messages::DEFAULT_LOCALE_RESOURCE,
rustc_errors::DEFAULT_LOCALE_RESOURCE,
rustc_expand::DEFAULT_LOCALE_RESOURCE,
rustc_hir_analysis::DEFAULT_LOCALE_RESOURCE,
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_error_messages/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ icu_provider_adapters = "1.2"
intl-memoizer = "0.5.1"
rustc_baked_icu_data = { path = "../rustc_baked_icu_data" }
rustc_data_structures = { path = "../rustc_data_structures" }
rustc_fluent_macro = { path = "../rustc_fluent_macro" }
rustc_macros = { path = "../rustc_macros" }
rustc_serialize = { path = "../rustc_serialize" }
rustc_span = { path = "../rustc_span" }
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_error_messages/messages.ftl

This file was deleted.

3 changes: 0 additions & 3 deletions compiler/rustc_error_messages/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use fluent_bundle::FluentResource;
use fluent_syntax::parser::ParserError;
use icu_provider_adapters::fallback::{LocaleFallbackProvider, LocaleFallbacker};
use rustc_data_structures::sync::{IntoDynSyncSend, Lrc};
use rustc_fluent_macro::fluent_messages;
use rustc_macros::{Decodable, Encodable};
use rustc_span::Span;
use std::borrow::Cow;
Expand All @@ -38,8 +37,6 @@ use intl_memoizer::IntlLangMemoizer;
pub use fluent_bundle::{self, types::FluentType, FluentArgs, FluentError, FluentValue};
pub use unic_langid::{langid, LanguageIdentifier};

fluent_messages! { "../messages.ftl" }

pub type FluentBundle =
IntoDynSyncSend<fluent_bundle::bundle::FluentBundle<FluentResource, IntlLangMemoizer>>;

Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_errors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ pub use rustc_error_messages::{
fallback_fluent_bundle, fluent_bundle, DelayDm, DiagnosticMessage, FluentBundle,
LanguageIdentifier, LazyFallbackBundle, MultiSpan, SpanLabel, SubdiagnosticMessage,
};
use rustc_fluent_macro::fluent_messages;
pub use rustc_lint_defs::{pluralize, Applicability};
use rustc_span::source_map::SourceMap;
pub use rustc_span::ErrorGuaranteed;
Expand Down Expand Up @@ -82,7 +81,7 @@ pub use snippet::Style;
pub type PErr<'a> = DiagnosticBuilder<'a, ErrorGuaranteed>;
pub type PResult<'a, T> = Result<T, PErr<'a>>;

fluent_messages! { "../messages.ftl" }
rustc_fluent_macro::fluent_messages! { "../messages.ftl" }

// `PResult` is used a lot. Make sure it doesn't unintentionally get bigger.
// (See also the comment on `DiagnosticBuilderInner`'s `diagnostic` field.)
Expand Down
5 changes: 1 addition & 4 deletions compiler/rustc_expand/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ extern crate tracing;

extern crate proc_macro as pm;

use rustc_errors::{DiagnosticMessage, SubdiagnosticMessage};
use rustc_fluent_macro::fluent_messages;

mod placeholders;
mod proc_macro_server;

Expand Down Expand Up @@ -67,4 +64,4 @@ mod mut_visit {
mod tests;
}

fluent_messages! { "../messages.ftl" }
rustc_fluent_macro::fluent_messages! { "../messages.ftl" }
33 changes: 14 additions & 19 deletions compiler/rustc_fluent_macro/src/fluent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,20 @@ fn finish(body: TokenStream, resource: TokenStream) -> proc_macro::TokenStream {
/// identifiers for different subdiagnostic kinds.
pub mod _subdiag {
/// Default for `#[help]`
pub const help: crate::SubdiagnosticMessage =
crate::SubdiagnosticMessage::FluentAttr(std::borrow::Cow::Borrowed("help"));
pub const help: rustc_errors::SubdiagnosticMessage =
rustc_errors::SubdiagnosticMessage::FluentAttr(std::borrow::Cow::Borrowed("help"));
/// Default for `#[note]`
pub const note: crate::SubdiagnosticMessage =
crate::SubdiagnosticMessage::FluentAttr(std::borrow::Cow::Borrowed("note"));
pub const note: rustc_errors::SubdiagnosticMessage =
rustc_errors::SubdiagnosticMessage::FluentAttr(std::borrow::Cow::Borrowed("note"));
/// Default for `#[warn]`
pub const warn: crate::SubdiagnosticMessage =
crate::SubdiagnosticMessage::FluentAttr(std::borrow::Cow::Borrowed("warn"));
pub const warn: rustc_errors::SubdiagnosticMessage =
rustc_errors::SubdiagnosticMessage::FluentAttr(std::borrow::Cow::Borrowed("warn"));
/// Default for `#[label]`
pub const label: crate::SubdiagnosticMessage =
crate::SubdiagnosticMessage::FluentAttr(std::borrow::Cow::Borrowed("label"));
pub const label: rustc_errors::SubdiagnosticMessage =
rustc_errors::SubdiagnosticMessage::FluentAttr(std::borrow::Cow::Borrowed("label"));
/// Default for `#[suggestion]`
pub const suggestion: crate::SubdiagnosticMessage =
crate::SubdiagnosticMessage::FluentAttr(std::borrow::Cow::Borrowed("suggestion"));
pub const suggestion: rustc_errors::SubdiagnosticMessage =
rustc_errors::SubdiagnosticMessage::FluentAttr(std::borrow::Cow::Borrowed("suggestion"));
}
}
}
Expand Down Expand Up @@ -248,11 +248,8 @@ pub(crate) fn fluent_messages(input: proc_macro::TokenStream) -> proc_macro::Tok
format!("Constant referring to Fluent message `{name}` from `{crate_name}`");
constants.extend(quote! {
#[doc = #docstr]
pub const #snake_name: crate::DiagnosticMessage =
crate::DiagnosticMessage::FluentIdentifier(
std::borrow::Cow::Borrowed(#name),
None
);
pub const #snake_name: rustc_errors::DiagnosticMessage =
rustc_errors::DiagnosticMessage::FluentIdentifier(std::borrow::Cow::Borrowed(#name), None);
});

for Attribute { id: Identifier { name: attr_name }, .. } in attributes {
Expand All @@ -279,10 +276,8 @@ pub(crate) fn fluent_messages(input: proc_macro::TokenStream) -> proc_macro::Tok
);
constants.extend(quote! {
#[doc = #msg]
pub const #snake_name: crate::SubdiagnosticMessage =
crate::SubdiagnosticMessage::FluentAttr(
std::borrow::Cow::Borrowed(#attr_name)
);
pub const #snake_name: rustc_errors::SubdiagnosticMessage =
rustc_errors::SubdiagnosticMessage::FluentAttr(std::borrow::Cow::Borrowed(#attr_name));
});
}

Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_fluent_macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ mod fluent;
/// );
/// err.emit();
/// ```
///
/// Note: any crate using this macro must also have a dependency on
/// `rustc_errors`, because the generated code refers to things from that
/// crate.
#[proc_macro]
pub fn fluent_messages(input: TokenStream) -> TokenStream {
fluent::fluent_messages(input)
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_hir/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ odht = { version = "0.3.1", features = ["nightly"] }
rustc_arena = { path = "../rustc_arena" }
rustc_ast = { path = "../rustc_ast" }
rustc_data_structures = { path = "../rustc_data_structures" }
rustc_error_messages = { path = "../rustc_error_messages" }
rustc_index = { path = "../rustc_index" }
rustc_macros = { path = "../rustc_macros" }
rustc_serialize = { path = "../rustc_serialize" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ pub(super) fn check_refining_return_position_impl_trait_in_trait<'tcx>(

// This opaque also needs to be from the impl method -- otherwise,
// it's a refinement to a TAIT.
if !tcx.hir().get_if_local(impl_opaque.def_id).map_or(false, |node| {
if !tcx.hir().get_if_local(impl_opaque.def_id).is_some_and(|node| {
matches!(
node.expect_item().expect_opaque_ty().origin,
hir::OpaqueTyOrigin::AsyncFn(def_id) | hir::OpaqueTyOrigin::FnReturn(def_id)
Expand Down
4 changes: 1 addition & 3 deletions compiler/rustc_hir_analysis/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,6 @@ pub mod structured_errors;
mod variance;

use rustc_errors::ErrorGuaranteed;
use rustc_errors::{DiagnosticMessage, SubdiagnosticMessage};
use rustc_fluent_macro::fluent_messages;
use rustc_hir as hir;
use rustc_middle::middle;
use rustc_middle::query::Providers;
Expand All @@ -115,7 +113,7 @@ use astconv::{AstConv, OnlySelfBounds};
use bounds::Bounds;
use rustc_hir::def::DefKind;

fluent_messages! { "../messages.ftl" }
rustc_fluent_macro::fluent_messages! { "../messages.ftl" }

fn require_c_abi_if_c_variadic(tcx: TyCtxt<'_>, decl: &hir::FnDecl<'_>, abi: Abi, span: Span) {
const CONVENTIONS_UNSTABLE: &str = "`C`, `cdecl`, `aapcs`, `win64`, `sysv64` or `efiapi`";
Expand Down
Loading

0 comments on commit 33f6af8

Please sign in to comment.