Auto merge of #120381 - fee1-dead-contrib:reconstify-add, r=compiler-… · rust-lang/rust@6894f43 (original) (raw)

File tree

4 files changed

lines changed

4 files changed

lines changed

Original file line number Diff line number Diff line change
@@ -98,6 +98,7 @@ impl<'tcx, T> IsSuggestable<'tcx> for T
98 98 where
99 99 T: TypeVisitable<TyCtxt<'tcx>> + TypeFoldable<TyCtxt<'tcx>>,
100 100 {
101 +#[tracing::instrument(level = "debug", skip(tcx))]
101 102 fn is_suggestable(self, tcx: TyCtxt<'tcx>, infer_suggestable: bool) -> bool {
102 103 self.visit_with(&mut IsSuggestableVisitor { tcx, infer_suggestable }).is_continue()
103 104 }
@@ -533,6 +534,9 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for IsSuggestableVisitor<'tcx> {
533 534 match c.kind() {
534 535 ConstKind::Infer(InferConst::Var(_)) if self.infer_suggestable => {}
535 536
537 +// effect variables are always suggestable, because they are not visible
538 +ConstKind::Infer(InferConst::EffectVar(_)) => {}
539 +
536 540 ConstKind::Infer(..)
537 541 | ConstKind::Bound(..)
538 542 | ConstKind::Placeholder(..)
Original file line number Diff line number Diff line change
@@ -73,6 +73,7 @@
73 73 append_const_msg
74 74 )]
75 75 #[doc(alias = "+")]
76 +#[const_trait]
76 77 pub trait Add<Rhs = Self> {
77 78 /// The resulting type after applying the `+` operator.
78 79 #[stable(feature = "rust1", since = "1.0.0")]
@@ -94,7 +95,8 @@ pub trait Add<Rhs = Self> {
94 95 macro_rules! add_impl {
95 96 ($($t:ty)*) => ($(
96 97 #[stable(feature = "rust1", since = "1.0.0")]
97 -impl Add for $t {
98 + #[rustc_const_unstable(feature = "const_ops", issue = "90080")]
99 +impl const Add for $t {
98 100 type Output = $t;
99 101
100 102 #[inline]
Original file line number Diff line number Diff line change
@@ -16,6 +16,10 @@ help: consider annotating `S` with `#[derive(PartialEq)]`
16 16 LL + #[derive(PartialEq)]
17 17 LL | struct S(T);
18 18 |
19 +help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement
20 + |
21 +LL | pub fn foo(s: S, t: S) where S: PartialEq {
22 + | +++++++++++++++++++++
19 23
20 24 error: aborting due to 1 previous error
21 25
Original file line number Diff line number Diff line change
@@ -11,6 +11,19 @@ LL | <i32 as Add>::add(1, 2);
11 11 <&'a i32 as Add>
12 12 <&i32 as Add<&i32>>
13 13
14 +error[E0277]: cannot add `u32` to `i32`
15 + --> $DIR/ufcs-qpath-self-mismatch.rs:4:5
16 + |
17 +LL | <i32 as Add>::add(1, 2);
18 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `i32 + u32`
19 + |
20 + = help: the trait `Add` is not implemented for `i32`
21 + = help: the following other types implement trait `Add`:
22 +
23 + <i32 as Add<&i32>>
24 + <&'a i32 as Add>
25 + <&i32 as Add<&i32>>
26 +
14 27 error[E0308]: mismatched types
15 28 --> $DIR/ufcs-qpath-self-mismatch.rs:7:28
16 29 |
@@ -55,19 +68,6 @@ help: change the type of the numeric literal from `u32` to `i32`
55 68 LL | <i32 as Add>::add(1, 2i32);
56 69 | ~~~
57 70
58 -error[E0277]: cannot add `u32` to `i32`
59 - --> $DIR/ufcs-qpath-self-mismatch.rs:4:5
60 - |
61 -LL | <i32 as Add>::add(1, 2);
62 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `i32 + u32`
63 - |
64 - = help: the trait `Add` is not implemented for `i32`
65 - = help: the following other types implement trait `Add`:
66 -
67 - <i32 as Add<&i32>>
68 - <&'a i32 as Add>
69 - <&i32 as Add<&i32>>
70 -
71 71 error: aborting due to 4 previous errors
72 72
73 73 Some errors have detailed explanations: E0277, E0308.