Skip to content

Commit

Permalink
Auto merge of #66571 - Centril:rollup-41tn2fw, r=Centril
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bors committed Nov 20, 2019
2 parents ea540b0 + ebd0ef9 commit b9cf541
Show file tree
Hide file tree
Showing 38 changed files with 426 additions and 203 deletions.
8 changes: 0 additions & 8 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3541,7 +3541,6 @@ dependencies = [
"rustc_metadata",
"rustc_mir",
"rustc_parse",
"rustc_plugin",
"rustc_plugin_impl",
"rustc_resolve",
"rustc_save_analysis",
Expand Down Expand Up @@ -3770,13 +3769,6 @@ dependencies = [
"syntax_pos",
]

[[package]]
name = "rustc_plugin"
version = "0.0.0"
dependencies = [
"rustc_plugin_impl",
]

[[package]]
name = "rustc_plugin_impl"
version = "0.0.0"
Expand Down
2 changes: 2 additions & 0 deletions src/librustc/session/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1331,6 +1331,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
"for every macro invocation, print its name and arguments"),
debug_macros: bool = (false, parse_bool, [TRACKED],
"emit line numbers debug info inside macros"),
generate_arange_section: bool = (true, parse_bool, [TRACKED],
"generate DWARF address ranges for faster lookups"),
keep_hygiene_data: bool = (false, parse_bool, [UNTRACKED],
"don't clear the hygiene data after analysis"),
keep_ast: bool = (false, parse_bool, [UNTRACKED],
Expand Down
3 changes: 3 additions & 0 deletions src/librustc_codegen_llvm/llvm_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ unsafe fn configure_llvm(sess: &Session) {
if sess.opts.debugging_opts.disable_instrumentation_preinliner {
add("-disable-preinline");
}
if sess.opts.debugging_opts.generate_arange_section {
add("-generate-arange-section");
}
if get_major_version() >= 8 {
match sess.opts.debugging_opts.merge_functions
.unwrap_or(sess.target.target.options.merge_functions) {
Expand Down
3 changes: 1 addition & 2 deletions src/librustc_driver/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ errors = { path = "../librustc_errors", package = "rustc_errors" }
rustc_metadata = { path = "../librustc_metadata" }
rustc_mir = { path = "../librustc_mir" }
rustc_parse = { path = "../librustc_parse" }
rustc_plugin = { path = "../librustc_plugin/deprecated" } # To get this in the sysroot
rustc_plugin_impl = { path = "../librustc_plugin" }
rustc_plugin_impl = { path = "../librustc_plugin_impl" }
rustc_save_analysis = { path = "../librustc_save_analysis" }
rustc_codegen_utils = { path = "../librustc_codegen_utils" }
rustc_error_codes = { path = "../librustc_error_codes" }
Expand Down
7 changes: 0 additions & 7 deletions src/librustc_driver/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,6 @@ const ICE_REPORT_COMPILER_FLAGS_EXCLUDE: &[&str] = &["metadata", "extra-filename

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

pub fn source_name(input: &Input) -> FileName {
match *input {
Input::File(ref ifile) => ifile.clone().into(),
Input::Str { ref name, .. } => name.clone(),
}
}

pub fn abort_on_err<T>(result: Result<T, ErrorReported>, sess: &Session) -> T {
match result {
Err(..) => {
Expand Down
6 changes: 1 addition & 5 deletions src/librustc_driver/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ pub use self::PpSourceMode::*;
pub use self::PpMode::*;
use crate::abort_on_err;

use crate::source_name;



// This slightly awkward construction is to allow for each PpMode to
// choose whether it needs to do analyses (which can consume the
// Session) and then pass through the session (now attached to the
Expand Down Expand Up @@ -391,7 +387,7 @@ impl<'a, 'tcx> pprust_hir::PpAnn for TypedAnnotation<'a, 'tcx> {
}

fn get_source(input: &Input, sess: &Session) -> (String, FileName) {
let src_name = source_name(input);
let src_name = input.source_name();
let src = String::clone(&sess.source_map()
.get_source_file(&src_name)
.unwrap()
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_error_codes/error_codes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ E0700: include_str!("./error_codes/E0700.md"),
E0701: include_str!("./error_codes/E0701.md"),
E0704: include_str!("./error_codes/E0704.md"),
E0705: include_str!("./error_codes/E0705.md"),
E0706: include_str!("./error_codes/E0706.md"),
E0712: include_str!("./error_codes/E0712.md"),
E0713: include_str!("./error_codes/E0713.md"),
E0714: include_str!("./error_codes/E0714.md"),
Expand Down Expand Up @@ -595,7 +596,6 @@ E0744: include_str!("./error_codes/E0744.md"),
E0696, // `continue` pointing to a labeled block
// E0702, // replaced with a generic attribute input check
E0703, // invalid ABI
E0706, // `async fn` in trait
// E0707, // multiple elided lifetimes used in arguments of `async fn`
E0708, // `async` non-`move` closures with parameters are not currently
// supported
Expand Down
57 changes: 57 additions & 0 deletions src/librustc_error_codes/error_codes/E0706.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
`async fn`s are not yet supported in traits in Rust.

Erroneous code example:

```compile_fail,edition2018
trait T {
// Neither case is currently supported.
async fn foo() {}
async fn bar(&self) {}
}
```

`async fn`s return an `impl Future`, making the following two examples equivalent:

```edition2018,ignore (example-of-desugaring-equivalence)
async fn foo() -> User {
unimplemented!()
}
// The async fn above gets desugared as follows:
fn foo(&self) -> impl Future<Output = User> + '_ {
unimplemented!()
}
```

But when it comes to supporting this in traits, there are [a few implementation
issues][async-is-hard]. One of them is returning `impl Trait` in traits is not supported,
as it would require [Generic Associated Types] to be supported:

```edition2018,ignore (example-of-desugaring-equivalence)
impl MyDatabase {
async fn get_user(&self) -> User {
unimplemented!()
}
}
impl MyDatabase {
fn get_user(&self) -> impl Future<Output = User> + '_ {
unimplemented!()
}
}
```

Until these issues are resolved, you can use the [`async-trait` crate], allowing you to use
`async fn` in traits by desugaring to "boxed futures"
(`Pin<Box<dyn Future + Send + 'async>>`).

Note that using these trait methods will result in a heap allocation per-function-call. This is not
a significant cost for the vast majority of applications, but should be considered when deciding
whether to use this functionality in the public API of a low-level function that is expected to be
called millions of times a second.

You might be interested in visiting the [async book] for further information.

[`async-trait` crate]: https://crates.io/crates/async-trait
[async-is-hard]: https://smallcultfollowing.com/babysteps/blog/2019/10/26/async-fn-in-traits-are-hard/
[Generic Associated Types]: https://github.com/rust-lang/rust/issues/44265
[async book]: https://rust-lang.github.io/async-book/07_workarounds/06_async_in_traits.html
2 changes: 1 addition & 1 deletion src/librustc_interface/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ rustc_passes = { path = "../librustc_passes" }
rustc_typeck = { path = "../librustc_typeck" }
rustc_lint = { path = "../librustc_lint" }
rustc_errors = { path = "../librustc_errors" }
rustc_plugin = { path = "../librustc_plugin", package = "rustc_plugin_impl" }
rustc_plugin_impl = { path = "../librustc_plugin_impl" }
rustc_privacy = { path = "../librustc_privacy" }
rustc_resolve = { path = "../librustc_resolve" }
tempfile = "3.0.5"
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_interface/passes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ use rustc_metadata::cstore;
use rustc_mir as mir;
use rustc_parse::{parse_crate_from_file, parse_crate_from_source_str};
use rustc_passes::{self, ast_validation, hir_stats, layout_test};
use rustc_plugin as plugin;
use rustc_plugin::registry::Registry;
use rustc_plugin_impl as plugin;
use rustc_plugin_impl::registry::Registry;
use rustc_privacy;
use rustc_resolve::{Resolver, ResolverArenas};
use rustc_traits;
Expand Down
Loading

0 comments on commit b9cf541

Please sign in to comment.