Skip to content

Commit ec48f81

Browse files
committed
Auto merge of rust-lang#138853 - jieyouxu:rollup-ogjxuq9, r=jieyouxu
Rollup of 9 pull requests Successful merges: - rust-lang#138236 (uefi: Add OwnedEvent abstraction) - rust-lang#138293 (rustdoc: Gate unstable `doc(cfg())` predicates) - rust-lang#138509 (Add test to ensure no index out of bounds panic (rust-lang#135474)) - rust-lang#138602 (Slim `rustc_parse_format` dependencies down) - rust-lang#138631 (Update test for SGX now implementing `read_buf`) - rust-lang#138641 (Add unstable `--print=supported-crate-types` option) - rust-lang#138662 (Implement some basics in UEFI fs) - rust-lang#138837 (resolve: Avoid remaining unstable iteration) - rust-lang#138849 (doc: rename reference #create-a-configtoml to #create-a-bootstraptoml) Failed merges: - rust-lang#138755 ([rustdoc] Remove duplicated loop when computing doc cfgs) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 60a3084 + 5c17679 commit ec48f81

32 files changed

+336
-93
lines changed

bootstrap.example.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Sample TOML configuration file for building Rust.
22
#
33
# To configure bootstrap, run `./configure` or `./x.py setup`.
4-
# See https://rustc-dev-guide.rust-lang.org/building/how-to-build-and-run.html#create-a-configtoml for more information.
4+
# See https://rustc-dev-guide.rust-lang.org/building/how-to-build-and-run.html#create-a-bootstraptoml for more information.
55
#
66
# All options are commented out by default in this file, and they're commented
77
# out with their default values. The build system by default looks for
@@ -446,7 +446,7 @@
446446
# a specific version.
447447
#ccache = false
448448

449-
# List of paths to exclude from the build and test processes.
449+
# List of paths to exclude from the build and test processes.
450450
# For example, exclude = ["tests/ui", "src/tools/tidy"].
451451
#exclude = []
452452

compiler/rustc_driver_impl/src/lib.rs

+12-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
// tidy-alphabetical-end
2121

2222
use std::cmp::max;
23-
use std::collections::BTreeMap;
23+
use std::collections::{BTreeMap, BTreeSet};
2424
use std::ffi::OsString;
2525
use std::fmt::Write as _;
2626
use std::fs::{self, File};
@@ -61,7 +61,7 @@ use rustc_session::config::{
6161
};
6262
use rustc_session::getopts::{self, Matches};
6363
use rustc_session::lint::{Lint, LintId};
64-
use rustc_session::output::collect_crate_types;
64+
use rustc_session::output::{CRATE_TYPES, collect_crate_types, invalid_output_for_target};
6565
use rustc_session::{EarlyDiagCtxt, Session, config, filesearch};
6666
use rustc_span::FileName;
6767
use rustc_target::json::ToJson;
@@ -790,6 +790,16 @@ fn print_crate_info(
790790
sess.dcx().fatal("only Apple targets currently support deployment version info")
791791
}
792792
}
793+
SupportedCrateTypes => {
794+
let supported_crate_types = CRATE_TYPES
795+
.iter()
796+
.filter(|(_, crate_type)| !invalid_output_for_target(&sess, *crate_type))
797+
.map(|(crate_type_sym, _)| *crate_type_sym)
798+
.collect::<BTreeSet<_>>();
799+
for supported_crate_type in supported_crate_types {
800+
println_info!("{}", supported_crate_type.as_str());
801+
}
802+
}
793803
}
794804

795805
req.out.overwrite(&crate_info, sess);

compiler/rustc_parse_format/Cargo.toml

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,7 @@ edition = "2024"
88
rustc_lexer = { path = "../rustc_lexer" }
99
# tidy-alphabetical-end
1010

11-
[target.'cfg(target_pointer_width = "64")'.dependencies]
11+
[target.'cfg(target_pointer_width = "64")'.dev-dependencies]
12+
# tidy-alphabetical-start
1213
rustc_index = { path = "../rustc_index", default-features = false }
14+
# tidy-alphabetical-end

compiler/rustc_parse_format/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1105,7 +1105,7 @@ fn unescape_string(string: &str) -> Option<String> {
11051105
}
11061106

11071107
// Assert a reasonable size for `Piece`
1108-
#[cfg(target_pointer_width = "64")]
1108+
#[cfg(all(test, target_pointer_width = "64"))]
11091109
rustc_index::static_assert_size!(Piece<'_>, 16);
11101110

11111111
#[cfg(test)]

compiler/rustc_resolve/src/late.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ impl RibKind<'_> {
272272
/// resolving, the name is looked up from inside out.
273273
#[derive(Debug)]
274274
pub(crate) struct Rib<'ra, R = Res> {
275-
pub bindings: FxHashMap<Ident, R>,
275+
pub bindings: FxIndexMap<Ident, R>,
276276
pub patterns_with_skipped_bindings: UnordMap<DefId, Vec<(Span, Result<(), ErrorGuaranteed>)>>,
277277
pub kind: RibKind<'ra>,
278278
}
@@ -1642,8 +1642,8 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
16421642

16431643
// Allow all following defaults to refer to this type parameter.
16441644
let i = &Ident::with_dummy_span(param.ident.name);
1645-
forward_ty_ban_rib.bindings.remove(i);
1646-
forward_ty_ban_rib_const_param_ty.bindings.remove(i);
1645+
forward_ty_ban_rib.bindings.swap_remove(i);
1646+
forward_ty_ban_rib_const_param_ty.bindings.swap_remove(i);
16471647
}
16481648
GenericParamKind::Const { ref ty, kw_span: _, ref default } => {
16491649
// Const parameters can't have param bounds.
@@ -1678,8 +1678,8 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
16781678

16791679
// Allow all following defaults to refer to this const parameter.
16801680
let i = &Ident::with_dummy_span(param.ident.name);
1681-
forward_const_ban_rib.bindings.remove(i);
1682-
forward_const_ban_rib_const_param_ty.bindings.remove(i);
1681+
forward_const_ban_rib.bindings.swap_remove(i);
1682+
forward_const_ban_rib_const_param_ty.bindings.swap_remove(i);
16831683
}
16841684
}
16851685
}
@@ -2888,7 +2888,6 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
28882888
break;
28892889
}
28902890

2891-
#[allow(rustc::potential_query_instability)] // FIXME
28922891
seen_bindings
28932892
.extend(parent_rib.bindings.keys().map(|ident| (*ident, ident.span)));
28942893
}
@@ -4003,7 +4002,7 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
40034002
}
40044003
}
40054004

4006-
fn innermost_rib_bindings(&mut self, ns: Namespace) -> &mut FxHashMap<Ident, Res> {
4005+
fn innermost_rib_bindings(&mut self, ns: Namespace) -> &mut FxIndexMap<Ident, Res> {
40074006
&mut self.ribs[ns].last_mut().unwrap().bindings
40084007
}
40094008

compiler/rustc_resolve/src/late/diagnostics.rs

-5
Original file line numberDiff line numberDiff line change
@@ -830,7 +830,6 @@ impl<'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> {
830830
if let Some(rib) = &self.last_block_rib
831831
&& let RibKind::Normal = rib.kind
832832
{
833-
#[allow(rustc::potential_query_instability)] // FIXME
834833
for (ident, &res) in &rib.bindings {
835834
if let Res::Local(_) = res
836835
&& path.len() == 1
@@ -1019,7 +1018,6 @@ impl<'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> {
10191018
if let Some(err_code) = err.code {
10201019
if err_code == E0425 {
10211020
for label_rib in &self.label_ribs {
1022-
#[allow(rustc::potential_query_instability)] // FIXME
10231021
for (label_ident, node_id) in &label_rib.bindings {
10241022
let ident = path.last().unwrap().ident;
10251023
if format!("'{ident}") == label_ident.to_string() {
@@ -2265,7 +2263,6 @@ impl<'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> {
22652263
};
22662264

22672265
// Locals and type parameters
2268-
#[allow(rustc::potential_query_instability)] // FIXME
22692266
for (ident, &res) in &rib.bindings {
22702267
if filter_fn(res) && ident.span.ctxt() == rib_ctxt {
22712268
names.push(TypoSuggestion::typo_from_ident(*ident, res));
@@ -2793,7 +2790,6 @@ impl<'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> {
27932790
let within_scope = self.is_label_valid_from_rib(rib_index);
27942791

27952792
let rib = &self.label_ribs[rib_index];
2796-
#[allow(rustc::potential_query_instability)] // FIXME
27972793
let names = rib
27982794
.bindings
27992795
.iter()
@@ -2805,7 +2801,6 @@ impl<'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> {
28052801
// Upon finding a similar name, get the ident that it was from - the span
28062802
// contained within helps make a useful diagnostic. In addition, determine
28072803
// whether this candidate is within scope.
2808-
#[allow(rustc::potential_query_instability)] // FIXME
28092804
let (ident, _) = rib.bindings.iter().find(|(ident, _)| ident.name == symbol).unwrap();
28102805
(*ident, within_scope)
28112806
})

compiler/rustc_session/src/config.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ pub const PRINT_KINDS: &[(&str, PrintKind)] = &[
5858
("relocation-models", PrintKind::RelocationModels),
5959
("split-debuginfo", PrintKind::SplitDebuginfo),
6060
("stack-protector-strategies", PrintKind::StackProtectorStrategies),
61+
("supported-crate-types", PrintKind::SupportedCrateTypes),
6162
("sysroot", PrintKind::Sysroot),
6263
("target-cpus", PrintKind::TargetCPUs),
6364
("target-features", PrintKind::TargetFeatures),
@@ -888,6 +889,7 @@ pub enum PrintKind {
888889
RelocationModels,
889890
SplitDebuginfo,
890891
StackProtectorStrategies,
892+
SupportedCrateTypes,
891893
Sysroot,
892894
TargetCPUs,
893895
TargetFeatures,
@@ -2063,7 +2065,10 @@ fn check_print_request_stability(
20632065
(print_name, print_kind): (&str, PrintKind),
20642066
) {
20652067
match print_kind {
2066-
PrintKind::AllTargetSpecsJson | PrintKind::CheckCfg | PrintKind::TargetSpecJson
2068+
PrintKind::AllTargetSpecsJson
2069+
| PrintKind::CheckCfg
2070+
| PrintKind::SupportedCrateTypes
2071+
| PrintKind::TargetSpecJson
20672072
if !unstable_opts.unstable_options =>
20682073
{
20692074
early_dcx.early_fatal(format!(

library/std/src/net/tcp/tests.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -315,12 +315,8 @@ fn read_buf() {
315315
let mut buf = BorrowedBuf::from(buf.as_mut_slice());
316316
t!(s.read_buf(buf.unfilled()));
317317
assert_eq!(buf.filled(), &[1, 2, 3, 4]);
318-
319-
// FIXME: sgx uses default_read_buf that initializes the buffer.
320-
if cfg!(not(target_env = "sgx")) {
321-
// TcpStream::read_buf should omit buffer initialization.
322-
assert_eq!(buf.init_len(), 4);
323-
}
318+
// TcpStream::read_buf should omit buffer initialization.
319+
assert_eq!(buf.init_len(), 4);
324320

325321
t.join().ok().expect("thread panicked");
326322
})

library/std/src/sys/fs/uefi.rs

+61-12
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use r_efi::protocols::file;
2+
13
use crate::ffi::OsString;
24
use crate::fmt;
35
use crate::hash::Hash;
@@ -22,7 +24,12 @@ pub struct ReadDir(!);
2224
pub struct DirEntry(!);
2325

2426
#[derive(Clone, Debug)]
25-
pub struct OpenOptions {}
27+
pub struct OpenOptions {
28+
mode: u64,
29+
append: bool,
30+
truncate: bool,
31+
create_new: bool,
32+
}
2633

2734
#[derive(Copy, Clone, Debug, Default)]
2835
pub struct FileTimes {}
@@ -141,15 +148,57 @@ impl DirEntry {
141148

142149
impl OpenOptions {
143150
pub fn new() -> OpenOptions {
144-
OpenOptions {}
151+
OpenOptions { mode: 0, append: false, create_new: false, truncate: false }
152+
}
153+
154+
pub fn read(&mut self, read: bool) {
155+
if read {
156+
self.mode |= file::MODE_READ;
157+
} else {
158+
self.mode &= !file::MODE_READ;
159+
}
160+
}
161+
162+
pub fn write(&mut self, write: bool) {
163+
if write {
164+
// Valid Combinations: Read, Read/Write, Read/Write/Create
165+
self.read(true);
166+
self.mode |= file::MODE_WRITE;
167+
} else {
168+
self.mode &= !file::MODE_WRITE;
169+
}
170+
}
171+
172+
pub fn append(&mut self, append: bool) {
173+
// Docs state that `.write(true).append(true)` has the same effect as `.append(true)`
174+
if append {
175+
self.write(true);
176+
}
177+
self.append = append;
145178
}
146179

147-
pub fn read(&mut self, _read: bool) {}
148-
pub fn write(&mut self, _write: bool) {}
149-
pub fn append(&mut self, _append: bool) {}
150-
pub fn truncate(&mut self, _truncate: bool) {}
151-
pub fn create(&mut self, _create: bool) {}
152-
pub fn create_new(&mut self, _create_new: bool) {}
180+
pub fn truncate(&mut self, truncate: bool) {
181+
self.truncate = truncate;
182+
}
183+
184+
pub fn create(&mut self, create: bool) {
185+
if create {
186+
self.mode |= file::MODE_CREATE;
187+
} else {
188+
self.mode &= !file::MODE_CREATE;
189+
}
190+
}
191+
192+
pub fn create_new(&mut self, create_new: bool) {
193+
self.create_new = create_new;
194+
}
195+
196+
const fn is_mode_valid(&self) -> bool {
197+
// Valid Combinations: Read, Read/Write, Read/Write/Create
198+
self.mode == file::MODE_READ
199+
|| self.mode == (file::MODE_READ | file::MODE_WRITE)
200+
|| self.mode == (file::MODE_READ | file::MODE_WRITE | file::MODE_CREATE)
201+
}
153202
}
154203

155204
impl File {
@@ -311,12 +360,12 @@ pub fn stat(_p: &Path) -> io::Result<FileAttr> {
311360
unsupported()
312361
}
313362

314-
pub fn lstat(_p: &Path) -> io::Result<FileAttr> {
315-
unsupported()
363+
pub fn lstat(p: &Path) -> io::Result<FileAttr> {
364+
stat(p)
316365
}
317366

318-
pub fn canonicalize(_p: &Path) -> io::Result<PathBuf> {
319-
unsupported()
367+
pub fn canonicalize(p: &Path) -> io::Result<PathBuf> {
368+
crate::path::absolute(p)
320369
}
321370

322371
pub fn copy(_from: &Path, _to: &Path) -> io::Result<u64> {

0 commit comments

Comments
 (0)