Auto merge of #104983 - matthiaskrgr:rollup-018sk73, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - #95836 (Use `rust_out{exe_suffix}` for doctests) - #104882 (notify lcnr on changes to `ObligationCtxt`) - #104892 (Explain how to get the discriminant out of a `#[repr(T)] enum` with payload) - #104917 (Allow non-org members to label `requires-debug-assertions`) - #104931 (Pretty-print generators with their `generator_kind`) - #104934 (Remove redundant `all` in cfg) - #104944 (Support unit tests for jsondoclint) - #104946 (rustdoc: improve popover focus handling JS) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
1eb62b1235
37 changed files with 318 additions and 114 deletions
|
@ -13,17 +13,17 @@
|
|||
|
||||
// The minimum alignment guaranteed by the architecture. This value is used to
|
||||
// add fast paths for low alignment values.
|
||||
#[cfg(all(any(target_arch = "x86",
|
||||
#[cfg(any(target_arch = "x86",
|
||||
target_arch = "arm",
|
||||
target_arch = "mips",
|
||||
target_arch = "powerpc",
|
||||
target_arch = "powerpc64")))]
|
||||
target_arch = "powerpc64"))]
|
||||
const MIN_ALIGN: usize = 8;
|
||||
#[cfg(all(any(target_arch = "x86_64",
|
||||
#[cfg(any(target_arch = "x86_64",
|
||||
target_arch = "aarch64",
|
||||
target_arch = "mips64",
|
||||
target_arch = "s390x",
|
||||
target_arch = "sparc64")))]
|
||||
target_arch = "sparc64"))]
|
||||
const MIN_ALIGN: usize = 16;
|
||||
|
||||
pub struct System;
|
||||
|
|
|
@ -376,7 +376,7 @@ impl<'tcx> NonConstOp<'tcx> for Generator {
|
|||
ccx: &ConstCx<'_, 'tcx>,
|
||||
span: Span,
|
||||
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
|
||||
let msg = format!("{}s are not allowed in {}s", self.0, ccx.const_kind());
|
||||
let msg = format!("{}s are not allowed in {}s", self.0.descr(), ccx.const_kind());
|
||||
if let hir::GeneratorKind::Async(hir::AsyncGeneratorKind::Block) = self.0 {
|
||||
ccx.tcx.sess.create_feature_err(
|
||||
UnallowedOpInConstContext { span, msg },
|
||||
|
|
|
@ -1526,9 +1526,9 @@ pub enum AsyncGeneratorKind {
|
|||
impl fmt::Display for AsyncGeneratorKind {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.write_str(match self {
|
||||
AsyncGeneratorKind::Block => "`async` block",
|
||||
AsyncGeneratorKind::Closure => "`async` closure body",
|
||||
AsyncGeneratorKind::Fn => "`async fn` body",
|
||||
AsyncGeneratorKind::Block => "async block",
|
||||
AsyncGeneratorKind::Closure => "async closure body",
|
||||
AsyncGeneratorKind::Fn => "async fn body",
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -118,7 +118,8 @@ impl<'a, 'tcx> InteriorVisitor<'a, 'tcx> {
|
|||
} else {
|
||||
let note = format!(
|
||||
"the type is part of the {} because of this {}",
|
||||
self.kind, yield_data.source
|
||||
self.kind.descr(),
|
||||
yield_data.source
|
||||
);
|
||||
|
||||
self.fcx
|
||||
|
|
|
@ -681,25 +681,20 @@ pub trait PrettyPrinter<'tcx>:
|
|||
}
|
||||
ty::Str => p!("str"),
|
||||
ty::Generator(did, substs, movability) => {
|
||||
// FIXME(swatinem): async constructs used to be pretty printed
|
||||
// as `impl Future` previously due to the `from_generator` wrapping.
|
||||
// lets special case this here for now to avoid churn in diagnostics.
|
||||
let generator_kind = self.tcx().generator_kind(did);
|
||||
if matches!(generator_kind, Some(hir::GeneratorKind::Async(..))) {
|
||||
let return_ty = substs.as_generator().return_ty();
|
||||
p!(write("impl Future<Output = {}>", return_ty));
|
||||
|
||||
return Ok(self);
|
||||
}
|
||||
|
||||
p!(write("["));
|
||||
match movability {
|
||||
hir::Movability::Movable => {}
|
||||
hir::Movability::Static => p!("static "),
|
||||
let generator_kind = self.tcx().generator_kind(did).unwrap();
|
||||
let should_print_movability =
|
||||
self.should_print_verbose() || generator_kind == hir::GeneratorKind::Gen;
|
||||
|
||||
if should_print_movability {
|
||||
match movability {
|
||||
hir::Movability::Movable => {}
|
||||
hir::Movability::Static => p!("static "),
|
||||
}
|
||||
}
|
||||
|
||||
if !self.should_print_verbose() {
|
||||
p!("generator");
|
||||
p!(write("{}", generator_kind));
|
||||
// FIXME(eddyb) should use `def_span`.
|
||||
if let Some(did) = did.as_local() {
|
||||
let span = self.tcx().def_span(did);
|
||||
|
|
|
@ -41,7 +41,7 @@ pub fn analyze_source_file(
|
|||
}
|
||||
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(all(any(target_arch = "x86", target_arch = "x86_64")))] {
|
||||
if #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] {
|
||||
fn analyze_source_file_dispatch(src: &str,
|
||||
source_file_start_pos: BytePos,
|
||||
lines: &mut Vec<BytePos>,
|
||||
|
|
|
@ -2673,7 +2673,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
let sp = self.tcx.def_span(def_id);
|
||||
|
||||
// Special-case this to say "async block" instead of `[static generator]`.
|
||||
let kind = tcx.generator_kind(def_id).unwrap();
|
||||
let kind = tcx.generator_kind(def_id).unwrap().descr();
|
||||
err.span_note(
|
||||
sp,
|
||||
&format!("required because it's used within this {}", kind),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue