Auto merge of #102526 - matthiaskrgr:rollup-9o6p98c, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - #102361 (Fix ICE in const_trait check code) - #102373 (Flush delayed bugs before codegen) - #102483 (create def ids for impl traits during ast lowering) - #102490 (Generate synthetic region from `impl` even in closure body within an associated fn) - #102492 (Don't lower assoc bindings just to deny them) - #102493 (Group together more size assertions.) - #102521 (rustdoc: add missing margin to no-docblock methods) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
de341fe668
@ -256,10 +256,6 @@ pub enum TokenKind {
|
|||||||
Eof,
|
Eof,
|
||||||
}
|
}
|
||||||
|
|
||||||
// `TokenKind` is used a lot. Make sure it doesn't unintentionally get bigger.
|
|
||||||
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
|
|
||||||
rustc_data_structures::static_assert_size!(TokenKind, 16);
|
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Encodable, Decodable, Debug, HashStable_Generic)]
|
#[derive(Clone, PartialEq, Encodable, Decodable, Debug, HashStable_Generic)]
|
||||||
pub struct Token {
|
pub struct Token {
|
||||||
pub kind: TokenKind,
|
pub kind: TokenKind,
|
||||||
@ -752,10 +748,6 @@ pub enum Nonterminal {
|
|||||||
NtVis(P<ast::Visibility>),
|
NtVis(P<ast::Visibility>),
|
||||||
}
|
}
|
||||||
|
|
||||||
// `Nonterminal` is used a lot. Make sure it doesn't unintentionally get bigger.
|
|
||||||
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
|
|
||||||
rustc_data_structures::static_assert_size!(Nonterminal, 16);
|
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Encodable, Decodable)]
|
#[derive(Debug, Copy, Clone, PartialEq, Encodable, Decodable)]
|
||||||
pub enum NonterminalKind {
|
pub enum NonterminalKind {
|
||||||
Item,
|
Item,
|
||||||
@ -894,3 +886,16 @@ where
|
|||||||
panic!("interpolated tokens should not be present in the HIR")
|
panic!("interpolated tokens should not be present in the HIR")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Some types are used a lot. Make sure they don't unintentionally get bigger.
|
||||||
|
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
|
||||||
|
mod size_asserts {
|
||||||
|
use super::*;
|
||||||
|
use rustc_data_structures::static_assert_size;
|
||||||
|
// These are in alphabetical order, which is easy to maintain.
|
||||||
|
static_assert_size!(Lit, 12);
|
||||||
|
static_assert_size!(LitKind, 2);
|
||||||
|
static_assert_size!(Nonterminal, 16);
|
||||||
|
static_assert_size!(Token, 24);
|
||||||
|
static_assert_size!(TokenKind, 16);
|
||||||
|
}
|
||||||
|
@ -47,10 +47,6 @@ pub enum TokenTree {
|
|||||||
Delimited(DelimSpan, Delimiter, TokenStream),
|
Delimited(DelimSpan, Delimiter, TokenStream),
|
||||||
}
|
}
|
||||||
|
|
||||||
// This type is used a lot. Make sure it doesn't unintentionally get bigger.
|
|
||||||
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
|
|
||||||
rustc_data_structures::static_assert_size!(TokenTree, 32);
|
|
||||||
|
|
||||||
// Ensure all fields of `TokenTree` is `Send` and `Sync`.
|
// Ensure all fields of `TokenTree` is `Send` and `Sync`.
|
||||||
#[cfg(parallel_compiler)]
|
#[cfg(parallel_compiler)]
|
||||||
fn _dummy()
|
fn _dummy()
|
||||||
@ -308,10 +304,6 @@ pub struct AttributesData {
|
|||||||
#[derive(Clone, Debug, Default, Encodable, Decodable)]
|
#[derive(Clone, Debug, Default, Encodable, Decodable)]
|
||||||
pub struct TokenStream(pub(crate) Lrc<Vec<TokenTree>>);
|
pub struct TokenStream(pub(crate) Lrc<Vec<TokenTree>>);
|
||||||
|
|
||||||
// `TokenStream` is used a lot. Make sure it doesn't unintentionally get bigger.
|
|
||||||
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
|
|
||||||
rustc_data_structures::static_assert_size!(TokenStream, 8);
|
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Encodable, Decodable, HashStable_Generic)]
|
#[derive(Clone, Copy, Debug, PartialEq, Encodable, Decodable, HashStable_Generic)]
|
||||||
pub enum Spacing {
|
pub enum Spacing {
|
||||||
Alone,
|
Alone,
|
||||||
@ -664,3 +656,16 @@ impl DelimSpan {
|
|||||||
self.open.with_hi(self.close.hi())
|
self.open.with_hi(self.close.hi())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Some types are used a lot. Make sure they don't unintentionally get bigger.
|
||||||
|
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
|
||||||
|
mod size_asserts {
|
||||||
|
use super::*;
|
||||||
|
use rustc_data_structures::static_assert_size;
|
||||||
|
// These are in alphabetical order, which is easy to maintain.
|
||||||
|
static_assert_size!(AttrTokenStream, 8);
|
||||||
|
static_assert_size!(AttrTokenTree, 32);
|
||||||
|
static_assert_size!(LazyAttrTokenStream, 8);
|
||||||
|
static_assert_size!(TokenStream, 8);
|
||||||
|
static_assert_size!(TokenTree, 32);
|
||||||
|
}
|
||||||
|
@ -61,8 +61,8 @@ use rustc_hir::def_id::{LocalDefId, CRATE_DEF_ID};
|
|||||||
use rustc_hir::definitions::DefPathData;
|
use rustc_hir::definitions::DefPathData;
|
||||||
use rustc_hir::{ConstArg, GenericArg, ItemLocalId, ParamName, TraitCandidate};
|
use rustc_hir::{ConstArg, GenericArg, ItemLocalId, ParamName, TraitCandidate};
|
||||||
use rustc_index::vec::{Idx, IndexVec};
|
use rustc_index::vec::{Idx, IndexVec};
|
||||||
use rustc_middle::span_bug;
|
|
||||||
use rustc_middle::ty::{ResolverAstLowering, TyCtxt};
|
use rustc_middle::ty::{ResolverAstLowering, TyCtxt};
|
||||||
|
use rustc_middle::{bug, span_bug};
|
||||||
use rustc_session::parse::feature_err;
|
use rustc_session::parse::feature_err;
|
||||||
use rustc_span::hygiene::MacroKind;
|
use rustc_span::hygiene::MacroKind;
|
||||||
use rustc_span::source_map::DesugaringKind;
|
use rustc_span::source_map::DesugaringKind;
|
||||||
@ -1060,13 +1060,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
|||||||
// Desugar `AssocTy: Bounds` into `AssocTy = impl Bounds`. We do this by
|
// Desugar `AssocTy: Bounds` into `AssocTy = impl Bounds`. We do this by
|
||||||
// constructing the HIR for `impl bounds...` and then lowering that.
|
// constructing the HIR for `impl bounds...` and then lowering that.
|
||||||
|
|
||||||
let parent_def_id = self.current_hir_id_owner;
|
|
||||||
let impl_trait_node_id = self.next_node_id();
|
let impl_trait_node_id = self.next_node_id();
|
||||||
self.create_def(
|
|
||||||
parent_def_id.def_id,
|
|
||||||
impl_trait_node_id,
|
|
||||||
DefPathData::ImplTrait,
|
|
||||||
);
|
|
||||||
|
|
||||||
self.with_dyn_type_scope(false, |this| {
|
self.with_dyn_type_scope(false, |this| {
|
||||||
let node_id = this.next_node_id();
|
let node_id = this.next_node_id();
|
||||||
@ -1357,9 +1351,14 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
|||||||
def_node_id,
|
def_node_id,
|
||||||
bounds,
|
bounds,
|
||||||
false,
|
false,
|
||||||
&ImplTraitContext::TypeAliasesOpaqueTy,
|
itctx,
|
||||||
),
|
),
|
||||||
ImplTraitContext::Universal => {
|
ImplTraitContext::Universal => {
|
||||||
|
self.create_def(
|
||||||
|
self.current_hir_id_owner.def_id,
|
||||||
|
def_node_id,
|
||||||
|
DefPathData::ImplTrait,
|
||||||
|
);
|
||||||
let span = t.span;
|
let span = t.span;
|
||||||
let ident = Ident::from_str_and_span(&pprust::ty_to_string(t), span);
|
let ident = Ident::from_str_and_span(&pprust::ty_to_string(t), span);
|
||||||
let (param, bounds, path) =
|
let (param, bounds, path) =
|
||||||
@ -1453,7 +1452,17 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
|||||||
// frequently opened issues show.
|
// frequently opened issues show.
|
||||||
let opaque_ty_span = self.mark_span_with_reason(DesugaringKind::OpaqueTy, span, None);
|
let opaque_ty_span = self.mark_span_with_reason(DesugaringKind::OpaqueTy, span, None);
|
||||||
|
|
||||||
let opaque_ty_def_id = self.local_def_id(opaque_ty_node_id);
|
let opaque_ty_def_id = match origin {
|
||||||
|
hir::OpaqueTyOrigin::TyAlias => self.create_def(
|
||||||
|
self.current_hir_id_owner.def_id,
|
||||||
|
opaque_ty_node_id,
|
||||||
|
DefPathData::ImplTrait,
|
||||||
|
),
|
||||||
|
hir::OpaqueTyOrigin::FnReturn(fn_def_id) => {
|
||||||
|
self.create_def(fn_def_id, opaque_ty_node_id, DefPathData::ImplTrait)
|
||||||
|
}
|
||||||
|
hir::OpaqueTyOrigin::AsyncFn(..) => bug!("unreachable"),
|
||||||
|
};
|
||||||
debug!(?opaque_ty_def_id);
|
debug!(?opaque_ty_def_id);
|
||||||
|
|
||||||
// Contains the new lifetime definitions created for the TAIT (if any).
|
// Contains the new lifetime definitions created for the TAIT (if any).
|
||||||
|
@ -864,15 +864,13 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let tcx = self.infcx.tcx;
|
let tcx = self.infcx.tcx;
|
||||||
let body_parent_did = tcx.opt_parent(self.mir_def_id().to_def_id())?;
|
let region_parent = tcx.parent(region.def_id);
|
||||||
if tcx.parent(region.def_id) != body_parent_did
|
if tcx.def_kind(region_parent) != DefKind::Impl {
|
||||||
|| tcx.def_kind(body_parent_did) != DefKind::Impl
|
|
||||||
{
|
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut found = false;
|
let mut found = false;
|
||||||
tcx.fold_regions(tcx.type_of(body_parent_did), |r: ty::Region<'tcx>, _| {
|
tcx.fold_regions(tcx.type_of(region_parent), |r: ty::Region<'tcx>, _| {
|
||||||
if *r == ty::ReEarlyBound(region) {
|
if *r == ty::ReEarlyBound(region) {
|
||||||
found = true;
|
found = true;
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ pub type PErr<'a> = DiagnosticBuilder<'a, ErrorGuaranteed>;
|
|||||||
pub type PResult<'a, T> = Result<T, PErr<'a>>;
|
pub type PResult<'a, T> = Result<T, PErr<'a>>;
|
||||||
|
|
||||||
// `PResult` is used a lot. Make sure it doesn't unintentionally get bigger.
|
// `PResult` is used a lot. Make sure it doesn't unintentionally get bigger.
|
||||||
// (See also the comment on `DiagnosticBuilder`'s `diagnostic` field.)
|
// (See also the comment on `DiagnosticBuilderInner`'s `diagnostic` field.)
|
||||||
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
|
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
|
||||||
rustc_data_structures::static_assert_size!(PResult<'_, ()>, 16);
|
rustc_data_structures::static_assert_size!(PResult<'_, ()>, 16);
|
||||||
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
|
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
|
||||||
@ -1134,6 +1134,12 @@ impl Handler {
|
|||||||
);
|
);
|
||||||
std::mem::take(&mut self.inner.borrow_mut().fulfilled_expectations)
|
std::mem::take(&mut self.inner.borrow_mut().fulfilled_expectations)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn flush_delayed(&self) {
|
||||||
|
let mut inner = self.inner.lock();
|
||||||
|
let bugs = std::mem::replace(&mut inner.delayed_span_bugs, Vec::new());
|
||||||
|
inner.flush_delayed(bugs, "no errors encountered even though `delay_span_bug` issued");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HandlerInner {
|
impl HandlerInner {
|
||||||
|
@ -448,8 +448,8 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||||||
let infer_lifetimes =
|
let infer_lifetimes =
|
||||||
(gen_pos != GenericArgPosition::Type || infer_args) && !gen_args.has_lifetime_params();
|
(gen_pos != GenericArgPosition::Type || infer_args) && !gen_args.has_lifetime_params();
|
||||||
|
|
||||||
if gen_pos != GenericArgPosition::Type && !gen_args.bindings.is_empty() {
|
if gen_pos != GenericArgPosition::Type && let Some(b) = gen_args.bindings.first() {
|
||||||
Self::prohibit_assoc_ty_binding(tcx, gen_args.bindings[0].span);
|
Self::prohibit_assoc_ty_binding(tcx, b.span);
|
||||||
}
|
}
|
||||||
|
|
||||||
let explicit_late_bound =
|
let explicit_late_bound =
|
||||||
|
@ -276,9 +276,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||||||
item_segment.infer_args,
|
item_segment.infer_args,
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
let assoc_bindings = self.create_assoc_bindings_for_generic_args(item_segment.args());
|
if let Some(b) = item_segment.args().bindings.first() {
|
||||||
|
|
||||||
if let Some(b) = assoc_bindings.first() {
|
|
||||||
Self::prohibit_assoc_ty_binding(self.tcx(), b.span);
|
Self::prohibit_assoc_ty_binding(self.tcx(), b.span);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -605,8 +603,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
|
|
||||||
let assoc_bindings = self.create_assoc_bindings_for_generic_args(item_segment.args());
|
if let Some(b) = item_segment.args().bindings.first() {
|
||||||
if let Some(b) = assoc_bindings.first() {
|
|
||||||
Self::prohibit_assoc_ty_binding(self.tcx(), b.span);
|
Self::prohibit_assoc_ty_binding(self.tcx(), b.span);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -794,8 +791,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||||||
trait_segment,
|
trait_segment,
|
||||||
is_impl,
|
is_impl,
|
||||||
);
|
);
|
||||||
let assoc_bindings = self.create_assoc_bindings_for_generic_args(trait_segment.args());
|
if let Some(b) = trait_segment.args().bindings.first() {
|
||||||
if let Some(b) = assoc_bindings.first() {
|
|
||||||
Self::prohibit_assoc_ty_binding(self.tcx(), b.span);
|
Self::prohibit_assoc_ty_binding(self.tcx(), b.span);
|
||||||
}
|
}
|
||||||
ty::TraitRef::new(trait_def_id, substs)
|
ty::TraitRef::new(trait_def_id, substs)
|
||||||
@ -2207,8 +2203,8 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||||||
|
|
||||||
for segment in segments {
|
for segment in segments {
|
||||||
// Only emit the first error to avoid overloading the user with error messages.
|
// Only emit the first error to avoid overloading the user with error messages.
|
||||||
if let [binding, ..] = segment.args().bindings {
|
if let Some(b) = segment.args().bindings.first() {
|
||||||
Self::prohibit_assoc_ty_binding(self.tcx(), binding.span);
|
Self::prohibit_assoc_ty_binding(self.tcx(), b.span);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -246,6 +246,10 @@ impl<'tcx> Queries<'tcx> {
|
|||||||
// Don't do code generation if there were any errors
|
// Don't do code generation if there were any errors
|
||||||
self.session().compile_status()?;
|
self.session().compile_status()?;
|
||||||
|
|
||||||
|
// If we have any delayed bugs, for example because we created TyKind::Error earlier,
|
||||||
|
// it's likely that codegen will only cause more ICEs, obscuring the original problem
|
||||||
|
self.session().diagnostic().flush_delayed();
|
||||||
|
|
||||||
// Hook for UI tests.
|
// Hook for UI tests.
|
||||||
Self::check_for_rustc_errors_attr(tcx);
|
Self::check_for_rustc_errors_attr(tcx);
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ use rustc_index::vec::Idx;
|
|||||||
use rustc_middle::hir::nested_filter;
|
use rustc_middle::hir::nested_filter;
|
||||||
use rustc_span::def_id::StableCrateId;
|
use rustc_span::def_id::StableCrateId;
|
||||||
use rustc_span::symbol::{kw, sym, Ident, Symbol};
|
use rustc_span::symbol::{kw, sym, Ident, Symbol};
|
||||||
use rustc_span::Span;
|
use rustc_span::{Span, DUMMY_SP};
|
||||||
use rustc_target::spec::abi::Abi;
|
use rustc_target::spec::abi::Abi;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
@ -1131,7 +1131,7 @@ pub(super) fn crate_hash(tcx: TyCtxt<'_>, crate_num: CrateNum) -> Svh {
|
|||||||
.filter_map(|(def_id, info)| {
|
.filter_map(|(def_id, info)| {
|
||||||
let _ = info.as_owner()?;
|
let _ = info.as_owner()?;
|
||||||
let def_path_hash = definitions.def_path_hash(def_id);
|
let def_path_hash = definitions.def_path_hash(def_id);
|
||||||
let span = resolutions.source_span[def_id];
|
let span = resolutions.source_span.get(def_id).unwrap_or(&DUMMY_SP);
|
||||||
debug_assert_eq!(span.parent(), None);
|
debug_assert_eq!(span.parent(), None);
|
||||||
Some((def_path_hash, span))
|
Some((def_path_hash, span))
|
||||||
})
|
})
|
||||||
|
@ -32,11 +32,6 @@ pub struct AttrWrapper {
|
|||||||
start_pos: usize,
|
start_pos: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
// This struct is passed around very frequently,
|
|
||||||
// so make sure it doesn't accidentally get larger
|
|
||||||
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
|
|
||||||
rustc_data_structures::static_assert_size!(AttrWrapper, 16);
|
|
||||||
|
|
||||||
impl AttrWrapper {
|
impl AttrWrapper {
|
||||||
pub(super) fn new(attrs: AttrVec, start_pos: usize) -> AttrWrapper {
|
pub(super) fn new(attrs: AttrVec, start_pos: usize) -> AttrWrapper {
|
||||||
AttrWrapper { attrs, start_pos }
|
AttrWrapper { attrs, start_pos }
|
||||||
@ -96,9 +91,6 @@ struct LazyAttrTokenStreamImpl {
|
|||||||
replace_ranges: Box<[ReplaceRange]>,
|
replace_ranges: Box<[ReplaceRange]>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
|
|
||||||
rustc_data_structures::static_assert_size!(LazyAttrTokenStreamImpl, 144);
|
|
||||||
|
|
||||||
impl ToAttrTokenStream for LazyAttrTokenStreamImpl {
|
impl ToAttrTokenStream for LazyAttrTokenStreamImpl {
|
||||||
fn to_attr_token_stream(&self) -> AttrTokenStream {
|
fn to_attr_token_stream(&self) -> AttrTokenStream {
|
||||||
// The token produced by the final call to `{,inlined_}next` was not
|
// The token produced by the final call to `{,inlined_}next` was not
|
||||||
@ -461,3 +453,13 @@ fn make_token_stream(
|
|||||||
}
|
}
|
||||||
AttrTokenStream::new(final_buf.inner)
|
AttrTokenStream::new(final_buf.inner)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Some types are used a lot. Make sure they don't unintentionally get bigger.
|
||||||
|
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
|
||||||
|
mod size_asserts {
|
||||||
|
use super::*;
|
||||||
|
use rustc_data_structures::static_assert_size;
|
||||||
|
// These are in alphabetical order, which is easy to maintain.
|
||||||
|
static_assert_size!(AttrWrapper, 16);
|
||||||
|
static_assert_size!(LazyAttrTokenStreamImpl, 144);
|
||||||
|
}
|
||||||
|
@ -198,8 +198,8 @@ impl<'tcx> Visitor<'tcx> for CheckConstVisitor<'tcx> {
|
|||||||
of_trait: Some(trait_ref),
|
of_trait: Some(trait_ref),
|
||||||
..
|
..
|
||||||
}) = item.kind
|
}) = item.kind
|
||||||
|
&& let Some(def_id) = trait_ref.trait_def_id()
|
||||||
{
|
{
|
||||||
let def_id = trait_ref.trait_def_id().unwrap();
|
|
||||||
let source_map = tcx.sess.source_map();
|
let source_map = tcx.sess.source_map();
|
||||||
if !tcx.has_attr(def_id, sym::const_trait) {
|
if !tcx.has_attr(def_id, sym::const_trait) {
|
||||||
tcx.sess
|
tcx.sess
|
||||||
|
@ -12,7 +12,7 @@ use rustc_session::cstore::CrateStore;
|
|||||||
use rustc_session::Session;
|
use rustc_session::Session;
|
||||||
use rustc_span::source_map::SourceMap;
|
use rustc_span::source_map::SourceMap;
|
||||||
use rustc_span::symbol::Symbol;
|
use rustc_span::symbol::Symbol;
|
||||||
use rustc_span::{BytePos, CachingSourceMapView, SourceFile, Span, SpanData};
|
use rustc_span::{BytePos, CachingSourceMapView, SourceFile, Span, SpanData, DUMMY_SP};
|
||||||
|
|
||||||
/// This is the context state available during incr. comp. hashing. It contains
|
/// This is the context state available during incr. comp. hashing. It contains
|
||||||
/// enough information to transform `DefId`s and `HirId`s into stable `DefPath`s (i.e.,
|
/// enough information to transform `DefId`s and `HirId`s into stable `DefPath`s (i.e.,
|
||||||
@ -185,7 +185,7 @@ impl<'a> rustc_span::HashStableContext for StableHashingContext<'a> {
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn def_span(&self, def_id: LocalDefId) -> Span {
|
fn def_span(&self, def_id: LocalDefId) -> Span {
|
||||||
self.source_span[def_id]
|
*self.source_span.get(def_id).unwrap_or(&DUMMY_SP)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -285,21 +285,6 @@ impl<'a, 'b> visit::Visitor<'a> for DefCollector<'a, 'b> {
|
|||||||
fn visit_ty(&mut self, ty: &'a Ty) {
|
fn visit_ty(&mut self, ty: &'a Ty) {
|
||||||
match ty.kind {
|
match ty.kind {
|
||||||
TyKind::MacCall(..) => self.visit_macro_invoc(ty.id),
|
TyKind::MacCall(..) => self.visit_macro_invoc(ty.id),
|
||||||
TyKind::ImplTrait(node_id, _) => {
|
|
||||||
let parent_def = match self.impl_trait_context {
|
|
||||||
ImplTraitContext::Universal(item_def) => self.resolver.create_def(
|
|
||||||
item_def,
|
|
||||||
node_id,
|
|
||||||
DefPathData::ImplTrait,
|
|
||||||
self.expansion.to_expn_id(),
|
|
||||||
ty.span,
|
|
||||||
),
|
|
||||||
ImplTraitContext::Existential => {
|
|
||||||
self.create_def(node_id, DefPathData::ImplTrait, ty.span)
|
|
||||||
}
|
|
||||||
};
|
|
||||||
self.with_parent(parent_def, |this| visit::walk_ty(this, ty))
|
|
||||||
}
|
|
||||||
_ => visit::walk_ty(self, ty),
|
_ => visit::walk_ty(self, ty),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -718,7 +718,7 @@ fn item_trait(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, t: &clean:
|
|||||||
if toggled {
|
if toggled {
|
||||||
write!(w, "<details class=\"rustdoc-toggle method-toggle\" open><summary>");
|
write!(w, "<details class=\"rustdoc-toggle method-toggle\" open><summary>");
|
||||||
}
|
}
|
||||||
write!(w, "<div id=\"{}\" class=\"method has-srclink\">", id);
|
write!(w, "<section id=\"{}\" class=\"method has-srclink\">", id);
|
||||||
render_rightside(w, cx, m, t, RenderMode::Normal);
|
render_rightside(w, cx, m, t, RenderMode::Normal);
|
||||||
write!(w, "<h4 class=\"code-header\">");
|
write!(w, "<h4 class=\"code-header\">");
|
||||||
render_assoc_item(
|
render_assoc_item(
|
||||||
@ -730,7 +730,7 @@ fn item_trait(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, t: &clean:
|
|||||||
RenderMode::Normal,
|
RenderMode::Normal,
|
||||||
);
|
);
|
||||||
w.write_str("</h4>");
|
w.write_str("</h4>");
|
||||||
w.write_str("</div>");
|
w.write_str("</section>");
|
||||||
if toggled {
|
if toggled {
|
||||||
write!(w, "</summary>");
|
write!(w, "</summary>");
|
||||||
w.push_buffer(content);
|
w.push_buffer(content);
|
||||||
|
@ -2006,7 +2006,10 @@ in storage.js plus the media query with (min-width: 701px)
|
|||||||
.method-toggle summary,
|
.method-toggle summary,
|
||||||
.implementors-toggle summary,
|
.implementors-toggle summary,
|
||||||
.impl,
|
.impl,
|
||||||
#implementors-list > .docblock {
|
#implementors-list > .docblock,
|
||||||
|
.impl-items > section,
|
||||||
|
.methods > section
|
||||||
|
{
|
||||||
margin-bottom: 0.75em;
|
margin-bottom: 0.75em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
8
src/test/rustdoc-gui/no-docblock.goml
Normal file
8
src/test/rustdoc-gui/no-docblock.goml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
// This test checks that there are margins applied to methods with no docblocks.
|
||||||
|
goto: file://|DOC_PATH|/test_docs/trait.TraitWithNoDocblocks.html
|
||||||
|
// Check that the two methods are more than 24px apart.
|
||||||
|
compare-elements-position-near-false: ("//*[@id='tymethod.first_fn']", "//*[@id='tymethod.second_fn']", {"y": 24})
|
||||||
|
|
||||||
|
goto: file://|DOC_PATH|/test_docs/struct.TypeWithNoDocblocks.html
|
||||||
|
// Check that the two methods are more than 24px apart.
|
||||||
|
compare-elements-position-near-false: ("//*[@id='method.first_fn']", "//*[@id='method.second_fn']", {"y": 24})
|
@ -6,7 +6,7 @@ assert-css: (".sidebar", {"display": "block", "left": "-1000px"})
|
|||||||
|
|
||||||
// Scroll down.
|
// Scroll down.
|
||||||
scroll-to: "//h2[@id='blanket-implementations']"
|
scroll-to: "//h2[@id='blanket-implementations']"
|
||||||
assert-window-property: {"pageYOffset": "639"}
|
assert-window-property: {"pageYOffset": "651"}
|
||||||
|
|
||||||
// Open the sidebar menu.
|
// Open the sidebar menu.
|
||||||
click: ".sidebar-menu-toggle"
|
click: ".sidebar-menu-toggle"
|
||||||
@ -21,11 +21,11 @@ assert-window-property: {"pageYOffset": "0"}
|
|||||||
// Close the sidebar menu. Make sure the scroll position gets restored.
|
// Close the sidebar menu. Make sure the scroll position gets restored.
|
||||||
click: ".sidebar-menu-toggle"
|
click: ".sidebar-menu-toggle"
|
||||||
wait-for-css: (".sidebar", {"left": "-1000px"})
|
wait-for-css: (".sidebar", {"left": "-1000px"})
|
||||||
assert-window-property: {"pageYOffset": "639"}
|
assert-window-property: {"pageYOffset": "651"}
|
||||||
|
|
||||||
// Now test that scrollability returns when the browser window is just resized.
|
// Now test that scrollability returns when the browser window is just resized.
|
||||||
click: ".sidebar-menu-toggle"
|
click: ".sidebar-menu-toggle"
|
||||||
wait-for-css: (".sidebar", {"left": "0px"})
|
wait-for-css: (".sidebar", {"left": "0px"})
|
||||||
assert-window-property: {"pageYOffset": "0"}
|
assert-window-property: {"pageYOffset": "0"}
|
||||||
size: (900, 600)
|
size: (900, 600)
|
||||||
assert-window-property: {"pageYOffset": "639"}
|
assert-window-property: {"pageYOffset": "651"}
|
||||||
|
@ -355,3 +355,15 @@ impl<R: std::io::Read> std::iter::Iterator for NotableStructWithLongName<R> {
|
|||||||
|
|
||||||
fn next(&mut self) -> Option<Self::Item> { () }
|
fn next(&mut self) -> Option<Self::Item> { () }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub trait TraitWithNoDocblocks {
|
||||||
|
fn first_fn(&self);
|
||||||
|
fn second_fn(&self);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct TypeWithNoDocblocks;
|
||||||
|
|
||||||
|
impl TypeWithNoDocblocks {
|
||||||
|
pub fn first_fn(&self) {}
|
||||||
|
pub fn second_fn(&self) {}
|
||||||
|
}
|
||||||
|
@ -1 +1 @@
|
|||||||
<div id="associatedconstant.YOLO" class="method has-srclink"><a class="srclink rightside" href="../src/foo/anchors.rs.html#16">source</a><h4 class="code-header">const <a href="#associatedconstant.YOLO" class="constant">YOLO</a>: <a class="primitive" href="{{channel}}/std/primitive.u32.html">u32</a></h4></div>
|
<section id="associatedconstant.YOLO" class="method has-srclink"><a class="srclink rightside" href="../src/foo/anchors.rs.html#16">source</a><h4 class="code-header">const <a href="#associatedconstant.YOLO" class="constant">YOLO</a>: <a class="primitive" href="{{channel}}/std/primitive.u32.html">u32</a></h4></section>
|
@ -1 +1 @@
|
|||||||
<div id="method.bar" class="method has-srclink"><a class="srclink rightside" href="../src/foo/anchors.rs.html#23">source</a><h4 class="code-header">fn <a href="#method.bar" class="fnname">bar</a>()</h4></div>
|
<section id="method.bar" class="method has-srclink"><a class="srclink rightside" href="../src/foo/anchors.rs.html#23">source</a><h4 class="code-header">fn <a href="#method.bar" class="fnname">bar</a>()</h4></section>
|
@ -1 +1 @@
|
|||||||
<div id="tymethod.foo" class="method has-srclink"><a class="srclink rightside" href="../src/foo/anchors.rs.html#20">source</a><h4 class="code-header">fn <a href="#tymethod.foo" class="fnname">foo</a>()</h4></div>
|
<section id="tymethod.foo" class="method has-srclink"><a class="srclink rightside" href="../src/foo/anchors.rs.html#20">source</a><h4 class="code-header">fn <a href="#tymethod.foo" class="fnname">foo</a>()</h4></section>
|
@ -1 +1 @@
|
|||||||
<div id="associatedtype.T" class="method has-srclink"><a class="srclink rightside" href="../src/foo/anchors.rs.html#13">source</a><h4 class="code-header">type <a href="#associatedtype.T" class="associatedtype">T</a></h4></div>
|
<section id="associatedtype.T" class="method has-srclink"><a class="srclink rightside" href="../src/foo/anchors.rs.html#13">source</a><h4 class="code-header">type <a href="#associatedtype.T" class="associatedtype">T</a></h4></section>
|
@ -18,10 +18,10 @@ pub struct S<T>(T);
|
|||||||
// @has - '//pre[@class="rust trait"]/code/span[@class="where"]' ': Clone'
|
// @has - '//pre[@class="rust trait"]/code/span[@class="where"]' ': Clone'
|
||||||
#[const_trait]
|
#[const_trait]
|
||||||
pub trait Tr<T> {
|
pub trait Tr<T> {
|
||||||
// @!has - '//div[@id="method.a"]/h4[@class="code-header"]' '~const'
|
// @!has - '//section[@id="method.a"]/h4[@class="code-header"]' '~const'
|
||||||
// @has - '//div[@id="method.a"]/h4[@class="code-header"]/a[@class="trait"]' 'Clone'
|
// @has - '//section[@id="method.a"]/h4[@class="code-header"]/a[@class="trait"]' 'Clone'
|
||||||
// @!has - '//div[@id="method.a"]/h4[@class="code-header"]/span[@class="where"]' '~const'
|
// @!has - '//section[@id="method.a"]/h4[@class="code-header"]/span[@class="where"]' '~const'
|
||||||
// @has - '//div[@id="method.a"]/h4[@class="code-header"]/span[@class="where fmt-newline"]' ': Clone'
|
// @has - '//section[@id="method.a"]/h4[@class="code-header"]/span[@class="where fmt-newline"]' ': Clone'
|
||||||
fn a<A: ~const Clone + ~const Destruct>()
|
fn a<A: ~const Clone + ~const Destruct>()
|
||||||
where
|
where
|
||||||
Option<A>: ~const Clone + ~const Destruct,
|
Option<A>: ~const Clone + ~const Destruct,
|
||||||
|
28
src/test/ui/borrowck/issue-102209.rs
Normal file
28
src/test/ui/borrowck/issue-102209.rs
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
|
pub struct NfaBuilder<'brand> {
|
||||||
|
brand: PhantomData<&'brand mut &'brand mut ()>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl NfaBuilder<'_> {
|
||||||
|
pub fn with<R, F: FnOnce(NfaBuilder<'_>) -> R>(f: F) -> R {
|
||||||
|
Brand::with(|brand| {
|
||||||
|
f(Self { brand: brand.lt })
|
||||||
|
//~^ ERROR lifetime may not live long enough
|
||||||
|
//~| ERROR lifetime may not live long enough
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Copy)]
|
||||||
|
pub struct Brand<'brand> {
|
||||||
|
lt: PhantomData<&'brand mut &'brand mut ()>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Brand<'_> {
|
||||||
|
pub fn with<R, F: FnOnce(Brand<'_>) -> R>(f: F) -> R {
|
||||||
|
f(Self { lt: PhantomData })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
22
src/test/ui/borrowck/issue-102209.stderr
Normal file
22
src/test/ui/borrowck/issue-102209.stderr
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
error: lifetime may not live long enough
|
||||||
|
--> $DIR/issue-102209.rs:10:29
|
||||||
|
|
|
||||||
|
LL | impl NfaBuilder<'_> {
|
||||||
|
| -- lifetime `'2` appears in the `impl`'s self type
|
||||||
|
LL | pub fn with<R, F: FnOnce(NfaBuilder<'_>) -> R>(f: F) -> R {
|
||||||
|
LL | Brand::with(|brand| {
|
||||||
|
| ----- has type `Brand<'1>`
|
||||||
|
LL | f(Self { brand: brand.lt })
|
||||||
|
| ^^^^^^^^ this usage requires that `'1` must outlive `'2`
|
||||||
|
|
||||||
|
error: lifetime may not live long enough
|
||||||
|
--> $DIR/issue-102209.rs:10:29
|
||||||
|
|
|
||||||
|
LL | impl NfaBuilder<'_> {
|
||||||
|
| -- lifetime `'1` appears in the `impl`'s self type
|
||||||
|
...
|
||||||
|
LL | f(Self { brand: brand.lt })
|
||||||
|
| ^^^^^^^^ this usage requires that `'1` must outlive `'static`
|
||||||
|
|
||||||
|
error: aborting due to 2 previous errors
|
||||||
|
|
@ -9,7 +9,7 @@ note: generator is not `Send` as this value is used across a yield
|
|||||||
--> $DIR/generator-print-verbose-1.rs:35:9
|
--> $DIR/generator-print-verbose-1.rs:35:9
|
||||||
|
|
|
|
||||||
LL | let _non_send_gen = make_non_send_generator();
|
LL | let _non_send_gen = make_non_send_generator();
|
||||||
| ------------- has type `Opaque(DefId(0:34 ~ generator_print_verbose_1[749a]::make_non_send_generator::{opaque#0}), [])` which is not `Send`
|
| ------------- has type `Opaque(DefId(0:44 ~ generator_print_verbose_1[749a]::make_non_send_generator::{opaque#0}), [])` which is not `Send`
|
||||||
LL | yield;
|
LL | yield;
|
||||||
| ^^^^^ yield occurs here, with `_non_send_gen` maybe used later
|
| ^^^^^ yield occurs here, with `_non_send_gen` maybe used later
|
||||||
LL | };
|
LL | };
|
||||||
@ -35,17 +35,17 @@ note: required because it's used within this generator
|
|||||||
|
|
|
|
||||||
LL | || {
|
LL | || {
|
||||||
| ^^
|
| ^^
|
||||||
note: required because it appears within the type `Opaque(DefId(0:39 ~ generator_print_verbose_1[749a]::make_gen2::{opaque#0}), [std::sync::Arc<std::cell::RefCell<i32>>])`
|
note: required because it appears within the type `Opaque(DefId(0:45 ~ generator_print_verbose_1[749a]::make_gen2::{opaque#0}), [std::sync::Arc<std::cell::RefCell<i32>>])`
|
||||||
--> $DIR/generator-print-verbose-1.rs:41:30
|
--> $DIR/generator-print-verbose-1.rs:41:30
|
||||||
|
|
|
|
||||||
LL | pub fn make_gen2<T>(t: T) -> impl Generator<Return = T> {
|
LL | pub fn make_gen2<T>(t: T) -> impl Generator<Return = T> {
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
note: required because it appears within the type `Opaque(DefId(0:42 ~ generator_print_verbose_1[749a]::make_non_send_generator2::{opaque#0}), [])`
|
note: required because it appears within the type `Opaque(DefId(0:46 ~ generator_print_verbose_1[749a]::make_non_send_generator2::{opaque#0}), [])`
|
||||||
--> $DIR/generator-print-verbose-1.rs:47:34
|
--> $DIR/generator-print-verbose-1.rs:47:34
|
||||||
|
|
|
|
||||||
LL | fn make_non_send_generator2() -> impl Generator<Return = Arc<RefCell<i32>>> {
|
LL | fn make_non_send_generator2() -> impl Generator<Return = Arc<RefCell<i32>>> {
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
= note: required because it captures the following types: `Opaque(DefId(0:42 ~ generator_print_verbose_1[749a]::make_non_send_generator2::{opaque#0}), [])`, `()`
|
= note: required because it captures the following types: `Opaque(DefId(0:46 ~ generator_print_verbose_1[749a]::make_non_send_generator2::{opaque#0}), [])`, `()`
|
||||||
note: required because it's used within this generator
|
note: required because it's used within this generator
|
||||||
--> $DIR/generator-print-verbose-1.rs:52:20
|
--> $DIR/generator-print-verbose-1.rs:52:20
|
||||||
|
|
|
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
error[E0700]: hidden type for `Opaque(DefId(0:11 ~ impl_trait_captures[1afc]::foo::{opaque#0}), [ReStatic, T, ReEarlyBound(0, 'a)])` captures lifetime that does not appear in bounds
|
error[E0700]: hidden type for `Opaque(DefId(0:13 ~ impl_trait_captures[1afc]::foo::{opaque#0}), [ReStatic, T, ReEarlyBound(0, 'a)])` captures lifetime that does not appear in bounds
|
||||||
--> $DIR/impl-trait-captures.rs:11:5
|
--> $DIR/impl-trait-captures.rs:11:5
|
||||||
|
|
|
|
||||||
LL | fn foo<'a, T>(x: &T) -> impl Foo<'a> {
|
LL | fn foo<'a, T>(x: &T) -> impl Foo<'a> {
|
||||||
| -- hidden type `&ReFree(DefId(0:8 ~ impl_trait_captures[1afc]::foo), BrNamed(DefId(0:13 ~ impl_trait_captures[1afc]::foo::'_), '_)) T` captures the anonymous lifetime defined here
|
| -- hidden type `&ReFree(DefId(0:8 ~ impl_trait_captures[1afc]::foo), BrNamed(DefId(0:12 ~ impl_trait_captures[1afc]::foo::'_), '_)) T` captures the anonymous lifetime defined here
|
||||||
LL | x
|
LL | x
|
||||||
| ^
|
| ^
|
||||||
|
|
|
|
||||||
help: to declare that the `impl Trait` captures `ReFree(DefId(0:8 ~ impl_trait_captures[1afc]::foo), BrNamed(DefId(0:13 ~ impl_trait_captures[1afc]::foo::'_), '_))`, you can add an explicit `ReFree(DefId(0:8 ~ impl_trait_captures[1afc]::foo), BrNamed(DefId(0:13 ~ impl_trait_captures[1afc]::foo::'_), '_))` lifetime bound
|
help: to declare that the `impl Trait` captures `ReFree(DefId(0:8 ~ impl_trait_captures[1afc]::foo), BrNamed(DefId(0:12 ~ impl_trait_captures[1afc]::foo::'_), '_))`, you can add an explicit `ReFree(DefId(0:8 ~ impl_trait_captures[1afc]::foo), BrNamed(DefId(0:12 ~ impl_trait_captures[1afc]::foo::'_), '_))` lifetime bound
|
||||||
|
|
|
|
||||||
LL | fn foo<'a, T>(x: &T) -> impl Foo<'a> + ReFree(DefId(0:8 ~ impl_trait_captures[1afc]::foo), BrNamed(DefId(0:13 ~ impl_trait_captures[1afc]::foo::'_), '_)) {
|
LL | fn foo<'a, T>(x: &T) -> impl Foo<'a> + ReFree(DefId(0:8 ~ impl_trait_captures[1afc]::foo), BrNamed(DefId(0:12 ~ impl_trait_captures[1afc]::foo::'_), '_)) {
|
||||||
| ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
| ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
15
src/test/ui/rfc-2632-const-trait-impl/issue-102156.rs
Normal file
15
src/test/ui/rfc-2632-const-trait-impl/issue-102156.rs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#![feature(allocator_api)]
|
||||||
|
#![feature(const_trait_impl)]
|
||||||
|
|
||||||
|
use core::convert::{From, TryFrom};
|
||||||
|
//~^ ERROR
|
||||||
|
//~| ERROR
|
||||||
|
|
||||||
|
use std::pin::Pin;
|
||||||
|
use std::alloc::Allocator;
|
||||||
|
impl<T: ?Sized, A: Allocator> const From<Box<T, A>> for Pin<Box<T, A>>
|
||||||
|
where
|
||||||
|
A: 'static,
|
||||||
|
{}
|
||||||
|
|
||||||
|
pub fn main() {}
|
19
src/test/ui/rfc-2632-const-trait-impl/issue-102156.stderr
Normal file
19
src/test/ui/rfc-2632-const-trait-impl/issue-102156.stderr
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
error[E0433]: failed to resolve: maybe a missing crate `core`?
|
||||||
|
--> $DIR/issue-102156.rs:4:5
|
||||||
|
|
|
||||||
|
LL | use core::convert::{From, TryFrom};
|
||||||
|
| ^^^^ maybe a missing crate `core`?
|
||||||
|
|
|
||||||
|
= help: consider adding `extern crate core` to use the `core` crate
|
||||||
|
|
||||||
|
error[E0433]: failed to resolve: maybe a missing crate `core`?
|
||||||
|
--> $DIR/issue-102156.rs:4:5
|
||||||
|
|
|
||||||
|
LL | use core::convert::{From, TryFrom};
|
||||||
|
| ^^^^ maybe a missing crate `core`?
|
||||||
|
|
|
||||||
|
= help: consider adding `extern crate core` to use the `core` crate
|
||||||
|
|
||||||
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0433`.
|
Loading…
x
Reference in New Issue
Block a user