Skip to content

Commit 42b14dc

Browse files
committed
Auto merge of rust-lang#2875 - RalfJung:rustup, r=RalfJung
Rustup This *should* fail because of rust-lang/miri#2874 but it seems we don't actually cover that in our tests...
2 parents cfd7eaa + f5fa50f commit 42b14dc

File tree

402 files changed

+6131
-4438
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

402 files changed

+6131
-4438
lines changed

Cargo.lock

Lines changed: 34 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,7 @@ dependencies = [
297297
"sha2",
298298
"tar",
299299
"toml",
300+
"xz2",
300301
]
301302

302303
[[package]]
@@ -1654,9 +1655,9 @@ dependencies = [
16541655

16551656
[[package]]
16561657
name = "icu_list"
1657-
version = "1.1.0"
1658+
version = "1.2.0"
16581659
source = "registry+https://github.com/rust-lang/crates.io-index"
1659-
checksum = "01a65ff0cab77c33c7e165c858eaa6e84a09f1e485dd495d9d0ae61083c6f786"
1660+
checksum = "fd7ba7442d9235b689d4fdce17c452ea229934980fd81ba50cc28275752c9f90"
16601661
dependencies = [
16611662
"displaydoc",
16621663
"icu_provider",
@@ -1666,9 +1667,9 @@ dependencies = [
16661667

16671668
[[package]]
16681669
name = "icu_locid"
1669-
version = "1.1.0"
1670+
version = "1.2.0"
16701671
source = "registry+https://github.com/rust-lang/crates.io-index"
1671-
checksum = "71d7a98ecb812760b5f077e55a4763edeefa7ccc30d6eb5680a70841ede81928"
1672+
checksum = "3003f85dccfc0e238ff567693248c59153a46f4e6125ba4020b973cef4d1d335"
16721673
dependencies = [
16731674
"displaydoc",
16741675
"litemap",
@@ -1679,9 +1680,9 @@ dependencies = [
16791680

16801681
[[package]]
16811682
name = "icu_provider"
1682-
version = "1.1.0"
1683+
version = "1.2.0"
16831684
source = "registry+https://github.com/rust-lang/crates.io-index"
1684-
checksum = "a86816c97bc4e613086497f9479f63e120315e056763e8c4435604f98d21d82d"
1685+
checksum = "8dc312a7b6148f7dfe098047ae2494d12d4034f48ade58d4f353000db376e305"
16851686
dependencies = [
16861687
"displaydoc",
16871688
"icu_locid",
@@ -1695,9 +1696,9 @@ dependencies = [
16951696

16961697
[[package]]
16971698
name = "icu_provider_adapters"
1698-
version = "1.1.0"
1699+
version = "1.2.0"
16991700
source = "registry+https://github.com/rust-lang/crates.io-index"
1700-
checksum = "8e89bf33962b24bb48a4a21330c20c9ff17949338ea376360dd9eda2c209dca1"
1701+
checksum = "f4ae1e2bd0c41728b77e7c46e9afdec5e2127d1eedacc684724667d50c126bd3"
17011702
dependencies = [
17021703
"icu_locid",
17031704
"icu_provider",
@@ -1708,9 +1709,9 @@ dependencies = [
17081709

17091710
[[package]]
17101711
name = "icu_provider_macros"
1711-
version = "1.1.0"
1712+
version = "1.2.0"
17121713
source = "registry+https://github.com/rust-lang/crates.io-index"
1713-
checksum = "9ddb07844c2ffc4c28840e799e9e54ff054393cf090740decf25624e9d94b93a"
1714+
checksum = "dd8b728b9421e93eff1d9f8681101b78fa745e0748c95c655c83f337044a7e10"
17141715
dependencies = [
17151716
"proc-macro2",
17161717
"quote",
@@ -2031,9 +2032,9 @@ checksum = "36eb31c1778188ae1e64398743890d0877fef36d11521ac60406b42016e8c2cf"
20312032

20322033
[[package]]
20332034
name = "litemap"
2034-
version = "0.6.1"
2035+
version = "0.7.0"
20352036
source = "registry+https://github.com/rust-lang/crates.io-index"
2036-
checksum = "575d8a551c59104b4df91269921e5eab561aa1b77c618dac0414b5d44a4617de"
2037+
checksum = "3a04a5b2b6f54acba899926491d0a6c59d98012938ca2ab5befb281c034e8f94"
20372038

20382039
[[package]]
20392040
name = "lld-wrapper"
@@ -2060,9 +2061,9 @@ dependencies = [
20602061

20612062
[[package]]
20622063
name = "lzma-sys"
2063-
version = "0.1.16"
2064+
version = "0.1.20"
20642065
source = "registry+https://github.com/rust-lang/crates.io-index"
2065-
checksum = "f24f76ec44a8ac23a31915d6e326bca17ce88da03096f1ff194925dc714dac99"
2066+
checksum = "5fda04ab3764e6cde78b9974eec4f779acaba7c4e84b36eca3cf77c581b85d27"
20662067
dependencies = [
20672068
"cc",
20682069
"libc",
@@ -2908,9 +2909,9 @@ dependencies = [
29082909

29092910
[[package]]
29102911
name = "rustc-build-sysroot"
2911-
version = "0.4.1"
2912+
version = "0.4.2"
29122913
source = "registry+https://github.com/rust-lang/crates.io-index"
2913-
checksum = "d65b1271cdac365b71b59570ea35d945dea2dd2cc47eba3d33b4bd1e0190ac6d"
2914+
checksum = "8ed2a90dfa5232ed5ff21d53d4df655f315ab316ea06fc508f1c74bcedb1ce6c"
29142915
dependencies = [
29152916
"anyhow",
29162917
"rustc_version",
@@ -3164,6 +3165,7 @@ dependencies = [
31643165
"rustc_expand",
31653166
"rustc_feature",
31663167
"rustc_fluent_macro",
3168+
"rustc_index",
31673169
"rustc_lexer",
31683170
"rustc_lint_defs",
31693171
"rustc_macros",
@@ -4059,6 +4061,7 @@ dependencies = [
40594061
"indexmap",
40604062
"rustc_macros",
40614063
"smallvec",
4064+
"tempfile",
40624065
"thin-vec",
40634066
]
40644067

@@ -4737,6 +4740,15 @@ dependencies = [
47374740
"unicode-xid",
47384741
]
47394742

4743+
[[package]]
4744+
name = "sysroot"
4745+
version = "0.0.0"
4746+
dependencies = [
4747+
"proc_macro",
4748+
"std",
4749+
"test",
4750+
]
4751+
47404752
[[package]]
47414753
name = "tar"
47424754
version = "0.4.38"
@@ -4821,7 +4833,6 @@ dependencies = [
48214833
"getopts",
48224834
"panic_abort",
48234835
"panic_unwind",
4824-
"proc_macro",
48254836
"std",
48264837
]
48274838

@@ -5659,9 +5670,9 @@ dependencies = [
56595670

56605671
[[package]]
56615672
name = "xz2"
5662-
version = "0.1.6"
5673+
version = "0.1.7"
56635674
source = "registry+https://github.com/rust-lang/crates.io-index"
5664-
checksum = "c179869f34fc7c01830d3ce7ea2086bc3a07e0d35289b667d0a8bf910258926c"
5675+
checksum = "388c44dc09d76f1536602ead6d325eb532f5c122f17782bd57fb47baeeb767e2"
56655676
dependencies = [
56665677
"lzma-sys",
56675678
]
@@ -5697,9 +5708,9 @@ dependencies = [
56975708

56985709
[[package]]
56995710
name = "yoke"
5700-
version = "0.7.0"
5711+
version = "0.7.1"
57015712
source = "registry+https://github.com/rust-lang/crates.io-index"
5702-
checksum = "222180af14a6b54ef2c33493c1eff77ae95a3687a21b243e752624006fb8f26e"
5713+
checksum = "1848075a23a28f9773498ee9a0f2cf58fcbad4f8c0ccf84a210ab33c6ae495de"
57035714
dependencies = [
57045715
"serde",
57055716
"stable_deref_trait",
@@ -5742,9 +5753,9 @@ dependencies = [
57425753

57435754
[[package]]
57445755
name = "zerovec"
5745-
version = "0.9.2"
5756+
version = "0.9.4"
57465757
source = "registry+https://github.com/rust-lang/crates.io-index"
5747-
checksum = "154df60c74c4a844bc04a53cef4fc18a909d3ea07e19f5225eaba86209da3aa6"
5758+
checksum = "198f54134cd865f437820aa3b43d0ad518af4e68ee161b444cdd15d8e567c8ea"
57485759
dependencies = [
57495760
"yoke",
57505761
"zerofrom",

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
members = [
33
"compiler/rustc",
44
"library/std",
5-
"library/test",
5+
"library/sysroot",
66
"src/rustdoc-json-types",
77
"src/tools/build_helper",
88
"src/tools/cargotest",

compiler/rustc_ast/src/ast.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,12 +287,20 @@ pub enum TraitBoundModifier {
287287
/// No modifiers
288288
None,
289289

290+
/// `!Trait`
291+
Negative,
292+
290293
/// `?Trait`
291294
Maybe,
292295

293296
/// `~const Trait`
294297
MaybeConst,
295298

299+
/// `~const !Trait`
300+
//
301+
// This parses but will be rejected during AST validation.
302+
MaybeConstNegative,
303+
296304
/// `~const ?Trait`
297305
//
298306
// This parses but will be rejected during AST validation.
@@ -2446,6 +2454,16 @@ impl fmt::Debug for ImplPolarity {
24462454
}
24472455
}
24482456

2457+
#[derive(Copy, Clone, PartialEq, Encodable, Decodable, HashStable_Generic)]
2458+
pub enum BoundPolarity {
2459+
/// `Type: Trait`
2460+
Positive,
2461+
/// `Type: !Trait`
2462+
Negative(Span),
2463+
/// `Type: ?Trait`
2464+
Maybe(Span),
2465+
}
2466+
24492467
#[derive(Clone, Encodable, Decodable, Debug)]
24502468
pub enum FnRetTy {
24512469
/// Returns type is not specified.

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1368,13 +1368,17 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
13681368
this.arena.alloc_from_iter(bounds.iter().filter_map(|bound| match bound {
13691369
GenericBound::Trait(
13701370
ty,
1371-
TraitBoundModifier::None | TraitBoundModifier::MaybeConst,
1371+
TraitBoundModifier::None
1372+
| TraitBoundModifier::MaybeConst
1373+
| TraitBoundModifier::Negative,
13721374
) => Some(this.lower_poly_trait_ref(ty, itctx)),
13731375
// `~const ?Bound` will cause an error during AST validation
13741376
// anyways, so treat it like `?Bound` as compilation proceeds.
13751377
GenericBound::Trait(
13761378
_,
1377-
TraitBoundModifier::Maybe | TraitBoundModifier::MaybeConstMaybe,
1379+
TraitBoundModifier::Maybe
1380+
| TraitBoundModifier::MaybeConstMaybe
1381+
| TraitBoundModifier::MaybeConstNegative,
13781382
) => None,
13791383
GenericBound::Outlives(lifetime) => {
13801384
if lifetime_bound.is_none() {
@@ -2421,11 +2425,20 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
24212425
TraitBoundModifier::None => hir::TraitBoundModifier::None,
24222426
TraitBoundModifier::MaybeConst => hir::TraitBoundModifier::MaybeConst,
24232427

2428+
TraitBoundModifier::Negative => {
2429+
if self.tcx.features().negative_bounds {
2430+
hir::TraitBoundModifier::Negative
2431+
} else {
2432+
hir::TraitBoundModifier::None
2433+
}
2434+
}
2435+
24242436
// `MaybeConstMaybe` will cause an error during AST validation, but we need to pick a
24252437
// placeholder for compilation to proceed.
24262438
TraitBoundModifier::MaybeConstMaybe | TraitBoundModifier::Maybe => {
24272439
hir::TraitBoundModifier::Maybe
24282440
}
2441+
TraitBoundModifier::MaybeConstNegative => hir::TraitBoundModifier::MaybeConst,
24292442
}
24302443
}
24312444

compiler/rustc_ast_passes/messages.ftl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ ast_passes_tilde_const_disallowed = `~const` is not allowed here
206206
.closure = closures cannot have `~const` trait bounds
207207
.function = this function is not `const`, so it cannot have `~const` trait bounds
208208
209-
ast_passes_optional_const_exclusive = `~const` and `?` are mutually exclusive
209+
ast_passes_optional_const_exclusive = `~const` and `{$modifier}` are mutually exclusive
210210
211211
ast_passes_const_and_async = functions cannot be both `const` and `async`
212212
.const = `const` because of this
@@ -235,3 +235,9 @@ ast_passes_incompatible_features = `{$f1}` and `{$f2}` are incompatible, using t
235235
.help = remove one of these features
236236
237237
ast_passes_show_span = {$msg}
238+
239+
ast_passes_negative_bound_not_supported =
240+
negative bounds are not supported
241+
242+
ast_passes_constraint_on_negative_bound =
243+
associated type constraints not allowed on negative bounds

compiler/rustc_ast_passes/src/ast_validation.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1168,12 +1168,27 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
11681168
});
11691169
}
11701170
(_, TraitBoundModifier::MaybeConstMaybe) => {
1171-
self.err_handler().emit_err(errors::OptionalConstExclusive {span: bound.span()});
1171+
self.err_handler().emit_err(errors::OptionalConstExclusive {span: bound.span(), modifier: "?" });
1172+
}
1173+
(_, TraitBoundModifier::MaybeConstNegative) => {
1174+
self.err_handler().emit_err(errors::OptionalConstExclusive {span: bound.span(), modifier: "!" });
11721175
}
11731176
_ => {}
11741177
}
11751178
}
11761179

1180+
// Negative trait bounds are not allowed to have associated constraints
1181+
if let GenericBound::Trait(trait_ref, TraitBoundModifier::Negative) = bound
1182+
&& let Some(segment) = trait_ref.trait_ref.path.segments.last()
1183+
&& let Some(ast::GenericArgs::AngleBracketed(args)) = segment.args.as_deref()
1184+
{
1185+
for arg in &args.args {
1186+
if let ast::AngleBracketedArg::Constraint(constraint) = arg {
1187+
self.err_handler().emit_err(errors::ConstraintOnNegativeBound { span: constraint.span });
1188+
}
1189+
}
1190+
}
1191+
11771192
visit::walk_param_bound(self, bound)
11781193
}
11791194

compiler/rustc_ast_passes/src/errors.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,7 @@ pub enum TildeConstReason {
567567
pub struct OptionalConstExclusive {
568568
#[primary_span]
569569
pub span: Span,
570+
pub modifier: &'static str,
570571
}
571572

572573
#[derive(Diagnostic)]
@@ -693,3 +694,17 @@ pub struct ShowSpan {
693694
pub span: Span,
694695
pub msg: &'static str,
695696
}
697+
698+
#[derive(Diagnostic)]
699+
#[diag(ast_passes_negative_bound_not_supported)]
700+
pub struct NegativeBoundUnsupported {
701+
#[primary_span]
702+
pub span: Span,
703+
}
704+
705+
#[derive(Diagnostic)]
706+
#[diag(ast_passes_constraint_on_negative_bound)]
707+
pub struct ConstraintOnNegativeBound {
708+
#[primary_span]
709+
pub span: Span,
710+
}

compiler/rustc_ast_passes/src/feature_gate.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,12 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session) {
603603
gate_all!(dyn_star, "`dyn*` trait objects are experimental");
604604
gate_all!(const_closures, "const closures are experimental");
605605

606+
if !visitor.features.negative_bounds {
607+
for &span in spans.get(&sym::negative_bounds).iter().copied().flatten() {
608+
sess.emit_err(errors::NegativeBoundUnsupported { span });
609+
}
610+
}
611+
606612
// All uses of `gate_all!` below this point were added in #65742,
607613
// and subsequently disabled (with the non-early gating readded).
608614
// We emit an early future-incompatible warning for these.

compiler/rustc_ast_pretty/src/pprust/state.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1570,12 +1570,19 @@ impl<'a> State<'a> {
15701570
GenericBound::Trait(tref, modifier) => {
15711571
match modifier {
15721572
TraitBoundModifier::None => {}
1573+
TraitBoundModifier::Negative => {
1574+
self.word("!");
1575+
}
15731576
TraitBoundModifier::Maybe => {
15741577
self.word("?");
15751578
}
15761579
TraitBoundModifier::MaybeConst => {
15771580
self.word_space("~const");
15781581
}
1582+
TraitBoundModifier::MaybeConstNegative => {
1583+
self.word_space("~const");
1584+
self.word("!");
1585+
}
15791586
TraitBoundModifier::MaybeConstMaybe => {
15801587
self.word_space("~const");
15811588
self.word("?");

compiler/rustc_baked_icu_data/Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ version = "0.0.0"
44
edition = "2021"
55

66
[dependencies]
7-
icu_list = "1.1.0"
8-
icu_locid = "1.1.0"
9-
icu_provider = "1.1.0"
10-
icu_provider_adapters = "1.1.0"
11-
zerovec = "0.9.2"
7+
icu_list = "1.2"
8+
icu_locid = "1.2"
9+
icu_provider = "1.2"
10+
icu_provider_adapters = "1.2"
11+
zerovec = "0.9.4"
1212

1313
[features]
1414
rustc_use_parallel_compiler = ['icu_provider/sync']

0 commit comments

Comments
 (0)