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 8 pull requests #105979

Merged
merged 21 commits into from
Dec 21, 2022
Merged
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
ee1a905
Fix arch flag on i686-apple-darwin
MarcusCalhoun-Lopez Dec 19, 2022
082ca1e
docs: add long error explanation for error E0472
Ezrashaw Dec 16, 2022
b859b8b
Bump `cfg-if` to `1.0`
ChrisDenton Dec 20, 2022
8b5a96e
Some tracing cleanups
oli-obk Dec 19, 2022
562d846
Make it easier to debug where a region error was created
oli-obk Dec 19, 2022
8b15302
Replace a `find` with a loop to simplify the logic.
oli-obk Dec 19, 2022
e405dab
Some style nits
oli-obk Dec 19, 2022
c9588d5
Hackily fix an opaque type ICE
oli-obk Dec 19, 2022
f1ef038
use `track_caller` to show where the panic is actually from
oli-obk Nov 30, 2022
168e3da
rustdoc: prevent CSS layout of line numbers shrinking into nothing
notriddle Dec 20, 2022
1c5b53b
Avoid going through the happy path in case of non-fn builtin calls
oli-obk Dec 20, 2022
b29a9e3
rustdoc: simplify section anchor CSS
notriddle Dec 20, 2022
fb89ae4
Remove unused `check-stage2-T-arm-linux-androideabi-H-x86_64-unknown-…
jyn514 Dec 20, 2022
4726e51
Rollup merge of #105791 - Ezrashaw:add-e0472-long-docs, r=GuillaumeGomez
matthiaskrgr Dec 20, 2022
a4ef47d
Rollup merge of #105897 - oli-obk:tait_patterns, r=TaKO8Ki
matthiaskrgr Dec 20, 2022
2ddfa8f
Rollup merge of #105904 - MarcusCalhoun-Lopez:darwin_arch_i386, r=bjorn3
matthiaskrgr Dec 20, 2022
a039b22
Rollup merge of #105949 - ChrisDenton:bump-cfg-if, r=Nilstrieb
matthiaskrgr Dec 20, 2022
50cfffa
Rollup merge of #105964 - notriddle:notriddle/scraped-example-length,…
matthiaskrgr Dec 20, 2022
b9edcfa
Rollup merge of #105972 - notriddle:notriddle/anchor, r=GuillaumeGomez
matthiaskrgr Dec 20, 2022
b68e994
Rollup merge of #105973 - oli-obk:simplify_callee_checks, r=jackh726
matthiaskrgr Dec 20, 2022
ae90226
Rollup merge of #105976 - jyn514:unused-make-targets, r=Mark-Simulacrum
matthiaskrgr Dec 20, 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
4 changes: 2 additions & 2 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3590,7 +3590,7 @@ version = "0.0.0"
dependencies = [
"arrayvec",
"bitflags",
"cfg-if 0.1.10",
"cfg-if 1.0.0",
"ena",
"indexmap",
"jobserver",
Expand Down Expand Up @@ -4374,7 +4374,7 @@ dependencies = [
name = "rustc_span"
version = "0.0.0"
dependencies = [
"cfg-if 0.1.10",
"cfg-if 1.0.0",
"md-5",
"rustc_arena",
"rustc_data_structures",
Expand Down
24 changes: 21 additions & 3 deletions compiler/rustc_borrowck/src/diagnostics/region_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ use rustc_infer::infer::{
use rustc_middle::hir::place::PlaceBase;
use rustc_middle::mir::{ConstraintCategory, ReturnConstraint};
use rustc_middle::ty::subst::InternalSubsts;
use rustc_middle::ty::Region;
use rustc_middle::ty::TypeVisitor;
use rustc_middle::ty::{self, RegionVid, Ty};
use rustc_middle::ty::{Region, TyCtxt};
use rustc_span::symbol::{kw, Ident};
use rustc_span::Span;
use rustc_span::{Span, DUMMY_SP};

use crate::borrowck_errors;
use crate::session_diagnostics::{
Expand Down Expand Up @@ -70,7 +70,25 @@ impl<'tcx> ConstraintDescription for ConstraintCategory<'tcx> {
///
/// Usually we expect this to either be empty or contain a small number of items, so we can avoid
/// allocation most of the time.
pub(crate) type RegionErrors<'tcx> = Vec<RegionErrorKind<'tcx>>;
pub(crate) struct RegionErrors<'tcx>(Vec<RegionErrorKind<'tcx>>, TyCtxt<'tcx>);

impl<'tcx> RegionErrors<'tcx> {
pub fn new(tcx: TyCtxt<'tcx>) -> Self {
Self(vec![], tcx)
}
#[track_caller]
pub fn push(&mut self, val: impl Into<RegionErrorKind<'tcx>>) {
let val = val.into();
self.1.sess.delay_span_bug(DUMMY_SP, "{val:?}");
self.0.push(val);
}
pub fn is_empty(&self) -> bool {
self.0.is_empty()
}
pub fn into_iter(self) -> impl Iterator<Item = RegionErrorKind<'tcx>> {
self.0.into_iter()
}
}

#[derive(Clone, Debug)]
pub(crate) enum RegionErrorKind<'tcx> {
Expand Down
43 changes: 23 additions & 20 deletions compiler/rustc_borrowck/src/region_infer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
let mir_def_id = body.source.def_id();
self.propagate_constraints(body);

let mut errors_buffer = RegionErrors::new();
let mut errors_buffer = RegionErrors::new(infcx.tcx);

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

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

// Find the region that introduced this `error_element`.
errors_buffer.push(RegionErrorKind::BoundUniversalRegionError {
longer_fr,
error_element,
placeholder,
});
errors_buffer.push(RegionErrorKind::BoundUniversalRegionError {
longer_fr,
error_element,
placeholder,
});

// Stop after the first error, it gets too noisy otherwise, and does not provide more information.
break;
}
debug!("check_bound_universal_region: all bounds satisfied");
}

#[instrument(level = "debug", skip(self, infcx, errors_buffer))]
Expand Down
14 changes: 9 additions & 5 deletions compiler/rustc_borrowck/src/type_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1153,27 +1153,31 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
category: ConstraintCategory<'tcx>,
) -> Fallible<()> {
let annotated_type = self.user_type_annotations[user_ty.base].inferred_ty;
trace!(?annotated_type);
let mut curr_projected_ty = PlaceTy::from_ty(annotated_type);

let tcx = self.infcx.tcx;

for proj in &user_ty.projs {
if let ty::Alias(ty::Opaque, ..) = curr_projected_ty.ty.kind() {
// There is nothing that we can compare here if we go through an opaque type.
// We're always in its defining scope as we can otherwise not project through
// it, so we're constraining it anyways.
return Ok(());
}
let projected_ty = curr_projected_ty.projection_ty_core(
tcx,
self.param_env,
proj,
|this, field, _| {
|this, field, ()| {
let ty = this.field_ty(tcx, field);
self.normalize(ty, locations)
},
|_, _| unreachable!(),
);
curr_projected_ty = projected_ty;
}
debug!(
"user_ty base: {:?} freshened: {:?} projs: {:?} yields: {:?}",
user_ty.base, annotated_type, user_ty.projs, curr_projected_ty
);
trace!(?curr_projected_ty);

let ty = curr_projected_ty.ty;
self.relate_types(ty, v.xform(ty::Variance::Contravariant), a, locations, category)?;
Expand Down
8 changes: 6 additions & 2 deletions compiler/rustc_data_structures/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ edition = "2021"
[dependencies]
arrayvec = { version = "0.7", default-features = false }
bitflags = "1.2.1"
cfg-if = "0.1.2"
cfg-if = "1.0"
ena = "0.14"
indexmap = { version = "1.9.1" }
jobserver_crate = { version = "0.1.13", package = "jobserver" }
Expand All @@ -21,7 +21,11 @@ rustc-hash = "1.1.0"
rustc_index = { path = "../rustc_index", package = "rustc_index" }
rustc_macros = { path = "../rustc_macros" }
rustc_serialize = { path = "../rustc_serialize" }
smallvec = { version = "1.8.1", features = ["const_generics", "union", "may_dangle"] }
smallvec = { version = "1.8.1", features = [
"const_generics",
"union",
"may_dangle",
] }
stable_deref_trait = "1.0.0"
stacker = "0.1.15"
tempfile = "3.2"
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_error_codes/src/error_codes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ E0464: include_str!("./error_codes/E0464.md"),
E0466: include_str!("./error_codes/E0466.md"),
E0468: include_str!("./error_codes/E0468.md"),
E0469: include_str!("./error_codes/E0469.md"),
E0472: include_str!("./error_codes/E0472.md"),
E0477: include_str!("./error_codes/E0477.md"),
E0478: include_str!("./error_codes/E0478.md"),
E0482: include_str!("./error_codes/E0482.md"),
Expand Down Expand Up @@ -599,7 +600,6 @@ E0791: include_str!("./error_codes/E0791.md"),
// E0467, // removed
// E0470, // removed
// E0471, // constant evaluation error (in pattern)
E0472, // llvm_asm! is unsupported on this target
// E0473, // dereference of reference outside its lifetime
// E0474, // captured variable `..` does not outlive the enclosing closure
// E0475, // index of slice outside its lifetime
Expand Down
31 changes: 31 additions & 0 deletions compiler/rustc_error_codes/src/error_codes/E0472.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
Inline assembly (`asm!`) is not supported on this target.

Example of erroneous code:

```ignore (cannot-change-target)
// compile-flags: --target sparc64-unknown-linux-gnu
#![no_std]

use core::arch::asm;

fn main() {
unsafe {
asm!(""); // error: inline assembly is not supported on this target
}
}
```

The Rust compiler does not support inline assembly, with the `asm!` macro
(previously `llvm_asm!`), for all targets. All Tier 1 targets do support this
macro but support among Tier 2 and 3 targets is not guaranteed (even when they
have `std` support). Note that this error is related to
`error[E0658]: inline assembly is not stable yet on this architecture`, but
distinct in that with `E0472` support is not planned or in progress.

There is no way to easily fix this issue, however:
* Consider if you really need inline assembly, is there some other way to
achieve your goal (intrinsics, etc)?
* Consider writing your assembly externally, linking with it and calling it
from Rust.
* Consider contributing to <https://github.com/rust-lang/rust> and help
integrate support for your target!
24 changes: 6 additions & 18 deletions compiler/rustc_hir_typeck/src/callee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use super::{Expectation, FnCtxt, TupleArgumentsFlag};

use crate::type_error_struct;
use rustc_ast::util::parser::PREC_POSTFIX;
use rustc_errors::{struct_span_err, Applicability, Diagnostic, StashKey};
use rustc_errors::{struct_span_err, Applicability, Diagnostic, ErrorGuaranteed, StashKey};
use rustc_hir as hir;
use rustc_hir::def::{self, CtorKind, Namespace, Res};
use rustc_hir::def_id::DefId;
Expand Down Expand Up @@ -424,21 +424,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
}

self.report_invalid_callee(call_expr, callee_expr, callee_ty, arg_exprs);

// This is the "default" function signature, used in case of error.
// In that case, we check each argument against "error" in order to
// set up all the node type bindings.
(
ty::Binder::dummy(self.tcx.mk_fn_sig(
self.err_args(arg_exprs.len()).into_iter(),
self.tcx.ty_error(),
false,
hir::Unsafety::Normal,
abi::Abi::Rust,
)),
None,
)
let err = self.report_invalid_callee(call_expr, callee_expr, callee_ty, arg_exprs);

return self.tcx.ty_error_with_guaranteed(err);
}
};

Expand Down Expand Up @@ -591,7 +579,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
callee_expr: &'tcx hir::Expr<'tcx>,
callee_ty: Ty<'tcx>,
arg_exprs: &'tcx [hir::Expr<'tcx>],
) {
) -> ErrorGuaranteed {
let mut unit_variant = None;
if let hir::ExprKind::Path(qpath) = &callee_expr.kind
&& let Res::Def(def::DefKind::Ctor(kind, CtorKind::Const), _)
Expand Down Expand Up @@ -720,7 +708,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
err.span_label(span, label);
}
}
err.emit();
err.emit()
}

fn confirm_deferred_closure_call(
Expand Down
7 changes: 3 additions & 4 deletions compiler/rustc_middle/src/mir/tcx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ impl<'tcx> PlaceTy<'tcx> {
/// not carry a `Ty` for `T`.)
///
/// Note that the resulting type has not been normalized.
#[instrument(level = "debug", skip(tcx), ret)]
pub fn field_ty(self, tcx: TyCtxt<'tcx>, f: Field) -> Ty<'tcx> {
let answer = match self.ty.kind() {
match self.ty.kind() {
ty::Adt(adt_def, substs) => {
let variant_def = match self.variant_index {
None => adt_def.non_enum_variant(),
Expand All @@ -47,9 +48,7 @@ impl<'tcx> PlaceTy<'tcx> {
}
ty::Tuple(tys) => tys[f.index()],
_ => bug!("extracting field of non-tuple non-adt: {:?}", self),
};
debug!("field_ty self: {:?} f: {:?} yields: {:?}", self, f, answer);
answer
}
}

/// Convenience wrapper around `projection_ty_core` for
Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_middle/src/ty/subst.rs
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@ impl<'tcx> InternalSubsts<'tcx> {
}

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

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

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

#[inline]
#[track_caller]
pub fn type_for_def(&self, def: &ty::GenericParamDef) -> GenericArg<'tcx> {
self.type_at(def.index as usize).into()
}
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_mir_build/src/build/expr/as_constant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,14 @@ pub fn as_constant_inner<'tcx>(

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

Constant { span, user_ty: user_ty, literal }
Constant { span, user_ty, literal }
}
ExprKind::ZstLiteral { ref user_ty } => {
let user_ty = user_ty.as_ref().map(push_cuta).flatten();

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

Constant { span, user_ty: user_ty, literal }
Constant { span, user_ty, literal }
}
ExprKind::NamedConst { def_id, substs, ref user_ty } => {
let user_ty = user_ty.as_ref().map(push_cuta).flatten();
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir_build/src/build/matches/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2210,7 +2210,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
BindingMode::ByValue => ty::BindingMode::BindByValue(mutability),
BindingMode::ByRef(_) => ty::BindingMode::BindByReference(mutability),
};
let local = LocalDecl::<'tcx> {
let local = LocalDecl {
mutability,
ty: var_ty,
user_ty: if user_ty.is_empty() { None } else { Some(Box::new(user_ty)) },
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_span/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ rustc_index = { path = "../rustc_index" }
rustc_arena = { path = "../rustc_arena" }
scoped-tls = "1.0"
unicode-width = "0.1.4"
cfg-if = "0.1.2"
cfg-if = "1.0"
tracing = "0.1"
sha1 = { package = "sha-1", version = "0.10.0" }
sha2 = "0.10.1"
Expand Down
5 changes: 0 additions & 5 deletions src/bootstrap/mk/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,6 @@ tidy:
prepare:
$(Q)$(BOOTSTRAP) build --stage 2 nonexistent/path/to/trigger/cargo/metadata

check-stage2-T-arm-linux-androideabi-H-x86_64-unknown-linux-gnu:
$(Q)$(BOOTSTRAP) test --stage 2 --target arm-linux-androideabi
check-stage2-T-x86_64-unknown-linux-musl-H-x86_64-unknown-linux-gnu:
$(Q)$(BOOTSTRAP) test --stage 2 --target x86_64-unknown-linux-musl

TESTS_IN_2 := \
src/test/ui \
src/tools/linkchecker
Expand Down
3 changes: 3 additions & 0 deletions src/bootstrap/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,9 @@ fn configure_cmake(
if target.starts_with("aarch64") {
// macOS uses a different name for building arm64
cfg.define("CMAKE_OSX_ARCHITECTURES", "arm64");
} else if target.starts_with("i686") {
// macOS uses a different name for building i386
cfg.define("CMAKE_OSX_ARCHITECTURES", "i386");
} else {
cfg.define("CMAKE_OSX_ARCHITECTURES", target.triple.split('-').next().unwrap());
}
Expand Down
Loading