Skip to content

Commit 59f551a

Browse files
committed
Auto merge of #84840 - Dylan-DPC:rollup-uzk7w0h, r=Dylan-DPC
Rollup of 6 pull requests Successful merges: - #84072 (Allow setting `target_family` to multiple values, and implement `target_family="wasm"`) - #84744 (Add ErrorKind::OutOfMemory) - #84784 (Add help message to suggest const for unused type param) - #84811 (RustDoc: Fix bounds linking trait.Foo instead of traitalias.Foo) - #84818 (suggestion for unit enum variant when matched with a patern) - #84832 (Do not print visibility in external traits) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 8a8ed07 + 83c49d0 commit 59f551a

File tree

67 files changed

+383
-94
lines changed

Some content is hidden

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

67 files changed

+383
-94
lines changed

compiler/rustc_resolve/src/late/diagnostics.rs

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -819,6 +819,19 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
819819
_ => false,
820820
};
821821

822+
let find_span = |source: &PathSource<'_>, err: &mut DiagnosticBuilder<'_>| {
823+
match source {
824+
PathSource::Expr(Some(Expr { span, kind: ExprKind::Call(_, _), .. }))
825+
| PathSource::TupleStruct(span, _) => {
826+
// We want the main underline to cover the suggested code as well for
827+
// cleaner output.
828+
err.set_span(*span);
829+
*span
830+
}
831+
_ => span,
832+
}
833+
};
834+
822835
let mut bad_struct_syntax_suggestion = |def_id: DefId| {
823836
let (followed_by_brace, closing_brace) = self.followed_by_brace(span);
824837

@@ -862,18 +875,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
862875
}
863876
}
864877
PathSource::Expr(_) | PathSource::TupleStruct(..) | PathSource::Pat => {
865-
let span = match &source {
866-
PathSource::Expr(Some(Expr {
867-
span, kind: ExprKind::Call(_, _), ..
868-
}))
869-
| PathSource::TupleStruct(span, _) => {
870-
// We want the main underline to cover the suggested code as well for
871-
// cleaner output.
872-
err.set_span(*span);
873-
*span
874-
}
875-
_ => span,
876-
};
878+
let span = find_span(&source, err);
877879
if let Some(span) = self.def_span(def_id) {
878880
err.span_label(span, &format!("`{}` defined here", path_str));
879881
}
@@ -1047,6 +1049,23 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
10471049
) if ns == ValueNS => {
10481050
bad_struct_syntax_suggestion(def_id);
10491051
}
1052+
(Res::Def(DefKind::Ctor(_, CtorKind::Const), def_id), _) if ns == ValueNS => {
1053+
match source {
1054+
PathSource::Expr(_) | PathSource::TupleStruct(..) | PathSource::Pat => {
1055+
let span = find_span(&source, err);
1056+
if let Some(span) = self.def_span(def_id) {
1057+
err.span_label(span, &format!("`{}` defined here", path_str));
1058+
}
1059+
err.span_suggestion(
1060+
span,
1061+
&format!("use this syntax instead"),
1062+
format!("{path_str}"),
1063+
Applicability::MaybeIncorrect,
1064+
);
1065+
}
1066+
_ => return false,
1067+
}
1068+
}
10501069
(Res::Def(DefKind::Ctor(_, CtorKind::Fn), def_id), _) if ns == ValueNS => {
10511070
if let Some(span) = self.def_span(def_id) {
10521071
err.span_label(span, &format!("`{}` defined here", path_str));

compiler/rustc_session/src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -816,7 +816,7 @@ fn default_configuration(sess: &Session) -> CrateConfig {
816816
ret.reserve(6); // the minimum number of insertions
817817
// Target bindings.
818818
ret.insert((sym::target_os, Some(Symbol::intern(os))));
819-
if let Some(ref fam) = sess.target.os_family {
819+
for fam in &sess.target.families {
820820
ret.insert((sym::target_family, Some(Symbol::intern(fam))));
821821
if fam == "windows" {
822822
ret.insert((sym::windows, None));

compiler/rustc_target/src/spec/apple_base.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub fn opts(os: &str) -> TargetOptions {
2323
function_sections: false,
2424
dynamic_linking: true,
2525
executables: true,
26-
os_family: Some("unix".to_string()),
26+
families: vec!["unix".to_string()],
2727
is_like_osx: true,
2828
dwarf_version: Some(2),
2929
has_rpath: true,

compiler/rustc_target/src/spec/dragonfly_base.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ pub fn opts() -> TargetOptions {
55
os: "dragonfly".to_string(),
66
dynamic_linking: true,
77
executables: true,
8-
os_family: Some("unix".to_string()),
8+
families: vec!["unix".to_string()],
99
linker_is_gnu: true,
1010
has_rpath: true,
1111
position_independent_executables: true,

compiler/rustc_target/src/spec/freebsd_base.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ pub fn opts() -> TargetOptions {
55
os: "freebsd".to_string(),
66
dynamic_linking: true,
77
executables: true,
8-
os_family: Some("unix".to_string()),
8+
families: vec!["unix".to_string()],
99
linker_is_gnu: true,
1010
has_rpath: true,
1111
position_independent_executables: true,

compiler/rustc_target/src/spec/fuchsia_base.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ pub fn opts() -> TargetOptions {
2525
linker: Some("rust-lld".to_owned()),
2626
dynamic_linking: true,
2727
executables: true,
28-
os_family: Some("unix".to_string()),
28+
families: vec!["unix".to_string()],
2929
is_like_fuchsia: true,
3030
linker_is_gnu: true,
3131
pre_link_args,

compiler/rustc_target/src/spec/haiku_base.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ pub fn opts() -> TargetOptions {
55
os: "haiku".to_string(),
66
dynamic_linking: true,
77
executables: true,
8-
os_family: Some("unix".to_string()),
8+
families: vec!["unix".to_string()],
99
relro_level: RelroLevel::Full,
1010
linker_is_gnu: true,
1111
..Default::default()

compiler/rustc_target/src/spec/illumos_base.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub fn opts() -> TargetOptions {
2020
dynamic_linking: true,
2121
executables: true,
2222
has_rpath: true,
23-
os_family: Some("unix".to_string()),
23+
families: vec!["unix".to_string()],
2424
is_like_solaris: true,
2525
limit_rdylib_exports: false, // Linker doesn't support this
2626
eliminate_frame_pointer: false,

compiler/rustc_target/src/spec/l4re_base.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub fn opts() -> TargetOptions {
2020
executables: true,
2121
panic_strategy: PanicStrategy::Abort,
2222
linker: Some("ld".to_string()),
23-
os_family: Some("unix".to_string()),
23+
families: vec!["unix".to_string()],
2424
..Default::default()
2525
}
2626
}

compiler/rustc_target/src/spec/linux_base.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ pub fn opts() -> TargetOptions {
55
os: "linux".to_string(),
66
dynamic_linking: true,
77
executables: true,
8-
os_family: Some("unix".to_string()),
8+
families: vec!["unix".to_string()],
99
linker_is_gnu: true,
1010
has_rpath: true,
1111
position_independent_executables: true,

0 commit comments

Comments
 (0)