diff options
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/asm.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_error_messages/locales/en-US/metadata.ftl | 2 | ||||
| -rw-r--r-- | compiler/rustc_hir_analysis/src/check/check.rs | 20 | ||||
| -rw-r--r-- | compiler/rustc_metadata/src/errors.rs | 36 | ||||
| -rw-r--r-- | compiler/rustc_metadata/src/native_libs.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_mir_build/src/build/expr/as_rvalue.rs | 4 |
6 files changed, 59 insertions, 9 deletions
diff --git a/compiler/rustc_codegen_llvm/src/asm.rs b/compiler/rustc_codegen_llvm/src/asm.rs index e723187ff1f..017513721b7 100644 --- a/compiler/rustc_codegen_llvm/src/asm.rs +++ b/compiler/rustc_codegen_llvm/src/asm.rs @@ -551,6 +551,8 @@ fn reg_to_llvm(reg: InlineAsmRegOrRegClass, layout: Option<&TyAndLayout<'_>>) -> format!("{{{}}}", reg.name()) } } + // The constraints can be retrieved from + // https://llvm.org/docs/LangRef.html#supported-constraint-code-list InlineAsmRegOrRegClass::RegClass(reg) => match reg { InlineAsmRegClass::AArch64(AArch64InlineAsmRegClass::reg) => "r", InlineAsmRegClass::AArch64(AArch64InlineAsmRegClass::vreg) => "w", @@ -624,6 +626,8 @@ fn modifier_to_llvm( reg: InlineAsmRegClass, modifier: Option<char>, ) -> Option<char> { + // The modifiers can be retrieved from + // https://llvm.org/docs/LangRef.html#asm-template-argument-modifiers match reg { InlineAsmRegClass::AArch64(AArch64InlineAsmRegClass::reg) => modifier, InlineAsmRegClass::AArch64(AArch64InlineAsmRegClass::vreg) diff --git a/compiler/rustc_error_messages/locales/en-US/metadata.ftl b/compiler/rustc_error_messages/locales/en-US/metadata.ftl index d27100c56af..08e553d9f15 100644 --- a/compiler/rustc_error_messages/locales/en-US/metadata.ftl +++ b/compiler/rustc_error_messages/locales/en-US/metadata.ftl @@ -165,6 +165,8 @@ metadata_failed_write_error = metadata_missing_native_library = could not find native static library `{$libname}`, perhaps an -L flag is missing? +metadata_only_provide_library_name = only provide the library name `{$suggested_name}`, not the full filename + metadata_failed_create_tempdir = couldn't create a temp dir: {$err} diff --git a/compiler/rustc_hir_analysis/src/check/check.rs b/compiler/rustc_hir_analysis/src/check/check.rs index 7cee9779c5f..c3583eeb430 100644 --- a/compiler/rustc_hir_analysis/src/check/check.rs +++ b/compiler/rustc_hir_analysis/src/check/check.rs @@ -732,8 +732,6 @@ fn check_opaque_meets_bounds<'tcx>( span: Span, origin: &hir::OpaqueTyOrigin, ) { - let hidden_type = tcx.bound_type_of(def_id.to_def_id()).subst(tcx, substs); - let hir_id = tcx.hir().local_def_id_to_hir_id(def_id); let defining_use_anchor = match *origin { hir::OpaqueTyOrigin::FnReturn(did) | hir::OpaqueTyOrigin::AsyncFn(did) => did, @@ -748,14 +746,26 @@ fn check_opaque_meets_bounds<'tcx>( let ocx = ObligationCtxt::new(&infcx); let opaque_ty = tcx.mk_opaque(def_id.to_def_id(), substs); + // `ReErased` regions appear in the "parent_substs" of closures/generators. + // We're ignoring them here and replacing them with fresh region variables. + // See tests in ui/type-alias-impl-trait/closure_{parent_substs,wf_outlives}.rs. + // + // FIXME: Consider wrapping the hidden type in an existential `Binder` and instantiating it + // here rather than using ReErased. + let hidden_ty = tcx.bound_type_of(def_id.to_def_id()).subst(tcx, substs); + let hidden_ty = tcx.fold_regions(hidden_ty, |re, _dbi| match re.kind() { + ty::ReErased => infcx.next_region_var(RegionVariableOrigin::MiscVariable(span)), + _ => re, + }); + let misc_cause = traits::ObligationCause::misc(span, hir_id); - match infcx.at(&misc_cause, param_env).eq(opaque_ty, hidden_type) { + match infcx.at(&misc_cause, param_env).eq(opaque_ty, hidden_ty) { Ok(infer_ok) => ocx.register_infer_ok_obligations(infer_ok), Err(ty_err) => { tcx.sess.delay_span_bug( span, - &format!("could not unify `{hidden_type}` with revealed type:\n{ty_err}"), + &format!("could not unify `{hidden_ty}` with revealed type:\n{ty_err}"), ); } } @@ -764,7 +774,7 @@ fn check_opaque_meets_bounds<'tcx>( // Defining use functions may have more bounds than the opaque type, which is ok, as long as the // hidden type is well formed even without those bounds. let predicate = - ty::Binder::dummy(ty::PredicateKind::WellFormed(hidden_type.into())).to_predicate(tcx); + ty::Binder::dummy(ty::PredicateKind::WellFormed(hidden_ty.into())).to_predicate(tcx); ocx.register_obligation(Obligation::new(misc_cause, param_env, predicate)); // Check that all obligations are satisfied by the implementation's diff --git a/compiler/rustc_metadata/src/errors.rs b/compiler/rustc_metadata/src/errors.rs index 1cd550644bf..dbfa22aaff0 100644 --- a/compiler/rustc_metadata/src/errors.rs +++ b/compiler/rustc_metadata/src/errors.rs @@ -372,7 +372,41 @@ pub struct FailedWriteError { #[derive(Diagnostic)] #[diag(metadata::missing_native_library)] pub struct MissingNativeLibrary<'a> { - pub libname: &'a str, + libname: &'a str, + #[subdiagnostic] + suggest_name: Option<SuggestLibraryName<'a>>, +} + +impl<'a> MissingNativeLibrary<'a> { + pub fn new(libname: &'a str, verbatim: bool) -> Self { + // if it looks like the user has provided a complete filename rather just the bare lib name, + // then provide a note that they might want to try trimming the name + let suggested_name = if !verbatim { + if let Some(libname) = libname.strip_prefix("lib") && let Some(libname) = libname.strip_suffix(".a") { + // this is a unix style filename so trim prefix & suffix + Some(libname) + } else if let Some(libname) = libname.strip_suffix(".lib") { + // this is a Windows style filename so just trim the suffix + Some(libname) + } else { + None + } + } else { + None + }; + + Self { + libname, + suggest_name: suggested_name + .map(|suggested_name| SuggestLibraryName { suggested_name }), + } + } +} + +#[derive(Subdiagnostic)] +#[help(metadata::only_provide_library_name)] +pub struct SuggestLibraryName<'a> { + suggested_name: &'a str, } #[derive(Diagnostic)] diff --git a/compiler/rustc_metadata/src/native_libs.rs b/compiler/rustc_metadata/src/native_libs.rs index 9abb5c74895..676c67bad82 100644 --- a/compiler/rustc_metadata/src/native_libs.rs +++ b/compiler/rustc_metadata/src/native_libs.rs @@ -52,7 +52,7 @@ pub fn find_native_static_library( } } - sess.emit_fatal(MissingNativeLibrary { libname: name }); + sess.emit_fatal(MissingNativeLibrary::new(name, verbatim.unwrap_or(false))); } fn find_bundled_library( diff --git a/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs b/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs index 35a00da8d38..3dafdcb7887 100644 --- a/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs +++ b/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs @@ -197,13 +197,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { // create all the steps directly in MIR with operations all backends need to support anyway. let (source, ty) = if let ty::Adt(adt_def, ..) = source.ty.kind() && adt_def.is_enum() { let discr_ty = adt_def.repr().discr_type().to_ty(this.tcx); - let place = unpack!(block = this.as_place(block, source)); + let temp = unpack!(block = this.as_temp(block, scope, source, Mutability::Not)); let discr = this.temp(discr_ty, source.span); this.cfg.push_assign( block, source_info, discr, - Rvalue::Discriminant(place), + Rvalue::Discriminant(temp.into()), ); (Operand::Move(discr), discr_ty) |
