Skip to content

Commit 5752b63

Browse files
committed
Auto merge of #64814 - Mark-Simulacrum:beta-next, r=Mark-Simulacrum
[beta] switch to stable bootstrap and rollup backports Contains the following: * Account for the Zero sub-pattern case. #64748 * relnotes: make compatibility section more sterile and fix rustc version #64742 * Rustdoc render async function re-export #64599 * Update cargo #64773 * switches us to stable bootstrap (not dev-static) (no PR)
2 parents 9689670 + 75f6517 commit 5752b63

File tree

16 files changed

+129
-27
lines changed

16 files changed

+129
-27
lines changed

RELEASES.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@ Misc
7070

7171
Compatibility Notes
7272
-------------------
73-
- Unfortunately the [`x86_64-unknown-uefi` platform can not be built][62785]
74-
with rustc 1.39.0.
75-
- The [`armv7-unknown-linux-gnueabihf` platform is also known to have
76-
issues][62896] for certain crates such as libc.
73+
- The [`x86_64-unknown-uefi` platform can not be built][62785] with rustc
74+
1.38.0.
75+
- The [`armv7-unknown-linux-gnueabihf` platform is known to have
76+
issues][62896] with certain crates such as libc.
7777

7878
[60260]: https://github.com/rust-lang/rust/pull/60260/
7979
[61457]: https://github.com/rust-lang/rust/pull/61457/

src/librustc/query/mod.rs

+4
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,10 @@ rustc_queries! {
244244
desc { |tcx| "checking if item is const fn: `{}`", tcx.def_path_str(key) }
245245
}
246246

247+
query asyncness(key: DefId) -> hir::IsAsync {
248+
desc { |tcx| "checking if the function is async: `{}`", tcx.def_path_str(key) }
249+
}
250+
247251
/// Returns `true` if calls to the function may be promoted.
248252
///
249253
/// This is either because the function is e.g., a tuple-struct or tuple-variant

src/librustc/ty/mod.rs

+17
Original file line numberDiff line numberDiff line change
@@ -3353,13 +3353,30 @@ fn issue33140_self_ty(tcx: TyCtxt<'_>, def_id: DefId) -> Option<Ty<'_>> {
33533353
}
33543354
}
33553355

3356+
/// Check if a function is async.
3357+
fn asyncness(tcx: TyCtxt<'_>, def_id: DefId) -> hir::IsAsync {
3358+
let hir_id = tcx.hir().as_local_hir_id(def_id).unwrap_or_else(|| {
3359+
bug!("asyncness: expected local `DefId`, got `{:?}`", def_id)
3360+
});
3361+
3362+
let node = tcx.hir().get(hir_id);
3363+
3364+
let fn_like = hir::map::blocks::FnLikeNode::from_node(node).unwrap_or_else(|| {
3365+
bug!("asyncness: expected fn-like node but got `{:?}`", def_id);
3366+
});
3367+
3368+
fn_like.asyncness()
3369+
}
3370+
3371+
33563372
pub fn provide(providers: &mut ty::query::Providers<'_>) {
33573373
context::provide(providers);
33583374
erase_regions::provide(providers);
33593375
layout::provide(providers);
33603376
util::provide(providers);
33613377
constness::provide(providers);
33623378
*providers = ty::query::Providers {
3379+
asyncness,
33633380
associated_item,
33643381
associated_item_def_ids,
33653382
adt_sized_constraint,

src/librustc_metadata/cstore_impl.rs

+1
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ provide! { <'tcx> tcx, def_id, other, cdata,
133133
fn_sig => { cdata.fn_sig(def_id.index, tcx) }
134134
inherent_impls => { cdata.get_inherent_implementations_for_type(tcx, def_id.index) }
135135
is_const_fn_raw => { cdata.is_const_fn_raw(def_id.index) }
136+
asyncness => { cdata.asyncness(def_id.index) }
136137
is_foreign_item => { cdata.is_foreign_item(def_id.index) }
137138
static_mutability => { cdata.static_mutability(def_id.index) }
138139
def_kind => { cdata.def_kind(def_id.index) }

src/librustc_metadata/decoder.rs

+9
Original file line numberDiff line numberDiff line change
@@ -1212,6 +1212,15 @@ impl<'a, 'tcx> CrateMetadata {
12121212
constness == hir::Constness::Const
12131213
}
12141214

1215+
pub fn asyncness(&self, id: DefIndex) -> hir::IsAsync {
1216+
match self.entry(id).kind {
1217+
EntryKind::Fn(data) => data.decode(self).asyncness,
1218+
EntryKind::Method(data) => data.decode(self).fn_data.asyncness,
1219+
EntryKind::ForeignFn(data) => data.decode(self).asyncness,
1220+
_ => bug!("asyncness: expect functions entry."),
1221+
}
1222+
}
1223+
12151224
pub fn is_foreign_item(&self, id: DefIndex) -> bool {
12161225
match self.entry(id).kind {
12171226
EntryKind::ForeignImmStatic |

src/librustc_metadata/encoder.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -875,7 +875,7 @@ impl EncodeContext<'tcx> {
875875
EntryKind::AssocConst(container, const_qualif, rendered_const)
876876
}
877877
ty::AssocKind::Method => {
878-
let fn_data = if let hir::TraitItemKind::Method(_, ref m) = ast_item.node {
878+
let fn_data = if let hir::TraitItemKind::Method(method_sig, m) = &ast_item.node {
879879
let param_names = match *m {
880880
hir::TraitMethod::Required(ref names) => {
881881
self.encode_fn_param_names(names)
@@ -885,6 +885,7 @@ impl EncodeContext<'tcx> {
885885
}
886886
};
887887
FnData {
888+
asyncness: method_sig.header.asyncness,
888889
constness: hir::Constness::NotConst,
889890
param_names,
890891
sig: self.lazy(&tcx.fn_sig(def_id)),
@@ -982,6 +983,7 @@ impl EncodeContext<'tcx> {
982983
ty::AssocKind::Method => {
983984
let fn_data = if let hir::ImplItemKind::Method(ref sig, body) = ast_item.node {
984985
FnData {
986+
asyncness: sig.header.asyncness,
985987
constness: sig.header.constness,
986988
param_names: self.encode_fn_param_names_for_body(body),
987989
sig: self.lazy(&tcx.fn_sig(def_id)),
@@ -1128,6 +1130,7 @@ impl EncodeContext<'tcx> {
11281130
}
11291131
hir::ItemKind::Fn(_, header, .., body) => {
11301132
let data = FnData {
1133+
asyncness: header.asyncness,
11311134
constness: header.constness,
11321135
param_names: self.encode_fn_param_names_for_body(body),
11331136
sig: self.lazy(tcx.fn_sig(def_id)),
@@ -1675,6 +1678,7 @@ impl EncodeContext<'tcx> {
16751678
let kind = match nitem.node {
16761679
hir::ForeignItemKind::Fn(_, ref names, _) => {
16771680
let data = FnData {
1681+
asyncness: hir::IsAsync::NotAsync,
16781682
constness: hir::Constness::NotConst,
16791683
param_names: self.encode_fn_param_names(names),
16801684
sig: self.lazy(tcx.fn_sig(def_id)),

src/librustc_metadata/schema.rs

+1
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ pub struct MacroDef {
295295

296296
#[derive(RustcEncodable, RustcDecodable)]
297297
pub struct FnData<'tcx> {
298+
pub asyncness: hir::IsAsync,
298299
pub constness: hir::Constness,
299300
pub param_names: Lazy<[ast::Name]>,
300301
pub sig: Lazy<ty::PolyFnSig<'tcx>>,

src/librustc_typeck/check/pat.rs

+46-13
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
676676
}
677677
} else {
678678
// Pattern has wrong number of fields.
679-
self.e0023(pat.span, res, &subpats, &variant.fields, expected);
679+
self.e0023(pat.span, res, qpath, subpats, &variant.fields, expected);
680680
on_error();
681681
return tcx.types.err;
682682
}
@@ -687,22 +687,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
687687
&self,
688688
pat_span: Span,
689689
res: Res,
690+
qpath: &hir::QPath,
690691
subpats: &'tcx [P<Pat>],
691692
fields: &[ty::FieldDef],
692693
expected: Ty<'tcx>
693694
) {
694695
let subpats_ending = pluralise!(subpats.len());
695696
let fields_ending = pluralise!(fields.len());
696-
let missing_parenthesis = match expected.sty {
697-
ty::Adt(_, substs) if fields.len() == 1 => {
698-
let field_ty = fields[0].ty(self.tcx, substs);
699-
match field_ty.sty {
700-
ty::Tuple(_) => field_ty.tuple_fields().count() == subpats.len(),
701-
_ => false,
702-
}
703-
}
704-
_ => false,
705-
};
706697
let res_span = self.tcx.def_span(res.def_id());
707698
let mut err = struct_span_err!(
708699
self.tcx.sess,
@@ -723,11 +714,53 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
723714
))
724715
.span_label(res_span, format!("{} defined here", res.descr()));
725716

717+
// Identify the case `Some(x, y)` where the expected type is e.g. `Option<(T, U)>`.
718+
// More generally, the expected type wants a tuple variant with one field of an
719+
// N-arity-tuple, e.g., `V_i((p_0, .., p_N))`. Meanwhile, the user supplied a pattern
720+
// with the subpatterns directly in the tuple variant pattern, e.g., `V_i(p_0, .., p_N)`.
721+
let missing_parenthesis = match expected.sty {
722+
ty::Adt(_, substs) if fields.len() == 1 => {
723+
let field_ty = fields[0].ty(self.tcx, substs);
724+
match field_ty.sty {
725+
ty::Tuple(_) => field_ty.tuple_fields().count() == subpats.len(),
726+
_ => false,
727+
}
728+
}
729+
_ => false,
730+
};
726731
if missing_parenthesis {
732+
let (left, right) = match subpats {
733+
// This is the zero case; we aim to get the "hi" part of the `QPath`'s
734+
// span as the "lo" and then the "hi" part of the pattern's span as the "hi".
735+
// This looks like:
736+
//
737+
// help: missing parenthesis
738+
// |
739+
// L | let A(()) = A(());
740+
// | ^ ^
741+
[] => {
742+
let qpath_span = match qpath {
743+
hir::QPath::Resolved(_, path) => path.span,
744+
hir::QPath::TypeRelative(_, ps) => ps.ident.span,
745+
};
746+
(qpath_span.shrink_to_hi(), pat_span)
747+
},
748+
// Easy case. Just take the "lo" of the first sub-pattern and the "hi" of the
749+
// last sub-pattern. In the case of `A(x)` the first and last may coincide.
750+
// This looks like:
751+
//
752+
// help: missing parenthesis
753+
// |
754+
// L | let A((x, y)) = A((1, 2));
755+
// | ^ ^
756+
[first, ..] => (first.span.shrink_to_lo(), subpats.last().unwrap().span),
757+
};
727758
err.multipart_suggestion(
728759
"missing parenthesis",
729-
vec![(subpats[0].span.shrink_to_lo(), "(".to_string()),
730-
(subpats[subpats.len()-1].span.shrink_to_hi(), ")".to_string())],
760+
vec![
761+
(left, "(".to_string()),
762+
(right.shrink_to_hi(), ")".to_string()),
763+
],
731764
Applicability::MachineApplicable,
732765
);
733766
}

src/librustdoc/clean/inline.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ fn build_external_function(cx: &DocContext<'_>, did: DefId) -> clean::Function {
217217
} else {
218218
hir::Constness::NotConst
219219
};
220-
220+
let asyncness = cx.tcx.asyncness(did);
221221
let predicates = cx.tcx.predicates_of(did);
222222
let (generics, decl) = clean::enter_impl_trait(cx, || {
223223
((cx.tcx.generics_of(did), &predicates).clean(cx), (did, sig).clean(cx))
@@ -230,7 +230,7 @@ fn build_external_function(cx: &DocContext<'_>, did: DefId) -> clean::Function {
230230
unsafety: sig.unsafety(),
231231
abi: sig.abi(),
232232
constness,
233-
asyncness: hir::IsAsync::NotAsync,
233+
asyncness,
234234
},
235235
all_types,
236236
ret_types,

src/librustdoc/clean/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -2403,6 +2403,7 @@ impl Clean<Item> for ty::AssocItem {
24032403
} else {
24042404
hir::Constness::NotConst
24052405
};
2406+
let asyncness = cx.tcx.asyncness(self.def_id);
24062407
let defaultness = match self.container {
24072408
ty::ImplContainer(_) => Some(self.defaultness),
24082409
ty::TraitContainer(_) => None,
@@ -2414,7 +2415,7 @@ impl Clean<Item> for ty::AssocItem {
24142415
unsafety: sig.unsafety(),
24152416
abi: sig.abi(),
24162417
constness,
2417-
asyncness: hir::IsAsync::NotAsync,
2418+
asyncness,
24182419
},
24192420
defaultness,
24202421
all_types,

src/stage0.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# source tarball for a stable release you'll likely see `1.x.0` for rustc and
1313
# `0.x.0` for Cargo where they were released on `date`.
1414

15-
date: 2019-09-24
15+
date: 2019-09-26
1616
rustc: 1.38.0
1717
cargo: 0.39.0
1818

@@ -34,4 +34,4 @@ cargo: 0.39.0
3434
# looking at a beta source tarball and it's uncommented we'll shortly comment it
3535
# out.
3636

37-
dev: 1
37+
#dev: 1

src/test/rustdoc/inline_cross/auxiliary/impl_trait_aux.rs

+10
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// edition:2018
2+
13
use std::ops::Deref;
24

35
pub fn func<'a>(_x: impl Clone + Into<Vec<u8>> + 'a) {}
@@ -11,8 +13,16 @@ pub fn func3(_x: impl Iterator<Item = impl Iterator<Item = u8>> + Clone) {}
1113

1214
pub fn func4<T: Iterator<Item = impl Clone>>(_x: T) {}
1315

16+
pub async fn async_fn() {}
17+
1418
pub struct Foo;
1519

1620
impl Foo {
1721
pub fn method<'a>(_x: impl Clone + Into<Vec<u8>> + 'a) {}
1822
}
23+
24+
pub struct Bar;
25+
26+
impl Bar {
27+
pub async fn async_foo(&self) {}
28+
}

src/test/rustdoc/inline_cross/impl_trait.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// aux-build:impl_trait_aux.rs
2+
// edition:2018
23

34
extern crate impl_trait_aux;
45

@@ -20,13 +21,20 @@ pub use impl_trait_aux::func2;
2021
// @!has - '//pre[@class="rust fn"]' 'where'
2122
pub use impl_trait_aux::func3;
2223

23-
2424
// @has impl_trait/fn.func4.html
2525
// @has - '//pre[@class="rust fn"]' "func4<T>("
2626
// @has - '//pre[@class="rust fn"]' "T: Iterator<Item = impl Clone>,"
2727
pub use impl_trait_aux::func4;
2828

29+
// @has impl_trait/fn.async_fn.html
30+
// @has - '//pre[@class="rust fn"]' "pub async fn async_fn()"
31+
pub use impl_trait_aux::async_fn;
32+
2933
// @has impl_trait/struct.Foo.html
3034
// @has - '//code[@id="method.v"]' "pub fn method<'a>(_x: impl Clone + Into<Vec<u8>> + 'a)"
3135
// @!has - '//code[@id="method.v"]' 'where'
3236
pub use impl_trait_aux::Foo;
37+
38+
// @has impl_trait/struct.Bar.html
39+
// @has - '//*[@id="method.async_foo"]' "pub async fn async_foo("
40+
pub use impl_trait_aux::Bar;

src/test/ui/error-codes/E0023.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@ enum Fruit {
22
Apple(String, String),
33
Pear(u32),
44
Orange((String, String)),
5+
Banana(()),
56
}
67

7-
88
fn main() {
99
let x = Fruit::Apple(String::new(), String::new());
1010
match x {
1111
Fruit::Apple(a) => {}, //~ ERROR E0023
1212
Fruit::Apple(a, b, c) => {}, //~ ERROR E0023
1313
Fruit::Pear(1, 2) => {}, //~ ERROR E0023
1414
Fruit::Orange(a, b) => {}, //~ ERROR E0023
15+
Fruit::Banana() => {}, //~ ERROR E0023
1516
}
1617
}

src/test/ui/error-codes/E0023.stderr

+14-1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,19 @@ help: missing parenthesis
3838
LL | Fruit::Orange((a, b)) => {},
3939
| ^ ^
4040

41-
error: aborting due to 4 previous errors
41+
error[E0023]: this pattern has 0 fields, but the corresponding tuple variant has 1 field
42+
--> $DIR/E0023.rs:15:9
43+
|
44+
LL | Banana(()),
45+
| ---------- tuple variant defined here
46+
...
47+
LL | Fruit::Banana() => {},
48+
| ^^^^^^^^^^^^^^^ expected 1 field, found 0
49+
help: missing parenthesis
50+
|
51+
LL | Fruit::Banana(()) => {},
52+
| ^ ^
53+
54+
error: aborting due to 5 previous errors
4255

4356
For more information about this error, try `rustc --explain E0023`.

0 commit comments

Comments
 (0)