Skip to content

Commit 7290b04

Browse files
committed
Auto merge of #138866 - compiler-errors:rollup-9d8v3mz, r=compiler-errors
Rollup of 12 pull requests Successful merges: - #136040 (Remove unused trait BoundedSize) - #138236 (uefi: Add OwnedEvent abstraction) - #138293 (rustdoc: Gate unstable `doc(cfg())` predicates) - #138509 (Add test to ensure no index out of bounds panic (#135474)) - #138545 (Add MIR pre-codegen tests to track #138544) - #138631 (Update test for SGX now implementing `read_buf`) - #138641 (Add unstable `--print=supported-crate-types` option) - #138667 (std: uefi: fs: Implement mkdir) - #138849 (doc: rename reference #create-a-configtoml to #create-a-bootstraptoml) - #138854 (Fix ICE #138415 for invalid extern function body) - #138858 (Say which test failed the `COMPILETEST_REQUIRE_ALL_LLVM_COMPONENTS` assertion) - #138861 (Tweak type flags, fix missing flags from coroutine kind ty) Failed merges: - #138755 ([rustdoc] Remove duplicated loop when computing doc cfgs) r? `@ghost` `@rustbot` modify labels: rollup
2 parents aa8f0fd + 045a1c7 commit 7290b04

Some content is hidden

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

45 files changed

+673
-222
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_ast_lowering/src/item.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1724,8 +1724,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
17241724
return;
17251725
};
17261726
let define_opaque = define_opaque.iter().filter_map(|(id, path)| {
1727-
let res = self.resolver.get_partial_res(*id).unwrap();
1728-
let Some(did) = res.expect_full_res().opt_def_id() else {
1727+
let res = self.resolver.get_partial_res(*id);
1728+
let Some(did) = res.and_then(|res| res.expect_full_res().opt_def_id()) else {
17291729
self.dcx().span_delayed_bug(path.span, "should have errored in resolve");
17301730
return None;
17311731
};

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_middle/src/ty/flags.rs

+15-74
Original file line numberDiff line numberDiff line change
@@ -101,63 +101,13 @@ impl FlagComputation {
101101

102102
&ty::Param(_) => {
103103
self.add_flags(TypeFlags::HAS_TY_PARAM);
104-
self.add_flags(TypeFlags::STILL_FURTHER_SPECIALIZABLE);
105104
}
106105

107-
ty::Coroutine(_, args) => {
108-
let args = args.as_coroutine();
109-
let should_remove_further_specializable =
110-
!self.flags.contains(TypeFlags::STILL_FURTHER_SPECIALIZABLE);
111-
self.add_args(args.parent_args());
112-
if should_remove_further_specializable {
113-
self.flags -= TypeFlags::STILL_FURTHER_SPECIALIZABLE;
114-
}
115-
116-
self.add_ty(args.resume_ty());
117-
self.add_ty(args.return_ty());
118-
self.add_ty(args.witness());
119-
self.add_ty(args.yield_ty());
120-
self.add_ty(args.tupled_upvars_ty());
121-
}
122-
123-
ty::CoroutineWitness(_, args) => {
124-
let should_remove_further_specializable =
125-
!self.flags.contains(TypeFlags::STILL_FURTHER_SPECIALIZABLE);
106+
&ty::Closure(_, args)
107+
| &ty::Coroutine(_, args)
108+
| &ty::CoroutineClosure(_, args)
109+
| &ty::CoroutineWitness(_, args) => {
126110
self.add_args(args);
127-
if should_remove_further_specializable {
128-
self.flags -= TypeFlags::STILL_FURTHER_SPECIALIZABLE;
129-
}
130-
self.add_flags(TypeFlags::HAS_TY_COROUTINE);
131-
}
132-
133-
&ty::Closure(_, args) => {
134-
let args = args.as_closure();
135-
let should_remove_further_specializable =
136-
!self.flags.contains(TypeFlags::STILL_FURTHER_SPECIALIZABLE);
137-
self.add_args(args.parent_args());
138-
if should_remove_further_specializable {
139-
self.flags -= TypeFlags::STILL_FURTHER_SPECIALIZABLE;
140-
}
141-
142-
self.add_ty(args.sig_as_fn_ptr_ty());
143-
self.add_ty(args.kind_ty());
144-
self.add_ty(args.tupled_upvars_ty());
145-
}
146-
147-
&ty::CoroutineClosure(_, args) => {
148-
let args = args.as_coroutine_closure();
149-
let should_remove_further_specializable =
150-
!self.flags.contains(TypeFlags::STILL_FURTHER_SPECIALIZABLE);
151-
self.add_args(args.parent_args());
152-
if should_remove_further_specializable {
153-
self.flags -= TypeFlags::STILL_FURTHER_SPECIALIZABLE;
154-
}
155-
156-
self.add_ty(args.kind_ty());
157-
self.add_ty(args.signature_parts_ty());
158-
self.add_ty(args.tupled_upvars_ty());
159-
self.add_ty(args.coroutine_captures_by_ref_ty());
160-
self.add_ty(args.coroutine_witness_ty());
161111
}
162112

163113
&ty::Bound(debruijn, _) => {
@@ -167,21 +117,17 @@ impl FlagComputation {
167117

168118
&ty::Placeholder(..) => {
169119
self.add_flags(TypeFlags::HAS_TY_PLACEHOLDER);
170-
self.add_flags(TypeFlags::STILL_FURTHER_SPECIALIZABLE);
171120
}
172121

173-
&ty::Infer(infer) => {
174-
self.add_flags(TypeFlags::STILL_FURTHER_SPECIALIZABLE);
175-
match infer {
176-
ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_) => {
177-
self.add_flags(TypeFlags::HAS_TY_FRESH)
178-
}
122+
&ty::Infer(infer) => match infer {
123+
ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_) => {
124+
self.add_flags(TypeFlags::HAS_TY_FRESH)
125+
}
179126

180-
ty::TyVar(_) | ty::IntVar(_) | ty::FloatVar(_) => {
181-
self.add_flags(TypeFlags::HAS_TY_INFER)
182-
}
127+
ty::TyVar(_) | ty::IntVar(_) | ty::FloatVar(_) => {
128+
self.add_flags(TypeFlags::HAS_TY_INFER)
183129
}
184-
}
130+
},
185131

186132
&ty::Adt(_, args) => {
187133
self.add_args(args);
@@ -358,24 +304,19 @@ impl FlagComputation {
358304
self.add_args(uv.args);
359305
self.add_flags(TypeFlags::HAS_CT_PROJECTION);
360306
}
361-
ty::ConstKind::Infer(infer) => {
362-
self.add_flags(TypeFlags::STILL_FURTHER_SPECIALIZABLE);
363-
match infer {
364-
InferConst::Fresh(_) => self.add_flags(TypeFlags::HAS_CT_FRESH),
365-
InferConst::Var(_) => self.add_flags(TypeFlags::HAS_CT_INFER),
366-
}
367-
}
307+
ty::ConstKind::Infer(infer) => match infer {
308+
InferConst::Fresh(_) => self.add_flags(TypeFlags::HAS_CT_FRESH),
309+
InferConst::Var(_) => self.add_flags(TypeFlags::HAS_CT_INFER),
310+
},
368311
ty::ConstKind::Bound(debruijn, _) => {
369312
self.add_bound_var(debruijn);
370313
self.add_flags(TypeFlags::HAS_CT_BOUND);
371314
}
372315
ty::ConstKind::Param(_) => {
373316
self.add_flags(TypeFlags::HAS_CT_PARAM);
374-
self.add_flags(TypeFlags::STILL_FURTHER_SPECIALIZABLE);
375317
}
376318
ty::ConstKind::Placeholder(_) => {
377319
self.add_flags(TypeFlags::HAS_CT_PLACEHOLDER);
378-
self.add_flags(TypeFlags::STILL_FURTHER_SPECIALIZABLE);
379320
}
380321
ty::ConstKind::Value(cv) => self.add_ty(cv.ty),
381322
ty::ConstKind::Expr(e) => self.add_args(e.args()),

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!(

compiler/rustc_type_ir/src/flags.rs

+9-7
Original file line numberDiff line numberDiff line change
@@ -111,18 +111,20 @@ bitflags::bitflags! {
111111

112112
/// Does this value have parameters/placeholders/inference variables which could be
113113
/// replaced later, in a way that would change the results of `impl` specialization?
114-
const STILL_FURTHER_SPECIALIZABLE = 1 << 21;
114+
const STILL_FURTHER_SPECIALIZABLE = TypeFlags::HAS_TY_PARAM.bits()
115+
| TypeFlags::HAS_TY_PLACEHOLDER.bits()
116+
| TypeFlags::HAS_TY_INFER.bits()
117+
| TypeFlags::HAS_CT_PARAM.bits()
118+
| TypeFlags::HAS_CT_PLACEHOLDER.bits()
119+
| TypeFlags::HAS_CT_INFER.bits();
115120

116121
/// Does this value have `InferTy::FreshTy/FreshIntTy/FreshFloatTy`?
117-
const HAS_TY_FRESH = 1 << 22;
122+
const HAS_TY_FRESH = 1 << 21;
118123

119124
/// Does this value have `InferConst::Fresh`?
120-
const HAS_CT_FRESH = 1 << 23;
121-
122-
/// Does this have `Coroutine` or `CoroutineWitness`?
123-
const HAS_TY_COROUTINE = 1 << 24;
125+
const HAS_CT_FRESH = 1 << 22;
124126

125127
/// Does this have any binders with bound vars (e.g. that need to be anonymized)?
126-
const HAS_BINDER_VARS = 1 << 25;
128+
const HAS_BINDER_VARS = 1 << 23;
127129
}
128130
}

compiler/rustc_type_ir/src/visit.rs

-4
Original file line numberDiff line numberDiff line change
@@ -269,10 +269,6 @@ pub trait TypeVisitableExt<I: Interner>: TypeVisitable<I> {
269269
self.has_type_flags(TypeFlags::HAS_TY_OPAQUE)
270270
}
271271

272-
fn has_coroutines(&self) -> bool {
273-
self.has_type_flags(TypeFlags::HAS_TY_COROUTINE)
274-
}
275-
276272
fn references_error(&self) -> bool {
277273
self.has_type_flags(TypeFlags::HAS_ERROR)
278274
}

library/core/src/iter/adapters/flatten.rs

-55
Original file line numberDiff line numberDiff line change
@@ -172,61 +172,6 @@ where
172172
}
173173
}
174174

175-
/// Marker trait for iterators/iterables which have a statically known upper
176-
/// bound of the number of items they can produce.
177-
///
178-
/// # Safety
179-
///
180-
/// Implementations must not yield more elements than indicated by UPPER_BOUND if it is `Some`.
181-
/// Used in specializations. Implementations must not be conditional on lifetimes or
182-
/// user-implementable traits.
183-
#[rustc_specialization_trait]
184-
#[unstable(issue = "none", feature = "inplace_iteration")]
185-
unsafe trait BoundedSize {
186-
const UPPER_BOUND: Option<NonZero<usize>> = NonZero::new(1);
187-
}
188-
189-
#[unstable(issue = "none", feature = "inplace_iteration")]
190-
unsafe impl<T> BoundedSize for Option<T> {}
191-
#[unstable(issue = "none", feature = "inplace_iteration")]
192-
unsafe impl<T> BoundedSize for option::IntoIter<T> {}
193-
#[unstable(issue = "none", feature = "inplace_iteration")]
194-
unsafe impl<T, U> BoundedSize for Result<T, U> {}
195-
#[unstable(issue = "none", feature = "inplace_iteration")]
196-
unsafe impl<T> BoundedSize for result::IntoIter<T> {}
197-
#[unstable(issue = "none", feature = "inplace_iteration")]
198-
unsafe impl<T> BoundedSize for Once<T> {}
199-
#[unstable(issue = "none", feature = "inplace_iteration")]
200-
unsafe impl<T> BoundedSize for OnceWith<T> {}
201-
#[unstable(issue = "none", feature = "inplace_iteration")]
202-
unsafe impl<T, const N: usize> BoundedSize for [T; N] {
203-
const UPPER_BOUND: Option<NonZero<usize>> = NonZero::new(N);
204-
}
205-
#[unstable(issue = "none", feature = "inplace_iteration")]
206-
unsafe impl<T, const N: usize> BoundedSize for array::IntoIter<T, N> {
207-
const UPPER_BOUND: Option<NonZero<usize>> = NonZero::new(N);
208-
}
209-
#[unstable(issue = "none", feature = "inplace_iteration")]
210-
unsafe impl<I: BoundedSize, P> BoundedSize for Filter<I, P> {
211-
const UPPER_BOUND: Option<NonZero<usize>> = I::UPPER_BOUND;
212-
}
213-
#[unstable(issue = "none", feature = "inplace_iteration")]
214-
unsafe impl<I: BoundedSize, P> BoundedSize for FilterMap<I, P> {
215-
const UPPER_BOUND: Option<NonZero<usize>> = I::UPPER_BOUND;
216-
}
217-
#[unstable(issue = "none", feature = "inplace_iteration")]
218-
unsafe impl<I: BoundedSize, F> BoundedSize for Map<I, F> {
219-
const UPPER_BOUND: Option<NonZero<usize>> = I::UPPER_BOUND;
220-
}
221-
#[unstable(issue = "none", feature = "inplace_iteration")]
222-
unsafe impl<I: BoundedSize> BoundedSize for Copied<I> {
223-
const UPPER_BOUND: Option<NonZero<usize>> = I::UPPER_BOUND;
224-
}
225-
#[unstable(issue = "none", feature = "inplace_iteration")]
226-
unsafe impl<I: BoundedSize> BoundedSize for Cloned<I> {
227-
const UPPER_BOUND: Option<NonZero<usize>> = I::UPPER_BOUND;
228-
}
229-
230175
/// An iterator that flattens one level of nesting in an iterator of things
231176
/// that can be turned into iterators.
232177
///

library/core/src/macros/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1744,7 +1744,7 @@ pub(crate) mod builtin {
17441744
}
17451745

17461746
/// Provide a list of type aliases and other opaque-type-containing type definitions.
1747-
/// This list will be used in the body of the item it is applied to to define opaque
1747+
/// This list will be used in the body of the item it is applied to define opaque
17481748
/// types' hidden types.
17491749
/// Can only be applied to things that have bodies.
17501750
#[unstable(

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

+30-4
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pub struct FilePermissions(bool);
3636
pub struct FileType(bool);
3737

3838
#[derive(Debug)]
39-
pub struct DirBuilder {}
39+
pub struct DirBuilder;
4040

4141
impl FileAttr {
4242
pub fn size(&self) -> u64 {
@@ -248,11 +248,11 @@ impl File {
248248

249249
impl DirBuilder {
250250
pub fn new() -> DirBuilder {
251-
DirBuilder {}
251+
DirBuilder
252252
}
253253

254-
pub fn mkdir(&self, _p: &Path) -> io::Result<()> {
255-
unsupported()
254+
pub fn mkdir(&self, p: &Path) -> io::Result<()> {
255+
uefi_fs::mkdir(p)
256256
}
257257
}
258258

@@ -452,4 +452,30 @@ mod uefi_fs {
452452
}
453453
}
454454
}
455+
456+
/// An implementation of mkdir to allow creating new directory without having to open the
457+
/// volume twice (once for checking and once for creating)
458+
pub(crate) fn mkdir(path: &Path) -> io::Result<()> {
459+
let absolute = crate::path::absolute(path)?;
460+
461+
let p = helpers::OwnedDevicePath::from_text(absolute.as_os_str())?;
462+
let (vol, mut path_remaining) = File::open_volume_from_device_path(p.borrow())?;
463+
464+
// Check if file exists
465+
match vol.open(&mut path_remaining, file::MODE_READ, 0) {
466+
Ok(_) => {
467+
return Err(io::Error::new(io::ErrorKind::AlreadyExists, "Path already exists"));
468+
}
469+
Err(e) if e.kind() == io::ErrorKind::NotFound => {}
470+
Err(e) => return Err(e),
471+
}
472+
473+
let _ = vol.open(
474+
&mut path_remaining,
475+
file::MODE_READ | file::MODE_WRITE | file::MODE_CREATE,
476+
file::DIRECTORY,
477+
)?;
478+
479+
Ok(())
480+
}
455481
}

0 commit comments

Comments
 (0)