Skip to content

Commit b1a392a

Browse files
authored
Merge branch 'rust-lang:master' into checked_ilog
2 parents 717880d + 8ed1d4a commit b1a392a

File tree

93 files changed

+2014
-472
lines changed

Some content is hidden

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

93 files changed

+2014
-472
lines changed

Diff for: .gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ build/
5858
\#*
5959
\#*\#
6060
.#*
61-
rustc-ice-*.txt
6261

6362
## Tags
6463
tags

Diff for: compiler/rustc_ast/src/attr/mod.rs

+16
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,22 @@ impl Attribute {
9999
}
100100
}
101101

102+
pub fn path_matches(&self, name: &[Symbol]) -> bool {
103+
match &self.kind {
104+
AttrKind::Normal(normal) => {
105+
normal.item.path.segments.len() == name.len()
106+
&& normal
107+
.item
108+
.path
109+
.segments
110+
.iter()
111+
.zip(name)
112+
.all(|(s, n)| s.args.is_none() && s.ident.name == *n)
113+
}
114+
AttrKind::DocComment(..) => false,
115+
}
116+
}
117+
102118
pub fn is_word(&self) -> bool {
103119
if let AttrKind::Normal(normal) = &self.kind {
104120
matches!(normal.item.args, AttrArgs::Empty)

Diff for: compiler/rustc_builtin_macros/src/deriving/generic/mod.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
//!
8989
//! When generating the `expr` for the `A` impl, the `SubstructureFields` is
9090
//!
91-
//! ```{.text}
91+
//! ```text
9292
//! Struct(vec![FieldInfo {
9393
//! span: <span of x>
9494
//! name: Some(<ident of x>),
@@ -99,7 +99,7 @@
9999
//!
100100
//! For the `B` impl, called with `B(a)` and `B(b)`,
101101
//!
102-
//! ```{.text}
102+
//! ```text
103103
//! Struct(vec![FieldInfo {
104104
//! span: <span of `i32`>,
105105
//! name: None,
@@ -113,7 +113,7 @@
113113
//! When generating the `expr` for a call with `self == C0(a)` and `other
114114
//! == C0(b)`, the SubstructureFields is
115115
//!
116-
//! ```{.text}
116+
//! ```text
117117
//! EnumMatching(0, <ast::Variant for C0>,
118118
//! vec![FieldInfo {
119119
//! span: <span of i32>
@@ -125,7 +125,7 @@
125125
//!
126126
//! For `C1 {x}` and `C1 {x}`,
127127
//!
128-
//! ```{.text}
128+
//! ```text
129129
//! EnumMatching(1, <ast::Variant for C1>,
130130
//! vec![FieldInfo {
131131
//! span: <span of x>
@@ -137,7 +137,7 @@
137137
//!
138138
//! For the tags,
139139
//!
140-
//! ```{.text}
140+
//! ```text
141141
//! EnumTag(
142142
//! &[<ident of self tag>, <ident of other tag>], <expr to combine with>)
143143
//! ```
@@ -149,7 +149,7 @@
149149
//!
150150
//! A static method on the types above would result in,
151151
//!
152-
//! ```{.text}
152+
//! ```text
153153
//! StaticStruct(<ast::VariantData of A>, Named(vec![(<ident of x>, <span of x>)]))
154154
//!
155155
//! StaticStruct(<ast::VariantData of B>, Unnamed(vec![<span of x>]))

Diff for: compiler/rustc_const_eval/src/interpret/operand.rs

+10-2
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,11 @@ impl<Prov: Provenance> std::fmt::Display for ImmTy<'_, Prov> {
136136

137137
impl<Prov: Provenance> std::fmt::Debug for ImmTy<'_, Prov> {
138138
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
139-
f.debug_struct("ImmTy").field("imm", &self.imm).field("ty", &self.layout.ty).finish()
139+
// Printing `layout` results in too much noise; just print a nice version of the type.
140+
f.debug_struct("ImmTy")
141+
.field("imm", &self.imm)
142+
.field("ty", &format_args!("{}", self.layout.ty))
143+
.finish()
140144
}
141145
}
142146

@@ -305,7 +309,11 @@ pub struct OpTy<'tcx, Prov: Provenance = AllocId> {
305309

306310
impl<Prov: Provenance> std::fmt::Debug for OpTy<'_, Prov> {
307311
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
308-
f.debug_struct("OpTy").field("op", &self.op).field("ty", &self.layout.ty).finish()
312+
// Printing `layout` results in too much noise; just print a nice version of the type.
313+
f.debug_struct("OpTy")
314+
.field("op", &self.op)
315+
.field("ty", &format_args!("{}", self.layout.ty))
316+
.finish()
309317
}
310318
}
311319

Diff for: compiler/rustc_const_eval/src/interpret/place.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,10 @@ pub struct MPlaceTy<'tcx, Prov: Provenance = AllocId> {
117117

118118
impl<Prov: Provenance> std::fmt::Debug for MPlaceTy<'_, Prov> {
119119
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
120+
// Printing `layout` results in too much noise; just print a nice version of the type.
120121
f.debug_struct("MPlaceTy")
121122
.field("mplace", &self.mplace)
122-
.field("ty", &self.layout.ty)
123+
.field("ty", &format_args!("{}", self.layout.ty))
123124
.finish()
124125
}
125126
}
@@ -237,7 +238,11 @@ pub struct PlaceTy<'tcx, Prov: Provenance = AllocId> {
237238

238239
impl<Prov: Provenance> std::fmt::Debug for PlaceTy<'_, Prov> {
239240
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
240-
f.debug_struct("PlaceTy").field("place", &self.place).field("ty", &self.layout.ty).finish()
241+
// Printing `layout` results in too much noise; just print a nice version of the type.
242+
f.debug_struct("PlaceTy")
243+
.field("place", &self.place)
244+
.field("ty", &format_args!("{}", self.layout.ty))
245+
.finish()
241246
}
242247
}
243248

Diff for: compiler/rustc_feature/src/active.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,8 @@ declare_features! (
401401
/// Allows function attribute `#[coverage(on/off)]`, to control coverage
402402
/// instrumentation of that function.
403403
(active, coverage_attribute, "CURRENT_RUSTC_VERSION", Some(84605), None),
404+
/// Allows users to provide classes for fenced code block using `class:classname`.
405+
(active, custom_code_classes_in_docs, "CURRENT_RUSTC_VERSION", Some(79483), None),
404406
/// Allows non-builtin attributes in inner attribute position.
405407
(active, custom_inner_attributes, "1.30.0", Some(54726), None),
406408
/// Allows custom test frameworks with `#![test_runner]` and `#[test_case]`.
@@ -414,7 +416,7 @@ declare_features! (
414416
/// Allows having using `suggestion` in the `#[deprecated]` attribute.
415417
(active, deprecated_suggestion, "1.61.0", Some(94785), None),
416418
/// Allows using the `#[diagnostic]` attribute tool namespace
417-
(active, diagnostic_namespace, "1.73.0", Some(94785), None),
419+
(active, diagnostic_namespace, "1.73.0", Some(111996), None),
418420
/// Controls errors in trait implementations.
419421
(active, do_not_recommend, "1.67.0", Some(51992), None),
420422
/// Tells rustdoc to automatically generate `#[doc(cfg(...))]`.

Diff for: compiler/rustc_hir_analysis/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ use rustc_hir::def::DefKind;
117117
fluent_messages! { "../messages.ftl" }
118118

119119
fn require_c_abi_if_c_variadic(tcx: TyCtxt<'_>, decl: &hir::FnDecl<'_>, abi: Abi, span: Span) {
120-
const CONVENTIONS_UNSTABLE: &str = "`C`, `cdecl`, `win64`, `sysv64` or `efiapi`";
120+
const CONVENTIONS_UNSTABLE: &str = "`C`, `cdecl`, `aapcs`, `win64`, `sysv64` or `efiapi`";
121121
const CONVENTIONS_STABLE: &str = "`C` or `cdecl`";
122122
const UNSTABLE_EXPLAIN: &str =
123123
"using calling conventions other than `C` or `cdecl` for varargs functions is unstable";

Diff for: compiler/rustc_interface/src/util.rs

+13-7
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,13 @@ pub fn build_output_filenames(attrs: &[ast::Attribute], sess: &Session) -> Outpu
568568
) {
569569
sess.emit_fatal(errors::MultipleOutputTypesToStdout);
570570
}
571+
572+
let crate_name = sess
573+
.opts
574+
.crate_name
575+
.clone()
576+
.or_else(|| rustc_attr::find_crate_name(attrs).map(|n| n.to_string()));
577+
571578
match sess.io.output_file {
572579
None => {
573580
// "-" as input file will cause the parser to read from stdin so we
@@ -576,15 +583,11 @@ pub fn build_output_filenames(attrs: &[ast::Attribute], sess: &Session) -> Outpu
576583
let dirpath = sess.io.output_dir.clone().unwrap_or_default();
577584

578585
// If a crate name is present, we use it as the link name
579-
let stem = sess
580-
.opts
581-
.crate_name
582-
.clone()
583-
.or_else(|| rustc_attr::find_crate_name(attrs).map(|n| n.to_string()))
584-
.unwrap_or_else(|| sess.io.input.filestem().to_owned());
586+
let stem = crate_name.clone().unwrap_or_else(|| sess.io.input.filestem().to_owned());
585587

586588
OutputFilenames::new(
587589
dirpath,
590+
crate_name.unwrap_or_else(|| stem.replace('-', "_")),
588591
stem,
589592
None,
590593
sess.io.temps_dir.clone(),
@@ -609,9 +612,12 @@ pub fn build_output_filenames(attrs: &[ast::Attribute], sess: &Session) -> Outpu
609612
sess.emit_warning(errors::IgnoringOutDir);
610613
}
611614

615+
let out_filestem =
616+
out_file.filestem().unwrap_or_default().to_str().unwrap().to_string();
612617
OutputFilenames::new(
613618
out_file.parent().unwrap_or_else(|| Path::new("")).to_path_buf(),
614-
out_file.filestem().unwrap_or_default().to_str().unwrap().to_string(),
619+
crate_name.unwrap_or_else(|| out_filestem.replace('-', "_")),
620+
out_filestem,
615621
ofile,
616622
sess.io.temps_dir.clone(),
617623
sess.opts.cg.extra_filename.clone(),

Diff for: compiler/rustc_lint_defs/src/builtin.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -3405,8 +3405,8 @@ declare_lint_pass! {
34053405
UNFULFILLED_LINT_EXPECTATIONS,
34063406
UNINHABITED_STATIC,
34073407
UNKNOWN_CRATE_TYPES,
3408-
UNKNOWN_DIAGNOSTIC_ATTRIBUTES,
34093408
UNKNOWN_LINTS,
3409+
UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES,
34103410
UNNAMEABLE_TEST_ITEMS,
34113411
UNNAMEABLE_TYPES,
34123412
UNREACHABLE_CODE,
@@ -4420,7 +4420,8 @@ declare_lint! {
44204420
}
44214421

44224422
declare_lint! {
4423-
/// The `unknown_diagnostic_attributes` lint detects unrecognized diagnostic attributes.
4423+
/// The `unknown_or_malformed_diagnostic_attributes` lint detects unrecognized or otherwise malformed
4424+
/// diagnostic attributes.
44244425
///
44254426
/// ### Example
44264427
///
@@ -4432,15 +4433,17 @@ declare_lint! {
44324433
///
44334434
/// {{produces}}
44344435
///
4436+
///
44354437
/// ### Explanation
44364438
///
44374439
/// It is usually a mistake to specify a diagnostic attribute that does not exist. Check
44384440
/// the spelling, and check the diagnostic attribute listing for the correct name. Also
44394441
/// consider if you are using an old version of the compiler, and the attribute
44404442
/// is only available in a newer version.
4441-
pub UNKNOWN_DIAGNOSTIC_ATTRIBUTES,
4443+
pub UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES,
44424444
Warn,
4443-
"unrecognized diagnostic attribute"
4445+
"unrecognized or malformed diagnostic attribute",
4446+
@feature_gate = sym::diagnostic_namespace;
44444447
}
44454448

44464449
declare_lint! {

Diff for: compiler/rustc_metadata/src/fs.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use crate::errors::{
55
use crate::{encode_metadata, EncodedMetadata};
66

77
use rustc_data_structures::temp_dir::MaybeTempDir;
8-
use rustc_hir::def_id::LOCAL_CRATE;
98
use rustc_middle::ty::TyCtxt;
109
use rustc_session::config::{OutFileName, OutputType};
1110
use rustc_session::output::filename_for_metadata;
@@ -40,8 +39,7 @@ pub fn emit_wrapper_file(
4039
}
4140

4241
pub fn encode_and_write_metadata(tcx: TyCtxt<'_>) -> (EncodedMetadata, bool) {
43-
let crate_name = tcx.crate_name(LOCAL_CRATE);
44-
let out_filename = filename_for_metadata(tcx.sess, crate_name, tcx.output_filenames(()));
42+
let out_filename = filename_for_metadata(tcx.sess, tcx.output_filenames(()));
4543
// To avoid races with another rustc process scanning the output directory,
4644
// we need to write the file somewhere else and atomically move it to its
4745
// final destination, with an `fs::rename` call. In order for the rename to

Diff for: compiler/rustc_middle/src/query/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1140,6 +1140,7 @@ rustc_queries! {
11401140
query reachable_set(_: ()) -> &'tcx LocalDefIdSet {
11411141
arena_cache
11421142
desc { "reachability" }
1143+
cache_on_disk_if { true }
11431144
}
11441145

11451146
/// Per-body `region::ScopeTree`. The `DefId` should be the owner `DefId` for the body;

Diff for: compiler/rustc_middle/src/ty/mod.rs

+16
Original file line numberDiff line numberDiff line change
@@ -2408,6 +2408,22 @@ impl<'tcx> TyCtxt<'tcx> {
24082408
}
24092409
}
24102410

2411+
pub fn get_attrs_by_path<'attr>(
2412+
self,
2413+
did: DefId,
2414+
attr: &'attr [Symbol],
2415+
) -> impl Iterator<Item = &'tcx ast::Attribute> + 'attr
2416+
where
2417+
'tcx: 'attr,
2418+
{
2419+
let filter_fn = move |a: &&ast::Attribute| a.path_matches(&attr);
2420+
if let Some(did) = did.as_local() {
2421+
self.hir().attrs(self.hir().local_def_id_to_hir_id(did)).iter().filter(filter_fn)
2422+
} else {
2423+
self.item_attrs(did).iter().filter(filter_fn)
2424+
}
2425+
}
2426+
24112427
pub fn get_attr(self, did: impl Into<DefId>, attr: Symbol) -> Option<&'tcx ast::Attribute> {
24122428
if cfg!(debug_assertions) && !rustc_feature::is_valid_for_get_attr(attr) {
24132429
let did: DefId = did.into();

Diff for: compiler/rustc_middle/src/ty/structural_impls.rs

+20-6
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use std::ops::ControlFlow;
1818
use std::rc::Rc;
1919
use std::sync::Arc;
2020

21+
use super::print::PrettyPrinter;
2122
use super::{GenericArg, GenericArgKind, Region};
2223

2324
impl fmt::Debug for ty::TraitDef {
@@ -343,14 +344,27 @@ impl<'tcx> DebugWithInfcx<TyCtxt<'tcx>> for ty::Const<'tcx> {
343344
this: OptWithInfcx<'_, TyCtxt<'tcx>, InfCtx, &Self>,
344345
f: &mut core::fmt::Formatter<'_>,
345346
) -> core::fmt::Result {
346-
// This reflects what `Const` looked liked before `Interned` was
347-
// introduced. We print it like this to avoid having to update expected
348-
// output in a lot of tests.
347+
// If this is a value, we spend some effort to make it look nice.
348+
if let ConstKind::Value(_) = this.data.kind() {
349+
return ty::tls::with(move |tcx| {
350+
// Somehow trying to lift the valtree results in lifetime errors, so we lift the
351+
// entire constant.
352+
let lifted = tcx.lift(*this.data).unwrap();
353+
let ConstKind::Value(valtree) = lifted.kind() else {
354+
bug!("we checked that this is a valtree")
355+
};
356+
let cx = FmtPrinter::new(tcx, Namespace::ValueNS);
357+
let cx =
358+
cx.pretty_print_const_valtree(valtree, lifted.ty(), /*print_ty*/ true)?;
359+
f.write_str(&cx.into_buffer())
360+
});
361+
}
362+
// Fall back to something verbose.
349363
write!(
350364
f,
351-
"Const {{ ty: {:?}, kind: {:?} }}",
352-
&this.map(|data| data.ty()),
353-
&this.map(|data| data.kind())
365+
"{kind:?}: {ty:?}",
366+
ty = &this.map(|data| data.ty()),
367+
kind = &this.map(|data| data.kind())
354368
)
355369
}
356370
}

Diff for: compiler/rustc_middle/src/ty/typeck_results.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -165,15 +165,15 @@ pub struct TypeckResults<'tcx> {
165165
/// reading places that are mentioned in a closure (because of _ patterns). However,
166166
/// to ensure the places are initialized, we introduce fake reads.
167167
/// Consider these two examples:
168-
/// ``` (discriminant matching with only wildcard arm)
168+
/// ```ignore (discriminant matching with only wildcard arm)
169169
/// let x: u8;
170170
/// let c = || match x { _ => () };
171171
/// ```
172172
/// In this example, we don't need to actually read/borrow `x` in `c`, and so we don't
173173
/// want to capture it. However, we do still want an error here, because `x` should have
174174
/// to be initialized at the point where c is created. Therefore, we add a "fake read"
175175
/// instead.
176-
/// ``` (destructured assignments)
176+
/// ```ignore (destructured assignments)
177177
/// let c = || {
178178
/// let (t1, t2) = t;
179179
/// }

0 commit comments

Comments
 (0)