Skip to content

Commit

Permalink
Auto merge of rust-lang#81678 - jackh726:rollup-3nerni4, r=jackh726
Browse files Browse the repository at this point in the history
Rollup of 14 pull requests

Successful merges:

 - rust-lang#80593 (Upgrade Chalk)
 - rust-lang#81260 (Add .editorconfig)
 - rust-lang#81455 (Add AArch64 big-endian and ILP32 targets)
 - rust-lang#81517 (Remove remnants of the santizer runtime crates from bootstrap)
 - rust-lang#81530 (sys: use `process::abort()` instead of `arch::wasm32::unreachable()`)
 - rust-lang#81544 (Add better diagnostic for unbounded Abst. Const)
 - rust-lang#81588 (Add doc aliases for "delete")
 - rust-lang#81603 (rustbuild: Don't build compiler twice for error-index-generator.)
 - rust-lang#81634 (Add long explanation e0521)
 - rust-lang#81636 (Directly use `Option<&[T]>` instead of converting from `Option<&Vec<T>>` later on)
 - rust-lang#81647 (Fix bug with assert!() calling the wrong edition of panic!().)
 - rust-lang#81655 (Improve wording of suggestion about accessing field)
 - rust-lang#81665 (Fix out of date `Scalar` documentation)
 - rust-lang#81671 (Add more associated type tests)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed Feb 2, 2021
2 parents 3682750 + 81c64b3 commit d95d4f0
Show file tree
Hide file tree
Showing 79 changed files with 645 additions and 202 deletions.
21 changes: 21 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# editorconfig.org

root = true

[*]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 4

[*.md]
# double whitespace at end of line
# denotes a line break in Markdown
trim_trailing_whitespace = false

[*.yml]
indent_size = 2
22 changes: 12 additions & 10 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -496,9 +496,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"

[[package]]
name = "chalk-derive"
version = "0.36.0"
version = "0.55.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9f88ce4deae1dace71e49b7611cfae2d5489de3530d6daba5758043c47ac3a10"
checksum = "3983193cacd81f0f924acb666b7fe5e1a0d81db9f113fa69203eda7ea8ce8b6c"
dependencies = [
"proc-macro2",
"quote",
Expand All @@ -508,9 +508,9 @@ dependencies = [

[[package]]
name = "chalk-engine"
version = "0.36.0"
version = "0.55.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0e34c9b1b10616782143d7f49490f91ae94afaf2202de3ab0b2835e78b4f0ccc"
checksum = "05a171ce5abbf0fbd06f221ab80ab182c7ef78603d23b858bc44e7ce8a86a396"
dependencies = [
"chalk-derive",
"chalk-ir",
Expand All @@ -521,19 +521,20 @@ dependencies = [

[[package]]
name = "chalk-ir"
version = "0.36.0"
version = "0.55.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "63362c629c2014ab639b04029070763fb8224df136d1363d30e9ece4c8877da3"
checksum = "a522f53af971e7678f472d687e053120157b3ae26e2ebd5ecbc0f5ab124f2cb6"
dependencies = [
"bitflags",
"chalk-derive",
"lazy_static",
]

[[package]]
name = "chalk-solve"
version = "0.36.0"
version = "0.55.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cac338a67af52a7f50bb2f8232e730a3518ce432dbe303246acfe525ddd838c7"
checksum = "cdf79fb77a567e456a170f7ec84ea6584163d4ba3f13660cd182013d34ca667c"
dependencies = [
"chalk-derive",
"chalk-ir",
Expand Down Expand Up @@ -1783,9 +1784,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"

[[package]]
name = "libc"
version = "0.2.79"
version = "0.2.85"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2448f6066e80e3bfc792e9c98bf705b4b0fc6e8ef5b43e5889aff0eaa9c58743"
checksum = "7ccac4b00700875e6a07c6cde370d44d32fa01c5a65cdd2fca6858c479d28bb3"
dependencies = [
"rustc-std-workspace-core",
]
Expand Down Expand Up @@ -4313,6 +4314,7 @@ dependencies = [
"chalk-ir",
"chalk-solve",
"rustc_ast",
"rustc_attr",
"rustc_data_structures",
"rustc_hir",
"rustc_index",
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_builtin_macros/src/assert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ pub fn expand_assert<'cx>(

let panic_call = if let Some(tokens) = custom_message {
let path = if span.rust_2021() {
// On edition 2021, we always call `$crate::panic!()`.
// On edition 2021, we always call `$crate::panic::panic_2021!()`.
Path {
span: sp,
segments: cx
.std_path(&[sym::panic])
.std_path(&[sym::panic, sym::panic_2021])
.into_iter()
.map(|ident| PathSegment::from_ident(ident))
.collect(),
Expand Down
12 changes: 8 additions & 4 deletions compiler/rustc_codegen_llvm/src/va_arg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ fn emit_aapcs_va_arg(
let mut end = bx.build_sibling_block("va_arg.end");
let zero = bx.const_i32(0);
let offset_align = Align::from_bytes(4).unwrap();
assert_eq!(bx.tcx().sess.target.endian, Endian::Little);

let gr_type = target_ty.is_any_ptr() || target_ty.is_integral();
let (reg_off, reg_top_index, slot_size) = if gr_type {
Expand Down Expand Up @@ -144,9 +143,14 @@ fn emit_aapcs_va_arg(
let top = in_reg.load(top, bx.tcx().data_layout.pointer_align.abi);

// reg_value = *(@top + reg_off_v);
let top = in_reg.gep(top, &[reg_off_v]);
let top = in_reg.bitcast(top, bx.cx.type_ptr_to(layout.llvm_type(bx)));
let reg_value = in_reg.load(top, layout.align.abi);
let mut reg_addr = in_reg.gep(top, &[reg_off_v]);
if bx.tcx().sess.target.endian == Endian::Big && layout.size.bytes() != slot_size {
// On big-endian systems the value is right-aligned in its slot.
let offset = bx.const_i32((slot_size - layout.size.bytes()) as i32);
reg_addr = in_reg.gep(reg_addr, &[offset]);
}
let reg_addr = in_reg.bitcast(reg_addr, bx.cx.type_ptr_to(layout.llvm_type(bx)));
let reg_value = in_reg.load(reg_addr, layout.align.abi);
in_reg.br(&end.llbb());

// On Stack block
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 @@ -267,6 +267,7 @@ E0516: include_str!("./error_codes/E0516.md"),
E0517: include_str!("./error_codes/E0517.md"),
E0518: include_str!("./error_codes/E0518.md"),
E0520: include_str!("./error_codes/E0520.md"),
E0521: include_str!("./error_codes/E0521.md"),
E0522: include_str!("./error_codes/E0522.md"),
E0524: include_str!("./error_codes/E0524.md"),
E0525: include_str!("./error_codes/E0525.md"),
Expand Down Expand Up @@ -597,7 +598,6 @@ E0780: include_str!("./error_codes/E0780.md"),
E0514, // metadata version mismatch
E0519, // local crate and dependency have same (crate-name, disambiguator)
// two dependencies have same (crate-name, disambiguator) but different SVH
E0521, // borrowed data escapes outside of closure
E0523,
// E0526, // shuffle indices are not constant
// E0540, // multiple rustc_deprecated attributes
Expand Down
28 changes: 28 additions & 0 deletions compiler/rustc_error_codes/src/error_codes/E0521.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Borrowed data escapes outside of closure.

Erroneous code example:

```compile_fail,E0521
let mut list: Vec<&str> = Vec::new();
let _add = |el: &str| {
list.push(el); // error: `el` escapes the closure body here
};
```

A type anotation of a closure parameter implies a new lifetime declaration.
Consider to drop it, the compiler is reliably able to infer them.

```
let mut list: Vec<&str> = Vec::new();
let _add = |el| {
list.push(el);
};
```

See the [Closure type inference and annotation][closure-infere-annotation] and
[Lifetime elision][lifetime-elision] sections of the Book for more details.

[closure-infere-annotation]: https://doc.rust-lang.org/book/ch13-01-closures.html#closure-type-inference-and-annotation
[lifetime-elision]: https://doc.rust-lang.org/reference/lifetime-elision.html
12 changes: 4 additions & 8 deletions compiler/rustc_infer/src/infer/canonical/canonicalizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,10 +353,8 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for Canonicalizer<'cx, 'tcx> {
// `TyVar(vid)` is unresolved, track its universe index in the canonicalized
// result.
Err(mut ui) => {
if !self.infcx.unwrap().tcx.sess.opts.debugging_opts.chalk {
// FIXME: perf problem described in #55921.
ui = ty::UniverseIndex::ROOT;
}
// FIXME: perf problem described in #55921.
ui = ty::UniverseIndex::ROOT;
self.canonicalize_ty_var(
CanonicalVarInfo {
kind: CanonicalVarKind::Ty(CanonicalTyVarKind::General(ui)),
Expand Down Expand Up @@ -440,10 +438,8 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for Canonicalizer<'cx, 'tcx> {
// `ConstVar(vid)` is unresolved, track its universe index in the
// canonicalized result
Err(mut ui) => {
if !self.infcx.unwrap().tcx.sess.opts.debugging_opts.chalk {
// FIXME: perf problem described in #55921.
ui = ty::UniverseIndex::ROOT;
}
// FIXME: perf problem described in #55921.
ui = ty::UniverseIndex::ROOT;
return self.canonicalize_const_var(
CanonicalVarInfo { kind: CanonicalVarKind::Const(ui) },
ct,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_infer/src/infer/error_reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1855,7 +1855,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
diag.span_suggestion(
span,
&format!(
"you might have meant to use field `{}` of type `{}`",
"you might have meant to use field `{}` whose type is `{}`",
name, ty
),
suggestion,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ rustc_index = { path = "../rustc_index" }
rustc_serialize = { path = "../rustc_serialize" }
rustc_ast = { path = "../rustc_ast" }
rustc_span = { path = "../rustc_span" }
chalk-ir = "0.36.0"
chalk-ir = "0.55.0"
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
measureme = "9.0.0"
rustc_session = { path = "../rustc_session" }
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/mir/interpret/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ impl<'tcx> ConstValue<'tcx> {
}

/// A `Scalar` represents an immediate, primitive value existing outside of a
/// `memory::Allocation`. It is in many ways like a small chunk of a `Allocation`, up to 8 bytes in
/// `memory::Allocation`. It is in many ways like a small chunk of a `Allocation`, up to 16 bytes in
/// size. Like a range of bytes in an `Allocation`, a `Scalar` can either represent the raw bytes
/// of a simple value or a pointer into another `Allocation`
#[derive(Clone, Copy, Eq, PartialEq, Ord, PartialOrd, TyEncodable, TyDecodable, Hash)]
Expand Down
40 changes: 36 additions & 4 deletions compiler/rustc_middle/src/traits/chalk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ impl<'tcx> chalk_ir::interner::Interner for RustInterner<'tcx> {
type InternedQuantifiedWhereClauses = Vec<chalk_ir::QuantifiedWhereClause<Self>>;
type InternedVariableKinds = Vec<chalk_ir::VariableKind<Self>>;
type InternedCanonicalVarKinds = Vec<chalk_ir::CanonicalVarKind<Self>>;
type InternedVariances = Vec<chalk_ir::Variance>;
type InternedConstraints = Vec<chalk_ir::InEnvironment<chalk_ir::Constraint<Self>>>;
type DefId = DefId;
type InternedAdtId = &'tcx AdtDef;
Expand All @@ -86,17 +87,34 @@ impl<'tcx> chalk_ir::interner::Interner for RustInterner<'tcx> {
write!(fmt, "{:?}", pci.consequence)?;

let conditions = pci.conditions.interned();
let constraints = pci.constraints.interned();

let conds = conditions.len();
if conds == 0 {
let consts = constraints.len();
if conds == 0 && consts == 0 {
return Ok(());
}

write!(fmt, " :- ")?;
for cond in &conditions[..conds - 1] {
write!(fmt, "{:?}, ", cond)?;

if conds != 0 {
for cond in &conditions[..conds - 1] {
write!(fmt, "{:?}, ", cond)?;
}
write!(fmt, "{:?}", conditions[conds - 1])?;
}

if conds != 0 && consts != 0 {
write!(fmt, " ; ")?;
}
write!(fmt, "{:?}", conditions[conds - 1])?;

if consts != 0 {
for constraint in &constraints[..consts - 1] {
write!(fmt, "{:?}, ", constraint)?;
}
write!(fmt, "{:?}", constraints[consts - 1])?;
}

Ok(())
};
Some(write())
Expand Down Expand Up @@ -351,6 +369,20 @@ impl<'tcx> chalk_ir::interner::Interner for RustInterner<'tcx> {
) -> &'a [chalk_ir::InEnvironment<chalk_ir::Constraint<Self>>] {
constraints
}

fn intern_variances<E>(
&self,
data: impl IntoIterator<Item = Result<chalk_ir::Variance, E>>,
) -> Result<Self::InternedVariances, E> {
data.into_iter().collect::<Result<Vec<_>, _>>()
}

fn variances_data<'a>(
&self,
variances: &'a Self::InternedVariances,
) -> &'a [chalk_ir::Variance] {
variances
}
}

impl<'tcx> chalk_ir::interner::HasInterner for RustInterner<'tcx> {
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_resolve/src/late/lifetimes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2415,7 +2415,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
_ => break,
}
}
break Some(e);
break Some(&e[..]);
}
Elide::Forbid => break None,
};
Expand Down Expand Up @@ -2445,7 +2445,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
lifetime_refs.len(),
&lifetime_names,
lifetime_spans,
error.map(|p| &p[..]).unwrap_or(&[]),
error.unwrap_or(&[]),
);
err.emit();
}
Expand Down
24 changes: 2 additions & 22 deletions compiler/rustc_target/src/abi/call/aarch64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,7 @@ where
let size = ret.layout.size;
let bits = size.bits();
if bits <= 128 {
let unit = if bits <= 8 {
Reg::i8()
} else if bits <= 16 {
Reg::i16()
} else if bits <= 32 {
Reg::i32()
} else {
Reg::i64()
};

ret.cast_to(Uniform { unit, total: size });
ret.cast_to(Uniform { unit: Reg::i64(), total: size });
return;
}
ret.make_indirect();
Expand All @@ -72,17 +62,7 @@ where
let size = arg.layout.size;
let bits = size.bits();
if bits <= 128 {
let unit = if bits <= 8 {
Reg::i8()
} else if bits <= 16 {
Reg::i16()
} else if bits <= 32 {
Reg::i32()
} else {
Reg::i64()
};

arg.cast_to(Uniform { unit, total: size });
arg.cast_to(Uniform { unit: Reg::i64(), total: size });
return;
}
arg.make_indirect();
Expand Down
9 changes: 1 addition & 8 deletions compiler/rustc_target/src/abi/call/arm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,7 @@ where
let size = ret.layout.size;
let bits = size.bits();
if bits <= 32 {
let unit = if bits <= 8 {
Reg::i8()
} else if bits <= 16 {
Reg::i16()
} else {
Reg::i32()
};
ret.cast_to(Uniform { unit, total: size });
ret.cast_to(Uniform { unit: Reg::i32(), total: size });
return;
}
ret.make_indirect();
Expand Down
20 changes: 20 additions & 0 deletions compiler/rustc_target/src/spec/aarch64_be_unknown_linux_gnu.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
use crate::abi::Endian;
use crate::spec::{Target, TargetOptions};

pub fn target() -> Target {
let mut base = super::linux_gnu_base::opts();
base.max_atomic_width = Some(128);

Target {
llvm_target: "aarch64_be-unknown-linux-gnu".to_string(),
pointer_width: 64,
data_layout: "E-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".to_string(),
arch: "aarch64".to_string(),
options: TargetOptions {
unsupported_abis: super::arm_base::unsupported_abis(),
mcount: "\u{1}_mcount".to_string(),
endian: Endian::Big,
..base
},
}
}

0 comments on commit d95d4f0

Please sign in to comment.