提交 b9cf5417 编写于 作者: B bors

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
......@@ -3541,7 +3541,6 @@ dependencies = [
"rustc_metadata",
"rustc_mir",
"rustc_parse",
"rustc_plugin",
"rustc_plugin_impl",
"rustc_resolve",
"rustc_save_analysis",
......@@ -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"
......
......@@ -1331,6 +1331,8 @@ fn parse_symbol_mangling_version(
"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],
......
......@@ -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) {
......
......@@ -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" }
......
......@@ -84,13 +84,6 @@
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(..) => {
......
......@@ -24,10 +24,6 @@
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
......@@ -391,7 +387,7 @@ fn post(&self, s: &mut pprust_hir::State<'_>, node: pprust_hir::AnnNode<'_>) {
}
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()
......
......@@ -383,6 +383,7 @@
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"),
......@@ -595,7 +596,6 @@
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
......
`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
......@@ -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"
......
......@@ -29,8 +29,8 @@
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;
......
......@@ -173,8 +173,11 @@ fn check_decl_no_pat<F: FnMut(Span, bool)>(decl: &FnDecl, mut report_err: F) {
fn check_trait_fn_not_async(&self, span: Span, asyncness: IsAsync) {
if asyncness.is_async() {
struct_span_err!(self.session, span, E0706,
"trait fns cannot be declared `async`").emit()
struct_span_err!(self.session, span, E0706, "trait fns cannot be declared `async`")
.note("`async` trait functions are not currently supported")
.note("consider using the `async-trait` crate: \
https://crates.io/crates/async-trait")
.emit();
}
}
......
[package]
authors = ["The Rust Project Developers"]
name = "rustc_plugin"
version = "0.0.0"
build = false
edition = "2018"
[lib]
name = "rustc_plugin"
path = "lib.rs"
doctest = false
[dependencies]
rustc_plugin_impl = { path = ".." }
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]
#![feature(staged_api)]
#![unstable(feature = "rustc_private", issue = "27812")]
#![rustc_deprecated(since = "1.38.0", reason = "\
import this through `rustc_driver::plugin` instead to make TLS work correctly. \
See https://github.com/rust-lang/rust/issues/62717")]
pub use rustc_plugin_impl::*;
......@@ -17,7 +17,7 @@ pub fn target() -> TargetResult {
options: TargetOptions {
linker: Some("rust-lld".to_string()),
cpu: "generic-rv32".to_string(),
max_atomic_width: None,
max_atomic_width: Some(0),
atomic_cas: false,
features: String::new(),
executables: true,
......
......@@ -17,8 +17,7 @@ pub fn target() -> TargetResult {
options: TargetOptions {
linker: Some("rust-lld".to_string()),
cpu: "generic-rv32".to_string(),
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86005
max_atomic_width: None, //Some(32),
max_atomic_width: Some(0),
atomic_cas: false,
features: "+m,+c".to_string(),
executables: true,
......
......@@ -697,10 +697,12 @@ fn write_shared(
static_files::source_serif_pro::ITALIC)?;
write(cx.dst.join("SourceSerifPro-LICENSE.md"),
static_files::source_serif_pro::LICENSE)?;
write(cx.dst.join("SourceCodePro-Regular.woff"),
write(cx.dst.join("SourceCodePro-Regular.ttf.woff"),
static_files::source_code_pro::REGULAR)?;
write(cx.dst.join("SourceCodePro-Semibold.woff"),
write(cx.dst.join("SourceCodePro-Semibold.ttf.woff"),
static_files::source_code_pro::SEMIBOLD)?;
write(cx.dst.join("SourceCodePro-It.ttf.woff"),
static_files::source_code_pro::ITALIC)?;
write(cx.dst.join("SourceCodePro-LICENSE.txt"),
static_files::source_code_pro::LICENSE)?;
write(cx.dst.join("LICENSE-MIT.txt"),
......
......@@ -23,7 +23,8 @@ included, and carry their own copyright notices and license terms:
Copyright (c) Nicolas Gallagher and Jonathan Neal.
Licensed under the MIT license (see LICENSE-MIT.txt).
* Source Code Pro (SourceCodePro-Regular.woff, SourceCodePro-Semibold.woff):
* Source Code Pro (SourceCodePro-Regular.ttf.woff,
SourceCodePro-Semibold.ttf.woff, SourceCodePro-It.ttf.woff):
Copyright 2010, 2012 Adobe Systems Incorporated (http://www.adobe.com/),
with Reserved Font Name 'Source'. All Rights Reserved. Source is a trademark
......
......@@ -39,13 +39,19 @@
font-weight: 400;
/* Avoid using locally installed font because bad versions are in circulation:
* see https://github.com/rust-lang/rust/issues/24355 */
src: url("SourceCodePro-Regular.woff") format('woff');
src: url("SourceCodePro-Regular.ttf.woff") format('woff');
}
@font-face {
font-family: 'Source Code Pro';
font-style: italic;
font-weight: 400;
src: url("SourceCodePro-It.ttf.woff") format('woff');
}
@font-face {
font-family: 'Source Code Pro';
font-style: normal;
font-weight: 600;
src: url("SourceCodePro-Semibold.woff") format('woff');
src: url("SourceCodePro-Semibold.ttf.woff") format('woff');
}
* {
......
......@@ -96,11 +96,15 @@ pub mod source_serif_pro {
/// Files related to the Source Code Pro font.
pub mod source_code_pro {
/// The file `SourceCodePro-Regular.woff`, the Regular variant of the Source Code Pro font.
pub static REGULAR: &'static [u8] = include_bytes!("static/SourceCodePro-Regular.woff");
/// The file `SourceCodePro-Regular.ttf.woff`, the Regular variant of the Source Code Pro font.
pub static REGULAR: &'static [u8] = include_bytes!("static/SourceCodePro-Regular.ttf.woff");
/// The file `SourceCodePro-Semibold.woff`, the Semibold variant of the Source Code Pro font.
pub static SEMIBOLD: &'static [u8] = include_bytes!("static/SourceCodePro-Semibold.woff");
/// The file `SourceCodePro-Semibold.ttf.woff`, the Semibold variant of the Source Code Pro
/// font.
pub static SEMIBOLD: &'static [u8] = include_bytes!("static/SourceCodePro-Semibold.ttf.woff");
/// The file `SourceCodePro-It.ttf.woff`, the Italic variant of the Source Code Pro font.
pub static ITALIC: &'static [u8] = include_bytes!("static/SourceCodePro-It.ttf.woff");
/// The file `SourceCodePro-LICENSE.txt`, the license text of the Source Code Pro font.
pub static LICENSE: &'static [u8] = include_bytes!("static/SourceCodePro-LICENSE.txt");
......
......@@ -10,7 +10,7 @@
// fallback implementation to use as well.
//
// Due to rust-lang/rust#18804, make sure this is not generic!
#[cfg(any(target_os = "linux", target_os = "fuchsia", target_os = "hermit", target_os = "redox",
#[cfg(any(target_os = "linux", target_os = "fuchsia", target_os = "redox",
target_os = "emscripten"))]
pub unsafe fn register_dtor(t: *mut u8, dtor: unsafe extern fn(*mut u8)) {
use crate::mem;
......
// edition:2018
trait T {
async fn foo() {} //~ ERROR trait fns cannot be declared `async`
async fn bar(&self) {} //~ ERROR trait fns cannot be declared `async`
}
fn main() {}
error[E0706]: trait fns cannot be declared `async`
--> $DIR/async-trait-fn.rs:3:5
|
LL | async fn foo() {}
| ^^^^^^^^^^^^^^^^^
|
= note: `async` trait functions are not currently supported
= note: consider using the `async-trait` crate: https://crates.io/crates/async-trait
error[E0706]: trait fns cannot be declared `async`
--> $DIR/async-trait-fn.rs:4:5
|
LL | async fn bar(&self) {}
| ^^^^^^^^^^^^^^^^^^^^^^
|
= note: `async` trait functions are not currently supported
= note: consider using the `async-trait` crate: https://crates.io/crates/async-trait
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0706`.
......@@ -57,7 +57,11 @@ error[E0706]: trait fns cannot be declared `async`
|
LL | async fn foo() {}
| ^^^^^^^^^^^^^^^^^
|
= note: `async` trait functions are not currently supported
= note: consider using the `async-trait` crate: https://crates.io/crates/async-trait
error: aborting due to 10 previous errors
For more information about this error, try `rustc --explain E0670`.
Some errors have detailed explanations: E0670, E0706.
For more information about an error, try `rustc --explain E0670`.
// check-pass
// This used to cause a stack overflow in the compiler.
#![feature(slice_patterns)]
fn main() {
const LARGE_SIZE: usize = 1024 * 1024;
let [..] = [0u8; LARGE_SIZE];
match [0u8; LARGE_SIZE] {
[..] => {}
}
}
error[E0004]: non-exhaustive patterns: `&[_, _, _, _]` not covered
error[E0004]: non-exhaustive patterns: `&[..]` not covered
--> $DIR/match-byte-array-patterns-2.rs:4:11
|
LL | match buf {
| ^^^ pattern `&[_, _, _, _]` not covered
| ^^^ pattern `&[..]` not covered
|
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
......
......@@ -5,6 +5,20 @@ fn main() {
let s1: &[bool; 1] = &[false; 1];
let s2: &[bool; 2] = &[false; 2];
let s3: &[bool; 3] = &[false; 3];
let s10: &[bool; 10] = &[false; 10];
match s2 {
//~^ ERROR `&[false, _]` not covered
[true, .., true] => {}
}
match s3 {
//~^ ERROR `&[false, ..]` not covered
[true, .., true] => {}
}
match s10 {
//~^ ERROR `&[false, ..]` not covered
[true, .., true] => {}
}
match s1 {
[true, ..] => {}
......@@ -16,7 +30,7 @@ fn main() {
[.., false] => {}
}
match s3 {
//~^ ERROR `&[false, _, true]` not covered
//~^ ERROR `&[false, .., true]` not covered
[true, ..] => {}
[.., false] => {}
}
......@@ -27,10 +41,6 @@ fn main() {
[.., false] => {}
}
match s3 {
//~^ ERROR `&[false, _, _]` not covered
[true, .., true] => {}
}
match s {
//~^ ERROR `&[_, ..]` not covered
[] => {}
......
error[E0004]: non-exhaustive patterns: `&[false, true]` not covered
--> $DIR/slice-patterns-exhaustiveness.rs:13:11
error[E0004]: non-exhaustive patterns: `&[false, _]` not covered
--> $DIR/slice-patterns-exhaustiveness.rs:10:11
|
LL | match s2 {
| ^^ pattern `&[false, true]` not covered
| ^^ pattern `&[false, _]` not covered
|
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
error[E0004]: non-exhaustive patterns: `&[false, _, true]` not covered
--> $DIR/slice-patterns-exhaustiveness.rs:18:11
error[E0004]: non-exhaustive patterns: `&[false, ..]` not covered
--> $DIR/slice-patterns-exhaustiveness.rs:14:11
|
LL | match s3 {
| ^^ pattern `&[false, _, true]` not covered
| ^^ pattern `&[false, ..]` not covered
|
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
error[E0004]: non-exhaustive patterns: `&[false, .., true]` not covered
--> $DIR/slice-patterns-exhaustiveness.rs:23:11
error[E0004]: non-exhaustive patterns: `&[false, ..]` not covered
--> $DIR/slice-patterns-exhaustiveness.rs:18:11
|
LL | match s {
| ^ pattern `&[false, .., true]` not covered
LL | match s10 {
| ^^^ pattern `&[false, ..]` not covered
|
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
error[E0004]: non-exhaustive patterns: `&[false, true]` not covered
--> $DIR/slice-patterns-exhaustiveness.rs:27:11
|
LL | match s2 {
| ^^ pattern `&[false, true]` not covered
|
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
error[E0004]: non-exhaustive patterns: `&[false, _, _]` not covered
--> $DIR/slice-patterns-exhaustiveness.rs:30:11
error[E0004]: non-exhaustive patterns: `&[false, .., true]` not covered
--> $DIR/slice-patterns-exhaustiveness.rs:32:11
|
LL | match s3 {
| ^^ pattern `&[false, _, _]` not covered
| ^^ pattern `&[false, .., true]` not covered
|
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
error[E0004]: non-exhaustive patterns: `&[false, .., true]` not covered
--> $DIR/slice-patterns-exhaustiveness.rs:37:11
|
LL | match s {
| ^ pattern `&[false, .., true]` not covered
|
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
error[E0004]: non-exhaustive patterns: `&[_, ..]` not covered
--> $DIR/slice-patterns-exhaustiveness.rs:34:11
--> $DIR/slice-patterns-exhaustiveness.rs:44:11
|
LL | match s {
| ^ pattern `&[_, ..]` not covered
......@@ -39,7 +55,7 @@ LL | match s {
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
error[E0004]: non-exhaustive patterns: `&[_, _, ..]` not covered
--> $DIR/slice-patterns-exhaustiveness.rs:38:11
--> $DIR/slice-patterns-exhaustiveness.rs:48:11
|
LL | match s {
| ^ pattern `&[_, _, ..]` not covered
......@@ -47,7 +63,7 @@ LL | match s {
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
error[E0004]: non-exhaustive patterns: `&[false, ..]` not covered
--> $DIR/slice-patterns-exhaustiveness.rs:43:11
--> $DIR/slice-patterns-exhaustiveness.rs:53:11
|
LL | match s {
| ^ pattern `&[false, ..]` not covered
......@@ -55,7 +71,7 @@ LL | match s {
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
error[E0004]: non-exhaustive patterns: `&[false, _, ..]` not covered
--> $DIR/slice-patterns-exhaustiveness.rs:48:11
--> $DIR/slice-patterns-exhaustiveness.rs:58:11
|
LL | match s {
| ^ pattern `&[false, _, ..]` not covered
......@@ -63,7 +79,7 @@ LL | match s {
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
error[E0004]: non-exhaustive patterns: `&[_, .., false]` not covered
--> $DIR/slice-patterns-exhaustiveness.rs:54:11
--> $DIR/slice-patterns-exhaustiveness.rs:64:11
|
LL | match s {
| ^ pattern `&[_, .., false]` not covered
......@@ -71,7 +87,7 @@ LL | match s {
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
error[E0004]: non-exhaustive patterns: `&[_, _, .., true]` not covered
--> $DIR/slice-patterns-exhaustiveness.rs:61:11
--> $DIR/slice-patterns-exhaustiveness.rs:71:11
|
LL | match s {
| ^ pattern `&[_, _, .., true]` not covered
......@@ -79,13 +95,13 @@ LL | match s {
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
error[E0004]: non-exhaustive patterns: `&[true, _, .., _]` not covered
--> $DIR/slice-patterns-exhaustiveness.rs:68:11
--> $DIR/slice-patterns-exhaustiveness.rs:78:11
|
LL | match s {
| ^ pattern `&[true, _, .., _]` not covered
|
= help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
error: aborting due to 11 previous errors
error: aborting due to 13 previous errors
For more information about this error, try `rustc --explain E0004`.
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册