Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
85872cf
Inhibit all-absent-variant optimization for all enum reprs that inhib…
zachs18 Sep 24, 2025
78ea999
std random.rs: update link to RTEMS docs
DanielEScherzer Feb 24, 2026
24ca3fc
delete several useless `Box` tests
cyrgani Feb 24, 2026
25ded11
coalesce some trivial `Box` tests into `basic-operations.rs`
cyrgani Feb 24, 2026
a5789d0
Fix ICE in `try_to_raw_bytes` when array elements have mismatched scalar
reddevilmidzy Feb 18, 2026
9fe6175
std: sys: pal: uefi: os: Implement split_paths
Ayush1325 Feb 2, 2026
c37e448
std: tests: env: Add split_paths_uefi
Ayush1325 Feb 16, 2026
3d03c8c
style: Update doctests for `TryFrom<integer> for bool`
sorairolake Feb 27, 2026
af35716
style: Update doctests for `From<bool> for float`
sorairolake Feb 27, 2026
038b718
Fix ICE on empty file with -Zquery-dep-graph
Delta17920 Feb 28, 2026
220295b
docs: note env var influence on `temp_dir` and `env_clear` on Windows
shri-prakhar Feb 28, 2026
5a18412
Remove `TranslationError`
JonathanBrouwer Feb 28, 2026
6e8d9c1
Adjust uses of `format_diag_message` to remove unwrap
JonathanBrouwer Feb 28, 2026
b42920d
Rollup merge of #146989 - zachs18:fix-146984, r=SparrowLii
JonathanBrouwer Feb 28, 2026
435be5b
Rollup merge of #151991 - Ayush1325:uefi-split-path, r=joboet
JonathanBrouwer Feb 28, 2026
794ac4e
Rollup merge of #152794 - reddevilmidzy:mgca-print, r=BoxyUwU
JonathanBrouwer Feb 28, 2026
5cf9a7f
Rollup merge of #153052 - DanielEScherzer:patch-2, r=joboet
JonathanBrouwer Feb 28, 2026
0425a45
Rollup merge of #153054 - shri-prakhar:docs-temp-dir-env-vars, r=Mark…
JonathanBrouwer Feb 28, 2026
c8e9647
Rollup merge of #153061 - cyrgani:box-tests-2, r=Kivooeo
JonathanBrouwer Feb 28, 2026
d94d079
Rollup merge of #153197 - sorairolake:change-doctests-style, r=joboet
JonathanBrouwer Feb 28, 2026
f462a5b
Rollup merge of #153210 - Delta17920:fix-query-dep-graph, r=jdonszelm…
JonathanBrouwer Feb 28, 2026
453fe91
Rollup merge of #153228 - JonathanBrouwer:remove_translate_error, r=lqd
JonathanBrouwer Feb 28, 2026
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
6 changes: 3 additions & 3 deletions compiler/rustc_abi/src/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,9 +348,9 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
always_sized: bool,
) -> LayoutCalculatorResult<FieldIdx, VariantIdx, F> {
let (present_first, present_second) = {
let mut present_variants = variants
.iter_enumerated()
.filter_map(|(i, v)| if !repr.c() && absent(v) { None } else { Some(i) });
let mut present_variants = variants.iter_enumerated().filter_map(|(i, v)| {
if !repr.inhibit_enum_layout_opt() && absent(v) { None } else { Some(i) }
});
(present_variants.next(), present_variants.next())
};
let present_first = match present_first {
Expand Down
12 changes: 3 additions & 9 deletions compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
//! [annotate_snippets]: https://docs.rs/crate/annotate-snippets/

use std::borrow::Cow;
use std::error::Report;
use std::fmt::Debug;
use std::io;
use std::io::Write;
Expand Down Expand Up @@ -361,10 +360,7 @@ impl AnnotateSnippetEmitter {
if substitutions.is_empty() {
continue;
}
let mut msg = format_diag_message(&suggestion.msg, args)
.map_err(Report::new)
.unwrap()
.to_string();
let mut msg = format_diag_message(&suggestion.msg, args).to_string();

let lo = substitutions
.iter()
Expand Down Expand Up @@ -547,7 +543,7 @@ impl AnnotateSnippetEmitter {
) -> String {
msgs.iter()
.filter_map(|(m, style)| {
let text = format_diag_message(m, args).map_err(Report::new).unwrap();
let text = format_diag_message(m, args);
let style = style.anstyle(level);
if text.is_empty() { None } else { Some(format!("{style}{text}{style:#}")) }
})
Expand Down Expand Up @@ -694,9 +690,7 @@ fn collect_annotations(

let kind = if is_primary { AnnotationKind::Primary } else { AnnotationKind::Context };

let label = label.as_ref().map(|m| {
normalize_whitespace(&format_diag_message(m, args).map_err(Report::new).unwrap())
});
let label = label.as_ref().map(|m| normalize_whitespace(&format_diag_message(m, args)));

let ann = Annotation { kind, span, label };
if sm.is_valid_span(ann.span).is_ok() {
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_errors/src/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
//! The output types are defined in `rustc_session::config::ErrorOutputType`.

use std::borrow::Cow;
use std::error::Report;
use std::io::prelude::*;
use std::io::{self, IsTerminal};
use std::iter;
Expand Down Expand Up @@ -106,7 +105,7 @@ pub trait Emitter {
fluent_args: &FluentArgs<'_>,
) {
if let Some((sugg, rest)) = suggestions.split_first() {
let msg = format_diag_message(&sugg.msg, fluent_args).map_err(Report::new).unwrap();
let msg = format_diag_message(&sugg.msg, fluent_args);
if rest.is_empty()
// ^ if there is only one suggestion
// don't display multi-suggestions as labels
Expand Down
139 changes: 0 additions & 139 deletions compiler/rustc_errors/src/error.rs

This file was deleted.

9 changes: 2 additions & 7 deletions compiler/rustc_errors/src/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

// FIXME: spec the JSON output properly.

use std::error::Report;
use std::io::{self, Write};
use std::path::{Path, PathBuf};
use std::sync::{Arc, Mutex};
Expand Down Expand Up @@ -301,8 +300,7 @@ impl Diagnostic {
fn from_errors_diagnostic(diag: crate::DiagInner, je: &JsonEmitter) -> Diagnostic {
let args = to_fluent_args(diag.args.iter());
let sugg_to_diag = |sugg: &CodeSuggestion| {
let translated_message =
format_diag_message(&sugg.msg, &args).map_err(Report::new).unwrap();
let translated_message = format_diag_message(&sugg.msg, &args);
Diagnostic {
message: translated_message.to_string(),
code: None,
Expand Down Expand Up @@ -417,10 +415,7 @@ impl DiagnosticSpan {
Self::from_span_etc(
span.span,
span.is_primary,
span.label
.as_ref()
.map(|m| format_diag_message(m, args).unwrap())
.map(|m| m.to_string()),
span.label.as_ref().map(|m| format_diag_message(m, args)).map(|m| m.to_string()),
suggestion,
je,
)
Expand Down
4 changes: 1 addition & 3 deletions compiler/rustc_errors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ extern crate self as rustc_errors;
use std::backtrace::{Backtrace, BacktraceStatus};
use std::borrow::Cow;
use std::cell::Cell;
use std::error::Report;
use std::ffi::OsStr;
use std::hash::Hash;
use std::io::Write;
Expand Down Expand Up @@ -78,7 +77,6 @@ mod decorate_diag;
mod diagnostic;
mod diagnostic_impls;
pub mod emitter;
pub mod error;
pub mod json;
mod lock;
pub mod markdown;
Expand Down Expand Up @@ -1437,7 +1435,7 @@ impl DiagCtxtInner {
args: impl Iterator<Item = DiagArg<'a>>,
) -> String {
let args = crate::translation::to_fluent_args(args);
format_diag_message(&message, &args).map_err(Report::new).unwrap().to_string()
format_diag_message(&message, &args).to_string()
}

fn eagerly_translate_for_subdiag(
Expand Down
20 changes: 5 additions & 15 deletions compiler/rustc_errors/src/translation.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
use std::borrow::Cow;
use std::error::Report;

pub use rustc_error_messages::FluentArgs;
use rustc_error_messages::{langid, register_functions};
use tracing::{debug, trace};

use crate::error::TranslateError;
use crate::fluent_bundle::FluentResource;
use crate::{DiagArg, DiagMessage, Style, fluent_bundle};

Expand Down Expand Up @@ -33,22 +31,14 @@ pub fn format_diag_messages(
messages: &[(DiagMessage, Style)],
args: &FluentArgs<'_>,
) -> Cow<'static, str> {
Cow::Owned(
messages
.iter()
.map(|(m, _)| format_diag_message(m, args).map_err(Report::new).unwrap())
.collect::<String>(),
)
Cow::Owned(messages.iter().map(|(m, _)| format_diag_message(m, args)).collect::<String>())
}

/// Convert a `DiagMessage` to a string
pub fn format_diag_message<'a>(
message: &'a DiagMessage,
args: &'a FluentArgs<'_>,
) -> Result<Cow<'a, str>, TranslateError<'a>> {
pub fn format_diag_message<'a>(message: &'a DiagMessage, args: &'a FluentArgs<'_>) -> Cow<'a, str> {
trace!(?message, ?args);
match message {
DiagMessage::Str(msg) => Ok(Cow::Borrowed(msg)),
DiagMessage::Str(msg) => Cow::Borrowed(msg),
// This translates an inline fluent diagnostic message
// It does this by creating a new `FluentBundle` with only one message,
// and then translating using this bundle.
Expand All @@ -67,9 +57,9 @@ pub fn format_diag_message<'a>(
let translated = bundle.format_pattern(value, Some(args), &mut errs).to_string();
debug!(?translated, ?errs);
if errs.is_empty() {
Ok(Cow::Owned(translated))
Cow::Owned(translated)
} else {
Err(TranslateError::fluent(&Cow::Borrowed(GENERATED_MSG_ID), args, errs))
panic!("Fluent errors while formatting message: {errs:?}");
}
}
}
Expand Down
8 changes: 7 additions & 1 deletion compiler/rustc_middle/src/dep_graph/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,13 @@ impl DepGraph {
where
F: FnOnce() -> String,
{
let dep_node_debug = &self.data.as_ref().unwrap().dep_node_debug;
// Early queries (e.g., `-Z query-dep-graph` on empty crates) can reach here
// before the graph is initialized. Return early to prevent an ICE.
let data = match &self.data {
Some(d) => d,
None => return,
};
let dep_node_debug = &data.dep_node_debug;

if dep_node_debug.borrow().contains_key(&dep_node) {
return;
Expand Down
15 changes: 10 additions & 5 deletions compiler/rustc_middle/src/ty/consts/valtree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,19 +136,24 @@ impl<'tcx> Value<'tcx> {
ty::Ref(_, inner_ty, _) => match inner_ty.kind() {
// `&str` can be interpreted as raw bytes
ty::Str => {}
// `&[u8]` can be interpreted as raw bytes
ty::Slice(slice_ty) if *slice_ty == tcx.types.u8 => {}
// `&[T]` can be interpreted as raw bytes if elements are `u8`
ty::Slice(_) => {}
// other `&_` can't be interpreted as raw bytes
_ => return None,
},
// `[u8; N]` can be interpreted as raw bytes
ty::Array(array_ty, _) if *array_ty == tcx.types.u8 => {}
// `[T; N]` can be interpreted as raw bytes if elements are `u8`
ty::Array(_, _) => {}
// Otherwise, type cannot be interpreted as raw bytes
_ => return None,
}

// We create an iterator that yields `Option<u8>`
let iterator = self.to_branch().into_iter().map(|ct| Some(ct.try_to_leaf()?.to_u8()));
let iterator = self.to_branch().into_iter().map(|ct| {
(*ct)
.try_to_value()
.and_then(|value| (value.ty == tcx.types.u8).then_some(value))
.and_then(|value| value.try_to_leaf().map(|leaf| leaf.to_u8()))
});
// If there is `None` in the iterator, then the array is not a valid array of u8s and we return `None`
let bytes: Vec<u8> = iterator.collect::<Option<Vec<u8>>>()?;

Expand Down
10 changes: 5 additions & 5 deletions library/core/src/convert/num.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,11 @@ macro_rules! impl_float_from_bool {
/// # Examples
/// ```
$($(#[doc = $doctest_prefix])*)?
#[doc = concat!("let x: ", stringify!($float)," = false.into();")]
#[doc = concat!("let x = ", stringify!($float), "::from(false);")]
/// assert_eq!(x, 0.0);
/// assert!(x.is_sign_positive());
///
#[doc = concat!("let y: ", stringify!($float)," = true.into();")]
#[doc = concat!("let y = ", stringify!($float), "::from(true);")]
/// assert_eq!(y, 1.0);
$($(#[doc = $doctest_suffix])*)?
/// ```
Expand Down Expand Up @@ -343,11 +343,11 @@ macro_rules! impl_try_from_integer_for_bool {
/// # Examples
///
/// ```
#[doc = concat!("assert_eq!(0_", stringify!($int), ".try_into(), Ok(false));")]
#[doc = concat!("assert_eq!(bool::try_from(0_", stringify!($int), "), Ok(false));")]
///
#[doc = concat!("assert_eq!(1_", stringify!($int), ".try_into(), Ok(true));")]
#[doc = concat!("assert_eq!(bool::try_from(1_", stringify!($int), "), Ok(true));")]
///
#[doc = concat!("assert!(<", stringify!($int), " as TryInto<bool>>::try_into(2).is_err());")]
#[doc = concat!("assert!(bool::try_from(2_", stringify!($int), ").is_err());")]
/// ```
#[inline]
fn try_from(i: $int) -> Result<Self, Self::Error> {
Expand Down
Loading
Loading