Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions compiler/rustc_attr_parsing/src/attributes/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,9 @@ impl DocParser {
for i in items.mixed() {
match i {
MetaItemOrLitParser::MetaItemParser(mip) => {
if self.nb_doc_attrs == 0 {
self.attribute.first_span = cx.attr_span;
}
self.nb_doc_attrs += 1;
self.parse_single_doc_attr_item(cx, mip);
}
Expand Down
17 changes: 9 additions & 8 deletions compiler/rustc_attr_parsing/src/target_checking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,15 +292,16 @@ impl<'sess, S: Stage> AttributeParser<'sess, S> {
// in where clauses. After that, this function would become useless.
let spans = attrs
.into_iter()
// FIXME: We shouldn't need to special-case `doc`!
.filter(|attr| {
matches!(
attr,
Attribute::Parsed(AttributeKind::DocComment { .. } | AttributeKind::Doc(_))
| Attribute::Unparsed(_)
)
.filter_map(|attr| {
match attr {
Attribute::Parsed(AttributeKind::DocComment { span, .. }) => Some(*span),
// FIXME: We shouldn't need to special-case `doc`!
Attribute::Parsed(AttributeKind::Doc(attr)) => Some(attr.first_span),
// Checked during attribute parsing target checking
Attribute::Parsed(_) => None,
Attribute::Unparsed(attr) => Some(attr.span),
}
})
.map(|attr| attr.span())
.collect::<Vec<_>>();
if !spans.is_empty() {
self.dcx()
Expand Down
4 changes: 3 additions & 1 deletion compiler/rustc_codegen_ssa/src/back/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,9 @@ pub(crate) fn create_object_file(sess: &Session) -> Option<write::Object<'static
file.set_sub_architecture(sub_architecture);
if sess.target.is_like_darwin {
if macho_is_arm64e(&sess.target) {
file.set_macho_cpu_subtype(object::macho::CPU_SUBTYPE_ARM64E);
file.set_macho_cpu_subtype(
object::macho::CPU_SUBTYPE_ARM64E | object::macho::CPU_SUBTYPE_PTRAUTH_ABI,
);
}

file.set_macho_build_version(macho_object_build_version_for_target(sess))
Expand Down
138 changes: 18 additions & 120 deletions compiler/rustc_const_eval/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,14 +139,7 @@ pub(crate) struct PanicNonStrErr {
}

#[derive(Diagnostic)]
#[diag(
r#"function pointer calls are not allowed in {$kind ->
[const] constant
[static] static
[const_fn] constant function
*[other] {""}
}s"#
)]
#[diag(r#"function pointer calls are not allowed in {$kind}s"#)]
pub(crate) struct UnallowedFnPointerCall {
#[primary_span]
pub span: Span,
Expand Down Expand Up @@ -224,12 +217,7 @@ pub(crate) struct MutableBorrowEscaping {

#[derive(Diagnostic)]
#[diag(
r#"cannot call {$non_or_conditionally}-const formatting macro in {$kind ->
[const] constant
[static] static
[const_fn] constant function
*[other] {""}
}s"#,
r#"cannot call {$non_or_conditionally}-const formatting macro in {$kind}s"#,
code = E0015,
)]
pub(crate) struct NonConstFmtMacroCall {
Expand All @@ -240,12 +228,7 @@ pub(crate) struct NonConstFmtMacroCall {
}

#[derive(Diagnostic)]
#[diag(r#"cannot call {$non_or_conditionally}-const {$def_descr} `{$def_path_str}` in {$kind ->
[const] constant
[static] static
[const_fn] constant function
*[other] {""}
}s"#, code = E0015)]
#[diag(r#"cannot call {$non_or_conditionally}-const {$def_descr} `{$def_path_str}` in {$kind}s"#, code = E0015)]
pub(crate) struct NonConstFnCall {
#[primary_span]
pub span: Span,
Expand All @@ -256,14 +239,7 @@ pub(crate) struct NonConstFnCall {
}

#[derive(Diagnostic)]
#[diag(
r#"cannot call non-const intrinsic `{$name}` in {$kind ->
[const] constant
[static] static
[const_fn] constant function
*[other] {""}
}s"#
)]
#[diag(r#"cannot call non-const intrinsic `{$name}` in {$kind}s"#)]
pub(crate) struct NonConstIntrinsic {
#[primary_span]
pub span: Span,
Expand All @@ -280,12 +256,7 @@ pub(crate) struct UnallowedOpInConstContext {
}

#[derive(Diagnostic)]
#[diag(r#"inline assembly is not allowed in {$kind ->
[const] constant
[static] static
[const_fn] constant function
*[other] {""}
}s"#, code = E0015)]
#[diag(r#"inline assembly is not allowed in {$kind}s"#, code = E0015)]
pub(crate) struct UnallowedInlineAsm {
#[primary_span]
pub span: Span,
Expand Down Expand Up @@ -384,14 +355,7 @@ pub(crate) struct RawBytesNote {
}

#[derive(Diagnostic)]
#[diag(
r#"cannot match on `{$ty}` in {$kind ->
[const] constant
[static] static
[const_fn] constant function
*[other] {""}
}s"#
)]
#[diag(r#"cannot match on `{$ty}` in {$kind}s"#)]
#[note("`{$ty}` cannot be compared in compile-time, and therefore cannot be used in `match`es")]
pub(crate) struct NonConstMatchEq<'tcx> {
#[primary_span]
Expand All @@ -402,12 +366,7 @@ pub(crate) struct NonConstMatchEq<'tcx> {
}

#[derive(Diagnostic)]
#[diag(r#"cannot use `for` loop on `{$ty}` in {$kind ->
[const] constant
[static] static
[const_fn] constant function
*[other] {""}
}s"#, code = E0015)]
#[diag(r#"cannot use `for` loop on `{$ty}` in {$kind}s"#, code = E0015)]
pub(crate) struct NonConstForLoopIntoIter<'tcx> {
#[primary_span]
pub span: Span,
Expand All @@ -417,12 +376,7 @@ pub(crate) struct NonConstForLoopIntoIter<'tcx> {
}

#[derive(Diagnostic)]
#[diag(r#"`?` is not allowed on `{$ty}` in {$kind ->
[const] constant
[static] static
[const_fn] constant function
*[other] {""}
}s"#, code = E0015)]
#[diag(r#"`?` is not allowed on `{$ty}` in {$kind}s"#, code = E0015)]
pub(crate) struct NonConstQuestionBranch<'tcx> {
#[primary_span]
pub span: Span,
Expand All @@ -432,12 +386,7 @@ pub(crate) struct NonConstQuestionBranch<'tcx> {
}

#[derive(Diagnostic)]
#[diag(r#"`?` is not allowed on `{$ty}` in {$kind ->
[const] constant
[static] static
[const_fn] constant function
*[other] {""}
}s"#, code = E0015)]
#[diag(r#"`?` is not allowed on `{$ty}` in {$kind}s"#, code = E0015)]
pub(crate) struct NonConstQuestionFromResidual<'tcx> {
#[primary_span]
pub span: Span,
Expand All @@ -447,12 +396,7 @@ pub(crate) struct NonConstQuestionFromResidual<'tcx> {
}

#[derive(Diagnostic)]
#[diag(r#"`try` block cannot convert `{$ty}` to the result in {$kind ->
[const] constant
[static] static
[const_fn] constant function
*[other] {""}
}s"#, code = E0015)]
#[diag(r#"`try` block cannot convert `{$ty}` to the result in {$kind}s"#, code = E0015)]
pub(crate) struct NonConstTryBlockFromOutput<'tcx> {
#[primary_span]
pub span: Span,
Expand All @@ -462,12 +406,7 @@ pub(crate) struct NonConstTryBlockFromOutput<'tcx> {
}

#[derive(Diagnostic)]
#[diag(r#"cannot convert `{$ty}` into a future in {$kind ->
[const] constant
[static] static
[const_fn] constant function
*[other] {""}
}s"#, code = E0015)]
#[diag(r#"cannot convert `{$ty}` into a future in {$kind}s"#, code = E0015)]
pub(crate) struct NonConstAwait<'tcx> {
#[primary_span]
pub span: Span,
Expand All @@ -477,12 +416,7 @@ pub(crate) struct NonConstAwait<'tcx> {
}

#[derive(Diagnostic)]
#[diag(r#"cannot call {$non_or_conditionally}-const closure in {$kind ->
[const] constant
[static] static
[const_fn] constant function
*[other] {""}
}s"#, code = E0015)]
#[diag(r#"cannot call {$non_or_conditionally}-const closure in {$kind}s"#, code = E0015)]
pub(crate) struct NonConstClosure {
#[primary_span]
pub span: Span,
Expand All @@ -493,12 +427,7 @@ pub(crate) struct NonConstClosure {
}

#[derive(Diagnostic)]
#[diag(r#"calling const c-variadic functions is unstable in {$kind ->
[const] constant
[static] static
[const_fn] constant function
*[other] {""}
}s"#, code = E0015)]
#[diag(r#"calling const c-variadic functions is unstable in {$kind}s"#, code = E0015)]
pub(crate) struct NonConstCVariadicCall {
#[primary_span]
pub span: Span,
Expand All @@ -512,23 +441,9 @@ pub(crate) enum NonConstClosureNote {
#[primary_span]
span: Span,
},
#[note(
r#"function pointers need an RFC before allowed to be called in {$kind ->
[const] constant
[static] static
[const_fn] constant function
*[other] {""}
}s"#
)]
#[note(r#"function pointers need an RFC before allowed to be called in {$kind}s"#)]
FnPtr { kind: ConstContext },
#[note(
r#"closures need an RFC before allowed to be called in {$kind ->
[const] constant
[static] static
[const_fn] constant function
*[other] {""}
}s"#
)]
#[note(r#"closures need an RFC before allowed to be called in {$kind}s"#)]
Closure { kind: ConstContext },
}

Expand All @@ -543,12 +458,7 @@ pub(crate) struct ConsiderDereferencing {
}

#[derive(Diagnostic)]
#[diag(r#"cannot call {$non_or_conditionally}-const operator in {$kind ->
[const] constant
[static] static
[const_fn] constant function
*[other] {""}
}s"#, code = E0015)]
#[diag(r#"cannot call {$non_or_conditionally}-const operator in {$kind}s"#, code = E0015)]
pub(crate) struct NonConstOperator {
#[primary_span]
pub span: Span,
Expand All @@ -559,12 +469,7 @@ pub(crate) struct NonConstOperator {
}

#[derive(Diagnostic)]
#[diag(r#"cannot perform {$non_or_conditionally}-const deref coercion on `{$ty}` in {$kind ->
[const] constant
[static] static
[const_fn] constant function
*[other] {""}
}s"#, code = E0015)]
#[diag(r#"cannot perform {$non_or_conditionally}-const deref coercion on `{$ty}` in {$kind}s"#, code = E0015)]
#[note("attempting to deref into `{$target_ty}`")]
pub(crate) struct NonConstDerefCoercion<'tcx> {
#[primary_span]
Expand All @@ -581,14 +486,7 @@ pub(crate) struct NonConstDerefCoercion<'tcx> {
#[diag("destructor of `{$dropped_ty}` cannot be evaluated at compile-time", code = E0493)]
pub(crate) struct LiveDrop<'tcx> {
#[primary_span]
#[label(
r#"the destructor for this type cannot be evaluated in {$kind ->
[const] constant
[static] static
[const_fn] constant function
*[other] {""}
}s"#
)]
#[label(r#"the destructor for this type cannot be evaluated in {$kind}s"#)]
pub span: Span,
pub kind: ConstContext,
pub dropped_ty: Ty<'tcx>,
Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_hir/src/attrs/data_structures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,8 @@ pub struct CfgHideShow {

#[derive(Clone, Debug, Default, HashStable_Generic, Decodable, PrintAttribute)]
pub struct DocAttribute {
pub first_span: Span,

pub aliases: FxIndexMap<Symbol, Span>,
pub hidden: Option<Span>,
// Because we need to emit the error if there is more than one `inline` attribute on an item
Expand Down Expand Up @@ -581,6 +583,7 @@ pub struct DocAttribute {
impl<E: rustc_span::SpanEncoder> rustc_serialize::Encodable<E> for DocAttribute {
fn encode(&self, encoder: &mut E) {
let DocAttribute {
first_span,
aliases,
hidden,
inline,
Expand All @@ -603,6 +606,7 @@ impl<E: rustc_span::SpanEncoder> rustc_serialize::Encodable<E> for DocAttribute
test_attrs,
no_crate_inject,
} = self;
rustc_serialize::Encodable::<E>::encode(first_span, encoder);
rustc_serialize::Encodable::<E>::encode(aliases, encoder);
rustc_serialize::Encodable::<E>::encode(hidden, encoder);

Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_hir/src/hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2389,9 +2389,9 @@ impl fmt::Display for ConstContext {
impl IntoDiagArg for ConstContext {
fn into_diag_arg(self, _: &mut Option<std::path::PathBuf>) -> DiagArgValue {
DiagArgValue::Str(Cow::Borrowed(match self {
ConstContext::ConstFn => "const_fn",
ConstContext::ConstFn => "constant function",
ConstContext::Static(_) => "static",
ConstContext::Const { .. } => "const",
ConstContext::Const { .. } => "constant",
}))
}
}
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_passes/src/check_attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1027,6 +1027,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
/// [`check_doc_inline`]: Self::check_doc_inline
fn check_doc_attrs(&self, attr: &DocAttribute, hir_id: HirId, target: Target) {
let DocAttribute {
first_span: _,
aliases,
// valid pretty much anywhere, not checked here?
// FIXME: should we?
Expand Down
8 changes: 8 additions & 0 deletions compiler/rustc_trait_selection/src/traits/select/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1115,6 +1115,14 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
debug!("CACHE MISS");
self.insert_evaluation_cache(param_env, fresh_trait_pred, dep_node, result);
stack.cache().on_completion(stack.dfn);
} else if let Some(_guar) = self.infcx.tainted_by_errors() {
// When an error has occurred, we allow global caching of results even if they
// appear stack-dependent. This prevents exponential re-evaluation of cycles
// in the presence of errors, avoiding compiler hangs like #150907.
// This is safe because compilation will fail anyway.
debug!("CACHE MISS (tainted by errors)");
self.insert_evaluation_cache(param_env, fresh_trait_pred, dep_node, result);
stack.cache().on_completion(stack.dfn);
} else {
debug!("PROVISIONAL");
debug!(
Expand Down
1 change: 1 addition & 0 deletions src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2780,6 +2780,7 @@ fn add_without_unwanted_attributes<'hir>(
hir::Attribute::Parsed(AttributeKind::Doc(box d)) => {
// Remove attributes from `normal` that should not be inherited by `use` re-export.
let DocAttribute {
first_span: _,
aliases,
hidden,
inline,
Expand Down
1 change: 1 addition & 0 deletions src/librustdoc/json/conversions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -960,6 +960,7 @@ fn maybe_from_hir_attr(attr: &hir::Attribute, item_id: ItemId, tcx: TyCtxt<'_>)
}

let DocAttribute {
first_span: _,
aliases,
hidden,
inline,
Expand Down
Loading
Loading