Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
aec806e
Add unwrap method for QueryResult
rsmyth-ecmi Dec 18, 2023
95f3a7d
tidy
rsmyth-ecmi Dec 18, 2023
fc561f0
Unwrap the other query result
rsmyth-ecmi Dec 18, 2023
0d9fba1
Add useful panic messages if queries fail to start
rsmyth-ecmi Dec 18, 2023
a482177
Remove parameter from functions that don't need it
rsmyth-ecmi Dec 18, 2023
90c1601
unwrap the correct value in the parallel code
rsmyth-ecmi Dec 18, 2023
0919a51
Wrong layer
rsmyth-ecmi Dec 18, 2023
983cf9c
Actually fixed errors
RossSmyth Dec 19, 2023
b679d8a
Address review conversations
RossSmyth Dec 19, 2023
abe9c14
Fix major diagnostic regression
RossSmyth Dec 21, 2023
f521b4c
suppress change-tracker warnings in containers
onur-ozkan Dec 27, 2023
8dd6fac
don't return suggestion message if no changes detected
onur-ozkan Dec 26, 2023
2c23c06
rc: Take *const T in is_dangling
taiki-e Dec 30, 2023
07adee7
is_coroutine -> is_coroutine_or_closure
compiler-errors Dec 30, 2023
847cd6c
Use the right type for upvars
compiler-errors Dec 30, 2023
86bd81f
Update tracking issue of naked_functions
nbdd0121 Dec 31, 2023
d796ad4
rustdoc ui: adjust tooltip z-index to be above sidebar
Dec 31, 2023
f118c76
Remove two unused feature gates from rustc_query_impl
bjorn3 Dec 31, 2023
5cbe41a
Document that File does not buffer reads/writes, refer to BufReader/B…
chfogelman Dec 26, 2023
884cb41
Minor improvements in comment for
gurry Jan 1, 2024
01ac44a
Pretty-print always-const trait predicates correctly
fmease Dec 31, 2023
b1853eb
use css variable for z-index of the sidebar
Dec 31, 2023
440ba5f
Update books
rustbot Jan 1, 2024
82a5745
Update deadlinks of `strict_provenance` lints
ShE3py Jan 1, 2024
3d0297a
Deny defaults for higher-ranked generic parameters
fmease Jan 1, 2024
23924fe
Mark myself as back from leave
oli-obk Jan 2, 2024
5e7c1b9
coverage: Avoid a query stability hazard in `function_coverage_map`
Zalathar Jan 2, 2024
94c43cc
Report I/O errors with emit_fatal not emit_err
saethlin Jan 2, 2024
ba86034
Don't synthesize host effect params for trait assoc fns marked const
fmease Jan 1, 2024
8f546aa
Turn a bug!() into a span_delay_bug()
fmease Jan 2, 2024
ae8e401
E0379: Make diagnostic more precise
fmease Jan 1, 2024
aa79904
E0379: Provide suggestions
fmease Jan 1, 2024
ee86b1f
llvm: Allow `noundef` in codegen tests
maurer Jan 2, 2024
6f49080
Update `thread_local` examples to use `local_key_cell_methods`
tgross35 Jan 2, 2024
fab6607
compiler: fix typos
vuittont60 Jan 3, 2024
fe4f85c
librustdoc: fix typos
vuittont60 Jan 3, 2024
d9d23fa
Fix: Properly set vendor in i686-win7-windows-msvc target
roblabla Jan 3, 2024
49f42db
Rollup merge of #119086 - RossSmyth:query_panics, r=davidtwco
fmease Jan 3, 2024
e1f8d68
Rollup merge of #119298 - onur-ozkan:silence-change-tracker-warning-f…
fmease Jan 3, 2024
383daa7
Rollup merge of #119319 - chfogelman:buffered-file-doc, r=the8472
fmease Jan 3, 2024
693dd56
Rollup merge of #119434 - taiki-e:rc-is-dangling, r=Mark-Simulacrum
fmease Jan 3, 2024
83ac3a7
Rollup merge of #119444 - compiler-errors:closure-or-coroutine, r=oli…
fmease Jan 3, 2024
f281ad9
Rollup merge of #119474 - nbdd0121:naked, r=Nilstrieb
fmease Jan 3, 2024
e8e5a7e
Rollup merge of #119476 - fmease:pp-always-const-trait-preds, r=compi…
fmease Jan 3, 2024
eeafb86
Rollup merge of #119477 - lukas-code:tooltip-z-index, r=notriddle
fmease Jan 3, 2024
5968c00
Rollup merge of #119479 - bjorn3:remove_unused_feature_gates, r=compi…
fmease Jan 3, 2024
d1b0151
Rollup merge of #119487 - gurry:improve-freshner-comment, r=Nilstrieb
fmease Jan 3, 2024
df2bbb7
Rollup merge of #119492 - rustbot:docs-update, r=ehuss
fmease Jan 3, 2024
bb124aa
Rollup merge of #119494 - fmease:deny-hr-param-defaults, r=compiler-e…
fmease Jan 3, 2024
f2d665f
Rollup merge of #119498 - ShE3py:provenance-lints-doc, r=Nilstrieb
fmease Jan 3, 2024
b2673fa
Rollup merge of #119505 - fmease:no-host-param-for-trait-fns, r=fee1-…
fmease Jan 3, 2024
462505d
Rollup merge of #119510 - saethlin:fatal-io-errors, r=WaffleLapkin,Ni…
fmease Jan 3, 2024
da65d7f
Rollup merge of #119512 - oli-obk:unleave, r=oli-obk
fmease Jan 3, 2024
bfefa4b
Rollup merge of #119514 - Zalathar:query-stability, r=wesleywiser
fmease Jan 3, 2024
7be0135
Rollup merge of #119523 - maurer:fix-sparc-llvm-18, r=nikic
fmease Jan 3, 2024
3dbbddc
Rollup merge of #119534 - tgross35:thread-local-example-updates, r=Jo…
fmease Jan 3, 2024
9511d10
Rollup merge of #119539 - vuittont60:master, r=TaKO8Ki
fmease Jan 3, 2024
89efc1e
Rollup merge of #119544 - roblabla:new-win7-targets, r=Nilstrieb
fmease Jan 3, 2024
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
Prev Previous commit
Next Next commit
E0379: Make diagnostic more precise
  • Loading branch information
fmease committed Jan 2, 2024
commit ae8e401c9f8b51dc8ff3ac5914e0203ea95e26d2
10 changes: 8 additions & 2 deletions compiler/rustc_ast_passes/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,14 @@ ast_passes_tilde_const_disallowed = `~const` is not allowed here
.item = this item cannot have `~const` trait bounds

ast_passes_trait_fn_const =
functions in traits cannot be declared const
.label = functions in traits cannot be const
functions in {$in_impl ->
[true] trait impls
*[false] traits
} cannot be declared const
.label = functions in {$in_impl ->
[true] trait impls
*[false] traits
} cannot be const

ast_passes_trait_object_single_bound = only a single explicit lifetime bound is permitted

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_ast_passes/src/ast_validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ impl<'a> AstValidator<'a> {

fn check_trait_fn_not_const(&self, constness: Const) {
if let Const::Yes(span) = constness {
self.dcx().emit_err(errors::TraitFnConst { span });
self.dcx().emit_err(errors::TraitFnConst { span, in_impl: self.in_trait_impl });
}
}

Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_ast_passes/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ pub struct TraitFnConst {
#[primary_span]
#[label]
pub span: Span,
pub in_impl: bool,
}

#[derive(Diagnostic)]
Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_error_codes/src/error_codes/E0379.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ Erroneous code example:
trait Foo {
const fn bar() -> u32; // error!
}

impl Foo for () {
const fn bar() -> u32 { 0 } // error!
}
```

Trait methods cannot be declared `const` by design. For more information, see
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/consts/const-fn-mismatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ trait Foo {

impl Foo for u32 {
const fn f() -> u32 {
//~^ ERROR functions in traits cannot be declared const
//~^ ERROR functions in trait impls cannot be declared const
22
}
}
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/consts/const-fn-mismatch.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
error[E0379]: functions in traits cannot be declared const
error[E0379]: functions in trait impls cannot be declared const
--> $DIR/const-fn-mismatch.rs:11:5
|
LL | const fn f() -> u32 {
| ^^^^^ functions in traits cannot be const
| ^^^^^ functions in trait impls cannot be const

error: aborting due to 1 previous error

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/feature-gates/feature-gate-min_const_fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ trait Foo {
}

impl Foo for u32 {
const fn foo() -> u32 { 0 } //~ ERROR functions in traits cannot be declared const
const fn foo() -> u32 { 0 } //~ ERROR functions in trait impls cannot be declared const
}

trait Bar {}
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/feature-gates/feature-gate-min_const_fn.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ error[E0379]: functions in traits cannot be declared const
LL | const fn bar() -> u32 { 0 }
| ^^^^^ functions in traits cannot be const

error[E0379]: functions in traits cannot be declared const
error[E0379]: functions in trait impls cannot be declared const
--> $DIR/feature-gate-min_const_fn.rs:11:5
|
LL | const fn foo() -> u32 { 0 }
| ^^^^^ functions in traits cannot be const
| ^^^^^ functions in trait impls cannot be const

error: aborting due to 3 previous errors

Expand Down
4 changes: 2 additions & 2 deletions tests/ui/mismatched_types/const-fn-in-trait.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ error[E0379]: functions in traits cannot be declared const
LL | const fn g();
| ^^^^^ functions in traits cannot be const

error[E0379]: functions in traits cannot be declared const
error[E0379]: functions in trait impls cannot be declared const
--> $DIR/const-fn-in-trait.rs:7:5
|
LL | const fn f() -> u32 { 22 }
| ^^^^^ functions in traits cannot be const
| ^^^^^ functions in trait impls cannot be const

error: aborting due to 2 previous errors

Expand Down
4 changes: 2 additions & 2 deletions tests/ui/parser/fn-header-semantic-fail.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ fn main() {
impl X for Y {
async fn ft1() {} // OK.
unsafe fn ft2() {} // OK.
const fn ft3() {} //~ ERROR functions in traits cannot be declared const
const fn ft3() {} //~ ERROR functions in trait impls cannot be declared const
extern "C" fn ft4() {}
const async unsafe extern "C" fn ft5() {}
//~^ ERROR functions in traits cannot be declared const
//~^ ERROR functions in trait impls cannot be declared const
//~| ERROR functions cannot be both `const` and `async`
}

Expand Down
8 changes: 4 additions & 4 deletions tests/ui/parser/fn-header-semantic-fail.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@ LL | const async unsafe extern "C" fn ft5();
| | `async` because of this
| `const` because of this

error[E0379]: functions in traits cannot be declared const
error[E0379]: functions in trait impls cannot be declared const
--> $DIR/fn-header-semantic-fail.rs:29:9
|
LL | const fn ft3() {}
| ^^^^^ functions in traits cannot be const
| ^^^^^ functions in trait impls cannot be const

error[E0379]: functions in traits cannot be declared const
error[E0379]: functions in trait impls cannot be declared const
--> $DIR/fn-header-semantic-fail.rs:31:9
|
LL | const async unsafe extern "C" fn ft5() {}
| ^^^^^ functions in traits cannot be const
| ^^^^^ functions in trait impls cannot be const

error: functions cannot be both `const` and `async`
--> $DIR/fn-header-semantic-fail.rs:31:9
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ trait Trait {
}

impl const Trait for () {
const fn fun() {} //~ ERROR functions in traits cannot be declared const
const fn fun() {} //~ ERROR functions in trait impls cannot be declared const
}

fn main() {}
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ error[E0379]: functions in traits cannot be declared const
LL | const fn fun();
| ^^^^^ functions in traits cannot be const

error[E0379]: functions in traits cannot be declared const
error[E0379]: functions in trait impls cannot be declared const
--> $DIR/trait-fn-const.rs:10:5
|
LL | const fn fun() {}
| ^^^^^ functions in traits cannot be const
| ^^^^^ functions in trait impls cannot be const

error: aborting due to 2 previous errors

Expand Down