Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 4d44e09

Browse files
committedSep 23, 2022
Auto merge of #102165 - matthiaskrgr:rollup-n5oquhe, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - #100734 (Split out async_fn_in_trait into a separate feature) - #101664 (Note if mismatched types have a similar name) - #101815 (Migrated the rustc_passes annotation without effect diagnostic infrastructure) - #102042 (Distribute rust-docs-json via rustup.) - #102066 (rustdoc: remove unnecessary `max-width` on headers) - #102095 (Deduplicate two functions that would soon have been three) - #102104 (Set 'exec-env:RUST_BACKTRACE=0' in const-eval-select tests) - #102112 (Allow full relro on powerpc64-unknown-linux-gnu) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents bc4d574 + 8e3b9bc commit 4d44e09

37 files changed

+442
-72
lines changed
 

‎compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,15 @@ impl FnDeclKind {
332332
_ => false,
333333
}
334334
}
335+
336+
fn async_fn_allowed(&self, tcx: TyCtxt<'_>) -> bool {
337+
match self {
338+
FnDeclKind::Fn | FnDeclKind::Inherent => true,
339+
FnDeclKind::Impl if tcx.features().async_fn_in_trait => true,
340+
FnDeclKind::Trait if tcx.features().async_fn_in_trait => true,
341+
_ => false,
342+
}
343+
}
335344
}
336345

337346
#[derive(Copy, Clone)]
@@ -1692,14 +1701,14 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
16921701
}));
16931702

16941703
let output = if let Some((ret_id, span)) = make_ret_async {
1695-
if !kind.impl_trait_allowed(self.tcx) {
1704+
if !kind.async_fn_allowed(self.tcx) {
16961705
match kind {
16971706
FnDeclKind::Trait | FnDeclKind::Impl => {
16981707
self.tcx
16991708
.sess
17001709
.create_feature_err(
17011710
TraitFnAsync { fn_span, span },
1702-
sym::return_position_impl_trait_in_trait,
1711+
sym::async_fn_in_trait,
17031712
)
17041713
.emit();
17051714
}
@@ -1917,9 +1926,13 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
19171926
let future_bound = this.lower_async_fn_output_type_to_future_bound(
19181927
output,
19191928
span,
1920-
ImplTraitContext::ReturnPositionOpaqueTy {
1921-
origin: hir::OpaqueTyOrigin::FnReturn(fn_def_id),
1922-
in_trait,
1929+
if in_trait && !this.tcx.features().return_position_impl_trait_in_trait {
1930+
ImplTraitContext::Disallowed(ImplTraitPosition::TraitReturn)
1931+
} else {
1932+
ImplTraitContext::ReturnPositionOpaqueTy {
1933+
origin: hir::OpaqueTyOrigin::FnReturn(fn_def_id),
1934+
in_trait,
1935+
}
19231936
},
19241937
);
19251938

‎compiler/rustc_error_messages/locales/en-US/passes.ftl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,3 +268,6 @@ passes_link_ordinal = attribute should be applied to a foreign function or stati
268268
269269
passes_collapse_debuginfo = `collapse_debuginfo` attribute should be applied to macro definitions
270270
.label = not a macro definition
271+
272+
passes_deprecated_annotation_has_no_effect = this `#[deprecated]` annotation has no effect
273+
.suggestion = remove the unnecessary deprecation attribute

‎compiler/rustc_feature/src/active.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,8 @@ declare_features! (
312312
(active, associated_type_defaults, "1.2.0", Some(29661), None),
313313
/// Allows `async || body` closures.
314314
(active, async_closure, "1.37.0", Some(62290), None),
315+
/// Alows async functions to be declared, implemented, and used in traits.
316+
(incomplete, async_fn_in_trait, "CURRENT_RUSTC_VERSION", Some(91611), None),
315317
/// Allows `extern "C-unwind" fn` to enable unwinding across ABI boundaries.
316318
(active, c_unwind, "1.52.0", Some(74990), None),
317319
/// Allows using C-variadics.

‎compiler/rustc_infer/src/infer/error_reporting/mod.rs

Lines changed: 111 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ use super::{InferCtxt, RegionVariableOrigin, SubregionOrigin, TypeTrace, ValuePa
5151

5252
use crate::infer;
5353
use crate::infer::error_reporting::nice_region_error::find_anon_type::find_anon_type;
54+
use crate::infer::ExpectedFound;
5455
use crate::traits::error_reporting::report_object_safety_error;
5556
use crate::traits::{
5657
IfExpressionCause, MatchExpressionArmCause, ObligationCause, ObligationCauseCode,
@@ -1653,8 +1654,114 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
16531654
),
16541655
Mismatch::Fixed(s) => (s.into(), s.into(), None),
16551656
};
1656-
match (&terr, expected == found) {
1657-
(TypeError::Sorts(values), extra) => {
1657+
1658+
enum Similar<'tcx> {
1659+
Adts { expected: ty::AdtDef<'tcx>, found: ty::AdtDef<'tcx> },
1660+
PrimitiveFound { expected: ty::AdtDef<'tcx>, found: Ty<'tcx> },
1661+
PrimitiveExpected { expected: Ty<'tcx>, found: ty::AdtDef<'tcx> },
1662+
}
1663+
1664+
let similarity = |ExpectedFound { expected, found }: ExpectedFound<Ty<'tcx>>| {
1665+
if let ty::Adt(expected, _) = expected.kind() && let Some(primitive) = found.primitive_symbol() {
1666+
let path = self.tcx.def_path(expected.did()).data;
1667+
let name = path.last().unwrap().data.get_opt_name();
1668+
if name == Some(primitive) {
1669+
return Some(Similar::PrimitiveFound { expected: *expected, found });
1670+
}
1671+
} else if let Some(primitive) = expected.primitive_symbol() && let ty::Adt(found, _) = found.kind() {
1672+
let path = self.tcx.def_path(found.did()).data;
1673+
let name = path.last().unwrap().data.get_opt_name();
1674+
if name == Some(primitive) {
1675+
return Some(Similar::PrimitiveExpected { expected, found: *found });
1676+
}
1677+
} else if let ty::Adt(expected, _) = expected.kind() && let ty::Adt(found, _) = found.kind() {
1678+
if !expected.did().is_local() && expected.did().krate == found.did().krate {
1679+
// Most likely types from different versions of the same crate
1680+
// are in play, in which case this message isn't so helpful.
1681+
// A "perhaps two different versions..." error is already emitted for that.
1682+
return None;
1683+
}
1684+
let f_path = self.tcx.def_path(found.did()).data;
1685+
let e_path = self.tcx.def_path(expected.did()).data;
1686+
1687+
if let (Some(e_last), Some(f_last)) = (e_path.last(), f_path.last()) && e_last == f_last {
1688+
return Some(Similar::Adts{expected: *expected, found: *found});
1689+
}
1690+
}
1691+
None
1692+
};
1693+
1694+
match terr {
1695+
// If two types mismatch but have similar names, mention that specifically.
1696+
TypeError::Sorts(values) if let Some(s) = similarity(values) => {
1697+
let diagnose_primitive =
1698+
|prim: Ty<'tcx>,
1699+
shadow: Ty<'tcx>,
1700+
defid: DefId,
1701+
diagnostic: &mut Diagnostic| {
1702+
let name = shadow.sort_string(self.tcx);
1703+
diagnostic.note(format!(
1704+
"{prim} and {name} have similar names, but are actually distinct types"
1705+
));
1706+
diagnostic
1707+
.note(format!("{prim} is a primitive defined by the language"));
1708+
let def_span = self.tcx.def_span(defid);
1709+
let msg = if defid.is_local() {
1710+
format!("{name} is defined in the current crate")
1711+
} else {
1712+
let crate_name = self.tcx.crate_name(defid.krate);
1713+
format!("{name} is defined in crate `{crate_name}")
1714+
};
1715+
diagnostic.span_note(def_span, msg);
1716+
};
1717+
1718+
let diagnose_adts =
1719+
|expected_adt : ty::AdtDef<'tcx>,
1720+
found_adt: ty::AdtDef<'tcx>,
1721+
diagnostic: &mut Diagnostic| {
1722+
let found_name = values.found.sort_string(self.tcx);
1723+
let expected_name = values.expected.sort_string(self.tcx);
1724+
1725+
let found_defid = found_adt.did();
1726+
let expected_defid = expected_adt.did();
1727+
1728+
diagnostic.note(format!("{found_name} and {expected_name} have similar names, but are actually distinct types"));
1729+
for (defid, name) in
1730+
[(found_defid, found_name), (expected_defid, expected_name)]
1731+
{
1732+
let def_span = self.tcx.def_span(defid);
1733+
1734+
let msg = if found_defid.is_local() && expected_defid.is_local() {
1735+
let module = self
1736+
.tcx
1737+
.parent_module_from_def_id(defid.expect_local())
1738+
.to_def_id();
1739+
let module_name = self.tcx.def_path(module).to_string_no_crate_verbose();
1740+
format!("{name} is defined in module `crate{module_name}` of the current crate")
1741+
} else if defid.is_local() {
1742+
format!("{name} is defined in the current crate")
1743+
} else {
1744+
let crate_name = self.tcx.crate_name(defid.krate);
1745+
format!("{name} is defined in crate `{crate_name}`")
1746+
};
1747+
diagnostic.span_note(def_span, msg);
1748+
}
1749+
};
1750+
1751+
match s {
1752+
Similar::Adts{expected, found} => {
1753+
diagnose_adts(expected, found, diag)
1754+
}
1755+
Similar::PrimitiveFound{expected, found: prim} => {
1756+
diagnose_primitive(prim, values.expected, expected.did(), diag)
1757+
}
1758+
Similar::PrimitiveExpected{expected: prim, found} => {
1759+
diagnose_primitive(prim, values.found, found.did(), diag)
1760+
}
1761+
}
1762+
}
1763+
TypeError::Sorts(values) => {
1764+
let extra = expected == found;
16581765
let sort_string = |ty: Ty<'tcx>| match (extra, ty.kind()) {
16591766
(true, ty::Opaque(def_id, _)) => {
16601767
let sm = self.tcx.sess.source_map();
@@ -1707,10 +1814,10 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
17071814
);
17081815
}
17091816
}
1710-
(TypeError::ObjectUnsafeCoercion(_), _) => {
1817+
TypeError::ObjectUnsafeCoercion(_) => {
17111818
diag.note_unsuccessful_coercion(found, expected);
17121819
}
1713-
(_, _) => {
1820+
_ => {
17141821
debug!(
17151822
"note_type_err: exp_found={:?}, expected={:?} found={:?}",
17161823
exp_found, expected, found

‎compiler/rustc_infer/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#![cfg_attr(bootstrap, feature(label_break_value))]
2121
#![feature(let_chains)]
2222
#![cfg_attr(bootstrap, feature(let_else))]
23+
#![feature(if_let_guard)]
2324
#![feature(min_specialization)]
2425
#![feature(never_type)]
2526
#![feature(try_blocks)]

‎compiler/rustc_middle/src/ty/sty.rs

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use rustc_hir as hir;
1919
use rustc_hir::def_id::DefId;
2020
use rustc_index::vec::Idx;
2121
use rustc_macros::HashStable;
22-
use rustc_span::symbol::{kw, Symbol};
22+
use rustc_span::symbol::{kw, sym, Symbol};
2323
use rustc_target::abi::VariantIdx;
2424
use rustc_target::spec::abi;
2525
use std::borrow::Cow;
@@ -2207,6 +2207,35 @@ impl<'tcx> Ty<'tcx> {
22072207
}
22082208
}
22092209
}
2210+
2211+
// If `self` is a primitive, return its [`Symbol`].
2212+
pub fn primitive_symbol(self) -> Option<Symbol> {
2213+
match self.kind() {
2214+
ty::Bool => Some(sym::bool),
2215+
ty::Char => Some(sym::char),
2216+
ty::Float(f) => match f {
2217+
ty::FloatTy::F32 => Some(sym::f32),
2218+
ty::FloatTy::F64 => Some(sym::f64),
2219+
},
2220+
ty::Int(f) => match f {
2221+
ty::IntTy::Isize => Some(sym::isize),
2222+
ty::IntTy::I8 => Some(sym::i8),
2223+
ty::IntTy::I16 => Some(sym::i16),
2224+
ty::IntTy::I32 => Some(sym::i32),
2225+
ty::IntTy::I64 => Some(sym::i64),
2226+
ty::IntTy::I128 => Some(sym::i128),
2227+
},
2228+
ty::Uint(f) => match f {
2229+
ty::UintTy::Usize => Some(sym::usize),
2230+
ty::UintTy::U8 => Some(sym::u8),
2231+
ty::UintTy::U16 => Some(sym::u16),
2232+
ty::UintTy::U32 => Some(sym::u32),
2233+
ty::UintTy::U64 => Some(sym::u64),
2234+
ty::UintTy::U128 => Some(sym::u128),
2235+
},
2236+
_ => None,
2237+
}
2238+
}
22102239
}
22112240

22122241
/// Extra information about why we ended up with a particular variance.

‎compiler/rustc_passes/src/errors.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -658,3 +658,10 @@ pub struct CollapseDebuginfo {
658658
#[label]
659659
pub defn_span: Span,
660660
}
661+
662+
#[derive(LintDiagnostic)]
663+
#[diag(passes::deprecated_annotation_has_no_effect)]
664+
pub struct DeprecatedAnnotationHasNoEffect {
665+
#[suggestion(applicability = "machine-applicable", code = "")]
666+
pub span: Span,
667+
}

‎compiler/rustc_passes/src/stability.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//! A pass that annotates every item and method with its stability level,
22
//! propagating default levels lexically from parent to children ast nodes.
33
4+
use crate::errors;
45
use rustc_attr::{
56
self as attr, rust_version_symbol, ConstStability, Stability, StabilityLevel, Unstable,
67
UnstableReason, VERSION_PLACEHOLDER,
@@ -122,16 +123,12 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {
122123

123124
if kind == AnnotationKind::Prohibited || kind == AnnotationKind::DeprecationProhibited {
124125
let hir_id = self.tcx.hir().local_def_id_to_hir_id(def_id);
125-
self.tcx.struct_span_lint_hir(USELESS_DEPRECATED, hir_id, *span, |lint| {
126-
lint.build("this `#[deprecated]` annotation has no effect")
127-
.span_suggestion_short(
128-
*span,
129-
"remove the unnecessary deprecation attribute",
130-
"",
131-
rustc_errors::Applicability::MachineApplicable,
132-
)
133-
.emit();
134-
});
126+
self.tcx.emit_spanned_lint(
127+
USELESS_DEPRECATED,
128+
hir_id,
129+
*span,
130+
errors::DeprecatedAnnotationHasNoEffect { span: *span },
131+
);
135132
}
136133

137134
// `Deprecation` is just two pointers, no need to intern it

‎compiler/rustc_span/src/symbol.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,7 @@ symbols! {
396396
assume_init,
397397
async_await,
398398
async_closure,
399+
async_fn_in_trait,
399400
atomic,
400401
atomic_mod,
401402
atomics,

‎compiler/rustc_target/src/spec/powerpc64_unknown_linux_gnu.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
use crate::abi::Endian;
2-
use crate::spec::{LinkerFlavor, RelroLevel, Target, TargetOptions};
2+
use crate::spec::{LinkerFlavor, Target, TargetOptions};
33

44
pub fn target() -> Target {
55
let mut base = super::linux_gnu_base::opts();
66
base.cpu = "ppc64".into();
77
base.add_pre_link_args(LinkerFlavor::Gcc, &["-m64"]);
88
base.max_atomic_width = Some(64);
99

10-
// ld.so in at least RHEL6 on ppc64 has a bug related to BIND_NOW, so only enable partial RELRO
11-
// for now. https://github.com/rust-lang/rust/pull/43170#issuecomment-315411474
12-
base.relro_level = RelroLevel::Partial;
13-
1410
Target {
1511
llvm_target: "powerpc64-unknown-linux-gnu".into(),
1612
pointer_width: 64,

‎compiler/rustc_typeck/src/check/writeback.rs

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -717,27 +717,13 @@ impl<'cx, 'tcx> Resolver<'cx, 'tcx> {
717717
Resolver { tcx: fcx.tcx, infcx: fcx, span, body, replaced_with_error: false }
718718
}
719719

720-
fn report_type_error(&self, t: Ty<'tcx>) {
720+
fn report_error(&self, p: impl Into<ty::GenericArg<'tcx>>) {
721721
if !self.tcx.sess.has_errors().is_some() {
722722
self.infcx
723723
.emit_inference_failure_err(
724724
Some(self.body.id()),
725725
self.span.to_span(self.tcx),
726-
t.into(),
727-
E0282,
728-
false,
729-
)
730-
.emit();
731-
}
732-
}
733-
734-
fn report_const_error(&self, c: ty::Const<'tcx>) {
735-
if self.tcx.sess.has_errors().is_none() {
736-
self.infcx
737-
.emit_inference_failure_err(
738-
Some(self.body.id()),
739-
self.span.to_span(self.tcx),
740-
c.into(),
726+
p.into(),
741727
E0282,
742728
false,
743729
)
@@ -782,7 +768,7 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for Resolver<'cx, 'tcx> {
782768
}
783769
Err(_) => {
784770
debug!("Resolver::fold_ty: input type `{:?}` not fully resolvable", t);
785-
self.report_type_error(t);
771+
self.report_error(t);
786772
self.replaced_with_error = true;
787773
self.tcx().ty_error()
788774
}
@@ -799,7 +785,7 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for Resolver<'cx, 'tcx> {
799785
Ok(ct) => self.tcx.erase_regions(ct),
800786
Err(_) => {
801787
debug!("Resolver::fold_const: input const `{:?}` not fully resolvable", ct);
802-
self.report_const_error(ct);
788+
self.report_error(ct);
803789
self.replaced_with_error = true;
804790
self.tcx().const_error(ct.ty())
805791
}

‎src/bootstrap/dist.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -86,29 +86,23 @@ impl Step for JsonDocs {
8686

8787
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
8888
let default = run.builder.config.docs;
89-
run.alias("rust-json-docs").default_condition(default)
89+
run.alias("rust-docs-json").default_condition(default)
9090
}
9191

9292
fn make_run(run: RunConfig<'_>) {
9393
run.builder.ensure(JsonDocs { host: run.target });
9494
}
9595

96-
/// Builds the `rust-json-docs` installer component.
96+
/// Builds the `rust-docs-json` installer component.
9797
fn run(self, builder: &Builder<'_>) -> Option<GeneratedTarball> {
98-
// This prevents JSON docs from being built for "dist" or "install"
99-
// on the stable/beta channels. The JSON format is not stable yet and
100-
// should not be included in stable/beta toolchains.
101-
if !builder.build.unstable_features() {
102-
return None;
103-
}
104-
10598
let host = self.host;
10699
builder.ensure(crate::doc::JsonStd { stage: builder.top_stage, target: host });
107100

108101
let dest = "share/doc/rust/json";
109102

110-
let mut tarball = Tarball::new(builder, "rust-json-docs", &host.triple);
103+
let mut tarball = Tarball::new(builder, "rust-docs-json", &host.triple);
111104
tarball.set_product_name("Rust Documentation In JSON Format");
105+
tarball.is_preview(true);
112106
tarball.add_bulk_dir(&builder.json_doc_out(host), dest);
113107
Some(tarball.generate())
114108
}

‎src/librustdoc/html/static/css/rustdoc.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,6 @@ h2.location a {
666666
}
667667

668668
.method > .code-header, .trait-impl > .code-header {
669-
max-width: calc(100% - 41px);
670669
display: block;
671670
}
672671

‎src/test/rustdoc-gui/notable-trait.goml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ assert-position: (
8383
)
8484

8585
// Checking on very small mobile. The `i` should be on its own line.
86-
size: (410, 600)
86+
size: (365, 600)
8787
compare-elements-position-false: (
8888
"//*[@id='method.create_an_iterator_from_read']//a[text()='NotableStructWithLongName']",
8989
"//*[@id='method.create_an_iterator_from_read']//*[@class='notable-traits']",

‎src/test/ui/async-await/async-trait-fn.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ LL | async fn foo() {}
99
= note: `async` trait functions are not currently supported
1010
= note: consider using the `async-trait` crate: https://crates.io/crates/async-trait
1111
= note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
12-
= help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable
12+
= help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable
1313

1414
error[E0706]: functions in traits cannot be declared `async`
1515
--> $DIR/async-trait-fn.rs:5:5
@@ -22,7 +22,7 @@ LL | async fn bar(&self) {}
2222
= note: `async` trait functions are not currently supported
2323
= note: consider using the `async-trait` crate: https://crates.io/crates/async-trait
2424
= note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
25-
= help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable
25+
= help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable
2626

2727
error[E0706]: functions in traits cannot be declared `async`
2828
--> $DIR/async-trait-fn.rs:7:5
@@ -35,7 +35,7 @@ LL | async fn baz() {
3535
= note: `async` trait functions are not currently supported
3636
= note: consider using the `async-trait` crate: https://crates.io/crates/async-trait
3737
= note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
38-
= help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable
38+
= help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable
3939

4040
error[E0308]: mismatched types
4141
--> $DIR/async-trait-fn.rs:3:20

‎src/test/ui/async-await/edition-deny-async-fns-2015.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ LL | async fn foo() {}
9090
= note: `async` trait functions are not currently supported
9191
= note: consider using the `async-trait` crate: https://crates.io/crates/async-trait
9292
= note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
93-
= help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable
93+
= help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable
9494

9595
error[E0308]: mismatched types
9696
--> $DIR/edition-deny-async-fns-2015.rs:18:20
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// edition:2021
2+
3+
// RPITIT is not enough to allow use of async functions
4+
#![allow(incomplete_features)]
5+
#![feature(return_position_impl_trait_in_trait)]
6+
7+
trait T {
8+
async fn foo(); //~ ERROR functions in traits cannot be declared `async`
9+
}
10+
11+
// Both return_position_impl_trait_in_trait and async_fn_in_trait are required for this (see also
12+
// feature-gate-return_position_impl_trait_in_trait.rs)
13+
trait T2 {
14+
async fn foo() -> impl Sized; //~ ERROR functions in traits cannot be declared `async`
15+
}
16+
17+
trait T3 {
18+
fn foo() -> impl std::future::Future<Output = ()>;
19+
}
20+
21+
impl T3 for () {
22+
async fn foo() {} //~ ERROR functions in traits cannot be declared `async`
23+
}
24+
25+
fn main() {}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
error[E0706]: functions in traits cannot be declared `async`
2+
--> $DIR/feature-gate-async_fn_in_trait.rs:8:5
3+
|
4+
LL | async fn foo();
5+
| -----^^^^^^^^^^
6+
| |
7+
| `async` because of this
8+
|
9+
= note: `async` trait functions are not currently supported
10+
= note: consider using the `async-trait` crate: https://crates.io/crates/async-trait
11+
= note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
12+
= help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable
13+
14+
error[E0706]: functions in traits cannot be declared `async`
15+
--> $DIR/feature-gate-async_fn_in_trait.rs:14:5
16+
|
17+
LL | async fn foo() -> impl Sized;
18+
| -----^^^^^^^^^^^^^^^^^^^^^^^^
19+
| |
20+
| `async` because of this
21+
|
22+
= note: `async` trait functions are not currently supported
23+
= note: consider using the `async-trait` crate: https://crates.io/crates/async-trait
24+
= note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
25+
= help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable
26+
27+
error[E0706]: functions in traits cannot be declared `async`
28+
--> $DIR/feature-gate-async_fn_in_trait.rs:22:5
29+
|
30+
LL | async fn foo() {}
31+
| -----^^^^^^^^^
32+
| |
33+
| `async` because of this
34+
|
35+
= note: `async` trait functions are not currently supported
36+
= note: consider using the `async-trait` crate: https://crates.io/crates/async-trait
37+
= note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
38+
= help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable
39+
40+
error: aborting due to 3 previous errors
41+
42+
For more information about this error, try `rustc --explain E0706`.

‎src/test/ui/async-await/issues/issue-95307.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ LL | async fn new() -> [u8; _];
99
= note: `async` trait functions are not currently supported
1010
= note: consider using the `async-trait` crate: https://crates.io/crates/async-trait
1111
= note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
12-
= help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable
12+
= help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable
1313

1414
error: in expressions, `_` can only be used on the left-hand side of an assignment
1515
--> $DIR/issue-95307.rs:7:28
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
1+
// edition:2021
2+
3+
// async_fn_in_trait is not enough to allow use of RPITIT
4+
#![allow(incomplete_features)]
5+
#![feature(async_fn_in_trait)]
6+
17
trait Foo {
28
fn bar() -> impl Sized; //~ ERROR `impl Trait` only allowed in function and inherent method return types, not in trait method return
9+
fn baz() -> Box<impl std::fmt::Display>; //~ ERROR `impl Trait` only allowed in function and inherent method return types, not in trait method return
10+
}
11+
12+
// Both return_position_impl_trait_in_trait and async_fn_in_trait are required for this (see also
13+
// feature-gate-async_fn_in_trait.rs)
14+
trait AsyncFoo {
15+
async fn bar() -> impl Sized; //~ ERROR `impl Trait` only allowed in function and inherent method return types, not in trait method return
316
}
417

518
fn main() {}
Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,30 @@
11
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in trait method return
2-
--> $DIR/feature-gate-return_position_impl_trait_in_trait.rs:2:17
2+
--> $DIR/feature-gate-return_position_impl_trait_in_trait.rs:8:17
33
|
44
LL | fn bar() -> impl Sized;
55
| ^^^^^^^^^^
66
|
77
= note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
88
= help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable
99

10-
error: aborting due to previous error
10+
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in trait method return
11+
--> $DIR/feature-gate-return_position_impl_trait_in_trait.rs:9:21
12+
|
13+
LL | fn baz() -> Box<impl std::fmt::Display>;
14+
| ^^^^^^^^^^^^^^^^^^^^^^
15+
|
16+
= note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
17+
= help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable
18+
19+
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in trait method return
20+
--> $DIR/feature-gate-return_position_impl_trait_in_trait.rs:15:23
21+
|
22+
LL | async fn bar() -> impl Sized;
23+
| ^^^^^^^^^^
24+
|
25+
= note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
26+
= help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable
27+
28+
error: aborting due to 3 previous errors
1129

1230
For more information about this error, try `rustc --explain E0562`.

‎src/test/ui/fully-qualified-type/fully-qualified-type-name2.stderr

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,18 @@ LL | fn bar(x: x::Foo) -> y::Foo {
55
| ------ expected `y::Foo` because of return type
66
LL | return x;
77
| ^ expected enum `y::Foo`, found enum `x::Foo`
8+
|
9+
= note: enum `x::Foo` and enum `y::Foo` have similar names, but are actually distinct types
10+
note: enum `x::Foo` is defined in module `crate::x` of the current crate
11+
--> $DIR/fully-qualified-type-name2.rs:4:5
12+
|
13+
LL | pub enum Foo { }
14+
| ^^^^^^^^^^^^
15+
note: enum `y::Foo` is defined in module `crate::y` of the current crate
16+
--> $DIR/fully-qualified-type-name2.rs:8:5
17+
|
18+
LL | pub enum Foo { }
19+
| ^^^^^^^^^^^^
820

921
error: aborting due to previous error
1022

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// See issue #100696.
22
// run-fail
33
// check-run-results
4+
// exec-env:RUST_BACKTRACE=0
45
fn main() {
56
&""[1..];
67
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
thread 'main' panicked at 'byte index 1 is out of bounds of ``', $DIR/const-eval-select-backtrace-std.rs:5:6
1+
thread 'main' panicked at 'byte index 1 is out of bounds of ``', $DIR/const-eval-select-backtrace-std.rs:6:6
22
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

‎src/test/ui/intrinsics/const-eval-select-backtrace.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// See issue #100696.
33
// run-fail
44
// check-run-results
5+
// exec-env:RUST_BACKTRACE=0
56

67
#[track_caller]
78
fn uhoh() {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
thread 'main' panicked at 'Aaah!', $DIR/const-eval-select-backtrace.rs:16:9
1+
thread 'main' panicked at 'Aaah!', $DIR/const-eval-select-backtrace.rs:17:9
22
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
pub mod blah {
2+
pub mod baz {
3+
pub struct Foo;
4+
}
5+
}
6+
7+
pub mod meh {
8+
pub struct Foo;
9+
}
10+
11+
pub type Foo = blah::baz::Foo;
12+
13+
fn foo() -> Foo {
14+
meh::Foo
15+
//~^ ERROR mismatched types [E0308]
16+
}
17+
18+
fn main() {}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/show_module.rs:14:5
3+
|
4+
LL | fn foo() -> Foo {
5+
| --- expected `baz::Foo` because of return type
6+
LL | meh::Foo
7+
| ^^^^^^^^ expected struct `baz::Foo`, found struct `meh::Foo`
8+
|
9+
= note: struct `meh::Foo` and struct `baz::Foo` have similar names, but are actually distinct types
10+
note: struct `meh::Foo` is defined in module `crate::meh` of the current crate
11+
--> $DIR/show_module.rs:8:5
12+
|
13+
LL | pub struct Foo;
14+
| ^^^^^^^^^^^^^^
15+
note: struct `baz::Foo` is defined in module `crate::blah::baz` of the current crate
16+
--> $DIR/show_module.rs:3:9
17+
|
18+
LL | pub struct Foo;
19+
| ^^^^^^^^^^^^^^
20+
21+
error: aborting due to previous error
22+
23+
For more information about this error, try `rustc --explain E0308`.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
enum Option<T> {
2+
Some(T),
3+
None,
4+
}
5+
6+
pub fn foo() -> Option<u8> {
7+
Some(42_u8)
8+
//~^ ERROR mismatched types [E0308]
9+
}
10+
11+
fn main() {}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/similar_paths.rs:7:5
3+
|
4+
LL | pub fn foo() -> Option<u8> {
5+
| ---------- expected `Option<u8>` because of return type
6+
LL | Some(42_u8)
7+
| ^^^^^^^^^^^ expected enum `Option`, found enum `std::option::Option`
8+
|
9+
= note: enum `std::option::Option` and enum `Option` have similar names, but are actually distinct types
10+
note: enum `std::option::Option` is defined in crate `core`
11+
--> $SRC_DIR/core/src/option.rs:LL:COL
12+
|
13+
LL | pub enum Option<T> {
14+
| ^^^^^^^^^^^^^^^^^^
15+
note: enum `Option` is defined in the current crate
16+
--> $DIR/similar_paths.rs:1:1
17+
|
18+
LL | enum Option<T> {
19+
| ^^^^^^^^^^^^^^
20+
21+
error: aborting due to previous error
22+
23+
For more information about this error, try `rustc --explain E0308`.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#![allow(non_camel_case_types)]
2+
3+
struct bool;
4+
5+
fn foo(_: bool) {}
6+
7+
fn main() {
8+
foo(true);
9+
//~^ ERROR mismatched types [E0308]
10+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/similar_paths_primitive.rs:8:9
3+
|
4+
LL | foo(true);
5+
| --- ^^^^ expected struct `bool`, found `bool`
6+
| |
7+
| arguments to this function are incorrect
8+
|
9+
= note: bool and struct `bool` have similar names, but are actually distinct types
10+
= note: bool is a primitive defined by the language
11+
note: struct `bool` is defined in the current crate
12+
--> $DIR/similar_paths_primitive.rs:3:1
13+
|
14+
LL | struct bool;
15+
| ^^^^^^^^^^^
16+
note: function defined here
17+
--> $DIR/similar_paths_primitive.rs:5:4
18+
|
19+
LL | fn foo(_: bool) {}
20+
| ^^^ -------
21+
22+
error: aborting due to previous error
23+
24+
For more information about this error, try `rustc --explain E0308`.

‎src/test/ui/parser/fn-header-semantic-fail.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ LL | async fn ft1();
147147
= note: `async` trait functions are not currently supported
148148
= note: consider using the `async-trait` crate: https://crates.io/crates/async-trait
149149
= note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
150-
= help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable
150+
= help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable
151151

152152
error[E0706]: functions in traits cannot be declared `async`
153153
--> $DIR/fn-header-semantic-fail.rs:21:9
@@ -160,7 +160,7 @@ LL | const async unsafe extern "C" fn ft5();
160160
= note: `async` trait functions are not currently supported
161161
= note: consider using the `async-trait` crate: https://crates.io/crates/async-trait
162162
= note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
163-
= help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable
163+
= help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable
164164

165165
error[E0706]: functions in traits cannot be declared `async`
166166
--> $DIR/fn-header-semantic-fail.rs:29:9
@@ -173,7 +173,7 @@ LL | async fn ft1() {}
173173
= note: `async` trait functions are not currently supported
174174
= note: consider using the `async-trait` crate: https://crates.io/crates/async-trait
175175
= note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
176-
= help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable
176+
= help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable
177177

178178
error[E0706]: functions in traits cannot be declared `async`
179179
--> $DIR/fn-header-semantic-fail.rs:33:9
@@ -186,7 +186,7 @@ LL | const async unsafe extern "C" fn ft5() {}
186186
= note: `async` trait functions are not currently supported
187187
= note: consider using the `async-trait` crate: https://crates.io/crates/async-trait
188188
= note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
189-
= help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable
189+
= help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable
190190

191191
error[E0391]: cycle detected when computing type of `main::ff5::{opaque#0}`
192192
--> $DIR/fn-header-semantic-fail.rs:12:44

‎src/test/ui/resolve/issue-70736-async-fn-no-body-def-collector.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ LL | async fn associated();
3333
= note: `async` trait functions are not currently supported
3434
= note: consider using the `async-trait` crate: https://crates.io/crates/async-trait
3535
= note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
36-
= help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable
36+
= help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable
3737

3838
error[E0706]: functions in traits cannot be declared `async`
3939
--> $DIR/issue-70736-async-fn-no-body-def-collector.rs:15:5
@@ -46,7 +46,7 @@ LL | async fn associated();
4646
= note: `async` trait functions are not currently supported
4747
= note: consider using the `async-trait` crate: https://crates.io/crates/async-trait
4848
= note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
49-
= help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable
49+
= help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable
5050

5151
error: aborting due to 5 previous errors
5252

‎src/test/ui/span/drop-location-span-error-rust-2021-incompatible-closure-captures-93117.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ LL | trait C{async fn new(val: T) {}
5151
= note: `async` trait functions are not currently supported
5252
= note: consider using the `async-trait` crate: https://crates.io/crates/async-trait
5353
= note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
54-
= help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable
54+
= help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable
5555

5656
warning: changes to closure capture in Rust 2021 will affect drop order
5757
--> $DIR/drop-location-span-error-rust-2021-incompatible-closure-captures-93117.rs:6:57

‎src/test/ui/type/type-mismatch-same-crate-name.stderr

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,17 @@ LL | a::try_foo(foo2);
66
| |
77
| arguments to this function are incorrect
88
|
9+
= note: struct `main::a::Foo` and struct `main::a::Foo` have similar names, but are actually distinct types
10+
note: struct `main::a::Foo` is defined in crate `crate_a2`
11+
--> $DIR/auxiliary/crate_a2.rs:1:1
12+
|
13+
LL | pub struct Foo;
14+
| ^^^^^^^^^^^^^^
15+
note: struct `main::a::Foo` is defined in crate `crate_a1`
16+
--> $DIR/auxiliary/crate_a1.rs:1:1
17+
|
18+
LL | pub struct Foo;
19+
| ^^^^^^^^^^^^^^
920
= note: perhaps two different versions of crate `crate_a1` are being used?
1021
note: function defined here
1122
--> $DIR/auxiliary/crate_a1.rs:10:8

‎src/tools/build-manifest/src/main.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ static PKG_INSTALLERS: &[&str] = &["x86_64-apple-darwin", "aarch64-apple-darwin"
184184

185185
static MINGW: &[&str] = &["i686-pc-windows-gnu", "x86_64-pc-windows-gnu"];
186186

187-
static NIGHTLY_ONLY_COMPONENTS: &[&str] = &["miri-preview"];
187+
static NIGHTLY_ONLY_COMPONENTS: &[&str] = &["miri-preview", "rust-docs-json-preview"];
188188

189189
macro_rules! t {
190190
($e:expr) => {
@@ -294,6 +294,7 @@ impl Builder {
294294
package!("rust-mingw", MINGW);
295295
package!("rust-std", TARGETS);
296296
self.package("rust-docs", &mut manifest.pkg, HOSTS, DOCS_FALLBACK);
297+
self.package("rust-docs-json-preview", &mut manifest.pkg, HOSTS, DOCS_FALLBACK);
297298
package!("rust-src", &["*"]);
298299
package!("rls-preview", HOSTS);
299300
package!("rust-analyzer-preview", HOSTS);
@@ -379,6 +380,7 @@ impl Builder {
379380
rename("rustfmt", "rustfmt-preview");
380381
rename("clippy", "clippy-preview");
381382
rename("miri", "miri-preview");
383+
rename("rust-docs-json", "rust-docs-json-preview");
382384
rename("rust-analyzer", "rust-analyzer-preview");
383385
}
384386

@@ -435,6 +437,7 @@ impl Builder {
435437
host_component("rustfmt-preview"),
436438
host_component("llvm-tools-preview"),
437439
host_component("rust-analysis"),
440+
host_component("rust-docs-json"),
438441
]);
439442

440443
extensions.extend(

0 commit comments

Comments
 (0)
Please sign in to comment.