Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 9 pull requests #111476

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
2198fae
Make `NonUseContext::AscribeUserTy` carry `ty::Variance`
obeis May 8, 2023
b64e911
Add test.
cjgillot May 10, 2023
d0d4e02
Iteratively replace pointers.
cjgillot May 10, 2023
aeac555
Do not see through copies of mutable pointers.
cjgillot May 10, 2023
9fb1c73
Avoid shadowing.
cjgillot May 10, 2023
a2fe993
Only warn single-use lifetime when the binders match.
cjgillot May 10, 2023
ccd8ad7
Note base types of coercion
compiler-errors May 11, 2023
eadf3bb
Update cargo
heiher May 11, 2023
616fb42
Update browser-ui-test version to 0.16.0
GuillaumeGomez May 10, 2023
0630283
Migrate to 0.16.0 browser-ui-test version
GuillaumeGomez May 10, 2023
8e55400
Convert some GUI tests color checks to use original format
GuillaumeGomez May 11, 2023
cac7e42
Fix backtrace normalization in ice-bug-report-url.rs
uweigand May 10, 2023
3851a4b
Improve error for `self: Box<self>`
clubby789 May 11, 2023
90ce53a
Usage of atomic counters for llvm code coverage
Dushistov May 11, 2023
e1746af
Rollup merge of #111366 - obeis:ascribe-user-type-variance, r=lcnr
matthiaskrgr May 11, 2023
1c5586a
Rollup merge of #111439 - uweigand:backtrace-normalize, r=compiler-er…
matthiaskrgr May 11, 2023
e4444d1
Rollup merge of #111441 - cjgillot:issue-111422, r=JakobDegen
matthiaskrgr May 11, 2023
2651fff
Rollup merge of #111444 - cjgillot:issue-111400, r=oli-obk
matthiaskrgr May 11, 2023
41ab9c8
Rollup merge of #111451 - compiler-errors:note-cast-origin, r=b-naber
matthiaskrgr May 11, 2023
c58dd49
Rollup merge of #111456 - loongarch-rs:bump-cargo, r=weihanglo
matthiaskrgr May 11, 2023
3a5077c
Rollup merge of #111459 - GuillaumeGomez:update-browser-ui-test, r=no…
matthiaskrgr May 11, 2023
ae2f6f2
Rollup merge of #111460 - clubby789:lowercase-box-self, r=compiler-er…
matthiaskrgr May 11, 2023
b203279
Rollup merge of #111469 - Dushistov:fix-coverage-data-race, r=wesleyw…
matthiaskrgr May 11, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/ty/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1253,7 +1253,7 @@ pub enum ExplicitSelf<'tcx> {

impl<'tcx> ExplicitSelf<'tcx> {
/// Categorizes an explicit self declaration like `self: SomeType`
/// into either `self`, `&self`, `&mut self`, `Box<self>`, or
/// into either `self`, `&self`, `&mut self`, `Box<Self>`, or
/// `Other`.
/// This is mainly used to require the arbitrary_self_types feature
/// in the case of `Other`, to improve error messages in the common cases,
Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_resolve/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,10 @@ resolve_invalid_asm_sym =
.label = is a local variable
.help = `sym` operands must refer to either a function or a static

resolve_lowercase_self =
attempt to use a non-constant value in a constant
.suggestion = try using `Self`

resolve_trait_impl_duplicate =
duplicate definitions with name `{$name}`:
.label = duplicate definition
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_resolve/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -948,6 +948,9 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
ResolutionError::InvalidAsmSym => {
self.tcx.sess.create_err(errs::InvalidAsmSym { span })
}
ResolutionError::LowercaseSelf => {
self.tcx.sess.create_err(errs::LowercaseSelf { span })
}
}
}

Expand Down
8 changes: 8 additions & 0 deletions compiler/rustc_resolve/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,14 @@ pub(crate) struct InvalidAsmSym {
pub(crate) span: Span,
}

#[derive(Diagnostic)]
#[diag(resolve_lowercase_self)]
pub(crate) struct LowercaseSelf {
#[primary_span]
#[suggestion(code = "Self", applicability = "maybe-incorrect", style = "short")]
pub(crate) span: Span,
}

#[derive(Diagnostic)]
#[diag(resolve_trait_impl_duplicate, code = "E0201")]
pub(crate) struct TraitImplDuplicate {
Expand Down
44 changes: 20 additions & 24 deletions compiler/rustc_resolve/src/ident.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ use std::ptr;

use crate::errors::{ParamKindInEnumDiscriminant, ParamKindInNonTrivialAnonConst};
use crate::late::{
ConstantHasGenerics, ConstantItemKind, HasGenericParams, NoConstantGenericsReason, PathSource,
Rib, RibKind,
ConstantHasGenerics, HasGenericParams, NoConstantGenericsReason, PathSource, Rib, RibKind,
};
use crate::macros::{sub_namespace_match, MacroRulesScope};
use crate::{errors, AmbiguityError, AmbiguityErrorMisc, AmbiguityKind, Determinacy, Finalize};
Expand Down Expand Up @@ -1127,28 +1126,25 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
RibKind::ConstantItem(_, item) => {
// Still doesn't deal with upvars
if let Some(span) = finalize {
let (span, resolution_error) =
if let Some((ident, constant_item_kind)) = item {
let kind_str = match constant_item_kind {
ConstantItemKind::Const => "const",
ConstantItemKind::Static => "static",
};
(
span,
AttemptToUseNonConstantValueInConstant(
ident, "let", kind_str,
),
)
} else {
(
rib_ident.span,
AttemptToUseNonConstantValueInConstant(
original_rib_ident_def,
"const",
"let",
),
)
};
let (span, resolution_error) = match item {
None if rib_ident.as_str() == "self" => (span, LowercaseSelf),
None => (
rib_ident.span,
AttemptToUseNonConstantValueInConstant(
original_rib_ident_def,
"const",
"let",
),
),
Some((ident, kind)) => (
span,
AttemptToUseNonConstantValueInConstant(
ident,
"let",
kind.as_str(),
),
),
};
self.report_error(span, resolution_error);
}
return Res::Err;
Expand Down
9 changes: 9 additions & 0 deletions compiler/rustc_resolve/src/late.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,15 @@ pub(crate) enum ConstantItemKind {
Static,
}

impl ConstantItemKind {
pub(crate) fn as_str(&self) -> &'static str {
match self {
Self::Const => "const",
Self::Static => "static",
}
}
}

#[derive(Debug, Copy, Clone, PartialEq, Eq)]
enum RecordPartialRes {
Yes,
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_resolve/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,8 @@ enum ResolutionError<'a> {
TraitImplDuplicate { name: Symbol, trait_item_span: Span, old_span: Span },
/// Inline asm `sym` operand must refer to a `fn` or `static`.
InvalidAsmSym,
/// `self` used instead of `Self` in a generic parameter
LowercaseSelf,
}

enum VisResolutionError<'a> {
Expand Down
8 changes: 8 additions & 0 deletions tests/ui/resolve/explicit-self-lowercase-param.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
struct Foo;

impl Foo {
fn do_nothing(self: Box<self>) {} //~ ERROR attempt to use a non-constant value in a constant
//~^ HELP try using `Self`
}

fn main() {}
8 changes: 8 additions & 0 deletions tests/ui/resolve/explicit-self-lowercase-param.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
error: attempt to use a non-constant value in a constant
--> $DIR/explicit-self-lowercase-param.rs:4:29
|
LL | fn do_nothing(self: Box<self>) {}
| ^^^^ help: try using `Self`

error: aborting due to previous error