Skip to content

Commit

Permalink
Auto merge of rust-lang#133865 - matthiaskrgr:rollup-9v2f3w4, r=matth…
Browse files Browse the repository at this point in the history
…iaskrgr

Rollup of 8 pull requests

Successful merges:

 - rust-lang#133737 (Include LLDB and GDB visualizers in MSVC distribution)
 - rust-lang#133774 (Make CoercePointee errors translatable)
 - rust-lang#133831 (Don't try and handle unfed `type_of` on anon consts)
 - rust-lang#133847 (Remove `-Zshow-span`.)
 - rust-lang#133849 (coverage: Use a separate counter type and simplification step during counter creation)
 - rust-lang#133850 (Avoid `opaque type not constrained` errors in the presence of other errors)
 - rust-lang#133851 (Stop git from merging generated files)
 - rust-lang#133856 (Update sysinfo version to 0.33.0)

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed Dec 4, 2024
2 parents 96e51d9 + 670affb commit acabb52
Show file tree
Hide file tree
Showing 86 changed files with 1,897 additions and 2,161 deletions.
6 changes: 4 additions & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
*.cpp rust
*.h rust
*.rs rust diff=rust
*.fixed linguist-language=Rust
*.mir linguist-language=Rust
*.fixed linguist-language=Rust -merge
*.mir linguist-language=Rust -merge
*.stderr -merge
*.stdout -merge
src/etc/installer/gfx/* binary
src/vendor/** -text
Cargo.lock linguist-generated=false
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_ast_passes/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,6 @@ ast_passes_precise_capturing_duplicated = duplicate `use<...>` precise capturing
ast_passes_precise_capturing_not_allowed_here = `use<...>` precise capturing syntax not allowed in {$loc}
ast_passes_show_span = {$msg}
ast_passes_stability_outside_std = stability attributes may not be used outside of the standard library
ast_passes_static_without_body =
Expand Down
8 changes: 0 additions & 8 deletions compiler/rustc_ast_passes/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -779,14 +779,6 @@ pub(crate) struct IncompatibleFeatures {
pub f2: Symbol,
}

#[derive(Diagnostic)]
#[diag(ast_passes_show_span)]
pub(crate) struct ShowSpan {
#[primary_span]
pub span: Span,
pub msg: &'static str,
}

#[derive(Diagnostic)]
#[diag(ast_passes_negative_bound_not_supported)]
pub(crate) struct NegativeBoundUnsupported {
Expand Down
3 changes: 0 additions & 3 deletions compiler/rustc_ast_passes/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
//! The `rustc_ast_passes` crate contains passes which validate the AST in `syntax`
//! parsed by `rustc_parse` and then lowered, after the passes in this crate,
//! by `rustc_ast_lowering`.
//!
//! The crate also contains other misc AST visitors, e.g. `node_count` and `show_span`.
// tidy-alphabetical-start
#![allow(internal_features)]
Expand All @@ -18,6 +16,5 @@
pub mod ast_validation;
mod errors;
pub mod feature_gate;
pub mod show_span;

rustc_fluent_macro::fluent_messages! { "../messages.ftl" }
68 changes: 0 additions & 68 deletions compiler/rustc_ast_passes/src/show_span.rs

This file was deleted.

15 changes: 15 additions & 0 deletions compiler/rustc_builtin_macros/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,21 @@ builtin_macros_cfg_accessible_indeterminate = cannot determine whether the path
builtin_macros_cfg_accessible_literal_path = `cfg_accessible` path cannot be a literal
builtin_macros_cfg_accessible_multiple_paths = multiple `cfg_accessible` paths are specified
builtin_macros_cfg_accessible_unspecified_path = `cfg_accessible` path is not specified
builtin_macros_coerce_pointee_requires_maybe_sized = `derive(CoercePointee)` requires `{$name}` to be marked `?Sized`
builtin_macros_coerce_pointee_requires_one_field = `CoercePointee` can only be derived on `struct`s with at least one field
builtin_macros_coerce_pointee_requires_one_generic = `CoercePointee` can only be derived on `struct`s that are generic over at least one type
builtin_macros_coerce_pointee_requires_one_pointee = exactly one generic type parameter must be marked as `#[pointee]` to derive `CoercePointee` traits
builtin_macros_coerce_pointee_requires_transparent = `CoercePointee` can only be derived on `struct`s with `#[repr(transparent)]`
builtin_macros_coerce_pointee_too_many_pointees = only one type parameter can be marked as `#[pointee]` when deriving `CoercePointee` traits
.label = here another type parameter is marked as `#[pointee]`
builtin_macros_concat_bytes_array = cannot concatenate doubly nested array
.note = byte strings are treated as arrays of bytes
.help = try flattening the array
Expand Down
97 changes: 56 additions & 41 deletions compiler/rustc_builtin_macros/src/deriving/coerce_pointee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use rustc_ast::{
use rustc_attr as attr;
use rustc_data_structures::flat_map_in_place::FlatMapInPlace;
use rustc_expand::base::{Annotatable, ExtCtxt};
use rustc_macros::Diagnostic;
use rustc_span::symbol::{Ident, sym};
use rustc_span::{Span, Symbol};
use thin_vec::{ThinVec, thin_vec};
Expand Down Expand Up @@ -38,35 +39,20 @@ pub(crate) fn expand_deriving_coerce_pointee(
.any(|r| matches!(r, attr::ReprTransparent))
});
if !is_transparent {
cx.dcx()
.struct_span_err(
span,
"`CoercePointee` can only be derived on `struct`s with `#[repr(transparent)]`",
)
.emit();
cx.dcx().emit_err(RequireTransparent { span });
return;
}
if !matches!(
struct_data,
VariantData::Struct { fields, recovered: _ } | VariantData::Tuple(fields, _)
if !fields.is_empty())
{
cx.dcx()
.struct_span_err(
span,
"`CoercePointee` can only be derived on `struct`s with at least one field",
)
.emit();
cx.dcx().emit_err(RequireOneField { span });
return;
}
(aitem.ident, g)
} else {
cx.dcx()
.struct_span_err(
span,
"`CoercePointee` can only be derived on `struct`s with `#[repr(transparent)]`",
)
.emit();
cx.dcx().emit_err(RequireTransparent { span });
return;
};

Expand Down Expand Up @@ -95,10 +81,7 @@ pub(crate) fn expand_deriving_coerce_pointee(

let pointee_param_idx = if type_params.is_empty() {
// `#[derive(CoercePointee)]` requires at least one generic type on the target `struct`
cx.dcx().struct_span_err(
span,
"`CoercePointee` can only be derived on `struct`s that are generic over at least one type",
).emit();
cx.dcx().emit_err(RequireOneGeneric { span });
return;
} else if type_params.len() == 1 {
// Regardless of the only type param being designed as `#[pointee]` or not, we can just use it as such
Expand All @@ -111,19 +94,11 @@ pub(crate) fn expand_deriving_coerce_pointee(
match (pointees.next(), pointees.next()) {
(Some((idx, _span)), None) => idx,
(None, _) => {
cx.dcx().struct_span_err(
span,
"exactly one generic type parameter must be marked as #[pointee] to derive CoercePointee traits",
).emit();
cx.dcx().emit_err(RequireOnePointee { span });
return;
}
(Some((_, one)), Some((_, another))) => {
cx.dcx()
.struct_span_err(
vec![one, another],
"only one type parameter can be marked as `#[pointee]` when deriving CoercePointee traits",
)
.emit();
cx.dcx().emit_err(TooManyPointees { one, another });
return;
}
}
Expand Down Expand Up @@ -181,15 +156,10 @@ pub(crate) fn expand_deriving_coerce_pointee(
pointee_ty_ident.name,
)
{
cx.dcx()
.struct_span_err(
pointee_ty_ident.span,
format!(
"`derive(CoercePointee)` requires {} to be marked `?Sized`",
pointee_ty_ident.name
),
)
.emit();
cx.dcx().emit_err(RequiresMaybeSized {
span: pointee_ty_ident.span,
name: pointee_ty_ident.name.to_ident_string(),
});
return;
}
let arg = GenericArg::Type(s_ty.clone());
Expand Down Expand Up @@ -459,3 +429,48 @@ impl<'a, 'b> rustc_ast::visit::Visitor<'a> for AlwaysErrorOnGenericParam<'a, 'b>
}
}
}

#[derive(Diagnostic)]
#[diag(builtin_macros_coerce_pointee_requires_transparent)]
struct RequireTransparent {
#[primary_span]
span: Span,
}

#[derive(Diagnostic)]
#[diag(builtin_macros_coerce_pointee_requires_one_field)]
struct RequireOneField {
#[primary_span]
span: Span,
}

#[derive(Diagnostic)]
#[diag(builtin_macros_coerce_pointee_requires_one_generic)]
struct RequireOneGeneric {
#[primary_span]
span: Span,
}

#[derive(Diagnostic)]
#[diag(builtin_macros_coerce_pointee_requires_one_pointee)]
struct RequireOnePointee {
#[primary_span]
span: Span,
}

#[derive(Diagnostic)]
#[diag(builtin_macros_coerce_pointee_too_many_pointees)]
struct TooManyPointees {
#[primary_span]
one: Span,
#[label]
another: Span,
}

#[derive(Diagnostic)]
#[diag(builtin_macros_coerce_pointee_requires_maybe_sized)]
struct RequiresMaybeSized {
#[primary_span]
span: Span,
name: String,
}
4 changes: 1 addition & 3 deletions compiler/rustc_driver_impl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -418,9 +418,7 @@ fn run_compiler(
return early_exit();
}

if sess.opts.unstable_opts.parse_crate_root_only
|| sess.opts.unstable_opts.show_span.is_some()
{
if sess.opts.unstable_opts.parse_crate_root_only {
return early_exit();
}

Expand Down
5 changes: 2 additions & 3 deletions compiler/rustc_hir_analysis/src/collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,10 +309,10 @@ impl<'tcx> Visitor<'tcx> for CollectItemTypesVisitor<'tcx> {
self.tcx.ensure().type_of(param.def_id);
if let Some(default) = default {
// need to store default and type of default
self.tcx.ensure().const_param_default(param.def_id);
if let hir::ConstArgKind::Anon(ac) = default.kind {
self.tcx.ensure().type_of(ac.def_id);
}
self.tcx.ensure().const_param_default(param.def_id);
}
}
}
Expand Down Expand Up @@ -1817,7 +1817,6 @@ fn const_param_default<'tcx>(
),
};
let icx = ItemCtxt::new(tcx, def_id);
// FIXME(const_generics): investigate which places do and don't need const ty feeding
let ct = icx.lowerer().lower_const_arg(default_ct, FeedConstTy::No);
let ct = icx.lowerer().lower_const_arg(default_ct, FeedConstTy::Param(def_id.to_def_id()));
ty::EarlyBinder::bind(ct)
}
Loading

0 comments on commit acabb52

Please sign in to comment.