Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
6f6620b
Rename "cyclone" to "apple-a7" per changes in upstream LLVM
trevyn Jun 7, 2020
95c4899
Added an example where explicitly dropping a lock is necessary/a good…
poliorcetics Jun 7, 2020
9c8f881
Improved the example to work with mutable data, providing a reason fo…
poliorcetics Jun 7, 2020
fdef1a5
Simply use drop instead of std::mem::drop
poliorcetics Jun 8, 2020
496818c
Add methods to go from a nul-terminated Vec<u8> to a CString, checked…
poliorcetics Jun 8, 2020
b03164e
Move to unstable, linking the issue
poliorcetics Jun 9, 2020
1312d30
Remove a lot of unecessary/duplicated comments
poliorcetics Jun 9, 2020
88ea7e5
Use min_specialization in the remaining rustc crates
matthewjasper Jun 1, 2020
c29b3fa
On recursive ADT, provide indirection structured suggestion
estebank May 29, 2020
7cde07e
review comments: only suggest one substitution
estebank May 31, 2020
03552ec
fix rebase
estebank Jun 10, 2020
7f3bb39
Add a TryFrom<Vec<u8>> impl that mirror from_vec_with_nul
poliorcetics Jun 10, 2020
6b95526
Fix the link in the TryFrom impl
poliorcetics Jun 11, 2020
871513d
make miri memory TyCtxtAt a TyCtxt
RalfJung Jun 1, 2020
dc6ffae
make miri InterpCx TyCtxtAt a TyCtxt, and separately remember the roo…
RalfJung Jun 1, 2020
0ac6fd0
fix const_prop spans and re-bless tests
RalfJung Jun 1, 2020
32b01c7
avoid computing cur_span all the time
RalfJung Jun 11, 2020
c0aef6d
Remove vestigial CI job msvc-aux.
ehuss Jun 12, 2020
8b20928
Stabilize Option::zip
tesuji Jun 13, 2020
c45231c
Revert heterogeneous SocketAddr PartialEq impls
dtolnay Jun 13, 2020
6049650
avoid computing precise span for const_eval query
RalfJung Jun 13, 2020
c6512fd
run const_eval_raw with root_span
RalfJung Jun 13, 2020
f747073
Apply suggestions from code review
poliorcetics Jun 13, 2020
34b3ff0
Clarify the scope-related explanation
poliorcetics Jun 13, 2020
c010e71
Rewrap comments in Mutex example
dtolnay Jun 13, 2020
204c236
Add test for comparing SocketAddr with inferred right-hand side
dtolnay Jun 13, 2020
71d41d9
add TcpListener support for HermitCore
stlankes Jun 13, 2020
c99116a
remove unused function
stlankes Jun 13, 2020
fd86a84
use latest interface to HermitCore
stlankes Jun 13, 2020
2210abe
keep root_span and tcx together
RalfJung Jun 14, 2020
5f4eb27
Removing the TryFrom impl
poliorcetics Jun 14, 2020
685f066
Add a new error type for the new method
poliorcetics Jun 14, 2020
47cc5cc
Update to use the new error type and correctly compile the doc tests
poliorcetics Jun 14, 2020
d221ffc
simplify conversion to IpAddr::V6
stlankes Jun 14, 2020
9d596b5
changes to pass the format check
stlankes Jun 15, 2020
810ba39
remove obsolete line
stlankes Jun 15, 2020
aa53a03
Revert "changes to pass the format check"
stlankes Jun 15, 2020
9c9f21f
Revert "simplify conversion to IpAddr::V6"
stlankes Jun 15, 2020
6c983a7
use Ipv6Addr::from to build the IPv6 address
stlankes Jun 15, 2020
a8e3746
add comment about the usage of Arc
stlankes Jun 15, 2020
76f1581
remove obsolete , to pass the format check
stlankes Jun 15, 2020
eef9356
Rollup merge of #72707 - matthewjasper:rustc_min_spec, r=oli-obk
RalfJung Jun 15, 2020
d97e8ca
Rollup merge of #72740 - estebank:recursive-indirection, r=matthewjasper
RalfJung Jun 15, 2020
f9c8a67
Rollup merge of #72879 - RalfJung:miri-tctx-at, r=oli-obk
RalfJung Jun 15, 2020
89eb74d
Rollup merge of #72938 - lzutao:stabilize_option_zip, r=dtolnay
RalfJung Jun 15, 2020
3440957
Rollup merge of #73086 - trevyn:apple-a7, r=nikic
RalfJung Jun 15, 2020
7c8b941
Rollup merge of #73104 - poliorcetics:explicit-mutex-drop-example, r=…
RalfJung Jun 15, 2020
ec6fe42
Rollup merge of #73139 - poliorcetics:cstring-from-vec-with-nul, r=dt…
RalfJung Jun 15, 2020
fb75d4a
Rollup merge of #73296 - ehuss:remove-msvc-aux, r=Mark-Simulacrum
RalfJung Jun 15, 2020
202499f
Rollup merge of #73304 - dtolnay:socketeq, r=Mark-Simulacrum
RalfJung Jun 15, 2020
54bd077
Rollup merge of #73331 - hermitcore:listen, r=kennytm
RalfJung Jun 15, 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
23 changes: 23 additions & 0 deletions src/librustc_errors/diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,29 @@ impl Diagnostic {
self
}

pub fn multipart_suggestions(
&mut self,
msg: &str,
suggestions: Vec<Vec<(Span, String)>>,
applicability: Applicability,
) -> &mut Self {
self.suggestions.push(CodeSuggestion {
substitutions: suggestions
.into_iter()
.map(|suggestion| Substitution {
parts: suggestion
.into_iter()
.map(|(span, snippet)| SubstitutionPart { snippet, span })
.collect(),
})
.collect(),
msg: msg.to_owned(),
style: SuggestionStyle::ShowCode,
applicability,
});
self
}

/// Prints out a message with for a multipart suggestion without showing the suggested code.
///
/// This is intended to be used for suggestions that are obvious in what the changes need to
Expand Down
13 changes: 13 additions & 0 deletions src/librustc_errors/diagnostic_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,19 @@ impl<'a> DiagnosticBuilder<'a> {
self
}

pub fn multipart_suggestions(
&mut self,
msg: &str,
suggestions: Vec<Vec<(Span, String)>>,
applicability: Applicability,
) -> &mut Self {
if !self.0.allow_suggestions {
return self;
}
self.0.diagnostic.multipart_suggestions(msg, suggestions, applicability);
self
}

pub fn tool_only_multipart_suggestion(
&mut self,
msg: &str,
Expand Down
10 changes: 9 additions & 1 deletion src/librustc_middle/ty/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,15 @@ impl<'tcx> ty::TyS<'tcx> {
// Find non representable fields with their spans
fold_repr(def.all_fields().map(|field| {
let ty = field.ty(tcx, substs);
let span = tcx.hir().span_if_local(field.did).unwrap_or(sp);
let span = match field
.did
.as_local()
.map(|id| tcx.hir().as_local_hir_id(id))
.and_then(|id| tcx.hir().find(id))
{
Some(hir::Node::Field(field)) => field.ty.span,
_ => sp,
};
match is_type_structurally_recursive(
tcx,
span,
Expand Down
45 changes: 31 additions & 14 deletions src/librustc_trait_selection/traits/error_reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1747,24 +1747,41 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
pub fn recursive_type_with_infinite_size_error(
tcx: TyCtxt<'tcx>,
type_def_id: DefId,
) -> DiagnosticBuilder<'tcx> {
spans: Vec<Span>,
) {
assert!(type_def_id.is_local());
let span = tcx.hir().span_if_local(type_def_id).unwrap();
let span = tcx.sess.source_map().guess_head_span(span);
let mut err = struct_span_err!(
tcx.sess,
span,
E0072,
"recursive type `{}` has infinite size",
tcx.def_path_str(type_def_id)
);
let path = tcx.def_path_str(type_def_id);
let mut err =
struct_span_err!(tcx.sess, span, E0072, "recursive type `{}` has infinite size", path);
err.span_label(span, "recursive type has infinite size");
err.help(&format!(
"insert indirection (e.g., a `Box`, `Rc`, or `&`) \
at some point to make `{}` representable",
tcx.def_path_str(type_def_id)
));
err
for &span in &spans {
err.span_label(span, "recursive without indirection");
}
let msg = format!(
"insert some indirection (e.g., a `Box`, `Rc`, or `&`) to make `{}` representable",
path,
);
if spans.len() <= 4 {
err.multipart_suggestion(
&msg,
spans
.iter()
.flat_map(|&span| {
vec![
(span.shrink_to_lo(), "Box<".to_string()),
(span.shrink_to_hi(), ">".to_string()),
]
.into_iter()
})
.collect(),
Applicability::HasPlaceholders,
);
} else {
err.help(&msg);
}
err.emit();
}

/// Summarizes information
Expand Down
6 changes: 1 addition & 5 deletions src/librustc_typeck/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2387,11 +2387,7 @@ fn check_representable(tcx: TyCtxt<'_>, sp: Span, item_def_id: LocalDefId) -> bo
// caught by case 1.
match rty.is_representable(tcx, sp) {
Representability::SelfRecursive(spans) => {
let mut err = recursive_type_with_infinite_size_error(tcx, item_def_id.to_def_id());
for span in spans {
err.span_label(span, "recursive without indirection");
}
err.emit();
recursive_type_with_infinite_size_error(tcx, item_def_id.to_def_id(), spans);
return false;
}
Representability::Representable | Representability::ContainsRecursive => (),
Expand Down
5 changes: 4 additions & 1 deletion src/test/ui/infinite/infinite-tag-type-recursion.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ LL | enum MList { Cons(isize, MList), Nil }
| |
| recursive type has infinite size
|
= help: insert indirection (e.g., a `Box`, `Rc`, or `&`) at some point to make `MList` representable
help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to make `MList` representable
|
LL | enum MList { Cons(isize, Box<MList>), Nil }
| ^^^^ ^

error[E0391]: cycle detected when computing drop-check constraints for `MList`
--> $DIR/infinite-tag-type-recursion.rs:1:1
Expand Down
7 changes: 5 additions & 2 deletions src/test/ui/issues/issue-17431-1.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@ error[E0072]: recursive type `Foo` has infinite size
--> $DIR/issue-17431-1.rs:1:1
|
LL | struct Foo { foo: Option<Option<Foo>> }
| ^^^^^^^^^^ ------------------------ recursive without indirection
| ^^^^^^^^^^ ------------------- recursive without indirection
| |
| recursive type has infinite size
|
= help: insert indirection (e.g., a `Box`, `Rc`, or `&`) at some point to make `Foo` representable
help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to make `Foo` representable
|
LL | struct Foo { foo: Box<Option<Option<Foo>>> }
| ^^^^ ^

error: aborting due to previous error

Expand Down
14 changes: 10 additions & 4 deletions src/test/ui/issues/issue-17431-2.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,27 @@ error[E0072]: recursive type `Baz` has infinite size
--> $DIR/issue-17431-2.rs:1:1
|
LL | struct Baz { q: Option<Foo> }
| ^^^^^^^^^^ -------------- recursive without indirection
| ^^^^^^^^^^ ----------- recursive without indirection
| |
| recursive type has infinite size
|
= help: insert indirection (e.g., a `Box`, `Rc`, or `&`) at some point to make `Baz` representable
help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to make `Baz` representable
|
LL | struct Baz { q: Box<Option<Foo>> }
| ^^^^ ^

error[E0072]: recursive type `Foo` has infinite size
--> $DIR/issue-17431-2.rs:4:1
|
LL | struct Foo { q: Option<Baz> }
| ^^^^^^^^^^ -------------- recursive without indirection
| ^^^^^^^^^^ ----------- recursive without indirection
| |
| recursive type has infinite size
|
= help: insert indirection (e.g., a `Box`, `Rc`, or `&`) at some point to make `Foo` representable
help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to make `Foo` representable
|
LL | struct Foo { q: Box<Option<Baz>> }
| ^^^^ ^

error: aborting due to 2 previous errors

Expand Down
7 changes: 5 additions & 2 deletions src/test/ui/issues/issue-17431-3.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@ error[E0072]: recursive type `Foo` has infinite size
--> $DIR/issue-17431-3.rs:3:1
|
LL | struct Foo { foo: Mutex<Option<Foo>> }
| ^^^^^^^^^^ ----------------------- recursive without indirection
| ^^^^^^^^^^ ------------------ recursive without indirection
| |
| recursive type has infinite size
|
= help: insert indirection (e.g., a `Box`, `Rc`, or `&`) at some point to make `Foo` representable
help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to make `Foo` representable
|
LL | struct Foo { foo: Box<Mutex<Option<Foo>>> }
| ^^^^ ^

error: aborting due to previous error

Expand Down
7 changes: 5 additions & 2 deletions src/test/ui/issues/issue-17431-4.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@ error[E0072]: recursive type `Foo` has infinite size
--> $DIR/issue-17431-4.rs:3:1
|
LL | struct Foo<T> { foo: Option<Option<Foo<T>>>, marker: marker::PhantomData<T> }
| ^^^^^^^^^^^^^ --------------------------- recursive without indirection
| ^^^^^^^^^^^^^ ---------------------- recursive without indirection
| |
| recursive type has infinite size
|
= help: insert indirection (e.g., a `Box`, `Rc`, or `&`) at some point to make `Foo` representable
help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to make `Foo` representable
|
LL | struct Foo<T> { foo: Box<Option<Option<Foo<T>>>>, marker: marker::PhantomData<T> }
| ^^^^ ^

error: aborting due to previous error

Expand Down
7 changes: 5 additions & 2 deletions src/test/ui/issues/issue-17431-5.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@ error[E0072]: recursive type `Bar` has infinite size
--> $DIR/issue-17431-5.rs:5:1
|
LL | struct Bar<T> { x: Bar<Foo> , marker: marker::PhantomData<T> }
| ^^^^^^^^^^^^^ ----------- recursive without indirection
| ^^^^^^^^^^^^^ -------- recursive without indirection
| |
| recursive type has infinite size
|
= help: insert indirection (e.g., a `Box`, `Rc`, or `&`) at some point to make `Bar` representable
help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to make `Bar` representable
|
LL | struct Bar<T> { x: Box<Bar<Foo>> , marker: marker::PhantomData<T> }
| ^^^^ ^

error: aborting due to previous error

Expand Down
5 changes: 4 additions & 1 deletion src/test/ui/issues/issue-17431-6.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ LL | enum Foo { X(Mutex<Option<Foo>>) }
| |
| recursive type has infinite size
|
= help: insert indirection (e.g., a `Box`, `Rc`, or `&`) at some point to make `Foo` representable
help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to make `Foo` representable
|
LL | enum Foo { X(Box<Mutex<Option<Foo>>>) }
| ^^^^ ^

error: aborting due to previous error

Expand Down
5 changes: 4 additions & 1 deletion src/test/ui/issues/issue-17431-7.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ LL | enum Foo { Voo(Option<Option<Foo>>) }
| |
| recursive type has infinite size
|
= help: insert indirection (e.g., a `Box`, `Rc`, or `&`) at some point to make `Foo` representable
help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to make `Foo` representable
|
LL | enum Foo { Voo(Box<Option<Option<Foo>>>) }
| ^^^^ ^

error: aborting due to previous error

Expand Down
5 changes: 4 additions & 1 deletion src/test/ui/issues/issue-2718-a.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ LL | pub struct Pong(SendPacket<Ping>);
| | recursive without indirection
| recursive type has infinite size
|
= help: insert indirection (e.g., a `Box`, `Rc`, or `&`) at some point to make `pingpong::Pong` representable
help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to make `pingpong::Pong` representable
|
LL | pub struct Pong(Box<SendPacket<Ping>>);
| ^^^^ ^

error: aborting due to previous error

Expand Down
5 changes: 4 additions & 1 deletion src/test/ui/issues/issue-3008-1.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ LL | enum Bar {
LL | BarSome(Bar)
| --- recursive without indirection
|
= help: insert indirection (e.g., a `Box`, `Rc`, or `&`) at some point to make `Bar` representable
help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to make `Bar` representable
|
LL | BarSome(Box<Bar>)
| ^^^^ ^

error: aborting due to previous error

Expand Down
7 changes: 5 additions & 2 deletions src/test/ui/issues/issue-3008-2.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@ error[E0072]: recursive type `Bar` has infinite size
--> $DIR/issue-3008-2.rs:2:1
|
LL | struct Bar { x: Bar }
| ^^^^^^^^^^ ------ recursive without indirection
| ^^^^^^^^^^ --- recursive without indirection
| |
| recursive type has infinite size
|
= help: insert indirection (e.g., a `Box`, `Rc`, or `&`) at some point to make `Bar` representable
help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to make `Bar` representable
|
LL | struct Bar { x: Box<Bar> }
| ^^^^ ^

error: aborting due to previous error

Expand Down
5 changes: 4 additions & 1 deletion src/test/ui/issues/issue-3008-3.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ LL | enum E2<T> { V2(E2<E1>, marker::PhantomData<T>), }
| |
| recursive type has infinite size
|
= help: insert indirection (e.g., a `Box`, `Rc`, or `&`) at some point to make `E2` representable
help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to make `E2` representable
|
LL | enum E2<T> { V2(Box<E2<E1>>, marker::PhantomData<T>), }
| ^^^^ ^

error: aborting due to previous error

Expand Down
5 changes: 4 additions & 1 deletion src/test/ui/issues/issue-32326.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ LL | Plus(Expr, Expr),
| |
| recursive without indirection
|
= help: insert indirection (e.g., a `Box`, `Rc`, or `&`) at some point to make `Expr` representable
help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to make `Expr` representable
|
LL | Plus(Box<Expr>, Box<Expr>),
| ^^^^ ^ ^^^^ ^

error: aborting due to previous error

Expand Down
7 changes: 5 additions & 2 deletions src/test/ui/issues/issue-3779.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ LL | struct S {
| ^^^^^^^^ recursive type has infinite size
LL |
LL | element: Option<S>
| ------------------ recursive without indirection
| --------- recursive without indirection
|
= help: insert indirection (e.g., a `Box`, `Rc`, or `&`) at some point to make `S` representable
help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to make `S` representable
|
LL | element: Box<Option<S>>
| ^^^^ ^

error: aborting due to previous error

Expand Down
10 changes: 8 additions & 2 deletions src/test/ui/issues/issue-57271.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ LL | Class(ClassTypeSignature),
LL | Array(TypeSignature),
| ------------- recursive without indirection
|
= help: insert indirection (e.g., a `Box`, `Rc`, or `&`) at some point to make `ObjectType` representable
help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to make `ObjectType` representable
|
LL | Array(Box<TypeSignature>),
| ^^^^ ^

error[E0072]: recursive type `TypeSignature` has infinite size
--> $DIR/issue-57271.rs:19:1
Expand All @@ -18,7 +21,10 @@ LL | Base(BaseType),
LL | Object(ObjectType),
| ---------- recursive without indirection
|
= help: insert indirection (e.g., a `Box`, `Rc`, or `&`) at some point to make `TypeSignature` representable
help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to make `TypeSignature` representable
|
LL | Object(Box<ObjectType>),
| ^^^^ ^

error: aborting due to 2 previous errors

Expand Down
5 changes: 4 additions & 1 deletion src/test/ui/issues/issue-72554.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ LL | pub enum ElemDerived {
LL | A(ElemDerived)
| ----------- recursive without indirection
|
= help: insert indirection (e.g., a `Box`, `Rc`, or `&`) at some point to make `ElemDerived` representable
help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to make `ElemDerived` representable
|
LL | A(Box<ElemDerived>)
| ^^^^ ^

error: aborting due to previous error

Expand Down
5 changes: 4 additions & 1 deletion src/test/ui/recursion/recursive-enum.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ LL | enum List<T> { Cons(T, List<T>), Nil }
| |
| recursive type has infinite size
|
= help: insert indirection (e.g., a `Box`, `Rc`, or `&`) at some point to make `List` representable
help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to make `List` representable
|
LL | enum List<T> { Cons(T, Box<List<T>>), Nil }
| ^^^^ ^

error: aborting due to previous error

Expand Down
Loading