Skip to content

Commit 155cdde

Browse files
committed
Auto merge of #65109 - Mark-Simulacrum:rollup-2pj0w1m, r=Mark-Simulacrum
Rollup of 7 pull requests Successful merges: - #64909 (When encountering chained operators use heuristics to recover from bad turbofish) - #65020 (Always mark rust and rust-call abi's as unwind) - #65064 (permit asyncawait-ondeck to be added by anyone) - #65066 ([const-prop] Fix ICE when trying to eval polymorphic promoted MIR) - #65100 (Replace GeneratorSubsts with SubstsRef) - #65101 (Upgrade librustc_macros dependencies) - #65105 (Split out some passes from librustc) Failed merges: r? @ghost
2 parents 2e72448 + 4c094e1 commit 155cdde

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+877
-480
lines changed

Cargo.lock

+20-6
Original file line numberDiff line numberDiff line change
@@ -993,7 +993,7 @@ dependencies = [
993993
"proc-macro2 0.4.30",
994994
"quote 0.6.12",
995995
"syn 0.15.35",
996-
"synstructure",
996+
"synstructure 0.10.2",
997997
]
998998

999999
[[package]]
@@ -3165,7 +3165,7 @@ dependencies = [
31653165
"proc-macro2 0.4.30",
31663166
"quote 0.6.12",
31673167
"syn 0.15.35",
3168-
"synstructure",
3168+
"synstructure 0.10.2",
31693169
]
31703170

31713171
[[package]]
@@ -3546,10 +3546,10 @@ name = "rustc_macros"
35463546
version = "0.1.0"
35473547
dependencies = [
35483548
"itertools 0.8.0",
3549-
"proc-macro2 0.4.30",
3550-
"quote 0.6.12",
3551-
"syn 0.15.35",
3552-
"synstructure",
3549+
"proc-macro2 1.0.3",
3550+
"quote 1.0.2",
3551+
"syn 1.0.5",
3552+
"synstructure 0.12.1",
35533553
]
35543554

35553555
[[package]]
@@ -3613,6 +3613,8 @@ dependencies = [
36133613
"rustc",
36143614
"rustc_data_structures",
36153615
"rustc_errors",
3616+
"rustc_index",
3617+
"rustc_target",
36163618
"syntax",
36173619
"syntax_pos",
36183620
]
@@ -4242,6 +4244,18 @@ dependencies = [
42424244
"unicode-xid 0.1.0",
42434245
]
42444246

4247+
[[package]]
4248+
name = "synstructure"
4249+
version = "0.12.1"
4250+
source = "registry+https://github.com/rust-lang/crates.io-index"
4251+
checksum = "3f085a5855930c0441ca1288cf044ea4aecf4f43a91668abdb870b4ba546a203"
4252+
dependencies = [
4253+
"proc-macro2 1.0.3",
4254+
"quote 1.0.2",
4255+
"syn 1.0.5",
4256+
"unicode-xid 0.2.0",
4257+
]
4258+
42454259
[[package]]
42464260
name = "syntax"
42474261
version = "0.0.0"

src/librustc/error_codes.rs

-180
Original file line numberDiff line numberDiff line change
@@ -466,66 +466,6 @@ fn main() {
466466
```
467467
"##,
468468

469-
// This shouldn't really ever trigger since the repeated value error comes first
470-
E0136: r##"
471-
A binary can only have one entry point, and by default that entry point is the
472-
function `main()`. If there are multiple such functions, please rename one.
473-
"##,
474-
475-
E0137: r##"
476-
More than one function was declared with the `#[main]` attribute.
477-
478-
Erroneous code example:
479-
480-
```compile_fail,E0137
481-
#![feature(main)]
482-
483-
#[main]
484-
fn foo() {}
485-
486-
#[main]
487-
fn f() {} // error: multiple functions with a `#[main]` attribute
488-
```
489-
490-
This error indicates that the compiler found multiple functions with the
491-
`#[main]` attribute. This is an error because there must be a unique entry
492-
point into a Rust program. Example:
493-
494-
```
495-
#![feature(main)]
496-
497-
#[main]
498-
fn f() {} // ok!
499-
```
500-
"##,
501-
502-
E0138: r##"
503-
More than one function was declared with the `#[start]` attribute.
504-
505-
Erroneous code example:
506-
507-
```compile_fail,E0138
508-
#![feature(start)]
509-
510-
#[start]
511-
fn foo(argc: isize, argv: *const *const u8) -> isize {}
512-
513-
#[start]
514-
fn f(argc: isize, argv: *const *const u8) -> isize {}
515-
// error: multiple 'start' functions
516-
```
517-
518-
This error indicates that the compiler found multiple functions with the
519-
`#[start]` attribute. This is an error because there must be a unique entry
520-
point into a Rust program. Example:
521-
522-
```
523-
#![feature(start)]
524-
525-
#[start]
526-
fn foo(argc: isize, argv: *const *const u8) -> isize { 0 } // ok!
527-
```
528-
"##,
529469

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

1629-
E0512: r##"
1630-
Transmute with two differently sized types was attempted. Erroneous code
1631-
example:
1632-
1633-
```compile_fail,E0512
1634-
fn takes_u8(_: u8) {}
1635-
1636-
fn main() {
1637-
unsafe { takes_u8(::std::mem::transmute(0u16)); }
1638-
// error: cannot transmute between types of different sizes,
1639-
// or dependently-sized types
1640-
}
1641-
```
1642-
1643-
Please use types with same size or use the expected type directly. Example:
1644-
1645-
```
1646-
fn takes_u8(_: u8) {}
1647-
1648-
fn main() {
1649-
unsafe { takes_u8(::std::mem::transmute(0i8)); } // ok!
1650-
// or:
1651-
unsafe { takes_u8(0u8); } // ok!
1652-
}
1653-
```
1654-
"##,
1655-
16561569
E0517: r##"
16571570
This error indicates that a `#[repr(..)]` attribute was placed on an
16581571
unsupported item.
@@ -1847,84 +1760,6 @@ See [RFC 1522] for more details.
18471760
[RFC 1522]: https://github.com/rust-lang/rfcs/blob/master/text/1522-conservative-impl-trait.md
18481761
"##,
18491762

1850-
E0591: r##"
1851-
Per [RFC 401][rfc401], if you have a function declaration `foo`:
1852-
1853-
```
1854-
// For the purposes of this explanation, all of these
1855-
// different kinds of `fn` declarations are equivalent:
1856-
struct S;
1857-
fn foo(x: S) { /* ... */ }
1858-
# #[cfg(for_demonstration_only)]
1859-
extern "C" { fn foo(x: S); }
1860-
# #[cfg(for_demonstration_only)]
1861-
impl S { fn foo(self) { /* ... */ } }
1862-
```
1863-
1864-
the type of `foo` is **not** `fn(S)`, as one might expect.
1865-
Rather, it is a unique, zero-sized marker type written here as `typeof(foo)`.
1866-
However, `typeof(foo)` can be _coerced_ to a function pointer `fn(S)`,
1867-
so you rarely notice this:
1868-
1869-
```
1870-
# struct S;
1871-
# fn foo(_: S) {}
1872-
let x: fn(S) = foo; // OK, coerces
1873-
```
1874-
1875-
The reason that this matter is that the type `fn(S)` is not specific to
1876-
any particular function: it's a function _pointer_. So calling `x()` results
1877-
in a virtual call, whereas `foo()` is statically dispatched, because the type
1878-
of `foo` tells us precisely what function is being called.
1879-
1880-
As noted above, coercions mean that most code doesn't have to be
1881-
concerned with this distinction. However, you can tell the difference
1882-
when using **transmute** to convert a fn item into a fn pointer.
1883-
1884-
This is sometimes done as part of an FFI:
1885-
1886-
```compile_fail,E0591
1887-
extern "C" fn foo(userdata: Box<i32>) {
1888-
/* ... */
1889-
}
1890-
1891-
# fn callback(_: extern "C" fn(*mut i32)) {}
1892-
# use std::mem::transmute;
1893-
# unsafe {
1894-
let f: extern "C" fn(*mut i32) = transmute(foo);
1895-
callback(f);
1896-
# }
1897-
```
1898-
1899-
Here, transmute is being used to convert the types of the fn arguments.
1900-
This pattern is incorrect because, because the type of `foo` is a function
1901-
**item** (`typeof(foo)`), which is zero-sized, and the target type (`fn()`)
1902-
is a function pointer, which is not zero-sized.
1903-
This pattern should be rewritten. There are a few possible ways to do this:
1904-
1905-
- change the original fn declaration to match the expected signature,
1906-
and do the cast in the fn body (the preferred option)
1907-
- cast the fn item fo a fn pointer before calling transmute, as shown here:
1908-
1909-
```
1910-
# extern "C" fn foo(_: Box<i32>) {}
1911-
# use std::mem::transmute;
1912-
# unsafe {
1913-
let f: extern "C" fn(*mut i32) = transmute(foo as extern "C" fn(_));
1914-
let f: extern "C" fn(*mut i32) = transmute(foo as usize); // works too
1915-
# }
1916-
```
1917-
1918-
The same applies to transmutes to `*mut fn()`, which were observed in practice.
1919-
Note though that use of this type is generally incorrect.
1920-
The intention is typically to describe a function pointer, but just `fn()`
1921-
alone suffices for that. `*mut fn()` is a pointer to a fn pointer.
1922-
(Since these values are typically just passed to C code, however, this rarely
1923-
makes a difference in practice.)
1924-
1925-
[rfc401]: https://github.com/rust-lang/rfcs/blob/master/text/0401-coercions.md
1926-
"##,
1927-
19281763
E0593: r##"
19291764
You tried to supply an `Fn`-based type with an incorrect number of arguments
19301765
than what was expected.
@@ -1941,21 +1776,6 @@ fn main() {
19411776
```
19421777
"##,
19431778

1944-
E0601: r##"
1945-
No `main` function was found in a binary crate. To fix this error, add a
1946-
`main` function. For example:
1947-
1948-
```
1949-
fn main() {
1950-
// Your program will start here.
1951-
println!("Hello world!");
1952-
}
1953-
```
1954-
1955-
If you don't know the basics of Rust, you can go look to the Rust Book to get
1956-
started: https://doc.rust-lang.org/book/
1957-
"##,
1958-
19591779
E0602: r##"
19601780
An unknown lint was used on the command line.
19611781

src/librustc/infer/opaque_types/mod.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -733,12 +733,12 @@ where
733733
// Skip lifetime parameters of the enclosing item(s)
734734
// Also skip the witness type, because that has no free regions.
735735

736-
for upvar_ty in substs.upvar_tys(def_id, self.tcx) {
736+
for upvar_ty in substs.as_generator().upvar_tys(def_id, self.tcx) {
737737
upvar_ty.visit_with(self);
738738
}
739739

740-
substs.return_ty(def_id, self.tcx).visit_with(self);
741-
substs.yield_ty(def_id, self.tcx).visit_with(self);
740+
substs.as_generator().return_ty(def_id, self.tcx).visit_with(self);
741+
substs.as_generator().yield_ty(def_id, self.tcx).visit_with(self);
742742
}
743743
_ => {
744744
ty.super_visit_with(self);
@@ -902,7 +902,7 @@ impl TypeFolder<'tcx> for ReverseMapper<'tcx> {
902902
ty::Generator(def_id, substs, movability) => {
903903
let generics = self.tcx.generics_of(def_id);
904904
let substs =
905-
self.tcx.mk_substs(substs.substs.iter().enumerate().map(|(index, &kind)| {
905+
self.tcx.mk_substs(substs.iter().enumerate().map(|(index, &kind)| {
906906
if index < generics.parent_count {
907907
// Accommodate missing regions in the parent kinds...
908908
self.fold_kind_mapping_missing_regions_to_empty(kind)
@@ -912,7 +912,7 @@ impl TypeFolder<'tcx> for ReverseMapper<'tcx> {
912912
}
913913
}));
914914

915-
self.tcx.mk_generator(def_id, ty::GeneratorSubsts { substs }, movability)
915+
self.tcx.mk_generator(def_id, substs, movability)
916916
}
917917

918918
ty::Param(..) => {

src/librustc/lib.rs

-4
Original file line numberDiff line numberDiff line change
@@ -102,16 +102,12 @@ pub mod lint;
102102
pub mod middle {
103103
pub mod expr_use_visitor;
104104
pub mod cstore;
105-
pub mod dead;
106105
pub mod dependency_format;
107106
pub mod diagnostic_items;
108-
pub mod entry;
109107
pub mod exported_symbols;
110108
pub mod free_region;
111-
pub mod intrinsicck;
112109
pub mod lib_features;
113110
pub mod lang_items;
114-
pub mod liveness;
115111
pub mod mem_categorization;
116112
pub mod privacy;
117113
pub mod reachable;

src/librustc/mir/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use crate::ty::layout::VariantIdx;
1515
use crate::ty::print::{FmtPrinter, Printer};
1616
use crate::ty::subst::{Subst, SubstsRef};
1717
use crate::ty::{
18-
self, AdtDef, CanonicalUserTypeAnnotations, GeneratorSubsts, Region, Ty, TyCtxt,
18+
self, AdtDef, CanonicalUserTypeAnnotations, Region, Ty, TyCtxt,
1919
UserTypeAnnotationIndex,
2020
};
2121

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

21912191
Closure(DefId, SubstsRef<'tcx>),
2192-
Generator(DefId, GeneratorSubsts<'tcx>, hir::GeneratorMovability),
2192+
Generator(DefId, SubstsRef<'tcx>, hir::GeneratorMovability),
21932193
}
21942194

21952195
#[derive(Copy, Clone, Debug, PartialEq, Eq, RustcEncodable, RustcDecodable, HashStable)]

src/librustc/mir/tcx.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ impl<'tcx> Rvalue<'tcx> {
197197
let ty = place.ty(local_decls, tcx).ty;
198198
match ty.kind {
199199
ty::Adt(adt_def, _) => adt_def.repr.discr_type().to_ty(tcx),
200-
ty::Generator(_, substs, _) => substs.discr_ty(tcx),
200+
ty::Generator(_, substs, _) => substs.as_generator().discr_ty(tcx),
201201
_ => {
202202
// This can only be `0`, for now, so `u8` will suffice.
203203
tcx.types.u8

src/librustc/mir/visit.rs

+2-12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::ty::subst::SubstsRef;
2-
use crate::ty::{CanonicalUserTypeAnnotation, GeneratorSubsts, Ty};
2+
use crate::ty::{CanonicalUserTypeAnnotation, Ty};
33
use crate::mir::*;
44
use syntax_pos::Span;
55

@@ -230,12 +230,6 @@ macro_rules! make_mir_visitor {
230230
self.super_substs(substs);
231231
}
232232

233-
fn visit_generator_substs(&mut self,
234-
substs: & $($mutability)? GeneratorSubsts<'tcx>,
235-
_: Location) {
236-
self.super_generator_substs(substs);
237-
}
238-
239233
fn visit_local_decl(&mut self,
240234
local: Local,
241235
local_decl: & $($mutability)? LocalDecl<'tcx>) {
@@ -628,7 +622,7 @@ macro_rules! make_mir_visitor {
628622
generator_substs,
629623
_movability,
630624
) => {
631-
self.visit_generator_substs(generator_substs, location);
625+
self.visit_substs(generator_substs, location);
632626
}
633627
}
634628

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

849-
fn super_generator_substs(&mut self,
850-
_substs: & $($mutability)? GeneratorSubsts<'tcx>) {
851-
}
852-
853843
// Convenience methods
854844

855845
fn visit_location(&mut self, body: & $($mutability)? Body<'tcx>, location: Location) {

src/librustc/traits/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ pub struct VtableImplData<'tcx, N> {
610610
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, HashStable)]
611611
pub struct VtableGeneratorData<'tcx, N> {
612612
pub generator_def_id: DefId,
613-
pub substs: ty::GeneratorSubsts<'tcx>,
613+
pub substs: SubstsRef<'tcx>,
614614
/// Nested obligations. This can be non-empty if the generator
615615
/// signature contains associated types.
616616
pub nested: Vec<N>

0 commit comments

Comments
 (0)