Skip to content

Commit

Permalink
Auto merge of #99177 - Dylan-DPC:rollup-m0k9q2w, r=Dylan-DPC
Browse files Browse the repository at this point in the history
Rollup of 6 pull requests

Successful merges:

 - #98622 (rustc_target: Flip the default for `TargetOptions::executables` to true)
 - #98633 (Fix last `let_chains` blocker)
 - #98972 (Suggest adding a missing zero to a floating point number)
 - #99038 (Some more `EarlyBinder` cleanups)
 - #99154 (use PlaceRef::iter_projections to fix old FIXME)
 - #99171 (Put back UI test regex)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed Jul 12, 2022
2 parents b3f4c31 + 87e25e4 commit 1c7b36d
Show file tree
Hide file tree
Showing 82 changed files with 1,180 additions and 427 deletions.
8 changes: 3 additions & 5 deletions compiler/rustc_middle/src/mir/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1111,11 +1111,9 @@ macro_rules! visit_place_fns {
context: PlaceContext,
location: Location,
) {
// FIXME: Use PlaceRef::iter_projections, once that exists.
let mut cursor = place_ref.projection;
while let &[ref proj_base @ .., elem] = cursor {
cursor = proj_base;
self.visit_projection_elem(place_ref.local, cursor, elem, context, location);
for (base, elem) in place_ref.iter_projections().rev() {
let base_proj = base.projection;
self.visit_projection_elem(place_ref.local, base_proj, elem, context, location);
}
}

Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_middle/src/ty/generics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ impl GenericParamDef {
) -> Option<EarlyBinder<ty::GenericArg<'tcx>>> {
match self.kind {
GenericParamDefKind::Type { has_default, .. } if has_default => {
Some(EarlyBinder(tcx.type_of(self.def_id).into()))
Some(tcx.bound_type_of(self.def_id).map_bound(|t| t.into()))
}
GenericParamDefKind::Const { has_default } if has_default => {
Some(EarlyBinder(tcx.const_param_default(self.def_id).into()))
Some(tcx.bound_const_param_default(self.def_id).map_bound(|c| c.into()))
}
_ => None,
}
Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_middle/src/ty/sty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -932,6 +932,10 @@ impl<T> EarlyBinder<T> {
let value = f(self.0)?;
Ok(EarlyBinder(value))
}

pub fn rebind<U>(&self, value: U) -> EarlyBinder<U> {
EarlyBinder(value)
}
}

impl<T> EarlyBinder<Option<T>> {
Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_middle/src/ty/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,10 @@ impl<'tcx> TyCtxt<'tcx> {
) -> ty::EarlyBinder<&'tcx ty::List<ty::Predicate<'tcx>>> {
ty::EarlyBinder(self.item_bounds(def_id))
}

pub fn bound_const_param_default(self, def_id: DefId) -> ty::EarlyBinder<ty::Const<'tcx>> {
ty::EarlyBinder(self.const_param_default(def_id))
}
}

struct OpaqueTypeExpander<'tcx> {
Expand Down
9 changes: 4 additions & 5 deletions compiler/rustc_mir_transform/src/shim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -537,13 +537,12 @@ fn build_call_shim<'tcx>(
};

let def_id = instance.def_id();
let sig = tcx.fn_sig(def_id);
let mut sig = tcx.erase_late_bound_regions(sig);
let sig = tcx.bound_fn_sig(def_id);
let sig = sig.map_bound(|sig| tcx.erase_late_bound_regions(sig));

assert_eq!(sig_substs.is_some(), !instance.has_polymorphic_mir_body());
if let Some(sig_substs) = sig_substs {
sig = EarlyBinder(sig).subst(tcx, sig_substs);
}
let mut sig =
if let Some(sig_substs) = sig_substs { sig.subst(tcx, sig_substs) } else { sig.0 };

if let CallKind::Indirect(fnty) = call_kind {
// `sig` determines our local decls, and thus the callee type in the `Call` terminator. This
Expand Down
32 changes: 24 additions & 8 deletions compiler/rustc_parse/src/parser/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1393,7 +1393,9 @@ impl<'a> Parser<'a> {
self.parse_yield_expr(attrs)
} else if self.is_do_yeet() {
self.parse_yeet_expr(attrs)
} else if self.eat_keyword(kw::Let) {
} else if self.check_keyword(kw::Let) {
self.manage_let_chains_context();
self.bump();
self.parse_let_expr(attrs)
} else if self.eat_keyword(kw::Underscore) {
Ok(self.mk_expr(self.prev_token.span, ExprKind::Underscore, attrs))
Expand Down Expand Up @@ -2355,16 +2357,30 @@ impl<'a> Parser<'a> {
Ok(cond)
}

// Checks if `let` is in an invalid position like `let x = let y = 1;` or
// if the current `let` is in a let_chains context but nested in another
// expression like `if let Some(_) = _opt && [1, 2, 3][let _ = ()] = 1`.
//
// This method expects that the current token is `let`.
fn manage_let_chains_context(&mut self) {
debug_assert!(matches!(self.token.kind, TokenKind::Ident(kw::Let, _)));
let is_in_a_let_chains_context_but_nested_in_other_expr = self.let_expr_allowed
&& !matches!(
self.prev_token.kind,
TokenKind::AndAnd
| TokenKind::CloseDelim(Delimiter::Brace)
| TokenKind::Ident(kw::If, _)
| TokenKind::Ident(kw::While, _)
);
if !self.let_expr_allowed || is_in_a_let_chains_context_but_nested_in_other_expr {
self.struct_span_err(self.token.span, "expected expression, found `let` statement")
.emit();
}
}

/// Parses a `let $pat = $expr` pseudo-expression.
/// The `let` token has already been eaten.
fn parse_let_expr(&mut self, attrs: AttrVec) -> PResult<'a, P<Expr>> {
if !self.let_expr_allowed {
self.struct_span_err(
self.prev_token.span,
"expected expression, found `let` statement",
)
.emit();
}
let lo = self.prev_token.span;
let pat = self.parse_pat_allow_top_alt(
None,
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_target/src/spec/aarch64_unknown_none.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ pub fn target() -> Target {
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
linker: Some("rust-lld".into()),
features: "+strict-align,+neon,+fp-armv8".into(),
executables: true,
relocation_model: RelocModel::Static,
disable_redzone: true,
max_atomic_width: Some(128),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ pub fn target() -> Target {
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
linker: Some("rust-lld".into()),
features: "+strict-align,-neon,-fp-armv8".into(),
executables: true,
relocation_model: RelocModel::Static,
disable_redzone: true,
max_atomic_width: Some(128),
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_target/src/spec/apple_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ pub fn opts(os: &'static str) -> TargetOptions {
function_sections: false,
dynamic_linking: true,
linker_is_gnu: false,
executables: true,
families: cvs!["unix"],
is_like_osx: true,
default_dwarf_version: 2,
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_target/src/spec/apple_sdk_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ pub fn opts(os: &'static str, arch: Arch) -> TargetOptions {
abi: target_abi(arch).into(),
cpu: target_cpu(arch).into(),
dynamic_linking: false,
executables: true,
link_env_remove: link_env_remove(arch),
has_thread_local: false,
..super::apple_base::opts(os)
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_target/src/spec/armebv7r_none_eabi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ pub fn target() -> Target {
abi: "eabi".into(),
endian: Endian::Big,
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
executables: true,
linker: Some("rust-lld".into()),
relocation_model: RelocModel::Static,
panic_strategy: PanicStrategy::Abort,
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_target/src/spec/armebv7r_none_eabihf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ pub fn target() -> Target {
abi: "eabihf".into(),
endian: Endian::Big,
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
executables: true,
linker: Some("rust-lld".into()),
relocation_model: RelocModel::Static,
panic_strategy: PanicStrategy::Abort,
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_target/src/spec/armv6k_nintendo_3ds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ pub fn target() -> Target {
abi: "eabihf".into(),
linker_flavor: LinkerFlavor::Gcc,
cpu: "mpcore".into(),
executables: true,
families: cvs!["unix"],
linker: Some("arm-none-eabi-gcc".into()),
relocation_model: RelocModel::Static,
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_target/src/spec/armv7a_none_eabi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ pub fn target() -> Target {
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
linker: Some("rust-lld".into()),
features: "+v7,+thumb2,+soft-float,-neon,+strict-align".into(),
executables: true,
relocation_model: RelocModel::Static,
disable_redzone: true,
max_atomic_width: Some(64),
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_target/src/spec/armv7a_none_eabihf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ pub fn target() -> Target {
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
linker: Some("rust-lld".into()),
features: "+v7,+vfp3,-d32,+thumb2,-neon,+strict-align".into(),
executables: true,
relocation_model: RelocModel::Static,
disable_redzone: true,
max_atomic_width: Some(64),
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_target/src/spec/armv7r_none_eabi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ pub fn target() -> Target {
options: TargetOptions {
abi: "eabi".into(),
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
executables: true,
linker: Some("rust-lld".into()),
relocation_model: RelocModel::Static,
panic_strategy: PanicStrategy::Abort,
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_target/src/spec/armv7r_none_eabihf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ pub fn target() -> Target {
options: TargetOptions {
abi: "eabihf".into(),
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
executables: true,
linker: Some("rust-lld".into()),
relocation_model: RelocModel::Static,
panic_strategy: PanicStrategy::Abort,
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_target/src/spec/avr_gnu_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ pub fn target(target_cpu: &'static str, mmcu: &'static str) -> Target {
exe_suffix: ".elf".into(),

linker: Some("avr-gcc".into()),
executables: true,
eh_frame_header: false,
pre_link_args: TargetOptions::link_args(LinkerFlavor::Gcc, &[mmcu]),
late_link_args: TargetOptions::link_args(LinkerFlavor::Gcc, &["-lgcc"]),
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_target/src/spec/bpf_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ pub fn opts(endian: Endian) -> TargetOptions {
endian,
linker_flavor: LinkerFlavor::BpfLinker,
atomic_cas: false,
executables: true,
dynamic_linking: true,
no_builtins: true,
panic_strategy: PanicStrategy::Abort,
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_target/src/spec/dragonfly_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ pub fn opts() -> TargetOptions {
TargetOptions {
os: "dragonfly".into(),
dynamic_linking: true,
executables: true,
families: cvs!["unix"],
has_rpath: true,
position_independent_executables: true,
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_target/src/spec/freebsd_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ pub fn opts() -> TargetOptions {
TargetOptions {
os: "freebsd".into(),
dynamic_linking: true,
executables: true,
families: cvs!["unix"],
has_rpath: true,
position_independent_executables: true,
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_target/src/spec/fuchsia_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ pub fn opts() -> TargetOptions {
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
linker: Some("rust-lld".into()),
dynamic_linking: true,
executables: true,
families: cvs!["unix"],
pre_link_args,
pre_link_objects: crt_objects::new(&[
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_target/src/spec/haiku_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ pub fn opts() -> TargetOptions {
TargetOptions {
os: "haiku".into(),
dynamic_linking: true,
executables: true,
families: cvs!["unix"],
relro_level: RelroLevel::Full,
..Default::default()
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_target/src/spec/hermit_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ pub fn opts() -> TargetOptions {
os: "hermit".into(),
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
linker: Some("rust-lld".into()),
executables: true,
has_thread_local: true,
pre_link_args,
panic_strategy: PanicStrategy::Abort,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ pub fn target() -> Target {
base.has_rpath = true;
base.linker_is_gnu = false;
base.dynamic_linking = true;
base.executables = true;

base.c_enum_min_bits = 8;

Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_target/src/spec/illumos_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ pub fn opts() -> TargetOptions {
TargetOptions {
os: "illumos".into(),
dynamic_linking: true,
executables: true,
has_rpath: true,
families: cvs!["unix"],
is_like_solaris: true,
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_target/src/spec/l4re_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ pub fn opts() -> TargetOptions {
os: "l4re".into(),
env: "uclibc".into(),
linker_flavor: LinkerFlavor::L4Bender,
executables: true,
panic_strategy: PanicStrategy::Abort,
linker: Some("l4-bender".into()),
linker_is_gnu: false,
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_target/src/spec/linux_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ pub fn opts() -> TargetOptions {
TargetOptions {
os: "linux".into(),
dynamic_linking: true,
executables: true,
families: cvs!["unix"],
has_rpath: true,
position_independent_executables: true,
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_target/src/spec/mipsel_sony_psp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ pub fn target() -> Target {
vendor: "sony".into(),
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
cpu: "mips2".into(),
executables: true,
linker: Some("rust-lld".into()),
relocation_model: RelocModel::Static,

Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_target/src/spec/mipsel_unknown_none.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ pub fn target() -> Target {
cpu: "mips32r2".into(),
features: "+mips32r2,+soft-float,+noabicalls".into(),
max_atomic_width: Some(32),
executables: true,
linker: Some("rust-lld".into()),
panic_strategy: PanicStrategy::Abort,
relocation_model: RelocModel::Static,
Expand Down
5 changes: 2 additions & 3 deletions compiler/rustc_target/src/spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1212,8 +1212,7 @@ pub struct TargetOptions {
pub dynamic_linking: bool,
/// If dynamic linking is available, whether only cdylibs are supported.
pub only_cdylib: bool,
/// Whether executables are available on this target. iOS, for example, only allows static
/// libraries. Defaults to false.
/// Whether executables are available on this target. Defaults to true.
pub executables: bool,
/// Relocation model to use in object file. Corresponds to `llc
/// -relocation-model=$relocation_model`. Defaults to `Pic`.
Expand Down Expand Up @@ -1520,7 +1519,7 @@ impl Default for TargetOptions {
features: "".into(),
dynamic_linking: false,
only_cdylib: false,
executables: false,
executables: true,
relocation_model: RelocModel::Pic,
code_model: None,
tls_model: TlsModel::GeneralDynamic,
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_target/src/spec/msp430_none_elf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ pub fn target() -> Target {

options: TargetOptions {
c_int_width: "16".into(),
executables: true,

// The LLVM backend currently can't generate object files. To
// workaround this LLVM generates assembly files which then we feed
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_target/src/spec/msvc_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ pub fn opts() -> TargetOptions {

TargetOptions {
linker_flavor: LinkerFlavor::Msvc,
executables: true,
is_like_windows: true,
is_like_msvc: true,
lld_flavor: LldFlavor::Link,
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_target/src/spec/netbsd_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ pub fn opts() -> TargetOptions {
TargetOptions {
os: "netbsd".into(),
dynamic_linking: true,
executables: true,
families: cvs!["unix"],
no_default_libraries: false,
has_rpath: true,
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_target/src/spec/nvptx64_nvidia_cuda.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ pub fn target() -> Target {

// Needed to use `dylib` and `bin` crate types and the linker.
dynamic_linking: true,
executables: true,

// Avoid using dylib because it contain metadata not supported
// by LLVM NVPTX backend.
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_target/src/spec/openbsd_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ pub fn opts() -> TargetOptions {
TargetOptions {
os: "openbsd".into(),
dynamic_linking: true,
executables: true,
families: cvs!["unix"],
has_rpath: true,
abi_return_struct_as_int: true,
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_target/src/spec/redox_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ pub fn opts() -> TargetOptions {
os: "redox".into(),
env: "relibc".into(),
dynamic_linking: true,
executables: true,
families: cvs!["unix"],
has_rpath: true,
position_independent_executables: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ pub fn target() -> Target {
cpu: "generic-rv32".into(),
max_atomic_width: Some(0),
atomic_cas: false,
executables: true,
panic_strategy: PanicStrategy::Abort,
relocation_model: RelocModel::Static,
emit_debug_gdb_scripts: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ pub fn target() -> Target {
max_atomic_width: Some(0),
atomic_cas: false,
features: "+m".into(),
executables: true,
panic_strategy: PanicStrategy::Abort,
relocation_model: RelocModel::Static,
emit_debug_gdb_scripts: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ pub fn target() -> Target {
cpu: "generic-rv32".into(),
max_atomic_width: Some(32),
features: "+m,+a,+c".into(),
executables: true,
panic_strategy: PanicStrategy::Abort,
relocation_model: RelocModel::Static,
emit_debug_gdb_scripts: false,
Expand Down
Loading

0 comments on commit 1c7b36d

Please sign in to comment.