Skip to content

Commit b9cf541

Browse files
committed
Auto merge of #66571 - Centril:rollup-41tn2fw, r=Centril
Rollup of 8 pull requests Successful merges: - #65665 (Update Source Code Pro and include italics) - #66478 (rustc_plugin: Remove the compatibility shim) - #66497 (Fix #53820) - #66526 (Add more context to `async fn` trait error) - #66532 (Generate DWARF address ranges for faster lookups) - #66546 (Remove duplicate function) - #66548 ([RISCV] Disable Atomics on all Non-A RISC-V targets) - #66553 (remove HermitCore leftovers from sys/unix) Failed merges: r? @ghost
2 parents ea540b0 + ebd0ef9 commit b9cf541

38 files changed

+426
-203
lines changed

Cargo.lock

-8
Original file line numberDiff line numberDiff line change
@@ -3541,7 +3541,6 @@ dependencies = [
35413541
"rustc_metadata",
35423542
"rustc_mir",
35433543
"rustc_parse",
3544-
"rustc_plugin",
35453544
"rustc_plugin_impl",
35463545
"rustc_resolve",
35473546
"rustc_save_analysis",
@@ -3770,13 +3769,6 @@ dependencies = [
37703769
"syntax_pos",
37713770
]
37723771

3773-
[[package]]
3774-
name = "rustc_plugin"
3775-
version = "0.0.0"
3776-
dependencies = [
3777-
"rustc_plugin_impl",
3778-
]
3779-
37803772
[[package]]
37813773
name = "rustc_plugin_impl"
37823774
version = "0.0.0"

src/librustc/session/config.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1331,6 +1331,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
13311331
"for every macro invocation, print its name and arguments"),
13321332
debug_macros: bool = (false, parse_bool, [TRACKED],
13331333
"emit line numbers debug info inside macros"),
1334+
generate_arange_section: bool = (true, parse_bool, [TRACKED],
1335+
"generate DWARF address ranges for faster lookups"),
13341336
keep_hygiene_data: bool = (false, parse_bool, [UNTRACKED],
13351337
"don't clear the hygiene data after analysis"),
13361338
keep_ast: bool = (false, parse_bool, [UNTRACKED],

src/librustc_codegen_llvm/llvm_util.rs

+3
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ unsafe fn configure_llvm(sess: &Session) {
6262
if sess.opts.debugging_opts.disable_instrumentation_preinliner {
6363
add("-disable-preinline");
6464
}
65+
if sess.opts.debugging_opts.generate_arange_section {
66+
add("-generate-arange-section");
67+
}
6568
if get_major_version() >= 8 {
6669
match sess.opts.debugging_opts.merge_functions
6770
.unwrap_or(sess.target.target.options.merge_functions) {

src/librustc_driver/Cargo.toml

+1-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ errors = { path = "../librustc_errors", package = "rustc_errors" }
2222
rustc_metadata = { path = "../librustc_metadata" }
2323
rustc_mir = { path = "../librustc_mir" }
2424
rustc_parse = { path = "../librustc_parse" }
25-
rustc_plugin = { path = "../librustc_plugin/deprecated" } # To get this in the sysroot
26-
rustc_plugin_impl = { path = "../librustc_plugin" }
25+
rustc_plugin_impl = { path = "../librustc_plugin_impl" }
2726
rustc_save_analysis = { path = "../librustc_save_analysis" }
2827
rustc_codegen_utils = { path = "../librustc_codegen_utils" }
2928
rustc_error_codes = { path = "../librustc_error_codes" }

src/librustc_driver/lib.rs

-7
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,6 @@ const ICE_REPORT_COMPILER_FLAGS_EXCLUDE: &[&str] = &["metadata", "extra-filename
8484

8585
const ICE_REPORT_COMPILER_FLAGS_STRIP_VALUE: &[&str] = &["incremental"];
8686

87-
pub fn source_name(input: &Input) -> FileName {
88-
match *input {
89-
Input::File(ref ifile) => ifile.clone().into(),
90-
Input::Str { ref name, .. } => name.clone(),
91-
}
92-
}
93-
9487
pub fn abort_on_err<T>(result: Result<T, ErrorReported>, sess: &Session) -> T {
9588
match result {
9689
Err(..) => {

src/librustc_driver/pretty.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@ pub use self::PpSourceMode::*;
2424
pub use self::PpMode::*;
2525
use crate::abort_on_err;
2626

27-
use crate::source_name;
28-
29-
30-
3127
// This slightly awkward construction is to allow for each PpMode to
3228
// choose whether it needs to do analyses (which can consume the
3329
// Session) and then pass through the session (now attached to the
@@ -391,7 +387,7 @@ impl<'a, 'tcx> pprust_hir::PpAnn for TypedAnnotation<'a, 'tcx> {
391387
}
392388

393389
fn get_source(input: &Input, sess: &Session) -> (String, FileName) {
394-
let src_name = source_name(input);
390+
let src_name = input.source_name();
395391
let src = String::clone(&sess.source_map()
396392
.get_source_file(&src_name)
397393
.unwrap()

src/librustc_error_codes/error_codes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,7 @@ E0700: include_str!("./error_codes/E0700.md"),
383383
E0701: include_str!("./error_codes/E0701.md"),
384384
E0704: include_str!("./error_codes/E0704.md"),
385385
E0705: include_str!("./error_codes/E0705.md"),
386+
E0706: include_str!("./error_codes/E0706.md"),
386387
E0712: include_str!("./error_codes/E0712.md"),
387388
E0713: include_str!("./error_codes/E0713.md"),
388389
E0714: include_str!("./error_codes/E0714.md"),
@@ -595,7 +596,6 @@ E0744: include_str!("./error_codes/E0744.md"),
595596
E0696, // `continue` pointing to a labeled block
596597
// E0702, // replaced with a generic attribute input check
597598
E0703, // invalid ABI
598-
E0706, // `async fn` in trait
599599
// E0707, // multiple elided lifetimes used in arguments of `async fn`
600600
E0708, // `async` non-`move` closures with parameters are not currently
601601
// supported
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
`async fn`s are not yet supported in traits in Rust.
2+
3+
Erroneous code example:
4+
5+
```compile_fail,edition2018
6+
trait T {
7+
// Neither case is currently supported.
8+
async fn foo() {}
9+
async fn bar(&self) {}
10+
}
11+
```
12+
13+
`async fn`s return an `impl Future`, making the following two examples equivalent:
14+
15+
```edition2018,ignore (example-of-desugaring-equivalence)
16+
async fn foo() -> User {
17+
unimplemented!()
18+
}
19+
// The async fn above gets desugared as follows:
20+
fn foo(&self) -> impl Future<Output = User> + '_ {
21+
unimplemented!()
22+
}
23+
```
24+
25+
But when it comes to supporting this in traits, there are [a few implementation
26+
issues][async-is-hard]. One of them is returning `impl Trait` in traits is not supported,
27+
as it would require [Generic Associated Types] to be supported:
28+
29+
```edition2018,ignore (example-of-desugaring-equivalence)
30+
impl MyDatabase {
31+
async fn get_user(&self) -> User {
32+
unimplemented!()
33+
}
34+
}
35+
36+
impl MyDatabase {
37+
fn get_user(&self) -> impl Future<Output = User> + '_ {
38+
unimplemented!()
39+
}
40+
}
41+
```
42+
43+
Until these issues are resolved, you can use the [`async-trait` crate], allowing you to use
44+
`async fn` in traits by desugaring to "boxed futures"
45+
(`Pin<Box<dyn Future + Send + 'async>>`).
46+
47+
Note that using these trait methods will result in a heap allocation per-function-call. This is not
48+
a significant cost for the vast majority of applications, but should be considered when deciding
49+
whether to use this functionality in the public API of a low-level function that is expected to be
50+
called millions of times a second.
51+
52+
You might be interested in visiting the [async book] for further information.
53+
54+
[`async-trait` crate]: https://crates.io/crates/async-trait
55+
[async-is-hard]: https://smallcultfollowing.com/babysteps/blog/2019/10/26/async-fn-in-traits-are-hard/
56+
[Generic Associated Types]: https://github.com/rust-lang/rust/issues/44265
57+
[async book]: https://rust-lang.github.io/async-book/07_workarounds/06_async_in_traits.html

src/librustc_interface/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ rustc_passes = { path = "../librustc_passes" }
3131
rustc_typeck = { path = "../librustc_typeck" }
3232
rustc_lint = { path = "../librustc_lint" }
3333
rustc_errors = { path = "../librustc_errors" }
34-
rustc_plugin = { path = "../librustc_plugin", package = "rustc_plugin_impl" }
34+
rustc_plugin_impl = { path = "../librustc_plugin_impl" }
3535
rustc_privacy = { path = "../librustc_privacy" }
3636
rustc_resolve = { path = "../librustc_resolve" }
3737
tempfile = "3.0.5"

src/librustc_interface/passes.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ use rustc_metadata::cstore;
2929
use rustc_mir as mir;
3030
use rustc_parse::{parse_crate_from_file, parse_crate_from_source_str};
3131
use rustc_passes::{self, ast_validation, hir_stats, layout_test};
32-
use rustc_plugin as plugin;
33-
use rustc_plugin::registry::Registry;
32+
use rustc_plugin_impl as plugin;
33+
use rustc_plugin_impl::registry::Registry;
3434
use rustc_privacy;
3535
use rustc_resolve::{Resolver, ResolverArenas};
3636
use rustc_traits;

0 commit comments

Comments
 (0)