mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +00:00
Auto merge of #87434 - Manishearth:rollup-b09njin, r=Manishearth
Rollup of 9 pull requests Successful merges: - #87348 (Fix span when suggesting to add an associated type bound) - #87359 (Remove detection of rustup and cargo in 'missing extern crate' diagnostics) - #87370 (Add support for powerpc-unknown-freebsd) - #87389 (Rename `known_attrs` to `expanded_inert_attrs` and move to rustc_expand) - #87395 (Clear up std::env::set_var panic section.) - #87403 (Implement `AssignToDroppingUnionField` in THIR unsafeck) - #87410 (Mark `format_args_nl` as `#[doc(hidden)]`) - #87419 (IEEE 754 is not an RFC) - #87422 (DOC: remove unnecessary feature crate attribute from example code) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
bddb59cf07
@ -44,7 +44,7 @@ Libraries
|
|||||||
- [`leading_zeros`, and `trailing_zeros` are now available on all
|
- [`leading_zeros`, and `trailing_zeros` are now available on all
|
||||||
`NonZero` integer types.][84082]
|
`NonZero` integer types.][84082]
|
||||||
- [`{f32, f64}::from_str` now parse and print special values
|
- [`{f32, f64}::from_str` now parse and print special values
|
||||||
(`NaN`, `-0`) according to IEEE RFC 754.][78618]
|
(`NaN`, `-0`) according to IEEE 754.][78618]
|
||||||
- [You can now index into slices using `(Bound<usize>, Bound<usize>)`.][77704]
|
- [You can now index into slices using `(Bound<usize>, Bound<usize>)`.][77704]
|
||||||
- [Add the `BITS` associated constant to all numeric types.][82565]
|
- [Add the `BITS` associated constant to all numeric types.][82565]
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
use crate::expand::{self, AstFragment, Invocation};
|
use crate::expand::{self, AstFragment, Invocation};
|
||||||
use crate::module::DirOwnership;
|
use crate::module::DirOwnership;
|
||||||
|
|
||||||
|
use rustc_ast::attr::MarkedAttrs;
|
||||||
use rustc_ast::ptr::P;
|
use rustc_ast::ptr::P;
|
||||||
use rustc_ast::token::{self, Nonterminal};
|
use rustc_ast::token::{self, Nonterminal};
|
||||||
use rustc_ast::tokenstream::{CanSynthesizeMissingTokens, TokenStream};
|
use rustc_ast::tokenstream::{CanSynthesizeMissingTokens, TokenStream};
|
||||||
@ -951,6 +952,10 @@ pub struct ExtCtxt<'a> {
|
|||||||
///
|
///
|
||||||
/// `Ident` is the module name.
|
/// `Ident` is the module name.
|
||||||
pub(super) extern_mod_loaded: OnExternModLoaded<'a>,
|
pub(super) extern_mod_loaded: OnExternModLoaded<'a>,
|
||||||
|
/// When we 'expand' an inert attribute, we leave it
|
||||||
|
/// in the AST, but insert it here so that we know
|
||||||
|
/// not to expand it again.
|
||||||
|
pub(super) expanded_inert_attrs: MarkedAttrs,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> ExtCtxt<'a> {
|
impl<'a> ExtCtxt<'a> {
|
||||||
@ -977,6 +982,7 @@ impl<'a> ExtCtxt<'a> {
|
|||||||
},
|
},
|
||||||
force_mode: false,
|
force_mode: false,
|
||||||
expansions: FxHashMap::default(),
|
expansions: FxHashMap::default(),
|
||||||
|
expanded_inert_attrs: MarkedAttrs::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -754,7 +754,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
SyntaxExtensionKind::NonMacroAttr { mark_used } => {
|
SyntaxExtensionKind::NonMacroAttr { mark_used } => {
|
||||||
self.cx.sess.mark_attr_known(&attr);
|
self.cx.expanded_inert_attrs.mark(&attr);
|
||||||
if *mark_used {
|
if *mark_used {
|
||||||
self.cx.sess.mark_attr_used(&attr);
|
self.cx.sess.mark_attr_used(&attr);
|
||||||
}
|
}
|
||||||
@ -1040,7 +1040,7 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
|
|||||||
item.visit_attrs(|attrs| {
|
item.visit_attrs(|attrs| {
|
||||||
attr = attrs
|
attr = attrs
|
||||||
.iter()
|
.iter()
|
||||||
.position(|a| !self.cx.sess.is_attr_known(a) && !is_builtin_attr(a))
|
.position(|a| !self.cx.expanded_inert_attrs.is_marked(a) && !is_builtin_attr(a))
|
||||||
.map(|attr_pos| {
|
.map(|attr_pos| {
|
||||||
let attr = attrs.remove(attr_pos);
|
let attr = attrs.remove(attr_pos);
|
||||||
let following_derives = attrs[attr_pos..]
|
let following_derives = attrs[attr_pos..]
|
||||||
|
@ -1080,7 +1080,10 @@ impl CrateError {
|
|||||||
locator.triple
|
locator.triple
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
if missing_core && std::env::var("RUSTUP_HOME").is_ok() {
|
// NOTE: this suggests using rustup, even though the user may not have it installed.
|
||||||
|
// That's because they could choose to install it; or this may give them a hint which
|
||||||
|
// target they need to install from their distro.
|
||||||
|
if missing_core {
|
||||||
err.help(&format!(
|
err.help(&format!(
|
||||||
"consider downloading the target with `rustup target add {}`",
|
"consider downloading the target with `rustup target add {}`",
|
||||||
locator.triple
|
locator.triple
|
||||||
@ -1097,7 +1100,7 @@ impl CrateError {
|
|||||||
current_crate
|
current_crate
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
if sess.is_nightly_build() && std::env::var("CARGO").is_ok() {
|
if sess.is_nightly_build() {
|
||||||
err.help("consider building the standard library from source with `cargo build -Zbuild-std`");
|
err.help("consider building the standard library from source with `cargo build -Zbuild-std`");
|
||||||
}
|
}
|
||||||
} else if Some(crate_name)
|
} else if Some(crate_name)
|
||||||
|
@ -628,6 +628,7 @@ impl<T> Trait<T> for X {
|
|||||||
assoc_substs,
|
assoc_substs,
|
||||||
ty,
|
ty,
|
||||||
msg,
|
msg,
|
||||||
|
false,
|
||||||
) {
|
) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -646,6 +647,7 @@ impl<T> Trait<T> for X {
|
|||||||
assoc_substs,
|
assoc_substs,
|
||||||
ty,
|
ty,
|
||||||
msg,
|
msg,
|
||||||
|
false,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -771,13 +773,24 @@ fn foo(&self) -> Self::T { String::new() }
|
|||||||
) -> bool {
|
) -> bool {
|
||||||
let assoc = self.associated_item(proj_ty.item_def_id);
|
let assoc = self.associated_item(proj_ty.item_def_id);
|
||||||
if let ty::Opaque(def_id, _) = *proj_ty.self_ty().kind() {
|
if let ty::Opaque(def_id, _) = *proj_ty.self_ty().kind() {
|
||||||
self.constrain_associated_type_structured_suggestion(
|
let opaque_local_def_id = def_id.expect_local();
|
||||||
|
let opaque_hir_id = self.hir().local_def_id_to_hir_id(opaque_local_def_id);
|
||||||
|
let opaque_hir_ty = match &self.hir().expect_item(opaque_hir_id).kind {
|
||||||
|
hir::ItemKind::OpaqueTy(opaque_hir_ty) => opaque_hir_ty,
|
||||||
|
_ => bug!("The HirId comes from a `ty::Opaque`"),
|
||||||
|
};
|
||||||
|
|
||||||
|
let (trait_ref, assoc_substs) = proj_ty.trait_ref_and_own_substs(self);
|
||||||
|
|
||||||
|
self.constrain_generic_bound_associated_type_structured_suggestion(
|
||||||
db,
|
db,
|
||||||
self.def_span(def_id),
|
&trait_ref,
|
||||||
&assoc,
|
opaque_hir_ty.bounds,
|
||||||
proj_ty.trait_ref_and_own_substs(self).1,
|
assoc,
|
||||||
|
assoc_substs,
|
||||||
ty,
|
ty,
|
||||||
&msg,
|
msg,
|
||||||
|
true,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
@ -899,6 +912,11 @@ fn foo(&self) -> Self::T { String::new() }
|
|||||||
|
|
||||||
/// Given a slice of `hir::GenericBound`s, if any of them corresponds to the `trait_ref`
|
/// Given a slice of `hir::GenericBound`s, if any of them corresponds to the `trait_ref`
|
||||||
/// requirement, provide a structured suggestion to constrain it to a given type `ty`.
|
/// requirement, provide a structured suggestion to constrain it to a given type `ty`.
|
||||||
|
///
|
||||||
|
/// `is_bound_surely_present` indicates whether we know the bound we're looking for is
|
||||||
|
/// inside `bounds`. If that's the case then we can consider `bounds` containing only one
|
||||||
|
/// trait bound as the one we're looking for. This can help in cases where the associated
|
||||||
|
/// type is defined on a supertrait of the one present in the bounds.
|
||||||
fn constrain_generic_bound_associated_type_structured_suggestion(
|
fn constrain_generic_bound_associated_type_structured_suggestion(
|
||||||
self,
|
self,
|
||||||
db: &mut DiagnosticBuilder<'_>,
|
db: &mut DiagnosticBuilder<'_>,
|
||||||
@ -908,23 +926,30 @@ fn foo(&self) -> Self::T { String::new() }
|
|||||||
assoc_substs: &[ty::GenericArg<'tcx>],
|
assoc_substs: &[ty::GenericArg<'tcx>],
|
||||||
ty: Ty<'tcx>,
|
ty: Ty<'tcx>,
|
||||||
msg: &str,
|
msg: &str,
|
||||||
|
is_bound_surely_present: bool,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
// FIXME: we would want to call `resolve_vars_if_possible` on `ty` before suggesting.
|
// FIXME: we would want to call `resolve_vars_if_possible` on `ty` before suggesting.
|
||||||
bounds.iter().any(|bound| match bound {
|
|
||||||
hir::GenericBound::Trait(ptr, hir::TraitBoundModifier::None) => {
|
let trait_bounds = bounds.iter().filter_map(|bound| match bound {
|
||||||
// Relate the type param against `T` in `<A as T>::Foo`.
|
hir::GenericBound::Trait(ptr, hir::TraitBoundModifier::None) => Some(ptr),
|
||||||
ptr.trait_ref.trait_def_id() == Some(trait_ref.def_id)
|
_ => None,
|
||||||
&& self.constrain_associated_type_structured_suggestion(
|
});
|
||||||
db,
|
|
||||||
ptr.span,
|
let matching_trait_bounds = trait_bounds
|
||||||
assoc,
|
.clone()
|
||||||
assoc_substs,
|
.filter(|ptr| ptr.trait_ref.trait_def_id() == Some(trait_ref.def_id))
|
||||||
ty,
|
.collect::<Vec<_>>();
|
||||||
msg,
|
|
||||||
)
|
let span = match &matching_trait_bounds[..] {
|
||||||
}
|
&[ptr] => ptr.span,
|
||||||
_ => false,
|
&[] if is_bound_surely_present => match &trait_bounds.collect::<Vec<_>>()[..] {
|
||||||
})
|
&[ptr] => ptr.span,
|
||||||
|
_ => return false,
|
||||||
|
},
|
||||||
|
_ => return false,
|
||||||
|
};
|
||||||
|
|
||||||
|
self.constrain_associated_type_structured_suggestion(db, span, assoc, assoc_substs, ty, msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Given a span corresponding to a bound, provide a structured suggestion to set an
|
/// Given a span corresponding to a bound, provide a structured suggestion to set an
|
||||||
|
@ -5,7 +5,7 @@ use rustc_errors::struct_span_err;
|
|||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_middle::mir::BorrowKind;
|
use rustc_middle::mir::BorrowKind;
|
||||||
use rustc_middle::thir::*;
|
use rustc_middle::thir::*;
|
||||||
use rustc_middle::ty::{self, ParamEnv, TyCtxt};
|
use rustc_middle::ty::{self, ParamEnv, Ty, TyCtxt};
|
||||||
use rustc_session::lint::builtin::{UNSAFE_OP_IN_UNSAFE_FN, UNUSED_UNSAFE};
|
use rustc_session::lint::builtin::{UNSAFE_OP_IN_UNSAFE_FN, UNUSED_UNSAFE};
|
||||||
use rustc_session::lint::Level;
|
use rustc_session::lint::Level;
|
||||||
use rustc_span::def_id::{DefId, LocalDefId};
|
use rustc_span::def_id::{DefId, LocalDefId};
|
||||||
@ -27,7 +27,9 @@ struct UnsafetyVisitor<'a, 'tcx> {
|
|||||||
/// The `#[target_feature]` attributes of the body. Used for checking
|
/// The `#[target_feature]` attributes of the body. Used for checking
|
||||||
/// calls to functions with `#[target_feature]` (RFC 2396).
|
/// calls to functions with `#[target_feature]` (RFC 2396).
|
||||||
body_target_features: &'tcx Vec<Symbol>,
|
body_target_features: &'tcx Vec<Symbol>,
|
||||||
in_possible_lhs_union_assign: bool,
|
/// When inside the LHS of an assignment to a field, this is the type
|
||||||
|
/// of the LHS and the span of the assignment expression.
|
||||||
|
assignment_info: Option<(Ty<'tcx>, Span)>,
|
||||||
in_union_destructure: bool,
|
in_union_destructure: bool,
|
||||||
param_env: ParamEnv<'tcx>,
|
param_env: ParamEnv<'tcx>,
|
||||||
inside_adt: bool,
|
inside_adt: bool,
|
||||||
@ -287,7 +289,7 @@ impl<'a, 'tcx> Visitor<'a, 'tcx> for UnsafetyVisitor<'a, 'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn visit_expr(&mut self, expr: &Expr<'tcx>) {
|
fn visit_expr(&mut self, expr: &Expr<'tcx>) {
|
||||||
// could we be in a the LHS of an assignment of a union?
|
// could we be in the LHS of an assignment to a field?
|
||||||
match expr.kind {
|
match expr.kind {
|
||||||
ExprKind::Field { .. }
|
ExprKind::Field { .. }
|
||||||
| ExprKind::VarRef { .. }
|
| ExprKind::VarRef { .. }
|
||||||
@ -329,7 +331,12 @@ impl<'a, 'tcx> Visitor<'a, 'tcx> for UnsafetyVisitor<'a, 'tcx> {
|
|||||||
| ExprKind::InlineAsm { .. }
|
| ExprKind::InlineAsm { .. }
|
||||||
| ExprKind::LlvmInlineAsm { .. }
|
| ExprKind::LlvmInlineAsm { .. }
|
||||||
| ExprKind::LogicalOp { .. }
|
| ExprKind::LogicalOp { .. }
|
||||||
| ExprKind::Use { .. } => self.in_possible_lhs_union_assign = false,
|
| ExprKind::Use { .. } => {
|
||||||
|
// We don't need to save the old value and restore it
|
||||||
|
// because all the place expressions can't have more
|
||||||
|
// than one child.
|
||||||
|
self.assignment_info = None;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
match expr.kind {
|
match expr.kind {
|
||||||
ExprKind::Scope { value, lint_level: LintLevel::Explicit(hir_id), region_scope: _ } => {
|
ExprKind::Scope { value, lint_level: LintLevel::Explicit(hir_id), region_scope: _ } => {
|
||||||
@ -409,11 +416,21 @@ impl<'a, 'tcx> Visitor<'a, 'tcx> for UnsafetyVisitor<'a, 'tcx> {
|
|||||||
self.safety_context = closure_visitor.safety_context;
|
self.safety_context = closure_visitor.safety_context;
|
||||||
}
|
}
|
||||||
ExprKind::Field { lhs, .. } => {
|
ExprKind::Field { lhs, .. } => {
|
||||||
// assigning to union field is okay for AccessToUnionField
|
let lhs = &self.thir[lhs];
|
||||||
if let ty::Adt(adt_def, _) = &self.thir[lhs].ty.kind() {
|
if let ty::Adt(adt_def, _) = lhs.ty.kind() {
|
||||||
if adt_def.is_union() {
|
if adt_def.is_union() {
|
||||||
if self.in_possible_lhs_union_assign {
|
if let Some((assigned_ty, assignment_span)) = self.assignment_info {
|
||||||
// FIXME: trigger AssignToDroppingUnionField unsafety if needed
|
// To avoid semver hazard, we only consider `Copy` and `ManuallyDrop` non-dropping.
|
||||||
|
if !(assigned_ty
|
||||||
|
.ty_adt_def()
|
||||||
|
.map_or(false, |adt| adt.is_manually_drop())
|
||||||
|
|| assigned_ty
|
||||||
|
.is_copy_modulo_regions(self.tcx.at(expr.span), self.param_env))
|
||||||
|
{
|
||||||
|
self.requires_unsafe(assignment_span, AssignToDroppingUnionField);
|
||||||
|
} else {
|
||||||
|
// write to non-drop union field, safe
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
self.requires_unsafe(expr.span, AccessToUnionField);
|
self.requires_unsafe(expr.span, AccessToUnionField);
|
||||||
}
|
}
|
||||||
@ -421,9 +438,10 @@ impl<'a, 'tcx> Visitor<'a, 'tcx> for UnsafetyVisitor<'a, 'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
ExprKind::Assign { lhs, rhs } | ExprKind::AssignOp { lhs, rhs, .. } => {
|
ExprKind::Assign { lhs, rhs } | ExprKind::AssignOp { lhs, rhs, .. } => {
|
||||||
|
let lhs = &self.thir[lhs];
|
||||||
// First, check whether we are mutating a layout constrained field
|
// First, check whether we are mutating a layout constrained field
|
||||||
let mut visitor = LayoutConstrainedPlaceVisitor::new(self.thir, self.tcx);
|
let mut visitor = LayoutConstrainedPlaceVisitor::new(self.thir, self.tcx);
|
||||||
visit::walk_expr(&mut visitor, &self.thir[lhs]);
|
visit::walk_expr(&mut visitor, lhs);
|
||||||
if visitor.found {
|
if visitor.found {
|
||||||
self.requires_unsafe(expr.span, MutationOfLayoutConstrainedField);
|
self.requires_unsafe(expr.span, MutationOfLayoutConstrainedField);
|
||||||
}
|
}
|
||||||
@ -431,10 +449,9 @@ impl<'a, 'tcx> Visitor<'a, 'tcx> for UnsafetyVisitor<'a, 'tcx> {
|
|||||||
// Second, check for accesses to union fields
|
// Second, check for accesses to union fields
|
||||||
// don't have any special handling for AssignOp since it causes a read *and* write to lhs
|
// don't have any special handling for AssignOp since it causes a read *and* write to lhs
|
||||||
if matches!(expr.kind, ExprKind::Assign { .. }) {
|
if matches!(expr.kind, ExprKind::Assign { .. }) {
|
||||||
// assigning to a union is safe, check here so it doesn't get treated as a read later
|
self.assignment_info = Some((lhs.ty, expr.span));
|
||||||
self.in_possible_lhs_union_assign = true;
|
visit::walk_expr(self, lhs);
|
||||||
visit::walk_expr(self, &self.thir()[lhs]);
|
self.assignment_info = None;
|
||||||
self.in_possible_lhs_union_assign = false;
|
|
||||||
visit::walk_expr(self, &self.thir()[rhs]);
|
visit::walk_expr(self, &self.thir()[rhs]);
|
||||||
return; // we have already visited everything by now
|
return; // we have already visited everything by now
|
||||||
}
|
}
|
||||||
@ -506,12 +523,9 @@ enum UnsafeOpKind {
|
|||||||
UseOfMutableStatic,
|
UseOfMutableStatic,
|
||||||
UseOfExternStatic,
|
UseOfExternStatic,
|
||||||
DerefOfRawPointer,
|
DerefOfRawPointer,
|
||||||
#[allow(dead_code)] // FIXME
|
|
||||||
AssignToDroppingUnionField,
|
AssignToDroppingUnionField,
|
||||||
AccessToUnionField,
|
AccessToUnionField,
|
||||||
#[allow(dead_code)] // FIXME
|
|
||||||
MutationOfLayoutConstrainedField,
|
MutationOfLayoutConstrainedField,
|
||||||
#[allow(dead_code)] // FIXME
|
|
||||||
BorrowOfLayoutConstrainedField,
|
BorrowOfLayoutConstrainedField,
|
||||||
CallToFunctionWith,
|
CallToFunctionWith,
|
||||||
}
|
}
|
||||||
@ -619,7 +633,7 @@ pub fn check_unsafety<'tcx>(tcx: TyCtxt<'tcx>, def: ty::WithOptConstParam<LocalD
|
|||||||
hir_context: hir_id,
|
hir_context: hir_id,
|
||||||
body_unsafety,
|
body_unsafety,
|
||||||
body_target_features,
|
body_target_features,
|
||||||
in_possible_lhs_union_assign: false,
|
assignment_info: None,
|
||||||
in_union_destructure: false,
|
in_union_destructure: false,
|
||||||
param_env: tcx.param_env(def.did),
|
param_env: tcx.param_env(def.did),
|
||||||
inside_adt: false,
|
inside_adt: false,
|
||||||
|
@ -219,7 +219,6 @@ pub struct Session {
|
|||||||
/// Set of enabled features for the current target.
|
/// Set of enabled features for the current target.
|
||||||
pub target_features: FxHashSet<Symbol>,
|
pub target_features: FxHashSet<Symbol>,
|
||||||
|
|
||||||
known_attrs: Lock<MarkedAttrs>,
|
|
||||||
used_attrs: Lock<MarkedAttrs>,
|
used_attrs: Lock<MarkedAttrs>,
|
||||||
|
|
||||||
/// `Span`s for `if` conditions that we have suggested turning into `if let`.
|
/// `Span`s for `if` conditions that we have suggested turning into `if let`.
|
||||||
@ -1076,14 +1075,6 @@ impl Session {
|
|||||||
== config::InstrumentCoverage::ExceptUnusedFunctions
|
== config::InstrumentCoverage::ExceptUnusedFunctions
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn mark_attr_known(&self, attr: &Attribute) {
|
|
||||||
self.known_attrs.lock().mark(attr)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn is_attr_known(&self, attr: &Attribute) -> bool {
|
|
||||||
self.known_attrs.lock().is_marked(attr)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn mark_attr_used(&self, attr: &Attribute) {
|
pub fn mark_attr_used(&self, attr: &Attribute) {
|
||||||
self.used_attrs.lock().mark(attr)
|
self.used_attrs.lock().mark(attr)
|
||||||
}
|
}
|
||||||
@ -1389,7 +1380,6 @@ pub fn build_session(
|
|||||||
miri_unleashed_features: Lock::new(Default::default()),
|
miri_unleashed_features: Lock::new(Default::default()),
|
||||||
asm_arch,
|
asm_arch,
|
||||||
target_features: FxHashSet::default(),
|
target_features: FxHashSet::default(),
|
||||||
known_attrs: Lock::new(MarkedAttrs::new()),
|
|
||||||
used_attrs: Lock::new(MarkedAttrs::new()),
|
used_attrs: Lock::new(MarkedAttrs::new()),
|
||||||
if_let_suggestions: Default::default(),
|
if_let_suggestions: Default::default(),
|
||||||
};
|
};
|
||||||
|
@ -802,6 +802,7 @@ supported_targets! {
|
|||||||
("armv6-unknown-freebsd", armv6_unknown_freebsd),
|
("armv6-unknown-freebsd", armv6_unknown_freebsd),
|
||||||
("armv7-unknown-freebsd", armv7_unknown_freebsd),
|
("armv7-unknown-freebsd", armv7_unknown_freebsd),
|
||||||
("i686-unknown-freebsd", i686_unknown_freebsd),
|
("i686-unknown-freebsd", i686_unknown_freebsd),
|
||||||
|
("powerpc-unknown-freebsd", powerpc_unknown_freebsd),
|
||||||
("powerpc64-unknown-freebsd", powerpc64_unknown_freebsd),
|
("powerpc64-unknown-freebsd", powerpc64_unknown_freebsd),
|
||||||
("powerpc64le-unknown-freebsd", powerpc64le_unknown_freebsd),
|
("powerpc64le-unknown-freebsd", powerpc64le_unknown_freebsd),
|
||||||
("x86_64-unknown-freebsd", x86_64_unknown_freebsd),
|
("x86_64-unknown-freebsd", x86_64_unknown_freebsd),
|
||||||
|
27
compiler/rustc_target/src/spec/powerpc_unknown_freebsd.rs
Normal file
27
compiler/rustc_target/src/spec/powerpc_unknown_freebsd.rs
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
use crate::abi::Endian;
|
||||||
|
use crate::spec::{LinkerFlavor, RelocModel, Target, TargetOptions};
|
||||||
|
|
||||||
|
pub fn target() -> Target {
|
||||||
|
let mut base = super::freebsd_base::opts();
|
||||||
|
base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m32".to_string());
|
||||||
|
// Extra hint to linker that we are generating secure-PLT code.
|
||||||
|
base.pre_link_args
|
||||||
|
.entry(LinkerFlavor::Gcc)
|
||||||
|
.or_default()
|
||||||
|
.push("--target=powerpc-unknown-freebsd13.0".to_string());
|
||||||
|
base.max_atomic_width = Some(32);
|
||||||
|
|
||||||
|
Target {
|
||||||
|
llvm_target: "powerpc-unknown-freebsd13.0".to_string(),
|
||||||
|
pointer_width: 32,
|
||||||
|
data_layout: "E-m:e-p:32:32-i64:64-n32".to_string(),
|
||||||
|
arch: "powerpc".to_string(),
|
||||||
|
options: TargetOptions {
|
||||||
|
endian: Endian::Big,
|
||||||
|
features: "+secure-plt".to_string(),
|
||||||
|
relocation_model: RelocModel::Pic,
|
||||||
|
mcount: "_mcount".to_string(),
|
||||||
|
..base
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
@ -845,6 +845,7 @@ pub(crate) mod builtin {
|
|||||||
language use and is subject to change"
|
language use and is subject to change"
|
||||||
)]
|
)]
|
||||||
#[allow_internal_unstable(fmt_internals)]
|
#[allow_internal_unstable(fmt_internals)]
|
||||||
|
#[doc(hidden)]
|
||||||
#[rustc_builtin_macro]
|
#[rustc_builtin_macro]
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! format_args_nl {
|
macro_rules! format_args_nl {
|
||||||
|
@ -461,7 +461,6 @@ impl<T> MaybeUninit<T> {
|
|||||||
/// With `write`, we can avoid the need to write through a raw pointer:
|
/// With `write`, we can avoid the need to write through a raw pointer:
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// #![feature(maybe_uninit_extra)]
|
|
||||||
/// use core::pin::Pin;
|
/// use core::pin::Pin;
|
||||||
/// use core::mem::MaybeUninit;
|
/// use core::mem::MaybeUninit;
|
||||||
///
|
///
|
||||||
|
@ -294,7 +294,7 @@ impl Error for VarError {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sets the environment variable `k` to the value `v` for the currently running
|
/// Sets the environment variable `key` to the value `value` for the currently running
|
||||||
/// process.
|
/// process.
|
||||||
///
|
///
|
||||||
/// Note that while concurrent access to environment variables is safe in Rust,
|
/// Note that while concurrent access to environment variables is safe in Rust,
|
||||||
@ -310,9 +310,8 @@ impl Error for VarError {
|
|||||||
///
|
///
|
||||||
/// # Panics
|
/// # Panics
|
||||||
///
|
///
|
||||||
/// This function may panic if `key` is empty, contains an ASCII equals sign
|
/// This function may panic if `key` is empty, contains an ASCII equals sign `'='`
|
||||||
/// `'='` or the NUL character `'\0'`, or when the value contains the NUL
|
/// or the NUL character `'\0'`, or when `value` contains the NUL character.
|
||||||
/// character.
|
|
||||||
///
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
|
@ -118,6 +118,10 @@ impl Step for Llvm {
|
|||||||
let idx = target.triple.find('-').unwrap();
|
let idx = target.triple.find('-').unwrap();
|
||||||
|
|
||||||
format!("riscv{}{}", &target.triple[5..7], &target.triple[idx..])
|
format!("riscv{}{}", &target.triple[5..7], &target.triple[idx..])
|
||||||
|
} else if self.target.starts_with("powerpc") && self.target.ends_with("freebsd") {
|
||||||
|
// FreeBSD 13 had incompatible ABI changes on all PowerPC platforms.
|
||||||
|
// Set the version suffix to 13.0 so the correct target details are used.
|
||||||
|
format!("{}{}", self.target, "13.0")
|
||||||
} else {
|
} else {
|
||||||
target.to_string()
|
target.to_string()
|
||||||
};
|
};
|
||||||
@ -277,6 +281,11 @@ impl Step for Llvm {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Workaround for ppc32 lld limitation
|
||||||
|
if target == "powerpc-unknown-freebsd" {
|
||||||
|
cfg.define("CMAKE_EXE_LINKER_FLAGS", "-fuse-ld=bfd");
|
||||||
|
}
|
||||||
|
|
||||||
// https://llvm.org/docs/HowToCrossCompileLLVM.html
|
// https://llvm.org/docs/HowToCrossCompileLLVM.html
|
||||||
if target != builder.config.build {
|
if target != builder.config.build {
|
||||||
builder.ensure(Llvm { target: builder.config.build });
|
builder.ensure(Llvm { target: builder.config.build });
|
||||||
|
@ -249,6 +249,7 @@ target | std | host | notes
|
|||||||
`powerpc-wrs-vxworks` | ? | |
|
`powerpc-wrs-vxworks` | ? | |
|
||||||
`powerpc64-unknown-freebsd` | ✓ | ✓ | PPC64 FreeBSD (ELFv1 and ELFv2)
|
`powerpc64-unknown-freebsd` | ✓ | ✓ | PPC64 FreeBSD (ELFv1 and ELFv2)
|
||||||
`powerpc64le-unknown-freebsd` | | | PPC64LE FreeBSD
|
`powerpc64le-unknown-freebsd` | | | PPC64LE FreeBSD
|
||||||
|
`powerpc-unknown-freebsd` | | | PowerPC FreeBSD
|
||||||
`powerpc64-unknown-linux-musl` | ? | |
|
`powerpc64-unknown-linux-musl` | ? | |
|
||||||
`powerpc64-wrs-vxworks` | ? | |
|
`powerpc64-wrs-vxworks` | ? | |
|
||||||
`powerpc64le-unknown-linux-musl` | ? | |
|
`powerpc64le-unknown-linux-musl` | ? | |
|
||||||
|
99
src/test/ui/associated-types/issue-87261.rs
Normal file
99
src/test/ui/associated-types/issue-87261.rs
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
trait Foo {}
|
||||||
|
|
||||||
|
trait Trait {
|
||||||
|
type Associated;
|
||||||
|
}
|
||||||
|
trait DerivedTrait: Trait {}
|
||||||
|
trait GenericTrait<A> {
|
||||||
|
type Associated;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Impl;
|
||||||
|
impl Foo for Impl {}
|
||||||
|
impl Trait for Impl {
|
||||||
|
type Associated = ();
|
||||||
|
}
|
||||||
|
impl DerivedTrait for Impl {}
|
||||||
|
impl<A> GenericTrait<A> for Impl {
|
||||||
|
type Associated = ();
|
||||||
|
}
|
||||||
|
|
||||||
|
fn returns_opaque() -> impl Trait + 'static {
|
||||||
|
Impl
|
||||||
|
}
|
||||||
|
fn returns_opaque_derived() -> impl DerivedTrait + 'static {
|
||||||
|
Impl
|
||||||
|
}
|
||||||
|
fn returns_opaque_foo() -> impl Trait + Foo {
|
||||||
|
Impl
|
||||||
|
}
|
||||||
|
fn returns_opaque_derived_foo() -> impl DerivedTrait + Foo {
|
||||||
|
Impl
|
||||||
|
}
|
||||||
|
fn returns_opaque_generic() -> impl GenericTrait<()> + 'static {
|
||||||
|
Impl
|
||||||
|
}
|
||||||
|
fn returns_opaque_generic_foo() -> impl GenericTrait<()> + Foo {
|
||||||
|
Impl
|
||||||
|
}
|
||||||
|
fn returns_opaque_generic_duplicate() -> impl GenericTrait<()> + GenericTrait<u8> {
|
||||||
|
Impl
|
||||||
|
}
|
||||||
|
|
||||||
|
fn accepts_trait<T: Trait<Associated = ()>>(_: T) {}
|
||||||
|
fn accepts_generic_trait<T: GenericTrait<(), Associated = ()>>(_: T) {}
|
||||||
|
|
||||||
|
fn check_generics<A, B, C, D, E, F, G>(a: A, b: B, c: C, d: D, e: E, f: F, g: G)
|
||||||
|
where
|
||||||
|
A: Trait + 'static,
|
||||||
|
B: DerivedTrait + 'static,
|
||||||
|
C: Trait + Foo,
|
||||||
|
D: DerivedTrait + Foo,
|
||||||
|
E: GenericTrait<()> + 'static,
|
||||||
|
F: GenericTrait<()> + Foo,
|
||||||
|
G: GenericTrait<()> + GenericTrait<u8>,
|
||||||
|
{
|
||||||
|
accepts_trait(a);
|
||||||
|
//~^ ERROR type mismatch resolving `<A as Trait>::Associated == ()`
|
||||||
|
|
||||||
|
accepts_trait(b);
|
||||||
|
//~^ ERROR type mismatch resolving `<B as Trait>::Associated == ()`
|
||||||
|
|
||||||
|
accepts_trait(c);
|
||||||
|
//~^ ERROR type mismatch resolving `<C as Trait>::Associated == ()`
|
||||||
|
|
||||||
|
accepts_trait(d);
|
||||||
|
//~^ ERROR type mismatch resolving `<D as Trait>::Associated == ()`
|
||||||
|
|
||||||
|
accepts_generic_trait(e);
|
||||||
|
//~^ ERROR type mismatch resolving `<E as GenericTrait<()>>::Associated == ()`
|
||||||
|
|
||||||
|
accepts_generic_trait(f);
|
||||||
|
//~^ ERROR type mismatch resolving `<F as GenericTrait<()>>::Associated == ()`
|
||||||
|
|
||||||
|
accepts_generic_trait(g);
|
||||||
|
//~^ ERROR type mismatch resolving `<G as GenericTrait<()>>::Associated == ()`
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
accepts_trait(returns_opaque());
|
||||||
|
//~^ ERROR type mismatch resolving `<impl Trait as Trait>::Associated == ()`
|
||||||
|
|
||||||
|
accepts_trait(returns_opaque_derived());
|
||||||
|
//~^ ERROR type mismatch resolving `<impl DerivedTrait as Trait>::Associated == ()`
|
||||||
|
|
||||||
|
accepts_trait(returns_opaque_foo());
|
||||||
|
//~^ ERROR type mismatch resolving `<impl Trait+Foo as Trait>::Associated == ()`
|
||||||
|
|
||||||
|
accepts_trait(returns_opaque_derived_foo());
|
||||||
|
//~^ ERROR type mismatch resolving `<impl DerivedTrait+Foo as Trait>::Associated == ()`
|
||||||
|
|
||||||
|
accepts_generic_trait(returns_opaque_generic());
|
||||||
|
//~^ ERROR type mismatch resolving `<impl GenericTrait<()> as GenericTrait<()>>::Associated == ()`
|
||||||
|
|
||||||
|
accepts_generic_trait(returns_opaque_generic_foo());
|
||||||
|
//~^ ERROR type mismatch resolving `<impl GenericTrait<()>+Foo as GenericTrait<()>>::Associated == ()`
|
||||||
|
|
||||||
|
accepts_generic_trait(returns_opaque_generic_duplicate());
|
||||||
|
//~^ ERROR type mismatch resolving `<impl GenericTrait<()>+GenericTrait<u8> as GenericTrait<()>>::Associated == ()`
|
||||||
|
}
|
238
src/test/ui/associated-types/issue-87261.stderr
Normal file
238
src/test/ui/associated-types/issue-87261.stderr
Normal file
@ -0,0 +1,238 @@
|
|||||||
|
error[E0271]: type mismatch resolving `<A as Trait>::Associated == ()`
|
||||||
|
--> $DIR/issue-87261.rs:56:5
|
||||||
|
|
|
||||||
|
LL | fn accepts_trait<T: Trait<Associated = ()>>(_: T) {}
|
||||||
|
| --------------- required by this bound in `accepts_trait`
|
||||||
|
...
|
||||||
|
LL | accepts_trait(a);
|
||||||
|
| ^^^^^^^^^^^^^ expected `()`, found associated type
|
||||||
|
|
|
||||||
|
= note: expected unit type `()`
|
||||||
|
found associated type `<A as Trait>::Associated`
|
||||||
|
help: consider constraining the associated type `<A as Trait>::Associated` to `()`
|
||||||
|
|
|
||||||
|
LL | A: Trait<Associated = ()> + 'static,
|
||||||
|
| ^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
error[E0271]: type mismatch resolving `<B as Trait>::Associated == ()`
|
||||||
|
--> $DIR/issue-87261.rs:59:5
|
||||||
|
|
|
||||||
|
LL | fn accepts_trait<T: Trait<Associated = ()>>(_: T) {}
|
||||||
|
| --------------- required by this bound in `accepts_trait`
|
||||||
|
...
|
||||||
|
LL | accepts_trait(b);
|
||||||
|
| ^^^^^^^^^^^^^ expected `()`, found associated type
|
||||||
|
|
|
||||||
|
= note: expected unit type `()`
|
||||||
|
found associated type `<B as Trait>::Associated`
|
||||||
|
= help: consider constraining the associated type `<B as Trait>::Associated` to `()`
|
||||||
|
= note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
|
||||||
|
|
||||||
|
error[E0271]: type mismatch resolving `<C as Trait>::Associated == ()`
|
||||||
|
--> $DIR/issue-87261.rs:62:5
|
||||||
|
|
|
||||||
|
LL | fn accepts_trait<T: Trait<Associated = ()>>(_: T) {}
|
||||||
|
| --------------- required by this bound in `accepts_trait`
|
||||||
|
...
|
||||||
|
LL | accepts_trait(c);
|
||||||
|
| ^^^^^^^^^^^^^ expected `()`, found associated type
|
||||||
|
|
|
||||||
|
= note: expected unit type `()`
|
||||||
|
found associated type `<C as Trait>::Associated`
|
||||||
|
help: consider constraining the associated type `<C as Trait>::Associated` to `()`
|
||||||
|
|
|
||||||
|
LL | C: Trait<Associated = ()> + Foo,
|
||||||
|
| ^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
error[E0271]: type mismatch resolving `<D as Trait>::Associated == ()`
|
||||||
|
--> $DIR/issue-87261.rs:65:5
|
||||||
|
|
|
||||||
|
LL | fn accepts_trait<T: Trait<Associated = ()>>(_: T) {}
|
||||||
|
| --------------- required by this bound in `accepts_trait`
|
||||||
|
...
|
||||||
|
LL | accepts_trait(d);
|
||||||
|
| ^^^^^^^^^^^^^ expected `()`, found associated type
|
||||||
|
|
|
||||||
|
= note: expected unit type `()`
|
||||||
|
found associated type `<D as Trait>::Associated`
|
||||||
|
= help: consider constraining the associated type `<D as Trait>::Associated` to `()`
|
||||||
|
= note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
|
||||||
|
|
||||||
|
error[E0271]: type mismatch resolving `<E as GenericTrait<()>>::Associated == ()`
|
||||||
|
--> $DIR/issue-87261.rs:68:5
|
||||||
|
|
|
||||||
|
LL | fn accepts_generic_trait<T: GenericTrait<(), Associated = ()>>(_: T) {}
|
||||||
|
| --------------- required by this bound in `accepts_generic_trait`
|
||||||
|
...
|
||||||
|
LL | accepts_generic_trait(e);
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^ expected `()`, found associated type
|
||||||
|
|
|
||||||
|
= note: expected unit type `()`
|
||||||
|
found associated type `<E as GenericTrait<()>>::Associated`
|
||||||
|
help: consider constraining the associated type `<E as GenericTrait<()>>::Associated` to `()`
|
||||||
|
|
|
||||||
|
LL | E: GenericTrait<(), Associated = ()> + 'static,
|
||||||
|
| ^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
error[E0271]: type mismatch resolving `<F as GenericTrait<()>>::Associated == ()`
|
||||||
|
--> $DIR/issue-87261.rs:71:5
|
||||||
|
|
|
||||||
|
LL | fn accepts_generic_trait<T: GenericTrait<(), Associated = ()>>(_: T) {}
|
||||||
|
| --------------- required by this bound in `accepts_generic_trait`
|
||||||
|
...
|
||||||
|
LL | accepts_generic_trait(f);
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^ expected `()`, found associated type
|
||||||
|
|
|
||||||
|
= note: expected unit type `()`
|
||||||
|
found associated type `<F as GenericTrait<()>>::Associated`
|
||||||
|
help: consider constraining the associated type `<F as GenericTrait<()>>::Associated` to `()`
|
||||||
|
|
|
||||||
|
LL | F: GenericTrait<(), Associated = ()> + Foo,
|
||||||
|
| ^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
error[E0271]: type mismatch resolving `<G as GenericTrait<()>>::Associated == ()`
|
||||||
|
--> $DIR/issue-87261.rs:74:5
|
||||||
|
|
|
||||||
|
LL | fn accepts_generic_trait<T: GenericTrait<(), Associated = ()>>(_: T) {}
|
||||||
|
| --------------- required by this bound in `accepts_generic_trait`
|
||||||
|
...
|
||||||
|
LL | accepts_generic_trait(g);
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^ expected `()`, found associated type
|
||||||
|
|
|
||||||
|
= note: expected unit type `()`
|
||||||
|
found associated type `<G as GenericTrait<()>>::Associated`
|
||||||
|
= help: consider constraining the associated type `<G as GenericTrait<()>>::Associated` to `()`
|
||||||
|
= note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
|
||||||
|
|
||||||
|
error[E0271]: type mismatch resolving `<impl Trait as Trait>::Associated == ()`
|
||||||
|
--> $DIR/issue-87261.rs:79:5
|
||||||
|
|
|
||||||
|
LL | fn returns_opaque() -> impl Trait + 'static {
|
||||||
|
| -------------------- the found opaque type
|
||||||
|
...
|
||||||
|
LL | fn accepts_trait<T: Trait<Associated = ()>>(_: T) {}
|
||||||
|
| --------------- required by this bound in `accepts_trait`
|
||||||
|
...
|
||||||
|
LL | accepts_trait(returns_opaque());
|
||||||
|
| ^^^^^^^^^^^^^ expected `()`, found associated type
|
||||||
|
|
|
||||||
|
= note: expected unit type `()`
|
||||||
|
found associated type `<impl Trait as Trait>::Associated`
|
||||||
|
help: consider constraining the associated type `<impl Trait as Trait>::Associated` to `()`
|
||||||
|
|
|
||||||
|
LL | fn returns_opaque() -> impl Trait<Associated = ()> + 'static {
|
||||||
|
| ^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
error[E0271]: type mismatch resolving `<impl DerivedTrait as Trait>::Associated == ()`
|
||||||
|
--> $DIR/issue-87261.rs:82:5
|
||||||
|
|
|
||||||
|
LL | fn returns_opaque_derived() -> impl DerivedTrait + 'static {
|
||||||
|
| --------------------------- the found opaque type
|
||||||
|
...
|
||||||
|
LL | fn accepts_trait<T: Trait<Associated = ()>>(_: T) {}
|
||||||
|
| --------------- required by this bound in `accepts_trait`
|
||||||
|
...
|
||||||
|
LL | accepts_trait(returns_opaque_derived());
|
||||||
|
| ^^^^^^^^^^^^^ expected `()`, found associated type
|
||||||
|
|
|
||||||
|
= note: expected unit type `()`
|
||||||
|
found associated type `<impl DerivedTrait as Trait>::Associated`
|
||||||
|
help: consider constraining the associated type `<impl DerivedTrait as Trait>::Associated` to `()`
|
||||||
|
|
|
||||||
|
LL | fn returns_opaque_derived() -> impl DerivedTrait<Associated = ()> + 'static {
|
||||||
|
| ^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
error[E0271]: type mismatch resolving `<impl Trait+Foo as Trait>::Associated == ()`
|
||||||
|
--> $DIR/issue-87261.rs:85:5
|
||||||
|
|
|
||||||
|
LL | fn returns_opaque_foo() -> impl Trait + Foo {
|
||||||
|
| ---------------- the found opaque type
|
||||||
|
...
|
||||||
|
LL | fn accepts_trait<T: Trait<Associated = ()>>(_: T) {}
|
||||||
|
| --------------- required by this bound in `accepts_trait`
|
||||||
|
...
|
||||||
|
LL | accepts_trait(returns_opaque_foo());
|
||||||
|
| ^^^^^^^^^^^^^ expected `()`, found associated type
|
||||||
|
|
|
||||||
|
= note: expected unit type `()`
|
||||||
|
found associated type `<impl Trait+Foo as Trait>::Associated`
|
||||||
|
help: consider constraining the associated type `<impl Trait+Foo as Trait>::Associated` to `()`
|
||||||
|
|
|
||||||
|
LL | fn returns_opaque_foo() -> impl Trait<Associated = ()> + Foo {
|
||||||
|
| ^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
error[E0271]: type mismatch resolving `<impl DerivedTrait+Foo as Trait>::Associated == ()`
|
||||||
|
--> $DIR/issue-87261.rs:88:5
|
||||||
|
|
|
||||||
|
LL | fn returns_opaque_derived_foo() -> impl DerivedTrait + Foo {
|
||||||
|
| ----------------------- the found opaque type
|
||||||
|
...
|
||||||
|
LL | fn accepts_trait<T: Trait<Associated = ()>>(_: T) {}
|
||||||
|
| --------------- required by this bound in `accepts_trait`
|
||||||
|
...
|
||||||
|
LL | accepts_trait(returns_opaque_derived_foo());
|
||||||
|
| ^^^^^^^^^^^^^ expected `()`, found associated type
|
||||||
|
|
|
||||||
|
= note: expected unit type `()`
|
||||||
|
found associated type `<impl DerivedTrait+Foo as Trait>::Associated`
|
||||||
|
= help: consider constraining the associated type `<impl DerivedTrait+Foo as Trait>::Associated` to `()`
|
||||||
|
= note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
|
||||||
|
|
||||||
|
error[E0271]: type mismatch resolving `<impl GenericTrait<()> as GenericTrait<()>>::Associated == ()`
|
||||||
|
--> $DIR/issue-87261.rs:91:5
|
||||||
|
|
|
||||||
|
LL | fn returns_opaque_generic() -> impl GenericTrait<()> + 'static {
|
||||||
|
| ------------------------------- the found opaque type
|
||||||
|
...
|
||||||
|
LL | fn accepts_generic_trait<T: GenericTrait<(), Associated = ()>>(_: T) {}
|
||||||
|
| --------------- required by this bound in `accepts_generic_trait`
|
||||||
|
...
|
||||||
|
LL | accepts_generic_trait(returns_opaque_generic());
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^ expected `()`, found associated type
|
||||||
|
|
|
||||||
|
= note: expected unit type `()`
|
||||||
|
found associated type `<impl GenericTrait<()> as GenericTrait<()>>::Associated`
|
||||||
|
help: consider constraining the associated type `<impl GenericTrait<()> as GenericTrait<()>>::Associated` to `()`
|
||||||
|
|
|
||||||
|
LL | fn returns_opaque_generic() -> impl GenericTrait<(), Associated = ()> + 'static {
|
||||||
|
| ^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
error[E0271]: type mismatch resolving `<impl GenericTrait<()>+Foo as GenericTrait<()>>::Associated == ()`
|
||||||
|
--> $DIR/issue-87261.rs:94:5
|
||||||
|
|
|
||||||
|
LL | fn returns_opaque_generic_foo() -> impl GenericTrait<()> + Foo {
|
||||||
|
| --------------------------- the found opaque type
|
||||||
|
...
|
||||||
|
LL | fn accepts_generic_trait<T: GenericTrait<(), Associated = ()>>(_: T) {}
|
||||||
|
| --------------- required by this bound in `accepts_generic_trait`
|
||||||
|
...
|
||||||
|
LL | accepts_generic_trait(returns_opaque_generic_foo());
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^ expected `()`, found associated type
|
||||||
|
|
|
||||||
|
= note: expected unit type `()`
|
||||||
|
found associated type `<impl GenericTrait<()>+Foo as GenericTrait<()>>::Associated`
|
||||||
|
help: consider constraining the associated type `<impl GenericTrait<()>+Foo as GenericTrait<()>>::Associated` to `()`
|
||||||
|
|
|
||||||
|
LL | fn returns_opaque_generic_foo() -> impl GenericTrait<(), Associated = ()> + Foo {
|
||||||
|
| ^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
error[E0271]: type mismatch resolving `<impl GenericTrait<()>+GenericTrait<u8> as GenericTrait<()>>::Associated == ()`
|
||||||
|
--> $DIR/issue-87261.rs:97:5
|
||||||
|
|
|
||||||
|
LL | fn returns_opaque_generic_duplicate() -> impl GenericTrait<()> + GenericTrait<u8> {
|
||||||
|
| ---------------------------------------- the found opaque type
|
||||||
|
...
|
||||||
|
LL | fn accepts_generic_trait<T: GenericTrait<(), Associated = ()>>(_: T) {}
|
||||||
|
| --------------- required by this bound in `accepts_generic_trait`
|
||||||
|
...
|
||||||
|
LL | accepts_generic_trait(returns_opaque_generic_duplicate());
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^ expected `()`, found associated type
|
||||||
|
|
|
||||||
|
= note: expected unit type `()`
|
||||||
|
found associated type `<impl GenericTrait<()>+GenericTrait<u8> as GenericTrait<()>>::Associated`
|
||||||
|
= help: consider constraining the associated type `<impl GenericTrait<()>+GenericTrait<u8> as GenericTrait<()>>::Associated` to `()`
|
||||||
|
= note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
|
||||||
|
|
||||||
|
error: aborting due to 14 previous errors
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0271`.
|
@ -1,7 +1,6 @@
|
|||||||
// compile-flags: --target x86_64-unknown-uefi
|
// compile-flags: --target x86_64-unknown-uefi
|
||||||
// needs-llvm-components: x86
|
// needs-llvm-components: x86
|
||||||
// rustc-env:CARGO=/usr/bin/cargo
|
// rustc-env:CARGO=/usr/bin/cargo
|
||||||
// rustc-env:RUSTUP_HOME=/home/bors/.rustup
|
|
||||||
#![no_core]
|
#![no_core]
|
||||||
extern crate core;
|
extern crate core;
|
||||||
//~^ ERROR can't find crate for `core`
|
//~^ ERROR can't find crate for `core`
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
error[E0463]: can't find crate for `core`
|
error[E0463]: can't find crate for `core`
|
||||||
--> $DIR/missing-std.rs:6:1
|
--> $DIR/missing-std.rs:5:1
|
||||||
|
|
|
|
||||||
LL | extern crate core;
|
LL | extern crate core;
|
||||||
| ^^^^^^^^^^^^^^^^^^ can't find crate
|
| ^^^^^^^^^^^^^^^^^^ can't find crate
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
error[E0463]: can't find crate for `std`
|
error[E0463]: can't find crate for `std`
|
||||||
|
|
|
|
||||||
= note: the `thumbv6m-none-eabi` target may not be installed
|
= note: the `thumbv6m-none-eabi` target may not be installed
|
||||||
|
= help: consider downloading the target with `rustup target add thumbv6m-none-eabi`
|
||||||
|
= help: consider building the standard library from source with `cargo build -Zbuild-std`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
error[E0463]: can't find crate for `core`
|
error[E0463]: can't find crate for `core`
|
||||||
|
|
|
|
||||||
= note: the `thumbv7em-none-eabihf` target may not be installed
|
= note: the `thumbv7em-none-eabihf` target may not be installed
|
||||||
|
= help: consider downloading the target with `rustup target add thumbv7em-none-eabihf`
|
||||||
|
= help: consider building the standard library from source with `cargo build -Zbuild-std`
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
@ -36,8 +36,8 @@ fn deref_union_field(mut u: URef) {
|
|||||||
|
|
||||||
fn assign_noncopy_union_field(mut u: URefCell) {
|
fn assign_noncopy_union_field(mut u: URefCell) {
|
||||||
// FIXME(thir-unsafeck)
|
// FIXME(thir-unsafeck)
|
||||||
u.a = (RefCell::new(0), 1); //[mir]~ ERROR assignment to union field that might need dropping
|
u.a = (RefCell::new(0), 1); //~ ERROR assignment to union field that might need dropping
|
||||||
u.a.0 = RefCell::new(0); //[mir]~ ERROR assignment to union field that might need dropping
|
u.a.0 = RefCell::new(0); //~ ERROR assignment to union field that might need dropping
|
||||||
u.a.1 = 1; // OK
|
u.a.1 = 1; // OK
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,22 @@ LL | *(u.p) = 13;
|
|||||||
|
|
|
|
||||||
= note: the field may not be properly initialized: using uninitialized data will cause undefined behavior
|
= note: the field may not be properly initialized: using uninitialized data will cause undefined behavior
|
||||||
|
|
||||||
|
error[E0133]: assignment to union field that might need dropping is unsafe and requires unsafe function or block
|
||||||
|
--> $DIR/union-unsafe.rs:39:5
|
||||||
|
|
|
||||||
|
LL | u.a = (RefCell::new(0), 1);
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ assignment to union field that might need dropping
|
||||||
|
|
|
||||||
|
= note: the previous content of the field will be dropped, which causes undefined behavior if the field was not properly initialized
|
||||||
|
|
||||||
|
error[E0133]: assignment to union field that might need dropping is unsafe and requires unsafe function or block
|
||||||
|
--> $DIR/union-unsafe.rs:40:5
|
||||||
|
|
|
||||||
|
LL | u.a.0 = RefCell::new(0);
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^ assignment to union field that might need dropping
|
||||||
|
|
|
||||||
|
= note: the previous content of the field will be dropped, which causes undefined behavior if the field was not properly initialized
|
||||||
|
|
||||||
error[E0133]: access to union field is unsafe and requires unsafe function or block
|
error[E0133]: access to union field is unsafe and requires unsafe function or block
|
||||||
--> $DIR/union-unsafe.rs:47:6
|
--> $DIR/union-unsafe.rs:47:6
|
||||||
|
|
|
|
||||||
@ -70,6 +86,6 @@ LL | *u3.a = String::from("new");
|
|||||||
|
|
|
|
||||||
= note: the field may not be properly initialized: using uninitialized data will cause undefined behavior
|
= note: the field may not be properly initialized: using uninitialized data will cause undefined behavior
|
||||||
|
|
||||||
error: aborting due to 9 previous errors
|
error: aborting due to 11 previous errors
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0133`.
|
For more information about this error, try `rustc --explain E0133`.
|
||||||
|
Loading…
Reference in New Issue
Block a user