Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 14 pull requests #65716

Merged
merged 43 commits into from
Oct 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
cabcd99
Mention keyword closing policy
Oct 2, 2019
59ce359
Fix typo
Oct 2, 2019
77f0aaf
Add more coherence tests
weiznich Oct 12, 2019
b9bca18
Replaced warn attibute by deny
Oct 17, 2019
43b5dca
Replaced warn attribute by deny
Oct 17, 2019
46a4466
Replaced pretty-json error-format with only json
Oct 17, 2019
a1387e3
Replaced pretty-json error-format with only json
Oct 17, 2019
95d98af
Added text after error messages
Oct 18, 2019
1c85b45
Apply suggested wording
Oct 18, 2019
7e17ea3
Fix test paths
weiznich Oct 19, 2019
1e2b711
fix WASI sleep impl
newpavlov Oct 20, 2019
429f91c
Add long error explanation for E0588
GuillaumeGomez Oct 19, 2019
2541d49
Update ui tests
GuillaumeGomez Oct 19, 2019
8774484
Add option to disable keyboard shortcuts in docs
GuillaumeGomez Oct 21, 2019
cde60e8
Add long error explanation for E0728
JohnTitor Oct 21, 2019
4fcc784
Apply suggestions
JohnTitor Oct 22, 2019
3f1af90
Code cleanups following up on #65576.
sunfishcode Oct 22, 2019
40f92b3
refactor maybe_append
yjhmelody Oct 22, 2019
a239c8d
Add test for issue-41366
JohnTitor Oct 22, 2019
dd0f98b
Add test for issue-51431
JohnTitor Oct 22, 2019
93fab98
Add test for issue-52437
JohnTitor Oct 22, 2019
768965a
bring back some Debug instances for Miri
RalfJung Oct 22, 2019
fc5b485
add comments
RalfJung Oct 22, 2019
7a85c43
Add test for issue-63496
JohnTitor Oct 22, 2019
07f2f05
Update error_codes.rs
Dylan-DPC Oct 22, 2019
66a0253
self-profiling: Remove module names from some event-ids in codegen ba…
michaelwoerister Oct 22, 2019
a1f6589
Add link to async/await
JohnTitor Oct 22, 2019
de3fd02
Target-feature documented as unsafe. rustc book and rustc -C help hav…
togiberlin Sep 4, 2019
8497f79
Add missing space in librustdoc
popzxc Oct 22, 2019
8699227
Rollup merge of #64145 - togiberlin:feature/target-features-doc, r=ehuss
JohnTitor Oct 23, 2019
bd82de0
Rollup merge of #65007 - BO41:keywords, r=nikomatsakis
JohnTitor Oct 23, 2019
557d276
Rollup merge of #65417 - weiznich:more_coherence_tests, r=nikomatsakis
JohnTitor Oct 23, 2019
1dbb010
Rollup merge of #65507 - polyedre:master, r=nikomatsakis
JohnTitor Oct 23, 2019
6f6f3e8
Rollup merge of #65591 - GuillaumeGomez:long-err-explanation-E0588, r…
JohnTitor Oct 23, 2019
ff2442f
Rollup merge of #65617 - newpavlov:patch-2, r=alexcrichton
JohnTitor Oct 23, 2019
88e3ae2
Rollup merge of #65656 - GuillaumeGomez:option-disable-shortcut, r=Dy…
JohnTitor Oct 23, 2019
b799465
Rollup merge of #65678 - JohnTitor:add-e0728-explanation, r=Guilliaum…
JohnTitor Oct 23, 2019
7fc6ce9
Rollup merge of #65681 - sunfishcode:followup, r=Centril
JohnTitor Oct 23, 2019
5bac361
Rollup merge of #65686 - yjhmelody:yjhmelody-patch-1, r=Centril
JohnTitor Oct 23, 2019
c3e5413
Rollup merge of #65688 - JohnTitor:add-some-tests, r=Dylan-DPC
JohnTitor Oct 23, 2019
12f32c2
Rollup merge of #65689 - RalfJung:miri-debug, r=Centril
JohnTitor Oct 23, 2019
41850df
Rollup merge of #65695 - michaelwoerister:fix-self-profiling-work-ite…
JohnTitor Oct 23, 2019
1df9081
Rollup merge of #65706 - popzxc:add-missing-space, r=Mark-Simulacrum
JohnTitor Oct 23, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,14 @@ the master branch to your feature branch.
Also, please make sure that fixup commits are squashed into other related
commits with meaningful commit messages.

GitHub allows [closing issues using keywords][closing-keywords]. This feature
should be used to keep the issue tracker tidy. However, it is generally preferred
to put the "closes #123" text in the PR description rather than the issue commit;
particularly during rebasing, citing the issue number in the commit can "spam"
the issue in question.

[closing-keywords]: https://help.github.com/en/articles/closing-issues-using-keywords

Please make sure your pull request is in compliance with Rust's style
guidelines by running

Expand Down
1 change: 1 addition & 0 deletions src/doc/rustc/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
- [Targets](targets/index.md)
- [Built-in Targets](targets/built-in.md)
- [Custom Targets](targets/custom.md)
- [Known Issues](targets/known-issues.md)
- [Profile-guided Optimization](profile-guided-optimization.md)
- [Linker-plugin based LTO](linker-plugin-lto.md)
- [Contributing to `rustc`](contributing.md)
2 changes: 2 additions & 0 deletions src/doc/rustc/src/codegen-options/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ enabling or disabling a feature.
To see the valid options and an example of use, run `rustc --print
target-features`.

Using this flag is unsafe and might result in [undefined runtime behavior](../targets/known-issues.md).

## passes

This flag can be used to add extra LLVM passes to the compilation.
Expand Down
2 changes: 1 addition & 1 deletion src/doc/rustc/src/command-line-arguments.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ of print values are:
target CPU may be selected with the `-C target-cpu=val` flag.
- `target-features` — List of available target features for the current
target. Target features may be enabled with the `-C target-feature=val`
flag.
flag. This flag is unsafe. See [known issues](targets/known-issues.md) for more details.
- `relocation-models` — List of relocation models. Relocation models may be
selected with the `-C relocation-model=val` flag.
- `code-models` — List of code models. Code models may be selected with the
Expand Down
6 changes: 6 additions & 0 deletions src/doc/rustc/src/targets/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,9 @@ To compile to a particular target, use the `--target` flag:
```bash
$ rustc src/main.rs --target=wasm32-unknown-unknown
```
## Target Features
`x86`, and `ARMv8` are two popular CPU architectures. Their instruction sets form a common baseline across most CPUs. However, some CPUs extend these with custom instruction sets, e.g. vector (`AVX`), bitwise manipulation (`BMI`) or cryptographic (`AES`).

Developers, who know on which CPUs their compiled code is going to run can choose to add (or remove) CPU specific instruction sets via the `-C target-feature=val` flag.

Please note, that this flag is generally considered as unsafe. More details can be found in [this section](known-issues.md).
13 changes: 13 additions & 0 deletions src/doc/rustc/src/targets/known-issues.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Known Issues
This section informs you about known "gotchas". Keep in mind, that this section is (and always will be) incomplete. For suggestions and amendments, feel free to [contribute](../contributing.md) to this guide.

## Target Features
Most target-feature problems arise, when mixing code that have the target-feature _enabled_ with code that have it _disabled_. If you want to avoid undefined behavior, it is recommended to build _all code_ (including the standard library and imported crates) with a common set of target-features.

By default, compiling your code with the `-C target-feature` flag will not recompile the entire standard library and/or imported crates with matching target features. Therefore, target features are generally considered as unsafe. Using `#[target_feature]` on individual functions makes the function unsafe.

Examples:

| Target-Feature | Issue | Seen on | Description | Details |
| -------------- | ----- | ------- | ----------- | ------- |
| `+soft-float` <br> and <br> `-sse` | Segfaults and ABI mismatches | `x86` and `x86-64` | The `x86` and `x86_64` architecture uses SSE registers (aka `xmm`) for floating point operations. Using software emulated floats ("soft-floats") disables usage of `xmm` registers, but parts of Rust's core libraries (e.g. `std::f32` or `std::f64`) are compiled without soft-floats and expect parameters to be passed in `xmm` registers. This leads to ABI mismatches. <br><br> Attempting to compile with disabled SSE causes the same error, too. | [#63466](https://github.com/rust-lang/rust/issues/63466) |
83 changes: 80 additions & 3 deletions src/librustc/error_codes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2045,8 +2045,8 @@ so that a generator can then be constructed:
async fn bar<T>() -> () {}

async fn foo() {
bar::<String>().await;
// ^^^^^^^^ specify type explicitly
bar::<String>().await;
// ^^^^^^^^ specify type explicitly
}
```
"##,
Expand Down Expand Up @@ -2126,6 +2126,84 @@ static X: u32 = 42;
```
"##,

E0728: r##"
[`await`] has been used outside [`async`] function or block.

Erroneous code examples:

```edition2018,compile_fail,E0728
# use std::pin::Pin;
# use std::future::Future;
# use std::task::{Context, Poll};
#
# struct WakeOnceThenComplete(bool);
#
# fn wake_and_yield_once() -> WakeOnceThenComplete {
# WakeOnceThenComplete(false)
# }
#
# impl Future for WakeOnceThenComplete {
# type Output = ();
# fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<()> {
# if self.0 {
# Poll::Ready(())
# } else {
# cx.waker().wake_by_ref();
# self.0 = true;
# Poll::Pending
# }
# }
# }
#
fn foo() {
wake_and_yield_once().await // `await` is used outside `async` context
}
```

[`await`] is used to suspend the current computation until the given
future is ready to produce a value. So it is legal only within
an [`async`] context, like an `async fn` or an `async` block.

```edition2018
# use std::pin::Pin;
# use std::future::Future;
# use std::task::{Context, Poll};
#
# struct WakeOnceThenComplete(bool);
#
# fn wake_and_yield_once() -> WakeOnceThenComplete {
# WakeOnceThenComplete(false)
# }
#
# impl Future for WakeOnceThenComplete {
# type Output = ();
# fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<()> {
# if self.0 {
# Poll::Ready(())
# } else {
# cx.waker().wake_by_ref();
# self.0 = true;
# Poll::Pending
# }
# }
# }
#
async fn foo() {
wake_and_yield_once().await // `await` is used within `async` function
}

fn bar(x: u8) -> impl Future<Output = u8> {
async move {
wake_and_yield_once().await; // `await` is used within `async` block
x
}
}
```

[`async`]: https://doc.rust-lang.org/std/keyword.async.html
[`await`]: https://doc.rust-lang.org/std/keyword.await.html
"##,

E0734: r##"
A stability attribute has been used outside of the standard library.

Expand Down Expand Up @@ -2218,6 +2296,5 @@ See [RFC 2091] for details on this and other limitations.
// E0702, // replaced with a generic attribute input check
E0726, // non-explicit (not `'_`) elided lifetime in unsupported position
E0727, // `async` generators are not yet supported
E0728, // `await` must be in an `async` function or block
E0739, // invalid track_caller application/syntax
}
3 changes: 2 additions & 1 deletion src/librustc/session/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1149,7 +1149,8 @@ options! {CodegenOptions, CodegenSetter, basic_codegen_options,
target_cpu: Option<String> = (None, parse_opt_string, [TRACKED],
"select target processor (`rustc --print target-cpus` for details)"),
target_feature: String = (String::new(), parse_string, [TRACKED],
"target specific attributes (`rustc --print target-features` for details)"),
"target specific attributes. (`rustc --print target-features` for details). \
This feature is unsafe."),
passes: Vec<String> = (Vec::new(), parse_list, [TRACKED],
"a list of extra LLVM passes to run (space separated)"),
llvm_args: Vec<String> = (Vec::new(), parse_list, [TRACKED],
Expand Down
12 changes: 6 additions & 6 deletions src/librustc_codegen_ssa/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ fn generate_lto_work<B: ExtraBackendMethods>(
needs_thin_lto: Vec<(String, B::ThinBuffer)>,
import_only_modules: Vec<(SerializedModule<B::ModuleBuffer>, WorkProduct)>
) -> Vec<(WorkItem<B>, u64)> {
let _prof_timer = cgcx.prof.generic_activity("codegen_run_lto");
let _prof_timer = cgcx.prof.generic_activity("codegen_generate_lto_work");

let (lto_modules, copy_jobs) = if !needs_fat_lto.is_empty() {
assert!(needs_thin_lto.is_empty());
Expand Down Expand Up @@ -674,11 +674,11 @@ impl<B: WriteBackendMethods> WorkItem<B> {
}
}

pub fn name(&self) -> String {
fn profiling_event_id(&self) -> &'static str {
match *self {
WorkItem::Optimize(ref m) => format!("optimize: {}", m.name),
WorkItem::CopyPostLtoArtifacts(ref m) => format!("copy post LTO artifacts: {}", m.name),
WorkItem::LTO(ref m) => format!("lto: {}", m.name()),
WorkItem::Optimize(_) => "codegen_module_optimize",
WorkItem::CopyPostLtoArtifacts(_) => "codegen_copy_artifacts_from_incr_cache",
WorkItem::LTO(_) => "codegen_module_perform_lto",
}
}
}
Expand Down Expand Up @@ -1587,7 +1587,7 @@ fn spawn_work<B: ExtraBackendMethods>(
// as a diagnostic was already sent off to the main thread - just
// surface that there was an error in this worker.
bomb.result = {
let _prof_timer = cgcx.prof.generic_activity(&work.name());
let _prof_timer = cgcx.prof.generic_activity(work.profiling_event_id());
execute_work_item(&cgcx, work).ok()
};
});
Expand Down
37 changes: 24 additions & 13 deletions src/librustc_codegen_ssa/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,8 @@ pub fn maybe_create_entry_wrapper<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(cx: &'
rust_main_def_id: DefId,
use_start_lang_item: bool,
) {
// The entry function is either `int main(void)` or `int main(int argc, char **argv)`,
// depending on whether the target needs `argc` and `argv` to be passed in.
let llfty = if cx.sess().target.target.options.main_needs_argc_argv {
cx.type_func(&[cx.type_int(), cx.type_ptr_to(cx.type_i8p())], cx.type_int())
} else {
Expand Down Expand Up @@ -440,19 +442,7 @@ pub fn maybe_create_entry_wrapper<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(cx: &'

bx.insert_reference_to_gdb_debug_scripts_section_global();

let (arg_argc, arg_argv) = if cx.sess().target.target.options.main_needs_argc_argv {
// Params from native main() used as args for rust start function
let param_argc = bx.get_param(0);
let param_argv = bx.get_param(1);
let arg_argc = bx.intcast(param_argc, cx.type_isize(), true);
let arg_argv = param_argv;
(arg_argc, arg_argv)
} else {
// The Rust start function doesn't need argc and argv, so just pass zeros.
let arg_argc = bx.const_int(cx.type_int(), 0);
let arg_argv = bx.const_null(cx.type_ptr_to(cx.type_i8p()));
(arg_argc, arg_argv)
};
let (arg_argc, arg_argv) = get_argc_argv(cx, &mut bx);

let (start_fn, args) = if use_start_lang_item {
let start_def_id = cx.tcx().require_lang_item(StartFnLangItem, None);
Expand All @@ -477,6 +467,27 @@ pub fn maybe_create_entry_wrapper<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(cx: &'
}
}

/// Obtain the `argc` and `argv` values to pass to the rust start function.
fn get_argc_argv<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
cx: &'a Bx::CodegenCx,
bx: &mut Bx
) -> (Bx::Value, Bx::Value)
{
if cx.sess().target.target.options.main_needs_argc_argv {
// Params from native `main()` used as args for rust start function
let param_argc = bx.get_param(0);
let param_argv = bx.get_param(1);
let arg_argc = bx.intcast(param_argc, cx.type_isize(), true);
let arg_argv = param_argv;
(arg_argc, arg_argv)
} else {
// The Rust start function doesn't need `argc` and `argv`, so just pass zeros.
let arg_argc = bx.const_int(cx.type_int(), 0);
let arg_argv = bx.const_null(cx.type_ptr_to(cx.type_i8p()));
(arg_argc, arg_argv)
}
}

pub const CODEGEN_WORKER_ID: usize = ::std::usize::MAX;

pub fn codegen_crate<B: ExtraBackendMethods>(
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_mir/interpret/eval_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ pub struct Frame<'mir, 'tcx, Tag=(), Extra=()> {
pub extra: Extra,
}

#[derive(Clone, Eq, PartialEq)]
#[derive(Clone, Eq, PartialEq, Debug)] // Miri debug-prints these
pub enum StackPopCleanup {
/// Jump to the next block in the caller, or cause UB if None (that's a function
/// that may never return). Also store layout of return place so
Expand All @@ -113,7 +113,7 @@ pub struct LocalState<'tcx, Tag=(), Id=AllocId> {
}

/// Current value of a local variable
#[derive(Clone, PartialEq, Eq)]
#[derive(Clone, PartialEq, Eq, Debug)] // Miri debug-prints these
pub enum LocalValue<Tag=(), Id=AllocId> {
/// This local is not currently alive, and cannot be used at all.
Dead,
Expand Down
38 changes: 32 additions & 6 deletions src/librustc_typeck/error_codes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ a guard.
```compile_fail,E0029
let string = "salutations !";

// The ordering relation for strings can't be evaluated at compile time,
// The ordering relation for strings cannot be evaluated at compile time,
// so this doesn't work:
match string {
"hello" ..= "world" => {}
Expand Down Expand Up @@ -348,7 +348,7 @@ fn main() {
"##,

E0044: r##"
You can't use type or const parameters on foreign items.
You cannot use type or const parameters on foreign items.
Example of erroneous code:

```compile_fail,E0044
Expand Down Expand Up @@ -788,7 +788,7 @@ fn some_other_func() {}
fn some_function() {
SOME_CONST = 14; // error : a constant value cannot be changed!
1 = 3; // error : 1 isn't a valid place!
some_other_func() = 4; // error : we can't assign value to a function!
some_other_func() = 4; // error : we cannot assign value to a function!
SomeStruct.x = 12; // error : SomeStruct a structure name but it is used
// like a variable!
}
Expand Down Expand Up @@ -3891,6 +3891,33 @@ details.
[issue #33685]: https://github.com/rust-lang/rust/issues/33685
"##,

E0588: r##"
A type with `packed` representation hint has a field with `align`
representation hint.

Erroneous code example:

```compile_fail,E0588
#[repr(align(16))]
struct Aligned(i32);

#[repr(packed)] // error!
struct Packed(Aligned);
```

Just like you cannot have both `align` and `packed` representation hints on a
same type, a `packed` type cannot contain another type with the `align`
representation hint. However, you can do the opposite:

```
#[repr(packed)]
struct Packed(i32);

#[repr(align(16))] // ok!
struct Aligned(Packed);
```
"##,

E0592: r##"
This error occurs when you defined methods or associated functions with same
name.
Expand Down Expand Up @@ -4299,7 +4326,7 @@ extern {

unsafe {
printf(::std::ptr::null(), 0f32);
// error: can't pass an `f32` to variadic function, cast to `c_double`
// error: cannot pass an `f32` to variadic function, cast to `c_double`
}
```

Expand Down Expand Up @@ -5000,7 +5027,7 @@ the future, [RFC 2091] prohibits their implementation without a follow-up RFC.
// E0174,
// E0182, // merged into E0229
E0183,
// E0187, // can't infer the kind of the closure
// E0187, // cannot infer the kind of the closure
// E0188, // can not cast an immutable reference to a mutable pointer
// E0189, // deprecated: can only cast a boxed pointer to a boxed object
// E0190, // deprecated: can only cast a &-pointer to an &-object
Expand Down Expand Up @@ -5047,7 +5074,6 @@ the future, [RFC 2091] prohibits their implementation without a follow-up RFC.
// E0564, // only named lifetimes are allowed in `impl Trait`,
// but `{}` was found in the type `{}`
E0587, // type has conflicting packed and align representation hints
E0588, // packed type cannot transitively contain a `[repr(align)]` type
// E0611, // merged into E0616
// E0612, // merged into E0609
// E0613, // Removed (merged with E0609)
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/doctree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ impl Module<'hir> {
fns : Vec::new(),
mods : Vec::new(),
typedefs : Vec::new(),
opaque_tys : Vec::new(),
opaque_tys : Vec::new(),
statics : Vec::new(),
constants : Vec::new(),
traits : Vec::new(),
Expand Down
1 change: 1 addition & 0 deletions src/librustdoc/html/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1241,6 +1241,7 @@ fn settings(root_path: &str, suffix: &str) -> String {
("go-to-only-result", "Directly go to item in search if there is only one result",
false),
("line-numbers", "Show line numbers on code examples", false),
("disable-shortcuts", "Disable keyboard shortcuts", false),
];
format!(
"<h1 class='fqn'>\
Expand Down
Loading