Skip to content

Commit c361d52

Browse files
committed
Auto merge of #3916 - rust-lang:rustup-2024-09-26, r=RalfJung
Automatic Rustup
2 parents fcc59fe + 18aa926 commit c361d52

File tree

930 files changed

+23069
-25616
lines changed

Some content is hidden

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

930 files changed

+23069
-25616
lines changed

Diff for: Cargo.lock

+7-34
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97"
524524

525525
[[package]]
526526
name = "clippy"
527-
version = "0.1.82"
527+
version = "0.1.83"
528528
dependencies = [
529529
"anstream",
530530
"cargo_metadata 0.18.1",
@@ -547,13 +547,13 @@ dependencies = [
547547
"termize",
548548
"tokio",
549549
"toml 0.7.8",
550-
"ui_test 0.25.0",
550+
"ui_test",
551551
"walkdir",
552552
]
553553

554554
[[package]]
555555
name = "clippy_config"
556-
version = "0.1.82"
556+
version = "0.1.83"
557557
dependencies = [
558558
"itertools",
559559
"serde",
@@ -576,7 +576,7 @@ dependencies = [
576576

577577
[[package]]
578578
name = "clippy_lints"
579-
version = "0.1.82"
579+
version = "0.1.83"
580580
dependencies = [
581581
"arrayvec",
582582
"cargo_metadata 0.18.1",
@@ -600,7 +600,7 @@ dependencies = [
600600

601601
[[package]]
602602
name = "clippy_utils"
603-
version = "0.1.82"
603+
version = "0.1.83"
604604
dependencies = [
605605
"arrayvec",
606606
"clippy_config",
@@ -902,7 +902,7 @@ dependencies = [
902902

903903
[[package]]
904904
name = "declare_clippy_lint"
905-
version = "0.1.82"
905+
version = "0.1.83"
906906
dependencies = [
907907
"itertools",
908908
"quote",
@@ -2269,7 +2269,7 @@ dependencies = [
22692269
"rustc_version",
22702270
"smallvec",
22712271
"tempfile",
2272-
"ui_test 0.26.5",
2272+
"ui_test",
22732273
"windows-sys 0.52.0",
22742274
]
22752275

@@ -5485,33 +5485,6 @@ version = "0.1.6"
54855485
source = "registry+https://github.com/rust-lang/crates.io-index"
54865486
checksum = "ed646292ffc8188ef8ea4d1e0e0150fb15a5c2e12ad9b8fc191ae7a8a7f3c4b9"
54875487

5488-
[[package]]
5489-
name = "ui_test"
5490-
version = "0.25.0"
5491-
source = "registry+https://github.com/rust-lang/crates.io-index"
5492-
checksum = "f7e4f339f62edc873975c47115f9e71c5454ddaa37c1142b42fc0b2672c8dacb"
5493-
dependencies = [
5494-
"annotate-snippets 0.11.4",
5495-
"anyhow",
5496-
"bstr",
5497-
"cargo-platform",
5498-
"cargo_metadata 0.18.1",
5499-
"color-eyre",
5500-
"colored",
5501-
"comma",
5502-
"crossbeam-channel",
5503-
"indicatif",
5504-
"lazy_static",
5505-
"levenshtein",
5506-
"prettydiff",
5507-
"regex",
5508-
"rustc_version",
5509-
"rustfix",
5510-
"serde",
5511-
"serde_json",
5512-
"spanned",
5513-
]
5514-
55155488
[[package]]
55165489
name = "ui_test"
55175490
version = "0.26.5"

Diff for: compiler/rustc_ast_passes/src/feature_gate.rs

+22-1
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ use rustc_ast::{NodeId, PatKind, attr, token};
44
use rustc_feature::{AttributeGate, BUILTIN_ATTRIBUTE_MAP, BuiltinAttribute, Features, GateIssue};
55
use rustc_session::Session;
66
use rustc_session::parse::{feature_err, feature_err_issue, feature_warn};
7-
use rustc_span::Span;
87
use rustc_span::source_map::Spanned;
98
use rustc_span::symbol::sym;
9+
use rustc_span::{Span, Symbol};
1010
use rustc_target::spec::abi;
1111
use thin_vec::ThinVec;
1212

@@ -483,6 +483,8 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
483483
pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) {
484484
maybe_stage_features(sess, features, krate);
485485
check_incompatible_features(sess, features);
486+
check_new_solver_banned_features(sess, features);
487+
486488
let mut visitor = PostExpansionVisitor { sess, features };
487489

488490
let spans = sess.psess.gated_spans.spans.borrow();
@@ -662,3 +664,22 @@ fn check_incompatible_features(sess: &Session, features: &Features) {
662664
}
663665
}
664666
}
667+
668+
fn check_new_solver_banned_features(sess: &Session, features: &Features) {
669+
if !sess.opts.unstable_opts.next_solver.is_some_and(|n| n.globally) {
670+
return;
671+
}
672+
673+
// Ban GCE with the new solver, because it does not implement GCE correctly.
674+
if let Some(&(_, gce_span, _)) = features
675+
.declared_lang_features
676+
.iter()
677+
.find(|&&(feat, _, _)| feat == sym::generic_const_exprs)
678+
{
679+
sess.dcx().emit_err(errors::IncompatibleFeatures {
680+
spans: vec![gce_span],
681+
f1: Symbol::intern("-Znext-solver=globally"),
682+
f2: sym::generic_const_exprs,
683+
});
684+
}
685+
}

Diff for: compiler/rustc_borrowck/src/facts.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::error::Error;
22
use std::fmt::Debug;
33
use std::fs::{self, File};
4-
use std::io::{BufWriter, Write};
4+
use std::io::Write;
55
use std::path::Path;
66

77
use polonius_engine::{AllFacts as PoloniusFacts, Atom};
@@ -127,7 +127,7 @@ impl<'w> FactWriter<'w> {
127127
T: FactRow,
128128
{
129129
let file = &self.dir.join(file_name);
130-
let mut file = BufWriter::new(File::create(file)?);
130+
let mut file = File::create_buffered(file)?;
131131
for row in rows {
132132
row.write(&mut file, self.location_table)?;
133133
}

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

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#![feature(assert_matches)]
77
#![feature(box_patterns)]
88
#![feature(control_flow_enum)]
9+
#![feature(file_buffered)]
910
#![feature(let_chains)]
1011
#![feature(never_type)]
1112
#![feature(rustc_attrs)]

Diff for: compiler/rustc_codegen_cranelift/src/unsize.rs

+16-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,22 @@ pub(crate) fn unsized_info<'tcx>(
3434
let old_info =
3535
old_info.expect("unsized_info: missing old info for trait upcasting coercion");
3636
if data_a.principal_def_id() == data_b.principal_def_id() {
37-
// A NOP cast that doesn't actually change anything, should be allowed even with invalid vtables.
37+
// Codegen takes advantage of the additional assumption, where if the
38+
// principal trait def id of what's being casted doesn't change,
39+
// then we don't need to adjust the vtable at all. This
40+
// corresponds to the fact that `dyn Tr<A>: Unsize<dyn Tr<B>>`
41+
// requires that `A = B`; we don't allow *upcasting* objects
42+
// between the same trait with different args. If we, for
43+
// some reason, were to relax the `Unsize` trait, it could become
44+
// unsound, so let's assert here that the trait refs are *equal*.
45+
//
46+
// We can use `assert_eq` because the binders should have been anonymized,
47+
// and because higher-ranked equality now requires the binders are equal.
48+
debug_assert_eq!(
49+
data_a.principal(),
50+
data_b.principal(),
51+
"NOP unsize vtable changed principal trait ref: {data_a} -> {data_b}"
52+
);
3853
return old_info;
3954
}
4055

Diff for: compiler/rustc_codegen_llvm/src/back/lto.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -808,8 +808,7 @@ struct ThinLTOKeysMap {
808808
impl ThinLTOKeysMap {
809809
fn save_to_file(&self, path: &Path) -> io::Result<()> {
810810
use std::io::Write;
811-
let file = File::create(path)?;
812-
let mut writer = io::BufWriter::new(file);
811+
let mut writer = File::create_buffered(path)?;
813812
// The entries are loaded back into a hash map in `load_from_file()`, so
814813
// the order in which we write them to file here does not matter.
815814
for (module, key) in &self.keys {
@@ -821,8 +820,8 @@ impl ThinLTOKeysMap {
821820
fn load_from_file(path: &Path) -> io::Result<Self> {
822821
use std::io::BufRead;
823822
let mut keys = BTreeMap::default();
824-
let file = File::open(path)?;
825-
for line in io::BufReader::new(file).lines() {
823+
let file = File::open_buffered(path)?;
824+
for line in file.lines() {
826825
let line = line?;
827826
let mut split = line.split(' ');
828827
let module = split.next().unwrap();

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

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#![feature(assert_matches)]
1212
#![feature(exact_size_is_empty)]
1313
#![feature(extern_types)]
14+
#![feature(file_buffered)]
1415
#![feature(hash_raw_entry)]
1516
#![feature(impl_trait_in_assoc_type)]
1617
#![feature(iter_intersperse)]

Diff for: compiler/rustc_codegen_ssa/src/back/link.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -1087,16 +1087,17 @@ fn link_natively(
10871087
let strip = sess.opts.cg.strip;
10881088

10891089
if sess.target.is_like_osx {
1090+
let stripcmd = "/usr/bin/strip";
10901091
match (strip, crate_type) {
10911092
(Strip::Debuginfo, _) => {
1092-
strip_symbols_with_external_utility(sess, "strip", out_filename, Some("-S"))
1093+
strip_symbols_with_external_utility(sess, stripcmd, out_filename, Some("-S"))
10931094
}
10941095
// Per the manpage, `-x` is the maximum safe strip level for dynamic libraries. (#93988)
10951096
(Strip::Symbols, CrateType::Dylib | CrateType::Cdylib | CrateType::ProcMacro) => {
1096-
strip_symbols_with_external_utility(sess, "strip", out_filename, Some("-x"))
1097+
strip_symbols_with_external_utility(sess, stripcmd, out_filename, Some("-x"))
10971098
}
10981099
(Strip::Symbols, _) => {
1099-
strip_symbols_with_external_utility(sess, "strip", out_filename, None)
1100+
strip_symbols_with_external_utility(sess, stripcmd, out_filename, None)
11001101
}
11011102
(Strip::None, _) => {}
11021103
}

Diff for: compiler/rustc_codegen_ssa/src/back/linker.rs

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
use std::ffi::{OsStr, OsString};
22
use std::fs::{self, File};
33
use std::io::prelude::*;
4-
use std::io::{self, BufWriter};
54
use std::path::{Path, PathBuf};
6-
use std::{env, iter, mem, str};
5+
use std::{env, io, iter, mem, str};
76

87
use cc::windows_registry;
98
use rustc_hir::def_id::{CrateNum, LOCAL_CRATE};
@@ -754,7 +753,7 @@ impl<'a> Linker for GccLinker<'a> {
754753
if self.sess.target.is_like_osx {
755754
// Write a plain, newline-separated list of symbols
756755
let res: io::Result<()> = try {
757-
let mut f = BufWriter::new(File::create(&path)?);
756+
let mut f = File::create_buffered(&path)?;
758757
for sym in symbols {
759758
debug!(" _{sym}");
760759
writeln!(f, "_{sym}")?;
@@ -765,7 +764,7 @@ impl<'a> Linker for GccLinker<'a> {
765764
}
766765
} else if is_windows {
767766
let res: io::Result<()> = try {
768-
let mut f = BufWriter::new(File::create(&path)?);
767+
let mut f = File::create_buffered(&path)?;
769768

770769
// .def file similar to MSVC one but without LIBRARY section
771770
// because LD doesn't like when it's empty
@@ -781,7 +780,7 @@ impl<'a> Linker for GccLinker<'a> {
781780
} else {
782781
// Write an LD version script
783782
let res: io::Result<()> = try {
784-
let mut f = BufWriter::new(File::create(&path)?);
783+
let mut f = File::create_buffered(&path)?;
785784
writeln!(f, "{{")?;
786785
if !symbols.is_empty() {
787786
writeln!(f, " global:")?;
@@ -1059,7 +1058,7 @@ impl<'a> Linker for MsvcLinker<'a> {
10591058

10601059
let path = tmpdir.join("lib.def");
10611060
let res: io::Result<()> = try {
1062-
let mut f = BufWriter::new(File::create(&path)?);
1061+
let mut f = File::create_buffered(&path)?;
10631062

10641063
// Start off with the standard module name header and then go
10651064
// straight to exports.
@@ -1648,7 +1647,7 @@ impl<'a> Linker for AixLinker<'a> {
16481647
fn export_symbols(&mut self, tmpdir: &Path, _crate_type: CrateType, symbols: &[String]) {
16491648
let path = tmpdir.join("list.exp");
16501649
let res: io::Result<()> = try {
1651-
let mut f = BufWriter::new(File::create(&path)?);
1650+
let mut f = File::create_buffered(&path)?;
16521651
// FIXME: use llvm-nm to generate export list.
16531652
for symbol in symbols {
16541653
debug!(" _{symbol}");
@@ -1961,7 +1960,7 @@ impl<'a> Linker for BpfLinker<'a> {
19611960
fn export_symbols(&mut self, tmpdir: &Path, _crate_type: CrateType, symbols: &[String]) {
19621961
let path = tmpdir.join("symbols");
19631962
let res: io::Result<()> = try {
1964-
let mut f = BufWriter::new(File::create(&path)?);
1963+
let mut f = File::create_buffered(&path)?;
19651964
for sym in symbols {
19661965
writeln!(f, "{sym}")?;
19671966
}

Diff for: compiler/rustc_codegen_ssa/src/base.rs

+24-9
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ use crate::back::write::{
3737
submit_codegened_module_to_llvm, submit_post_lto_module_to_llvm, submit_pre_lto_module_to_llvm,
3838
};
3939
use crate::common::{self, IntPredicate, RealPredicate, TypeKind};
40+
use crate::meth::load_vtable;
4041
use crate::mir::operand::OperandValue;
4142
use crate::mir::place::PlaceRef;
4243
use crate::traits::*;
@@ -124,8 +125,28 @@ fn unsized_info<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
124125
let old_info =
125126
old_info.expect("unsized_info: missing old info for trait upcasting coercion");
126127
if data_a.principal_def_id() == data_b.principal_def_id() {
127-
// A NOP cast that doesn't actually change anything, should be allowed even with
128-
// invalid vtables.
128+
// Codegen takes advantage of the additional assumption, where if the
129+
// principal trait def id of what's being casted doesn't change,
130+
// then we don't need to adjust the vtable at all. This
131+
// corresponds to the fact that `dyn Tr<A>: Unsize<dyn Tr<B>>`
132+
// requires that `A = B`; we don't allow *upcasting* objects
133+
// between the same trait with different args. If we, for
134+
// some reason, were to relax the `Unsize` trait, it could become
135+
// unsound, so let's assert here that the trait refs are *equal*.
136+
//
137+
// We can use `assert_eq` because the binders should have been anonymized,
138+
// and because higher-ranked equality now requires the binders are equal.
139+
debug_assert_eq!(
140+
data_a.principal(),
141+
data_b.principal(),
142+
"NOP unsize vtable changed principal trait ref: {data_a} -> {data_b}"
143+
);
144+
145+
// A NOP cast that doesn't actually change anything, let's avoid any
146+
// unnecessary work. This relies on the assumption that if the principal
147+
// traits are equal, then the associated type bounds (`dyn Trait<Assoc=T>`)
148+
// are also equal, which is ensured by the fact that normalization is
149+
// a function and we do not allow overlapping impls.
129150
return old_info;
130151
}
131152

@@ -135,14 +156,8 @@ fn unsized_info<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
135156

136157
if let Some(entry_idx) = vptr_entry_idx {
137158
let ptr_size = bx.data_layout().pointer_size;
138-
let ptr_align = bx.data_layout().pointer_align.abi;
139159
let vtable_byte_offset = u64::try_from(entry_idx).unwrap() * ptr_size.bytes();
140-
let gep = bx.inbounds_ptradd(old_info, bx.const_usize(vtable_byte_offset));
141-
let new_vptr = bx.load(bx.type_ptr(), gep, ptr_align);
142-
bx.nonnull_metadata(new_vptr);
143-
// VTable loads are invariant.
144-
bx.set_invariant_load(new_vptr);
145-
new_vptr
160+
load_vtable(bx, old_info, bx.type_ptr(), vtable_byte_offset, source, true)
146161
} else {
147162
old_info
148163
}

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

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#![doc(rust_logo)]
77
#![feature(assert_matches)]
88
#![feature(box_patterns)]
9+
#![feature(file_buffered)]
910
#![feature(if_let_guard)]
1011
#![feature(let_chains)]
1112
#![feature(negative_impls)]

0 commit comments

Comments
 (0)