Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 7fe2c4b

Browse files
committedJun 7, 2022
Auto merge of rust-lang#97825 - Dylan-DPC:rollup-ya51k1k, r=Dylan-DPC
Rollup of 5 pull requests Successful merges: - rust-lang#97058 (Various refactors to the incr comp workproduct handling) - rust-lang#97301 (Allow unstable items to be re-exported unstably without requiring the feature be enabled) - rust-lang#97738 (Fix ICEs from zsts within unsized types with non-zero offsets) - rust-lang#97771 (Remove SIGIO reference on Haiku) - rust-lang#97808 (Add some unstable target features for the wasm target codegen) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 91cacb3 + 9526653 commit 7fe2c4b

File tree

18 files changed

+284
-115
lines changed

18 files changed

+284
-115
lines changed
 

‎compiler/rustc_codegen_cranelift/src/driver/aot.rs

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,7 @@ fn emit_module(
6666
let work_product = if backend_config.disable_incr_cache {
6767
None
6868
} else {
69-
rustc_incremental::copy_cgu_workproduct_to_incr_comp_cache_dir(
70-
tcx.sess,
71-
&name,
72-
&Some(tmp_file.clone()),
73-
)
69+
rustc_incremental::copy_cgu_workproduct_to_incr_comp_cache_dir(tcx.sess, &name, &tmp_file)
7470
};
7571

7672
ModuleCodegenResult(
@@ -84,29 +80,24 @@ fn reuse_workproduct_for_cgu(
8480
cgu: &CodegenUnit<'_>,
8581
work_products: &mut FxHashMap<WorkProductId, WorkProduct>,
8682
) -> CompiledModule {
87-
let mut object = None;
88-
let work_product = cgu.work_product(tcx);
89-
if let Some(saved_file) = &work_product.saved_file {
90-
let obj_out =
91-
tcx.output_filenames(()).temp_path(OutputType::Object, Some(cgu.name().as_str()));
92-
object = Some(obj_out.clone());
93-
let source_file = rustc_incremental::in_incr_comp_dir_sess(&tcx.sess, &saved_file);
94-
if let Err(err) = rustc_fs_util::link_or_copy(&source_file, &obj_out) {
95-
tcx.sess.err(&format!(
96-
"unable to copy {} to {}: {}",
97-
source_file.display(),
98-
obj_out.display(),
99-
err
100-
));
101-
}
83+
let work_product = cgu.previous_work_product(tcx);
84+
let obj_out = tcx.output_filenames(()).temp_path(OutputType::Object, Some(cgu.name().as_str()));
85+
let source_file = rustc_incremental::in_incr_comp_dir_sess(&tcx.sess, &work_product.saved_file);
86+
if let Err(err) = rustc_fs_util::link_or_copy(&source_file, &obj_out) {
87+
tcx.sess.err(&format!(
88+
"unable to copy {} to {}: {}",
89+
source_file.display(),
90+
obj_out.display(),
91+
err
92+
));
10293
}
10394

10495
work_products.insert(cgu.work_product_id(), work_product);
10596

10697
CompiledModule {
10798
name: cgu.name().to_string(),
10899
kind: ModuleKind::Regular,
109-
object,
100+
object: Some(obj_out),
110101
dwarf_object: None,
111102
bytecode: None,
112103
}

‎compiler/rustc_codegen_ssa/src/back/write.rs

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -494,12 +494,12 @@ fn copy_all_cgu_workproducts_to_incr_comp_cache_dir(
494494
let _timer = sess.timer("copy_all_cgu_workproducts_to_incr_comp_cache_dir");
495495

496496
for module in compiled_modules.modules.iter().filter(|m| m.kind == ModuleKind::Regular) {
497-
let path = module.object.as_ref().cloned();
498-
499-
if let Some((id, product)) =
500-
copy_cgu_workproduct_to_incr_comp_cache_dir(sess, &module.name, &path)
501-
{
502-
work_products.insert(id, product);
497+
if let Some(path) = &module.object {
498+
if let Some((id, product)) =
499+
copy_cgu_workproduct_to_incr_comp_cache_dir(sess, &module.name, path)
500+
{
501+
work_products.insert(id, product);
502+
}
503503
}
504504
}
505505

@@ -853,35 +853,31 @@ fn execute_copy_from_cache_work_item<B: ExtraBackendMethods>(
853853
module: CachedModuleCodegen,
854854
module_config: &ModuleConfig,
855855
) -> WorkItemResult<B> {
856+
assert!(module_config.emit_obj != EmitObj::None);
857+
856858
let incr_comp_session_dir = cgcx.incr_comp_session_dir.as_ref().unwrap();
857-
let mut object = None;
858-
if let Some(saved_file) = module.source.saved_file {
859-
let obj_out = cgcx.output_filenames.temp_path(OutputType::Object, Some(&module.name));
860-
object = Some(obj_out.clone());
861-
let source_file = in_incr_comp_dir(&incr_comp_session_dir, &saved_file);
862-
debug!(
863-
"copying pre-existing module `{}` from {:?} to {}",
864-
module.name,
865-
source_file,
866-
obj_out.display()
867-
);
868-
if let Err(err) = link_or_copy(&source_file, &obj_out) {
869-
let diag_handler = cgcx.create_diag_handler();
870-
diag_handler.err(&format!(
871-
"unable to copy {} to {}: {}",
872-
source_file.display(),
873-
obj_out.display(),
874-
err
875-
));
876-
}
859+
let obj_out = cgcx.output_filenames.temp_path(OutputType::Object, Some(&module.name));
860+
let source_file = in_incr_comp_dir(&incr_comp_session_dir, &module.source.saved_file);
861+
debug!(
862+
"copying pre-existing module `{}` from {:?} to {}",
863+
module.name,
864+
source_file,
865+
obj_out.display()
866+
);
867+
if let Err(err) = link_or_copy(&source_file, &obj_out) {
868+
let diag_handler = cgcx.create_diag_handler();
869+
diag_handler.err(&format!(
870+
"unable to copy {} to {}: {}",
871+
source_file.display(),
872+
obj_out.display(),
873+
err
874+
));
877875
}
878876

879-
assert_eq!(object.is_some(), module_config.emit_obj != EmitObj::None);
880-
881877
WorkItemResult::Compiled(CompiledModule {
882878
name: module.name,
883879
kind: ModuleKind::Regular,
884-
object,
880+
object: Some(obj_out),
885881
dwarf_object: None,
886882
bytecode: None,
887883
})

‎compiler/rustc_codegen_ssa/src/base.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,11 +216,12 @@ pub fn unsize_ptr<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
216216
let mut result = None;
217217
for i in 0..src_layout.fields.count() {
218218
let src_f = src_layout.field(bx.cx(), i);
219-
assert_eq!(src_layout.fields.offset(i).bytes(), 0);
220-
assert_eq!(dst_layout.fields.offset(i).bytes(), 0);
221219
if src_f.is_zst() {
222220
continue;
223221
}
222+
223+
assert_eq!(src_layout.fields.offset(i).bytes(), 0);
224+
assert_eq!(dst_layout.fields.offset(i).bytes(), 0);
224225
assert_eq!(src_layout.size, src_f.size);
225226

226227
let dst_f = dst_layout.field(bx.cx(), i);
@@ -716,7 +717,7 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
716717
&ongoing_codegen.coordinator_send,
717718
CachedModuleCodegen {
718719
name: cgu.name().to_string(),
719-
source: cgu.work_product(tcx),
720+
source: cgu.previous_work_product(tcx),
720721
},
721722
);
722723
true
@@ -727,7 +728,7 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
727728
&ongoing_codegen.coordinator_send,
728729
CachedModuleCodegen {
729730
name: cgu.name().to_string(),
730-
source: cgu.work_product(tcx),
731+
source: cgu.previous_work_product(tcx),
731732
},
732733
);
733734
true

‎compiler/rustc_codegen_ssa/src/target_features.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,9 @@ const WASM_ALLOWED_FEATURES: &[(&str, Option<Symbol>)] = &[
246246
("simd128", None),
247247
("atomics", Some(sym::wasm_target_feature)),
248248
("nontrapping-fptoint", Some(sym::wasm_target_feature)),
249+
("bulk-memory", Some(sym::wasm_target_feature)),
250+
("mutable-globals", Some(sym::wasm_target_feature)),
251+
("reference-types", Some(sym::wasm_target_feature)),
249252
];
250253

251254
const BPF_ALLOWED_FEATURES: &[(&str, Option<Symbol>)] = &[("alu32", Some(sym::bpf_target_feature))];

‎compiler/rustc_incremental/src/persist/load.rs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -162,18 +162,16 @@ pub fn load_dep_graph(sess: &Session) -> DepGraphFuture {
162162

163163
for swp in work_products {
164164
let mut all_files_exist = true;
165-
if let Some(ref file_name) = swp.work_product.saved_file {
166-
let path = in_incr_comp_dir_sess(sess, file_name);
167-
if !path.exists() {
168-
all_files_exist = false;
169-
170-
if sess.opts.debugging_opts.incremental_info {
171-
eprintln!(
172-
"incremental: could not find file for work \
165+
let path = in_incr_comp_dir_sess(sess, &swp.work_product.saved_file);
166+
if !path.exists() {
167+
all_files_exist = false;
168+
169+
if sess.opts.debugging_opts.incremental_info {
170+
eprintln!(
171+
"incremental: could not find file for work \
173172
product: {}",
174-
path.display()
175-
);
176-
}
173+
path.display()
174+
);
177175
}
178176
}
179177

‎compiler/rustc_incremental/src/persist/save.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,20 +107,15 @@ pub fn save_work_product_index(
107107
for (id, wp) in previous_work_products.iter() {
108108
if !new_work_products.contains_key(id) {
109109
work_product::delete_workproduct_files(sess, wp);
110-
debug_assert!(
111-
wp.saved_file.as_ref().map_or(true, |file_name| {
112-
!in_incr_comp_dir_sess(sess, &file_name).exists()
113-
})
114-
);
110+
debug_assert!(!in_incr_comp_dir_sess(sess, &wp.saved_file).exists());
115111
}
116112
}
117113

118114
// Check that we did not delete one of the current work-products:
119115
debug_assert!({
120116
new_work_products
121117
.iter()
122-
.flat_map(|(_, wp)| wp.saved_file.iter())
123-
.map(|name| in_incr_comp_dir_sess(sess, name))
118+
.map(|(_, wp)| in_incr_comp_dir_sess(sess, &wp.saved_file))
124119
.all(|path| path.exists())
125120
});
126121
}

‎compiler/rustc_incremental/src/persist/work_product.rs

Lines changed: 23 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,34 +7,30 @@ use rustc_fs_util::link_or_copy;
77
use rustc_middle::dep_graph::{WorkProduct, WorkProductId};
88
use rustc_session::Session;
99
use std::fs as std_fs;
10-
use std::path::PathBuf;
10+
use std::path::Path;
1111

1212
/// Copies a CGU work product to the incremental compilation directory, so next compilation can find and reuse it.
1313
pub fn copy_cgu_workproduct_to_incr_comp_cache_dir(
1414
sess: &Session,
1515
cgu_name: &str,
16-
path: &Option<PathBuf>,
16+
path: &Path,
1717
) -> Option<(WorkProductId, WorkProduct)> {
1818
debug!("copy_cgu_workproduct_to_incr_comp_cache_dir({:?},{:?})", cgu_name, path);
1919
sess.opts.incremental.as_ref()?;
2020

21-
let saved_file = if let Some(path) = path {
22-
let file_name = format!("{}.o", cgu_name);
23-
let path_in_incr_dir = in_incr_comp_dir_sess(sess, &file_name);
24-
match link_or_copy(path, &path_in_incr_dir) {
25-
Ok(_) => Some(file_name),
26-
Err(err) => {
27-
sess.warn(&format!(
28-
"error copying object file `{}` to incremental directory as `{}`: {}",
29-
path.display(),
30-
path_in_incr_dir.display(),
31-
err
32-
));
33-
return None;
34-
}
21+
let file_name = format!("{}.o", cgu_name);
22+
let path_in_incr_dir = in_incr_comp_dir_sess(sess, &file_name);
23+
let saved_file = match link_or_copy(path, &path_in_incr_dir) {
24+
Ok(_) => file_name,
25+
Err(err) => {
26+
sess.warn(&format!(
27+
"error copying object file `{}` to incremental directory as `{}`: {}",
28+
path.display(),
29+
path_in_incr_dir.display(),
30+
err
31+
));
32+
return None;
3533
}
36-
} else {
37-
None
3834
};
3935

4036
let work_product = WorkProduct { cgu_name: cgu_name.to_string(), saved_file };
@@ -45,17 +41,15 @@ pub fn copy_cgu_workproduct_to_incr_comp_cache_dir(
4541

4642
/// Removes files for a given work product.
4743
pub fn delete_workproduct_files(sess: &Session, work_product: &WorkProduct) {
48-
if let Some(ref file_name) = work_product.saved_file {
49-
let path = in_incr_comp_dir_sess(sess, file_name);
50-
match std_fs::remove_file(&path) {
51-
Ok(()) => {}
52-
Err(err) => {
53-
sess.warn(&format!(
54-
"file-system error deleting outdated file `{}`: {}",
55-
path.display(),
56-
err
57-
));
58-
}
44+
let path = in_incr_comp_dir_sess(sess, &work_product.saved_file);
45+
match std_fs::remove_file(&path) {
46+
Ok(()) => {}
47+
Err(err) => {
48+
sess.warn(&format!(
49+
"file-system error deleting outdated file `{}`: {}",
50+
path.display(),
51+
err
52+
));
5953
}
6054
}
6155
}

‎compiler/rustc_middle/src/middle/stability.rs

Lines changed: 69 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@ use rustc_attr::{self as attr, ConstStability, Deprecation, Stability};
99
use rustc_data_structures::fx::FxHashMap;
1010
use rustc_errors::{Applicability, Diagnostic};
1111
use rustc_feature::GateIssue;
12-
use rustc_hir as hir;
1312
use rustc_hir::def::DefKind;
1413
use rustc_hir::def_id::{DefId, LocalDefId};
15-
use rustc_hir::{self, HirId};
14+
use rustc_hir::{self as hir, HirId};
1615
use rustc_middle::ty::print::with_no_trimmed_paths;
1716
use rustc_session::lint::builtin::{DEPRECATED, DEPRECATED_IN_FUTURE, SOFT_UNSTABLE};
1817
use rustc_session::lint::{BuiltinLintDiagnostics, Level, Lint, LintBuffer};
@@ -306,6 +305,14 @@ fn suggestion_for_allocator_api(
306305
None
307306
}
308307

308+
/// An override option for eval_stability.
309+
pub enum AllowUnstable {
310+
/// Don't emit an unstable error for the item
311+
Yes,
312+
/// Handle the item normally
313+
No,
314+
}
315+
309316
impl<'tcx> TyCtxt<'tcx> {
310317
/// Evaluates the stability of an item.
311318
///
@@ -322,6 +329,28 @@ impl<'tcx> TyCtxt<'tcx> {
322329
id: Option<HirId>,
323330
span: Span,
324331
method_span: Option<Span>,
332+
) -> EvalResult {
333+
self.eval_stability_allow_unstable(def_id, id, span, method_span, AllowUnstable::No)
334+
}
335+
336+
/// Evaluates the stability of an item.
337+
///
338+
/// Returns `EvalResult::Allow` if the item is stable, or unstable but the corresponding
339+
/// `#![feature]` has been provided. Returns `EvalResult::Deny` which describes the offending
340+
/// unstable feature otherwise.
341+
///
342+
/// If `id` is `Some(_)`, this function will also check if the item at `def_id` has been
343+
/// deprecated. If the item is indeed deprecated, we will emit a deprecation lint attached to
344+
/// `id`.
345+
///
346+
/// Pass `AllowUnstable::Yes` to `allow_unstable` to force an unstable item to be allowed. Deprecation warnings will be emitted normally.
347+
pub fn eval_stability_allow_unstable(
348+
self,
349+
def_id: DefId,
350+
id: Option<HirId>,
351+
span: Span,
352+
method_span: Option<Span>,
353+
allow_unstable: AllowUnstable,
325354
) -> EvalResult {
326355
// Deprecated attributes apply in-crate and cross-crate.
327356
if let Some(id) = id {
@@ -419,6 +448,10 @@ impl<'tcx> TyCtxt<'tcx> {
419448
}
420449
}
421450

451+
if matches!(allow_unstable, AllowUnstable::Yes) {
452+
return EvalResult::Allow;
453+
}
454+
422455
let suggestion = suggestion_for_allocator_api(self, def_id, span, feature);
423456
EvalResult::Deny { feature, reason, issue, suggestion, is_soft }
424457
}
@@ -445,11 +478,38 @@ impl<'tcx> TyCtxt<'tcx> {
445478
span: Span,
446479
method_span: Option<Span>,
447480
) {
448-
self.check_optional_stability(def_id, id, span, method_span, |span, def_id| {
449-
// The API could be uncallable for other reasons, for example when a private module
450-
// was referenced.
451-
self.sess.delay_span_bug(span, &format!("encountered unmarked API: {:?}", def_id));
452-
})
481+
self.check_stability_allow_unstable(def_id, id, span, method_span, AllowUnstable::No)
482+
}
483+
484+
/// Checks if an item is stable or error out.
485+
///
486+
/// If the item defined by `def_id` is unstable and the corresponding `#![feature]` does not
487+
/// exist, emits an error.
488+
///
489+
/// This function will also check if the item is deprecated.
490+
/// If so, and `id` is not `None`, a deprecated lint attached to `id` will be emitted.
491+
///
492+
/// Pass `AllowUnstable::Yes` to `allow_unstable` to force an unstable item to be allowed. Deprecation warnings will be emitted normally.
493+
pub fn check_stability_allow_unstable(
494+
self,
495+
def_id: DefId,
496+
id: Option<HirId>,
497+
span: Span,
498+
method_span: Option<Span>,
499+
allow_unstable: AllowUnstable,
500+
) {
501+
self.check_optional_stability(
502+
def_id,
503+
id,
504+
span,
505+
method_span,
506+
allow_unstable,
507+
|span, def_id| {
508+
// The API could be uncallable for other reasons, for example when a private module
509+
// was referenced.
510+
self.sess.delay_span_bug(span, &format!("encountered unmarked API: {:?}", def_id));
511+
},
512+
)
453513
}
454514

455515
/// Like `check_stability`, except that we permit items to have custom behaviour for
@@ -462,14 +522,15 @@ impl<'tcx> TyCtxt<'tcx> {
462522
id: Option<HirId>,
463523
span: Span,
464524
method_span: Option<Span>,
525+
allow_unstable: AllowUnstable,
465526
unmarked: impl FnOnce(Span, DefId),
466527
) {
467528
let soft_handler = |lint, span, msg: &_| {
468529
self.struct_span_lint_hir(lint, id.unwrap_or(hir::CRATE_HIR_ID), span, |lint| {
469530
lint.build(msg).emit();
470531
})
471532
};
472-
match self.eval_stability(def_id, id, span, method_span) {
533+
match self.eval_stability_allow_unstable(def_id, id, span, method_span, allow_unstable) {
473534
EvalResult::Allow => {}
474535
EvalResult::Deny { feature, reason, issue, suggestion, is_soft } => report_unstable(
475536
self.sess,

‎compiler/rustc_middle/src/mir/mono.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ impl<'tcx> CodegenUnit<'tcx> {
336336
WorkProductId::from_cgu_name(self.name().as_str())
337337
}
338338

339-
pub fn work_product(&self, tcx: TyCtxt<'_>) -> WorkProduct {
339+
pub fn previous_work_product(&self, tcx: TyCtxt<'_>) -> WorkProduct {
340340
let work_product_id = self.work_product_id();
341341
tcx.dep_graph
342342
.previous_work_product(&work_product_id)

‎compiler/rustc_passes/src/stability.rs

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ use rustc_hir::def::{DefKind, Res};
99
use rustc_hir::def_id::{LocalDefId, CRATE_DEF_ID};
1010
use rustc_hir::hir_id::CRATE_HIR_ID;
1111
use rustc_hir::intravisit::{self, Visitor};
12-
use rustc_hir::{FieldDef, Generics, HirId, Item, TraitRef, Ty, TyKind, Variant};
12+
use rustc_hir::{FieldDef, Generics, HirId, Item, ItemKind, TraitRef, Ty, TyKind, Variant};
1313
use rustc_middle::hir::nested_filter;
1414
use rustc_middle::middle::privacy::AccessLevels;
15-
use rustc_middle::middle::stability::{DeprecationEntry, Index};
15+
use rustc_middle::middle::stability::{AllowUnstable, DeprecationEntry, Index};
1616
use rustc_middle::ty::{self, query::Providers, TyCtxt};
1717
use rustc_session::lint;
1818
use rustc_session::lint::builtin::{INEFFECTIVE_UNSTABLE_TRAIT_IMPL, USELESS_DEPRECATED};
@@ -807,12 +807,46 @@ impl<'tcx> Visitor<'tcx> for Checker<'tcx> {
807807
fn visit_path(&mut self, path: &'tcx hir::Path<'tcx>, id: hir::HirId) {
808808
if let Some(def_id) = path.res.opt_def_id() {
809809
let method_span = path.segments.last().map(|s| s.ident.span);
810-
self.tcx.check_stability(def_id, Some(id), path.span, method_span)
810+
self.tcx.check_stability_allow_unstable(
811+
def_id,
812+
Some(id),
813+
path.span,
814+
method_span,
815+
if is_unstable_reexport(self.tcx, id) {
816+
AllowUnstable::Yes
817+
} else {
818+
AllowUnstable::No
819+
},
820+
)
811821
}
812822
intravisit::walk_path(self, path)
813823
}
814824
}
815825

826+
/// Check whether a path is a `use` item that has been marked as unstable.
827+
///
828+
/// See issue #94972 for details on why this is a special case
829+
fn is_unstable_reexport<'tcx>(tcx: TyCtxt<'tcx>, id: hir::HirId) -> bool {
830+
// Get the LocalDefId so we can lookup the item to check the kind.
831+
let Some(def_id) = tcx.hir().opt_local_def_id(id) else { return false; };
832+
833+
let Some(stab) = tcx.stability().local_stability(def_id) else {
834+
return false;
835+
};
836+
837+
if stab.level.is_stable() {
838+
// The re-export is not marked as unstable, don't override
839+
return false;
840+
}
841+
842+
// If this is a path that isn't a use, we don't need to do anything special
843+
if !matches!(tcx.hir().item(hir::ItemId { def_id }).kind, ItemKind::Use(..)) {
844+
return false;
845+
}
846+
847+
true
848+
}
849+
816850
struct CheckTraitImplStable<'tcx> {
817851
tcx: TyCtxt<'tcx>,
818852
fully_stable: bool,

‎compiler/rustc_query_system/src/dep_graph/dep_node.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,6 @@ pub struct WorkProductId {
164164
impl WorkProductId {
165165
pub fn from_cgu_name(cgu_name: &str) -> WorkProductId {
166166
let mut hasher = StableHasher::new();
167-
cgu_name.len().hash(&mut hasher);
168167
cgu_name.hash(&mut hasher);
169168
WorkProductId { hash: hasher.finish() }
170169
}

‎compiler/rustc_query_system/src/dep_graph/graph.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -887,7 +887,7 @@ impl<K: DepKind> DepGraph<K> {
887887
pub struct WorkProduct {
888888
pub cgu_name: String,
889889
/// Saved file associated with this CGU.
890-
pub saved_file: Option<String>,
890+
pub saved_file: String,
891891
}
892892

893893
// Index type for `DepNodeData`'s edges.

‎compiler/rustc_typeck/src/astconv/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ use rustc_hir::def_id::{DefId, LocalDefId};
2424
use rustc_hir::intravisit::{walk_generics, Visitor as _};
2525
use rustc_hir::lang_items::LangItem;
2626
use rustc_hir::{GenericArg, GenericArgs};
27+
use rustc_middle::middle::stability::AllowUnstable;
2728
use rustc_middle::ty::subst::{self, GenericArgKind, InternalSubsts, Subst, SubstsRef};
2829
use rustc_middle::ty::GenericParamDefKind;
2930
use rustc_middle::ty::{self, Const, DefIdTree, EarlyBinder, Ty, TyCtxt, TypeFoldable};
@@ -426,6 +427,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
426427
Some(arg.id()),
427428
arg.span(),
428429
None,
430+
AllowUnstable::No,
429431
|_, _| {
430432
// Default generic parameters may not be marked
431433
// with stability attributes, i.e. when the

‎library/std/src/sys/unix/process/process_unix.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -730,6 +730,7 @@ fn signal_string(signal: i32) -> &'static str {
730730
libc::SIGVTALRM => " (SIGVTALRM)",
731731
libc::SIGPROF => " (SIGPROF)",
732732
libc::SIGWINCH => " (SIGWINCH)",
733+
#[cfg(not(target_os = "haiku"))]
733734
libc::SIGIO => " (SIGIO)",
734735
libc::SIGSYS => " (SIGSYS)",
735736
// For information on Linux signals, run `man 7 signal`
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Allow an unstable re-export without requiring a feature gate.
2+
// #94972
3+
4+
// aux-build:lint-stability.rs
5+
// aux-build:lint-stability-reexport.rs
6+
#![feature(staged_api)]
7+
#![stable(feature = "lint_stability", since = "1.0.0")]
8+
9+
extern crate lint_stability;
10+
extern crate lint_stability_reexport;
11+
12+
#[unstable(feature = "unstable_test_feature", issue = "none")]
13+
pub use lint_stability::unstable;
14+
15+
// We want to confirm that using a re-export through another crate behaves
16+
// the same way as using an item directly
17+
#[unstable(feature = "unstable_test_feature", issue = "none")]
18+
pub use lint_stability_reexport::unstable_text;
19+
20+
// Ensure items which aren't marked as unstable can't re-export unstable items
21+
#[stable(feature = "lint_stability", since = "1.0.0")]
22+
pub use lint_stability::unstable as unstable2;
23+
//~^ ERROR use of unstable library feature 'unstable_test_feature'
24+
25+
fn main() {
26+
// Since we didn't enable the feature in this crate, we still can't
27+
// use these items, even though they're in scope from the `use`s which are now allowed.
28+
unstable(); //~ ERROR use of unstable library feature 'unstable_test_feature'
29+
unstable_text(); //~ ERROR use of unstable library feature 'unstable_test_feature'
30+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
error[E0658]: use of unstable library feature 'unstable_test_feature'
2+
--> $DIR/allow-unstable-reexport.rs:22:9
3+
|
4+
LL | pub use lint_stability::unstable as unstable2;
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable
8+
9+
error[E0658]: use of unstable library feature 'unstable_test_feature'
10+
--> $DIR/allow-unstable-reexport.rs:28:5
11+
|
12+
LL | unstable();
13+
| ^^^^^^^^
14+
|
15+
= help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable
16+
17+
error[E0658]: use of unstable library feature 'unstable_test_feature': text
18+
--> $DIR/allow-unstable-reexport.rs:29:5
19+
|
20+
LL | unstable_text();
21+
| ^^^^^^^^^^^^^
22+
|
23+
= help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable
24+
25+
error: aborting due to 3 previous errors
26+
27+
For more information about this error, try `rustc --explain E0658`.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#![crate_type = "lib"]
2+
#![feature(staged_api)]
3+
#![stable(feature = "lint_stability", since = "1.0.0")]
4+
5+
extern crate lint_stability;
6+
7+
// Re-exporting without enabling the feature "unstable_test_feature" in this crate
8+
#[unstable(feature = "unstable_test_feature", issue = "none")]
9+
pub use lint_stability::unstable_text;

‎src/test/ui/unsized/issue-97732.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// check-pass
2+
3+
#![feature(coerce_unsized)]
4+
5+
// Ensure that unsizing structs that contain ZSTs at non-zero offsets don't ICE
6+
7+
use std::ops::CoerceUnsized;
8+
9+
#[repr(C)]
10+
pub struct BoxWithZstTail<T: ?Sized>(Box<T>, ());
11+
12+
impl<S: ?Sized, T: ?Sized> CoerceUnsized<BoxWithZstTail<T>> for BoxWithZstTail<S> where
13+
Box<S>: CoerceUnsized<Box<T>>
14+
{
15+
}
16+
17+
pub fn noop_dyn_upcast_with_zst_tail(
18+
b: BoxWithZstTail<dyn ToString + Send>,
19+
) -> BoxWithZstTail<dyn ToString> {
20+
b
21+
}
22+
23+
fn main() {
24+
let original = "foo";
25+
let boxed = BoxWithZstTail(Box::new(original) as Box<dyn ToString + Send>, ());
26+
let noop_upcasted = noop_dyn_upcast_with_zst_tail(boxed);
27+
assert_eq!(original, noop_upcasted.0.to_string());
28+
}

0 commit comments

Comments
 (0)
This repository has been archived.