Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 9 pull requests #79122

Closed
wants to merge 36 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
6e88e96
Support repr(simd) on ADTs containing a single array field
gnzlbg Jul 13, 2019
9bb4202
update ui tests
KodrAus Nov 8, 2020
899d9b9
Fix test checking that into_boxed_slice does not panic
tmiasko Nov 12, 2020
28463aa
Ensure that closure call is not removed by MIR optimizations in a test
tmiasko Nov 12, 2020
d54ea4f
Fix codegen test for issue 37945
tmiasko Nov 12, 2020
540b5db
remove const_generics from codegen tests
KodrAus Nov 13, 2020
045105b
remove internal simd_size_and_ty from llvm backend
KodrAus Nov 13, 2020
74f2941
tweak new codegen test to work on local
KodrAus Nov 14, 2020
e0f3119
Introduce `TypeVisitor::BreakTy`
LeSeulArtichaut Nov 5, 2020
17b395d
Use `TypeVisitor::BreakTy` in `structural_match::Search`
LeSeulArtichaut Nov 5, 2020
23feec3
Use `TypeVisitor::BreakTy` in `ProhibitOpaqueVisitor`
LeSeulArtichaut Nov 5, 2020
29b140a
Use `TypeVisitor::BreakTy` in `HasTypeFlagsVisitor`
LeSeulArtichaut Nov 5, 2020
44f7d8f
Use `TypeVisitor::BreakTy` in `HasEscapingVarsVisitor`
LeSeulArtichaut Nov 5, 2020
df6e87c
Use `TypeVisitor::BreakTy` in `UnresolvedTypeFinder`
LeSeulArtichaut Nov 6, 2020
65cdc21
Set the default `BreakTy` to `!`
LeSeulArtichaut Nov 14, 2020
07b37cf
Use `TypeVisitor::BreakTy` in `ProhibitOpaqueTypes`
LeSeulArtichaut Nov 14, 2020
7565809
add a canary test for complex repr(simd)
KodrAus Nov 14, 2020
f27d56d
Limit storage duration of inlined always live locals
tmiasko Nov 15, 2020
e217fc4
fix up tidy
KodrAus Nov 15, 2020
43bfbb1
Add column number support to Backtrace
est31 Nov 12, 2020
f6e6a15
Remove dead `TypeFoldable::visit_tys_shallow` method
LeSeulArtichaut Nov 15, 2020
1861a38
Ensure that the source code display is working with DOS backline
GuillaumeGomez Oct 14, 2020
af869c2
document that __rust_alloc is also magic to our LLVM fork
RalfJung Nov 15, 2020
0c52044
Add test to ensure that no DOS backline (\r\n) doesn't create extra b…
GuillaumeGomez Nov 15, 2020
7986bb8
Don't warn about invalid HTML tags in code blocks
GuillaumeGomez Nov 16, 2020
bbd302b
Add test to ensure that "invalid HTML tag" lint isn't fired in code b…
GuillaumeGomez Nov 16, 2020
a78966d
clarify `span_label` documentation
euclio Nov 16, 2020
0ad71f3
Rollup merge of #77939 - GuillaumeGomez:fix-source-code-dos-backline,…
Dylan-DPC Nov 17, 2020
975b50d
Rollup merge of #78779 - LeSeulArtichaut:ty-visitor-return, r=oli-obk
Dylan-DPC Nov 17, 2020
80c3b55
Rollup merge of #78863 - KodrAus:feat/simd-array, r=oli-obk
Dylan-DPC Nov 17, 2020
5a6cbaf
Rollup merge of #78967 - tmiasko:codegen-tests, r=cuviper
Dylan-DPC Nov 17, 2020
d037be3
Rollup merge of #79002 - est31:backtrace_colno, r=dtolnay
Dylan-DPC Nov 17, 2020
77dc14a
Rollup merge of #79027 - tmiasko:inline-always-live-locals, r=oli-obk
Dylan-DPC Nov 17, 2020
7c50422
Rollup merge of #79077 - RalfJung:llvm-magic, r=Mark-Simulacrum
Dylan-DPC Nov 17, 2020
f25688b
Rollup merge of #79088 - euclio:span-label-doc, r=estebank
Dylan-DPC Nov 17, 2020
da0319b
Rollup merge of #79097 - GuillaumeGomez:code-block-invalid-html-tag-l…
Dylan-DPC Nov 17, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 55 additions & 50 deletions compiler/rustc_codegen_llvm/src/intrinsic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,7 @@ fn generic_simd_intrinsic(
_ => return_error!("`{}` is not an integral type", in_ty),
};
require_simd!(arg_tys[1], "argument");
let v_len = arg_tys[1].simd_size(tcx);
let (v_len, _) = arg_tys[1].simd_size_and_type(bx.tcx());
require!(
// Allow masks for vectors with fewer than 8 elements to be
// represented with a u8 or i8.
Expand All @@ -812,8 +812,6 @@ fn generic_simd_intrinsic(
// every intrinsic below takes a SIMD vector as its first argument
require_simd!(arg_tys[0], "input");
let in_ty = arg_tys[0];
let in_elem = arg_tys[0].simd_type(tcx);
let in_len = arg_tys[0].simd_size(tcx);

let comparison = match name {
sym::simd_eq => Some(hir::BinOpKind::Eq),
Expand All @@ -825,14 +823,15 @@ fn generic_simd_intrinsic(
_ => None,
};

let (in_len, in_elem) = arg_tys[0].simd_size_and_type(bx.tcx());
if let Some(cmp_op) = comparison {
require_simd!(ret_ty, "return");

let out_len = ret_ty.simd_size(tcx);
let (out_len, out_ty) = ret_ty.simd_size_and_type(bx.tcx());
require!(
in_len == out_len,
"expected return type with length {} (same as input type `{}`), \
found `{}` with length {}",
found `{}` with length {}",
in_len,
in_ty,
ret_ty,
Expand All @@ -842,7 +841,7 @@ fn generic_simd_intrinsic(
bx.type_kind(bx.element_type(llret_ty)) == TypeKind::Integer,
"expected return type with integer elements, found `{}` with non-integer `{}`",
ret_ty,
ret_ty.simd_type(tcx)
out_ty
);

return Ok(compare_simd_types(
Expand All @@ -862,7 +861,7 @@ fn generic_simd_intrinsic(

require_simd!(ret_ty, "return");

let out_len = ret_ty.simd_size(tcx);
let (out_len, out_ty) = ret_ty.simd_size_and_type(bx.tcx());
require!(
out_len == n,
"expected return type of length {}, found `{}` with length {}",
Expand All @@ -871,13 +870,13 @@ fn generic_simd_intrinsic(
out_len
);
require!(
in_elem == ret_ty.simd_type(tcx),
in_elem == out_ty,
"expected return element type `{}` (element of input `{}`), \
found `{}` with element type `{}`",
found `{}` with element type `{}`",
in_elem,
in_ty,
ret_ty,
ret_ty.simd_type(tcx)
out_ty
);

let total_len = u128::from(in_len) * 2;
Expand Down Expand Up @@ -946,7 +945,7 @@ fn generic_simd_intrinsic(
let m_elem_ty = in_elem;
let m_len = in_len;
require_simd!(arg_tys[1], "argument");
let v_len = arg_tys[1].simd_size(tcx);
let (v_len, _) = arg_tys[1].simd_size_and_type(bx.tcx());
require!(
m_len == v_len,
"mismatched lengths: mask length `{}` != other vector length `{}`",
Expand Down Expand Up @@ -1173,25 +1172,27 @@ fn generic_simd_intrinsic(
require_simd!(ret_ty, "return");

// Of the same length:
let (out_len, _) = arg_tys[1].simd_size_and_type(bx.tcx());
let (out_len2, _) = arg_tys[2].simd_size_and_type(bx.tcx());
require!(
in_len == arg_tys[1].simd_size(tcx),
in_len == out_len,
"expected {} argument with length {} (same as input type `{}`), \
found `{}` with length {}",
found `{}` with length {}",
"second",
in_len,
in_ty,
arg_tys[1],
arg_tys[1].simd_size(tcx)
out_len
);
require!(
in_len == arg_tys[2].simd_size(tcx),
in_len == out_len2,
"expected {} argument with length {} (same as input type `{}`), \
found `{}` with length {}",
found `{}` with length {}",
"third",
in_len,
in_ty,
arg_tys[2],
arg_tys[2].simd_size(tcx)
out_len2
);

// The return type must match the first argument type
Expand All @@ -1215,39 +1216,40 @@ fn generic_simd_intrinsic(

// The second argument must be a simd vector with an element type that's a pointer
// to the element type of the first argument
let (pointer_count, underlying_ty) = match arg_tys[1].simd_type(tcx).kind() {
ty::RawPtr(p) if p.ty == in_elem => {
(ptr_count(arg_tys[1].simd_type(tcx)), non_ptr(arg_tys[1].simd_type(tcx)))
}
let (_, element_ty0) = arg_tys[0].simd_size_and_type(bx.tcx());
let (_, element_ty1) = arg_tys[1].simd_size_and_type(bx.tcx());
let (pointer_count, underlying_ty) = match element_ty1.kind() {
ty::RawPtr(p) if p.ty == in_elem => (ptr_count(element_ty1), non_ptr(element_ty1)),
_ => {
require!(
false,
"expected element type `{}` of second argument `{}` \
to be a pointer to the element type `{}` of the first \
argument `{}`, found `{}` != `*_ {}`",
arg_tys[1].simd_type(tcx),
to be a pointer to the element type `{}` of the first \
argument `{}`, found `{}` != `*_ {}`",
element_ty1,
arg_tys[1],
in_elem,
in_ty,
arg_tys[1].simd_type(tcx),
element_ty1,
in_elem
);
unreachable!();
}
};
assert!(pointer_count > 0);
assert_eq!(pointer_count - 1, ptr_count(arg_tys[0].simd_type(tcx)));
assert_eq!(underlying_ty, non_ptr(arg_tys[0].simd_type(tcx)));
assert_eq!(pointer_count - 1, ptr_count(element_ty0));
assert_eq!(underlying_ty, non_ptr(element_ty0));

// The element type of the third argument must be a signed integer type of any width:
match arg_tys[2].simd_type(tcx).kind() {
let (_, element_ty2) = arg_tys[2].simd_size_and_type(bx.tcx());
match element_ty2.kind() {
ty::Int(_) => (),
_ => {
require!(
false,
"expected element type `{}` of third argument `{}` \
to be a signed integer type",
arg_tys[2].simd_type(tcx),
element_ty2,
arg_tys[2]
);
}
Expand Down Expand Up @@ -1299,25 +1301,27 @@ fn generic_simd_intrinsic(
require_simd!(arg_tys[2], "third");

// Of the same length:
let (element_len1, _) = arg_tys[1].simd_size_and_type(bx.tcx());
let (element_len2, _) = arg_tys[2].simd_size_and_type(bx.tcx());
require!(
in_len == arg_tys[1].simd_size(tcx),
in_len == element_len1,
"expected {} argument with length {} (same as input type `{}`), \
found `{}` with length {}",
found `{}` with length {}",
"second",
in_len,
in_ty,
arg_tys[1],
arg_tys[1].simd_size(tcx)
element_len1
);
require!(
in_len == arg_tys[2].simd_size(tcx),
in_len == element_len2,
"expected {} argument with length {} (same as input type `{}`), \
found `{}` with length {}",
found `{}` with length {}",
"third",
in_len,
in_ty,
arg_tys[2],
arg_tys[2].simd_size(tcx)
element_len2
);

// This counts how many pointers
Expand All @@ -1338,39 +1342,42 @@ fn generic_simd_intrinsic(

// The second argument must be a simd vector with an element type that's a pointer
// to the element type of the first argument
let (pointer_count, underlying_ty) = match arg_tys[1].simd_type(tcx).kind() {
let (_, element_ty0) = arg_tys[0].simd_size_and_type(bx.tcx());
let (_, element_ty1) = arg_tys[1].simd_size_and_type(bx.tcx());
let (_, element_ty2) = arg_tys[2].simd_size_and_type(bx.tcx());
let (pointer_count, underlying_ty) = match element_ty1.kind() {
ty::RawPtr(p) if p.ty == in_elem && p.mutbl == hir::Mutability::Mut => {
(ptr_count(arg_tys[1].simd_type(tcx)), non_ptr(arg_tys[1].simd_type(tcx)))
(ptr_count(element_ty1), non_ptr(element_ty1))
}
_ => {
require!(
false,
"expected element type `{}` of second argument `{}` \
to be a pointer to the element type `{}` of the first \
argument `{}`, found `{}` != `*mut {}`",
arg_tys[1].simd_type(tcx),
to be a pointer to the element type `{}` of the first \
argument `{}`, found `{}` != `*mut {}`",
element_ty1,
arg_tys[1],
in_elem,
in_ty,
arg_tys[1].simd_type(tcx),
element_ty1,
in_elem
);
unreachable!();
}
};
assert!(pointer_count > 0);
assert_eq!(pointer_count - 1, ptr_count(arg_tys[0].simd_type(tcx)));
assert_eq!(underlying_ty, non_ptr(arg_tys[0].simd_type(tcx)));
assert_eq!(pointer_count - 1, ptr_count(element_ty0));
assert_eq!(underlying_ty, non_ptr(element_ty0));

// The element type of the third argument must be a signed integer type of any width:
match arg_tys[2].simd_type(tcx).kind() {
match element_ty2.kind() {
ty::Int(_) => (),
_ => {
require!(
false,
"expected element type `{}` of third argument `{}` \
to be a signed integer type",
arg_tys[2].simd_type(tcx),
be a signed integer type",
element_ty2,
arg_tys[2]
);
}
Expand Down Expand Up @@ -1567,7 +1574,7 @@ unsupported {} from `{}` with element `{}` of size `{}` to `{}`"#,

if name == sym::simd_cast {
require_simd!(ret_ty, "return");
let out_len = ret_ty.simd_size(tcx);
let (out_len, out_elem) = ret_ty.simd_size_and_type(bx.tcx());
require!(
in_len == out_len,
"expected return type with length {} (same as input type `{}`), \
Expand All @@ -1578,8 +1585,6 @@ unsupported {} from `{}` with element `{}` of size `{}` to `{}`"#,
out_len
);
// casting cares about nominal type, not just structural type
let out_elem = ret_ty.simd_type(tcx);

if in_elem == out_elem {
return Ok(args[0].immediate());
}
Expand Down Expand Up @@ -1695,7 +1700,7 @@ unsupported {} from `{}` with element `{}` of size `{}` to `{}`"#,
return_error!(
"expected element type `{}` of vector type `{}` \
to be a signed or unsigned integer type",
arg_tys[0].simd_type(tcx),
arg_tys[0].simd_size_and_type(bx.tcx()).1,
arg_tys[0]
);
}
Expand Down
18 changes: 10 additions & 8 deletions compiler/rustc_errors/src/diagnostic_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,16 +184,18 @@ impl<'a> DiagnosticBuilder<'a> {
self.cancel();
}

/// Adds a span/label to be included in the resulting snippet.
/// Appends a labeled span to the diagnostic.
///
/// This is pushed onto the [`MultiSpan`] that was created when the diagnostic
/// was first built. That means it will be shown together with the original
/// span/label, *not* a span added by one of the `span_{note,warn,help,suggestions}` methods.
/// Labels are used to convey additional context for the diagnostic's primary span. They will
/// be shown together with the original diagnostic's span, *not* with spans added by
/// `span_note`, `span_help`, etc. Therefore, if the primary span is not displayable (because
/// the span is `DUMMY_SP` or the source code isn't found), labels will not be displayed
/// either.
///
/// This span is *not* considered a ["primary span"][`MultiSpan`]; only
/// the `Span` supplied when creating the diagnostic is primary.
///
/// [`MultiSpan`]: ../rustc_span/struct.MultiSpan.html
/// Implementation-wise, the label span is pushed onto the [`MultiSpan`] that was created when
/// the diagnostic was constructed. However, the label span is *not* considered a
/// ["primary span"][`MultiSpan`]; only the `Span` supplied when creating the diagnostic is
/// primary.
pub fn span_label(&mut self, span: Span, label: impl Into<String>) -> &mut Self {
self.0.diagnostic.span_label(span, label);
self
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_infer/src/infer/error_reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1498,7 +1498,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
}

impl<'tcx> ty::fold::TypeVisitor<'tcx> for OpaqueTypesVisitor<'tcx> {
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<()> {
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
if let Some((kind, def_id)) = TyCategory::from_ty(t) {
let span = self.tcx.def_span(def_id);
// Avoid cluttering the output when the "found" and error span overlap:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
struct TraitObjectVisitor(Vec<DefId>);

impl TypeVisitor<'_> for TraitObjectVisitor {
fn visit_ty(&mut self, t: Ty<'_>) -> ControlFlow<()> {
fn visit_ty(&mut self, t: Ty<'_>) -> ControlFlow<Self::BreakTy> {
match t.kind() {
ty::Dynamic(preds, RegionKind::ReStatic) => {
if let Some(def_id) = preds.principal_def_id() {
Expand Down
6 changes: 1 addition & 5 deletions compiler/rustc_infer/src/infer/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
//! See the Book for more information.

pub use self::freshen::TypeFreshener;
pub use self::LateBoundRegionConversionTime::*;
pub use self::RegionVariableOrigin::*;
Expand Down Expand Up @@ -1334,9 +1332,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
where
T: TypeFoldable<'tcx>,
{
let mut r = resolve::UnresolvedTypeFinder::new(self);
value.visit_with(&mut r);
r.first_unresolved
value.visit_with(&mut resolve::UnresolvedTypeFinder::new(self)).break_value()
}

pub fn probe_const_var(
Expand Down
7 changes: 5 additions & 2 deletions compiler/rustc_infer/src/infer/nll_relate/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -741,15 +741,18 @@ struct ScopeInstantiator<'me, 'tcx> {
}

impl<'me, 'tcx> TypeVisitor<'tcx> for ScopeInstantiator<'me, 'tcx> {
fn visit_binder<T: TypeFoldable<'tcx>>(&mut self, t: &ty::Binder<T>) -> ControlFlow<()> {
fn visit_binder<T: TypeFoldable<'tcx>>(
&mut self,
t: &ty::Binder<T>,
) -> ControlFlow<Self::BreakTy> {
self.target_index.shift_in(1);
t.super_visit_with(self);
self.target_index.shift_out(1);

ControlFlow::CONTINUE
}

fn visit_region(&mut self, r: ty::Region<'tcx>) -> ControlFlow<()> {
fn visit_region(&mut self, r: ty::Region<'tcx>) -> ControlFlow<Self::BreakTy> {
let ScopeInstantiator { bound_region_scope, next_region, .. } = self;

match r {
Expand Down
11 changes: 4 additions & 7 deletions compiler/rustc_infer/src/infer/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,19 +111,17 @@ impl<'a, 'tcx> TypeFolder<'tcx> for OpportunisticRegionResolver<'a, 'tcx> {
/// involve some hashing and so forth).
pub struct UnresolvedTypeFinder<'a, 'tcx> {
infcx: &'a InferCtxt<'a, 'tcx>,

/// Used to find the type parameter name and location for error reporting.
pub first_unresolved: Option<(Ty<'tcx>, Option<Span>)>,
}

impl<'a, 'tcx> UnresolvedTypeFinder<'a, 'tcx> {
pub fn new(infcx: &'a InferCtxt<'a, 'tcx>) -> Self {
UnresolvedTypeFinder { infcx, first_unresolved: None }
UnresolvedTypeFinder { infcx }
}
}

impl<'a, 'tcx> TypeVisitor<'tcx> for UnresolvedTypeFinder<'a, 'tcx> {
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<()> {
type BreakTy = (Ty<'tcx>, Option<Span>);
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
let t = self.infcx.shallow_resolve(t);
if t.has_infer_types() {
if let ty::Infer(infer_ty) = *t.kind() {
Expand All @@ -144,8 +142,7 @@ impl<'a, 'tcx> TypeVisitor<'tcx> for UnresolvedTypeFinder<'a, 'tcx> {
} else {
None
};
self.first_unresolved = Some((t, ty_var_span));
ControlFlow::BREAK
ControlFlow::Break((t, ty_var_span))
} else {
// Otherwise, visit its contents.
t.super_visit_with(self)
Expand Down
Loading