Skip to content

Commit edabf59

Browse files
committed
Auto merge of #103026 - matthiaskrgr:rollup-gfmlfkt, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - #103000 (Add suggestion to the "missing native library" error) - #103006 (rustdoc: don't ICE on `TyKind::Typeof`) - #103008 (replace ReErased with fresh region vars in opaque types) - #103011 (Improve rustdoc `unsafe-fn` GUI test) - #103013 (Add new bootstrap entrypoints to triagebot) - #103016 (Ensure enum cast moves) - #103021 (Add links to relevant pages to find constraint information) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 60bd3f9 + 3f12e4b commit edabf59

File tree

26 files changed

+392
-67
lines changed

26 files changed

+392
-67
lines changed

compiler/rustc_codegen_llvm/src/asm.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,8 @@ fn reg_to_llvm(reg: InlineAsmRegOrRegClass, layout: Option<&TyAndLayout<'_>>) ->
551551
format!("{{{}}}", reg.name())
552552
}
553553
}
554+
// The constraints can be retrieved from
555+
// https://llvm.org/docs/LangRef.html#supported-constraint-code-list
554556
InlineAsmRegOrRegClass::RegClass(reg) => match reg {
555557
InlineAsmRegClass::AArch64(AArch64InlineAsmRegClass::reg) => "r",
556558
InlineAsmRegClass::AArch64(AArch64InlineAsmRegClass::vreg) => "w",
@@ -624,6 +626,8 @@ fn modifier_to_llvm(
624626
reg: InlineAsmRegClass,
625627
modifier: Option<char>,
626628
) -> Option<char> {
629+
// The modifiers can be retrieved from
630+
// https://llvm.org/docs/LangRef.html#asm-template-argument-modifiers
627631
match reg {
628632
InlineAsmRegClass::AArch64(AArch64InlineAsmRegClass::reg) => modifier,
629633
InlineAsmRegClass::AArch64(AArch64InlineAsmRegClass::vreg)

compiler/rustc_error_messages/locales/en-US/metadata.ftl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,8 @@ metadata_failed_write_error =
165165
metadata_missing_native_library =
166166
could not find native static library `{$libname}`, perhaps an -L flag is missing?
167167
168+
metadata_only_provide_library_name = only provide the library name `{$suggested_name}`, not the full filename
169+
168170
metadata_failed_create_tempdir =
169171
couldn't create a temp dir: {$err}
170172

compiler/rustc_hir_analysis/src/check/check.rs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -732,8 +732,6 @@ fn check_opaque_meets_bounds<'tcx>(
732732
span: Span,
733733
origin: &hir::OpaqueTyOrigin,
734734
) {
735-
let hidden_type = tcx.bound_type_of(def_id.to_def_id()).subst(tcx, substs);
736-
737735
let hir_id = tcx.hir().local_def_id_to_hir_id(def_id);
738736
let defining_use_anchor = match *origin {
739737
hir::OpaqueTyOrigin::FnReturn(did) | hir::OpaqueTyOrigin::AsyncFn(did) => did,
@@ -748,14 +746,26 @@ fn check_opaque_meets_bounds<'tcx>(
748746
let ocx = ObligationCtxt::new(&infcx);
749747
let opaque_ty = tcx.mk_opaque(def_id.to_def_id(), substs);
750748

749+
// `ReErased` regions appear in the "parent_substs" of closures/generators.
750+
// We're ignoring them here and replacing them with fresh region variables.
751+
// See tests in ui/type-alias-impl-trait/closure_{parent_substs,wf_outlives}.rs.
752+
//
753+
// FIXME: Consider wrapping the hidden type in an existential `Binder` and instantiating it
754+
// here rather than using ReErased.
755+
let hidden_ty = tcx.bound_type_of(def_id.to_def_id()).subst(tcx, substs);
756+
let hidden_ty = tcx.fold_regions(hidden_ty, |re, _dbi| match re.kind() {
757+
ty::ReErased => infcx.next_region_var(RegionVariableOrigin::MiscVariable(span)),
758+
_ => re,
759+
});
760+
751761
let misc_cause = traits::ObligationCause::misc(span, hir_id);
752762

753-
match infcx.at(&misc_cause, param_env).eq(opaque_ty, hidden_type) {
763+
match infcx.at(&misc_cause, param_env).eq(opaque_ty, hidden_ty) {
754764
Ok(infer_ok) => ocx.register_infer_ok_obligations(infer_ok),
755765
Err(ty_err) => {
756766
tcx.sess.delay_span_bug(
757767
span,
758-
&format!("could not unify `{hidden_type}` with revealed type:\n{ty_err}"),
768+
&format!("could not unify `{hidden_ty}` with revealed type:\n{ty_err}"),
759769
);
760770
}
761771
}
@@ -764,7 +774,7 @@ fn check_opaque_meets_bounds<'tcx>(
764774
// Defining use functions may have more bounds than the opaque type, which is ok, as long as the
765775
// hidden type is well formed even without those bounds.
766776
let predicate =
767-
ty::Binder::dummy(ty::PredicateKind::WellFormed(hidden_type.into())).to_predicate(tcx);
777+
ty::Binder::dummy(ty::PredicateKind::WellFormed(hidden_ty.into())).to_predicate(tcx);
768778
ocx.register_obligation(Obligation::new(misc_cause, param_env, predicate));
769779

770780
// Check that all obligations are satisfied by the implementation's

compiler/rustc_metadata/src/errors.rs

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,41 @@ pub struct FailedWriteError {
372372
#[derive(Diagnostic)]
373373
#[diag(metadata::missing_native_library)]
374374
pub struct MissingNativeLibrary<'a> {
375-
pub libname: &'a str,
375+
libname: &'a str,
376+
#[subdiagnostic]
377+
suggest_name: Option<SuggestLibraryName<'a>>,
378+
}
379+
380+
impl<'a> MissingNativeLibrary<'a> {
381+
pub fn new(libname: &'a str, verbatim: bool) -> Self {
382+
// if it looks like the user has provided a complete filename rather just the bare lib name,
383+
// then provide a note that they might want to try trimming the name
384+
let suggested_name = if !verbatim {
385+
if let Some(libname) = libname.strip_prefix("lib") && let Some(libname) = libname.strip_suffix(".a") {
386+
// this is a unix style filename so trim prefix & suffix
387+
Some(libname)
388+
} else if let Some(libname) = libname.strip_suffix(".lib") {
389+
// this is a Windows style filename so just trim the suffix
390+
Some(libname)
391+
} else {
392+
None
393+
}
394+
} else {
395+
None
396+
};
397+
398+
Self {
399+
libname,
400+
suggest_name: suggested_name
401+
.map(|suggested_name| SuggestLibraryName { suggested_name }),
402+
}
403+
}
404+
}
405+
406+
#[derive(Subdiagnostic)]
407+
#[help(metadata::only_provide_library_name)]
408+
pub struct SuggestLibraryName<'a> {
409+
suggested_name: &'a str,
376410
}
377411

378412
#[derive(Diagnostic)]

compiler/rustc_metadata/src/native_libs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ pub fn find_native_static_library(
5252
}
5353
}
5454

55-
sess.emit_fatal(MissingNativeLibrary { libname: name });
55+
sess.emit_fatal(MissingNativeLibrary::new(name, verbatim.unwrap_or(false)));
5656
}
5757

5858
fn find_bundled_library(

compiler/rustc_mir_build/src/build/expr/as_rvalue.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,13 +197,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
197197
// create all the steps directly in MIR with operations all backends need to support anyway.
198198
let (source, ty) = if let ty::Adt(adt_def, ..) = source.ty.kind() && adt_def.is_enum() {
199199
let discr_ty = adt_def.repr().discr_type().to_ty(this.tcx);
200-
let place = unpack!(block = this.as_place(block, source));
200+
let temp = unpack!(block = this.as_temp(block, scope, source, Mutability::Not));
201201
let discr = this.temp(discr_ty, source.span);
202202
this.cfg.push_assign(
203203
block,
204204
source_info,
205205
discr,
206-
Rvalue::Discriminant(place),
206+
Rvalue::Discriminant(temp.into()),
207207
);
208208

209209
(Operand::Move(discr), discr_ty)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.12.2
1+
0.12.3

src/librustdoc/clean/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1543,8 +1543,7 @@ pub(crate) fn clean_ty<'tcx>(ty: &hir::Ty<'tcx>, cx: &mut DocContext<'tcx>) -> T
15431543
}
15441544
TyKind::BareFn(barefn) => BareFunction(Box::new(clean_bare_fn_ty(barefn, cx))),
15451545
// Rustdoc handles `TyKind::Err`s by turning them into `Type::Infer`s.
1546-
TyKind::Infer | TyKind::Err => Infer,
1547-
TyKind::Typeof(..) => panic!("unimplemented type {:?}", ty.kind),
1546+
TyKind::Infer | TyKind::Err | TyKind::Typeof(..) => Infer,
15481547
}
15491548
}
15501549

src/test/mir-opt/enum_cast.bar.mir_map.0.mir

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,15 @@
33
fn bar(_1: Bar) -> usize {
44
debug bar => _1; // in scope 0 at $DIR/enum_cast.rs:+0:8: +0:11
55
let mut _0: usize; // return place in scope 0 at $DIR/enum_cast.rs:+0:21: +0:26
6-
let mut _2: isize; // in scope 0 at $DIR/enum_cast.rs:+1:5: +1:8
6+
let _2: Bar; // in scope 0 at $DIR/enum_cast.rs:+1:5: +1:8
7+
let mut _3: isize; // in scope 0 at $DIR/enum_cast.rs:+1:5: +1:8
78

89
bb0: {
9-
_2 = discriminant(_1); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:17
10-
_0 = move _2 as usize (IntToInt); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:17
10+
StorageLive(_2); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:8
11+
_2 = move _1; // scope 0 at $DIR/enum_cast.rs:+1:5: +1:8
12+
_3 = discriminant(_2); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:17
13+
_0 = move _3 as usize (IntToInt); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:17
14+
StorageDead(_2); // scope 0 at $DIR/enum_cast.rs:+1:16: +1:17
1115
return; // scope 0 at $DIR/enum_cast.rs:+2:2: +2:2
1216
}
1317
}

src/test/mir-opt/enum_cast.boo.mir_map.0.mir

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,15 @@
33
fn boo(_1: Boo) -> usize {
44
debug boo => _1; // in scope 0 at $DIR/enum_cast.rs:+0:8: +0:11
55
let mut _0: usize; // return place in scope 0 at $DIR/enum_cast.rs:+0:21: +0:26
6-
let mut _2: u8; // in scope 0 at $DIR/enum_cast.rs:+1:5: +1:8
6+
let _2: Boo; // in scope 0 at $DIR/enum_cast.rs:+1:5: +1:8
7+
let mut _3: u8; // in scope 0 at $DIR/enum_cast.rs:+1:5: +1:8
78

89
bb0: {
9-
_2 = discriminant(_1); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:17
10-
_0 = move _2 as usize (IntToInt); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:17
10+
StorageLive(_2); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:8
11+
_2 = move _1; // scope 0 at $DIR/enum_cast.rs:+1:5: +1:8
12+
_3 = discriminant(_2); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:17
13+
_0 = move _3 as usize (IntToInt); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:17
14+
StorageDead(_2); // scope 0 at $DIR/enum_cast.rs:+1:16: +1:17
1115
return; // scope 0 at $DIR/enum_cast.rs:+2:2: +2:2
1216
}
1317
}

0 commit comments

Comments
 (0)