mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-06 04:08:40 +00:00
Auto merge of #64230 - Centril:rollup-vxyczjq, r=Centril
Rollup of 8 pull requests Successful merges: - #63565 (Rust 2018: NLL migrate mode => hard error) - #63969 (Add missing examples for Option type) - #64067 (Remove no-prefer-dynamic from valgrind tests) - #64166 (Better way of conditioning the sanitizer builds) - #64189 (annotate-snippet emitter: Deal with multispans from macros, too) - #64202 (Fixed grammar/style in some error messages) - #64206 (annotate-snippet emitter: Update an issue number) - #64208 (it's more pythonic to use 'is not None' in python files) Failed merges: r? @ghost
This commit is contained in:
commit
6e19f3f383
@ -668,7 +668,7 @@ class RustBuild(object):
|
|||||||
def update_submodule(self, module, checked_out, recorded_submodules):
|
def update_submodule(self, module, checked_out, recorded_submodules):
|
||||||
module_path = os.path.join(self.rust_root, module)
|
module_path = os.path.join(self.rust_root, module)
|
||||||
|
|
||||||
if checked_out != None:
|
if checked_out is not None:
|
||||||
default_encoding = sys.getdefaultencoding()
|
default_encoding = sys.getdefaultencoding()
|
||||||
checked_out = checked_out.communicate()[0].decode(default_encoding).strip()
|
checked_out = checked_out.communicate()[0].decode(default_encoding).strip()
|
||||||
if recorded_submodules[module] == checked_out:
|
if recorded_submodules[module] == checked_out:
|
||||||
|
@ -212,6 +212,7 @@ pub fn std_cargo(builder: &Builder<'_>,
|
|||||||
emscripten: false,
|
emscripten: false,
|
||||||
});
|
});
|
||||||
cargo.env("LLVM_CONFIG", llvm_config);
|
cargo.env("LLVM_CONFIG", llvm_config);
|
||||||
|
cargo.env("RUSTC_BUILD_SANITIZERS", "1");
|
||||||
}
|
}
|
||||||
|
|
||||||
cargo.arg("--features").arg(features)
|
cargo.arg("--features").arg(features)
|
||||||
|
@ -1110,6 +1110,18 @@ impl<T: Deref> Option<T> {
|
|||||||
/// to the original one, additionally coercing the contents via [`Deref`].
|
/// to the original one, additionally coercing the contents via [`Deref`].
|
||||||
///
|
///
|
||||||
/// [`Deref`]: ../../std/ops/trait.Deref.html
|
/// [`Deref`]: ../../std/ops/trait.Deref.html
|
||||||
|
///
|
||||||
|
/// # Examples
|
||||||
|
///
|
||||||
|
/// ```
|
||||||
|
/// #![feature(inner_deref)]
|
||||||
|
///
|
||||||
|
/// let x: Option<String> = Some("hey".to_owned());
|
||||||
|
/// assert_eq!(x.as_deref(), Some("hey"));
|
||||||
|
///
|
||||||
|
/// let x: Option<String> = None;
|
||||||
|
/// assert_eq!(x.as_deref(), None);
|
||||||
|
/// ```
|
||||||
pub fn as_deref(&self) -> Option<&T::Target> {
|
pub fn as_deref(&self) -> Option<&T::Target> {
|
||||||
self.as_ref().map(|t| t.deref())
|
self.as_ref().map(|t| t.deref())
|
||||||
}
|
}
|
||||||
@ -1121,6 +1133,18 @@ impl<T: DerefMut> Option<T> {
|
|||||||
///
|
///
|
||||||
/// Leaves the original `Option` in-place, creating a new one containing a mutable reference to
|
/// Leaves the original `Option` in-place, creating a new one containing a mutable reference to
|
||||||
/// the inner type's `Deref::Target` type.
|
/// the inner type's `Deref::Target` type.
|
||||||
|
///
|
||||||
|
/// # Examples
|
||||||
|
///
|
||||||
|
/// ```
|
||||||
|
/// #![feature(inner_deref)]
|
||||||
|
///
|
||||||
|
/// let mut x: Option<String> = Some("hey".to_owned());
|
||||||
|
/// assert_eq!(x.as_deref_mut().map(|x| {
|
||||||
|
/// x.make_ascii_uppercase();
|
||||||
|
/// x
|
||||||
|
/// }), Some("HEY".to_owned().as_mut_str()));
|
||||||
|
/// ```
|
||||||
pub fn as_deref_mut(&mut self) -> Option<&mut T::Target> {
|
pub fn as_deref_mut(&mut self) -> Option<&mut T::Target> {
|
||||||
self.as_mut().map(|t| t.deref_mut())
|
self.as_mut().map(|t| t.deref_mut())
|
||||||
}
|
}
|
||||||
@ -1199,6 +1223,13 @@ impl<T: Clone> Clone for Option<T> {
|
|||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
impl<T> Default for Option<T> {
|
impl<T> Default for Option<T> {
|
||||||
/// Returns [`None`][Option::None].
|
/// Returns [`None`][Option::None].
|
||||||
|
///
|
||||||
|
/// # Examples
|
||||||
|
///
|
||||||
|
/// ```
|
||||||
|
/// let opt: Option<u32> = Option::default();
|
||||||
|
/// assert!(opt.is_none());
|
||||||
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
fn default() -> Option<T> { None }
|
fn default() -> Option<T> { None }
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ def get_codepoints(f):
|
|||||||
yield Codepoint(codepoint, class_)
|
yield Codepoint(codepoint, class_)
|
||||||
prev_codepoint = codepoint
|
prev_codepoint = codepoint
|
||||||
|
|
||||||
if class_first != None:
|
if class_first is not None:
|
||||||
raise ValueError("Missing Last after First")
|
raise ValueError("Missing Last after First")
|
||||||
|
|
||||||
for c in range(prev_codepoint + 1, NUM_CODEPOINTS):
|
for c in range(prev_codepoint + 1, NUM_CODEPOINTS):
|
||||||
|
@ -436,7 +436,7 @@ impl fmt::Debug for UnsupportedOpInfo<'tcx> {
|
|||||||
ValidationFailure(ref err) => {
|
ValidationFailure(ref err) => {
|
||||||
write!(f, "type validation failed: {}", err)
|
write!(f, "type validation failed: {}", err)
|
||||||
}
|
}
|
||||||
NoMirFor(ref func) => write!(f, "no mir for `{}`", func),
|
NoMirFor(ref func) => write!(f, "no MIR for `{}`", func),
|
||||||
FunctionAbiMismatch(caller_abi, callee_abi) =>
|
FunctionAbiMismatch(caller_abi, callee_abi) =>
|
||||||
write!(f, "tried to call a function with ABI {:?} using caller ABI {:?}",
|
write!(f, "tried to call a function with ABI {:?} using caller ABI {:?}",
|
||||||
callee_abi, caller_abi),
|
callee_abi, caller_abi),
|
||||||
@ -451,9 +451,9 @@ impl fmt::Debug for UnsupportedOpInfo<'tcx> {
|
|||||||
FunctionArgCountMismatch =>
|
FunctionArgCountMismatch =>
|
||||||
write!(f, "tried to call a function with incorrect number of arguments"),
|
write!(f, "tried to call a function with incorrect number of arguments"),
|
||||||
ReallocatedWrongMemoryKind(ref old, ref new) =>
|
ReallocatedWrongMemoryKind(ref old, ref new) =>
|
||||||
write!(f, "tried to reallocate memory from {} to {}", old, new),
|
write!(f, "tried to reallocate memory from `{}` to `{}`", old, new),
|
||||||
DeallocatedWrongMemoryKind(ref old, ref new) =>
|
DeallocatedWrongMemoryKind(ref old, ref new) =>
|
||||||
write!(f, "tried to deallocate {} memory but gave {} as the kind", old, new),
|
write!(f, "tried to deallocate `{}` memory but gave `{}` as the kind", old, new),
|
||||||
InvalidChar(c) =>
|
InvalidChar(c) =>
|
||||||
write!(f, "tried to interpret an invalid 32-bit value as a char: {}", c),
|
write!(f, "tried to interpret an invalid 32-bit value as a char: {}", c),
|
||||||
AlignmentCheckFailed { required, has } =>
|
AlignmentCheckFailed { required, has } =>
|
||||||
@ -462,7 +462,7 @@ impl fmt::Debug for UnsupportedOpInfo<'tcx> {
|
|||||||
TypeNotPrimitive(ty) =>
|
TypeNotPrimitive(ty) =>
|
||||||
write!(f, "expected primitive type, got {}", ty),
|
write!(f, "expected primitive type, got {}", ty),
|
||||||
PathNotFound(ref path) =>
|
PathNotFound(ref path) =>
|
||||||
write!(f, "Cannot find path {:?}", path),
|
write!(f, "cannot find path {:?}", path),
|
||||||
IncorrectAllocationInformation(size, size2, align, align2) =>
|
IncorrectAllocationInformation(size, size2, align, align2) =>
|
||||||
write!(f, "incorrect alloc info: expected size {} and align {}, \
|
write!(f, "incorrect alloc info: expected size {} and align {}, \
|
||||||
got size {} and align {}",
|
got size {} and align {}",
|
||||||
@ -525,7 +525,7 @@ impl fmt::Debug for UnsupportedOpInfo<'tcx> {
|
|||||||
InvalidBoolOp(_) =>
|
InvalidBoolOp(_) =>
|
||||||
write!(f, "invalid boolean operation"),
|
write!(f, "invalid boolean operation"),
|
||||||
UnterminatedCString(_) =>
|
UnterminatedCString(_) =>
|
||||||
write!(f, "attempted to get length of a null terminated string, but no null \
|
write!(f, "attempted to get length of a null-terminated string, but no null \
|
||||||
found before end of allocation"),
|
found before end of allocation"),
|
||||||
ReadUndefBytes(_) =>
|
ReadUndefBytes(_) =>
|
||||||
write!(f, "attempted to read undefined bytes"),
|
write!(f, "attempted to read undefined bytes"),
|
||||||
|
@ -1998,7 +1998,7 @@ pub fn parse_error_format(
|
|||||||
Some(arg) => early_error(
|
Some(arg) => early_error(
|
||||||
ErrorOutputType::HumanReadable(HumanReadableErrorType::Default(color)),
|
ErrorOutputType::HumanReadable(HumanReadableErrorType::Default(color)),
|
||||||
&format!(
|
&format!(
|
||||||
"argument for --error-format must be `human`, `json` or \
|
"argument for `--error-format` must be `human`, `json` or \
|
||||||
`short` (instead was `{}`)",
|
`short` (instead was `{}`)",
|
||||||
arg
|
arg
|
||||||
),
|
),
|
||||||
@ -2037,7 +2037,7 @@ pub fn build_session_options_and_crate_config(
|
|||||||
early_error(
|
early_error(
|
||||||
ErrorOutputType::default(),
|
ErrorOutputType::default(),
|
||||||
&format!(
|
&format!(
|
||||||
"argument for --edition must be one of: \
|
"argument for `--edition` must be one of: \
|
||||||
{}. (instead was `{}`)",
|
{}. (instead was `{}`)",
|
||||||
EDITION_NAME_LIST,
|
EDITION_NAME_LIST,
|
||||||
arg
|
arg
|
||||||
@ -2051,7 +2051,7 @@ pub fn build_session_options_and_crate_config(
|
|||||||
early_error(
|
early_error(
|
||||||
ErrorOutputType::default(),
|
ErrorOutputType::default(),
|
||||||
&format!(
|
&format!(
|
||||||
"Edition {} is unstable and only \
|
"edition {} is unstable and only \
|
||||||
available for nightly builds of rustc.",
|
available for nightly builds of rustc.",
|
||||||
edition,
|
edition,
|
||||||
)
|
)
|
||||||
@ -2075,14 +2075,14 @@ pub fn build_session_options_and_crate_config(
|
|||||||
if let ErrorOutputType::Json { pretty: true, json_rendered } = error_format {
|
if let ErrorOutputType::Json { pretty: true, json_rendered } = error_format {
|
||||||
early_error(
|
early_error(
|
||||||
ErrorOutputType::Json { pretty: false, json_rendered },
|
ErrorOutputType::Json { pretty: false, json_rendered },
|
||||||
"--error-format=pretty-json is unstable",
|
"`--error-format=pretty-json` is unstable",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if let ErrorOutputType::HumanReadable(HumanReadableErrorType::AnnotateSnippet(_)) =
|
if let ErrorOutputType::HumanReadable(HumanReadableErrorType::AnnotateSnippet(_)) =
|
||||||
error_format {
|
error_format {
|
||||||
early_error(
|
early_error(
|
||||||
ErrorOutputType::Json { pretty: false, json_rendered },
|
ErrorOutputType::Json { pretty: false, json_rendered },
|
||||||
"--error-format=human-annotate-rs is unstable",
|
"`--error-format=human-annotate-rs` is unstable",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2132,8 +2132,8 @@ pub fn build_session_options_and_crate_config(
|
|||||||
early_warn(
|
early_warn(
|
||||||
error_format,
|
error_format,
|
||||||
&format!(
|
&format!(
|
||||||
"--emit={} with -o incompatible with \
|
"`--emit={}` with `-o` incompatible with \
|
||||||
-C codegen-units=N for N > 1",
|
`-C codegen-units=N` for N > 1",
|
||||||
ot
|
ot
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@ -2153,21 +2153,21 @@ pub fn build_session_options_and_crate_config(
|
|||||||
if debugging_opts.threads == Some(0) {
|
if debugging_opts.threads == Some(0) {
|
||||||
early_error(
|
early_error(
|
||||||
error_format,
|
error_format,
|
||||||
"Value for threads must be a positive nonzero integer",
|
"value for threads must be a positive non-zero integer",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if debugging_opts.threads.unwrap_or(1) > 1 && debugging_opts.fuel.is_some() {
|
if debugging_opts.threads.unwrap_or(1) > 1 && debugging_opts.fuel.is_some() {
|
||||||
early_error(
|
early_error(
|
||||||
error_format,
|
error_format,
|
||||||
"Optimization fuel is incompatible with multiple threads",
|
"optimization fuel is incompatible with multiple threads",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if codegen_units == Some(0) {
|
if codegen_units == Some(0) {
|
||||||
early_error(
|
early_error(
|
||||||
error_format,
|
error_format,
|
||||||
"Value for codegen units must be a positive nonzero integer",
|
"value for codegen units must be a positive non-zero integer",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -368,7 +368,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||||||
match self.layout_of(param_env.and(ty)) {
|
match self.layout_of(param_env.and(ty)) {
|
||||||
Ok(layout) => &layout.abi,
|
Ok(layout) => &layout.abi,
|
||||||
Err(err) => bug!(
|
Err(err) => bug!(
|
||||||
"Error: {}\n while computing layout for type {:?}", err, ty
|
"error: {}\n while computing layout for type {:?}", err, ty
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -384,7 +384,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||||||
self.sess.delay_span_bug(
|
self.sess.delay_span_bug(
|
||||||
self.def_span(method.def_id),
|
self.def_span(method.def_id),
|
||||||
&format!(
|
&format!(
|
||||||
"Receiver when Self = () should have a Scalar ABI, found {:?}",
|
"receiver when `Self = ()` should have a Scalar ABI; found {:?}",
|
||||||
abi
|
abi
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@ -406,7 +406,8 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||||||
self.sess.delay_span_bug(
|
self.sess.delay_span_bug(
|
||||||
self.def_span(method.def_id),
|
self.def_span(method.def_id),
|
||||||
&format!(
|
&format!(
|
||||||
"Receiver when Self = {} should have a ScalarPair ABI, found {:?}",
|
"receiver when `Self = {}` should have a ScalarPair ABI; \
|
||||||
|
found {:?}",
|
||||||
trait_object_ty, abi
|
trait_object_ty, abi
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -4,6 +4,9 @@ use build_helper::sanitizer_lib_boilerplate;
|
|||||||
use cmake::Config;
|
use cmake::Config;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
if env::var("RUSTC_BUILD_SANITIZERS") != Ok("1".to_string()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if let Some(llvm_config) = env::var_os("LLVM_CONFIG") {
|
if let Some(llvm_config) = env::var_os("LLVM_CONFIG") {
|
||||||
build_helper::restore_library_path();
|
build_helper::restore_library_path();
|
||||||
|
|
||||||
|
@ -30,10 +30,14 @@ pub struct AnnotateSnippetEmitterWriter {
|
|||||||
impl Emitter for AnnotateSnippetEmitterWriter {
|
impl Emitter for AnnotateSnippetEmitterWriter {
|
||||||
/// The entry point for the diagnostics generation
|
/// The entry point for the diagnostics generation
|
||||||
fn emit_diagnostic(&mut self, db: &DiagnosticBuilder<'_>) {
|
fn emit_diagnostic(&mut self, db: &DiagnosticBuilder<'_>) {
|
||||||
let children = db.children.clone();
|
let mut children = db.children.clone();
|
||||||
let (primary_span, suggestions) = self.primary_span_formatted(&db);
|
let (mut primary_span, suggestions) = self.primary_span_formatted(&db);
|
||||||
|
|
||||||
// FIXME(#59346): Add `fix_multispans_in_std_macros` function from emitter.rs
|
self.fix_multispans_in_std_macros(&self.source_map,
|
||||||
|
&mut primary_span,
|
||||||
|
&mut children,
|
||||||
|
&db.level,
|
||||||
|
db.handler.flags.external_macro_backtrace);
|
||||||
|
|
||||||
self.emit_messages_default(&db.level,
|
self.emit_messages_default(&db.level,
|
||||||
db.message(),
|
db.message(),
|
||||||
@ -105,7 +109,7 @@ impl<'a> DiagnosticConverter<'a> {
|
|||||||
annotated_files: Vec<FileWithAnnotatedLines>,
|
annotated_files: Vec<FileWithAnnotatedLines>,
|
||||||
primary_lo: Loc
|
primary_lo: Loc
|
||||||
) -> Vec<Slice> {
|
) -> Vec<Slice> {
|
||||||
// FIXME(#59346): Provide a test case where `annotated_files` is > 1
|
// FIXME(#64205): Provide a test case where `annotated_files` is > 1
|
||||||
annotated_files.iter().flat_map(|annotated_file| {
|
annotated_files.iter().flat_map(|annotated_file| {
|
||||||
annotated_file.lines.iter().map(|line| {
|
annotated_file.lines.iter().map(|line| {
|
||||||
let line_source = Self::source_string(annotated_file.file.clone(), &line);
|
let line_source = Self::source_string(annotated_file.file.clone(), &line);
|
||||||
|
@ -247,6 +247,133 @@ pub trait Emitter {
|
|||||||
(primary_span, &db.suggestions)
|
(primary_span, &db.suggestions)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This does a small "fix" for multispans by looking to see if it can find any that
|
||||||
|
// point directly at <*macros>. Since these are often difficult to read, this
|
||||||
|
// will change the span to point at the use site.
|
||||||
|
fn fix_multispans_in_std_macros(&self,
|
||||||
|
source_map: &Option<Lrc<SourceMapperDyn>>,
|
||||||
|
span: &mut MultiSpan,
|
||||||
|
children: &mut Vec<SubDiagnostic>,
|
||||||
|
level: &Level,
|
||||||
|
backtrace: bool) {
|
||||||
|
let mut spans_updated = self.fix_multispan_in_std_macros(source_map, span, backtrace);
|
||||||
|
for child in children.iter_mut() {
|
||||||
|
spans_updated |= self.fix_multispan_in_std_macros(
|
||||||
|
source_map,
|
||||||
|
&mut child.span,
|
||||||
|
backtrace
|
||||||
|
);
|
||||||
|
}
|
||||||
|
let msg = if level == &Error {
|
||||||
|
"this error originates in a macro outside of the current crate \
|
||||||
|
(in Nightly builds, run with -Z external-macro-backtrace \
|
||||||
|
for more info)".to_string()
|
||||||
|
} else {
|
||||||
|
"this warning originates in a macro outside of the current crate \
|
||||||
|
(in Nightly builds, run with -Z external-macro-backtrace \
|
||||||
|
for more info)".to_string()
|
||||||
|
};
|
||||||
|
|
||||||
|
if spans_updated {
|
||||||
|
children.push(SubDiagnostic {
|
||||||
|
level: Level::Note,
|
||||||
|
message: vec![
|
||||||
|
(msg,
|
||||||
|
Style::NoStyle),
|
||||||
|
],
|
||||||
|
span: MultiSpan::new(),
|
||||||
|
render_span: None,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// This "fixes" MultiSpans that contain Spans that are pointing to locations inside of
|
||||||
|
// <*macros>. Since these locations are often difficult to read, we move these Spans from
|
||||||
|
// <*macros> to their corresponding use site.
|
||||||
|
fn fix_multispan_in_std_macros(&self,
|
||||||
|
source_map: &Option<Lrc<SourceMapperDyn>>,
|
||||||
|
span: &mut MultiSpan,
|
||||||
|
always_backtrace: bool) -> bool {
|
||||||
|
let mut spans_updated = false;
|
||||||
|
|
||||||
|
if let Some(ref sm) = source_map {
|
||||||
|
let mut before_after: Vec<(Span, Span)> = vec![];
|
||||||
|
let mut new_labels: Vec<(Span, String)> = vec![];
|
||||||
|
|
||||||
|
// First, find all the spans in <*macros> and point instead at their use site
|
||||||
|
for sp in span.primary_spans() {
|
||||||
|
if sp.is_dummy() {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
let call_sp = sm.call_span_if_macro(*sp);
|
||||||
|
if call_sp != *sp && !always_backtrace {
|
||||||
|
before_after.push((*sp, call_sp));
|
||||||
|
}
|
||||||
|
let backtrace_len = sp.macro_backtrace().len();
|
||||||
|
for (i, trace) in sp.macro_backtrace().iter().rev().enumerate() {
|
||||||
|
// Only show macro locations that are local
|
||||||
|
// and display them like a span_note
|
||||||
|
if trace.def_site_span.is_dummy() {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if always_backtrace {
|
||||||
|
new_labels.push((trace.def_site_span,
|
||||||
|
format!("in this expansion of `{}`{}",
|
||||||
|
trace.macro_decl_name,
|
||||||
|
if backtrace_len > 2 {
|
||||||
|
// if backtrace_len == 1 it'll be pointed
|
||||||
|
// at by "in this macro invocation"
|
||||||
|
format!(" (#{})", i + 1)
|
||||||
|
} else {
|
||||||
|
String::new()
|
||||||
|
})));
|
||||||
|
}
|
||||||
|
// Check to make sure we're not in any <*macros>
|
||||||
|
if !sm.span_to_filename(trace.def_site_span).is_macros() &&
|
||||||
|
!trace.macro_decl_name.starts_with("desugaring of ") &&
|
||||||
|
!trace.macro_decl_name.starts_with("#[") ||
|
||||||
|
always_backtrace {
|
||||||
|
new_labels.push((trace.call_site,
|
||||||
|
format!("in this macro invocation{}",
|
||||||
|
if backtrace_len > 2 && always_backtrace {
|
||||||
|
// only specify order when the macro
|
||||||
|
// backtrace is multiple levels deep
|
||||||
|
format!(" (#{})", i + 1)
|
||||||
|
} else {
|
||||||
|
String::new()
|
||||||
|
})));
|
||||||
|
if !always_backtrace {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (label_span, label_text) in new_labels {
|
||||||
|
span.push_span_label(label_span, label_text);
|
||||||
|
}
|
||||||
|
for sp_label in span.span_labels() {
|
||||||
|
if sp_label.span.is_dummy() {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if sm.span_to_filename(sp_label.span.clone()).is_macros() &&
|
||||||
|
!always_backtrace
|
||||||
|
{
|
||||||
|
let v = sp_label.span.macro_backtrace();
|
||||||
|
if let Some(use_site) = v.last() {
|
||||||
|
before_after.push((sp_label.span.clone(), use_site.call_site.clone()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// After we have them, make sure we replace these 'bad' def sites with their use sites
|
||||||
|
for (before, after) in before_after {
|
||||||
|
span.replace(before, after);
|
||||||
|
spans_updated = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
spans_updated
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Emitter for EmitterWriter {
|
impl Emitter for EmitterWriter {
|
||||||
@ -254,7 +381,8 @@ impl Emitter for EmitterWriter {
|
|||||||
let mut children = db.children.clone();
|
let mut children = db.children.clone();
|
||||||
let (mut primary_span, suggestions) = self.primary_span_formatted(&db);
|
let (mut primary_span, suggestions) = self.primary_span_formatted(&db);
|
||||||
|
|
||||||
self.fix_multispans_in_std_macros(&mut primary_span,
|
self.fix_multispans_in_std_macros(&self.sm,
|
||||||
|
&mut primary_span,
|
||||||
&mut children,
|
&mut children,
|
||||||
&db.level,
|
&db.level,
|
||||||
db.handler.flags.external_macro_backtrace);
|
db.handler.flags.external_macro_backtrace);
|
||||||
@ -919,127 +1047,6 @@ impl EmitterWriter {
|
|||||||
max
|
max
|
||||||
}
|
}
|
||||||
|
|
||||||
// This "fixes" MultiSpans that contain Spans that are pointing to locations inside of
|
|
||||||
// <*macros>. Since these locations are often difficult to read, we move these Spans from
|
|
||||||
// <*macros> to their corresponding use site.
|
|
||||||
fn fix_multispan_in_std_macros(&mut self,
|
|
||||||
span: &mut MultiSpan,
|
|
||||||
always_backtrace: bool) -> bool {
|
|
||||||
let mut spans_updated = false;
|
|
||||||
|
|
||||||
if let Some(ref sm) = self.sm {
|
|
||||||
let mut before_after: Vec<(Span, Span)> = vec![];
|
|
||||||
let mut new_labels: Vec<(Span, String)> = vec![];
|
|
||||||
|
|
||||||
// First, find all the spans in <*macros> and point instead at their use site
|
|
||||||
for sp in span.primary_spans() {
|
|
||||||
if sp.is_dummy() {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
let call_sp = sm.call_span_if_macro(*sp);
|
|
||||||
if call_sp != *sp && !always_backtrace {
|
|
||||||
before_after.push((*sp, call_sp));
|
|
||||||
}
|
|
||||||
let backtrace_len = sp.macro_backtrace().len();
|
|
||||||
for (i, trace) in sp.macro_backtrace().iter().rev().enumerate() {
|
|
||||||
// Only show macro locations that are local
|
|
||||||
// and display them like a span_note
|
|
||||||
if trace.def_site_span.is_dummy() {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if always_backtrace {
|
|
||||||
new_labels.push((trace.def_site_span,
|
|
||||||
format!("in this expansion of `{}`{}",
|
|
||||||
trace.macro_decl_name,
|
|
||||||
if backtrace_len > 2 {
|
|
||||||
// if backtrace_len == 1 it'll be pointed
|
|
||||||
// at by "in this macro invocation"
|
|
||||||
format!(" (#{})", i + 1)
|
|
||||||
} else {
|
|
||||||
String::new()
|
|
||||||
})));
|
|
||||||
}
|
|
||||||
// Check to make sure we're not in any <*macros>
|
|
||||||
if !sm.span_to_filename(trace.def_site_span).is_macros() &&
|
|
||||||
!trace.macro_decl_name.starts_with("desugaring of ") &&
|
|
||||||
!trace.macro_decl_name.starts_with("#[") ||
|
|
||||||
always_backtrace {
|
|
||||||
new_labels.push((trace.call_site,
|
|
||||||
format!("in this macro invocation{}",
|
|
||||||
if backtrace_len > 2 && always_backtrace {
|
|
||||||
// only specify order when the macro
|
|
||||||
// backtrace is multiple levels deep
|
|
||||||
format!(" (#{})", i + 1)
|
|
||||||
} else {
|
|
||||||
String::new()
|
|
||||||
})));
|
|
||||||
if !always_backtrace {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (label_span, label_text) in new_labels {
|
|
||||||
span.push_span_label(label_span, label_text);
|
|
||||||
}
|
|
||||||
for sp_label in span.span_labels() {
|
|
||||||
if sp_label.span.is_dummy() {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if sm.span_to_filename(sp_label.span.clone()).is_macros() &&
|
|
||||||
!always_backtrace
|
|
||||||
{
|
|
||||||
let v = sp_label.span.macro_backtrace();
|
|
||||||
if let Some(use_site) = v.last() {
|
|
||||||
before_after.push((sp_label.span.clone(), use_site.call_site.clone()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// After we have them, make sure we replace these 'bad' def sites with their use sites
|
|
||||||
for (before, after) in before_after {
|
|
||||||
span.replace(before, after);
|
|
||||||
spans_updated = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
spans_updated
|
|
||||||
}
|
|
||||||
|
|
||||||
// This does a small "fix" for multispans by looking to see if it can find any that
|
|
||||||
// point directly at <*macros>. Since these are often difficult to read, this
|
|
||||||
// will change the span to point at the use site.
|
|
||||||
fn fix_multispans_in_std_macros(&mut self,
|
|
||||||
span: &mut MultiSpan,
|
|
||||||
children: &mut Vec<SubDiagnostic>,
|
|
||||||
level: &Level,
|
|
||||||
backtrace: bool) {
|
|
||||||
let mut spans_updated = self.fix_multispan_in_std_macros(span, backtrace);
|
|
||||||
for child in children.iter_mut() {
|
|
||||||
spans_updated |= self.fix_multispan_in_std_macros(&mut child.span, backtrace);
|
|
||||||
}
|
|
||||||
let msg = if level == &Error {
|
|
||||||
"this error originates in a macro outside of the current crate \
|
|
||||||
(in Nightly builds, run with -Z external-macro-backtrace \
|
|
||||||
for more info)".to_string()
|
|
||||||
} else {
|
|
||||||
"this warning originates in a macro outside of the current crate \
|
|
||||||
(in Nightly builds, run with -Z external-macro-backtrace \
|
|
||||||
for more info)".to_string()
|
|
||||||
};
|
|
||||||
|
|
||||||
if spans_updated {
|
|
||||||
children.push(SubDiagnostic {
|
|
||||||
level: Level::Note,
|
|
||||||
message: vec![
|
|
||||||
(msg,
|
|
||||||
Style::NoStyle),
|
|
||||||
],
|
|
||||||
span: MultiSpan::new(),
|
|
||||||
render_span: None,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Adds a left margin to every line but the first, given a padding length and the label being
|
/// Adds a left margin to every line but the first, given a padding length and the label being
|
||||||
/// displayed, keeping the provided highlighting.
|
/// displayed, keeping the provided highlighting.
|
||||||
fn msg_to_buffer(&self,
|
fn msg_to_buffer(&self,
|
||||||
|
@ -4,6 +4,9 @@ use build_helper::sanitizer_lib_boilerplate;
|
|||||||
use cmake::Config;
|
use cmake::Config;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
if env::var("RUSTC_BUILD_SANITIZERS") != Ok("1".to_string()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if let Some(llvm_config) = env::var_os("LLVM_CONFIG") {
|
if let Some(llvm_config) = env::var_os("LLVM_CONFIG") {
|
||||||
build_helper::restore_library_path();
|
build_helper::restore_library_path();
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
|||||||
&self.describe_place_with_options(moved_place, IncludingDowncast(true))
|
&self.describe_place_with_options(moved_place, IncludingDowncast(true))
|
||||||
.unwrap_or_else(|| "_".to_owned()),
|
.unwrap_or_else(|| "_".to_owned()),
|
||||||
);
|
);
|
||||||
err.span_label(span, format!("use of possibly uninitialized {}", item_msg));
|
err.span_label(span, format!("use of possibly-uninitialized {}", item_msg));
|
||||||
|
|
||||||
use_spans.var_span_label(
|
use_spans.var_span_label(
|
||||||
&mut err,
|
&mut err,
|
||||||
|
@ -164,8 +164,8 @@ fn do_mir_borrowck<'a, 'tcx>(
|
|||||||
};
|
};
|
||||||
|
|
||||||
let mdpe = MoveDataParamEnv {
|
let mdpe = MoveDataParamEnv {
|
||||||
move_data: move_data,
|
move_data,
|
||||||
param_env: param_env,
|
param_env,
|
||||||
};
|
};
|
||||||
|
|
||||||
let dead_unwinds = BitSet::new_empty(body.basic_blocks().len());
|
let dead_unwinds = BitSet::new_empty(body.basic_blocks().len());
|
||||||
@ -259,7 +259,10 @@ fn do_mir_borrowck<'a, 'tcx>(
|
|||||||
move_error_reported: BTreeMap::new(),
|
move_error_reported: BTreeMap::new(),
|
||||||
uninitialized_error_reported: Default::default(),
|
uninitialized_error_reported: Default::default(),
|
||||||
errors_buffer,
|
errors_buffer,
|
||||||
disable_error_downgrading: false,
|
// Only downgrade errors on Rust 2015 and refuse to do so on Rust 2018.
|
||||||
|
// FIXME(Centril): In Rust 1.40.0, refuse doing so on 2015 as well and
|
||||||
|
// proceed to throwing out the migration infrastructure.
|
||||||
|
disable_error_downgrading: body.span.rust_2018(),
|
||||||
nonlexical_regioncx: regioncx,
|
nonlexical_regioncx: regioncx,
|
||||||
used_mut: Default::default(),
|
used_mut: Default::default(),
|
||||||
used_mut_upvars: SmallVec::new(),
|
used_mut_upvars: SmallVec::new(),
|
||||||
|
@ -533,8 +533,8 @@ pub fn error_to_const_error<'mir, 'tcx>(
|
|||||||
|
|
||||||
pub fn note_on_undefined_behavior_error() -> &'static str {
|
pub fn note_on_undefined_behavior_error() -> &'static str {
|
||||||
"The rules on what exactly is undefined behavior aren't clear, \
|
"The rules on what exactly is undefined behavior aren't clear, \
|
||||||
so this check might be overzealous. Please open an issue on the rust compiler \
|
so this check might be overzealous. Please open an issue on the rustc \
|
||||||
repository if you believe it should not be considered undefined behavior"
|
repository if you believe it should not be considered undefined behavior."
|
||||||
}
|
}
|
||||||
|
|
||||||
fn validate_and_turn_into_const<'tcx>(
|
fn validate_and_turn_into_const<'tcx>(
|
||||||
|
@ -748,7 +748,7 @@ It is not allowed to use or capture an uninitialized variable. For example:
|
|||||||
```compile_fail,E0381
|
```compile_fail,E0381
|
||||||
fn main() {
|
fn main() {
|
||||||
let x: i32;
|
let x: i32;
|
||||||
let y = x; // error, use of possibly uninitialized variable
|
let y = x; // error, use of possibly-uninitialized variable
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ impl<'cx, 'tcx> crate::borrow_check::MirBorrowckCtxt<'cx, 'tcx> {
|
|||||||
self,
|
self,
|
||||||
span,
|
span,
|
||||||
E0381,
|
E0381,
|
||||||
"{} of possibly uninitialized variable: `{}`",
|
"{} of possibly-uninitialized variable: `{}`",
|
||||||
verb,
|
verb,
|
||||||
desc,
|
desc,
|
||||||
)
|
)
|
||||||
|
@ -4,6 +4,9 @@ use build_helper::sanitizer_lib_boilerplate;
|
|||||||
use cmake::Config;
|
use cmake::Config;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
if env::var("RUSTC_BUILD_SANITIZERS") != Ok("1".to_string()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if let Some(llvm_config) = env::var_os("LLVM_CONFIG") {
|
if let Some(llvm_config) = env::var_os("LLVM_CONFIG") {
|
||||||
build_helper::restore_library_path();
|
build_helper::restore_library_path();
|
||||||
|
|
||||||
|
@ -4,6 +4,9 @@ use build_helper::sanitizer_lib_boilerplate;
|
|||||||
use cmake::Config;
|
use cmake::Config;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
if env::var("RUSTC_BUILD_SANITIZERS") != Ok("1".to_string()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if let Some(llvm_config) = env::var_os("LLVM_CONFIG") {
|
if let Some(llvm_config) = env::var_os("LLVM_CONFIG") {
|
||||||
build_helper::restore_library_path();
|
build_helper::restore_library_path();
|
||||||
|
|
||||||
|
@ -982,7 +982,7 @@ impl<'a> Parser<'a> {
|
|||||||
}
|
}
|
||||||
if self.is_do_catch_block() {
|
if self.is_do_catch_block() {
|
||||||
let mut db = self.fatal("found removed `do catch` syntax");
|
let mut db = self.fatal("found removed `do catch` syntax");
|
||||||
db.help("Following RFC #2388, the new non-placeholder syntax is `try`");
|
db.help("following RFC #2388, the new non-placeholder syntax is `try`");
|
||||||
return Err(db);
|
return Err(db);
|
||||||
}
|
}
|
||||||
if self.is_try_block() {
|
if self.is_try_block() {
|
||||||
|
@ -469,7 +469,7 @@ impl<'a> Parser<'a> {
|
|||||||
self.diagnostic().struct_span_warn(self.token.span, {
|
self.diagnostic().struct_span_warn(self.token.span, {
|
||||||
&format!("expected `;`, found {}", self.this_token_descr())
|
&format!("expected `;`, found {}", self.this_token_descr())
|
||||||
}).note({
|
}).note({
|
||||||
"This was erroneously allowed and will become a hard error in a future release"
|
"this was erroneously allowed and will become a hard error in a future release"
|
||||||
}).emit();
|
}).emit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// no-prefer-dynamic
|
|
||||||
|
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
|
|
||||||
// check dtor calling order when casting enums.
|
// check dtor calling order when casting enums.
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// no-prefer-dynamic
|
|
||||||
|
|
||||||
// This would previously leak the Box<Trait> because we wouldn't
|
// This would previously leak the Box<Trait> because we wouldn't
|
||||||
// schedule cleanups when auto borrowing trait objects.
|
// schedule cleanups when auto borrowing trait objects.
|
||||||
// This program should be valgrind clean.
|
// This program should be valgrind clean.
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// no-prefer-dynamic
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let _ = std::io::stdin();
|
let _ = std::io::stdin();
|
||||||
let _ = std::io::stdout();
|
let _ = std::io::stdout();
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
// no-prefer-dynamic
|
|
||||||
// ignore-emscripten
|
// ignore-emscripten
|
||||||
|
|
||||||
thread_local!(static FOO: Foo = Foo);
|
thread_local!(static FOO: Foo = Foo);
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// no-prefer-dynamic
|
|
||||||
|
|
||||||
static mut DROP_RAN: bool = false;
|
static mut DROP_RAN: bool = false;
|
||||||
|
|
||||||
struct Foo;
|
struct Foo;
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// no-prefer-dynamic
|
|
||||||
|
|
||||||
static mut DROP_RAN: isize = 0;
|
static mut DROP_RAN: isize = 0;
|
||||||
|
|
||||||
struct Foo;
|
struct Foo;
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// no-prefer-dynamic
|
|
||||||
|
|
||||||
#![feature(unsized_tuple_coercion)]
|
#![feature(unsized_tuple_coercion)]
|
||||||
|
|
||||||
static mut DROP_RAN: bool = false;
|
static mut DROP_RAN: bool = false;
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// no-prefer-dynamic
|
|
||||||
|
|
||||||
#![feature(unsized_tuple_coercion)]
|
#![feature(unsized_tuple_coercion)]
|
||||||
|
|
||||||
static mut DROP_RAN: isize = 0;
|
static mut DROP_RAN: isize = 0;
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
// no-prefer-dynamic
|
|
||||||
// ignore-cloudabi
|
// ignore-cloudabi
|
||||||
// ignore-emscripten
|
// ignore-emscripten
|
||||||
// ignore-sgx no processes
|
// ignore-sgx no processes
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
// no-prefer-dynamic
|
|
||||||
// pretty-expanded FIXME #23616
|
// pretty-expanded FIXME #23616
|
||||||
|
|
||||||
#![feature(rustc_private)]
|
#![feature(rustc_private)]
|
||||||
|
@ -20,7 +20,7 @@ pub fn main() {
|
|||||||
let x: isize;
|
let x: isize;
|
||||||
unsafe {
|
unsafe {
|
||||||
asm!("mov $1, $0" : "=r"(x) : "r"(x));
|
asm!("mov $1, $0" : "=r"(x) : "r"(x));
|
||||||
//~^ ERROR use of possibly uninitialized variable: `x`
|
//~^ ERROR use of possibly-uninitialized variable: `x`
|
||||||
}
|
}
|
||||||
foo(x);
|
foo(x);
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
error[E0381]: use of possibly uninitialized variable: `x`
|
error[E0381]: use of possibly-uninitialized variable: `x`
|
||||||
--> $DIR/asm-out-read-uninit.rs:22:43
|
--> $DIR/asm-out-read-uninit.rs:22:43
|
||||||
|
|
|
|
||||||
LL | asm!("mov $1, $0" : "=r"(x) : "r"(x));
|
LL | asm!("mov $1, $0" : "=r"(x) : "r"(x));
|
||||||
| ^ use of possibly uninitialized `x`
|
| ^ use of possibly-uninitialized `x`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ async fn no_non_guaranteed_initialization(x: usize) -> usize {
|
|||||||
y = echo(10).await;
|
y = echo(10).await;
|
||||||
}
|
}
|
||||||
y
|
y
|
||||||
//~^ use of possibly uninitialized variable: `y`
|
//~^ use of possibly-uninitialized variable: `y`
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn echo(x: usize) -> usize { x + 1 }
|
async fn echo(x: usize) -> usize { x + 1 }
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
error[E0381]: use of possibly uninitialized variable: `y`
|
error[E0381]: use of possibly-uninitialized variable: `y`
|
||||||
--> $DIR/no-non-guaranteed-initialization.rs:10:5
|
--> $DIR/no-non-guaranteed-initialization.rs:10:5
|
||||||
|
|
|
|
||||||
LL | y
|
LL | y
|
||||||
| ^ use of possibly uninitialized `y`
|
| ^ use of possibly-uninitialized `y`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ async fn noop() {}
|
|||||||
async fn test_tuple() {
|
async fn test_tuple() {
|
||||||
let mut t: (i32, i32);
|
let mut t: (i32, i32);
|
||||||
t.0 = 42;
|
t.0 = 42;
|
||||||
//~^ ERROR assign to part of possibly uninitialized variable: `t` [E0381]
|
//~^ ERROR assign to part of possibly-uninitialized variable: `t` [E0381]
|
||||||
noop().await;
|
noop().await;
|
||||||
t.1 = 88;
|
t.1 = 88;
|
||||||
let _ = t;
|
let _ = t;
|
||||||
@ -20,7 +20,7 @@ async fn test_tuple() {
|
|||||||
async fn test_tuple_struct() {
|
async fn test_tuple_struct() {
|
||||||
let mut t: T;
|
let mut t: T;
|
||||||
t.0 = 42;
|
t.0 = 42;
|
||||||
//~^ ERROR assign to part of possibly uninitialized variable: `t` [E0381]
|
//~^ ERROR assign to part of possibly-uninitialized variable: `t` [E0381]
|
||||||
noop().await;
|
noop().await;
|
||||||
t.1 = 88;
|
t.1 = 88;
|
||||||
let _ = t;
|
let _ = t;
|
||||||
@ -29,7 +29,7 @@ async fn test_tuple_struct() {
|
|||||||
async fn test_struct() {
|
async fn test_struct() {
|
||||||
let mut t: S;
|
let mut t: S;
|
||||||
t.x = 42;
|
t.x = 42;
|
||||||
//~^ ERROR assign to part of possibly uninitialized variable: `t` [E0381]
|
//~^ ERROR assign to part of possibly-uninitialized variable: `t` [E0381]
|
||||||
noop().await;
|
noop().await;
|
||||||
t.y = 88;
|
t.y = 88;
|
||||||
let _ = t;
|
let _ = t;
|
||||||
|
@ -1,20 +1,20 @@
|
|||||||
error[E0381]: assign to part of possibly uninitialized variable: `t`
|
error[E0381]: assign to part of possibly-uninitialized variable: `t`
|
||||||
--> $DIR/partial-initialization-across-await.rs:13:5
|
--> $DIR/partial-initialization-across-await.rs:13:5
|
||||||
|
|
|
|
||||||
LL | t.0 = 42;
|
LL | t.0 = 42;
|
||||||
| ^^^^^^^^ use of possibly uninitialized `t`
|
| ^^^^^^^^ use of possibly-uninitialized `t`
|
||||||
|
|
||||||
error[E0381]: assign to part of possibly uninitialized variable: `t`
|
error[E0381]: assign to part of possibly-uninitialized variable: `t`
|
||||||
--> $DIR/partial-initialization-across-await.rs:22:5
|
--> $DIR/partial-initialization-across-await.rs:22:5
|
||||||
|
|
|
|
||||||
LL | t.0 = 42;
|
LL | t.0 = 42;
|
||||||
| ^^^^^^^^ use of possibly uninitialized `t`
|
| ^^^^^^^^ use of possibly-uninitialized `t`
|
||||||
|
|
||||||
error[E0381]: assign to part of possibly uninitialized variable: `t`
|
error[E0381]: assign to part of possibly-uninitialized variable: `t`
|
||||||
--> $DIR/partial-initialization-across-await.rs:31:5
|
--> $DIR/partial-initialization-across-await.rs:31:5
|
||||||
|
|
|
|
||||||
LL | t.x = 42;
|
LL | t.x = 42;
|
||||||
| ^^^^^^^^ use of possibly uninitialized `t`
|
| ^^^^^^^^ use of possibly-uninitialized `t`
|
||||||
|
|
||||||
error: aborting due to 3 previous errors
|
error: aborting due to 3 previous errors
|
||||||
|
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
error[E0381]: assign to part of possibly uninitialized variable: `x`
|
error[E0381]: assign to part of possibly-uninitialized variable: `x`
|
||||||
--> $DIR/assign_mutable_fields.rs:9:5
|
--> $DIR/assign_mutable_fields.rs:9:5
|
||||||
|
|
|
|
||||||
LL | x.0 = 1;
|
LL | x.0 = 1;
|
||||||
| ^^^^^^^ use of possibly uninitialized `x`
|
| ^^^^^^^ use of possibly-uninitialized `x`
|
||||||
|
|
||||||
error[E0381]: assign to part of possibly uninitialized variable: `x`
|
error[E0381]: assign to part of possibly-uninitialized variable: `x`
|
||||||
--> $DIR/assign_mutable_fields.rs:17:5
|
--> $DIR/assign_mutable_fields.rs:17:5
|
||||||
|
|
|
|
||||||
LL | x.0 = 1;
|
LL | x.0 = 1;
|
||||||
| ^^^^^^^ use of possibly uninitialized `x`
|
| ^^^^^^^ use of possibly-uninitialized `x`
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
@ -2,5 +2,5 @@ fn main() {
|
|||||||
let i: isize;
|
let i: isize;
|
||||||
|
|
||||||
println!("{}", false && { i = 5; true });
|
println!("{}", false && { i = 5; true });
|
||||||
println!("{}", i); //~ ERROR borrow of possibly uninitialized variable: `i`
|
println!("{}", i); //~ ERROR borrow of possibly-uninitialized variable: `i`
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
error[E0381]: borrow of possibly uninitialized variable: `i`
|
error[E0381]: borrow of possibly-uninitialized variable: `i`
|
||||||
--> $DIR/borrowck-and-init.rs:5:20
|
--> $DIR/borrowck-and-init.rs:5:20
|
||||||
|
|
|
|
||||||
LL | println!("{}", i);
|
LL | println!("{}", i);
|
||||||
| ^ use of possibly uninitialized `i`
|
| ^ use of possibly-uninitialized `i`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ mod test_cases {
|
|||||||
fn indirect_is_not_init() {
|
fn indirect_is_not_init() {
|
||||||
let x: i32;
|
let x: i32;
|
||||||
unsafe {
|
unsafe {
|
||||||
asm!("nop" : "=*r"(x)); //~ ERROR use of possibly uninitialized variable
|
asm!("nop" : "=*r"(x)); //~ ERROR use of possibly-uninitialized variable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,11 +46,11 @@ LL | unsafe {
|
|||||||
LL | asm!("nop" : "+r"(x));
|
LL | asm!("nop" : "+r"(x));
|
||||||
| ^ cannot assign twice to immutable variable
|
| ^ cannot assign twice to immutable variable
|
||||||
|
|
||||||
error[E0381]: use of possibly uninitialized variable: `x`
|
error[E0381]: use of possibly-uninitialized variable: `x`
|
||||||
--> $DIR/borrowck-asm.rs:60:32
|
--> $DIR/borrowck-asm.rs:60:32
|
||||||
|
|
|
|
||||||
LL | asm!("nop" : "=*r"(x));
|
LL | asm!("nop" : "=*r"(x));
|
||||||
| ^ use of possibly uninitialized `x`
|
| ^ use of possibly-uninitialized `x`
|
||||||
|
|
||||||
error[E0506]: cannot assign to `x` because it is borrowed
|
error[E0506]: cannot assign to `x` because it is borrowed
|
||||||
--> $DIR/borrowck-asm.rs:68:31
|
--> $DIR/borrowck-asm.rs:68:31
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
fn force<F>(f: F) where F: FnOnce() { f(); }
|
fn force<F>(f: F) where F: FnOnce() { f(); }
|
||||||
fn main() {
|
fn main() {
|
||||||
let x: isize;
|
let x: isize;
|
||||||
force(|| { //~ ERROR borrow of possibly uninitialized variable: `x`
|
force(|| { //~ ERROR borrow of possibly-uninitialized variable: `x`
|
||||||
println!("{}", x);
|
println!("{}", x);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
error[E0381]: borrow of possibly uninitialized variable: `x`
|
error[E0381]: borrow of possibly-uninitialized variable: `x`
|
||||||
--> $DIR/borrowck-block-unint.rs:4:11
|
--> $DIR/borrowck-block-unint.rs:4:11
|
||||||
|
|
|
|
||||||
LL | force(|| {
|
LL | force(|| {
|
||||||
| ^^ use of possibly uninitialized `x`
|
| ^^ use of possibly-uninitialized `x`
|
||||||
LL | println!("{}", x);
|
LL | println!("{}", x);
|
||||||
| - borrow occurs due to use in closure
|
| - borrow occurs due to use in closure
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ fn foo() -> isize {
|
|||||||
x = 0;
|
x = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("{}", x); //~ ERROR borrow of possibly uninitialized variable: `x`
|
println!("{}", x); //~ ERROR borrow of possibly-uninitialized variable: `x`
|
||||||
|
|
||||||
return 17;
|
return 17;
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
error[E0381]: borrow of possibly uninitialized variable: `x`
|
error[E0381]: borrow of possibly-uninitialized variable: `x`
|
||||||
--> $DIR/borrowck-break-uninit-2.rs:9:20
|
--> $DIR/borrowck-break-uninit-2.rs:9:20
|
||||||
|
|
|
|
||||||
LL | println!("{}", x);
|
LL | println!("{}", x);
|
||||||
| ^ use of possibly uninitialized `x`
|
| ^ use of possibly-uninitialized `x`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ fn foo() -> isize {
|
|||||||
x = 0;
|
x = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("{}", x); //~ ERROR borrow of possibly uninitialized variable: `x`
|
println!("{}", x); //~ ERROR borrow of possibly-uninitialized variable: `x`
|
||||||
|
|
||||||
return 17;
|
return 17;
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
error[E0381]: borrow of possibly uninitialized variable: `x`
|
error[E0381]: borrow of possibly-uninitialized variable: `x`
|
||||||
--> $DIR/borrowck-break-uninit.rs:9:20
|
--> $DIR/borrowck-break-uninit.rs:9:20
|
||||||
|
|
|
|
||||||
LL | println!("{}", x);
|
LL | println!("{}", x);
|
||||||
| ^ use of possibly uninitialized `x`
|
| ^ use of possibly-uninitialized `x`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
@ -78,20 +78,20 @@ fn fu_move_after_fu_move() {
|
|||||||
|
|
||||||
fn copy_after_field_assign_after_uninit() {
|
fn copy_after_field_assign_after_uninit() {
|
||||||
let mut x: A;
|
let mut x: A;
|
||||||
x.a = 1; //~ ERROR assign to part of possibly uninitialized variable: `x`
|
x.a = 1; //~ ERROR assign to part of possibly-uninitialized variable: `x`
|
||||||
drop(x.a);
|
drop(x.a);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn borrow_after_field_assign_after_uninit() {
|
fn borrow_after_field_assign_after_uninit() {
|
||||||
let mut x: A;
|
let mut x: A;
|
||||||
x.a = 1; //~ ERROR assign to part of possibly uninitialized variable: `x`
|
x.a = 1; //~ ERROR assign to part of possibly-uninitialized variable: `x`
|
||||||
let p = &x.a;
|
let p = &x.a;
|
||||||
drop(*p);
|
drop(*p);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn move_after_field_assign_after_uninit() {
|
fn move_after_field_assign_after_uninit() {
|
||||||
let mut x: A;
|
let mut x: A;
|
||||||
x.b = box 1; //~ ERROR assign to part of possibly uninitialized variable: `x`
|
x.b = box 1; //~ ERROR assign to part of possibly-uninitialized variable: `x`
|
||||||
drop(x.b);
|
drop(x.b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,23 +108,23 @@ LL | let _z = A { a: 4, .. x };
|
|||||||
|
|
|
|
||||||
= note: move occurs because `x.b` has type `std::boxed::Box<isize>`, which does not implement the `Copy` trait
|
= note: move occurs because `x.b` has type `std::boxed::Box<isize>`, which does not implement the `Copy` trait
|
||||||
|
|
||||||
error[E0381]: assign to part of possibly uninitialized variable: `x`
|
error[E0381]: assign to part of possibly-uninitialized variable: `x`
|
||||||
--> $DIR/borrowck-field-sensitivity.rs:81:5
|
--> $DIR/borrowck-field-sensitivity.rs:81:5
|
||||||
|
|
|
|
||||||
LL | x.a = 1;
|
LL | x.a = 1;
|
||||||
| ^^^^^^^ use of possibly uninitialized `x`
|
| ^^^^^^^ use of possibly-uninitialized `x`
|
||||||
|
|
||||||
error[E0381]: assign to part of possibly uninitialized variable: `x`
|
error[E0381]: assign to part of possibly-uninitialized variable: `x`
|
||||||
--> $DIR/borrowck-field-sensitivity.rs:87:5
|
--> $DIR/borrowck-field-sensitivity.rs:87:5
|
||||||
|
|
|
|
||||||
LL | x.a = 1;
|
LL | x.a = 1;
|
||||||
| ^^^^^^^ use of possibly uninitialized `x`
|
| ^^^^^^^ use of possibly-uninitialized `x`
|
||||||
|
|
||||||
error[E0381]: assign to part of possibly uninitialized variable: `x`
|
error[E0381]: assign to part of possibly-uninitialized variable: `x`
|
||||||
--> $DIR/borrowck-field-sensitivity.rs:94:5
|
--> $DIR/borrowck-field-sensitivity.rs:94:5
|
||||||
|
|
|
|
||||||
LL | x.b = box 1;
|
LL | x.b = box 1;
|
||||||
| ^^^ use of possibly uninitialized `x`
|
| ^^^ use of possibly-uninitialized `x`
|
||||||
|
|
||||||
error: aborting due to 14 previous errors
|
error: aborting due to 14 previous errors
|
||||||
|
|
||||||
|
@ -2,5 +2,5 @@ fn foo(x: isize) { println!("{}", x); }
|
|||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let x: isize; if 1 > 2 { x = 10; }
|
let x: isize; if 1 > 2 { x = 10; }
|
||||||
foo(x); //~ ERROR use of possibly uninitialized variable: `x`
|
foo(x); //~ ERROR use of possibly-uninitialized variable: `x`
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
error[E0381]: use of possibly uninitialized variable: `x`
|
error[E0381]: use of possibly-uninitialized variable: `x`
|
||||||
--> $DIR/borrowck-if-no-else.rs:5:9
|
--> $DIR/borrowck-if-no-else.rs:5:9
|
||||||
|
|
|
|
||||||
LL | foo(x);
|
LL | foo(x);
|
||||||
| ^ use of possibly uninitialized `x`
|
| ^ use of possibly-uninitialized `x`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
@ -7,5 +7,5 @@ fn main() {
|
|||||||
} else {
|
} else {
|
||||||
x = 10;
|
x = 10;
|
||||||
}
|
}
|
||||||
foo(x); //~ ERROR use of possibly uninitialized variable: `x`
|
foo(x); //~ ERROR use of possibly-uninitialized variable: `x`
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
error[E0381]: use of possibly uninitialized variable: `x`
|
error[E0381]: use of possibly-uninitialized variable: `x`
|
||||||
--> $DIR/borrowck-if-with-else.rs:10:9
|
--> $DIR/borrowck-if-with-else.rs:10:9
|
||||||
|
|
|
|
||||||
LL | foo(x);
|
LL | foo(x);
|
||||||
| ^ use of possibly uninitialized `x`
|
| ^ use of possibly-uninitialized `x`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
fn main() {
|
fn main() {
|
||||||
let j = || -> isize {
|
let j = || -> isize {
|
||||||
let i: isize;
|
let i: isize;
|
||||||
i //~ ERROR use of possibly uninitialized variable: `i`
|
i //~ ERROR use of possibly-uninitialized variable: `i`
|
||||||
};
|
};
|
||||||
j();
|
j();
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
error[E0381]: use of possibly uninitialized variable: `i`
|
error[E0381]: use of possibly-uninitialized variable: `i`
|
||||||
--> $DIR/borrowck-init-in-called-fn-expr.rs:4:9
|
--> $DIR/borrowck-init-in-called-fn-expr.rs:4:9
|
||||||
|
|
|
|
||||||
LL | i
|
LL | i
|
||||||
| ^ use of possibly uninitialized `i`
|
| ^ use of possibly-uninitialized `i`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
fn main() {
|
fn main() {
|
||||||
let f = || -> isize {
|
let f = || -> isize {
|
||||||
let i: isize;
|
let i: isize;
|
||||||
i //~ ERROR use of possibly uninitialized variable: `i`
|
i //~ ERROR use of possibly-uninitialized variable: `i`
|
||||||
};
|
};
|
||||||
println!("{}", f());
|
println!("{}", f());
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
error[E0381]: use of possibly uninitialized variable: `i`
|
error[E0381]: use of possibly-uninitialized variable: `i`
|
||||||
--> $DIR/borrowck-init-in-fn-expr.rs:4:9
|
--> $DIR/borrowck-init-in-fn-expr.rs:4:9
|
||||||
|
|
|
|
||||||
LL | i
|
LL | i
|
||||||
| ^ use of possibly uninitialized `i`
|
| ^ use of possibly-uninitialized `i`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
@ -7,6 +7,6 @@ struct Point {
|
|||||||
fn main() {
|
fn main() {
|
||||||
let mut origin: Point;
|
let mut origin: Point;
|
||||||
origin = Point { x: 10, ..origin };
|
origin = Point { x: 10, ..origin };
|
||||||
//~^ ERROR use of possibly uninitialized variable: `origin` [E0381]
|
//~^ ERROR use of possibly-uninitialized variable: `origin` [E0381]
|
||||||
origin.clone();
|
origin.clone();
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
error[E0381]: use of possibly uninitialized variable: `origin`
|
error[E0381]: use of possibly-uninitialized variable: `origin`
|
||||||
--> $DIR/borrowck-init-in-fru.rs:9:5
|
--> $DIR/borrowck-init-in-fru.rs:9:5
|
||||||
|
|
|
|
||||||
LL | origin = Point { x: 10, ..origin };
|
LL | origin = Point { x: 10, ..origin };
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ use of possibly uninitialized `origin.y`
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ use of possibly-uninitialized `origin.y`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
fn test() {
|
fn test() {
|
||||||
let v: isize;
|
let v: isize;
|
||||||
v += 1; //~ ERROR use of possibly uninitialized variable: `v`
|
v += 1; //~ ERROR use of possibly-uninitialized variable: `v`
|
||||||
v.clone();
|
v.clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
error[E0381]: use of possibly uninitialized variable: `v`
|
error[E0381]: use of possibly-uninitialized variable: `v`
|
||||||
--> $DIR/borrowck-init-op-equal.rs:3:5
|
--> $DIR/borrowck-init-op-equal.rs:3:5
|
||||||
|
|
|
|
||||||
LL | v += 1;
|
LL | v += 1;
|
||||||
| ^^^^^^ use of possibly uninitialized `v`
|
| ^^^^^^ use of possibly-uninitialized `v`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
fn test() {
|
fn test() {
|
||||||
let mut v: isize;
|
let mut v: isize;
|
||||||
v = v + 1; //~ ERROR use of possibly uninitialized variable: `v`
|
v = v + 1; //~ ERROR use of possibly-uninitialized variable: `v`
|
||||||
v.clone();
|
v.clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
error[E0381]: use of possibly uninitialized variable: `v`
|
error[E0381]: use of possibly-uninitialized variable: `v`
|
||||||
--> $DIR/borrowck-init-plus-equal.rs:3:9
|
--> $DIR/borrowck-init-plus-equal.rs:3:9
|
||||||
|
|
|
|
||||||
LL | v = v + 1;
|
LL | v = v + 1;
|
||||||
| ^ use of possibly uninitialized `v`
|
| ^ use of possibly-uninitialized `v`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
@ -1,15 +1,14 @@
|
|||||||
warning[E0502]: cannot borrow `*block.current` as immutable because it is also borrowed as mutable
|
error[E0502]: cannot borrow `*block.current` as immutable because it is also borrowed as mutable
|
||||||
--> $DIR/borrowck-migrate-to-nll.rs:28:21
|
--> $DIR/borrowck-migrate-to-nll.rs:29:21
|
||||||
|
|
|
|
||||||
LL | let x = &mut block;
|
LL | let x = &mut block;
|
||||||
| ---------- mutable borrow occurs here
|
| ---------- mutable borrow occurs here
|
||||||
LL | let p: &'a u8 = &*block.current;
|
LL | let p: &'a u8 = &*block.current;
|
||||||
| ^^^^^^^^^^^^^^^ immutable borrow occurs here
|
| ^^^^^^^^^^^^^^^ immutable borrow occurs here
|
||||||
LL | // (use `x` and `p` so enabling NLL doesn't assign overly short lifetimes)
|
...
|
||||||
LL | drop(x);
|
LL | drop(x);
|
||||||
| - mutable borrow later used here
|
| - mutable borrow later used here
|
||||||
|
|
|
||||||
= warning: this error has been downgraded to a warning for backwards compatibility with previous releases
|
|
||||||
= warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future
|
|
||||||
= note: for more information, try `rustc --explain E0729`
|
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0502`.
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
//
|
//
|
||||||
// Therefore, for backwards-compatiblity, under borrowck=migrate the
|
// Therefore, for backwards-compatiblity, under borrowck=migrate the
|
||||||
// NLL checks will be emitted as *warnings*.
|
// NLL checks will be emitted as *warnings*.
|
||||||
|
//
|
||||||
|
// In Rust 2018, no errors will be downgraded to warnings.
|
||||||
|
|
||||||
// NLL mode makes this compile-fail; we cannot currently encode a
|
// NLL mode makes this compile-fail; we cannot currently encode a
|
||||||
// test that is run-pass or compile-fail based on compare-mode. So
|
// test that is run-pass or compile-fail based on compare-mode. So
|
||||||
@ -16,7 +18,6 @@
|
|||||||
//[zflag]compile-flags: -Z borrowck=migrate
|
//[zflag]compile-flags: -Z borrowck=migrate
|
||||||
//[edition]edition:2018
|
//[edition]edition:2018
|
||||||
//[zflag] run-pass
|
//[zflag] run-pass
|
||||||
//[edition] run-pass
|
|
||||||
|
|
||||||
pub struct Block<'a> {
|
pub struct Block<'a> {
|
||||||
current: &'a u8,
|
current: &'a u8,
|
||||||
@ -26,6 +27,7 @@ pub struct Block<'a> {
|
|||||||
fn bump<'a>(mut block: &mut Block<'a>) {
|
fn bump<'a>(mut block: &mut Block<'a>) {
|
||||||
let x = &mut block;
|
let x = &mut block;
|
||||||
let p: &'a u8 = &*block.current;
|
let p: &'a u8 = &*block.current;
|
||||||
|
//[edition]~^ ERROR cannot borrow `*block.current` as immutable
|
||||||
// (use `x` and `p` so enabling NLL doesn't assign overly short lifetimes)
|
// (use `x` and `p` so enabling NLL doesn't assign overly short lifetimes)
|
||||||
drop(x);
|
drop(x);
|
||||||
drop(p);
|
drop(p);
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
warning[E0502]: cannot borrow `*block.current` as immutable because it is also borrowed as mutable
|
warning[E0502]: cannot borrow `*block.current` as immutable because it is also borrowed as mutable
|
||||||
--> $DIR/borrowck-migrate-to-nll.rs:28:21
|
--> $DIR/borrowck-migrate-to-nll.rs:29:21
|
||||||
|
|
|
|
||||||
LL | let x = &mut block;
|
LL | let x = &mut block;
|
||||||
| ---------- mutable borrow occurs here
|
| ---------- mutable borrow occurs here
|
||||||
LL | let p: &'a u8 = &*block.current;
|
LL | let p: &'a u8 = &*block.current;
|
||||||
| ^^^^^^^^^^^^^^^ immutable borrow occurs here
|
| ^^^^^^^^^^^^^^^ immutable borrow occurs here
|
||||||
LL | // (use `x` and `p` so enabling NLL doesn't assign overly short lifetimes)
|
...
|
||||||
LL | drop(x);
|
LL | drop(x);
|
||||||
| - mutable borrow later used here
|
| - mutable borrow later used here
|
||||||
|
|
|
|
||||||
|
@ -2,5 +2,5 @@ fn main() {
|
|||||||
let i: isize;
|
let i: isize;
|
||||||
|
|
||||||
println!("{}", false || { i = 5; true });
|
println!("{}", false || { i = 5; true });
|
||||||
println!("{}", i); //~ ERROR borrow of possibly uninitialized variable: `i`
|
println!("{}", i); //~ ERROR borrow of possibly-uninitialized variable: `i`
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
error[E0381]: borrow of possibly uninitialized variable: `i`
|
error[E0381]: borrow of possibly-uninitialized variable: `i`
|
||||||
--> $DIR/borrowck-or-init.rs:5:20
|
--> $DIR/borrowck-or-init.rs:5:20
|
||||||
|
|
|
|
||||||
LL | println!("{}", i);
|
LL | println!("{}", i);
|
||||||
| ^ use of possibly uninitialized `i`
|
| ^ use of possibly-uninitialized `i`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ impl Drop for Test2 {
|
|||||||
fn stuff() {
|
fn stuff() {
|
||||||
let mut x : (Test2, Test2);
|
let mut x : (Test2, Test2);
|
||||||
(x.0).0 = Some(Test);
|
(x.0).0 = Some(Test);
|
||||||
//~^ ERROR assign of possibly uninitialized variable: `x.0`
|
//~^ ERROR assign of possibly-uninitialized variable: `x.0`
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
error[E0381]: assign of possibly uninitialized variable: `x.0`
|
error[E0381]: assign of possibly-uninitialized variable: `x.0`
|
||||||
--> $DIR/borrowck-partial-reinit-4.rs:17:5
|
--> $DIR/borrowck-partial-reinit-4.rs:17:5
|
||||||
|
|
|
|
||||||
LL | (x.0).0 = Some(Test);
|
LL | (x.0).0 = Some(Test);
|
||||||
| ^^^^^^^ use of possibly uninitialized `x.0`
|
| ^^^^^^^ use of possibly-uninitialized `x.0`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
fn f() -> isize {
|
fn f() -> isize {
|
||||||
let x: isize;
|
let x: isize;
|
||||||
return x; //~ ERROR use of possibly uninitialized variable: `x`
|
return x; //~ ERROR use of possibly-uninitialized variable: `x`
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() { f(); }
|
fn main() { f(); }
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
error[E0381]: use of possibly uninitialized variable: `x`
|
error[E0381]: use of possibly-uninitialized variable: `x`
|
||||||
--> $DIR/borrowck-return.rs:3:12
|
--> $DIR/borrowck-return.rs:3:12
|
||||||
|
|
|
|
||||||
LL | return x;
|
LL | return x;
|
||||||
| ^ use of possibly uninitialized `x`
|
| ^ use of possibly-uninitialized `x`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
error[E0381]: use of possibly uninitialized variable: `x`
|
error[E0381]: use of possibly-uninitialized variable: `x`
|
||||||
--> $DIR/borrowck-storage-dead.rs:16:17
|
--> $DIR/borrowck-storage-dead.rs:16:17
|
||||||
|
|
|
|
||||||
LL | let _ = x + 1;
|
LL | let _ = x + 1;
|
||||||
| ^ use of possibly uninitialized `x`
|
| ^ use of possibly-uninitialized `x`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
fn main() {
|
fn main() {
|
||||||
let bar;
|
let bar;
|
||||||
fn baz(_x: isize) { }
|
fn baz(_x: isize) { }
|
||||||
baz(bar); //~ ERROR use of possibly uninitialized variable: `bar`
|
baz(bar); //~ ERROR use of possibly-uninitialized variable: `bar`
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
error[E0381]: use of possibly uninitialized variable: `bar`
|
error[E0381]: use of possibly-uninitialized variable: `bar`
|
||||||
--> $DIR/borrowck-uninit-after-item.rs:4:9
|
--> $DIR/borrowck-uninit-after-item.rs:4:9
|
||||||
|
|
|
|
||||||
LL | baz(bar);
|
LL | baz(bar);
|
||||||
| ^^^ use of possibly uninitialized `bar`
|
| ^^^ use of possibly-uninitialized `bar`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
error[E0381]: use of possibly uninitialized variable: `a`
|
error[E0381]: use of possibly-uninitialized variable: `a`
|
||||||
--> $DIR/borrowck-uninit-field-access.rs:21:13
|
--> $DIR/borrowck-uninit-field-access.rs:21:13
|
||||||
|
|
|
|
||||||
LL | let _ = a.x + 1;
|
LL | let _ = a.x + 1;
|
||||||
| ^^^ use of possibly uninitialized `a.x`
|
| ^^^ use of possibly-uninitialized `a.x`
|
||||||
|
|
||||||
error[E0382]: use of moved value: `line1.origin`
|
error[E0382]: use of moved value: `line1.origin`
|
||||||
--> $DIR/borrowck-uninit-field-access.rs:25:13
|
--> $DIR/borrowck-uninit-field-access.rs:25:13
|
||||||
|
@ -3,32 +3,32 @@
|
|||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
let x: isize;
|
let x: isize;
|
||||||
x += 1; //~ ERROR use of possibly uninitialized variable: `x`
|
x += 1; //~ ERROR use of possibly-uninitialized variable: `x`
|
||||||
|
|
||||||
let x: isize;
|
let x: isize;
|
||||||
x -= 1; //~ ERROR use of possibly uninitialized variable: `x`
|
x -= 1; //~ ERROR use of possibly-uninitialized variable: `x`
|
||||||
|
|
||||||
let x: isize;
|
let x: isize;
|
||||||
x *= 1; //~ ERROR use of possibly uninitialized variable: `x`
|
x *= 1; //~ ERROR use of possibly-uninitialized variable: `x`
|
||||||
|
|
||||||
let x: isize;
|
let x: isize;
|
||||||
x /= 1; //~ ERROR use of possibly uninitialized variable: `x`
|
x /= 1; //~ ERROR use of possibly-uninitialized variable: `x`
|
||||||
|
|
||||||
let x: isize;
|
let x: isize;
|
||||||
x %= 1; //~ ERROR use of possibly uninitialized variable: `x`
|
x %= 1; //~ ERROR use of possibly-uninitialized variable: `x`
|
||||||
|
|
||||||
let x: isize;
|
let x: isize;
|
||||||
x ^= 1; //~ ERROR use of possibly uninitialized variable: `x`
|
x ^= 1; //~ ERROR use of possibly-uninitialized variable: `x`
|
||||||
|
|
||||||
let x: isize;
|
let x: isize;
|
||||||
x &= 1; //~ ERROR use of possibly uninitialized variable: `x`
|
x &= 1; //~ ERROR use of possibly-uninitialized variable: `x`
|
||||||
|
|
||||||
let x: isize;
|
let x: isize;
|
||||||
x |= 1; //~ ERROR use of possibly uninitialized variable: `x`
|
x |= 1; //~ ERROR use of possibly-uninitialized variable: `x`
|
||||||
|
|
||||||
let x: isize;
|
let x: isize;
|
||||||
x <<= 1; //~ ERROR use of possibly uninitialized variable: `x`
|
x <<= 1; //~ ERROR use of possibly-uninitialized variable: `x`
|
||||||
|
|
||||||
let x: isize;
|
let x: isize;
|
||||||
x >>= 1; //~ ERROR use of possibly uninitialized variable: `x`
|
x >>= 1; //~ ERROR use of possibly-uninitialized variable: `x`
|
||||||
}
|
}
|
||||||
|
@ -1,62 +1,62 @@
|
|||||||
error[E0381]: use of possibly uninitialized variable: `x`
|
error[E0381]: use of possibly-uninitialized variable: `x`
|
||||||
--> $DIR/borrowck-uninit-in-assignop.rs:6:5
|
--> $DIR/borrowck-uninit-in-assignop.rs:6:5
|
||||||
|
|
|
|
||||||
LL | x += 1;
|
LL | x += 1;
|
||||||
| ^^^^^^ use of possibly uninitialized `x`
|
| ^^^^^^ use of possibly-uninitialized `x`
|
||||||
|
|
||||||
error[E0381]: use of possibly uninitialized variable: `x`
|
error[E0381]: use of possibly-uninitialized variable: `x`
|
||||||
--> $DIR/borrowck-uninit-in-assignop.rs:9:5
|
--> $DIR/borrowck-uninit-in-assignop.rs:9:5
|
||||||
|
|
|
|
||||||
LL | x -= 1;
|
LL | x -= 1;
|
||||||
| ^^^^^^ use of possibly uninitialized `x`
|
| ^^^^^^ use of possibly-uninitialized `x`
|
||||||
|
|
||||||
error[E0381]: use of possibly uninitialized variable: `x`
|
error[E0381]: use of possibly-uninitialized variable: `x`
|
||||||
--> $DIR/borrowck-uninit-in-assignop.rs:12:5
|
--> $DIR/borrowck-uninit-in-assignop.rs:12:5
|
||||||
|
|
|
|
||||||
LL | x *= 1;
|
LL | x *= 1;
|
||||||
| ^^^^^^ use of possibly uninitialized `x`
|
| ^^^^^^ use of possibly-uninitialized `x`
|
||||||
|
|
||||||
error[E0381]: use of possibly uninitialized variable: `x`
|
error[E0381]: use of possibly-uninitialized variable: `x`
|
||||||
--> $DIR/borrowck-uninit-in-assignop.rs:15:5
|
--> $DIR/borrowck-uninit-in-assignop.rs:15:5
|
||||||
|
|
|
|
||||||
LL | x /= 1;
|
LL | x /= 1;
|
||||||
| ^^^^^^ use of possibly uninitialized `x`
|
| ^^^^^^ use of possibly-uninitialized `x`
|
||||||
|
|
||||||
error[E0381]: use of possibly uninitialized variable: `x`
|
error[E0381]: use of possibly-uninitialized variable: `x`
|
||||||
--> $DIR/borrowck-uninit-in-assignop.rs:18:5
|
--> $DIR/borrowck-uninit-in-assignop.rs:18:5
|
||||||
|
|
|
|
||||||
LL | x %= 1;
|
LL | x %= 1;
|
||||||
| ^^^^^^ use of possibly uninitialized `x`
|
| ^^^^^^ use of possibly-uninitialized `x`
|
||||||
|
|
||||||
error[E0381]: use of possibly uninitialized variable: `x`
|
error[E0381]: use of possibly-uninitialized variable: `x`
|
||||||
--> $DIR/borrowck-uninit-in-assignop.rs:21:5
|
--> $DIR/borrowck-uninit-in-assignop.rs:21:5
|
||||||
|
|
|
|
||||||
LL | x ^= 1;
|
LL | x ^= 1;
|
||||||
| ^^^^^^ use of possibly uninitialized `x`
|
| ^^^^^^ use of possibly-uninitialized `x`
|
||||||
|
|
||||||
error[E0381]: use of possibly uninitialized variable: `x`
|
error[E0381]: use of possibly-uninitialized variable: `x`
|
||||||
--> $DIR/borrowck-uninit-in-assignop.rs:24:5
|
--> $DIR/borrowck-uninit-in-assignop.rs:24:5
|
||||||
|
|
|
|
||||||
LL | x &= 1;
|
LL | x &= 1;
|
||||||
| ^^^^^^ use of possibly uninitialized `x`
|
| ^^^^^^ use of possibly-uninitialized `x`
|
||||||
|
|
||||||
error[E0381]: use of possibly uninitialized variable: `x`
|
error[E0381]: use of possibly-uninitialized variable: `x`
|
||||||
--> $DIR/borrowck-uninit-in-assignop.rs:27:5
|
--> $DIR/borrowck-uninit-in-assignop.rs:27:5
|
||||||
|
|
|
|
||||||
LL | x |= 1;
|
LL | x |= 1;
|
||||||
| ^^^^^^ use of possibly uninitialized `x`
|
| ^^^^^^ use of possibly-uninitialized `x`
|
||||||
|
|
||||||
error[E0381]: use of possibly uninitialized variable: `x`
|
error[E0381]: use of possibly-uninitialized variable: `x`
|
||||||
--> $DIR/borrowck-uninit-in-assignop.rs:30:5
|
--> $DIR/borrowck-uninit-in-assignop.rs:30:5
|
||||||
|
|
|
|
||||||
LL | x <<= 1;
|
LL | x <<= 1;
|
||||||
| ^^^^^^^ use of possibly uninitialized `x`
|
| ^^^^^^^ use of possibly-uninitialized `x`
|
||||||
|
|
||||||
error[E0381]: use of possibly uninitialized variable: `x`
|
error[E0381]: use of possibly-uninitialized variable: `x`
|
||||||
--> $DIR/borrowck-uninit-in-assignop.rs:33:5
|
--> $DIR/borrowck-uninit-in-assignop.rs:33:5
|
||||||
|
|
|
|
||||||
LL | x >>= 1;
|
LL | x >>= 1;
|
||||||
| ^^^^^^^ use of possibly uninitialized `x`
|
| ^^^^^^^ use of possibly-uninitialized `x`
|
||||||
|
|
||||||
error: aborting due to 10 previous errors
|
error: aborting due to 10 previous errors
|
||||||
|
|
||||||
|
@ -15,19 +15,19 @@ fn main() {
|
|||||||
|
|
||||||
|
|
||||||
let mut a: S<i32, i32>;
|
let mut a: S<i32, i32>;
|
||||||
a.x = 0; //~ ERROR assign to part of possibly uninitialized variable: `a` [E0381]
|
a.x = 0; //~ ERROR assign to part of possibly-uninitialized variable: `a` [E0381]
|
||||||
let _b = &a.x;
|
let _b = &a.x;
|
||||||
|
|
||||||
let mut a: S<&&i32, &&i32>;
|
let mut a: S<&&i32, &&i32>;
|
||||||
a.x = &&0; //~ ERROR assign to part of possibly uninitialized variable: `a` [E0381]
|
a.x = &&0; //~ ERROR assign to part of possibly-uninitialized variable: `a` [E0381]
|
||||||
let _b = &**a.x;
|
let _b = &**a.x;
|
||||||
|
|
||||||
|
|
||||||
let mut a: S<i32, i32>;
|
let mut a: S<i32, i32>;
|
||||||
a.x = 0; //~ ERROR assign to part of possibly uninitialized variable: `a` [E0381]
|
a.x = 0; //~ ERROR assign to part of possibly-uninitialized variable: `a` [E0381]
|
||||||
let _b = &a.y;
|
let _b = &a.y;
|
||||||
|
|
||||||
let mut a: S<&&i32, &&i32>;
|
let mut a: S<&&i32, &&i32>;
|
||||||
a.x = &&0; //~ assign to part of possibly uninitialized variable: `a` [E0381]
|
a.x = &&0; //~ assign to part of possibly-uninitialized variable: `a` [E0381]
|
||||||
let _b = &**a.y;
|
let _b = &**a.y;
|
||||||
}
|
}
|
||||||
|
@ -1,44 +1,44 @@
|
|||||||
error[E0381]: borrow of possibly uninitialized variable: `x`
|
error[E0381]: borrow of possibly-uninitialized variable: `x`
|
||||||
--> $DIR/borrowck-uninit-ref-chain.rs:8:14
|
--> $DIR/borrowck-uninit-ref-chain.rs:8:14
|
||||||
|
|
|
|
||||||
LL | let _y = &**x;
|
LL | let _y = &**x;
|
||||||
| ^^^^ use of possibly uninitialized `**x`
|
| ^^^^ use of possibly-uninitialized `**x`
|
||||||
|
|
||||||
error[E0381]: borrow of possibly uninitialized variable: `x`
|
error[E0381]: borrow of possibly-uninitialized variable: `x`
|
||||||
--> $DIR/borrowck-uninit-ref-chain.rs:11:14
|
--> $DIR/borrowck-uninit-ref-chain.rs:11:14
|
||||||
|
|
|
|
||||||
LL | let _y = &**x;
|
LL | let _y = &**x;
|
||||||
| ^^^^ use of possibly uninitialized `**x`
|
| ^^^^ use of possibly-uninitialized `**x`
|
||||||
|
|
||||||
error[E0381]: borrow of possibly uninitialized variable: `x`
|
error[E0381]: borrow of possibly-uninitialized variable: `x`
|
||||||
--> $DIR/borrowck-uninit-ref-chain.rs:14:14
|
--> $DIR/borrowck-uninit-ref-chain.rs:14:14
|
||||||
|
|
|
|
||||||
LL | let _y = &**x;
|
LL | let _y = &**x;
|
||||||
| ^^^^ use of possibly uninitialized `**x`
|
| ^^^^ use of possibly-uninitialized `**x`
|
||||||
|
|
||||||
error[E0381]: assign to part of possibly uninitialized variable: `a`
|
error[E0381]: assign to part of possibly-uninitialized variable: `a`
|
||||||
--> $DIR/borrowck-uninit-ref-chain.rs:18:5
|
--> $DIR/borrowck-uninit-ref-chain.rs:18:5
|
||||||
|
|
|
|
||||||
LL | a.x = 0;
|
LL | a.x = 0;
|
||||||
| ^^^^^^^ use of possibly uninitialized `a`
|
| ^^^^^^^ use of possibly-uninitialized `a`
|
||||||
|
|
||||||
error[E0381]: assign to part of possibly uninitialized variable: `a`
|
error[E0381]: assign to part of possibly-uninitialized variable: `a`
|
||||||
--> $DIR/borrowck-uninit-ref-chain.rs:22:5
|
--> $DIR/borrowck-uninit-ref-chain.rs:22:5
|
||||||
|
|
|
|
||||||
LL | a.x = &&0;
|
LL | a.x = &&0;
|
||||||
| ^^^^^^^^^ use of possibly uninitialized `a`
|
| ^^^^^^^^^ use of possibly-uninitialized `a`
|
||||||
|
|
||||||
error[E0381]: assign to part of possibly uninitialized variable: `a`
|
error[E0381]: assign to part of possibly-uninitialized variable: `a`
|
||||||
--> $DIR/borrowck-uninit-ref-chain.rs:27:5
|
--> $DIR/borrowck-uninit-ref-chain.rs:27:5
|
||||||
|
|
|
|
||||||
LL | a.x = 0;
|
LL | a.x = 0;
|
||||||
| ^^^^^^^ use of possibly uninitialized `a`
|
| ^^^^^^^ use of possibly-uninitialized `a`
|
||||||
|
|
||||||
error[E0381]: assign to part of possibly uninitialized variable: `a`
|
error[E0381]: assign to part of possibly-uninitialized variable: `a`
|
||||||
--> $DIR/borrowck-uninit-ref-chain.rs:31:5
|
--> $DIR/borrowck-uninit-ref-chain.rs:31:5
|
||||||
|
|
|
|
||||||
LL | a.x = &&0;
|
LL | a.x = &&0;
|
||||||
| ^^^^^^^^^ use of possibly uninitialized `a`
|
| ^^^^^^^^^ use of possibly-uninitialized `a`
|
||||||
|
|
||||||
error: aborting due to 7 previous errors
|
error: aborting due to 7 previous errors
|
||||||
|
|
||||||
|
@ -2,5 +2,5 @@ fn foo(x: isize) { println!("{}", x); }
|
|||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let x: isize;
|
let x: isize;
|
||||||
foo(x); //~ ERROR use of possibly uninitialized variable: `x`
|
foo(x); //~ ERROR use of possibly-uninitialized variable: `x`
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
error[E0381]: use of possibly uninitialized variable: `x`
|
error[E0381]: use of possibly-uninitialized variable: `x`
|
||||||
--> $DIR/borrowck-uninit.rs:5:9
|
--> $DIR/borrowck-uninit.rs:5:9
|
||||||
|
|
|
|
||||||
LL | foo(x);
|
LL | foo(x);
|
||||||
| ^ use of possibly uninitialized `x`
|
| ^ use of possibly-uninitialized `x`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
@ -10,8 +10,8 @@ fn main() {
|
|||||||
unsafe {
|
unsafe {
|
||||||
let mut s: S;
|
let mut s: S;
|
||||||
let mut u: U;
|
let mut u: U;
|
||||||
s.a = 0; //~ ERROR assign to part of possibly uninitialized variable: `s`
|
s.a = 0; //~ ERROR assign to part of possibly-uninitialized variable: `s`
|
||||||
u.a = 0; //~ ERROR assign to part of possibly uninitialized variable: `u`
|
u.a = 0; //~ ERROR assign to part of possibly-uninitialized variable: `u`
|
||||||
let sa = s.a;
|
let sa = s.a;
|
||||||
let ua = u.a;
|
let ua = u.a;
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
error[E0381]: assign to part of possibly uninitialized variable: `s`
|
error[E0381]: assign to part of possibly-uninitialized variable: `s`
|
||||||
--> $DIR/borrowck-union-uninitialized.rs:13:9
|
--> $DIR/borrowck-union-uninitialized.rs:13:9
|
||||||
|
|
|
|
||||||
LL | s.a = 0;
|
LL | s.a = 0;
|
||||||
| ^^^^^^^ use of possibly uninitialized `s`
|
| ^^^^^^^ use of possibly-uninitialized `s`
|
||||||
|
|
||||||
error[E0381]: assign to part of possibly uninitialized variable: `u`
|
error[E0381]: assign to part of possibly-uninitialized variable: `u`
|
||||||
--> $DIR/borrowck-union-uninitialized.rs:14:9
|
--> $DIR/borrowck-union-uninitialized.rs:14:9
|
||||||
|
|
|
|
||||||
LL | u.a = 0;
|
LL | u.a = 0;
|
||||||
| ^^^^^^^ use of possibly uninitialized `u`
|
| ^^^^^^^ use of possibly-uninitialized `u`
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
error[E0381]: use of possibly uninitialized variable: `w`
|
error[E0381]: use of possibly-uninitialized variable: `w`
|
||||||
--> $DIR/borrowck-use-in-index-lvalue.rs:3:5
|
--> $DIR/borrowck-use-in-index-lvalue.rs:3:5
|
||||||
|
|
|
|
||||||
LL | w[5] = 0;
|
LL | w[5] = 0;
|
||||||
| ^^^^ use of possibly uninitialized `*w`
|
| ^^^^ use of possibly-uninitialized `*w`
|
||||||
|
|
||||||
error[E0381]: use of possibly uninitialized variable: `w`
|
error[E0381]: use of possibly-uninitialized variable: `w`
|
||||||
--> $DIR/borrowck-use-in-index-lvalue.rs:6:5
|
--> $DIR/borrowck-use-in-index-lvalue.rs:6:5
|
||||||
|
|
|
|
||||||
LL | w[5] = 0;
|
LL | w[5] = 0;
|
||||||
| ^^^^ use of possibly uninitialized `*w`
|
| ^^^^ use of possibly-uninitialized `*w`
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
error[E0381]: borrow of possibly uninitialized variable: `x`
|
error[E0381]: borrow of possibly-uninitialized variable: `x`
|
||||||
--> $DIR/borrowck-use-uninitialized-in-cast-trait.rs:9:13
|
--> $DIR/borrowck-use-uninitialized-in-cast-trait.rs:9:13
|
||||||
|
|
|
|
||||||
LL | let y = x as *const dyn Foo;
|
LL | let y = x as *const dyn Foo;
|
||||||
| ^ use of possibly uninitialized `*x`
|
| ^ use of possibly-uninitialized `*x`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
error[E0381]: borrow of possibly uninitialized variable: `x`
|
error[E0381]: borrow of possibly-uninitialized variable: `x`
|
||||||
--> $DIR/borrowck-use-uninitialized-in-cast.rs:7:13
|
--> $DIR/borrowck-use-uninitialized-in-cast.rs:7:13
|
||||||
|
|
|
|
||||||
LL | let y = x as *const i32;
|
LL | let y = x as *const i32;
|
||||||
| ^ use of possibly uninitialized `*x`
|
| ^ use of possibly-uninitialized `*x`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ fn test(cond: bool) {
|
|||||||
v = 3;
|
v = 3;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
println!("{}", v); //~ ERROR borrow of possibly uninitialized variable: `v`
|
println!("{}", v); //~ ERROR borrow of possibly-uninitialized variable: `v`
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
error[E0381]: borrow of possibly uninitialized variable: `v`
|
error[E0381]: borrow of possibly-uninitialized variable: `v`
|
||||||
--> $DIR/borrowck-while-break.rs:7:20
|
--> $DIR/borrowck-while-break.rs:7:20
|
||||||
|
|
|
|
||||||
LL | println!("{}", v);
|
LL | println!("{}", v);
|
||||||
| ^ use of possibly uninitialized `v`
|
| ^ use of possibly-uninitialized `v`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
fn main() {
|
fn main() {
|
||||||
let x: bool;
|
let x: bool;
|
||||||
while x { } //~ ERROR use of possibly uninitialized variable: `x`
|
while x { } //~ ERROR use of possibly-uninitialized variable: `x`
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
error[E0381]: use of possibly uninitialized variable: `x`
|
error[E0381]: use of possibly-uninitialized variable: `x`
|
||||||
--> $DIR/borrowck-while-cond.rs:3:11
|
--> $DIR/borrowck-while-cond.rs:3:11
|
||||||
|
|
|
|
||||||
LL | while x { }
|
LL | while x { }
|
||||||
| ^ use of possibly uninitialized `x`
|
| ^ use of possibly-uninitialized `x`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
fn f() -> isize {
|
fn f() -> isize {
|
||||||
let mut x: isize;
|
let mut x: isize;
|
||||||
while 1 == 1 { x = 10; }
|
while 1 == 1 { x = 10; }
|
||||||
return x; //~ ERROR use of possibly uninitialized variable: `x`
|
return x; //~ ERROR use of possibly-uninitialized variable: `x`
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() { f(); }
|
fn main() { f(); }
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
error[E0381]: use of possibly uninitialized variable: `x`
|
error[E0381]: use of possibly-uninitialized variable: `x`
|
||||||
--> $DIR/borrowck-while.rs:4:12
|
--> $DIR/borrowck-while.rs:4:12
|
||||||
|
|
|
|
||||||
LL | return x;
|
LL | return x;
|
||||||
| ^ use of possibly uninitialized `x`
|
| ^ use of possibly-uninitialized `x`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
@ -4,19 +4,19 @@
|
|||||||
fn main() {
|
fn main() {
|
||||||
let mut t: (u64, u64);
|
let mut t: (u64, u64);
|
||||||
t.0 = 1;
|
t.0 = 1;
|
||||||
//~^ ERROR assign to part of possibly uninitialized variable: `t` [E0381]
|
//~^ ERROR assign to part of possibly-uninitialized variable: `t` [E0381]
|
||||||
t.1 = 1;
|
t.1 = 1;
|
||||||
|
|
||||||
let mut t: (u64, u64);
|
let mut t: (u64, u64);
|
||||||
t.1 = 1;
|
t.1 = 1;
|
||||||
//~^ ERROR assign to part of possibly uninitialized variable: `t` [E0381]
|
//~^ ERROR assign to part of possibly-uninitialized variable: `t` [E0381]
|
||||||
t.0 = 1;
|
t.0 = 1;
|
||||||
|
|
||||||
let mut t: (u64, u64);
|
let mut t: (u64, u64);
|
||||||
t.0 = 1;
|
t.0 = 1;
|
||||||
//~^ ERROR assign to part of possibly uninitialized variable: `t` [E0381]
|
//~^ ERROR assign to part of possibly-uninitialized variable: `t` [E0381]
|
||||||
|
|
||||||
let mut t: (u64,);
|
let mut t: (u64,);
|
||||||
t.0 = 1;
|
t.0 = 1;
|
||||||
//~^ ERROR assign to part of possibly uninitialized variable: `t` [E0381]
|
//~^ ERROR assign to part of possibly-uninitialized variable: `t` [E0381]
|
||||||
}
|
}
|
||||||
|
@ -1,26 +1,26 @@
|
|||||||
error[E0381]: assign to part of possibly uninitialized variable: `t`
|
error[E0381]: assign to part of possibly-uninitialized variable: `t`
|
||||||
--> $DIR/disallow-possibly-uninitialized.rs:6:5
|
--> $DIR/disallow-possibly-uninitialized.rs:6:5
|
||||||
|
|
|
|
||||||
LL | t.0 = 1;
|
LL | t.0 = 1;
|
||||||
| ^^^^^^^ use of possibly uninitialized `t`
|
| ^^^^^^^ use of possibly-uninitialized `t`
|
||||||
|
|
||||||
error[E0381]: assign to part of possibly uninitialized variable: `t`
|
error[E0381]: assign to part of possibly-uninitialized variable: `t`
|
||||||
--> $DIR/disallow-possibly-uninitialized.rs:11:5
|
--> $DIR/disallow-possibly-uninitialized.rs:11:5
|
||||||
|
|
|
|
||||||
LL | t.1 = 1;
|
LL | t.1 = 1;
|
||||||
| ^^^^^^^ use of possibly uninitialized `t`
|
| ^^^^^^^ use of possibly-uninitialized `t`
|
||||||
|
|
||||||
error[E0381]: assign to part of possibly uninitialized variable: `t`
|
error[E0381]: assign to part of possibly-uninitialized variable: `t`
|
||||||
--> $DIR/disallow-possibly-uninitialized.rs:16:5
|
--> $DIR/disallow-possibly-uninitialized.rs:16:5
|
||||||
|
|
|
|
||||||
LL | t.0 = 1;
|
LL | t.0 = 1;
|
||||||
| ^^^^^^^ use of possibly uninitialized `t`
|
| ^^^^^^^ use of possibly-uninitialized `t`
|
||||||
|
|
||||||
error[E0381]: assign to part of possibly uninitialized variable: `t`
|
error[E0381]: assign to part of possibly-uninitialized variable: `t`
|
||||||
--> $DIR/disallow-possibly-uninitialized.rs:20:5
|
--> $DIR/disallow-possibly-uninitialized.rs:20:5
|
||||||
|
|
|
|
||||||
LL | t.0 = 1;
|
LL | t.0 = 1;
|
||||||
| ^^^^^^^ use of possibly uninitialized `t`
|
| ^^^^^^^ use of possibly-uninitialized `t`
|
||||||
|
|
||||||
error: aborting due to 4 previous errors
|
error: aborting due to 4 previous errors
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ fn main() {
|
|||||||
{
|
{
|
||||||
let mut t: Tuple;
|
let mut t: Tuple;
|
||||||
t.0 = S(1);
|
t.0 = S(1);
|
||||||
//~^ ERROR assign to part of possibly uninitialized variable: `t` [E0381]
|
//~^ ERROR assign to part of possibly-uninitialized variable: `t` [E0381]
|
||||||
t.1 = 2;
|
t.1 = 2;
|
||||||
println!("{:?} {:?}", t.0, t.1);
|
println!("{:?} {:?}", t.0, t.1);
|
||||||
}
|
}
|
||||||
@ -18,7 +18,7 @@ fn main() {
|
|||||||
{
|
{
|
||||||
let mut u: Tpair;
|
let mut u: Tpair;
|
||||||
u.0 = S(1);
|
u.0 = S(1);
|
||||||
//~^ ERROR assign to part of possibly uninitialized variable: `u` [E0381]
|
//~^ ERROR assign to part of possibly-uninitialized variable: `u` [E0381]
|
||||||
u.1 = 2;
|
u.1 = 2;
|
||||||
println!("{:?} {:?}", u.0, u.1);
|
println!("{:?} {:?}", u.0, u.1);
|
||||||
}
|
}
|
||||||
@ -26,7 +26,7 @@ fn main() {
|
|||||||
{
|
{
|
||||||
let mut v: Spair;
|
let mut v: Spair;
|
||||||
v.x = S(1);
|
v.x = S(1);
|
||||||
//~^ ERROR assign to part of possibly uninitialized variable: `v` [E0381]
|
//~^ ERROR assign to part of possibly-uninitialized variable: `v` [E0381]
|
||||||
v.y = 2;
|
v.y = 2;
|
||||||
println!("{:?} {:?}", v.x, v.y);
|
println!("{:?} {:?}", v.x, v.y);
|
||||||
}
|
}
|
||||||
|
@ -1,20 +1,20 @@
|
|||||||
error[E0381]: assign to part of possibly uninitialized variable: `t`
|
error[E0381]: assign to part of possibly-uninitialized variable: `t`
|
||||||
--> $DIR/issue-54499-field-mutation-marks-mut-as-used.rs:12:9
|
--> $DIR/issue-54499-field-mutation-marks-mut-as-used.rs:12:9
|
||||||
|
|
|
|
||||||
LL | t.0 = S(1);
|
LL | t.0 = S(1);
|
||||||
| ^^^^^^^^^^ use of possibly uninitialized `t`
|
| ^^^^^^^^^^ use of possibly-uninitialized `t`
|
||||||
|
|
||||||
error[E0381]: assign to part of possibly uninitialized variable: `u`
|
error[E0381]: assign to part of possibly-uninitialized variable: `u`
|
||||||
--> $DIR/issue-54499-field-mutation-marks-mut-as-used.rs:20:9
|
--> $DIR/issue-54499-field-mutation-marks-mut-as-used.rs:20:9
|
||||||
|
|
|
|
||||||
LL | u.0 = S(1);
|
LL | u.0 = S(1);
|
||||||
| ^^^^^^^^^^ use of possibly uninitialized `u`
|
| ^^^^^^^^^^ use of possibly-uninitialized `u`
|
||||||
|
|
||||||
error[E0381]: assign to part of possibly uninitialized variable: `v`
|
error[E0381]: assign to part of possibly-uninitialized variable: `v`
|
||||||
--> $DIR/issue-54499-field-mutation-marks-mut-as-used.rs:28:9
|
--> $DIR/issue-54499-field-mutation-marks-mut-as-used.rs:28:9
|
||||||
|
|
|
|
||||||
LL | v.x = S(1);
|
LL | v.x = S(1);
|
||||||
| ^^^^^^^^^^ use of possibly uninitialized `v`
|
| ^^^^^^^^^^ use of possibly-uninitialized `v`
|
||||||
|
|
||||||
error: aborting due to 3 previous errors
|
error: aborting due to 3 previous errors
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ fn main() {
|
|||||||
{
|
{
|
||||||
let t: Tuple;
|
let t: Tuple;
|
||||||
t.0 = S(1);
|
t.0 = S(1);
|
||||||
//~^ ERROR assign to part of possibly uninitialized variable: `t` [E0381]
|
//~^ ERROR assign to part of possibly-uninitialized variable: `t` [E0381]
|
||||||
t.1 = 2;
|
t.1 = 2;
|
||||||
println!("{:?} {:?}", t.0, t.1);
|
println!("{:?} {:?}", t.0, t.1);
|
||||||
}
|
}
|
||||||
@ -18,7 +18,7 @@ fn main() {
|
|||||||
{
|
{
|
||||||
let u: Tpair;
|
let u: Tpair;
|
||||||
u.0 = S(1);
|
u.0 = S(1);
|
||||||
//~^ ERROR assign to part of possibly uninitialized variable: `u` [E0381]
|
//~^ ERROR assign to part of possibly-uninitialized variable: `u` [E0381]
|
||||||
u.1 = 2;
|
u.1 = 2;
|
||||||
println!("{:?} {:?}", u.0, u.1);
|
println!("{:?} {:?}", u.0, u.1);
|
||||||
}
|
}
|
||||||
@ -26,7 +26,7 @@ fn main() {
|
|||||||
{
|
{
|
||||||
let v: Spair;
|
let v: Spair;
|
||||||
v.x = S(1);
|
v.x = S(1);
|
||||||
//~^ ERROR assign to part of possibly uninitialized variable: `v` [E0381]
|
//~^ ERROR assign to part of possibly-uninitialized variable: `v` [E0381]
|
||||||
v.y = 2;
|
v.y = 2;
|
||||||
println!("{:?} {:?}", v.x, v.y);
|
println!("{:?} {:?}", v.x, v.y);
|
||||||
}
|
}
|
||||||
|
@ -1,20 +1,20 @@
|
|||||||
error[E0381]: assign to part of possibly uninitialized variable: `t`
|
error[E0381]: assign to part of possibly-uninitialized variable: `t`
|
||||||
--> $DIR/issue-54499-field-mutation-of-never-init.rs:12:9
|
--> $DIR/issue-54499-field-mutation-of-never-init.rs:12:9
|
||||||
|
|
|
|
||||||
LL | t.0 = S(1);
|
LL | t.0 = S(1);
|
||||||
| ^^^^^^^^^^ use of possibly uninitialized `t`
|
| ^^^^^^^^^^ use of possibly-uninitialized `t`
|
||||||
|
|
||||||
error[E0381]: assign to part of possibly uninitialized variable: `u`
|
error[E0381]: assign to part of possibly-uninitialized variable: `u`
|
||||||
--> $DIR/issue-54499-field-mutation-of-never-init.rs:20:9
|
--> $DIR/issue-54499-field-mutation-of-never-init.rs:20:9
|
||||||
|
|
|
|
||||||
LL | u.0 = S(1);
|
LL | u.0 = S(1);
|
||||||
| ^^^^^^^^^^ use of possibly uninitialized `u`
|
| ^^^^^^^^^^ use of possibly-uninitialized `u`
|
||||||
|
|
||||||
error[E0381]: assign to part of possibly uninitialized variable: `v`
|
error[E0381]: assign to part of possibly-uninitialized variable: `v`
|
||||||
--> $DIR/issue-54499-field-mutation-of-never-init.rs:28:9
|
--> $DIR/issue-54499-field-mutation-of-never-init.rs:28:9
|
||||||
|
|
|
|
||||||
LL | v.x = S(1);
|
LL | v.x = S(1);
|
||||||
| ^^^^^^^^^^ use of possibly uninitialized `v`
|
| ^^^^^^^^^^ use of possibly-uninitialized `v`
|
||||||
|
|
||||||
error: aborting due to 3 previous errors
|
error: aborting due to 3 previous errors
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
fn main() {
|
fn main() {
|
||||||
let e: i32;
|
let e: i32;
|
||||||
match e {
|
match e {
|
||||||
//~^ ERROR use of possibly uninitialized variable
|
//~^ ERROR use of possibly-uninitialized variable
|
||||||
ref u if true => {}
|
ref u if true => {}
|
||||||
ref v if true => {
|
ref v if true => {
|
||||||
let tx = 0;
|
let tx = 0;
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user