Skip to content

Commit a457433

Browse files
committed
Auto merge of #63234 - Centril:rollup-h9t731z, r=Centril
Rollup of 5 pull requests Successful merges: - #62954 (Fix typo in Delimited::open_tt) - #63146 (Cleanup syntax::attr) - #63218 (rustbuild: RISC-V is no longer an experimental LLVM target) - #63227 (dead_code: Properly inspect fields in struct patterns with type relative paths) - #63229 (A bit of Miri error cleanup) Failed merges: r? @ghost
2 parents 8e917f4 + 42dfdc5 commit a457433

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+360
-671
lines changed

config.toml.example

+3-4
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,13 @@
5757
# support. You'll need to write a target specification at least, and most
5858
# likely, teach rustc about the C ABI of the target. Get in touch with the
5959
# Rust team and file an issue if you need assistance in porting!
60-
#targets = "X86;ARM;AArch64;Mips;PowerPC;SystemZ;MSP430;Sparc;NVPTX;Hexagon"
60+
#targets = "AArch64;ARM;Hexagon;MSP430;Mips;NVPTX;PowerPC;RISCV;Sparc;SystemZ;WebAssembly;X86"
6161

6262
# LLVM experimental targets to build support for. These targets are specified in
6363
# the same format as above, but since these targets are experimental, they are
6464
# not built by default and the experimental Rust compilation targets that depend
65-
# on them will not work unless the user opts in to building them. By default the
66-
# `WebAssembly` and `RISCV` targets are enabled when compiling LLVM from scratch.
67-
#experimental-targets = "WebAssembly;RISCV"
65+
# on them will not work unless the user opts in to building them.
66+
#experimental-targets = ""
6867

6968
# Cap the number of parallel linker invocations when compiling LLVM.
7069
# This can be useful when building LLVM with debug info, which significantly

src/bootstrap/config.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ pub struct Config {
7575
pub llvm_link_shared: bool,
7676
pub llvm_clang_cl: Option<String>,
7777
pub llvm_targets: Option<String>,
78-
pub llvm_experimental_targets: String,
78+
pub llvm_experimental_targets: Option<String>,
7979
pub llvm_link_jobs: Option<u32>,
8080
pub llvm_version_suffix: Option<String>,
8181
pub llvm_use_linker: Option<String>,
@@ -524,8 +524,7 @@ impl Config {
524524
set(&mut config.llvm_static_stdcpp, llvm.static_libstdcpp);
525525
set(&mut config.llvm_link_shared, llvm.link_shared);
526526
config.llvm_targets = llvm.targets.clone();
527-
config.llvm_experimental_targets = llvm.experimental_targets.clone()
528-
.unwrap_or_else(|| "WebAssembly;RISCV".to_string());
527+
config.llvm_experimental_targets = llvm.experimental_targets.clone();
529528
config.llvm_link_jobs = llvm.link_jobs;
530529
config.llvm_version_suffix = llvm.version_suffix.clone();
531530
config.llvm_clang_cl = llvm.clang_cl.clone();

src/bootstrap/native.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -125,14 +125,18 @@ impl Step for Llvm {
125125
} else {
126126
match builder.config.llvm_targets {
127127
Some(ref s) => s,
128-
None => "X86;ARM;AArch64;Mips;PowerPC;SystemZ;MSP430;Sparc;NVPTX;Hexagon",
128+
None => "AArch64;ARM;Hexagon;MSP430;Mips;NVPTX;PowerPC;RISCV;\
129+
Sparc;SystemZ;WebAssembly;X86",
129130
}
130131
};
131132

132133
let llvm_exp_targets = if self.emscripten {
133134
""
134135
} else {
135-
&builder.config.llvm_experimental_targets[..]
136+
match builder.config.llvm_experimental_targets {
137+
Some(ref s) => s,
138+
None => "",
139+
}
136140
};
137141

138142
let assertions = if builder.config.llvm_assertions {"ON"} else {"OFF"};

src/doc/unstable-book/src/language-features/plugin.md

-8
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ extern crate rustc_plugin;
5959
use syntax::parse::token::{self, Token};
6060
use syntax::tokenstream::TokenTree;
6161
use syntax::ext::base::{ExtCtxt, MacResult, DummyResult, MacEager};
62-
use syntax::ext::build::AstBuilder; // A trait for expr_usize.
6362
use syntax_pos::Span;
6463
use rustc_plugin::Registry;
6564
@@ -164,13 +163,6 @@ can continue and find further errors.
164163
To print syntax fragments for debugging, you can use `span_note` together with
165164
`syntax::print::pprust::*_to_string`.
166165

167-
The example above produced an integer literal using `AstBuilder::expr_usize`.
168-
As an alternative to the `AstBuilder` trait, `libsyntax` provides a set of
169-
quasiquote macros. They are undocumented and very rough around the edges.
170-
However, the implementation may be a good starting point for an improved
171-
quasiquote as an ordinary plugin library.
172-
173-
174166
# Lint plugins
175167

176168
Plugins can extend [Rust's lint

src/librustc/hir/lowering.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5168,7 +5168,7 @@ impl<'a> LoweringContext<'a> {
51685168
let uc_nested = attr::mk_nested_word_item(uc_ident);
51695169
attr::mk_list_item(e.span, allow_ident, vec![uc_nested])
51705170
};
5171-
attr::mk_spanned_attr_outer(e.span, attr::mk_attr_id(), allow)
5171+
attr::mk_attr_outer(allow)
51725172
};
51735173
let attrs = vec![attr];
51745174

src/librustc/middle/dead.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,9 @@ impl<'a, 'tcx> Visitor<'tcx> for MarkSymbolVisitor<'a, 'tcx> {
269269

270270
fn visit_pat(&mut self, pat: &'tcx hir::Pat) {
271271
match pat.node {
272-
PatKind::Struct(hir::QPath::Resolved(_, ref path), ref fields, _) => {
273-
self.handle_field_pattern_match(pat, path.res, fields);
272+
PatKind::Struct(ref path, ref fields, _) => {
273+
let res = self.tables.qpath_res(path, pat.hir_id);
274+
self.handle_field_pattern_match(pat, res, fields);
274275
}
275276
PatKind::Path(ref qpath @ hir::QPath::TypeRelative(..)) => {
276277
let res = self.tables.qpath_res(qpath, pat.hir_id);

src/librustc/mir/interpret/error.rs

+7-18
Original file line numberDiff line numberDiff line change
@@ -341,16 +341,16 @@ impl fmt::Debug for InvalidProgramInfo<'tcx> {
341341
}
342342

343343
#[derive(Clone, RustcEncodable, RustcDecodable, HashStable)]
344-
pub enum UndefinedBehaviourInfo {
344+
pub enum UndefinedBehaviorInfo {
345345
/// Handle cases which for which we do not have a fixed variant.
346346
Ub(String),
347347
/// Unreachable code was executed.
348348
Unreachable,
349349
}
350350

351-
impl fmt::Debug for UndefinedBehaviourInfo {
351+
impl fmt::Debug for UndefinedBehaviorInfo {
352352
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
353-
use UndefinedBehaviourInfo::*;
353+
use UndefinedBehaviorInfo::*;
354354
match self {
355355
Ub(ref msg) =>
356356
write!(f, "{}", msg),
@@ -363,7 +363,7 @@ impl fmt::Debug for UndefinedBehaviourInfo {
363363
#[derive(Clone, RustcEncodable, RustcDecodable, HashStable)]
364364
pub enum UnsupportedOpInfo<'tcx> {
365365
/// Handle cases which for which we do not have a fixed variant.
366-
Unimplemented(String),
366+
Unsupported(String),
367367

368368
// -- Everything below is not classified yet --
369369
FunctionAbiMismatch(Abi, Abi),
@@ -390,20 +390,14 @@ pub enum UnsupportedOpInfo<'tcx> {
390390
ReadUndefBytes(Size),
391391
DeadLocal,
392392
InvalidBoolOp(mir::BinOp),
393-
InlineAsm,
394393
UnimplementedTraitSelection,
395394
CalledClosureAsFunction,
396395
NoMirFor(String),
397-
/// This variant is used by machines to signal their own errors that do not
398-
/// match an existing variant.
399-
MachineError(String),
400396
DerefFunctionPointer,
401397
ExecuteMemory,
402-
Intrinsic(String),
403398
InvalidChar(u128),
404399
OutOfTls,
405400
TlsOutOfBounds,
406-
AbiViolation(String),
407401
AlignmentCheckFailed {
408402
required: Align,
409403
has: Align,
@@ -513,8 +507,6 @@ impl fmt::Debug for UnsupportedOpInfo<'tcx> {
513507
initializer"),
514508
AssumptionNotHeld =>
515509
write!(f, "`assume` argument was false"),
516-
InlineAsm =>
517-
write!(f, "miri does not support inline assembly"),
518510
ReallocateNonBasePtr =>
519511
write!(f, "tried to reallocate with a pointer not to the beginning of an \
520512
existing object"),
@@ -537,10 +529,7 @@ impl fmt::Debug for UnsupportedOpInfo<'tcx> {
537529
HeapAllocNonPowerOfTwoAlignment(_) =>
538530
write!(f, "tried to re-, de-, or allocate heap memory with alignment that is \
539531
not a power of two"),
540-
MachineError(ref msg) |
541-
Unimplemented(ref msg) |
542-
AbiViolation(ref msg) |
543-
Intrinsic(ref msg) =>
532+
Unsupported(ref msg) =>
544533
write!(f, "{}", msg),
545534
}
546535
}
@@ -572,7 +561,7 @@ pub enum InterpError<'tcx> {
572561
/// The program panicked.
573562
Panic(PanicInfo<u64>),
574563
/// The program caused undefined behavior.
575-
UndefinedBehaviour(UndefinedBehaviourInfo),
564+
UndefinedBehavior(UndefinedBehaviorInfo),
576565
/// The program did something the interpreter does not support (some of these *might* be UB
577566
/// but the interpreter is not sure).
578567
Unsupported(UnsupportedOpInfo<'tcx>),
@@ -603,7 +592,7 @@ impl fmt::Debug for InterpError<'_> {
603592
write!(f, "{:?}", msg),
604593
InvalidProgram(ref msg) =>
605594
write!(f, "{:?}", msg),
606-
UndefinedBehaviour(ref msg) =>
595+
UndefinedBehavior(ref msg) =>
607596
write!(f, "{:?}", msg),
608597
ResourceExhaustion(ref msg) =>
609598
write!(f, "{:?}", msg),

src/librustc/mir/interpret/mod.rs

+13-3
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ macro_rules! err_inval {
2121
#[macro_export]
2222
macro_rules! err_ub {
2323
($($tt:tt)*) => {
24-
$crate::mir::interpret::InterpError::UndefinedBehaviour(
25-
$crate::mir::interpret::UndefinedBehaviourInfo::$($tt)*
24+
$crate::mir::interpret::InterpError::UndefinedBehavior(
25+
$crate::mir::interpret::UndefinedBehaviorInfo::$($tt)*
2626
)
2727
};
2828
}
@@ -50,6 +50,11 @@ macro_rules! throw_unsup {
5050
($($tt:tt)*) => { return Err(err_unsup!($($tt)*).into()) };
5151
}
5252

53+
#[macro_export]
54+
macro_rules! throw_unsup_format {
55+
($($tt:tt)*) => { throw_unsup!(Unsupported(format!($($tt)*))) };
56+
}
57+
5358
#[macro_export]
5459
macro_rules! throw_inval {
5560
($($tt:tt)*) => { return Err(err_inval!($($tt)*).into()) };
@@ -60,6 +65,11 @@ macro_rules! throw_ub {
6065
($($tt:tt)*) => { return Err(err_ub!($($tt)*).into()) };
6166
}
6267

68+
#[macro_export]
69+
macro_rules! throw_ub_format {
70+
($($tt:tt)*) => { throw_ub!(Ub(format!($($tt)*))) };
71+
}
72+
6373
#[macro_export]
6474
macro_rules! throw_panic {
6575
($($tt:tt)*) => { return Err(err_panic!($($tt)*).into()) };
@@ -78,7 +88,7 @@ mod pointer;
7888
pub use self::error::{
7989
InterpErrorInfo, InterpResult, InterpError, AssertMessage, ConstEvalErr, struct_error,
8090
FrameInfo, ConstEvalRawResult, ConstEvalResult, ErrorHandled, PanicInfo, UnsupportedOpInfo,
81-
InvalidProgramInfo, ResourceExhaustionInfo, UndefinedBehaviourInfo,
91+
InvalidProgramInfo, ResourceExhaustionInfo, UndefinedBehaviorInfo,
8292
};
8393

8494
pub use self::value::{Scalar, ScalarMaybeUndef, RawConst, ConstValue};

src/librustc_metadata/decoder.rs

+1-8
Original file line numberDiff line numberDiff line change
@@ -980,14 +980,7 @@ impl<'a, 'tcx> CrateMetadata {
980980
}
981981

982982
fn get_attributes(&self, item: &Entry<'tcx>, sess: &Session) -> Vec<ast::Attribute> {
983-
item.attributes
984-
.decode((self, sess))
985-
.map(|mut attr| {
986-
// Need new unique IDs: old thread-local IDs won't map to new threads.
987-
attr.id = attr::mk_attr_id();
988-
attr
989-
})
990-
.collect()
983+
item.attributes.decode((self, sess)).collect()
991984
}
992985

993986
// Translate a DefId from the current compilation environment to a DefId

src/librustc_mir/const_eval.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -181,17 +181,17 @@ fn eval_body_using_ecx<'mir, 'tcx>(
181181
Ok(ret)
182182
}
183183

184-
impl<'tcx> Into<InterpErrorInfo<'tcx>> for ConstEvalError {
185-
fn into(self) -> InterpErrorInfo<'tcx> {
186-
err_unsup!(MachineError(self.to_string())).into()
187-
}
188-
}
189-
190184
#[derive(Clone, Debug)]
191185
enum ConstEvalError {
192186
NeedsRfc(String),
193187
}
194188

189+
impl<'tcx> Into<InterpErrorInfo<'tcx>> for ConstEvalError {
190+
fn into(self) -> InterpErrorInfo<'tcx> {
191+
err_unsup!(Unsupported(self.to_string())).into()
192+
}
193+
}
194+
195195
impl fmt::Display for ConstEvalError {
196196
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
197197
use self::ConstEvalError::*;
@@ -341,7 +341,7 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir,
341341
debug!("eval_fn_call: {:?}", instance);
342342
// Only check non-glue functions
343343
if let ty::InstanceDef::Item(def_id) = instance.def {
344-
// Execution might have wandered off into other crates, so we cannot to a stability-
344+
// Execution might have wandered off into other crates, so we cannot do a stability-
345345
// sensitive check here. But we can at least rule out functions that are not const
346346
// at all.
347347
if !ecx.tcx.is_const_fn_raw(def_id) {
@@ -352,7 +352,7 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir,
352352
ecx.goto_block(ret)?; // fully evaluated and done
353353
Ok(None)
354354
} else {
355-
throw_unsup!(MachineError(format!("calling non-const function `{}`", instance)))
355+
throw_unsup_format!("calling non-const function `{}`", instance)
356356
};
357357
}
358358
}

src/librustc_mir/interpret/cast.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
198198
},
199199

200200
// Casts to bool are not permitted by rustc, no need to handle them here.
201-
_ => throw_unsup!(Unimplemented(format!("int to {:?} cast", dest_layout.ty))),
201+
_ => bug!("invalid int to {:?} cast", dest_layout.ty),
202202
}
203203
}
204204

src/librustc_mir/interpret/intrinsics.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,11 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
9898
let bits = self.read_scalar(args[0])?.to_bits(layout_of.size)?;
9999
let kind = match layout_of.abi {
100100
ty::layout::Abi::Scalar(ref scalar) => scalar.value,
101-
_ => Err(err_unsup!(TypeNotPrimitive(ty)))?,
101+
_ => throw_unsup!(TypeNotPrimitive(ty)),
102102
};
103103
let out_val = if intrinsic_name.ends_with("_nonzero") {
104104
if bits == 0 {
105-
throw_unsup!(Intrinsic(format!("{} called on 0", intrinsic_name)))
105+
throw_ub_format!("`{}` called on 0", intrinsic_name);
106106
}
107107
numeric_intrinsic(intrinsic_name.trim_end_matches("_nonzero"), bits, kind)?
108108
} else {
@@ -187,10 +187,8 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
187187
let (val, overflowed) = self.binary_op(bin_op, l, r)?;
188188
if overflowed {
189189
let layout = self.layout_of(substs.type_at(0))?;
190-
let r_val = r.to_scalar()?.to_bits(layout.size)?;
191-
throw_unsup!(
192-
Intrinsic(format!("Overflowing shift by {} in {}", r_val, intrinsic_name))
193-
)
190+
let r_val = r.to_scalar()?.to_bits(layout.size)?;
191+
throw_ub_format!("Overflowing shift by {} in `{}`", r_val, intrinsic_name);
194192
}
195193
self.write_scalar(val, dest)?;
196194
}

src/librustc_mir/interpret/memory.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ impl<'tcx, Other> FnVal<'tcx, Other> {
6666
match self {
6767
FnVal::Instance(instance) =>
6868
Ok(instance),
69-
FnVal::Other(_) => throw_unsup!(MachineError(format!(
70-
"Expected instance function pointer, got 'other' pointer"
71-
))),
69+
FnVal::Other(_) => throw_unsup_format!(
70+
"'foreign' function pointers are not supported in this context"
71+
),
7272
}
7373
}
7474
}
@@ -834,9 +834,9 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
834834
if (src.offset <= dest.offset && src.offset + size > dest.offset) ||
835835
(dest.offset <= src.offset && dest.offset + size > src.offset)
836836
{
837-
throw_unsup!(Intrinsic(
838-
"copy_nonoverlapping called on overlapping ranges".to_string(),
839-
))
837+
throw_ub_format!(
838+
"copy_nonoverlapping called on overlapping ranges"
839+
)
840840
}
841841
}
842842

src/librustc_mir/interpret/operator.rs

+8-12
Original file line numberDiff line numberDiff line change
@@ -147,15 +147,12 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
147147

148148
// For the remaining ops, the types must be the same on both sides
149149
if left_layout.ty != right_layout.ty {
150-
let msg = format!(
151-
"unimplemented asymmetric binary op {:?}: {:?} ({:?}), {:?} ({:?})",
150+
bug!(
151+
"invalid asymmetric binary op {:?}: {:?} ({:?}), {:?} ({:?})",
152152
bin_op,
153-
l,
154-
left_layout.ty,
155-
r,
156-
right_layout.ty
157-
);
158-
throw_unsup!(Unimplemented(msg))
153+
l, left_layout.ty,
154+
r, right_layout.ty,
155+
)
159156
}
160157

161158
// Operations that need special treatment for signed integers
@@ -243,14 +240,13 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
243240
}
244241

245242
_ => {
246-
let msg = format!(
247-
"unimplemented binary op {:?}: {:?}, {:?} (both {:?})",
243+
bug!(
244+
"invalid binary op {:?}: {:?}, {:?} (both {:?})",
248245
bin_op,
249246
l,
250247
r,
251248
right_layout.ty,
252-
);
253-
throw_unsup!(Unimplemented(msg))
249+
)
254250
}
255251
};
256252

0 commit comments

Comments
 (0)