mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-01 15:01:51 +00:00
Auto merge of #108732 - Dylan-DPC:rollup-dy1l8sx, r=Dylan-DPC
Rollup of 6 pull requests Successful merges: - #108298 (Fix ICE: check if snippet is `)`) - #108405 (Lazily compute crate name for consider_optimizing) - #108656 (Rustdoc search: Emit an error for unclosed generic) - #108660 (Remove ne implementations from strings) - #108669 (Allow checking whether a type allows being uninitialized) - #108727 (rustc_expand: make proc-macro derive error translatable) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
276b75a843
@ -444,6 +444,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||
"aborted execution: attempted to leave type `{}` uninitialized, which is invalid",
|
||||
ty
|
||||
),
|
||||
ValidityRequirement::Uninit => bug!("assert_uninit_valid doesn't exist"),
|
||||
};
|
||||
|
||||
M::abort(self, msg)?;
|
||||
|
@ -30,7 +30,7 @@ pub fn check_validity_requirement<'tcx>(
|
||||
return Ok(!layout.abi.is_uninhabited());
|
||||
}
|
||||
|
||||
if tcx.sess.opts.unstable_opts.strict_init_checks {
|
||||
if kind == ValidityRequirement::Uninit || tcx.sess.opts.unstable_opts.strict_init_checks {
|
||||
might_permit_raw_init_strict(layout, tcx, kind)
|
||||
} else {
|
||||
let layout_cx = LayoutCx { tcx, param_env: param_env_and_ty.param_env };
|
||||
@ -99,6 +99,9 @@ fn might_permit_raw_init_lax<'tcx>(
|
||||
}
|
||||
s.valid_range(cx).contains(val)
|
||||
}
|
||||
ValidityRequirement::Uninit => {
|
||||
bug!("ValidityRequirement::Uninit should have been handled above")
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -133,3 +133,6 @@ expand_trace_macro = trace_macro
|
||||
expand_proc_macro_panicked =
|
||||
proc macro panicked
|
||||
.help = message: {$message}
|
||||
|
||||
expand_proc_macro_derive_tokens =
|
||||
proc-macro derive produced unparseable tokens
|
||||
|
@ -390,3 +390,10 @@ pub(crate) struct ProcMacroPanicked {
|
||||
pub(crate) struct ProcMacroPanickedHelp {
|
||||
pub message: String,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(expand_proc_macro_derive_tokens)]
|
||||
pub struct ProcMacroDeriveTokens {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
}
|
||||
|
@ -176,7 +176,7 @@ impl MultiItemModifier for DeriveProcMacro {
|
||||
|
||||
// fail if there have been errors emitted
|
||||
if ecx.sess.parse_sess.span_diagnostic.err_count() > error_count_before {
|
||||
ecx.struct_span_err(span, "proc-macro derive produced unparseable tokens").emit();
|
||||
ecx.sess.emit_err(errors::ProcMacroDeriveTokens { span });
|
||||
}
|
||||
|
||||
ExpandResult::Ready(items)
|
||||
|
@ -794,8 +794,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
}
|
||||
|
||||
pub fn consider_optimizing<T: Fn() -> String>(self, msg: T) -> bool {
|
||||
let cname = self.crate_name(LOCAL_CRATE);
|
||||
self.sess.consider_optimizing(cname.as_str(), msg)
|
||||
self.sess.consider_optimizing(|| self.crate_name(LOCAL_CRATE), msg)
|
||||
}
|
||||
|
||||
/// Obtain all lang items of this crate and all dependencies (recursively)
|
||||
|
@ -170,13 +170,17 @@ pub const FAT_PTR_EXTRA: usize = 1;
|
||||
/// * Cranelift stores the base-2 log of the lane count in a 4 bit integer.
|
||||
pub const MAX_SIMD_LANES: u64 = 1 << 0xF;
|
||||
|
||||
/// Used in `might_permit_raw_init` to indicate the kind of initialisation
|
||||
/// Used in `check_validity_requirement` to indicate the kind of initialization
|
||||
/// that is checked to be valid
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, HashStable)]
|
||||
pub enum ValidityRequirement {
|
||||
Inhabited,
|
||||
Zero,
|
||||
/// The return value of mem::uninitialized, 0x01
|
||||
/// (unless -Zstrict-init-checks is on, in which case it's the same as Uninit).
|
||||
UninitMitigated0x01Fill,
|
||||
/// True uninitialized memory.
|
||||
Uninit,
|
||||
}
|
||||
|
||||
impl ValidityRequirement {
|
||||
@ -196,6 +200,7 @@ impl fmt::Display for ValidityRequirement {
|
||||
Self::Inhabited => f.write_str("is inhabited"),
|
||||
Self::Zero => f.write_str("allows being left zeroed"),
|
||||
Self::UninitMitigated0x01Fill => f.write_str("allows being filled with 0x01"),
|
||||
Self::Uninit => f.write_str("allows being left uninitialized"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1210,8 +1210,13 @@ impl<'a> Parser<'a> {
|
||||
// `Enum::Foo { a: 3, b: 4 }` or `Enum::Foo(3, 4)`.
|
||||
self.restore_snapshot(snapshot);
|
||||
let close_paren = self.prev_token.span;
|
||||
let span = lo.to(self.prev_token.span);
|
||||
if !fields.is_empty() {
|
||||
let span = lo.to(close_paren);
|
||||
if !fields.is_empty() &&
|
||||
// `token.kind` should not be compared here.
|
||||
// This is because the `snapshot.token.kind` is treated as the same as
|
||||
// that of the open delim in `TokenTreesReader::parse_token_tree`, even if they are different.
|
||||
self.span_to_snippet(close_paren).map_or(false, |snippet| snippet == ")")
|
||||
{
|
||||
let mut replacement_err = errors::ParenthesesWithStructFields {
|
||||
span,
|
||||
r#type: path,
|
||||
|
@ -882,10 +882,14 @@ impl Session {
|
||||
|
||||
/// We want to know if we're allowed to do an optimization for crate foo from -z fuel=foo=n.
|
||||
/// This expends fuel if applicable, and records fuel if applicable.
|
||||
pub fn consider_optimizing<T: Fn() -> String>(&self, crate_name: &str, msg: T) -> bool {
|
||||
pub fn consider_optimizing(
|
||||
&self,
|
||||
get_crate_name: impl Fn() -> Symbol,
|
||||
msg: impl Fn() -> String,
|
||||
) -> bool {
|
||||
let mut ret = true;
|
||||
if let Some((ref c, _)) = self.opts.unstable_opts.fuel {
|
||||
if c == crate_name {
|
||||
if c == get_crate_name().as_str() {
|
||||
assert_eq!(self.threads(), 1);
|
||||
let mut fuel = self.optimization_fuel.lock();
|
||||
ret = fuel.remaining != 0;
|
||||
@ -903,7 +907,7 @@ impl Session {
|
||||
}
|
||||
}
|
||||
if let Some(ref c) = self.opts.unstable_opts.print_fuel {
|
||||
if c == crate_name {
|
||||
if c == get_crate_name().as_str() {
|
||||
assert_eq!(self.threads(), 1);
|
||||
self.print_fuel.fetch_add(1, SeqCst);
|
||||
}
|
||||
|
@ -2213,10 +2213,6 @@ impl PartialEq for String {
|
||||
fn eq(&self, other: &String) -> bool {
|
||||
PartialEq::eq(&self[..], &other[..])
|
||||
}
|
||||
#[inline]
|
||||
fn ne(&self, other: &String) -> bool {
|
||||
PartialEq::ne(&self[..], &other[..])
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! impl_eq {
|
||||
|
@ -28,10 +28,6 @@ impl PartialEq for str {
|
||||
fn eq(&self, other: &str) -> bool {
|
||||
self.as_bytes() == other.as_bytes()
|
||||
}
|
||||
#[inline]
|
||||
fn ne(&self, other: &str) -> bool {
|
||||
!(*self).eq(other)
|
||||
}
|
||||
}
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
|
@ -469,6 +469,15 @@ function initSearch(rawSearchIndex) {
|
||||
}
|
||||
const posBefore = parserState.pos;
|
||||
getNextElem(query, parserState, elems, endChar === ">");
|
||||
if (endChar !== "") {
|
||||
if (parserState.pos >= parserState.length) {
|
||||
throw ["Unclosed ", "<"];
|
||||
}
|
||||
const c2 = parserState.userQuery[parserState.pos];
|
||||
if (!isSeparatorCharacter(c2) && c2 !== endChar) {
|
||||
throw ["Expected ", endChar, ", found ", c2];
|
||||
}
|
||||
}
|
||||
// This case can be encountered if `getNextElem` encountered a "stop character" right
|
||||
// from the start. For example if you have `,,` or `<>`. In this case, we simply move up
|
||||
// the current position to continue the parsing.
|
||||
@ -477,7 +486,10 @@ function initSearch(rawSearchIndex) {
|
||||
}
|
||||
foundStopChar = false;
|
||||
}
|
||||
// We are either at the end of the string or on the `endChar`` character, let's move forward
|
||||
if (parserState.pos >= parserState.length && endChar !== "") {
|
||||
throw ["Unclosed ", "<"];
|
||||
}
|
||||
// We are either at the end of the string or on the `endChar` character, let's move forward
|
||||
// in any case.
|
||||
parserState.pos += 1;
|
||||
}
|
||||
|
@ -39,6 +39,7 @@ const QUERY = [
|
||||
"a!!",
|
||||
"mod:a!",
|
||||
"a!::a",
|
||||
"a<",
|
||||
];
|
||||
|
||||
const PARSED = [
|
||||
@ -402,4 +403,13 @@ const PARSED = [
|
||||
userQuery: "a!::a",
|
||||
error: 'Cannot have associated items in macros',
|
||||
},
|
||||
{
|
||||
elems: [],
|
||||
foundElems: 0,
|
||||
original: "a<",
|
||||
returned: [],
|
||||
typeFilter: -1,
|
||||
userQuery: "a<",
|
||||
error: "Unclosed `<`",
|
||||
},
|
||||
];
|
||||
|
3
tests/ui/parser/issue-107705.rs
Normal file
3
tests/ui/parser/issue-107705.rs
Normal file
@ -0,0 +1,3 @@
|
||||
// compile-flags: -C debug-assertions
|
||||
|
||||
fn f() {a(b:&, //~ ERROR this file contains an unclosed delimiter
|
10
tests/ui/parser/issue-107705.stderr
Normal file
10
tests/ui/parser/issue-107705.stderr
Normal file
@ -0,0 +1,10 @@
|
||||
error: this file contains an unclosed delimiter
|
||||
--> $DIR/issue-107705.rs:3:67
|
||||
|
|
||||
LL | fn f() {a(b:&,
|
||||
| - - unclosed delimiter ^
|
||||
| |
|
||||
| unclosed delimiter
|
||||
|
||||
error: aborting due to previous error
|
||||
|
Loading…
Reference in New Issue
Block a user