Skip to content

Commit b569c9d

Browse files
committed
Auto merge of #105979 - matthiaskrgr:rollup-2luw3mx, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - #105791 (docs: add long error explanation for error E0472) - #105897 (Fix an opaque type ICE) - #105904 (Fix arch flag on i686-apple-darwin) - #105949 (Bump `cfg-if` to `1.0` in rustc crates) - #105964 (rustdoc: prevent CSS layout of line numbers shrinking into nothing) - #105972 (rustdoc: simplify section anchor CSS) - #105973 (Avoid going through the happy path in case of non-fn builtin calls) - #105976 (Remove unused `check-stage2-T-arm-linux-androideabi-H-x86_64-unknown-linux-gnu` make rule) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents a8207df + ae90226 commit b569c9d

File tree

27 files changed

+235
-72
lines changed

27 files changed

+235
-72
lines changed

Cargo.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -3590,7 +3590,7 @@ version = "0.0.0"
35903590
dependencies = [
35913591
"arrayvec",
35923592
"bitflags",
3593-
"cfg-if 0.1.10",
3593+
"cfg-if 1.0.0",
35943594
"ena",
35953595
"indexmap",
35963596
"jobserver",
@@ -4374,7 +4374,7 @@ dependencies = [
43744374
name = "rustc_span"
43754375
version = "0.0.0"
43764376
dependencies = [
4377-
"cfg-if 0.1.10",
4377+
"cfg-if 1.0.0",
43784378
"md-5",
43794379
"rustc_arena",
43804380
"rustc_data_structures",

compiler/rustc_borrowck/src/diagnostics/region_errors.rs

+21-3
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ use rustc_infer::infer::{
1818
use rustc_middle::hir::place::PlaceBase;
1919
use rustc_middle::mir::{ConstraintCategory, ReturnConstraint};
2020
use rustc_middle::ty::subst::InternalSubsts;
21-
use rustc_middle::ty::Region;
2221
use rustc_middle::ty::TypeVisitor;
2322
use rustc_middle::ty::{self, RegionVid, Ty};
23+
use rustc_middle::ty::{Region, TyCtxt};
2424
use rustc_span::symbol::{kw, Ident};
25-
use rustc_span::Span;
25+
use rustc_span::{Span, DUMMY_SP};
2626

2727
use crate::borrowck_errors;
2828
use crate::session_diagnostics::{
@@ -70,7 +70,25 @@ impl<'tcx> ConstraintDescription for ConstraintCategory<'tcx> {
7070
///
7171
/// Usually we expect this to either be empty or contain a small number of items, so we can avoid
7272
/// allocation most of the time.
73-
pub(crate) type RegionErrors<'tcx> = Vec<RegionErrorKind<'tcx>>;
73+
pub(crate) struct RegionErrors<'tcx>(Vec<RegionErrorKind<'tcx>>, TyCtxt<'tcx>);
74+
75+
impl<'tcx> RegionErrors<'tcx> {
76+
pub fn new(tcx: TyCtxt<'tcx>) -> Self {
77+
Self(vec![], tcx)
78+
}
79+
#[track_caller]
80+
pub fn push(&mut self, val: impl Into<RegionErrorKind<'tcx>>) {
81+
let val = val.into();
82+
self.1.sess.delay_span_bug(DUMMY_SP, "{val:?}");
83+
self.0.push(val);
84+
}
85+
pub fn is_empty(&self) -> bool {
86+
self.0.is_empty()
87+
}
88+
pub fn into_iter(self) -> impl Iterator<Item = RegionErrorKind<'tcx>> {
89+
self.0.into_iter()
90+
}
91+
}
7492

7593
#[derive(Clone, Debug)]
7694
pub(crate) enum RegionErrorKind<'tcx> {

compiler/rustc_borrowck/src/region_infer/mod.rs

+23-20
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
562562
let mir_def_id = body.source.def_id();
563563
self.propagate_constraints(body);
564564

565-
let mut errors_buffer = RegionErrors::new();
565+
let mut errors_buffer = RegionErrors::new(infcx.tcx);
566566

567567
// If this is a closure, we can propagate unsatisfied
568568
// `outlives_requirements` to our creator, so create a vector
@@ -1647,26 +1647,29 @@ impl<'tcx> RegionInferenceContext<'tcx> {
16471647
let longer_fr_scc = self.constraint_sccs.scc(longer_fr);
16481648
debug!("check_bound_universal_region: longer_fr_scc={:?}", longer_fr_scc,);
16491649

1650-
// If we have some bound universal region `'a`, then the only
1651-
// elements it can contain is itself -- we don't know anything
1652-
// else about it!
1653-
let Some(error_element) = ({
1654-
self.scc_values.elements_contained_in(longer_fr_scc).find(|element| match element {
1655-
RegionElement::Location(_) => true,
1656-
RegionElement::RootUniversalRegion(_) => true,
1657-
RegionElement::PlaceholderRegion(placeholder1) => placeholder != *placeholder1,
1658-
})
1659-
}) else {
1660-
return;
1661-
};
1662-
debug!("check_bound_universal_region: error_element = {:?}", error_element);
1650+
for error_element in self.scc_values.elements_contained_in(longer_fr_scc) {
1651+
match error_element {
1652+
RegionElement::Location(_) | RegionElement::RootUniversalRegion(_) => {}
1653+
// If we have some bound universal region `'a`, then the only
1654+
// elements it can contain is itself -- we don't know anything
1655+
// else about it!
1656+
RegionElement::PlaceholderRegion(placeholder1) => {
1657+
if placeholder == placeholder1 {
1658+
continue;
1659+
}
1660+
}
1661+
}
16631662

1664-
// Find the region that introduced this `error_element`.
1665-
errors_buffer.push(RegionErrorKind::BoundUniversalRegionError {
1666-
longer_fr,
1667-
error_element,
1668-
placeholder,
1669-
});
1663+
errors_buffer.push(RegionErrorKind::BoundUniversalRegionError {
1664+
longer_fr,
1665+
error_element,
1666+
placeholder,
1667+
});
1668+
1669+
// Stop after the first error, it gets too noisy otherwise, and does not provide more information.
1670+
break;
1671+
}
1672+
debug!("check_bound_universal_region: all bounds satisfied");
16701673
}
16711674

16721675
#[instrument(level = "debug", skip(self, infcx, errors_buffer))]

compiler/rustc_borrowck/src/type_check/mod.rs

+9-5
Original file line numberDiff line numberDiff line change
@@ -1153,27 +1153,31 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
11531153
category: ConstraintCategory<'tcx>,
11541154
) -> Fallible<()> {
11551155
let annotated_type = self.user_type_annotations[user_ty.base].inferred_ty;
1156+
trace!(?annotated_type);
11561157
let mut curr_projected_ty = PlaceTy::from_ty(annotated_type);
11571158

11581159
let tcx = self.infcx.tcx;
11591160

11601161
for proj in &user_ty.projs {
1162+
if let ty::Alias(ty::Opaque, ..) = curr_projected_ty.ty.kind() {
1163+
// There is nothing that we can compare here if we go through an opaque type.
1164+
// We're always in its defining scope as we can otherwise not project through
1165+
// it, so we're constraining it anyways.
1166+
return Ok(());
1167+
}
11611168
let projected_ty = curr_projected_ty.projection_ty_core(
11621169
tcx,
11631170
self.param_env,
11641171
proj,
1165-
|this, field, _| {
1172+
|this, field, ()| {
11661173
let ty = this.field_ty(tcx, field);
11671174
self.normalize(ty, locations)
11681175
},
11691176
|_, _| unreachable!(),
11701177
);
11711178
curr_projected_ty = projected_ty;
11721179
}
1173-
debug!(
1174-
"user_ty base: {:?} freshened: {:?} projs: {:?} yields: {:?}",
1175-
user_ty.base, annotated_type, user_ty.projs, curr_projected_ty
1176-
);
1180+
trace!(?curr_projected_ty);
11771181

11781182
let ty = curr_projected_ty.ty;
11791183
self.relate_types(ty, v.xform(ty::Variance::Contravariant), a, locations, category)?;

compiler/rustc_data_structures/Cargo.toml

+6-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ edition = "2021"
88
[dependencies]
99
arrayvec = { version = "0.7", default-features = false }
1010
bitflags = "1.2.1"
11-
cfg-if = "0.1.2"
11+
cfg-if = "1.0"
1212
ena = "0.14"
1313
indexmap = { version = "1.9.1" }
1414
jobserver_crate = { version = "0.1.13", package = "jobserver" }
@@ -21,7 +21,11 @@ rustc-hash = "1.1.0"
2121
rustc_index = { path = "../rustc_index", package = "rustc_index" }
2222
rustc_macros = { path = "../rustc_macros" }
2323
rustc_serialize = { path = "../rustc_serialize" }
24-
smallvec = { version = "1.8.1", features = ["const_generics", "union", "may_dangle"] }
24+
smallvec = { version = "1.8.1", features = [
25+
"const_generics",
26+
"union",
27+
"may_dangle",
28+
] }
2529
stable_deref_trait = "1.0.0"
2630
stacker = "0.1.15"
2731
tempfile = "3.2"

compiler/rustc_error_codes/src/error_codes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ E0464: include_str!("./error_codes/E0464.md"),
249249
E0466: include_str!("./error_codes/E0466.md"),
250250
E0468: include_str!("./error_codes/E0468.md"),
251251
E0469: include_str!("./error_codes/E0469.md"),
252+
E0472: include_str!("./error_codes/E0472.md"),
252253
E0477: include_str!("./error_codes/E0477.md"),
253254
E0478: include_str!("./error_codes/E0478.md"),
254255
E0482: include_str!("./error_codes/E0482.md"),
@@ -599,7 +600,6 @@ E0791: include_str!("./error_codes/E0791.md"),
599600
// E0467, // removed
600601
// E0470, // removed
601602
// E0471, // constant evaluation error (in pattern)
602-
E0472, // llvm_asm! is unsupported on this target
603603
// E0473, // dereference of reference outside its lifetime
604604
// E0474, // captured variable `..` does not outlive the enclosing closure
605605
// E0475, // index of slice outside its lifetime
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
Inline assembly (`asm!`) is not supported on this target.
2+
3+
Example of erroneous code:
4+
5+
```ignore (cannot-change-target)
6+
// compile-flags: --target sparc64-unknown-linux-gnu
7+
#![no_std]
8+
9+
use core::arch::asm;
10+
11+
fn main() {
12+
unsafe {
13+
asm!(""); // error: inline assembly is not supported on this target
14+
}
15+
}
16+
```
17+
18+
The Rust compiler does not support inline assembly, with the `asm!` macro
19+
(previously `llvm_asm!`), for all targets. All Tier 1 targets do support this
20+
macro but support among Tier 2 and 3 targets is not guaranteed (even when they
21+
have `std` support). Note that this error is related to
22+
`error[E0658]: inline assembly is not stable yet on this architecture`, but
23+
distinct in that with `E0472` support is not planned or in progress.
24+
25+
There is no way to easily fix this issue, however:
26+
* Consider if you really need inline assembly, is there some other way to
27+
achieve your goal (intrinsics, etc)?
28+
* Consider writing your assembly externally, linking with it and calling it
29+
from Rust.
30+
* Consider contributing to <https://github.com/rust-lang/rust> and help
31+
integrate support for your target!

compiler/rustc_hir_typeck/src/callee.rs

+6-18
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use super::{Expectation, FnCtxt, TupleArgumentsFlag};
44

55
use crate::type_error_struct;
66
use rustc_ast::util::parser::PREC_POSTFIX;
7-
use rustc_errors::{struct_span_err, Applicability, Diagnostic, StashKey};
7+
use rustc_errors::{struct_span_err, Applicability, Diagnostic, ErrorGuaranteed, StashKey};
88
use rustc_hir as hir;
99
use rustc_hir::def::{self, CtorKind, Namespace, Res};
1010
use rustc_hir::def_id::DefId;
@@ -424,21 +424,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
424424
}
425425
}
426426

427-
self.report_invalid_callee(call_expr, callee_expr, callee_ty, arg_exprs);
428-
429-
// This is the "default" function signature, used in case of error.
430-
// In that case, we check each argument against "error" in order to
431-
// set up all the node type bindings.
432-
(
433-
ty::Binder::dummy(self.tcx.mk_fn_sig(
434-
self.err_args(arg_exprs.len()).into_iter(),
435-
self.tcx.ty_error(),
436-
false,
437-
hir::Unsafety::Normal,
438-
abi::Abi::Rust,
439-
)),
440-
None,
441-
)
427+
let err = self.report_invalid_callee(call_expr, callee_expr, callee_ty, arg_exprs);
428+
429+
return self.tcx.ty_error_with_guaranteed(err);
442430
}
443431
};
444432

@@ -591,7 +579,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
591579
callee_expr: &'tcx hir::Expr<'tcx>,
592580
callee_ty: Ty<'tcx>,
593581
arg_exprs: &'tcx [hir::Expr<'tcx>],
594-
) {
582+
) -> ErrorGuaranteed {
595583
let mut unit_variant = None;
596584
if let hir::ExprKind::Path(qpath) = &callee_expr.kind
597585
&& let Res::Def(def::DefKind::Ctor(kind, CtorKind::Const), _)
@@ -720,7 +708,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
720708
err.span_label(span, label);
721709
}
722710
}
723-
err.emit();
711+
err.emit()
724712
}
725713

726714
fn confirm_deferred_closure_call(

compiler/rustc_middle/src/mir/tcx.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@ impl<'tcx> PlaceTy<'tcx> {
3232
/// not carry a `Ty` for `T`.)
3333
///
3434
/// Note that the resulting type has not been normalized.
35+
#[instrument(level = "debug", skip(tcx), ret)]
3536
pub fn field_ty(self, tcx: TyCtxt<'tcx>, f: Field) -> Ty<'tcx> {
36-
let answer = match self.ty.kind() {
37+
match self.ty.kind() {
3738
ty::Adt(adt_def, substs) => {
3839
let variant_def = match self.variant_index {
3940
None => adt_def.non_enum_variant(),
@@ -47,9 +48,7 @@ impl<'tcx> PlaceTy<'tcx> {
4748
}
4849
ty::Tuple(tys) => tys[f.index()],
4950
_ => bug!("extracting field of non-tuple non-adt: {:?}", self),
50-
};
51-
debug!("field_ty self: {:?} f: {:?} yields: {:?}", self, f, answer);
52-
answer
51+
}
5352
}
5453

5554
/// Convenience wrapper around `projection_ty_core` for

compiler/rustc_middle/src/ty/subst.rs

+4
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,7 @@ impl<'tcx> InternalSubsts<'tcx> {
400400
}
401401

402402
#[inline]
403+
#[track_caller]
403404
pub fn type_at(&self, i: usize) -> Ty<'tcx> {
404405
if let GenericArgKind::Type(ty) = self[i].unpack() {
405406
ty
@@ -409,6 +410,7 @@ impl<'tcx> InternalSubsts<'tcx> {
409410
}
410411

411412
#[inline]
413+
#[track_caller]
412414
pub fn region_at(&self, i: usize) -> ty::Region<'tcx> {
413415
if let GenericArgKind::Lifetime(lt) = self[i].unpack() {
414416
lt
@@ -418,6 +420,7 @@ impl<'tcx> InternalSubsts<'tcx> {
418420
}
419421

420422
#[inline]
423+
#[track_caller]
421424
pub fn const_at(&self, i: usize) -> ty::Const<'tcx> {
422425
if let GenericArgKind::Const(ct) = self[i].unpack() {
423426
ct
@@ -427,6 +430,7 @@ impl<'tcx> InternalSubsts<'tcx> {
427430
}
428431

429432
#[inline]
433+
#[track_caller]
430434
pub fn type_for_def(&self, def: &ty::GenericParamDef) -> GenericArg<'tcx> {
431435
self.type_at(def.index as usize).into()
432436
}

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,14 @@ pub fn as_constant_inner<'tcx>(
6666

6767
let literal = ConstantKind::Val(ConstValue::Scalar(Scalar::Int(lit)), ty);
6868

69-
Constant { span, user_ty: user_ty, literal }
69+
Constant { span, user_ty, literal }
7070
}
7171
ExprKind::ZstLiteral { ref user_ty } => {
7272
let user_ty = user_ty.as_ref().map(push_cuta).flatten();
7373

7474
let literal = ConstantKind::Val(ConstValue::ZeroSized, ty);
7575

76-
Constant { span, user_ty: user_ty, literal }
76+
Constant { span, user_ty, literal }
7777
}
7878
ExprKind::NamedConst { def_id, substs, ref user_ty } => {
7979
let user_ty = user_ty.as_ref().map(push_cuta).flatten();

compiler/rustc_mir_build/src/build/matches/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2210,7 +2210,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
22102210
BindingMode::ByValue => ty::BindingMode::BindByValue(mutability),
22112211
BindingMode::ByRef(_) => ty::BindingMode::BindByReference(mutability),
22122212
};
2213-
let local = LocalDecl::<'tcx> {
2213+
let local = LocalDecl {
22142214
mutability,
22152215
ty: var_ty,
22162216
user_ty: if user_ty.is_empty() { None } else { Some(Box::new(user_ty)) },

compiler/rustc_span/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ rustc_index = { path = "../rustc_index" }
1313
rustc_arena = { path = "../rustc_arena" }
1414
scoped-tls = "1.0"
1515
unicode-width = "0.1.4"
16-
cfg-if = "0.1.2"
16+
cfg-if = "1.0"
1717
tracing = "0.1"
1818
sha1 = { package = "sha-1", version = "0.10.0" }
1919
sha2 = "0.10.1"

src/bootstrap/mk/Makefile.in

-5
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,6 @@ tidy:
5757
prepare:
5858
$(Q)$(BOOTSTRAP) build --stage 2 nonexistent/path/to/trigger/cargo/metadata
5959

60-
check-stage2-T-arm-linux-androideabi-H-x86_64-unknown-linux-gnu:
61-
$(Q)$(BOOTSTRAP) test --stage 2 --target arm-linux-androideabi
62-
check-stage2-T-x86_64-unknown-linux-musl-H-x86_64-unknown-linux-gnu:
63-
$(Q)$(BOOTSTRAP) test --stage 2 --target x86_64-unknown-linux-musl
64-
6560
TESTS_IN_2 := \
6661
src/test/ui \
6762
src/tools/linkchecker

src/bootstrap/native.rs

+3
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,9 @@ fn configure_cmake(
600600
if target.starts_with("aarch64") {
601601
// macOS uses a different name for building arm64
602602
cfg.define("CMAKE_OSX_ARCHITECTURES", "arm64");
603+
} else if target.starts_with("i686") {
604+
// macOS uses a different name for building i386
605+
cfg.define("CMAKE_OSX_ARCHITECTURES", "i386");
603606
} else {
604607
cfg.define("CMAKE_OSX_ARCHITECTURES", target.triple.split('-').next().unwrap());
605608
}

0 commit comments

Comments
 (0)