Skip to content

Commit 0fa4b13

Browse files
more specific subvariant errors
1 parent d87a4b3 commit 0fa4b13

File tree

1 file changed

+77
-48
lines changed

1 file changed

+77
-48
lines changed

src/lib.rs

Lines changed: 77 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,41 @@
11
/*!
2-
# Selecting the right chip
2+
# Selecting the right chip
3+
4+
This crate requires you to specify your target chip as a feature.
5+
6+
Please select one of the following
7+
8+
(Note: `x` denotes any character in [a-z])
9+
* stm32f301xb
10+
* stm32f301xc
11+
* stm32f301xd
12+
* stm32f301xe
13+
* stm32f318
14+
* stm32f302
15+
* stm32f303xb
16+
* stm32f303xc
17+
* stm32f303xd
18+
* stm32f303xe
19+
* stm32f303x6
20+
* stm32f303x8
21+
* stm32f373
22+
* stm32f378
23+
* stm32f334
24+
* stm32f328
25+
* stm32f358
26+
* stm32f398
27+
28+
Example: The STM32F3Discovery board has a STM32F303VCT6 chip.
29+
So you want to expand your call to `cargo` with `--features stm32f303xc`.
30+
31+
For more information, see the [README](https://github.com/stm32-rs/stm32f3xx-hal/blob/master/README.md#selecting-the-right-chip)
32+
*/
33+
#![no_std]
34+
#![allow(non_camel_case_types)]
335

4-
This crate requires you to specify your target chip as a feature.
36+
#[cfg(all(not(feature = "device-selected"), not(feature = "needs-subvariant")))]
37+
compile_error!(
38+
"This crate requires you to specify your target chip as a feature.
539
640
Please select one of the following
741
@@ -28,79 +62,74 @@
2862
Example: The STM32F3Discovery board has a STM32F303VCT6 chip.
2963
So you want to expand your call to `cargo` with `--features stm32f303xc`.
3064
31-
For more information, see the [README](https://github.com/stm32-rs/stm32f3xx-hal/blob/master/README.md#selecting-the-right-chip)
32-
*/
33-
#![no_std]
34-
#![allow(non_camel_case_types)]
65+
For more information, see README -> Selecting the right chip.
66+
"
67+
);
3568

36-
#[cfg(all(not(feature = "device-selected"), not(feature = "needs-subvariant")))]
69+
#[cfg(all(not(feature = "device-selected"), feature = "stm32f301"))]
3770
compile_error!(
38-
"This crate requires you to specify your target chip as a feature.
71+
"This crate requires you to specify the subvariant of your chip.
3972
40-
Please select one of the following
73+
You probably see this error because you updated the stm32f3xxx-hal and are still using
74+
`--features stm32f301`.
75+
Don't worry, you probably don't neet to change your code.
4176
77+
Please check your datasheet and change `stm32f301` to one of those subvariants:
4278
(Note: `x` denotes any character in [a-z])
4379
* stm32f301xb
4480
* stm32f301xc
4581
* stm32f301xd
4682
* stm32f301xe
47-
* stm32f318
48-
* stm32f302
49-
* stm32f303xb
50-
* stm32f303xc
51-
* stm32f303xd
52-
* stm32f303xe
53-
* stm32f303x6
54-
* stm32f303x8
55-
* stm32f373
56-
* stm32f378
57-
* stm32f334
58-
* stm32f328
59-
* stm32f358
60-
* stm32f398
6183
62-
Example: The STM32F3Discovery board has a STM32F303VCT6 chip.
63-
So you want to expand your call to `cargo` with `--features stm32f303xc`.
84+
For more information, see README -> Selecting the right chip.
6485
65-
For more information, see README -> Selecting the right feature gate.
66-
"
86+
Also check the CHANGELOG for awesome new features for your chip that were made possible by
87+
forcing you to specify the subvariant.
88+
"
6789
);
6890

69-
#[cfg(all(not(feature = "device-selected"), feature = "needs-subvariant"))]
91+
#[cfg(all(not(feature = "device-selected"), feature = "stm32f303"))]
7092
compile_error!(
7193
"This crate requires you to specify the subvariant of your chip.
7294
73-
Please select one of the following
95+
You probably see this error because you updated the stm32f3xxx-hal and are still using
96+
`--features stm32f303`.
97+
Don't worry, you probably don't neet to change your code.
7498
99+
Please check your datasheet and change your `stm32f303` to one of those subvariants:
75100
(Note: `x` denotes any character in [a-z])
76-
* stm32f301xb
77-
* stm32f301xc
78-
* stm32f301xd
79-
* stm32f301xe
80-
* stm32f318
81-
* stm32f302
82101
* stm32f303xb
83102
* stm32f303xc
84103
* stm32f303xd
85104
* stm32f303xe
86105
* stm32f303x6
87106
* stm32f303x8
88-
* stm32f373
89-
* stm32f378
90-
* stm32f334
91-
* stm32f328
92-
* stm32f358
93-
* stm32f398
107+
108+
For more information, see README -> Selecting the right chip.
109+
110+
Also check the CHANGELOG for awesome new features for your chip that were made possible by
111+
forcing you to specify the subvariant.
112+
"
113+
);
114+
#[cfg(all(
115+
not(feature = "device-selected"),
116+
feature = "needs-subvariant",
117+
not(any(feature = "stm32f303", feature = "stm32f301"))
118+
))]
119+
compile_error!(
120+
"This crate requires you to specify the subvariant of your chip.
94121
95-
You probably see this error because you updated the stm32f3xxx-hal.
96-
Don't worry, you don't neet to change your code.
122+
However this compile error should also tell you which subvariants to pick from.
123+
As this is not the case, please
97124
98-
Example: The STM32F3Discovery board has a STM32F303VCT6 chip.
99-
You only specified `--features stm32f303` and got this error.
100-
Expand it to `--features stm32f303xc` (note the `xc` at the end)
101-
to get all the functionality of your board.
125+
File an issue at
126+
https://github.com/stm32-rs/stm32f3xx-hal/issues/new
127+
including your call to `cargo` and the version of stm32f3xxx-hal you want to use.
102128
103-
For more information, see README -> Selecting the right feature gate.
129+
You may also
130+
* See README -> Selecting the right chip.
131+
* Check the CHANGELOG for awesome new features for your chip that were made possible by
132+
forcing you to specify the subvariant.
104133
"
105134
);
106135

0 commit comments

Comments
 (0)