Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit a74d186

Browse files
committed
Auto merge of rust-lang#72202 - Dylan-DPC:rollup-6lbxh1s, r=Dylan-DPC
Rollup of 8 pull requests Successful merges: - rust-lang#71910 (Fix unused_parens false positive when using binary operations) - rust-lang#72087 (Fix hang in lexical_region_resolve) - rust-lang#72126 (Change `WorkProduct::saved_files` to an `Option`.) - rust-lang#72127 (add long error explanation for E0228) - rust-lang#72141 (Warn against thread::sleep in async fn) - rust-lang#72170 (use `require_lang_item` over `unwrap`.) - rust-lang#72191 (Clean up E0589 explanation) - rust-lang#72194 (Don't ICE on missing `Unsize` impl) Failed merges: r? @ghost
2 parents af6d886 + 7b5bc61 commit a74d186

File tree

35 files changed

+246
-86
lines changed

35 files changed

+246
-86
lines changed

src/librustc_codegen_ssa/back/write.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use rustc_errors::{DiagnosticId, FatalError, Handler, Level};
2121
use rustc_fs_util::link_or_copy;
2222
use rustc_hir::def_id::{CrateNum, LOCAL_CRATE};
2323
use rustc_incremental::{
24-
copy_cgu_workproducts_to_incr_comp_cache_dir, in_incr_comp_dir, in_incr_comp_dir_sess,
24+
copy_cgu_workproduct_to_incr_comp_cache_dir, in_incr_comp_dir, in_incr_comp_dir_sess,
2525
};
2626
use rustc_middle::dep_graph::{WorkProduct, WorkProductId};
2727
use rustc_middle::middle::cstore::EncodedMetadata;
@@ -465,17 +465,13 @@ fn copy_all_cgu_workproducts_to_incr_comp_cache_dir(
465465
return work_products;
466466
}
467467

468-
let _timer = sess.timer("incr_comp_copy_cgu_workproducts");
468+
let _timer = sess.timer("copy_all_cgu_workproducts_to_incr_comp_cache_dir");
469469

470470
for module in compiled_modules.modules.iter().filter(|m| m.kind == ModuleKind::Regular) {
471-
let mut files = vec![];
472-
473-
if let Some(ref path) = module.object {
474-
files.push(path.clone());
475-
}
471+
let path = module.object.as_ref().map(|path| path.clone());
476472

477473
if let Some((id, product)) =
478-
copy_cgu_workproducts_to_incr_comp_cache_dir(sess, &module.name, &files)
474+
copy_cgu_workproduct_to_incr_comp_cache_dir(sess, &module.name, &path)
479475
{
480476
work_products.insert(id, product);
481477
}
@@ -817,7 +813,7 @@ fn execute_copy_from_cache_work_item<B: ExtraBackendMethods>(
817813
) -> Result<WorkItemResult<B>, FatalError> {
818814
let incr_comp_session_dir = cgcx.incr_comp_session_dir.as_ref().unwrap();
819815
let mut object = None;
820-
for saved_file in &module.source.saved_files {
816+
if let Some(saved_file) = module.source.saved_file {
821817
let obj_out = cgcx.output_filenames.temp_path(OutputType::Object, Some(&module.name));
822818
object = Some(obj_out.clone());
823819
let source_file = in_incr_comp_dir(&incr_comp_session_dir, &saved_file);

src/librustc_error_codes/error_codes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ E0223: include_str!("./error_codes/E0223.md"),
120120
E0224: include_str!("./error_codes/E0224.md"),
121121
E0225: include_str!("./error_codes/E0225.md"),
122122
E0226: include_str!("./error_codes/E0226.md"),
123+
E0228: include_str!("./error_codes/E0228.md"),
123124
E0229: include_str!("./error_codes/E0229.md"),
124125
E0230: include_str!("./error_codes/E0230.md"),
125126
E0231: include_str!("./error_codes/E0231.md"),
@@ -482,7 +483,6 @@ E0753: include_str!("./error_codes/E0753.md"),
482483
// E0218, // no associated type defined
483484
// E0219, // associated type defined in higher-ranked supertrait
484485
E0227, // ambiguous lifetime bound, explicit lifetime bound required
485-
E0228, // explicit lifetime bound required
486486
// E0233,
487487
// E0234,
488488
// E0235, // structure constructor specifies a structure of type but
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
The lifetime bound for this object type cannot be deduced from context and must
2+
be specified.
3+
4+
Erroneous code example:
5+
6+
```compile_fail,E0228
7+
trait Trait { }
8+
9+
struct TwoBounds<'a, 'b, T: Sized + 'a + 'b> {
10+
x: &'a i32,
11+
y: &'b i32,
12+
z: T,
13+
}
14+
15+
type Foo<'a, 'b> = TwoBounds<'a, 'b, dyn Trait>;
16+
```
17+
18+
When a trait object is used as a type argument of a generic type, Rust will try
19+
to infer its lifetime if unspecified. However, this isn't possible when the
20+
containing type has more than one lifetime bound.
21+
22+
The above example can be resolved by either reducing the number of lifetime
23+
bounds to one or by making the trait object lifetime explicit, like so:
24+
25+
```
26+
trait Trait { }
27+
28+
struct TwoBounds<'a, 'b, T: Sized + 'a + 'b> {
29+
x: &'a i32,
30+
y: &'b i32,
31+
z: T,
32+
}
33+
34+
type Foo<'a, 'b> = TwoBounds<'a, 'b, dyn Trait + 'b>;
35+
```
36+
37+
For more information, see [RFC 599] and its amendment [RFC 1156].
38+
39+
[RFC 599]: https://github.com/rust-lang/rfcs/blob/master/text/0599-default-object-bound.md
40+
[RFC 1156]: https://github.com/rust-lang/rfcs/blob/master/text/1156-adjust-default-object-bounds.md

src/librustc_error_codes/error_codes/E0589.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
The value of `N` that was specified for `repr(align(N))` was not a power
22
of two, or was greater than 2^29.
33

4+
Erroneous code example:
5+
46
```compile_fail,E0589
57
#[repr(align(15))] // error: invalid `repr(align)` attribute: not a power of two
68
enum Foo {

src/librustc_incremental/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub mod assert_module_sources;
1515
mod persist;
1616

1717
pub use assert_dep_graph::assert_dep_graph;
18-
pub use persist::copy_cgu_workproducts_to_incr_comp_cache_dir;
18+
pub use persist::copy_cgu_workproduct_to_incr_comp_cache_dir;
1919
pub use persist::delete_workproduct_files;
2020
pub use persist::dep_graph_tcx_init;
2121
pub use persist::finalize_session_directory;

src/librustc_incremental/persist/load.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ pub fn load_dep_graph(sess: &Session) -> DepGraphFuture {
134134

135135
for swp in work_products {
136136
let mut all_files_exist = true;
137-
for file_name in swp.work_product.saved_files.iter() {
137+
if let Some(ref file_name) = swp.work_product.saved_file {
138138
let path = in_incr_comp_dir_sess(sess, file_name);
139139
if !path.exists() {
140140
all_files_exist = false;

src/librustc_incremental/persist/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ pub use load::LoadResult;
2121
pub use load::{load_dep_graph, DepGraphFuture};
2222
pub use save::save_dep_graph;
2323
pub use save::save_work_product_index;
24-
pub use work_product::copy_cgu_workproducts_to_incr_comp_cache_dir;
24+
pub use work_product::copy_cgu_workproduct_to_incr_comp_cache_dir;
2525
pub use work_product::delete_workproduct_files;

src/librustc_incremental/persist/save.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ pub fn save_work_product_index(
7474
if !new_work_products.contains_key(id) {
7575
work_product::delete_workproduct_files(sess, wp);
7676
debug_assert!(
77-
wp.saved_files
78-
.iter()
79-
.all(|file_name| { !in_incr_comp_dir_sess(sess, file_name).exists() })
77+
wp.saved_file.as_ref().map_or(true, |file_name| {
78+
!in_incr_comp_dir_sess(sess, &file_name).exists()
79+
})
8080
);
8181
}
8282
}
@@ -85,7 +85,7 @@ pub fn save_work_product_index(
8585
debug_assert!({
8686
new_work_products
8787
.iter()
88-
.flat_map(|(_, wp)| wp.saved_files.iter())
88+
.flat_map(|(_, wp)| wp.saved_file.iter())
8989
.map(|name| in_incr_comp_dir_sess(sess, name))
9090
.all(|path| path.exists())
9191
});

src/librustc_incremental/persist/work_product.rs

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,43 +7,41 @@ use rustc_session::Session;
77
use std::fs as std_fs;
88
use std::path::PathBuf;
99

10-
pub fn copy_cgu_workproducts_to_incr_comp_cache_dir(
10+
pub fn copy_cgu_workproduct_to_incr_comp_cache_dir(
1111
sess: &Session,
1212
cgu_name: &str,
13-
files: &[PathBuf],
13+
path: &Option<PathBuf>,
1414
) -> Option<(WorkProductId, WorkProduct)> {
15-
debug!("copy_cgu_workproducts_to_incr_comp_cache_dir({:?},{:?})", cgu_name, files);
15+
debug!("copy_cgu_workproduct_to_incr_comp_cache_dir({:?},{:?})", cgu_name, path);
1616
sess.opts.incremental.as_ref()?;
1717

18-
let saved_files = files
19-
.iter()
20-
.map(|path| {
21-
let file_name = format!("{}.o", cgu_name);
22-
let path_in_incr_dir = in_incr_comp_dir_sess(sess, &file_name);
23-
match link_or_copy(path, &path_in_incr_dir) {
24-
Ok(_) => Some(file_name),
25-
Err(err) => {
26-
sess.warn(&format!(
27-
"error copying object file `{}` \
28-
to incremental directory as `{}`: {}",
29-
path.display(),
30-
path_in_incr_dir.display(),
31-
err
32-
));
33-
None
34-
}
18+
let saved_file = if let Some(path) = path {
19+
let file_name = format!("{}.o", cgu_name);
20+
let path_in_incr_dir = in_incr_comp_dir_sess(sess, &file_name);
21+
match link_or_copy(path, &path_in_incr_dir) {
22+
Ok(_) => Some(file_name),
23+
Err(err) => {
24+
sess.warn(&format!(
25+
"error copying object file `{}` to incremental directory as `{}`: {}",
26+
path.display(),
27+
path_in_incr_dir.display(),
28+
err
29+
));
30+
return None;
3531
}
36-
})
37-
.collect::<Option<Vec<_>>>()?;
32+
}
33+
} else {
34+
None
35+
};
3836

39-
let work_product = WorkProduct { cgu_name: cgu_name.to_string(), saved_files };
37+
let work_product = WorkProduct { cgu_name: cgu_name.to_string(), saved_file };
4038

4139
let work_product_id = WorkProductId::from_cgu_name(cgu_name);
4240
Some((work_product_id, work_product))
4341
}
4442

4543
pub fn delete_workproduct_files(sess: &Session, work_product: &WorkProduct) {
46-
for file_name in &work_product.saved_files {
44+
if let Some(ref file_name) = work_product.saved_file {
4745
let path = in_incr_comp_dir_sess(sess, file_name);
4846
match std_fs::remove_file(&path) {
4947
Ok(()) => {}

src/librustc_infer/infer/lexical_region_resolve/mod.rs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -325,8 +325,21 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
325325
}
326326
}
327327

328-
debug!("enforce_member_constraint: final least choice = {:?}", least_choice);
329-
if least_choice != member_lower_bound {
328+
// (#72087) Different `ty::Regions` can be known to be equal, for
329+
// example, we know that `'a` and `'static` are equal in a function
330+
// with a parameter of type `&'static &'a ()`.
331+
//
332+
// When we have two equal regions like this `expansion` will use
333+
// `lub_concrete_regions` to pick a canonical representative. The same
334+
// choice is needed here so that we don't end up in a cycle of
335+
// `expansion` changing the region one way and the code here changing
336+
// it back.
337+
let lub = self.lub_concrete_regions(least_choice, member_lower_bound);
338+
debug!(
339+
"enforce_member_constraint: final least choice = {:?}\nlub = {:?}",
340+
least_choice, lub
341+
);
342+
if lub != member_lower_bound {
330343
*var_values.value_mut(member_vid) = VarValue::Value(least_choice);
331344
true
332345
} else {
@@ -578,8 +591,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
578591
self.tcx().mk_region(ReScope(lub))
579592
}
580593

581-
(&ReEarlyBound(_), &ReEarlyBound(_) | &ReFree(_))
582-
| (&ReFree(_), &ReEarlyBound(_) | &ReFree(_)) => {
594+
(&ReEarlyBound(_) | &ReFree(_), &ReEarlyBound(_) | &ReFree(_)) => {
583595
self.region_rels.lub_free_regions(a, b)
584596
}
585597

0 commit comments

Comments
 (0)