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 6 pull requests #102413

Closed
wants to merge 21 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
c846a2a
Make `std::os::fd` public.
sunfishcode Jun 14, 2022
09bbc42
Update asrawfd.js.
sunfishcode Jun 22, 2022
bda1262
Clarify that the `fd` module is supported on Unix and WASI.
sunfishcode Jun 30, 2022
7d80510
Re-introduce `unstable` attributes.
sunfishcode Aug 23, 2022
a7f3ba9
Fix compilation of the doc tests on Windows.
sunfishcode Sep 2, 2022
f9ef7e2
code refactoring smart_resolve_report_errors
chenyukang Sep 20, 2022
7adfb44
add trivial comments
chenyukang Sep 21, 2022
fdda7e0
more code refactor on smart_resolve_report_errors
chenyukang Sep 25, 2022
db0877f
trivial fix on fallback
chenyukang Sep 25, 2022
cca4828
Format type_of
compiler-errors Sep 26, 2022
05267b5
Make type_of work correctly for const arg bindings
compiler-errors Sep 26, 2022
92561f4
Support bindings with anon consts in generics
compiler-errors Sep 26, 2022
7f06d51
Don't export `__heap_base` and `__data_end` on wasm32-wasi.
sunfishcode Sep 28, 2022
356a52c
add regression test
Rageking8 Sep 28, 2022
715d61d
errors: rename `typeck.ftl` to `hir_analysis.ftl`
davidtwco Sep 28, 2022
c76cda9
Rollup merge of #98368 - sunfishcode:sunfishcode/std-os-fd, r=joshtri…
Dylan-DPC Sep 28, 2022
528956c
Rollup merge of #102085 - chenyukang:code-refactor, r=cjgillot
Dylan-DPC Sep 28, 2022
d049c3e
Rollup merge of #102336 - compiler-errors:issue-102333, r=jackh726
Dylan-DPC Sep 28, 2022
9c4b247
Rollup merge of #102385 - sunfishcode:sunfishcode/wasm-no-export-heap…
Dylan-DPC Sep 28, 2022
d72a105
Rollup merge of #102393 - Rageking8:add-regression-test-for-issue-949…
Dylan-DPC Sep 28, 2022
51743a2
Rollup merge of #102395 - davidtwco:translation-rename-typeck, r=este…
Dylan-DPC Sep 28, 2022
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: 6 additions & 4 deletions compiler/rustc_codegen_ssa/src/back/linker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1320,10 +1320,12 @@ impl<'a> Linker for WasmLd<'a> {

// LLD will hide these otherwise-internal symbols since it only exports
// symbols explicitly passed via the `--export` flags above and hides all
// others. Various bits and pieces of tooling use this, so be sure these
// symbols make their way out of the linker as well.
self.cmd.arg("--export=__heap_base");
self.cmd.arg("--export=__data_end");
// others. Various bits and pieces of wasm32-unknown-unknown tooling use
// this, so be sure these symbols make their way out of the linker as well.
if self.sess.target.os == "unknown" {
self.cmd.arg("--export=__heap_base");
self.cmd.arg("--export=__data_end");
}
}

fn subsystem(&mut self, _subsystem: &str) {}
Expand Down
5 changes: 5 additions & 0 deletions compiler/rustc_error_messages/locales/en-US/compiletest.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
compiletest_example = this is an example message used in testing
.note = with a note
.help = with a help
.suggestion = with a suggestion
.label = with a label
Original file line number Diff line number Diff line change
@@ -1,101 +1,101 @@
typeck_field_multiply_specified_in_initializer =
hir_analysis_field_multiply_specified_in_initializer =
field `{$ident}` specified more than once
.label = used more than once
.previous_use_label = first use of `{$ident}`

typeck_unrecognized_atomic_operation =
hir_analysis_unrecognized_atomic_operation =
unrecognized atomic operation function: `{$op}`
.label = unrecognized atomic operation

typeck_wrong_number_of_generic_arguments_to_intrinsic =
hir_analysis_wrong_number_of_generic_arguments_to_intrinsic =
intrinsic has wrong number of {$descr} parameters: found {$found}, expected {$expected}
.label = expected {$expected} {$descr} {$expected ->
[one] parameter
*[other] parameters
}

typeck_unrecognized_intrinsic_function =
hir_analysis_unrecognized_intrinsic_function =
unrecognized intrinsic function: `{$name}`
.label = unrecognized intrinsic

typeck_lifetimes_or_bounds_mismatch_on_trait =
hir_analysis_lifetimes_or_bounds_mismatch_on_trait =
lifetime parameters or bounds on {$item_kind} `{$ident}` do not match the trait declaration
.label = lifetimes do not match {$item_kind} in trait
.generics_label = lifetimes in impl do not match this {$item_kind} in trait

typeck_drop_impl_on_wrong_item =
hir_analysis_drop_impl_on_wrong_item =
the `Drop` trait may only be implemented for local structs, enums, and unions
.label = must be a struct, enum, or union in the current crate

typeck_field_already_declared =
hir_analysis_field_already_declared =
field `{$field_name}` is already declared
.label = field already declared
.previous_decl_label = `{$field_name}` first declared here

typeck_copy_impl_on_type_with_dtor =
hir_analysis_copy_impl_on_type_with_dtor =
the trait `Copy` may not be implemented for this type; the type has a destructor
.label = `Copy` not allowed on types with destructors

typeck_multiple_relaxed_default_bounds =
hir_analysis_multiple_relaxed_default_bounds =
type parameter has more than one relaxed default bound, only one is supported

typeck_copy_impl_on_non_adt =
hir_analysis_copy_impl_on_non_adt =
the trait `Copy` may not be implemented for this type
.label = type is not a structure or enumeration

typeck_trait_object_declared_with_no_traits =
hir_analysis_trait_object_declared_with_no_traits =
at least one trait is required for an object type
.alias_span = this alias does not contain a trait

typeck_ambiguous_lifetime_bound =
hir_analysis_ambiguous_lifetime_bound =
ambiguous lifetime bound, explicit lifetime bound required

typeck_assoc_type_binding_not_allowed =
hir_analysis_assoc_type_binding_not_allowed =
associated type bindings are not allowed here
.label = associated type not allowed here

typeck_functional_record_update_on_non_struct =
hir_analysis_functional_record_update_on_non_struct =
functional record update syntax requires a struct

typeck_typeof_reserved_keyword_used =
hir_analysis_typeof_reserved_keyword_used =
`typeof` is a reserved keyword but unimplemented
.suggestion = consider replacing `typeof(...)` with an actual type
.label = reserved keyword

typeck_return_stmt_outside_of_fn_body =
hir_analysis_return_stmt_outside_of_fn_body =
return statement outside of function body
.encl_body_label = the return is part of this body...
.encl_fn_label = ...not the enclosing function body

typeck_yield_expr_outside_of_generator =
hir_analysis_yield_expr_outside_of_generator =
yield expression outside of generator literal

typeck_struct_expr_non_exhaustive =
hir_analysis_struct_expr_non_exhaustive =
cannot create non-exhaustive {$what} using struct expression

typeck_method_call_on_unknown_type =
hir_analysis_method_call_on_unknown_type =
the type of this value must be known to call a method on a raw pointer on it

typeck_value_of_associated_struct_already_specified =
hir_analysis_value_of_associated_struct_already_specified =
the value of the associated type `{$item_name}` (from trait `{$def_path}`) is already specified
.label = re-bound here
.previous_bound_label = `{$item_name}` bound here first

typeck_address_of_temporary_taken = cannot take address of a temporary
hir_analysis_address_of_temporary_taken = cannot take address of a temporary
.label = temporary value

typeck_add_return_type_add = try adding a return type
hir_analysis_add_return_type_add = try adding a return type

typeck_add_return_type_missing_here = a return type might be missing here
hir_analysis_add_return_type_missing_here = a return type might be missing here

typeck_expected_default_return_type = expected `()` because of default return type
hir_analysis_expected_default_return_type = expected `()` because of default return type

typeck_expected_return_type = expected `{$expected}` because of return type
hir_analysis_expected_return_type = expected `{$expected}` because of return type

typeck_unconstrained_opaque_type = unconstrained opaque type
hir_analysis_unconstrained_opaque_type = unconstrained opaque type
.note = `{$name}` must be used in combination with a concrete type within the same module

typeck_missing_type_params =
hir_analysis_missing_type_params =
the type {$parameterCount ->
[one] parameter
*[other] parameters
Expand All @@ -117,19 +117,19 @@ typeck_missing_type_params =
} to {$parameters}
.note = because of the default `Self` reference, type parameters must be specified on object types

typeck_manual_implementation =
hir_analysis_manual_implementation =
manual implementations of `{$trait_name}` are experimental
.label = manual implementations of `{$trait_name}` are experimental
.help = add `#![feature(unboxed_closures)]` to the crate attributes to enable

typeck_substs_on_overridden_impl = could not resolve substs on overridden impl
hir_analysis_substs_on_overridden_impl = could not resolve substs on overridden impl

typeck_unused_extern_crate =
hir_analysis_unused_extern_crate =
unused extern crate
.suggestion = remove it

typeck_extern_crate_not_idiomatic =
hir_analysis_extern_crate_not_idiomatic =
`extern crate` is not idiomatic in the new edition
.suggestion = convert it to a `{$msg_code}`

typeck_expected_used_symbol = expected `used`, `used(compiler)` or `used(linker)`
hir_analysis_expected_used_symbol = expected `used`, `used(compiler)` or `used(linker)`
15 changes: 8 additions & 7 deletions compiler/rustc_error_messages/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,27 +40,28 @@ fluent_messages! {
attr => "../locales/en-US/attr.ftl",
borrowck => "../locales/en-US/borrowck.ftl",
builtin_macros => "../locales/en-US/builtin_macros.ftl",
compiletest => "../locales/en-US/compiletest.ftl",
const_eval => "../locales/en-US/const_eval.ftl",
driver => "../locales/en-US/driver.ftl",
expand => "../locales/en-US/expand.ftl",
session => "../locales/en-US/session.ftl",
interface => "../locales/en-US/interface.ftl",
hir_analysis => "../locales/en-US/hir_analysis.ftl",
infer => "../locales/en-US/infer.ftl",
interface => "../locales/en-US/interface.ftl",
lint => "../locales/en-US/lint.ftl",
metadata => "../locales/en-US/metadata.ftl",
middle => "../locales/en-US/middle.ftl",
mir_dataflow => "../locales/en-US/mir_dataflow.ftl",
monomorphize => "../locales/en-US/monomorphize.ftl",
metadata => "../locales/en-US/metadata.ftl",
parser => "../locales/en-US/parser.ftl",
passes => "../locales/en-US/passes.ftl",
plugin_impl => "../locales/en-US/plugin_impl.ftl",
privacy => "../locales/en-US/privacy.ftl",
query_system => "../locales/en-US/query_system.ftl",
trait_selection => "../locales/en-US/trait_selection.ftl",
save_analysis => "../locales/en-US/save_analysis.ftl",
ty_utils => "../locales/en-US/ty_utils.ftl",
typeck => "../locales/en-US/typeck.ftl",
mir_dataflow => "../locales/en-US/mir_dataflow.ftl",
session => "../locales/en-US/session.ftl",
symbol_mangling => "../locales/en-US/symbol_mangling.ftl",
trait_selection => "../locales/en-US/trait_selection.ftl",
ty_utils => "../locales/en-US/ty_utils.ftl",
}

pub use fluent_generated::{self as fluent, DEFAULT_LOCALE_RESOURCES};
Expand Down
117 changes: 87 additions & 30 deletions compiler/rustc_hir_analysis/src/collect/type_of.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,12 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: DefId) -> Ty<'_> {
find_opaque_ty_constraints_for_tait(tcx, def_id)
}
// Opaque types desugared from `impl Trait`.
ItemKind::OpaqueTy(OpaqueTy { origin: hir::OpaqueTyOrigin::FnReturn(owner) | hir::OpaqueTyOrigin::AsyncFn(owner), in_trait, .. }) => {
ItemKind::OpaqueTy(OpaqueTy {
origin:
hir::OpaqueTyOrigin::FnReturn(owner) | hir::OpaqueTyOrigin::AsyncFn(owner),
in_trait,
..
}) => {
if in_trait {
span_bug!(item.span, "impl-trait in trait has no default")
} else {
Expand Down Expand Up @@ -378,7 +383,9 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: DefId) -> Ty<'_> {

Node::Field(field) => icx.to_ty(field.ty),

Node::Expr(&Expr { kind: ExprKind::Closure{..}, .. }) => tcx.typeck(def_id).node_type(hir_id),
Node::Expr(&Expr { kind: ExprKind::Closure { .. }, .. }) => {
tcx.typeck(def_id).node_type(hir_id)
}

Node::AnonConst(_) if let Some(param) = tcx.opt_const_param_of(def_id) => {
// We defer to `type_of` of the corresponding parameter
Expand Down Expand Up @@ -410,40 +417,91 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: DefId) -> Ty<'_> {
| Node::Item(&Item { kind: ItemKind::GlobalAsm(asm), .. })
if asm.operands.iter().any(|(op, _op_sp)| match op {
hir::InlineAsmOperand::Const { anon_const }
| hir::InlineAsmOperand::SymFn { anon_const } => anon_const.hir_id == hir_id,
| hir::InlineAsmOperand::SymFn { anon_const } => {
anon_const.hir_id == hir_id
}
_ => false,
}) =>
{
tcx.typeck(def_id).node_type(hir_id)
}

Node::Variant(Variant { disr_expr: Some(ref e), .. }) if e.hir_id == hir_id => tcx
.adt_def(tcx.hir().get_parent_item(hir_id))
.repr()
.discr_type()
.to_ty(tcx),
Node::Variant(Variant { disr_expr: Some(ref e), .. }) if e.hir_id == hir_id => {
tcx.adt_def(tcx.hir().get_parent_item(hir_id)).repr().discr_type().to_ty(tcx)
}

Node::TypeBinding(binding @ &TypeBinding { hir_id: binding_id, .. })
if let Node::TraitRef(trait_ref) = tcx.hir().get(
tcx.hir().get_parent_node(binding_id)
) =>
Node::TypeBinding(
binding @ &TypeBinding {
hir_id: binding_id,
kind: TypeBindingKind::Equality { term: Term::Const(ref e) },
..
},
) if let Node::TraitRef(trait_ref) =
tcx.hir().get(tcx.hir().get_parent_node(binding_id))
&& e.hir_id == hir_id =>
{
let Some(trait_def_id) = trait_ref.trait_def_id() else {
return tcx.ty_error_with_message(DUMMY_SP, "Could not find trait");
};
let assoc_items = tcx.associated_items(trait_def_id);
let assoc_item = assoc_items.find_by_name_and_kind(
tcx, binding.ident, ty::AssocKind::Const, def_id.to_def_id(),
);
if let Some(assoc_item) = assoc_item {
tcx.type_of(assoc_item.def_id)
} else {
// FIXME(associated_const_equality): add a useful error message here.
tcx.ty_error_with_message(
DUMMY_SP,
"Could not find associated const on trait",
)
}
let Some(trait_def_id) = trait_ref.trait_def_id() else {
return tcx.ty_error_with_message(DUMMY_SP, "Could not find trait");
};
let assoc_items = tcx.associated_items(trait_def_id);
let assoc_item = assoc_items.find_by_name_and_kind(
tcx,
binding.ident,
ty::AssocKind::Const,
def_id.to_def_id(),
);
if let Some(assoc_item) = assoc_item {
tcx.type_of(assoc_item.def_id)
} else {
// FIXME(associated_const_equality): add a useful error message here.
tcx.ty_error_with_message(
DUMMY_SP,
"Could not find associated const on trait",
)
}
}

Node::TypeBinding(
binding @ &TypeBinding { hir_id: binding_id, gen_args, ref kind, .. },
) if let Node::TraitRef(trait_ref) =
tcx.hir().get(tcx.hir().get_parent_node(binding_id))
&& let Some((idx, _)) =
gen_args.args.iter().enumerate().find(|(_, arg)| {
if let GenericArg::Const(ct) = arg {
ct.value.hir_id == hir_id
} else {
false
}
}) =>
{
let Some(trait_def_id) = trait_ref.trait_def_id() else {
return tcx.ty_error_with_message(DUMMY_SP, "Could not find trait");
};
let assoc_items = tcx.associated_items(trait_def_id);
let assoc_item = assoc_items.find_by_name_and_kind(
tcx,
binding.ident,
match kind {
// I think `<A: T>` type bindings requires that `A` is a type
TypeBindingKind::Constraint { .. }
| TypeBindingKind::Equality { term: Term::Ty(..) } => {
ty::AssocKind::Type
}
TypeBindingKind::Equality { term: Term::Const(..) } => {
ty::AssocKind::Const
}
},
def_id.to_def_id(),
);
if let Some(assoc_item) = assoc_item {
tcx.type_of(tcx.generics_of(assoc_item.def_id).params[idx].def_id)
} else {
// FIXME(associated_const_equality): add a useful error message here.
tcx.ty_error_with_message(
DUMMY_SP,
"Could not find associated const on trait",
)
}
}

Node::GenericParam(&GenericParam {
Expand All @@ -452,8 +510,7 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: DefId) -> Ty<'_> {
..
}) if ct.hir_id == hir_id => tcx.type_of(tcx.hir().local_def_id(param_hir_id)),

x =>
tcx.ty_error_with_message(
x => tcx.ty_error_with_message(
DUMMY_SP,
&format!("unexpected const parent in type_of(): {x:?}"),
),
Expand Down
Loading