Auto merge of #125313 - matthiaskrgr:rollup-65etxv0, r=matthiaskrgr

Rollup of 5 pull requests

Successful merges:

 - #125034 (Weekly `cargo update`)
 - #125093 (Add `fn into_raw_with_allocator` to Rc/Arc/Weak.)
 - #125282 (Never type unsafe lint improvements)
 - #125301 (fix suggestion in E0373 for !Unpin coroutines)
 - #125302 (defrost `RUST_MIN_STACK=ice rustc hello.rs`)

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2024-05-20 07:58:40 +00:00
commit e8ada6ab25
18 changed files with 445 additions and 150 deletions

View File

@ -74,11 +74,11 @@ checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f"
[[package]]
name = "ammonia"
version = "3.3.0"
version = "4.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "64e6d1c7838db705c9b756557ee27c384ce695a1c51a6fe528784cb1c6840170"
checksum = "1ab99eae5ee58501ab236beb6f20f6ca39be615267b014899c89b2f0bc18a459"
dependencies = [
"html5ever",
"html5ever 0.27.0",
"maplit",
"once_cell",
"tendril",
@ -212,9 +212,9 @@ dependencies = [
[[package]]
name = "anyhow"
version = "1.0.83"
version = "1.0.86"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "25bdb32cbbdce2b519a9cd7df3a678443100e265d5e25ca763b7572a5104f5f3"
checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da"
dependencies = [
"backtrace",
]
@ -257,7 +257,7 @@ dependencies = [
"proc-macro2",
"quote",
"serde",
"syn 2.0.62",
"syn 2.0.64",
]
[[package]]
@ -414,9 +414,9 @@ checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9"
[[package]]
name = "camino"
version = "1.1.6"
version = "1.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c59e92b5a388f549b863a7bea62612c09f24c8393560709a54558a9abdfb3b9c"
checksum = "e0ec6b951b160caa93cc0c7b209e5a3bff7aae9062213451ac99493cd844c239"
dependencies = [
"serde",
]
@ -571,7 +571,7 @@ dependencies = [
"anstream",
"anstyle",
"clap_lex",
"strsim 0.11.1",
"strsim",
"terminal_size",
]
@ -593,7 +593,7 @@ dependencies = [
"heck 0.5.0",
"proc-macro2",
"quote",
"syn 2.0.62",
"syn 2.0.64",
]
[[package]]
@ -620,7 +620,7 @@ dependencies = [
"regex",
"rustc_tools_util",
"serde",
"syn 2.0.62",
"syn 2.0.64",
"tempfile",
"termize",
"tokio",
@ -647,7 +647,7 @@ dependencies = [
"clap",
"indoc",
"itertools 0.12.1",
"opener",
"opener 0.6.1",
"shell-escape",
"walkdir",
]
@ -730,7 +730,7 @@ dependencies = [
"nom",
"proc-macro2",
"quote",
"syn 2.0.62",
"syn 2.0.64",
]
[[package]]
@ -957,9 +957,9 @@ dependencies = [
[[package]]
name = "darling"
version = "0.20.8"
version = "0.20.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "54e36fcd13ed84ffdfda6f5be89b31287cbb80c439841fe69e04841435464391"
checksum = "83b2eb4d90d12bdda5ed17de686c2acb4c57914f8f921b8da7e112b5a36f3fe1"
dependencies = [
"darling_core",
"darling_macro",
@ -967,27 +967,27 @@ dependencies = [
[[package]]
name = "darling_core"
version = "0.20.8"
version = "0.20.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c2cf1c23a687a1feeb728783b993c4e1ad83d99f351801977dd809b48d0a70f"
checksum = "622687fe0bac72a04e5599029151f5796111b90f1baaa9b544d807a5e31cd120"
dependencies = [
"fnv",
"ident_case",
"proc-macro2",
"quote",
"strsim 0.10.0",
"syn 2.0.62",
"strsim",
"syn 2.0.64",
]
[[package]]
name = "darling_macro"
version = "0.20.8"
version = "0.20.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a668eda54683121533a393014d8692171709ff57a7d61f187b6e782719f8933f"
checksum = "733cabb43482b1a1b53eee8583c2b9e8684d592215ea83efd305dd31bc2f0178"
dependencies = [
"darling_core",
"quote",
"syn 2.0.62",
"syn 2.0.64",
]
[[package]]
@ -996,13 +996,24 @@ version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a0afaad2b26fa326569eb264b1363e8ae3357618c43982b3f285f0774ce76b69"
[[package]]
name = "dbus"
version = "0.9.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1bb21987b9fb1613058ba3843121dd18b163b254d8a6e797e144cbac14d96d1b"
dependencies = [
"libc",
"libdbus-sys",
"winapi",
]
[[package]]
name = "declare_clippy_lint"
version = "0.1.80"
dependencies = [
"itertools 0.12.1",
"quote",
"syn 2.0.62",
"syn 2.0.64",
]
[[package]]
@ -1043,7 +1054,7 @@ dependencies = [
"darling",
"proc-macro2",
"quote",
"syn 2.0.62",
"syn 2.0.64",
]
[[package]]
@ -1053,7 +1064,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "206868b8242f27cecce124c19fd88157fbd0dd334df2587f36417bafbc85097b"
dependencies = [
"derive_builder_core",
"syn 2.0.62",
"syn 2.0.64",
]
[[package]]
@ -1076,7 +1087,7 @@ dependencies = [
"darling",
"proc-macro2",
"quote",
"syn 2.0.62",
"syn 2.0.64",
]
[[package]]
@ -1165,7 +1176,7 @@ checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.62",
"syn 2.0.64",
]
[[package]]
@ -1189,9 +1200,9 @@ dependencies = [
[[package]]
name = "either"
version = "1.11.0"
version = "1.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a47c1c47d2f5964e29c61246e81db715514cd532db6b5116a25ea3c03d6780a2"
checksum = "3dca9240753cf90908d7e4aac30f630662b02aebaa1b58a3cadabdb23385b58b"
[[package]]
name = "elasticlunr-rs"
@ -1503,7 +1514,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.62",
"syn 2.0.64",
]
[[package]]
@ -1735,12 +1746,26 @@ checksum = "bea68cab48b8459f17cf1c944c67ddc572d272d9f2b274140f223ecb1da4a3b7"
dependencies = [
"log",
"mac",
"markup5ever",
"markup5ever 0.11.0",
"proc-macro2",
"quote",
"syn 1.0.109",
]
[[package]]
name = "html5ever"
version = "0.27.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c13771afe0e6e846f1e67d038d4cb29998a6779f93c809212e4e9c32efd244d4"
dependencies = [
"log",
"mac",
"markup5ever 0.12.1",
"proc-macro2",
"quote",
"syn 2.0.64",
]
[[package]]
name = "http"
version = "0.2.12"
@ -1941,7 +1966,7 @@ checksum = "d2abdd3a62551e8337af119c5899e600ca0c88ec8f23a46c60ba216c803dcf1a"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.62",
"syn 2.0.64",
]
[[package]]
@ -2044,9 +2069,9 @@ dependencies = [
[[package]]
name = "instant"
version = "0.1.12"
version = "0.1.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c"
checksum = "e0242819d153cba4b4b05a5a8f2a7e9bbf97b6055b2a002b395c96b5ff3c0222"
dependencies = [
"cfg-if",
]
@ -2197,6 +2222,16 @@ dependencies = [
"rustc-std-workspace-core",
]
[[package]]
name = "libdbus-sys"
version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06085512b750d640299b79be4bad3d2fa90a9c00b1fd9e1b46364f66f0485c72"
dependencies = [
"cc",
"pkg-config",
]
[[package]]
name = "libffi"
version = "3.2.0"
@ -2258,7 +2293,7 @@ dependencies = [
name = "linkchecker"
version = "0.1.0"
dependencies = [
"html5ever",
"html5ever 0.26.0",
"regex",
]
@ -2273,9 +2308,9 @@ dependencies = [
[[package]]
name = "linux-raw-sys"
version = "0.4.13"
version = "0.4.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c"
checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89"
[[package]]
name = "litemap"
@ -2351,6 +2386,20 @@ dependencies = [
"tendril",
]
[[package]]
name = "markup5ever"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "16ce3abbeba692c8b8441d036ef91aea6df8da2c6b6e21c7e14d3c18e526be45"
dependencies = [
"log",
"phf 0.11.2",
"phf_codegen 0.11.2",
"string_cache",
"string_cache_codegen",
"tendril",
]
[[package]]
name = "matchers"
version = "0.1.0"
@ -2372,9 +2421,9 @@ dependencies = [
[[package]]
name = "mdbook"
version = "0.4.37"
version = "0.4.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c33564061c3c640bed5ace7d6a2a1b65f2c64257d1ac930c15e94ed0fb561d3"
checksum = "b45a38e19bd200220ef07c892b0157ad3d2365e5b5a267ca01ad12182491eea5"
dependencies = [
"ammonia",
"anyhow",
@ -2387,7 +2436,7 @@ dependencies = [
"log",
"memchr",
"once_cell",
"opener",
"opener 0.7.1",
"pulldown-cmark 0.10.3",
"regex",
"serde",
@ -2470,9 +2519,9 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
[[package]]
name = "miniz_oxide"
version = "0.7.2"
version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7"
checksum = "87dfd01fe195c66b572b37921ad8803d010623c0aca821bea2302239d155cdae"
dependencies = [
"adler",
"compiler_builtins",
@ -2697,6 +2746,18 @@ dependencies = [
"winapi",
]
[[package]]
name = "opener"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8df34be653210fbe9ffaff41d3b92721c56ce82dfee58ee684f9afb5e3a90c0"
dependencies = [
"bstr",
"dbus",
"normpath",
"windows-sys 0.52.0",
]
[[package]]
name = "openssl"
version = "0.10.64"
@ -2720,7 +2781,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.62",
"syn 2.0.64",
]
[[package]]
@ -2912,7 +2973,7 @@ dependencies = [
"pest_meta",
"proc-macro2",
"quote",
"syn 2.0.62",
"syn 2.0.64",
]
[[package]]
@ -4001,7 +4062,7 @@ dependencies = [
"fluent-syntax",
"proc-macro2",
"quote",
"syn 2.0.62",
"syn 2.0.64",
"unic-langid",
]
@ -4135,7 +4196,7 @@ version = "0.0.0"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.62",
"syn 2.0.64",
"synstructure",
]
@ -4282,7 +4343,7 @@ version = "0.0.0"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.62",
"syn 2.0.64",
"synstructure",
]
@ -4859,7 +4920,7 @@ version = "0.0.0"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.62",
"syn 2.0.64",
"synstructure",
]
@ -4957,7 +5018,7 @@ dependencies = [
"proc-macro2",
"quote",
"serde",
"syn 2.0.62",
"syn 2.0.64",
]
[[package]]
@ -5014,9 +5075,9 @@ dependencies = [
[[package]]
name = "rustversion"
version = "1.0.16"
version = "1.0.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "092474d1a01ea8278f69e6a358998405fae5b8b963ddaeb2b0b04a128bf1dfb0"
checksum = "955d28af4278de8121b7ebeb796b6a45735dc01436d898801014aced2773a3d6"
[[package]]
name = "ruzstd"
@ -5125,22 +5186,22 @@ dependencies = [
[[package]]
name = "serde"
version = "1.0.201"
version = "1.0.202"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "780f1cebed1629e4753a1a38a3c72d30b97ec044f0aef68cb26650a3c5cf363c"
checksum = "226b61a0d411b2ba5ff6d7f73a476ac4f8bb900373459cd00fab8512828ba395"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.201"
version = "1.0.202"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c5e405930b9796f1c00bee880d03fc7e0bb4b9a11afc776885ffe84320da2865"
checksum = "6048858004bcff69094cd972ed40a32500f153bd3be9f716b2eed2e8217c4838"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.62",
"syn 2.0.64",
]
[[package]]
@ -5157,9 +5218,9 @@ dependencies = [
[[package]]
name = "serde_spanned"
version = "0.6.5"
version = "0.6.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eb3622f419d1296904700073ea6cc23ad690adbd66f13ea683df73298736f0c1"
checksum = "79e674e01f999af37c49f70a6ede167a8a60b2503e56c5599532a65baa5969a0"
dependencies = [
"serde",
]
@ -5400,12 +5461,6 @@ dependencies = [
"quote",
]
[[package]]
name = "strsim"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
[[package]]
name = "strsim"
version = "0.11.1"
@ -5452,9 +5507,9 @@ dependencies = [
[[package]]
name = "syn"
version = "2.0.62"
version = "2.0.64"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9f660c3bfcefb88c538776b6685a0c472e3128b51e74d48793dc2a488196e8eb"
checksum = "7ad3dee41f36859875573074334c200d1add8e4a87bb37113ebd31d926b7b11f"
dependencies = [
"proc-macro2",
"quote",
@ -5475,7 +5530,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.62",
"syn 2.0.64",
]
[[package]]
@ -5626,22 +5681,22 @@ checksum = "a38c90d48152c236a3ab59271da4f4ae63d678c5d7ad6b7714d7cb9760be5e4b"
[[package]]
name = "thiserror"
version = "1.0.60"
version = "1.0.61"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "579e9083ca58dd9dcf91a9923bb9054071b9ebbd800b342194c9feb0ee89fc18"
checksum = "c546c80d6be4bc6a00c0f01730c08df82eaa7a7a61f11d656526506112cc1709"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
version = "1.0.60"
version = "1.0.61"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2470041c06ec3ac1ab38d0356a6119054dedaea53e12fbefc0de730a1c08524"
checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.62",
"syn 2.0.64",
]
[[package]]
@ -5810,9 +5865,9 @@ dependencies = [
[[package]]
name = "toml_datetime"
version = "0.6.5"
version = "0.6.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1"
checksum = "4badfd56924ae69bcc9039335b2e017639ce3f9b001c393c1b2d1ef846ce2cbf"
dependencies = [
"serde",
]
@ -5862,7 +5917,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.62",
"syn 2.0.64",
]
[[package]]
@ -6068,7 +6123,7 @@ checksum = "1ed7f4237ba393424195053097c1516bd4590dc82b84f2f97c5c69e12704555b"
dependencies = [
"proc-macro-hack",
"quote",
"syn 2.0.62",
"syn 2.0.64",
"unic-langid-impl",
]
@ -6300,7 +6355,7 @@ dependencies = [
"once_cell",
"proc-macro2",
"quote",
"syn 2.0.62",
"syn 2.0.64",
"wasm-bindgen-shared",
]
@ -6334,7 +6389,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.62",
"syn 2.0.64",
"wasm-bindgen-backend",
"wasm-bindgen-shared",
]
@ -6425,7 +6480,7 @@ dependencies = [
"rayon",
"serde",
"serde_json",
"syn 2.0.62",
"syn 2.0.64",
"windows-metadata",
]
@ -6657,7 +6712,7 @@ checksum = "9e6936f0cce458098a201c245a11bef556c6a0181129c7034d10d76d1ec3a2b8"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.62",
"syn 2.0.64",
"synstructure",
]
@ -6678,7 +6733,7 @@ checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.62",
"syn 2.0.64",
]
[[package]]
@ -6698,7 +6753,7 @@ checksum = "e6a647510471d372f2e6c2e6b7219e44d8c574d24fdc11c610a61455782f18c3"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.62",
"syn 2.0.64",
"synstructure",
]
@ -6721,7 +6776,7 @@ checksum = "7b4e5997cbf58990550ef1f0e5124a05e47e1ebd33a84af25739be6031a62c20"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.62",
"syn 2.0.64",
]
[[package]]

View File

@ -3343,6 +3343,10 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
} else if string.starts_with("gen") {
// `gen` is 3 chars long
Some(3)
} else if string.starts_with("static") {
// `static` is 6 chars long
// This is used for `!Unpin` coroutines
Some(6)
} else {
None
};

View File

@ -364,41 +364,11 @@ impl<'tcx> FnCtxt<'_, 'tcx> {
};
let mut fallback_to = |ty| {
let unsafe_infer_vars = unsafe_infer_vars.get_or_init(|| {
let unsafe_infer_vars = compute_unsafe_infer_vars(self.root_ctxt, self.body_id);
debug!(?unsafe_infer_vars);
unsafe_infer_vars
});
let affected_unsafe_infer_vars =
graph::depth_first_search_as_undirected(&coercion_graph, root_vid)
.filter_map(|x| unsafe_infer_vars.get(&x).copied())
.collect::<Vec<_>>();
for (hir_id, span, reason) in affected_unsafe_infer_vars {
self.tcx.emit_node_span_lint(
lint::builtin::NEVER_TYPE_FALLBACK_FLOWING_INTO_UNSAFE,
hir_id,
span,
match reason {
UnsafeUseReason::Call => {
errors::NeverTypeFallbackFlowingIntoUnsafe::Call
}
UnsafeUseReason::Method => {
errors::NeverTypeFallbackFlowingIntoUnsafe::Method
}
UnsafeUseReason::Path => {
errors::NeverTypeFallbackFlowingIntoUnsafe::Path
}
UnsafeUseReason::UnionField => {
errors::NeverTypeFallbackFlowingIntoUnsafe::UnionField
}
UnsafeUseReason::Deref => {
errors::NeverTypeFallbackFlowingIntoUnsafe::Deref
}
},
);
}
self.lint_never_type_fallback_flowing_into_unsafe_code(
&unsafe_infer_vars,
&coercion_graph,
root_vid,
);
diverging_fallback.insert(diverging_ty, ty);
};
@ -464,6 +434,41 @@ impl<'tcx> FnCtxt<'_, 'tcx> {
diverging_fallback
}
fn lint_never_type_fallback_flowing_into_unsafe_code(
&self,
unsafe_infer_vars: &OnceCell<UnordMap<ty::TyVid, (HirId, Span, UnsafeUseReason)>>,
coercion_graph: &VecGraph<ty::TyVid, true>,
root_vid: ty::TyVid,
) {
let unsafe_infer_vars = unsafe_infer_vars.get_or_init(|| {
let unsafe_infer_vars = compute_unsafe_infer_vars(self.root_ctxt, self.body_id);
debug!(?unsafe_infer_vars);
unsafe_infer_vars
});
let affected_unsafe_infer_vars =
graph::depth_first_search_as_undirected(&coercion_graph, root_vid)
.filter_map(|x| unsafe_infer_vars.get(&x).copied())
.collect::<Vec<_>>();
for (hir_id, span, reason) in affected_unsafe_infer_vars {
self.tcx.emit_node_span_lint(
lint::builtin::NEVER_TYPE_FALLBACK_FLOWING_INTO_UNSAFE,
hir_id,
span,
match reason {
UnsafeUseReason::Call => errors::NeverTypeFallbackFlowingIntoUnsafe::Call,
UnsafeUseReason::Method => errors::NeverTypeFallbackFlowingIntoUnsafe::Method,
UnsafeUseReason::Path => errors::NeverTypeFallbackFlowingIntoUnsafe::Path,
UnsafeUseReason::UnionField => {
errors::NeverTypeFallbackFlowingIntoUnsafe::UnionField
}
UnsafeUseReason::Deref => errors::NeverTypeFallbackFlowingIntoUnsafe::Deref,
},
);
}
}
/// Returns a graph whose nodes are (unresolved) inference variables and where
/// an edge `?A -> ?B` indicates that the variable `?A` is coerced to `?B`.
fn create_coercion_graph(&self) -> VecGraph<ty::TyVid, true> {

View File

@ -389,6 +389,7 @@ pub fn run_compiler<R: Send>(config: Config, f: impl FnOnce(&Compiler) -> R + Se
let hash_kind = config.opts.unstable_opts.src_hash_algorithm(&target);
util::run_in_thread_pool_with_globals(
&early_dcx,
config.opts.edition,
config.opts.unstable_opts.threads,
SourceMapInputs { file_loader, path_mapping, hash_kind },

View File

@ -51,20 +51,38 @@ pub fn add_configuration(cfg: &mut Cfg, sess: &mut Session, codegen_backend: &dy
pub static STACK_SIZE: OnceLock<usize> = OnceLock::new();
pub const DEFAULT_STACK_SIZE: usize = 8 * 1024 * 1024;
fn init_stack_size() -> usize {
fn init_stack_size(early_dcx: &EarlyDiagCtxt) -> usize {
// Obey the environment setting or default
*STACK_SIZE.get_or_init(|| {
env::var_os("RUST_MIN_STACK")
.map(|os_str| os_str.to_string_lossy().into_owned())
// ignore if it is set to nothing
.filter(|s| s.trim() != "")
.map(|s| s.trim().parse::<usize>().unwrap())
.as_ref()
.map(|os_str| os_str.to_string_lossy())
// if someone finds out `export RUST_MIN_STACK=640000` isn't enough stack
// they might try to "unset" it by running `RUST_MIN_STACK= rustc code.rs`
// this is wrong, but std would nonetheless "do what they mean", so let's do likewise
.filter(|s| !s.trim().is_empty())
// rustc is a batch program, so error early on inputs which are unlikely to be intended
// so no one thinks we parsed them setting `RUST_MIN_STACK="64 megabytes"`
// FIXME: we could accept `RUST_MIN_STACK=64MB`, perhaps?
.map(|s| {
let s = s.trim();
// FIXME(workingjubilee): add proper diagnostics when we factor out "pre-run" setup
#[allow(rustc::untranslatable_diagnostic, rustc::diagnostic_outside_of_impl)]
s.parse::<usize>().unwrap_or_else(|_| {
let mut err = early_dcx.early_struct_fatal(format!(
r#"`RUST_MIN_STACK` should be a number of bytes, but was "{s}""#,
));
err.note("you can also unset `RUST_MIN_STACK` to use the default stack size");
err.emit()
})
})
// otherwise pick a consistent default
.unwrap_or(DEFAULT_STACK_SIZE)
})
}
fn run_in_thread_with_globals<F: FnOnce(CurrentGcx) -> R + Send, R: Send>(
thread_stack_size: usize,
edition: Edition,
sm_inputs: SourceMapInputs,
f: F,
@ -75,7 +93,7 @@ fn run_in_thread_with_globals<F: FnOnce(CurrentGcx) -> R + Send, R: Send>(
// the parallel compiler, in particular to ensure there is no accidental
// sharing of data between the main thread and the compilation thread
// (which might cause problems for the parallel compiler).
let builder = thread::Builder::new().name("rustc".to_string()).stack_size(init_stack_size());
let builder = thread::Builder::new().name("rustc".to_string()).stack_size(thread_stack_size);
// We build the session globals and run `f` on the spawned thread, because
// `SessionGlobals` does not impl `Send` in the non-parallel compiler.
@ -100,16 +118,19 @@ fn run_in_thread_with_globals<F: FnOnce(CurrentGcx) -> R + Send, R: Send>(
#[cfg(not(parallel_compiler))]
pub(crate) fn run_in_thread_pool_with_globals<F: FnOnce(CurrentGcx) -> R + Send, R: Send>(
thread_builder_diag: &EarlyDiagCtxt,
edition: Edition,
_threads: usize,
sm_inputs: SourceMapInputs,
f: F,
) -> R {
run_in_thread_with_globals(edition, sm_inputs, f)
let thread_stack_size = init_stack_size(thread_builder_diag);
run_in_thread_with_globals(thread_stack_size, edition, sm_inputs, f)
}
#[cfg(parallel_compiler)]
pub(crate) fn run_in_thread_pool_with_globals<F: FnOnce(CurrentGcx) -> R + Send, R: Send>(
thread_builder_diag: &EarlyDiagCtxt,
edition: Edition,
threads: usize,
sm_inputs: SourceMapInputs,
@ -121,10 +142,12 @@ pub(crate) fn run_in_thread_pool_with_globals<F: FnOnce(CurrentGcx) -> R + Send,
use rustc_query_system::query::{break_query_cycles, QueryContext};
use std::process;
let thread_stack_size = init_stack_size(thread_builder_diag);
let registry = sync::Registry::new(std::num::NonZero::new(threads).unwrap());
if !sync::is_dyn_thread_safe() {
return run_in_thread_with_globals(edition, sm_inputs, |current_gcx| {
return run_in_thread_with_globals(thread_stack_size, edition, sm_inputs, |current_gcx| {
// Register the thread for use with the `WorkerLocal` type.
registry.register();
@ -167,7 +190,7 @@ pub(crate) fn run_in_thread_pool_with_globals<F: FnOnce(CurrentGcx) -> R + Send,
})
.unwrap();
})
.stack_size(init_stack_size());
.stack_size(thread_stack_size);
// We create the session globals on the main thread, then create the thread
// pool. Upon creation, each worker thread created gets a copy of the

View File

@ -4263,8 +4263,7 @@ declare_lint! {
///
/// // where absurd is a function with the following signature
/// // (it's sound, because `!` always marks unreachable code):
/// fn absurd<T>(_: !) -> T { ... }
// FIXME: use `core::convert::absurd` here instead, once it's merged
/// fn absurd<T>(never: !) -> T { ... }
/// ```
///
/// While it's convenient to be able to use non-diverging code in one of the branches (like
@ -4321,7 +4320,12 @@ declare_lint! {
/// [`()`]: https://doc.rust-lang.org/core/primitive.unit.html
pub NEVER_TYPE_FALLBACK_FLOWING_INTO_UNSAFE,
Warn,
"never type fallback affecting unsafe function calls"
"never type fallback affecting unsafe function calls",
@future_incompatible = FutureIncompatibleInfo {
reason: FutureIncompatibilityReason::FutureReleaseSemanticsChange,
reference: "issue #123748 <https://github.com/rust-lang/rust/issues/123748>",
};
report_in_external_macro
}
declare_lint! {

View File

@ -1356,6 +1356,33 @@ impl<T: ?Sized, A: Allocator> Rc<T, A> {
ptr
}
/// Consumes the `Rc`, returning the wrapped pointer and allocator.
///
/// To avoid a memory leak the pointer must be converted back to an `Rc` using
/// [`Rc::from_raw_in`].
///
/// # Examples
///
/// ```
/// #![feature(allocator_api)]
/// use std::rc::Rc;
/// use std::alloc::System;
///
/// let x = Rc::new_in("hello".to_owned(), System);
/// let (ptr, alloc) = Rc::into_raw_with_allocator(x);
/// assert_eq!(unsafe { &*ptr }, "hello");
/// let x = unsafe { Rc::from_raw_in(ptr, alloc) };
/// assert_eq!(&*x, "hello");
/// ```
#[unstable(feature = "allocator_api", issue = "32838")]
pub fn into_raw_with_allocator(this: Self) -> (*const T, A) {
let this = mem::ManuallyDrop::new(this);
let ptr = Self::as_ptr(&this);
// Safety: `this` is ManuallyDrop so the allocator will not be double-dropped
let alloc = unsafe { ptr::read(&this.alloc) };
(ptr, alloc)
}
/// Provides a raw pointer to the data.
///
/// The counts are not affected in any way and the `Rc` is not consumed. The pointer is valid
@ -3024,11 +3051,11 @@ impl<T: ?Sized, A: Allocator> Weak<T, A> {
result
}
/// Consumes the `Weak<T>` and turns it into a raw pointer.
/// Consumes the `Weak<T>`, returning the wrapped pointer and allocator.
///
/// This converts the weak pointer into a raw pointer, while still preserving the ownership of
/// one weak reference (the weak count is not modified by this operation). It can be turned
/// back into the `Weak<T>` with [`from_raw`].
/// back into the `Weak<T>` with [`from_raw_in`].
///
/// The same restrictions of accessing the target of the pointer as with
/// [`as_ptr`] apply.
@ -3036,27 +3063,30 @@ impl<T: ?Sized, A: Allocator> Weak<T, A> {
/// # Examples
///
/// ```
/// #![feature(allocator_api)]
/// use std::rc::{Rc, Weak};
/// use std::alloc::System;
///
/// let strong = Rc::new("hello".to_owned());
/// let strong = Rc::new_in("hello".to_owned(), System);
/// let weak = Rc::downgrade(&strong);
/// let raw = weak.into_raw();
/// let (raw, alloc) = weak.into_raw_with_allocator();
///
/// assert_eq!(1, Rc::weak_count(&strong));
/// assert_eq!("hello", unsafe { &*raw });
///
/// drop(unsafe { Weak::from_raw(raw) });
/// drop(unsafe { Weak::from_raw_in(raw, alloc) });
/// assert_eq!(0, Rc::weak_count(&strong));
/// ```
///
/// [`from_raw`]: Weak::from_raw
/// [`from_raw_in`]: Weak::from_raw_in
/// [`as_ptr`]: Weak::as_ptr
#[inline]
#[unstable(feature = "allocator_api", issue = "32838")]
pub fn into_raw_and_alloc(self) -> (*const T, A) {
let rc = mem::ManuallyDrop::new(self);
let result = rc.as_ptr();
let alloc = unsafe { ptr::read(&rc.alloc) };
pub fn into_raw_with_allocator(self) -> (*const T, A) {
let this = mem::ManuallyDrop::new(self);
let result = this.as_ptr();
// Safety: `this` is ManuallyDrop so the allocator will not be double-dropped
let alloc = unsafe { ptr::read(&this.alloc) };
(result, alloc)
}

View File

@ -1496,6 +1496,34 @@ impl<T: ?Sized, A: Allocator> Arc<T, A> {
ptr
}
/// Consumes the `Arc`, returning the wrapped pointer and allocator.
///
/// To avoid a memory leak the pointer must be converted back to an `Arc` using
/// [`Arc::from_raw_in`].
///
/// # Examples
///
/// ```
/// #![feature(allocator_api)]
/// use std::sync::Arc;
/// use std::alloc::System;
///
/// let x = Arc::new_in("hello".to_owned(), System);
/// let (ptr, alloc) = Arc::into_raw_with_allocator(x);
/// assert_eq!(unsafe { &*ptr }, "hello");
/// let x = unsafe { Arc::from_raw_in(ptr, alloc) };
/// assert_eq!(&*x, "hello");
/// ```
#[must_use = "losing the pointer will leak memory"]
#[unstable(feature = "allocator_api", issue = "32838")]
pub fn into_raw_with_allocator(this: Self) -> (*const T, A) {
let this = mem::ManuallyDrop::new(this);
let ptr = Self::as_ptr(&this);
// Safety: `this` is ManuallyDrop so the allocator will not be double-dropped
let alloc = unsafe { ptr::read(&this.alloc) };
(ptr, alloc)
}
/// Provides a raw pointer to the data.
///
/// The counts are not affected in any way and the `Arc` is not consumed. The pointer is valid for
@ -2740,6 +2768,45 @@ impl<T: ?Sized, A: Allocator> Weak<T, A> {
result
}
/// Consumes the `Weak<T>`, returning the wrapped pointer and allocator.
///
/// This converts the weak pointer into a raw pointer, while still preserving the ownership of
/// one weak reference (the weak count is not modified by this operation). It can be turned
/// back into the `Weak<T>` with [`from_raw_in`].
///
/// The same restrictions of accessing the target of the pointer as with
/// [`as_ptr`] apply.
///
/// # Examples
///
/// ```
/// #![feature(allocator_api)]
/// use std::sync::{Arc, Weak};
/// use std::alloc::System;
///
/// let strong = Arc::new_in("hello".to_owned(), System);
/// let weak = Arc::downgrade(&strong);
/// let (raw, alloc) = weak.into_raw_with_allocator();
///
/// assert_eq!(1, Arc::weak_count(&strong));
/// assert_eq!("hello", unsafe { &*raw });
///
/// drop(unsafe { Weak::from_raw_in(raw, alloc) });
/// assert_eq!(0, Arc::weak_count(&strong));
/// ```
///
/// [`from_raw_in`]: Weak::from_raw_in
/// [`as_ptr`]: Weak::as_ptr
#[must_use = "losing the pointer will leak memory"]
#[unstable(feature = "allocator_api", issue = "32838")]
pub fn into_raw_with_allocator(self) -> (*const T, A) {
let this = mem::ManuallyDrop::new(self);
let result = this.as_ptr();
// Safety: `this` is ManuallyDrop so the allocator will not be double-dropped
let alloc = unsafe { ptr::read(&this.alloc) };
(result, alloc)
}
/// Converts a raw pointer previously created by [`into_raw`] back into `Weak<T>` in the provided
/// allocator.
///

View File

@ -0,0 +1,19 @@
//@ run-rustfix
// check to make sure that we suggest adding `move` after `static`
#![feature(coroutines)]
fn check() -> impl Sized {
let x = 0;
#[coroutine]
static move || {
//~^ ERROR E0373
yield;
x
}
}
fn main() {
check();
}

View File

@ -0,0 +1,19 @@
//@ run-rustfix
// check to make sure that we suggest adding `move` after `static`
#![feature(coroutines)]
fn check() -> impl Sized {
let x = 0;
#[coroutine]
static || {
//~^ ERROR E0373
yield;
x
}
}
fn main() {
check();
}

View File

@ -0,0 +1,26 @@
error[E0373]: coroutine may outlive the current function, but it borrows `x`, which is owned by the current function
--> $DIR/static-move-suggestion.rs:10:5
|
LL | static || {
| ^^^^^^^^^ may outlive borrowed value `x`
...
LL | x
| - `x` is borrowed here
|
note: coroutine is returned here
--> $DIR/static-move-suggestion.rs:10:5
|
LL | / static || {
LL | |
LL | | yield;
LL | | x
LL | | }
| |_____^
help: to force the coroutine to take ownership of `x` (and any other referenced variables), use the `move` keyword
|
LL | static move || {
| ++++
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0373`.

View File

@ -7,6 +7,7 @@ fn _zero() {
if false {
unsafe { mem::zeroed() }
//~^ warn: never type fallback affects this call to an `unsafe` function
//~| warn: this will change its meaning in a future release!
} else {
return;
};
@ -21,6 +22,7 @@ fn _trans() {
struct Zst;
core::mem::transmute(Zst)
//~^ warn: never type fallback affects this call to an `unsafe` function
//~| warn: this will change its meaning in a future release!
}
} else {
return;
@ -36,6 +38,7 @@ fn _union() {
unsafe { Union { a: () }.b }
//~^ warn: never type fallback affects this union access
//~| warn: this will change its meaning in a future release!
} else {
return;
};
@ -45,6 +48,7 @@ fn _deref() {
if false {
unsafe { *ptr::from_ref(&()).cast() }
//~^ warn: never type fallback affects this raw pointer dereference
//~| warn: this will change its meaning in a future release!
} else {
return;
};
@ -62,6 +66,7 @@ fn _only_generics() {
unsafe { internally_create(x) }
//~^ warn: never type fallback affects this call to an `unsafe` function
//~| warn: this will change its meaning in a future release!
x.unwrap()
} else {
@ -73,9 +78,11 @@ fn _stored_function() {
if false {
let zeroed = mem::zeroed;
//~^ warn: never type fallback affects this `unsafe` function
//~| warn: this will change its meaning in a future release!
unsafe { zeroed() }
//~^ warn: never type fallback affects this call to an `unsafe` function
//~| warn: this will change its meaning in a future release!
} else {
return;
};
@ -90,6 +97,7 @@ fn _only_generics_stored_function() {
let x = None;
let f = internally_create;
//~^ warn: never type fallback affects this `unsafe` function
//~| warn: this will change its meaning in a future release!
unsafe { f(x) }
@ -113,6 +121,7 @@ fn _method() {
unsafe {
S(marker::PhantomData).create_out_of_thin_air()
//~^ warn: never type fallback affects this call to an `unsafe` method
//~| warn: this will change its meaning in a future release!
}
} else {
return;
@ -129,6 +138,7 @@ fn _objc() {
() => {
match send_message::<_ /* ?0 */>() {
//~^ warn: never type fallback affects this call to an `unsafe` function
//~| warn: this will change its meaning in a future release!
Ok(x) => x,
Err(_) => loop {},
}

View File

@ -4,75 +4,93 @@ warning: never type fallback affects this call to an `unsafe` function
LL | unsafe { mem::zeroed() }
| ^^^^^^^^^^^^^
|
= warning: this will change its meaning in a future release!
= note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748>
= help: specify the type explicitly
= note: `#[warn(never_type_fallback_flowing_into_unsafe)]` on by default
warning: never type fallback affects this call to an `unsafe` function
--> $DIR/lint-never-type-fallback-flowing-into-unsafe.rs:22:13
--> $DIR/lint-never-type-fallback-flowing-into-unsafe.rs:23:13
|
LL | core::mem::transmute(Zst)
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
= warning: this will change its meaning in a future release!
= note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748>
= help: specify the type explicitly
warning: never type fallback affects this union access
--> $DIR/lint-never-type-fallback-flowing-into-unsafe.rs:37:18
--> $DIR/lint-never-type-fallback-flowing-into-unsafe.rs:39:18
|
LL | unsafe { Union { a: () }.b }
| ^^^^^^^^^^^^^^^^^
|
= warning: this will change its meaning in a future release!
= note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748>
= help: specify the type explicitly
warning: never type fallback affects this raw pointer dereference
--> $DIR/lint-never-type-fallback-flowing-into-unsafe.rs:46:18
--> $DIR/lint-never-type-fallback-flowing-into-unsafe.rs:49:18
|
LL | unsafe { *ptr::from_ref(&()).cast() }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= warning: this will change its meaning in a future release!
= note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748>
= help: specify the type explicitly
warning: never type fallback affects this call to an `unsafe` function
--> $DIR/lint-never-type-fallback-flowing-into-unsafe.rs:63:18
--> $DIR/lint-never-type-fallback-flowing-into-unsafe.rs:67:18
|
LL | unsafe { internally_create(x) }
| ^^^^^^^^^^^^^^^^^^^^
|
= warning: this will change its meaning in a future release!
= note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748>
= help: specify the type explicitly
warning: never type fallback affects this call to an `unsafe` function
--> $DIR/lint-never-type-fallback-flowing-into-unsafe.rs:77:18
--> $DIR/lint-never-type-fallback-flowing-into-unsafe.rs:83:18
|
LL | unsafe { zeroed() }
| ^^^^^^^^
|
= warning: this will change its meaning in a future release!
= note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748>
= help: specify the type explicitly
warning: never type fallback affects this `unsafe` function
--> $DIR/lint-never-type-fallback-flowing-into-unsafe.rs:74:22
--> $DIR/lint-never-type-fallback-flowing-into-unsafe.rs:79:22
|
LL | let zeroed = mem::zeroed;
| ^^^^^^^^^^^
|
= warning: this will change its meaning in a future release!
= note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748>
= help: specify the type explicitly
warning: never type fallback affects this `unsafe` function
--> $DIR/lint-never-type-fallback-flowing-into-unsafe.rs:91:17
--> $DIR/lint-never-type-fallback-flowing-into-unsafe.rs:98:17
|
LL | let f = internally_create;
| ^^^^^^^^^^^^^^^^^
|
= warning: this will change its meaning in a future release!
= note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748>
= help: specify the type explicitly
warning: never type fallback affects this call to an `unsafe` method
--> $DIR/lint-never-type-fallback-flowing-into-unsafe.rs:114:13
--> $DIR/lint-never-type-fallback-flowing-into-unsafe.rs:122:13
|
LL | S(marker::PhantomData).create_out_of_thin_air()
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= warning: this will change its meaning in a future release!
= note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748>
= help: specify the type explicitly
warning: never type fallback affects this call to an `unsafe` function
--> $DIR/lint-never-type-fallback-flowing-into-unsafe.rs:130:19
--> $DIR/lint-never-type-fallback-flowing-into-unsafe.rs:139:19
|
LL | match send_message::<_ /* ?0 */>() {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -80,6 +98,8 @@ LL | match send_message::<_ /* ?0 */>() {
LL | msg_send!();
| ----------- in this macro invocation
|
= warning: this will change its meaning in a future release!
= note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748>
= help: specify the type explicitly
= note: this warning originates in the macro `msg_send` (in Nightly builds, run with -Z macro-backtrace for more info)

View File

@ -0,0 +1,6 @@
Some environment variables affect rustc's behavior not because they are major compiler interfaces
but rather because rustc is, ultimately, a Rust program, with debug logging, stack control, etc.
Prefer to group tests that use environment variables to control something about rustc's core UX,
like "can we parse this number of parens if we raise RUST_MIN_STACK?" with related code for that
compiler feature.

View File

@ -0,0 +1,2 @@
//@ rustc-env:RUST_MIN_STACK=banana
fn main() {}

View File

@ -0,0 +1,4 @@
error: `RUST_MIN_STACK` should be a number of bytes, but was "banana"
|
= note: you can also unset `RUST_MIN_STACK` to use the default stack size

View File

@ -5,7 +5,7 @@
//@ dont-check-compiler-stdout
//@ dont-check-compiler-stderr
//@ compile-flags: --error-format human
//@ aux-build: rustc-rust-log-aux.rs
//@ aux-build: rust-log-aux.rs
//@ rustc-env:RUSTC_LOG=debug
fn main() {}