Auto merge of #121810 - matthiaskrgr:rollup-mawij2g, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - #121326 (Detect empty leading where clauses on type aliases) - #121464 (rustc: Fix wasm64 metadata object files) - #121681 (Safe Transmute: Revise safety analysis) - #121753 (Add proper cfg to keep only one AlignmentEnum definition for different target_pointer_widths) - #121782 (allow statics pointing to mutable statics) - #121798 (Fix links in rustc doc) - #121806 (add const test for ptr::metadata) - #121809 (Remove doc aliases to PATH) r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
77be7a3e0d
172 changed files with 1813 additions and 2512 deletions
10
Cargo.lock
10
Cargo.lock
|
@ -3646,6 +3646,7 @@ dependencies = [
|
|||
"thin-vec",
|
||||
"thorin-dwp",
|
||||
"tracing",
|
||||
"wasm-encoder",
|
||||
"windows",
|
||||
]
|
||||
|
||||
|
@ -6142,6 +6143,15 @@ version = "0.2.91"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4f186bd2dcf04330886ce82d6f33dd75a7bfcf69ecf5763b89fcde53b6ac9838"
|
||||
|
||||
[[package]]
|
||||
name = "wasm-encoder"
|
||||
version = "0.200.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b9e3fb0c8fbddd78aa6095b850dfeedbc7506cf5f81e633f69cf8f2333ab84b9"
|
||||
dependencies = [
|
||||
"leb128",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasmparser"
|
||||
version = "0.118.2"
|
||||
|
|
|
@ -403,9 +403,10 @@ impl Default for Generics {
|
|||
/// A where-clause in a definition.
|
||||
#[derive(Clone, Encodable, Decodable, Debug)]
|
||||
pub struct WhereClause {
|
||||
/// `true` if we ate a `where` token: this can happen
|
||||
/// if we parsed no predicates (e.g. `struct Foo where {}`).
|
||||
/// This allows us to pretty-print accurately.
|
||||
/// `true` if we ate a `where` token.
|
||||
///
|
||||
/// This can happen if we parsed no predicates, e.g., `struct Foo where {}`.
|
||||
/// This allows us to pretty-print accurately and provide correct suggestion diagnostics.
|
||||
pub has_where_token: bool,
|
||||
pub predicates: ThinVec<WherePredicate>,
|
||||
pub span: Span,
|
||||
|
@ -3007,18 +3008,29 @@ pub struct Trait {
|
|||
///
|
||||
/// If there is no where clause, then this is `false` with `DUMMY_SP`.
|
||||
#[derive(Copy, Clone, Encodable, Decodable, Debug, Default)]
|
||||
pub struct TyAliasWhereClause(pub bool, pub Span);
|
||||
pub struct TyAliasWhereClause {
|
||||
pub has_where_token: bool,
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
/// The span information for the two where clauses on a `TyAlias`.
|
||||
#[derive(Copy, Clone, Encodable, Decodable, Debug, Default)]
|
||||
pub struct TyAliasWhereClauses {
|
||||
/// Before the equals sign.
|
||||
pub before: TyAliasWhereClause,
|
||||
/// After the equals sign.
|
||||
pub after: TyAliasWhereClause,
|
||||
/// The index in `TyAlias.generics.where_clause.predicates` that would split
|
||||
/// into predicates from the where clause before the equals sign and the ones
|
||||
/// from the where clause after the equals sign.
|
||||
pub split: usize,
|
||||
}
|
||||
|
||||
#[derive(Clone, Encodable, Decodable, Debug)]
|
||||
pub struct TyAlias {
|
||||
pub defaultness: Defaultness,
|
||||
pub generics: Generics,
|
||||
/// The span information for the two where clauses (before equals, after equals)
|
||||
pub where_clauses: (TyAliasWhereClause, TyAliasWhereClause),
|
||||
/// The index in `generics.where_clause.predicates` that would split into
|
||||
/// predicates from the where clause before the equals and the predicates
|
||||
/// from the where clause after the equals
|
||||
pub where_predicates_split: usize,
|
||||
pub where_clauses: TyAliasWhereClauses,
|
||||
pub bounds: GenericBounds,
|
||||
pub ty: Option<P<Ty>>,
|
||||
}
|
||||
|
|
|
@ -1079,8 +1079,8 @@ pub fn noop_visit_item_kind<T: MutVisitor>(kind: &mut ItemKind, vis: &mut T) {
|
|||
}) => {
|
||||
visit_defaultness(defaultness, vis);
|
||||
vis.visit_generics(generics);
|
||||
vis.visit_span(&mut where_clauses.0.1);
|
||||
vis.visit_span(&mut where_clauses.1.1);
|
||||
vis.visit_span(&mut where_clauses.before.span);
|
||||
vis.visit_span(&mut where_clauses.after.span);
|
||||
visit_bounds(bounds, vis);
|
||||
visit_opt(ty, |ty| vis.visit_ty(ty));
|
||||
}
|
||||
|
@ -1163,8 +1163,8 @@ pub fn noop_flat_map_assoc_item<T: MutVisitor>(
|
|||
}) => {
|
||||
visit_defaultness(defaultness, visitor);
|
||||
visitor.visit_generics(generics);
|
||||
visitor.visit_span(&mut where_clauses.0.1);
|
||||
visitor.visit_span(&mut where_clauses.1.1);
|
||||
visitor.visit_span(&mut where_clauses.before.span);
|
||||
visitor.visit_span(&mut where_clauses.after.span);
|
||||
visit_bounds(bounds, visitor);
|
||||
visit_opt(ty, |ty| visitor.visit_ty(ty));
|
||||
}
|
||||
|
@ -1257,8 +1257,8 @@ pub fn noop_flat_map_foreign_item<T: MutVisitor>(
|
|||
}) => {
|
||||
visit_defaultness(defaultness, visitor);
|
||||
visitor.visit_generics(generics);
|
||||
visitor.visit_span(&mut where_clauses.0.1);
|
||||
visitor.visit_span(&mut where_clauses.1.1);
|
||||
visitor.visit_span(&mut where_clauses.before.span);
|
||||
visitor.visit_span(&mut where_clauses.after.span);
|
||||
visit_bounds(bounds, visitor);
|
||||
visit_opt(ty, |ty| visitor.visit_ty(ty));
|
||||
}
|
||||
|
|
|
@ -33,19 +33,20 @@ pub(super) struct ItemLowerer<'a, 'hir> {
|
|||
/// clause if it exists.
|
||||
fn add_ty_alias_where_clause(
|
||||
generics: &mut ast::Generics,
|
||||
mut where_clauses: (TyAliasWhereClause, TyAliasWhereClause),
|
||||
mut where_clauses: TyAliasWhereClauses,
|
||||
prefer_first: bool,
|
||||
) {
|
||||
if !prefer_first {
|
||||
where_clauses = (where_clauses.1, where_clauses.0);
|
||||
}
|
||||
if where_clauses.0.0 || !where_clauses.1.0 {
|
||||
generics.where_clause.has_where_token = where_clauses.0.0;
|
||||
generics.where_clause.span = where_clauses.0.1;
|
||||
} else {
|
||||
generics.where_clause.has_where_token = where_clauses.1.0;
|
||||
generics.where_clause.span = where_clauses.1.1;
|
||||
(where_clauses.before, where_clauses.after) = (where_clauses.after, where_clauses.before);
|
||||
}
|
||||
let where_clause =
|
||||
if where_clauses.before.has_where_token || !where_clauses.after.has_where_token {
|
||||
where_clauses.before
|
||||
} else {
|
||||
where_clauses.after
|
||||
};
|
||||
generics.where_clause.has_where_token = where_clause.has_where_token;
|
||||
generics.where_clause.span = where_clause.span;
|
||||
}
|
||||
|
||||
impl<'a, 'hir> ItemLowerer<'a, 'hir> {
|
||||
|
|
|
@ -280,4 +280,5 @@ ast_passes_where_clause_after_type_alias = where clauses are not allowed after t
|
|||
|
||||
ast_passes_where_clause_before_type_alias = where clauses are not allowed before the type for type aliases
|
||||
.note = see issue #89122 <https://github.com/rust-lang/rust/issues/89122> for more information
|
||||
.suggestion = move it to the end of the type declaration
|
||||
.remove_suggestion = remove this `where`
|
||||
.move_suggestion = move it to the end of the type declaration
|
||||
|
|
|
@ -138,38 +138,42 @@ impl<'a> AstValidator<'a> {
|
|||
&mut self,
|
||||
ty_alias: &TyAlias,
|
||||
) -> Result<(), errors::WhereClauseBeforeTypeAlias> {
|
||||
let before_predicates =
|
||||
ty_alias.generics.where_clause.predicates.split_at(ty_alias.where_predicates_split).0;
|
||||
|
||||
if ty_alias.ty.is_none() || before_predicates.is_empty() {
|
||||
if ty_alias.ty.is_none() || !ty_alias.where_clauses.before.has_where_token {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let mut state = State::new();
|
||||
if !ty_alias.where_clauses.1.0 {
|
||||
state.space();
|
||||
state.word_space("where");
|
||||
} else {
|
||||
state.word_space(",");
|
||||
}
|
||||
let mut first = true;
|
||||
for p in before_predicates {
|
||||
if !first {
|
||||
state.word_space(",");
|
||||
}
|
||||
first = false;
|
||||
state.print_where_predicate(p);
|
||||
}
|
||||
let (before_predicates, after_predicates) =
|
||||
ty_alias.generics.where_clause.predicates.split_at(ty_alias.where_clauses.split);
|
||||
let span = ty_alias.where_clauses.before.span;
|
||||
|
||||
let span = ty_alias.where_clauses.0.1;
|
||||
Err(errors::WhereClauseBeforeTypeAlias {
|
||||
span,
|
||||
sugg: errors::WhereClauseBeforeTypeAliasSugg {
|
||||
let sugg = if !before_predicates.is_empty() || !ty_alias.where_clauses.after.has_where_token
|
||||
{
|
||||
let mut state = State::new();
|
||||
|
||||
if !ty_alias.where_clauses.after.has_where_token {
|
||||
state.space();
|
||||
state.word_space("where");
|
||||
}
|
||||
|
||||
let mut first = after_predicates.is_empty();
|
||||
for p in before_predicates {
|
||||
if !first {
|
||||
state.word_space(",");
|
||||
}
|
||||
first = false;
|
||||
state.print_where_predicate(p);
|
||||
}
|
||||
|
||||
errors::WhereClauseBeforeTypeAliasSugg::Move {
|
||||
left: span,
|
||||
snippet: state.s.eof(),
|
||||
right: ty_alias.where_clauses.1.1.shrink_to_hi(),
|
||||
},
|
||||
})
|
||||
right: ty_alias.where_clauses.after.span.shrink_to_hi(),
|
||||
}
|
||||
} else {
|
||||
errors::WhereClauseBeforeTypeAliasSugg::Remove { span }
|
||||
};
|
||||
|
||||
Err(errors::WhereClauseBeforeTypeAlias { span, sugg })
|
||||
}
|
||||
|
||||
fn with_impl_trait(&mut self, outer: Option<Span>, f: impl FnOnce(&mut Self)) {
|
||||
|
@ -457,8 +461,7 @@ impl<'a> AstValidator<'a> {
|
|||
fn check_foreign_ty_genericless(
|
||||
&self,
|
||||
generics: &Generics,
|
||||
before_where_clause: &TyAliasWhereClause,
|
||||
after_where_clause: &TyAliasWhereClause,
|
||||
where_clauses: &TyAliasWhereClauses,
|
||||
) {
|
||||
let cannot_have = |span, descr, remove_descr| {
|
||||
self.dcx().emit_err(errors::ExternTypesCannotHave {
|
||||
|
@ -473,14 +476,14 @@ impl<'a> AstValidator<'a> {
|
|||
cannot_have(generics.span, "generic parameters", "generic parameters");
|
||||
}
|
||||
|
||||
let check_where_clause = |where_clause: &TyAliasWhereClause| {
|
||||
if let TyAliasWhereClause(true, where_clause_span) = where_clause {
|
||||
cannot_have(*where_clause_span, "`where` clauses", "`where` clause");
|
||||
let check_where_clause = |where_clause: TyAliasWhereClause| {
|
||||
if where_clause.has_where_token {
|
||||
cannot_have(where_clause.span, "`where` clauses", "`where` clause");
|
||||
}
|
||||
};
|
||||
|
||||
check_where_clause(before_where_clause);
|
||||
check_where_clause(after_where_clause);
|
||||
check_where_clause(where_clauses.before);
|
||||
check_where_clause(where_clauses.after);
|
||||
}
|
||||
|
||||
fn check_foreign_kind_bodyless(&self, ident: Ident, kind: &str, body: Option<Span>) {
|
||||
|
@ -1122,9 +1125,9 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
|||
if let Err(err) = self.check_type_alias_where_clause_location(ty_alias) {
|
||||
self.dcx().emit_err(err);
|
||||
}
|
||||
} else if where_clauses.1.0 {
|
||||
} else if where_clauses.after.has_where_token {
|
||||
self.dcx().emit_err(errors::WhereClauseAfterTypeAlias {
|
||||
span: where_clauses.1.1,
|
||||
span: where_clauses.after.span,
|
||||
help: self.session.is_nightly_build().then_some(()),
|
||||
});
|
||||
}
|
||||
|
@ -1154,7 +1157,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
|||
self.check_defaultness(fi.span, *defaultness);
|
||||
self.check_foreign_kind_bodyless(fi.ident, "type", ty.as_ref().map(|b| b.span));
|
||||
self.check_type_no_bounds(bounds, "`extern` blocks");
|
||||
self.check_foreign_ty_genericless(generics, &where_clauses.0, &where_clauses.1);
|
||||
self.check_foreign_ty_genericless(generics, where_clauses);
|
||||
self.check_foreign_item_ascii_only(fi.ident);
|
||||
}
|
||||
ForeignItemKind::Static(_, _, body) => {
|
||||
|
@ -1477,15 +1480,18 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
|||
if let AssocItemKind::Type(ty_alias) = &item.kind
|
||||
&& let Err(err) = self.check_type_alias_where_clause_location(ty_alias)
|
||||
{
|
||||
let sugg = match err.sugg {
|
||||
errors::WhereClauseBeforeTypeAliasSugg::Remove { .. } => None,
|
||||
errors::WhereClauseBeforeTypeAliasSugg::Move { snippet, right, .. } => {
|
||||
Some((right, snippet))
|
||||
}
|
||||
};
|
||||
self.lint_buffer.buffer_lint_with_diagnostic(
|
||||
DEPRECATED_WHERE_CLAUSE_LOCATION,
|
||||
item.id,
|
||||
err.span,
|
||||
fluent::ast_passes_deprecated_where_clause_location,
|
||||
BuiltinLintDiagnostics::DeprecatedWhereclauseLocation(
|
||||
err.sugg.right,
|
||||
err.sugg.snippet,
|
||||
),
|
||||
BuiltinLintDiagnostics::DeprecatedWhereclauseLocation(sugg),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -515,17 +515,25 @@ pub struct WhereClauseBeforeTypeAlias {
|
|||
}
|
||||
|
||||
#[derive(Subdiagnostic)]
|
||||
#[multipart_suggestion(
|
||||
ast_passes_suggestion,
|
||||
applicability = "machine-applicable",
|
||||
style = "verbose"
|
||||
)]
|
||||
pub struct WhereClauseBeforeTypeAliasSugg {
|
||||
#[suggestion_part(code = "")]
|
||||
pub left: Span,
|
||||
pub snippet: String,
|
||||
#[suggestion_part(code = "{snippet}")]
|
||||
pub right: Span,
|
||||
|
||||
pub enum WhereClauseBeforeTypeAliasSugg {
|
||||
#[suggestion(ast_passes_remove_suggestion, applicability = "machine-applicable", code = "")]
|
||||
Remove {
|
||||
#[primary_span]
|
||||
span: Span,
|
||||
},
|
||||
#[multipart_suggestion(
|
||||
ast_passes_move_suggestion,
|
||||
applicability = "machine-applicable",
|
||||
style = "verbose"
|
||||
)]
|
||||
Move {
|
||||
#[suggestion_part(code = "")]
|
||||
left: Span,
|
||||
snippet: String,
|
||||
#[suggestion_part(code = "{snippet}")]
|
||||
right: Span,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
|
|
|
@ -43,7 +43,6 @@ impl<'a> State<'a> {
|
|||
defaultness,
|
||||
generics,
|
||||
where_clauses,
|
||||
where_predicates_split,
|
||||
bounds,
|
||||
ty,
|
||||
}) => {
|
||||
|
@ -51,7 +50,6 @@ impl<'a> State<'a> {
|
|||
ident,
|
||||
generics,
|
||||
*where_clauses,
|
||||
*where_predicates_split,
|
||||
bounds,
|
||||
ty.as_deref(),
|
||||
vis,
|
||||
|
@ -108,15 +106,14 @@ impl<'a> State<'a> {
|
|||
&mut self,
|
||||
ident: Ident,
|
||||
generics: &ast::Generics,
|
||||
where_clauses: (ast::TyAliasWhereClause, ast::TyAliasWhereClause),
|
||||
where_predicates_split: usize,
|
||||
where_clauses: ast::TyAliasWhereClauses,
|
||||
bounds: &ast::GenericBounds,
|
||||
ty: Option<&ast::Ty>,
|
||||
vis: &ast::Visibility,
|
||||
defaultness: ast::Defaultness,
|
||||
) {
|
||||
let (before_predicates, after_predicates) =
|
||||
generics.where_clause.predicates.split_at(where_predicates_split);
|
||||
generics.where_clause.predicates.split_at(where_clauses.split);
|
||||
self.head("");
|
||||
self.print_visibility(vis);
|
||||
self.print_defaultness(defaultness);
|
||||
|
@ -127,13 +124,13 @@ impl<'a> State<'a> {
|
|||
self.word_nbsp(":");
|
||||
self.print_type_bounds(bounds);
|
||||
}
|
||||
self.print_where_clause_parts(where_clauses.0.0, before_predicates);
|
||||
self.print_where_clause_parts(where_clauses.before.has_where_token, before_predicates);
|
||||
if let Some(ty) = ty {
|
||||
self.space();
|
||||
self.word_space("=");
|
||||
self.print_type(ty);
|
||||
}
|
||||
self.print_where_clause_parts(where_clauses.1.0, after_predicates);
|
||||
self.print_where_clause_parts(where_clauses.after.has_where_token, after_predicates);
|
||||
self.word(";");
|
||||
self.end(); // end inner head-block
|
||||
self.end(); // end outer head-block
|
||||
|
@ -249,7 +246,6 @@ impl<'a> State<'a> {
|
|||
defaultness,
|
||||
generics,
|
||||
where_clauses,
|
||||
where_predicates_split,
|
||||
bounds,
|
||||
ty,
|
||||
}) => {
|
||||
|
@ -257,7 +253,6 @@ impl<'a> State<'a> {
|
|||
item.ident,
|
||||
generics,
|
||||
*where_clauses,
|
||||
*where_predicates_split,
|
||||
bounds,
|
||||
ty.as_deref(),
|
||||
&item.vis,
|
||||
|
@ -536,7 +531,6 @@ impl<'a> State<'a> {
|
|||
defaultness,
|
||||
generics,
|
||||
where_clauses,
|
||||
where_predicates_split,
|
||||
bounds,
|
||||
ty,
|
||||
}) => {
|
||||
|
@ -544,7 +538,6 @@ impl<'a> State<'a> {
|
|||
ident,
|
||||
generics,
|
||||
*where_clauses,
|
||||
*where_predicates_split,
|
||||
bounds,
|
||||
ty.as_deref(),
|
||||
vis,
|
||||
|
|
|
@ -601,11 +601,7 @@ impl<'a> TraitDef<'a> {
|
|||
kind: ast::AssocItemKind::Type(Box::new(ast::TyAlias {
|
||||
defaultness: ast::Defaultness::Final,
|
||||
generics: Generics::default(),
|
||||
where_clauses: (
|
||||
ast::TyAliasWhereClause::default(),
|
||||
ast::TyAliasWhereClause::default(),
|
||||
),
|
||||
where_predicates_split: 0,
|
||||
where_clauses: ast::TyAliasWhereClauses::default(),
|
||||
bounds: Vec::new(),
|
||||
ty: Some(type_def.to_ty(cx, self.span, type_ident, generics)),
|
||||
})),
|
||||
|
|
|
@ -38,6 +38,7 @@ tempfile = "3.2"
|
|||
thin-vec = "0.2.12"
|
||||
thorin-dwp = "0.7"
|
||||
tracing = "0.1"
|
||||
wasm-encoder = "0.200.0"
|
||||
# tidy-alphabetical-end
|
||||
|
||||
[target.'cfg(unix)'.dependencies]
|
||||
|
|
|
@ -315,8 +315,11 @@ fn link_rlib<'a>(
|
|||
|
||||
let trailing_metadata = match flavor {
|
||||
RlibFlavor::Normal => {
|
||||
let (metadata, metadata_position) =
|
||||
create_wrapper_file(sess, b".rmeta".to_vec(), codegen_results.metadata.raw_data());
|
||||
let (metadata, metadata_position) = create_wrapper_file(
|
||||
sess,
|
||||
".rmeta".to_string(),
|
||||
codegen_results.metadata.raw_data(),
|
||||
);
|
||||
let metadata = emit_wrapper_file(sess, &metadata, tmpdir, METADATA_FILENAME);
|
||||
match metadata_position {
|
||||
MetadataPosition::First => {
|
||||
|
@ -384,7 +387,7 @@ fn link_rlib<'a>(
|
|||
let path = find_native_static_library(filename.as_str(), true, &lib_search_paths, sess);
|
||||
let src = read(path)
|
||||
.map_err(|e| sess.dcx().emit_fatal(errors::ReadFileError { message: e }))?;
|
||||
let (data, _) = create_wrapper_file(sess, b".bundled_lib".to_vec(), &src);
|
||||
let (data, _) = create_wrapper_file(sess, ".bundled_lib".to_string(), &src);
|
||||
let wrapper_file = emit_wrapper_file(sess, &data, tmpdir, filename.as_str());
|
||||
packed_bundled_libs.push(wrapper_file);
|
||||
} else {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
//! Reading of the rustc metadata for rlibs and dylibs
|
||||
|
||||
use std::borrow::Cow;
|
||||
use std::fs::File;
|
||||
use std::io::Write;
|
||||
use std::path::Path;
|
||||
|
@ -15,7 +16,6 @@ use rustc_data_structures::owned_slice::{try_slice_owned, OwnedSlice};
|
|||
use rustc_metadata::creader::MetadataLoader;
|
||||
use rustc_metadata::fs::METADATA_FILENAME;
|
||||
use rustc_metadata::EncodedMetadata;
|
||||
use rustc_serialize::leb128;
|
||||
use rustc_session::Session;
|
||||
use rustc_span::sym;
|
||||
use rustc_target::abi::Endian;
|
||||
|
@ -434,12 +434,15 @@ pub enum MetadataPosition {
|
|||
/// automatically removed from the final output.
|
||||
pub fn create_wrapper_file(
|
||||
sess: &Session,
|
||||
section_name: Vec<u8>,
|
||||
section_name: String,
|
||||
data: &[u8],
|
||||
) -> (Vec<u8>, MetadataPosition) {
|
||||
let Some(mut file) = create_object_file(sess) else {
|
||||
if sess.target.is_like_wasm {
|
||||
return (create_metadata_file_for_wasm(data, §ion_name), MetadataPosition::First);
|
||||
return (
|
||||
create_metadata_file_for_wasm(sess, data, §ion_name),
|
||||
MetadataPosition::First,
|
||||
);
|
||||
}
|
||||
|
||||
// Targets using this branch don't have support implemented here yet or
|
||||
|
@ -452,7 +455,7 @@ pub fn create_wrapper_file(
|
|||
} else {
|
||||
file.add_section(
|
||||
file.segment_name(StandardSegment::Debug).to_vec(),
|
||||
section_name,
|
||||
section_name.into_bytes(),
|
||||
SectionKind::Debug,
|
||||
)
|
||||
};
|
||||
|
@ -524,7 +527,7 @@ pub fn create_compressed_metadata_file(
|
|||
|
||||
let Some(mut file) = create_object_file(sess) else {
|
||||
if sess.target.is_like_wasm {
|
||||
return create_metadata_file_for_wasm(&packed_metadata, b".rustc");
|
||||
return create_metadata_file_for_wasm(sess, &packed_metadata, ".rustc");
|
||||
}
|
||||
return packed_metadata.to_vec();
|
||||
};
|
||||
|
@ -624,51 +627,41 @@ pub fn create_compressed_metadata_file_for_xcoff(
|
|||
/// `data`.
|
||||
///
|
||||
/// NB: the `object` crate does not yet have support for writing the wasm
|
||||
/// object file format. The format is simple enough that for now an extra crate
|
||||
/// from crates.io (such as `wasm-encoder`). The file format is:
|
||||
/// object file format. In lieu of that the `wasm-encoder` crate is used to
|
||||
/// build a wasm file by hand.
|
||||
///
|
||||
/// * 4-byte header "\0asm"
|
||||
/// * 4-byte version number - 1u32 in little-endian format
|
||||
/// * concatenated sections, which for this object is always "custom sections"
|
||||
///
|
||||
/// Custom sections are then defined by:
|
||||
/// * 1-byte section identifier - 0 for a custom section
|
||||
/// * leb-encoded section length (size of the contents beneath this bullet)
|
||||
/// * leb-encoded custom section name length
|
||||
/// * custom section name
|
||||
/// * section contents
|
||||
///
|
||||
/// One custom section, `linking`, is added here in accordance with
|
||||
/// The wasm object file format is defined at
|
||||
/// <https://github.com/WebAssembly/tool-conventions/blob/main/Linking.md>
|
||||
/// which is required to inform LLD that this is an object file but it should
|
||||
/// otherwise basically ignore it if it otherwise looks at it. The linking
|
||||
/// section currently is defined by a single version byte (2) and then further
|
||||
/// sections, but we have no more sections, so it's just the byte "2".
|
||||
/// and mainly consists of a `linking` custom section. In this case the custom
|
||||
/// section there is empty except for a version marker indicating what format
|
||||
/// it's in.
|
||||
///
|
||||
/// The next custom section is the one we're interested in.
|
||||
pub fn create_metadata_file_for_wasm(data: &[u8], section_name: &[u8]) -> Vec<u8> {
|
||||
let mut bytes = b"\0asm\x01\0\0\0".to_vec();
|
||||
/// The main purpose of this is to contain a custom section with `section_name`,
|
||||
/// which is then appended after `linking`.
|
||||
///
|
||||
/// As a further detail the object needs to have a 64-bit memory if `wasm64` is
|
||||
/// the target or otherwise it's interpreted as a 32-bit object which is
|
||||
/// incompatible with 64-bit ones.
|
||||
pub fn create_metadata_file_for_wasm(sess: &Session, data: &[u8], section_name: &str) -> Vec<u8> {
|
||||
assert!(sess.target.is_like_wasm);
|
||||
let mut module = wasm_encoder::Module::new();
|
||||
let mut imports = wasm_encoder::ImportSection::new();
|
||||
|
||||
let mut append_custom_section = |section_name: &[u8], data: &[u8]| {
|
||||
let mut section_name_len = [0; leb128::max_leb128_len::<usize>()];
|
||||
let off = leb128::write_usize_leb128(&mut section_name_len, section_name.len());
|
||||
let section_name_len = §ion_name_len[..off];
|
||||
|
||||
let mut section_len = [0; leb128::max_leb128_len::<usize>()];
|
||||
let off = leb128::write_usize_leb128(
|
||||
&mut section_len,
|
||||
data.len() + section_name_len.len() + section_name.len(),
|
||||
if sess.target.pointer_width == 64 {
|
||||
imports.import(
|
||||
"env",
|
||||
"__linear_memory",
|
||||
wasm_encoder::MemoryType { minimum: 0, maximum: None, memory64: true, shared: false },
|
||||
);
|
||||
let section_len = §ion_len[..off];
|
||||
}
|
||||
|
||||
bytes.push(0u8);
|
||||
bytes.extend_from_slice(section_len);
|
||||
bytes.extend_from_slice(section_name_len);
|
||||
bytes.extend_from_slice(section_name);
|
||||
bytes.extend_from_slice(data);
|
||||
};
|
||||
|
||||
append_custom_section(b"linking", &[2]);
|
||||
append_custom_section(section_name, data);
|
||||
bytes
|
||||
if imports.len() > 0 {
|
||||
module.section(&imports);
|
||||
}
|
||||
module.section(&wasm_encoder::CustomSection {
|
||||
name: "linking".into(),
|
||||
data: Cow::Borrowed(&[2]),
|
||||
});
|
||||
module.section(&wasm_encoder::CustomSection { name: section_name.into(), data: data.into() });
|
||||
module.finish()
|
||||
}
|
||||
|
|
|
@ -453,7 +453,6 @@ const_eval_validation_invalid_fn_ptr = {$front_matter}: encountered {$value}, bu
|
|||
const_eval_validation_invalid_ref_meta = {$front_matter}: encountered invalid reference metadata: total size is bigger than largest supported object
|
||||
const_eval_validation_invalid_ref_slice_meta = {$front_matter}: encountered invalid reference metadata: slice is bigger than largest supported object
|
||||
const_eval_validation_invalid_vtable_ptr = {$front_matter}: encountered {$value}, but expected a vtable pointer
|
||||
const_eval_validation_mutable_ref_in_const_or_static = {$front_matter}: encountered mutable reference in a `const` or `static`
|
||||
const_eval_validation_mutable_ref_to_immutable = {$front_matter}: encountered mutable reference or box pointing to read-only memory
|
||||
const_eval_validation_never_val = {$front_matter}: encountered a value of the never type `!`
|
||||
const_eval_validation_null_box = {$front_matter}: encountered a null box
|
||||
|
|
|
@ -613,7 +613,6 @@ impl<'tcx> ReportErrorExt for ValidationErrorInfo<'tcx> {
|
|||
PartialPointer => const_eval_validation_partial_pointer,
|
||||
ConstRefToMutable => const_eval_validation_const_ref_to_mutable,
|
||||
ConstRefToExtern => const_eval_validation_const_ref_to_extern,
|
||||
MutableRefInConstOrStatic => const_eval_validation_mutable_ref_in_const_or_static,
|
||||
MutableRefToImmutable => const_eval_validation_mutable_ref_to_immutable,
|
||||
NullFnPtr => const_eval_validation_null_fn_ptr,
|
||||
NeverVal => const_eval_validation_never_val,
|
||||
|
@ -767,7 +766,6 @@ impl<'tcx> ReportErrorExt for ValidationErrorInfo<'tcx> {
|
|||
}
|
||||
NullPtr { .. }
|
||||
| PtrToStatic { .. }
|
||||
| MutableRefInConstOrStatic
|
||||
| ConstRefToMutable
|
||||
| ConstRefToExtern
|
||||
| MutableRefToImmutable
|
||||
|
|
|
@ -148,14 +148,6 @@ impl CtfeValidationMode {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn may_contain_mutable_ref(self) -> bool {
|
||||
match self {
|
||||
CtfeValidationMode::Static { mutbl } => mutbl == Mutability::Mut,
|
||||
CtfeValidationMode::Promoted { .. } => false,
|
||||
CtfeValidationMode::Const { .. } => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// State for tracking recursive validation of references
|
||||
|
@ -511,20 +503,19 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, '
|
|||
// If this allocation has size zero, there is no actual mutability here.
|
||||
let (size, _align, _alloc_kind) = self.ecx.get_alloc_info(alloc_id);
|
||||
if size != Size::ZERO {
|
||||
// Mutable pointer to immutable memory is no good.
|
||||
if ptr_expected_mutbl == Mutability::Mut
|
||||
&& alloc_actual_mutbl == Mutability::Not
|
||||
{
|
||||
throw_validation_failure!(self.path, MutableRefToImmutable);
|
||||
}
|
||||
if ptr_expected_mutbl == Mutability::Mut
|
||||
&& self.ctfe_mode.is_some_and(|c| !c.may_contain_mutable_ref())
|
||||
{
|
||||
throw_validation_failure!(self.path, MutableRefInConstOrStatic);
|
||||
}
|
||||
if alloc_actual_mutbl == Mutability::Mut
|
||||
&& matches!(self.ctfe_mode, Some(CtfeValidationMode::Const { .. }))
|
||||
{
|
||||
throw_validation_failure!(self.path, ConstRefToMutable);
|
||||
// In a const, everything must be completely immutable.
|
||||
if matches!(self.ctfe_mode, Some(CtfeValidationMode::Const { .. })) {
|
||||
if ptr_expected_mutbl == Mutability::Mut
|
||||
|| alloc_actual_mutbl == Mutability::Mut
|
||||
{
|
||||
throw_validation_failure!(self.path, ConstRefToMutable);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Potentially skip recursive check.
|
||||
|
|
|
@ -167,7 +167,7 @@ language_item_table! {
|
|||
|
||||
// language items relating to transmutability
|
||||
TransmuteOpts, sym::transmute_opts, transmute_opts, Target::Struct, GenericRequirement::Exact(0);
|
||||
TransmuteTrait, sym::transmute_trait, transmute_trait, Target::Trait, GenericRequirement::Exact(3);
|
||||
TransmuteTrait, sym::transmute_trait, transmute_trait, Target::Trait, GenericRequirement::Exact(2);
|
||||
|
||||
Add, sym::add, add_trait, Target::Trait, GenericRequirement::Exact(1);
|
||||
Sub, sym::sub, sub_trait, Target::Trait, GenericRequirement::Exact(1);
|
||||
|
|
|
@ -428,15 +428,22 @@ pub(super) fn builtin(sess: &Session, diagnostic: BuiltinLintDiagnostics, diag:
|
|||
diag.note("see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration");
|
||||
}
|
||||
}
|
||||
BuiltinLintDiagnostics::DeprecatedWhereclauseLocation(new_span, suggestion) => {
|
||||
diag.multipart_suggestion(
|
||||
"move it to the end of the type declaration",
|
||||
vec![(diag.span.primary_span().unwrap(), "".to_string()), (new_span, suggestion)],
|
||||
Applicability::MachineApplicable,
|
||||
);
|
||||
diag.note(
|
||||
"see issue #89122 <https://github.com/rust-lang/rust/issues/89122> for more information",
|
||||
);
|
||||
BuiltinLintDiagnostics::DeprecatedWhereclauseLocation(sugg) => {
|
||||
let left_sp = diag.span.primary_span().unwrap();
|
||||
match sugg {
|
||||
Some((right_sp, sugg)) => diag.multipart_suggestion(
|
||||
"move it to the end of the type declaration",
|
||||
vec![(left_sp, String::new()), (right_sp, sugg)],
|
||||
Applicability::MachineApplicable,
|
||||
),
|
||||
None => diag.span_suggestion(
|
||||
left_sp,
|
||||
"remove this `where`",
|
||||
"",
|
||||
Applicability::MachineApplicable,
|
||||
),
|
||||
};
|
||||
diag.note("see issue #89122 <https://github.com/rust-lang/rust/issues/89122> for more information");
|
||||
}
|
||||
BuiltinLintDiagnostics::SingleUseLifetime {
|
||||
param_span,
|
||||
|
|
|
@ -597,7 +597,7 @@ pub enum BuiltinLintDiagnostics {
|
|||
UnicodeTextFlow(Span, String),
|
||||
UnexpectedCfgName((Symbol, Span), Option<(Symbol, Span)>),
|
||||
UnexpectedCfgValue((Symbol, Span), Option<(Symbol, Span)>),
|
||||
DeprecatedWhereclauseLocation(Span, String),
|
||||
DeprecatedWhereclauseLocation(Option<(Span, String)>),
|
||||
SingleUseLifetime {
|
||||
/// Span of the parameter which declares this lifetime.
|
||||
param_span: Span,
|
||||
|
|
|
@ -420,7 +420,6 @@ pub enum ValidationErrorKind<'tcx> {
|
|||
PartialPointer,
|
||||
PtrToUninhabited { ptr_kind: PointerKind, ty: Ty<'tcx> },
|
||||
PtrToStatic { ptr_kind: PointerKind },
|
||||
MutableRefInConstOrStatic,
|
||||
ConstRefToMutable,
|
||||
ConstRefToExtern,
|
||||
MutableRefToImmutable,
|
||||
|
|
|
@ -971,11 +971,17 @@ impl<'a> Parser<'a> {
|
|||
|
||||
let after_where_clause = self.parse_where_clause()?;
|
||||
|
||||
let where_clauses = (
|
||||
TyAliasWhereClause(before_where_clause.has_where_token, before_where_clause.span),
|
||||
TyAliasWhereClause(after_where_clause.has_where_token, after_where_clause.span),
|
||||
);
|
||||
let where_predicates_split = before_where_clause.predicates.len();
|
||||
let where_clauses = TyAliasWhereClauses {
|
||||
before: TyAliasWhereClause {
|
||||
has_where_token: before_where_clause.has_where_token,
|
||||
span: before_where_clause.span,
|
||||
},
|
||||
after: TyAliasWhereClause {
|
||||
has_where_token: after_where_clause.has_where_token,
|
||||
span: after_where_clause.span,
|
||||
},
|
||||
split: before_where_clause.predicates.len(),
|
||||
};
|
||||
let mut predicates = before_where_clause.predicates;
|
||||
predicates.extend(after_where_clause.predicates);
|
||||
let where_clause = WhereClause {
|
||||
|
@ -994,7 +1000,6 @@ impl<'a> Parser<'a> {
|
|||
defaultness,
|
||||
generics,
|
||||
where_clauses,
|
||||
where_predicates_split,
|
||||
bounds,
|
||||
ty,
|
||||
})),
|
||||
|
|
|
@ -874,7 +874,6 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
|
|||
pub(super) fn is_transmutable(
|
||||
&self,
|
||||
src_and_dst: rustc_transmute::Types<'tcx>,
|
||||
scope: Ty<'tcx>,
|
||||
assume: rustc_transmute::Assume,
|
||||
) -> Result<Certainty, NoSolution> {
|
||||
use rustc_transmute::Answer;
|
||||
|
@ -882,7 +881,6 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
|
|||
match rustc_transmute::TransmuteTypeEnv::new(self.infcx).is_transmutable(
|
||||
ObligationCause::dummy(),
|
||||
src_and_dst,
|
||||
scope,
|
||||
assume,
|
||||
) {
|
||||
Answer::Yes => Ok(Certainty::Yes),
|
||||
|
|
|
@ -549,14 +549,13 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> {
|
|||
let args = ecx.tcx().erase_regions(goal.predicate.trait_ref.args);
|
||||
|
||||
let Some(assume) =
|
||||
rustc_transmute::Assume::from_const(ecx.tcx(), goal.param_env, args.const_at(3))
|
||||
rustc_transmute::Assume::from_const(ecx.tcx(), goal.param_env, args.const_at(2))
|
||||
else {
|
||||
return Err(NoSolution);
|
||||
};
|
||||
|
||||
let certainty = ecx.is_transmutable(
|
||||
rustc_transmute::Types { dst: args.type_at(0), src: args.type_at(1) },
|
||||
args.type_at(2),
|
||||
assume,
|
||||
)?;
|
||||
ecx.evaluate_added_goals_and_make_canonical_response(certainty)
|
||||
|
|
|
@ -2960,11 +2960,10 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
dst: trait_ref.args.type_at(0),
|
||||
src: trait_ref.args.type_at(1),
|
||||
};
|
||||
let scope = trait_ref.args.type_at(2);
|
||||
let Some(assume) = rustc_transmute::Assume::from_const(
|
||||
self.infcx.tcx,
|
||||
obligation.param_env,
|
||||
trait_ref.args.const_at(3),
|
||||
trait_ref.args.const_at(2),
|
||||
) else {
|
||||
self.dcx().span_delayed_bug(
|
||||
span,
|
||||
|
@ -2976,15 +2975,12 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
match rustc_transmute::TransmuteTypeEnv::new(self.infcx).is_transmutable(
|
||||
obligation.cause,
|
||||
src_and_dst,
|
||||
scope,
|
||||
assume,
|
||||
) {
|
||||
Answer::No(reason) => {
|
||||
let dst = trait_ref.args.type_at(0);
|
||||
let src = trait_ref.args.type_at(1);
|
||||
let err_msg = format!(
|
||||
"`{src}` cannot be safely transmuted into `{dst}` in the defining scope of `{scope}`"
|
||||
);
|
||||
let err_msg = format!("`{src}` cannot be safely transmuted into `{dst}`");
|
||||
let safe_transmute_explanation = match reason {
|
||||
rustc_transmute::Reason::SrcIsUnspecified => {
|
||||
format!("`{src}` does not have a well-specified layout")
|
||||
|
@ -2998,9 +2994,9 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
format!("At least one value of `{src}` isn't a bit-valid value of `{dst}`")
|
||||
}
|
||||
|
||||
rustc_transmute::Reason::DstIsPrivate => format!(
|
||||
"`{dst}` is or contains a type or field that is not visible in that scope"
|
||||
),
|
||||
rustc_transmute::Reason::DstMayHaveSafetyInvariants => {
|
||||
format!("`{dst}` may carry safety invariants")
|
||||
}
|
||||
rustc_transmute::Reason::DstIsTooBig => {
|
||||
format!("The size of `{src}` is smaller than the size of `{dst}`")
|
||||
}
|
||||
|
|
|
@ -310,8 +310,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
.collect(),
|
||||
Condition::IfTransmutable { src, dst } => {
|
||||
let trait_def_id = obligation.predicate.def_id();
|
||||
let scope = predicate.trait_ref.args.type_at(2);
|
||||
let assume_const = predicate.trait_ref.args.const_at(3);
|
||||
let assume_const = predicate.trait_ref.args.const_at(2);
|
||||
let make_obl = |from_ty, to_ty| {
|
||||
let trait_ref1 = ty::TraitRef::new(
|
||||
tcx,
|
||||
|
@ -319,7 +318,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
[
|
||||
ty::GenericArg::from(to_ty),
|
||||
ty::GenericArg::from(from_ty),
|
||||
ty::GenericArg::from(scope),
|
||||
ty::GenericArg::from(assume_const),
|
||||
],
|
||||
);
|
||||
|
@ -355,7 +353,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
let Some(assume) = rustc_transmute::Assume::from_const(
|
||||
self.infcx.tcx,
|
||||
obligation.param_env,
|
||||
predicate.trait_ref.args.const_at(3),
|
||||
predicate.trait_ref.args.const_at(2),
|
||||
) else {
|
||||
return Err(Unimplemented);
|
||||
};
|
||||
|
@ -367,7 +365,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
let maybe_transmutable = transmute_env.is_transmutable(
|
||||
obligation.cause.clone(),
|
||||
rustc_transmute::Types { dst, src },
|
||||
predicate.trait_ref.args.type_at(2),
|
||||
assume,
|
||||
);
|
||||
|
||||
|
|
|
@ -29,14 +29,21 @@ impl fmt::Debug for Byte {
|
|||
}
|
||||
}
|
||||
|
||||
pub(crate) trait Def: Debug + Hash + Eq + PartialEq + Copy + Clone {}
|
||||
pub(crate) trait Def: Debug + Hash + Eq + PartialEq + Copy + Clone {
|
||||
fn has_safety_invariants(&self) -> bool;
|
||||
}
|
||||
pub trait Ref: Debug + Hash + Eq + PartialEq + Copy + Clone {
|
||||
fn min_align(&self) -> usize;
|
||||
|
||||
fn is_mutable(&self) -> bool;
|
||||
}
|
||||
|
||||
impl Def for ! {}
|
||||
impl Def for ! {
|
||||
fn has_safety_invariants(&self) -> bool {
|
||||
unreachable!()
|
||||
}
|
||||
}
|
||||
|
||||
impl Ref for ! {
|
||||
fn min_align(&self) -> usize {
|
||||
unreachable!()
|
||||
|
@ -83,5 +90,12 @@ pub mod rustc {
|
|||
Primitive,
|
||||
}
|
||||
|
||||
impl<'tcx> super::Def for Def<'tcx> {}
|
||||
impl<'tcx> super::Def for Def<'tcx> {
|
||||
fn has_safety_invariants(&self) -> bool {
|
||||
// Rust presently has no notion of 'unsafe fields', so for now we
|
||||
// make the conservative assumption that everything besides
|
||||
// primitive types carry safety invariants.
|
||||
self != &Self::Primitive
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -81,7 +81,8 @@ where
|
|||
Self::Seq(vec![Self::uninit(); width_in_bytes])
|
||||
}
|
||||
|
||||
/// Remove all `Def` nodes, and all branches of the layout for which `f` produces false.
|
||||
/// Remove all `Def` nodes, and all branches of the layout for which `f`
|
||||
/// produces `true`.
|
||||
pub(crate) fn prune<F>(self, f: &F) -> Tree<!, R>
|
||||
where
|
||||
F: Fn(D) -> bool,
|
||||
|
@ -106,7 +107,7 @@ where
|
|||
Self::Byte(b) => Tree::Byte(b),
|
||||
Self::Ref(r) => Tree::Ref(r),
|
||||
Self::Def(d) => {
|
||||
if !f(d) {
|
||||
if f(d) {
|
||||
Tree::uninhabited()
|
||||
} else {
|
||||
Tree::unit()
|
||||
|
|
|
@ -2,11 +2,15 @@ use super::Tree;
|
|||
|
||||
#[derive(Debug, Hash, Eq, PartialEq, Clone, Copy)]
|
||||
pub enum Def {
|
||||
Visible,
|
||||
Invisible,
|
||||
NoSafetyInvariants,
|
||||
HasSafetyInvariants,
|
||||
}
|
||||
|
||||
impl super::Def for Def {}
|
||||
impl super::Def for Def {
|
||||
fn has_safety_invariants(&self) -> bool {
|
||||
self == &Self::HasSafetyInvariants
|
||||
}
|
||||
}
|
||||
|
||||
mod prune {
|
||||
use super::*;
|
||||
|
@ -16,17 +20,22 @@ mod prune {
|
|||
|
||||
#[test]
|
||||
fn seq_1() {
|
||||
let layout: Tree<Def, !> = Tree::def(Def::Visible).then(Tree::from_bits(0x00));
|
||||
assert_eq!(layout.prune(&|d| matches!(d, Def::Visible)), Tree::from_bits(0x00));
|
||||
let layout: Tree<Def, !> =
|
||||
Tree::def(Def::NoSafetyInvariants).then(Tree::from_bits(0x00));
|
||||
assert_eq!(
|
||||
layout.prune(&|d| matches!(d, Def::HasSafetyInvariants)),
|
||||
Tree::from_bits(0x00)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn seq_2() {
|
||||
let layout: Tree<Def, !> =
|
||||
Tree::from_bits(0x00).then(Tree::def(Def::Visible)).then(Tree::from_bits(0x01));
|
||||
let layout: Tree<Def, !> = Tree::from_bits(0x00)
|
||||
.then(Tree::def(Def::NoSafetyInvariants))
|
||||
.then(Tree::from_bits(0x01));
|
||||
|
||||
assert_eq!(
|
||||
layout.prune(&|d| matches!(d, Def::Visible)),
|
||||
layout.prune(&|d| matches!(d, Def::HasSafetyInvariants)),
|
||||
Tree::from_bits(0x00).then(Tree::from_bits(0x01))
|
||||
);
|
||||
}
|
||||
|
@ -37,21 +46,32 @@ mod prune {
|
|||
|
||||
#[test]
|
||||
fn invisible_def() {
|
||||
let layout: Tree<Def, !> = Tree::def(Def::Invisible);
|
||||
assert_eq!(layout.prune(&|d| matches!(d, Def::Visible)), Tree::uninhabited());
|
||||
let layout: Tree<Def, !> = Tree::def(Def::HasSafetyInvariants);
|
||||
assert_eq!(
|
||||
layout.prune(&|d| matches!(d, Def::HasSafetyInvariants)),
|
||||
Tree::uninhabited()
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn invisible_def_in_seq_len_2() {
|
||||
let layout: Tree<Def, !> = Tree::def(Def::Visible).then(Tree::def(Def::Invisible));
|
||||
assert_eq!(layout.prune(&|d| matches!(d, Def::Visible)), Tree::uninhabited());
|
||||
let layout: Tree<Def, !> =
|
||||
Tree::def(Def::NoSafetyInvariants).then(Tree::def(Def::HasSafetyInvariants));
|
||||
assert_eq!(
|
||||
layout.prune(&|d| matches!(d, Def::HasSafetyInvariants)),
|
||||
Tree::uninhabited()
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn invisible_def_in_seq_len_3() {
|
||||
let layout: Tree<Def, !> =
|
||||
Tree::def(Def::Visible).then(Tree::from_bits(0x00)).then(Tree::def(Def::Invisible));
|
||||
assert_eq!(layout.prune(&|d| matches!(d, Def::Visible)), Tree::uninhabited());
|
||||
let layout: Tree<Def, !> = Tree::def(Def::NoSafetyInvariants)
|
||||
.then(Tree::from_bits(0x00))
|
||||
.then(Tree::def(Def::HasSafetyInvariants));
|
||||
assert_eq!(
|
||||
layout.prune(&|d| matches!(d, Def::HasSafetyInvariants)),
|
||||
Tree::uninhabited()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -60,21 +80,26 @@ mod prune {
|
|||
|
||||
#[test]
|
||||
fn visible_def() {
|
||||
let layout: Tree<Def, !> = Tree::def(Def::Visible);
|
||||
assert_eq!(layout.prune(&|d| matches!(d, Def::Visible)), Tree::unit());
|
||||
let layout: Tree<Def, !> = Tree::def(Def::NoSafetyInvariants);
|
||||
assert_eq!(layout.prune(&|d| matches!(d, Def::HasSafetyInvariants)), Tree::unit());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn visible_def_in_seq_len_2() {
|
||||
let layout: Tree<Def, !> = Tree::def(Def::Visible).then(Tree::def(Def::Visible));
|
||||
assert_eq!(layout.prune(&|d| matches!(d, Def::Visible)), Tree::unit());
|
||||
let layout: Tree<Def, !> =
|
||||
Tree::def(Def::NoSafetyInvariants).then(Tree::def(Def::NoSafetyInvariants));
|
||||
assert_eq!(layout.prune(&|d| matches!(d, Def::HasSafetyInvariants)), Tree::unit());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn visible_def_in_seq_len_3() {
|
||||
let layout: Tree<Def, !> =
|
||||
Tree::def(Def::Visible).then(Tree::from_bits(0x00)).then(Tree::def(Def::Visible));
|
||||
assert_eq!(layout.prune(&|d| matches!(d, Def::Visible)), Tree::from_bits(0x00));
|
||||
let layout: Tree<Def, !> = Tree::def(Def::NoSafetyInvariants)
|
||||
.then(Tree::from_bits(0x00))
|
||||
.then(Tree::def(Def::NoSafetyInvariants));
|
||||
assert_eq!(
|
||||
layout.prune(&|d| matches!(d, Def::HasSafetyInvariants)),
|
||||
Tree::from_bits(0x00)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,8 +49,8 @@ pub enum Reason {
|
|||
DstIsUnspecified,
|
||||
/// The layout of the destination type is bit-incompatible with the source type.
|
||||
DstIsBitIncompatible,
|
||||
/// There aren't any public constructors for `Dst`.
|
||||
DstIsPrivate,
|
||||
/// The destination type may carry safety invariants.
|
||||
DstMayHaveSafetyInvariants,
|
||||
/// `Dst` is larger than `Src`, and the excess bytes were not exclusively uninitialized.
|
||||
DstIsTooBig,
|
||||
/// Src should have a stricter alignment than Dst, but it does not.
|
||||
|
@ -106,13 +106,11 @@ mod rustc {
|
|||
&mut self,
|
||||
cause: ObligationCause<'tcx>,
|
||||
types: Types<'tcx>,
|
||||
scope: Ty<'tcx>,
|
||||
assume: crate::Assume,
|
||||
) -> crate::Answer<crate::layout::rustc::Ref<'tcx>> {
|
||||
crate::maybe_transmutable::MaybeTransmutableQuery::new(
|
||||
types.src,
|
||||
types.dst,
|
||||
scope,
|
||||
assume,
|
||||
self.infcx.tcx,
|
||||
)
|
||||
|
|
|
@ -3,7 +3,7 @@ pub(crate) mod query_context;
|
|||
mod tests;
|
||||
|
||||
use crate::{
|
||||
layout::{self, dfa, Byte, Dfa, Nfa, Ref, Tree, Uninhabited},
|
||||
layout::{self, dfa, Byte, Def, Dfa, Nfa, Ref, Tree, Uninhabited},
|
||||
maybe_transmutable::query_context::QueryContext,
|
||||
Answer, Condition, Map, Reason,
|
||||
};
|
||||
|
@ -14,7 +14,6 @@ where
|
|||
{
|
||||
src: L,
|
||||
dst: L,
|
||||
scope: <C as QueryContext>::Scope,
|
||||
assume: crate::Assume,
|
||||
context: C,
|
||||
}
|
||||
|
@ -23,14 +22,8 @@ impl<L, C> MaybeTransmutableQuery<L, C>
|
|||
where
|
||||
C: QueryContext,
|
||||
{
|
||||
pub(crate) fn new(
|
||||
src: L,
|
||||
dst: L,
|
||||
scope: <C as QueryContext>::Scope,
|
||||
assume: crate::Assume,
|
||||
context: C,
|
||||
) -> Self {
|
||||
Self { src, dst, scope, assume, context }
|
||||
pub(crate) fn new(src: L, dst: L, assume: crate::Assume, context: C) -> Self {
|
||||
Self { src, dst, assume, context }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,7 +41,7 @@ mod rustc {
|
|||
/// then computes an answer using those trees.
|
||||
#[instrument(level = "debug", skip(self), fields(src = ?self.src, dst = ?self.dst))]
|
||||
pub fn answer(self) -> Answer<<TyCtxt<'tcx> as QueryContext>::Ref> {
|
||||
let Self { src, dst, scope, assume, context } = self;
|
||||
let Self { src, dst, assume, context } = self;
|
||||
|
||||
// Convert `src` and `dst` from their rustc representations, to `Tree`-based
|
||||
// representations. If these conversions fail, conclude that the transmutation is
|
||||
|
@ -67,9 +60,7 @@ mod rustc {
|
|||
(_, Err(Err::Unspecified)) => Answer::No(Reason::DstIsUnspecified),
|
||||
(Err(Err::SizeOverflow), _) => Answer::No(Reason::SrcSizeOverflow),
|
||||
(_, Err(Err::SizeOverflow)) => Answer::No(Reason::DstSizeOverflow),
|
||||
(Ok(src), Ok(dst)) => {
|
||||
MaybeTransmutableQuery { src, dst, scope, assume, context }.answer()
|
||||
}
|
||||
(Ok(src), Ok(dst)) => MaybeTransmutableQuery { src, dst, assume, context }.answer(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -86,43 +77,51 @@ where
|
|||
#[inline(always)]
|
||||
#[instrument(level = "debug", skip(self), fields(src = ?self.src, dst = ?self.dst))]
|
||||
pub(crate) fn answer(self) -> Answer<<C as QueryContext>::Ref> {
|
||||
let assume_visibility = self.assume.safety;
|
||||
let Self { src, dst, assume, context } = self;
|
||||
|
||||
let Self { src, dst, scope, assume, context } = self;
|
||||
|
||||
// Remove all `Def` nodes from `src`, without checking their visibility.
|
||||
let src = src.prune(&|def| true);
|
||||
// Unconditionally all `Def` nodes from `src`, without pruning away the
|
||||
// branches they appear in. This is valid to do for value-to-value
|
||||
// transmutations, but not for `&mut T` to `&mut U`; we will need to be
|
||||
// more sophisticated to handle transmutations between mutable
|
||||
// references.
|
||||
let src = src.prune(&|def| false);
|
||||
|
||||
trace!(?src, "pruned src");
|
||||
|
||||
// Remove all `Def` nodes from `dst`, additionally...
|
||||
let dst = if assume_visibility {
|
||||
// ...if visibility is assumed, don't check their visibility.
|
||||
dst.prune(&|def| true)
|
||||
let dst = if assume.safety {
|
||||
// ...if safety is assumed, don't check if they carry safety
|
||||
// invariants; retain all paths.
|
||||
dst.prune(&|def| false)
|
||||
} else {
|
||||
// ...otherwise, prune away all unreachable paths through the `Dst` layout.
|
||||
dst.prune(&|def| context.is_accessible_from(def, scope))
|
||||
// ...otherwise, prune away all paths with safety invariants from
|
||||
// the `Dst` layout.
|
||||
dst.prune(&|def| def.has_safety_invariants())
|
||||
};
|
||||
|
||||
trace!(?dst, "pruned dst");
|
||||
|
||||
// Convert `src` from a tree-based representation to an NFA-based representation.
|
||||
// If the conversion fails because `src` is uninhabited, conclude that the transmutation
|
||||
// is acceptable, because instances of the `src` type do not exist.
|
||||
// Convert `src` from a tree-based representation to an NFA-based
|
||||
// representation. If the conversion fails because `src` is uninhabited,
|
||||
// conclude that the transmutation is acceptable, because instances of
|
||||
// the `src` type do not exist.
|
||||
let src = match Nfa::from_tree(src) {
|
||||
Ok(src) => src,
|
||||
Err(Uninhabited) => return Answer::Yes,
|
||||
};
|
||||
|
||||
// Convert `dst` from a tree-based representation to an NFA-based representation.
|
||||
// If the conversion fails because `src` is uninhabited, conclude that the transmutation
|
||||
// is unacceptable, because instances of the `dst` type do not exist.
|
||||
// Convert `dst` from a tree-based representation to an NFA-based
|
||||
// representation. If the conversion fails because `src` is uninhabited,
|
||||
// conclude that the transmutation is unacceptable. Valid instances of
|
||||
// the `dst` type do not exist, either because it's genuinely
|
||||
// uninhabited, or because there are no branches of the tree that are
|
||||
// free of safety invariants.
|
||||
let dst = match Nfa::from_tree(dst) {
|
||||
Ok(dst) => dst,
|
||||
Err(Uninhabited) => return Answer::No(Reason::DstIsPrivate),
|
||||
Err(Uninhabited) => return Answer::No(Reason::DstMayHaveSafetyInvariants),
|
||||
};
|
||||
|
||||
MaybeTransmutableQuery { src, dst, scope, assume, context }.answer()
|
||||
MaybeTransmutableQuery { src, dst, assume, context }.answer()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -136,10 +135,10 @@ where
|
|||
#[inline(always)]
|
||||
#[instrument(level = "debug", skip(self), fields(src = ?self.src, dst = ?self.dst))]
|
||||
pub(crate) fn answer(self) -> Answer<<C as QueryContext>::Ref> {
|
||||
let Self { src, dst, scope, assume, context } = self;
|
||||
let Self { src, dst, assume, context } = self;
|
||||
let src = Dfa::from_nfa(src);
|
||||
let dst = Dfa::from_nfa(dst);
|
||||
MaybeTransmutableQuery { src, dst, scope, assume, context }.answer()
|
||||
MaybeTransmutableQuery { src, dst, assume, context }.answer()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,9 +6,6 @@ pub(crate) trait QueryContext {
|
|||
type Ref: layout::Ref;
|
||||
type Scope: Copy;
|
||||
|
||||
/// Is `def` accessible from the defining module of `scope`?
|
||||
fn is_accessible_from(&self, def: Self::Def, scope: Self::Scope) -> bool;
|
||||
|
||||
fn min_align(&self, reference: Self::Ref) -> usize;
|
||||
}
|
||||
|
||||
|
@ -20,21 +17,21 @@ pub(crate) mod test {
|
|||
|
||||
#[derive(Debug, Hash, Eq, PartialEq, Clone, Copy)]
|
||||
pub(crate) enum Def {
|
||||
Visible,
|
||||
Invisible,
|
||||
HasSafetyInvariants,
|
||||
NoSafetyInvariants,
|
||||
}
|
||||
|
||||
impl crate::layout::Def for Def {}
|
||||
impl crate::layout::Def for Def {
|
||||
fn has_safety_invariants(&self) -> bool {
|
||||
self == &Self::HasSafetyInvariants
|
||||
}
|
||||
}
|
||||
|
||||
impl QueryContext for UltraMinimal {
|
||||
type Def = Def;
|
||||
type Ref = !;
|
||||
type Scope = ();
|
||||
|
||||
fn is_accessible_from(&self, def: Def, scope: ()) -> bool {
|
||||
matches!(Def::Visible, def)
|
||||
}
|
||||
|
||||
fn min_align(&self, reference: !) -> usize {
|
||||
unimplemented!()
|
||||
}
|
||||
|
@ -52,34 +49,6 @@ mod rustc {
|
|||
|
||||
type Scope = Ty<'tcx>;
|
||||
|
||||
#[instrument(level = "debug", skip(self))]
|
||||
fn is_accessible_from(&self, def: Self::Def, scope: Self::Scope) -> bool {
|
||||
use layout::rustc::Def;
|
||||
use rustc_middle::ty;
|
||||
|
||||
let parent = if let ty::Adt(adt_def, ..) = scope.kind() {
|
||||
self.parent(adt_def.did())
|
||||
} else {
|
||||
// Is this always how we want to handle a non-ADT scope?
|
||||
return false;
|
||||
};
|
||||
|
||||
let def_id = match def {
|
||||
Def::Adt(adt_def) => adt_def.did(),
|
||||
Def::Variant(variant_def) => variant_def.def_id,
|
||||
Def::Field(field_def) => field_def.did,
|
||||
Def::Primitive => {
|
||||
// primitives do not have a def_id, but they're always accessible
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
let ret: bool = self.visibility(def_id).is_accessible_from(parent, *self);
|
||||
|
||||
trace!(?ret, "ret");
|
||||
ret
|
||||
}
|
||||
|
||||
fn min_align(&self, reference: Self::Ref) -> usize {
|
||||
unimplemented!()
|
||||
}
|
||||
|
|
|
@ -3,6 +3,65 @@ use crate::maybe_transmutable::MaybeTransmutableQuery;
|
|||
use crate::{layout, Reason};
|
||||
use itertools::Itertools;
|
||||
|
||||
mod safety {
|
||||
use crate::Answer;
|
||||
|
||||
use super::*;
|
||||
|
||||
type Tree = layout::Tree<Def, !>;
|
||||
|
||||
const DST_HAS_SAFETY_INVARIANTS: Answer<!> =
|
||||
Answer::No(crate::Reason::DstMayHaveSafetyInvariants);
|
||||
|
||||
fn is_transmutable(src: &Tree, dst: &Tree, assume_safety: bool) -> crate::Answer<!> {
|
||||
let src = src.clone();
|
||||
let dst = dst.clone();
|
||||
// The only dimension of the transmutability analysis we want to test
|
||||
// here is the safety analysis. To ensure this, we disable all other
|
||||
// toggleable aspects of the transmutability analysis.
|
||||
let assume = crate::Assume {
|
||||
alignment: true,
|
||||
lifetimes: true,
|
||||
validity: true,
|
||||
safety: assume_safety,
|
||||
};
|
||||
crate::maybe_transmutable::MaybeTransmutableQuery::new(src, dst, assume, UltraMinimal)
|
||||
.answer()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn src_safe_dst_safe() {
|
||||
let src = Tree::Def(Def::NoSafetyInvariants).then(Tree::u8());
|
||||
let dst = Tree::Def(Def::NoSafetyInvariants).then(Tree::u8());
|
||||
assert_eq!(is_transmutable(&src, &dst, false), Answer::Yes);
|
||||
assert_eq!(is_transmutable(&src, &dst, true), Answer::Yes);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn src_safe_dst_unsafe() {
|
||||
let src = Tree::Def(Def::NoSafetyInvariants).then(Tree::u8());
|
||||
let dst = Tree::Def(Def::HasSafetyInvariants).then(Tree::u8());
|
||||
assert_eq!(is_transmutable(&src, &dst, false), DST_HAS_SAFETY_INVARIANTS);
|
||||
assert_eq!(is_transmutable(&src, &dst, true), Answer::Yes);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn src_unsafe_dst_safe() {
|
||||
let src = Tree::Def(Def::HasSafetyInvariants).then(Tree::u8());
|
||||
let dst = Tree::Def(Def::NoSafetyInvariants).then(Tree::u8());
|
||||
assert_eq!(is_transmutable(&src, &dst, false), Answer::Yes);
|
||||
assert_eq!(is_transmutable(&src, &dst, true), Answer::Yes);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn src_unsafe_dst_unsafe() {
|
||||
let src = Tree::Def(Def::HasSafetyInvariants).then(Tree::u8());
|
||||
let dst = Tree::Def(Def::HasSafetyInvariants).then(Tree::u8());
|
||||
assert_eq!(is_transmutable(&src, &dst, false), DST_HAS_SAFETY_INVARIANTS);
|
||||
assert_eq!(is_transmutable(&src, &dst, true), Answer::Yes);
|
||||
}
|
||||
}
|
||||
|
||||
mod bool {
|
||||
use crate::Answer;
|
||||
|
||||
|
@ -10,11 +69,9 @@ mod bool {
|
|||
|
||||
#[test]
|
||||
fn should_permit_identity_transmutation_tree() {
|
||||
println!("{:?}", layout::Tree::<!, !>::bool());
|
||||
let answer = crate::maybe_transmutable::MaybeTransmutableQuery::new(
|
||||
layout::Tree::<Def, !>::bool(),
|
||||
layout::Tree::<Def, !>::bool(),
|
||||
(),
|
||||
crate::Assume { alignment: false, lifetimes: false, validity: true, safety: false },
|
||||
UltraMinimal,
|
||||
)
|
||||
|
@ -27,7 +84,6 @@ mod bool {
|
|||
let answer = crate::maybe_transmutable::MaybeTransmutableQuery::new(
|
||||
layout::Dfa::<!>::bool(),
|
||||
layout::Dfa::<!>::bool(),
|
||||
(),
|
||||
crate::Assume { alignment: false, lifetimes: false, validity: true, safety: false },
|
||||
UltraMinimal,
|
||||
)
|
||||
|
@ -71,7 +127,6 @@ mod bool {
|
|||
MaybeTransmutableQuery::new(
|
||||
src_layout.clone(),
|
||||
dst_layout.clone(),
|
||||
(),
|
||||
crate::Assume { validity: false, ..crate::Assume::default() },
|
||||
UltraMinimal,
|
||||
)
|
||||
|
@ -86,7 +141,6 @@ mod bool {
|
|||
MaybeTransmutableQuery::new(
|
||||
src_layout.clone(),
|
||||
dst_layout.clone(),
|
||||
(),
|
||||
crate::Assume { validity: true, ..crate::Assume::default() },
|
||||
UltraMinimal,
|
||||
)
|
||||
|
@ -101,7 +155,6 @@ mod bool {
|
|||
MaybeTransmutableQuery::new(
|
||||
src_layout.clone(),
|
||||
dst_layout.clone(),
|
||||
(),
|
||||
crate::Assume { validity: false, ..crate::Assume::default() },
|
||||
UltraMinimal,
|
||||
)
|
||||
|
|
|
@ -6,10 +6,10 @@ use crate::marker::ConstParamTy;
|
|||
/// any value of type `Self` are safely transmutable into a value of type `Dst`, in a given `Context`,
|
||||
/// notwithstanding whatever safety checks you have asked the compiler to [`Assume`] are satisfied.
|
||||
#[unstable(feature = "transmutability", issue = "99571")]
|
||||
#[lang = "transmute_trait"]
|
||||
#[cfg_attr(not(bootstrap), lang = "transmute_trait")]
|
||||
#[rustc_deny_explicit_impl(implement_via_object = false)]
|
||||
#[rustc_coinductive]
|
||||
pub unsafe trait BikeshedIntrinsicFrom<Src, Context, const ASSUME: Assume = { Assume::NOTHING }>
|
||||
pub unsafe trait BikeshedIntrinsicFrom<Src, const ASSUME: Assume = { Assume::NOTHING }>
|
||||
where
|
||||
Src: ?Sized,
|
||||
{
|
||||
|
@ -28,8 +28,9 @@ pub struct Assume {
|
|||
/// that violates Rust's memory model.
|
||||
pub lifetimes: bool,
|
||||
|
||||
/// When `true`, the compiler assumes that *you* have ensured that it is safe for you to violate the
|
||||
/// type and field privacy of the destination type (and sometimes of the source type, too).
|
||||
/// When `true`, the compiler assumes that *you* have ensured that no
|
||||
/// unsoundness will arise from violating the safety invariants of the
|
||||
/// destination type (and sometimes of the source type, too).
|
||||
pub safety: bool,
|
||||
|
||||
/// When `true`, the compiler assumes that *you* are ensuring that the source type is actually a valid
|
||||
|
|
|
@ -234,15 +234,9 @@ impl Default for Alignment {
|
|||
}
|
||||
|
||||
#[cfg(target_pointer_width = "16")]
|
||||
type AlignmentEnum = AlignmentEnum16;
|
||||
#[cfg(target_pointer_width = "32")]
|
||||
type AlignmentEnum = AlignmentEnum32;
|
||||
#[cfg(target_pointer_width = "64")]
|
||||
type AlignmentEnum = AlignmentEnum64;
|
||||
|
||||
#[derive(Copy, Clone, PartialEq, Eq)]
|
||||
#[repr(u16)]
|
||||
enum AlignmentEnum16 {
|
||||
enum AlignmentEnum {
|
||||
_Align1Shl0 = 1 << 0,
|
||||
_Align1Shl1 = 1 << 1,
|
||||
_Align1Shl2 = 1 << 2,
|
||||
|
@ -261,9 +255,10 @@ enum AlignmentEnum16 {
|
|||
_Align1Shl15 = 1 << 15,
|
||||
}
|
||||
|
||||
#[cfg(target_pointer_width = "32")]
|
||||
#[derive(Copy, Clone, PartialEq, Eq)]
|
||||
#[repr(u32)]
|
||||
enum AlignmentEnum32 {
|
||||
enum AlignmentEnum {
|
||||
_Align1Shl0 = 1 << 0,
|
||||
_Align1Shl1 = 1 << 1,
|
||||
_Align1Shl2 = 1 << 2,
|
||||
|
@ -298,9 +293,10 @@ enum AlignmentEnum32 {
|
|||
_Align1Shl31 = 1 << 31,
|
||||
}
|
||||
|
||||
#[cfg(target_pointer_width = "64")]
|
||||
#[derive(Copy, Clone, PartialEq, Eq)]
|
||||
#[repr(u64)]
|
||||
enum AlignmentEnum64 {
|
||||
enum AlignmentEnum {
|
||||
_Align1Shl0 = 1 << 0,
|
||||
_Align1Shl1 = 1 << 1,
|
||||
_Align1Shl2 = 1 << 2,
|
||||
|
|
|
@ -469,7 +469,6 @@ pub struct SplitPaths<'a> {
|
|||
/// None => println!("{key} is not defined in the environment.")
|
||||
/// }
|
||||
/// ```
|
||||
#[doc(alias = "PATH")]
|
||||
#[stable(feature = "env", since = "1.0.0")]
|
||||
pub fn split_paths<T: AsRef<OsStr> + ?Sized>(unparsed: &T) -> SplitPaths<'_> {
|
||||
SplitPaths { inner: os_imp::split_paths(unparsed.as_ref()) }
|
||||
|
@ -565,7 +564,6 @@ pub struct JoinPathsError {
|
|||
/// ```
|
||||
///
|
||||
/// [`env::split_paths()`]: split_paths
|
||||
#[doc(alias = "PATH")]
|
||||
#[stable(feature = "env", since = "1.0.0")]
|
||||
pub fn join_paths<I, T>(paths: I) -> Result<OsString, JoinPathsError>
|
||||
where
|
||||
|
|
|
@ -6,7 +6,7 @@ ARM64e macOS (11.0+, Big Sur+)
|
|||
|
||||
## Target maintainers
|
||||
|
||||
- Artyom Tetyukhin ([@arttet](https://github.com/https://github.com/arttet))
|
||||
- Artyom Tetyukhin ([@arttet](https://github.com/arttet))
|
||||
|
||||
## Requirements
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ ARM64e iOS (12.0+)
|
|||
|
||||
## Target maintainers
|
||||
|
||||
- Artyom Tetyukhin ([@arttet](https://github.com/https://github.com/arttet))
|
||||
- Artyom Tetyukhin ([@arttet](https://github.com/arttet))
|
||||
|
||||
## Requirements
|
||||
|
||||
|
|
|
@ -1651,8 +1651,7 @@ struct TyAliasRewriteInfo<'c, 'g>(
|
|||
&'c RewriteContext<'c>,
|
||||
Indent,
|
||||
&'g ast::Generics,
|
||||
(ast::TyAliasWhereClause, ast::TyAliasWhereClause),
|
||||
usize,
|
||||
ast::TyAliasWhereClauses,
|
||||
symbol::Ident,
|
||||
Span,
|
||||
);
|
||||
|
@ -1672,7 +1671,6 @@ pub(crate) fn rewrite_type_alias<'a, 'b>(
|
|||
ref bounds,
|
||||
ref ty,
|
||||
where_clauses,
|
||||
where_predicates_split,
|
||||
} = *ty_alias_kind;
|
||||
let ty_opt = ty.as_ref();
|
||||
let (ident, vis) = match visitor_kind {
|
||||
|
@ -1680,15 +1678,7 @@ pub(crate) fn rewrite_type_alias<'a, 'b>(
|
|||
AssocTraitItem(i) | AssocImplItem(i) => (i.ident, &i.vis),
|
||||
ForeignItem(i) => (i.ident, &i.vis),
|
||||
};
|
||||
let rw_info = &TyAliasRewriteInfo(
|
||||
context,
|
||||
indent,
|
||||
generics,
|
||||
where_clauses,
|
||||
where_predicates_split,
|
||||
ident,
|
||||
span,
|
||||
);
|
||||
let rw_info = &TyAliasRewriteInfo(context, indent, generics, where_clauses, ident, span);
|
||||
let op_ty = opaque_ty(ty);
|
||||
// Type Aliases are formatted slightly differently depending on the context
|
||||
// in which they appear, whether they are opaque, and whether they are associated.
|
||||
|
@ -1724,19 +1714,11 @@ fn rewrite_ty<R: Rewrite>(
|
|||
vis: &ast::Visibility,
|
||||
) -> Option<String> {
|
||||
let mut result = String::with_capacity(128);
|
||||
let TyAliasRewriteInfo(
|
||||
context,
|
||||
indent,
|
||||
generics,
|
||||
where_clauses,
|
||||
where_predicates_split,
|
||||
ident,
|
||||
span,
|
||||
) = *rw_info;
|
||||
let TyAliasRewriteInfo(context, indent, generics, where_clauses, ident, span) = *rw_info;
|
||||
let (before_where_predicates, after_where_predicates) = generics
|
||||
.where_clause
|
||||
.predicates
|
||||
.split_at(where_predicates_split);
|
||||
.split_at(where_clauses.split);
|
||||
if !after_where_predicates.is_empty() {
|
||||
return None;
|
||||
}
|
||||
|
@ -1771,7 +1753,7 @@ fn rewrite_ty<R: Rewrite>(
|
|||
let where_clause_str = rewrite_where_clause(
|
||||
context,
|
||||
before_where_predicates,
|
||||
where_clauses.0.1,
|
||||
where_clauses.before.span,
|
||||
context.config.brace_style(),
|
||||
Shape::legacy(where_budget, indent),
|
||||
false,
|
||||
|
@ -1795,7 +1777,7 @@ fn rewrite_ty<R: Rewrite>(
|
|||
let comment_span = context
|
||||
.snippet_provider
|
||||
.opt_span_before(span, "=")
|
||||
.map(|op_lo| mk_sp(where_clauses.0.1.hi(), op_lo));
|
||||
.map(|op_lo| mk_sp(where_clauses.before.span.hi(), op_lo));
|
||||
|
||||
let lhs = match comment_span {
|
||||
Some(comment_span)
|
||||
|
|
|
@ -92,6 +92,7 @@ const EXCEPTIONS: ExceptionList = &[
|
|||
("ryu", "Apache-2.0 OR BSL-1.0"), // BSL is not acceptble, but we use it under Apache-2.0 // cargo/... (because of serde)
|
||||
("self_cell", "Apache-2.0"), // rustc (fluent translations)
|
||||
("snap", "BSD-3-Clause"), // rustc
|
||||
("wasm-encoder", "Apache-2.0 WITH LLVM-exception"), // rustc
|
||||
("wasmparser", "Apache-2.0 WITH LLVM-exception"), // rustc
|
||||
// tidy-alphabetical-end
|
||||
];
|
||||
|
@ -267,6 +268,7 @@ const PERMITTED_RUSTC_DEPENDENCIES: &[&str] = &[
|
|||
"jemalloc-sys",
|
||||
"jobserver",
|
||||
"lazy_static",
|
||||
"leb128",
|
||||
"libc",
|
||||
"libloading",
|
||||
"linux-raw-sys",
|
||||
|
@ -380,6 +382,7 @@ const PERMITTED_RUSTC_DEPENDENCIES: &[&str] = &[
|
|||
"valuable",
|
||||
"version_check",
|
||||
"wasi",
|
||||
"wasm-encoder",
|
||||
"wasmparser",
|
||||
"winapi",
|
||||
"winapi-i686-pc-windows-gnu",
|
||||
|
|
|
@ -4133,7 +4133,6 @@
|
|||
"ui/transmutability/issue-101739-2.rs",
|
||||
"ui/transmutability/issue-110467.rs",
|
||||
"ui/transmutability/issue-110892.rs",
|
||||
"ui/transmute/issue-115402-overflow-size.rs",
|
||||
"ui/trivial-bounds/issue-73021-impossible-inline.rs",
|
||||
"ui/try-block/issue-45124.rs",
|
||||
"ui/try-trait/issue-32709.rs",
|
||||
|
|
|
@ -69,7 +69,7 @@
|
|||
|
||||
bb2: {
|
||||
- _1 = move ((_2 as Some).0: std::alloc::Layout);
|
||||
+ _1 = const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(4 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x00000000): std::ptr::alignment::AlignmentEnum32) }};
|
||||
+ _1 = const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(4 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x00000000): std::ptr::alignment::AlignmentEnum) }};
|
||||
StorageDead(_10);
|
||||
StorageDead(_2);
|
||||
StorageLive(_3);
|
||||
|
@ -83,8 +83,8 @@
|
|||
StorageLive(_8);
|
||||
- _8 = _1;
|
||||
- _6 = std::alloc::Global::alloc_impl(move _7, move _8, const false) -> [return: bb3, unwind unreachable];
|
||||
+ _8 = const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(4 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x00000000): std::ptr::alignment::AlignmentEnum32) }};
|
||||
+ _6 = std::alloc::Global::alloc_impl(const {ALLOC1<imm>: &std::alloc::Global}, const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(4 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x00000000): std::ptr::alignment::AlignmentEnum32) }}, const false) -> [return: bb3, unwind unreachable];
|
||||
+ _8 = const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(4 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x00000000): std::ptr::alignment::AlignmentEnum) }};
|
||||
+ _6 = std::alloc::Global::alloc_impl(const {ALLOC1<imm>: &std::alloc::Global}, const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(4 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x00000000): std::ptr::alignment::AlignmentEnum) }}, const false) -> [return: bb3, unwind unreachable];
|
||||
}
|
||||
|
||||
bb3: {
|
||||
|
|
|
@ -73,7 +73,7 @@
|
|||
|
||||
bb3: {
|
||||
- _1 = move ((_2 as Some).0: std::alloc::Layout);
|
||||
+ _1 = const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(4 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x00000000): std::ptr::alignment::AlignmentEnum32) }};
|
||||
+ _1 = const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(4 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x00000000): std::ptr::alignment::AlignmentEnum) }};
|
||||
StorageDead(_10);
|
||||
StorageDead(_2);
|
||||
StorageLive(_3);
|
||||
|
@ -87,8 +87,8 @@
|
|||
StorageLive(_8);
|
||||
- _8 = _1;
|
||||
- _6 = std::alloc::Global::alloc_impl(move _7, move _8, const false) -> [return: bb4, unwind continue];
|
||||
+ _8 = const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(4 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x00000000): std::ptr::alignment::AlignmentEnum32) }};
|
||||
+ _6 = std::alloc::Global::alloc_impl(const {ALLOC1<imm>: &std::alloc::Global}, const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(4 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x00000000): std::ptr::alignment::AlignmentEnum32) }}, const false) -> [return: bb4, unwind continue];
|
||||
+ _8 = const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(4 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x00000000): std::ptr::alignment::AlignmentEnum) }};
|
||||
+ _6 = std::alloc::Global::alloc_impl(const {ALLOC1<imm>: &std::alloc::Global}, const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(4 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x00000000): std::ptr::alignment::AlignmentEnum) }}, const false) -> [return: bb4, unwind continue];
|
||||
}
|
||||
|
||||
bb4: {
|
||||
|
|
|
@ -69,7 +69,7 @@
|
|||
|
||||
bb2: {
|
||||
- _1 = move ((_2 as Some).0: std::alloc::Layout);
|
||||
+ _1 = const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(8 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x0000000000000000): std::ptr::alignment::AlignmentEnum64) }};
|
||||
+ _1 = const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(8 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x0000000000000000): std::ptr::alignment::AlignmentEnum) }};
|
||||
StorageDead(_10);
|
||||
StorageDead(_2);
|
||||
StorageLive(_3);
|
||||
|
@ -83,8 +83,8 @@
|
|||
StorageLive(_8);
|
||||
- _8 = _1;
|
||||
- _6 = std::alloc::Global::alloc_impl(move _7, move _8, const false) -> [return: bb3, unwind unreachable];
|
||||
+ _8 = const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(8 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x0000000000000000): std::ptr::alignment::AlignmentEnum64) }};
|
||||
+ _6 = std::alloc::Global::alloc_impl(const {ALLOC1<imm>: &std::alloc::Global}, const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(8 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x0000000000000000): std::ptr::alignment::AlignmentEnum64) }}, const false) -> [return: bb3, unwind unreachable];
|
||||
+ _8 = const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(8 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x0000000000000000): std::ptr::alignment::AlignmentEnum) }};
|
||||
+ _6 = std::alloc::Global::alloc_impl(const {ALLOC1<imm>: &std::alloc::Global}, const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(8 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x0000000000000000): std::ptr::alignment::AlignmentEnum) }}, const false) -> [return: bb3, unwind unreachable];
|
||||
}
|
||||
|
||||
bb3: {
|
||||
|
|
|
@ -73,7 +73,7 @@
|
|||
|
||||
bb3: {
|
||||
- _1 = move ((_2 as Some).0: std::alloc::Layout);
|
||||
+ _1 = const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(8 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x0000000000000000): std::ptr::alignment::AlignmentEnum64) }};
|
||||
+ _1 = const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(8 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x0000000000000000): std::ptr::alignment::AlignmentEnum) }};
|
||||
StorageDead(_10);
|
||||
StorageDead(_2);
|
||||
StorageLive(_3);
|
||||
|
@ -87,8 +87,8 @@
|
|||
StorageLive(_8);
|
||||
- _8 = _1;
|
||||
- _6 = std::alloc::Global::alloc_impl(move _7, move _8, const false) -> [return: bb4, unwind continue];
|
||||
+ _8 = const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(8 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x0000000000000000): std::ptr::alignment::AlignmentEnum64) }};
|
||||
+ _6 = std::alloc::Global::alloc_impl(const {ALLOC1<imm>: &std::alloc::Global}, const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(8 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x0000000000000000): std::ptr::alignment::AlignmentEnum64) }}, const false) -> [return: bb4, unwind continue];
|
||||
+ _8 = const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(8 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x0000000000000000): std::ptr::alignment::AlignmentEnum) }};
|
||||
+ _6 = std::alloc::Global::alloc_impl(const {ALLOC1<imm>: &std::alloc::Global}, const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(8 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x0000000000000000): std::ptr::alignment::AlignmentEnum) }}, const false) -> [return: bb4, unwind continue];
|
||||
}
|
||||
|
||||
bb4: {
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
// ignore-tidy-linelength
|
||||
#![allow(unused)]
|
||||
#![feature(ptr_metadata)]
|
||||
|
||||
use std::mem;
|
||||
use std::{ptr, mem};
|
||||
|
||||
// Strip out raw byte dumps to make comparison platform-independent:
|
||||
//@ normalize-stderr-test "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)"
|
||||
|
@ -145,6 +146,8 @@ const RAW_TRAIT_OBJ_VTABLE_NULL: *const dyn Trait = unsafe { mem::transmute((&92
|
|||
const RAW_TRAIT_OBJ_VTABLE_INVALID: *const dyn Trait = unsafe { mem::transmute((&92u8, &3u64)) };
|
||||
//~^ ERROR it is undefined behavior to use this value
|
||||
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>());
|
||||
|
||||
// Const eval fails for these, so they need to be statics to error.
|
||||
static mut RAW_TRAIT_OBJ_VTABLE_NULL_THROUGH_REF: *const dyn Trait = unsafe {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/ub-wide-ptr.rs:38:1
|
||||
--> $DIR/ub-wide-ptr.rs:39: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)
|
||||
|
@ -10,7 +10,7 @@ LL | const STR_TOO_LONG: &str = unsafe { mem::transmute((&42u8, 999usize)) };
|
|||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/ub-wide-ptr.rs:40:1
|
||||
--> $DIR/ub-wide-ptr.rs:41: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
|
||||
|
@ -21,7 +21,7 @@ LL | const NESTED_STR_MUCH_TOO_LONG: (&str,) = (unsafe { mem::transmute((&42, us
|
|||
}
|
||||
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/ub-wide-ptr.rs:43:1
|
||||
--> $DIR/ub-wide-ptr.rs:44:1
|
||||
|
|
||||
LL | const STR_LENGTH_PTR: &str = unsafe { mem::transmute((&42u8, &3)) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
|
||||
|
@ -30,7 +30,7 @@ LL | const STR_LENGTH_PTR: &str = unsafe { mem::transmute((&42u8, &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/ub-wide-ptr.rs:46:1
|
||||
--> $DIR/ub-wide-ptr.rs:47:1
|
||||
|
|
||||
LL | const MY_STR_LENGTH_PTR: &MyStr = unsafe { mem::transmute((&42u8, &3)) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
|
||||
|
@ -39,7 +39,7 @@ LL | const MY_STR_LENGTH_PTR: &MyStr = unsafe { mem::transmute((&42u8, &3)) };
|
|||
= 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-wide-ptr.rs:48:1
|
||||
--> $DIR/ub-wide-ptr.rs:49: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
|
||||
|
@ -50,7 +50,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/ub-wide-ptr.rs:52:1
|
||||
--> $DIR/ub-wide-ptr.rs:53: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
|
||||
|
@ -61,7 +61,7 @@ LL | const STR_NO_INIT: &str = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit:
|
|||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/ub-wide-ptr.rs:55:1
|
||||
--> $DIR/ub-wide-ptr.rs:56: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
|
||||
|
@ -72,13 +72,13 @@ LL | const MYSTR_NO_INIT: &MyStr = unsafe { mem::transmute::<&[_], _>(&[MaybeUni
|
|||
}
|
||||
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/ub-wide-ptr.rs:62:1
|
||||
--> $DIR/ub-wide-ptr.rs:63:1
|
||||
|
|
||||
LL | const SLICE_LENGTH_UNINIT: &[u8] = unsafe {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/ub-wide-ptr.rs:69:1
|
||||
--> $DIR/ub-wide-ptr.rs:70: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)
|
||||
|
@ -89,7 +89,7 @@ LL | const SLICE_TOO_LONG: &[u8] = unsafe { mem::transmute((&42u8, 999usize)) };
|
|||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/ub-wide-ptr.rs:72:1
|
||||
--> $DIR/ub-wide-ptr.rs:73: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
|
||||
|
@ -100,7 +100,7 @@ LL | const SLICE_TOO_LONG_OVERFLOW: &[u32] = unsafe { mem::transmute((&42u32, is
|
|||
}
|
||||
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/ub-wide-ptr.rs:75:1
|
||||
--> $DIR/ub-wide-ptr.rs:76:1
|
||||
|
|
||||
LL | const SLICE_LENGTH_PTR: &[u8] = unsafe { mem::transmute((&42u8, &3)) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
|
||||
|
@ -109,7 +109,7 @@ LL | const SLICE_LENGTH_PTR: &[u8] = unsafe { mem::transmute((&42u8, &3)) };
|
|||
= 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-wide-ptr.rs:78:1
|
||||
--> $DIR/ub-wide-ptr.rs:79: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)
|
||||
|
@ -120,7 +120,7 @@ LL | const SLICE_TOO_LONG_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, 999us
|
|||
}
|
||||
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/ub-wide-ptr.rs:81:1
|
||||
--> $DIR/ub-wide-ptr.rs:82:1
|
||||
|
|
||||
LL | const SLICE_LENGTH_PTR_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, &3)) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
|
||||
|
@ -129,7 +129,7 @@ LL | const SLICE_LENGTH_PTR_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, &3)
|
|||
= 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-wide-ptr.rs:85:1
|
||||
--> $DIR/ub-wide-ptr.rs:86:1
|
||||
|
|
||||
LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }];
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered 0x03, but expected a boolean
|
||||
|
@ -140,13 +140,13 @@ LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }];
|
|||
}
|
||||
|
||||
note: erroneous constant encountered
|
||||
--> $DIR/ub-wide-ptr.rs:85:40
|
||||
--> $DIR/ub-wide-ptr.rs:86:40
|
||||
|
|
||||
LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }];
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/ub-wide-ptr.rs:92:1
|
||||
--> $DIR/ub-wide-ptr.rs:93: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
|
||||
|
@ -157,13 +157,13 @@ LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3
|
|||
}
|
||||
|
||||
note: erroneous constant encountered
|
||||
--> $DIR/ub-wide-ptr.rs:92:42
|
||||
--> $DIR/ub-wide-ptr.rs:93:42
|
||||
|
|
||||
LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/ub-wide-ptr.rs:96:1
|
||||
--> $DIR/ub-wide-ptr.rs:97: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
|
||||
|
@ -174,19 +174,19 @@ LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::tran
|
|||
}
|
||||
|
||||
note: erroneous constant encountered
|
||||
--> $DIR/ub-wide-ptr.rs:96:42
|
||||
--> $DIR/ub-wide-ptr.rs:97:42
|
||||
|
|
||||
LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/ub-wide-ptr.rs:104:1
|
||||
--> $DIR/ub-wide-ptr.rs:105:1
|
||||
|
|
||||
LL | const RAW_SLICE_LENGTH_UNINIT: *const [u8] = unsafe {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/ub-wide-ptr.rs:113:1
|
||||
--> $DIR/ub-wide-ptr.rs:114:1
|
||||
|
|
||||
LL | const TRAIT_OBJ_SHORT_VTABLE_1: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u8))) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC12<imm>, but expected a vtable pointer
|
||||
|
@ -197,7 +197,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/ub-wide-ptr.rs:117:1
|
||||
--> $DIR/ub-wide-ptr.rs:118:1
|
||||
|
|
||||
LL | const TRAIT_OBJ_SHORT_VTABLE_2: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u64))) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC14<imm>, but expected a vtable pointer
|
||||
|
@ -208,7 +208,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/ub-wide-ptr.rs:121:1
|
||||
--> $DIR/ub-wide-ptr.rs:122: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
|
||||
|
@ -219,7 +219,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/ub-wide-ptr.rs:124:1
|
||||
--> $DIR/ub-wide-ptr.rs:125:1
|
||||
|
|
||||
LL | const TRAIT_OBJ_UNALIGNED_VTABLE: &dyn Trait = unsafe { mem::transmute((&92u8, &[0u8; 128])) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC17<imm>, but expected a vtable pointer
|
||||
|
@ -230,7 +230,7 @@ LL | const TRAIT_OBJ_UNALIGNED_VTABLE: &dyn Trait = unsafe { mem::transmute((&92
|
|||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/ub-wide-ptr.rs:127:1
|
||||
--> $DIR/ub-wide-ptr.rs:128:1
|
||||
|
|
||||
LL | const TRAIT_OBJ_BAD_DROP_FN_NULL: &dyn Trait = unsafe { mem::transmute((&92u8, &[0usize; 8])) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC19<imm>, but expected a vtable pointer
|
||||
|
@ -241,7 +241,7 @@ LL | const TRAIT_OBJ_BAD_DROP_FN_NULL: &dyn Trait = unsafe { mem::transmute((&92
|
|||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/ub-wide-ptr.rs:130:1
|
||||
--> $DIR/ub-wide-ptr.rs:131:1
|
||||
|
|
||||
LL | const TRAIT_OBJ_BAD_DROP_FN_INT: &dyn Trait = unsafe { mem::transmute((&92u8, &[1usize; 8])) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC21<imm>, but expected a vtable pointer
|
||||
|
@ -252,7 +252,7 @@ LL | const TRAIT_OBJ_BAD_DROP_FN_INT: &dyn Trait = unsafe { mem::transmute((&92u
|
|||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/ub-wide-ptr.rs:133:1
|
||||
--> $DIR/ub-wide-ptr.rs:134: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 ALLOC23<imm>, but expected a vtable pointer
|
||||
|
@ -263,7 +263,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/ub-wide-ptr.rs:138:1
|
||||
--> $DIR/ub-wide-ptr.rs:139: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
|
||||
|
@ -274,7 +274,7 @@ LL | const TRAIT_OBJ_CONTENT_INVALID: &dyn Trait = unsafe { mem::transmute::<_,
|
|||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/ub-wide-ptr.rs:143:1
|
||||
--> $DIR/ub-wide-ptr.rs:144: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
|
||||
|
@ -285,7 +285,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/ub-wide-ptr.rs:145:1
|
||||
--> $DIR/ub-wide-ptr.rs:146:1
|
||||
|
|
||||
LL | const RAW_TRAIT_OBJ_VTABLE_INVALID: *const dyn Trait = unsafe { mem::transmute((&92u8, &3u64)) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC28<imm>, but expected a vtable pointer
|
||||
|
@ -296,7 +296,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/ub-wide-ptr.rs:150:1
|
||||
--> $DIR/ub-wide-ptr.rs:153:1
|
||||
|
|
||||
LL | static mut RAW_TRAIT_OBJ_VTABLE_NULL_THROUGH_REF: *const dyn Trait = unsafe {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered null pointer, but expected a vtable pointer
|
||||
|
@ -307,7 +307,7 @@ LL | static mut RAW_TRAIT_OBJ_VTABLE_NULL_THROUGH_REF: *const dyn Trait = unsafe
|
|||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/ub-wide-ptr.rs:154:1
|
||||
--> $DIR/ub-wide-ptr.rs:157:1
|
||||
|
|
||||
LL | static mut RAW_TRAIT_OBJ_VTABLE_INVALID_THROUGH_REF: *const dyn Trait = unsafe {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC31<imm>, but expected a vtable pointer
|
||||
|
|
|
@ -33,6 +33,11 @@ const fn bazz(foo: &mut Foo) -> usize {
|
|||
// Empty slices get promoted so this passes the static checks.
|
||||
// Make sure it also passes the dynamic checks.
|
||||
static MUTABLE_REFERENCE_HOLDER: Mutex<&mut [u8]> = Mutex::new(&mut []);
|
||||
// This variant with a non-empty slice also seems entirely reasonable.
|
||||
static MUTABLE_REFERENCE_HOLDER2: Mutex<&mut [u8]> = unsafe {
|
||||
static mut FOO: [u8; 1] = [42]; // a private static that we are sure nobody else will reference
|
||||
Mutex::new(&mut *std::ptr::addr_of_mut!(FOO))
|
||||
};
|
||||
|
||||
fn main() {
|
||||
let _: [(); foo().bar()] = [(); 1];
|
||||
|
|
|
@ -18,9 +18,7 @@ const fn helper() -> Option<&'static mut i32> { unsafe {
|
|||
Some(&mut *std::ptr::addr_of_mut!(BUFFER))
|
||||
} }
|
||||
const MUT: Option<&mut i32> = helper(); //~ ERROR it is undefined behavior to use this value
|
||||
//~^ encountered mutable reference
|
||||
static MUT_STATIC: Option<&mut i32> = helper(); //~ ERROR it is undefined behavior to use this value
|
||||
//~^ encountered mutable reference
|
||||
//~^ encountered reference to mutable
|
||||
|
||||
const fn helper_int2ptr() -> Option<&'static mut i32> { unsafe {
|
||||
// Undefined behaviour (integer as pointer), who doesn't love tests like this.
|
||||
|
@ -38,11 +36,9 @@ const fn helper_dangling() -> Option<&'static mut i32> { unsafe {
|
|||
const DANGLING: Option<&mut i32> = helper_dangling(); //~ ERROR encountered dangling pointer
|
||||
static DANGLING_STATIC: Option<&mut i32> = helper_dangling(); //~ ERROR encountered dangling pointer
|
||||
|
||||
// Variant of the real-world case in <https://github.com/rust-lang/rust/issues/120450>.
|
||||
// Maybe we should allow this in the future (then the rest should move to `const_mut_refs.rs`),
|
||||
// but for now we reject it.
|
||||
// These are fine! Just statics pointing to mutable statics, nothing fundamentally wrong with this.
|
||||
static MUT_STATIC: Option<&mut i32> = helper();
|
||||
static mut MUT_ARRAY: &mut [u8] = &mut [42];
|
||||
static MUTEX: Mutex<&mut [u8]> = Mutex::new(unsafe { &mut *MUT_ARRAY }); //~ ERROR it is undefined behavior to use this value
|
||||
//~^ encountered mutable reference
|
||||
static MUTEX: Mutex<&mut [u8]> = Mutex::new(unsafe { &mut *MUT_ARRAY });
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -2,7 +2,7 @@ error[E0080]: it is undefined behavior to use this value
|
|||
--> $DIR/mut_ref_in_final_dynamic_check.rs:20:1
|
||||
|
|
||||
LL | const MUT: Option<&mut i32> = helper();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-variant(Some)>.0: encountered mutable reference in a `const` or `static`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-variant(Some)>.0: encountered reference to mutable memory in `const`
|
||||
|
|
||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
||||
= note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
|
||||
|
@ -10,18 +10,7 @@ LL | const MUT: Option<&mut i32> = helper();
|
|||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/mut_ref_in_final_dynamic_check.rs:22:1
|
||||
|
|
||||
LL | static MUT_STATIC: Option<&mut i32> = helper();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-variant(Some)>.0: encountered mutable reference in a `const` or `static`
|
||||
|
|
||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
||||
= note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
|
||||
HEX_DUMP
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/mut_ref_in_final_dynamic_check.rs:29:1
|
||||
--> $DIR/mut_ref_in_final_dynamic_check.rs:27:1
|
||||
|
|
||||
LL | const INT2PTR: Option<&mut i32> = helper_int2ptr();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-variant(Some)>.0: encountered a dangling reference (0x2a[noalloc] has no provenance)
|
||||
|
@ -32,7 +21,7 @@ LL | const INT2PTR: Option<&mut i32> = helper_int2ptr();
|
|||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/mut_ref_in_final_dynamic_check.rs:31:1
|
||||
--> $DIR/mut_ref_in_final_dynamic_check.rs:29:1
|
||||
|
|
||||
LL | static INT2PTR_STATIC: Option<&mut i32> = helper_int2ptr();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-variant(Some)>.0: encountered a dangling reference (0x2a[noalloc] has no provenance)
|
||||
|
@ -43,28 +32,17 @@ LL | static INT2PTR_STATIC: Option<&mut i32> = helper_int2ptr();
|
|||
}
|
||||
|
||||
error: encountered dangling pointer in final value of constant
|
||||
--> $DIR/mut_ref_in_final_dynamic_check.rs:38:1
|
||||
--> $DIR/mut_ref_in_final_dynamic_check.rs:36:1
|
||||
|
|
||||
LL | const DANGLING: Option<&mut i32> = helper_dangling();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: encountered dangling pointer in final value of static
|
||||
--> $DIR/mut_ref_in_final_dynamic_check.rs:39:1
|
||||
--> $DIR/mut_ref_in_final_dynamic_check.rs:37:1
|
||||
|
|
||||
LL | static DANGLING_STATIC: Option<&mut i32> = helper_dangling();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/mut_ref_in_final_dynamic_check.rs:45:1
|
||||
|
|
||||
LL | static MUTEX: Mutex<&mut [u8]> = Mutex::new(unsafe { &mut *MUT_ARRAY });
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .data.value: encountered mutable reference in a `const` or `static`
|
||||
|
|
||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
||||
= note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
|
||||
HEX_DUMP
|
||||
}
|
||||
|
||||
error: aborting due to 7 previous errors
|
||||
error: aborting due to 5 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0080`.
|
||||
|
|
|
@ -1,180 +0,0 @@
|
|||
error: encountered mutable pointer in final value of constant
|
||||
--> $DIR/mutable_references_err.rs:17:1
|
||||
|
|
||||
LL | const MUH: Meh = Meh {
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
error: encountered mutable pointer in final value of constant
|
||||
--> $DIR/mutable_references_err.rs:28:1
|
||||
|
|
||||
LL | const SNEAKY: &dyn Sync = &Synced { x: UnsafeCell::new(42) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/mutable_references_err.rs:33:1
|
||||
|
|
||||
LL | const SUBTLE: &mut i32 = unsafe { &mut FOO };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered mutable reference in a `const` or `static`
|
||||
|
|
||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
||||
= note: the raw bytes of the constant (size: 8, align: 8) {
|
||||
╾ALLOC0╼ │ ╾──────╼
|
||||
}
|
||||
|
||||
error: encountered mutable pointer in final value of constant
|
||||
--> $DIR/mutable_references_err.rs:36:1
|
||||
|
|
||||
LL | const BLUNT: &mut i32 = &mut 42;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/mutable_references_err.rs:41:1
|
||||
|
|
||||
LL | static mut MUT_TO_READONLY: &mut i32 = unsafe { &mut *(&READONLY as *const _ as *mut _) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered mutable reference or box pointing to read-only memory
|
||||
|
|
||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
||||
= note: the raw bytes of the constant (size: 8, align: 8) {
|
||||
╾ALLOC1<imm>╼ │ ╾──────╼
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/mutable_references_err.rs:48:1
|
||||
|
|
||||
LL | const POINTS_TO_MUTABLE1: &i32 = unsafe { &MUTABLE };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered reference to mutable memory in `const`
|
||||
|
|
||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
||||
= note: the raw bytes of the constant (size: 8, align: 8) {
|
||||
╾ALLOC2<imm>╼ │ ╾──────╼
|
||||
}
|
||||
|
||||
note: erroneous constant encountered
|
||||
--> $DIR/mutable_references_err.rs:50:34
|
||||
|
|
||||
LL | const READS_FROM_MUTABLE: i32 = *POINTS_TO_MUTABLE1;
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/mutable_references_err.rs:52:43
|
||||
|
|
||||
LL | const POINTS_TO_MUTABLE2: &i32 = unsafe { &*MUTABLE_REF };
|
||||
| ^^^^^^^^^^^^^ constant accesses mutable global memory
|
||||
|
||||
error: encountered mutable pointer in final value of constant
|
||||
--> $DIR/mutable_references_err.rs:56:1
|
||||
|
|
||||
LL | const POINTS_TO_MUTABLE_INNER: *const i32 = &mut 42 as *mut _ as *const _;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: encountered mutable pointer in final value of constant
|
||||
--> $DIR/mutable_references_err.rs:58:1
|
||||
|
|
||||
LL | const POINTS_TO_MUTABLE_INNER2: *const i32 = &mut 42 as *const _;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: encountered mutable pointer in final value of constant
|
||||
--> $DIR/mutable_references_err.rs:60:1
|
||||
|
|
||||
LL | const INTERIOR_MUTABLE_BEHIND_RAW: *mut i32 = &UnsafeCell::new(42) as *const _ as *mut _;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: encountered mutable pointer in final value of constant
|
||||
--> $DIR/mutable_references_err.rs:72:1
|
||||
|
|
||||
LL | const RAW_SYNC: SyncPtr<AtomicI32> = SyncPtr { x: &AtomicI32::new(42) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: encountered mutable pointer in final value of constant
|
||||
--> $DIR/mutable_references_err.rs:74:1
|
||||
|
|
||||
LL | const RAW_MUT_CAST: SyncPtr<i32> = SyncPtr { x: &mut 42 as *mut _ as *const _ };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: encountered mutable pointer in final value of constant
|
||||
--> $DIR/mutable_references_err.rs:76:1
|
||||
|
|
||||
LL | const RAW_MUT_COERCE: SyncPtr<i32> = SyncPtr { x: &mut 0 };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: skipping const checks
|
||||
|
|
||||
help: skipping check that does not even have a feature gate
|
||||
--> $DIR/mutable_references_err.rs:19:8
|
||||
|
|
||||
LL | x: &UnsafeCell::new(42),
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
help: skipping check that does not even have a feature gate
|
||||
--> $DIR/mutable_references_err.rs:28:27
|
||||
|
|
||||
LL | const SNEAKY: &dyn Sync = &Synced { x: UnsafeCell::new(42) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
help: skipping check for `const_refs_to_static` feature
|
||||
--> $DIR/mutable_references_err.rs:33:40
|
||||
|
|
||||
LL | const SUBTLE: &mut i32 = unsafe { &mut FOO };
|
||||
| ^^^
|
||||
help: skipping check for `const_mut_refs` feature
|
||||
--> $DIR/mutable_references_err.rs:33:35
|
||||
|
|
||||
LL | const SUBTLE: &mut i32 = unsafe { &mut FOO };
|
||||
| ^^^^^^^^
|
||||
help: skipping check that does not even have a feature gate
|
||||
--> $DIR/mutable_references_err.rs:36:25
|
||||
|
|
||||
LL | const BLUNT: &mut i32 = &mut 42;
|
||||
| ^^^^^^^
|
||||
help: skipping check for `const_mut_refs` feature
|
||||
--> $DIR/mutable_references_err.rs:41:49
|
||||
|
|
||||
LL | static mut MUT_TO_READONLY: &mut i32 = unsafe { &mut *(&READONLY as *const _ as *mut _) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
help: skipping check for `const_mut_refs` feature
|
||||
--> $DIR/mutable_references_err.rs:41:49
|
||||
|
|
||||
LL | static mut MUT_TO_READONLY: &mut i32 = unsafe { &mut *(&READONLY as *const _ as *mut _) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
help: skipping check for `const_refs_to_static` feature
|
||||
--> $DIR/mutable_references_err.rs:48:44
|
||||
|
|
||||
LL | const POINTS_TO_MUTABLE1: &i32 = unsafe { &MUTABLE };
|
||||
| ^^^^^^^
|
||||
help: skipping check for `const_refs_to_static` feature
|
||||
--> $DIR/mutable_references_err.rs:52:45
|
||||
|
|
||||
LL | const POINTS_TO_MUTABLE2: &i32 = unsafe { &*MUTABLE_REF };
|
||||
| ^^^^^^^^^^^
|
||||
help: skipping check that does not even have a feature gate
|
||||
--> $DIR/mutable_references_err.rs:56:45
|
||||
|
|
||||
LL | const POINTS_TO_MUTABLE_INNER: *const i32 = &mut 42 as *mut _ as *const _;
|
||||
| ^^^^^^^
|
||||
help: skipping check that does not even have a feature gate
|
||||
--> $DIR/mutable_references_err.rs:58:46
|
||||
|
|
||||
LL | const POINTS_TO_MUTABLE_INNER2: *const i32 = &mut 42 as *const _;
|
||||
| ^^^^^^^
|
||||
help: skipping check that does not even have a feature gate
|
||||
--> $DIR/mutable_references_err.rs:60:47
|
||||
|
|
||||
LL | const INTERIOR_MUTABLE_BEHIND_RAW: *mut i32 = &UnsafeCell::new(42) as *const _ as *mut _;
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
help: skipping check that does not even have a feature gate
|
||||
--> $DIR/mutable_references_err.rs:72:51
|
||||
|
|
||||
LL | const RAW_SYNC: SyncPtr<AtomicI32> = SyncPtr { x: &AtomicI32::new(42) };
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
help: skipping check that does not even have a feature gate
|
||||
--> $DIR/mutable_references_err.rs:74:49
|
||||
|
|
||||
LL | const RAW_MUT_CAST: SyncPtr<i32> = SyncPtr { x: &mut 42 as *mut _ as *const _ };
|
||||
| ^^^^^^^
|
||||
help: skipping check that does not even have a feature gate
|
||||
--> $DIR/mutable_references_err.rs:76:51
|
||||
|
|
||||
LL | const RAW_MUT_COERCE: SyncPtr<i32> = SyncPtr { x: &mut 0 };
|
||||
| ^^^^^^
|
||||
|
||||
error: aborting due to 13 previous errors; 1 warning emitted
|
||||
|
||||
For more information about this error, try `rustc --explain E0080`.
|
|
@ -1,5 +1,6 @@
|
|||
//@ stderr-per-bitwidth
|
||||
//@ compile-flags: -Zunleash-the-miri-inside-of-you
|
||||
//@ normalize-stderr-test "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)"
|
||||
//@ normalize-stderr-test "([0-9a-f][0-9a-f] |╾─*ALLOC[0-9]+(\+[a-z0-9]+)?(<imm>)?─*╼ )+ *│.*" -> "HEX_DUMP"
|
||||
#![allow(invalid_reference_casting, static_mut_refs)]
|
||||
|
||||
use std::cell::UnsafeCell;
|
||||
|
|
|
@ -1,98 +1,98 @@
|
|||
error: encountered mutable pointer in final value of constant
|
||||
--> $DIR/mutable_references_err.rs:17:1
|
||||
--> $DIR/mutable_references_err.rs:18:1
|
||||
|
|
||||
LL | const MUH: Meh = Meh {
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
error: encountered mutable pointer in final value of constant
|
||||
--> $DIR/mutable_references_err.rs:28:1
|
||||
--> $DIR/mutable_references_err.rs:29:1
|
||||
|
|
||||
LL | const SNEAKY: &dyn Sync = &Synced { x: UnsafeCell::new(42) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/mutable_references_err.rs:33:1
|
||||
--> $DIR/mutable_references_err.rs:34:1
|
||||
|
|
||||
LL | const SUBTLE: &mut i32 = unsafe { &mut FOO };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered mutable reference in a `const` or `static`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered reference to mutable memory in `const`
|
||||
|
|
||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
||||
= note: the raw bytes of the constant (size: 4, align: 4) {
|
||||
╾ALLOC0╼ │ ╾──╼
|
||||
= note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
|
||||
HEX_DUMP
|
||||
}
|
||||
|
||||
error: encountered mutable pointer in final value of constant
|
||||
--> $DIR/mutable_references_err.rs:36:1
|
||||
--> $DIR/mutable_references_err.rs:37:1
|
||||
|
|
||||
LL | const BLUNT: &mut i32 = &mut 42;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/mutable_references_err.rs:41:1
|
||||
--> $DIR/mutable_references_err.rs:42:1
|
||||
|
|
||||
LL | static mut MUT_TO_READONLY: &mut i32 = unsafe { &mut *(&READONLY as *const _ as *mut _) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered mutable reference or box pointing to read-only memory
|
||||
|
|
||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
||||
= note: the raw bytes of the constant (size: 4, align: 4) {
|
||||
╾ALLOC1<imm>╼ │ ╾──╼
|
||||
= note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
|
||||
HEX_DUMP
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/mutable_references_err.rs:48:1
|
||||
--> $DIR/mutable_references_err.rs:49:1
|
||||
|
|
||||
LL | const POINTS_TO_MUTABLE1: &i32 = unsafe { &MUTABLE };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered reference to mutable memory in `const`
|
||||
|
|
||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
||||
= note: the raw bytes of the constant (size: 4, align: 4) {
|
||||
╾ALLOC2<imm>╼ │ ╾──╼
|
||||
= note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
|
||||
HEX_DUMP
|
||||
}
|
||||
|
||||
note: erroneous constant encountered
|
||||
--> $DIR/mutable_references_err.rs:50:34
|
||||
--> $DIR/mutable_references_err.rs:51:34
|
||||
|
|
||||
LL | const READS_FROM_MUTABLE: i32 = *POINTS_TO_MUTABLE1;
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/mutable_references_err.rs:52:43
|
||||
--> $DIR/mutable_references_err.rs:53:43
|
||||
|
|
||||
LL | const POINTS_TO_MUTABLE2: &i32 = unsafe { &*MUTABLE_REF };
|
||||
| ^^^^^^^^^^^^^ constant accesses mutable global memory
|
||||
|
||||
error: encountered mutable pointer in final value of constant
|
||||
--> $DIR/mutable_references_err.rs:56:1
|
||||
--> $DIR/mutable_references_err.rs:57:1
|
||||
|
|
||||
LL | const POINTS_TO_MUTABLE_INNER: *const i32 = &mut 42 as *mut _ as *const _;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: encountered mutable pointer in final value of constant
|
||||
--> $DIR/mutable_references_err.rs:58:1
|
||||
--> $DIR/mutable_references_err.rs:59:1
|
||||
|
|
||||
LL | const POINTS_TO_MUTABLE_INNER2: *const i32 = &mut 42 as *const _;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: encountered mutable pointer in final value of constant
|
||||
--> $DIR/mutable_references_err.rs:60:1
|
||||
--> $DIR/mutable_references_err.rs:61:1
|
||||
|
|
||||
LL | const INTERIOR_MUTABLE_BEHIND_RAW: *mut i32 = &UnsafeCell::new(42) as *const _ as *mut _;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: encountered mutable pointer in final value of constant
|
||||
--> $DIR/mutable_references_err.rs:72:1
|
||||
--> $DIR/mutable_references_err.rs:73:1
|
||||
|
|
||||
LL | const RAW_SYNC: SyncPtr<AtomicI32> = SyncPtr { x: &AtomicI32::new(42) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: encountered mutable pointer in final value of constant
|
||||
--> $DIR/mutable_references_err.rs:74:1
|
||||
--> $DIR/mutable_references_err.rs:75:1
|
||||
|
|
||||
LL | const RAW_MUT_CAST: SyncPtr<i32> = SyncPtr { x: &mut 42 as *mut _ as *const _ };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: encountered mutable pointer in final value of constant
|
||||
--> $DIR/mutable_references_err.rs:76:1
|
||||
--> $DIR/mutable_references_err.rs:77:1
|
||||
|
|
||||
LL | const RAW_MUT_COERCE: SyncPtr<i32> = SyncPtr { x: &mut 0 };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -100,77 +100,77 @@ LL | const RAW_MUT_COERCE: SyncPtr<i32> = SyncPtr { x: &mut 0 };
|
|||
warning: skipping const checks
|
||||
|
|
||||
help: skipping check that does not even have a feature gate
|
||||
--> $DIR/mutable_references_err.rs:19:8
|
||||
--> $DIR/mutable_references_err.rs:20:8
|
||||
|
|
||||
LL | x: &UnsafeCell::new(42),
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
help: skipping check that does not even have a feature gate
|
||||
--> $DIR/mutable_references_err.rs:28:27
|
||||
--> $DIR/mutable_references_err.rs:29:27
|
||||
|
|
||||
LL | const SNEAKY: &dyn Sync = &Synced { x: UnsafeCell::new(42) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
help: skipping check for `const_refs_to_static` feature
|
||||
--> $DIR/mutable_references_err.rs:33:40
|
||||
--> $DIR/mutable_references_err.rs:34:40
|
||||
|
|
||||
LL | const SUBTLE: &mut i32 = unsafe { &mut FOO };
|
||||
| ^^^
|
||||
help: skipping check for `const_mut_refs` feature
|
||||
--> $DIR/mutable_references_err.rs:33:35
|
||||
--> $DIR/mutable_references_err.rs:34:35
|
||||
|
|
||||
LL | const SUBTLE: &mut i32 = unsafe { &mut FOO };
|
||||
| ^^^^^^^^
|
||||
help: skipping check that does not even have a feature gate
|
||||
--> $DIR/mutable_references_err.rs:36:25
|
||||
--> $DIR/mutable_references_err.rs:37:25
|
||||
|
|
||||
LL | const BLUNT: &mut i32 = &mut 42;
|
||||
| ^^^^^^^
|
||||
help: skipping check for `const_mut_refs` feature
|
||||
--> $DIR/mutable_references_err.rs:41:49
|
||||
--> $DIR/mutable_references_err.rs:42:49
|
||||
|
|
||||
LL | static mut MUT_TO_READONLY: &mut i32 = unsafe { &mut *(&READONLY as *const _ as *mut _) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
help: skipping check for `const_mut_refs` feature
|
||||
--> $DIR/mutable_references_err.rs:41:49
|
||||
--> $DIR/mutable_references_err.rs:42:49
|
||||
|
|
||||
LL | static mut MUT_TO_READONLY: &mut i32 = unsafe { &mut *(&READONLY as *const _ as *mut _) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
help: skipping check for `const_refs_to_static` feature
|
||||
--> $DIR/mutable_references_err.rs:48:44
|
||||
--> $DIR/mutable_references_err.rs:49:44
|
||||
|
|
||||
LL | const POINTS_TO_MUTABLE1: &i32 = unsafe { &MUTABLE };
|
||||
| ^^^^^^^
|
||||
help: skipping check for `const_refs_to_static` feature
|
||||
--> $DIR/mutable_references_err.rs:52:45
|
||||
--> $DIR/mutable_references_err.rs:53:45
|
||||
|
|
||||
LL | const POINTS_TO_MUTABLE2: &i32 = unsafe { &*MUTABLE_REF };
|
||||
| ^^^^^^^^^^^
|
||||
help: skipping check that does not even have a feature gate
|
||||
--> $DIR/mutable_references_err.rs:56:45
|
||||
--> $DIR/mutable_references_err.rs:57:45
|
||||
|
|
||||
LL | const POINTS_TO_MUTABLE_INNER: *const i32 = &mut 42 as *mut _ as *const _;
|
||||
| ^^^^^^^
|
||||
help: skipping check that does not even have a feature gate
|
||||
--> $DIR/mutable_references_err.rs:58:46
|
||||
--> $DIR/mutable_references_err.rs:59:46
|
||||
|
|
||||
LL | const POINTS_TO_MUTABLE_INNER2: *const i32 = &mut 42 as *const _;
|
||||
| ^^^^^^^
|
||||
help: skipping check that does not even have a feature gate
|
||||
--> $DIR/mutable_references_err.rs:60:47
|
||||
--> $DIR/mutable_references_err.rs:61:47
|
||||
|
|
||||
LL | const INTERIOR_MUTABLE_BEHIND_RAW: *mut i32 = &UnsafeCell::new(42) as *const _ as *mut _;
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
help: skipping check that does not even have a feature gate
|
||||
--> $DIR/mutable_references_err.rs:72:51
|
||||
--> $DIR/mutable_references_err.rs:73:51
|
||||
|
|
||||
LL | const RAW_SYNC: SyncPtr<AtomicI32> = SyncPtr { x: &AtomicI32::new(42) };
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
help: skipping check that does not even have a feature gate
|
||||
--> $DIR/mutable_references_err.rs:74:49
|
||||
--> $DIR/mutable_references_err.rs:75:49
|
||||
|
|
||||
LL | const RAW_MUT_CAST: SyncPtr<i32> = SyncPtr { x: &mut 42 as *mut _ as *const _ };
|
||||
| ^^^^^^^
|
||||
help: skipping check that does not even have a feature gate
|
||||
--> $DIR/mutable_references_err.rs:76:51
|
||||
--> $DIR/mutable_references_err.rs:77:51
|
||||
|
|
||||
LL | const RAW_MUT_COERCE: SyncPtr<i32> = SyncPtr { x: &mut 0 };
|
||||
| ^^^^^^
|
|
@ -15,8 +15,4 @@ static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR cannot borrow immutable
|
|||
static CONST_REF: &'static mut i32 = &mut C; //~ ERROR mutable references are not allowed
|
||||
//~| WARN taking a mutable
|
||||
|
||||
static STATIC_MUT_REF: &'static mut i32 = unsafe { &mut M };
|
||||
//~^ WARN mutable reference to mutable static is discouraged [static_mut_refs]
|
||||
//~| ERROR undefined behavior
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -1,18 +1,3 @@
|
|||
warning: creating a mutable reference to mutable static is discouraged
|
||||
--> $DIR/E0017.rs:18:52
|
||||
|
|
||||
LL | static STATIC_MUT_REF: &'static mut i32 = unsafe { &mut M };
|
||||
| ^^^^^^ mutable reference to mutable static
|
||||
|
|
||||
= note: for more information, see issue #114447 <https://github.com/rust-lang/rust/issues/114447>
|
||||
= note: this will be a hard error in the 2024 edition
|
||||
= note: this mutable reference has lifetime `'static`, but if the static gets accessed (read or written) by any other means, or any other reference is created, then any further use of this mutable reference is Undefined Behavior
|
||||
= note: `#[warn(static_mut_refs)]` on by default
|
||||
help: use `addr_of_mut!` instead to create a raw pointer
|
||||
|
|
||||
LL | static STATIC_MUT_REF: &'static mut i32 = unsafe { addr_of_mut!(M) };
|
||||
| ~~~~~~~~~~~~~~~
|
||||
|
||||
warning: taking a mutable reference to a `const` item
|
||||
--> $DIR/E0017.rs:10:30
|
||||
|
|
||||
|
@ -60,18 +45,7 @@ error[E0764]: mutable references are not allowed in the final value of statics
|
|||
LL | static CONST_REF: &'static mut i32 = &mut C;
|
||||
| ^^^^^^
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/E0017.rs:18:1
|
||||
|
|
||||
LL | static STATIC_MUT_REF: &'static mut i32 = unsafe { &mut M };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered mutable reference in a `const` or `static`
|
||||
|
|
||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
|
||||
= note: the raw bytes of the constant {
|
||||
╾ALLOC0╼
|
||||
}
|
||||
error: aborting due to 3 previous errors; 2 warnings emitted
|
||||
|
||||
error: aborting due to 4 previous errors; 3 warnings emitted
|
||||
|
||||
Some errors have detailed explanations: E0080, E0596, E0764.
|
||||
For more information about an error, try `rustc --explain E0080`.
|
||||
Some errors have detailed explanations: E0596, E0764.
|
||||
For more information about an error, try `rustc --explain E0596`.
|
||||
|
|
|
@ -2,14 +2,22 @@
|
|||
|
||||
#![feature(lazy_type_alias)]
|
||||
#![allow(incomplete_features)]
|
||||
#![crate_type = "lib"]
|
||||
|
||||
// Check that we *reject* leading where-clauses on lazy type aliases.
|
||||
|
||||
type Alias<T>
|
||||
pub type Leading0<T>
|
||||
|
||||
= T where String: From<T>;
|
||||
//~^^^ ERROR where clauses are not allowed before the type for type aliases
|
||||
|
||||
fn main() {
|
||||
let _: Alias<&str>;
|
||||
}
|
||||
pub type Leading1<T, U>
|
||||
|
||||
= (T, U)
|
||||
where
|
||||
U: Copy, String: From<T>;
|
||||
|
||||
pub type EmptyLeading0 = () where;
|
||||
//~^ ERROR where clauses are not allowed before the type for type aliases
|
||||
|
||||
pub type EmptyLeading1<T> = T where T: Copy;
|
||||
//~^ ERROR where clauses are not allowed before the type for type aliases
|
||||
|
|
|
@ -2,15 +2,24 @@
|
|||
|
||||
#![feature(lazy_type_alias)]
|
||||
#![allow(incomplete_features)]
|
||||
#![crate_type = "lib"]
|
||||
|
||||
// Check that we *reject* leading where-clauses on lazy type aliases.
|
||||
|
||||
type Alias<T>
|
||||
where
|
||||
pub type Leading0<T>
|
||||
where //~ ERROR where clauses are not allowed before the type for type aliases
|
||||
String: From<T>,
|
||||
= T;
|
||||
//~^^^ ERROR where clauses are not allowed before the type for type aliases
|
||||
|
||||
fn main() {
|
||||
let _: Alias<&str>;
|
||||
}
|
||||
pub type Leading1<T, U>
|
||||
where //~ ERROR where clauses are not allowed before the type for type aliases
|
||||
String: From<T>,
|
||||
= (T, U)
|
||||
where
|
||||
U: Copy;
|
||||
|
||||
pub type EmptyLeading0 where = ();
|
||||
//~^ ERROR where clauses are not allowed before the type for type aliases
|
||||
|
||||
pub type EmptyLeading1<T> where = T where T: Copy;
|
||||
//~^ ERROR where clauses are not allowed before the type for type aliases
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error: where clauses are not allowed before the type for type aliases
|
||||
--> $DIR/leading-where-clause.rs:9:1
|
||||
--> $DIR/leading-where-clause.rs:10:1
|
||||
|
|
||||
LL | / where
|
||||
LL | | String: From<T>,
|
||||
|
@ -12,5 +12,42 @@ LL +
|
|||
LL ~ = T where String: From<T>;
|
||||
|
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
error: where clauses are not allowed before the type for type aliases
|
||||
--> $DIR/leading-where-clause.rs:15:1
|
||||
|
|
||||
LL | / where
|
||||
LL | | String: From<T>,
|
||||
| |____________________^
|
||||
|
|
||||
= note: see issue #89122 <https://github.com/rust-lang/rust/issues/89122> for more information
|
||||
help: move it to the end of the type declaration
|
||||
|
|
||||
LL +
|
||||
LL | = (T, U)
|
||||
LL | where
|
||||
LL ~ U: Copy, String: From<T>;
|
||||
|
|
||||
|
||||
error: where clauses are not allowed before the type for type aliases
|
||||
--> $DIR/leading-where-clause.rs:21:24
|
||||
|
|
||||
LL | pub type EmptyLeading0 where = ();
|
||||
| ^^^^^
|
||||
|
|
||||
= note: see issue #89122 <https://github.com/rust-lang/rust/issues/89122> for more information
|
||||
help: move it to the end of the type declaration
|
||||
|
|
||||
LL - pub type EmptyLeading0 where = ();
|
||||
LL + pub type EmptyLeading0 = () where;
|
||||
|
|
||||
|
||||
error: where clauses are not allowed before the type for type aliases
|
||||
--> $DIR/leading-where-clause.rs:24:27
|
||||
|
|
||||
LL | pub type EmptyLeading1<T> where = T where T: Copy;
|
||||
| ^^^^^ help: remove this `where`
|
||||
|
|
||||
= note: see issue #89122 <https://github.com/rust-lang/rust/issues/89122> for more information
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
|
|
|
@ -13,41 +13,27 @@ mod assert {
|
|||
pub fn is_transmutable<
|
||||
Src,
|
||||
Dst,
|
||||
Context,
|
||||
const ASSUME: std::mem::Assume,
|
||||
>()
|
||||
where
|
||||
Dst: BikeshedIntrinsicFrom<
|
||||
Src,
|
||||
Context,
|
||||
ASSUME,
|
||||
>,
|
||||
{}
|
||||
}
|
||||
|
||||
fn direct() {
|
||||
struct Context;
|
||||
#[repr(C)] struct Src;
|
||||
#[repr(C)] struct Dst;
|
||||
|
||||
assert::is_transmutable::<Src, Dst, Context, { std::mem::Assume::NOTHING }>();
|
||||
assert::is_transmutable::<(), (), { std::mem::Assume::NOTHING }>();
|
||||
}
|
||||
|
||||
fn via_const() {
|
||||
struct Context;
|
||||
#[repr(C)] struct Src;
|
||||
#[repr(C)] struct Dst;
|
||||
|
||||
const FALSE: bool = false;
|
||||
|
||||
assert::is_transmutable::<Src, Dst, Context, { std::mem::Assume::NOTHING }>();
|
||||
assert::is_transmutable::<(), (), { std::mem::Assume::NOTHING }>();
|
||||
}
|
||||
|
||||
fn via_associated_const() {
|
||||
struct Context;
|
||||
#[repr(C)] struct Src;
|
||||
#[repr(C)] struct Dst;
|
||||
|
||||
trait Trait {
|
||||
const FALSE: bool = true;
|
||||
}
|
||||
|
@ -57,9 +43,8 @@ fn via_associated_const() {
|
|||
impl Trait for Ty {}
|
||||
|
||||
assert::is_transmutable::<
|
||||
Src,
|
||||
Dst,
|
||||
Context,
|
||||
(),
|
||||
(),
|
||||
{
|
||||
std::mem::Assume {
|
||||
alignment: {Ty::FALSE},
|
||||
|
|
|
@ -7,12 +7,11 @@
|
|||
|
||||
mod assert {
|
||||
use std::mem::{Assume, BikeshedIntrinsicFrom};
|
||||
pub struct Context;
|
||||
|
||||
pub fn array_like<T, E, const N: usize>()
|
||||
where
|
||||
T: BikeshedIntrinsicFrom<[E; N], Context, { Assume::SAFETY }>,
|
||||
[E; N]: BikeshedIntrinsicFrom<T, Context, { Assume::SAFETY }>
|
||||
T: BikeshedIntrinsicFrom<[E; N], { Assume::SAFETY }>,
|
||||
[E; N]: BikeshedIntrinsicFrom<T, { Assume::SAFETY }>
|
||||
{}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,11 +3,10 @@
|
|||
|
||||
mod assert {
|
||||
use std::mem::{Assume, BikeshedIntrinsicFrom};
|
||||
pub struct Context;
|
||||
|
||||
pub fn is_maybe_transmutable<Src, Dst>()
|
||||
where
|
||||
Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
Dst: BikeshedIntrinsicFrom<Src, {
|
||||
Assume {
|
||||
alignment: false,
|
||||
lifetimes: true,
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
error[E0277]: `&[u8; 0]` cannot be safely transmuted into `&[u16; 0]` in the defining scope of `assert::Context`
|
||||
--> $DIR/align-fail.rs:22:55
|
||||
error[E0277]: `&[u8; 0]` cannot be safely transmuted into `&[u16; 0]`
|
||||
--> $DIR/align-fail.rs:21:55
|
||||
|
|
||||
LL | ...tatic [u8; 0], &'static [u16; 0]>();
|
||||
| ^^^^^^^^^^^^^^^^^ The minimum alignment of `&[u8; 0]` (1) should be greater than that of `&[u16; 0]` (2)
|
||||
|
|
||||
note: required by a bound in `is_maybe_transmutable`
|
||||
--> $DIR/align-fail.rs:10:14
|
||||
--> $DIR/align-fail.rs:9:14
|
||||
|
|
||||
LL | pub fn is_maybe_transmutable<Src, Dst>()
|
||||
| --------------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume {
|
||||
LL | | alignment: false,
|
||||
|
|
|
@ -3,11 +3,10 @@
|
|||
|
||||
mod assert {
|
||||
use std::mem::{Assume, BikeshedIntrinsicFrom};
|
||||
pub struct Context;
|
||||
|
||||
pub fn is_maybe_transmutable<Src, Dst>()
|
||||
where
|
||||
Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
Dst: BikeshedIntrinsicFrom<Src, {
|
||||
Assume {
|
||||
alignment: false,
|
||||
lifetimes: false,
|
||||
|
|
|
@ -2,11 +2,10 @@
|
|||
#![feature(transmutability)]
|
||||
mod assert {
|
||||
use std::mem::BikeshedIntrinsicFrom;
|
||||
struct Context;
|
||||
|
||||
pub fn is_maybe_transmutable<Src, Dst>()
|
||||
where
|
||||
Dst: BikeshedIntrinsicFrom<Src, Context>,
|
||||
Dst: BikeshedIntrinsicFrom<Src>,
|
||||
{
|
||||
}
|
||||
}
|
|
@ -1,32 +1,32 @@
|
|||
error[E0277]: `()` cannot be safely transmuted into `ExplicitlyPadded` in the defining scope of `assert::Context`
|
||||
--> $DIR/issue-115402-overflow-size.rs:22:41
|
||||
error[E0277]: `()` cannot be safely transmuted into `ExplicitlyPadded`
|
||||
--> $DIR/huge-len.rs:21:41
|
||||
|
|
||||
LL | assert::is_maybe_transmutable::<(), ExplicitlyPadded>();
|
||||
| ^^^^^^^^^^^^^^^^ values of the type `ExplicitlyPadded` are too big for the current architecture
|
||||
|
|
||||
note: required by a bound in `is_maybe_transmutable`
|
||||
--> $DIR/issue-115402-overflow-size.rs:9:14
|
||||
--> $DIR/huge-len.rs:8:14
|
||||
|
|
||||
LL | pub fn is_maybe_transmutable<Src, Dst>()
|
||||
| --------------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context>,
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_maybe_transmutable`
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src>,
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_maybe_transmutable`
|
||||
|
||||
error[E0277]: `ExplicitlyPadded` cannot be safely transmuted into `()` in the defining scope of `assert::Context`
|
||||
--> $DIR/issue-115402-overflow-size.rs:25:55
|
||||
error[E0277]: `ExplicitlyPadded` cannot be safely transmuted into `()`
|
||||
--> $DIR/huge-len.rs:24:55
|
||||
|
|
||||
LL | assert::is_maybe_transmutable::<ExplicitlyPadded, ()>();
|
||||
| ^^ values of the type `ExplicitlyPadded` are too big for the current architecture
|
||||
|
|
||||
note: required by a bound in `is_maybe_transmutable`
|
||||
--> $DIR/issue-115402-overflow-size.rs:9:14
|
||||
--> $DIR/huge-len.rs:8:14
|
||||
|
|
||||
LL | pub fn is_maybe_transmutable<Src, Dst>()
|
||||
| --------------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context>,
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_maybe_transmutable`
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src>,
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_maybe_transmutable`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
|
@ -4,13 +4,11 @@
|
|||
|
||||
mod assert {
|
||||
use std::mem::{Assume, BikeshedIntrinsicFrom};
|
||||
pub struct Context;
|
||||
|
||||
pub fn is_maybe_transmutable<Src, Dst>()
|
||||
where
|
||||
Dst: BikeshedIntrinsicFrom<
|
||||
Src,
|
||||
Context,
|
||||
{ Assume { alignment: true, lifetimes: true, safety: true, validity: true } },
|
||||
>,
|
||||
{
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/issue-103783-array-length.rs:21:34
|
||||
--> $DIR/issue-103783-array-length.rs:19:34
|
||||
|
|
||||
LL | type NaughtyLenArray = [u32; 3.14159];
|
||||
| ^^^^^^^ expected `usize`, found floating-point number
|
||||
|
|
|
@ -7,11 +7,10 @@
|
|||
|
||||
mod assert {
|
||||
use std::mem::{Assume, BikeshedIntrinsicFrom};
|
||||
pub struct Context;
|
||||
|
||||
pub fn is_maybe_transmutable<Src, Dst>()
|
||||
where
|
||||
Dst: BikeshedIntrinsicFrom<Src, Context, { Assume::SAFETY.and(Assume::VALIDITY) }>
|
||||
Dst: BikeshedIntrinsicFrom<Src, { Assume::SAFETY.and(Assume::VALIDITY) }>
|
||||
{}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,11 +7,10 @@
|
|||
|
||||
mod assert {
|
||||
use std::mem::{Assume, BikeshedIntrinsicFrom};
|
||||
pub struct Context;
|
||||
|
||||
pub fn is_maybe_transmutable<Src, Dst>()
|
||||
where
|
||||
Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
Dst: BikeshedIntrinsicFrom<Src, {
|
||||
Assume::ALIGNMENT
|
||||
.and(Assume::LIFETIMES)
|
||||
.and(Assume::SAFETY)
|
||||
|
|
|
@ -6,11 +6,10 @@
|
|||
|
||||
mod assert {
|
||||
use std::mem::{Assume, BikeshedIntrinsicFrom};
|
||||
pub struct Context;
|
||||
|
||||
pub fn is_maybe_transmutable<Src, Dst>()
|
||||
where
|
||||
Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
Dst: BikeshedIntrinsicFrom<Src, {
|
||||
Assume::ALIGNMENT
|
||||
.and(Assume::LIFETIMES)
|
||||
.and(Assume::SAFETY)
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
error[E0277]: `[String; 0]` cannot be safely transmuted into `()` in the defining scope of `assert::Context`
|
||||
--> $DIR/should_require_well_defined_layout.rs:26:52
|
||||
error[E0277]: `[String; 0]` cannot be safely transmuted into `()`
|
||||
--> $DIR/should_require_well_defined_layout.rs:25:52
|
||||
|
|
||||
LL | assert::is_maybe_transmutable::<repr_rust, ()>();
|
||||
| ^^ `[String; 0]` does not have a well-specified layout
|
||||
|
|
||||
note: required by a bound in `is_maybe_transmutable`
|
||||
--> $DIR/should_require_well_defined_layout.rs:13:14
|
||||
--> $DIR/should_require_well_defined_layout.rs:12:14
|
||||
|
|
||||
LL | pub fn is_maybe_transmutable<Src, Dst>()
|
||||
| --------------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume::ALIGNMENT
|
||||
LL | | .and(Assume::LIFETIMES)
|
||||
|
@ -19,19 +19,19 @@ LL | | .and(Assume::VALIDITY)
|
|||
LL | | }>
|
||||
| |__________^ required by this bound in `is_maybe_transmutable`
|
||||
|
||||
error[E0277]: `u128` cannot be safely transmuted into `[String; 0]` in the defining scope of `assert::Context`
|
||||
--> $DIR/should_require_well_defined_layout.rs:27:47
|
||||
error[E0277]: `u128` cannot be safely transmuted into `[String; 0]`
|
||||
--> $DIR/should_require_well_defined_layout.rs:26:47
|
||||
|
|
||||
LL | assert::is_maybe_transmutable::<u128, repr_rust>();
|
||||
| ^^^^^^^^^ `[String; 0]` does not have a well-specified layout
|
||||
|
|
||||
note: required by a bound in `is_maybe_transmutable`
|
||||
--> $DIR/should_require_well_defined_layout.rs:13:14
|
||||
--> $DIR/should_require_well_defined_layout.rs:12:14
|
||||
|
|
||||
LL | pub fn is_maybe_transmutable<Src, Dst>()
|
||||
| --------------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume::ALIGNMENT
|
||||
LL | | .and(Assume::LIFETIMES)
|
||||
|
@ -40,19 +40,19 @@ LL | | .and(Assume::VALIDITY)
|
|||
LL | | }>
|
||||
| |__________^ required by this bound in `is_maybe_transmutable`
|
||||
|
||||
error[E0277]: `[String; 1]` cannot be safely transmuted into `()` in the defining scope of `assert::Context`
|
||||
--> $DIR/should_require_well_defined_layout.rs:32:52
|
||||
error[E0277]: `[String; 1]` cannot be safely transmuted into `()`
|
||||
--> $DIR/should_require_well_defined_layout.rs:31:52
|
||||
|
|
||||
LL | assert::is_maybe_transmutable::<repr_rust, ()>();
|
||||
| ^^ `[String; 1]` does not have a well-specified layout
|
||||
|
|
||||
note: required by a bound in `is_maybe_transmutable`
|
||||
--> $DIR/should_require_well_defined_layout.rs:13:14
|
||||
--> $DIR/should_require_well_defined_layout.rs:12:14
|
||||
|
|
||||
LL | pub fn is_maybe_transmutable<Src, Dst>()
|
||||
| --------------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume::ALIGNMENT
|
||||
LL | | .and(Assume::LIFETIMES)
|
||||
|
@ -61,19 +61,19 @@ LL | | .and(Assume::VALIDITY)
|
|||
LL | | }>
|
||||
| |__________^ required by this bound in `is_maybe_transmutable`
|
||||
|
||||
error[E0277]: `u128` cannot be safely transmuted into `[String; 1]` in the defining scope of `assert::Context`
|
||||
--> $DIR/should_require_well_defined_layout.rs:33:47
|
||||
error[E0277]: `u128` cannot be safely transmuted into `[String; 1]`
|
||||
--> $DIR/should_require_well_defined_layout.rs:32:47
|
||||
|
|
||||
LL | assert::is_maybe_transmutable::<u128, repr_rust>();
|
||||
| ^^^^^^^^^ `[String; 1]` does not have a well-specified layout
|
||||
|
|
||||
note: required by a bound in `is_maybe_transmutable`
|
||||
--> $DIR/should_require_well_defined_layout.rs:13:14
|
||||
--> $DIR/should_require_well_defined_layout.rs:12:14
|
||||
|
|
||||
LL | pub fn is_maybe_transmutable<Src, Dst>()
|
||||
| --------------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume::ALIGNMENT
|
||||
LL | | .and(Assume::LIFETIMES)
|
||||
|
@ -82,19 +82,19 @@ LL | | .and(Assume::VALIDITY)
|
|||
LL | | }>
|
||||
| |__________^ required by this bound in `is_maybe_transmutable`
|
||||
|
||||
error[E0277]: `[String; 2]` cannot be safely transmuted into `()` in the defining scope of `assert::Context`
|
||||
--> $DIR/should_require_well_defined_layout.rs:38:52
|
||||
error[E0277]: `[String; 2]` cannot be safely transmuted into `()`
|
||||
--> $DIR/should_require_well_defined_layout.rs:37:52
|
||||
|
|
||||
LL | assert::is_maybe_transmutable::<repr_rust, ()>();
|
||||
| ^^ `[String; 2]` does not have a well-specified layout
|
||||
|
|
||||
note: required by a bound in `is_maybe_transmutable`
|
||||
--> $DIR/should_require_well_defined_layout.rs:13:14
|
||||
--> $DIR/should_require_well_defined_layout.rs:12:14
|
||||
|
|
||||
LL | pub fn is_maybe_transmutable<Src, Dst>()
|
||||
| --------------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume::ALIGNMENT
|
||||
LL | | .and(Assume::LIFETIMES)
|
||||
|
@ -103,19 +103,19 @@ LL | | .and(Assume::VALIDITY)
|
|||
LL | | }>
|
||||
| |__________^ required by this bound in `is_maybe_transmutable`
|
||||
|
||||
error[E0277]: `u128` cannot be safely transmuted into `[String; 2]` in the defining scope of `assert::Context`
|
||||
--> $DIR/should_require_well_defined_layout.rs:39:47
|
||||
error[E0277]: `u128` cannot be safely transmuted into `[String; 2]`
|
||||
--> $DIR/should_require_well_defined_layout.rs:38:47
|
||||
|
|
||||
LL | assert::is_maybe_transmutable::<u128, repr_rust>();
|
||||
| ^^^^^^^^^ `[String; 2]` does not have a well-specified layout
|
||||
|
|
||||
note: required by a bound in `is_maybe_transmutable`
|
||||
--> $DIR/should_require_well_defined_layout.rs:13:14
|
||||
--> $DIR/should_require_well_defined_layout.rs:12:14
|
||||
|
|
||||
LL | pub fn is_maybe_transmutable<Src, Dst>()
|
||||
| --------------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume::ALIGNMENT
|
||||
LL | | .and(Assume::LIFETIMES)
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
mod assert {
|
||||
use std::mem::{Assume, BikeshedIntrinsicFrom};
|
||||
|
||||
pub fn is_transmutable<Src, Dst, Context>()
|
||||
pub fn is_transmutable<Src, Dst>()
|
||||
where
|
||||
Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
Dst: BikeshedIntrinsicFrom<Src, {
|
||||
Assume {
|
||||
alignment: true,
|
||||
lifetimes: true,
|
||||
|
@ -36,8 +36,6 @@ struct Zst;
|
|||
#[repr(usize)] enum V0usize { V }
|
||||
|
||||
fn n8() {
|
||||
struct Context;
|
||||
|
||||
type Smaller = Zst;
|
||||
type Analog = u8;
|
||||
type Larger = u16;
|
||||
|
@ -45,23 +43,21 @@ fn n8() {
|
|||
fn i_should_have_correct_length() {
|
||||
type Current = V0i8;
|
||||
|
||||
assert::is_transmutable::<Smaller, Current, Context>(); //~ ERROR cannot be safely transmuted
|
||||
assert::is_transmutable::<Current, Analog, Context>();
|
||||
assert::is_transmutable::<Current, Larger, Context>(); //~ ERROR cannot be safely transmuted
|
||||
assert::is_transmutable::<Smaller, Current>(); //~ ERROR cannot be safely transmuted
|
||||
assert::is_transmutable::<Current, Analog>();
|
||||
assert::is_transmutable::<Current, Larger>(); //~ ERROR cannot be safely transmuted
|
||||
}
|
||||
|
||||
fn u_should_have_correct_length() {
|
||||
type Current = V0u8;
|
||||
|
||||
assert::is_transmutable::<Smaller, Current, Context>(); //~ ERROR cannot be safely transmuted
|
||||
assert::is_transmutable::<Current, Analog, Context>();
|
||||
assert::is_transmutable::<Current, Larger, Context>(); //~ ERROR cannot be safely transmuted
|
||||
assert::is_transmutable::<Smaller, Current>(); //~ ERROR cannot be safely transmuted
|
||||
assert::is_transmutable::<Current, Analog>();
|
||||
assert::is_transmutable::<Current, Larger>(); //~ ERROR cannot be safely transmuted
|
||||
}
|
||||
}
|
||||
|
||||
fn n16() {
|
||||
struct Context;
|
||||
|
||||
type Smaller = u8;
|
||||
type Analog = u16;
|
||||
type Larger = u32;
|
||||
|
@ -69,23 +65,21 @@ fn n16() {
|
|||
fn i_should_have_correct_length() {
|
||||
type Current = V0i16;
|
||||
|
||||
assert::is_transmutable::<Smaller, Current, Context>(); //~ ERROR cannot be safely transmuted
|
||||
assert::is_transmutable::<Current, Analog, Context>();
|
||||
assert::is_transmutable::<Current, Larger, Context>(); //~ ERROR cannot be safely transmuted
|
||||
assert::is_transmutable::<Smaller, Current>(); //~ ERROR cannot be safely transmuted
|
||||
assert::is_transmutable::<Current, Analog>();
|
||||
assert::is_transmutable::<Current, Larger>(); //~ ERROR cannot be safely transmuted
|
||||
}
|
||||
|
||||
fn u_should_have_correct_length() {
|
||||
type Current = V0u16;
|
||||
|
||||
assert::is_transmutable::<Smaller, Current, Context>(); //~ ERROR cannot be safely transmuted
|
||||
assert::is_transmutable::<Current, Analog, Context>();
|
||||
assert::is_transmutable::<Current, Larger, Context>(); //~ ERROR cannot be safely transmuted
|
||||
assert::is_transmutable::<Smaller, Current>(); //~ ERROR cannot be safely transmuted
|
||||
assert::is_transmutable::<Current, Analog>();
|
||||
assert::is_transmutable::<Current, Larger>(); //~ ERROR cannot be safely transmuted
|
||||
}
|
||||
}
|
||||
|
||||
fn n32() {
|
||||
struct Context;
|
||||
|
||||
type Smaller = u16;
|
||||
type Analog = u32;
|
||||
type Larger = u64;
|
||||
|
@ -93,23 +87,21 @@ fn n32() {
|
|||
fn i_should_have_correct_length() {
|
||||
type Current = V0i32;
|
||||
|
||||
assert::is_transmutable::<Smaller, Current, Context>(); //~ ERROR cannot be safely transmuted
|
||||
assert::is_transmutable::<Current, Analog, Context>();
|
||||
assert::is_transmutable::<Current, Larger, Context>(); //~ ERROR cannot be safely transmuted
|
||||
assert::is_transmutable::<Smaller, Current>(); //~ ERROR cannot be safely transmuted
|
||||
assert::is_transmutable::<Current, Analog>();
|
||||
assert::is_transmutable::<Current, Larger>(); //~ ERROR cannot be safely transmuted
|
||||
}
|
||||
|
||||
fn u_should_have_correct_length() {
|
||||
type Current = V0u32;
|
||||
|
||||
assert::is_transmutable::<Smaller, Current, Context>(); //~ ERROR cannot be safely transmuted
|
||||
assert::is_transmutable::<Current, Analog, Context>();
|
||||
assert::is_transmutable::<Current, Larger, Context>(); //~ ERROR cannot be safely transmuted
|
||||
assert::is_transmutable::<Smaller, Current>(); //~ ERROR cannot be safely transmuted
|
||||
assert::is_transmutable::<Current, Analog>();
|
||||
assert::is_transmutable::<Current, Larger>(); //~ ERROR cannot be safely transmuted
|
||||
}
|
||||
}
|
||||
|
||||
fn n64() {
|
||||
struct Context;
|
||||
|
||||
type Smaller = u32;
|
||||
type Analog = u64;
|
||||
type Larger = u128;
|
||||
|
@ -117,23 +109,21 @@ fn n64() {
|
|||
fn i_should_have_correct_length() {
|
||||
type Current = V0i64;
|
||||
|
||||
assert::is_transmutable::<Smaller, Current, Context>(); //~ ERROR cannot be safely transmuted
|
||||
assert::is_transmutable::<Current, Analog, Context>();
|
||||
assert::is_transmutable::<Current, Larger, Context>(); //~ ERROR cannot be safely transmuted
|
||||
assert::is_transmutable::<Smaller, Current>(); //~ ERROR cannot be safely transmuted
|
||||
assert::is_transmutable::<Current, Analog>();
|
||||
assert::is_transmutable::<Current, Larger>(); //~ ERROR cannot be safely transmuted
|
||||
}
|
||||
|
||||
fn u_should_have_correct_length() {
|
||||
type Current = V0u64;
|
||||
|
||||
assert::is_transmutable::<Smaller, Current, Context>(); //~ ERROR cannot be safely transmuted
|
||||
assert::is_transmutable::<Current, Analog, Context>();
|
||||
assert::is_transmutable::<Current, Larger, Context>(); //~ ERROR cannot be safely transmuted
|
||||
assert::is_transmutable::<Smaller, Current>(); //~ ERROR cannot be safely transmuted
|
||||
assert::is_transmutable::<Current, Analog>();
|
||||
assert::is_transmutable::<Current, Larger>(); //~ ERROR cannot be safely transmuted
|
||||
}
|
||||
}
|
||||
|
||||
fn nsize() {
|
||||
struct Context;
|
||||
|
||||
type Smaller = u8;
|
||||
type Analog = usize;
|
||||
type Larger = [usize; 2];
|
||||
|
@ -141,16 +131,16 @@ fn nsize() {
|
|||
fn i_should_have_correct_length() {
|
||||
type Current = V0isize;
|
||||
|
||||
assert::is_transmutable::<Smaller, Current, Context>(); //~ ERROR cannot be safely transmuted
|
||||
assert::is_transmutable::<Current, Analog, Context>();
|
||||
assert::is_transmutable::<Current, Larger, Context>(); //~ ERROR cannot be safely transmuted
|
||||
assert::is_transmutable::<Smaller, Current>(); //~ ERROR cannot be safely transmuted
|
||||
assert::is_transmutable::<Current, Analog>();
|
||||
assert::is_transmutable::<Current, Larger>(); //~ ERROR cannot be safely transmuted
|
||||
}
|
||||
|
||||
fn u_should_have_correct_length() {
|
||||
type Current = V0usize;
|
||||
|
||||
assert::is_transmutable::<Smaller, Current, Context>(); //~ ERROR cannot be safely transmuted
|
||||
assert::is_transmutable::<Current, Analog, Context>();
|
||||
assert::is_transmutable::<Current, Larger, Context>(); //~ ERROR cannot be safely transmuted
|
||||
assert::is_transmutable::<Smaller, Current>(); //~ ERROR cannot be safely transmuted
|
||||
assert::is_transmutable::<Current, Analog>();
|
||||
assert::is_transmutable::<Current, Larger>(); //~ ERROR cannot be safely transmuted
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
error[E0277]: `Zst` cannot be safely transmuted into `V0i8` in the defining scope of `n8::Context`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:48:44
|
||||
error[E0277]: `Zst` cannot be safely transmuted into `V0i8`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:46:44
|
||||
|
|
||||
LL | assert::is_transmutable::<Smaller, Current, Context>();
|
||||
LL | assert::is_transmutable::<Smaller, Current>();
|
||||
| ^^^^^^^ The size of `Zst` is smaller than the size of `V0i8`
|
||||
|
|
||||
note: required by a bound in `is_transmutable`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:12:14
|
||||
|
|
||||
LL | pub fn is_transmutable<Src, Dst, Context>()
|
||||
LL | pub fn is_transmutable<Src, Dst>()
|
||||
| --------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume {
|
||||
LL | | alignment: true,
|
||||
|
@ -20,19 +20,19 @@ LL | | }
|
|||
LL | | }>
|
||||
| |__________^ required by this bound in `is_transmutable`
|
||||
|
||||
error[E0277]: `V0i8` cannot be safely transmuted into `u16` in the defining scope of `n8::Context`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:50:44
|
||||
error[E0277]: `V0i8` cannot be safely transmuted into `u16`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:48:44
|
||||
|
|
||||
LL | assert::is_transmutable::<Current, Larger, Context>();
|
||||
LL | assert::is_transmutable::<Current, Larger>();
|
||||
| ^^^^^^ The size of `V0i8` is smaller than the size of `u16`
|
||||
|
|
||||
note: required by a bound in `is_transmutable`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:12:14
|
||||
|
|
||||
LL | pub fn is_transmutable<Src, Dst, Context>()
|
||||
LL | pub fn is_transmutable<Src, Dst>()
|
||||
| --------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume {
|
||||
LL | | alignment: true,
|
||||
|
@ -42,19 +42,19 @@ LL | | }
|
|||
LL | | }>
|
||||
| |__________^ required by this bound in `is_transmutable`
|
||||
|
||||
error[E0277]: `Zst` cannot be safely transmuted into `V0u8` in the defining scope of `n8::Context`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:56:44
|
||||
error[E0277]: `Zst` cannot be safely transmuted into `V0u8`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:54:44
|
||||
|
|
||||
LL | assert::is_transmutable::<Smaller, Current, Context>();
|
||||
LL | assert::is_transmutable::<Smaller, Current>();
|
||||
| ^^^^^^^ The size of `Zst` is smaller than the size of `V0u8`
|
||||
|
|
||||
note: required by a bound in `is_transmutable`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:12:14
|
||||
|
|
||||
LL | pub fn is_transmutable<Src, Dst, Context>()
|
||||
LL | pub fn is_transmutable<Src, Dst>()
|
||||
| --------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume {
|
||||
LL | | alignment: true,
|
||||
|
@ -64,19 +64,19 @@ LL | | }
|
|||
LL | | }>
|
||||
| |__________^ required by this bound in `is_transmutable`
|
||||
|
||||
error[E0277]: `V0u8` cannot be safely transmuted into `u16` in the defining scope of `n8::Context`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:58:44
|
||||
error[E0277]: `V0u8` cannot be safely transmuted into `u16`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:56:44
|
||||
|
|
||||
LL | assert::is_transmutable::<Current, Larger, Context>();
|
||||
LL | assert::is_transmutable::<Current, Larger>();
|
||||
| ^^^^^^ The size of `V0u8` is smaller than the size of `u16`
|
||||
|
|
||||
note: required by a bound in `is_transmutable`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:12:14
|
||||
|
|
||||
LL | pub fn is_transmutable<Src, Dst, Context>()
|
||||
LL | pub fn is_transmutable<Src, Dst>()
|
||||
| --------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume {
|
||||
LL | | alignment: true,
|
||||
|
@ -86,19 +86,19 @@ LL | | }
|
|||
LL | | }>
|
||||
| |__________^ required by this bound in `is_transmutable`
|
||||
|
||||
error[E0277]: `u8` cannot be safely transmuted into `V0i16` in the defining scope of `n16::Context`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:72:44
|
||||
error[E0277]: `u8` cannot be safely transmuted into `V0i16`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:68:44
|
||||
|
|
||||
LL | assert::is_transmutable::<Smaller, Current, Context>();
|
||||
LL | assert::is_transmutable::<Smaller, Current>();
|
||||
| ^^^^^^^ The size of `u8` is smaller than the size of `V0i16`
|
||||
|
|
||||
note: required by a bound in `is_transmutable`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:12:14
|
||||
|
|
||||
LL | pub fn is_transmutable<Src, Dst, Context>()
|
||||
LL | pub fn is_transmutable<Src, Dst>()
|
||||
| --------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume {
|
||||
LL | | alignment: true,
|
||||
|
@ -108,19 +108,19 @@ LL | | }
|
|||
LL | | }>
|
||||
| |__________^ required by this bound in `is_transmutable`
|
||||
|
||||
error[E0277]: `V0i16` cannot be safely transmuted into `u32` in the defining scope of `n16::Context`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:74:44
|
||||
error[E0277]: `V0i16` cannot be safely transmuted into `u32`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:70:44
|
||||
|
|
||||
LL | assert::is_transmutable::<Current, Larger, Context>();
|
||||
LL | assert::is_transmutable::<Current, Larger>();
|
||||
| ^^^^^^ The size of `V0i16` is smaller than the size of `u32`
|
||||
|
|
||||
note: required by a bound in `is_transmutable`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:12:14
|
||||
|
|
||||
LL | pub fn is_transmutable<Src, Dst, Context>()
|
||||
LL | pub fn is_transmutable<Src, Dst>()
|
||||
| --------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume {
|
||||
LL | | alignment: true,
|
||||
|
@ -130,19 +130,19 @@ LL | | }
|
|||
LL | | }>
|
||||
| |__________^ required by this bound in `is_transmutable`
|
||||
|
||||
error[E0277]: `u8` cannot be safely transmuted into `V0u16` in the defining scope of `n16::Context`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:80:44
|
||||
error[E0277]: `u8` cannot be safely transmuted into `V0u16`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:76:44
|
||||
|
|
||||
LL | assert::is_transmutable::<Smaller, Current, Context>();
|
||||
LL | assert::is_transmutable::<Smaller, Current>();
|
||||
| ^^^^^^^ The size of `u8` is smaller than the size of `V0u16`
|
||||
|
|
||||
note: required by a bound in `is_transmutable`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:12:14
|
||||
|
|
||||
LL | pub fn is_transmutable<Src, Dst, Context>()
|
||||
LL | pub fn is_transmutable<Src, Dst>()
|
||||
| --------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume {
|
||||
LL | | alignment: true,
|
||||
|
@ -152,19 +152,19 @@ LL | | }
|
|||
LL | | }>
|
||||
| |__________^ required by this bound in `is_transmutable`
|
||||
|
||||
error[E0277]: `V0u16` cannot be safely transmuted into `u32` in the defining scope of `n16::Context`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:82:44
|
||||
error[E0277]: `V0u16` cannot be safely transmuted into `u32`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:78:44
|
||||
|
|
||||
LL | assert::is_transmutable::<Current, Larger, Context>();
|
||||
LL | assert::is_transmutable::<Current, Larger>();
|
||||
| ^^^^^^ The size of `V0u16` is smaller than the size of `u32`
|
||||
|
|
||||
note: required by a bound in `is_transmutable`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:12:14
|
||||
|
|
||||
LL | pub fn is_transmutable<Src, Dst, Context>()
|
||||
LL | pub fn is_transmutable<Src, Dst>()
|
||||
| --------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume {
|
||||
LL | | alignment: true,
|
||||
|
@ -174,19 +174,19 @@ LL | | }
|
|||
LL | | }>
|
||||
| |__________^ required by this bound in `is_transmutable`
|
||||
|
||||
error[E0277]: `u16` cannot be safely transmuted into `V0i32` in the defining scope of `n32::Context`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:96:44
|
||||
error[E0277]: `u16` cannot be safely transmuted into `V0i32`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:90:44
|
||||
|
|
||||
LL | assert::is_transmutable::<Smaller, Current, Context>();
|
||||
LL | assert::is_transmutable::<Smaller, Current>();
|
||||
| ^^^^^^^ The size of `u16` is smaller than the size of `V0i32`
|
||||
|
|
||||
note: required by a bound in `is_transmutable`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:12:14
|
||||
|
|
||||
LL | pub fn is_transmutable<Src, Dst, Context>()
|
||||
LL | pub fn is_transmutable<Src, Dst>()
|
||||
| --------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume {
|
||||
LL | | alignment: true,
|
||||
|
@ -196,19 +196,19 @@ LL | | }
|
|||
LL | | }>
|
||||
| |__________^ required by this bound in `is_transmutable`
|
||||
|
||||
error[E0277]: `V0i32` cannot be safely transmuted into `u64` in the defining scope of `n32::Context`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:98:44
|
||||
error[E0277]: `V0i32` cannot be safely transmuted into `u64`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:92:44
|
||||
|
|
||||
LL | assert::is_transmutable::<Current, Larger, Context>();
|
||||
LL | assert::is_transmutable::<Current, Larger>();
|
||||
| ^^^^^^ The size of `V0i32` is smaller than the size of `u64`
|
||||
|
|
||||
note: required by a bound in `is_transmutable`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:12:14
|
||||
|
|
||||
LL | pub fn is_transmutable<Src, Dst, Context>()
|
||||
LL | pub fn is_transmutable<Src, Dst>()
|
||||
| --------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume {
|
||||
LL | | alignment: true,
|
||||
|
@ -218,19 +218,19 @@ LL | | }
|
|||
LL | | }>
|
||||
| |__________^ required by this bound in `is_transmutable`
|
||||
|
||||
error[E0277]: `u16` cannot be safely transmuted into `V0u32` in the defining scope of `n32::Context`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:104:44
|
||||
error[E0277]: `u16` cannot be safely transmuted into `V0u32`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:98:44
|
||||
|
|
||||
LL | assert::is_transmutable::<Smaller, Current, Context>();
|
||||
LL | assert::is_transmutable::<Smaller, Current>();
|
||||
| ^^^^^^^ The size of `u16` is smaller than the size of `V0u32`
|
||||
|
|
||||
note: required by a bound in `is_transmutable`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:12:14
|
||||
|
|
||||
LL | pub fn is_transmutable<Src, Dst, Context>()
|
||||
LL | pub fn is_transmutable<Src, Dst>()
|
||||
| --------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume {
|
||||
LL | | alignment: true,
|
||||
|
@ -240,19 +240,19 @@ LL | | }
|
|||
LL | | }>
|
||||
| |__________^ required by this bound in `is_transmutable`
|
||||
|
||||
error[E0277]: `V0u32` cannot be safely transmuted into `u64` in the defining scope of `n32::Context`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:106:44
|
||||
error[E0277]: `V0u32` cannot be safely transmuted into `u64`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:100:44
|
||||
|
|
||||
LL | assert::is_transmutable::<Current, Larger, Context>();
|
||||
LL | assert::is_transmutable::<Current, Larger>();
|
||||
| ^^^^^^ The size of `V0u32` is smaller than the size of `u64`
|
||||
|
|
||||
note: required by a bound in `is_transmutable`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:12:14
|
||||
|
|
||||
LL | pub fn is_transmutable<Src, Dst, Context>()
|
||||
LL | pub fn is_transmutable<Src, Dst>()
|
||||
| --------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume {
|
||||
LL | | alignment: true,
|
||||
|
@ -262,19 +262,19 @@ LL | | }
|
|||
LL | | }>
|
||||
| |__________^ required by this bound in `is_transmutable`
|
||||
|
||||
error[E0277]: `u32` cannot be safely transmuted into `V0i64` in the defining scope of `n64::Context`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:120:44
|
||||
error[E0277]: `u32` cannot be safely transmuted into `V0i64`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:112:44
|
||||
|
|
||||
LL | assert::is_transmutable::<Smaller, Current, Context>();
|
||||
LL | assert::is_transmutable::<Smaller, Current>();
|
||||
| ^^^^^^^ The size of `u32` is smaller than the size of `V0i64`
|
||||
|
|
||||
note: required by a bound in `is_transmutable`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:12:14
|
||||
|
|
||||
LL | pub fn is_transmutable<Src, Dst, Context>()
|
||||
LL | pub fn is_transmutable<Src, Dst>()
|
||||
| --------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume {
|
||||
LL | | alignment: true,
|
||||
|
@ -284,19 +284,19 @@ LL | | }
|
|||
LL | | }>
|
||||
| |__________^ required by this bound in `is_transmutable`
|
||||
|
||||
error[E0277]: `V0i64` cannot be safely transmuted into `u128` in the defining scope of `n64::Context`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:122:44
|
||||
error[E0277]: `V0i64` cannot be safely transmuted into `u128`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:114:44
|
||||
|
|
||||
LL | assert::is_transmutable::<Current, Larger, Context>();
|
||||
LL | assert::is_transmutable::<Current, Larger>();
|
||||
| ^^^^^^ The size of `V0i64` is smaller than the size of `u128`
|
||||
|
|
||||
note: required by a bound in `is_transmutable`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:12:14
|
||||
|
|
||||
LL | pub fn is_transmutable<Src, Dst, Context>()
|
||||
LL | pub fn is_transmutable<Src, Dst>()
|
||||
| --------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume {
|
||||
LL | | alignment: true,
|
||||
|
@ -306,19 +306,19 @@ LL | | }
|
|||
LL | | }>
|
||||
| |__________^ required by this bound in `is_transmutable`
|
||||
|
||||
error[E0277]: `u32` cannot be safely transmuted into `V0u64` in the defining scope of `n64::Context`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:128:44
|
||||
error[E0277]: `u32` cannot be safely transmuted into `V0u64`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:120:44
|
||||
|
|
||||
LL | assert::is_transmutable::<Smaller, Current, Context>();
|
||||
LL | assert::is_transmutable::<Smaller, Current>();
|
||||
| ^^^^^^^ The size of `u32` is smaller than the size of `V0u64`
|
||||
|
|
||||
note: required by a bound in `is_transmutable`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:12:14
|
||||
|
|
||||
LL | pub fn is_transmutable<Src, Dst, Context>()
|
||||
LL | pub fn is_transmutable<Src, Dst>()
|
||||
| --------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume {
|
||||
LL | | alignment: true,
|
||||
|
@ -328,19 +328,19 @@ LL | | }
|
|||
LL | | }>
|
||||
| |__________^ required by this bound in `is_transmutable`
|
||||
|
||||
error[E0277]: `V0u64` cannot be safely transmuted into `u128` in the defining scope of `n64::Context`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:130:44
|
||||
error[E0277]: `V0u64` cannot be safely transmuted into `u128`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:122:44
|
||||
|
|
||||
LL | assert::is_transmutable::<Current, Larger, Context>();
|
||||
LL | assert::is_transmutable::<Current, Larger>();
|
||||
| ^^^^^^ The size of `V0u64` is smaller than the size of `u128`
|
||||
|
|
||||
note: required by a bound in `is_transmutable`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:12:14
|
||||
|
|
||||
LL | pub fn is_transmutable<Src, Dst, Context>()
|
||||
LL | pub fn is_transmutable<Src, Dst>()
|
||||
| --------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume {
|
||||
LL | | alignment: true,
|
||||
|
@ -350,19 +350,19 @@ LL | | }
|
|||
LL | | }>
|
||||
| |__________^ required by this bound in `is_transmutable`
|
||||
|
||||
error[E0277]: `u8` cannot be safely transmuted into `V0isize` in the defining scope of `nsize::Context`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:144:44
|
||||
error[E0277]: `u8` cannot be safely transmuted into `V0isize`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:134:44
|
||||
|
|
||||
LL | assert::is_transmutable::<Smaller, Current, Context>();
|
||||
LL | assert::is_transmutable::<Smaller, Current>();
|
||||
| ^^^^^^^ The size of `u8` is smaller than the size of `V0isize`
|
||||
|
|
||||
note: required by a bound in `is_transmutable`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:12:14
|
||||
|
|
||||
LL | pub fn is_transmutable<Src, Dst, Context>()
|
||||
LL | pub fn is_transmutable<Src, Dst>()
|
||||
| --------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume {
|
||||
LL | | alignment: true,
|
||||
|
@ -372,19 +372,19 @@ LL | | }
|
|||
LL | | }>
|
||||
| |__________^ required by this bound in `is_transmutable`
|
||||
|
||||
error[E0277]: `V0isize` cannot be safely transmuted into `[usize; 2]` in the defining scope of `nsize::Context`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:146:44
|
||||
error[E0277]: `V0isize` cannot be safely transmuted into `[usize; 2]`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:136:44
|
||||
|
|
||||
LL | assert::is_transmutable::<Current, Larger, Context>();
|
||||
LL | assert::is_transmutable::<Current, Larger>();
|
||||
| ^^^^^^ The size of `V0isize` is smaller than the size of `[usize; 2]`
|
||||
|
|
||||
note: required by a bound in `is_transmutable`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:12:14
|
||||
|
|
||||
LL | pub fn is_transmutable<Src, Dst, Context>()
|
||||
LL | pub fn is_transmutable<Src, Dst>()
|
||||
| --------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume {
|
||||
LL | | alignment: true,
|
||||
|
@ -394,19 +394,19 @@ LL | | }
|
|||
LL | | }>
|
||||
| |__________^ required by this bound in `is_transmutable`
|
||||
|
||||
error[E0277]: `u8` cannot be safely transmuted into `V0usize` in the defining scope of `nsize::Context`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:152:44
|
||||
error[E0277]: `u8` cannot be safely transmuted into `V0usize`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:142:44
|
||||
|
|
||||
LL | assert::is_transmutable::<Smaller, Current, Context>();
|
||||
LL | assert::is_transmutable::<Smaller, Current>();
|
||||
| ^^^^^^^ The size of `u8` is smaller than the size of `V0usize`
|
||||
|
|
||||
note: required by a bound in `is_transmutable`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:12:14
|
||||
|
|
||||
LL | pub fn is_transmutable<Src, Dst, Context>()
|
||||
LL | pub fn is_transmutable<Src, Dst>()
|
||||
| --------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume {
|
||||
LL | | alignment: true,
|
||||
|
@ -416,19 +416,19 @@ LL | | }
|
|||
LL | | }>
|
||||
| |__________^ required by this bound in `is_transmutable`
|
||||
|
||||
error[E0277]: `V0usize` cannot be safely transmuted into `[usize; 2]` in the defining scope of `nsize::Context`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:154:44
|
||||
error[E0277]: `V0usize` cannot be safely transmuted into `[usize; 2]`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:144:44
|
||||
|
|
||||
LL | assert::is_transmutable::<Current, Larger, Context>();
|
||||
LL | assert::is_transmutable::<Current, Larger>();
|
||||
| ^^^^^^ The size of `V0usize` is smaller than the size of `[usize; 2]`
|
||||
|
|
||||
note: required by a bound in `is_transmutable`
|
||||
--> $DIR/primitive_reprs_should_have_correct_length.rs:12:14
|
||||
|
|
||||
LL | pub fn is_transmutable<Src, Dst, Context>()
|
||||
LL | pub fn is_transmutable<Src, Dst>()
|
||||
| --------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume {
|
||||
LL | | alignment: true,
|
||||
|
|
|
@ -7,11 +7,10 @@
|
|||
|
||||
mod assert {
|
||||
use std::mem::{Assume, BikeshedIntrinsicFrom};
|
||||
pub struct Context;
|
||||
|
||||
pub fn is_maybe_transmutable<Src, Dst>()
|
||||
where
|
||||
Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
Dst: BikeshedIntrinsicFrom<Src, {
|
||||
Assume {
|
||||
alignment: true,
|
||||
lifetimes: true,
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
error[E0277]: `void::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`
|
||||
--> $DIR/should_require_well_defined_layout.rs:28:52
|
||||
error[E0277]: `void::repr_rust` cannot be safely transmuted into `()`
|
||||
--> $DIR/should_require_well_defined_layout.rs:27:52
|
||||
|
|
||||
LL | assert::is_maybe_transmutable::<repr_rust, ()>();
|
||||
| ^^ `void::repr_rust` does not have a well-specified layout
|
||||
|
|
||||
note: required by a bound in `is_maybe_transmutable`
|
||||
--> $DIR/should_require_well_defined_layout.rs:14:14
|
||||
--> $DIR/should_require_well_defined_layout.rs:13:14
|
||||
|
|
||||
LL | pub fn is_maybe_transmutable<Src, Dst>()
|
||||
| --------------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume {
|
||||
LL | | alignment: true,
|
||||
|
@ -20,19 +20,19 @@ LL | | }
|
|||
LL | | }>
|
||||
| |__________^ required by this bound in `is_maybe_transmutable`
|
||||
|
||||
error[E0277]: `u128` cannot be safely transmuted into `void::repr_rust` in the defining scope of `assert::Context`
|
||||
--> $DIR/should_require_well_defined_layout.rs:29:47
|
||||
error[E0277]: `u128` cannot be safely transmuted into `void::repr_rust`
|
||||
--> $DIR/should_require_well_defined_layout.rs:28:47
|
||||
|
|
||||
LL | assert::is_maybe_transmutable::<u128, repr_rust>();
|
||||
| ^^^^^^^^^ `void::repr_rust` does not have a well-specified layout
|
||||
|
|
||||
note: required by a bound in `is_maybe_transmutable`
|
||||
--> $DIR/should_require_well_defined_layout.rs:14:14
|
||||
--> $DIR/should_require_well_defined_layout.rs:13:14
|
||||
|
|
||||
LL | pub fn is_maybe_transmutable<Src, Dst>()
|
||||
| --------------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume {
|
||||
LL | | alignment: true,
|
||||
|
@ -42,19 +42,19 @@ LL | | }
|
|||
LL | | }>
|
||||
| |__________^ required by this bound in `is_maybe_transmutable`
|
||||
|
||||
error[E0277]: `singleton::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`
|
||||
--> $DIR/should_require_well_defined_layout.rs:34:52
|
||||
error[E0277]: `singleton::repr_rust` cannot be safely transmuted into `()`
|
||||
--> $DIR/should_require_well_defined_layout.rs:33:52
|
||||
|
|
||||
LL | assert::is_maybe_transmutable::<repr_rust, ()>();
|
||||
| ^^ `singleton::repr_rust` does not have a well-specified layout
|
||||
|
|
||||
note: required by a bound in `is_maybe_transmutable`
|
||||
--> $DIR/should_require_well_defined_layout.rs:14:14
|
||||
--> $DIR/should_require_well_defined_layout.rs:13:14
|
||||
|
|
||||
LL | pub fn is_maybe_transmutable<Src, Dst>()
|
||||
| --------------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume {
|
||||
LL | | alignment: true,
|
||||
|
@ -64,19 +64,19 @@ LL | | }
|
|||
LL | | }>
|
||||
| |__________^ required by this bound in `is_maybe_transmutable`
|
||||
|
||||
error[E0277]: `u128` cannot be safely transmuted into `singleton::repr_rust` in the defining scope of `assert::Context`
|
||||
--> $DIR/should_require_well_defined_layout.rs:35:47
|
||||
error[E0277]: `u128` cannot be safely transmuted into `singleton::repr_rust`
|
||||
--> $DIR/should_require_well_defined_layout.rs:34:47
|
||||
|
|
||||
LL | assert::is_maybe_transmutable::<u128, repr_rust>();
|
||||
| ^^^^^^^^^ `singleton::repr_rust` does not have a well-specified layout
|
||||
|
|
||||
note: required by a bound in `is_maybe_transmutable`
|
||||
--> $DIR/should_require_well_defined_layout.rs:14:14
|
||||
--> $DIR/should_require_well_defined_layout.rs:13:14
|
||||
|
|
||||
LL | pub fn is_maybe_transmutable<Src, Dst>()
|
||||
| --------------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume {
|
||||
LL | | alignment: true,
|
||||
|
@ -86,19 +86,19 @@ LL | | }
|
|||
LL | | }>
|
||||
| |__________^ required by this bound in `is_maybe_transmutable`
|
||||
|
||||
error[E0277]: `duplex::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`
|
||||
--> $DIR/should_require_well_defined_layout.rs:40:52
|
||||
error[E0277]: `duplex::repr_rust` cannot be safely transmuted into `()`
|
||||
--> $DIR/should_require_well_defined_layout.rs:39:52
|
||||
|
|
||||
LL | assert::is_maybe_transmutable::<repr_rust, ()>();
|
||||
| ^^ `duplex::repr_rust` does not have a well-specified layout
|
||||
|
|
||||
note: required by a bound in `is_maybe_transmutable`
|
||||
--> $DIR/should_require_well_defined_layout.rs:14:14
|
||||
--> $DIR/should_require_well_defined_layout.rs:13:14
|
||||
|
|
||||
LL | pub fn is_maybe_transmutable<Src, Dst>()
|
||||
| --------------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume {
|
||||
LL | | alignment: true,
|
||||
|
@ -108,19 +108,19 @@ LL | | }
|
|||
LL | | }>
|
||||
| |__________^ required by this bound in `is_maybe_transmutable`
|
||||
|
||||
error[E0277]: `u128` cannot be safely transmuted into `duplex::repr_rust` in the defining scope of `assert::Context`
|
||||
--> $DIR/should_require_well_defined_layout.rs:41:47
|
||||
error[E0277]: `u128` cannot be safely transmuted into `duplex::repr_rust`
|
||||
--> $DIR/should_require_well_defined_layout.rs:40:47
|
||||
|
|
||||
LL | assert::is_maybe_transmutable::<u128, repr_rust>();
|
||||
| ^^^^^^^^^ `duplex::repr_rust` does not have a well-specified layout
|
||||
|
|
||||
note: required by a bound in `is_maybe_transmutable`
|
||||
--> $DIR/should_require_well_defined_layout.rs:14:14
|
||||
--> $DIR/should_require_well_defined_layout.rs:13:14
|
||||
|
|
||||
LL | pub fn is_maybe_transmutable<Src, Dst>()
|
||||
| --------------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume {
|
||||
LL | | alignment: true,
|
||||
|
|
|
@ -7,11 +7,10 @@
|
|||
|
||||
mod assert {
|
||||
use std::mem::{Assume, BikeshedIntrinsicFrom};
|
||||
pub struct Context;
|
||||
|
||||
pub fn is_transmutable<Src, Dst>()
|
||||
where
|
||||
Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
Dst: BikeshedIntrinsicFrom<Src, {
|
||||
Assume::ALIGNMENT
|
||||
.and(Assume::LIFETIMES)
|
||||
.and(Assume::SAFETY)
|
||||
|
|
|
@ -8,9 +8,9 @@
|
|||
mod assert {
|
||||
use std::mem::{Assume, BikeshedIntrinsicFrom};
|
||||
|
||||
pub fn is_transmutable<Src, Dst, Context>()
|
||||
pub fn is_transmutable<Src, Dst>()
|
||||
where
|
||||
Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
Dst: BikeshedIntrinsicFrom<Src, {
|
||||
Assume::ALIGNMENT
|
||||
.and(Assume::LIFETIMES)
|
||||
.and(Assume::SAFETY)
|
||||
|
@ -38,8 +38,7 @@ enum Lopsided {
|
|||
#[repr(C)] struct Dst(Lopsided, V2);
|
||||
|
||||
fn should_pad_variants() {
|
||||
struct Context;
|
||||
// If the implementation (incorrectly) fails to pad `Lopsided::Smol` with
|
||||
// an uninitialized byte, this transmutation might be (wrongly) accepted:
|
||||
assert::is_transmutable::<Src, Dst, Context>(); //~ ERROR cannot be safely transmuted
|
||||
assert::is_transmutable::<Src, Dst>(); //~ ERROR cannot be safely transmuted
|
||||
}
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
error[E0277]: `Src` cannot be safely transmuted into `Dst` in the defining scope of `should_pad_variants::Context`
|
||||
--> $DIR/should_pad_variants.rs:44:36
|
||||
error[E0277]: `Src` cannot be safely transmuted into `Dst`
|
||||
--> $DIR/should_pad_variants.rs:43:36
|
||||
|
|
||||
LL | assert::is_transmutable::<Src, Dst, Context>();
|
||||
LL | assert::is_transmutable::<Src, Dst>();
|
||||
| ^^^ The size of `Src` is smaller than the size of `Dst`
|
||||
|
|
||||
note: required by a bound in `is_transmutable`
|
||||
--> $DIR/should_pad_variants.rs:13:14
|
||||
|
|
||||
LL | pub fn is_transmutable<Src, Dst, Context>()
|
||||
LL | pub fn is_transmutable<Src, Dst>()
|
||||
| --------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume::ALIGNMENT
|
||||
LL | | .and(Assume::LIFETIMES)
|
||||
|
|
|
@ -7,11 +7,10 @@
|
|||
|
||||
mod assert {
|
||||
use std::mem::{Assume, BikeshedIntrinsicFrom};
|
||||
pub struct Context;
|
||||
|
||||
pub fn is_transmutable<Src, Dst>()
|
||||
where
|
||||
Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
Dst: BikeshedIntrinsicFrom<Src, {
|
||||
Assume::ALIGNMENT
|
||||
.and(Assume::LIFETIMES)
|
||||
.and(Assume::SAFETY)
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
error[E0277]: `Src` cannot be safely transmuted into `Unexpected` in the defining scope of `assert::Context`
|
||||
--> $DIR/should_respect_endianness.rs:36:36
|
||||
error[E0277]: `Src` cannot be safely transmuted into `Unexpected`
|
||||
--> $DIR/should_respect_endianness.rs:35:36
|
||||
|
|
||||
LL | assert::is_transmutable::<Src, Unexpected>();
|
||||
| ^^^^^^^^^^ At least one value of `Src` isn't a bit-valid value of `Unexpected`
|
||||
|
|
||||
note: required by a bound in `is_transmutable`
|
||||
--> $DIR/should_respect_endianness.rs:14:14
|
||||
--> $DIR/should_respect_endianness.rs:13:14
|
||||
|
|
||||
LL | pub fn is_transmutable<Src, Dst>()
|
||||
| --------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, {
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, {
|
||||
| ______________^
|
||||
LL | | Assume::ALIGNMENT
|
||||
LL | | .and(Assume::LIFETIMES)
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
mod assert {
|
||||
use std::mem::BikeshedIntrinsicFrom;
|
||||
|
||||
pub fn is_transmutable<Src, Context, const ASSUME_ALIGNMENT: bool>()
|
||||
pub fn is_transmutable<Src, const ASSUME_ALIGNMENT: bool>()
|
||||
where
|
||||
Dst: BikeshedIntrinsicFrom<Src, Context, ASSUME_ALIGNMENT>, //~ ERROR cannot find type `Dst` in this scope
|
||||
Dst: BikeshedIntrinsicFrom<Src, ASSUME_ALIGNMENT>, //~ ERROR cannot find type `Dst` in this scope
|
||||
//~^ the constant `ASSUME_ALIGNMENT` is not of type `Assume`
|
||||
//~| ERROR: mismatched types
|
||||
{
|
||||
|
@ -13,10 +13,9 @@ mod assert {
|
|||
}
|
||||
|
||||
fn via_const() {
|
||||
struct Context;
|
||||
struct Src;
|
||||
|
||||
assert::is_transmutable::<Src, Context, false>();
|
||||
assert::is_transmutable::<Src, false>();
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -1,23 +1,23 @@
|
|||
error[E0412]: cannot find type `Dst` in this scope
|
||||
--> $DIR/issue-101739-1.rs:8:9
|
||||
|
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, ASSUME_ALIGNMENT>,
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, ASSUME_ALIGNMENT>,
|
||||
| ^^^ not found in this scope
|
||||
|
||||
error: the constant `ASSUME_ALIGNMENT` is not of type `Assume`
|
||||
--> $DIR/issue-101739-1.rs:8:14
|
||||
|
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, ASSUME_ALIGNMENT>,
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Assume`, found `bool`
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, ASSUME_ALIGNMENT>,
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Assume`, found `bool`
|
||||
|
|
||||
note: required by a bound in `BikeshedIntrinsicFrom`
|
||||
--> $SRC_DIR/core/src/mem/transmutability.rs:LL:COL
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/issue-101739-1.rs:8:50
|
||||
--> $DIR/issue-101739-1.rs:8:41
|
||||
|
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, ASSUME_ALIGNMENT>,
|
||||
| ^^^^^^^^^^^^^^^^ expected `Assume`, found `bool`
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, ASSUME_ALIGNMENT>,
|
||||
| ^^^^^^^^^^^^^^^^ expected `Assume`, found `bool`
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
|
|
|
@ -8,17 +8,15 @@ mod assert {
|
|||
pub fn is_transmutable<
|
||||
Src,
|
||||
Dst,
|
||||
Context,
|
||||
const ASSUME_ALIGNMENT: bool,
|
||||
const ASSUME_LIFETIMES: bool,
|
||||
const ASSUME_VALIDITY: bool,
|
||||
const ASSUME_VISIBILITY: bool,
|
||||
>()
|
||||
where
|
||||
Dst: BikeshedIntrinsicFrom< //~ ERROR trait takes at most 3 generic arguments but 6 generic arguments were supplied
|
||||
Dst: BikeshedIntrinsicFrom< //~ ERROR trait takes at most 2 generic arguments but 5 generic arguments were supplied
|
||||
//~^ ERROR: the constant `ASSUME_ALIGNMENT` is not of type `Assume`
|
||||
Src,
|
||||
Context,
|
||||
ASSUME_ALIGNMENT, //~ ERROR: mismatched types
|
||||
ASSUME_LIFETIMES,
|
||||
ASSUME_VALIDITY,
|
||||
|
@ -28,11 +26,10 @@ mod assert {
|
|||
}
|
||||
|
||||
fn via_const() {
|
||||
struct Context;
|
||||
#[repr(C)] struct Src;
|
||||
#[repr(C)] struct Dst;
|
||||
|
||||
const FALSE: bool = false;
|
||||
|
||||
assert::is_transmutable::<Src, Dst, Context, FALSE, FALSE, FALSE, FALSE>();
|
||||
assert::is_transmutable::<Src, Dst, FALSE, FALSE, FALSE, FALSE>();
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
error[E0107]: trait takes at most 3 generic arguments but 6 generic arguments were supplied
|
||||
--> $DIR/issue-101739-2.rs:18:14
|
||||
error[E0107]: trait takes at most 2 generic arguments but 5 generic arguments were supplied
|
||||
--> $DIR/issue-101739-2.rs:17:14
|
||||
|
|
||||
LL | Dst: BikeshedIntrinsicFrom<
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ expected at most 3 generic arguments
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ expected at most 2 generic arguments
|
||||
...
|
||||
LL | / ASSUME_LIFETIMES,
|
||||
LL | | ASSUME_VALIDITY,
|
||||
|
@ -10,13 +10,13 @@ LL | | ASSUME_VISIBILITY,
|
|||
| |_____________________________- help: remove these generic arguments
|
||||
|
||||
error: the constant `ASSUME_ALIGNMENT` is not of type `Assume`
|
||||
--> $DIR/issue-101739-2.rs:18:14
|
||||
--> $DIR/issue-101739-2.rs:17:14
|
||||
|
|
||||
LL | Dst: BikeshedIntrinsicFrom<
|
||||
| ______________^
|
||||
LL | |
|
||||
LL | | Src,
|
||||
LL | | Context,
|
||||
LL | | ASSUME_ALIGNMENT,
|
||||
... |
|
||||
LL | | ASSUME_VISIBILITY,
|
||||
LL | | >,
|
||||
|
@ -26,7 +26,7 @@ note: required by a bound in `BikeshedIntrinsicFrom`
|
|||
--> $SRC_DIR/core/src/mem/transmutability.rs:LL:COL
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/issue-101739-2.rs:22:13
|
||||
--> $DIR/issue-101739-2.rs:20:13
|
||||
|
|
||||
LL | ASSUME_ALIGNMENT,
|
||||
| ^^^^^^^^^^^^^^^^ expected `Assume`, found `bool`
|
||||
|
|
|
@ -2,11 +2,10 @@
|
|||
#![crate_type = "lib"]
|
||||
#![feature(transmutability)]
|
||||
use std::mem::BikeshedIntrinsicFrom;
|
||||
pub struct Context;
|
||||
|
||||
pub fn is_maybe_transmutable<Src, Dst>()
|
||||
where
|
||||
Dst: BikeshedIntrinsicFrom<Src, Context>,
|
||||
Dst: BikeshedIntrinsicFrom<Src>,
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@ mod assert {
|
|||
pub fn is_transmutable<
|
||||
Src,
|
||||
Dst,
|
||||
Context,
|
||||
const ASSUME_ALIGNMENT: bool,
|
||||
const ASSUME_LIFETIMES: bool,
|
||||
const ASSUME_SAFETY: bool,
|
||||
|
@ -17,7 +16,6 @@ mod assert {
|
|||
where
|
||||
Dst: BikeshedIntrinsicFrom<
|
||||
Src,
|
||||
Context,
|
||||
{ from_options(ASSUME_ALIGNMENT, ASSUME_LIFETIMES, ASSUME_SAFETY, ASSUME_VALIDITY) }
|
||||
>,
|
||||
{}
|
||||
|
@ -32,9 +30,8 @@ mod assert {
|
|||
}
|
||||
|
||||
fn main() {
|
||||
struct Context;
|
||||
#[repr(C)] struct Src;
|
||||
#[repr(C)] struct Dst;
|
||||
|
||||
assert::is_transmutable::<Src, Dst, Context, false, false, { true }, false>();
|
||||
assert::is_transmutable::<Src, Dst, false, false, { true }, false>();
|
||||
}
|
||||
|
|
|
@ -1,3 +1,15 @@
|
|||
error: expected parameter name, found `,`
|
||||
--> $DIR/issue-110892.rs:25:9
|
||||
|
|
||||
LL | ,
|
||||
| ^ expected parameter name
|
||||
|
||||
error: expected parameter name, found `,`
|
||||
--> $DIR/issue-110892.rs:26:9
|
||||
|
|
||||
LL | ,
|
||||
| ^ expected parameter name
|
||||
|
||||
error: expected parameter name, found `,`
|
||||
--> $DIR/issue-110892.rs:27:9
|
||||
|
|
||||
|
@ -10,20 +22,8 @@ error: expected parameter name, found `,`
|
|||
LL | ,
|
||||
| ^ expected parameter name
|
||||
|
||||
error: expected parameter name, found `,`
|
||||
--> $DIR/issue-110892.rs:29:9
|
||||
|
|
||||
LL | ,
|
||||
| ^ expected parameter name
|
||||
|
||||
error: expected parameter name, found `,`
|
||||
--> $DIR/issue-110892.rs:30:9
|
||||
|
|
||||
LL | ,
|
||||
| ^ expected parameter name
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/issue-110892.rs:31:10
|
||||
--> $DIR/issue-110892.rs:29:10
|
||||
|
|
||||
LL | const fn from_options(
|
||||
| ------------ implicitly returns `()` as its body has no tail or `return` expression
|
||||
|
|
|
@ -6,16 +6,14 @@
|
|||
|
||||
mod assert {
|
||||
use std::mem::BikeshedIntrinsicFrom;
|
||||
pub struct Context;
|
||||
|
||||
pub fn is_transmutable<Src, Dst, Context>()
|
||||
pub fn is_transmutable<Src, Dst>()
|
||||
where
|
||||
Dst: BikeshedIntrinsicFrom<Src, Context>
|
||||
Dst: BikeshedIntrinsicFrom<Src>
|
||||
{}
|
||||
}
|
||||
|
||||
fn should_gracefully_handle_unknown_dst() {
|
||||
struct Context;
|
||||
struct Src;
|
||||
assert::is_transmutable::<Src, Dst, Context>(); //~ cannot find type
|
||||
assert::is_transmutable::<Src, Dst>(); //~ cannot find type
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
error[E0412]: cannot find type `Dst` in this scope
|
||||
--> $DIR/unknown_dst.rs:20:36
|
||||
--> $DIR/unknown_dst.rs:18:36
|
||||
|
|
||||
LL | assert::is_transmutable::<Src, Dst, Context>();
|
||||
LL | assert::is_transmutable::<Src, Dst>();
|
||||
| ^^^ not found in this scope
|
||||
|
|
||||
help: you might be missing a type parameter
|
||||
|
|
|
@ -6,16 +6,14 @@
|
|||
|
||||
mod assert {
|
||||
use std::mem::BikeshedIntrinsicFrom;
|
||||
pub struct Context;
|
||||
|
||||
pub fn is_transmutable<Src, Dst, Context>()
|
||||
pub fn is_transmutable<Src, Dst>()
|
||||
where
|
||||
Dst: BikeshedIntrinsicFrom<Src, Context>
|
||||
Dst: BikeshedIntrinsicFrom<Src>
|
||||
{}
|
||||
}
|
||||
|
||||
fn should_gracefully_handle_unknown_src() {
|
||||
struct Context;
|
||||
#[repr(C)] struct Dst;
|
||||
assert::is_transmutable::<Src, Dst, Context>(); //~ cannot find type
|
||||
assert::is_transmutable::<Src, Dst>(); //~ cannot find type
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
error[E0412]: cannot find type `Src` in this scope
|
||||
--> $DIR/unknown_src.rs:20:31
|
||||
--> $DIR/unknown_src.rs:18:31
|
||||
|
|
||||
LL | assert::is_transmutable::<Src, Dst, Context>();
|
||||
LL | assert::is_transmutable::<Src, Dst>();
|
||||
| ^^^ not found in this scope
|
||||
|
|
||||
help: you might be missing a type parameter
|
||||
|
|
|
@ -6,17 +6,15 @@
|
|||
|
||||
mod assert {
|
||||
use std::mem::BikeshedIntrinsicFrom;
|
||||
pub struct Context;
|
||||
|
||||
pub fn is_transmutable<Src, Dst, Context>()
|
||||
pub fn is_transmutable<Src, Dst>()
|
||||
where
|
||||
Dst: BikeshedIntrinsicFrom<Src, Context>
|
||||
Dst: BikeshedIntrinsicFrom<Src>
|
||||
{}
|
||||
}
|
||||
|
||||
fn should_gracefully_handle_unknown_dst_field() {
|
||||
struct Context;
|
||||
#[repr(C)] struct Src;
|
||||
#[repr(C)] struct Dst(Missing); //~ cannot find type
|
||||
assert::is_transmutable::<Src, Dst, Context>(); //~ ERROR cannot be safely transmuted
|
||||
assert::is_transmutable::<Src, Dst>(); //~ ERROR cannot be safely transmuted
|
||||
}
|
||||
|
|
|
@ -1,23 +1,23 @@
|
|||
error[E0412]: cannot find type `Missing` in this scope
|
||||
--> $DIR/unknown_src_field.rs:20:27
|
||||
--> $DIR/unknown_src_field.rs:18:27
|
||||
|
|
||||
LL | #[repr(C)] struct Dst(Missing);
|
||||
| ^^^^^^^ not found in this scope
|
||||
|
||||
error[E0277]: `Src` cannot be safely transmuted into `Dst` in the defining scope of `should_gracefully_handle_unknown_dst_field::Context`
|
||||
--> $DIR/unknown_src_field.rs:21:36
|
||||
error[E0277]: `Src` cannot be safely transmuted into `Dst`
|
||||
--> $DIR/unknown_src_field.rs:19:36
|
||||
|
|
||||
LL | assert::is_transmutable::<Src, Dst, Context>();
|
||||
LL | assert::is_transmutable::<Src, Dst>();
|
||||
| ^^^ `Dst` has an unknown layout
|
||||
|
|
||||
note: required by a bound in `is_transmutable`
|
||||
--> $DIR/unknown_src_field.rs:13:14
|
||||
--> $DIR/unknown_src_field.rs:12:14
|
||||
|
|
||||
LL | pub fn is_transmutable<Src, Dst, Context>()
|
||||
LL | pub fn is_transmutable<Src, Dst>()
|
||||
| --------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context>
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable`
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src>
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
@ -13,7 +13,6 @@ mod assert {
|
|||
pub fn is_transmutable<
|
||||
Src,
|
||||
Dst,
|
||||
Context,
|
||||
const ASSUME_ALIGNMENT: bool,
|
||||
const ASSUME_LIFETIMES: bool,
|
||||
const ASSUME_SAFETY: bool,
|
||||
|
@ -22,7 +21,6 @@ mod assert {
|
|||
where
|
||||
Dst: BikeshedIntrinsicFrom<
|
||||
Src,
|
||||
Context,
|
||||
{ from_options(ASSUME_ALIGNMENT, ASSUME_LIFETIMES, ASSUME_SAFETY, ASSUME_VALIDITY) }
|
||||
>,
|
||||
{}
|
||||
|
@ -43,11 +41,10 @@ mod assert {
|
|||
}
|
||||
|
||||
fn test() {
|
||||
struct Context;
|
||||
#[repr(C)] struct Src;
|
||||
#[repr(C)] struct Dst;
|
||||
assert::is_transmutable::<Src, Dst, Context, {0u8}, false, false, false>(); //~ ERROR mismatched types
|
||||
assert::is_transmutable::<Src, Dst, Context, false, {0u8}, false, false>(); //~ ERROR mismatched types
|
||||
assert::is_transmutable::<Src, Dst, Context, false, false, {0u8}, false>(); //~ ERROR mismatched types
|
||||
assert::is_transmutable::<Src, Dst, Context, false, false, false, {0u8}>(); //~ ERROR mismatched types
|
||||
assert::is_transmutable::<Src, Dst, {0u8}, false, false, false>(); //~ ERROR mismatched types
|
||||
assert::is_transmutable::<Src, Dst, false, {0u8}, false, false>(); //~ ERROR mismatched types
|
||||
assert::is_transmutable::<Src, Dst, false, false, {0u8}, false>(); //~ ERROR mismatched types
|
||||
assert::is_transmutable::<Src, Dst, false, false, false, {0u8}>(); //~ ERROR mismatched types
|
||||
}
|
||||
|
|
|
@ -1,26 +1,26 @@
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/wrong-type-assume.rs:49:51
|
||||
--> $DIR/wrong-type-assume.rs:46:42
|
||||
|
|
||||
LL | assert::is_transmutable::<Src, Dst, Context, {0u8}, false, false, false>();
|
||||
| ^^^ expected `bool`, found `u8`
|
||||
LL | assert::is_transmutable::<Src, Dst, {0u8}, false, false, false>();
|
||||
| ^^^ expected `bool`, found `u8`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/wrong-type-assume.rs:50:58
|
||||
--> $DIR/wrong-type-assume.rs:47:49
|
||||
|
|
||||
LL | assert::is_transmutable::<Src, Dst, Context, false, {0u8}, false, false>();
|
||||
| ^^^ expected `bool`, found `u8`
|
||||
LL | assert::is_transmutable::<Src, Dst, false, {0u8}, false, false>();
|
||||
| ^^^ expected `bool`, found `u8`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/wrong-type-assume.rs:51:65
|
||||
--> $DIR/wrong-type-assume.rs:48:56
|
||||
|
|
||||
LL | assert::is_transmutable::<Src, Dst, Context, false, false, {0u8}, false>();
|
||||
| ^^^ expected `bool`, found `u8`
|
||||
LL | assert::is_transmutable::<Src, Dst, false, false, {0u8}, false>();
|
||||
| ^^^ expected `bool`, found `u8`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/wrong-type-assume.rs:52:72
|
||||
--> $DIR/wrong-type-assume.rs:49:63
|
||||
|
|
||||
LL | assert::is_transmutable::<Src, Dst, Context, false, false, false, {0u8}>();
|
||||
| ^^^ expected `bool`, found `u8`
|
||||
LL | assert::is_transmutable::<Src, Dst, false, false, false, {0u8}>();
|
||||
| ^^^ expected `bool`, found `u8`
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
|
|
|
@ -4,11 +4,10 @@
|
|||
#![feature(transmutability)]
|
||||
mod assert {
|
||||
use std::mem::{Assume, BikeshedIntrinsicFrom};
|
||||
pub struct Context;
|
||||
|
||||
pub fn is_transmutable<Src, Dst>()
|
||||
where
|
||||
Dst: BikeshedIntrinsicFrom<Src, Context, { Assume::SAFETY }>
|
||||
Dst: BikeshedIntrinsicFrom<Src, { Assume::SAFETY }>
|
||||
{}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
error[E0277]: `u8` cannot be safely transmuted into `bool` in the defining scope of `assert::Context`
|
||||
--> $DIR/bool-mut.rs:16:50
|
||||
error[E0277]: `u8` cannot be safely transmuted into `bool`
|
||||
--> $DIR/bool-mut.rs:15:50
|
||||
|
|
||||
LL | assert::is_transmutable::<&'static mut bool, &'static mut u8>()
|
||||
| ^^^^^^^^^^^^^^^ At least one value of `u8` isn't a bit-valid value of `bool`
|
||||
|
|
||||
note: required by a bound in `is_transmutable`
|
||||
--> $DIR/bool-mut.rs:11:14
|
||||
--> $DIR/bool-mut.rs:10:14
|
||||
|
|
||||
LL | pub fn is_transmutable<Src, Dst>()
|
||||
| --------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, { Assume::SAFETY }>
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable`
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, { Assume::SAFETY }>
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable`
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
error[E0277]: `u8` cannot be safely transmuted into `bool` in the defining scope of `assert::Context`
|
||||
--> $DIR/bool.rs:21:35
|
||||
error[E0277]: `u8` cannot be safely transmuted into `bool`
|
||||
--> $DIR/bool.rs:20:35
|
||||
|
|
||||
LL | assert::is_transmutable::<u8, bool>();
|
||||
| ^^^^ At least one value of `u8` isn't a bit-valid value of `bool`
|
||||
|
|
||||
note: required by a bound in `is_transmutable`
|
||||
--> $DIR/bool.rs:11:14
|
||||
--> $DIR/bool.rs:10:14
|
||||
|
|
||||
LL | pub fn is_transmutable<Src, Dst>()
|
||||
| --------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, { Assume::SAFETY }>
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable`
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, { Assume::SAFETY }>
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable`
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
error[E0277]: `u8` cannot be safely transmuted into `bool` in the defining scope of `assert::Context`
|
||||
--> $DIR/bool.rs:21:35
|
||||
error[E0277]: `u8` cannot be safely transmuted into `bool`
|
||||
--> $DIR/bool.rs:20:35
|
||||
|
|
||||
LL | assert::is_transmutable::<u8, bool>();
|
||||
| ^^^^ At least one value of `u8` isn't a bit-valid value of `bool`
|
||||
|
|
||||
note: required by a bound in `is_transmutable`
|
||||
--> $DIR/bool.rs:11:14
|
||||
--> $DIR/bool.rs:10:14
|
||||
|
|
||||
LL | pub fn is_transmutable<Src, Dst>()
|
||||
| --------------- required by a bound in this function
|
||||
LL | where
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, Context, { Assume::SAFETY }>
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable`
|
||||
LL | Dst: BikeshedIntrinsicFrom<Src, { Assume::SAFETY }>
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable`
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
|
|
|
@ -4,16 +4,15 @@
|
|||
#![feature(transmutability)]
|
||||
mod assert {
|
||||
use std::mem::{Assume, BikeshedIntrinsicFrom};
|
||||
pub struct Context;
|
||||
|
||||
pub fn is_transmutable<Src, Dst>()
|
||||
where
|
||||
Dst: BikeshedIntrinsicFrom<Src, Context, { Assume::SAFETY }>
|
||||
Dst: BikeshedIntrinsicFrom<Src, { Assume::SAFETY }>
|
||||
{}
|
||||
|
||||
pub fn is_maybe_transmutable<Src, Dst>()
|
||||
where
|
||||
Dst: BikeshedIntrinsicFrom<Src, Context, { Assume::SAFETY.and(Assume::VALIDITY) }>
|
||||
Dst: BikeshedIntrinsicFrom<Src, { Assume::SAFETY.and(Assume::VALIDITY) }>
|
||||
{}
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue