Skip to content

Commit 634770c

Browse files
committed
Auto merge of rust-lang#95667 - Dylan-DPC:rollup-n7xzs3y, r=Dylan-DPC
Rollup of 5 pull requests Successful merges: - rust-lang#95234 (bootstrap.py: nixos check in /etc/os-release with quotes) - rust-lang#95449 (Fix `x doc --stage 0 compiler`) - rust-lang#95512 (diagnostics: translation infrastructure) - rust-lang#95607 (Note invariance reason for FnDef types) - rust-lang#95645 (Fix intra doc link ICE when trying to get traits in scope for primitive) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 949b98c + bf44a87 commit 634770c

File tree

137 files changed

+3104
-1191
lines changed

Some content is hidden

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

137 files changed

+3104
-1191
lines changed

Cargo.lock

+142
Original file line numberDiff line numberDiff line change
@@ -1238,6 +1238,40 @@ dependencies = [
12381238
"miniz_oxide",
12391239
]
12401240

1241+
[[package]]
1242+
name = "fluent-bundle"
1243+
version = "0.15.2"
1244+
source = "registry+https://github.com/rust-lang/crates.io-index"
1245+
checksum = "e242c601dec9711505f6d5bbff5bedd4b61b2469f2e8bb8e57ee7c9747a87ffd"
1246+
dependencies = [
1247+
"fluent-langneg",
1248+
"fluent-syntax",
1249+
"intl-memoizer",
1250+
"intl_pluralrules",
1251+
"rustc-hash",
1252+
"self_cell",
1253+
"smallvec",
1254+
"unic-langid",
1255+
]
1256+
1257+
[[package]]
1258+
name = "fluent-langneg"
1259+
version = "0.13.0"
1260+
source = "registry+https://github.com/rust-lang/crates.io-index"
1261+
checksum = "2c4ad0989667548f06ccd0e306ed56b61bd4d35458d54df5ec7587c0e8ed5e94"
1262+
dependencies = [
1263+
"unic-langid",
1264+
]
1265+
1266+
[[package]]
1267+
name = "fluent-syntax"
1268+
version = "0.11.0"
1269+
source = "registry+https://github.com/rust-lang/crates.io-index"
1270+
checksum = "c0abed97648395c902868fee9026de96483933faa54ea3b40d652f7dfe61ca78"
1271+
dependencies = [
1272+
"thiserror",
1273+
]
1274+
12411275
[[package]]
12421276
name = "fnv"
12431277
version = "1.0.7"
@@ -1782,6 +1816,26 @@ dependencies = [
17821816
"cfg-if 1.0.0",
17831817
]
17841818

1819+
[[package]]
1820+
name = "intl-memoizer"
1821+
version = "0.5.1"
1822+
source = "registry+https://github.com/rust-lang/crates.io-index"
1823+
checksum = "c310433e4a310918d6ed9243542a6b83ec1183df95dff8f23f87bb88a264a66f"
1824+
dependencies = [
1825+
"type-map",
1826+
"unic-langid",
1827+
]
1828+
1829+
[[package]]
1830+
name = "intl_pluralrules"
1831+
version = "7.0.1"
1832+
source = "registry+https://github.com/rust-lang/crates.io-index"
1833+
checksum = "b18f988384267d7066cc2be425e6faf352900652c046b6971d2e228d3b1c5ecf"
1834+
dependencies = [
1835+
"tinystr",
1836+
"unic-langid",
1837+
]
1838+
17851839
[[package]]
17861840
name = "itertools"
17871841
version = "0.10.1"
@@ -2812,6 +2866,12 @@ dependencies = [
28122866
"version_check",
28132867
]
28142868

2869+
[[package]]
2870+
name = "proc-macro-hack"
2871+
version = "0.5.19"
2872+
source = "registry+https://github.com/rust-lang/crates.io-index"
2873+
checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5"
2874+
28152875
[[package]]
28162876
name = "proc-macro2"
28172877
version = "1.0.30"
@@ -3645,13 +3705,29 @@ dependencies = [
36453705
name = "rustc_error_codes"
36463706
version = "0.0.0"
36473707

3708+
[[package]]
3709+
name = "rustc_error_messages"
3710+
version = "0.0.0"
3711+
dependencies = [
3712+
"fluent-bundle",
3713+
"fluent-syntax",
3714+
"intl-memoizer",
3715+
"rustc_data_structures",
3716+
"rustc_macros",
3717+
"rustc_serialize",
3718+
"rustc_span",
3719+
"tracing",
3720+
"unic-langid",
3721+
]
3722+
36483723
[[package]]
36493724
name = "rustc_errors"
36503725
version = "0.0.0"
36513726
dependencies = [
36523727
"annotate-snippets",
36533728
"atty",
36543729
"rustc_data_structures",
3730+
"rustc_error_messages",
36553731
"rustc_lint_defs",
36563732
"rustc_macros",
36573733
"rustc_serialize",
@@ -3708,6 +3784,7 @@ dependencies = [
37083784
"odht",
37093785
"rustc_ast",
37103786
"rustc_data_structures",
3787+
"rustc_error_messages",
37113788
"rustc_feature",
37123789
"rustc_index",
37133790
"rustc_macros",
@@ -3864,6 +3941,7 @@ version = "0.0.0"
38643941
dependencies = [
38653942
"rustc_ast",
38663943
"rustc_data_structures",
3944+
"rustc_error_messages",
38673945
"rustc_hir",
38683946
"rustc_macros",
38693947
"rustc_serialize",
@@ -4573,6 +4651,12 @@ dependencies = [
45734651
"libc",
45744652
]
45754653

4654+
[[package]]
4655+
name = "self_cell"
4656+
version = "0.10.2"
4657+
source = "registry+https://github.com/rust-lang/crates.io-index"
4658+
checksum = "1ef965a420fe14fdac7dd018862966a4c14094f900e1650bbc71ddd7d580c8af"
4659+
45764660
[[package]]
45774661
name = "semver"
45784662
version = "1.0.3"
@@ -5104,6 +5188,12 @@ dependencies = [
51045188
"winapi",
51055189
]
51065190

5191+
[[package]]
5192+
name = "tinystr"
5193+
version = "0.3.4"
5194+
source = "registry+https://github.com/rust-lang/crates.io-index"
5195+
checksum = "29738eedb4388d9ea620eeab9384884fc3f06f586a2eddb56bedc5885126c7c1"
5196+
51075197
[[package]]
51085198
name = "tinyvec"
51095199
version = "0.3.4"
@@ -5262,6 +5352,15 @@ dependencies = [
52625352
"tracing-subscriber",
52635353
]
52645354

5355+
[[package]]
5356+
name = "type-map"
5357+
version = "0.4.0"
5358+
source = "registry+https://github.com/rust-lang/crates.io-index"
5359+
checksum = "b6d3364c5e96cb2ad1603037ab253ddd34d7fb72a58bdddf4b7350760fc69a46"
5360+
dependencies = [
5361+
"rustc-hash",
5362+
]
5363+
52655364
[[package]]
52665365
name = "typenum"
52675366
version = "1.12.0"
@@ -5316,6 +5415,49 @@ dependencies = [
53165415
"unic-ucd-version",
53175416
]
53185417

5418+
[[package]]
5419+
name = "unic-langid"
5420+
version = "0.9.0"
5421+
source = "registry+https://github.com/rust-lang/crates.io-index"
5422+
checksum = "73328fcd730a030bdb19ddf23e192187a6b01cd98be6d3140622a89129459ce5"
5423+
dependencies = [
5424+
"unic-langid-impl",
5425+
"unic-langid-macros",
5426+
]
5427+
5428+
[[package]]
5429+
name = "unic-langid-impl"
5430+
version = "0.9.0"
5431+
source = "registry+https://github.com/rust-lang/crates.io-index"
5432+
checksum = "1a4a8eeaf0494862c1404c95ec2f4c33a2acff5076f64314b465e3ddae1b934d"
5433+
dependencies = [
5434+
"tinystr",
5435+
]
5436+
5437+
[[package]]
5438+
name = "unic-langid-macros"
5439+
version = "0.9.0"
5440+
source = "registry+https://github.com/rust-lang/crates.io-index"
5441+
checksum = "18f980d6d87e8805f2836d64b4138cc95aa7986fa63b1f51f67d5fbff64dd6e5"
5442+
dependencies = [
5443+
"proc-macro-hack",
5444+
"tinystr",
5445+
"unic-langid-impl",
5446+
"unic-langid-macros-impl",
5447+
]
5448+
5449+
[[package]]
5450+
name = "unic-langid-macros-impl"
5451+
version = "0.9.0"
5452+
source = "registry+https://github.com/rust-lang/crates.io-index"
5453+
checksum = "29396ffd97e27574c3e01368b1a64267d3064969e4848e2e130ff668be9daa9f"
5454+
dependencies = [
5455+
"proc-macro-hack",
5456+
"quote",
5457+
"syn",
5458+
"unic-langid-impl",
5459+
]
5460+
53195461
[[package]]
53205462
name = "unic-ucd-version"
53215463
version = "0.9.0"

compiler/rustc_borrowck/src/borrowck_errors.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
use rustc_errors::{struct_span_err, DiagnosticBuilder, DiagnosticId, ErrorGuaranteed};
1+
use rustc_errors::{struct_span_err, DiagnosticBuilder, DiagnosticId, ErrorGuaranteed, MultiSpan};
22
use rustc_middle::ty::{self, Ty, TyCtxt};
3-
use rustc_span::{MultiSpan, Span};
3+
use rustc_span::Span;
44

55
impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
66
crate fn cannot_move_when_borrowed(

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use either::Either;
22
use rustc_const_eval::util::CallKind;
33
use rustc_data_structures::fx::FxHashSet;
4-
use rustc_errors::{Applicability, Diagnostic, DiagnosticBuilder, ErrorGuaranteed};
4+
use rustc_errors::{Applicability, Diagnostic, DiagnosticBuilder, ErrorGuaranteed, MultiSpan};
55
use rustc_hir as hir;
66
use rustc_hir::def_id::DefId;
77
use rustc_hir::{AsyncGeneratorKind, GeneratorKind};
@@ -15,7 +15,7 @@ use rustc_middle::mir::{
1515
use rustc_middle::ty::{self, subst::Subst, suggest_constraining_type_params, PredicateKind, Ty};
1616
use rustc_mir_dataflow::move_paths::{InitKind, MoveOutIndex, MovePathIndex};
1717
use rustc_span::symbol::sym;
18-
use rustc_span::{BytePos, MultiSpan, Span};
18+
use rustc_span::{BytePos, Span};
1919
use rustc_trait_selection::infer::InferCtxtExt;
2020
use rustc_trait_selection::traits::TraitEngineExt as _;
2121

compiler/rustc_borrowck/src/diagnostics/region_errors.rs

+15-4
Original file line numberDiff line numberDiff line change
@@ -330,14 +330,14 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
330330
ty::RawPtr(ty_mut) => {
331331
assert_eq!(ty_mut.mutbl, rustc_hir::Mutability::Mut);
332332
(
333-
format!("a mutable pointer to {}", ty_mut.ty),
333+
format!("a mutable pointer to `{}`", ty_mut.ty),
334334
"mutable pointers are invariant over their type parameter".to_string(),
335335
)
336336
}
337337
ty::Ref(_, inner_ty, mutbl) => {
338338
assert_eq!(*mutbl, rustc_hir::Mutability::Mut);
339339
(
340-
format!("a mutable reference to {}", inner_ty),
340+
format!("a mutable reference to `{}`", inner_ty),
341341
"mutable references are invariant over their type parameter"
342342
.to_string(),
343343
)
@@ -351,10 +351,21 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
351351
let adt_desc = adt.descr();
352352

353353
let desc = format!(
354-
"the type {ty}, which makes the generic argument {generic_arg} invariant"
354+
"the type `{ty}`, which makes the generic argument `{generic_arg}` invariant"
355355
);
356356
let note = format!(
357-
"the {adt_desc} {base_ty} is invariant over the parameter {base_generic_arg}"
357+
"the {adt_desc} `{base_ty}` is invariant over the parameter `{base_generic_arg}`"
358+
);
359+
(desc, note)
360+
}
361+
ty::FnDef(def_id, _) => {
362+
let name = self.infcx.tcx.item_name(*def_id);
363+
let identity_substs =
364+
InternalSubsts::identity_for_item(self.infcx.tcx, *def_id);
365+
let desc = format!("a function pointer to `{name}`");
366+
let note = format!(
367+
"the function `{name}` is invariant over the parameter `{}`",
368+
identity_substs[param_index as usize]
358369
);
359370
(desc, note)
360371
}

compiler/rustc_borrowck/src/diagnostics/region_name.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ impl RegionName {
109109
*span,
110110
format!("lifetime `{}` represents this closure's body", self),
111111
);
112-
diag.note(&note);
112+
diag.note(note);
113113
}
114114
RegionNameSource::AnonRegionFromArgument(RegionNameHighlight::CannotMatchHirTy(
115115
span,

compiler/rustc_builtin_macros/src/format.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ use rustc_ast::tokenstream::TokenStream;
77
use rustc_ast::visit::{self, Visitor};
88
use rustc_ast::{token, BlockCheckMode, UnsafeSource};
99
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
10-
use rustc_errors::{pluralize, Applicability, PResult};
10+
use rustc_errors::{pluralize, Applicability, MultiSpan, PResult};
1111
use rustc_expand::base::{self, *};
1212
use rustc_parse_format as parse;
1313
use rustc_span::symbol::{sym, Ident, Symbol};
14-
use rustc_span::{InnerSpan, MultiSpan, Span};
14+
use rustc_span::{InnerSpan, Span};
1515
use smallvec::SmallVec;
1616

1717
use std::borrow::Cow;
@@ -446,7 +446,9 @@ impl<'a, 'b> Context<'a, 'b> {
446446
.iter()
447447
.filter(|fmt| fmt.precision_span.is_some())
448448
.count();
449-
e.span_label(span, &format!(
449+
e.span_label(
450+
span,
451+
&format!(
450452
"this precision flag adds an extra required argument at position {}, \
451453
which is why there {} expected",
452454
pos,
@@ -455,7 +457,8 @@ impl<'a, 'b> Context<'a, 'b> {
455457
} else {
456458
format!("are {} arguments", count)
457459
},
458-
));
460+
),
461+
);
459462
if let Some(arg) = self.args.get(pos) {
460463
e.span_label(
461464
arg.span,

compiler/rustc_codegen_ssa/src/back/write.rs

+15-5
Original file line numberDiff line numberDiff line change
@@ -1707,23 +1707,33 @@ impl SharedEmitter {
17071707

17081708
impl Emitter for SharedEmitter {
17091709
fn emit_diagnostic(&mut self, diag: &rustc_errors::Diagnostic) {
1710+
let fluent_args = self.to_fluent_args(diag.args());
17101711
drop(self.sender.send(SharedEmitterMessage::Diagnostic(Diagnostic {
1711-
msg: diag.message(),
1712+
msg: self.translate_messages(&diag.message, &fluent_args).to_string(),
17121713
code: diag.code.clone(),
17131714
lvl: diag.level(),
17141715
})));
17151716
for child in &diag.children {
17161717
drop(self.sender.send(SharedEmitterMessage::Diagnostic(Diagnostic {
1717-
msg: child.message(),
1718+
msg: self.translate_messages(&child.message, &fluent_args).to_string(),
17181719
code: None,
17191720
lvl: child.level,
17201721
})));
17211722
}
17221723
drop(self.sender.send(SharedEmitterMessage::AbortIfErrors));
17231724
}
1725+
17241726
fn source_map(&self) -> Option<&Lrc<SourceMap>> {
17251727
None
17261728
}
1729+
1730+
fn fluent_bundle(&self) -> Option<&Lrc<rustc_errors::FluentBundle>> {
1731+
None
1732+
}
1733+
1734+
fn fallback_fluent_bundle(&self) -> &Lrc<rustc_errors::FluentBundle> {
1735+
panic!("shared emitter attempted to translate a diagnostic");
1736+
}
17271737
}
17281738

17291739
impl SharedEmitterMain {
@@ -1754,9 +1764,9 @@ impl SharedEmitterMain {
17541764
let msg = msg.strip_prefix("error: ").unwrap_or(&msg);
17551765

17561766
let mut err = match level {
1757-
Level::Error { lint: false } => sess.struct_err(&msg).forget_guarantee(),
1758-
Level::Warning => sess.struct_warn(&msg),
1759-
Level::Note => sess.struct_note_without_error(&msg),
1767+
Level::Error { lint: false } => sess.struct_err(msg).forget_guarantee(),
1768+
Level::Warning => sess.struct_warn(msg),
1769+
Level::Note => sess.struct_note_without_error(msg),
17601770
_ => bug!("Invalid inline asm diagnostic level"),
17611771
};
17621772

0 commit comments

Comments
 (0)