compiletest: Make diagnostic kind mandatory on line annotations

This commit is contained in:
Vadim Petrochenkov 2025-04-05 19:19:56 +03:00
parent 427288b3ce
commit 20faf8532b
372 changed files with 2377 additions and 2107 deletions

View file

@ -372,9 +372,9 @@ E.g. use `//@ dont-require-annotations: NOTE` to annotate notes selectively.
Avoid using this directive for `ERROR`s and `WARN`ings, unless there's a serious reason, like
target-dependent compiler output.
Missing diagnostic kinds (`//~ message`) are currently accepted, but are being phased away.
They will match any compiler output kind, but will not force exhaustive annotations for that kind.
Prefer explicit kind and `//@ dont-require-annotations` to achieve the same effect.
Some diagnostics are never required to be line-annotated, regardless of their kind or directives,
for example secondary lines of multiline diagnostics,
or ubiquitous diagnostics like `aborting due to N previous errors`.
UI tests use the `-A unused` flag by default to ignore all unused warnings, as
unused warnings are usually not the focus of a test. However, simple code

View file

@ -30,24 +30,20 @@ impl ErrorKind {
/// Either the canonical uppercase string, or some additional versions for compatibility.
/// FIXME: consider keeping only the canonical versions here.
fn from_user_str(s: &str) -> Option<ErrorKind> {
Some(match s {
pub fn from_user_str(s: &str) -> ErrorKind {
match s {
"HELP" | "help" => ErrorKind::Help,
"ERROR" | "error" => ErrorKind::Error,
"NOTE" | "note" => ErrorKind::Note,
// `MONO_ITEM` makes annotations in `codegen-units` tests syntactically correct,
// but those tests never use the error kind later on.
"NOTE" | "note" | "MONO_ITEM" => ErrorKind::Note,
"SUGGESTION" => ErrorKind::Suggestion,
"WARN" | "WARNING" | "warn" | "warning" => ErrorKind::Warning,
_ => return None,
})
}
pub fn expect_from_user_str(s: &str) -> ErrorKind {
ErrorKind::from_user_str(s).unwrap_or_else(|| {
panic!(
_ => panic!(
"unexpected diagnostic kind `{s}`, expected \
`ERROR`, `WARN`, `NOTE`, `HELP` or `SUGGESTION`"
)
})
),
}
}
}
@ -67,8 +63,7 @@ impl fmt::Display for ErrorKind {
pub struct Error {
pub line_num: Option<usize>,
/// What kind of message we expect (e.g., warning, error, suggestion).
/// `None` if not specified or unknown message kind.
pub kind: Option<ErrorKind>,
pub kind: ErrorKind,
pub msg: String,
/// For some `Error`s, like secondary lines of multi-line diagnostics, line annotations
/// are not mandatory, even if they would otherwise be mandatory for primary errors.
@ -79,12 +74,7 @@ pub struct Error {
impl Error {
pub fn render_for_expected(&self) -> String {
use colored::Colorize;
format!(
"{: <10}line {: >3}: {}",
self.kind.map(|kind| kind.to_string()).unwrap_or_default(),
self.line_num_str(),
self.msg.cyan(),
)
format!("{: <10}line {: >3}: {}", self.kind, self.line_num_str(), self.msg.cyan())
}
pub fn line_num_str(&self) -> String {
@ -173,9 +163,10 @@ fn parse_expected(
// Get the part of the comment after the sigil (e.g. `~^^` or ~|).
let tag = captures.get(0).unwrap();
let rest = line[tag.end()..].trim_start();
let (kind_str, _) = rest.split_once(|c: char| !c.is_ascii_alphabetic()).unwrap_or((rest, ""));
let (kind_str, _) =
rest.split_once(|c: char| c != '_' && !c.is_ascii_alphabetic()).unwrap_or((rest, ""));
let kind = ErrorKind::from_user_str(kind_str);
let untrimmed_msg = if kind.is_some() { &rest[kind_str.len()..] } else { rest };
let untrimmed_msg = &rest[kind_str.len()..];
let msg = untrimmed_msg.strip_prefix(':').unwrap_or(untrimmed_msg).trim().to_owned();
let line_num_adjust = &captures["adjust"];

View file

@ -593,7 +593,7 @@ impl TestProps {
config.parse_name_value_directive(ln, DONT_REQUIRE_ANNOTATIONS)
{
self.dont_require_annotations
.insert(ErrorKind::expect_from_user_str(err_kind.trim()));
.insert(ErrorKind::from_user_str(err_kind.trim()));
}
},
);

View file

@ -229,7 +229,7 @@ fn push_actual_errors(
// Convert multi-line messages into multiple errors.
// We expect to replace these with something more structured anyhow.
let mut message_lines = diagnostic.message.lines();
let kind = Some(ErrorKind::from_compiler_str(&diagnostic.level));
let kind = ErrorKind::from_compiler_str(&diagnostic.level);
let first_line = message_lines.next().unwrap_or(&diagnostic.message);
if primary_spans.is_empty() {
static RE: OnceLock<Regex> = OnceLock::new();
@ -278,7 +278,7 @@ fn push_actual_errors(
for (index, line) in suggested_replacement.lines().enumerate() {
errors.push(Error {
line_num: Some(span.line_start + index),
kind: Some(ErrorKind::Suggestion),
kind: ErrorKind::Suggestion,
msg: line.to_string(),
require_annotation: true,
});
@ -297,7 +297,7 @@ fn push_actual_errors(
for span in spans_in_this_file.iter().filter(|span| span.label.is_some()) {
errors.push(Error {
line_num: Some(span.line_start),
kind: Some(ErrorKind::Note),
kind: ErrorKind::Note,
msg: span.label.clone().unwrap(),
require_annotation: true,
});
@ -317,7 +317,7 @@ fn push_backtrace(
if Path::new(&expansion.span.file_name) == Path::new(&file_name) {
errors.push(Error {
line_num: Some(expansion.span.line_start),
kind: Some(ErrorKind::Note),
kind: ErrorKind::Note,
msg: format!("in this expansion of {}", expansion.macro_decl_name),
require_annotation: true,
});

View file

@ -675,9 +675,7 @@ impl<'test> TestCx<'test> {
"check_expected_errors: expected_errors={:?} proc_res.status={:?}",
expected_errors, proc_res.status
);
if proc_res.status.success()
&& expected_errors.iter().any(|x| x.kind == Some(ErrorKind::Error))
{
if proc_res.status.success() && expected_errors.iter().any(|x| x.kind == ErrorKind::Error) {
self.fatal_proc_rec("process did not return an error status", proc_res);
}
@ -709,7 +707,7 @@ impl<'test> TestCx<'test> {
// if one of them actually occurs in the test.
let expected_kinds: HashSet<_> = [ErrorKind::Error, ErrorKind::Warning]
.into_iter()
.chain(expected_errors.iter().filter_map(|e| e.kind))
.chain(expected_errors.iter().map(|e| e.kind))
.collect();
// Parse the JSON output from the compiler and extract out the messages.
@ -723,8 +721,7 @@ impl<'test> TestCx<'test> {
expected_errors.iter().enumerate().position(|(index, expected_error)| {
!found[index]
&& actual_error.line_num == expected_error.line_num
&& (expected_error.kind.is_none()
|| actual_error.kind == expected_error.kind)
&& actual_error.kind == expected_error.kind
&& actual_error.msg.contains(&expected_error.msg)
});
@ -737,19 +734,14 @@ impl<'test> TestCx<'test> {
None => {
if actual_error.require_annotation
&& actual_error.kind.map_or(false, |kind| {
expected_kinds.contains(&kind)
&& !self.props.dont_require_annotations.contains(&kind)
})
&& expected_kinds.contains(&actual_error.kind)
&& !self.props.dont_require_annotations.contains(&actual_error.kind)
{
self.error(&format!(
"{}:{}: unexpected {}: '{}'",
file_name,
actual_error.line_num_str(),
actual_error
.kind
.as_ref()
.map_or(String::from("message"), |k| k.to_string()),
actual_error.kind,
actual_error.msg
));
unexpected.push(actual_error);
@ -766,7 +758,7 @@ impl<'test> TestCx<'test> {
"{}:{}: expected {} not found: {}",
file_name,
expected_error.line_num_str(),
expected_error.kind.as_ref().map_or("message".into(), |k| k.to_string()),
expected_error.kind,
expected_error.msg
));
not_found.push(expected_error);

View file

@ -6,8 +6,8 @@ use rustfix::{Filter, apply_suggestions, get_suggestions_from_json};
use tracing::debug;
use super::{
AllowUnused, Emit, ErrorKind, FailMode, LinkToAux, PassMode, TargetLocation, TestCx,
TestOutput, Truncated, UI_FIXED, WillExecute,
AllowUnused, Emit, FailMode, LinkToAux, PassMode, TargetLocation, TestCx, TestOutput,
Truncated, UI_FIXED, WillExecute,
};
use crate::{errors, json};
@ -176,7 +176,7 @@ impl TestCx<'_> {
let msg = format!(
"line {}: cannot combine `--error-format` with {} annotations; use `error-pattern` instead",
expected_errors[0].line_num_str(),
expected_errors[0].kind.unwrap_or(ErrorKind::Error),
expected_errors[0].kind,
);
self.fatal(&msg);
}

View file

@ -1,12 +1,14 @@
//@ compile-flags: -Znormalize-docs
//@ dont-require-annotations: NOTE
// https://github.com/rust-lang/rust/issues/105742
use std::ops::Index;
pub fn next<'a, T>(s: &'a mut dyn SVec<Item = T, Output = T>) {
//~^ expected 1 lifetime argument
//~| expected 1 generic argument
//~^ NOTE expected 1 lifetime argument
//~| NOTE expected 1 generic argument
//~| ERROR the trait `SVec` is not dyn compatible
//~| `SVec` is not dyn compatible
//~| NOTE `SVec` is not dyn compatible
//~| ERROR missing generics for associated type `SVec::Item`
//~| ERROR missing generics for associated type `SVec::Item`
let _ = s;
@ -14,8 +16,8 @@ pub fn next<'a, T>(s: &'a mut dyn SVec<Item = T, Output = T>) {
pub trait SVec: Index<
<Self as SVec>::Item,
//~^ expected 1 lifetime argument
//~| expected 1 generic argument
//~^ NOTE expected 1 lifetime argument
//~| NOTE expected 1 generic argument
//~| ERROR missing generics for associated type `SVec::Item`
//~| ERROR missing generics for associated type `SVec::Item`
//~| ERROR missing generics for associated type `SVec::Item`
@ -25,8 +27,8 @@ pub trait SVec: Index<
//~| ERROR missing generics for associated type `SVec::Item`
//~| ERROR missing generics for associated type `SVec::Item`
Output = <Index<<Self as SVec>::Item,
//~^ expected 1 lifetime argument
//~| expected 1 generic argument
//~^ NOTE expected 1 lifetime argument
//~| NOTE expected 1 generic argument
//~| ERROR missing generics for associated type `SVec::Item`
//~| ERROR missing generics for associated type `SVec::Item`
//~| ERROR missing generics for associated type `SVec::Item`
@ -36,16 +38,16 @@ pub trait SVec: Index<
//~| ERROR missing generics for associated type `SVec::Item`
//~| ERROR missing generics for associated type `SVec::Item`
Output = <Self as SVec>::Item> as SVec>::Item,
//~^ expected 1 lifetime argument
//~| expected 1 generic argument
//~| expected 1 lifetime argument
//~^ NOTE expected 1 lifetime argument
//~| NOTE expected 1 generic argument
//~| NOTE expected 1 lifetime argument
//~| ERROR missing generics for associated type `SVec::Item`
//~| ERROR missing generics for associated type `SVec::Item`
//~| ERROR missing generics for associated type `SVec::Item`
//~| ERROR missing generics for associated type `SVec::Item`
//~| ERROR missing generics for associated type `SVec::Item`
//~| ERROR missing generics for associated type `SVec::Item`
//~| expected 1 generic argument
//~| NOTE expected 1 generic argument
//~| ERROR missing generics for associated type `SVec::Item`
//~| ERROR missing generics for associated type `SVec::Item`
//~| ERROR missing generics for associated type `SVec::Item`
@ -60,8 +62,8 @@ pub trait SVec: Index<
type Item<'a, T>;
fn len(&self) -> <Self as SVec>::Item;
//~^ expected 1 lifetime argument
//~^ NOTE expected 1 lifetime argument
//~| ERROR missing generics for associated type `SVec::Item`
//~| expected 1 generic argument
//~| NOTE expected 1 generic argument
//~| ERROR missing generics for associated type `SVec::Item`
}

View file

@ -1,11 +1,11 @@
error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/ice-generic-type-alias-105742.rs:16:21
--> $DIR/ice-generic-type-alias-105742.rs:18:21
|
LL | <Self as SVec>::Item,
| ^^^^ expected 1 lifetime argument
|
note: associated type defined here, with 1 lifetime parameter: `'a`
--> $DIR/ice-generic-type-alias-105742.rs:60:10
--> $DIR/ice-generic-type-alias-105742.rs:62:10
|
LL | type Item<'a, T>;
| ^^^^ --
@ -15,13 +15,13 @@ LL | <Self as SVec>::Item<'a>,
| ++++
error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/ice-generic-type-alias-105742.rs:16:21
--> $DIR/ice-generic-type-alias-105742.rs:18:21
|
LL | <Self as SVec>::Item,
| ^^^^ expected 1 generic argument
|
note: associated type defined here, with 1 generic parameter: `T`
--> $DIR/ice-generic-type-alias-105742.rs:60:10
--> $DIR/ice-generic-type-alias-105742.rs:62:10
|
LL | type Item<'a, T>;
| ^^^^ -
@ -31,13 +31,13 @@ LL | <Self as SVec>::Item<T>,
| +++
error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/ice-generic-type-alias-105742.rs:27:37
--> $DIR/ice-generic-type-alias-105742.rs:29:37
|
LL | Output = <Index<<Self as SVec>::Item,
| ^^^^ expected 1 lifetime argument
|
note: associated type defined here, with 1 lifetime parameter: `'a`
--> $DIR/ice-generic-type-alias-105742.rs:60:10
--> $DIR/ice-generic-type-alias-105742.rs:62:10
|
LL | type Item<'a, T>;
| ^^^^ --
@ -47,13 +47,13 @@ LL | Output = <Index<<Self as SVec>::Item<'a>,
| ++++
error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/ice-generic-type-alias-105742.rs:27:37
--> $DIR/ice-generic-type-alias-105742.rs:29:37
|
LL | Output = <Index<<Self as SVec>::Item,
| ^^^^ expected 1 generic argument
|
note: associated type defined here, with 1 generic parameter: `T`
--> $DIR/ice-generic-type-alias-105742.rs:60:10
--> $DIR/ice-generic-type-alias-105742.rs:62:10
|
LL | type Item<'a, T>;
| ^^^^ -
@ -63,13 +63,13 @@ LL | Output = <Index<<Self as SVec>::Item<T>,
| +++
error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/ice-generic-type-alias-105742.rs:38:30
--> $DIR/ice-generic-type-alias-105742.rs:40:30
|
LL | Output = <Self as SVec>::Item> as SVec>::Item,
| ^^^^ expected 1 lifetime argument
|
note: associated type defined here, with 1 lifetime parameter: `'a`
--> $DIR/ice-generic-type-alias-105742.rs:60:10
--> $DIR/ice-generic-type-alias-105742.rs:62:10
|
LL | type Item<'a, T>;
| ^^^^ --
@ -79,13 +79,13 @@ LL | Output = <Self as SVec>::Item<'a>> as SVec>::Item,
| ++++
error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/ice-generic-type-alias-105742.rs:38:30
--> $DIR/ice-generic-type-alias-105742.rs:40:30
|
LL | Output = <Self as SVec>::Item> as SVec>::Item,
| ^^^^ expected 1 generic argument
|
note: associated type defined here, with 1 generic parameter: `T`
--> $DIR/ice-generic-type-alias-105742.rs:60:10
--> $DIR/ice-generic-type-alias-105742.rs:62:10
|
LL | type Item<'a, T>;
| ^^^^ -
@ -95,13 +95,13 @@ LL | Output = <Self as SVec>::Item<T>> as SVec>::Item,
| +++
error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/ice-generic-type-alias-105742.rs:38:46
--> $DIR/ice-generic-type-alias-105742.rs:40:46
|
LL | Output = <Self as SVec>::Item> as SVec>::Item,
| ^^^^ expected 1 lifetime argument
|
note: associated type defined here, with 1 lifetime parameter: `'a`
--> $DIR/ice-generic-type-alias-105742.rs:60:10
--> $DIR/ice-generic-type-alias-105742.rs:62:10
|
LL | type Item<'a, T>;
| ^^^^ --
@ -111,13 +111,13 @@ LL | Output = <Self as SVec>::Item> as SVec>::Item<'a>,
| ++++
error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/ice-generic-type-alias-105742.rs:38:46
--> $DIR/ice-generic-type-alias-105742.rs:40:46
|
LL | Output = <Self as SVec>::Item> as SVec>::Item,
| ^^^^ expected 1 generic argument
|
note: associated type defined here, with 1 generic parameter: `T`
--> $DIR/ice-generic-type-alias-105742.rs:60:10
--> $DIR/ice-generic-type-alias-105742.rs:62:10
|
LL | type Item<'a, T>;
| ^^^^ -
@ -127,13 +127,13 @@ LL | Output = <Self as SVec>::Item> as SVec>::Item<T>,
| +++
error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/ice-generic-type-alias-105742.rs:5:40
--> $DIR/ice-generic-type-alias-105742.rs:7:40
|
LL | pub fn next<'a, T>(s: &'a mut dyn SVec<Item = T, Output = T>) {
| ^^^^ expected 1 lifetime argument
|
note: associated type defined here, with 1 lifetime parameter: `'a`
--> $DIR/ice-generic-type-alias-105742.rs:60:10
--> $DIR/ice-generic-type-alias-105742.rs:62:10
|
LL | type Item<'a, T>;
| ^^^^ --
@ -143,13 +143,13 @@ LL | pub fn next<'a, T>(s: &'a mut dyn SVec<Item<'_> = T, Output = T>) {
| ++++
error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/ice-generic-type-alias-105742.rs:5:40
--> $DIR/ice-generic-type-alias-105742.rs:7:40
|
LL | pub fn next<'a, T>(s: &'a mut dyn SVec<Item = T, Output = T>) {
| ^^^^ expected 1 generic argument
|
note: associated type defined here, with 1 generic parameter: `T`
--> $DIR/ice-generic-type-alias-105742.rs:60:10
--> $DIR/ice-generic-type-alias-105742.rs:62:10
|
LL | type Item<'a, T>;
| ^^^^ -
@ -159,13 +159,13 @@ LL | pub fn next<'a, T>(s: &'a mut dyn SVec<Item<T> = T, Output = T>) {
| +++
error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/ice-generic-type-alias-105742.rs:16:21
--> $DIR/ice-generic-type-alias-105742.rs:18:21
|
LL | <Self as SVec>::Item,
| ^^^^ expected 1 lifetime argument
|
note: associated type defined here, with 1 lifetime parameter: `'a`
--> $DIR/ice-generic-type-alias-105742.rs:60:10
--> $DIR/ice-generic-type-alias-105742.rs:62:10
|
LL | type Item<'a, T>;
| ^^^^ --
@ -176,13 +176,13 @@ LL | <Self as SVec>::Item<'a>,
| ++++
error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/ice-generic-type-alias-105742.rs:16:21
--> $DIR/ice-generic-type-alias-105742.rs:18:21
|
LL | <Self as SVec>::Item,
| ^^^^ expected 1 generic argument
|
note: associated type defined here, with 1 generic parameter: `T`
--> $DIR/ice-generic-type-alias-105742.rs:60:10
--> $DIR/ice-generic-type-alias-105742.rs:62:10
|
LL | type Item<'a, T>;
| ^^^^ -
@ -193,13 +193,13 @@ LL | <Self as SVec>::Item<T>,
| +++
error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/ice-generic-type-alias-105742.rs:27:37
--> $DIR/ice-generic-type-alias-105742.rs:29:37
|
LL | Output = <Index<<Self as SVec>::Item,
| ^^^^ expected 1 lifetime argument
|
note: associated type defined here, with 1 lifetime parameter: `'a`
--> $DIR/ice-generic-type-alias-105742.rs:60:10
--> $DIR/ice-generic-type-alias-105742.rs:62:10
|
LL | type Item<'a, T>;
| ^^^^ --
@ -210,13 +210,13 @@ LL | Output = <Index<<Self as SVec>::Item<'a>,
| ++++
error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/ice-generic-type-alias-105742.rs:27:37
--> $DIR/ice-generic-type-alias-105742.rs:29:37
|
LL | Output = <Index<<Self as SVec>::Item,
| ^^^^ expected 1 generic argument
|
note: associated type defined here, with 1 generic parameter: `T`
--> $DIR/ice-generic-type-alias-105742.rs:60:10
--> $DIR/ice-generic-type-alias-105742.rs:62:10
|
LL | type Item<'a, T>;
| ^^^^ -
@ -227,13 +227,13 @@ LL | Output = <Index<<Self as SVec>::Item<T>,
| +++
error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/ice-generic-type-alias-105742.rs:38:30
--> $DIR/ice-generic-type-alias-105742.rs:40:30
|
LL | Output = <Self as SVec>::Item> as SVec>::Item,
| ^^^^ expected 1 lifetime argument
|
note: associated type defined here, with 1 lifetime parameter: `'a`
--> $DIR/ice-generic-type-alias-105742.rs:60:10
--> $DIR/ice-generic-type-alias-105742.rs:62:10
|
LL | type Item<'a, T>;
| ^^^^ --
@ -244,13 +244,13 @@ LL | Output = <Self as SVec>::Item<'a>> as SVec>::Item,
| ++++
error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/ice-generic-type-alias-105742.rs:38:30
--> $DIR/ice-generic-type-alias-105742.rs:40:30
|
LL | Output = <Self as SVec>::Item> as SVec>::Item,
| ^^^^ expected 1 generic argument
|
note: associated type defined here, with 1 generic parameter: `T`
--> $DIR/ice-generic-type-alias-105742.rs:60:10
--> $DIR/ice-generic-type-alias-105742.rs:62:10
|
LL | type Item<'a, T>;
| ^^^^ -
@ -261,13 +261,13 @@ LL | Output = <Self as SVec>::Item<T>> as SVec>::Item,
| +++
error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/ice-generic-type-alias-105742.rs:38:46
--> $DIR/ice-generic-type-alias-105742.rs:40:46
|
LL | Output = <Self as SVec>::Item> as SVec>::Item,
| ^^^^ expected 1 lifetime argument
|
note: associated type defined here, with 1 lifetime parameter: `'a`
--> $DIR/ice-generic-type-alias-105742.rs:60:10
--> $DIR/ice-generic-type-alias-105742.rs:62:10
|
LL | type Item<'a, T>;
| ^^^^ --
@ -278,13 +278,13 @@ LL | Output = <Self as SVec>::Item> as SVec>::Item<'a>,
| ++++
error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/ice-generic-type-alias-105742.rs:38:46
--> $DIR/ice-generic-type-alias-105742.rs:40:46
|
LL | Output = <Self as SVec>::Item> as SVec>::Item,
| ^^^^ expected 1 generic argument
|
note: associated type defined here, with 1 generic parameter: `T`
--> $DIR/ice-generic-type-alias-105742.rs:60:10
--> $DIR/ice-generic-type-alias-105742.rs:62:10
|
LL | type Item<'a, T>;
| ^^^^ -
@ -295,14 +295,14 @@ LL | Output = <Self as SVec>::Item> as SVec>::Item<T>,
| +++
error[E0038]: the trait `SVec` is not dyn compatible
--> $DIR/ice-generic-type-alias-105742.rs:5:35
--> $DIR/ice-generic-type-alias-105742.rs:7:35
|
LL | pub fn next<'a, T>(s: &'a mut dyn SVec<Item = T, Output = T>) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ `SVec` is not dyn compatible
|
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
--> $DIR/ice-generic-type-alias-105742.rs:15:17
--> $DIR/ice-generic-type-alias-105742.rs:17:17
|
LL | pub trait SVec: Index<
| ____________----__^
@ -324,13 +324,13 @@ LL + pub fn next<'a, T>(s: &'a mut impl SVec<Item = T, Output = T>) {
|
error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/ice-generic-type-alias-105742.rs:16:21
--> $DIR/ice-generic-type-alias-105742.rs:18:21
|
LL | <Self as SVec>::Item,
| ^^^^ expected 1 lifetime argument
|
note: associated type defined here, with 1 lifetime parameter: `'a`
--> $DIR/ice-generic-type-alias-105742.rs:60:10
--> $DIR/ice-generic-type-alias-105742.rs:62:10
|
LL | type Item<'a, T>;
| ^^^^ --
@ -341,13 +341,13 @@ LL | <Self as SVec>::Item<'a>,
| ++++
error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/ice-generic-type-alias-105742.rs:16:21
--> $DIR/ice-generic-type-alias-105742.rs:18:21
|
LL | <Self as SVec>::Item,
| ^^^^ expected 1 generic argument
|
note: associated type defined here, with 1 generic parameter: `T`
--> $DIR/ice-generic-type-alias-105742.rs:60:10
--> $DIR/ice-generic-type-alias-105742.rs:62:10
|
LL | type Item<'a, T>;
| ^^^^ -
@ -358,13 +358,13 @@ LL | <Self as SVec>::Item<T>,
| +++
error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/ice-generic-type-alias-105742.rs:27:37
--> $DIR/ice-generic-type-alias-105742.rs:29:37
|
LL | Output = <Index<<Self as SVec>::Item,
| ^^^^ expected 1 lifetime argument
|
note: associated type defined here, with 1 lifetime parameter: `'a`
--> $DIR/ice-generic-type-alias-105742.rs:60:10
--> $DIR/ice-generic-type-alias-105742.rs:62:10
|
LL | type Item<'a, T>;
| ^^^^ --
@ -375,13 +375,13 @@ LL | Output = <Index<<Self as SVec>::Item<'a>,
| ++++
error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/ice-generic-type-alias-105742.rs:27:37
--> $DIR/ice-generic-type-alias-105742.rs:29:37
|
LL | Output = <Index<<Self as SVec>::Item,
| ^^^^ expected 1 generic argument
|
note: associated type defined here, with 1 generic parameter: `T`
--> $DIR/ice-generic-type-alias-105742.rs:60:10
--> $DIR/ice-generic-type-alias-105742.rs:62:10
|
LL | type Item<'a, T>;
| ^^^^ -
@ -392,13 +392,13 @@ LL | Output = <Index<<Self as SVec>::Item<T>,
| +++
error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/ice-generic-type-alias-105742.rs:38:30
--> $DIR/ice-generic-type-alias-105742.rs:40:30
|
LL | Output = <Self as SVec>::Item> as SVec>::Item,
| ^^^^ expected 1 lifetime argument
|
note: associated type defined here, with 1 lifetime parameter: `'a`
--> $DIR/ice-generic-type-alias-105742.rs:60:10
--> $DIR/ice-generic-type-alias-105742.rs:62:10
|
LL | type Item<'a, T>;
| ^^^^ --
@ -409,13 +409,13 @@ LL | Output = <Self as SVec>::Item<'a>> as SVec>::Item,
| ++++
error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/ice-generic-type-alias-105742.rs:38:30
--> $DIR/ice-generic-type-alias-105742.rs:40:30
|
LL | Output = <Self as SVec>::Item> as SVec>::Item,
| ^^^^ expected 1 generic argument
|
note: associated type defined here, with 1 generic parameter: `T`
--> $DIR/ice-generic-type-alias-105742.rs:60:10
--> $DIR/ice-generic-type-alias-105742.rs:62:10
|
LL | type Item<'a, T>;
| ^^^^ -
@ -426,13 +426,13 @@ LL | Output = <Self as SVec>::Item<T>> as SVec>::Item,
| +++
error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/ice-generic-type-alias-105742.rs:38:46
--> $DIR/ice-generic-type-alias-105742.rs:40:46
|
LL | Output = <Self as SVec>::Item> as SVec>::Item,
| ^^^^ expected 1 lifetime argument
|
note: associated type defined here, with 1 lifetime parameter: `'a`
--> $DIR/ice-generic-type-alias-105742.rs:60:10
--> $DIR/ice-generic-type-alias-105742.rs:62:10
|
LL | type Item<'a, T>;
| ^^^^ --
@ -443,13 +443,13 @@ LL | Output = <Self as SVec>::Item> as SVec>::Item<'a>,
| ++++
error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/ice-generic-type-alias-105742.rs:38:46
--> $DIR/ice-generic-type-alias-105742.rs:40:46
|
LL | Output = <Self as SVec>::Item> as SVec>::Item,
| ^^^^ expected 1 generic argument
|
note: associated type defined here, with 1 generic parameter: `T`
--> $DIR/ice-generic-type-alias-105742.rs:60:10
--> $DIR/ice-generic-type-alias-105742.rs:62:10
|
LL | type Item<'a, T>;
| ^^^^ -
@ -460,13 +460,13 @@ LL | Output = <Self as SVec>::Item> as SVec>::Item<T>,
| +++
error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/ice-generic-type-alias-105742.rs:16:21
--> $DIR/ice-generic-type-alias-105742.rs:18:21
|
LL | <Self as SVec>::Item,
| ^^^^ expected 1 lifetime argument
|
note: associated type defined here, with 1 lifetime parameter: `'a`
--> $DIR/ice-generic-type-alias-105742.rs:60:10
--> $DIR/ice-generic-type-alias-105742.rs:62:10
|
LL | type Item<'a, T>;
| ^^^^ --
@ -477,13 +477,13 @@ LL | <Self as SVec>::Item<'a>,
| ++++
error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/ice-generic-type-alias-105742.rs:16:21
--> $DIR/ice-generic-type-alias-105742.rs:18:21
|
LL | <Self as SVec>::Item,
| ^^^^ expected 1 generic argument
|
note: associated type defined here, with 1 generic parameter: `T`
--> $DIR/ice-generic-type-alias-105742.rs:60:10
--> $DIR/ice-generic-type-alias-105742.rs:62:10
|
LL | type Item<'a, T>;
| ^^^^ -
@ -494,13 +494,13 @@ LL | <Self as SVec>::Item<T>,
| +++
error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/ice-generic-type-alias-105742.rs:27:37
--> $DIR/ice-generic-type-alias-105742.rs:29:37
|
LL | Output = <Index<<Self as SVec>::Item,
| ^^^^ expected 1 lifetime argument
|
note: associated type defined here, with 1 lifetime parameter: `'a`
--> $DIR/ice-generic-type-alias-105742.rs:60:10
--> $DIR/ice-generic-type-alias-105742.rs:62:10
|
LL | type Item<'a, T>;
| ^^^^ --
@ -511,13 +511,13 @@ LL | Output = <Index<<Self as SVec>::Item<'a>,
| ++++
error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/ice-generic-type-alias-105742.rs:27:37
--> $DIR/ice-generic-type-alias-105742.rs:29:37
|
LL | Output = <Index<<Self as SVec>::Item,
| ^^^^ expected 1 generic argument
|
note: associated type defined here, with 1 generic parameter: `T`
--> $DIR/ice-generic-type-alias-105742.rs:60:10
--> $DIR/ice-generic-type-alias-105742.rs:62:10
|
LL | type Item<'a, T>;
| ^^^^ -
@ -528,13 +528,13 @@ LL | Output = <Index<<Self as SVec>::Item<T>,
| +++
error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/ice-generic-type-alias-105742.rs:38:30
--> $DIR/ice-generic-type-alias-105742.rs:40:30
|
LL | Output = <Self as SVec>::Item> as SVec>::Item,
| ^^^^ expected 1 lifetime argument
|
note: associated type defined here, with 1 lifetime parameter: `'a`
--> $DIR/ice-generic-type-alias-105742.rs:60:10
--> $DIR/ice-generic-type-alias-105742.rs:62:10
|
LL | type Item<'a, T>;
| ^^^^ --
@ -545,13 +545,13 @@ LL | Output = <Self as SVec>::Item<'a>> as SVec>::Item,
| ++++
error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/ice-generic-type-alias-105742.rs:38:30
--> $DIR/ice-generic-type-alias-105742.rs:40:30
|
LL | Output = <Self as SVec>::Item> as SVec>::Item,
| ^^^^ expected 1 generic argument
|
note: associated type defined here, with 1 generic parameter: `T`
--> $DIR/ice-generic-type-alias-105742.rs:60:10
--> $DIR/ice-generic-type-alias-105742.rs:62:10
|
LL | type Item<'a, T>;
| ^^^^ -
@ -562,13 +562,13 @@ LL | Output = <Self as SVec>::Item<T>> as SVec>::Item,
| +++
error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/ice-generic-type-alias-105742.rs:38:46
--> $DIR/ice-generic-type-alias-105742.rs:40:46
|
LL | Output = <Self as SVec>::Item> as SVec>::Item,
| ^^^^ expected 1 lifetime argument
|
note: associated type defined here, with 1 lifetime parameter: `'a`
--> $DIR/ice-generic-type-alias-105742.rs:60:10
--> $DIR/ice-generic-type-alias-105742.rs:62:10
|
LL | type Item<'a, T>;
| ^^^^ --
@ -579,13 +579,13 @@ LL | Output = <Self as SVec>::Item> as SVec>::Item<'a>,
| ++++
error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/ice-generic-type-alias-105742.rs:38:46
--> $DIR/ice-generic-type-alias-105742.rs:40:46
|
LL | Output = <Self as SVec>::Item> as SVec>::Item,
| ^^^^ expected 1 generic argument
|
note: associated type defined here, with 1 generic parameter: `T`
--> $DIR/ice-generic-type-alias-105742.rs:60:10
--> $DIR/ice-generic-type-alias-105742.rs:62:10
|
LL | type Item<'a, T>;
| ^^^^ -
@ -596,13 +596,13 @@ LL | Output = <Self as SVec>::Item> as SVec>::Item<T>,
| +++
error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/ice-generic-type-alias-105742.rs:62:38
--> $DIR/ice-generic-type-alias-105742.rs:64:38
|
LL | fn len(&self) -> <Self as SVec>::Item;
| ^^^^ expected 1 lifetime argument
|
note: associated type defined here, with 1 lifetime parameter: `'a`
--> $DIR/ice-generic-type-alias-105742.rs:60:10
--> $DIR/ice-generic-type-alias-105742.rs:62:10
|
LL | type Item<'a, T>;
| ^^^^ --
@ -612,13 +612,13 @@ LL | fn len(&self) -> <Self as SVec>::Item<'_>;
| ++++
error[E0107]: missing generics for associated type `SVec::Item`
--> $DIR/ice-generic-type-alias-105742.rs:62:38
--> $DIR/ice-generic-type-alias-105742.rs:64:38
|
LL | fn len(&self) -> <Self as SVec>::Item;
| ^^^^ expected 1 generic argument
|
note: associated type defined here, with 1 generic parameter: `T`
--> $DIR/ice-generic-type-alias-105742.rs:60:10
--> $DIR/ice-generic-type-alias-105742.rs:62:10
|
LL | type Item<'a, T>;
| ^^^^ -

View file

@ -1,12 +1,14 @@
//@ dont-require-annotations: NOTE
fn main() {
let _x: i32 = [1, 2, 3];
//~^ ERROR mismatched types
//~| expected `i32`, found `[{integer}; 3]`
//~| NOTE expected `i32`, found `[{integer}; 3]`
let x: &[i32] = &[1, 2, 3];
let _y: &i32 = x;
//~^ ERROR mismatched types
//~| expected reference `&i32`
//~| found reference `&[i32]`
//~| expected `&i32`, found `&[i32]`
//~| NOTE expected reference `&i32`
//~| NOTE found reference `&[i32]`
//~| NOTE expected `&i32`, found `&[i32]`
}

View file

@ -1,5 +1,5 @@
error[E0308]: mismatched types
--> $DIR/array-not-vector.rs:2:19
--> $DIR/array-not-vector.rs:4:19
|
LL | let _x: i32 = [1, 2, 3];
| --- ^^^^^^^^^ expected `i32`, found `[{integer}; 3]`
@ -7,7 +7,7 @@ LL | let _x: i32 = [1, 2, 3];
| expected due to this
error[E0308]: mismatched types
--> $DIR/array-not-vector.rs:7:20
--> $DIR/array-not-vector.rs:9:20
|
LL | let _y: &i32 = x;
| ---- ^ expected `&i32`, found `&[i32]`

View file

@ -6,7 +6,8 @@ fn main() {
let y: &mut[_] = &x[2..4];
//~^ ERROR mismatched types
//~| expected mutable reference `&mut [_]`
//~| found reference `&[isize]`
//~| types differ in mutability
//~| NOTE expected mutable reference `&mut [_]`
//~| NOTE found reference `&[isize]`
//~| NOTE types differ in mutability
//~| NOTE expected due to this
}

View file

@ -1,4 +1,5 @@
//@ build-fail
//@ dont-require-annotations: NOTE
trait Tr {
const A: u8 = 255;
@ -31,7 +32,7 @@ impl Tr for u32 {
fn main() {
assert_eq!(<() as Tr>::A, 255);
assert_eq!(<() as Tr>::B, 0); // causes the error above
//~^ constant
//~^ NOTE constant
assert_eq!(<u8 as Tr>::A, 254);
assert_eq!(<u8 as Tr>::B, 255);

View file

@ -1,17 +1,17 @@
error[E0080]: evaluation of `<() as Tr>::B` failed
--> $DIR/defaults-not-assumed-fail.rs:8:19
--> $DIR/defaults-not-assumed-fail.rs:9:19
|
LL | const B: u8 = Self::A + 1;
| ^^^^^^^^^^^ attempt to compute `u8::MAX + 1_u8`, which would overflow
note: erroneous constant encountered
--> $DIR/defaults-not-assumed-fail.rs:33:16
--> $DIR/defaults-not-assumed-fail.rs:34:16
|
LL | assert_eq!(<() as Tr>::B, 0); // causes the error above
| ^^^^^^^^^^^^^
note: erroneous constant encountered
--> $DIR/defaults-not-assumed-fail.rs:33:16
--> $DIR/defaults-not-assumed-fail.rs:34:16
|
LL | assert_eq!(<() as Tr>::B, 0); // causes the error above
| ^^^^^^^^^^^^^
@ -19,7 +19,7 @@ LL | assert_eq!(<() as Tr>::B, 0); // causes the error above
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
note: erroneous constant encountered
--> $DIR/defaults-not-assumed-fail.rs:33:5
--> $DIR/defaults-not-assumed-fail.rs:34:5
|
LL | assert_eq!(<() as Tr>::B, 0); // causes the error above
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -27,7 +27,7 @@ LL | assert_eq!(<() as Tr>::B, 0); // causes the error above
= note: this note originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)
note: erroneous constant encountered
--> $DIR/defaults-not-assumed-fail.rs:33:5
--> $DIR/defaults-not-assumed-fail.rs:34:5
|
LL | assert_eq!(<() as Tr>::B, 0); // causes the error above
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View file

@ -1,6 +1,8 @@
// Test equality constraints on associated types. Check we get type errors
// where we should.
//@ dont-require-annotations: NOTE
pub trait Foo {
type A;
fn boo(&self) -> <Self as Foo>::A;
@ -22,9 +24,9 @@ fn foo1<I: Foo<A=Bar>>(x: I) {
fn foo2<I: Foo>(x: I) {
let _: Bar = x.boo();
//~^ ERROR mismatched types
//~| found associated type `<I as Foo>::A`
//~| expected `Bar`, found
//~| expected struct `Bar`
//~| NOTE found associated type `<I as Foo>::A`
//~| NOTE expected `Bar`, found
//~| NOTE expected struct `Bar`
}

View file

@ -1,5 +1,5 @@
error[E0308]: mismatched types
--> $DIR/associated-types-eq-3.rs:23:18
--> $DIR/associated-types-eq-3.rs:25:18
|
LL | let _: Bar = x.boo();
| --- ^^^^^^^ expected `Bar`, found associated type
@ -14,7 +14,7 @@ LL | fn foo2<I: Foo<A = Bar>>(x: I) {
| +++++++++
error[E0271]: type mismatch resolving `<isize as Foo>::A == Bar`
--> $DIR/associated-types-eq-3.rs:38:10
--> $DIR/associated-types-eq-3.rs:40:10
|
LL | foo1(a);
| ---- ^ type mismatch resolving `<isize as Foo>::A == Bar`
@ -22,24 +22,24 @@ LL | foo1(a);
| required by a bound introduced by this call
|
note: expected this to be `Bar`
--> $DIR/associated-types-eq-3.rs:12:14
--> $DIR/associated-types-eq-3.rs:14:14
|
LL | type A = usize;
| ^^^^^
note: required by a bound in `foo1`
--> $DIR/associated-types-eq-3.rs:18:16
--> $DIR/associated-types-eq-3.rs:20:16
|
LL | fn foo1<I: Foo<A=Bar>>(x: I) {
| ^^^^^ required by this bound in `foo1`
error[E0271]: type mismatch resolving `<isize as Foo>::A == Bar`
--> $DIR/associated-types-eq-3.rs:40:9
--> $DIR/associated-types-eq-3.rs:42:9
|
LL | baz(&a);
| ^^ type mismatch resolving `<isize as Foo>::A == Bar`
|
note: expected this to be `Bar`
--> $DIR/associated-types-eq-3.rs:12:14
--> $DIR/associated-types-eq-3.rs:14:14
|
LL | type A = usize;
| ^^^^^

View file

@ -1,5 +1,7 @@
// Test type checking of uses of associated types via sugary paths.
//@ dont-require-annotations: NOTE
pub trait Foo {
type A;
@ -18,7 +20,7 @@ pub fn f2<T: Foo>(a: T) -> T::A {
pub fn f1_int_int() {
f1(2i32, 4i32);
//~^ ERROR mismatched types
//~| expected `u32`, found `i32`
//~| NOTE expected `u32`, found `i32`
}
pub fn f1_int_uint() {
@ -40,7 +42,7 @@ pub fn f1_uint_int() {
pub fn f2_int() {
let _: i32 = f2(2i32);
//~^ ERROR mismatched types
//~| expected `i32`, found `u32`
//~| NOTE expected `i32`, found `u32`
}
pub fn main() { }

View file

@ -1,5 +1,5 @@
error[E0308]: mismatched types
--> $DIR/associated-types-path-2.rs:19:14
--> $DIR/associated-types-path-2.rs:21:14
|
LL | f1(2i32, 4i32);
| -- ^^^^ expected `u32`, found `i32`
@ -7,7 +7,7 @@ LL | f1(2i32, 4i32);
| arguments to this function are incorrect
|
note: function defined here
--> $DIR/associated-types-path-2.rs:13:8
--> $DIR/associated-types-path-2.rs:15:8
|
LL | pub fn f1<T: Foo>(a: T, x: T::A) {}
| ^^ -------
@ -18,7 +18,7 @@ LL + f1(2i32, 4u32);
|
error[E0277]: the trait bound `u32: Foo` is not satisfied
--> $DIR/associated-types-path-2.rs:29:8
--> $DIR/associated-types-path-2.rs:31:8
|
LL | f1(2u32, 4u32);
| -- ^^^^ the trait `Foo` is not implemented for `u32`
@ -27,13 +27,13 @@ LL | f1(2u32, 4u32);
|
= help: the trait `Foo` is implemented for `i32`
note: required by a bound in `f1`
--> $DIR/associated-types-path-2.rs:13:14
--> $DIR/associated-types-path-2.rs:15:14
|
LL | pub fn f1<T: Foo>(a: T, x: T::A) {}
| ^^^ required by this bound in `f1`
error[E0277]: the trait bound `u32: Foo` is not satisfied
--> $DIR/associated-types-path-2.rs:29:14
--> $DIR/associated-types-path-2.rs:31:14
|
LL | f1(2u32, 4u32);
| ^^^^ the trait `Foo` is not implemented for `u32`
@ -41,7 +41,7 @@ LL | f1(2u32, 4u32);
= help: the trait `Foo` is implemented for `i32`
error[E0277]: the trait bound `u32: Foo` is not satisfied
--> $DIR/associated-types-path-2.rs:35:8
--> $DIR/associated-types-path-2.rs:37:8
|
LL | f1(2u32, 4i32);
| -- ^^^^ the trait `Foo` is not implemented for `u32`
@ -50,13 +50,13 @@ LL | f1(2u32, 4i32);
|
= help: the trait `Foo` is implemented for `i32`
note: required by a bound in `f1`
--> $DIR/associated-types-path-2.rs:13:14
--> $DIR/associated-types-path-2.rs:15:14
|
LL | pub fn f1<T: Foo>(a: T, x: T::A) {}
| ^^^ required by this bound in `f1`
error[E0277]: the trait bound `u32: Foo` is not satisfied
--> $DIR/associated-types-path-2.rs:35:14
--> $DIR/associated-types-path-2.rs:37:14
|
LL | f1(2u32, 4i32);
| ^^^^ the trait `Foo` is not implemented for `u32`
@ -64,7 +64,7 @@ LL | f1(2u32, 4i32);
= help: the trait `Foo` is implemented for `i32`
error[E0308]: mismatched types
--> $DIR/associated-types-path-2.rs:41:18
--> $DIR/associated-types-path-2.rs:43:18
|
LL | let _: i32 = f2(2i32);
| --- ^^^^^^^^ expected `i32`, found `u32`

View file

@ -1,5 +1,5 @@
error[E0308]: mismatched types
--> $DIR/substs-ppaux.rs:23:17
--> $DIR/substs-ppaux.rs:22:17
|
LL | / fn bar<'a, T>()
LL | | where
@ -19,7 +19,7 @@ LL | let x: () = <i8 as Foo<'static, 'static, u8>>::bar::<'static, char>();
| ++
error[E0308]: mismatched types
--> $DIR/substs-ppaux.rs:31:17
--> $DIR/substs-ppaux.rs:30:17
|
LL | / fn bar<'a, T>()
LL | | where
@ -39,7 +39,7 @@ LL | let x: () = <i8 as Foo<'static, 'static, u32>>::bar::<'static, char>();
| ++
error[E0308]: mismatched types
--> $DIR/substs-ppaux.rs:39:17
--> $DIR/substs-ppaux.rs:38:17
|
LL | fn baz() {}
| -------- associated function `baz` defined here
@ -57,7 +57,7 @@ LL | let x: () = <i8 as Foo<'static, 'static, u8>>::baz();
| ++
error[E0308]: mismatched types
--> $DIR/substs-ppaux.rs:47:17
--> $DIR/substs-ppaux.rs:46:17
|
LL | / fn foo<'z>()
LL | | where
@ -77,13 +77,13 @@ LL | let x: () = foo::<'static>();
| ++
error[E0277]: the trait bound `str: Foo<'_, '_, u8>` is not satisfied
--> $DIR/substs-ppaux.rs:55:6
--> $DIR/substs-ppaux.rs:54:6
|
LL | <str as Foo<u8>>::bar;
| ^^^ the trait `Sized` is not implemented for `str`
|
note: required for `str` to implement `Foo<'_, '_, u8>`
--> $DIR/substs-ppaux.rs:15:20
--> $DIR/substs-ppaux.rs:14:20
|
LL | impl<'a, 'b, T, S> Foo<'a, 'b, S> for T {}
| - ^^^^^^^^^^^^^^ ^

View file

@ -1,7 +1,6 @@
//
//@ revisions: verbose normal
//
//@[verbose] compile-flags: -Z verbose-internals
//@ dont-require-annotations: NOTE
trait Foo<'b, 'c, S = u32> {
fn bar<'a, T>()
@ -22,35 +21,35 @@ where
{
let x: () = <i8 as Foo<'static, 'static, u8>>::bar::<'static, char>;
//[verbose]~^ ERROR mismatched types
//[verbose]~| expected unit type `()`
//[verbose]~| found fn item `fn() {<i8 as Foo<'static, 'static, u8>>::bar::<'static, char>}`
//[verbose]~| NOTE expected unit type `()`
//[verbose]~| NOTE found fn item `fn() {<i8 as Foo<'static, 'static, u8>>::bar::<'static, char>}`
//[normal]~^^^^ ERROR mismatched types
//[normal]~| expected unit type `()`
//[normal]~| found fn item `fn() {<i8 as Foo<'static, 'static, u8>>::bar::<'static, char>}`
//[normal]~| NOTE expected unit type `()`
//[normal]~| NOTE found fn item `fn() {<i8 as Foo<'static, 'static, u8>>::bar::<'static, char>}`
let x: () = <i8 as Foo<'static, 'static, u32>>::bar::<'static, char>;
//[verbose]~^ ERROR mismatched types
//[verbose]~| expected unit type `()`
//[verbose]~| found fn item `fn() {<i8 as Foo<'static, 'static>>::bar::<'static, char>}`
//[verbose]~| NOTE expected unit type `()`
//[verbose]~| NOTE found fn item `fn() {<i8 as Foo<'static, 'static>>::bar::<'static, char>}`
//[normal]~^^^^ ERROR mismatched types
//[normal]~| expected unit type `()`
//[normal]~| found fn item `fn() {<i8 as Foo<'static, 'static>>::bar::<'static, char>}`
//[normal]~| NOTE expected unit type `()`
//[normal]~| NOTE found fn item `fn() {<i8 as Foo<'static, 'static>>::bar::<'static, char>}`
let x: () = <i8 as Foo<'static, 'static, u8>>::baz;
//[verbose]~^ ERROR mismatched types
//[verbose]~| expected unit type `()`
//[verbose]~| found fn item `fn() {<i8 as Foo<'static, 'static, u8>>::baz}`
//[verbose]~| NOTE expected unit type `()`
//[verbose]~| NOTE found fn item `fn() {<i8 as Foo<'static, 'static, u8>>::baz}`
//[normal]~^^^^ ERROR mismatched types
//[normal]~| expected unit type `()`
//[normal]~| found fn item `fn() {<i8 as Foo<'static, 'static, u8>>::baz}`
//[normal]~| NOTE expected unit type `()`
//[normal]~| NOTE found fn item `fn() {<i8 as Foo<'static, 'static, u8>>::baz}`
let x: () = foo::<'static>;
//[verbose]~^ ERROR mismatched types
//[verbose]~| expected unit type `()`
//[verbose]~| found fn item `fn() {foo::<'static>}`
//[verbose]~| NOTE expected unit type `()`
//[verbose]~| NOTE found fn item `fn() {foo::<'static>}`
//[normal]~^^^^ ERROR mismatched types
//[normal]~| expected unit type `()`
//[normal]~| found fn item `fn() {foo::<'static>}`
//[normal]~| NOTE expected unit type `()`
//[normal]~| NOTE found fn item `fn() {foo::<'static>}`
<str as Foo<u8>>::bar;
//[verbose]~^ ERROR the trait bound `str: Foo<'?0, '?1, u8>` is not satisfied

View file

@ -1,5 +1,5 @@
error[E0308]: mismatched types
--> $DIR/substs-ppaux.rs:23:17
--> $DIR/substs-ppaux.rs:22:17
|
LL | / fn bar<'a, T>()
LL | | where
@ -19,7 +19,7 @@ LL | let x: () = <i8 as Foo<'static, 'static, u8>>::bar::<'static, char>();
| ++
error[E0308]: mismatched types
--> $DIR/substs-ppaux.rs:31:17
--> $DIR/substs-ppaux.rs:30:17
|
LL | / fn bar<'a, T>()
LL | | where
@ -39,7 +39,7 @@ LL | let x: () = <i8 as Foo<'static, 'static, u32>>::bar::<'static, char>();
| ++
error[E0308]: mismatched types
--> $DIR/substs-ppaux.rs:39:17
--> $DIR/substs-ppaux.rs:38:17
|
LL | fn baz() {}
| -------- associated function `baz` defined here
@ -57,7 +57,7 @@ LL | let x: () = <i8 as Foo<'static, 'static, u8>>::baz();
| ++
error[E0308]: mismatched types
--> $DIR/substs-ppaux.rs:47:17
--> $DIR/substs-ppaux.rs:46:17
|
LL | / fn foo<'z>()
LL | | where
@ -77,13 +77,13 @@ LL | let x: () = foo::<'static>();
| ++
error[E0277]: the trait bound `str: Foo<'?0, '?1, u8>` is not satisfied
--> $DIR/substs-ppaux.rs:55:6
--> $DIR/substs-ppaux.rs:54:6
|
LL | <str as Foo<u8>>::bar;
| ^^^ the trait `Sized` is not implemented for `str`
|
note: required for `str` to implement `Foo<'?0, '?1, u8>`
--> $DIR/substs-ppaux.rs:15:20
--> $DIR/substs-ppaux.rs:14:20
|
LL | impl<'a, 'b, T, S> Foo<'a, 'b, S> for T {}
| - ^^^^^^^^^^^^^^ ^

View file

@ -1,5 +1,7 @@
// Test that we can do shifts by any integral type.
//@ dont-require-annotations: NOTE
struct Panolpy {
char: char,
str: &'static str,
@ -24,7 +26,7 @@ fn foo(p: &Panolpy) {
// Type of the result follows the LHS, not the RHS:
let _: i32 = 22_i64 >> 1_i32;
//~^ ERROR mismatched types
//~| expected `i32`, found `i64`
//~| NOTE expected `i32`, found `i64`
}
fn main() {

View file

@ -1,5 +1,5 @@
error[E0277]: no implementation for `{integer} >> char`
--> $DIR/shift-various-bad-types.rs:9:8
--> $DIR/shift-various-bad-types.rs:11:8
|
LL | 22 >> p.char;
| ^^ no implementation for `{integer} >> char`
@ -17,7 +17,7 @@ LL | 22 >> p.char;
and 568 others
error[E0277]: no implementation for `{integer} >> &str`
--> $DIR/shift-various-bad-types.rs:12:8
--> $DIR/shift-various-bad-types.rs:14:8
|
LL | 22 >> p.str;
| ^^ no implementation for `{integer} >> &str`
@ -35,7 +35,7 @@ LL | 22 >> p.str;
and 568 others
error[E0277]: no implementation for `{integer} >> &Panolpy`
--> $DIR/shift-various-bad-types.rs:15:8
--> $DIR/shift-various-bad-types.rs:17:8
|
LL | 22 >> p;
| ^^ no implementation for `{integer} >> &Panolpy`
@ -53,7 +53,7 @@ LL | 22 >> p;
and 568 others
error[E0308]: mismatched types
--> $DIR/shift-various-bad-types.rs:25:18
--> $DIR/shift-various-bad-types.rs:27:18
|
LL | let _: i32 = 22_i64 >> 1_i32;
| --- ^^^^^^^^^^^^^^^ expected `i32`, found `i64`

View file

@ -1,7 +1,9 @@
//@ dont-require-annotations: NOTE
mod foo { pub mod foo { } }
use foo::foo;
//~^ ERROR the name `foo` is defined multiple times
//~| `foo` reimported here
//~| NOTE `foo` reimported here
fn main() {}

View file

@ -1,5 +1,5 @@
error[E0255]: the name `foo` is defined multiple times
--> $DIR/blind-item-item-shadow.rs:3:5
--> $DIR/blind-item-item-shadow.rs:5:5
|
LL | mod foo { pub mod foo { } }
| ------- previous definition of the module `foo` here

View file

@ -1,6 +1,8 @@
//@ dont-require-annotations: NOTE
fn main() {
while true { //~ WARN denote infinite loops with
true //~ ERROR mismatched types
//~| expected `()`, found `bool`
//~| NOTE expected `()`, found `bool`
}
}

View file

@ -1,5 +1,5 @@
warning: denote infinite loops with `loop { ... }`
--> $DIR/block-must-not-have-result-while.rs:2:5
--> $DIR/block-must-not-have-result-while.rs:4:5
|
LL | while true {
| ^^^^^^^^^^ help: use `loop`
@ -7,7 +7,7 @@ LL | while true {
= note: `#[warn(while_true)]` on by default
error[E0308]: mismatched types
--> $DIR/block-must-not-have-result-while.rs:3:9
--> $DIR/block-must-not-have-result-while.rs:5:9
|
LL | / while true {
LL | | true

View file

@ -1,3 +1,5 @@
//@ dont-require-annotations: NOTE
mod a {
pub enum Enum {
EnumStructVariant { x: u8, y: u8, z: u8 }
@ -6,7 +8,7 @@ mod a {
pub fn get_enum_struct_variant() -> () {
Enum::EnumStructVariant { x: 1, y: 2, z: 3 }
//~^ ERROR mismatched types
//~| expected `()`, found `Enum`
//~| NOTE expected `()`, found `Enum`
}
}
@ -19,7 +21,7 @@ mod b {
match enum_struct_variant {
a::Enum::EnumStructVariant { x, y, z } => {
//~^ ERROR mismatched types
//~| expected `()`, found `Enum`
//~| NOTE expected `()`, found `Enum`
}
}
}

View file

@ -1,5 +1,5 @@
error[E0308]: mismatched types
--> $DIR/issue-13624.rs:7:5
--> $DIR/issue-13624.rs:9:5
|
LL | pub fn get_enum_struct_variant() -> () {
| -- expected `()` because of return type
@ -7,7 +7,7 @@ LL | Enum::EnumStructVariant { x: 1, y: 2, z: 3 }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found `Enum`
error[E0308]: mismatched types
--> $DIR/issue-13624.rs:20:9
--> $DIR/issue-13624.rs:22:9
|
LL | match enum_struct_variant {
| ------------------- this expression has type `()`

View file

@ -1,7 +1,7 @@
fn main() {
fn main() { //~ NOTE expected `()` because of default return type
&panic!()
//~^ ERROR mismatched types
//~| expected unit type `()`
//~| found reference `&_`
//~| expected `()`, found `&_`
//~| NOTE expected unit type `()`
//~| NOTE found reference `&_`
//~| NOTE expected `()`, found `&_`
}

View file

@ -1,11 +1,13 @@
//@ dont-require-annotations: NOTE
#![allow(dead_code)]
fn main() {
// Original borrow ends at end of function
let mut x = 1;
let y = &mut x;
//~^ mutable borrow occurs here
//~^ NOTE mutable borrow occurs here
let z = &x; //~ ERROR cannot borrow
//~^ immutable borrow occurs here
//~^ NOTE immutable borrow occurs here
z.use_ref();
y.use_mut();
}
@ -16,9 +18,9 @@ fn foo() {
// Original borrow ends at end of match arm
let mut x = 1;
let y = &x;
//~^ immutable borrow occurs here
//~^ NOTE immutable borrow occurs here
let z = &mut x; //~ ERROR cannot borrow
//~^ mutable borrow occurs here
//~^ NOTE mutable borrow occurs here
z.use_mut();
y.use_ref();
}
@ -31,9 +33,9 @@ fn bar() {
|| {
let mut x = 1;
let y = &mut x;
//~^ first mutable borrow occurs here
//~^ NOTE first mutable borrow occurs here
let z = &mut x; //~ ERROR cannot borrow
//~^ second mutable borrow occurs here
//~^ NOTE second mutable borrow occurs here
z.use_mut();
y.use_mut();
};

View file

@ -1,5 +1,5 @@
error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable
--> $DIR/borrowck-report-with-custom-diagnostic.rs:7:13
--> $DIR/borrowck-report-with-custom-diagnostic.rs:9:13
|
LL | let y = &mut x;
| ------ mutable borrow occurs here
@ -11,7 +11,7 @@ LL | y.use_mut();
| - mutable borrow later used here
error[E0502]: cannot borrow `x` as mutable because it is also borrowed as immutable
--> $DIR/borrowck-report-with-custom-diagnostic.rs:20:21
--> $DIR/borrowck-report-with-custom-diagnostic.rs:22:21
|
LL | let y = &x;
| -- immutable borrow occurs here
@ -23,7 +23,7 @@ LL | y.use_ref();
| - immutable borrow later used here
error[E0499]: cannot borrow `x` as mutable more than once at a time
--> $DIR/borrowck-report-with-custom-diagnostic.rs:35:17
--> $DIR/borrowck-report-with-custom-diagnostic.rs:37:17
|
LL | let y = &mut x;
| ------ first mutable borrow occurs here

View file

@ -1,14 +1,16 @@
// Regression test for #81899.
// The `panic!()` below is important to trigger the fixed ICE.
//@ dont-require-annotations: NOTE
const _CONST: &[u8] = &f(&[], |_| {}); //~ ERROR evaluation of constant value failed
//~^ constant
//~^ NOTE constant
const fn f<F>(_: &[u8], _: F) -> &[u8]
where
F: FnMut(&u8),
{
panic!() //~ inside `f
panic!() //~ NOTE inside `f
}
fn main() {}

View file

@ -1,17 +1,17 @@
error[E0080]: evaluation of constant value failed
--> $DIR/issue-81899.rs:4:24
--> $DIR/issue-81899.rs:6:24
|
LL | const _CONST: &[u8] = &f(&[], |_| {});
| ^^^^^^^^^^^^^^ evaluation panicked: explicit panic
|
note: inside `f::<{closure@$DIR/issue-81899.rs:4:31: 4:34}>`
--> $DIR/issue-81899.rs:11:5
note: inside `f::<{closure@$DIR/issue-81899.rs:6:31: 6:34}>`
--> $DIR/issue-81899.rs:13:5
|
LL | panic!()
| ^^^^^^^^ the failure occurred here
note: erroneous constant encountered
--> $DIR/issue-81899.rs:4:23
--> $DIR/issue-81899.rs:6:23
|
LL | const _CONST: &[u8] = &f(&[], |_| {});
| ^^^^^^^^^^^^^^^

View file

@ -1,13 +1,15 @@
// Regression test related to issue 88434
//@ dont-require-annotations: NOTE
const _CONST: &() = &f(&|_| {}); //~ ERROR evaluation of constant value failed
//~^ constant
//~^ NOTE constant
const fn f<F>(_: &F)
where
F: FnMut(&u8),
{
panic!() //~ inside `f
panic!() //~ NOTE inside `f
}
fn main() { }

View file

@ -1,17 +1,17 @@
error[E0080]: evaluation of constant value failed
--> $DIR/issue-88434-minimal-example.rs:3:22
--> $DIR/issue-88434-minimal-example.rs:5:22
|
LL | const _CONST: &() = &f(&|_| {});
| ^^^^^^^^^^ evaluation panicked: explicit panic
|
note: inside `f::<{closure@$DIR/issue-88434-minimal-example.rs:3:25: 3:28}>`
--> $DIR/issue-88434-minimal-example.rs:10:5
note: inside `f::<{closure@$DIR/issue-88434-minimal-example.rs:5:25: 5:28}>`
--> $DIR/issue-88434-minimal-example.rs:12:5
|
LL | panic!()
| ^^^^^^^^ the failure occurred here
note: erroneous constant encountered
--> $DIR/issue-88434-minimal-example.rs:3:21
--> $DIR/issue-88434-minimal-example.rs:5:21
|
LL | const _CONST: &() = &f(&|_| {});
| ^^^^^^^^^^^

View file

@ -1,13 +1,15 @@
// Regression test for issue 88434
//@ dont-require-annotations: NOTE
const _CONST: &[u8] = &f(&[], |_| {}); //~ ERROR evaluation of constant value failed
//~^ constant
//~^ NOTE constant
const fn f<F>(_: &[u8], _: F) -> &[u8]
where
F: FnMut(&u8),
{
panic!() //~ inside `f
panic!() //~ NOTE inside `f
}
fn main() { }

View file

@ -1,17 +1,17 @@
error[E0080]: evaluation of constant value failed
--> $DIR/issue-88434-removal-index-should-be-less.rs:3:24
--> $DIR/issue-88434-removal-index-should-be-less.rs:5:24
|
LL | const _CONST: &[u8] = &f(&[], |_| {});
| ^^^^^^^^^^^^^^ evaluation panicked: explicit panic
|
note: inside `f::<{closure@$DIR/issue-88434-removal-index-should-be-less.rs:3:31: 3:34}>`
--> $DIR/issue-88434-removal-index-should-be-less.rs:10:5
note: inside `f::<{closure@$DIR/issue-88434-removal-index-should-be-less.rs:5:31: 5:34}>`
--> $DIR/issue-88434-removal-index-should-be-less.rs:12:5
|
LL | panic!()
| ^^^^^^^^ the failure occurred here
note: erroneous constant encountered
--> $DIR/issue-88434-removal-index-should-be-less.rs:3:23
--> $DIR/issue-88434-removal-index-should-be-less.rs:5:23
|
LL | const _CONST: &[u8] = &f(&[], |_| {});
| ^^^^^^^^^^^^^^^

View file

@ -1,4 +1,5 @@
//@ check-fail
//@ dont-require-annotations: NOTE
trait Trait<'a> {}
@ -18,7 +19,7 @@ fn change_lt_ba<'a, 'b: 'a>(x: *mut dyn Trait<'a>) -> *mut dyn Trait<'b> {
fn change_lt_hr<'a>(x: *mut dyn Trait<'a>) -> *mut dyn for<'b> Trait<'b> {
x as _ //~ error: lifetime may not live long enough
//~^ error: mismatched types
//~| one type is more general than the other
//~| NOTE one type is more general than the other
}
trait Assocked {

View file

@ -1,5 +1,5 @@
error: lifetime may not live long enough
--> $DIR/ptr-to-trait-obj-different-regions-misc.rs:6:5
--> $DIR/ptr-to-trait-obj-different-regions-misc.rs:7:5
|
LL | fn change_lt<'a, 'b>(x: *mut dyn Trait<'a>) -> *mut dyn Trait<'b> {
| -- -- lifetime `'b` defined here
@ -14,7 +14,7 @@ LL | x as _
= help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
error: lifetime may not live long enough
--> $DIR/ptr-to-trait-obj-different-regions-misc.rs:6:5
--> $DIR/ptr-to-trait-obj-different-regions-misc.rs:7:5
|
LL | fn change_lt<'a, 'b>(x: *mut dyn Trait<'a>) -> *mut dyn Trait<'b> {
| -- -- lifetime `'b` defined here
@ -31,7 +31,7 @@ LL | x as _
help: `'b` and `'a` must be the same: replace one with the other
error: lifetime may not live long enough
--> $DIR/ptr-to-trait-obj-different-regions-misc.rs:11:5
--> $DIR/ptr-to-trait-obj-different-regions-misc.rs:12:5
|
LL | fn change_lt_ab<'a: 'b, 'b>(x: *mut dyn Trait<'a>) -> *mut dyn Trait<'b> {
| -- -- lifetime `'b` defined here
@ -46,7 +46,7 @@ LL | x as _
= help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
error: lifetime may not live long enough
--> $DIR/ptr-to-trait-obj-different-regions-misc.rs:15:5
--> $DIR/ptr-to-trait-obj-different-regions-misc.rs:16:5
|
LL | fn change_lt_ba<'a, 'b: 'a>(x: *mut dyn Trait<'a>) -> *mut dyn Trait<'b> {
| -- -- lifetime `'b` defined here
@ -61,7 +61,7 @@ LL | x as _
= help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
error: lifetime may not live long enough
--> $DIR/ptr-to-trait-obj-different-regions-misc.rs:19:5
--> $DIR/ptr-to-trait-obj-different-regions-misc.rs:20:5
|
LL | fn change_lt_hr<'a>(x: *mut dyn Trait<'a>) -> *mut dyn for<'b> Trait<'b> {
| -- lifetime `'a` defined here
@ -74,7 +74,7 @@ LL | fn change_lt_hr<'a>(x: *mut dyn Trait<'a>) -> *mut dyn for<'b> Trait<'b> +
| ++++
error[E0308]: mismatched types
--> $DIR/ptr-to-trait-obj-different-regions-misc.rs:19:5
--> $DIR/ptr-to-trait-obj-different-regions-misc.rs:20:5
|
LL | x as _
| ^^^^^^ one type is more general than the other
@ -83,7 +83,7 @@ LL | x as _
found trait object `dyn Trait<'_>`
error: lifetime may not live long enough
--> $DIR/ptr-to-trait-obj-different-regions-misc.rs:31:5
--> $DIR/ptr-to-trait-obj-different-regions-misc.rs:32:5
|
LL | fn change_assoc_0<'a, 'b>(
| -- -- lifetime `'b` defined here
@ -99,7 +99,7 @@ LL | x as _
= help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
error: lifetime may not live long enough
--> $DIR/ptr-to-trait-obj-different-regions-misc.rs:31:5
--> $DIR/ptr-to-trait-obj-different-regions-misc.rs:32:5
|
LL | fn change_assoc_0<'a, 'b>(
| -- -- lifetime `'b` defined here
@ -119,7 +119,7 @@ help: `'b` and `'a` must be the same: replace one with the other
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: lifetime may not live long enough
--> $DIR/ptr-to-trait-obj-different-regions-misc.rs:38:5
--> $DIR/ptr-to-trait-obj-different-regions-misc.rs:39:5
|
LL | fn change_assoc_1<'a, 'b>(
| -- -- lifetime `'b` defined here
@ -135,7 +135,7 @@ LL | x as _
= help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
error: lifetime may not live long enough
--> $DIR/ptr-to-trait-obj-different-regions-misc.rs:38:5
--> $DIR/ptr-to-trait-obj-different-regions-misc.rs:39:5
|
LL | fn change_assoc_1<'a, 'b>(
| -- -- lifetime `'b` defined here
@ -155,7 +155,7 @@ help: `'b` and `'a` must be the same: replace one with the other
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0521]: borrowed data escapes outside of function
--> $DIR/ptr-to-trait-obj-different-regions-misc.rs:45:5
--> $DIR/ptr-to-trait-obj-different-regions-misc.rs:46:5
|
LL | fn extend_to_static<'a>(ptr: *const dyn Trait<'a>) {
| -- ---

View file

@ -1,10 +1,12 @@
//@ dont-require-annotations: NOTE
fn f(x: &mut i32) {}
fn main() {
let x = 0;
f(&x);
//~^ ERROR mismatched types
//~| expected mutable reference `&mut i32`
//~| found reference `&{integer}`
//~| types differ in mutability
//~| NOTE expected mutable reference `&mut i32`
//~| NOTE found reference `&{integer}`
//~| NOTE types differ in mutability
}

View file

@ -1,5 +1,5 @@
error[E0308]: mismatched types
--> $DIR/coerce-mut.rs:5:7
--> $DIR/coerce-mut.rs:7:7
|
LL | f(&x);
| - ^^ types differ in mutability
@ -9,7 +9,7 @@ LL | f(&x);
= note: expected mutable reference `&mut i32`
found reference `&{integer}`
note: function defined here
--> $DIR/coerce-mut.rs:1:4
--> $DIR/coerce-mut.rs:3:4
|
LL | fn f(x: &mut i32) {}
| ^ -----------

View file

@ -3,5 +3,6 @@
fn main() {
let _: &[i32] = [0];
//~^ ERROR mismatched types
//~| expected `&[i32]`, found `[{integer}; 1]`
//~| NOTE expected `&[i32]`, found `[{integer}; 1]`
//~| NOTE expected due to this
}

View file

@ -2,6 +2,9 @@
// Making this compile was a feature request in rust-lang/rust#34117 but this is currently
// "working as intended". Allowing "deep pointer coercion" seems footgun-prone, and would
// require proceeding carefully.
//@ dont-require-annotations: NOTE
use std::ops::{Deref, DerefMut};
struct Foo(i32);
@ -34,7 +37,7 @@ fn make_foo(_: *mut *mut Foo) {
fn main() {
let mut result: SmartPtr<Foo> = SmartPtr(std::ptr::null_mut());
make_foo(&mut &mut *result); //~ ERROR mismatched types
//~^ expected `*mut *mut Foo`, found `&mut &mut Foo`
//~^ NOTE expected `*mut *mut Foo`, found `&mut &mut Foo`
make_foo(out(&mut result)); // works, but makes one wonder why above coercion cannot happen
}

View file

@ -1,5 +1,5 @@
error[E0308]: mismatched types
--> $DIR/mut-mut-wont-coerce.rs:36:14
--> $DIR/mut-mut-wont-coerce.rs:39:14
|
LL | make_foo(&mut &mut *result);
| -------- ^^^^^^^^^^^^^^^^^ expected `*mut *mut Foo`, found `&mut &mut Foo`
@ -9,7 +9,7 @@ LL | make_foo(&mut &mut *result);
= note: expected raw pointer `*mut *mut Foo`
found mutable reference `&mut &mut Foo`
note: function defined here
--> $DIR/mut-mut-wont-coerce.rs:30:4
--> $DIR/mut-mut-wont-coerce.rs:33:4
|
LL | fn make_foo(_: *mut *mut Foo) {
| ^^^^^^^^ ----------------

View file

@ -9,11 +9,11 @@ struct CantParam(ImplementsConstParamTy);
impl std::marker::UnsizedConstParamTy for CantParam {}
//~^ error: the type `CantParam` does not `#[derive(PartialEq)]`
//~| the trait bound `CantParam: Eq` is not satisfied
//~| ERROR the trait bound `CantParam: Eq` is not satisfied
#[derive(std::marker::UnsizedConstParamTy)]
//~^ error: the type `CantParamDerive` does not `#[derive(PartialEq)]`
//~| the trait bound `CantParamDerive: Eq` is not satisfied
//~| ERROR the trait bound `CantParamDerive: Eq` is not satisfied
struct CantParamDerive(ImplementsConstParamTy);
fn check<T: std::marker::UnsizedConstParamTy>() {}

View file

@ -1,3 +1,5 @@
//@ dont-require-annotations: NOTE
pub struct Example<const N: usize = 13>;
pub struct Example2<T = u32, const N: usize = 13>(T);
pub struct Example3<const N: usize = 13, T = u32>(T);
@ -6,17 +8,17 @@ pub struct Example4<const N: usize = 13, const M: usize = 4>;
fn main() {
let e: Example<13> = ();
//~^ ERROR mismatched types
//~| expected struct `Example`
//~| NOTE expected struct `Example`
let e: Example2<u32, 13> = ();
//~^ ERROR mismatched types
//~| expected struct `Example2`
//~| NOTE expected struct `Example2`
let e: Example3<13, u32> = ();
//~^ ERROR mismatched types
//~| expected struct `Example3`
//~| NOTE expected struct `Example3`
let e: Example3<7> = ();
//~^ ERROR mismatched types
//~| expected struct `Example3<7>`
//~| NOTE expected struct `Example3<7>`
let e: Example4<7> = ();
//~^ ERROR mismatched types
//~| expected struct `Example4<7>`
//~| NOTE expected struct `Example4<7>`
}

View file

@ -1,5 +1,5 @@
error[E0308]: mismatched types
--> $DIR/mismatch.rs:7:26
--> $DIR/mismatch.rs:9:26
|
LL | let e: Example<13> = ();
| ----------- ^^ expected `Example`, found `()`
@ -10,7 +10,7 @@ LL | let e: Example<13> = ();
found unit type `()`
error[E0308]: mismatched types
--> $DIR/mismatch.rs:10:32
--> $DIR/mismatch.rs:12:32
|
LL | let e: Example2<u32, 13> = ();
| ----------------- ^^ expected `Example2`, found `()`
@ -21,7 +21,7 @@ LL | let e: Example2<u32, 13> = ();
found unit type `()`
error[E0308]: mismatched types
--> $DIR/mismatch.rs:13:32
--> $DIR/mismatch.rs:15:32
|
LL | let e: Example3<13, u32> = ();
| ----------------- ^^ expected `Example3`, found `()`
@ -32,7 +32,7 @@ LL | let e: Example3<13, u32> = ();
found unit type `()`
error[E0308]: mismatched types
--> $DIR/mismatch.rs:16:26
--> $DIR/mismatch.rs:18:26
|
LL | let e: Example3<7> = ();
| ----------- ^^ expected `Example3<7>`, found `()`
@ -43,7 +43,7 @@ LL | let e: Example3<7> = ();
found unit type `()`
error[E0308]: mismatched types
--> $DIR/mismatch.rs:19:26
--> $DIR/mismatch.rs:21:26
|
LL | let e: Example4<7> = ();
| ----------- ^^ expected `Example4<7>`, found `()`

View file

@ -1,3 +1,5 @@
//@ dont-require-annotations: NOTE
#![allow(incomplete_features)]
#![feature(adt_const_params, unsized_const_params)]
@ -6,7 +8,7 @@ struct T<const B: &'static bool>;
impl<const B: &'static bool> T<B> {
const fn set_false(&self) {
unsafe {
*(B as *const bool as *mut bool) = false; //~ inside `T
*(B as *const bool as *mut bool) = false; //~ NOTE inside `T
}
}
}

View file

@ -1,11 +1,11 @@
error[E0080]: evaluation of constant value failed
--> $DIR/issue-100313.rs:16:5
--> $DIR/issue-100313.rs:18:5
|
LL | x.set_false();
| ^^^^^^^^^^^^^ writing to ALLOC0 which is read-only
|
note: inside `T::<&true>::set_false`
--> $DIR/issue-100313.rs:9:13
--> $DIR/issue-100313.rs:11:13
|
LL | *(B as *const bool as *mut bool) = false;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the failure occurred here

View file

@ -1,11 +1,11 @@
error[E0080]: evaluation of constant value failed
--> $DIR/invalid-patterns.rs:38:32
--> $DIR/invalid-patterns.rs:40:32
|
LL | get_flag::<false, { unsafe { char_raw.character } }>();
| ^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory
error[E0080]: it is undefined behavior to use this value
--> $DIR/invalid-patterns.rs:41:14
--> $DIR/invalid-patterns.rs:43:14
|
LL | get_flag::<{ unsafe { bool_raw.boolean } }, 'z'>();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0x42, but expected a boolean
@ -16,7 +16,7 @@ LL | get_flag::<{ unsafe { bool_raw.boolean } }, 'z'>();
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/invalid-patterns.rs:43:14
--> $DIR/invalid-patterns.rs:45:14
|
LL | get_flag::<{ unsafe { bool_raw.boolean } }, { unsafe { char_raw.character } }>();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0x42, but expected a boolean
@ -27,31 +27,31 @@ LL | get_flag::<{ unsafe { bool_raw.boolean } }, { unsafe { char_raw.character
}
error[E0080]: evaluation of constant value failed
--> $DIR/invalid-patterns.rs:43:58
--> $DIR/invalid-patterns.rs:45:58
|
LL | get_flag::<{ unsafe { bool_raw.boolean } }, { unsafe { char_raw.character } }>();
| ^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory
error[E0308]: mismatched types
--> $DIR/invalid-patterns.rs:29:21
--> $DIR/invalid-patterns.rs:31:21
|
LL | get_flag::<false, 0xFF>();
| ^^^^ expected `char`, found `u8`
error[E0308]: mismatched types
--> $DIR/invalid-patterns.rs:31:14
--> $DIR/invalid-patterns.rs:33:14
|
LL | get_flag::<7, 'c'>();
| ^ expected `bool`, found integer
error[E0308]: mismatched types
--> $DIR/invalid-patterns.rs:33:14
--> $DIR/invalid-patterns.rs:35:14
|
LL | get_flag::<42, 0x5ad>();
| ^^ expected `bool`, found integer
error[E0308]: mismatched types
--> $DIR/invalid-patterns.rs:33:18
--> $DIR/invalid-patterns.rs:35:18
|
LL | get_flag::<42, 0x5ad>();
| ^^^^^ expected `char`, found `u8`

View file

@ -1,11 +1,11 @@
error[E0080]: evaluation of constant value failed
--> $DIR/invalid-patterns.rs:38:32
--> $DIR/invalid-patterns.rs:40:32
|
LL | get_flag::<false, { unsafe { char_raw.character } }>();
| ^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory
error[E0080]: it is undefined behavior to use this value
--> $DIR/invalid-patterns.rs:41:14
--> $DIR/invalid-patterns.rs:43:14
|
LL | get_flag::<{ unsafe { bool_raw.boolean } }, 'z'>();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0x42, but expected a boolean
@ -16,7 +16,7 @@ LL | get_flag::<{ unsafe { bool_raw.boolean } }, 'z'>();
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/invalid-patterns.rs:43:14
--> $DIR/invalid-patterns.rs:45:14
|
LL | get_flag::<{ unsafe { bool_raw.boolean } }, { unsafe { char_raw.character } }>();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0x42, but expected a boolean
@ -27,31 +27,31 @@ LL | get_flag::<{ unsafe { bool_raw.boolean } }, { unsafe { char_raw.character
}
error[E0080]: evaluation of constant value failed
--> $DIR/invalid-patterns.rs:43:58
--> $DIR/invalid-patterns.rs:45:58
|
LL | get_flag::<{ unsafe { bool_raw.boolean } }, { unsafe { char_raw.character } }>();
| ^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory
error[E0308]: mismatched types
--> $DIR/invalid-patterns.rs:29:21
--> $DIR/invalid-patterns.rs:31:21
|
LL | get_flag::<false, 0xFF>();
| ^^^^ expected `char`, found `u8`
error[E0308]: mismatched types
--> $DIR/invalid-patterns.rs:31:14
--> $DIR/invalid-patterns.rs:33:14
|
LL | get_flag::<7, 'c'>();
| ^ expected `bool`, found integer
error[E0308]: mismatched types
--> $DIR/invalid-patterns.rs:33:14
--> $DIR/invalid-patterns.rs:35:14
|
LL | get_flag::<42, 0x5ad>();
| ^^ expected `bool`, found integer
error[E0308]: mismatched types
--> $DIR/invalid-patterns.rs:33:18
--> $DIR/invalid-patterns.rs:35:18
|
LL | get_flag::<42, 0x5ad>();
| ^^^^^ expected `char`, found `u8`

View file

@ -1,4 +1,6 @@
//@ stderr-per-bitwidth
//@ dont-require-annotations: NOTE
use std::mem::transmute;
fn get_flag<const FlagSet: bool, const ShortName: char>() -> Option<char> {
@ -37,11 +39,11 @@ fn main() {
get_flag::<false, { unsafe { char_raw.character } }>();
//~^ ERROR evaluation of constant value failed
//~| uninitialized
//~| NOTE uninitialized
get_flag::<{ unsafe { bool_raw.boolean } }, 'z'>();
//~^ ERROR it is undefined behavior
get_flag::<{ unsafe { bool_raw.boolean } }, { unsafe { char_raw.character } }>();
//~^ ERROR evaluation of constant value failed
//~| uninitialized
//~| NOTE uninitialized
//~| ERROR it is undefined behavior
}

View file

@ -1,10 +1,11 @@
const FOO: [usize; 3] = [1, 2, 3];
const BAR: usize = FOO[5];
//~^ ERROR: evaluation of constant value failed
//~| NOTE index out of bounds: the length is 3 but the index is 5
const BLUB: [u32; FOO[4]] = [5, 6];
//~^ ERROR evaluation of constant value failed [E0080]
//~| index out of bounds: the length is 3 but the index is 4
//~| NOTE index out of bounds: the length is 3 but the index is 4
fn main() {
let _ = BAR;

View file

@ -1,5 +1,5 @@
error[E0080]: evaluation of constant value failed
--> $DIR/const-array-oob.rs:5:19
--> $DIR/const-array-oob.rs:6:19
|
LL | const BLUB: [u32; FOO[4]] = [5, 6];
| ^^^^^^ index out of bounds: the length is 3 but the index is 4

View file

@ -1,5 +1,6 @@
//@ build-fail
//@ compile-flags: -C overflow-checks=on
//@ dont-require-annotations: NOTE
#![allow(arithmetic_overflow, unconditional_panic)]
@ -16,5 +17,5 @@ impl<T> S<T> {
}
fn main() {
black_box((S::<i32>::FOO, S::<u32>::FOO)); //~ constant
black_box((S::<i32>::FOO, S::<u32>::FOO)); //~ NOTE constant
}

View file

@ -1,29 +1,29 @@
error[E0080]: evaluation of `S::<i32>::FOO` failed
--> $DIR/const-err-late.rs:13:21
--> $DIR/const-err-late.rs:14:21
|
LL | const FOO: u8 = [5u8][1];
| ^^^^^^^^ index out of bounds: the length is 1 but the index is 1
note: erroneous constant encountered
--> $DIR/const-err-late.rs:19:16
--> $DIR/const-err-late.rs:20:16
|
LL | black_box((S::<i32>::FOO, S::<u32>::FOO));
| ^^^^^^^^^^^^^
error[E0080]: evaluation of `S::<u32>::FOO` failed
--> $DIR/const-err-late.rs:13:21
--> $DIR/const-err-late.rs:14:21
|
LL | const FOO: u8 = [5u8][1];
| ^^^^^^^^ index out of bounds: the length is 1 but the index is 1
note: erroneous constant encountered
--> $DIR/const-err-late.rs:19:31
--> $DIR/const-err-late.rs:20:31
|
LL | black_box((S::<i32>::FOO, S::<u32>::FOO));
| ^^^^^^^^^^^^^
note: erroneous constant encountered
--> $DIR/const-err-late.rs:19:16
--> $DIR/const-err-late.rs:20:16
|
LL | black_box((S::<i32>::FOO, S::<u32>::FOO));
| ^^^^^^^^^^^^^
@ -31,7 +31,7 @@ LL | black_box((S::<i32>::FOO, S::<u32>::FOO));
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
note: erroneous constant encountered
--> $DIR/const-err-late.rs:19:31
--> $DIR/const-err-late.rs:20:31
|
LL | black_box((S::<i32>::FOO, S::<u32>::FOO));
| ^^^^^^^^^^^^^

View file

@ -1,11 +1,12 @@
pub const A: i8 = -i8::MIN;
//~^ ERROR constant
//~| NOTE attempt to negate `i8::MIN`, which would overflow
pub const B: i8 = A;
//~^ constant
//~^ NOTE constant
pub const C: u8 = A as u8;
//~^ constant
//~^ NOTE constant
pub const D: i8 = 50 - A;
//~^ constant
//~^ NOTE constant
fn main() {
let _ = (A, B, C, D);

View file

@ -5,19 +5,19 @@ LL | pub const A: i8 = -i8::MIN;
| ^^^^^^^^ attempt to negate `i8::MIN`, which would overflow
note: erroneous constant encountered
--> $DIR/const-err-multi.rs:3:19
--> $DIR/const-err-multi.rs:4:19
|
LL | pub const B: i8 = A;
| ^
note: erroneous constant encountered
--> $DIR/const-err-multi.rs:5:19
--> $DIR/const-err-multi.rs:6:19
|
LL | pub const C: u8 = A as u8;
| ^
note: erroneous constant encountered
--> $DIR/const-err-multi.rs:7:24
--> $DIR/const-err-multi.rs:8:24
|
LL | pub const D: i8 = 50 - A;
| ^

View file

@ -3,12 +3,14 @@
//
// This test is checking the count in an array type.
//@ dont-require-annotations: NOTE
#![allow(unused_imports)]
const A_I8_T
: [u32; (i8::MAX as i8 + 1u8) as usize]
//~^ ERROR mismatched types
//~| expected `i8`, found `u8`
//~| NOTE expected `i8`, found `u8`
//~| ERROR cannot add `u8` to `i8`
= [0; (i8::MAX as usize) + 1];

View file

@ -1,11 +1,11 @@
error[E0308]: mismatched types
--> $DIR/const-eval-overflow-4b.rs:9:30
--> $DIR/const-eval-overflow-4b.rs:11:30
|
LL | : [u32; (i8::MAX as i8 + 1u8) as usize]
| ^^^ expected `i8`, found `u8`
error[E0277]: cannot add `u8` to `i8`
--> $DIR/const-eval-overflow-4b.rs:9:28
--> $DIR/const-eval-overflow-4b.rs:11:28
|
LL | : [u32; (i8::MAX as i8 + 1u8) as usize]
| ^ no implementation for `i8 + u8`
@ -18,13 +18,13 @@ LL | : [u32; (i8::MAX as i8 + 1u8) as usize]
`i8` implements `Add`
error[E0604]: only `u8` can be cast as `char`, not `i8`
--> $DIR/const-eval-overflow-4b.rs:22:13
--> $DIR/const-eval-overflow-4b.rs:24:13
|
LL | : [u32; 5i8 as char as usize]
| ^^^^^^^^^^^ invalid cast
|
help: try casting from `u8` instead
--> $DIR/const-eval-overflow-4b.rs:22:13
--> $DIR/const-eval-overflow-4b.rs:24:13
|
LL | : [u32; 5i8 as char as usize]
| ^^^^^^^^^^^

View file

@ -1,5 +1,5 @@
error[E0080]: evaluation of constant value failed
--> $DIR/const-pointer-values-in-various-types.rs:26:49
--> $DIR/const-pointer-values-in-various-types.rs:27:49
|
LL | const I32_REF_USIZE_UNION: usize = unsafe { Nonsense { int_32_ref: &3 }.u };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
@ -8,7 +8,7 @@ LL | const I32_REF_USIZE_UNION: usize = unsafe { Nonsense { int_32_ref: &3 }
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
error[E0080]: evaluation of constant value failed
--> $DIR/const-pointer-values-in-various-types.rs:29:43
--> $DIR/const-pointer-values-in-various-types.rs:30:43
|
LL | const I32_REF_U8_UNION: u8 = unsafe { Nonsense { int_32_ref: &3 }.uint_8 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
@ -17,7 +17,7 @@ LL | const I32_REF_U8_UNION: u8 = unsafe { Nonsense { int_32_ref: &3 }.uint_
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
error[E0080]: evaluation of constant value failed
--> $DIR/const-pointer-values-in-various-types.rs:32:45
--> $DIR/const-pointer-values-in-various-types.rs:33:45
|
LL | const I32_REF_U16_UNION: u16 = unsafe { Nonsense { int_32_ref: &3 }.uint_16 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
@ -26,7 +26,7 @@ LL | const I32_REF_U16_UNION: u16 = unsafe { Nonsense { int_32_ref: &3 }.uin
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
error[E0080]: evaluation of constant value failed
--> $DIR/const-pointer-values-in-various-types.rs:35:45
--> $DIR/const-pointer-values-in-various-types.rs:36:45
|
LL | const I32_REF_U32_UNION: u32 = unsafe { Nonsense { int_32_ref: &3 }.uint_32 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
@ -35,7 +35,7 @@ LL | const I32_REF_U32_UNION: u32 = unsafe { Nonsense { int_32_ref: &3 }.uin
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
error[E0080]: evaluation of constant value failed
--> $DIR/const-pointer-values-in-various-types.rs:38:45
--> $DIR/const-pointer-values-in-various-types.rs:39:45
|
LL | const I32_REF_U64_UNION: u64 = unsafe { Nonsense { int_32_ref: &3 }.uint_64 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
@ -44,13 +44,13 @@ LL | const I32_REF_U64_UNION: u64 = unsafe { Nonsense { int_32_ref: &3 }.uin
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
error[E0080]: evaluation of constant value failed
--> $DIR/const-pointer-values-in-various-types.rs:41:47
--> $DIR/const-pointer-values-in-various-types.rs:42:47
|
LL | const I32_REF_U128_UNION: u128 = unsafe { Nonsense { int_32_ref: &3 }.uint_128 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory
error[E0080]: evaluation of constant value failed
--> $DIR/const-pointer-values-in-various-types.rs:45:43
--> $DIR/const-pointer-values-in-various-types.rs:46:43
|
LL | const I32_REF_I8_UNION: i8 = unsafe { Nonsense { int_32_ref: &3 }.int_8 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
@ -59,7 +59,7 @@ LL | const I32_REF_I8_UNION: i8 = unsafe { Nonsense { int_32_ref: &3 }.int_8
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
error[E0080]: evaluation of constant value failed
--> $DIR/const-pointer-values-in-various-types.rs:48:45
--> $DIR/const-pointer-values-in-various-types.rs:49:45
|
LL | const I32_REF_I16_UNION: i16 = unsafe { Nonsense { int_32_ref: &3 }.int_16 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
@ -68,7 +68,7 @@ LL | const I32_REF_I16_UNION: i16 = unsafe { Nonsense { int_32_ref: &3 }.int
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
error[E0080]: evaluation of constant value failed
--> $DIR/const-pointer-values-in-various-types.rs:51:45
--> $DIR/const-pointer-values-in-various-types.rs:52:45
|
LL | const I32_REF_I32_UNION: i32 = unsafe { Nonsense { int_32_ref: &3 }.int_32 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
@ -77,7 +77,7 @@ LL | const I32_REF_I32_UNION: i32 = unsafe { Nonsense { int_32_ref: &3 }.int
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
error[E0080]: evaluation of constant value failed
--> $DIR/const-pointer-values-in-various-types.rs:54:45
--> $DIR/const-pointer-values-in-various-types.rs:55:45
|
LL | const I32_REF_I64_UNION: i64 = unsafe { Nonsense { int_32_ref: &3 }.int_64 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
@ -86,13 +86,13 @@ LL | const I32_REF_I64_UNION: i64 = unsafe { Nonsense { int_32_ref: &3 }.int
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
error[E0080]: evaluation of constant value failed
--> $DIR/const-pointer-values-in-various-types.rs:57:47
--> $DIR/const-pointer-values-in-various-types.rs:58:47
|
LL | const I32_REF_I128_UNION: i128 = unsafe { Nonsense { int_32_ref: &3 }.int_128 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory
error[E0080]: evaluation of constant value failed
--> $DIR/const-pointer-values-in-various-types.rs:61:45
--> $DIR/const-pointer-values-in-various-types.rs:62:45
|
LL | const I32_REF_F32_UNION: f32 = unsafe { Nonsense { int_32_ref: &3 }.float_32 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
@ -101,7 +101,7 @@ LL | const I32_REF_F32_UNION: f32 = unsafe { Nonsense { int_32_ref: &3 }.flo
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
error[E0080]: evaluation of constant value failed
--> $DIR/const-pointer-values-in-various-types.rs:64:45
--> $DIR/const-pointer-values-in-various-types.rs:65:45
|
LL | const I32_REF_F64_UNION: f64 = unsafe { Nonsense { int_32_ref: &3 }.float_64 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
@ -110,7 +110,7 @@ LL | const I32_REF_F64_UNION: f64 = unsafe { Nonsense { int_32_ref: &3 }.flo
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
error[E0080]: evaluation of constant value failed
--> $DIR/const-pointer-values-in-various-types.rs:67:47
--> $DIR/const-pointer-values-in-various-types.rs:68:47
|
LL | const I32_REF_BOOL_UNION: bool = unsafe { Nonsense { int_32_ref: &3 }.truthy_falsey };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
@ -119,7 +119,7 @@ LL | const I32_REF_BOOL_UNION: bool = unsafe { Nonsense { int_32_ref: &3 }.t
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
error[E0080]: evaluation of constant value failed
--> $DIR/const-pointer-values-in-various-types.rs:70:47
--> $DIR/const-pointer-values-in-various-types.rs:71:47
|
LL | const I32_REF_CHAR_UNION: char = unsafe { Nonsense { int_32_ref: &3 }.character };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
@ -128,7 +128,7 @@ LL | const I32_REF_CHAR_UNION: char = unsafe { Nonsense { int_32_ref: &3 }.c
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
error[E0080]: evaluation of constant value failed
--> $DIR/const-pointer-values-in-various-types.rs:73:39
--> $DIR/const-pointer-values-in-various-types.rs:74:39
|
LL | const STR_U8_UNION: u8 = unsafe { Nonsense { stringy: "3" }.uint_8 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
@ -137,7 +137,7 @@ LL | const STR_U8_UNION: u8 = unsafe { Nonsense { stringy: "3" }.uint_8 };
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
error[E0080]: evaluation of constant value failed
--> $DIR/const-pointer-values-in-various-types.rs:76:41
--> $DIR/const-pointer-values-in-various-types.rs:77:41
|
LL | const STR_U16_UNION: u16 = unsafe { Nonsense { stringy: "3" }.uint_16 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
@ -146,7 +146,7 @@ LL | const STR_U16_UNION: u16 = unsafe { Nonsense { stringy: "3" }.uint_16 }
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
error[E0080]: evaluation of constant value failed
--> $DIR/const-pointer-values-in-various-types.rs:79:41
--> $DIR/const-pointer-values-in-various-types.rs:80:41
|
LL | const STR_U32_UNION: u32 = unsafe { Nonsense { stringy: "3" }.uint_32 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
@ -155,7 +155,7 @@ LL | const STR_U32_UNION: u32 = unsafe { Nonsense { stringy: "3" }.uint_32 }
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
error[E0080]: evaluation of constant value failed
--> $DIR/const-pointer-values-in-various-types.rs:82:41
--> $DIR/const-pointer-values-in-various-types.rs:83:41
|
LL | const STR_U64_UNION: u64 = unsafe { Nonsense { stringy: "3" }.uint_64 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
@ -164,7 +164,7 @@ LL | const STR_U64_UNION: u64 = unsafe { Nonsense { stringy: "3" }.uint_64 }
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
error[E0080]: evaluation of constant value failed
--> $DIR/const-pointer-values-in-various-types.rs:85:43
--> $DIR/const-pointer-values-in-various-types.rs:86:43
|
LL | const STR_U128_UNION: u128 = unsafe { Nonsense { stringy: "3" }.uint_128 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
@ -173,7 +173,7 @@ LL | const STR_U128_UNION: u128 = unsafe { Nonsense { stringy: "3" }.uint_12
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
error[E0080]: evaluation of constant value failed
--> $DIR/const-pointer-values-in-various-types.rs:88:39
--> $DIR/const-pointer-values-in-various-types.rs:89:39
|
LL | const STR_I8_UNION: i8 = unsafe { Nonsense { stringy: "3" }.int_8 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
@ -182,7 +182,7 @@ LL | const STR_I8_UNION: i8 = unsafe { Nonsense { stringy: "3" }.int_8 };
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
error[E0080]: evaluation of constant value failed
--> $DIR/const-pointer-values-in-various-types.rs:91:41
--> $DIR/const-pointer-values-in-various-types.rs:92:41
|
LL | const STR_I16_UNION: i16 = unsafe { Nonsense { stringy: "3" }.int_16 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
@ -191,7 +191,7 @@ LL | const STR_I16_UNION: i16 = unsafe { Nonsense { stringy: "3" }.int_16 };
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
error[E0080]: evaluation of constant value failed
--> $DIR/const-pointer-values-in-various-types.rs:94:41
--> $DIR/const-pointer-values-in-various-types.rs:95:41
|
LL | const STR_I32_UNION: i32 = unsafe { Nonsense { stringy: "3" }.int_32 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
@ -200,7 +200,7 @@ LL | const STR_I32_UNION: i32 = unsafe { Nonsense { stringy: "3" }.int_32 };
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
error[E0080]: evaluation of constant value failed
--> $DIR/const-pointer-values-in-various-types.rs:97:41
--> $DIR/const-pointer-values-in-various-types.rs:98:41
|
LL | const STR_I64_UNION: i64 = unsafe { Nonsense { stringy: "3" }.int_64 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
@ -209,7 +209,7 @@ LL | const STR_I64_UNION: i64 = unsafe { Nonsense { stringy: "3" }.int_64 };
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
error[E0080]: evaluation of constant value failed
--> $DIR/const-pointer-values-in-various-types.rs:100:43
--> $DIR/const-pointer-values-in-various-types.rs:101:43
|
LL | const STR_I128_UNION: i128 = unsafe { Nonsense { stringy: "3" }.int_128 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
@ -218,7 +218,7 @@ LL | const STR_I128_UNION: i128 = unsafe { Nonsense { stringy: "3" }.int_128
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
error[E0080]: evaluation of constant value failed
--> $DIR/const-pointer-values-in-various-types.rs:103:41
--> $DIR/const-pointer-values-in-various-types.rs:104:41
|
LL | const STR_F32_UNION: f32 = unsafe { Nonsense { stringy: "3" }.float_32 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
@ -227,7 +227,7 @@ LL | const STR_F32_UNION: f32 = unsafe { Nonsense { stringy: "3" }.float_32
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
error[E0080]: evaluation of constant value failed
--> $DIR/const-pointer-values-in-various-types.rs:106:41
--> $DIR/const-pointer-values-in-various-types.rs:107:41
|
LL | const STR_F64_UNION: f64 = unsafe { Nonsense { stringy: "3" }.float_64 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
@ -236,7 +236,7 @@ LL | const STR_F64_UNION: f64 = unsafe { Nonsense { stringy: "3" }.float_64
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
error[E0080]: evaluation of constant value failed
--> $DIR/const-pointer-values-in-various-types.rs:109:43
--> $DIR/const-pointer-values-in-various-types.rs:110:43
|
LL | const STR_BOOL_UNION: bool = unsafe { Nonsense { stringy: "3" }.truthy_falsey };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
@ -245,7 +245,7 @@ LL | const STR_BOOL_UNION: bool = unsafe { Nonsense { stringy: "3" }.truthy_
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
error[E0080]: evaluation of constant value failed
--> $DIR/const-pointer-values-in-various-types.rs:112:43
--> $DIR/const-pointer-values-in-various-types.rs:113:43
|
LL | const STR_CHAR_UNION: char = unsafe { Nonsense { stringy: "3" }.character };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer

View file

@ -1,5 +1,6 @@
//@ only-x86_64
//@ stderr-per-bitwidth
//@ dont-require-annotations: NOTE
#[repr(C)]
union Nonsense {
@ -40,7 +41,7 @@ fn main() {
const I32_REF_U128_UNION: u128 = unsafe { Nonsense { int_32_ref: &3 }.uint_128 };
//~^ ERROR evaluation of constant value failed
//~| uninitialized
//~| NOTE uninitialized
const I32_REF_I8_UNION: i8 = unsafe { Nonsense { int_32_ref: &3 }.int_8 };
//~^ ERROR evaluation of constant value failed
@ -56,7 +57,7 @@ fn main() {
const I32_REF_I128_UNION: i128 = unsafe { Nonsense { int_32_ref: &3 }.int_128 };
//~^ ERROR evaluation of constant value failed
//~| uninitialized
//~| NOTE uninitialized
const I32_REF_F32_UNION: f32 = unsafe { Nonsense { int_32_ref: &3 }.float_32 };
//~^ ERROR evaluation of constant value failed

View file

@ -1,11 +1,13 @@
//@ dont-require-annotations: NOTE
#![feature(core_intrinsics)]
#![feature(const_heap)]
use std::intrinsics;
const FOO: i32 = foo(); //~ error: evaluation of constant value failed
const FOO: i32 = foo(); //~ ERROR evaluation of constant value failed
const fn foo() -> i32 {
unsafe {
let _ = intrinsics::const_allocate(4, 3) as *mut i32; //~ inside `foo`
let _ = intrinsics::const_allocate(4, 3) as *mut i32; //~ NOTE inside `foo`
}
1
}

View file

@ -1,11 +1,11 @@
error[E0080]: evaluation of constant value failed
--> $DIR/alloc_intrinsic_errors.rs:5:18
--> $DIR/alloc_intrinsic_errors.rs:7:18
|
LL | const FOO: i32 = foo();
| ^^^^^ invalid align passed to `const_allocate`: 3 is not a power of 2
|
note: inside `foo`
--> $DIR/alloc_intrinsic_errors.rs:8:17
--> $DIR/alloc_intrinsic_errors.rs:10:17
|
LL | let _ = intrinsics::const_allocate(4, 3) as *mut i32;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the failure occurred here

View file

@ -1,4 +1,5 @@
//@ build-fail
//@ dont-require-annotations: NOTE
trait Foo {
const AMT: usize;
@ -23,5 +24,5 @@ impl Foo for u16 {
fn main() {
println!("{}", <Bar<u16, u8> as Foo>::AMT);
//~^ constant
//~^ NOTE constant
}

View file

@ -1,17 +1,17 @@
error[E0080]: evaluation of `<Bar<u16, u8> as Foo>::AMT` failed
--> $DIR/issue-44578.rs:13:24
--> $DIR/issue-44578.rs:14:24
|
LL | const AMT: usize = [A::AMT][(A::AMT > B::AMT) as usize];
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ index out of bounds: the length is 1 but the index is 1
note: erroneous constant encountered
--> $DIR/issue-44578.rs:25:20
--> $DIR/issue-44578.rs:26:20
|
LL | println!("{}", <Bar<u16, u8> as Foo>::AMT);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
note: erroneous constant encountered
--> $DIR/issue-44578.rs:25:20
--> $DIR/issue-44578.rs:26:20
|
LL | println!("{}", <Bar<u16, u8> as Foo>::AMT);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -19,7 +19,7 @@ LL | println!("{}", <Bar<u16, u8> as Foo>::AMT);
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
note: erroneous constant encountered
--> $DIR/issue-44578.rs:25:20
--> $DIR/issue-44578.rs:26:20
|
LL | println!("{}", <Bar<u16, u8> as Foo>::AMT);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -27,7 +27,7 @@ LL | println!("{}", <Bar<u16, u8> as Foo>::AMT);
= note: this note originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
note: erroneous constant encountered
--> $DIR/issue-44578.rs:25:20
--> $DIR/issue-44578.rs:26:20
|
LL | println!("{}", <Bar<u16, u8> as Foo>::AMT);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^

View file

@ -1,23 +1,23 @@
error[E0080]: evaluation of `<A<()> as Foo<()>>::BAR` failed
--> $DIR/issue-50814-2.rs:16:24
--> $DIR/issue-50814-2.rs:17:24
|
LL | const BAR: usize = [5, 6, 7][T::BOO];
| ^^^^^^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 42
note: erroneous constant encountered
--> $DIR/issue-50814-2.rs:20:6
--> $DIR/issue-50814-2.rs:21:6
|
LL | &<A<T> as Foo<T>>::BAR
| ^^^^^^^^^^^^^^^^^^^^^
note: erroneous constant encountered
--> $DIR/issue-50814-2.rs:20:5
--> $DIR/issue-50814-2.rs:21:5
|
LL | &<A<T> as Foo<T>>::BAR
| ^^^^^^^^^^^^^^^^^^^^^^
note: erroneous constant encountered
--> $DIR/issue-50814-2.rs:20:5
--> $DIR/issue-50814-2.rs:21:5
|
LL | &<A<T> as Foo<T>>::BAR
| ^^^^^^^^^^^^^^^^^^^^^^
@ -25,7 +25,7 @@ LL | &<A<T> as Foo<T>>::BAR
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
note: erroneous constant encountered
--> $DIR/issue-50814-2.rs:20:5
--> $DIR/issue-50814-2.rs:21:5
|
LL | &<A<T> as Foo<T>>::BAR
| ^^^^^^^^^^^^^^^^^^^^^^
@ -33,7 +33,7 @@ LL | &<A<T> as Foo<T>>::BAR
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
note: erroneous constant encountered
--> $DIR/issue-50814-2.rs:20:5
--> $DIR/issue-50814-2.rs:21:5
|
LL | &<A<T> as Foo<T>>::BAR
| ^^^^^^^^^^^^^^^^^^^^^^
@ -41,7 +41,7 @@ LL | &<A<T> as Foo<T>>::BAR
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
note: erroneous constant encountered
--> $DIR/issue-50814-2.rs:20:6
--> $DIR/issue-50814-2.rs:21:6
|
LL | &<A<T> as Foo<T>>::BAR
| ^^^^^^^^^^^^^^^^^^^^^
@ -49,7 +49,7 @@ LL | &<A<T> as Foo<T>>::BAR
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
note: erroneous constant encountered
--> $DIR/issue-50814-2.rs:20:6
--> $DIR/issue-50814-2.rs:21:6
|
LL | &<A<T> as Foo<T>>::BAR
| ^^^^^^^^^^^^^^^^^^^^^

View file

@ -1,23 +1,23 @@
error[E0080]: evaluation of `<A<()> as Foo<()>>::BAR` failed
--> $DIR/issue-50814-2.rs:16:24
--> $DIR/issue-50814-2.rs:17:24
|
LL | const BAR: usize = [5, 6, 7][T::BOO];
| ^^^^^^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 42
note: erroneous constant encountered
--> $DIR/issue-50814-2.rs:20:6
--> $DIR/issue-50814-2.rs:21:6
|
LL | &<A<T> as Foo<T>>::BAR
| ^^^^^^^^^^^^^^^^^^^^^
note: erroneous constant encountered
--> $DIR/issue-50814-2.rs:20:5
--> $DIR/issue-50814-2.rs:21:5
|
LL | &<A<T> as Foo<T>>::BAR
| ^^^^^^^^^^^^^^^^^^^^^^
note: erroneous constant encountered
--> $DIR/issue-50814-2.rs:20:6
--> $DIR/issue-50814-2.rs:21:6
|
LL | &<A<T> as Foo<T>>::BAR
| ^^^^^^^^^^^^^^^^^^^^^
@ -25,7 +25,7 @@ LL | &<A<T> as Foo<T>>::BAR
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
note: the above error was encountered while instantiating `fn foo::<()>`
--> $DIR/issue-50814-2.rs:32:22
--> $DIR/issue-50814-2.rs:33:22
|
LL | println!("{:x}", foo::<()>() as *const usize as usize);
| ^^^^^^^^^^^

View file

@ -1,6 +1,7 @@
//@ build-fail
//@ revisions: normal mir-opt
//@ [mir-opt]compile-flags: -Zmir-opt-level=4
//@ dont-require-annotations: NOTE
trait C {
const BOO: usize;
@ -17,7 +18,7 @@ impl<T: C> Foo<T> for A<T> {
}
fn foo<T: C>() -> &'static usize {
&<A<T> as Foo<T>>::BAR //~ constant
&<A<T> as Foo<T>>::BAR //~ NOTE constant
}
impl C for () {

View file

@ -1,4 +1,5 @@
//@ build-fail
//@ dont-require-annotations: NOTE
trait Unsigned {
const MAX: u8;
@ -19,7 +20,7 @@ impl<A: Unsigned, B: Unsigned> Unsigned for Sum<A, B> {
fn foo<T>(_: T) -> &'static u8 {
&Sum::<U8, U8>::MAX
//~^ constant
//~^ NOTE constant
}
fn main() {

View file

@ -1,17 +1,17 @@
error[E0080]: evaluation of `<Sum<U8, U8> as Unsigned>::MAX` failed
--> $DIR/issue-50814.rs:15:21
--> $DIR/issue-50814.rs:16:21
|
LL | const MAX: u8 = A::MAX + B::MAX;
| ^^^^^^^^^^^^^^^ attempt to compute `u8::MAX + u8::MAX`, which would overflow
note: erroneous constant encountered
--> $DIR/issue-50814.rs:21:6
--> $DIR/issue-50814.rs:22:6
|
LL | &Sum::<U8, U8>::MAX
| ^^^^^^^^^^^^^^^^^^
error[E0080]: evaluation of `<Sum<U8, U8> as Unsigned>::MAX` failed
--> $DIR/issue-50814.rs:15:21
--> $DIR/issue-50814.rs:16:21
|
LL | const MAX: u8 = A::MAX + B::MAX;
| ^^^^^^^^^^^^^^^ attempt to compute `u8::MAX + u8::MAX`, which would overflow
@ -19,7 +19,7 @@ LL | const MAX: u8 = A::MAX + B::MAX;
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
note: erroneous constant encountered
--> $DIR/issue-50814.rs:21:6
--> $DIR/issue-50814.rs:22:6
|
LL | &Sum::<U8, U8>::MAX
| ^^^^^^^^^^^^^^^^^^
@ -27,13 +27,13 @@ LL | &Sum::<U8, U8>::MAX
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
note: erroneous constant encountered
--> $DIR/issue-50814.rs:21:5
--> $DIR/issue-50814.rs:22:5
|
LL | &Sum::<U8, U8>::MAX
| ^^^^^^^^^^^^^^^^^^^
note: erroneous constant encountered
--> $DIR/issue-50814.rs:21:6
--> $DIR/issue-50814.rs:22:6
|
LL | &Sum::<U8, U8>::MAX
| ^^^^^^^^^^^^^^^^^^
@ -41,7 +41,7 @@ LL | &Sum::<U8, U8>::MAX
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
note: the above error was encountered while instantiating `fn foo::<i32>`
--> $DIR/issue-50814.rs:26:5
--> $DIR/issue-50814.rs:27:5
|
LL | foo(0);
| ^^^^^^

View file

@ -1,4 +1,5 @@
//@ build-fail
//@ dont-require-annotations: NOTE
// Regression test for #66975
#![feature(never_type)]
@ -11,5 +12,5 @@ impl PrintName {
}
fn main() {
let _ = PrintName::VOID; //~ erroneous constant encountered
let _ = PrintName::VOID; //~ NOTE erroneous constant encountered
}

View file

@ -1,17 +1,17 @@
error[E0080]: evaluation of constant value failed
--> $DIR/panic-assoc-never-type.rs:9:21
--> $DIR/panic-assoc-never-type.rs:10:21
|
LL | const VOID: ! = panic!();
| ^^^^^^^^ evaluation panicked: explicit panic
note: erroneous constant encountered
--> $DIR/panic-assoc-never-type.rs:14:13
--> $DIR/panic-assoc-never-type.rs:15:13
|
LL | let _ = PrintName::VOID;
| ^^^^^^^^^^^^^^^
note: erroneous constant encountered
--> $DIR/panic-assoc-never-type.rs:14:13
--> $DIR/panic-assoc-never-type.rs:15:13
|
LL | let _ = PrintName::VOID;
| ^^^^^^^^^^^^^^^

View file

@ -1,5 +1,5 @@
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:21:1
--> $DIR/raw-bytes.rs:23:1
|
LL | const BAD_ENUM: Enum = unsafe { mem::transmute(1usize) };
| ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-tag>: encountered 0x00000001, but expected a valid enum tag
@ -10,7 +10,7 @@ LL | const BAD_ENUM: Enum = unsafe { mem::transmute(1usize) };
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:29:1
--> $DIR/raw-bytes.rs:31:1
|
LL | const BAD_ENUM2: Enum2 = unsafe { mem::transmute(0usize) };
| ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-tag>: encountered 0x00000000, but expected a valid enum tag
@ -21,7 +21,7 @@ LL | const BAD_ENUM2: Enum2 = unsafe { mem::transmute(0usize) };
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:43:1
--> $DIR/raw-bytes.rs:45:1
|
LL | const BAD_UNINHABITED_VARIANT1: UninhDiscriminant = unsafe { mem::transmute(1u8) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-tag>: encountered an uninhabited enum variant
@ -32,7 +32,7 @@ LL | const BAD_UNINHABITED_VARIANT1: UninhDiscriminant = unsafe { mem::transmute
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:45:1
--> $DIR/raw-bytes.rs:47:1
|
LL | const BAD_UNINHABITED_VARIANT2: UninhDiscriminant = unsafe { mem::transmute(3u8) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-tag>: encountered an uninhabited enum variant
@ -43,7 +43,7 @@ LL | const BAD_UNINHABITED_VARIANT2: UninhDiscriminant = unsafe { mem::transmute
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:51:1
--> $DIR/raw-bytes.rs:53:1
|
LL | const BAD_OPTION_CHAR: Option<(char, char)> = Some(('x', unsafe { mem::transmute(!0u32) }));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-variant(Some)>.0.1: encountered 0xffffffff, but expected a valid unicode scalar value (in `0..=0x10FFFF` but not in `0xD800..=0xDFFF`)
@ -54,7 +54,7 @@ LL | const BAD_OPTION_CHAR: Option<(char, char)> = Some(('x', unsafe { mem::tran
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:56:1
--> $DIR/raw-bytes.rs:58:1
|
LL | const NULL_PTR: NonNull<u8> = unsafe { mem::transmute(0usize) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0, but expected something greater or equal to 1
@ -65,7 +65,7 @@ LL | const NULL_PTR: NonNull<u8> = unsafe { mem::transmute(0usize) };
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:59:1
--> $DIR/raw-bytes.rs:61:1
|
LL | const NULL_U8: NonZero<u8> = unsafe { mem::transmute(0u8) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered 0, but expected something greater or equal to 1
@ -76,7 +76,7 @@ LL | const NULL_U8: NonZero<u8> = unsafe { mem::transmute(0u8) };
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:61:1
--> $DIR/raw-bytes.rs:63:1
|
LL | const NULL_USIZE: NonZero<usize> = unsafe { mem::transmute(0usize) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered 0, but expected something greater or equal to 1
@ -87,7 +87,7 @@ LL | const NULL_USIZE: NonZero<usize> = unsafe { mem::transmute(0usize) };
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:67:1
--> $DIR/raw-bytes.rs:69:1
|
LL | const BAD_RANGE1: RestrictedRange1 = unsafe { RestrictedRange1(42) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 42, but expected something in the range 10..=30
@ -98,7 +98,7 @@ LL | const BAD_RANGE1: RestrictedRange1 = unsafe { RestrictedRange1(42) };
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:73:1
--> $DIR/raw-bytes.rs:75:1
|
LL | const BAD_RANGE2: RestrictedRange2 = unsafe { RestrictedRange2(20) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 20, but expected something less or equal to 10, or greater or equal to 30
@ -109,7 +109,7 @@ LL | const BAD_RANGE2: RestrictedRange2 = unsafe { RestrictedRange2(20) };
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:76:1
--> $DIR/raw-bytes.rs:78:1
|
LL | const NULL_FAT_PTR: NonNull<dyn Send> = unsafe {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0, but expected something greater or equal to 1
@ -120,7 +120,7 @@ LL | const NULL_FAT_PTR: NonNull<dyn Send> = unsafe {
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:84:1
--> $DIR/raw-bytes.rs:86:1
|
LL | const UNALIGNED: &u16 = unsafe { mem::transmute(&[0u8; 4]) };
| ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered an unaligned reference (required 2 byte alignment but found 1)
@ -131,7 +131,7 @@ LL | const UNALIGNED: &u16 = unsafe { mem::transmute(&[0u8; 4]) };
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:88:1
--> $DIR/raw-bytes.rs:90:1
|
LL | const UNALIGNED_BOX: Box<u16> = unsafe { mem::transmute(&[0u8; 4]) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered an unaligned box (required 2 byte alignment but found 1)
@ -142,7 +142,7 @@ LL | const UNALIGNED_BOX: Box<u16> = unsafe { mem::transmute(&[0u8; 4]) };
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:92:1
--> $DIR/raw-bytes.rs:94:1
|
LL | const NULL: &u16 = unsafe { mem::transmute(0usize) };
| ^^^^^^^^^^^^^^^^ constructing invalid value: encountered a null reference
@ -153,7 +153,7 @@ LL | const NULL: &u16 = unsafe { mem::transmute(0usize) };
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:95:1
--> $DIR/raw-bytes.rs:97:1
|
LL | const NULL_BOX: Box<u16> = unsafe { mem::transmute(0usize) };
| ^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a null box
@ -164,7 +164,7 @@ LL | const NULL_BOX: Box<u16> = unsafe { mem::transmute(0usize) };
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:98:1
--> $DIR/raw-bytes.rs:100:1
|
LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (0x539[noalloc] has no provenance)
@ -175,7 +175,7 @@ LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) };
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:101:1
--> $DIR/raw-bytes.rs:103:1
|
LL | const USIZE_AS_BOX: Box<u8> = unsafe { mem::transmute(1337usize) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling box (0x539[noalloc] has no provenance)
@ -186,7 +186,7 @@ LL | const USIZE_AS_BOX: Box<u8> = unsafe { mem::transmute(1337usize) };
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:104:1
--> $DIR/raw-bytes.rs:106:1
|
LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) };
| ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered null pointer, but expected a function pointer
@ -197,7 +197,7 @@ LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) };
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:106:1
--> $DIR/raw-bytes.rs:108:1
|
LL | const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0xd[noalloc], but expected a function pointer
@ -208,7 +208,7 @@ LL | const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) };
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:108:1
--> $DIR/raw-bytes.rs:110:1
|
LL | const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) };
| ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC3<imm>, but expected a function pointer
@ -219,7 +219,7 @@ LL | const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) };
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:114:1
--> $DIR/raw-bytes.rs:116:1
|
LL | const BAD_BAD_REF: &Bar = unsafe { mem::transmute(1usize) };
| ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to uninhabited type Bar
@ -230,7 +230,7 @@ LL | const BAD_BAD_REF: &Bar = unsafe { mem::transmute(1usize) };
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:139:1
--> $DIR/raw-bytes.rs:141:1
|
LL | const STR_TOO_LONG: &str = unsafe { mem::transmute((&42u8, 999usize)) };
| ^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (going beyond the bounds of its allocation)
@ -241,7 +241,7 @@ LL | const STR_TOO_LONG: &str = unsafe { mem::transmute((&42u8, 999usize)) };
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:141:1
--> $DIR/raw-bytes.rs:143:1
|
LL | const NESTED_STR_MUCH_TOO_LONG: (&str,) = (unsafe { mem::transmute((&42, usize::MAX)) },);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered invalid reference metadata: slice is bigger than largest supported object
@ -252,7 +252,7 @@ LL | const NESTED_STR_MUCH_TOO_LONG: (&str,) = (unsafe { mem::transmute((&42, us
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:143:1
--> $DIR/raw-bytes.rs:145:1
|
LL | const MY_STR_MUCH_TOO_LONG: &MyStr = unsafe { mem::transmute((&42u8, usize::MAX)) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered invalid reference metadata: slice is bigger than largest supported object
@ -263,7 +263,7 @@ LL | const MY_STR_MUCH_TOO_LONG: &MyStr = unsafe { mem::transmute((&42u8, usize:
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:146:1
--> $DIR/raw-bytes.rs:148:1
|
LL | const STR_NO_INIT: &str = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit::<u8> { uninit: () }]) };
| ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>: encountered uninitialized memory, but expected a string
@ -274,7 +274,7 @@ LL | const STR_NO_INIT: &str = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit:
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:148:1
--> $DIR/raw-bytes.rs:150:1
|
LL | const MYSTR_NO_INIT: &MyStr = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit::<u8> { uninit: () }]) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.0: encountered uninitialized memory, but expected a string
@ -285,7 +285,7 @@ LL | const MYSTR_NO_INIT: &MyStr = unsafe { mem::transmute::<&[_], _>(&[MaybeUni
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:150:1
--> $DIR/raw-bytes.rs:152:1
|
LL | const MYSTR_NO_INIT_ISSUE83182: &MyStr = unsafe { mem::transmute::<&[_], _>(&[&()]) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.0: encountered a pointer, but expected a string
@ -298,7 +298,7 @@ LL | const MYSTR_NO_INIT_ISSUE83182: &MyStr = unsafe { mem::transmute::<&[_], _>
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:154:1
--> $DIR/raw-bytes.rs:156:1
|
LL | const SLICE_TOO_LONG: &[u8] = unsafe { mem::transmute((&42u8, 999usize)) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (going beyond the bounds of its allocation)
@ -309,7 +309,7 @@ LL | const SLICE_TOO_LONG: &[u8] = unsafe { mem::transmute((&42u8, 999usize)) };
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:156:1
--> $DIR/raw-bytes.rs:158:1
|
LL | const SLICE_TOO_LONG_OVERFLOW: &[u32] = unsafe { mem::transmute((&42u32, isize::MAX)) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered invalid reference metadata: slice is bigger than largest supported object
@ -320,7 +320,7 @@ LL | const SLICE_TOO_LONG_OVERFLOW: &[u32] = unsafe { mem::transmute((&42u32, is
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:159:1
--> $DIR/raw-bytes.rs:161:1
|
LL | const SLICE_TOO_LONG_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, 999usize)) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling box (going beyond the bounds of its allocation)
@ -331,7 +331,7 @@ LL | const SLICE_TOO_LONG_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, 999us
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:162:1
--> $DIR/raw-bytes.rs:164:1
|
LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }];
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered 0x03, but expected a boolean
@ -342,13 +342,13 @@ LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }];
}
note: erroneous constant encountered
--> $DIR/raw-bytes.rs:162:40
--> $DIR/raw-bytes.rs:164:40
|
LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }];
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:168:1
--> $DIR/raw-bytes.rs:170:1
|
LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.0: encountered 0x03, but expected a boolean
@ -359,13 +359,13 @@ LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3
}
note: erroneous constant encountered
--> $DIR/raw-bytes.rs:168:42
--> $DIR/raw-bytes.rs:170:42
|
LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:172:1
--> $DIR/raw-bytes.rs:174:1
|
LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.1[0]: encountered 0x03, but expected a boolean
@ -376,13 +376,13 @@ LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::tran
}
note: erroneous constant encountered
--> $DIR/raw-bytes.rs:172:42
--> $DIR/raw-bytes.rs:174:42
|
LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:177:1
--> $DIR/raw-bytes.rs:179:1
|
LL | const TRAIT_OBJ_SHORT_VTABLE_1: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u8))) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC17<imm>, but expected a vtable pointer
@ -393,7 +393,7 @@ LL | const TRAIT_OBJ_SHORT_VTABLE_1: W<&dyn Trait> = unsafe { mem::transmute(W((
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:181:1
--> $DIR/raw-bytes.rs:183:1
|
LL | const TRAIT_OBJ_SHORT_VTABLE_2: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u64))) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC19<imm>, but expected a vtable pointer
@ -404,7 +404,7 @@ LL | const TRAIT_OBJ_SHORT_VTABLE_2: W<&dyn Trait> = unsafe { mem::transmute(W((
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:185:1
--> $DIR/raw-bytes.rs:187:1
|
LL | const TRAIT_OBJ_INT_VTABLE: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, 4usize))) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered 0x4[noalloc], but expected a vtable pointer
@ -415,7 +415,7 @@ LL | const TRAIT_OBJ_INT_VTABLE: W<&dyn Trait> = unsafe { mem::transmute(W((&92u
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:188:1
--> $DIR/raw-bytes.rs:190:1
|
LL | const TRAIT_OBJ_BAD_DROP_FN_NOT_FN_PTR: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &[&42u8; 8]))) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC22<imm>, but expected a vtable pointer
@ -426,7 +426,7 @@ LL | const TRAIT_OBJ_BAD_DROP_FN_NOT_FN_PTR: W<&dyn Trait> = unsafe { mem::trans
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:192:1
--> $DIR/raw-bytes.rs:194:1
|
LL | const TRAIT_OBJ_CONTENT_INVALID: &dyn Trait = unsafe { mem::transmute::<_, &bool>(&3u8) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.<dyn-downcast>: encountered 0x03, but expected a boolean
@ -437,7 +437,7 @@ LL | const TRAIT_OBJ_CONTENT_INVALID: &dyn Trait = unsafe { mem::transmute::<_,
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:196:1
--> $DIR/raw-bytes.rs:198:1
|
LL | const RAW_TRAIT_OBJ_VTABLE_NULL: *const dyn Trait = unsafe { mem::transmute((&92u8, 0usize)) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered null pointer, but expected a vtable pointer
@ -448,7 +448,7 @@ LL | const RAW_TRAIT_OBJ_VTABLE_NULL: *const dyn Trait = unsafe { mem::transmute
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:199:1
--> $DIR/raw-bytes.rs:201:1
|
LL | const RAW_TRAIT_OBJ_VTABLE_INVALID: *const dyn Trait = unsafe { mem::transmute((&92u8, &3u64)) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC27<imm>, but expected a vtable pointer
@ -459,7 +459,7 @@ LL | const RAW_TRAIT_OBJ_VTABLE_INVALID: *const dyn Trait = unsafe { mem::transm
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:204:1
--> $DIR/raw-bytes.rs:206:1
|
LL | const _: &[!; 1] = unsafe { &*(1_usize as *const [!; 1]) };
| ^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to uninhabited type [!; 1]
@ -470,7 +470,7 @@ LL | const _: &[!; 1] = unsafe { &*(1_usize as *const [!; 1]) };
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:205:1
--> $DIR/raw-bytes.rs:207:1
|
LL | const _: &[!] = unsafe { &*(1_usize as *const [!; 1]) };
| ^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered a value of the never type `!`
@ -481,7 +481,7 @@ LL | const _: &[!] = unsafe { &*(1_usize as *const [!; 1]) };
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:206:1
--> $DIR/raw-bytes.rs:208:1
|
LL | const _: &[!] = unsafe { &*(1_usize as *const [!; 42]) };
| ^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered a value of the never type `!`
@ -492,7 +492,7 @@ LL | const _: &[!] = unsafe { &*(1_usize as *const [!; 42]) };
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:210:1
--> $DIR/raw-bytes.rs:212:1
|
LL | pub static S4: &[u8] = unsafe { from_raw_parts((&D1) as *const _ as _, 1) };
| ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered uninitialized memory, but expected an integer
@ -503,7 +503,7 @@ LL | pub static S4: &[u8] = unsafe { from_raw_parts((&D1) as *const _ as _, 1) }
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:213:1
--> $DIR/raw-bytes.rs:215:1
|
LL | pub static S5: &[u8] = unsafe { from_raw_parts((&D3) as *const _ as _, mem::size_of::<&u32>()) };
| ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered a pointer, but expected an integer
@ -516,7 +516,7 @@ LL | pub static S5: &[u8] = unsafe { from_raw_parts((&D3) as *const _ as _, mem:
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:216:1
--> $DIR/raw-bytes.rs:218:1
|
LL | pub static S6: &[bool] = unsafe { from_raw_parts((&D0) as *const _ as _, 4) };
| ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered 0x11, but expected a boolean
@ -527,7 +527,7 @@ LL | pub static S6: &[bool] = unsafe { from_raw_parts((&D0) as *const _ as _, 4)
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:220:1
--> $DIR/raw-bytes.rs:222:1
|
LL | pub static S7: &[u16] = unsafe {
| ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[1]: encountered uninitialized memory, but expected an integer
@ -538,7 +538,7 @@ LL | pub static S7: &[u16] = unsafe {
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:227:1
--> $DIR/raw-bytes.rs:229:1
|
LL | pub static R4: &[u8] = unsafe {
| ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered uninitialized memory, but expected an integer
@ -549,7 +549,7 @@ LL | pub static R4: &[u8] = unsafe {
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:232:1
--> $DIR/raw-bytes.rs:234:1
|
LL | pub static R5: &[u8] = unsafe {
| ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered a pointer, but expected an integer
@ -562,7 +562,7 @@ LL | pub static R5: &[u8] = unsafe {
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:237:1
--> $DIR/raw-bytes.rs:239:1
|
LL | pub static R6: &[bool] = unsafe {
| ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered 0x11, but expected a boolean

View file

@ -1,5 +1,5 @@
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:21:1
--> $DIR/raw-bytes.rs:23:1
|
LL | const BAD_ENUM: Enum = unsafe { mem::transmute(1usize) };
| ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-tag>: encountered 0x0000000000000001, but expected a valid enum tag
@ -10,7 +10,7 @@ LL | const BAD_ENUM: Enum = unsafe { mem::transmute(1usize) };
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:29:1
--> $DIR/raw-bytes.rs:31:1
|
LL | const BAD_ENUM2: Enum2 = unsafe { mem::transmute(0usize) };
| ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-tag>: encountered 0x0000000000000000, but expected a valid enum tag
@ -21,7 +21,7 @@ LL | const BAD_ENUM2: Enum2 = unsafe { mem::transmute(0usize) };
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:43:1
--> $DIR/raw-bytes.rs:45:1
|
LL | const BAD_UNINHABITED_VARIANT1: UninhDiscriminant = unsafe { mem::transmute(1u8) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-tag>: encountered an uninhabited enum variant
@ -32,7 +32,7 @@ LL | const BAD_UNINHABITED_VARIANT1: UninhDiscriminant = unsafe { mem::transmute
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:45:1
--> $DIR/raw-bytes.rs:47:1
|
LL | const BAD_UNINHABITED_VARIANT2: UninhDiscriminant = unsafe { mem::transmute(3u8) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-tag>: encountered an uninhabited enum variant
@ -43,7 +43,7 @@ LL | const BAD_UNINHABITED_VARIANT2: UninhDiscriminant = unsafe { mem::transmute
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:51:1
--> $DIR/raw-bytes.rs:53:1
|
LL | const BAD_OPTION_CHAR: Option<(char, char)> = Some(('x', unsafe { mem::transmute(!0u32) }));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-variant(Some)>.0.1: encountered 0xffffffff, but expected a valid unicode scalar value (in `0..=0x10FFFF` but not in `0xD800..=0xDFFF`)
@ -54,7 +54,7 @@ LL | const BAD_OPTION_CHAR: Option<(char, char)> = Some(('x', unsafe { mem::tran
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:56:1
--> $DIR/raw-bytes.rs:58:1
|
LL | const NULL_PTR: NonNull<u8> = unsafe { mem::transmute(0usize) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0, but expected something greater or equal to 1
@ -65,7 +65,7 @@ LL | const NULL_PTR: NonNull<u8> = unsafe { mem::transmute(0usize) };
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:59:1
--> $DIR/raw-bytes.rs:61:1
|
LL | const NULL_U8: NonZero<u8> = unsafe { mem::transmute(0u8) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered 0, but expected something greater or equal to 1
@ -76,7 +76,7 @@ LL | const NULL_U8: NonZero<u8> = unsafe { mem::transmute(0u8) };
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:61:1
--> $DIR/raw-bytes.rs:63:1
|
LL | const NULL_USIZE: NonZero<usize> = unsafe { mem::transmute(0usize) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered 0, but expected something greater or equal to 1
@ -87,7 +87,7 @@ LL | const NULL_USIZE: NonZero<usize> = unsafe { mem::transmute(0usize) };
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:67:1
--> $DIR/raw-bytes.rs:69:1
|
LL | const BAD_RANGE1: RestrictedRange1 = unsafe { RestrictedRange1(42) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 42, but expected something in the range 10..=30
@ -98,7 +98,7 @@ LL | const BAD_RANGE1: RestrictedRange1 = unsafe { RestrictedRange1(42) };
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:73:1
--> $DIR/raw-bytes.rs:75:1
|
LL | const BAD_RANGE2: RestrictedRange2 = unsafe { RestrictedRange2(20) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 20, but expected something less or equal to 10, or greater or equal to 30
@ -109,7 +109,7 @@ LL | const BAD_RANGE2: RestrictedRange2 = unsafe { RestrictedRange2(20) };
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:76:1
--> $DIR/raw-bytes.rs:78:1
|
LL | const NULL_FAT_PTR: NonNull<dyn Send> = unsafe {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0, but expected something greater or equal to 1
@ -120,7 +120,7 @@ LL | const NULL_FAT_PTR: NonNull<dyn Send> = unsafe {
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:84:1
--> $DIR/raw-bytes.rs:86:1
|
LL | const UNALIGNED: &u16 = unsafe { mem::transmute(&[0u8; 4]) };
| ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered an unaligned reference (required 2 byte alignment but found 1)
@ -131,7 +131,7 @@ LL | const UNALIGNED: &u16 = unsafe { mem::transmute(&[0u8; 4]) };
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:88:1
--> $DIR/raw-bytes.rs:90:1
|
LL | const UNALIGNED_BOX: Box<u16> = unsafe { mem::transmute(&[0u8; 4]) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered an unaligned box (required 2 byte alignment but found 1)
@ -142,7 +142,7 @@ LL | const UNALIGNED_BOX: Box<u16> = unsafe { mem::transmute(&[0u8; 4]) };
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:92:1
--> $DIR/raw-bytes.rs:94:1
|
LL | const NULL: &u16 = unsafe { mem::transmute(0usize) };
| ^^^^^^^^^^^^^^^^ constructing invalid value: encountered a null reference
@ -153,7 +153,7 @@ LL | const NULL: &u16 = unsafe { mem::transmute(0usize) };
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:95:1
--> $DIR/raw-bytes.rs:97:1
|
LL | const NULL_BOX: Box<u16> = unsafe { mem::transmute(0usize) };
| ^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a null box
@ -164,7 +164,7 @@ LL | const NULL_BOX: Box<u16> = unsafe { mem::transmute(0usize) };
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:98:1
--> $DIR/raw-bytes.rs:100:1
|
LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (0x539[noalloc] has no provenance)
@ -175,7 +175,7 @@ LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) };
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:101:1
--> $DIR/raw-bytes.rs:103:1
|
LL | const USIZE_AS_BOX: Box<u8> = unsafe { mem::transmute(1337usize) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling box (0x539[noalloc] has no provenance)
@ -186,7 +186,7 @@ LL | const USIZE_AS_BOX: Box<u8> = unsafe { mem::transmute(1337usize) };
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:104:1
--> $DIR/raw-bytes.rs:106:1
|
LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) };
| ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered null pointer, but expected a function pointer
@ -197,7 +197,7 @@ LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) };
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:106:1
--> $DIR/raw-bytes.rs:108:1
|
LL | const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0xd[noalloc], but expected a function pointer
@ -208,7 +208,7 @@ LL | const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) };
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:108:1
--> $DIR/raw-bytes.rs:110:1
|
LL | const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) };
| ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC3<imm>, but expected a function pointer
@ -219,7 +219,7 @@ LL | const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) };
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:114:1
--> $DIR/raw-bytes.rs:116:1
|
LL | const BAD_BAD_REF: &Bar = unsafe { mem::transmute(1usize) };
| ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to uninhabited type Bar
@ -230,7 +230,7 @@ LL | const BAD_BAD_REF: &Bar = unsafe { mem::transmute(1usize) };
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:139:1
--> $DIR/raw-bytes.rs:141:1
|
LL | const STR_TOO_LONG: &str = unsafe { mem::transmute((&42u8, 999usize)) };
| ^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (going beyond the bounds of its allocation)
@ -241,7 +241,7 @@ LL | const STR_TOO_LONG: &str = unsafe { mem::transmute((&42u8, 999usize)) };
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:141:1
--> $DIR/raw-bytes.rs:143:1
|
LL | const NESTED_STR_MUCH_TOO_LONG: (&str,) = (unsafe { mem::transmute((&42, usize::MAX)) },);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered invalid reference metadata: slice is bigger than largest supported object
@ -252,7 +252,7 @@ LL | const NESTED_STR_MUCH_TOO_LONG: (&str,) = (unsafe { mem::transmute((&42, us
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:143:1
--> $DIR/raw-bytes.rs:145:1
|
LL | const MY_STR_MUCH_TOO_LONG: &MyStr = unsafe { mem::transmute((&42u8, usize::MAX)) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered invalid reference metadata: slice is bigger than largest supported object
@ -263,7 +263,7 @@ LL | const MY_STR_MUCH_TOO_LONG: &MyStr = unsafe { mem::transmute((&42u8, usize:
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:146:1
--> $DIR/raw-bytes.rs:148:1
|
LL | const STR_NO_INIT: &str = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit::<u8> { uninit: () }]) };
| ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>: encountered uninitialized memory, but expected a string
@ -274,7 +274,7 @@ LL | const STR_NO_INIT: &str = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit:
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:148:1
--> $DIR/raw-bytes.rs:150:1
|
LL | const MYSTR_NO_INIT: &MyStr = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit::<u8> { uninit: () }]) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.0: encountered uninitialized memory, but expected a string
@ -285,7 +285,7 @@ LL | const MYSTR_NO_INIT: &MyStr = unsafe { mem::transmute::<&[_], _>(&[MaybeUni
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:150:1
--> $DIR/raw-bytes.rs:152:1
|
LL | const MYSTR_NO_INIT_ISSUE83182: &MyStr = unsafe { mem::transmute::<&[_], _>(&[&()]) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.0: encountered a pointer, but expected a string
@ -298,7 +298,7 @@ LL | const MYSTR_NO_INIT_ISSUE83182: &MyStr = unsafe { mem::transmute::<&[_], _>
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:154:1
--> $DIR/raw-bytes.rs:156:1
|
LL | const SLICE_TOO_LONG: &[u8] = unsafe { mem::transmute((&42u8, 999usize)) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (going beyond the bounds of its allocation)
@ -309,7 +309,7 @@ LL | const SLICE_TOO_LONG: &[u8] = unsafe { mem::transmute((&42u8, 999usize)) };
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:156:1
--> $DIR/raw-bytes.rs:158:1
|
LL | const SLICE_TOO_LONG_OVERFLOW: &[u32] = unsafe { mem::transmute((&42u32, isize::MAX)) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered invalid reference metadata: slice is bigger than largest supported object
@ -320,7 +320,7 @@ LL | const SLICE_TOO_LONG_OVERFLOW: &[u32] = unsafe { mem::transmute((&42u32, is
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:159:1
--> $DIR/raw-bytes.rs:161:1
|
LL | const SLICE_TOO_LONG_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, 999usize)) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling box (going beyond the bounds of its allocation)
@ -331,7 +331,7 @@ LL | const SLICE_TOO_LONG_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, 999us
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:162:1
--> $DIR/raw-bytes.rs:164:1
|
LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }];
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered 0x03, but expected a boolean
@ -342,13 +342,13 @@ LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }];
}
note: erroneous constant encountered
--> $DIR/raw-bytes.rs:162:40
--> $DIR/raw-bytes.rs:164:40
|
LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }];
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:168:1
--> $DIR/raw-bytes.rs:170:1
|
LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.0: encountered 0x03, but expected a boolean
@ -359,13 +359,13 @@ LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3
}
note: erroneous constant encountered
--> $DIR/raw-bytes.rs:168:42
--> $DIR/raw-bytes.rs:170:42
|
LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:172:1
--> $DIR/raw-bytes.rs:174:1
|
LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.1[0]: encountered 0x03, but expected a boolean
@ -376,13 +376,13 @@ LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::tran
}
note: erroneous constant encountered
--> $DIR/raw-bytes.rs:172:42
--> $DIR/raw-bytes.rs:174:42
|
LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:177:1
--> $DIR/raw-bytes.rs:179:1
|
LL | const TRAIT_OBJ_SHORT_VTABLE_1: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u8))) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC17<imm>, but expected a vtable pointer
@ -393,7 +393,7 @@ LL | const TRAIT_OBJ_SHORT_VTABLE_1: W<&dyn Trait> = unsafe { mem::transmute(W((
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:181:1
--> $DIR/raw-bytes.rs:183:1
|
LL | const TRAIT_OBJ_SHORT_VTABLE_2: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u64))) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC19<imm>, but expected a vtable pointer
@ -404,7 +404,7 @@ LL | const TRAIT_OBJ_SHORT_VTABLE_2: W<&dyn Trait> = unsafe { mem::transmute(W((
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:185:1
--> $DIR/raw-bytes.rs:187:1
|
LL | const TRAIT_OBJ_INT_VTABLE: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, 4usize))) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered 0x4[noalloc], but expected a vtable pointer
@ -415,7 +415,7 @@ LL | const TRAIT_OBJ_INT_VTABLE: W<&dyn Trait> = unsafe { mem::transmute(W((&92u
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:188:1
--> $DIR/raw-bytes.rs:190:1
|
LL | const TRAIT_OBJ_BAD_DROP_FN_NOT_FN_PTR: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &[&42u8; 8]))) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC22<imm>, but expected a vtable pointer
@ -426,7 +426,7 @@ LL | const TRAIT_OBJ_BAD_DROP_FN_NOT_FN_PTR: W<&dyn Trait> = unsafe { mem::trans
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:192:1
--> $DIR/raw-bytes.rs:194:1
|
LL | const TRAIT_OBJ_CONTENT_INVALID: &dyn Trait = unsafe { mem::transmute::<_, &bool>(&3u8) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.<dyn-downcast>: encountered 0x03, but expected a boolean
@ -437,7 +437,7 @@ LL | const TRAIT_OBJ_CONTENT_INVALID: &dyn Trait = unsafe { mem::transmute::<_,
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:196:1
--> $DIR/raw-bytes.rs:198:1
|
LL | const RAW_TRAIT_OBJ_VTABLE_NULL: *const dyn Trait = unsafe { mem::transmute((&92u8, 0usize)) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered null pointer, but expected a vtable pointer
@ -448,7 +448,7 @@ LL | const RAW_TRAIT_OBJ_VTABLE_NULL: *const dyn Trait = unsafe { mem::transmute
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:199:1
--> $DIR/raw-bytes.rs:201:1
|
LL | const RAW_TRAIT_OBJ_VTABLE_INVALID: *const dyn Trait = unsafe { mem::transmute((&92u8, &3u64)) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC27<imm>, but expected a vtable pointer
@ -459,7 +459,7 @@ LL | const RAW_TRAIT_OBJ_VTABLE_INVALID: *const dyn Trait = unsafe { mem::transm
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:204:1
--> $DIR/raw-bytes.rs:206:1
|
LL | const _: &[!; 1] = unsafe { &*(1_usize as *const [!; 1]) };
| ^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to uninhabited type [!; 1]
@ -470,7 +470,7 @@ LL | const _: &[!; 1] = unsafe { &*(1_usize as *const [!; 1]) };
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:205:1
--> $DIR/raw-bytes.rs:207:1
|
LL | const _: &[!] = unsafe { &*(1_usize as *const [!; 1]) };
| ^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered a value of the never type `!`
@ -481,7 +481,7 @@ LL | const _: &[!] = unsafe { &*(1_usize as *const [!; 1]) };
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:206:1
--> $DIR/raw-bytes.rs:208:1
|
LL | const _: &[!] = unsafe { &*(1_usize as *const [!; 42]) };
| ^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered a value of the never type `!`
@ -492,7 +492,7 @@ LL | const _: &[!] = unsafe { &*(1_usize as *const [!; 42]) };
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:210:1
--> $DIR/raw-bytes.rs:212:1
|
LL | pub static S4: &[u8] = unsafe { from_raw_parts((&D1) as *const _ as _, 1) };
| ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered uninitialized memory, but expected an integer
@ -503,7 +503,7 @@ LL | pub static S4: &[u8] = unsafe { from_raw_parts((&D1) as *const _ as _, 1) }
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:213:1
--> $DIR/raw-bytes.rs:215:1
|
LL | pub static S5: &[u8] = unsafe { from_raw_parts((&D3) as *const _ as _, mem::size_of::<&u32>()) };
| ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered a pointer, but expected an integer
@ -516,7 +516,7 @@ LL | pub static S5: &[u8] = unsafe { from_raw_parts((&D3) as *const _ as _, mem:
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:216:1
--> $DIR/raw-bytes.rs:218:1
|
LL | pub static S6: &[bool] = unsafe { from_raw_parts((&D0) as *const _ as _, 4) };
| ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered 0x11, but expected a boolean
@ -527,7 +527,7 @@ LL | pub static S6: &[bool] = unsafe { from_raw_parts((&D0) as *const _ as _, 4)
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:220:1
--> $DIR/raw-bytes.rs:222:1
|
LL | pub static S7: &[u16] = unsafe {
| ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[1]: encountered uninitialized memory, but expected an integer
@ -538,7 +538,7 @@ LL | pub static S7: &[u16] = unsafe {
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:227:1
--> $DIR/raw-bytes.rs:229:1
|
LL | pub static R4: &[u8] = unsafe {
| ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered uninitialized memory, but expected an integer
@ -549,7 +549,7 @@ LL | pub static R4: &[u8] = unsafe {
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:232:1
--> $DIR/raw-bytes.rs:234:1
|
LL | pub static R5: &[u8] = unsafe {
| ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered a pointer, but expected an integer
@ -562,7 +562,7 @@ LL | pub static R5: &[u8] = unsafe {
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
error[E0080]: it is undefined behavior to use this value
--> $DIR/raw-bytes.rs:237:1
--> $DIR/raw-bytes.rs:239:1
|
LL | pub static R6: &[bool] = unsafe {
| ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered 0x11, but expected a boolean

View file

@ -2,6 +2,8 @@
//@ ignore-endian-big
// ignore-tidy-linelength
//@ normalize-stderr: "╾─*ALLOC[0-9]+(\+[a-z0-9]+)?(<imm>)?─*╼" -> "╾ALLOC_ID$1╼"
//@ dont-require-annotations: NOTE
#![allow(invalid_value, unnecessary_transmutes)]
#![feature(never_type, rustc_attrs, ptr_metadata, slice_from_ptr_range, const_slice_from_ptr_range)]
@ -83,11 +85,11 @@ const NULL_FAT_PTR: NonNull<dyn Send> = unsafe {
const UNALIGNED: &u16 = unsafe { mem::transmute(&[0u8; 4]) };
//~^ ERROR it is undefined behavior to use this value
//~| constructing invalid value: encountered an unaligned reference (required 2 byte alignment but found 1)
//~| NOTE constructing invalid value: encountered an unaligned reference (required 2 byte alignment but found 1)
const UNALIGNED_BOX: Box<u16> = unsafe { mem::transmute(&[0u8; 4]) };
//~^ ERROR it is undefined behavior to use this value
//~| constructing invalid value: encountered an unaligned box (required 2 byte alignment but found 1)
//~| NOTE constructing invalid value: encountered an unaligned box (required 2 byte alignment but found 1)
const NULL: &u16 = unsafe { mem::transmute(0usize) };
//~^ ERROR it is undefined behavior to use this value
@ -161,44 +163,44 @@ const SLICE_TOO_LONG_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, 999usize))
// bad data *inside* the slice
const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }];
//~^ ERROR it is undefined behavior to use this value
//~| constant
//~| NOTE constant
// bad: sized field is not okay
const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]);
//~^ ERROR it is undefined behavior to use this value
//~| constant
//~| NOTE constant
// bad: unsized part is not okay
const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]);
//~^ ERROR it is undefined behavior to use this value
//~| constant
//~| NOTE constant
// bad trait object
const TRAIT_OBJ_SHORT_VTABLE_1: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u8))) };
//~^ ERROR it is undefined behavior to use this value
//~| expected a vtable
//~| NOTE expected a vtable
// bad trait object
const TRAIT_OBJ_SHORT_VTABLE_2: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u64))) };
//~^ ERROR it is undefined behavior to use this value
//~| expected a vtable
//~| NOTE expected a vtable
// bad trait object
const TRAIT_OBJ_INT_VTABLE: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, 4usize))) };
//~^ ERROR it is undefined behavior to use this value
//~| expected a vtable
//~| NOTE expected a vtable
const TRAIT_OBJ_BAD_DROP_FN_NOT_FN_PTR: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &[&42u8; 8]))) };
//~^ ERROR it is undefined behavior to use this value
//~| expected a vtable
//~| NOTE expected a vtable
// bad data *inside* the trait object
const TRAIT_OBJ_CONTENT_INVALID: &dyn Trait = unsafe { mem::transmute::<_, &bool>(&3u8) };
//~^ ERROR it is undefined behavior to use this value
//~| expected a boolean
//~| NOTE expected a boolean
const RAW_TRAIT_OBJ_VTABLE_NULL: *const dyn Trait = unsafe { mem::transmute((&92u8, 0usize)) };
//~^ ERROR it is undefined behavior to use this value
//~| null pointer
//~| NOTE null pointer
const RAW_TRAIT_OBJ_VTABLE_INVALID: *const dyn Trait = unsafe { mem::transmute((&92u8, &3u64)) };
//~^ ERROR it is undefined behavior to use this value
//~| vtable
//~| NOTE vtable
// Uninhabited types
const _: &[!; 1] = unsafe { &*(1_usize as *const [!; 1]) }; //~ ERROR undefined behavior

View file

@ -2,6 +2,8 @@
//@ normalize-stderr: "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)"
//@ normalize-stderr: "([0-9a-f][0-9a-f] |╾─*ALLOC[0-9]+(\+[a-z0-9]+)?(<imm>)?─*╼ )+ *│.*" -> "HEX_DUMP"
//@ normalize-stderr: "0x0+" -> "0x0"
//@ dont-require-annotations: NOTE
#![feature(never_type)]
#![allow(invalid_value, unnecessary_transmutes)]
@ -58,7 +60,7 @@ union MaybeUninit<T: Copy> {
}
const BAD_ENUM2_UNDEF : Enum2 = unsafe { MaybeUninit { uninit: () }.init };
//~^ ERROR evaluation of constant value failed
//~| uninitialized
//~| NOTE uninitialized
// Pointer value in an enum with a niche that is not just 0.
const BAD_ENUM2_OPTION_PTR: Option<Enum2> = unsafe { mem::transmute(&0) };

View file

@ -1,5 +1,5 @@
error[E0080]: it is undefined behavior to use this value
--> $DIR/ub-enum.rs:27:1
--> $DIR/ub-enum.rs:29:1
|
LL | const BAD_ENUM: Enum = unsafe { mem::transmute(1usize) };
| ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-tag>: encountered 0x01, but expected a valid enum tag
@ -10,7 +10,7 @@ LL | const BAD_ENUM: Enum = unsafe { mem::transmute(1usize) };
}
error[E0080]: evaluation of constant value failed
--> $DIR/ub-enum.rs:30:1
--> $DIR/ub-enum.rs:32:1
|
LL | const BAD_ENUM_PTR: Enum = unsafe { mem::transmute(&1) };
| ^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
@ -19,7 +19,7 @@ LL | const BAD_ENUM_PTR: Enum = unsafe { mem::transmute(&1) };
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
error[E0080]: evaluation of constant value failed
--> $DIR/ub-enum.rs:33:1
--> $DIR/ub-enum.rs:35:1
|
LL | const BAD_ENUM_WRAPPED: Wrap<Enum> = unsafe { mem::transmute(&1) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
@ -28,7 +28,7 @@ LL | const BAD_ENUM_WRAPPED: Wrap<Enum> = unsafe { mem::transmute(&1) };
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
error[E0080]: it is undefined behavior to use this value
--> $DIR/ub-enum.rs:45:1
--> $DIR/ub-enum.rs:47:1
|
LL | const BAD_ENUM2: Enum2 = unsafe { mem::transmute(0usize) };
| ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-tag>: encountered 0x0, but expected a valid enum tag
@ -39,7 +39,7 @@ LL | const BAD_ENUM2: Enum2 = unsafe { mem::transmute(0usize) };
}
error[E0080]: evaluation of constant value failed
--> $DIR/ub-enum.rs:47:1
--> $DIR/ub-enum.rs:49:1
|
LL | const BAD_ENUM2_PTR: Enum2 = unsafe { mem::transmute(&0) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
@ -48,7 +48,7 @@ LL | const BAD_ENUM2_PTR: Enum2 = unsafe { mem::transmute(&0) };
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
error[E0080]: evaluation of constant value failed
--> $DIR/ub-enum.rs:50:1
--> $DIR/ub-enum.rs:52:1
|
LL | const BAD_ENUM2_WRAPPED: Wrap<Enum2> = unsafe { mem::transmute(&0) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
@ -57,13 +57,13 @@ LL | const BAD_ENUM2_WRAPPED: Wrap<Enum2> = unsafe { mem::transmute(&0) };
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
error[E0080]: evaluation of constant value failed
--> $DIR/ub-enum.rs:59:42
--> $DIR/ub-enum.rs:61:42
|
LL | const BAD_ENUM2_UNDEF : Enum2 = unsafe { MaybeUninit { uninit: () }.init };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory
error[E0080]: evaluation of constant value failed
--> $DIR/ub-enum.rs:64:1
--> $DIR/ub-enum.rs:66:1
|
LL | const BAD_ENUM2_OPTION_PTR: Option<Enum2> = unsafe { mem::transmute(&0) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
@ -72,7 +72,7 @@ LL | const BAD_ENUM2_OPTION_PTR: Option<Enum2> = unsafe { mem::transmute(&0) };
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
error[E0080]: it is undefined behavior to use this value
--> $DIR/ub-enum.rs:81:1
--> $DIR/ub-enum.rs:83:1
|
LL | const BAD_UNINHABITED_VARIANT1: UninhDiscriminant = unsafe { mem::transmute(1u8) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-tag>: encountered an uninhabited enum variant
@ -83,7 +83,7 @@ LL | const BAD_UNINHABITED_VARIANT1: UninhDiscriminant = unsafe { mem::transmute
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/ub-enum.rs:83:1
--> $DIR/ub-enum.rs:85:1
|
LL | const BAD_UNINHABITED_VARIANT2: UninhDiscriminant = unsafe { mem::transmute(3u8) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-tag>: encountered an uninhabited enum variant
@ -94,7 +94,7 @@ LL | const BAD_UNINHABITED_VARIANT2: UninhDiscriminant = unsafe { mem::transmute
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/ub-enum.rs:91:1
--> $DIR/ub-enum.rs:93:1
|
LL | const BAD_OPTION_CHAR: Option<(char, char)> = Some(('x', unsafe { mem::transmute(!0u32) }));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-variant(Some)>.0.1: encountered 0xffffffff, but expected a valid unicode scalar value (in `0..=0x10FFFF` but not in `0xD800..=0xDFFF`)
@ -105,19 +105,19 @@ LL | const BAD_OPTION_CHAR: Option<(char, char)> = Some(('x', unsafe { mem::tran
}
error[E0080]: evaluation of constant value failed
--> $DIR/ub-enum.rs:96:77
--> $DIR/ub-enum.rs:98:77
|
LL | const BAD_UNINHABITED_WITH_DATA1: Result<(i32, Never), (i32, !)> = unsafe { mem::transmute(0u64) };
| ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-tag>: encountered an uninhabited enum variant
error[E0080]: evaluation of constant value failed
--> $DIR/ub-enum.rs:98:77
--> $DIR/ub-enum.rs:100:77
|
LL | const BAD_UNINHABITED_WITH_DATA2: Result<(i32, !), (i32, Never)> = unsafe { mem::transmute(0u64) };
| ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-tag>: encountered an uninhabited enum variant
error[E0080]: evaluation of constant value failed
--> $DIR/ub-enum.rs:103:14
--> $DIR/ub-enum.rs:105:14
|
LL | unsafe { std::mem::discriminant(&*(&() as *const () as *const Never)); };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ read discriminant of an uninhabited enum variant

View file

@ -11,19 +11,19 @@
// errors are emitted instead of ICEs.
//@ stderr-per-bitwidth
//@ dont-require-annotations: NOTE
trait Trait {}
const INVALID_VTABLE_ALIGNMENT: &dyn Trait =
unsafe { std::mem::transmute((&92u8, &[0usize, 1usize, 1000usize])) };
//~^^ ERROR it is undefined behavior to use this value
//~| vtable
//~| NOTE vtable
const INVALID_VTABLE_SIZE: &dyn Trait =
unsafe { std::mem::transmute((&92u8, &[1usize, usize::MAX, 1usize])) };
//~^^ ERROR it is undefined behavior to use this value
//~| vtable
//~| NOTE vtable
#[repr(transparent)]
struct W<T>(T);
@ -33,18 +33,18 @@ fn drop_me(_: *mut usize) {}
const INVALID_VTABLE_ALIGNMENT_UB: W<&dyn Trait> =
unsafe { std::mem::transmute((&92u8, &(drop_me as fn(*mut usize), 1usize, 1000usize))) };
//~^^ ERROR it is undefined behavior to use this value
//~| expected a vtable pointer
//~| NOTE expected a vtable pointer
const INVALID_VTABLE_SIZE_UB: W<&dyn Trait> =
unsafe { std::mem::transmute((&92u8, &(drop_me as fn(*mut usize), usize::MAX, 1usize))) };
//~^^ ERROR it is undefined behavior to use this value
//~| expected a vtable pointer
//~| NOTE expected a vtable pointer
// Even if the vtable has a fn ptr and a reasonable size+align, it still does not work.
const INVALID_VTABLE_UB: W<&dyn Trait> =
unsafe { std::mem::transmute((&92u8, &(drop_me as fn(*mut usize), 1usize, 1usize))) };
//~^^ ERROR it is undefined behavior to use this value
//~| expected a vtable pointer
//~| NOTE expected a vtable pointer
// Trying to access the data in a vtable does not work, either.
@ -90,7 +90,7 @@ union Transmute<T: Copy, U: Copy> {
const FOO: &dyn Bar = &Foo { foo: 128, bar: false };
const G: Wide = unsafe { Transmute { t: FOO }.u };
//~^ ERROR it is undefined behavior to use this value
//~| encountered a dangling reference
//~| NOTE encountered a dangling reference
// (it is dangling because vtables do not contain memory that can be dereferenced)
fn main() {}

View file

@ -1,6 +1,8 @@
//! Test the "array of int" fast path in validity checking, and in particular whether it
//! points at the right array element.
//@ dont-require-annotations: NOTE
use std::mem;
#[repr(C)]
@ -17,7 +19,7 @@ impl<T: Copy> MaybeUninit<T> {
const UNINIT_INT_0: [u32; 3] = unsafe {
//~^ ERROR it is undefined behavior to use this value
//~| invalid value at [0]
//~| NOTE invalid value at [0]
mem::transmute([
MaybeUninit { uninit: () },
// Constants chosen to achieve endianness-independent hex dump.
@ -27,7 +29,7 @@ const UNINIT_INT_0: [u32; 3] = unsafe {
};
const UNINIT_INT_1: [u32; 3] = unsafe {
//~^ ERROR it is undefined behavior to use this value
//~| invalid value at [1]
//~| NOTE invalid value at [1]
mem::transmute([
MaybeUninit::new(0u8),
MaybeUninit::new(0u8),
@ -45,7 +47,7 @@ const UNINIT_INT_1: [u32; 3] = unsafe {
};
const UNINIT_INT_2: [u32; 3] = unsafe {
//~^ ERROR it is undefined behavior to use this value
//~| invalid value at [2]
//~| NOTE invalid value at [2]
mem::transmute([
MaybeUninit::new(0u8),
MaybeUninit::new(0u8),

View file

@ -1,5 +1,5 @@
error[E0080]: it is undefined behavior to use this value
--> $DIR/ub-int-array.rs:18:1
--> $DIR/ub-int-array.rs:20:1
|
LL | const UNINIT_INT_0: [u32; 3] = unsafe {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at [0]: encountered uninitialized memory, but expected an integer
@ -10,7 +10,7 @@ LL | const UNINIT_INT_0: [u32; 3] = unsafe {
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/ub-int-array.rs:28:1
--> $DIR/ub-int-array.rs:30:1
|
LL | const UNINIT_INT_1: [u32; 3] = unsafe {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at [1]: encountered uninitialized memory, but expected an integer
@ -21,7 +21,7 @@ LL | const UNINIT_INT_1: [u32; 3] = unsafe {
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/ub-int-array.rs:46:1
--> $DIR/ub-int-array.rs:48:1
|
LL | const UNINIT_INT_2: [u32; 3] = unsafe {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at [2]: encountered uninitialized memory, but expected an integer

View file

@ -1,6 +1,8 @@
// Strip out raw byte dumps to make comparison platform-independent:
//@ normalize-stderr: "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)"
//@ normalize-stderr: "([0-9a-f][0-9a-f] |╾─*ALLOC[0-9]+(\+[a-z0-9]+)?─*╼ )+ *│.*" -> "HEX_DUMP"
//@ dont-require-annotations: NOTE
#![allow(invalid_value)] // make sure we cannot allow away the errors tested here
#![feature(rustc_attrs, ptr_metadata)]
@ -33,7 +35,7 @@ union MaybeUninit<T: Copy> {
}
const UNINIT: NonZero<u8> = unsafe { MaybeUninit { uninit: () }.init };
//~^ ERROR evaluation of constant value failed
//~| uninitialized
//~| NOTE uninitialized
// Also test other uses of rustc_layout_scalar_valid_range_start

View file

@ -1,5 +1,5 @@
error[E0080]: it is undefined behavior to use this value
--> $DIR/ub-nonnull.rs:14:1
--> $DIR/ub-nonnull.rs:16:1
|
LL | const NULL_PTR: NonNull<u8> = unsafe { mem::transmute(0usize) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0, but expected something greater or equal to 1
@ -10,13 +10,13 @@ LL | const NULL_PTR: NonNull<u8> = unsafe { mem::transmute(0usize) };
}
error[E0080]: evaluation of constant value failed
--> $DIR/ub-nonnull.rs:20:29
--> $DIR/ub-nonnull.rs:22:29
|
LL | let out_of_bounds_ptr = &ptr[255];
| ^^^^^^^^^ out-of-bounds pointer arithmetic: expected a pointer to 255 bytes of memory, but got ALLOC1 which is only 1 byte from the end of the allocation
error[E0080]: it is undefined behavior to use this value
--> $DIR/ub-nonnull.rs:24:1
--> $DIR/ub-nonnull.rs:26:1
|
LL | const NULL_U8: NonZero<u8> = unsafe { mem::transmute(0u8) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered 0, but expected something greater or equal to 1
@ -27,7 +27,7 @@ LL | const NULL_U8: NonZero<u8> = unsafe { mem::transmute(0u8) };
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/ub-nonnull.rs:26:1
--> $DIR/ub-nonnull.rs:28:1
|
LL | const NULL_USIZE: NonZero<usize> = unsafe { mem::transmute(0usize) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered 0, but expected something greater or equal to 1
@ -38,13 +38,13 @@ LL | const NULL_USIZE: NonZero<usize> = unsafe { mem::transmute(0usize) };
}
error[E0080]: evaluation of constant value failed
--> $DIR/ub-nonnull.rs:34:38
--> $DIR/ub-nonnull.rs:36:38
|
LL | const UNINIT: NonZero<u8> = unsafe { MaybeUninit { uninit: () }.init };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory
error[E0080]: it is undefined behavior to use this value
--> $DIR/ub-nonnull.rs:43:1
--> $DIR/ub-nonnull.rs:45:1
|
LL | const BAD_RANGE1: RestrictedRange1 = unsafe { RestrictedRange1(42) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 42, but expected something in the range 10..=30
@ -55,7 +55,7 @@ LL | const BAD_RANGE1: RestrictedRange1 = unsafe { RestrictedRange1(42) };
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/ub-nonnull.rs:49:1
--> $DIR/ub-nonnull.rs:51:1
|
LL | const BAD_RANGE2: RestrictedRange2 = unsafe { RestrictedRange2(20) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 20, but expected something less or equal to 10, or greater or equal to 30
@ -66,7 +66,7 @@ LL | const BAD_RANGE2: RestrictedRange2 = unsafe { RestrictedRange2(20) };
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/ub-nonnull.rs:52:1
--> $DIR/ub-nonnull.rs:54:1
|
LL | const NULL_FAT_PTR: NonNull<dyn Send> = unsafe {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0, but expected something greater or equal to 1

View file

@ -2,6 +2,8 @@
// Strip out raw byte dumps to make comparison platform-independent:
//@ normalize-stderr: "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)"
//@ normalize-stderr: "([0-9a-f][0-9a-f] |╾─*ALLOC[0-9]+(\+[a-z0-9]+)?(<imm>)?─*╼ )+ *│.*" -> "HEX_DUMP"
//@ dont-require-annotations: NOTE
#![allow(invalid_value)]
use std::mem;
@ -14,11 +16,11 @@ union MaybeUninit<T: Copy> {
const UNALIGNED: &u16 = unsafe { mem::transmute(&[0u8; 4]) };
//~^ ERROR it is undefined behavior to use this value
//~| constructing invalid value: encountered an unaligned reference (required 2 byte alignment but found 1)
//~| NOTE constructing invalid value: encountered an unaligned reference (required 2 byte alignment but found 1)
const UNALIGNED_BOX: Box<u16> = unsafe { mem::transmute(&[0u8; 4]) };
//~^ ERROR it is undefined behavior to use this value
//~| constructing invalid value: encountered an unaligned box (required 2 byte alignment but found 1)
//~| NOTE constructing invalid value: encountered an unaligned box (required 2 byte alignment but found 1)
const NULL: &u16 = unsafe { mem::transmute(0usize) };
//~^ ERROR it is undefined behavior to use this value
@ -47,13 +49,13 @@ const USIZE_AS_BOX: Box<u8> = unsafe { mem::transmute(1337usize) };
const UNINIT_PTR: *const i32 = unsafe { MaybeUninit { uninit: () }.init };
//~^ ERROR evaluation of constant value failed
//~| uninitialized
//~| NOTE uninitialized
const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) };
//~^ ERROR it is undefined behavior to use this value
const UNINIT_FN_PTR: fn() = unsafe { MaybeUninit { uninit: () }.init };
//~^ ERROR evaluation of constant value failed
//~| uninitialized
//~| NOTE uninitialized
const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) };
//~^ ERROR it is undefined behavior to use this value
const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) };

View file

@ -1,5 +1,5 @@
error[E0080]: it is undefined behavior to use this value
--> $DIR/ub-ref-ptr.rs:15:1
--> $DIR/ub-ref-ptr.rs:17:1
|
LL | const UNALIGNED: &u16 = unsafe { mem::transmute(&[0u8; 4]) };
| ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered an unaligned reference (required 2 byte alignment but found 1)
@ -10,7 +10,7 @@ LL | const UNALIGNED: &u16 = unsafe { mem::transmute(&[0u8; 4]) };
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/ub-ref-ptr.rs:19:1
--> $DIR/ub-ref-ptr.rs:21:1
|
LL | const UNALIGNED_BOX: Box<u16> = unsafe { mem::transmute(&[0u8; 4]) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered an unaligned box (required 2 byte alignment but found 1)
@ -21,7 +21,7 @@ LL | const UNALIGNED_BOX: Box<u16> = unsafe { mem::transmute(&[0u8; 4]) };
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/ub-ref-ptr.rs:23:1
--> $DIR/ub-ref-ptr.rs:25:1
|
LL | const NULL: &u16 = unsafe { mem::transmute(0usize) };
| ^^^^^^^^^^^^^^^^ constructing invalid value: encountered a null reference
@ -32,7 +32,7 @@ LL | const NULL: &u16 = unsafe { mem::transmute(0usize) };
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/ub-ref-ptr.rs:26:1
--> $DIR/ub-ref-ptr.rs:28:1
|
LL | const NULL_BOX: Box<u16> = unsafe { mem::transmute(0usize) };
| ^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a null box
@ -43,7 +43,7 @@ LL | const NULL_BOX: Box<u16> = unsafe { mem::transmute(0usize) };
}
error[E0080]: evaluation of constant value failed
--> $DIR/ub-ref-ptr.rs:33:1
--> $DIR/ub-ref-ptr.rs:35:1
|
LL | const REF_AS_USIZE: usize = unsafe { mem::transmute(&0) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
@ -52,7 +52,7 @@ LL | const REF_AS_USIZE: usize = unsafe { mem::transmute(&0) };
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
error[E0080]: evaluation of constant value failed
--> $DIR/ub-ref-ptr.rs:36:39
--> $DIR/ub-ref-ptr.rs:38:39
|
LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }];
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
@ -61,13 +61,13 @@ LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }];
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
note: erroneous constant encountered
--> $DIR/ub-ref-ptr.rs:36:38
--> $DIR/ub-ref-ptr.rs:38:38
|
LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }];
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0080]: evaluation of constant value failed
--> $DIR/ub-ref-ptr.rs:39:86
--> $DIR/ub-ref-ptr.rs:41:86
|
LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[usize], _>(&[mem::transmute(&0)]) };
| ^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
@ -76,13 +76,13 @@ LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[us
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
note: erroneous constant encountered
--> $DIR/ub-ref-ptr.rs:39:85
--> $DIR/ub-ref-ptr.rs:41:85
|
LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[usize], _>(&[mem::transmute(&0)]) };
| ^^^^^^^^^^^^^^^^^^^^^
error[E0080]: it is undefined behavior to use this value
--> $DIR/ub-ref-ptr.rs:42:1
--> $DIR/ub-ref-ptr.rs:44:1
|
LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (0x539[noalloc] has no provenance)
@ -93,7 +93,7 @@ LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) };
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/ub-ref-ptr.rs:45:1
--> $DIR/ub-ref-ptr.rs:47:1
|
LL | const USIZE_AS_BOX: Box<u8> = unsafe { mem::transmute(1337usize) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling box (0x539[noalloc] has no provenance)
@ -104,13 +104,13 @@ LL | const USIZE_AS_BOX: Box<u8> = unsafe { mem::transmute(1337usize) };
}
error[E0080]: evaluation of constant value failed
--> $DIR/ub-ref-ptr.rs:48:41
--> $DIR/ub-ref-ptr.rs:50:41
|
LL | const UNINIT_PTR: *const i32 = unsafe { MaybeUninit { uninit: () }.init };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory
error[E0080]: it is undefined behavior to use this value
--> $DIR/ub-ref-ptr.rs:52:1
--> $DIR/ub-ref-ptr.rs:54:1
|
LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) };
| ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered null pointer, but expected a function pointer
@ -121,13 +121,13 @@ LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) };
}
error[E0080]: evaluation of constant value failed
--> $DIR/ub-ref-ptr.rs:54:38
--> $DIR/ub-ref-ptr.rs:56:38
|
LL | const UNINIT_FN_PTR: fn() = unsafe { MaybeUninit { uninit: () }.init };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory
error[E0080]: it is undefined behavior to use this value
--> $DIR/ub-ref-ptr.rs:57:1
--> $DIR/ub-ref-ptr.rs:59:1
|
LL | const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0xd[noalloc], but expected a function pointer
@ -138,7 +138,7 @@ LL | const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) };
}
error[E0080]: it is undefined behavior to use this value
--> $DIR/ub-ref-ptr.rs:59:1
--> $DIR/ub-ref-ptr.rs:61:1
|
LL | const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) };
| ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC2<imm>, but expected a function pointer
@ -149,7 +149,7 @@ LL | const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) };
}
error[E0080]: evaluation of constant value failed
--> $DIR/ub-ref-ptr.rs:66:5
--> $DIR/ub-ref-ptr.rs:68:5
|
LL | ptr.read();
| ^^^^^^^^^^ accessing memory based on pointer with alignment 1, but alignment 4 is required

View file

@ -1,6 +1,8 @@
// Strip out raw byte dumps to make comparison platform-independent:
//@ normalize-stderr: "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)"
//@ normalize-stderr: "([0-9a-f][0-9a-f] |╾─*ALLOC[0-9]+(\+[a-z0-9]+)?(<imm>)?─*╼ )+ *│.*" -> "HEX_DUMP"
//@ dont-require-annotations: NOTE
#![feature(core_intrinsics)]
#![feature(never_type)]
@ -18,15 +20,15 @@ union MaybeUninit<T: Copy> {
const BAD_BAD_BAD: Bar = unsafe { MaybeUninit { uninit: () }.init };
//~^ ERROR evaluation of constant value failed
//~| constructing invalid value
//~| NOTE constructing invalid value
const BAD_BAD_REF: &Bar = unsafe { mem::transmute(1usize) };
//~^ ERROR it is undefined behavior to use this value
//~| constructing invalid value
//~| NOTE constructing invalid value
const BAD_BAD_ARRAY: [Bar; 1] = unsafe { MaybeUninit { uninit: () }.init };
//~^ ERROR evaluation of constant value failed
//~| constructing invalid value
//~| NOTE constructing invalid value
const READ_NEVER: () = unsafe {
@ -34,7 +36,7 @@ const READ_NEVER: () = unsafe {
let ptr = mem.as_ptr().cast::<!>();
let _val = intrinsics::read_via_copy(ptr);
//~^ ERROR evaluation of constant value failed
//~| constructing invalid value
//~| NOTE constructing invalid value
};

View file

@ -1,11 +1,11 @@
error[E0080]: evaluation of constant value failed
--> $DIR/ub-uninhabit.rs:19:35
--> $DIR/ub-uninhabit.rs:21:35
|
LL | const BAD_BAD_BAD: Bar = unsafe { MaybeUninit { uninit: () }.init };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a value of uninhabited type `Bar`
error[E0080]: it is undefined behavior to use this value
--> $DIR/ub-uninhabit.rs:23:1
--> $DIR/ub-uninhabit.rs:25:1
|
LL | const BAD_BAD_REF: &Bar = unsafe { mem::transmute(1usize) };
| ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to uninhabited type Bar
@ -16,13 +16,13 @@ LL | const BAD_BAD_REF: &Bar = unsafe { mem::transmute(1usize) };
}
error[E0080]: evaluation of constant value failed
--> $DIR/ub-uninhabit.rs:27:42
--> $DIR/ub-uninhabit.rs:29:42
|
LL | const BAD_BAD_ARRAY: [Bar; 1] = unsafe { MaybeUninit { uninit: () }.init };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at [0]: encountered a value of uninhabited type `Bar`
error[E0080]: evaluation of constant value failed
--> $DIR/ub-uninhabit.rs:35:16
--> $DIR/ub-uninhabit.rs:37:16
|
LL | let _val = intrinsics::read_via_copy(ptr);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a value of the never type `!`

View file

@ -9,7 +9,7 @@ use std::{ptr, mem};
//@ normalize-stderr: "([0-9a-f][0-9a-f] |╾─*ALLOC[0-9]+(\+[a-z0-9]+)?(<imm>)?─*╼ )+ *│.*" -> "HEX_DUMP"
//@ normalize-stderr: "offset \d+" -> "offset N"
//@ normalize-stderr: "size \d+" -> "size N"
//@ dont-require-annotations: NOTE
/// A newtype wrapper to prevent MIR generation from inserting reborrows that would affect the error
/// message.
@ -62,7 +62,7 @@ const SLICE_VALID: &[u8] = unsafe { mem::transmute((&42u8, 1usize)) };
// bad slice: length uninit
const SLICE_LENGTH_UNINIT: &[u8] = unsafe {
//~^ ERROR evaluation of constant value failed
//~| uninitialized
//~| NOTE uninitialized
let uninit_len = MaybeUninit::<usize> { uninit: () };
mem::transmute((42, uninit_len))
};
@ -85,18 +85,18 @@ const SLICE_LENGTH_PTR_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, &3)) };
// bad data *inside* the slice
const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }];
//~^ ERROR it is undefined behavior to use this value
//~| constant
//~| NOTE constant
// good MySliceBool
const MYSLICE_GOOD: &MySliceBool = &MySlice(true, [false]);
// bad: sized field is not okay
const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]);
//~^ ERROR it is undefined behavior to use this value
//~| constant
//~| NOTE constant
// bad: unsized part is not okay
const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]);
//~^ ERROR it is undefined behavior to use this value
//~| constant
//~| NOTE constant
// # raw slice
const RAW_SLICE_VALID: *const [u8] = unsafe { mem::transmute((&42u8, 1usize)) }; // ok
@ -104,7 +104,7 @@ const RAW_SLICE_TOO_LONG: *const [u8] = unsafe { mem::transmute((&42u8, 999usize
const RAW_SLICE_MUCH_TOO_LONG: *const [u8] = unsafe { mem::transmute((&42u8, usize::MAX)) }; // ok because raw
const RAW_SLICE_LENGTH_UNINIT: *const [u8] = unsafe {
//~^ ERROR evaluation of constant value failed
//~| uninitialized
//~| NOTE uninitialized
let uninit_len = MaybeUninit::<usize> { uninit: () };
mem::transmute((42, uninit_len))
};
@ -113,40 +113,40 @@ const RAW_SLICE_LENGTH_UNINIT: *const [u8] = unsafe {
// bad trait object
const TRAIT_OBJ_SHORT_VTABLE_1: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u8))) };
//~^ ERROR it is undefined behavior to use this value
//~| vtable
//~| NOTE vtable
// bad trait object
const TRAIT_OBJ_SHORT_VTABLE_2: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u64))) };
//~^ ERROR it is undefined behavior to use this value
//~| vtable
//~| NOTE vtable
// bad trait object
const TRAIT_OBJ_INT_VTABLE: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, 4usize))) };
//~^ ERROR it is undefined behavior to use this value
//~| vtable
//~| NOTE vtable
const TRAIT_OBJ_UNALIGNED_VTABLE: &dyn Trait = unsafe { mem::transmute((&92u8, &[0u8; 128])) };
//~^ ERROR it is undefined behavior to use this value
//~| vtable
//~| NOTE vtable
const TRAIT_OBJ_BAD_DROP_FN_NULL: &dyn Trait = unsafe { mem::transmute((&92u8, &[0usize; 8])) };
//~^ ERROR it is undefined behavior to use this value
//~| vtable
//~| NOTE vtable
const TRAIT_OBJ_BAD_DROP_FN_INT: &dyn Trait = unsafe { mem::transmute((&92u8, &[1usize; 8])) };
//~^ ERROR it is undefined behavior to use this value
//~| vtable
//~| NOTE vtable
const TRAIT_OBJ_BAD_DROP_FN_NOT_FN_PTR: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &[&42u8; 8]))) };
//~^ ERROR it is undefined behavior to use this value
//~| vtable
//~| NOTE vtable
// bad data *inside* the trait object
const TRAIT_OBJ_CONTENT_INVALID: &dyn Trait = unsafe { mem::transmute::<_, &bool>(&3u8) };
//~^ ERROR it is undefined behavior to use this value
//~| expected a boolean
//~| NOTE expected a boolean
// # raw trait object
const RAW_TRAIT_OBJ_VTABLE_NULL: *const dyn Trait = unsafe { mem::transmute((&92u8, 0usize)) };
//~^ ERROR it is undefined behavior to use this value
//~| null pointer
//~| NOTE null pointer
const RAW_TRAIT_OBJ_VTABLE_INVALID: *const dyn Trait = unsafe { mem::transmute((&92u8, &3u64)) };
//~^ ERROR it is undefined behavior to use this value
//~| vtable
//~| NOTE vtable
const RAW_TRAIT_OBJ_CONTENT_INVALID: *const dyn Trait = unsafe { mem::transmute::<_, &bool>(&3u8) } as *const dyn Trait; // ok because raw
// Officially blessed way to get the vtable
const DYN_METADATA: ptr::DynMetadata<dyn Send> = ptr::metadata::<dyn Send>(ptr::null::<i32>());
@ -155,12 +155,12 @@ const DYN_METADATA: ptr::DynMetadata<dyn Send> = ptr::metadata::<dyn Send>(ptr::
static mut RAW_TRAIT_OBJ_VTABLE_NULL_THROUGH_REF: *const dyn Trait = unsafe {
mem::transmute::<_, &dyn Trait>((&92u8, 0usize))
//~^^ ERROR it is undefined behavior to use this value
//~| null pointer
//~| NOTE null pointer
};
static mut RAW_TRAIT_OBJ_VTABLE_INVALID_THROUGH_REF: *const dyn Trait = unsafe {
mem::transmute::<_, &dyn Trait>((&92u8, &3u64))
//~^^ ERROR it is undefined behavior to use this value
//~| vtable
//~| NOTE vtable
};
fn main() {}

View file

@ -1,3 +1,5 @@
//@ dont-require-annotations: NOTE
type Field1 = i32;
type Field2 = f32;
type Field3 = i64;
@ -25,7 +27,7 @@ const fn read_field2() -> Field2 {
const fn read_field3() -> Field3 {
const FIELD3: Field3 = unsafe { UNION.field3 };
//~^ ERROR evaluation of constant value failed
//~| uninitialized
//~| NOTE uninitialized
FIELD3
}

View file

@ -1,17 +1,17 @@
error[E0080]: evaluation of constant value failed
--> $DIR/union-const-eval-field.rs:26:37
--> $DIR/union-const-eval-field.rs:28:37
|
LL | const FIELD3: Field3 = unsafe { UNION.field3 };
| ^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory
note: erroneous constant encountered
--> $DIR/union-const-eval-field.rs:29:5
--> $DIR/union-const-eval-field.rs:31:5
|
LL | FIELD3
| ^^^^^^
note: erroneous constant encountered
--> $DIR/union-const-eval-field.rs:29:5
--> $DIR/union-const-eval-field.rs:31:5
|
LL | FIELD3
| ^^^^^^

View file

@ -1,5 +1,5 @@
error[E0080]: it is undefined behavior to use this value
--> $DIR/union-ub.rs:32:1
--> $DIR/union-ub.rs:33:1
|
LL | const BAD_BOOL: bool = unsafe { DummyUnion { u8: 42 }.bool};
| ^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0x2a, but expected a boolean
@ -10,7 +10,7 @@ LL | const BAD_BOOL: bool = unsafe { DummyUnion { u8: 42 }.bool};
}
error[E0080]: evaluation of constant value failed
--> $DIR/union-ub.rs:34:36
--> $DIR/union-ub.rs:35:36
|
LL | const UNINIT_BOOL: bool = unsafe { DummyUnion { unit: () }.bool};
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory

View file

@ -1,5 +1,5 @@
error[E0080]: it is undefined behavior to use this value
--> $DIR/union-ub.rs:32:1
--> $DIR/union-ub.rs:33:1
|
LL | const BAD_BOOL: bool = unsafe { DummyUnion { u8: 42 }.bool};
| ^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0x2a, but expected a boolean
@ -10,7 +10,7 @@ LL | const BAD_BOOL: bool = unsafe { DummyUnion { u8: 42 }.bool};
}
error[E0080]: evaluation of constant value failed
--> $DIR/union-ub.rs:34:36
--> $DIR/union-ub.rs:35:36
|
LL | const UNINIT_BOOL: bool = unsafe { DummyUnion { unit: () }.bool};
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory

View file

@ -1,4 +1,5 @@
//@ stderr-per-bitwidth
//@ dont-require-annotations: NOTE
#[repr(C)]
union DummyUnion {
@ -33,7 +34,7 @@ const BAD_BOOL: bool = unsafe { DummyUnion { u8: 42 }.bool};
//~^ ERROR it is undefined behavior to use this value
const UNINIT_BOOL: bool = unsafe { DummyUnion { unit: () }.bool};
//~^ ERROR evaluation of constant value failed
//~| uninitialized
//~| NOTE uninitialized
// The value is not valid for any union variant, but that's fine
// unions are just a convenient way to transmute bits around

View file

@ -1,5 +1,7 @@
//@ dont-require-annotations: NOTE
const extern "C" fn foo() {
panic!() //~ inside `foo`
panic!() //~ NOTE inside `foo`
}
const _: () = foo(); //~ ERROR evaluation of constant value failed

View file

@ -1,11 +1,11 @@
error[E0080]: evaluation of constant value failed
--> $DIR/unwind-abort.rs:5:15
--> $DIR/unwind-abort.rs:7:15
|
LL | const _: () = foo();
| ^^^^^ evaluation panicked: explicit panic
|
note: inside `foo`
--> $DIR/unwind-abort.rs:2:5
--> $DIR/unwind-abort.rs:4:5
|
LL | panic!()
| ^^^^^^^^ the failure occurred here

View file

@ -1,5 +1,7 @@
//@ dont-require-annotations: NOTE
const fn foo() -> ! {
unsafe { std::mem::transmute(()) } //~ inside `foo`
unsafe { std::mem::transmute(()) } //~ NOTE inside `foo`
}
// Type defined in a submodule, so that it is not "visibly"

View file

@ -1,17 +1,17 @@
error[E0080]: evaluation of constant value failed
--> $DIR/validate_uninhabited_zsts.rs:15:33
--> $DIR/validate_uninhabited_zsts.rs:17:33
|
LL | const FOO: [empty::Empty; 3] = [foo(); 3];
| ^^^^^ constructing invalid value: encountered a value of the never type `!`
|
note: inside `foo`
--> $DIR/validate_uninhabited_zsts.rs:2:14
--> $DIR/validate_uninhabited_zsts.rs:4:14
|
LL | unsafe { std::mem::transmute(()) }
| ^^^^^^^^^^^^^^^^^^^^^^^ the failure occurred here
error[E0080]: evaluation of constant value failed
--> $DIR/validate_uninhabited_zsts.rs:18:42
--> $DIR/validate_uninhabited_zsts.rs:20:42
|
LL | const BAR: [empty::Empty; 3] = [unsafe { std::mem::transmute(()) }; 3];
| ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered a value of uninhabited type `Void`

View file

@ -5,7 +5,7 @@ LL | const LEN: usize = ONE - TWO;
| ^^^^^^^^^ attempt to compute `1_usize - 2_usize`, which would overflow
note: erroneous constant encountered
--> $DIR/const-len-underflow-separate-spans.rs:14:17
--> $DIR/const-len-underflow-separate-spans.rs:15:17
|
LL | let a: [i8; LEN] = unimplemented!();
| ^^^

View file

@ -5,7 +5,7 @@ LL | const LEN: usize = ONE - TWO;
| ^^^^^^^^^ attempt to compute `1_usize - 2_usize`, which would overflow
note: erroneous constant encountered
--> $DIR/const-len-underflow-separate-spans.rs:14:17
--> $DIR/const-len-underflow-separate-spans.rs:15:17
|
LL | let a: [i8; LEN] = unimplemented!();
| ^^^

View file

@ -9,8 +9,9 @@ const ONE: usize = 1;
const TWO: usize = 2;
const LEN: usize = ONE - TWO;
//~^ ERROR constant
//~| NOTE attempt to compute `1_usize - 2_usize`, which would overflow
fn main() {
let a: [i8; LEN] = unimplemented!();
//~^ constant
//~^ NOTE constant
}

Some files were not shown because too many files have changed in this diff Show more