Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 7 pull requests #110119

Closed
wants to merge 18 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
b7a5f3a
Instantiate instead of erasing binder when probing param methods
compiler-errors Mar 7, 2023
4698b9f
Updating Wake example to use new 'pin!' macro
madsravn Apr 6, 2023
f7f2eb3
Move `FnPtrAddr` error to `SessionDiagnostic`
matthewjasper Apr 7, 2023
066638b
Migrate `rustc_hir_analysis` to session diagnostic
obeis Apr 6, 2023
55219b3
bump `thiserror` to use syn 2.0
fee1-dead Apr 8, 2023
804e938
Move SIMD layout errors to `SessionDiagnostic`
matthewjasper Apr 8, 2023
8e76c76
Update compiler/rustc_ty_utils/src/layout.rs
matthewjasper Apr 8, 2023
c17a705
Add test for new delayed bug code path
matthewjasper Apr 8, 2023
5c75dcd
Add renaming of ignore-git to changelog
duckymirror Apr 9, 2023
3fcc007
Add PR link to changelog entry for renaming of ignore-git
duckymirror Apr 9, 2023
7ca7c8f
compiletest: Give a better error message if `node` isn't installed
jyn514 Apr 9, 2023
3c64ff7
Rollup merge of #108843 - compiler-errors:non_lifetime_binders-method…
matthiaskrgr Apr 9, 2023
8d427ce
Rollup merge of #110026 - madsravn:master, r=Mark-Simulacrum
matthiaskrgr Apr 9, 2023
1b74d0c
Rollup merge of #110028 - obeis:hir-analysis-migrate-diagnostics-3, r…
matthiaskrgr Apr 9, 2023
0c72a07
Rollup merge of #110081 - fee1-dead-contrib:bump-thiserror, r=Mark-Si…
matthiaskrgr Apr 9, 2023
49f9843
Rollup merge of #110095 - matthewjasper:ty-utils-diagnostics, r=compi…
matthiaskrgr Apr 9, 2023
4916371
Rollup merge of #110108 - duckymirror:rename-ignore-git-changelog, r=…
matthiaskrgr Apr 9, 2023
9f3a751
Rollup merge of #110114 - jyn514:wasm-errors, r=compiler-errors
matthiaskrgr Apr 9, 2023
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
10 changes: 5 additions & 5 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6258,22 +6258,22 @@ checksum = "aac81b6fd6beb5884b0cf3321b8117e6e5d47ecb6fc89f414cfdcca8b2fe2dd8"

[[package]]
name = "thiserror"
version = "1.0.38"
version = "1.0.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6a9cd18aa97d5c45c6603caea1da6628790b37f7a34b6ca89522331c5180fed0"
checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac"
dependencies = [
"thiserror-impl",
]

[[package]]
name = "thiserror-impl"
version = "1.0.38"
version = "1.0.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fb327af4685e4d03fa8cbcf1716380da910eeb2bb8be417e7f9fd3fb164f36f"
checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f"
dependencies = [
"proc-macro2",
"quote",
"syn 1.0.102",
"syn 2.0.8",
]

[[package]]
Expand Down
36 changes: 36 additions & 0 deletions compiler/rustc_hir_analysis/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -189,3 +189,39 @@ hir_analysis_return_type_notation_equality_bound =

hir_analysis_return_type_notation_missing_method =
cannot find associated function `{$assoc_name}` in trait `{$trait_name}`

hir_analysis_placeholder_not_allowed_item_signatures = the placeholder `_` is not allowed within types on item signatures for {$kind}
.label = not allowed in type signatures

hir_analysis_associated_type_trait_uninferred_generic_params = cannot use the associated type of a trait with uninferred generic parameters
.suggestion = use a fully qualified path with inferred lifetimes

hir_analysis_associated_type_trait_uninferred_generic_params_multipart_suggestion = use a fully qualified path with explicit lifetimes

hir_analysis_enum_discriminant_overflowed = enum discriminant overflowed
.label = overflowed on value after {$discr}
.note = explicitly set `{$item_name} = {$wrapped_discr}` if that is desired outcome

hir_analysis_paren_sugar_attribute = the `#[rustc_paren_sugar]` attribute is a temporary means of controlling which traits can use parenthetical notation
.help = add `#![feature(unboxed_closures)]` to the crate attributes to use it

hir_analysis_must_implement_one_of_attribute = the `#[rustc_must_implement_one_of]` attribute must be used with at least 2 args

hir_analysis_must_be_name_of_associated_function = must be a name of an associated function

hir_analysis_function_not_have_default_implementation = function doesn't have a default implementation
.note = required by this annotation

hir_analysis_must_implement_not_function = not a function

hir_analysis_must_implement_not_function_span_note = required by this annotation

hir_analysis_must_implement_not_function_note = all `#[rustc_must_implement_one_of]` arguments must be associated function names

hir_analysis_function_not_found_in_trait = function not found in this trait

hir_analysis_functions_names_duplicated = functions names are duplicated
.note = all `#[rustc_must_implement_one_of]` arguments must be unique

hir_analysis_simd_ffi_highly_experimental = use of SIMD type{$snip} in FFI is highly experimental and may result in invalid code
.help = add `#![feature(simd_ffi)]` to the crate attributes to enable
165 changes: 55 additions & 110 deletions compiler/rustc_hir_analysis/src/collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use crate::errors;
use hir::def::DefKind;
use rustc_data_structures::captures::Captures;
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder, ErrorGuaranteed, StashKey};
use rustc_errors::{Applicability, DiagnosticBuilder, ErrorGuaranteed, StashKey};
use rustc_hir as hir;
use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_hir::intravisit::{self, Visitor};
Expand Down Expand Up @@ -333,17 +333,7 @@ fn bad_placeholder<'tcx>(
let kind = if kind.ends_with('s') { format!("{}es", kind) } else { format!("{}s", kind) };

spans.sort();
let mut err = struct_span_err!(
tcx.sess,
spans.clone(),
E0121,
"the placeholder `_` is not allowed within types on item signatures for {}",
kind
);
for span in spans {
err.span_label(span, "not allowed in type signatures");
}
err
tcx.sess.create_err(errors::PlaceholderNotAllowedItemSignatures { spans, kind })
}

impl<'tcx> ItemCtxt<'tcx> {
Expand Down Expand Up @@ -419,13 +409,8 @@ impl<'tcx> AstConv<'tcx> for ItemCtxt<'tcx> {
self.tcx().mk_projection(item_def_id, item_substs)
} else {
// There are no late-bound regions; we can just ignore the binder.
let mut err = struct_span_err!(
self.tcx().sess,
span,
E0212,
"cannot use the associated type of a trait \
with uninferred generic parameters"
);
let (mut mpart_sugg, mut inferred_sugg) = (None, None);
let mut bound = String::new();

match self.node() {
hir::Node::Field(_) | hir::Node::Ctor(_) | hir::Node::Variant(_) => {
Expand All @@ -444,31 +429,25 @@ impl<'tcx> AstConv<'tcx> for ItemCtxt<'tcx> {
(bound.span.shrink_to_lo(), format!("{}, ", lt_name))
}
};
let suggestions = vec![
(lt_sp, sugg),
(
span.with_hi(item_segment.ident.span.lo()),
format!(
"{}::",
// Replace the existing lifetimes with a new named lifetime.
self.tcx.replace_late_bound_regions_uncached(
poly_trait_ref,
|_| {
self.tcx.mk_re_early_bound(ty::EarlyBoundRegion {
def_id: item_def_id,
index: 0,
name: Symbol::intern(&lt_name),
})
}
),
mpart_sugg = Some(errors::AssociatedTypeTraitUninferredGenericParamsMultipartSuggestion {
fspan: lt_sp,
first: sugg,
sspan: span.with_hi(item_segment.ident.span.lo()),
second: format!(
"{}::",
// Replace the existing lifetimes with a new named lifetime.
self.tcx.replace_late_bound_regions_uncached(
poly_trait_ref,
|_| {
self.tcx.mk_re_early_bound(ty::EarlyBoundRegion {
def_id: item_def_id,
index: 0,
name: Symbol::intern(&lt_name),
})
}
),
),
];
err.multipart_suggestion(
"use a fully qualified path with explicit lifetimes",
suggestions,
Applicability::MaybeIncorrect,
);
});
}
_ => {}
}
Expand All @@ -482,20 +461,23 @@ impl<'tcx> AstConv<'tcx> for ItemCtxt<'tcx> {
| hir::Node::ForeignItem(_)
| hir::Node::TraitItem(_)
| hir::Node::ImplItem(_) => {
err.span_suggestion_verbose(
span.with_hi(item_segment.ident.span.lo()),
"use a fully qualified path with inferred lifetimes",
format!(
"{}::",
// Erase named lt, we want `<A as B<'_>::C`, not `<A as B<'a>::C`.
self.tcx.anonymize_bound_vars(poly_trait_ref).skip_binder(),
),
Applicability::MaybeIncorrect,
inferred_sugg = Some(span.with_hi(item_segment.ident.span.lo()));
bound = format!(
"{}::",
// Erase named lt, we want `<A as B<'_>::C`, not `<A as B<'a>::C`.
self.tcx.anonymize_bound_vars(poly_trait_ref).skip_binder(),
);
}
_ => {}
}
self.tcx().ty_error(err.emit())
self.tcx().ty_error(self.tcx().sess.emit_err(
errors::AssociatedTypeTraitUninferredGenericParams {
span,
inferred_sugg,
bound,
mpart_sugg,
},
))
}
}

Expand Down Expand Up @@ -763,14 +745,12 @@ fn convert_enum_variant_types(tcx: TyCtxt<'_>, def_id: DefId) {
Some(discr)
} else {
let span = tcx.def_span(variant.def_id);
struct_span_err!(tcx.sess, span, E0370, "enum discriminant overflowed")
.span_label(span, format!("overflowed on value after {}", prev_discr.unwrap()))
.note(&format!(
"explicitly set `{} = {}` if that is desired outcome",
tcx.item_name(variant.def_id),
wrapped_discr
))
.emit();
tcx.sess.emit_err(errors::EnumDiscriminantOverflowed {
span,
discr: prev_discr.unwrap().to_string(),
item_name: tcx.item_name(variant.def_id),
wrapped_discr: wrapped_discr.to_string(),
});
None
}
.unwrap_or(wrapped_discr),
Expand Down Expand Up @@ -915,14 +895,7 @@ fn trait_def(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::TraitDef {

let paren_sugar = tcx.has_attr(def_id, sym::rustc_paren_sugar);
if paren_sugar && !tcx.features().unboxed_closures {
tcx.sess
.struct_span_err(
item.span,
"the `#[rustc_paren_sugar]` attribute is a temporary means of controlling \
which traits can use parenthetical notation",
)
.help("add `#![feature(unboxed_closures)]` to the crate attributes to use it")
.emit();
tcx.sess.emit_err(errors::ParenSugarAttribute { span: item.span });
}

let is_marker = tcx.has_attr(def_id, sym::marker);
Expand All @@ -942,13 +915,7 @@ fn trait_def(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::TraitDef {
// and that they are all identifiers
.and_then(|attr| match attr.meta_item_list() {
Some(items) if items.len() < 2 => {
tcx.sess
.struct_span_err(
attr.span,
"the `#[rustc_must_implement_one_of]` attribute must be \
used with at least 2 args",
)
.emit();
tcx.sess.emit_err(errors::MustImplementOneOfAttribute { span: attr.span });

None
}
Expand All @@ -957,9 +924,7 @@ fn trait_def(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::TraitDef {
.map(|item| item.ident().ok_or(item.span()))
.collect::<Result<Box<[_]>, _>>()
.map_err(|span| {
tcx.sess
.struct_span_err(span, "must be a name of an associated function")
.emit();
tcx.sess.emit_err(errors::MustBeNameOfAssociatedFunction { span });
})
.ok()
.zip(Some(attr.span)),
Expand All @@ -975,33 +940,25 @@ fn trait_def(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::TraitDef {
match item {
Some(item) if matches!(item.kind, hir::AssocItemKind::Fn { .. }) => {
if !tcx.impl_defaultness(item.id.owner_id).has_value() {
tcx.sess
.struct_span_err(
item.span,
"function doesn't have a default implementation",
)
.span_note(attr_span, "required by this annotation")
.emit();
tcx.sess.emit_err(errors::FunctionNotHaveDefaultImplementation {
span: item.span,
note_span: attr_span,
});

return Some(());
}

return None;
}
Some(item) => {
tcx.sess
.struct_span_err(item.span, "not a function")
.span_note(attr_span, "required by this annotation")
.note(
"all `#[rustc_must_implement_one_of]` arguments must be associated \
function names",
)
.emit();
tcx.sess.emit_err(errors::MustImplementNotFunction {
span: item.span,
span_note: errors::MustImplementNotFunctionSpanNote { span: attr_span },
note: errors::MustImplementNotFunctionNote {},
});
}
None => {
tcx.sess
.struct_span_err(ident.span, "function not found in this trait")
.emit();
tcx.sess.emit_err(errors::FunctionNotFoundInTrait { span: ident.span });
}
}

Expand All @@ -1018,9 +975,7 @@ fn trait_def(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::TraitDef {
for ident in &*list {
if let Some(dup) = set.insert(ident.name, ident.span) {
tcx.sess
.struct_span_err(vec![dup, ident.span], "functions names are duplicated")
.note("all `#[rustc_must_implement_one_of]` arguments must be unique")
.emit();
.emit_err(errors::FunctionNamesDuplicated { spans: vec![dup, ident.span] });

no_dups = false;
}
Expand Down Expand Up @@ -1485,17 +1440,7 @@ fn compute_sig_of_foreign_fn_decl<'tcx>(
.source_map()
.span_to_snippet(ast_ty.span)
.map_or_else(|_| String::new(), |s| format!(" `{}`", s));
tcx.sess
.struct_span_err(
ast_ty.span,
&format!(
"use of SIMD type{} in FFI is highly experimental and \
may result in invalid code",
snip
),
)
.help("add `#![feature(simd_ffi)]` to the crate attributes to enable")
.emit();
tcx.sess.emit_err(errors::SIMDFFIHighlyExperimental { span: ast_ty.span, snip });
}
};
for (input, ty) in iter::zip(decl.inputs, fty.inputs().skip_binder()) {
Expand Down
Loading