Skip to content

Rollup of 7 pull requests #65109

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

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
9fbb2a9
Fix missing calls to drop on unwind with lto=fat; issue 64655.
pnkfelix Oct 2, 2019
a371972
Regression tests for issue 64655.
pnkfelix Oct 2, 2019
3adcc3e
fix typo
pnkfelix Oct 2, 2019
e7e6dec
Apply suggestions from code review
pnkfelix Oct 3, 2019
5e7e8cd
Update attributes.rs
pnkfelix Oct 3, 2019
71e5f78
Update issue-64655-extern-rust-must-allow-unwind.rs
pnkfelix Oct 3, 2019
1222cc9
permit asyncawait-ondeck to be added by anyone
nikomatsakis Oct 3, 2019
1fcbd90
Update triagebot.toml
nikomatsakis Oct 3, 2019
ed60cf2
When encountering chained operators use heuristics to recover from ba…
estebank Sep 30, 2019
6c9f298
review comments
estebank Sep 30, 2019
d7dceaa
Account for missing turbofish in paths too
estebank Sep 30, 2019
d27683a
Prove bad turbofish parser recovery in test
estebank Sep 30, 2019
dfdc369
review comments
estebank Oct 1, 2019
f1499a8
review comments
estebank Oct 1, 2019
02f57f8
review comments
estebank Oct 3, 2019
76456e7
review comments
estebank Oct 4, 2019
d896088
Upgrade librustc_macros dependencies
mati865 Oct 4, 2019
2d87bac
replace GeneratorSubsts with SubstsRef
csmoe Oct 3, 2019
fa7a87b
generate GeneratorSubsts from SubstsRef
csmoe Oct 3, 2019
774ea80
replace GeneratorSubsts inside related types
csmoe Oct 3, 2019
ef9fe10
remove GeneratorSubsts visitors
csmoe Oct 3, 2019
afc0bb9
clean up GeneratorSubsts
csmoe Oct 3, 2019
e9009c8
[const-prop] Fix ICE when trying to eval polymorphic promoted MIR
wesleywiser Oct 3, 2019
08ec3fe
dont run these tests on targets that default to panic=abort.
pnkfelix Oct 4, 2019
91a096a
move middle::liveness to rustc_passes
Mark-Simulacrum Oct 4, 2019
bb70782
middle::dead -> rustc_passes
Mark-Simulacrum Oct 4, 2019
82bfd8e
middle::entry -> rustc_passes
Mark-Simulacrum Oct 4, 2019
7c3f65b
middle::intrinsicck -> rustc_passes
Mark-Simulacrum Oct 4, 2019
c4ec53f
Rollup merge of #64909 - estebank:turbofish-reloaded, r=Centril
Mark-Simulacrum Oct 4, 2019
2889139
Rollup merge of #65020 - pnkfelix:targetted-fix-for-always-marking-ru…
Mark-Simulacrum Oct 4, 2019
b7c3e07
Rollup merge of #65064 - rust-lang:permit-asyncawait-ondeck-by-anyone…
Mark-Simulacrum Oct 4, 2019
dc87b27
Rollup merge of #65066 - wesleywiser:fix_const_prop_ice_on_polymorphi…
Mark-Simulacrum Oct 4, 2019
aa98a2b
Rollup merge of #65100 - csmoe:generator, r=nikomatsakis
Mark-Simulacrum Oct 4, 2019
18f62d7
Rollup merge of #65101 - mati865:rustc_macro-deps, r=nikomatsakis
Mark-Simulacrum Oct 4, 2019
4c094e1
Rollup merge of #65105 - Mark-Simulacrum:split-librustc, r=nikomatsakis
Mark-Simulacrum Oct 4, 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
26 changes: 20 additions & 6 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -993,7 +993,7 @@ dependencies = [
"proc-macro2 0.4.30",
"quote 0.6.12",
"syn 0.15.35",
"synstructure",
"synstructure 0.10.2",
]

[[package]]
Expand Down Expand Up @@ -3165,7 +3165,7 @@ dependencies = [
"proc-macro2 0.4.30",
"quote 0.6.12",
"syn 0.15.35",
"synstructure",
"synstructure 0.10.2",
]

[[package]]
Expand Down Expand Up @@ -3546,10 +3546,10 @@ name = "rustc_macros"
version = "0.1.0"
dependencies = [
"itertools 0.8.0",
"proc-macro2 0.4.30",
"quote 0.6.12",
"syn 0.15.35",
"synstructure",
"proc-macro2 1.0.3",
"quote 1.0.2",
"syn 1.0.5",
"synstructure 0.12.1",
]

[[package]]
Expand Down Expand Up @@ -3613,6 +3613,8 @@ dependencies = [
"rustc",
"rustc_data_structures",
"rustc_errors",
"rustc_index",
"rustc_target",
"syntax",
"syntax_pos",
]
Expand Down Expand Up @@ -4242,6 +4244,18 @@ dependencies = [
"unicode-xid 0.1.0",
]

[[package]]
name = "synstructure"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f085a5855930c0441ca1288cf044ea4aecf4f43a91668abdb870b4ba546a203"
dependencies = [
"proc-macro2 1.0.3",
"quote 1.0.2",
"syn 1.0.5",
"unicode-xid 0.2.0",
]

[[package]]
name = "syntax"
version = "0.0.0"
Expand Down
180 changes: 0 additions & 180 deletions src/librustc/error_codes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -466,66 +466,6 @@ fn main() {
```
"##,

// This shouldn't really ever trigger since the repeated value error comes first
E0136: r##"
A binary can only have one entry point, and by default that entry point is the
function `main()`. If there are multiple such functions, please rename one.
"##,

E0137: r##"
More than one function was declared with the `#[main]` attribute.

Erroneous code example:

```compile_fail,E0137
#![feature(main)]

#[main]
fn foo() {}

#[main]
fn f() {} // error: multiple functions with a `#[main]` attribute
```

This error indicates that the compiler found multiple functions with the
`#[main]` attribute. This is an error because there must be a unique entry
point into a Rust program. Example:

```
#![feature(main)]

#[main]
fn f() {} // ok!
```
"##,

E0138: r##"
More than one function was declared with the `#[start]` attribute.

Erroneous code example:

```compile_fail,E0138
#![feature(start)]

#[start]
fn foo(argc: isize, argv: *const *const u8) -> isize {}

#[start]
fn f(argc: isize, argv: *const *const u8) -> isize {}
// error: multiple 'start' functions
```

This error indicates that the compiler found multiple functions with the
`#[start]` attribute. This is an error because there must be a unique entry
point into a Rust program. Example:

```
#![feature(start)]

#[start]
fn foo(argc: isize, argv: *const *const u8) -> isize { 0 } // ok!
```
"##,

E0139: r##"
#### Note: this error code is no longer emitted by the compiler.
Expand Down Expand Up @@ -1626,33 +1566,6 @@ It is not possible to use stability attributes outside of the standard library.
Also, for now, it is not possible to write deprecation messages either.
"##,

E0512: r##"
Transmute with two differently sized types was attempted. Erroneous code
example:

```compile_fail,E0512
fn takes_u8(_: u8) {}

fn main() {
unsafe { takes_u8(::std::mem::transmute(0u16)); }
// error: cannot transmute between types of different sizes,
// or dependently-sized types
}
```

Please use types with same size or use the expected type directly. Example:

```
fn takes_u8(_: u8) {}

fn main() {
unsafe { takes_u8(::std::mem::transmute(0i8)); } // ok!
// or:
unsafe { takes_u8(0u8); } // ok!
}
```
"##,

E0517: r##"
This error indicates that a `#[repr(..)]` attribute was placed on an
unsupported item.
Expand Down Expand Up @@ -1847,84 +1760,6 @@ See [RFC 1522] for more details.
[RFC 1522]: https://github.com/rust-lang/rfcs/blob/master/text/1522-conservative-impl-trait.md
"##,

E0591: r##"
Per [RFC 401][rfc401], if you have a function declaration `foo`:

```
// For the purposes of this explanation, all of these
// different kinds of `fn` declarations are equivalent:
struct S;
fn foo(x: S) { /* ... */ }
# #[cfg(for_demonstration_only)]
extern "C" { fn foo(x: S); }
# #[cfg(for_demonstration_only)]
impl S { fn foo(self) { /* ... */ } }
```

the type of `foo` is **not** `fn(S)`, as one might expect.
Rather, it is a unique, zero-sized marker type written here as `typeof(foo)`.
However, `typeof(foo)` can be _coerced_ to a function pointer `fn(S)`,
so you rarely notice this:

```
# struct S;
# fn foo(_: S) {}
let x: fn(S) = foo; // OK, coerces
```

The reason that this matter is that the type `fn(S)` is not specific to
any particular function: it's a function _pointer_. So calling `x()` results
in a virtual call, whereas `foo()` is statically dispatched, because the type
of `foo` tells us precisely what function is being called.

As noted above, coercions mean that most code doesn't have to be
concerned with this distinction. However, you can tell the difference
when using **transmute** to convert a fn item into a fn pointer.

This is sometimes done as part of an FFI:

```compile_fail,E0591
extern "C" fn foo(userdata: Box<i32>) {
/* ... */
}

# fn callback(_: extern "C" fn(*mut i32)) {}
# use std::mem::transmute;
# unsafe {
let f: extern "C" fn(*mut i32) = transmute(foo);
callback(f);
# }
```

Here, transmute is being used to convert the types of the fn arguments.
This pattern is incorrect because, because the type of `foo` is a function
**item** (`typeof(foo)`), which is zero-sized, and the target type (`fn()`)
is a function pointer, which is not zero-sized.
This pattern should be rewritten. There are a few possible ways to do this:

- change the original fn declaration to match the expected signature,
and do the cast in the fn body (the preferred option)
- cast the fn item fo a fn pointer before calling transmute, as shown here:

```
# extern "C" fn foo(_: Box<i32>) {}
# use std::mem::transmute;
# unsafe {
let f: extern "C" fn(*mut i32) = transmute(foo as extern "C" fn(_));
let f: extern "C" fn(*mut i32) = transmute(foo as usize); // works too
# }
```

The same applies to transmutes to `*mut fn()`, which were observed in practice.
Note though that use of this type is generally incorrect.
The intention is typically to describe a function pointer, but just `fn()`
alone suffices for that. `*mut fn()` is a pointer to a fn pointer.
(Since these values are typically just passed to C code, however, this rarely
makes a difference in practice.)

[rfc401]: https://github.com/rust-lang/rfcs/blob/master/text/0401-coercions.md
"##,

E0593: r##"
You tried to supply an `Fn`-based type with an incorrect number of arguments
than what was expected.
Expand All @@ -1941,21 +1776,6 @@ fn main() {
```
"##,

E0601: r##"
No `main` function was found in a binary crate. To fix this error, add a
`main` function. For example:

```
fn main() {
// Your program will start here.
println!("Hello world!");
}
```

If you don't know the basics of Rust, you can go look to the Rust Book to get
started: https://doc.rust-lang.org/book/
"##,

E0602: r##"
An unknown lint was used on the command line.

Expand Down
10 changes: 5 additions & 5 deletions src/librustc/infer/opaque_types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -733,12 +733,12 @@ where
// Skip lifetime parameters of the enclosing item(s)
// Also skip the witness type, because that has no free regions.

for upvar_ty in substs.upvar_tys(def_id, self.tcx) {
for upvar_ty in substs.as_generator().upvar_tys(def_id, self.tcx) {
upvar_ty.visit_with(self);
}

substs.return_ty(def_id, self.tcx).visit_with(self);
substs.yield_ty(def_id, self.tcx).visit_with(self);
substs.as_generator().return_ty(def_id, self.tcx).visit_with(self);
substs.as_generator().yield_ty(def_id, self.tcx).visit_with(self);
}
_ => {
ty.super_visit_with(self);
Expand Down Expand Up @@ -902,7 +902,7 @@ impl TypeFolder<'tcx> for ReverseMapper<'tcx> {
ty::Generator(def_id, substs, movability) => {
let generics = self.tcx.generics_of(def_id);
let substs =
self.tcx.mk_substs(substs.substs.iter().enumerate().map(|(index, &kind)| {
self.tcx.mk_substs(substs.iter().enumerate().map(|(index, &kind)| {
if index < generics.parent_count {
// Accommodate missing regions in the parent kinds...
self.fold_kind_mapping_missing_regions_to_empty(kind)
Expand All @@ -912,7 +912,7 @@ impl TypeFolder<'tcx> for ReverseMapper<'tcx> {
}
}));

self.tcx.mk_generator(def_id, ty::GeneratorSubsts { substs }, movability)
self.tcx.mk_generator(def_id, substs, movability)
}

ty::Param(..) => {
Expand Down
4 changes: 0 additions & 4 deletions src/librustc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,16 +102,12 @@ pub mod lint;
pub mod middle {
pub mod expr_use_visitor;
pub mod cstore;
pub mod dead;
pub mod dependency_format;
pub mod diagnostic_items;
pub mod entry;
pub mod exported_symbols;
pub mod free_region;
pub mod intrinsicck;
pub mod lib_features;
pub mod lang_items;
pub mod liveness;
pub mod mem_categorization;
pub mod privacy;
pub mod reachable;
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use crate::ty::layout::VariantIdx;
use crate::ty::print::{FmtPrinter, Printer};
use crate::ty::subst::{Subst, SubstsRef};
use crate::ty::{
self, AdtDef, CanonicalUserTypeAnnotations, GeneratorSubsts, Region, Ty, TyCtxt,
self, AdtDef, CanonicalUserTypeAnnotations, Region, Ty, TyCtxt,
UserTypeAnnotationIndex,
};

Expand Down Expand Up @@ -2189,7 +2189,7 @@ pub enum AggregateKind<'tcx> {
Adt(&'tcx AdtDef, VariantIdx, SubstsRef<'tcx>, Option<UserTypeAnnotationIndex>, Option<usize>),

Closure(DefId, SubstsRef<'tcx>),
Generator(DefId, GeneratorSubsts<'tcx>, hir::GeneratorMovability),
Generator(DefId, SubstsRef<'tcx>, hir::GeneratorMovability),
}

#[derive(Copy, Clone, Debug, PartialEq, Eq, RustcEncodable, RustcDecodable, HashStable)]
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/mir/tcx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ impl<'tcx> Rvalue<'tcx> {
let ty = place.ty(local_decls, tcx).ty;
match ty.kind {
ty::Adt(adt_def, _) => adt_def.repr.discr_type().to_ty(tcx),
ty::Generator(_, substs, _) => substs.discr_ty(tcx),
ty::Generator(_, substs, _) => substs.as_generator().discr_ty(tcx),
_ => {
// This can only be `0`, for now, so `u8` will suffice.
tcx.types.u8
Expand Down
14 changes: 2 additions & 12 deletions src/librustc/mir/visit.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::ty::subst::SubstsRef;
use crate::ty::{CanonicalUserTypeAnnotation, GeneratorSubsts, Ty};
use crate::ty::{CanonicalUserTypeAnnotation, Ty};
use crate::mir::*;
use syntax_pos::Span;

Expand Down Expand Up @@ -230,12 +230,6 @@ macro_rules! make_mir_visitor {
self.super_substs(substs);
}

fn visit_generator_substs(&mut self,
substs: & $($mutability)? GeneratorSubsts<'tcx>,
_: Location) {
self.super_generator_substs(substs);
}

fn visit_local_decl(&mut self,
local: Local,
local_decl: & $($mutability)? LocalDecl<'tcx>) {
Expand Down Expand Up @@ -628,7 +622,7 @@ macro_rules! make_mir_visitor {
generator_substs,
_movability,
) => {
self.visit_generator_substs(generator_substs, location);
self.visit_substs(generator_substs, location);
}
}

Expand Down Expand Up @@ -846,10 +840,6 @@ macro_rules! make_mir_visitor {
fn super_substs(&mut self, _substs: & $($mutability)? SubstsRef<'tcx>) {
}

fn super_generator_substs(&mut self,
_substs: & $($mutability)? GeneratorSubsts<'tcx>) {
}

// Convenience methods

fn visit_location(&mut self, body: & $($mutability)? Body<'tcx>, location: Location) {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/traits/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ pub struct VtableImplData<'tcx, N> {
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, HashStable)]
pub struct VtableGeneratorData<'tcx, N> {
pub generator_def_id: DefId,
pub substs: ty::GeneratorSubsts<'tcx>,
pub substs: SubstsRef<'tcx>,
/// Nested obligations. This can be non-empty if the generator
/// signature contains associated types.
pub nested: Vec<N>
Expand Down
Loading